@ai-react-markdown/core 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1071,6 +1071,64 @@ var defaultAIMarkdownRenderConfig = Object.freeze({
1071
1071
  preserveOrphanReferences: true
1072
1072
  });
1073
1073
 
1074
+ // src/components/shortenDocumentId.ts
1075
+ var BASE62_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1076
+ function toBase62(n) {
1077
+ if (n === 0) return BASE62_ALPHABET[0];
1078
+ let v = n >>> 0;
1079
+ let out = "";
1080
+ while (v > 0) {
1081
+ out = BASE62_ALPHABET[v % 62] + out;
1082
+ v = Math.floor(v / 62);
1083
+ }
1084
+ return out;
1085
+ }
1086
+ function rotl32(x, r) {
1087
+ return (x << r | x >>> 32 - r) >>> 0;
1088
+ }
1089
+ var C1 = 3432918353;
1090
+ var C2 = 461845907;
1091
+ var UTF8_ENCODER = /* @__PURE__ */ new TextEncoder();
1092
+ function murmur3_32(s, seed = 0) {
1093
+ const bytes = UTF8_ENCODER.encode(s);
1094
+ const len = bytes.length;
1095
+ let h1 = seed >>> 0;
1096
+ const nblocks = len >>> 2;
1097
+ for (let i = 0; i < nblocks; i++) {
1098
+ const b = i * 4;
1099
+ let k1 = bytes[b] | bytes[b + 1] << 8 | bytes[b + 2] << 16 | bytes[b + 3] << 24;
1100
+ k1 = Math.imul(k1, C1);
1101
+ k1 = rotl32(k1, 15);
1102
+ k1 = Math.imul(k1, C2);
1103
+ h1 ^= k1;
1104
+ h1 = rotl32(h1, 13);
1105
+ h1 = Math.imul(h1, 5) + 3864292196 >>> 0;
1106
+ }
1107
+ const tail = nblocks * 4;
1108
+ const rem = len & 3;
1109
+ if (rem > 0) {
1110
+ let k1 = 0;
1111
+ if (rem === 3) k1 ^= bytes[tail + 2] << 16;
1112
+ if (rem >= 2) k1 ^= bytes[tail + 1] << 8;
1113
+ k1 ^= bytes[tail];
1114
+ k1 = Math.imul(k1, C1);
1115
+ k1 = rotl32(k1, 15);
1116
+ k1 = Math.imul(k1, C2);
1117
+ h1 ^= k1;
1118
+ }
1119
+ h1 ^= len;
1120
+ h1 ^= h1 >>> 16;
1121
+ h1 = Math.imul(h1, 2246822507);
1122
+ h1 ^= h1 >>> 13;
1123
+ h1 = Math.imul(h1, 3266489909);
1124
+ h1 ^= h1 >>> 16;
1125
+ return h1 >>> 0;
1126
+ }
1127
+ function shortenDocumentId(id, threshold = 16) {
1128
+ if (id.length <= threshold) return id;
1129
+ return toBase62(murmur3_32(id));
1130
+ }
1131
+
1074
1132
  // src/context.tsx
1075
1133
  import { jsx } from "react/jsx-runtime";
1076
1134
  var AIMarkdownRenderStateContext = createContext(null);
@@ -1126,7 +1184,15 @@ var AIMarkdownRenderStateProvider = ({
1126
1184
  // construction site, not at the documentId storage site, so consumers
1127
1185
  // accessing `documentId` directly still see the raw React-native value
1128
1186
  // (e.g. `useId()`'s `_r_0_`) while id="..."/href="#..." bytes are safe.
1129
- clobberPrefix: `${encodeURIComponent(resolvedDocumentId)}-user-content-`,
1187
+ //
1188
+ // `shortenDocumentId` is applied here (NOT at the documentId storage
1189
+ // site) for the same reason: consumer-supplied UUIDs and nanoids
1190
+ // shouldn't bloat every rendered `id="…"`. Registry keying — which
1191
+ // reads `state.documentId` directly — stays on the raw value, so the
1192
+ // shortening is a pure HTML-output concern and the `useDocumentRegistry`
1193
+ // API surface is unaffected. Pure function ⇒ all chunks sharing one
1194
+ // logical documentId still produce identical prefixes.
1195
+ clobberPrefix: `${encodeURIComponent(shortenDocumentId(resolvedDocumentId))}-user-content-`,
1130
1196
  config: mergedConfig
1131
1197
  }),
1132
1198
  [streaming, fontSize, variant, colorScheme, resolvedDocumentId, mergedConfig]
@@ -2792,8 +2858,7 @@ var ExtraSyntaxRemarkPluginMap = {
2792
2858
  };
2793
2859
  var DefaultCustomComponents = {};
2794
2860
  var BlockMemoizedRenderer = memo2(
2795
- ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => {
2796
- const urlTransform = void 0;
2861
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions, urlTransform }) => {
2797
2862
  const allowedElements = void 0;
2798
2863
  const disallowedElements = void 0;
2799
2864
  const allowElement = void 0;
@@ -3042,108 +3107,116 @@ var BlockMemoizedRenderer = memo2(
3042
3107
  );
3043
3108
  BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
3044
3109
  var LegacyRenderer = memo2(
3045
- ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => /* @__PURE__ */ jsx6(
3110
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions, urlTransform }) => /* @__PURE__ */ jsx6(
3046
3111
  Markdown_default,
3047
3112
  {
3048
3113
  remarkPlugins,
3049
3114
  rehypePlugins,
3050
3115
  remarkRehypeOptions,
3051
3116
  components: usedComponents,
3117
+ urlTransform,
3052
3118
  children: content
3053
3119
  }
3054
3120
  )
3055
3121
  );
3056
3122
  LegacyRenderer.displayName = "LegacyRenderer";
3057
- var AIMarkdownContent = memo2(({ content, customComponents }) => {
3058
- const { config, clobberPrefix } = useAIMarkdownRenderState();
3059
- const { extraSyntaxRemarkPlugins, enableDefinitionList } = useMemo4(
3060
- () => ({
3061
- extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
3062
- enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
3063
- }),
3064
- [config.extraSyntaxSupported]
3065
- );
3066
- const displayOptimizeRemarkPlugins = useMemo4(() => {
3067
- return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
3068
- }, [config.displayOptimizeAbilities]);
3069
- const usedComponents = useMemo4(() => {
3070
- return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
3071
- }, [customComponents]);
3072
- const remarkPlugins = useMemo4(
3073
- () => [
3074
- // --- Core plugins (always active) ---
3075
- remarkGfm2,
3076
- [
3077
- remarkMath,
3078
- {
3079
- // Disable single-dollar inline math to avoid conflicts with currency
3080
- // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
3081
- singleDollarTextMath: false
3082
- }
3123
+ var AIMarkdownContent = memo2(
3124
+ ({ content, customComponents, urlTransform, sanitizeSchema: customSanitizeSchema }) => {
3125
+ const { config, clobberPrefix } = useAIMarkdownRenderState();
3126
+ const usedSanitizeSchema = customSanitizeSchema ?? sanitizeSchema;
3127
+ const { extraSyntaxRemarkPlugins, enableDefinitionList } = useMemo4(
3128
+ () => ({
3129
+ extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
3130
+ enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
3131
+ }),
3132
+ [config.extraSyntaxSupported]
3133
+ );
3134
+ const displayOptimizeRemarkPlugins = useMemo4(() => {
3135
+ return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
3136
+ }, [config.displayOptimizeAbilities]);
3137
+ const usedComponents = useMemo4(() => {
3138
+ return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
3139
+ }, [customComponents]);
3140
+ const remarkPlugins = useMemo4(
3141
+ () => [
3142
+ // --- Core plugins (always active) ---
3143
+ remarkGfm2,
3144
+ [
3145
+ remarkMath,
3146
+ {
3147
+ // Disable single-dollar inline math to avoid conflicts with currency
3148
+ // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
3149
+ singleDollarTextMath: false
3150
+ }
3151
+ ],
3152
+ // --- Configurable extra syntax plugins ---
3153
+ ...extraSyntaxRemarkPlugins,
3154
+ // --- Formatting & normalization ---
3155
+ remarkBreaks,
3156
+ remarkEmoji,
3157
+ remarkSqueezeParagraphs,
3158
+ remarkCjkFriendly,
3159
+ remarkCjkFriendlyGfmStrikethrough,
3160
+ // --- Configurable display optimizations ---
3161
+ ...displayOptimizeRemarkPlugins
3083
3162
  ],
3084
- // --- Configurable extra syntax plugins ---
3085
- ...extraSyntaxRemarkPlugins,
3086
- // --- Formatting & normalization ---
3087
- remarkBreaks,
3088
- remarkEmoji,
3089
- remarkSqueezeParagraphs,
3090
- remarkCjkFriendly,
3091
- remarkCjkFriendlyGfmStrikethrough,
3092
- // --- Configurable display optimizations ---
3093
- ...displayOptimizeRemarkPlugins
3094
- ],
3095
- [extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
3096
- );
3097
- const rehypePlugins = useMemo4(
3098
- () => [
3099
- // Allow raw HTML through so rehype-sanitize can handle it.
3100
- [rehypeRaw, { passThrough: [] }],
3101
- // Sanitize HTML while allowing <mark> (highlight) and KaTeX class names.
3102
- // Override `clobberPrefix` with the instance-scoped value so every id
3103
- // and clobberable attribute is namespaced to this `<AIMarkdown>` instance.
3104
- [rehypeSanitize, { ...sanitizeSchema, clobberPrefix }],
3105
- // Normalize the auto-generated `<section data-footnotes>`: strip the
3106
- // sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
3107
- // single-doc rendering visually consistent with the cross-chunk aggregate
3108
- // footer (which builds the same shape from scratch).
3109
- rehypeFooterAdorn,
3110
- // Re-prefix intra-document hash hrefs so they match the ids that
3111
- // rehype-sanitize just clobbered. Must use the SAME prefix as the schema
3112
- // above — that's why both read from `clobberPrefix`.
3113
- [rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
3114
- rehypeKatex,
3115
- rehypeUnwrapImages
3116
- ],
3117
- [clobberPrefix]
3118
- );
3119
- const remarkRehypeOptions = useMemo4(
3120
- () => ({
3121
- allowDangerousHtml: true,
3122
- // Suppress mdast-util-to-hast's `user-content-` prefix on footnote
3123
- // ids/hrefs; rehype-sanitize will apply the same prefix downstream
3124
- // and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
3125
- // Without this, ids would end up double-prefixed
3126
- // (`user-content-user-content-fn-x`).
3127
- clobberPrefix: "",
3128
- handlers: {
3129
- // Inject definition-list HAST handlers when the extension is active.
3130
- ...enableDefinitionList ? defListHastHandlers : {}
3163
+ [extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
3164
+ );
3165
+ const rehypePlugins = useMemo4(
3166
+ () => [
3167
+ // Allow raw HTML through so rehype-sanitize can handle it.
3168
+ [rehypeRaw, { passThrough: [] }],
3169
+ // Sanitize HTML while allowing <mark> (highlight), KaTeX class names,
3170
+ // and any extra protocols the caller permitted via the `sanitizeSchema`
3171
+ // prop. Override `clobberPrefix` with the instance-scoped value so every
3172
+ // id and clobberable attribute is namespaced to this `<AIMarkdown>`
3173
+ // instance — the spread order is intentional: our prefix wins over any
3174
+ // caller-supplied prefix on the schema.
3175
+ [rehypeSanitize, { ...usedSanitizeSchema, clobberPrefix }],
3176
+ // Normalize the auto-generated `<section data-footnotes>`: strip the
3177
+ // sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
3178
+ // single-doc rendering visually consistent with the cross-chunk aggregate
3179
+ // footer (which builds the same shape from scratch).
3180
+ rehypeFooterAdorn,
3181
+ // Re-prefix intra-document hash hrefs so they match the ids that
3182
+ // rehype-sanitize just clobbered. Must use the SAME prefix as the schema
3183
+ // above that's why both read from `clobberPrefix`.
3184
+ [rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
3185
+ rehypeKatex,
3186
+ rehypeUnwrapImages
3187
+ ],
3188
+ [clobberPrefix, usedSanitizeSchema]
3189
+ );
3190
+ const remarkRehypeOptions = useMemo4(
3191
+ () => ({
3192
+ allowDangerousHtml: true,
3193
+ // Suppress mdast-util-to-hast's `user-content-` prefix on footnote
3194
+ // ids/hrefs; rehype-sanitize will apply the same prefix downstream
3195
+ // and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
3196
+ // Without this, ids would end up double-prefixed
3197
+ // (`user-content-user-content-fn-x`).
3198
+ clobberPrefix: "",
3199
+ handlers: {
3200
+ // Inject definition-list HAST handlers when the extension is active.
3201
+ ...enableDefinitionList ? defListHastHandlers : {}
3202
+ }
3203
+ }),
3204
+ [enableDefinitionList]
3205
+ );
3206
+ const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
3207
+ return /* @__PURE__ */ jsx6(
3208
+ Renderer,
3209
+ {
3210
+ content,
3211
+ usedComponents,
3212
+ remarkPlugins,
3213
+ rehypePlugins,
3214
+ remarkRehypeOptions,
3215
+ urlTransform
3131
3216
  }
3132
- }),
3133
- [enableDefinitionList]
3134
- );
3135
- const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
3136
- return /* @__PURE__ */ jsx6(
3137
- Renderer,
3138
- {
3139
- content,
3140
- usedComponents,
3141
- remarkPlugins,
3142
- rehypePlugins,
3143
- remarkRehypeOptions
3144
- }
3145
- );
3146
- });
3217
+ );
3218
+ }
3219
+ );
3147
3220
  AIMarkdownContent.displayName = "AIMarkdownContent";
3148
3221
  var MarkdownContent_default = AIMarkdownContent;
3149
3222
 
@@ -3579,6 +3652,28 @@ function useStableValue(value) {
3579
3652
  return stableValue;
3580
3653
  }
3581
3654
 
3655
+ // src/hooks/useReferenceFlipWarning.ts
3656
+ import { useRef as useRef4 } from "react";
3657
+ var __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV !== "production";
3658
+ var FLIP_THRESHOLD = 3;
3659
+ var WARN_COOLDOWN_MS = 5e3;
3660
+ function trackFlip(state, value, propName, now) {
3661
+ if (state.prev === value) return;
3662
+ state.flips++;
3663
+ state.prev = value;
3664
+ if (state.flips < FLIP_THRESHOLD) return;
3665
+ if (now - state.lastWarnAt < WARN_COOLDOWN_MS) return;
3666
+ state.lastWarnAt = now;
3667
+ console.warn(
3668
+ `[AIMarkdown] \`${propName}\` reference is changing on every render. Define it at module scope or wrap with useMemo/useCallback to avoid discarding the per-block memo cache on every parent re-render.`
3669
+ );
3670
+ }
3671
+ function useReferenceFlipWarning(value, propName) {
3672
+ const stateRef = useRef4({ prev: value, flips: 0, lastWarnAt: -Infinity });
3673
+ if (!__DEV__) return;
3674
+ trackFlip(stateRef.current, value, propName, Date.now());
3675
+ }
3676
+
3582
3677
  // src/components/typography/Default.tsx
3583
3678
  import { memo as memo3, useMemo as useMemo5 } from "react";
3584
3679
  import { jsx as jsx7 } from "react/jsx-runtime";
@@ -3593,6 +3688,286 @@ var DefaultTypography = memo3(({ children, fontSize, variant, colorScheme, style
3593
3688
  DefaultTypography.displayName = "DefaultTypography";
3594
3689
  var Default_default = DefaultTypography;
3595
3690
 
3691
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js
3692
+ function arrayEach(array, iteratee) {
3693
+ var index = -1, length = array == null ? 0 : array.length;
3694
+ while (++index < length) {
3695
+ if (iteratee(array[index], index, array) === false) {
3696
+ break;
3697
+ }
3698
+ }
3699
+ return array;
3700
+ }
3701
+ var arrayEach_default = arrayEach;
3702
+
3703
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js
3704
+ function baseAssign(object, source) {
3705
+ return object && copyObject_default(source, keys_default(source), object);
3706
+ }
3707
+ var baseAssign_default = baseAssign;
3708
+
3709
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js
3710
+ function baseAssignIn(object, source) {
3711
+ return object && copyObject_default(source, keysIn_default(source), object);
3712
+ }
3713
+ var baseAssignIn_default = baseAssignIn;
3714
+
3715
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js
3716
+ function copySymbols(source, object) {
3717
+ return copyObject_default(source, getSymbols_default(source), object);
3718
+ }
3719
+ var copySymbols_default = copySymbols;
3720
+
3721
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js
3722
+ var nativeGetSymbols2 = Object.getOwnPropertySymbols;
3723
+ var getSymbolsIn = !nativeGetSymbols2 ? stubArray_default : function(object) {
3724
+ var result = [];
3725
+ while (object) {
3726
+ arrayPush_default(result, getSymbols_default(object));
3727
+ object = getPrototype_default(object);
3728
+ }
3729
+ return result;
3730
+ };
3731
+ var getSymbolsIn_default = getSymbolsIn;
3732
+
3733
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js
3734
+ function copySymbolsIn(source, object) {
3735
+ return copyObject_default(source, getSymbolsIn_default(source), object);
3736
+ }
3737
+ var copySymbolsIn_default = copySymbolsIn;
3738
+
3739
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js
3740
+ function getAllKeysIn(object) {
3741
+ return baseGetAllKeys_default(object, keysIn_default, getSymbolsIn_default);
3742
+ }
3743
+ var getAllKeysIn_default = getAllKeysIn;
3744
+
3745
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js
3746
+ var objectProto16 = Object.prototype;
3747
+ var hasOwnProperty13 = objectProto16.hasOwnProperty;
3748
+ function initCloneArray(array) {
3749
+ var length = array.length, result = new array.constructor(length);
3750
+ if (length && typeof array[0] == "string" && hasOwnProperty13.call(array, "index")) {
3751
+ result.index = array.index;
3752
+ result.input = array.input;
3753
+ }
3754
+ return result;
3755
+ }
3756
+ var initCloneArray_default = initCloneArray;
3757
+
3758
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js
3759
+ function cloneDataView(dataView, isDeep) {
3760
+ var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
3761
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
3762
+ }
3763
+ var cloneDataView_default = cloneDataView;
3764
+
3765
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js
3766
+ var reFlags = /\w*$/;
3767
+ function cloneRegExp(regexp) {
3768
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
3769
+ result.lastIndex = regexp.lastIndex;
3770
+ return result;
3771
+ }
3772
+ var cloneRegExp_default = cloneRegExp;
3773
+
3774
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js
3775
+ var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
3776
+ var symbolValueOf2 = symbolProto2 ? symbolProto2.valueOf : void 0;
3777
+ function cloneSymbol(symbol) {
3778
+ return symbolValueOf2 ? Object(symbolValueOf2.call(symbol)) : {};
3779
+ }
3780
+ var cloneSymbol_default = cloneSymbol;
3781
+
3782
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js
3783
+ var boolTag3 = "[object Boolean]";
3784
+ var dateTag3 = "[object Date]";
3785
+ var mapTag4 = "[object Map]";
3786
+ var numberTag3 = "[object Number]";
3787
+ var regexpTag3 = "[object RegExp]";
3788
+ var setTag4 = "[object Set]";
3789
+ var stringTag3 = "[object String]";
3790
+ var symbolTag2 = "[object Symbol]";
3791
+ var arrayBufferTag3 = "[object ArrayBuffer]";
3792
+ var dataViewTag4 = "[object DataView]";
3793
+ var float32Tag2 = "[object Float32Array]";
3794
+ var float64Tag2 = "[object Float64Array]";
3795
+ var int8Tag2 = "[object Int8Array]";
3796
+ var int16Tag2 = "[object Int16Array]";
3797
+ var int32Tag2 = "[object Int32Array]";
3798
+ var uint8Tag2 = "[object Uint8Array]";
3799
+ var uint8ClampedTag2 = "[object Uint8ClampedArray]";
3800
+ var uint16Tag2 = "[object Uint16Array]";
3801
+ var uint32Tag2 = "[object Uint32Array]";
3802
+ function initCloneByTag(object, tag, isDeep) {
3803
+ var Ctor = object.constructor;
3804
+ switch (tag) {
3805
+ case arrayBufferTag3:
3806
+ return cloneArrayBuffer_default(object);
3807
+ case boolTag3:
3808
+ case dateTag3:
3809
+ return new Ctor(+object);
3810
+ case dataViewTag4:
3811
+ return cloneDataView_default(object, isDeep);
3812
+ case float32Tag2:
3813
+ case float64Tag2:
3814
+ case int8Tag2:
3815
+ case int16Tag2:
3816
+ case int32Tag2:
3817
+ case uint8Tag2:
3818
+ case uint8ClampedTag2:
3819
+ case uint16Tag2:
3820
+ case uint32Tag2:
3821
+ return cloneTypedArray_default(object, isDeep);
3822
+ case mapTag4:
3823
+ return new Ctor();
3824
+ case numberTag3:
3825
+ case stringTag3:
3826
+ return new Ctor(object);
3827
+ case regexpTag3:
3828
+ return cloneRegExp_default(object);
3829
+ case setTag4:
3830
+ return new Ctor();
3831
+ case symbolTag2:
3832
+ return cloneSymbol_default(object);
3833
+ }
3834
+ }
3835
+ var initCloneByTag_default = initCloneByTag;
3836
+
3837
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js
3838
+ var mapTag5 = "[object Map]";
3839
+ function baseIsMap(value) {
3840
+ return isObjectLike_default(value) && getTag_default(value) == mapTag5;
3841
+ }
3842
+ var baseIsMap_default = baseIsMap;
3843
+
3844
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isMap.js
3845
+ var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
3846
+ var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
3847
+ var isMap_default = isMap;
3848
+
3849
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js
3850
+ var setTag5 = "[object Set]";
3851
+ function baseIsSet(value) {
3852
+ return isObjectLike_default(value) && getTag_default(value) == setTag5;
3853
+ }
3854
+ var baseIsSet_default = baseIsSet;
3855
+
3856
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isSet.js
3857
+ var nodeIsSet = nodeUtil_default && nodeUtil_default.isSet;
3858
+ var isSet = nodeIsSet ? baseUnary_default(nodeIsSet) : baseIsSet_default;
3859
+ var isSet_default = isSet;
3860
+
3861
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js
3862
+ var CLONE_DEEP_FLAG = 1;
3863
+ var CLONE_FLAT_FLAG = 2;
3864
+ var CLONE_SYMBOLS_FLAG = 4;
3865
+ var argsTag4 = "[object Arguments]";
3866
+ var arrayTag3 = "[object Array]";
3867
+ var boolTag4 = "[object Boolean]";
3868
+ var dateTag4 = "[object Date]";
3869
+ var errorTag3 = "[object Error]";
3870
+ var funcTag3 = "[object Function]";
3871
+ var genTag2 = "[object GeneratorFunction]";
3872
+ var mapTag6 = "[object Map]";
3873
+ var numberTag4 = "[object Number]";
3874
+ var objectTag5 = "[object Object]";
3875
+ var regexpTag4 = "[object RegExp]";
3876
+ var setTag6 = "[object Set]";
3877
+ var stringTag4 = "[object String]";
3878
+ var symbolTag3 = "[object Symbol]";
3879
+ var weakMapTag3 = "[object WeakMap]";
3880
+ var arrayBufferTag4 = "[object ArrayBuffer]";
3881
+ var dataViewTag5 = "[object DataView]";
3882
+ var float32Tag3 = "[object Float32Array]";
3883
+ var float64Tag3 = "[object Float64Array]";
3884
+ var int8Tag3 = "[object Int8Array]";
3885
+ var int16Tag3 = "[object Int16Array]";
3886
+ var int32Tag3 = "[object Int32Array]";
3887
+ var uint8Tag3 = "[object Uint8Array]";
3888
+ var uint8ClampedTag3 = "[object Uint8ClampedArray]";
3889
+ var uint16Tag3 = "[object Uint16Array]";
3890
+ var uint32Tag3 = "[object Uint32Array]";
3891
+ var cloneableTags = {};
3892
+ cloneableTags[argsTag4] = cloneableTags[arrayTag3] = cloneableTags[arrayBufferTag4] = cloneableTags[dataViewTag5] = cloneableTags[boolTag4] = cloneableTags[dateTag4] = cloneableTags[float32Tag3] = cloneableTags[float64Tag3] = cloneableTags[int8Tag3] = cloneableTags[int16Tag3] = cloneableTags[int32Tag3] = cloneableTags[mapTag6] = cloneableTags[numberTag4] = cloneableTags[objectTag5] = cloneableTags[regexpTag4] = cloneableTags[setTag6] = cloneableTags[stringTag4] = cloneableTags[symbolTag3] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
3893
+ cloneableTags[errorTag3] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
3894
+ function baseClone(value, bitmask, customizer, key, object, stack) {
3895
+ var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
3896
+ if (customizer) {
3897
+ result = object ? customizer(value, key, object, stack) : customizer(value);
3898
+ }
3899
+ if (result !== void 0) {
3900
+ return result;
3901
+ }
3902
+ if (!isObject_default(value)) {
3903
+ return value;
3904
+ }
3905
+ var isArr = isArray_default(value);
3906
+ if (isArr) {
3907
+ result = initCloneArray_default(value);
3908
+ if (!isDeep) {
3909
+ return copyArray_default(value, result);
3910
+ }
3911
+ } else {
3912
+ var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
3913
+ if (isBuffer_default(value)) {
3914
+ return cloneBuffer_default(value, isDeep);
3915
+ }
3916
+ if (tag == objectTag5 || tag == argsTag4 || isFunc && !object) {
3917
+ result = isFlat || isFunc ? {} : initCloneObject_default(value);
3918
+ if (!isDeep) {
3919
+ return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
3920
+ }
3921
+ } else {
3922
+ if (!cloneableTags[tag]) {
3923
+ return object ? value : {};
3924
+ }
3925
+ result = initCloneByTag_default(value, tag, isDeep);
3926
+ }
3927
+ }
3928
+ stack || (stack = new Stack_default());
3929
+ var stacked = stack.get(value);
3930
+ if (stacked) {
3931
+ return stacked;
3932
+ }
3933
+ stack.set(value, result);
3934
+ if (isSet_default(value)) {
3935
+ value.forEach(function(subValue) {
3936
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
3937
+ });
3938
+ } else if (isMap_default(value)) {
3939
+ value.forEach(function(subValue, key2) {
3940
+ result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
3941
+ });
3942
+ }
3943
+ var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
3944
+ var props = isArr ? void 0 : keysFunc(value);
3945
+ arrayEach_default(props || value, function(subValue, key2) {
3946
+ if (props) {
3947
+ key2 = subValue;
3948
+ subValue = value[key2];
3949
+ }
3950
+ assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
3951
+ });
3952
+ return result;
3953
+ }
3954
+ var baseClone_default = baseClone;
3955
+
3956
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js
3957
+ var CLONE_DEEP_FLAG2 = 1;
3958
+ var CLONE_SYMBOLS_FLAG2 = 4;
3959
+ function cloneDeep(value) {
3960
+ return baseClone_default(value, CLONE_DEEP_FLAG2 | CLONE_SYMBOLS_FLAG2);
3961
+ }
3962
+ var cloneDeep_default = cloneDeep;
3963
+
3964
+ // src/components/extendSanitizeSchema.ts
3965
+ function extendSanitizeSchema(modifier) {
3966
+ const draft = cloneDeep_default(sanitizeSchema);
3967
+ const result = modifier(draft);
3968
+ return result ?? draft;
3969
+ }
3970
+
3596
3971
  // src/index.tsx
3597
3972
  import { jsx as jsx8 } from "react/jsx-runtime";
3598
3973
  var AIMarkdownComponent = ({
@@ -3608,15 +3983,20 @@ var AIMarkdownComponent = ({
3608
3983
  ExtraStyles,
3609
3984
  variant = "default",
3610
3985
  colorScheme = "light",
3611
- documentId
3986
+ documentId,
3987
+ urlTransform,
3988
+ sanitizeSchema: sanitizeSchema2
3612
3989
  }) => {
3613
3990
  const usedFontSize = fontSize === void 0 ? "0.9375rem" : typeof fontSize === "number" ? `${fontSize}px` : fontSize;
3614
3991
  const generatedId = useId3();
3615
3992
  const usedDocumentId = documentId && documentId.length > 0 ? documentId : generatedId;
3993
+ useReferenceFlipWarning(urlTransform, "urlTransform");
3994
+ useReferenceFlipWarning(sanitizeSchema2, "sanitizeSchema");
3616
3995
  const stableDefaultConfig = useStableValue(defaultConfig);
3617
3996
  const stableConfig = useStableValue(config);
3618
3997
  const stablePreprocessors = useStableValue(contentPreprocessors);
3619
3998
  const stableCustomComponents = useStableValue(customComponents);
3999
+ const stableSanitizeSchema = useStableValue(sanitizeSchema2);
3620
4000
  const usedContent = useMemo6(
3621
4001
  () => content ? preprocessAIMDContent(content, stablePreprocessors) : content,
3622
4002
  [content, stablePreprocessors]
@@ -3639,7 +4019,23 @@ var AIMarkdownComponent = ({
3639
4019
  variant,
3640
4020
  colorScheme,
3641
4021
  style: typographyStyle,
3642
- children: ExtraStyles ? /* @__PURE__ */ jsx8(ExtraStyles, { children: /* @__PURE__ */ jsx8(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents }) }) : /* @__PURE__ */ jsx8(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents })
4022
+ children: ExtraStyles ? /* @__PURE__ */ jsx8(ExtraStyles, { children: /* @__PURE__ */ jsx8(
4023
+ MarkdownContent_default,
4024
+ {
4025
+ content: usedContent,
4026
+ customComponents: stableCustomComponents,
4027
+ urlTransform: urlTransform ?? void 0,
4028
+ sanitizeSchema: stableSanitizeSchema
4029
+ }
4030
+ ) }) : /* @__PURE__ */ jsx8(
4031
+ MarkdownContent_default,
4032
+ {
4033
+ content: usedContent,
4034
+ customComponents: stableCustomComponents,
4035
+ urlTransform: urlTransform ?? void 0,
4036
+ sanitizeSchema: stableSanitizeSchema
4037
+ }
4038
+ )
3643
4039
  }
3644
4040
  )
3645
4041
  }
@@ -3654,6 +4050,9 @@ export {
3654
4050
  AIMarkdownRenderExtraSyntax,
3655
4051
  index_default as default,
3656
4052
  defaultAIMarkdownRenderConfig,
4053
+ defaultUrlTransform,
4054
+ extendSanitizeSchema,
4055
+ sanitizeSchema,
3657
4056
  useAIMarkdownMetadata,
3658
4057
  useAIMarkdownRenderState,
3659
4058
  useDocumentRegistry,