@ai-react-markdown/core 1.2.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -40,7 +40,7 @@ __export(index_exports, {
40
40
  useStableValue: () => useStableValue
41
41
  });
42
42
  module.exports = __toCommonJS(index_exports);
43
- var import_react5 = require("react");
43
+ var import_react6 = require("react");
44
44
 
45
45
  // src/context.tsx
46
46
  var import_react = require("react");
@@ -301,8 +301,8 @@ function getNative(object, key) {
301
301
  var getNative_default = getNative;
302
302
 
303
303
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Map.js
304
- var Map = getNative_default(root_default, "Map");
305
- var Map_default = Map;
304
+ var Map2 = getNative_default(root_default, "Map");
305
+ var Map_default = Map2;
306
306
 
307
307
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js
308
308
  var nativeCreate = getNative_default(Object, "create");
@@ -473,18 +473,6 @@ Stack.prototype.has = stackHas_default;
473
473
  Stack.prototype.set = stackSet_default;
474
474
  var Stack_default = Stack;
475
475
 
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
476
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js
489
477
  var defineProperty = (function() {
490
478
  try {
@@ -511,47 +499,124 @@ function baseAssignValue(object, key, value) {
511
499
  }
512
500
  var baseAssignValue_default = baseAssignValue;
513
501
 
514
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js
515
- var objectProto6 = Object.prototype;
516
- var hasOwnProperty5 = objectProto6.hasOwnProperty;
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)) {
502
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js
503
+ function assignMergeValue(object, key, value) {
504
+ if (value !== void 0 && !eq_default(object[key], value) || value === void 0 && !(key in object)) {
520
505
  baseAssignValue_default(object, key, value);
521
506
  }
522
507
  }
523
- var assignValue_default = assignValue;
508
+ var assignMergeValue_default = assignMergeValue;
524
509
 
525
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js
526
- function copyObject(source, props, object, customizer) {
527
- var isNew = !object;
528
- object || (object = {});
529
- var index = -1, length = props.length;
530
- while (++index < length) {
531
- var key = props[index];
532
- var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
533
- if (newValue === void 0) {
534
- newValue = source[key];
535
- }
536
- if (isNew) {
537
- baseAssignValue_default(object, key, newValue);
538
- } else {
539
- assignValue_default(object, key, newValue);
510
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js
511
+ function createBaseFor(fromRight) {
512
+ return function(object, iteratee, keysFunc) {
513
+ var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
514
+ while (length--) {
515
+ var key = props[fromRight ? length : ++index];
516
+ if (iteratee(iterable[key], key, iterable) === false) {
517
+ break;
518
+ }
540
519
  }
541
- }
542
- return object;
520
+ return object;
521
+ };
543
522
  }
544
- var copyObject_default = copyObject;
523
+ var createBaseFor_default = createBaseFor;
545
524
 
546
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js
547
- function baseTimes(n, iteratee) {
548
- var index = -1, result = Array(n);
549
- while (++index < n) {
550
- result[index] = iteratee(index);
525
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js
526
+ var baseFor = createBaseFor_default();
527
+ var baseFor_default = baseFor;
528
+
529
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js
530
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
531
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
532
+ var moduleExports = freeModule && freeModule.exports === freeExports;
533
+ var Buffer2 = moduleExports ? root_default.Buffer : void 0;
534
+ var allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
535
+ function cloneBuffer(buffer, isDeep) {
536
+ if (isDeep) {
537
+ return buffer.slice();
551
538
  }
539
+ var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
540
+ buffer.copy(result);
552
541
  return result;
553
542
  }
554
- var baseTimes_default = baseTimes;
543
+ var cloneBuffer_default = cloneBuffer;
544
+
545
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js
546
+ var Uint8Array2 = root_default.Uint8Array;
547
+ var Uint8Array_default = Uint8Array2;
548
+
549
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js
550
+ function cloneArrayBuffer(arrayBuffer) {
551
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
552
+ new Uint8Array_default(result).set(new Uint8Array_default(arrayBuffer));
553
+ return result;
554
+ }
555
+ var cloneArrayBuffer_default = cloneArrayBuffer;
556
+
557
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js
558
+ function cloneTypedArray(typedArray, isDeep) {
559
+ var buffer = isDeep ? cloneArrayBuffer_default(typedArray.buffer) : typedArray.buffer;
560
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
561
+ }
562
+ var cloneTypedArray_default = cloneTypedArray;
563
+
564
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js
565
+ function copyArray(source, array) {
566
+ var index = -1, length = source.length;
567
+ array || (array = Array(length));
568
+ while (++index < length) {
569
+ array[index] = source[index];
570
+ }
571
+ return array;
572
+ }
573
+ var copyArray_default = copyArray;
574
+
575
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js
576
+ var objectCreate = Object.create;
577
+ var baseCreate = /* @__PURE__ */ (function() {
578
+ function object() {
579
+ }
580
+ return function(proto) {
581
+ if (!isObject_default(proto)) {
582
+ return {};
583
+ }
584
+ if (objectCreate) {
585
+ return objectCreate(proto);
586
+ }
587
+ object.prototype = proto;
588
+ var result = new object();
589
+ object.prototype = void 0;
590
+ return result;
591
+ };
592
+ })();
593
+ var baseCreate_default = baseCreate;
594
+
595
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js
596
+ function overArg(func, transform) {
597
+ return function(arg) {
598
+ return func(transform(arg));
599
+ };
600
+ }
601
+ var overArg_default = overArg;
602
+
603
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js
604
+ var getPrototype = overArg_default(Object.getPrototypeOf, Object);
605
+ var getPrototype_default = getPrototype;
606
+
607
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js
608
+ var objectProto6 = Object.prototype;
609
+ function isPrototype(value) {
610
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto6;
611
+ return value === proto;
612
+ }
613
+ var isPrototype_default = isPrototype;
614
+
615
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js
616
+ function initCloneObject(object) {
617
+ return typeof object.constructor == "function" && !isPrototype_default(object) ? baseCreate_default(getPrototype_default(object)) : {};
618
+ }
619
+ var initCloneObject_default = initCloneObject;
555
620
 
556
621
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js
557
622
  function isObjectLike(value) {
@@ -568,12 +633,12 @@ var baseIsArguments_default = baseIsArguments;
568
633
 
569
634
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js
570
635
  var objectProto7 = Object.prototype;
571
- var hasOwnProperty6 = objectProto7.hasOwnProperty;
636
+ var hasOwnProperty5 = objectProto7.hasOwnProperty;
572
637
  var propertyIsEnumerable = objectProto7.propertyIsEnumerable;
573
638
  var isArguments = baseIsArguments_default(/* @__PURE__ */ (function() {
574
639
  return arguments;
575
640
  })()) ? baseIsArguments_default : function(value) {
576
- return isObjectLike_default(value) && hasOwnProperty6.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
641
+ return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
577
642
  };
578
643
  var isArguments_default = isArguments;
579
644
 
@@ -581,6 +646,25 @@ var isArguments_default = isArguments;
581
646
  var isArray = Array.isArray;
582
647
  var isArray_default = isArray;
583
648
 
649
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isLength.js
650
+ var MAX_SAFE_INTEGER = 9007199254740991;
651
+ function isLength(value) {
652
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
653
+ }
654
+ var isLength_default = isLength;
655
+
656
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js
657
+ function isArrayLike(value) {
658
+ return value != null && isLength_default(value.length) && !isFunction_default(value);
659
+ }
660
+ var isArrayLike_default = isArrayLike;
661
+
662
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js
663
+ function isArrayLikeObject(value) {
664
+ return isObjectLike_default(value) && isArrayLike_default(value);
665
+ }
666
+ var isArrayLikeObject_default = isArrayLikeObject;
667
+
584
668
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js
585
669
  function stubFalse() {
586
670
  return false;
@@ -588,30 +672,33 @@ function stubFalse() {
588
672
  var stubFalse_default = stubFalse;
589
673
 
590
674
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js
591
- var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
592
- var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
593
- var moduleExports = freeModule && freeModule.exports === freeExports;
594
- var Buffer2 = moduleExports ? root_default.Buffer : void 0;
595
- var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
675
+ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
676
+ var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
677
+ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
678
+ var Buffer3 = moduleExports2 ? root_default.Buffer : void 0;
679
+ var nativeIsBuffer = Buffer3 ? Buffer3.isBuffer : void 0;
596
680
  var isBuffer = nativeIsBuffer || stubFalse_default;
597
681
  var isBuffer_default = isBuffer;
598
682
 
599
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js
600
- var MAX_SAFE_INTEGER = 9007199254740991;
601
- var reIsUint = /^(?:0|[1-9]\d*)$/;
602
- function isIndex(value, length) {
603
- var type = typeof value;
604
- length = length == null ? MAX_SAFE_INTEGER : length;
605
- return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
606
- }
607
- var isIndex_default = isIndex;
608
-
609
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isLength.js
610
- var MAX_SAFE_INTEGER2 = 9007199254740991;
611
- function isLength(value) {
612
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
683
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js
684
+ var objectTag = "[object Object]";
685
+ var funcProto3 = Function.prototype;
686
+ var objectProto8 = Object.prototype;
687
+ var funcToString3 = funcProto3.toString;
688
+ var hasOwnProperty6 = objectProto8.hasOwnProperty;
689
+ var objectCtorString = funcToString3.call(Object);
690
+ function isPlainObject(value) {
691
+ if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag) {
692
+ return false;
693
+ }
694
+ var proto = getPrototype_default(value);
695
+ if (proto === null) {
696
+ return true;
697
+ }
698
+ var Ctor = hasOwnProperty6.call(proto, "constructor") && proto.constructor;
699
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
613
700
  }
614
- var isLength_default = isLength;
701
+ var isPlainObject_default = isPlainObject;
615
702
 
616
703
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js
617
704
  var argsTag2 = "[object Arguments]";
@@ -622,7 +709,7 @@ var errorTag = "[object Error]";
622
709
  var funcTag2 = "[object Function]";
623
710
  var mapTag = "[object Map]";
624
711
  var numberTag = "[object Number]";
625
- var objectTag = "[object Object]";
712
+ var objectTag2 = "[object Object]";
626
713
  var regexpTag = "[object RegExp]";
627
714
  var setTag = "[object Set]";
628
715
  var stringTag = "[object String]";
@@ -640,7 +727,7 @@ var uint16Tag = "[object Uint16Array]";
640
727
  var uint32Tag = "[object Uint32Array]";
641
728
  var typedArrayTags = {};
642
729
  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[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
730
+ 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
731
  function baseIsTypedArray(value) {
645
732
  return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
646
733
  }
@@ -655,13 +742,13 @@ function baseUnary(func) {
655
742
  var baseUnary_default = baseUnary;
656
743
 
657
744
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js
658
- var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
659
- var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
660
- var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
661
- var freeProcess = moduleExports2 && freeGlobal_default.process;
745
+ var freeExports3 = typeof exports == "object" && exports && !exports.nodeType && exports;
746
+ var freeModule3 = freeExports3 && typeof module == "object" && module && !module.nodeType && module;
747
+ var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
748
+ var freeProcess = moduleExports3 && freeGlobal_default.process;
662
749
  var nodeUtil = (function() {
663
750
  try {
664
- var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
751
+ var types = freeModule3 && freeModule3.require && freeModule3.require("util").types;
665
752
  if (types) {
666
753
  return types;
667
754
  }
@@ -676,78 +763,87 @@ var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
676
763
  var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
677
764
  var isTypedArray_default = isTypedArray;
678
765
 
679
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js
680
- var objectProto8 = Object.prototype;
681
- var hasOwnProperty7 = objectProto8.hasOwnProperty;
682
- function arrayLikeKeys(value, inherited) {
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
- }
766
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js
767
+ function safeGet(object, key) {
768
+ if (key === "constructor" && typeof object[key] === "function") {
769
+ return;
692
770
  }
693
- return result;
771
+ if (key == "__proto__") {
772
+ return;
773
+ }
774
+ return object[key];
694
775
  }
695
- var arrayLikeKeys_default = arrayLikeKeys;
776
+ var safeGet_default = safeGet;
696
777
 
697
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js
778
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js
698
779
  var objectProto9 = Object.prototype;
699
- function isPrototype(value) {
700
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto9;
701
- return value === proto;
702
- }
703
- var isPrototype_default = isPrototype;
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
- };
780
+ var hasOwnProperty7 = objectProto9.hasOwnProperty;
781
+ function assignValue(object, key, value) {
782
+ var objValue = object[key];
783
+ if (!(hasOwnProperty7.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
784
+ baseAssignValue_default(object, key, value);
785
+ }
710
786
  }
711
- var overArg_default = overArg;
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;
787
+ var assignValue_default = assignValue;
716
788
 
717
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
718
- var objectProto10 = Object.prototype;
719
- var hasOwnProperty8 = objectProto10.hasOwnProperty;
720
- function baseKeys(object) {
721
- if (!isPrototype_default(object)) {
722
- return nativeKeys_default(object);
723
- }
724
- var result = [];
725
- for (var key in Object(object)) {
726
- if (hasOwnProperty8.call(object, key) && key != "constructor") {
727
- result.push(key);
789
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js
790
+ function copyObject(source, props, object, customizer) {
791
+ var isNew = !object;
792
+ object || (object = {});
793
+ var index = -1, length = props.length;
794
+ while (++index < length) {
795
+ var key = props[index];
796
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
797
+ if (newValue === void 0) {
798
+ newValue = source[key];
799
+ }
800
+ if (isNew) {
801
+ baseAssignValue_default(object, key, newValue);
802
+ } else {
803
+ assignValue_default(object, key, newValue);
728
804
  }
729
805
  }
730
- return result;
806
+ return object;
731
807
  }
732
- var baseKeys_default = baseKeys;
808
+ var copyObject_default = copyObject;
733
809
 
734
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js
735
- function isArrayLike(value) {
736
- return value != null && isLength_default(value.length) && !isFunction_default(value);
810
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js
811
+ function baseTimes(n, iteratee) {
812
+ var index = -1, result = Array(n);
813
+ while (++index < n) {
814
+ result[index] = iteratee(index);
815
+ }
816
+ return result;
737
817
  }
738
- var isArrayLike_default = isArrayLike;
818
+ var baseTimes_default = baseTimes;
739
819
 
740
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
741
- function keys(object) {
742
- return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
820
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js
821
+ var MAX_SAFE_INTEGER2 = 9007199254740991;
822
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
823
+ function isIndex(value, length) {
824
+ var type = typeof value;
825
+ length = length == null ? MAX_SAFE_INTEGER2 : length;
826
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
743
827
  }
744
- var keys_default = keys;
828
+ var isIndex_default = isIndex;
745
829
 
746
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js
747
- function baseAssign(object, source) {
748
- return object && copyObject_default(source, keys_default(source), object);
830
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js
831
+ var objectProto10 = Object.prototype;
832
+ var hasOwnProperty8 = objectProto10.hasOwnProperty;
833
+ function arrayLikeKeys(value, inherited) {
834
+ 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;
835
+ for (var key in value) {
836
+ if ((inherited || hasOwnProperty8.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
837
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
838
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
839
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
840
+ isIndex_default(key, length)))) {
841
+ result.push(key);
842
+ }
843
+ }
844
+ return result;
749
845
  }
750
- var baseAssign_default = baseAssign;
846
+ var arrayLikeKeys_default = arrayLikeKeys;
751
847
 
752
848
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js
753
849
  function nativeKeysIn(object) {
@@ -784,510 +880,6 @@ function keysIn(object) {
784
880
  }
785
881
  var keysIn_default = keysIn;
786
882
 
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;
1286
- }
1287
- return object[key];
1288
- }
1289
- var safeGet_default = safeGet;
1290
-
1291
883
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js
1292
884
  function toPlainObject(value) {
1293
885
  return copyObject_default(value, keysIn_default(value));
@@ -1496,7 +1088,6 @@ var mergeWith_default = mergeWith;
1496
1088
  var AIMarkdownRenderExtraSyntax = /* @__PURE__ */ ((AIMarkdownRenderExtraSyntax2) => {
1497
1089
  AIMarkdownRenderExtraSyntax2["HIGHLIGHT"] = "HIGHLIGHT";
1498
1090
  AIMarkdownRenderExtraSyntax2["DEFINITION_LIST"] = "DEFINITION_LIST";
1499
- AIMarkdownRenderExtraSyntax2["SUBSCRIPT"] = "SUBSCRIPT";
1500
1091
  return AIMarkdownRenderExtraSyntax2;
1501
1092
  })(AIMarkdownRenderExtraSyntax || {});
1502
1093
  var AIMarkdownRenderDisplayOptimizeAbility = /* @__PURE__ */ ((AIMarkdownRenderDisplayOptimizeAbility2) => {
@@ -1508,14 +1099,14 @@ var AIMarkdownRenderDisplayOptimizeAbility = /* @__PURE__ */ ((AIMarkdownRenderD
1508
1099
  var defaultAIMarkdownRenderConfig = Object.freeze({
1509
1100
  extraSyntaxSupported: Object.freeze([
1510
1101
  "HIGHLIGHT" /* HIGHLIGHT */,
1511
- "DEFINITION_LIST" /* DEFINITION_LIST */,
1512
- "SUBSCRIPT" /* SUBSCRIPT */
1102
+ "DEFINITION_LIST" /* DEFINITION_LIST */
1513
1103
  ]),
1514
1104
  displayOptimizeAbilities: Object.freeze([
1515
1105
  "REMOVE_COMMENTS" /* REMOVE_COMMENTS */,
1516
1106
  "SMARTYPANTS" /* SMARTYPANTS */,
1517
1107
  "PANGU" /* PANGU */
1518
- ])
1108
+ ]),
1109
+ blockMemoEnabled: true
1519
1110
  });
1520
1111
 
1521
1112
  // src/context.tsx
@@ -1548,24 +1139,28 @@ var AIMarkdownRenderStateProvider = ({
1548
1139
  fontSize,
1549
1140
  variant,
1550
1141
  colorScheme,
1142
+ documentId,
1551
1143
  defaultConfig,
1552
1144
  config,
1553
1145
  children
1554
1146
  }) => {
1555
1147
  const baseConfig = defaultConfig ?? defaultAIMarkdownRenderConfig;
1556
1148
  const mergedConfig = (0, import_react.useMemo)(
1557
- () => config ? mergeWith_default(cloneDeep_default(baseConfig), config, configMergeCustomizer) : baseConfig,
1149
+ () => config ? mergeWith_default({}, baseConfig, config, configMergeCustomizer) : baseConfig,
1558
1150
  [baseConfig, config]
1559
1151
  );
1152
+ const fallbackId = (0, import_react.useId)();
1153
+ const resolvedDocumentId = documentId && documentId.length > 0 ? documentId : fallbackId;
1560
1154
  const state = (0, import_react.useMemo)(
1561
1155
  () => Object.freeze({
1562
1156
  streaming,
1563
1157
  fontSize,
1564
1158
  variant,
1565
1159
  colorScheme,
1160
+ documentId: resolvedDocumentId,
1566
1161
  config: mergedConfig
1567
1162
  }),
1568
- [streaming, fontSize, variant, colorScheme, mergedConfig]
1163
+ [streaming, fontSize, variant, colorScheme, resolvedDocumentId, mergedConfig]
1569
1164
  );
1570
1165
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AIMarkdownRenderStateContext.Provider, { value: state, children });
1571
1166
  };
@@ -1579,10 +1174,42 @@ function getRepeatedMarkerLength(content, start, marker) {
1579
1174
  }
1580
1175
  return end - start;
1581
1176
  }
1177
+ 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;
1178
+ var LITERAL_CONTENT_TAGS = /* @__PURE__ */ new Set(["code", "pre", "kbd", "samp", "math", "svg"]);
1179
+ var LITERAL_CONTENT_CLOSE_REGEX = {
1180
+ code: /<\/code\s*>/gi,
1181
+ pre: /<\/pre\s*>/gi,
1182
+ kbd: /<\/kbd\s*>/gi,
1183
+ samp: /<\/samp\s*>/gi,
1184
+ math: /<\/math\s*>/gi,
1185
+ svg: /<\/svg\s*>/gi
1186
+ };
1187
+ function isAtLineStart(content, pos) {
1188
+ let i = pos - 1;
1189
+ let spaces = 0;
1190
+ while (i >= 0 && content[i] === " ") {
1191
+ spaces++;
1192
+ if (spaces > 3) return false;
1193
+ i--;
1194
+ }
1195
+ return i < 0 || content[i] === "\n" || content[i] === "\r";
1196
+ }
1197
+ function findClosingBacktickRun(content, start, n) {
1198
+ let i = start;
1199
+ while (i < content.length) {
1200
+ if (content[i] === "`") {
1201
+ const runLen = getRepeatedMarkerLength(content, i, "`");
1202
+ if (runLen === n) return i;
1203
+ i += runLen;
1204
+ } else {
1205
+ i += 1;
1206
+ }
1207
+ }
1208
+ return -1;
1209
+ }
1582
1210
  function splitByProtectedRegions(content) {
1583
1211
  const segments = [];
1584
1212
  let lastIndex = 0;
1585
- let inlineStart = -1;
1586
1213
  let multilineStart = -1;
1587
1214
  let multilineFenceMarker = null;
1588
1215
  let multilineFenceLength = 0;
@@ -1593,42 +1220,69 @@ function splitByProtectedRegions(content) {
1593
1220
  segments.push({ text: content.substring(start, end), isCode: true });
1594
1221
  lastIndex = end;
1595
1222
  }
1596
- for (let i = 0; i < content.length; i++) {
1223
+ let i = 0;
1224
+ while (i < content.length) {
1597
1225
  const char = content[i];
1598
- const fenceLength = char === "`" || char === "~" ? getRepeatedMarkerLength(content, i, char) : 0;
1599
- if ((char === "`" || char === "~") && fenceLength >= 3) {
1600
- if (multilineStart === -1) {
1601
- inlineStart = -1;
1226
+ if (multilineStart !== -1) {
1227
+ if (char === multilineFenceMarker) {
1228
+ const runLen = getRepeatedMarkerLength(content, i, multilineFenceMarker);
1229
+ if (runLen >= multilineFenceLength && isAtLineStart(content, i)) {
1230
+ pushProtected(multilineStart, i + runLen);
1231
+ multilineStart = -1;
1232
+ multilineFenceMarker = null;
1233
+ multilineFenceLength = 0;
1234
+ i += runLen;
1235
+ continue;
1236
+ }
1237
+ i += runLen;
1238
+ continue;
1239
+ }
1240
+ i += 1;
1241
+ continue;
1242
+ }
1243
+ if (char === "`" || char === "~") {
1244
+ const runLen = getRepeatedMarkerLength(content, i, char);
1245
+ if (runLen >= 3 && isAtLineStart(content, i)) {
1602
1246
  multilineStart = i;
1603
1247
  multilineFenceMarker = char;
1604
- multilineFenceLength = fenceLength;
1605
- i += fenceLength - 1;
1606
- } else if (char === multilineFenceMarker && fenceLength >= multilineFenceLength) {
1607
- pushProtected(multilineStart, i + fenceLength);
1608
- multilineStart = -1;
1609
- multilineFenceMarker = null;
1610
- multilineFenceLength = 0;
1611
- i += fenceLength - 1;
1612
- } else {
1613
- i += fenceLength - 1;
1248
+ multilineFenceLength = runLen;
1249
+ i += runLen;
1250
+ continue;
1614
1251
  }
1615
- } else if (char === "`" && multilineStart === -1) {
1616
- if (inlineStart === -1) {
1617
- inlineStart = i;
1618
- } else {
1619
- pushProtected(inlineStart, i + 1);
1620
- inlineStart = -1;
1252
+ if (char === "`") {
1253
+ const closeIdx = findClosingBacktickRun(content, i + runLen, runLen);
1254
+ if (closeIdx !== -1) {
1255
+ pushProtected(i, closeIdx + runLen);
1256
+ i = closeIdx + runLen;
1257
+ continue;
1258
+ }
1621
1259
  }
1622
- } else if (char === "<" && multilineStart === -1 && inlineStart === -1) {
1623
- const rest = content.substring(i);
1624
- const tagMatch = rest.match(
1625
- /^<\/?(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[^>]*)?\/?>/i
1626
- );
1260
+ i += runLen;
1261
+ continue;
1262
+ }
1263
+ if (char === "<") {
1264
+ HTML_TAG_REGEX.lastIndex = i;
1265
+ const tagMatch = HTML_TAG_REGEX.exec(content);
1627
1266
  if (tagMatch) {
1628
- pushProtected(i, i + tagMatch[0].length);
1629
- i += tagMatch[0].length - 1;
1267
+ let endIndex = i + tagMatch[0].length;
1268
+ const tagName = tagMatch[1].toLowerCase();
1269
+ const isOpeningPairedTag = content[i + 1] !== "/" && !tagMatch[0].endsWith("/>") && LITERAL_CONTENT_TAGS.has(tagName);
1270
+ if (isOpeningPairedTag) {
1271
+ const closeRegex = LITERAL_CONTENT_CLOSE_REGEX[tagName];
1272
+ closeRegex.lastIndex = endIndex;
1273
+ const closeMatch = closeRegex.exec(content);
1274
+ if (closeMatch) {
1275
+ endIndex = closeMatch.index + closeMatch[0].length;
1276
+ } else {
1277
+ endIndex = content.length;
1278
+ }
1279
+ }
1280
+ pushProtected(i, endIndex);
1281
+ i = endIndex;
1282
+ continue;
1630
1283
  }
1631
1284
  }
1285
+ i += 1;
1632
1286
  }
1633
1287
  if (multilineStart !== -1) {
1634
1288
  pushProtected(multilineStart, content.length);
@@ -1646,15 +1300,23 @@ var NO_ESCAPED_DOLLAR_REGEX = /(?<![\\$])\$(?!\$)/g;
1646
1300
  var DELIMITERS_REGEX = /(?<!!)\\\[([\S\s]*?[^\\])\\](?!\()|\\\((.*?)\\\)/g;
1647
1301
  var ARRAY_COL_SPEC_OR_PIPE_REGEX = /(\\begin\{(?:array|tabular[x*]?)\}\{[^}]*\})|(?<!\\)\|/g;
1648
1302
  var LATEX_BLOCK_REGEX = /\$\$([\S\s]*?)\$\$|(?<![\\$])\$(?!\$)((?:[^$\n]|\\\$)*?)(?<![\\`])\$(?!\$)/g;
1649
- var ESCAPE_TEXT_UNDERSCORES_REGEX = /\\text{([^}]*)}/g;
1303
+ var TEXT_COMMAND = "\\text{";
1650
1304
  var SINGLE_DOLLAR_REGEX = /(?<![\\$])\$(?!\$)((?:[^$\n]|\\[$])+?)(?<!\\)(?<!`)\$(?!\$)/g;
1651
1305
  function escapeCurrencyDollarSigns(text) {
1652
1306
  const parts = [];
1653
1307
  let lastIndex = 0;
1654
1308
  const currencyMatches = Array.from(text.matchAll(CURRENCY_REGEX));
1309
+ let currentLineProcessed = "";
1655
1310
  for (let i = 0; i < currencyMatches.length; i++) {
1656
1311
  const match = currencyMatches[i];
1657
- parts.push(text.substring(lastIndex, match.index));
1312
+ const segment = text.substring(lastIndex, match.index);
1313
+ parts.push(segment);
1314
+ const newlineIdx = Math.max(segment.lastIndexOf("\n"), segment.lastIndexOf("\r"));
1315
+ if (newlineIdx !== -1) {
1316
+ currentLineProcessed = segment.substring(newlineIdx + 1);
1317
+ } else {
1318
+ currentLineProcessed += segment;
1319
+ }
1658
1320
  let needEscape = true;
1659
1321
  let restBeforeNextMatchOrEnd = "";
1660
1322
  if (i < currencyMatches.length - 1) {
@@ -1667,14 +1329,14 @@ function escapeCurrencyDollarSigns(text) {
1667
1329
  }
1668
1330
  const firstLineBeforeNextMatch = restBeforeNextMatchOrEnd.split(/\r\n|\r|\n/g)[0];
1669
1331
  if (Array.from(firstLineBeforeNextMatch.matchAll(NO_ESCAPED_DOLLAR_REGEX)).length % 2 !== 0) {
1670
- const previousNewContent = parts.join("");
1671
- const previousLastLineContent = previousNewContent.split(/\r\n|\r|\n/g).pop();
1672
- const wholeLineBeforeNextMatchWithoutCurrentDollar = previousLastLineContent + firstLineBeforeNextMatch;
1332
+ const wholeLineBeforeNextMatchWithoutCurrentDollar = currentLineProcessed + firstLineBeforeNextMatch;
1673
1333
  if (Array.from(wholeLineBeforeNextMatchWithoutCurrentDollar.matchAll(NO_ESCAPED_DOLLAR_REGEX)).length % 2 !== 0) {
1674
1334
  needEscape = false;
1675
1335
  }
1676
1336
  }
1677
- parts.push(needEscape ? "\\$" : "$");
1337
+ const replacement = needEscape ? "\\$" : "$";
1338
+ parts.push(replacement);
1339
+ currentLineProcessed += replacement;
1678
1340
  lastIndex = match.index + 1;
1679
1341
  }
1680
1342
  parts.push(text.substring(lastIndex));
@@ -1708,14 +1370,23 @@ function escapeLatexPipes(text) {
1708
1370
  return match;
1709
1371
  });
1710
1372
  }
1373
+ function isEscapedByBackslashRun(text, pos) {
1374
+ let count = 0;
1375
+ let j = pos - 1;
1376
+ while (j >= 0 && text[j] === "\\") {
1377
+ count++;
1378
+ j--;
1379
+ }
1380
+ return count % 2 === 1;
1381
+ }
1711
1382
  function findUnclosedDelimiterStart(text, mode) {
1712
1383
  let unclosedStart = -1;
1713
1384
  let i = 0;
1714
1385
  while (i < text.length) {
1715
- if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$") {
1386
+ if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$" && !isEscapedByBackslashRun(text, i)) {
1716
1387
  unclosedStart = unclosedStart === -1 ? i : -1;
1717
1388
  i += 2;
1718
- } else if (mode === "both" && text[i] === "$" && (i === 0 || text[i - 1] !== "\\") && (i + 1 >= text.length || text[i + 1] !== "$")) {
1389
+ } else if (mode === "both" && text[i] === "$" && !isEscapedByBackslashRun(text, i) && (i + 1 >= text.length || text[i + 1] !== "$")) {
1719
1390
  unclosedStart = unclosedStart === -1 ? i : -1;
1720
1391
  i += 1;
1721
1392
  } else {
@@ -1739,10 +1410,41 @@ function truncateUnclosedLatexBlock(text) {
1739
1410
  return text.substring(0, unclosedStart).trimEnd();
1740
1411
  }
1741
1412
  function escapeTextUnderscores(text) {
1742
- return text.replaceAll(ESCAPE_TEXT_UNDERSCORES_REGEX, (_match, textContent) => {
1743
- const escapedTextContent = textContent.replaceAll(/(?<!\\)_/g, "\\_");
1744
- return `\\text{${escapedTextContent}}`;
1745
- });
1413
+ let out = "";
1414
+ let i = 0;
1415
+ while (i < text.length) {
1416
+ const start = text.indexOf(TEXT_COMMAND, i);
1417
+ if (start === -1) {
1418
+ out += text.substring(i);
1419
+ return out;
1420
+ }
1421
+ out += text.substring(i, start);
1422
+ const bodyStart = start + TEXT_COMMAND.length;
1423
+ let depth = 1;
1424
+ let j = bodyStart;
1425
+ while (j < text.length && depth > 0) {
1426
+ const c = text[j];
1427
+ if (c === "\\" && j + 1 < text.length) {
1428
+ j += 2;
1429
+ continue;
1430
+ }
1431
+ if (c === "{") depth++;
1432
+ else if (c === "}") {
1433
+ depth--;
1434
+ if (depth === 0) break;
1435
+ }
1436
+ j++;
1437
+ }
1438
+ if (depth !== 0) {
1439
+ out += text.substring(start);
1440
+ return out;
1441
+ }
1442
+ const body = text.substring(bodyStart, j);
1443
+ const escapedBody = body.replaceAll(/(?<!\\)_/g, "\\_");
1444
+ out += `\\text{${escapedBody}}`;
1445
+ i = j + 1;
1446
+ }
1447
+ return out;
1746
1448
  }
1747
1449
  function convertSingleToDoubleDollar(text) {
1748
1450
  return text.replaceAll(SINGLE_DOLLAR_REGEX, (_match, content) => `$$${content}$$`);
@@ -1766,22 +1468,249 @@ function preprocessLaTeX(str) {
1766
1468
  return result.join("");
1767
1469
  }
1768
1470
 
1769
- // src/preprocessors/index.ts
1770
- function applyPreprocessors(value, ...fns) {
1771
- return fns.reduce((result, fn) => fn(result), value);
1471
+ // src/preprocessors/index.ts
1472
+ function applyPreprocessors(value, ...fns) {
1473
+ return fns.reduce((result, fn) => fn(result), value);
1474
+ }
1475
+ var defaultExtraPreprocessors = [];
1476
+ function preprocessAIMDContent(content, extraPreprocessors = defaultExtraPreprocessors) {
1477
+ return applyPreprocessors(content, preprocessLaTeX, ...extraPreprocessors);
1478
+ }
1479
+
1480
+ // src/components/MarkdownContent.tsx
1481
+ var import_react3 = require("react");
1482
+
1483
+ // src/components/markdown/Markdown.tsx
1484
+ var import_devlop2 = require("devlop");
1485
+ var import_hast_util_to_jsx_runtime = require("hast-util-to-jsx-runtime");
1486
+ var import_react2 = require("react");
1487
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1488
+ var import_unist_util_visit = require("unist-util-visit");
1489
+
1490
+ // src/components/markdown/processor.ts
1491
+ var import_devlop = require("devlop");
1492
+ var import_remark_parse = __toESM(require("remark-parse"), 1);
1493
+ var import_remark_rehype = __toESM(require("remark-rehype"), 1);
1494
+ var import_unified = require("unified");
1495
+ var import_vfile = require("vfile");
1496
+ var emptyPlugins = [];
1497
+ var emptyRemarkRehypeOptions = { allowDangerousHtml: true };
1498
+ function createProcessor(options) {
1499
+ const rehypePlugins = options.rehypePlugins || emptyPlugins;
1500
+ const remarkPlugins = options.remarkPlugins || emptyPlugins;
1501
+ const remarkRehypeOptions = options.remarkRehypeOptions ? { ...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions } : emptyRemarkRehypeOptions;
1502
+ return (0, import_unified.unified)().use(import_remark_parse.default).use(remarkPlugins).use(import_remark_rehype.default, remarkRehypeOptions).use(rehypePlugins);
1503
+ }
1504
+ function createFile(options) {
1505
+ const children = options.children || "";
1506
+ const file = new import_vfile.VFile();
1507
+ if (typeof children === "string") {
1508
+ file.value = children;
1509
+ } else {
1510
+ (0, import_devlop.unreachable)("Unexpected value `" + String(children) + "` for `children` prop, expected `string`");
1511
+ }
1512
+ return file;
1513
+ }
1514
+
1515
+ // src/components/markdown/transform.ts
1516
+ var import_html_url_attributes = require("html-url-attributes");
1517
+ function buildTransform(ctx) {
1518
+ return function transform(node, index, parent) {
1519
+ if (node.type === "raw" && parent && typeof index === "number") {
1520
+ if (ctx.skipHtml) {
1521
+ parent.children.splice(index, 1);
1522
+ } else {
1523
+ parent.children[index] = { type: "text", value: node.value };
1524
+ }
1525
+ return index;
1526
+ }
1527
+ if (node.type === "element") {
1528
+ const element = node;
1529
+ let key;
1530
+ for (key in import_html_url_attributes.urlAttributes) {
1531
+ if (Object.hasOwn(import_html_url_attributes.urlAttributes, key) && Object.hasOwn(element.properties, key)) {
1532
+ const value = element.properties[key];
1533
+ const test = import_html_url_attributes.urlAttributes[key];
1534
+ if (test === null || test.includes(element.tagName)) {
1535
+ element.properties[key] = ctx.urlTransform(String(value || ""), key, element);
1536
+ }
1537
+ }
1538
+ }
1539
+ }
1540
+ if (node.type === "element") {
1541
+ const element = node;
1542
+ let remove = ctx.allowedElements ? !ctx.allowedElements.includes(element.tagName) : ctx.disallowedElements ? ctx.disallowedElements.includes(element.tagName) : false;
1543
+ if (!remove && ctx.allowElement && typeof index === "number") {
1544
+ remove = !ctx.allowElement(element, index, parent);
1545
+ }
1546
+ if (remove && parent && typeof index === "number") {
1547
+ if (ctx.unwrapDisallowed && element.children) {
1548
+ parent.children.splice(index, 1, ...element.children);
1549
+ } else {
1550
+ parent.children.splice(index, 1);
1551
+ }
1552
+ return index;
1553
+ }
1554
+ }
1555
+ return void 0;
1556
+ };
1557
+ }
1558
+
1559
+ // src/components/markdown/urlTransform.ts
1560
+ var safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i;
1561
+ var defaultUrlTransform = (value) => {
1562
+ const colon = value.indexOf(":");
1563
+ const questionMark = value.indexOf("?");
1564
+ const numberSign = value.indexOf("#");
1565
+ const slash = value.indexOf("/");
1566
+ if (
1567
+ // No protocol → relative.
1568
+ colon === -1 || // First colon is after `/`, `?`, or `#` → not a protocol.
1569
+ slash !== -1 && colon > slash || questionMark !== -1 && colon > questionMark || numberSign !== -1 && colon > numberSign || // Allowed protocol.
1570
+ safeProtocol.test(value.slice(0, colon))
1571
+ ) {
1572
+ return value;
1573
+ }
1574
+ return "";
1575
+ };
1576
+
1577
+ // src/components/markdown/Markdown.tsx
1578
+ var changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
1579
+ var deprecations = [
1580
+ { from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" },
1581
+ { from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" },
1582
+ {
1583
+ from: "allowNode",
1584
+ id: "replace-allownode-allowedtypes-and-disallowedtypes",
1585
+ to: "allowElement"
1586
+ },
1587
+ {
1588
+ from: "allowedTypes",
1589
+ id: "replace-allownode-allowedtypes-and-disallowedtypes",
1590
+ to: "allowedElements"
1591
+ },
1592
+ { from: "className", id: "remove-classname" },
1593
+ {
1594
+ from: "disallowedTypes",
1595
+ id: "replace-allownode-allowedtypes-and-disallowedtypes",
1596
+ to: "disallowedElements"
1597
+ },
1598
+ { from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" },
1599
+ { from: "includeElementIndex", id: "#remove-includeelementindex" },
1600
+ {
1601
+ from: "includeNodeIndex",
1602
+ id: "change-includenodeindex-to-includeelementindex"
1603
+ },
1604
+ { from: "linkTarget", id: "remove-linktarget" },
1605
+ { from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" },
1606
+ { from: "rawSourcePos", id: "#remove-rawsourcepos" },
1607
+ { from: "renderers", id: "change-renderers-to-components", to: "components" },
1608
+ { from: "source", id: "change-source-to-children", to: "children" },
1609
+ { from: "sourcePos", id: "#remove-sourcepos" },
1610
+ { from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" },
1611
+ { from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }
1612
+ ];
1613
+ function validateOptions(options) {
1614
+ for (const deprecation of deprecations) {
1615
+ if (Object.hasOwn(options, deprecation.from)) {
1616
+ (0, import_devlop2.unreachable)(
1617
+ "Unexpected `" + deprecation.from + "` prop, " + (deprecation.to ? "use `" + deprecation.to + "` instead" : "remove it") + " (see <" + changelog + "#" + deprecation.id + "> for more info)"
1618
+ );
1619
+ }
1620
+ }
1621
+ if (options.allowedElements && options.disallowedElements) {
1622
+ (0, import_devlop2.unreachable)("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other");
1623
+ }
1624
+ }
1625
+ function parseStage(options) {
1626
+ validateOptions(options);
1627
+ const processor = createProcessor(options);
1628
+ const file = createFile(options);
1629
+ const mdast = processor.parse(file);
1630
+ return { processor, file, mdast };
1631
+ }
1632
+ function transformStage(parsed) {
1633
+ return parsed.processor.runSync(parsed.mdast, parsed.file);
1634
+ }
1635
+ function renderHastSubtree(tree, options) {
1636
+ const root2 = tree.type === "root" ? tree : { type: "root", children: [tree] };
1637
+ (0, import_unist_util_visit.visit)(
1638
+ root2,
1639
+ buildTransform({
1640
+ allowedElements: options.allowedElements,
1641
+ allowElement: options.allowElement,
1642
+ disallowedElements: options.disallowedElements,
1643
+ skipHtml: options.skipHtml,
1644
+ unwrapDisallowed: options.unwrapDisallowed,
1645
+ urlTransform: options.urlTransform || defaultUrlTransform
1646
+ })
1647
+ );
1648
+ return (0, import_hast_util_to_jsx_runtime.toJsxRuntime)(root2, {
1649
+ Fragment: import_react2.Fragment,
1650
+ components: options.components,
1651
+ ignoreInvalidStyle: true,
1652
+ jsx: import_jsx_runtime2.jsx,
1653
+ jsxs: import_jsx_runtime2.jsxs,
1654
+ passKeys: true,
1655
+ passNode: true
1656
+ });
1772
1657
  }
1773
- var defaultExtraPreprocessors = [];
1774
- function preprocessAIMDContent(content, extraPreprocessors = defaultExtraPreprocessors) {
1775
- return applyPreprocessors(content, preprocessLaTeX, ...extraPreprocessors);
1658
+ function Markdown(options) {
1659
+ const parsed = parseStage(options);
1660
+ const tree = transformStage(parsed);
1661
+ return renderHastSubtree(tree, options);
1776
1662
  }
1663
+ var Markdown_default = Markdown;
1777
1664
 
1778
1665
  // src/components/MarkdownContent.tsx
1779
- var import_react2 = require("react");
1780
- var import_react_markdown = __toESM(require("react-markdown"), 1);
1781
1666
  var import_rehype_katex = __toESM(require("rehype-katex"), 1);
1782
1667
  var import_rehype_raw = __toESM(require("rehype-raw"), 1);
1783
1668
  var import_rehype_unwrap_images = __toESM(require("rehype-unwrap-images"), 1);
1784
- var import_rehype_sanitize = __toESM(require("rehype-sanitize"), 1);
1669
+ var import_rehype_sanitize2 = __toESM(require("rehype-sanitize"), 1);
1670
+
1671
+ // src/components/sanitizeSchema.ts
1672
+ var import_rehype_sanitize = require("rehype-sanitize");
1673
+ function mergeClassNameAllowlist(existing, extraClassNames) {
1674
+ const entries = existing ? [...existing] : [];
1675
+ const idx = entries.findIndex(
1676
+ (entry) => typeof entry === "string" ? entry === "className" : entry[0] === "className"
1677
+ );
1678
+ if (idx === -1) {
1679
+ return [...entries, ["className", ...extraClassNames]];
1680
+ }
1681
+ const current = entries[idx];
1682
+ const merged = typeof current === "string" ? ["className", ...extraClassNames] : [...current, ...extraClassNames];
1683
+ entries[idx] = merged;
1684
+ return entries;
1685
+ }
1686
+ var sanitizeSchema = {
1687
+ ...import_rehype_sanitize.defaultSchema,
1688
+ tagNames: [...import_rehype_sanitize.defaultSchema.tagNames || [], "mark"],
1689
+ attributes: {
1690
+ ...import_rehype_sanitize.defaultSchema.attributes,
1691
+ code: mergeClassNameAllowlist(import_rehype_sanitize.defaultSchema.attributes?.code, ["math-inline", "math-display"])
1692
+ }
1693
+ };
1694
+
1695
+ // src/components/rehypeRebaseHashLinks.ts
1696
+ var import_unist_util_visit2 = require("unist-util-visit");
1697
+ var DEFAULT_PREFIX = "user-content-";
1698
+ var rehypeRebaseHashLinks = (options) => {
1699
+ const prefix = options?.prefix ?? DEFAULT_PREFIX;
1700
+ const hashPrefix = "#" + prefix;
1701
+ return (tree) => {
1702
+ (0, import_unist_util_visit2.visit)(tree, "element", (node) => {
1703
+ if (node.tagName !== "a") return;
1704
+ const href = node.properties?.href;
1705
+ if (typeof href !== "string" || !href.startsWith("#")) return;
1706
+ if (href.startsWith(hashPrefix)) return;
1707
+ node.properties.href = hashPrefix + href.slice(1);
1708
+ });
1709
+ };
1710
+ };
1711
+ var rehypeRebaseHashLinks_default = rehypeRebaseHashLinks;
1712
+
1713
+ // src/components/MarkdownContent.tsx
1785
1714
  var import_remark_breaks = __toESM(require("remark-breaks"), 1);
1786
1715
  var import_remark_cjk_friendly = __toESM(require("remark-cjk-friendly"), 1);
1787
1716
  var import_remark_cjk_friendly_gfm_strikethrough = __toESM(require("remark-cjk-friendly-gfm-strikethrough"), 1);
@@ -1789,13 +1718,180 @@ var import_remark_emoji = __toESM(require("remark-emoji"), 1);
1789
1718
  var import_remark_gfm = __toESM(require("remark-gfm"), 1);
1790
1719
  var import_remark_math = __toESM(require("remark-math"), 1);
1791
1720
  var import_remark_definition_list = require("remark-definition-list");
1792
- var import_remark_supersub = __toESM(require("remark-supersub"), 1);
1793
1721
  var import_remark_mark_highlight = require("remark-mark-highlight");
1794
1722
  var import_remark_squeeze_paragraphs = __toESM(require("remark-squeeze-paragraphs"), 1);
1795
1723
  var import_remark_smartypants = __toESM(require("remark-smartypants"), 1);
1796
1724
  var import_remark_pangu = __toESM(require("remark-pangu"), 1);
1797
1725
  var import_remark_remove_comments = __toESM(require("remark-remove-comments"), 1);
1798
- var import_jsx_runtime2 = require("react/jsx-runtime");
1726
+
1727
+ // src/components/blockMemo.ts
1728
+ var import_unist_util_visit3 = require("unist-util-visit");
1729
+ var TAINT_TYPES = /* @__PURE__ */ new Set([
1730
+ "footnoteReference",
1731
+ "footnoteDefinition",
1732
+ "linkReference",
1733
+ "imageReference",
1734
+ "definition"
1735
+ ]);
1736
+ var CTX_TYPES = TAINT_TYPES;
1737
+ function createCache() {
1738
+ return { blocks: /* @__PURE__ */ new Map() };
1739
+ }
1740
+ function extractRaw(node, source) {
1741
+ if (!node.position) return "";
1742
+ return source.slice(node.position.start.offset, node.position.end.offset);
1743
+ }
1744
+ function isFootnoteSection(node) {
1745
+ if (node.tagName !== "section") return false;
1746
+ const props = node.properties;
1747
+ return props?.dataFootnotes !== void 0;
1748
+ }
1749
+ function hasMdastSource(node) {
1750
+ return node.position !== void 0;
1751
+ }
1752
+ var FOOTNOTE_SECTION_KEY = "__footnote_section__";
1753
+ function buildBlocks(mdast, hast, source) {
1754
+ const mdastByOffset = /* @__PURE__ */ new Map();
1755
+ for (const child of mdast.children) {
1756
+ const off = child.position?.start.offset;
1757
+ if (off !== void 0) {
1758
+ mdastByOffset.set(off, child);
1759
+ }
1760
+ }
1761
+ const ctxParts = [];
1762
+ (0, import_unist_util_visit3.visit)(mdast, (n) => {
1763
+ if (!CTX_TYPES.has(n.type)) return;
1764
+ if (n.type === "footnoteReference") ctxParts.push(["fr", n.identifier]);
1765
+ else if (n.type === "footnoteDefinition") ctxParts.push(["fd", n.identifier, extractRaw(n, source)]);
1766
+ else if (n.type === "linkReference") ctxParts.push(["lr", n.identifier]);
1767
+ else if (n.type === "imageReference") ctxParts.push(["ir", n.identifier]);
1768
+ else if (n.type === "definition") ctxParts.push(["d", n.identifier, n.url, n.title ?? null]);
1769
+ });
1770
+ const globalCtx = JSON.stringify(ctxParts);
1771
+ const plan = [];
1772
+ const blocks = [];
1773
+ const blockHasts = [];
1774
+ let synthetic;
1775
+ for (let i = 0; i < hast.children.length; i++) {
1776
+ const hastChild = hast.children[i];
1777
+ if (hastChild.type !== "element") {
1778
+ const off = hastChild.position?.start.offset;
1779
+ const reactKey = off !== void 0 ? `inline-${off}` : `inline-i${i}`;
1780
+ plan.push({ kind: "inline", el: hastChild, reactKey });
1781
+ continue;
1782
+ }
1783
+ const el = hastChild;
1784
+ if (isFootnoteSection(el)) {
1785
+ synthetic = el;
1786
+ plan.push({ kind: "synthetic", el, reactKey: FOOTNOTE_SECTION_KEY });
1787
+ continue;
1788
+ }
1789
+ const hastOffset = el.position?.start.offset;
1790
+ if (hastOffset === void 0) {
1791
+ plan.push({ kind: "inline", el, reactKey: `inline-i${i}` });
1792
+ continue;
1793
+ }
1794
+ let mdastNode = mdastByOffset.get(hastOffset);
1795
+ if (!mdastNode) {
1796
+ mdastNode = mdast.children.findLast((child) => {
1797
+ const startOff = child.position?.start.offset;
1798
+ const endOff = child.position?.end.offset;
1799
+ return startOff !== void 0 && endOff !== void 0 && startOff <= hastOffset && hastOffset < endOff;
1800
+ });
1801
+ }
1802
+ if (!mdastNode) {
1803
+ if (process.env.NODE_ENV !== "production") {
1804
+ throw new Error(
1805
+ `block-memo: hast block at offset ${hastOffset} has no mdast counterpart. A rehype plugin may have synthesized positions outside source. tagName=${el.tagName}`
1806
+ );
1807
+ }
1808
+ plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
1809
+ continue;
1810
+ }
1811
+ if (mdastNode.type === "footnoteDefinition") {
1812
+ plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
1813
+ continue;
1814
+ }
1815
+ let hasReference = false;
1816
+ (0, import_unist_util_visit3.visit)(mdastNode, (n) => {
1817
+ if (TAINT_TYPES.has(n.type)) {
1818
+ hasReference = true;
1819
+ return false;
1820
+ }
1821
+ return void 0;
1822
+ });
1823
+ const mdastPos = mdastNode.position;
1824
+ if (!mdastPos || mdastPos.start.offset === void 0 || mdastPos.end.offset === void 0) {
1825
+ continue;
1826
+ }
1827
+ const info = {
1828
+ raw: extractRaw(mdastNode, source),
1829
+ startOffset: mdastPos.start.offset,
1830
+ endOffset: mdastPos.end.offset,
1831
+ startLine: mdastPos.start.line,
1832
+ startColumn: mdastPos.start.column,
1833
+ hasReference
1834
+ };
1835
+ blocks.push(info);
1836
+ blockHasts.push(el);
1837
+ plan.push({ kind: "block", el, info, reactKey: `block-${hastOffset}` });
1838
+ }
1839
+ return { plan, globalCtx, blocks, blockHasts, synthetic };
1840
+ }
1841
+ function renderBlocksWithCache(cacheRef, plan, globalCtx, postOptions) {
1842
+ const prev = cacheRef.current;
1843
+ const next = { blocks: /* @__PURE__ */ new Map() };
1844
+ const rendered = [];
1845
+ if (process.env.NODE_ENV !== "production") {
1846
+ for (const item of plan) {
1847
+ if (item.kind === "block" && !hasMdastSource(item.el)) {
1848
+ throw new Error(
1849
+ "block-memo: block hast child has no position. Did a rehype plugin strip it? (Run positionPropagation.test.ts to verify.)"
1850
+ );
1851
+ }
1852
+ }
1853
+ }
1854
+ for (const item of plan) {
1855
+ if (item.kind === "inline") {
1856
+ rendered.push({
1857
+ node: renderHastSubtree(item.el, postOptions),
1858
+ reactKey: item.reactKey
1859
+ });
1860
+ continue;
1861
+ }
1862
+ if (item.kind === "synthetic") {
1863
+ const cached = prev.footnoteSection;
1864
+ const node2 = cached && cached.ctx === globalCtx ? cached.node : renderHastSubtree(item.el, postOptions);
1865
+ next.footnoteSection = { ctx: globalCtx, node: node2 };
1866
+ rendered.push({ node: node2, reactKey: item.reactKey });
1867
+ continue;
1868
+ }
1869
+ const block = item.info;
1870
+ let bucket = next.blocks.get(block.raw);
1871
+ if (!bucket) {
1872
+ bucket = [];
1873
+ next.blocks.set(block.raw, bucket);
1874
+ }
1875
+ const occ = bucket.length;
1876
+ const blockCtx = block.hasReference ? globalCtx : "";
1877
+ const entry = prev.blocks.get(block.raw)?.[occ];
1878
+ const valid = entry !== void 0 && entry.ctx === blockCtx && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
1879
+ const node = valid ? entry.node : renderHastSubtree(item.el, postOptions);
1880
+ bucket.push({
1881
+ node,
1882
+ ctx: blockCtx,
1883
+ startOffset: block.startOffset,
1884
+ startLine: block.startLine,
1885
+ startColumn: block.startColumn
1886
+ });
1887
+ rendered.push({ node, reactKey: item.reactKey });
1888
+ }
1889
+ cacheRef.current = next;
1890
+ return rendered;
1891
+ }
1892
+
1893
+ // src/components/MarkdownContent.tsx
1894
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1799
1895
  var DisplayOptimizeRemarkPluginMap = {
1800
1896
  ["REMOVE_COMMENTS" /* REMOVE_COMMENTS */]: import_remark_remove_comments.default,
1801
1897
  ["SMARTYPANTS" /* SMARTYPANTS */]: import_remark_smartypants.default,
@@ -1803,83 +1899,169 @@ var DisplayOptimizeRemarkPluginMap = {
1803
1899
  };
1804
1900
  var ExtraSyntaxRemarkPluginMap = {
1805
1901
  ["HIGHLIGHT" /* HIGHLIGHT */]: import_remark_mark_highlight.remarkMark,
1806
- ["DEFINITION_LIST" /* DEFINITION_LIST */]: import_remark_definition_list.remarkDefinitionList,
1807
- ["SUBSCRIPT" /* SUBSCRIPT */]: import_remark_supersub.default
1902
+ ["DEFINITION_LIST" /* DEFINITION_LIST */]: import_remark_definition_list.remarkDefinitionList
1808
1903
  };
1809
1904
  var DefaultCustomComponents = {};
1810
- var AIMarkdownContent = (0, import_react2.memo)(({ content, customComponents }) => {
1811
- const { config } = useAIMarkdownRenderState();
1812
- const { extraSyntaxRemarkPlugins, enableDefinitionList } = (0, import_react2.useMemo)(
1905
+ var BlockMemoizedRenderer = (0, import_react3.memo)(
1906
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => {
1907
+ const urlTransform = void 0;
1908
+ const allowedElements = void 0;
1909
+ const disallowedElements = void 0;
1910
+ const allowElement = void 0;
1911
+ const skipHtml = void 0;
1912
+ const unwrapDisallowed = void 0;
1913
+ const cacheRef = (0, import_react3.useRef)(createCache());
1914
+ const depsRef = (0, import_react3.useRef)({
1915
+ usedComponents,
1916
+ remarkPlugins,
1917
+ rehypePlugins,
1918
+ remarkRehypeOptions,
1919
+ urlTransform,
1920
+ allowedElements,
1921
+ disallowedElements,
1922
+ allowElement,
1923
+ skipHtml,
1924
+ unwrapDisallowed
1925
+ });
1926
+ 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) {
1927
+ cacheRef.current = createCache();
1928
+ depsRef.current = {
1929
+ usedComponents,
1930
+ remarkPlugins,
1931
+ rehypePlugins,
1932
+ remarkRehypeOptions,
1933
+ urlTransform,
1934
+ allowedElements,
1935
+ disallowedElements,
1936
+ allowElement,
1937
+ skipHtml,
1938
+ unwrapDisallowed
1939
+ };
1940
+ }
1941
+ const parsed = (0, import_react3.useMemo)(
1942
+ () => parseStage({
1943
+ children: content,
1944
+ remarkPlugins,
1945
+ rehypePlugins,
1946
+ remarkRehypeOptions
1947
+ }),
1948
+ [content, remarkPlugins, rehypePlugins, remarkRehypeOptions]
1949
+ );
1950
+ const hast = (0, import_react3.useMemo)(() => transformStage(parsed), [parsed]);
1951
+ const built = (0, import_react3.useMemo)(() => buildBlocks(parsed.mdast, hast, content), [parsed.mdast, hast, content]);
1952
+ const postOptions = (0, import_react3.useMemo)(
1953
+ () => ({
1954
+ components: usedComponents,
1955
+ urlTransform,
1956
+ allowedElements,
1957
+ disallowedElements,
1958
+ allowElement,
1959
+ skipHtml,
1960
+ unwrapDisallowed
1961
+ }),
1962
+ [usedComponents, urlTransform, allowedElements, disallowedElements, allowElement, skipHtml, unwrapDisallowed]
1963
+ );
1964
+ const rendered = renderBlocksWithCache(cacheRef, built.plan, built.globalCtx, postOptions);
1965
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: rendered.map(({ node, reactKey }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.Fragment, { children: node }, reactKey)) });
1966
+ }
1967
+ );
1968
+ BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
1969
+ var LegacyRenderer = (0, import_react3.memo)(
1970
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1971
+ Markdown_default,
1972
+ {
1973
+ remarkPlugins,
1974
+ rehypePlugins,
1975
+ remarkRehypeOptions,
1976
+ components: usedComponents,
1977
+ children: content
1978
+ }
1979
+ )
1980
+ );
1981
+ LegacyRenderer.displayName = "LegacyRenderer";
1982
+ var AIMarkdownContent = (0, import_react3.memo)(({ content, customComponents }) => {
1983
+ const { config, documentId } = useAIMarkdownRenderState();
1984
+ const clobberPrefix = `${encodeURIComponent(documentId)}-user-content-`;
1985
+ const { extraSyntaxRemarkPlugins, enableDefinitionList } = (0, import_react3.useMemo)(
1813
1986
  () => ({
1814
1987
  extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
1815
1988
  enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
1816
1989
  }),
1817
1990
  [config.extraSyntaxSupported]
1818
1991
  );
1819
- const displayOptimizeRemarkPlugins = (0, import_react2.useMemo)(() => {
1992
+ const displayOptimizeRemarkPlugins = (0, import_react3.useMemo)(() => {
1820
1993
  return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
1821
1994
  }, [config.displayOptimizeAbilities]);
1822
- const usedComponents = (0, import_react2.useMemo)(() => {
1995
+ const usedComponents = (0, import_react3.useMemo)(() => {
1823
1996
  return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
1824
1997
  }, [customComponents]);
1825
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1826
- import_react_markdown.default,
1827
- {
1828
- remarkPlugins: [
1829
- // --- Core plugins (always active) ---
1830
- import_remark_gfm.default,
1831
- [
1832
- import_remark_math.default,
1833
- {
1834
- // Disable single-dollar inline math to avoid conflicts with currency
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 : {}
1998
+ const remarkPlugins = (0, import_react3.useMemo)(
1999
+ () => [
2000
+ // --- Core plugins (always active) ---
2001
+ import_remark_gfm.default,
2002
+ [
2003
+ import_remark_math.default,
2004
+ {
2005
+ // Disable single-dollar inline math to avoid conflicts with currency
2006
+ // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
2007
+ singleDollarTextMath: false
1879
2008
  }
1880
- },
1881
- components: usedComponents,
1882
- children: content
2009
+ ],
2010
+ // --- Configurable extra syntax plugins ---
2011
+ ...extraSyntaxRemarkPlugins,
2012
+ // --- Formatting & normalization ---
2013
+ import_remark_breaks.default,
2014
+ import_remark_emoji.default,
2015
+ import_remark_squeeze_paragraphs.default,
2016
+ import_remark_cjk_friendly.default,
2017
+ import_remark_cjk_friendly_gfm_strikethrough.default,
2018
+ // --- Configurable display optimizations ---
2019
+ ...displayOptimizeRemarkPlugins
2020
+ ],
2021
+ [extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
2022
+ );
2023
+ const rehypePlugins = (0, import_react3.useMemo)(
2024
+ () => [
2025
+ // Allow raw HTML through so rehype-sanitize can handle it.
2026
+ [import_rehype_raw.default, { passThrough: [] }],
2027
+ // Sanitize HTML while allowing <mark> (highlight) and KaTeX class names.
2028
+ // Override `clobberPrefix` with the instance-scoped value so every id
2029
+ // and clobberable attribute is namespaced to this `<AIMarkdown>` instance.
2030
+ [import_rehype_sanitize2.default, { ...sanitizeSchema, clobberPrefix }],
2031
+ // Re-prefix intra-document hash hrefs so they match the ids that
2032
+ // rehype-sanitize just clobbered. Must use the SAME prefix as the schema
2033
+ // above — that's why both read from `clobberPrefix`.
2034
+ [rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
2035
+ import_rehype_katex.default,
2036
+ import_rehype_unwrap_images.default
2037
+ ],
2038
+ [clobberPrefix]
2039
+ );
2040
+ const remarkRehypeOptions = (0, import_react3.useMemo)(
2041
+ () => ({
2042
+ allowDangerousHtml: true,
2043
+ // Suppress mdast-util-to-hast's `user-content-` prefix on footnote
2044
+ // ids/hrefs; rehype-sanitize will apply the same prefix downstream
2045
+ // and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
2046
+ // Without this, ids would end up double-prefixed
2047
+ // (`user-content-user-content-fn-x`).
2048
+ clobberPrefix: "",
2049
+ handlers: {
2050
+ // Inject definition-list HAST handlers when the extension is active.
2051
+ ...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
2052
+ }
2053
+ }),
2054
+ [enableDefinitionList]
2055
+ );
2056
+ const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
2057
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2058
+ Renderer,
2059
+ {
2060
+ content,
2061
+ usedComponents,
2062
+ remarkPlugins,
2063
+ rehypePlugins,
2064
+ remarkRehypeOptions
1883
2065
  }
1884
2066
  );
1885
2067
  });
@@ -1887,7 +2069,7 @@ AIMarkdownContent.displayName = "AIMarkdownContent";
1887
2069
  var MarkdownContent_default = AIMarkdownContent;
1888
2070
 
1889
2071
  // src/hooks/useStableValue.ts
1890
- var import_react3 = require("react");
2072
+ var import_react4 = require("react");
1891
2073
 
1892
2074
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js
1893
2075
  var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
@@ -2004,44 +2186,44 @@ var setToArray_default = setToArray;
2004
2186
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js
2005
2187
  var COMPARE_PARTIAL_FLAG2 = 1;
2006
2188
  var COMPARE_UNORDERED_FLAG2 = 2;
2007
- var boolTag4 = "[object Boolean]";
2008
- var dateTag4 = "[object Date]";
2009
- var errorTag3 = "[object Error]";
2010
- var mapTag6 = "[object Map]";
2011
- var numberTag4 = "[object Number]";
2012
- var regexpTag4 = "[object RegExp]";
2013
- var setTag6 = "[object Set]";
2014
- var stringTag4 = "[object String]";
2015
- var symbolTag3 = "[object Symbol]";
2016
- var arrayBufferTag4 = "[object ArrayBuffer]";
2017
- var dataViewTag5 = "[object DataView]";
2018
- var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
2019
- var symbolValueOf2 = symbolProto2 ? symbolProto2.valueOf : void 0;
2189
+ var boolTag2 = "[object Boolean]";
2190
+ var dateTag2 = "[object Date]";
2191
+ var errorTag2 = "[object Error]";
2192
+ var mapTag2 = "[object Map]";
2193
+ var numberTag2 = "[object Number]";
2194
+ var regexpTag2 = "[object RegExp]";
2195
+ var setTag2 = "[object Set]";
2196
+ var stringTag2 = "[object String]";
2197
+ var symbolTag = "[object Symbol]";
2198
+ var arrayBufferTag2 = "[object ArrayBuffer]";
2199
+ var dataViewTag2 = "[object DataView]";
2200
+ var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
2201
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2020
2202
  function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
2021
2203
  switch (tag) {
2022
- case dataViewTag5:
2204
+ case dataViewTag2:
2023
2205
  if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
2024
2206
  return false;
2025
2207
  }
2026
2208
  object = object.buffer;
2027
2209
  other = other.buffer;
2028
- case arrayBufferTag4:
2210
+ case arrayBufferTag2:
2029
2211
  if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
2030
2212
  return false;
2031
2213
  }
2032
2214
  return true;
2033
- case boolTag4:
2034
- case dateTag4:
2035
- case numberTag4:
2215
+ case boolTag2:
2216
+ case dateTag2:
2217
+ case numberTag2:
2036
2218
  return eq_default(+object, +other);
2037
- case errorTag3:
2219
+ case errorTag2:
2038
2220
  return object.name == other.name && object.message == other.message;
2039
- case regexpTag4:
2040
- case stringTag4:
2221
+ case regexpTag2:
2222
+ case stringTag2:
2041
2223
  return object == other + "";
2042
- case mapTag6:
2224
+ case mapTag2:
2043
2225
  var convert = mapToArray_default;
2044
- case setTag6:
2226
+ case setTag2:
2045
2227
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
2046
2228
  convert || (convert = setToArray_default);
2047
2229
  if (object.size != other.size && !isPartial) {
@@ -2056,19 +2238,103 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
2056
2238
  var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
2057
2239
  stack["delete"](object);
2058
2240
  return result;
2059
- case symbolTag3:
2060
- if (symbolValueOf2) {
2061
- return symbolValueOf2.call(object) == symbolValueOf2.call(other);
2241
+ case symbolTag:
2242
+ if (symbolValueOf) {
2243
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
2062
2244
  }
2063
2245
  }
2064
2246
  return false;
2065
2247
  }
2066
2248
  var equalByTag_default = equalByTag;
2067
2249
 
2250
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
2251
+ function arrayPush(array, values) {
2252
+ var index = -1, length = values.length, offset = array.length;
2253
+ while (++index < length) {
2254
+ array[offset + index] = values[index];
2255
+ }
2256
+ return array;
2257
+ }
2258
+ var arrayPush_default = arrayPush;
2259
+
2260
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
2261
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
2262
+ var result = keysFunc(object);
2263
+ return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
2264
+ }
2265
+ var baseGetAllKeys_default = baseGetAllKeys;
2266
+
2267
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
2268
+ function arrayFilter(array, predicate) {
2269
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
2270
+ while (++index < length) {
2271
+ var value = array[index];
2272
+ if (predicate(value, index, array)) {
2273
+ result[resIndex++] = value;
2274
+ }
2275
+ }
2276
+ return result;
2277
+ }
2278
+ var arrayFilter_default = arrayFilter;
2279
+
2280
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
2281
+ function stubArray() {
2282
+ return [];
2283
+ }
2284
+ var stubArray_default = stubArray;
2285
+
2286
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
2287
+ var objectProto12 = Object.prototype;
2288
+ var propertyIsEnumerable2 = objectProto12.propertyIsEnumerable;
2289
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
2290
+ var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
2291
+ if (object == null) {
2292
+ return [];
2293
+ }
2294
+ object = Object(object);
2295
+ return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
2296
+ return propertyIsEnumerable2.call(object, symbol);
2297
+ });
2298
+ };
2299
+ var getSymbols_default = getSymbols;
2300
+
2301
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
2302
+ var nativeKeys = overArg_default(Object.keys, Object);
2303
+ var nativeKeys_default = nativeKeys;
2304
+
2305
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
2306
+ var objectProto13 = Object.prototype;
2307
+ var hasOwnProperty10 = objectProto13.hasOwnProperty;
2308
+ function baseKeys(object) {
2309
+ if (!isPrototype_default(object)) {
2310
+ return nativeKeys_default(object);
2311
+ }
2312
+ var result = [];
2313
+ for (var key in Object(object)) {
2314
+ if (hasOwnProperty10.call(object, key) && key != "constructor") {
2315
+ result.push(key);
2316
+ }
2317
+ }
2318
+ return result;
2319
+ }
2320
+ var baseKeys_default = baseKeys;
2321
+
2322
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
2323
+ function keys(object) {
2324
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
2325
+ }
2326
+ var keys_default = keys;
2327
+
2328
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
2329
+ function getAllKeys(object) {
2330
+ return baseGetAllKeys_default(object, keys_default, getSymbols_default);
2331
+ }
2332
+ var getAllKeys_default = getAllKeys;
2333
+
2068
2334
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js
2069
2335
  var COMPARE_PARTIAL_FLAG3 = 1;
2070
- var objectProto15 = Object.prototype;
2071
- var hasOwnProperty12 = objectProto15.hasOwnProperty;
2336
+ var objectProto14 = Object.prototype;
2337
+ var hasOwnProperty11 = objectProto14.hasOwnProperty;
2072
2338
  function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2073
2339
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
2074
2340
  if (objLength != othLength && !isPartial) {
@@ -2077,7 +2343,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2077
2343
  var index = objLength;
2078
2344
  while (index--) {
2079
2345
  var key = objProps[index];
2080
- if (!(isPartial ? key in other : hasOwnProperty12.call(other, key))) {
2346
+ if (!(isPartial ? key in other : hasOwnProperty11.call(other, key))) {
2081
2347
  return false;
2082
2348
  }
2083
2349
  }
@@ -2114,18 +2380,69 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2114
2380
  }
2115
2381
  var equalObjects_default = equalObjects;
2116
2382
 
2383
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
2384
+ var DataView = getNative_default(root_default, "DataView");
2385
+ var DataView_default = DataView;
2386
+
2387
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
2388
+ var Promise2 = getNative_default(root_default, "Promise");
2389
+ var Promise_default = Promise2;
2390
+
2391
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
2392
+ var Set2 = getNative_default(root_default, "Set");
2393
+ var Set_default = Set2;
2394
+
2395
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
2396
+ var WeakMap = getNative_default(root_default, "WeakMap");
2397
+ var WeakMap_default = WeakMap;
2398
+
2399
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
2400
+ var mapTag3 = "[object Map]";
2401
+ var objectTag3 = "[object Object]";
2402
+ var promiseTag = "[object Promise]";
2403
+ var setTag3 = "[object Set]";
2404
+ var weakMapTag2 = "[object WeakMap]";
2405
+ var dataViewTag3 = "[object DataView]";
2406
+ var dataViewCtorString = toSource_default(DataView_default);
2407
+ var mapCtorString = toSource_default(Map_default);
2408
+ var promiseCtorString = toSource_default(Promise_default);
2409
+ var setCtorString = toSource_default(Set_default);
2410
+ var weakMapCtorString = toSource_default(WeakMap_default);
2411
+ var getTag = baseGetTag_default;
2412
+ 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) {
2413
+ getTag = function(value) {
2414
+ var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
2415
+ if (ctorString) {
2416
+ switch (ctorString) {
2417
+ case dataViewCtorString:
2418
+ return dataViewTag3;
2419
+ case mapCtorString:
2420
+ return mapTag3;
2421
+ case promiseCtorString:
2422
+ return promiseTag;
2423
+ case setCtorString:
2424
+ return setTag3;
2425
+ case weakMapCtorString:
2426
+ return weakMapTag2;
2427
+ }
2428
+ }
2429
+ return result;
2430
+ };
2431
+ }
2432
+ var getTag_default = getTag;
2433
+
2117
2434
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js
2118
2435
  var COMPARE_PARTIAL_FLAG4 = 1;
2119
- var argsTag4 = "[object Arguments]";
2120
- var arrayTag3 = "[object Array]";
2121
- var objectTag5 = "[object Object]";
2122
- var objectProto16 = Object.prototype;
2123
- var hasOwnProperty13 = objectProto16.hasOwnProperty;
2436
+ var argsTag3 = "[object Arguments]";
2437
+ var arrayTag2 = "[object Array]";
2438
+ var objectTag4 = "[object Object]";
2439
+ var objectProto15 = Object.prototype;
2440
+ var hasOwnProperty12 = objectProto15.hasOwnProperty;
2124
2441
  function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2125
- var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag3 : getTag_default(object), othTag = othIsArr ? arrayTag3 : getTag_default(other);
2126
- objTag = objTag == argsTag4 ? objectTag5 : objTag;
2127
- othTag = othTag == argsTag4 ? objectTag5 : othTag;
2128
- var objIsObj = objTag == objectTag5, othIsObj = othTag == objectTag5, isSameTag = objTag == othTag;
2442
+ var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
2443
+ objTag = objTag == argsTag3 ? objectTag4 : objTag;
2444
+ othTag = othTag == argsTag3 ? objectTag4 : othTag;
2445
+ var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
2129
2446
  if (isSameTag && isBuffer_default(object)) {
2130
2447
  if (!isBuffer_default(other)) {
2131
2448
  return false;
@@ -2138,7 +2455,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2138
2455
  return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
2139
2456
  }
2140
2457
  if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
2141
- var objIsWrapped = objIsObj && hasOwnProperty13.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty13.call(other, "__wrapped__");
2458
+ var objIsWrapped = objIsObj && hasOwnProperty12.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty12.call(other, "__wrapped__");
2142
2459
  if (objIsWrapped || othIsWrapped) {
2143
2460
  var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
2144
2461
  stack || (stack = new Stack_default());
@@ -2172,32 +2489,33 @@ function isEqual(value, other) {
2172
2489
  var isEqual_default = isEqual;
2173
2490
 
2174
2491
  // src/hooks/useStableValue.ts
2492
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react4.useLayoutEffect : import_react4.useEffect;
2175
2493
  function useStableValue(value) {
2176
- const ref = (0, import_react3.useRef)(value);
2494
+ const ref = (0, import_react4.useRef)(value);
2177
2495
  const prev = ref.current;
2178
2496
  const stableValue = isEqual_default(prev, value) ? prev : value;
2179
- (0, import_react3.useEffect)(() => {
2497
+ useIsomorphicLayoutEffect(() => {
2180
2498
  ref.current = stableValue;
2181
2499
  }, [stableValue]);
2182
2500
  return stableValue;
2183
2501
  }
2184
2502
 
2185
2503
  // src/components/typography/Default.tsx
2186
- var import_react4 = require("react");
2187
- var import_jsx_runtime3 = require("react/jsx-runtime");
2188
- var DefaultTypography = (0, import_react4.memo)(({ children, fontSize, variant, colorScheme, style }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2189
- "div",
2190
- {
2191
- className: `aim-typography-root ${variant ?? ""} ${colorScheme ?? ""}`.trim(),
2192
- style: { width: "100%", fontSize, ...style },
2193
- children
2194
- }
2195
- ));
2504
+ var import_react5 = require("react");
2505
+ var import_jsx_runtime4 = require("react/jsx-runtime");
2506
+ var DefaultTypography = (0, import_react5.memo)(({ children, fontSize, variant, colorScheme, style }) => {
2507
+ const className = (0, import_react5.useMemo)(
2508
+ () => ["aim-typography-root", variant, colorScheme].filter(Boolean).join(" "),
2509
+ [variant, colorScheme]
2510
+ );
2511
+ const mergedStyle = (0, import_react5.useMemo)(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
2512
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, style: mergedStyle, children });
2513
+ });
2196
2514
  DefaultTypography.displayName = "DefaultTypography";
2197
2515
  var Default_default = DefaultTypography;
2198
2516
 
2199
2517
  // src/index.tsx
2200
- var import_jsx_runtime4 = require("react/jsx-runtime");
2518
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2201
2519
  var AIMarkdownComponent = ({
2202
2520
  streaming = false,
2203
2521
  content,
@@ -2210,40 +2528,45 @@ var AIMarkdownComponent = ({
2210
2528
  Typography = Default_default,
2211
2529
  ExtraStyles,
2212
2530
  variant = "default",
2213
- colorScheme = "light"
2531
+ colorScheme = "light",
2532
+ documentId
2214
2533
  }) => {
2215
- const usedFontSize = fontSize ? typeof fontSize === "number" ? `${fontSize}px` : fontSize : "0.9375rem";
2534
+ const usedFontSize = fontSize === void 0 ? "0.9375rem" : typeof fontSize === "number" ? `${fontSize}px` : fontSize;
2535
+ const generatedId = (0, import_react6.useId)();
2536
+ const usedDocumentId = documentId && documentId.length > 0 ? documentId : generatedId;
2216
2537
  const stableDefaultConfig = useStableValue(defaultConfig);
2217
2538
  const stableConfig = useStableValue(config);
2218
2539
  const stablePreprocessors = useStableValue(contentPreprocessors);
2219
2540
  const stableCustomComponents = useStableValue(customComponents);
2220
- const usedContent = (0, import_react5.useMemo)(
2541
+ const usedContent = (0, import_react6.useMemo)(
2221
2542
  () => content ? preprocessAIMDContent(content, stablePreprocessors) : content,
2222
2543
  [content, stablePreprocessors]
2223
2544
  );
2224
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2545
+ const typographyStyle = (0, import_react6.useMemo)(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
2546
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2225
2547
  context_default,
2226
2548
  {
2227
2549
  streaming,
2228
2550
  fontSize: usedFontSize,
2229
2551
  variant,
2230
2552
  colorScheme,
2553
+ documentId: usedDocumentId,
2231
2554
  defaultConfig: stableDefaultConfig,
2232
2555
  config: stableConfig,
2233
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2556
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2234
2557
  Typography,
2235
2558
  {
2236
2559
  fontSize: usedFontSize,
2237
2560
  variant,
2238
2561
  colorScheme,
2239
- style: { "--aim-font-size-root": usedFontSize },
2240
- children: ExtraStyles ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ExtraStyles, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents })
2562
+ style: typographyStyle,
2563
+ children: ExtraStyles ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExtraStyles, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents }) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents })
2241
2564
  }
2242
2565
  )
2243
2566
  }
2244
2567
  ) });
2245
2568
  };
2246
- var AIMarkdown = (0, import_react5.memo)(AIMarkdownComponent);
2569
+ var AIMarkdown = (0, import_react6.memo)(AIMarkdownComponent);
2247
2570
  AIMarkdown.displayName = "AIMarkdown";
2248
2571
  var index_default = AIMarkdown;
2249
2572
  // Annotate the CommonJS export names for ESM import in node: