@ai-react-markdown/core 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -54
- package/dist/index.cjs +2185 -2080
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -58
- package/dist/index.d.ts +82 -58
- package/dist/index.js +586 -480
- package/dist/index.js.map +1 -1
- package/package.json +11 -3
package/dist/index.cjs
CHANGED
|
@@ -38,14 +38,13 @@ __export(index_exports, {
|
|
|
38
38
|
defaultAIMarkdownRenderConfig: () => defaultAIMarkdownRenderConfig,
|
|
39
39
|
defaultUrlTransform: () => defaultUrlTransform,
|
|
40
40
|
extendSanitizeSchema: () => extendSanitizeSchema,
|
|
41
|
-
sanitizeSchema: () => sanitizeSchema,
|
|
42
41
|
useAIMarkdownMetadata: () => useAIMarkdownMetadata,
|
|
43
42
|
useAIMarkdownRenderState: () => useAIMarkdownRenderState,
|
|
44
43
|
useDocumentRegistry: () => useDocumentRegistry,
|
|
45
44
|
useStableValue: () => useStableValue
|
|
46
45
|
});
|
|
47
46
|
module.exports = __toCommonJS(index_exports);
|
|
48
|
-
var
|
|
47
|
+
var import_react12 = require("react");
|
|
49
48
|
|
|
50
49
|
// src/context.tsx
|
|
51
50
|
var import_react = require("react");
|
|
@@ -1557,7 +1556,7 @@ function preprocessAIMDContent(content, extraPreprocessors = defaultExtraPreproc
|
|
|
1557
1556
|
}
|
|
1558
1557
|
|
|
1559
1558
|
// src/components/MarkdownContent.tsx
|
|
1560
|
-
var
|
|
1559
|
+
var import_react8 = require("react");
|
|
1561
1560
|
|
|
1562
1561
|
// src/components/markdown/Markdown.tsx
|
|
1563
1562
|
var import_devlop2 = require("devlop");
|
|
@@ -1606,15 +1605,17 @@ function buildTransform(ctx) {
|
|
|
1606
1605
|
if (node.type === "element") {
|
|
1607
1606
|
const element = node;
|
|
1608
1607
|
let key;
|
|
1608
|
+
const properties = element.properties ?? {};
|
|
1609
1609
|
for (key in import_html_url_attributes.urlAttributes) {
|
|
1610
|
-
if (Object.hasOwn(import_html_url_attributes.urlAttributes, key) && Object.hasOwn(
|
|
1611
|
-
const value =
|
|
1610
|
+
if (Object.hasOwn(import_html_url_attributes.urlAttributes, key) && Object.hasOwn(properties, key)) {
|
|
1611
|
+
const value = properties[key];
|
|
1612
1612
|
const test = import_html_url_attributes.urlAttributes[key];
|
|
1613
1613
|
if (test === null || test.includes(element.tagName)) {
|
|
1614
|
-
|
|
1614
|
+
properties[key] = ctx.urlTransform(String(value || ""), key, element);
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
1617
|
}
|
|
1618
|
+
element.properties = properties;
|
|
1618
1619
|
}
|
|
1619
1620
|
if (node.type === "element") {
|
|
1620
1621
|
const element = node;
|
|
@@ -1747,2263 +1748,2368 @@ var import_rehype_raw = __toESM(require("rehype-raw"), 1);
|
|
|
1747
1748
|
var import_rehype_unwrap_images = __toESM(require("rehype-unwrap-images"), 1);
|
|
1748
1749
|
var import_rehype_sanitize2 = __toESM(require("rehype-sanitize"), 1);
|
|
1749
1750
|
|
|
1750
|
-
//
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
if (idx === -1) {
|
|
1758
|
-
return [...entries, ["className", ...extraClassNames]];
|
|
1751
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js
|
|
1752
|
+
function arrayEach(array, iteratee) {
|
|
1753
|
+
var index = -1, length = array == null ? 0 : array.length;
|
|
1754
|
+
while (++index < length) {
|
|
1755
|
+
if (iteratee(array[index], index, array) === false) {
|
|
1756
|
+
break;
|
|
1757
|
+
}
|
|
1759
1758
|
}
|
|
1760
|
-
|
|
1761
|
-
const merged = typeof current === "string" ? ["className", ...extraClassNames] : [...current, ...extraClassNames];
|
|
1762
|
-
entries[idx] = merged;
|
|
1763
|
-
return entries;
|
|
1759
|
+
return array;
|
|
1764
1760
|
}
|
|
1765
|
-
var
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1761
|
+
var arrayEach_default = arrayEach;
|
|
1762
|
+
|
|
1763
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
|
|
1764
|
+
var nativeKeys = overArg_default(Object.keys, Object);
|
|
1765
|
+
var nativeKeys_default = nativeKeys;
|
|
1766
|
+
|
|
1767
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
|
|
1768
|
+
var objectProto12 = Object.prototype;
|
|
1769
|
+
var hasOwnProperty10 = objectProto12.hasOwnProperty;
|
|
1770
|
+
function baseKeys(object) {
|
|
1771
|
+
if (!isPrototype_default(object)) {
|
|
1772
|
+
return nativeKeys_default(object);
|
|
1775
1773
|
}
|
|
1776
|
-
|
|
1774
|
+
var result = [];
|
|
1775
|
+
for (var key in Object(object)) {
|
|
1776
|
+
if (hasOwnProperty10.call(object, key) && key != "constructor") {
|
|
1777
|
+
result.push(key);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
return result;
|
|
1781
|
+
}
|
|
1782
|
+
var baseKeys_default = baseKeys;
|
|
1777
1783
|
|
|
1778
|
-
//
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
const hashPrefix = "#" + prefix;
|
|
1784
|
-
return (tree) => {
|
|
1785
|
-
(0, import_unist_util_visit2.visit)(tree, "element", (node) => {
|
|
1786
|
-
if (node.tagName !== "a") return;
|
|
1787
|
-
const href = node.properties?.href;
|
|
1788
|
-
if (typeof href !== "string" || !href.startsWith("#")) return;
|
|
1789
|
-
if (href.startsWith(hashPrefix)) return;
|
|
1790
|
-
node.properties.href = hashPrefix + href.slice(1);
|
|
1791
|
-
});
|
|
1792
|
-
};
|
|
1793
|
-
};
|
|
1794
|
-
var rehypeRebaseHashLinks_default = rehypeRebaseHashLinks;
|
|
1784
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
|
|
1785
|
+
function keys(object) {
|
|
1786
|
+
return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
|
|
1787
|
+
}
|
|
1788
|
+
var keys_default = keys;
|
|
1795
1789
|
|
|
1796
|
-
//
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
function isFootnoteLabelH2(node) {
|
|
1800
|
-
if (node.type !== "element") return false;
|
|
1801
|
-
const el = node;
|
|
1802
|
-
if (el.tagName !== "h2") return false;
|
|
1803
|
-
const id = el.properties?.id;
|
|
1804
|
-
return typeof id === "string" && FOOTNOTE_LABEL_ID_RE.test(id);
|
|
1790
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js
|
|
1791
|
+
function baseAssign(object, source) {
|
|
1792
|
+
return object && copyObject_default(source, keys_default(source), object);
|
|
1805
1793
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1794
|
+
var baseAssign_default = baseAssign;
|
|
1795
|
+
|
|
1796
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js
|
|
1797
|
+
function baseAssignIn(object, source) {
|
|
1798
|
+
return object && copyObject_default(source, keysIn_default(source), object);
|
|
1809
1799
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
children: []
|
|
1823
|
-
};
|
|
1824
|
-
filtered.unshift(hr);
|
|
1825
|
-
}
|
|
1826
|
-
el.children = filtered;
|
|
1827
|
-
if (!el.properties) el.properties = {};
|
|
1828
|
-
if (!("ariaLabel" in el.properties)) {
|
|
1829
|
-
el.properties.ariaLabel = "Footnotes";
|
|
1830
|
-
}
|
|
1831
|
-
});
|
|
1832
|
-
};
|
|
1800
|
+
var baseAssignIn_default = baseAssignIn;
|
|
1801
|
+
|
|
1802
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
|
|
1803
|
+
function arrayFilter(array, predicate) {
|
|
1804
|
+
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
|
|
1805
|
+
while (++index < length) {
|
|
1806
|
+
var value = array[index];
|
|
1807
|
+
if (predicate(value, index, array)) {
|
|
1808
|
+
result[resIndex++] = value;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
return result;
|
|
1833
1812
|
}
|
|
1813
|
+
var arrayFilter_default = arrayFilter;
|
|
1834
1814
|
|
|
1835
|
-
//
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
var
|
|
1840
|
-
var import_remark_gfm2 = __toESM(require("remark-gfm"), 1);
|
|
1841
|
-
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1842
|
-
var import_remark_definition_list = require("remark-definition-list");
|
|
1843
|
-
var import_remark_mark_highlight = require("remark-mark-highlight");
|
|
1844
|
-
var import_remark_squeeze_paragraphs = __toESM(require("remark-squeeze-paragraphs"), 1);
|
|
1845
|
-
var import_remark_smartypants = __toESM(require("remark-smartypants"), 1);
|
|
1846
|
-
var import_remark_pangu = __toESM(require("remark-pangu"), 1);
|
|
1847
|
-
var import_remark_remove_comments = __toESM(require("remark-remove-comments"), 1);
|
|
1815
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
|
|
1816
|
+
function stubArray() {
|
|
1817
|
+
return [];
|
|
1818
|
+
}
|
|
1819
|
+
var stubArray_default = stubArray;
|
|
1848
1820
|
|
|
1849
|
-
//
|
|
1850
|
-
var
|
|
1821
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
|
|
1822
|
+
var objectProto13 = Object.prototype;
|
|
1823
|
+
var propertyIsEnumerable2 = objectProto13.propertyIsEnumerable;
|
|
1824
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
1825
|
+
var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
|
|
1826
|
+
if (object == null) {
|
|
1827
|
+
return [];
|
|
1828
|
+
}
|
|
1829
|
+
object = Object(object);
|
|
1830
|
+
return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
|
|
1831
|
+
return propertyIsEnumerable2.call(object, symbol);
|
|
1832
|
+
});
|
|
1833
|
+
};
|
|
1834
|
+
var getSymbols_default = getSymbols;
|
|
1851
1835
|
|
|
1852
|
-
//
|
|
1853
|
-
function
|
|
1854
|
-
return
|
|
1836
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js
|
|
1837
|
+
function copySymbols(source, object) {
|
|
1838
|
+
return copyObject_default(source, getSymbols_default(source), object);
|
|
1855
1839
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1840
|
+
var copySymbols_default = copySymbols;
|
|
1841
|
+
|
|
1842
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
|
|
1843
|
+
function arrayPush(array, values) {
|
|
1844
|
+
var index = -1, length = values.length, offset = array.length;
|
|
1845
|
+
while (++index < length) {
|
|
1846
|
+
array[offset + index] = values[index];
|
|
1847
|
+
}
|
|
1848
|
+
return array;
|
|
1858
1849
|
}
|
|
1850
|
+
var arrayPush_default = arrayPush;
|
|
1859
1851
|
|
|
1860
|
-
//
|
|
1861
|
-
var
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1852
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js
|
|
1853
|
+
var nativeGetSymbols2 = Object.getOwnPropertySymbols;
|
|
1854
|
+
var getSymbolsIn = !nativeGetSymbols2 ? stubArray_default : function(object) {
|
|
1855
|
+
var result = [];
|
|
1856
|
+
while (object) {
|
|
1857
|
+
arrayPush_default(result, getSymbols_default(object));
|
|
1858
|
+
object = getPrototype_default(object);
|
|
1859
|
+
}
|
|
1860
|
+
return result;
|
|
1861
|
+
};
|
|
1862
|
+
var getSymbolsIn_default = getSymbolsIn;
|
|
1863
|
+
|
|
1864
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js
|
|
1865
|
+
function copySymbolsIn(source, object) {
|
|
1866
|
+
return copyObject_default(source, getSymbolsIn_default(source), object);
|
|
1871
1867
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1868
|
+
var copySymbolsIn_default = copySymbolsIn;
|
|
1869
|
+
|
|
1870
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
|
|
1871
|
+
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
1872
|
+
var result = keysFunc(object);
|
|
1873
|
+
return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
|
|
1875
1874
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1875
|
+
var baseGetAllKeys_default = baseGetAllKeys;
|
|
1876
|
+
|
|
1877
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
|
|
1878
|
+
function getAllKeys(object) {
|
|
1879
|
+
return baseGetAllKeys_default(object, keys_default, getSymbols_default);
|
|
1880
1880
|
}
|
|
1881
|
-
|
|
1882
|
-
|
|
1881
|
+
var getAllKeys_default = getAllKeys;
|
|
1882
|
+
|
|
1883
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js
|
|
1884
|
+
function getAllKeysIn(object) {
|
|
1885
|
+
return baseGetAllKeys_default(object, keysIn_default, getSymbolsIn_default);
|
|
1883
1886
|
}
|
|
1884
|
-
var
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
const plan = [];
|
|
1931
|
-
const blocks = [];
|
|
1932
|
-
const blockHasts = [];
|
|
1933
|
-
let synthetic;
|
|
1934
|
-
for (let i = 0; i < hast.children.length; i++) {
|
|
1935
|
-
const hastChild = hast.children[i];
|
|
1936
|
-
if (hastChild.type !== "element") {
|
|
1937
|
-
const off = hastChild.position?.start.offset;
|
|
1938
|
-
const reactKey = off !== void 0 ? `inline-${off}` : `inline-i${i}`;
|
|
1939
|
-
plan.push({ kind: "inline", el: hastChild, reactKey });
|
|
1940
|
-
continue;
|
|
1941
|
-
}
|
|
1942
|
-
const el = hastChild;
|
|
1943
|
-
if (isFootnoteSection(el)) {
|
|
1944
|
-
synthetic = el;
|
|
1945
|
-
plan.push({ kind: "synthetic", el, reactKey: FOOTNOTE_SECTION_KEY });
|
|
1946
|
-
continue;
|
|
1947
|
-
}
|
|
1948
|
-
const hastOffset = el.position?.start.offset;
|
|
1949
|
-
if (hastOffset === void 0) {
|
|
1950
|
-
plan.push({ kind: "inline", el, reactKey: `inline-i${i}` });
|
|
1951
|
-
continue;
|
|
1952
|
-
}
|
|
1953
|
-
let mdastNode = mdastByOffset.get(hastOffset);
|
|
1954
|
-
if (!mdastNode) {
|
|
1955
|
-
mdastNode = findContainingMdast(hastOffset);
|
|
1956
|
-
}
|
|
1957
|
-
if (!mdastNode) {
|
|
1958
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1959
|
-
throw new Error(
|
|
1960
|
-
`block-memo: hast block at offset ${hastOffset} has no mdast counterpart. A rehype plugin may have synthesized positions outside source. tagName=${el.tagName}`
|
|
1961
|
-
);
|
|
1887
|
+
var getAllKeysIn_default = getAllKeysIn;
|
|
1888
|
+
|
|
1889
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
|
|
1890
|
+
var DataView = getNative_default(root_default, "DataView");
|
|
1891
|
+
var DataView_default = DataView;
|
|
1892
|
+
|
|
1893
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
|
|
1894
|
+
var Promise2 = getNative_default(root_default, "Promise");
|
|
1895
|
+
var Promise_default = Promise2;
|
|
1896
|
+
|
|
1897
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
|
|
1898
|
+
var Set2 = getNative_default(root_default, "Set");
|
|
1899
|
+
var Set_default = Set2;
|
|
1900
|
+
|
|
1901
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
|
|
1902
|
+
var WeakMap = getNative_default(root_default, "WeakMap");
|
|
1903
|
+
var WeakMap_default = WeakMap;
|
|
1904
|
+
|
|
1905
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
|
|
1906
|
+
var mapTag2 = "[object Map]";
|
|
1907
|
+
var objectTag3 = "[object Object]";
|
|
1908
|
+
var promiseTag = "[object Promise]";
|
|
1909
|
+
var setTag2 = "[object Set]";
|
|
1910
|
+
var weakMapTag2 = "[object WeakMap]";
|
|
1911
|
+
var dataViewTag2 = "[object DataView]";
|
|
1912
|
+
var dataViewCtorString = toSource_default(DataView_default);
|
|
1913
|
+
var mapCtorString = toSource_default(Map_default);
|
|
1914
|
+
var promiseCtorString = toSource_default(Promise_default);
|
|
1915
|
+
var setCtorString = toSource_default(Set_default);
|
|
1916
|
+
var weakMapCtorString = toSource_default(WeakMap_default);
|
|
1917
|
+
var getTag = baseGetTag_default;
|
|
1918
|
+
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) {
|
|
1919
|
+
getTag = function(value) {
|
|
1920
|
+
var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
|
|
1921
|
+
if (ctorString) {
|
|
1922
|
+
switch (ctorString) {
|
|
1923
|
+
case dataViewCtorString:
|
|
1924
|
+
return dataViewTag2;
|
|
1925
|
+
case mapCtorString:
|
|
1926
|
+
return mapTag2;
|
|
1927
|
+
case promiseCtorString:
|
|
1928
|
+
return promiseTag;
|
|
1929
|
+
case setCtorString:
|
|
1930
|
+
return setTag2;
|
|
1931
|
+
case weakMapCtorString:
|
|
1932
|
+
return weakMapTag2;
|
|
1962
1933
|
}
|
|
1963
|
-
plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
|
|
1964
|
-
continue;
|
|
1965
|
-
}
|
|
1966
|
-
if (mdastNode.type === "footnoteDefinition") {
|
|
1967
|
-
plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
|
|
1968
|
-
continue;
|
|
1969
|
-
}
|
|
1970
|
-
let hasReference = false;
|
|
1971
|
-
const footnoteRefLabels = [];
|
|
1972
|
-
const linkRefLabels = [];
|
|
1973
|
-
const imageRefLabels = [];
|
|
1974
|
-
const footnoteDefLabels = [];
|
|
1975
|
-
(0, import_unist_util_visit4.visit)(mdastNode, (n) => {
|
|
1976
|
-
if (!TAINT_TYPES.has(n.type)) return;
|
|
1977
|
-
hasReference = true;
|
|
1978
|
-
const id = "identifier" in n ? normalizeId(String(n.identifier)) : null;
|
|
1979
|
-
if (id === null) return;
|
|
1980
|
-
if (n.type === "footnoteReference") footnoteRefLabels.push(id);
|
|
1981
|
-
else if (n.type === "linkReference") linkRefLabels.push(id);
|
|
1982
|
-
else if (n.type === "imageReference") imageRefLabels.push(id);
|
|
1983
|
-
else if (n.type === "footnoteDefinition") footnoteDefLabels.push(id);
|
|
1984
|
-
});
|
|
1985
|
-
const mdastPos = mdastNode.position;
|
|
1986
|
-
if (!mdastPos || mdastPos.start.offset === void 0 || mdastPos.end.offset === void 0) {
|
|
1987
|
-
continue;
|
|
1988
1934
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
startOffset: mdastPos.start.offset,
|
|
1992
|
-
endOffset: mdastPos.end.offset,
|
|
1993
|
-
startLine: mdastPos.start.line,
|
|
1994
|
-
startColumn: mdastPos.start.column,
|
|
1995
|
-
hasReference,
|
|
1996
|
-
...hasReference ? {
|
|
1997
|
-
taintLabels: { footnoteRefLabels, linkRefLabels, imageRefLabels, footnoteDefLabels }
|
|
1998
|
-
} : {}
|
|
1999
|
-
};
|
|
2000
|
-
blocks.push(info);
|
|
2001
|
-
blockHasts.push(el);
|
|
2002
|
-
plan.push({ kind: "block", el, info, reactKey: `block-${hastOffset}` });
|
|
2003
|
-
}
|
|
2004
|
-
return { plan, globalCtx, blocks, blockHasts, synthetic };
|
|
2005
|
-
}
|
|
2006
|
-
function computeBlockFingerprint(taintLabels, registry, thisChunkSym, clobberPrefix) {
|
|
2007
|
-
const parts = [clobberPrefix];
|
|
2008
|
-
for (const label of taintLabels.footnoteRefLabels) {
|
|
2009
|
-
parts.push(`fn:${label}=${registry.globalNumber(label) ?? "null"}`);
|
|
2010
|
-
}
|
|
2011
|
-
for (const label of taintLabels.linkRefLabels) {
|
|
2012
|
-
const def = registry.resolveLinkDef(label);
|
|
2013
|
-
parts.push(`lr:${label}=${def?.url ?? "null"}|${def?.title ?? ""}`);
|
|
2014
|
-
}
|
|
2015
|
-
for (const label of taintLabels.imageRefLabels) {
|
|
2016
|
-
const def = registry.resolveLinkDef(label);
|
|
2017
|
-
parts.push(`ir:${label}=${def?.url ?? "null"}|${def?.title ?? ""}`);
|
|
2018
|
-
}
|
|
2019
|
-
for (const label of taintLabels.footnoteDefLabels) {
|
|
2020
|
-
const isCanonical = registry.canonicalFootnoteFor(label) === thisChunkSym ? 1 : 0;
|
|
2021
|
-
parts.push(`fd:${label}=${isCanonical}/${registry.getRefsForLabel(label)}`);
|
|
2022
|
-
}
|
|
2023
|
-
return parts.join("|");
|
|
1935
|
+
return result;
|
|
1936
|
+
};
|
|
2024
1937
|
}
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
for (const item of plan) {
|
|
2039
|
-
if (item.kind === "inline") {
|
|
2040
|
-
rendered.push({
|
|
2041
|
-
node: renderHastSubtree(item.el, postOptions),
|
|
2042
|
-
reactKey: item.reactKey
|
|
2043
|
-
});
|
|
2044
|
-
continue;
|
|
2045
|
-
}
|
|
2046
|
-
if (item.kind === "synthetic") {
|
|
2047
|
-
if (postOptions.registry && postOptions.thisChunkSymbol) {
|
|
2048
|
-
continue;
|
|
2049
|
-
}
|
|
2050
|
-
const cached = prev.footnoteSection;
|
|
2051
|
-
let node;
|
|
2052
|
-
if (cached && cached.ctx === globalCtx) {
|
|
2053
|
-
node = cached.node;
|
|
2054
|
-
} else {
|
|
2055
|
-
node = renderHastSubtree(item.el, postOptions);
|
|
2056
|
-
}
|
|
2057
|
-
next.footnoteSection = { ctx: globalCtx, node };
|
|
2058
|
-
rendered.push({ node, reactKey: item.reactKey });
|
|
2059
|
-
continue;
|
|
2060
|
-
}
|
|
2061
|
-
const block = item.info;
|
|
2062
|
-
let bucket = next.blocks.get(block.raw);
|
|
2063
|
-
if (!bucket) {
|
|
2064
|
-
bucket = [];
|
|
2065
|
-
next.blocks.set(block.raw, bucket);
|
|
2066
|
-
}
|
|
2067
|
-
const occ = bucket.length;
|
|
2068
|
-
if (block.hasReference) {
|
|
2069
|
-
const useFingerprint = postOptions.registry && block.taintLabels && postOptions.thisChunkSymbol && postOptions.clobberPrefix !== void 0;
|
|
2070
|
-
const blockCtx = useFingerprint ? computeBlockFingerprint(
|
|
2071
|
-
block.taintLabels,
|
|
2072
|
-
postOptions.registry,
|
|
2073
|
-
postOptions.thisChunkSymbol,
|
|
2074
|
-
postOptions.clobberPrefix
|
|
2075
|
-
) : globalCtx;
|
|
2076
|
-
const entry = prev.blocks.get(block.raw)?.[occ];
|
|
2077
|
-
const valid = entry !== void 0 && entry.ctx === blockCtx && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
|
|
2078
|
-
let node;
|
|
2079
|
-
if (valid) {
|
|
2080
|
-
node = entry.node;
|
|
2081
|
-
} else {
|
|
2082
|
-
node = renderHastSubtree(item.el, postOptions);
|
|
2083
|
-
}
|
|
2084
|
-
bucket.push({
|
|
2085
|
-
node,
|
|
2086
|
-
ctx: blockCtx,
|
|
2087
|
-
startOffset: block.startOffset,
|
|
2088
|
-
startLine: block.startLine,
|
|
2089
|
-
startColumn: block.startColumn
|
|
2090
|
-
});
|
|
2091
|
-
rendered.push({ node, reactKey: item.reactKey });
|
|
2092
|
-
continue;
|
|
2093
|
-
}
|
|
2094
|
-
{
|
|
2095
|
-
const entry = prev.blocks.get(block.raw)?.[occ];
|
|
2096
|
-
const valid = entry !== void 0 && entry.ctx === "" && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
|
|
2097
|
-
const node = valid ? entry.node : renderHastSubtree(item.el, postOptions);
|
|
2098
|
-
bucket.push({
|
|
2099
|
-
node,
|
|
2100
|
-
ctx: "",
|
|
2101
|
-
startOffset: block.startOffset,
|
|
2102
|
-
startLine: block.startLine,
|
|
2103
|
-
startColumn: block.startColumn
|
|
2104
|
-
});
|
|
2105
|
-
rendered.push({ node, reactKey: item.reactKey });
|
|
2106
|
-
}
|
|
1938
|
+
var getTag_default = getTag;
|
|
1939
|
+
|
|
1940
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js
|
|
1941
|
+
var objectProto14 = Object.prototype;
|
|
1942
|
+
var hasOwnProperty11 = objectProto14.hasOwnProperty;
|
|
1943
|
+
function initCloneArray(array) {
|
|
1944
|
+
var length = array.length, result = new array.constructor(length);
|
|
1945
|
+
if (length && typeof array[0] == "string" && hasOwnProperty11.call(array, "index")) {
|
|
1946
|
+
result.index = array.index;
|
|
1947
|
+
result.input = array.input;
|
|
2107
1948
|
}
|
|
2108
|
-
|
|
2109
|
-
return rendered;
|
|
1949
|
+
return result;
|
|
2110
1950
|
}
|
|
1951
|
+
var initCloneArray_default = initCloneArray;
|
|
2111
1952
|
|
|
2112
|
-
//
|
|
2113
|
-
|
|
2114
|
-
var
|
|
2115
|
-
|
|
2116
|
-
var import_unist_util_visit5 = require("unist-util-visit");
|
|
2117
|
-
function buildProcessor() {
|
|
2118
|
-
return (0, import_unified2.unified)().use(import_remark_parse2.default).use(import_remark_gfm.default);
|
|
1953
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js
|
|
1954
|
+
function cloneDataView(dataView, isDeep) {
|
|
1955
|
+
var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
|
|
1956
|
+
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
|
2119
1957
|
}
|
|
2120
|
-
var
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
1958
|
+
var cloneDataView_default = cloneDataView;
|
|
1959
|
+
|
|
1960
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js
|
|
1961
|
+
var reFlags = /\w*$/;
|
|
1962
|
+
function cloneRegExp(regexp) {
|
|
1963
|
+
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
|
1964
|
+
result.lastIndex = regexp.lastIndex;
|
|
1965
|
+
return result;
|
|
2124
1966
|
}
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
1967
|
+
var cloneRegExp_default = cloneRegExp;
|
|
1968
|
+
|
|
1969
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js
|
|
1970
|
+
var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
|
|
1971
|
+
var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
1972
|
+
function cloneSymbol(symbol) {
|
|
1973
|
+
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
|
1974
|
+
}
|
|
1975
|
+
var cloneSymbol_default = cloneSymbol;
|
|
1976
|
+
|
|
1977
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js
|
|
1978
|
+
var boolTag2 = "[object Boolean]";
|
|
1979
|
+
var dateTag2 = "[object Date]";
|
|
1980
|
+
var mapTag3 = "[object Map]";
|
|
1981
|
+
var numberTag2 = "[object Number]";
|
|
1982
|
+
var regexpTag2 = "[object RegExp]";
|
|
1983
|
+
var setTag3 = "[object Set]";
|
|
1984
|
+
var stringTag2 = "[object String]";
|
|
1985
|
+
var symbolTag = "[object Symbol]";
|
|
1986
|
+
var arrayBufferTag2 = "[object ArrayBuffer]";
|
|
1987
|
+
var dataViewTag3 = "[object DataView]";
|
|
1988
|
+
var float32Tag2 = "[object Float32Array]";
|
|
1989
|
+
var float64Tag2 = "[object Float64Array]";
|
|
1990
|
+
var int8Tag2 = "[object Int8Array]";
|
|
1991
|
+
var int16Tag2 = "[object Int16Array]";
|
|
1992
|
+
var int32Tag2 = "[object Int32Array]";
|
|
1993
|
+
var uint8Tag2 = "[object Uint8Array]";
|
|
1994
|
+
var uint8ClampedTag2 = "[object Uint8ClampedArray]";
|
|
1995
|
+
var uint16Tag2 = "[object Uint16Array]";
|
|
1996
|
+
var uint32Tag2 = "[object Uint32Array]";
|
|
1997
|
+
function initCloneByTag(object, tag, isDeep) {
|
|
1998
|
+
var Ctor = object.constructor;
|
|
1999
|
+
switch (tag) {
|
|
2000
|
+
case arrayBufferTag2:
|
|
2001
|
+
return cloneArrayBuffer_default(object);
|
|
2002
|
+
case boolTag2:
|
|
2003
|
+
case dateTag2:
|
|
2004
|
+
return new Ctor(+object);
|
|
2005
|
+
case dataViewTag3:
|
|
2006
|
+
return cloneDataView_default(object, isDeep);
|
|
2007
|
+
case float32Tag2:
|
|
2008
|
+
case float64Tag2:
|
|
2009
|
+
case int8Tag2:
|
|
2010
|
+
case int16Tag2:
|
|
2011
|
+
case int32Tag2:
|
|
2012
|
+
case uint8Tag2:
|
|
2013
|
+
case uint8ClampedTag2:
|
|
2014
|
+
case uint16Tag2:
|
|
2015
|
+
case uint32Tag2:
|
|
2016
|
+
return cloneTypedArray_default(object, isDeep);
|
|
2017
|
+
case mapTag3:
|
|
2018
|
+
return new Ctor();
|
|
2019
|
+
case numberTag2:
|
|
2020
|
+
case stringTag2:
|
|
2021
|
+
return new Ctor(object);
|
|
2022
|
+
case regexpTag2:
|
|
2023
|
+
return cloneRegExp_default(object);
|
|
2024
|
+
case setTag3:
|
|
2025
|
+
return new Ctor();
|
|
2026
|
+
case symbolTag:
|
|
2027
|
+
return cloneSymbol_default(object);
|
|
2128
2028
|
}
|
|
2129
|
-
const mdast = processor().parse(source);
|
|
2130
|
-
const footnoteLabels = /* @__PURE__ */ new Set();
|
|
2131
|
-
const linkLabels = /* @__PURE__ */ new Set();
|
|
2132
|
-
(0, import_unist_util_visit5.visit)(mdast, (node) => {
|
|
2133
|
-
if (node.type === "footnoteDefinition" && "identifier" in node) {
|
|
2134
|
-
footnoteLabels.add(normalizeId(node.identifier));
|
|
2135
|
-
} else if (node.type === "definition" && "identifier" in node) {
|
|
2136
|
-
linkLabels.add(normalizeId(node.identifier));
|
|
2137
|
-
}
|
|
2138
|
-
});
|
|
2139
|
-
return { footnoteLabels, linkLabels };
|
|
2140
2029
|
}
|
|
2030
|
+
var initCloneByTag_default = initCloneByTag;
|
|
2141
2031
|
|
|
2142
|
-
//
|
|
2143
|
-
var
|
|
2032
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js
|
|
2033
|
+
var mapTag4 = "[object Map]";
|
|
2034
|
+
function baseIsMap(value) {
|
|
2035
|
+
return isObjectLike_default(value) && getTag_default(value) == mapTag4;
|
|
2036
|
+
}
|
|
2037
|
+
var baseIsMap_default = baseIsMap;
|
|
2144
2038
|
|
|
2145
|
-
//
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2039
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isMap.js
|
|
2040
|
+
var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
|
|
2041
|
+
var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
|
|
2042
|
+
var isMap_default = isMap;
|
|
2043
|
+
|
|
2044
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js
|
|
2045
|
+
var setTag4 = "[object Set]";
|
|
2046
|
+
function baseIsSet(value) {
|
|
2047
|
+
return isObjectLike_default(value) && getTag_default(value) == setTag4;
|
|
2048
|
+
}
|
|
2049
|
+
var baseIsSet_default = baseIsSet;
|
|
2050
|
+
|
|
2051
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isSet.js
|
|
2052
|
+
var nodeIsSet = nodeUtil_default && nodeUtil_default.isSet;
|
|
2053
|
+
var isSet = nodeIsSet ? baseUnary_default(nodeIsSet) : baseIsSet_default;
|
|
2054
|
+
var isSet_default = isSet;
|
|
2055
|
+
|
|
2056
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js
|
|
2057
|
+
var CLONE_DEEP_FLAG = 1;
|
|
2058
|
+
var CLONE_FLAT_FLAG = 2;
|
|
2059
|
+
var CLONE_SYMBOLS_FLAG = 4;
|
|
2060
|
+
var argsTag3 = "[object Arguments]";
|
|
2061
|
+
var arrayTag2 = "[object Array]";
|
|
2062
|
+
var boolTag3 = "[object Boolean]";
|
|
2063
|
+
var dateTag3 = "[object Date]";
|
|
2064
|
+
var errorTag2 = "[object Error]";
|
|
2065
|
+
var funcTag3 = "[object Function]";
|
|
2066
|
+
var genTag2 = "[object GeneratorFunction]";
|
|
2067
|
+
var mapTag5 = "[object Map]";
|
|
2068
|
+
var numberTag3 = "[object Number]";
|
|
2069
|
+
var objectTag4 = "[object Object]";
|
|
2070
|
+
var regexpTag3 = "[object RegExp]";
|
|
2071
|
+
var setTag5 = "[object Set]";
|
|
2072
|
+
var stringTag3 = "[object String]";
|
|
2073
|
+
var symbolTag2 = "[object Symbol]";
|
|
2074
|
+
var weakMapTag3 = "[object WeakMap]";
|
|
2075
|
+
var arrayBufferTag3 = "[object ArrayBuffer]";
|
|
2076
|
+
var dataViewTag4 = "[object DataView]";
|
|
2077
|
+
var float32Tag3 = "[object Float32Array]";
|
|
2078
|
+
var float64Tag3 = "[object Float64Array]";
|
|
2079
|
+
var int8Tag3 = "[object Int8Array]";
|
|
2080
|
+
var int16Tag3 = "[object Int16Array]";
|
|
2081
|
+
var int32Tag3 = "[object Int32Array]";
|
|
2082
|
+
var uint8Tag3 = "[object Uint8Array]";
|
|
2083
|
+
var uint8ClampedTag3 = "[object Uint8ClampedArray]";
|
|
2084
|
+
var uint16Tag3 = "[object Uint16Array]";
|
|
2085
|
+
var uint32Tag3 = "[object Uint32Array]";
|
|
2086
|
+
var cloneableTags = {};
|
|
2087
|
+
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[objectTag4] = cloneableTags[regexpTag3] = cloneableTags[setTag5] = cloneableTags[stringTag3] = cloneableTags[symbolTag2] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
|
|
2088
|
+
cloneableTags[errorTag2] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
|
|
2089
|
+
function baseClone(value, bitmask, customizer, key, object, stack) {
|
|
2090
|
+
var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
|
|
2091
|
+
if (customizer) {
|
|
2092
|
+
result = object ? customizer(value, key, object, stack) : customizer(value);
|
|
2093
|
+
}
|
|
2094
|
+
if (result !== void 0) {
|
|
2095
|
+
return result;
|
|
2096
|
+
}
|
|
2097
|
+
if (!isObject_default(value)) {
|
|
2098
|
+
return value;
|
|
2099
|
+
}
|
|
2100
|
+
var isArr = isArray_default(value);
|
|
2101
|
+
if (isArr) {
|
|
2102
|
+
result = initCloneArray_default(value);
|
|
2103
|
+
if (!isDeep) {
|
|
2104
|
+
return copyArray_default(value, result);
|
|
2105
|
+
}
|
|
2106
|
+
} else {
|
|
2107
|
+
var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
|
|
2108
|
+
if (isBuffer_default(value)) {
|
|
2109
|
+
return cloneBuffer_default(value, isDeep);
|
|
2110
|
+
}
|
|
2111
|
+
if (tag == objectTag4 || tag == argsTag3 || isFunc && !object) {
|
|
2112
|
+
result = isFlat || isFunc ? {} : initCloneObject_default(value);
|
|
2113
|
+
if (!isDeep) {
|
|
2114
|
+
return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
|
|
2213
2115
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
for (const l of cd.ownFootnoteLabels) newFn.add(l);
|
|
2218
|
-
for (const l of cd.ownLinkLabels) newLink.add(l);
|
|
2116
|
+
} else {
|
|
2117
|
+
if (!cloneableTags[tag]) {
|
|
2118
|
+
return object ? value : {};
|
|
2219
2119
|
}
|
|
2220
|
-
|
|
2221
|
-
this.labelSet.linkLabels = newLink;
|
|
2222
|
-
this._notify();
|
|
2223
|
-
},
|
|
2224
|
-
contributeChunkData(symbol, data) {
|
|
2225
|
-
this.chunkData.set(symbol, data);
|
|
2226
|
-
this.labelSet.footnoteLabels = /* @__PURE__ */ new Set();
|
|
2227
|
-
this.labelSet.linkLabels = /* @__PURE__ */ new Set();
|
|
2228
|
-
for (const cd of this.chunkData.values()) {
|
|
2229
|
-
for (const l of cd.ownFootnoteLabels) this.labelSet.footnoteLabels.add(l);
|
|
2230
|
-
for (const l of cd.ownLinkLabels) this.labelSet.linkLabels.add(l);
|
|
2231
|
-
}
|
|
2232
|
-
this._notify();
|
|
2233
|
-
},
|
|
2234
|
-
subscribe(cb) {
|
|
2235
|
-
this._subscribers.add(cb);
|
|
2236
|
-
return () => {
|
|
2237
|
-
this._subscribers.delete(cb);
|
|
2238
|
-
};
|
|
2239
|
-
},
|
|
2240
|
-
canonicalFootnoteFor(label) {
|
|
2241
|
-
const id = normalizeId(label);
|
|
2242
|
-
for (const sym of this.chunkOrder) {
|
|
2243
|
-
const data = this.chunkData.get(sym);
|
|
2244
|
-
if (data?.defs.has(id)) return sym;
|
|
2245
|
-
}
|
|
2246
|
-
return null;
|
|
2247
|
-
},
|
|
2248
|
-
canonicalLinkFor(label) {
|
|
2249
|
-
const id = normalizeId(label);
|
|
2250
|
-
for (const sym of this.chunkOrder) {
|
|
2251
|
-
const data = this.chunkData.get(sym);
|
|
2252
|
-
if (data?.linkDefs.has(id)) return sym;
|
|
2253
|
-
}
|
|
2254
|
-
return null;
|
|
2255
|
-
},
|
|
2256
|
-
globalNumber(label) {
|
|
2257
|
-
const id = normalizeId(label);
|
|
2258
|
-
let n = 0;
|
|
2259
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2260
|
-
for (const sym of this.chunkOrder) {
|
|
2261
|
-
const data = this.chunkData.get(sym);
|
|
2262
|
-
if (!data) continue;
|
|
2263
|
-
for (const ref of data.refs) {
|
|
2264
|
-
if (ref.kind !== "footnote") continue;
|
|
2265
|
-
if (!seen.has(ref.label)) {
|
|
2266
|
-
seen.add(ref.label);
|
|
2267
|
-
n++;
|
|
2268
|
-
if (ref.label === id) return n;
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
return null;
|
|
2273
|
-
},
|
|
2274
|
-
resolveLinkDef(label) {
|
|
2275
|
-
const sym = this.canonicalLinkFor(label);
|
|
2276
|
-
if (!sym) return null;
|
|
2277
|
-
return this.chunkData.get(sym)?.linkDefs.get(normalizeId(label)) ?? null;
|
|
2278
|
-
},
|
|
2279
|
-
getRefsForLabel(label) {
|
|
2280
|
-
const id = normalizeId(label);
|
|
2281
|
-
let n = 0;
|
|
2282
|
-
for (const sym of this.chunkOrder) {
|
|
2283
|
-
const data = this.chunkData.get(sym);
|
|
2284
|
-
if (!data) continue;
|
|
2285
|
-
for (const ref of data.refs) {
|
|
2286
|
-
if (ref.kind === "footnote" && ref.label === id) n++;
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
return n;
|
|
2290
|
-
},
|
|
2291
|
-
globalOccurrenceForRef(chunkSym, label, localOccurrence) {
|
|
2292
|
-
const id = normalizeId(label);
|
|
2293
|
-
let global2 = 0;
|
|
2294
|
-
for (const sym of this.chunkOrder) {
|
|
2295
|
-
const data = this.chunkData.get(sym);
|
|
2296
|
-
if (!data) continue;
|
|
2297
|
-
let localCount = 0;
|
|
2298
|
-
for (const ref of data.refs) {
|
|
2299
|
-
if (ref.kind !== "footnote") continue;
|
|
2300
|
-
if (ref.label !== id) continue;
|
|
2301
|
-
localCount++;
|
|
2302
|
-
global2++;
|
|
2303
|
-
if (sym === chunkSym && localCount === localOccurrence) return global2;
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
return null;
|
|
2307
|
-
},
|
|
2308
|
-
_notify() {
|
|
2309
|
-
this.version++;
|
|
2310
|
-
if (this._notifyScheduled) return;
|
|
2311
|
-
this._notifyScheduled = true;
|
|
2312
|
-
queueMicrotask(() => {
|
|
2313
|
-
this._notifyScheduled = false;
|
|
2314
|
-
for (const cb of [...this._subscribers]) cb();
|
|
2315
|
-
});
|
|
2120
|
+
result = initCloneByTag_default(value, tag, isDeep);
|
|
2316
2121
|
}
|
|
2317
|
-
};
|
|
2318
|
-
return reg;
|
|
2319
|
-
}
|
|
2320
|
-
|
|
2321
|
-
// src/components/AIMarkdownDocuments.tsx
|
|
2322
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2323
|
-
var AIMarkdownDocumentsContext = (0, import_react3.createContext)(null);
|
|
2324
|
-
var AIMarkdownDocuments = ({ preserveOrphanReferences = true, children }) => {
|
|
2325
|
-
const parent = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
|
|
2326
|
-
if (parent !== null) {
|
|
2327
|
-
throw new Error(
|
|
2328
|
-
"<AIMarkdownDocuments> must not be nested inside another <AIMarkdownDocuments>. Use a single top-level wrapper per coordinated scope."
|
|
2329
|
-
);
|
|
2330
2122
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
return ctx.getRegistry(documentId);
|
|
2123
|
+
stack || (stack = new Stack_default());
|
|
2124
|
+
var stacked = stack.get(value);
|
|
2125
|
+
if (stacked) {
|
|
2126
|
+
return stacked;
|
|
2127
|
+
}
|
|
2128
|
+
stack.set(value, result);
|
|
2129
|
+
if (isSet_default(value)) {
|
|
2130
|
+
value.forEach(function(subValue) {
|
|
2131
|
+
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
|
2132
|
+
});
|
|
2133
|
+
} else if (isMap_default(value)) {
|
|
2134
|
+
value.forEach(function(subValue, key2) {
|
|
2135
|
+
result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
|
|
2139
|
+
var props = isArr ? void 0 : keysFunc(value);
|
|
2140
|
+
arrayEach_default(props || value, function(subValue, key2) {
|
|
2141
|
+
if (props) {
|
|
2142
|
+
key2 = subValue;
|
|
2143
|
+
subValue = value[key2];
|
|
2144
|
+
}
|
|
2145
|
+
assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
|
2146
|
+
});
|
|
2147
|
+
return result;
|
|
2357
2148
|
}
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2149
|
+
var baseClone_default = baseClone;
|
|
2150
|
+
|
|
2151
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js
|
|
2152
|
+
var CLONE_DEEP_FLAG2 = 1;
|
|
2153
|
+
var CLONE_SYMBOLS_FLAG2 = 4;
|
|
2154
|
+
function cloneDeep(value) {
|
|
2155
|
+
return baseClone_default(value, CLONE_DEEP_FLAG2 | CLONE_SYMBOLS_FLAG2);
|
|
2361
2156
|
}
|
|
2157
|
+
var cloneDeep_default = cloneDeep;
|
|
2362
2158
|
|
|
2363
|
-
// src/components/
|
|
2364
|
-
var
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
suffix += `[${label}]: ${SENTINEL_LINK_URL}
|
|
2373
|
-
`;
|
|
2374
|
-
}
|
|
2375
|
-
for (const label of phantoms.missingFootnotes) {
|
|
2376
|
-
suffix += `[^${label}]: ${SENTINEL_FN_CONTENT}
|
|
2377
|
-
`;
|
|
2159
|
+
// src/components/sanitizeSchema.ts
|
|
2160
|
+
var import_rehype_sanitize = require("rehype-sanitize");
|
|
2161
|
+
function mergeClassNameAllowlist(existing, extraClassNames) {
|
|
2162
|
+
const entries = existing ? [...existing] : [];
|
|
2163
|
+
const idx = entries.findIndex(
|
|
2164
|
+
(entry) => typeof entry === "string" ? entry === "className" : entry[0] === "className"
|
|
2165
|
+
);
|
|
2166
|
+
if (idx === -1) {
|
|
2167
|
+
return [...entries, ["className", ...extraClassNames]];
|
|
2378
2168
|
}
|
|
2379
|
-
|
|
2169
|
+
const current = entries[idx];
|
|
2170
|
+
const merged = typeof current === "string" ? ["className", ...extraClassNames] : [...current, ...extraClassNames];
|
|
2171
|
+
entries[idx] = merged;
|
|
2172
|
+
return entries;
|
|
2380
2173
|
}
|
|
2174
|
+
var crossChunkTags = ["cross-chunk-link", "cross-chunk-image", "footnote-sup"];
|
|
2175
|
+
var sanitizeSchema = cloneDeep_default({
|
|
2176
|
+
...import_rehype_sanitize.defaultSchema,
|
|
2177
|
+
tagNames: [...import_rehype_sanitize.defaultSchema.tagNames || [], "mark", ...crossChunkTags],
|
|
2178
|
+
attributes: {
|
|
2179
|
+
...import_rehype_sanitize.defaultSchema.attributes,
|
|
2180
|
+
code: mergeClassNameAllowlist(import_rehype_sanitize.defaultSchema.attributes?.code, ["math-inline", "math-display"]),
|
|
2181
|
+
"cross-chunk-link": ["label", "referenceType", "documentId"],
|
|
2182
|
+
"cross-chunk-image": ["label", "referenceType", "documentId", "alt"],
|
|
2183
|
+
"footnote-sup": ["label", "localOccurrence", "documentId"]
|
|
2184
|
+
}
|
|
2185
|
+
});
|
|
2381
2186
|
|
|
2382
|
-
// src/components/
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
const
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
if (!resolved) return void 0;
|
|
2424
|
-
return {
|
|
2425
|
-
type: "element",
|
|
2426
|
-
tagName: "cross-chunk-image",
|
|
2427
|
-
properties: {
|
|
2428
|
-
label: node.label ?? node.identifier,
|
|
2429
|
-
referenceType: node.referenceType,
|
|
2430
|
-
alt: node.alt ?? "",
|
|
2431
|
-
documentId: s.options.documentId
|
|
2432
|
-
},
|
|
2433
|
-
children: []
|
|
2434
|
-
};
|
|
2435
|
-
}),
|
|
2436
|
-
footnoteReference: ((state, node) => {
|
|
2437
|
-
const s = state;
|
|
2438
|
-
const id = normalizeId(node.identifier);
|
|
2439
|
-
const localOccurrence = (s.footnoteCounts.get(id) ?? 0) + 1;
|
|
2440
|
-
s.footnoteCounts.set(id, localOccurrence);
|
|
2441
|
-
if (s.options.phantomFootnoteLabels.has(id)) {
|
|
2442
|
-
return {
|
|
2187
|
+
// src/components/rehypeRebaseHashLinks.ts
|
|
2188
|
+
var import_unist_util_visit2 = require("unist-util-visit");
|
|
2189
|
+
var DEFAULT_PREFIX = "user-content-";
|
|
2190
|
+
var rehypeRebaseHashLinks = (options) => {
|
|
2191
|
+
const prefix = options?.prefix ?? DEFAULT_PREFIX;
|
|
2192
|
+
const hashPrefix = "#" + prefix;
|
|
2193
|
+
return (tree) => {
|
|
2194
|
+
(0, import_unist_util_visit2.visit)(tree, "element", (node) => {
|
|
2195
|
+
if (node.tagName !== "a") return;
|
|
2196
|
+
const href = node.properties?.href;
|
|
2197
|
+
if (typeof href !== "string" || !href.startsWith("#")) return;
|
|
2198
|
+
if (href.startsWith(hashPrefix)) return;
|
|
2199
|
+
node.properties.href = hashPrefix + href.slice(1);
|
|
2200
|
+
});
|
|
2201
|
+
};
|
|
2202
|
+
};
|
|
2203
|
+
var rehypeRebaseHashLinks_default = rehypeRebaseHashLinks;
|
|
2204
|
+
|
|
2205
|
+
// src/components/rehypeFooterAdorn.ts
|
|
2206
|
+
var import_unist_util_visit3 = require("unist-util-visit");
|
|
2207
|
+
var FOOTNOTE_LABEL_ID_RE = /(?:^|-)footnote-label$/;
|
|
2208
|
+
function isFootnoteLabelH2(node) {
|
|
2209
|
+
if (node.type !== "element") return false;
|
|
2210
|
+
const el = node;
|
|
2211
|
+
if (el.tagName !== "h2") return false;
|
|
2212
|
+
const id = el.properties?.id;
|
|
2213
|
+
return typeof id === "string" && FOOTNOTE_LABEL_ID_RE.test(id);
|
|
2214
|
+
}
|
|
2215
|
+
function isHr(node) {
|
|
2216
|
+
if (node.type !== "element") return false;
|
|
2217
|
+
return node.tagName === "hr";
|
|
2218
|
+
}
|
|
2219
|
+
function rehypeFooterAdorn() {
|
|
2220
|
+
return (tree) => {
|
|
2221
|
+
(0, import_unist_util_visit3.visit)(tree, "element", (n) => {
|
|
2222
|
+
const el = n;
|
|
2223
|
+
if (el.tagName !== "section") return;
|
|
2224
|
+
if (!(el.properties && "dataFootnotes" in el.properties)) return;
|
|
2225
|
+
const filtered = el.children.filter((c) => !isFootnoteLabelH2(c));
|
|
2226
|
+
if (!filtered.some(isHr)) {
|
|
2227
|
+
const hr = {
|
|
2443
2228
|
type: "element",
|
|
2444
|
-
tagName: "
|
|
2445
|
-
properties: {
|
|
2446
|
-
label: node.identifier,
|
|
2447
|
-
localOccurrence,
|
|
2448
|
-
documentId: s.options.documentId
|
|
2449
|
-
},
|
|
2229
|
+
tagName: "hr",
|
|
2230
|
+
properties: {},
|
|
2450
2231
|
children: []
|
|
2451
2232
|
};
|
|
2233
|
+
filtered.unshift(hr);
|
|
2452
2234
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
localOccurrence,
|
|
2460
|
-
documentId: s.options.documentId
|
|
2461
|
-
},
|
|
2462
|
-
children: []
|
|
2463
|
-
};
|
|
2464
|
-
})
|
|
2235
|
+
el.children = filtered;
|
|
2236
|
+
if (!el.properties) el.properties = {};
|
|
2237
|
+
if (!("ariaLabel" in el.properties)) {
|
|
2238
|
+
el.properties.ariaLabel = "Footnotes";
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2465
2241
|
};
|
|
2466
2242
|
}
|
|
2467
2243
|
|
|
2468
|
-
// src/components/
|
|
2469
|
-
var
|
|
2244
|
+
// src/components/MarkdownContent.tsx
|
|
2245
|
+
var import_remark_breaks = __toESM(require("remark-breaks"), 1);
|
|
2246
|
+
var import_remark_cjk_friendly = __toESM(require("remark-cjk-friendly"), 1);
|
|
2247
|
+
var import_remark_cjk_friendly_gfm_strikethrough = __toESM(require("remark-cjk-friendly-gfm-strikethrough"), 1);
|
|
2248
|
+
var import_remark_emoji = __toESM(require("remark-emoji"), 1);
|
|
2249
|
+
var import_remark_gfm2 = __toESM(require("remark-gfm"), 1);
|
|
2250
|
+
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
2251
|
+
var import_remark_definition_list = require("remark-definition-list");
|
|
2252
|
+
var import_remark_mark_highlight = require("remark-mark-highlight");
|
|
2253
|
+
var import_remark_squeeze_paragraphs = __toESM(require("remark-squeeze-paragraphs"), 1);
|
|
2254
|
+
var import_remark_smartypants = __toESM(require("remark-smartypants"), 1);
|
|
2255
|
+
var import_remark_pangu = __toESM(require("remark-pangu"), 1);
|
|
2256
|
+
var import_remark_remove_comments = __toESM(require("remark-remove-comments"), 1);
|
|
2470
2257
|
|
|
2471
|
-
// src/components/
|
|
2472
|
-
var
|
|
2473
|
-
var ChunkSymbolContext = (0, import_react4.createContext)(null);
|
|
2258
|
+
// src/components/blockMemo.ts
|
|
2259
|
+
var import_unist_util_visit4 = require("unist-util-visit");
|
|
2474
2260
|
|
|
2475
|
-
// src/components/
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
var SSR_DEF_SNAPSHOT = () => null;
|
|
2479
|
-
function coerceLocalOccurrence(v) {
|
|
2480
|
-
if (v === void 0) return null;
|
|
2481
|
-
if (typeof v === "number") return Number.isFinite(v) && v >= 1 ? Math.trunc(v) : null;
|
|
2482
|
-
const n = Number(v);
|
|
2483
|
-
return Number.isFinite(n) && n >= 1 ? Math.trunc(n) : null;
|
|
2484
|
-
}
|
|
2485
|
-
function FootnoteSupNumber({ label, localOccurrence: localOccurrenceRaw }) {
|
|
2486
|
-
const localOccurrence = coerceLocalOccurrence(localOccurrenceRaw);
|
|
2487
|
-
const { documentId, clobberPrefix } = useAIMarkdownRenderState();
|
|
2488
|
-
const registry = useDocumentRegistry(documentId);
|
|
2489
|
-
const chunkSym = (0, import_react5.useContext)(ChunkSymbolContext);
|
|
2490
|
-
const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2491
|
-
}, [registry]);
|
|
2492
|
-
const getSnapshot = (0, import_react5.useCallback)(() => registry?.version ?? 0, [registry]);
|
|
2493
|
-
(0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
|
|
2494
|
-
const num = registry?.globalNumber(label) ?? null;
|
|
2495
|
-
if (num === null) return null;
|
|
2496
|
-
if (localOccurrence !== null && !chunkSym) return null;
|
|
2497
|
-
const globalOcc = registry && chunkSym && localOccurrence !== null ? registry.globalOccurrenceForRef(chunkSym, label, localOccurrence) : null;
|
|
2498
|
-
if (localOccurrence !== null && globalOcc === null) return null;
|
|
2499
|
-
const occSuffix = globalOcc !== null && globalOcc > 1 ? `-${globalOcc}` : "";
|
|
2500
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("sup", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: `#${clobberPrefix}fn-${label}`, id: `${clobberPrefix}fnref-${label}${occSuffix}`, "data-footnote-ref": true, children: num }) });
|
|
2261
|
+
// src/components/normalizeId.ts
|
|
2262
|
+
function normalizeId(s) {
|
|
2263
|
+
return s.replace(/\s+/g, " ").toUpperCase();
|
|
2501
2264
|
}
|
|
2502
|
-
function
|
|
2503
|
-
|
|
2504
|
-
if (typeof node === "string") return node;
|
|
2505
|
-
if (typeof node === "number" || typeof node === "bigint") return String(node);
|
|
2506
|
-
if (Array.isArray(node)) return node.map(reactNodeToText).join("");
|
|
2507
|
-
if ((0, import_react5.isValidElement)(node)) {
|
|
2508
|
-
return reactNodeToText(node.props.children);
|
|
2509
|
-
}
|
|
2510
|
-
return "";
|
|
2265
|
+
function normalizeForMatch(s) {
|
|
2266
|
+
return s.replace(/\\(.)/g, "$1").replace(/\s+/g, " ").toUpperCase();
|
|
2511
2267
|
}
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2268
|
+
|
|
2269
|
+
// src/components/blockMemo.ts
|
|
2270
|
+
var TAINT_TYPES = /* @__PURE__ */ new Set([
|
|
2271
|
+
"footnoteReference",
|
|
2272
|
+
"footnoteDefinition",
|
|
2273
|
+
"linkReference",
|
|
2274
|
+
"imageReference",
|
|
2275
|
+
"definition"
|
|
2276
|
+
]);
|
|
2277
|
+
var CTX_TYPES = TAINT_TYPES;
|
|
2278
|
+
function createCache() {
|
|
2279
|
+
return { blocks: /* @__PURE__ */ new Map() };
|
|
2523
2280
|
}
|
|
2524
|
-
function
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2528
|
-
}, [registry]);
|
|
2529
|
-
const getSnapshot = (0, import_react5.useCallback)(() => registry?.resolveLinkDef(label) ?? null, [registry, label]);
|
|
2530
|
-
const def = (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_DEF_SNAPSHOT);
|
|
2531
|
-
if (!def) {
|
|
2532
|
-
return literalLink(referenceType, label, children);
|
|
2533
|
-
}
|
|
2534
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: def.url, title: def.title, children });
|
|
2281
|
+
function extractRaw(node, source) {
|
|
2282
|
+
if (!node.position) return "";
|
|
2283
|
+
return source.slice(node.position.start.offset, node.position.end.offset);
|
|
2535
2284
|
}
|
|
2536
|
-
function
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
case "collapsed":
|
|
2541
|
-
return `![${alt}][]`;
|
|
2542
|
-
case "shortcut":
|
|
2543
|
-
default:
|
|
2544
|
-
return `![${label}]`;
|
|
2545
|
-
}
|
|
2285
|
+
function isFootnoteSection(node) {
|
|
2286
|
+
if (node.tagName !== "section") return false;
|
|
2287
|
+
const props = node.properties;
|
|
2288
|
+
return props?.dataFootnotes !== void 0;
|
|
2546
2289
|
}
|
|
2547
|
-
function
|
|
2548
|
-
|
|
2549
|
-
const registry = useDocumentRegistry(documentId);
|
|
2550
|
-
const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2551
|
-
}, [registry]);
|
|
2552
|
-
const getSnapshot = (0, import_react5.useCallback)(() => registry?.resolveLinkDef(label) ?? null, [registry, label]);
|
|
2553
|
-
const def = (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_DEF_SNAPSHOT);
|
|
2554
|
-
if (!def) {
|
|
2555
|
-
return literalImage(referenceType, label, alt);
|
|
2556
|
-
}
|
|
2557
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: def.url, alt, title: def.title });
|
|
2290
|
+
function hasMdastSource(node) {
|
|
2291
|
+
return node.position !== void 0;
|
|
2558
2292
|
}
|
|
2559
|
-
var
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
if (n.type === "footnoteReference") {
|
|
2572
|
-
out.push({
|
|
2573
|
-
kind: "ref",
|
|
2574
|
-
refKind: "footnote",
|
|
2575
|
-
label: normalizeId(n.identifier)
|
|
2576
|
-
});
|
|
2577
|
-
} else if (n.type === "linkReference") {
|
|
2578
|
-
const r = n;
|
|
2579
|
-
out.push({ kind: "ref", refKind: "link", label: normalizeId(r.identifier), referenceType: r.referenceType });
|
|
2580
|
-
} else if (n.type === "imageReference") {
|
|
2581
|
-
const r = n;
|
|
2582
|
-
out.push({ kind: "ref", refKind: "image", label: normalizeId(r.identifier), referenceType: r.referenceType });
|
|
2583
|
-
} else if (n.type === "footnoteDefinition") {
|
|
2584
|
-
const d = n;
|
|
2585
|
-
const label = normalizeId(d.identifier);
|
|
2586
|
-
if (phantomFn?.has(label)) return import_unist_util_visit6.SKIP;
|
|
2587
|
-
const content = JSON.stringify(d.children ?? []);
|
|
2588
|
-
out.push({ kind: "fnDef", label, sourceIdentifier: d.identifier, content });
|
|
2589
|
-
return import_unist_util_visit6.SKIP;
|
|
2590
|
-
} else if (n.type === "definition") {
|
|
2591
|
-
const d = n;
|
|
2592
|
-
if (d.url === SENTINEL_LINK_URL) return;
|
|
2593
|
-
out.push({ kind: "linkDef", label: normalizeId(d.identifier), url: d.url, title: d.title });
|
|
2293
|
+
var FOOTNOTE_SECTION_KEY = "__footnote_section__";
|
|
2294
|
+
function buildBlocks(mdast, hast, source) {
|
|
2295
|
+
const mdastByOffset = /* @__PURE__ */ new Map();
|
|
2296
|
+
const mdastRanges = [];
|
|
2297
|
+
for (const child of mdast.children) {
|
|
2298
|
+
const off = child.position?.start.offset;
|
|
2299
|
+
const endOff = child.position?.end.offset;
|
|
2300
|
+
if (off !== void 0) {
|
|
2301
|
+
mdastByOffset.set(off, child);
|
|
2302
|
+
}
|
|
2303
|
+
if (off !== void 0 && endOff !== void 0) {
|
|
2304
|
+
mdastRanges.push({ start: off, end: endOff, node: child });
|
|
2594
2305
|
}
|
|
2595
|
-
});
|
|
2596
|
-
for (const c of out) yield c;
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
|
-
// src/components/extractDefBodiesFromHast.ts
|
|
2600
|
-
var import_unist_util_visit7 = require("unist-util-visit");
|
|
2601
|
-
var FN_LI_ID_RE = /(?:^|-)user-content-fn-(.+)$/;
|
|
2602
|
-
function sourceIdFromFootnoteLiId(idProp, clobberPrefix) {
|
|
2603
|
-
let raw = null;
|
|
2604
|
-
if (clobberPrefix !== void 0) {
|
|
2605
|
-
const exactPrefix = `${clobberPrefix}fn-`;
|
|
2606
|
-
if (idProp.startsWith(exactPrefix)) raw = idProp.slice(exactPrefix.length);
|
|
2607
2306
|
}
|
|
2608
|
-
if (
|
|
2609
|
-
|
|
2610
|
-
|
|
2307
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2308
|
+
for (let i = 1; i < mdastRanges.length; i++) {
|
|
2309
|
+
if (mdastRanges[i].start < mdastRanges[i - 1].start) {
|
|
2310
|
+
throw new Error(
|
|
2311
|
+
"block-memo: mdast.children not sorted by source offset \u2014 a remark plugin is reordering top-level children."
|
|
2312
|
+
);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2611
2315
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
function isBackrefAnchor(c) {
|
|
2620
|
-
if (c.type !== "element") return false;
|
|
2621
|
-
const el = c;
|
|
2622
|
-
if (el.tagName !== "a") return false;
|
|
2623
|
-
return Boolean(el.properties && "dataFootnoteBackref" in el.properties);
|
|
2624
|
-
}
|
|
2625
|
-
function isWhitespaceText(c) {
|
|
2626
|
-
if (c.type !== "text") return false;
|
|
2627
|
-
return /^\s*$/.test(c.value);
|
|
2628
|
-
}
|
|
2629
|
-
function lastMeaningfulIdx(children) {
|
|
2630
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
2631
|
-
if (!isWhitespaceText(children[i])) return i;
|
|
2632
|
-
}
|
|
2633
|
-
return -1;
|
|
2634
|
-
}
|
|
2635
|
-
function dropTrailingBackrefs(children) {
|
|
2636
|
-
let trailingWsStart = children.length;
|
|
2637
|
-
while (trailingWsStart > 0 && isWhitespaceText(children[trailingWsStart - 1])) {
|
|
2638
|
-
trailingWsStart--;
|
|
2639
|
-
}
|
|
2640
|
-
let scan = trailingWsStart;
|
|
2641
|
-
let peeledAny = false;
|
|
2642
|
-
while (scan > 0) {
|
|
2643
|
-
const t = children[scan - 1];
|
|
2644
|
-
if (!isBackrefAnchor(t)) break;
|
|
2645
|
-
peeledAny = true;
|
|
2646
|
-
scan -= 1;
|
|
2647
|
-
if (scan > 0 && children[scan - 1].type === "text" && children[scan - 1].value === " ") {
|
|
2648
|
-
scan -= 1;
|
|
2316
|
+
function findContainingMdast(offset) {
|
|
2317
|
+
let lo = 0;
|
|
2318
|
+
let hi = mdastRanges.length;
|
|
2319
|
+
while (lo < hi) {
|
|
2320
|
+
const mid = lo + hi >>> 1;
|
|
2321
|
+
if (mdastRanges[mid].start <= offset) lo = mid + 1;
|
|
2322
|
+
else hi = mid;
|
|
2649
2323
|
}
|
|
2324
|
+
const idx = lo - 1;
|
|
2325
|
+
if (idx < 0) return void 0;
|
|
2326
|
+
const r = mdastRanges[idx];
|
|
2327
|
+
return offset < r.end ? r.node : void 0;
|
|
2650
2328
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
if (
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2329
|
+
const ctxParts = [];
|
|
2330
|
+
(0, import_unist_util_visit4.visit)(mdast, (n) => {
|
|
2331
|
+
if (!CTX_TYPES.has(n.type)) return;
|
|
2332
|
+
if (n.type === "footnoteReference") ctxParts.push(["fr", n.identifier]);
|
|
2333
|
+
else if (n.type === "footnoteDefinition") ctxParts.push(["fd", n.identifier, extractRaw(n, source)]);
|
|
2334
|
+
else if (n.type === "linkReference") ctxParts.push(["lr", n.identifier]);
|
|
2335
|
+
else if (n.type === "imageReference") ctxParts.push(["ir", n.identifier]);
|
|
2336
|
+
else if (n.type === "definition") ctxParts.push(["d", n.identifier, n.url, n.title ?? null]);
|
|
2337
|
+
});
|
|
2338
|
+
const globalCtx = JSON.stringify(ctxParts);
|
|
2339
|
+
const plan = [];
|
|
2340
|
+
const blocks = [];
|
|
2341
|
+
const blockHasts = [];
|
|
2342
|
+
let synthetic;
|
|
2343
|
+
for (let i = 0; i < hast.children.length; i++) {
|
|
2344
|
+
const hastChild = hast.children[i];
|
|
2345
|
+
if (hastChild.type !== "element") {
|
|
2346
|
+
const off = hastChild.position?.start.offset;
|
|
2347
|
+
const reactKey = off !== void 0 ? `inline-${off}` : `inline-i${i}`;
|
|
2348
|
+
plan.push({ kind: "inline", el: hastChild, reactKey });
|
|
2349
|
+
continue;
|
|
2350
|
+
}
|
|
2351
|
+
const el = hastChild;
|
|
2352
|
+
if (isFootnoteSection(el)) {
|
|
2353
|
+
synthetic = el;
|
|
2354
|
+
plan.push({ kind: "synthetic", el, reactKey: FOOTNOTE_SECTION_KEY });
|
|
2355
|
+
continue;
|
|
2356
|
+
}
|
|
2357
|
+
const hastOffset = el.position?.start.offset;
|
|
2358
|
+
if (hastOffset === void 0) {
|
|
2359
|
+
plan.push({ kind: "inline", el, reactKey: `inline-i${i}` });
|
|
2360
|
+
continue;
|
|
2361
|
+
}
|
|
2362
|
+
let mdastNode = mdastByOffset.get(hastOffset);
|
|
2363
|
+
if (!mdastNode) {
|
|
2364
|
+
mdastNode = findContainingMdast(hastOffset);
|
|
2365
|
+
}
|
|
2366
|
+
if (!mdastNode) {
|
|
2367
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2368
|
+
throw new Error(
|
|
2369
|
+
`block-memo: hast block at offset ${hastOffset} has no mdast counterpart. A rehype plugin may have synthesized positions outside source. tagName=${el.tagName}`
|
|
2370
|
+
);
|
|
2659
2371
|
}
|
|
2372
|
+
plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
|
|
2373
|
+
continue;
|
|
2374
|
+
}
|
|
2375
|
+
if (mdastNode.type === "footnoteDefinition") {
|
|
2376
|
+
plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
|
|
2377
|
+
continue;
|
|
2378
|
+
}
|
|
2379
|
+
let hasReference = false;
|
|
2380
|
+
const footnoteRefLabels = [];
|
|
2381
|
+
const linkRefLabels = [];
|
|
2382
|
+
const imageRefLabels = [];
|
|
2383
|
+
const footnoteDefLabels = [];
|
|
2384
|
+
(0, import_unist_util_visit4.visit)(mdastNode, (n) => {
|
|
2385
|
+
if (!TAINT_TYPES.has(n.type)) return;
|
|
2386
|
+
hasReference = true;
|
|
2387
|
+
const id = "identifier" in n ? normalizeId(String(n.identifier)) : null;
|
|
2388
|
+
if (id === null) return;
|
|
2389
|
+
if (n.type === "footnoteReference") footnoteRefLabels.push(id);
|
|
2390
|
+
else if (n.type === "linkReference") linkRefLabels.push(id);
|
|
2391
|
+
else if (n.type === "imageReference") imageRefLabels.push(id);
|
|
2392
|
+
else if (n.type === "footnoteDefinition") footnoteDefLabels.push(id);
|
|
2393
|
+
});
|
|
2394
|
+
const mdastPos = mdastNode.position;
|
|
2395
|
+
if (!mdastPos || mdastPos.start.offset === void 0 || mdastPos.end.offset === void 0) {
|
|
2396
|
+
continue;
|
|
2660
2397
|
}
|
|
2398
|
+
const info = {
|
|
2399
|
+
raw: extractRaw(mdastNode, source),
|
|
2400
|
+
startOffset: mdastPos.start.offset,
|
|
2401
|
+
endOffset: mdastPos.end.offset,
|
|
2402
|
+
startLine: mdastPos.start.line,
|
|
2403
|
+
startColumn: mdastPos.start.column,
|
|
2404
|
+
hasReference,
|
|
2405
|
+
...hasReference ? {
|
|
2406
|
+
taintLabels: { footnoteRefLabels, linkRefLabels, imageRefLabels, footnoteDefLabels }
|
|
2407
|
+
} : {}
|
|
2408
|
+
};
|
|
2409
|
+
blocks.push(info);
|
|
2410
|
+
blockHasts.push(el);
|
|
2411
|
+
plan.push({ kind: "block", el, info, reactKey: `block-${hastOffset}` });
|
|
2661
2412
|
}
|
|
2662
|
-
return
|
|
2413
|
+
return { plan, globalCtx, blocks, blockHasts, synthetic };
|
|
2663
2414
|
}
|
|
2664
|
-
function
|
|
2665
|
-
|
|
2666
|
-
const
|
|
2667
|
-
|
|
2668
|
-
const last = liChildren[lastIdx];
|
|
2669
|
-
if (isBackrefAnchor(last)) {
|
|
2670
|
-
return dropTrailingBackrefs(liChildren);
|
|
2415
|
+
function computeBlockFingerprint(taintLabels, registry, thisChunkSym, clobberPrefix) {
|
|
2416
|
+
const parts = [clobberPrefix];
|
|
2417
|
+
for (const label of taintLabels.footnoteRefLabels) {
|
|
2418
|
+
parts.push(`fn:${label}=${registry.globalNumber(label) ?? "null"}`);
|
|
2671
2419
|
}
|
|
2672
|
-
|
|
2673
|
-
const
|
|
2674
|
-
|
|
2675
|
-
if (newPChildren === p.children) return liChildren;
|
|
2676
|
-
return liChildren.map((c, i) => i === lastIdx ? { ...p, children: newPChildren } : c);
|
|
2420
|
+
for (const label of taintLabels.linkRefLabels) {
|
|
2421
|
+
const def = registry.resolveLinkDef(label);
|
|
2422
|
+
parts.push(`lr:${label}=${def?.url ?? "null"}|${def?.title ?? ""}`);
|
|
2677
2423
|
}
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
let changed = false;
|
|
2682
|
-
const out = [];
|
|
2683
|
-
for (const c of children) {
|
|
2684
|
-
if (c.type === "element") {
|
|
2685
|
-
const el = c;
|
|
2686
|
-
let nextEl = el;
|
|
2687
|
-
if (el.tagName === "footnote-sup" && el.properties && "localOccurrence" in el.properties) {
|
|
2688
|
-
const { localOccurrence: _drop, ...rest } = el.properties;
|
|
2689
|
-
nextEl = { ...el, properties: rest };
|
|
2690
|
-
changed = true;
|
|
2691
|
-
}
|
|
2692
|
-
const newChildren = stripLocalOccurrenceFromFootnoteSups(nextEl.children);
|
|
2693
|
-
if (newChildren !== nextEl.children) {
|
|
2694
|
-
nextEl = { ...nextEl, children: newChildren };
|
|
2695
|
-
changed = true;
|
|
2696
|
-
}
|
|
2697
|
-
out.push(nextEl);
|
|
2698
|
-
} else {
|
|
2699
|
-
out.push(c);
|
|
2700
|
-
}
|
|
2424
|
+
for (const label of taintLabels.imageRefLabels) {
|
|
2425
|
+
const def = registry.resolveLinkDef(label);
|
|
2426
|
+
parts.push(`ir:${label}=${def?.url ?? "null"}|${def?.title ?? ""}`);
|
|
2701
2427
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
const out = /* @__PURE__ */ new Map();
|
|
2706
|
-
(0, import_unist_util_visit7.visit)(hast, "element", (sectionNode) => {
|
|
2707
|
-
const sec = sectionNode;
|
|
2708
|
-
if (sec.tagName !== "section") return;
|
|
2709
|
-
if (!(sec.properties && "dataFootnotes" in sec.properties)) return;
|
|
2710
|
-
(0, import_unist_util_visit7.visit)(sec, "element", (liNode) => {
|
|
2711
|
-
const li = liNode;
|
|
2712
|
-
if (li.tagName !== "li") return;
|
|
2713
|
-
const idProp = li.properties?.id;
|
|
2714
|
-
if (typeof idProp !== "string") return;
|
|
2715
|
-
const sourceId = sourceIdFromFootnoteLiId(idProp, clobberPrefix);
|
|
2716
|
-
if (sourceId === null) return;
|
|
2717
|
-
const normalized = normalizeId(sourceId);
|
|
2718
|
-
const stripped = stripBackrefs(li.children);
|
|
2719
|
-
out.set(normalized, stripLocalOccurrenceFromFootnoteSups(stripped));
|
|
2720
|
-
});
|
|
2721
|
-
return import_unist_util_visit7.SKIP;
|
|
2722
|
-
});
|
|
2723
|
-
return out;
|
|
2724
|
-
}
|
|
2725
|
-
|
|
2726
|
-
// src/components/aggregateFootnotesIfLast.tsx
|
|
2727
|
-
var import_react6 = require("react");
|
|
2728
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2729
|
-
function cloneHast(node) {
|
|
2730
|
-
return JSON.parse(JSON.stringify(node));
|
|
2731
|
-
}
|
|
2732
|
-
function isWhitespaceText2(c) {
|
|
2733
|
-
return c.type === "text" && /^\s*$/.test(c.value);
|
|
2734
|
-
}
|
|
2735
|
-
function lastMeaningfulIdx2(children) {
|
|
2736
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
2737
|
-
if (!isWhitespaceText2(children[i])) return i;
|
|
2428
|
+
for (const label of taintLabels.footnoteDefLabels) {
|
|
2429
|
+
const isCanonical = registry.canonicalFootnoteFor(label) === thisChunkSym ? 1 : 0;
|
|
2430
|
+
parts.push(`fd:${label}=${isCanonical}/${registry.getRefsForLabel(label)}`);
|
|
2738
2431
|
}
|
|
2739
|
-
return
|
|
2432
|
+
return parts.join("|");
|
|
2740
2433
|
}
|
|
2741
|
-
function
|
|
2742
|
-
const
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2434
|
+
function renderBlocksWithCache(cacheRef, plan, globalCtx, postOptions) {
|
|
2435
|
+
const prev = cacheRef.current;
|
|
2436
|
+
const next = { blocks: /* @__PURE__ */ new Map() };
|
|
2437
|
+
const rendered = [];
|
|
2438
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2439
|
+
for (const item of plan) {
|
|
2440
|
+
if (item.kind === "block" && !hasMdastSource(item.el)) {
|
|
2441
|
+
throw new Error(
|
|
2442
|
+
"block-memo: block hast child has no position. Did a rehype plugin strip it? (Run positionPropagation.test.ts to verify.)"
|
|
2443
|
+
);
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2750
2446
|
}
|
|
2751
|
-
const
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
href,
|
|
2757
|
-
dataFootnoteBackref: "",
|
|
2758
|
-
className: ["data-footnote-backref"],
|
|
2759
|
-
ariaLabel
|
|
2760
|
-
},
|
|
2761
|
-
children
|
|
2762
|
-
};
|
|
2763
|
-
}
|
|
2764
|
-
function buildAggregateTree(registry, clobberPrefix, preserveOrphanReferences = false) {
|
|
2765
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2766
|
-
const ordered = [];
|
|
2767
|
-
for (const sym of registry.chunkOrder) {
|
|
2768
|
-
const data = registry.chunkData.get(sym);
|
|
2769
|
-
if (!data) continue;
|
|
2770
|
-
for (const ref of data.refs) {
|
|
2771
|
-
if (ref.kind !== "footnote") continue;
|
|
2772
|
-
if (seen.has(ref.label)) continue;
|
|
2773
|
-
seen.add(ref.label);
|
|
2774
|
-
const canonicalSym = registry.canonicalFootnoteFor(ref.label);
|
|
2775
|
-
if (!canonicalSym) continue;
|
|
2776
|
-
const def = registry.chunkData.get(canonicalSym)?.defs.get(ref.label);
|
|
2777
|
-
if (!def) continue;
|
|
2778
|
-
const n = registry.globalNumber(ref.label);
|
|
2779
|
-
if (n === null) continue;
|
|
2780
|
-
const sourceIdentifier = def.sourceIdentifier ?? ref.label;
|
|
2781
|
-
ordered.push({
|
|
2782
|
-
normalizedLabel: ref.label,
|
|
2783
|
-
sourceIdentifier,
|
|
2784
|
-
bodyHast: def.bodyHast ?? [],
|
|
2785
|
-
n,
|
|
2786
|
-
withBackref: true
|
|
2447
|
+
for (const item of plan) {
|
|
2448
|
+
if (item.kind === "inline") {
|
|
2449
|
+
rendered.push({
|
|
2450
|
+
node: renderHastSubtree(item.el, postOptions),
|
|
2451
|
+
reactKey: item.reactKey
|
|
2787
2452
|
});
|
|
2453
|
+
continue;
|
|
2788
2454
|
}
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
const data = registry.chunkData.get(sym);
|
|
2793
|
-
if (!data) continue;
|
|
2794
|
-
for (const [label, def] of data.defs) {
|
|
2795
|
-
if (seen.has(label)) continue;
|
|
2796
|
-
if (registry.canonicalFootnoteFor(label) !== sym) continue;
|
|
2797
|
-
seen.add(label);
|
|
2798
|
-
ordered.push({
|
|
2799
|
-
normalizedLabel: label,
|
|
2800
|
-
sourceIdentifier: def.sourceIdentifier ?? label,
|
|
2801
|
-
bodyHast: def.bodyHast ?? [],
|
|
2802
|
-
n: null,
|
|
2803
|
-
withBackref: false
|
|
2804
|
-
});
|
|
2455
|
+
if (item.kind === "synthetic") {
|
|
2456
|
+
if (postOptions.registry && postOptions.thisChunkSymbol) {
|
|
2457
|
+
continue;
|
|
2805
2458
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
const totalRefs = registry.getRefsForLabel(normalizedLabel);
|
|
2813
|
-
const tailIdx = lastMeaningfulIdx2(liChildren);
|
|
2814
|
-
const tail = tailIdx !== -1 ? liChildren[tailIdx] : null;
|
|
2815
|
-
const dest = tail && tail.type === "element" && tail.tagName === "p" ? tail : null;
|
|
2816
|
-
const appended = [];
|
|
2817
|
-
for (let i = 1; i <= Math.max(totalRefs, 1); i++) {
|
|
2818
|
-
appended.push({ type: "text", value: " " });
|
|
2819
|
-
const href = i === 1 ? `#${clobberPrefix}fnref-${sourceIdentifier}` : `#${clobberPrefix}fnref-${sourceIdentifier}-${i}`;
|
|
2820
|
-
appended.push(buildBackref(href, i, n ?? 0));
|
|
2459
|
+
const cached = prev.footnoteSection;
|
|
2460
|
+
let node;
|
|
2461
|
+
if (cached && cached.ctx === globalCtx) {
|
|
2462
|
+
node = cached.node;
|
|
2463
|
+
} else {
|
|
2464
|
+
node = renderHastSubtree(item.el, postOptions);
|
|
2821
2465
|
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2466
|
+
next.footnoteSection = { ctx: globalCtx, node };
|
|
2467
|
+
rendered.push({ node, reactKey: item.reactKey });
|
|
2468
|
+
continue;
|
|
2469
|
+
}
|
|
2470
|
+
const block = item.info;
|
|
2471
|
+
let bucket = next.blocks.get(block.raw);
|
|
2472
|
+
if (!bucket) {
|
|
2473
|
+
bucket = [];
|
|
2474
|
+
next.blocks.set(block.raw, bucket);
|
|
2475
|
+
}
|
|
2476
|
+
const occ = bucket.length;
|
|
2477
|
+
if (block.hasReference) {
|
|
2478
|
+
const useFingerprint = postOptions.registry && block.taintLabels && postOptions.thisChunkSymbol && postOptions.clobberPrefix !== void 0;
|
|
2479
|
+
const blockCtx = useFingerprint ? computeBlockFingerprint(
|
|
2480
|
+
block.taintLabels,
|
|
2481
|
+
postOptions.registry,
|
|
2482
|
+
postOptions.thisChunkSymbol,
|
|
2483
|
+
postOptions.clobberPrefix
|
|
2484
|
+
) : globalCtx;
|
|
2485
|
+
const entry = prev.blocks.get(block.raw)?.[occ];
|
|
2486
|
+
const valid = entry !== void 0 && entry.ctx === blockCtx && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
|
|
2487
|
+
let node;
|
|
2488
|
+
if (valid) {
|
|
2489
|
+
node = entry.node;
|
|
2826
2490
|
} else {
|
|
2827
|
-
|
|
2491
|
+
node = renderHastSubtree(item.el, postOptions);
|
|
2828
2492
|
}
|
|
2493
|
+
bucket.push({
|
|
2494
|
+
node,
|
|
2495
|
+
ctx: blockCtx,
|
|
2496
|
+
startOffset: block.startOffset,
|
|
2497
|
+
startLine: block.startLine,
|
|
2498
|
+
startColumn: block.startColumn
|
|
2499
|
+
});
|
|
2500
|
+
rendered.push({ node, reactKey: item.reactKey });
|
|
2501
|
+
continue;
|
|
2502
|
+
}
|
|
2503
|
+
{
|
|
2504
|
+
const entry = prev.blocks.get(block.raw)?.[occ];
|
|
2505
|
+
const valid = entry !== void 0 && entry.ctx === "" && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
|
|
2506
|
+
const node = valid ? entry.node : renderHastSubtree(item.el, postOptions);
|
|
2507
|
+
bucket.push({
|
|
2508
|
+
node,
|
|
2509
|
+
ctx: "",
|
|
2510
|
+
startOffset: block.startOffset,
|
|
2511
|
+
startLine: block.startLine,
|
|
2512
|
+
startColumn: block.startColumn
|
|
2513
|
+
});
|
|
2514
|
+
rendered.push({ node, reactKey: item.reactKey });
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
cacheRef.current = next;
|
|
2518
|
+
return rendered;
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
// src/components/collectDefLabels.ts
|
|
2522
|
+
var import_unified2 = require("unified");
|
|
2523
|
+
var import_remark_parse2 = __toESM(require("remark-parse"), 1);
|
|
2524
|
+
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
2525
|
+
var import_unist_util_visit5 = require("unist-util-visit");
|
|
2526
|
+
function buildProcessor() {
|
|
2527
|
+
return (0, import_unified2.unified)().use(import_remark_parse2.default).use(import_remark_gfm.default);
|
|
2528
|
+
}
|
|
2529
|
+
var _processor = null;
|
|
2530
|
+
function processor() {
|
|
2531
|
+
if (!_processor) _processor = buildProcessor();
|
|
2532
|
+
return _processor;
|
|
2533
|
+
}
|
|
2534
|
+
function collectDefLabels(source) {
|
|
2535
|
+
if (!source) {
|
|
2536
|
+
return { footnoteLabels: /* @__PURE__ */ new Set(), linkLabels: /* @__PURE__ */ new Set() };
|
|
2537
|
+
}
|
|
2538
|
+
const mdast = processor().parse(source);
|
|
2539
|
+
const footnoteLabels = /* @__PURE__ */ new Set();
|
|
2540
|
+
const linkLabels = /* @__PURE__ */ new Set();
|
|
2541
|
+
(0, import_unist_util_visit5.visit)(mdast, (node) => {
|
|
2542
|
+
if (node.type === "footnoteDefinition" && "identifier" in node) {
|
|
2543
|
+
footnoteLabels.add(normalizeId(node.identifier));
|
|
2544
|
+
} else if (node.type === "definition" && "identifier" in node) {
|
|
2545
|
+
linkLabels.add(normalizeId(node.identifier));
|
|
2829
2546
|
}
|
|
2830
|
-
return {
|
|
2831
|
-
type: "element",
|
|
2832
|
-
tagName: "li",
|
|
2833
|
-
properties: {
|
|
2834
|
-
id: `${clobberPrefix}fn-${sourceIdentifier}`,
|
|
2835
|
-
...n !== null ? { value: n } : {}
|
|
2836
|
-
},
|
|
2837
|
-
children: liChildren
|
|
2838
|
-
};
|
|
2839
2547
|
});
|
|
2840
|
-
return {
|
|
2841
|
-
type: "element",
|
|
2842
|
-
tagName: "section",
|
|
2843
|
-
properties: {
|
|
2844
|
-
className: ["footnotes"],
|
|
2845
|
-
dataFootnotes: true,
|
|
2846
|
-
// a11y: name the section landmark so screen readers still announce it
|
|
2847
|
-
// even though the visible "Footnotes" h2 is omitted in coordinated mode.
|
|
2848
|
-
ariaLabel: "Footnotes"
|
|
2849
|
-
},
|
|
2850
|
-
children: [
|
|
2851
|
-
// Conventional separator above the footnote list. The default
|
|
2852
|
-
// mdast-util-to-hast footer doesn't emit one (GitHub renders the
|
|
2853
|
-
// separation via CSS `border-top` on `.footnotes`); we render a literal
|
|
2854
|
-
// `<hr>` so the visual break is preserved without sanitize-friendly CSS.
|
|
2855
|
-
{
|
|
2856
|
-
type: "element",
|
|
2857
|
-
tagName: "hr",
|
|
2858
|
-
properties: {},
|
|
2859
|
-
children: []
|
|
2860
|
-
},
|
|
2861
|
-
{
|
|
2862
|
-
type: "element",
|
|
2863
|
-
tagName: "ol",
|
|
2864
|
-
properties: {},
|
|
2865
|
-
children: liElements
|
|
2866
|
-
}
|
|
2867
|
-
]
|
|
2868
|
-
};
|
|
2548
|
+
return { footnoteLabels, linkLabels };
|
|
2869
2549
|
}
|
|
2870
|
-
var AggregateFootnotesIfLastImpl = ({
|
|
2871
|
-
registry,
|
|
2872
|
-
thisChunkSym,
|
|
2873
|
-
clobberPrefix,
|
|
2874
|
-
postOptions,
|
|
2875
|
-
preserveOrphanReferences = false
|
|
2876
|
-
}) => {
|
|
2877
|
-
const tree = (0, import_react6.useMemo)(
|
|
2878
|
-
() => buildAggregateTree(registry, clobberPrefix, preserveOrphanReferences),
|
|
2879
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2880
|
-
[registry, registry.version, clobberPrefix, preserveOrphanReferences]
|
|
2881
|
-
);
|
|
2882
|
-
const order = registry.chunkOrder;
|
|
2883
|
-
if (order.length === 0) return null;
|
|
2884
|
-
if (order[order.length - 1] !== thisChunkSym) return null;
|
|
2885
|
-
if (!tree) return null;
|
|
2886
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: renderHastSubtree(cloneHast(tree), postOptions) });
|
|
2887
|
-
};
|
|
2888
|
-
var AggregateFootnotesIfLast = (0, import_react6.memo)(AggregateFootnotesIfLastImpl);
|
|
2889
|
-
AggregateFootnotesIfLast.displayName = "AggregateFootnotesIfLast";
|
|
2890
2550
|
|
|
2891
|
-
// src/components/
|
|
2892
|
-
var
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
if (
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
remarkRehypeOptions,
|
|
2955
|
-
urlTransform,
|
|
2956
|
-
allowedElements,
|
|
2957
|
-
disallowedElements,
|
|
2958
|
-
allowElement,
|
|
2959
|
-
skipHtml,
|
|
2960
|
-
unwrapDisallowed,
|
|
2961
|
-
registry,
|
|
2962
|
-
symbol: sym
|
|
2963
|
-
};
|
|
2964
|
-
}
|
|
2965
|
-
const targetPhantomsRef = (0, import_react7.useRef)({
|
|
2966
|
-
missingFootnotes: /* @__PURE__ */ new Set(),
|
|
2967
|
-
missingLinks: /* @__PURE__ */ new Set()
|
|
2968
|
-
});
|
|
2969
|
-
const targetPhantoms = (0, import_react7.useMemo)(() => {
|
|
2970
|
-
let nextFootnotes;
|
|
2971
|
-
let nextLinks;
|
|
2972
|
-
if (!registry) {
|
|
2973
|
-
nextFootnotes = /* @__PURE__ */ new Set();
|
|
2974
|
-
nextLinks = /* @__PURE__ */ new Set();
|
|
2551
|
+
// src/components/AIMarkdownDocuments.tsx
|
|
2552
|
+
var import_react3 = require("react");
|
|
2553
|
+
|
|
2554
|
+
// src/components/documentRegistry.ts
|
|
2555
|
+
function createRegistry(onEmpty) {
|
|
2556
|
+
const reg = {
|
|
2557
|
+
chunkOrder: [],
|
|
2558
|
+
chunkData: /* @__PURE__ */ new Map(),
|
|
2559
|
+
labelSet: { footnoteLabels: /* @__PURE__ */ new Set(), linkLabels: /* @__PURE__ */ new Set() },
|
|
2560
|
+
version: 0,
|
|
2561
|
+
_reactIdMap: /* @__PURE__ */ new Map(),
|
|
2562
|
+
_subscribers: /* @__PURE__ */ new Set(),
|
|
2563
|
+
_notifyScheduled: false,
|
|
2564
|
+
allocateSymbol(reactId) {
|
|
2565
|
+
const existing = this._reactIdMap.get(reactId);
|
|
2566
|
+
if (existing) {
|
|
2567
|
+
existing.refcount++;
|
|
2568
|
+
return existing.symbol;
|
|
2569
|
+
}
|
|
2570
|
+
const sym = Symbol(reactId);
|
|
2571
|
+
this._reactIdMap.set(reactId, { symbol: sym, refcount: 1 });
|
|
2572
|
+
this.chunkOrder.push(sym);
|
|
2573
|
+
this._notify();
|
|
2574
|
+
return sym;
|
|
2575
|
+
},
|
|
2576
|
+
registerChunk(reactId, footnotes, links) {
|
|
2577
|
+
const sym = this.allocateSymbol(reactId);
|
|
2578
|
+
this.contributeLabels(sym, footnotes, links);
|
|
2579
|
+
return sym;
|
|
2580
|
+
},
|
|
2581
|
+
releaseSymbol(reactId) {
|
|
2582
|
+
const entry = this._reactIdMap.get(reactId);
|
|
2583
|
+
if (!entry) return;
|
|
2584
|
+
entry.refcount--;
|
|
2585
|
+
if (entry.refcount === 0) {
|
|
2586
|
+
queueMicrotask(() => {
|
|
2587
|
+
const latest = this._reactIdMap.get(reactId);
|
|
2588
|
+
if (latest && latest.refcount === 0) {
|
|
2589
|
+
this._reactIdMap.delete(reactId);
|
|
2590
|
+
const idx = this.chunkOrder.indexOf(entry.symbol);
|
|
2591
|
+
if (idx !== -1) this.chunkOrder.splice(idx, 1);
|
|
2592
|
+
this.chunkData.delete(entry.symbol);
|
|
2593
|
+
const nextFn = /* @__PURE__ */ new Set();
|
|
2594
|
+
const nextLink = /* @__PURE__ */ new Set();
|
|
2595
|
+
for (const cd of this.chunkData.values()) {
|
|
2596
|
+
for (const l of cd.ownFootnoteLabels) nextFn.add(l);
|
|
2597
|
+
for (const l of cd.ownLinkLabels) nextLink.add(l);
|
|
2598
|
+
}
|
|
2599
|
+
this.labelSet.footnoteLabels = nextFn;
|
|
2600
|
+
this.labelSet.linkLabels = nextLink;
|
|
2601
|
+
this._notify();
|
|
2602
|
+
if (this.chunkOrder.length === 0 && this.chunkData.size === 0 && onEmpty) {
|
|
2603
|
+
onEmpty();
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
contributeLabels(symbol, footnotes, links) {
|
|
2610
|
+
const data = this.chunkData.get(symbol);
|
|
2611
|
+
if (data) {
|
|
2612
|
+
data.ownFootnoteLabels = footnotes;
|
|
2613
|
+
data.ownLinkLabels = links;
|
|
2975
2614
|
} else {
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
}
|
|
2983
|
-
for (const label of registry.labelSet.linkLabels) {
|
|
2984
|
-
if (ownLabels.linkLabels.has(label)) continue;
|
|
2985
|
-
if (normalized.includes(label)) nextLinks.add(label);
|
|
2986
|
-
}
|
|
2615
|
+
this.chunkData.set(symbol, {
|
|
2616
|
+
refs: [],
|
|
2617
|
+
defs: /* @__PURE__ */ new Map(),
|
|
2618
|
+
linkDefs: /* @__PURE__ */ new Map(),
|
|
2619
|
+
ownFootnoteLabels: footnotes,
|
|
2620
|
+
ownLinkLabels: links
|
|
2621
|
+
});
|
|
2987
2622
|
}
|
|
2988
|
-
const
|
|
2989
|
-
|
|
2990
|
-
|
|
2623
|
+
const newFn = /* @__PURE__ */ new Set();
|
|
2624
|
+
const newLink = /* @__PURE__ */ new Set();
|
|
2625
|
+
for (const cd of this.chunkData.values()) {
|
|
2626
|
+
for (const l of cd.ownFootnoteLabels) newFn.add(l);
|
|
2627
|
+
for (const l of cd.ownLinkLabels) newLink.add(l);
|
|
2991
2628
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
},
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
const
|
|
3002
|
-
|
|
2629
|
+
this.labelSet.footnoteLabels = newFn;
|
|
2630
|
+
this.labelSet.linkLabels = newLink;
|
|
2631
|
+
this._notify();
|
|
2632
|
+
},
|
|
2633
|
+
contributeChunkData(symbol, data) {
|
|
2634
|
+
this.chunkData.set(symbol, data);
|
|
2635
|
+
this.labelSet.footnoteLabels = /* @__PURE__ */ new Set();
|
|
2636
|
+
this.labelSet.linkLabels = /* @__PURE__ */ new Set();
|
|
2637
|
+
for (const cd of this.chunkData.values()) {
|
|
2638
|
+
for (const l of cd.ownFootnoteLabels) this.labelSet.footnoteLabels.add(l);
|
|
2639
|
+
for (const l of cd.ownLinkLabels) this.labelSet.linkLabels.add(l);
|
|
3003
2640
|
}
|
|
3004
|
-
|
|
3005
|
-
},
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
...remarkRehypeOptions,
|
|
3011
|
-
handlers: { ...baseHandlers, ...handlers },
|
|
3012
|
-
// Phantom label sets are empty in standalone mode (no PASS 0.5
|
|
3013
|
-
// injection happened); the footnoteDefinition handler still reads
|
|
3014
|
-
// them via `state.options.phantomFootnoteLabels.has(id)`, which
|
|
3015
|
-
// returns false for every id → orphan-protect path proceeds.
|
|
3016
|
-
phantomFootnoteLabels: targetPhantoms.missingFootnotes,
|
|
3017
|
-
phantomLinkLabels: targetPhantoms.missingLinks,
|
|
3018
|
-
preserveOrphan: preserveForBodyHarvest,
|
|
3019
|
-
documentId
|
|
3020
|
-
} : {
|
|
3021
|
-
...remarkRehypeOptions
|
|
2641
|
+
this._notify();
|
|
2642
|
+
},
|
|
2643
|
+
subscribe(cb) {
|
|
2644
|
+
this._subscribers.add(cb);
|
|
2645
|
+
return () => {
|
|
2646
|
+
this._subscribers.delete(cb);
|
|
3022
2647
|
};
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
}),
|
|
3055
|
-
// `sym` is now real state (setSym after allocateSymbol), so it's a
|
|
3056
|
-
// proper dep and postOptions refreshes when allocation completes.
|
|
3057
|
-
// `registry?.version` stays in deps so the per-block fingerprint cache
|
|
3058
|
-
// path sees the latest registry version on every coordinated update.
|
|
3059
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3060
|
-
[
|
|
3061
|
-
usedComponents,
|
|
3062
|
-
urlTransform,
|
|
3063
|
-
allowedElements,
|
|
3064
|
-
disallowedElements,
|
|
3065
|
-
allowElement,
|
|
3066
|
-
skipHtml,
|
|
3067
|
-
unwrapDisallowed,
|
|
3068
|
-
registry,
|
|
3069
|
-
registry?.version,
|
|
3070
|
-
sym,
|
|
3071
|
-
clobberPrefix
|
|
3072
|
-
]
|
|
3073
|
-
);
|
|
3074
|
-
const lastContributionRef = (0, import_react7.useRef)(null);
|
|
3075
|
-
(0, import_react7.useEffect)(() => {
|
|
3076
|
-
if (!registry || !sym) return;
|
|
3077
|
-
const refs = [];
|
|
3078
|
-
const defMeta = /* @__PURE__ */ new Map();
|
|
3079
|
-
const linkDefs = /* @__PURE__ */ new Map();
|
|
3080
|
-
for (const node of extractContributions(parsed.mdast, {
|
|
3081
|
-
phantomFootnoteLabels: targetPhantoms.missingFootnotes
|
|
3082
|
-
})) {
|
|
3083
|
-
if (node.kind === "ref") {
|
|
3084
|
-
refs.push({ label: node.label, kind: node.refKind, referenceType: node.referenceType });
|
|
3085
|
-
} else if (node.kind === "fnDef") {
|
|
3086
|
-
defMeta.set(node.label, {
|
|
3087
|
-
identifier: node.label,
|
|
3088
|
-
sourceIdentifier: node.sourceIdentifier,
|
|
3089
|
-
contentSource: node.content
|
|
3090
|
-
});
|
|
3091
|
-
} else if (node.kind === "linkDef") {
|
|
3092
|
-
linkDefs.set(node.label, { identifier: node.label, url: node.url, title: node.title });
|
|
2648
|
+
},
|
|
2649
|
+
canonicalFootnoteFor(label) {
|
|
2650
|
+
const id = normalizeId(label);
|
|
2651
|
+
for (const sym of this.chunkOrder) {
|
|
2652
|
+
const data = this.chunkData.get(sym);
|
|
2653
|
+
if (data?.defs.has(id)) return sym;
|
|
2654
|
+
}
|
|
2655
|
+
return null;
|
|
2656
|
+
},
|
|
2657
|
+
canonicalLinkFor(label) {
|
|
2658
|
+
const id = normalizeId(label);
|
|
2659
|
+
for (const sym of this.chunkOrder) {
|
|
2660
|
+
const data = this.chunkData.get(sym);
|
|
2661
|
+
if (data?.linkDefs.has(id)) return sym;
|
|
2662
|
+
}
|
|
2663
|
+
return null;
|
|
2664
|
+
},
|
|
2665
|
+
globalNumber(label) {
|
|
2666
|
+
const id = normalizeId(label);
|
|
2667
|
+
let n = 0;
|
|
2668
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2669
|
+
for (const sym of this.chunkOrder) {
|
|
2670
|
+
const data = this.chunkData.get(sym);
|
|
2671
|
+
if (!data) continue;
|
|
2672
|
+
for (const ref of data.refs) {
|
|
2673
|
+
if (ref.kind !== "footnote") continue;
|
|
2674
|
+
if (!seen.has(ref.label)) {
|
|
2675
|
+
seen.add(ref.label);
|
|
2676
|
+
n++;
|
|
2677
|
+
if (ref.label === id) return n;
|
|
2678
|
+
}
|
|
3093
2679
|
}
|
|
3094
2680
|
}
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
tpfn: Array.from(targetPhantoms.missingFootnotes).sort(),
|
|
3112
|
-
tpl: Array.from(targetPhantoms.missingLinks).sort()
|
|
3113
|
-
});
|
|
3114
|
-
if (lastContributionRef.current?.registry === registry && lastContributionRef.current.symbol === sym && lastContributionRef.current.fp === fp) {
|
|
3115
|
-
return;
|
|
2681
|
+
return null;
|
|
2682
|
+
},
|
|
2683
|
+
resolveLinkDef(label) {
|
|
2684
|
+
const sym = this.canonicalLinkFor(label);
|
|
2685
|
+
if (!sym) return null;
|
|
2686
|
+
return this.chunkData.get(sym)?.linkDefs.get(normalizeId(label)) ?? null;
|
|
2687
|
+
},
|
|
2688
|
+
getRefsForLabel(label) {
|
|
2689
|
+
const id = normalizeId(label);
|
|
2690
|
+
let n = 0;
|
|
2691
|
+
for (const sym of this.chunkOrder) {
|
|
2692
|
+
const data = this.chunkData.get(sym);
|
|
2693
|
+
if (!data) continue;
|
|
2694
|
+
for (const ref of data.refs) {
|
|
2695
|
+
if (ref.kind === "footnote" && ref.label === id) n++;
|
|
2696
|
+
}
|
|
3116
2697
|
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
2698
|
+
return n;
|
|
2699
|
+
},
|
|
2700
|
+
globalOccurrenceForRef(chunkSym, label, localOccurrence) {
|
|
2701
|
+
const id = normalizeId(label);
|
|
2702
|
+
let global2 = 0;
|
|
2703
|
+
for (const sym of this.chunkOrder) {
|
|
2704
|
+
const data = this.chunkData.get(sym);
|
|
2705
|
+
if (!data) continue;
|
|
2706
|
+
let localCount = 0;
|
|
2707
|
+
for (const ref of data.refs) {
|
|
2708
|
+
if (ref.kind !== "footnote") continue;
|
|
2709
|
+
if (ref.label !== id) continue;
|
|
2710
|
+
localCount++;
|
|
2711
|
+
global2++;
|
|
2712
|
+
if (sym === chunkSym && localCount === localOccurrence) return global2;
|
|
2713
|
+
}
|
|
3126
2714
|
}
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
2715
|
+
return null;
|
|
2716
|
+
},
|
|
2717
|
+
_notify() {
|
|
2718
|
+
this.version++;
|
|
2719
|
+
if (this._notifyScheduled) return;
|
|
2720
|
+
this._notifyScheduled = true;
|
|
2721
|
+
queueMicrotask(() => {
|
|
2722
|
+
this._notifyScheduled = false;
|
|
2723
|
+
for (const cb of [...this._subscribers]) cb();
|
|
3134
2724
|
});
|
|
3135
|
-
}, [parsed, ownLabels, registry, targetPhantoms, sym, hast, clobberPrefix]);
|
|
3136
|
-
const rendered = renderBlocksWithCache(cacheRef, built.plan, built.globalCtx, postOptions);
|
|
3137
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ChunkSymbolContext.Provider, { value: sym, children: [
|
|
3138
|
-
rendered.map(({ node, reactKey }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: node }, reactKey)),
|
|
3139
|
-
registry && sym ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3140
|
-
AggregateFootnotesIfLast,
|
|
3141
|
-
{
|
|
3142
|
-
registry,
|
|
3143
|
-
thisChunkSym: sym,
|
|
3144
|
-
clobberPrefix,
|
|
3145
|
-
postOptions,
|
|
3146
|
-
preserveOrphanReferences: effectivePreserveOrphan
|
|
3147
|
-
}
|
|
3148
|
-
) : null
|
|
3149
|
-
] });
|
|
3150
|
-
}
|
|
3151
|
-
);
|
|
3152
|
-
BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
|
|
3153
|
-
var LegacyRenderer = (0, import_react7.memo)(
|
|
3154
|
-
({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions, urlTransform }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3155
|
-
Markdown_default,
|
|
3156
|
-
{
|
|
3157
|
-
remarkPlugins,
|
|
3158
|
-
rehypePlugins,
|
|
3159
|
-
remarkRehypeOptions,
|
|
3160
|
-
components: usedComponents,
|
|
3161
|
-
urlTransform,
|
|
3162
|
-
children: content
|
|
3163
2725
|
}
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
import_remark_gfm2.default,
|
|
3188
|
-
[
|
|
3189
|
-
import_remark_math.default,
|
|
3190
|
-
{
|
|
3191
|
-
// Disable single-dollar inline math to avoid conflicts with currency
|
|
3192
|
-
// signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
|
|
3193
|
-
singleDollarTextMath: false
|
|
3194
|
-
}
|
|
3195
|
-
],
|
|
3196
|
-
// --- Configurable extra syntax plugins ---
|
|
3197
|
-
...extraSyntaxRemarkPlugins,
|
|
3198
|
-
// --- Formatting & normalization ---
|
|
3199
|
-
import_remark_breaks.default,
|
|
3200
|
-
import_remark_emoji.default,
|
|
3201
|
-
import_remark_squeeze_paragraphs.default,
|
|
3202
|
-
import_remark_cjk_friendly.default,
|
|
3203
|
-
import_remark_cjk_friendly_gfm_strikethrough.default,
|
|
3204
|
-
// --- Configurable display optimizations ---
|
|
3205
|
-
...displayOptimizeRemarkPlugins
|
|
3206
|
-
],
|
|
3207
|
-
[extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
|
|
3208
|
-
);
|
|
3209
|
-
const rehypePlugins = (0, import_react7.useMemo)(
|
|
3210
|
-
() => [
|
|
3211
|
-
// Allow raw HTML through so rehype-sanitize can handle it.
|
|
3212
|
-
[import_rehype_raw.default, { passThrough: [] }],
|
|
3213
|
-
// Sanitize HTML while allowing <mark> (highlight), KaTeX class names,
|
|
3214
|
-
// and any extra protocols the caller permitted via the `sanitizeSchema`
|
|
3215
|
-
// prop. Override `clobberPrefix` with the instance-scoped value so every
|
|
3216
|
-
// id and clobberable attribute is namespaced to this `<AIMarkdown>`
|
|
3217
|
-
// instance — the spread order is intentional: our prefix wins over any
|
|
3218
|
-
// caller-supplied prefix on the schema.
|
|
3219
|
-
[import_rehype_sanitize2.default, { ...usedSanitizeSchema, clobberPrefix }],
|
|
3220
|
-
// Normalize the auto-generated `<section data-footnotes>`: strip the
|
|
3221
|
-
// sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
|
|
3222
|
-
// single-doc rendering visually consistent with the cross-chunk aggregate
|
|
3223
|
-
// footer (which builds the same shape from scratch).
|
|
3224
|
-
rehypeFooterAdorn,
|
|
3225
|
-
// Re-prefix intra-document hash hrefs so they match the ids that
|
|
3226
|
-
// rehype-sanitize just clobbered. Must use the SAME prefix as the schema
|
|
3227
|
-
// above — that's why both read from `clobberPrefix`.
|
|
3228
|
-
[rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
|
|
3229
|
-
import_rehype_katex.default,
|
|
3230
|
-
import_rehype_unwrap_images.default
|
|
3231
|
-
],
|
|
3232
|
-
[clobberPrefix, usedSanitizeSchema]
|
|
3233
|
-
);
|
|
3234
|
-
const remarkRehypeOptions = (0, import_react7.useMemo)(
|
|
3235
|
-
() => ({
|
|
3236
|
-
allowDangerousHtml: true,
|
|
3237
|
-
// Suppress mdast-util-to-hast's `user-content-` prefix on footnote
|
|
3238
|
-
// ids/hrefs; rehype-sanitize will apply the same prefix downstream
|
|
3239
|
-
// and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
|
|
3240
|
-
// Without this, ids would end up double-prefixed
|
|
3241
|
-
// (`user-content-user-content-fn-x`).
|
|
3242
|
-
clobberPrefix: "",
|
|
3243
|
-
handlers: {
|
|
3244
|
-
// Inject definition-list HAST handlers when the extension is active.
|
|
3245
|
-
...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
|
|
2726
|
+
};
|
|
2727
|
+
return reg;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
// src/components/AIMarkdownDocuments.tsx
|
|
2731
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2732
|
+
var AIMarkdownDocumentsContext = (0, import_react3.createContext)(null);
|
|
2733
|
+
var NESTED_WRAPPER_MESSAGE = "<AIMarkdownDocuments> must not be nested inside another <AIMarkdownDocuments>. Use a single top-level wrapper per coordinated scope.";
|
|
2734
|
+
var AIMarkdownDocumentsRoot = ({ preserveOrphanReferences, children }) => {
|
|
2735
|
+
const registriesRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
2736
|
+
const value = (0, import_react3.useMemo)(
|
|
2737
|
+
() => ({
|
|
2738
|
+
preserveOrphanReferences,
|
|
2739
|
+
getRegistry(documentId) {
|
|
2740
|
+
let r = registriesRef.current.get(documentId);
|
|
2741
|
+
if (!r) {
|
|
2742
|
+
const created = createRegistry(() => {
|
|
2743
|
+
if (registriesRef.current.get(documentId) === created) {
|
|
2744
|
+
registriesRef.current.delete(documentId);
|
|
2745
|
+
}
|
|
2746
|
+
});
|
|
2747
|
+
r = created;
|
|
2748
|
+
registriesRef.current.set(documentId, r);
|
|
3246
2749
|
}
|
|
3247
|
-
|
|
3248
|
-
[enableDefinitionList]
|
|
3249
|
-
);
|
|
3250
|
-
const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
|
|
3251
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3252
|
-
Renderer,
|
|
3253
|
-
{
|
|
3254
|
-
content,
|
|
3255
|
-
usedComponents,
|
|
3256
|
-
remarkPlugins,
|
|
3257
|
-
rehypePlugins,
|
|
3258
|
-
remarkRehypeOptions,
|
|
3259
|
-
urlTransform
|
|
2750
|
+
return r;
|
|
3260
2751
|
}
|
|
2752
|
+
}),
|
|
2753
|
+
[preserveOrphanReferences]
|
|
2754
|
+
);
|
|
2755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AIMarkdownDocumentsContext.Provider, { value, children });
|
|
2756
|
+
};
|
|
2757
|
+
var AIMarkdownDocuments = ({ preserveOrphanReferences = true, children }) => {
|
|
2758
|
+
const parent = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
|
|
2759
|
+
if (parent !== null) {
|
|
2760
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2761
|
+
throw new Error(NESTED_WRAPPER_MESSAGE);
|
|
2762
|
+
}
|
|
2763
|
+
console.error(
|
|
2764
|
+
`[ai-react-markdown] ${NESTED_WRAPPER_MESSAGE} Falling back to the outer wrapper; the inner wrapper is a no-op.`
|
|
3261
2765
|
);
|
|
2766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
|
|
3262
2767
|
}
|
|
3263
|
-
);
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js
|
|
3271
|
-
var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
|
|
3272
|
-
function setCacheAdd(value) {
|
|
3273
|
-
this.__data__.set(value, HASH_UNDEFINED3);
|
|
3274
|
-
return this;
|
|
2768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AIMarkdownDocumentsRoot, { preserveOrphanReferences, children });
|
|
2769
|
+
};
|
|
2770
|
+
function useDocumentRegistry(documentId) {
|
|
2771
|
+
const ctx = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
|
|
2772
|
+
if (!ctx || !documentId) return null;
|
|
2773
|
+
return ctx.getRegistry(documentId);
|
|
3275
2774
|
}
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
function setCacheHas(value) {
|
|
3280
|
-
return this.__data__.has(value);
|
|
2775
|
+
function usePreserveOrphanReferences(fallback) {
|
|
2776
|
+
const ctx = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
|
|
2777
|
+
return ctx?.preserveOrphanReferences ?? fallback;
|
|
3281
2778
|
}
|
|
3282
|
-
var setCacheHas_default = setCacheHas;
|
|
3283
2779
|
|
|
3284
|
-
//
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
2780
|
+
// src/components/remarkInjectPhantomDefs.ts
|
|
2781
|
+
var SENTINEL_LINK_URL = "__aimd_sentinel_link__";
|
|
2782
|
+
var SENTINEL_FN_CONTENT = "__aimd_sentinel_fn__";
|
|
2783
|
+
function augmentSourceWithPhantoms(source, phantoms) {
|
|
2784
|
+
if (phantoms.missingFootnotes.size === 0 && phantoms.missingLinks.size === 0) {
|
|
2785
|
+
return source;
|
|
3290
2786
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js
|
|
3297
|
-
function arraySome(array, predicate) {
|
|
3298
|
-
var index = -1, length = array == null ? 0 : array.length;
|
|
3299
|
-
while (++index < length) {
|
|
3300
|
-
if (predicate(array[index], index, array)) {
|
|
3301
|
-
return true;
|
|
3302
|
-
}
|
|
2787
|
+
let suffix = "\n\n";
|
|
2788
|
+
for (const label of phantoms.missingLinks) {
|
|
2789
|
+
suffix += `[${label}]: ${SENTINEL_LINK_URL}
|
|
2790
|
+
`;
|
|
3303
2791
|
}
|
|
3304
|
-
|
|
3305
|
-
}
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
function cacheHas(cache, key) {
|
|
3310
|
-
return cache.has(key);
|
|
2792
|
+
for (const label of phantoms.missingFootnotes) {
|
|
2793
|
+
suffix += `[^${label}]: ${SENTINEL_FN_CONTENT}
|
|
2794
|
+
`;
|
|
2795
|
+
}
|
|
2796
|
+
return source + suffix;
|
|
3311
2797
|
}
|
|
3312
|
-
var cacheHas_default = cacheHas;
|
|
3313
2798
|
|
|
3314
|
-
//
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
var arrStacked = stack.get(array);
|
|
3323
|
-
var othStacked = stack.get(other);
|
|
3324
|
-
if (arrStacked && othStacked) {
|
|
3325
|
-
return arrStacked == other && othStacked == array;
|
|
3326
|
-
}
|
|
3327
|
-
var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
|
|
3328
|
-
stack.set(array, other);
|
|
3329
|
-
stack.set(other, array);
|
|
3330
|
-
while (++index < arrLength) {
|
|
3331
|
-
var arrValue = array[index], othValue = other[index];
|
|
3332
|
-
if (customizer) {
|
|
3333
|
-
var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
|
|
3334
|
-
}
|
|
3335
|
-
if (compared !== void 0) {
|
|
3336
|
-
if (compared) {
|
|
3337
|
-
continue;
|
|
2799
|
+
// src/components/customMdastHandlers.ts
|
|
2800
|
+
function buildCrossChunkHandlers() {
|
|
2801
|
+
return {
|
|
2802
|
+
footnoteDefinition: (state, node) => {
|
|
2803
|
+
const s = state;
|
|
2804
|
+
const id = normalizeId(node.identifier);
|
|
2805
|
+
if (s.options.phantomFootnoteLabels.has(id)) {
|
|
2806
|
+
return void 0;
|
|
3338
2807
|
}
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
}
|
|
3342
|
-
if (seen) {
|
|
3343
|
-
if (!arraySome_default(other, function(othValue2, othIndex) {
|
|
3344
|
-
if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
|
|
3345
|
-
return seen.push(othIndex);
|
|
3346
|
-
}
|
|
3347
|
-
})) {
|
|
3348
|
-
result = false;
|
|
3349
|
-
break;
|
|
2808
|
+
if (s.options.preserveOrphan && !s.footnoteOrder.includes(id)) {
|
|
2809
|
+
s.footnoteOrder.push(id);
|
|
3350
2810
|
}
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
2811
|
+
return void 0;
|
|
2812
|
+
},
|
|
2813
|
+
linkReference: ((state, node) => {
|
|
2814
|
+
const s = state;
|
|
2815
|
+
const id = normalizeId(node.identifier);
|
|
2816
|
+
const resolved = s.definitionById.has(id);
|
|
2817
|
+
if (!resolved) {
|
|
2818
|
+
return void 0;
|
|
2819
|
+
}
|
|
2820
|
+
return {
|
|
2821
|
+
type: "element",
|
|
2822
|
+
tagName: "cross-chunk-link",
|
|
2823
|
+
properties: {
|
|
2824
|
+
// `label` is the ORIGINAL source text (mdast's `label` field), NOT
|
|
2825
|
+
// the normalized `identifier`. The placeholder uses it to construct
|
|
2826
|
+
// hrefs that line up with mdast-util-to-hast's default `<li id>`
|
|
2827
|
+
// which also preserves source case. Registry lookups normalize
|
|
2828
|
+
// internally, so cross-chunk case-insensitive matching still works.
|
|
2829
|
+
label: node.label ?? node.identifier,
|
|
2830
|
+
referenceType: node.referenceType,
|
|
2831
|
+
documentId: s.options.documentId
|
|
2832
|
+
},
|
|
2833
|
+
children: s.all(node)
|
|
2834
|
+
};
|
|
2835
|
+
}),
|
|
2836
|
+
imageReference: ((state, node) => {
|
|
2837
|
+
const s = state;
|
|
2838
|
+
const id = normalizeId(node.identifier);
|
|
2839
|
+
const resolved = s.definitionById.has(id);
|
|
2840
|
+
if (!resolved) return void 0;
|
|
2841
|
+
return {
|
|
2842
|
+
type: "element",
|
|
2843
|
+
tagName: "cross-chunk-image",
|
|
2844
|
+
properties: {
|
|
2845
|
+
label: node.label ?? node.identifier,
|
|
2846
|
+
referenceType: node.referenceType,
|
|
2847
|
+
alt: node.alt ?? "",
|
|
2848
|
+
documentId: s.options.documentId
|
|
2849
|
+
},
|
|
2850
|
+
children: []
|
|
2851
|
+
};
|
|
2852
|
+
}),
|
|
2853
|
+
footnoteReference: ((state, node) => {
|
|
2854
|
+
const s = state;
|
|
2855
|
+
const id = normalizeId(node.identifier);
|
|
2856
|
+
const localOccurrence = (s.footnoteCounts.get(id) ?? 0) + 1;
|
|
2857
|
+
s.footnoteCounts.set(id, localOccurrence);
|
|
2858
|
+
if (s.options.phantomFootnoteLabels.has(id)) {
|
|
2859
|
+
return {
|
|
2860
|
+
type: "element",
|
|
2861
|
+
tagName: "footnote-sup",
|
|
2862
|
+
properties: {
|
|
2863
|
+
label: node.identifier,
|
|
2864
|
+
localOccurrence,
|
|
2865
|
+
documentId: s.options.documentId
|
|
2866
|
+
},
|
|
2867
|
+
children: []
|
|
2868
|
+
};
|
|
2869
|
+
}
|
|
2870
|
+
if (!s.footnoteOrder.includes(id)) s.footnoteOrder.push(id);
|
|
2871
|
+
return {
|
|
2872
|
+
type: "element",
|
|
2873
|
+
tagName: "footnote-sup",
|
|
2874
|
+
properties: {
|
|
2875
|
+
label: node.identifier,
|
|
2876
|
+
localOccurrence,
|
|
2877
|
+
documentId: s.options.documentId
|
|
2878
|
+
},
|
|
2879
|
+
children: []
|
|
2880
|
+
};
|
|
2881
|
+
})
|
|
2882
|
+
};
|
|
3359
2883
|
}
|
|
3360
|
-
var equalArrays_default = equalArrays;
|
|
3361
2884
|
|
|
3362
|
-
//
|
|
3363
|
-
|
|
3364
|
-
var index = -1, result = Array(map.size);
|
|
3365
|
-
map.forEach(function(value, key) {
|
|
3366
|
-
result[++index] = [key, value];
|
|
3367
|
-
});
|
|
3368
|
-
return result;
|
|
3369
|
-
}
|
|
3370
|
-
var mapToArray_default = mapToArray;
|
|
2885
|
+
// src/components/crossChunkPlaceholders.tsx
|
|
2886
|
+
var import_react6 = require("react");
|
|
3371
2887
|
|
|
3372
|
-
//
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
set.forEach(function(value) {
|
|
3376
|
-
result[++index] = value;
|
|
3377
|
-
});
|
|
3378
|
-
return result;
|
|
3379
|
-
}
|
|
3380
|
-
var setToArray_default = setToArray;
|
|
2888
|
+
// src/components/chunkSymbolContext.ts
|
|
2889
|
+
var import_react4 = require("react");
|
|
2890
|
+
var ChunkSymbolContext = (0, import_react4.createContext)(null);
|
|
3381
2891
|
|
|
3382
|
-
//
|
|
3383
|
-
var
|
|
3384
|
-
var
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
3399
|
-
switch (tag) {
|
|
3400
|
-
case dataViewTag2:
|
|
3401
|
-
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
|
|
3402
|
-
return false;
|
|
3403
|
-
}
|
|
3404
|
-
object = object.buffer;
|
|
3405
|
-
other = other.buffer;
|
|
3406
|
-
case arrayBufferTag2:
|
|
3407
|
-
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
|
|
3408
|
-
return false;
|
|
3409
|
-
}
|
|
3410
|
-
return true;
|
|
3411
|
-
case boolTag2:
|
|
3412
|
-
case dateTag2:
|
|
3413
|
-
case numberTag2:
|
|
3414
|
-
return eq_default(+object, +other);
|
|
3415
|
-
case errorTag2:
|
|
3416
|
-
return object.name == other.name && object.message == other.message;
|
|
3417
|
-
case regexpTag2:
|
|
3418
|
-
case stringTag2:
|
|
3419
|
-
return object == other + "";
|
|
3420
|
-
case mapTag2:
|
|
3421
|
-
var convert = mapToArray_default;
|
|
3422
|
-
case setTag2:
|
|
3423
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
|
|
3424
|
-
convert || (convert = setToArray_default);
|
|
3425
|
-
if (object.size != other.size && !isPartial) {
|
|
3426
|
-
return false;
|
|
3427
|
-
}
|
|
3428
|
-
var stacked = stack.get(object);
|
|
3429
|
-
if (stacked) {
|
|
3430
|
-
return stacked == other;
|
|
3431
|
-
}
|
|
3432
|
-
bitmask |= COMPARE_UNORDERED_FLAG2;
|
|
3433
|
-
stack.set(object, other);
|
|
3434
|
-
var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
3435
|
-
stack["delete"](object);
|
|
3436
|
-
return result;
|
|
3437
|
-
case symbolTag:
|
|
3438
|
-
if (symbolValueOf) {
|
|
3439
|
-
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
2892
|
+
// src/components/crossChunkUrlContext.ts
|
|
2893
|
+
var import_react5 = require("react");
|
|
2894
|
+
var CrossChunkUrlContext = (0, import_react5.createContext)(null);
|
|
2895
|
+
|
|
2896
|
+
// src/components/crossChunkUrlSanitize.ts
|
|
2897
|
+
function fakeElement(tagName, key, url) {
|
|
2898
|
+
return { type: "element", tagName, properties: { [key]: url }, children: [] };
|
|
2899
|
+
}
|
|
2900
|
+
function isRelative(url, colon) {
|
|
2901
|
+
if (colon === -1) return true;
|
|
2902
|
+
const slash = url.indexOf("/");
|
|
2903
|
+
const questionMark = url.indexOf("?");
|
|
2904
|
+
const numberSign = url.indexOf("#");
|
|
2905
|
+
if (slash !== -1 && colon > slash) return true;
|
|
2906
|
+
if (questionMark !== -1 && colon > questionMark) return true;
|
|
2907
|
+
if (numberSign !== -1 && colon > numberSign) return true;
|
|
3442
2908
|
return false;
|
|
3443
2909
|
}
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
while (++index < length) {
|
|
3450
|
-
array[offset + index] = values[index];
|
|
3451
|
-
}
|
|
3452
|
-
return array;
|
|
2910
|
+
function isProtocolAllowed(url, allowed) {
|
|
2911
|
+
const colon = url.indexOf(":");
|
|
2912
|
+
if (isRelative(url, colon)) return true;
|
|
2913
|
+
const protocol = url.slice(0, colon);
|
|
2914
|
+
return allowed.some((p) => p === protocol);
|
|
3453
2915
|
}
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
2916
|
+
function sanitizeCrossChunkUrl(rawUrl, key, tagName, urlTransform, schema) {
|
|
2917
|
+
const transformed = urlTransform(rawUrl, key, fakeElement(tagName, key, rawUrl));
|
|
2918
|
+
if (transformed == null) return "";
|
|
2919
|
+
const stringUrl = String(transformed);
|
|
2920
|
+
if (stringUrl === "") return "";
|
|
2921
|
+
const callerProtocols = schema.protocols;
|
|
2922
|
+
const allowed = callerProtocols === void 0 || callerProtocols === null ? sanitizeSchema.protocols?.[key] : callerProtocols[key];
|
|
2923
|
+
if (!allowed || allowed.length === 0) return stringUrl;
|
|
2924
|
+
return isProtocolAllowed(stringUrl, allowed) ? stringUrl : "";
|
|
3460
2925
|
}
|
|
3461
|
-
var baseGetAllKeys_default = baseGetAllKeys;
|
|
3462
2926
|
|
|
3463
|
-
//
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
}
|
|
3472
|
-
return result;
|
|
2927
|
+
// src/components/crossChunkPlaceholders.tsx
|
|
2928
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2929
|
+
var SSR_NUM_SNAPSHOT = () => 0;
|
|
2930
|
+
function coerceLocalOccurrence(v) {
|
|
2931
|
+
if (v === void 0) return null;
|
|
2932
|
+
if (typeof v === "number") return Number.isFinite(v) && v >= 1 ? Math.trunc(v) : null;
|
|
2933
|
+
const n = Number(v);
|
|
2934
|
+
return Number.isFinite(n) && n >= 1 ? Math.trunc(n) : null;
|
|
3473
2935
|
}
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
2936
|
+
function FootnoteSupNumber({ label, localOccurrence: localOccurrenceRaw }) {
|
|
2937
|
+
const localOccurrence = coerceLocalOccurrence(localOccurrenceRaw);
|
|
2938
|
+
const { documentId, clobberPrefix } = useAIMarkdownRenderState();
|
|
2939
|
+
const registry = useDocumentRegistry(documentId);
|
|
2940
|
+
const chunkSym = (0, import_react6.useContext)(ChunkSymbolContext);
|
|
2941
|
+
const subscribe = (0, import_react6.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2942
|
+
}, [registry]);
|
|
2943
|
+
const getSnapshot = (0, import_react6.useCallback)(() => registry?.version ?? 0, [registry]);
|
|
2944
|
+
(0, import_react6.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
|
|
2945
|
+
const num = registry?.globalNumber(label) ?? null;
|
|
2946
|
+
if (num === null) return null;
|
|
2947
|
+
if (localOccurrence !== null && !chunkSym) return null;
|
|
2948
|
+
const globalOcc = registry && chunkSym && localOccurrence !== null ? registry.globalOccurrenceForRef(chunkSym, label, localOccurrence) : null;
|
|
2949
|
+
if (localOccurrence !== null && globalOcc === null) return null;
|
|
2950
|
+
const occSuffix = globalOcc !== null && globalOcc > 1 ? `-${globalOcc}` : "";
|
|
2951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("sup", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: `#${clobberPrefix}fn-${label}`, id: `${clobberPrefix}fnref-${label}${occSuffix}`, "data-footnote-ref": true, children: num }) });
|
|
3479
2952
|
}
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
if (object == null) {
|
|
3488
|
-
return [];
|
|
2953
|
+
function reactNodeToText(node) {
|
|
2954
|
+
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
2955
|
+
if (typeof node === "string") return node;
|
|
2956
|
+
if (typeof node === "number" || typeof node === "bigint") return String(node);
|
|
2957
|
+
if (Array.isArray(node)) return node.map(reactNodeToText).join("");
|
|
2958
|
+
if ((0, import_react6.isValidElement)(node)) {
|
|
2959
|
+
return reactNodeToText(node.props.children);
|
|
3489
2960
|
}
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
var objectProto13 = Object.prototype;
|
|
3503
|
-
var hasOwnProperty10 = objectProto13.hasOwnProperty;
|
|
3504
|
-
function baseKeys(object) {
|
|
3505
|
-
if (!isPrototype_default(object)) {
|
|
3506
|
-
return nativeKeys_default(object);
|
|
2961
|
+
return "";
|
|
2962
|
+
}
|
|
2963
|
+
function literalLink(rt, label, children) {
|
|
2964
|
+
const text = reactNodeToText(children);
|
|
2965
|
+
switch (rt) {
|
|
2966
|
+
case "full":
|
|
2967
|
+
return `[${text}][${label}]`;
|
|
2968
|
+
case "collapsed":
|
|
2969
|
+
return `[${label}][]`;
|
|
2970
|
+
case "shortcut":
|
|
2971
|
+
default:
|
|
2972
|
+
return `[${label}]`;
|
|
3507
2973
|
}
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
2974
|
+
}
|
|
2975
|
+
function CrossChunkLink({ label, referenceType, children }) {
|
|
2976
|
+
const { documentId } = useAIMarkdownRenderState();
|
|
2977
|
+
const registry = useDocumentRegistry(documentId);
|
|
2978
|
+
const policy = (0, import_react6.useContext)(CrossChunkUrlContext);
|
|
2979
|
+
const subscribe = (0, import_react6.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2980
|
+
}, [registry]);
|
|
2981
|
+
const getSnapshot = (0, import_react6.useCallback)(() => registry?.version ?? 0, [registry]);
|
|
2982
|
+
(0, import_react6.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
|
|
2983
|
+
const def = registry?.resolveLinkDef(label) ?? null;
|
|
2984
|
+
if (!def) {
|
|
2985
|
+
return literalLink(referenceType, label, children);
|
|
3513
2986
|
}
|
|
3514
|
-
|
|
2987
|
+
const url = sanitizeCrossChunkUrl(
|
|
2988
|
+
def.url,
|
|
2989
|
+
"href",
|
|
2990
|
+
"a",
|
|
2991
|
+
policy?.urlTransform ?? defaultUrlTransform,
|
|
2992
|
+
policy?.sanitizeSchema ?? sanitizeSchema
|
|
2993
|
+
);
|
|
2994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: url, title: def.title, children });
|
|
3515
2995
|
}
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
2996
|
+
function literalImage(rt, label, alt) {
|
|
2997
|
+
switch (rt) {
|
|
2998
|
+
case "full":
|
|
2999
|
+
return `![${alt}][${label}]`;
|
|
3000
|
+
case "collapsed":
|
|
3001
|
+
return `![${alt}][]`;
|
|
3002
|
+
case "shortcut":
|
|
3003
|
+
default:
|
|
3004
|
+
return `![${label}]`;
|
|
3005
|
+
}
|
|
3521
3006
|
}
|
|
3522
|
-
|
|
3007
|
+
function CrossChunkImage({ label, referenceType, alt = "" }) {
|
|
3008
|
+
const { documentId } = useAIMarkdownRenderState();
|
|
3009
|
+
const registry = useDocumentRegistry(documentId);
|
|
3010
|
+
const policy = (0, import_react6.useContext)(CrossChunkUrlContext);
|
|
3011
|
+
const subscribe = (0, import_react6.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
3012
|
+
}, [registry]);
|
|
3013
|
+
const getSnapshot = (0, import_react6.useCallback)(() => registry?.version ?? 0, [registry]);
|
|
3014
|
+
(0, import_react6.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
|
|
3015
|
+
const def = registry?.resolveLinkDef(label) ?? null;
|
|
3016
|
+
if (!def) {
|
|
3017
|
+
return literalImage(referenceType, label, alt);
|
|
3018
|
+
}
|
|
3019
|
+
const url = sanitizeCrossChunkUrl(
|
|
3020
|
+
def.url,
|
|
3021
|
+
"src",
|
|
3022
|
+
"img",
|
|
3023
|
+
policy?.urlTransform ?? defaultUrlTransform,
|
|
3024
|
+
policy?.sanitizeSchema ?? sanitizeSchema
|
|
3025
|
+
);
|
|
3026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: url, alt, title: def.title });
|
|
3027
|
+
}
|
|
3028
|
+
var crossChunkComponents = {
|
|
3029
|
+
"footnote-sup": FootnoteSupNumber,
|
|
3030
|
+
"cross-chunk-link": CrossChunkLink,
|
|
3031
|
+
"cross-chunk-image": CrossChunkImage
|
|
3032
|
+
};
|
|
3523
3033
|
|
|
3524
|
-
//
|
|
3525
|
-
|
|
3526
|
-
|
|
3034
|
+
// src/components/extractContributions.ts
|
|
3035
|
+
var import_unist_util_visit6 = require("unist-util-visit");
|
|
3036
|
+
function fakeAnchorElement(url) {
|
|
3037
|
+
return { type: "element", tagName: "a", properties: { href: url }, children: [] };
|
|
3038
|
+
}
|
|
3039
|
+
function sanitizeDefUrl(url, urlTransform) {
|
|
3040
|
+
if (!urlTransform) return url;
|
|
3041
|
+
const result = urlTransform(url, "href", fakeAnchorElement(url));
|
|
3042
|
+
return result == null ? "" : String(result);
|
|
3043
|
+
}
|
|
3044
|
+
function* extractContributions(mdast, options = {}) {
|
|
3045
|
+
const phantomFn = options.phantomFootnoteLabels;
|
|
3046
|
+
const urlTransform = options.urlTransform;
|
|
3047
|
+
const out = [];
|
|
3048
|
+
(0, import_unist_util_visit6.visit)(mdast, (n) => {
|
|
3049
|
+
if (n.type === "footnoteReference") {
|
|
3050
|
+
out.push({
|
|
3051
|
+
kind: "ref",
|
|
3052
|
+
refKind: "footnote",
|
|
3053
|
+
label: normalizeId(n.identifier)
|
|
3054
|
+
});
|
|
3055
|
+
} else if (n.type === "linkReference") {
|
|
3056
|
+
const r = n;
|
|
3057
|
+
out.push({ kind: "ref", refKind: "link", label: normalizeId(r.identifier), referenceType: r.referenceType });
|
|
3058
|
+
} else if (n.type === "imageReference") {
|
|
3059
|
+
const r = n;
|
|
3060
|
+
out.push({ kind: "ref", refKind: "image", label: normalizeId(r.identifier), referenceType: r.referenceType });
|
|
3061
|
+
} else if (n.type === "footnoteDefinition") {
|
|
3062
|
+
const d = n;
|
|
3063
|
+
const label = normalizeId(d.identifier);
|
|
3064
|
+
if (phantomFn?.has(label)) return import_unist_util_visit6.SKIP;
|
|
3065
|
+
const content = JSON.stringify(d.children ?? []);
|
|
3066
|
+
out.push({ kind: "fnDef", label, sourceIdentifier: d.identifier, content });
|
|
3067
|
+
return import_unist_util_visit6.SKIP;
|
|
3068
|
+
} else if (n.type === "definition") {
|
|
3069
|
+
const d = n;
|
|
3070
|
+
if (d.url === SENTINEL_LINK_URL) return;
|
|
3071
|
+
out.push({
|
|
3072
|
+
kind: "linkDef",
|
|
3073
|
+
label: normalizeId(d.identifier),
|
|
3074
|
+
url: sanitizeDefUrl(d.url, urlTransform),
|
|
3075
|
+
title: d.title
|
|
3076
|
+
});
|
|
3077
|
+
}
|
|
3078
|
+
});
|
|
3079
|
+
for (const c of out) yield c;
|
|
3527
3080
|
}
|
|
3528
|
-
var getAllKeys_default = getAllKeys;
|
|
3529
3081
|
|
|
3530
|
-
//
|
|
3531
|
-
var
|
|
3532
|
-
var
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3082
|
+
// src/components/extractDefBodiesFromHast.ts
|
|
3083
|
+
var import_unist_util_visit7 = require("unist-util-visit");
|
|
3084
|
+
var FN_LI_ID_RE = /(?:^|-)user-content-fn-(.+)$/;
|
|
3085
|
+
function sourceIdFromFootnoteLiId(idProp, clobberPrefix) {
|
|
3086
|
+
let raw = null;
|
|
3087
|
+
if (clobberPrefix !== void 0) {
|
|
3088
|
+
const exactPrefix = `${clobberPrefix}fn-`;
|
|
3089
|
+
if (idProp.startsWith(exactPrefix)) raw = idProp.slice(exactPrefix.length);
|
|
3538
3090
|
}
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
if (!(isPartial ? key in other : hasOwnProperty11.call(other, key))) {
|
|
3543
|
-
return false;
|
|
3544
|
-
}
|
|
3091
|
+
if (raw === null) {
|
|
3092
|
+
const m = idProp.match(FN_LI_ID_RE);
|
|
3093
|
+
raw = m ? m[1] : null;
|
|
3545
3094
|
}
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3095
|
+
if (raw === null) return null;
|
|
3096
|
+
try {
|
|
3097
|
+
return decodeURIComponent(raw);
|
|
3098
|
+
} catch {
|
|
3099
|
+
return raw;
|
|
3550
3100
|
}
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3101
|
+
}
|
|
3102
|
+
function isBackrefAnchor(c) {
|
|
3103
|
+
if (c.type !== "element") return false;
|
|
3104
|
+
const el = c;
|
|
3105
|
+
if (el.tagName !== "a") return false;
|
|
3106
|
+
return Boolean(el.properties && "dataFootnoteBackref" in el.properties);
|
|
3107
|
+
}
|
|
3108
|
+
function isWhitespaceText(c) {
|
|
3109
|
+
if (c.type !== "text") return false;
|
|
3110
|
+
return /^\s*$/.test(c.value);
|
|
3111
|
+
}
|
|
3112
|
+
function lastMeaningfulIdx(children) {
|
|
3113
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
3114
|
+
if (!isWhitespaceText(children[i])) return i;
|
|
3115
|
+
}
|
|
3116
|
+
return -1;
|
|
3117
|
+
}
|
|
3118
|
+
function dropTrailingBackrefs(children) {
|
|
3119
|
+
let trailingWsStart = children.length;
|
|
3120
|
+
while (trailingWsStart > 0 && isWhitespaceText(children[trailingWsStart - 1])) {
|
|
3121
|
+
trailingWsStart--;
|
|
3122
|
+
}
|
|
3123
|
+
let scan = trailingWsStart;
|
|
3124
|
+
let peeledAny = false;
|
|
3125
|
+
while (scan > 0) {
|
|
3126
|
+
const t = children[scan - 1];
|
|
3127
|
+
if (!isBackrefAnchor(t)) break;
|
|
3128
|
+
peeledAny = true;
|
|
3129
|
+
scan -= 1;
|
|
3130
|
+
if (scan > 0 && children[scan - 1].type === "text" && children[scan - 1].value === " ") {
|
|
3131
|
+
scan -= 1;
|
|
3564
3132
|
}
|
|
3565
|
-
skipCtor || (skipCtor = key == "constructor");
|
|
3566
3133
|
}
|
|
3567
|
-
if (
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3134
|
+
if (!peeledAny) return children;
|
|
3135
|
+
const trailing = children.slice(trailingWsStart);
|
|
3136
|
+
if (scan > 0) {
|
|
3137
|
+
const last = children[scan - 1];
|
|
3138
|
+
if (last.type === "text") {
|
|
3139
|
+
const v = last.value;
|
|
3140
|
+
if (v.endsWith(" ") && !/^\s*$/.test(v)) {
|
|
3141
|
+
return [...children.slice(0, scan - 1), { ...last, value: v.slice(0, -1) }, ...trailing];
|
|
3142
|
+
}
|
|
3571
3143
|
}
|
|
3572
3144
|
}
|
|
3573
|
-
|
|
3574
|
-
stack["delete"](other);
|
|
3575
|
-
return result;
|
|
3145
|
+
return [...children.slice(0, scan), ...trailing];
|
|
3576
3146
|
}
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
var Promise2 = getNative_default(root_default, "Promise");
|
|
3585
|
-
var Promise_default = Promise2;
|
|
3586
|
-
|
|
3587
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
|
|
3588
|
-
var Set2 = getNative_default(root_default, "Set");
|
|
3589
|
-
var Set_default = Set2;
|
|
3590
|
-
|
|
3591
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
|
|
3592
|
-
var WeakMap = getNative_default(root_default, "WeakMap");
|
|
3593
|
-
var WeakMap_default = WeakMap;
|
|
3594
|
-
|
|
3595
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
|
|
3596
|
-
var mapTag3 = "[object Map]";
|
|
3597
|
-
var objectTag3 = "[object Object]";
|
|
3598
|
-
var promiseTag = "[object Promise]";
|
|
3599
|
-
var setTag3 = "[object Set]";
|
|
3600
|
-
var weakMapTag2 = "[object WeakMap]";
|
|
3601
|
-
var dataViewTag3 = "[object DataView]";
|
|
3602
|
-
var dataViewCtorString = toSource_default(DataView_default);
|
|
3603
|
-
var mapCtorString = toSource_default(Map_default);
|
|
3604
|
-
var promiseCtorString = toSource_default(Promise_default);
|
|
3605
|
-
var setCtorString = toSource_default(Set_default);
|
|
3606
|
-
var weakMapCtorString = toSource_default(WeakMap_default);
|
|
3607
|
-
var getTag = baseGetTag_default;
|
|
3608
|
-
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) {
|
|
3609
|
-
getTag = function(value) {
|
|
3610
|
-
var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
|
|
3611
|
-
if (ctorString) {
|
|
3612
|
-
switch (ctorString) {
|
|
3613
|
-
case dataViewCtorString:
|
|
3614
|
-
return dataViewTag3;
|
|
3615
|
-
case mapCtorString:
|
|
3616
|
-
return mapTag3;
|
|
3617
|
-
case promiseCtorString:
|
|
3618
|
-
return promiseTag;
|
|
3619
|
-
case setCtorString:
|
|
3620
|
-
return setTag3;
|
|
3621
|
-
case weakMapCtorString:
|
|
3622
|
-
return weakMapTag2;
|
|
3623
|
-
}
|
|
3624
|
-
}
|
|
3625
|
-
return result;
|
|
3626
|
-
};
|
|
3627
|
-
}
|
|
3628
|
-
var getTag_default = getTag;
|
|
3629
|
-
|
|
3630
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js
|
|
3631
|
-
var COMPARE_PARTIAL_FLAG4 = 1;
|
|
3632
|
-
var argsTag3 = "[object Arguments]";
|
|
3633
|
-
var arrayTag2 = "[object Array]";
|
|
3634
|
-
var objectTag4 = "[object Object]";
|
|
3635
|
-
var objectProto15 = Object.prototype;
|
|
3636
|
-
var hasOwnProperty12 = objectProto15.hasOwnProperty;
|
|
3637
|
-
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
3638
|
-
var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
|
|
3639
|
-
objTag = objTag == argsTag3 ? objectTag4 : objTag;
|
|
3640
|
-
othTag = othTag == argsTag3 ? objectTag4 : othTag;
|
|
3641
|
-
var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
|
|
3642
|
-
if (isSameTag && isBuffer_default(object)) {
|
|
3643
|
-
if (!isBuffer_default(other)) {
|
|
3644
|
-
return false;
|
|
3645
|
-
}
|
|
3646
|
-
objIsArr = true;
|
|
3647
|
-
objIsObj = false;
|
|
3147
|
+
function stripBackrefs(liChildren) {
|
|
3148
|
+
if (liChildren.length === 0) return liChildren;
|
|
3149
|
+
const lastIdx = lastMeaningfulIdx(liChildren);
|
|
3150
|
+
if (lastIdx < 0) return liChildren;
|
|
3151
|
+
const last = liChildren[lastIdx];
|
|
3152
|
+
if (isBackrefAnchor(last)) {
|
|
3153
|
+
return dropTrailingBackrefs(liChildren);
|
|
3648
3154
|
}
|
|
3649
|
-
if (
|
|
3650
|
-
|
|
3651
|
-
|
|
3155
|
+
if (last.type === "element" && last.tagName === "p") {
|
|
3156
|
+
const p = last;
|
|
3157
|
+
const newPChildren = dropTrailingBackrefs(p.children);
|
|
3158
|
+
if (newPChildren === p.children) return liChildren;
|
|
3159
|
+
return liChildren.map((c, i) => i === lastIdx ? { ...p, children: newPChildren } : c);
|
|
3652
3160
|
}
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3161
|
+
return liChildren;
|
|
3162
|
+
}
|
|
3163
|
+
function stripLocalOccurrenceFromFootnoteSups(children) {
|
|
3164
|
+
let changed = false;
|
|
3165
|
+
const out = [];
|
|
3166
|
+
for (const c of children) {
|
|
3167
|
+
if (c.type === "element") {
|
|
3168
|
+
const el = c;
|
|
3169
|
+
let nextEl = el;
|
|
3170
|
+
if (el.tagName === "footnote-sup" && el.properties && "localOccurrence" in el.properties) {
|
|
3171
|
+
const { localOccurrence: _drop, ...rest } = el.properties;
|
|
3172
|
+
nextEl = { ...el, properties: rest };
|
|
3173
|
+
changed = true;
|
|
3174
|
+
}
|
|
3175
|
+
const newChildren = stripLocalOccurrenceFromFootnoteSups(nextEl.children);
|
|
3176
|
+
if (newChildren !== nextEl.children) {
|
|
3177
|
+
nextEl = { ...nextEl, children: newChildren };
|
|
3178
|
+
changed = true;
|
|
3179
|
+
}
|
|
3180
|
+
out.push(nextEl);
|
|
3181
|
+
} else {
|
|
3182
|
+
out.push(c);
|
|
3659
3183
|
}
|
|
3660
3184
|
}
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3185
|
+
return changed ? out : children;
|
|
3186
|
+
}
|
|
3187
|
+
function extractDefBodiesFromHast(hast, clobberPrefix) {
|
|
3188
|
+
const out = /* @__PURE__ */ new Map();
|
|
3189
|
+
(0, import_unist_util_visit7.visit)(hast, "element", (sectionNode) => {
|
|
3190
|
+
const sec = sectionNode;
|
|
3191
|
+
if (sec.tagName !== "section") return;
|
|
3192
|
+
if (!(sec.properties && "dataFootnotes" in sec.properties)) return;
|
|
3193
|
+
(0, import_unist_util_visit7.visit)(sec, "element", (liNode) => {
|
|
3194
|
+
const li = liNode;
|
|
3195
|
+
if (li.tagName !== "li") return;
|
|
3196
|
+
const idProp = li.properties?.id;
|
|
3197
|
+
if (typeof idProp !== "string") return;
|
|
3198
|
+
const sourceId = sourceIdFromFootnoteLiId(idProp, clobberPrefix);
|
|
3199
|
+
if (sourceId === null) return;
|
|
3200
|
+
const normalized = normalizeId(sourceId);
|
|
3201
|
+
const stripped = stripBackrefs(li.children);
|
|
3202
|
+
out.set(normalized, stripLocalOccurrenceFromFootnoteSups(stripped));
|
|
3203
|
+
});
|
|
3204
|
+
return import_unist_util_visit7.SKIP;
|
|
3205
|
+
});
|
|
3206
|
+
return out;
|
|
3666
3207
|
}
|
|
3667
|
-
var baseIsEqualDeep_default = baseIsEqualDeep;
|
|
3668
3208
|
|
|
3669
|
-
//
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3209
|
+
// src/components/aggregateFootnotesIfLast.tsx
|
|
3210
|
+
var import_react7 = require("react");
|
|
3211
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3212
|
+
function cloneHast(node) {
|
|
3213
|
+
return JSON.parse(JSON.stringify(node));
|
|
3214
|
+
}
|
|
3215
|
+
function isWhitespaceText2(c) {
|
|
3216
|
+
return c.type === "text" && /^\s*$/.test(c.value);
|
|
3217
|
+
}
|
|
3218
|
+
function lastMeaningfulIdx2(children) {
|
|
3219
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
3220
|
+
if (!isWhitespaceText2(children[i])) return i;
|
|
3676
3221
|
}
|
|
3677
|
-
return
|
|
3222
|
+
return -1;
|
|
3678
3223
|
}
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3224
|
+
function buildBackref(href, occurrence, globalNumber) {
|
|
3225
|
+
const children = [{ type: "text", value: "\u21A9" }];
|
|
3226
|
+
if (occurrence > 1) {
|
|
3227
|
+
children.push({
|
|
3228
|
+
type: "element",
|
|
3229
|
+
tagName: "sup",
|
|
3230
|
+
properties: {},
|
|
3231
|
+
children: [{ type: "text", value: String(occurrence) }]
|
|
3232
|
+
});
|
|
3233
|
+
}
|
|
3234
|
+
const ariaLabel = occurrence === 1 ? `Back to reference ${globalNumber}` : `Back to reference ${globalNumber}-${occurrence}`;
|
|
3235
|
+
return {
|
|
3236
|
+
type: "element",
|
|
3237
|
+
tagName: "a",
|
|
3238
|
+
properties: {
|
|
3239
|
+
href,
|
|
3240
|
+
dataFootnoteBackref: "",
|
|
3241
|
+
className: ["data-footnote-backref"],
|
|
3242
|
+
ariaLabel
|
|
3243
|
+
},
|
|
3244
|
+
children
|
|
3245
|
+
};
|
|
3684
3246
|
}
|
|
3685
|
-
|
|
3247
|
+
function buildAggregateTree(registry, clobberPrefix, preserveOrphanReferences = false) {
|
|
3248
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3249
|
+
const ordered = [];
|
|
3250
|
+
for (const sym of registry.chunkOrder) {
|
|
3251
|
+
const data = registry.chunkData.get(sym);
|
|
3252
|
+
if (!data) continue;
|
|
3253
|
+
for (const ref of data.refs) {
|
|
3254
|
+
if (ref.kind !== "footnote") continue;
|
|
3255
|
+
if (seen.has(ref.label)) continue;
|
|
3256
|
+
seen.add(ref.label);
|
|
3257
|
+
const canonicalSym = registry.canonicalFootnoteFor(ref.label);
|
|
3258
|
+
if (!canonicalSym) continue;
|
|
3259
|
+
const def = registry.chunkData.get(canonicalSym)?.defs.get(ref.label);
|
|
3260
|
+
if (!def) continue;
|
|
3261
|
+
const n = registry.globalNumber(ref.label);
|
|
3262
|
+
if (n === null) continue;
|
|
3263
|
+
const sourceIdentifier = def.sourceIdentifier ?? ref.label;
|
|
3264
|
+
ordered.push({
|
|
3265
|
+
normalizedLabel: ref.label,
|
|
3266
|
+
sourceIdentifier,
|
|
3267
|
+
bodyHast: def.bodyHast ?? [],
|
|
3268
|
+
n,
|
|
3269
|
+
withBackref: true
|
|
3270
|
+
});
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
if (preserveOrphanReferences) {
|
|
3274
|
+
for (const sym of registry.chunkOrder) {
|
|
3275
|
+
const data = registry.chunkData.get(sym);
|
|
3276
|
+
if (!data) continue;
|
|
3277
|
+
for (const [label, def] of data.defs) {
|
|
3278
|
+
if (seen.has(label)) continue;
|
|
3279
|
+
if (registry.canonicalFootnoteFor(label) !== sym) continue;
|
|
3280
|
+
seen.add(label);
|
|
3281
|
+
ordered.push({
|
|
3282
|
+
normalizedLabel: label,
|
|
3283
|
+
sourceIdentifier: def.sourceIdentifier ?? label,
|
|
3284
|
+
bodyHast: def.bodyHast ?? [],
|
|
3285
|
+
n: null,
|
|
3286
|
+
withBackref: false
|
|
3287
|
+
});
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
if (ordered.length === 0) return null;
|
|
3292
|
+
const liElements = ordered.map(({ normalizedLabel, sourceIdentifier, bodyHast, n, withBackref }) => {
|
|
3293
|
+
const liChildren = bodyHast.map((c) => cloneHast(c));
|
|
3294
|
+
if (withBackref) {
|
|
3295
|
+
const totalRefs = registry.getRefsForLabel(normalizedLabel);
|
|
3296
|
+
const tailIdx = lastMeaningfulIdx2(liChildren);
|
|
3297
|
+
const tail = tailIdx !== -1 ? liChildren[tailIdx] : null;
|
|
3298
|
+
const dest = tail && tail.type === "element" && tail.tagName === "p" ? tail : null;
|
|
3299
|
+
const appended = [];
|
|
3300
|
+
for (let i = 1; i <= Math.max(totalRefs, 1); i++) {
|
|
3301
|
+
appended.push({ type: "text", value: " " });
|
|
3302
|
+
const href = i === 1 ? `#${clobberPrefix}fnref-${sourceIdentifier}` : `#${clobberPrefix}fnref-${sourceIdentifier}-${i}`;
|
|
3303
|
+
appended.push(buildBackref(href, i, n ?? 0));
|
|
3304
|
+
}
|
|
3305
|
+
if (dest) {
|
|
3306
|
+
dest.children = [...dest.children, ...appended];
|
|
3307
|
+
} else if (tailIdx !== -1) {
|
|
3308
|
+
liChildren.splice(tailIdx + 1, 0, ...appended);
|
|
3309
|
+
} else {
|
|
3310
|
+
liChildren.push(...appended);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
return {
|
|
3314
|
+
type: "element",
|
|
3315
|
+
tagName: "li",
|
|
3316
|
+
properties: {
|
|
3317
|
+
id: `${clobberPrefix}fn-${sourceIdentifier}`,
|
|
3318
|
+
...n !== null ? { value: n } : {}
|
|
3319
|
+
},
|
|
3320
|
+
children: liChildren
|
|
3321
|
+
};
|
|
3322
|
+
});
|
|
3323
|
+
return {
|
|
3324
|
+
type: "element",
|
|
3325
|
+
tagName: "section",
|
|
3326
|
+
properties: {
|
|
3327
|
+
className: ["footnotes"],
|
|
3328
|
+
dataFootnotes: true,
|
|
3329
|
+
// a11y: name the section landmark so screen readers still announce it
|
|
3330
|
+
// even though the visible "Footnotes" h2 is omitted in coordinated mode.
|
|
3331
|
+
ariaLabel: "Footnotes"
|
|
3332
|
+
},
|
|
3333
|
+
children: [
|
|
3334
|
+
// Conventional separator above the footnote list. The default
|
|
3335
|
+
// mdast-util-to-hast footer doesn't emit one (GitHub renders the
|
|
3336
|
+
// separation via CSS `border-top` on `.footnotes`); we render a literal
|
|
3337
|
+
// `<hr>` so the visual break is preserved without sanitize-friendly CSS.
|
|
3338
|
+
{
|
|
3339
|
+
type: "element",
|
|
3340
|
+
tagName: "hr",
|
|
3341
|
+
properties: {},
|
|
3342
|
+
children: []
|
|
3343
|
+
},
|
|
3344
|
+
{
|
|
3345
|
+
type: "element",
|
|
3346
|
+
tagName: "ol",
|
|
3347
|
+
properties: {},
|
|
3348
|
+
children: liElements
|
|
3349
|
+
}
|
|
3350
|
+
]
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
var AggregateFootnotesIfLastImpl = ({
|
|
3354
|
+
registry,
|
|
3355
|
+
thisChunkSym,
|
|
3356
|
+
clobberPrefix,
|
|
3357
|
+
postOptions,
|
|
3358
|
+
preserveOrphanReferences = false
|
|
3359
|
+
}) => {
|
|
3360
|
+
const tree = (0, import_react7.useMemo)(
|
|
3361
|
+
() => buildAggregateTree(registry, clobberPrefix, preserveOrphanReferences),
|
|
3362
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3363
|
+
[registry, registry.version, clobberPrefix, preserveOrphanReferences]
|
|
3364
|
+
);
|
|
3365
|
+
const order = registry.chunkOrder;
|
|
3366
|
+
if (order.length === 0) return null;
|
|
3367
|
+
if (order[order.length - 1] !== thisChunkSym) return null;
|
|
3368
|
+
if (!tree) return null;
|
|
3369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: renderHastSubtree(cloneHast(tree), postOptions) });
|
|
3370
|
+
};
|
|
3371
|
+
var AggregateFootnotesIfLast = (0, import_react7.memo)(AggregateFootnotesIfLastImpl);
|
|
3372
|
+
AggregateFootnotesIfLast.displayName = "AggregateFootnotesIfLast";
|
|
3373
|
+
|
|
3374
|
+
// src/components/MarkdownContent.tsx
|
|
3375
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3376
|
+
var REGISTRY_SSR_SNAPSHOT = () => 0;
|
|
3377
|
+
var DisplayOptimizeRemarkPluginMap = {
|
|
3378
|
+
["REMOVE_COMMENTS" /* REMOVE_COMMENTS */]: import_remark_remove_comments.default,
|
|
3379
|
+
["SMARTYPANTS" /* SMARTYPANTS */]: import_remark_smartypants.default,
|
|
3380
|
+
["PANGU" /* PANGU */]: import_remark_pangu.default
|
|
3381
|
+
};
|
|
3382
|
+
var ExtraSyntaxRemarkPluginMap = {
|
|
3383
|
+
["HIGHLIGHT" /* HIGHLIGHT */]: import_remark_mark_highlight.remarkMark,
|
|
3384
|
+
["DEFINITION_LIST" /* DEFINITION_LIST */]: import_remark_definition_list.remarkDefinitionList
|
|
3385
|
+
};
|
|
3386
|
+
var DefaultCustomComponents = {};
|
|
3387
|
+
var BlockMemoizedRenderer = (0, import_react8.memo)(
|
|
3388
|
+
({
|
|
3389
|
+
content,
|
|
3390
|
+
usedComponents,
|
|
3391
|
+
remarkPlugins,
|
|
3392
|
+
rehypePlugins,
|
|
3393
|
+
remarkRehypeOptions,
|
|
3394
|
+
urlTransform,
|
|
3395
|
+
sanitizeSchema: usedSanitizeSchema
|
|
3396
|
+
}) => {
|
|
3397
|
+
const allowedElements = void 0;
|
|
3398
|
+
const disallowedElements = void 0;
|
|
3399
|
+
const allowElement = void 0;
|
|
3400
|
+
const skipHtml = void 0;
|
|
3401
|
+
const unwrapDisallowed = void 0;
|
|
3402
|
+
const { documentId, clobberPrefix, config } = useAIMarkdownRenderState();
|
|
3403
|
+
const reactId = (0, import_react8.useId)();
|
|
3404
|
+
const registry = useDocumentRegistry(documentId);
|
|
3405
|
+
const [allocation, setAllocation] = (0, import_react8.useState)(null);
|
|
3406
|
+
const sym = allocation && allocation.registry === registry ? allocation.sym : null;
|
|
3407
|
+
const subscribeRegistry = (0, import_react8.useCallback)(
|
|
3408
|
+
(cb) => registry ? registry.subscribe(cb) : () => {
|
|
3409
|
+
},
|
|
3410
|
+
[registry]
|
|
3411
|
+
);
|
|
3412
|
+
const getRegistryVersion = (0, import_react8.useCallback)(() => registry?.version ?? 0, [registry]);
|
|
3413
|
+
(0, import_react8.useSyncExternalStore)(subscribeRegistry, getRegistryVersion, REGISTRY_SSR_SNAPSHOT);
|
|
3414
|
+
const ownLabels = (0, import_react8.useMemo)(() => collectDefLabels(content ?? ""), [content]);
|
|
3415
|
+
(0, import_react8.useEffect)(() => {
|
|
3416
|
+
if (!registry) return;
|
|
3417
|
+
const s = registry.registerChunk(reactId, ownLabels.footnoteLabels, ownLabels.linkLabels);
|
|
3418
|
+
setAllocation({ registry, sym: s });
|
|
3419
|
+
return () => {
|
|
3420
|
+
registry.releaseSymbol(reactId);
|
|
3421
|
+
setAllocation(null);
|
|
3422
|
+
};
|
|
3423
|
+
}, [reactId, registry, ownLabels]);
|
|
3424
|
+
const cacheRef = (0, import_react8.useRef)(createCache());
|
|
3425
|
+
const depsRef = (0, import_react8.useRef)({
|
|
3426
|
+
usedComponents,
|
|
3427
|
+
remarkPlugins,
|
|
3428
|
+
rehypePlugins,
|
|
3429
|
+
remarkRehypeOptions,
|
|
3430
|
+
urlTransform,
|
|
3431
|
+
allowedElements,
|
|
3432
|
+
disallowedElements,
|
|
3433
|
+
allowElement,
|
|
3434
|
+
skipHtml,
|
|
3435
|
+
unwrapDisallowed,
|
|
3436
|
+
registry,
|
|
3437
|
+
symbol: sym
|
|
3438
|
+
});
|
|
3439
|
+
if (depsRef.current.usedComponents !== usedComponents || depsRef.current.remarkPlugins !== remarkPlugins || depsRef.current.rehypePlugins !== rehypePlugins || depsRef.current.remarkRehypeOptions !== remarkRehypeOptions || depsRef.current.urlTransform !== urlTransform || depsRef.current.allowedElements !== allowedElements || depsRef.current.disallowedElements !== disallowedElements || depsRef.current.allowElement !== allowElement || depsRef.current.skipHtml !== skipHtml || depsRef.current.unwrapDisallowed !== unwrapDisallowed || depsRef.current.registry !== registry || depsRef.current.symbol !== sym) {
|
|
3440
|
+
cacheRef.current = createCache();
|
|
3441
|
+
depsRef.current = {
|
|
3442
|
+
usedComponents,
|
|
3443
|
+
remarkPlugins,
|
|
3444
|
+
rehypePlugins,
|
|
3445
|
+
remarkRehypeOptions,
|
|
3446
|
+
urlTransform,
|
|
3447
|
+
allowedElements,
|
|
3448
|
+
disallowedElements,
|
|
3449
|
+
allowElement,
|
|
3450
|
+
skipHtml,
|
|
3451
|
+
unwrapDisallowed,
|
|
3452
|
+
registry,
|
|
3453
|
+
symbol: sym
|
|
3454
|
+
};
|
|
3455
|
+
}
|
|
3456
|
+
const targetPhantomsRef = (0, import_react8.useRef)({
|
|
3457
|
+
missingFootnotes: /* @__PURE__ */ new Set(),
|
|
3458
|
+
missingLinks: /* @__PURE__ */ new Set()
|
|
3459
|
+
});
|
|
3460
|
+
const targetPhantoms = (0, import_react8.useMemo)(() => {
|
|
3461
|
+
let nextFootnotes;
|
|
3462
|
+
let nextLinks;
|
|
3463
|
+
if (!registry) {
|
|
3464
|
+
nextFootnotes = /* @__PURE__ */ new Set();
|
|
3465
|
+
nextLinks = /* @__PURE__ */ new Set();
|
|
3466
|
+
} else {
|
|
3467
|
+
const normalized = normalizeForMatch(content ?? "");
|
|
3468
|
+
nextFootnotes = /* @__PURE__ */ new Set();
|
|
3469
|
+
nextLinks = /* @__PURE__ */ new Set();
|
|
3470
|
+
for (const label of registry.labelSet.footnoteLabels) {
|
|
3471
|
+
if (ownLabels.footnoteLabels.has(label)) continue;
|
|
3472
|
+
if (normalized.includes(label)) nextFootnotes.add(label);
|
|
3473
|
+
}
|
|
3474
|
+
for (const label of registry.labelSet.linkLabels) {
|
|
3475
|
+
if (ownLabels.linkLabels.has(label)) continue;
|
|
3476
|
+
if (normalized.includes(label)) nextLinks.add(label);
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
const prev = targetPhantomsRef.current;
|
|
3480
|
+
if (nextFootnotes.size === prev.missingFootnotes.size && nextLinks.size === prev.missingLinks.size && [...nextFootnotes].every((l) => prev.missingFootnotes.has(l)) && [...nextLinks].every((l) => prev.missingLinks.has(l))) {
|
|
3481
|
+
return prev;
|
|
3482
|
+
}
|
|
3483
|
+
const next = { missingFootnotes: nextFootnotes, missingLinks: nextLinks };
|
|
3484
|
+
targetPhantomsRef.current = next;
|
|
3485
|
+
return next;
|
|
3486
|
+
}, [registry, registry?.version, content, ownLabels]);
|
|
3487
|
+
const effectivePreserveOrphan = usePreserveOrphanReferences(config.preserveOrphanReferences);
|
|
3488
|
+
const preserveForBodyHarvest = effectivePreserveOrphan || Boolean(registry && sym);
|
|
3489
|
+
const handlers = (0, import_react8.useMemo)(() => {
|
|
3490
|
+
if (registry) return buildCrossChunkHandlers();
|
|
3491
|
+
if (effectivePreserveOrphan) {
|
|
3492
|
+
const { footnoteDefinition } = buildCrossChunkHandlers();
|
|
3493
|
+
return { footnoteDefinition };
|
|
3494
|
+
}
|
|
3495
|
+
return void 0;
|
|
3496
|
+
}, [registry, effectivePreserveOrphan]);
|
|
3497
|
+
const parsed = (0, import_react8.useMemo)(() => {
|
|
3498
|
+
const augmented = augmentSourceWithPhantoms(content ?? "", targetPhantoms);
|
|
3499
|
+
const baseHandlers = remarkRehypeOptions?.handlers ?? {};
|
|
3500
|
+
const mergedRemarkRehypeOptions = handlers ? {
|
|
3501
|
+
...remarkRehypeOptions,
|
|
3502
|
+
handlers: { ...baseHandlers, ...handlers },
|
|
3503
|
+
// Phantom label sets are empty in standalone mode (no PASS 0.5
|
|
3504
|
+
// injection happened); the footnoteDefinition handler still reads
|
|
3505
|
+
// them via `state.options.phantomFootnoteLabels.has(id)`, which
|
|
3506
|
+
// returns false for every id → orphan-protect path proceeds.
|
|
3507
|
+
phantomFootnoteLabels: targetPhantoms.missingFootnotes,
|
|
3508
|
+
phantomLinkLabels: targetPhantoms.missingLinks,
|
|
3509
|
+
preserveOrphan: preserveForBodyHarvest,
|
|
3510
|
+
documentId
|
|
3511
|
+
} : {
|
|
3512
|
+
...remarkRehypeOptions
|
|
3513
|
+
};
|
|
3514
|
+
return parseStage({
|
|
3515
|
+
children: augmented,
|
|
3516
|
+
remarkPlugins,
|
|
3517
|
+
rehypePlugins,
|
|
3518
|
+
remarkRehypeOptions: mergedRemarkRehypeOptions
|
|
3519
|
+
});
|
|
3520
|
+
}, [
|
|
3521
|
+
content,
|
|
3522
|
+
targetPhantoms,
|
|
3523
|
+
remarkPlugins,
|
|
3524
|
+
rehypePlugins,
|
|
3525
|
+
remarkRehypeOptions,
|
|
3526
|
+
handlers,
|
|
3527
|
+
preserveForBodyHarvest,
|
|
3528
|
+
documentId
|
|
3529
|
+
]);
|
|
3530
|
+
const hast = (0, import_react8.useMemo)(() => transformStage(parsed), [parsed]);
|
|
3531
|
+
const built = (0, import_react8.useMemo)(() => buildBlocks(parsed.mdast, hast, content ?? ""), [parsed.mdast, hast, content]);
|
|
3532
|
+
const postOptions = (0, import_react8.useMemo)(
|
|
3533
|
+
() => ({
|
|
3534
|
+
components: { ...crossChunkComponents, ...usedComponents },
|
|
3535
|
+
urlTransform,
|
|
3536
|
+
allowedElements,
|
|
3537
|
+
disallowedElements,
|
|
3538
|
+
allowElement,
|
|
3539
|
+
skipHtml,
|
|
3540
|
+
unwrapDisallowed,
|
|
3541
|
+
// v6 fingerprint cache fields:
|
|
3542
|
+
registry: registry ?? void 0,
|
|
3543
|
+
thisChunkSymbol: sym ?? void 0,
|
|
3544
|
+
clobberPrefix
|
|
3545
|
+
}),
|
|
3546
|
+
// `sym` is now real state (setSym after allocateSymbol), so it's a
|
|
3547
|
+
// proper dep and postOptions refreshes when allocation completes.
|
|
3548
|
+
// `registry?.version` stays in deps so the per-block fingerprint cache
|
|
3549
|
+
// path sees the latest registry version on every coordinated update.
|
|
3550
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3551
|
+
[
|
|
3552
|
+
usedComponents,
|
|
3553
|
+
urlTransform,
|
|
3554
|
+
allowedElements,
|
|
3555
|
+
disallowedElements,
|
|
3556
|
+
allowElement,
|
|
3557
|
+
skipHtml,
|
|
3558
|
+
unwrapDisallowed,
|
|
3559
|
+
registry,
|
|
3560
|
+
registry?.version,
|
|
3561
|
+
sym,
|
|
3562
|
+
clobberPrefix
|
|
3563
|
+
]
|
|
3564
|
+
);
|
|
3565
|
+
const lastContributionRef = (0, import_react8.useRef)(null);
|
|
3566
|
+
(0, import_react8.useEffect)(() => {
|
|
3567
|
+
if (!registry || !sym) return;
|
|
3568
|
+
const refs = [];
|
|
3569
|
+
const defMeta = /* @__PURE__ */ new Map();
|
|
3570
|
+
const linkDefs = /* @__PURE__ */ new Map();
|
|
3571
|
+
const resolvedUrlTransform = urlTransform ?? defaultUrlTransform;
|
|
3572
|
+
for (const node of extractContributions(parsed.mdast, {
|
|
3573
|
+
phantomFootnoteLabels: targetPhantoms.missingFootnotes,
|
|
3574
|
+
urlTransform: resolvedUrlTransform
|
|
3575
|
+
})) {
|
|
3576
|
+
if (node.kind === "ref") {
|
|
3577
|
+
refs.push({ label: node.label, kind: node.refKind, referenceType: node.referenceType });
|
|
3578
|
+
} else if (node.kind === "fnDef") {
|
|
3579
|
+
defMeta.set(node.label, {
|
|
3580
|
+
identifier: node.label,
|
|
3581
|
+
sourceIdentifier: node.sourceIdentifier,
|
|
3582
|
+
contentSource: node.content
|
|
3583
|
+
});
|
|
3584
|
+
} else if (node.kind === "linkDef") {
|
|
3585
|
+
linkDefs.set(node.label, { identifier: node.label, url: node.url, title: node.title });
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
const fp = JSON.stringify({
|
|
3589
|
+
r: refs,
|
|
3590
|
+
d: Array.from(defMeta.entries()).map(([k, v]) => [k, v.sourceIdentifier, v.contentSource]),
|
|
3591
|
+
l: Array.from(linkDefs.entries()).map(([k, v]) => [k, v.url, v.title ?? ""]),
|
|
3592
|
+
ofn: Array.from(ownLabels.footnoteLabels).sort(),
|
|
3593
|
+
ol: Array.from(ownLabels.linkLabels).sort(),
|
|
3594
|
+
// Include targetPhantoms in the fingerprint: a phantom→resolved
|
|
3595
|
+
// transition (another chunk publishes a def for a label this chunk
|
|
3596
|
+
// references inside one of its OWN def bodies) changes the rendered
|
|
3597
|
+
// hast — the `<cross-chunk-link>` / `<cross-chunk-image>` placeholder
|
|
3598
|
+
// disappears and a real `<a>` / `<img>` takes its place — without
|
|
3599
|
+
// touching this chunk's refs / defMeta / linkDefs / ownLabels. Without
|
|
3600
|
+
// including the phantom snapshot in the fingerprint, the fp check
|
|
3601
|
+
// would short-circuit and the registry would keep stale bodyHast
|
|
3602
|
+
// forever, leaving the aggregate footer rendering the placeholder
|
|
3603
|
+
// long after the label was resolved.
|
|
3604
|
+
tpfn: Array.from(targetPhantoms.missingFootnotes).sort(),
|
|
3605
|
+
tpl: Array.from(targetPhantoms.missingLinks).sort()
|
|
3606
|
+
});
|
|
3607
|
+
if (lastContributionRef.current?.registry === registry && lastContributionRef.current.symbol === sym && lastContributionRef.current.fp === fp) {
|
|
3608
|
+
return;
|
|
3609
|
+
}
|
|
3610
|
+
const bodiesByLabel = extractDefBodiesFromHast(hast, clobberPrefix);
|
|
3611
|
+
const defs = /* @__PURE__ */ new Map();
|
|
3612
|
+
for (const [label, meta] of defMeta) {
|
|
3613
|
+
defs.set(label, {
|
|
3614
|
+
identifier: meta.identifier,
|
|
3615
|
+
sourceIdentifier: meta.sourceIdentifier,
|
|
3616
|
+
contentSource: meta.contentSource,
|
|
3617
|
+
bodyHast: bodiesByLabel.get(label) ?? []
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3620
|
+
lastContributionRef.current = { registry, symbol: sym, fp };
|
|
3621
|
+
registry.contributeChunkData(sym, {
|
|
3622
|
+
refs,
|
|
3623
|
+
defs,
|
|
3624
|
+
linkDefs,
|
|
3625
|
+
ownFootnoteLabels: ownLabels.footnoteLabels,
|
|
3626
|
+
ownLinkLabels: ownLabels.linkLabels
|
|
3627
|
+
});
|
|
3628
|
+
}, [parsed, ownLabels, registry, targetPhantoms, sym, hast, clobberPrefix, urlTransform]);
|
|
3629
|
+
const rendered = renderBlocksWithCache(cacheRef, built.plan, built.globalCtx, postOptions);
|
|
3630
|
+
const crossChunkUrlPolicy = (0, import_react8.useMemo)(
|
|
3631
|
+
() => ({
|
|
3632
|
+
urlTransform: urlTransform || defaultUrlTransform,
|
|
3633
|
+
sanitizeSchema: usedSanitizeSchema
|
|
3634
|
+
}),
|
|
3635
|
+
[urlTransform, usedSanitizeSchema]
|
|
3636
|
+
);
|
|
3637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CrossChunkUrlContext.Provider, { value: crossChunkUrlPolicy, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ChunkSymbolContext.Provider, { value: sym, children: [
|
|
3638
|
+
rendered.map(({ node, reactKey }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react8.Fragment, { children: node }, reactKey)),
|
|
3639
|
+
registry && sym ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3640
|
+
AggregateFootnotesIfLast,
|
|
3641
|
+
{
|
|
3642
|
+
registry,
|
|
3643
|
+
thisChunkSym: sym,
|
|
3644
|
+
clobberPrefix,
|
|
3645
|
+
postOptions,
|
|
3646
|
+
preserveOrphanReferences: effectivePreserveOrphan
|
|
3647
|
+
}
|
|
3648
|
+
) : null
|
|
3649
|
+
] }) });
|
|
3650
|
+
}
|
|
3651
|
+
);
|
|
3652
|
+
BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
|
|
3653
|
+
var LegacyRenderer = (0, import_react8.memo)(
|
|
3654
|
+
// `sanitizeSchema` is accepted (and ignored) here purely for prop-shape
|
|
3655
|
+
// parity with `BlockMemoizedRenderer` — legacy mode skips cross-chunk
|
|
3656
|
+
// coordination entirely, so there's no placeholder needing the schema.
|
|
3657
|
+
// Rebind to an underscore-prefixed local so the project's
|
|
3658
|
+
// no-unused-vars rule (which allows `_`-prefixed names) accepts it.
|
|
3659
|
+
({
|
|
3660
|
+
content,
|
|
3661
|
+
usedComponents,
|
|
3662
|
+
remarkPlugins,
|
|
3663
|
+
rehypePlugins,
|
|
3664
|
+
remarkRehypeOptions,
|
|
3665
|
+
urlTransform,
|
|
3666
|
+
sanitizeSchema: _sanitizeSchema
|
|
3667
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3668
|
+
Markdown_default,
|
|
3669
|
+
{
|
|
3670
|
+
remarkPlugins,
|
|
3671
|
+
rehypePlugins,
|
|
3672
|
+
remarkRehypeOptions,
|
|
3673
|
+
components: usedComponents,
|
|
3674
|
+
urlTransform,
|
|
3675
|
+
children: content
|
|
3676
|
+
}
|
|
3677
|
+
)
|
|
3678
|
+
);
|
|
3679
|
+
LegacyRenderer.displayName = "LegacyRenderer";
|
|
3680
|
+
var AIMarkdownContent = (0, import_react8.memo)(
|
|
3681
|
+
({ content, customComponents, urlTransform, sanitizeSchema: customSanitizeSchema }) => {
|
|
3682
|
+
const { config, clobberPrefix } = useAIMarkdownRenderState();
|
|
3683
|
+
const usedSanitizeSchema = customSanitizeSchema ?? sanitizeSchema;
|
|
3684
|
+
const { extraSyntaxRemarkPlugins, enableDefinitionList } = (0, import_react8.useMemo)(
|
|
3685
|
+
() => ({
|
|
3686
|
+
extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
|
|
3687
|
+
enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
|
|
3688
|
+
}),
|
|
3689
|
+
[config.extraSyntaxSupported]
|
|
3690
|
+
);
|
|
3691
|
+
const displayOptimizeRemarkPlugins = (0, import_react8.useMemo)(() => {
|
|
3692
|
+
return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
|
|
3693
|
+
}, [config.displayOptimizeAbilities]);
|
|
3694
|
+
const usedComponents = (0, import_react8.useMemo)(() => {
|
|
3695
|
+
return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
|
|
3696
|
+
}, [customComponents]);
|
|
3697
|
+
const remarkPlugins = (0, import_react8.useMemo)(
|
|
3698
|
+
() => [
|
|
3699
|
+
// --- Core plugins (always active) ---
|
|
3700
|
+
import_remark_gfm2.default,
|
|
3701
|
+
[
|
|
3702
|
+
import_remark_math.default,
|
|
3703
|
+
{
|
|
3704
|
+
// Disable single-dollar inline math to avoid conflicts with currency
|
|
3705
|
+
// signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
|
|
3706
|
+
singleDollarTextMath: false
|
|
3707
|
+
}
|
|
3708
|
+
],
|
|
3709
|
+
// --- Configurable extra syntax plugins ---
|
|
3710
|
+
...extraSyntaxRemarkPlugins,
|
|
3711
|
+
// --- Formatting & normalization ---
|
|
3712
|
+
import_remark_breaks.default,
|
|
3713
|
+
import_remark_emoji.default,
|
|
3714
|
+
import_remark_squeeze_paragraphs.default,
|
|
3715
|
+
import_remark_cjk_friendly.default,
|
|
3716
|
+
import_remark_cjk_friendly_gfm_strikethrough.default,
|
|
3717
|
+
// --- Configurable display optimizations ---
|
|
3718
|
+
...displayOptimizeRemarkPlugins
|
|
3719
|
+
],
|
|
3720
|
+
[extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
|
|
3721
|
+
);
|
|
3722
|
+
const rehypePlugins = (0, import_react8.useMemo)(
|
|
3723
|
+
() => [
|
|
3724
|
+
// Allow raw HTML through so rehype-sanitize can handle it.
|
|
3725
|
+
[import_rehype_raw.default, { passThrough: [] }],
|
|
3726
|
+
// Sanitize HTML while allowing <mark> (highlight), KaTeX class names,
|
|
3727
|
+
// and any extra protocols the caller permitted via the `sanitizeSchema`
|
|
3728
|
+
// prop. Override `clobberPrefix` with the instance-scoped value so every
|
|
3729
|
+
// id and clobberable attribute is namespaced to this `<AIMarkdown>`
|
|
3730
|
+
// instance — the spread order is intentional: our prefix wins over any
|
|
3731
|
+
// caller-supplied prefix on the schema.
|
|
3732
|
+
[import_rehype_sanitize2.default, { ...usedSanitizeSchema, clobberPrefix }],
|
|
3733
|
+
// Normalize the auto-generated `<section data-footnotes>`: strip the
|
|
3734
|
+
// sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
|
|
3735
|
+
// single-doc rendering visually consistent with the cross-chunk aggregate
|
|
3736
|
+
// footer (which builds the same shape from scratch).
|
|
3737
|
+
rehypeFooterAdorn,
|
|
3738
|
+
// Re-prefix intra-document hash hrefs so they match the ids that
|
|
3739
|
+
// rehype-sanitize just clobbered. Must use the SAME prefix as the schema
|
|
3740
|
+
// above — that's why both read from `clobberPrefix`.
|
|
3741
|
+
[rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
|
|
3742
|
+
import_rehype_katex.default,
|
|
3743
|
+
import_rehype_unwrap_images.default
|
|
3744
|
+
],
|
|
3745
|
+
[clobberPrefix, usedSanitizeSchema]
|
|
3746
|
+
);
|
|
3747
|
+
const remarkRehypeOptions = (0, import_react8.useMemo)(
|
|
3748
|
+
() => ({
|
|
3749
|
+
allowDangerousHtml: true,
|
|
3750
|
+
// Suppress mdast-util-to-hast's `user-content-` prefix on footnote
|
|
3751
|
+
// ids/hrefs; rehype-sanitize will apply the same prefix downstream
|
|
3752
|
+
// and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
|
|
3753
|
+
// Without this, ids would end up double-prefixed
|
|
3754
|
+
// (`user-content-user-content-fn-x`).
|
|
3755
|
+
clobberPrefix: "",
|
|
3756
|
+
handlers: {
|
|
3757
|
+
// Inject definition-list HAST handlers when the extension is active.
|
|
3758
|
+
...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
|
|
3759
|
+
}
|
|
3760
|
+
}),
|
|
3761
|
+
[enableDefinitionList]
|
|
3762
|
+
);
|
|
3763
|
+
const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
|
|
3764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3765
|
+
Renderer,
|
|
3766
|
+
{
|
|
3767
|
+
content,
|
|
3768
|
+
usedComponents,
|
|
3769
|
+
remarkPlugins,
|
|
3770
|
+
rehypePlugins,
|
|
3771
|
+
remarkRehypeOptions,
|
|
3772
|
+
urlTransform,
|
|
3773
|
+
sanitizeSchema: usedSanitizeSchema
|
|
3774
|
+
}
|
|
3775
|
+
);
|
|
3776
|
+
}
|
|
3777
|
+
);
|
|
3778
|
+
AIMarkdownContent.displayName = "AIMarkdownContent";
|
|
3779
|
+
var MarkdownContent_default = AIMarkdownContent;
|
|
3686
3780
|
|
|
3687
3781
|
// src/hooks/useStableValue.ts
|
|
3688
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react8.useLayoutEffect : import_react8.useEffect;
|
|
3689
|
-
function useStableValue(value) {
|
|
3690
|
-
const ref = (0, import_react8.useRef)(value);
|
|
3691
|
-
const prev = ref.current;
|
|
3692
|
-
const stableValue = isEqual_default(prev, value) ? prev : value;
|
|
3693
|
-
useIsomorphicLayoutEffect(() => {
|
|
3694
|
-
ref.current = stableValue;
|
|
3695
|
-
}, [stableValue]);
|
|
3696
|
-
return stableValue;
|
|
3697
|
-
}
|
|
3698
|
-
|
|
3699
|
-
// src/hooks/useReferenceFlipWarning.ts
|
|
3700
3782
|
var import_react9 = require("react");
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
var
|
|
3704
|
-
function
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
state.prev = value;
|
|
3708
|
-
if (state.flips < FLIP_THRESHOLD) return;
|
|
3709
|
-
if (now - state.lastWarnAt < WARN_COOLDOWN_MS) return;
|
|
3710
|
-
state.lastWarnAt = now;
|
|
3711
|
-
console.warn(
|
|
3712
|
-
`[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.`
|
|
3713
|
-
);
|
|
3783
|
+
|
|
3784
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js
|
|
3785
|
+
var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
|
|
3786
|
+
function setCacheAdd(value) {
|
|
3787
|
+
this.__data__.set(value, HASH_UNDEFINED3);
|
|
3788
|
+
return this;
|
|
3714
3789
|
}
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3790
|
+
var setCacheAdd_default = setCacheAdd;
|
|
3791
|
+
|
|
3792
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js
|
|
3793
|
+
function setCacheHas(value) {
|
|
3794
|
+
return this.__data__.has(value);
|
|
3719
3795
|
}
|
|
3796
|
+
var setCacheHas_default = setCacheHas;
|
|
3720
3797
|
|
|
3721
|
-
//
|
|
3722
|
-
|
|
3723
|
-
var
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
(
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
DefaultTypography.displayName = "DefaultTypography";
|
|
3733
|
-
var Default_default = DefaultTypography;
|
|
3798
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js
|
|
3799
|
+
function SetCache(values) {
|
|
3800
|
+
var index = -1, length = values == null ? 0 : values.length;
|
|
3801
|
+
this.__data__ = new MapCache_default();
|
|
3802
|
+
while (++index < length) {
|
|
3803
|
+
this.add(values[index]);
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
|
|
3807
|
+
SetCache.prototype.has = setCacheHas_default;
|
|
3808
|
+
var SetCache_default = SetCache;
|
|
3734
3809
|
|
|
3735
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
3736
|
-
function
|
|
3810
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js
|
|
3811
|
+
function arraySome(array, predicate) {
|
|
3737
3812
|
var index = -1, length = array == null ? 0 : array.length;
|
|
3738
3813
|
while (++index < length) {
|
|
3739
|
-
if (
|
|
3740
|
-
|
|
3814
|
+
if (predicate(array[index], index, array)) {
|
|
3815
|
+
return true;
|
|
3741
3816
|
}
|
|
3742
3817
|
}
|
|
3743
|
-
return
|
|
3744
|
-
}
|
|
3745
|
-
var arrayEach_default = arrayEach;
|
|
3746
|
-
|
|
3747
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js
|
|
3748
|
-
function baseAssign(object, source) {
|
|
3749
|
-
return object && copyObject_default(source, keys_default(source), object);
|
|
3750
|
-
}
|
|
3751
|
-
var baseAssign_default = baseAssign;
|
|
3752
|
-
|
|
3753
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js
|
|
3754
|
-
function baseAssignIn(object, source) {
|
|
3755
|
-
return object && copyObject_default(source, keysIn_default(source), object);
|
|
3818
|
+
return false;
|
|
3756
3819
|
}
|
|
3757
|
-
var
|
|
3820
|
+
var arraySome_default = arraySome;
|
|
3758
3821
|
|
|
3759
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
3760
|
-
function
|
|
3761
|
-
return
|
|
3822
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js
|
|
3823
|
+
function cacheHas(cache, key) {
|
|
3824
|
+
return cache.has(key);
|
|
3762
3825
|
}
|
|
3763
|
-
var
|
|
3826
|
+
var cacheHas_default = cacheHas;
|
|
3764
3827
|
|
|
3765
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
3766
|
-
var
|
|
3767
|
-
var
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3828
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js
|
|
3829
|
+
var COMPARE_PARTIAL_FLAG = 1;
|
|
3830
|
+
var COMPARE_UNORDERED_FLAG = 2;
|
|
3831
|
+
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
3832
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
|
|
3833
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
3834
|
+
return false;
|
|
3772
3835
|
}
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3836
|
+
var arrStacked = stack.get(array);
|
|
3837
|
+
var othStacked = stack.get(other);
|
|
3838
|
+
if (arrStacked && othStacked) {
|
|
3839
|
+
return arrStacked == other && othStacked == array;
|
|
3840
|
+
}
|
|
3841
|
+
var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
|
|
3842
|
+
stack.set(array, other);
|
|
3843
|
+
stack.set(other, array);
|
|
3844
|
+
while (++index < arrLength) {
|
|
3845
|
+
var arrValue = array[index], othValue = other[index];
|
|
3846
|
+
if (customizer) {
|
|
3847
|
+
var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
|
|
3848
|
+
}
|
|
3849
|
+
if (compared !== void 0) {
|
|
3850
|
+
if (compared) {
|
|
3851
|
+
continue;
|
|
3852
|
+
}
|
|
3853
|
+
result = false;
|
|
3854
|
+
break;
|
|
3855
|
+
}
|
|
3856
|
+
if (seen) {
|
|
3857
|
+
if (!arraySome_default(other, function(othValue2, othIndex) {
|
|
3858
|
+
if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
|
|
3859
|
+
return seen.push(othIndex);
|
|
3860
|
+
}
|
|
3861
|
+
})) {
|
|
3862
|
+
result = false;
|
|
3863
|
+
break;
|
|
3864
|
+
}
|
|
3865
|
+
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
3866
|
+
result = false;
|
|
3867
|
+
break;
|
|
3868
|
+
}
|
|
3797
3869
|
}
|
|
3870
|
+
stack["delete"](array);
|
|
3871
|
+
stack["delete"](other);
|
|
3798
3872
|
return result;
|
|
3799
3873
|
}
|
|
3800
|
-
var
|
|
3801
|
-
|
|
3802
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js
|
|
3803
|
-
function cloneDataView(dataView, isDeep) {
|
|
3804
|
-
var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
|
|
3805
|
-
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
|
3806
|
-
}
|
|
3807
|
-
var cloneDataView_default = cloneDataView;
|
|
3874
|
+
var equalArrays_default = equalArrays;
|
|
3808
3875
|
|
|
3809
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3876
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js
|
|
3877
|
+
function mapToArray(map) {
|
|
3878
|
+
var index = -1, result = Array(map.size);
|
|
3879
|
+
map.forEach(function(value, key) {
|
|
3880
|
+
result[++index] = [key, value];
|
|
3881
|
+
});
|
|
3814
3882
|
return result;
|
|
3815
3883
|
}
|
|
3816
|
-
var
|
|
3817
|
-
|
|
3818
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js
|
|
3819
|
-
var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
|
|
3820
|
-
var symbolValueOf2 = symbolProto2 ? symbolProto2.valueOf : void 0;
|
|
3821
|
-
function cloneSymbol(symbol) {
|
|
3822
|
-
return symbolValueOf2 ? Object(symbolValueOf2.call(symbol)) : {};
|
|
3823
|
-
}
|
|
3824
|
-
var cloneSymbol_default = cloneSymbol;
|
|
3825
|
-
|
|
3826
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js
|
|
3827
|
-
var boolTag3 = "[object Boolean]";
|
|
3828
|
-
var dateTag3 = "[object Date]";
|
|
3829
|
-
var mapTag4 = "[object Map]";
|
|
3830
|
-
var numberTag3 = "[object Number]";
|
|
3831
|
-
var regexpTag3 = "[object RegExp]";
|
|
3832
|
-
var setTag4 = "[object Set]";
|
|
3833
|
-
var stringTag3 = "[object String]";
|
|
3834
|
-
var symbolTag2 = "[object Symbol]";
|
|
3835
|
-
var arrayBufferTag3 = "[object ArrayBuffer]";
|
|
3836
|
-
var dataViewTag4 = "[object DataView]";
|
|
3837
|
-
var float32Tag2 = "[object Float32Array]";
|
|
3838
|
-
var float64Tag2 = "[object Float64Array]";
|
|
3839
|
-
var int8Tag2 = "[object Int8Array]";
|
|
3840
|
-
var int16Tag2 = "[object Int16Array]";
|
|
3841
|
-
var int32Tag2 = "[object Int32Array]";
|
|
3842
|
-
var uint8Tag2 = "[object Uint8Array]";
|
|
3843
|
-
var uint8ClampedTag2 = "[object Uint8ClampedArray]";
|
|
3844
|
-
var uint16Tag2 = "[object Uint16Array]";
|
|
3845
|
-
var uint32Tag2 = "[object Uint32Array]";
|
|
3846
|
-
function initCloneByTag(object, tag, isDeep) {
|
|
3847
|
-
var Ctor = object.constructor;
|
|
3848
|
-
switch (tag) {
|
|
3849
|
-
case arrayBufferTag3:
|
|
3850
|
-
return cloneArrayBuffer_default(object);
|
|
3851
|
-
case boolTag3:
|
|
3852
|
-
case dateTag3:
|
|
3853
|
-
return new Ctor(+object);
|
|
3854
|
-
case dataViewTag4:
|
|
3855
|
-
return cloneDataView_default(object, isDeep);
|
|
3856
|
-
case float32Tag2:
|
|
3857
|
-
case float64Tag2:
|
|
3858
|
-
case int8Tag2:
|
|
3859
|
-
case int16Tag2:
|
|
3860
|
-
case int32Tag2:
|
|
3861
|
-
case uint8Tag2:
|
|
3862
|
-
case uint8ClampedTag2:
|
|
3863
|
-
case uint16Tag2:
|
|
3864
|
-
case uint32Tag2:
|
|
3865
|
-
return cloneTypedArray_default(object, isDeep);
|
|
3866
|
-
case mapTag4:
|
|
3867
|
-
return new Ctor();
|
|
3868
|
-
case numberTag3:
|
|
3869
|
-
case stringTag3:
|
|
3870
|
-
return new Ctor(object);
|
|
3871
|
-
case regexpTag3:
|
|
3872
|
-
return cloneRegExp_default(object);
|
|
3873
|
-
case setTag4:
|
|
3874
|
-
return new Ctor();
|
|
3875
|
-
case symbolTag2:
|
|
3876
|
-
return cloneSymbol_default(object);
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
var initCloneByTag_default = initCloneByTag;
|
|
3880
|
-
|
|
3881
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js
|
|
3882
|
-
var mapTag5 = "[object Map]";
|
|
3883
|
-
function baseIsMap(value) {
|
|
3884
|
-
return isObjectLike_default(value) && getTag_default(value) == mapTag5;
|
|
3885
|
-
}
|
|
3886
|
-
var baseIsMap_default = baseIsMap;
|
|
3887
|
-
|
|
3888
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isMap.js
|
|
3889
|
-
var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
|
|
3890
|
-
var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
|
|
3891
|
-
var isMap_default = isMap;
|
|
3892
|
-
|
|
3893
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js
|
|
3894
|
-
var setTag5 = "[object Set]";
|
|
3895
|
-
function baseIsSet(value) {
|
|
3896
|
-
return isObjectLike_default(value) && getTag_default(value) == setTag5;
|
|
3897
|
-
}
|
|
3898
|
-
var baseIsSet_default = baseIsSet;
|
|
3884
|
+
var mapToArray_default = mapToArray;
|
|
3899
3885
|
|
|
3900
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
3901
|
-
|
|
3902
|
-
var
|
|
3903
|
-
|
|
3886
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js
|
|
3887
|
+
function setToArray(set) {
|
|
3888
|
+
var index = -1, result = Array(set.size);
|
|
3889
|
+
set.forEach(function(value) {
|
|
3890
|
+
result[++index] = value;
|
|
3891
|
+
});
|
|
3892
|
+
return result;
|
|
3893
|
+
}
|
|
3894
|
+
var setToArray_default = setToArray;
|
|
3904
3895
|
|
|
3905
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
3906
|
-
var
|
|
3907
|
-
var
|
|
3908
|
-
var CLONE_SYMBOLS_FLAG = 4;
|
|
3909
|
-
var argsTag4 = "[object Arguments]";
|
|
3910
|
-
var arrayTag3 = "[object Array]";
|
|
3896
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js
|
|
3897
|
+
var COMPARE_PARTIAL_FLAG2 = 1;
|
|
3898
|
+
var COMPARE_UNORDERED_FLAG2 = 2;
|
|
3911
3899
|
var boolTag4 = "[object Boolean]";
|
|
3912
3900
|
var dateTag4 = "[object Date]";
|
|
3913
3901
|
var errorTag3 = "[object Error]";
|
|
3914
|
-
var funcTag3 = "[object Function]";
|
|
3915
|
-
var genTag2 = "[object GeneratorFunction]";
|
|
3916
3902
|
var mapTag6 = "[object Map]";
|
|
3917
3903
|
var numberTag4 = "[object Number]";
|
|
3918
|
-
var objectTag5 = "[object Object]";
|
|
3919
3904
|
var regexpTag4 = "[object RegExp]";
|
|
3920
3905
|
var setTag6 = "[object Set]";
|
|
3921
3906
|
var stringTag4 = "[object String]";
|
|
3922
3907
|
var symbolTag3 = "[object Symbol]";
|
|
3923
|
-
var weakMapTag3 = "[object WeakMap]";
|
|
3924
3908
|
var arrayBufferTag4 = "[object ArrayBuffer]";
|
|
3925
3909
|
var dataViewTag5 = "[object DataView]";
|
|
3926
|
-
var
|
|
3927
|
-
var
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3910
|
+
var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
|
|
3911
|
+
var symbolValueOf2 = symbolProto2 ? symbolProto2.valueOf : void 0;
|
|
3912
|
+
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
3913
|
+
switch (tag) {
|
|
3914
|
+
case dataViewTag5:
|
|
3915
|
+
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
|
|
3916
|
+
return false;
|
|
3917
|
+
}
|
|
3918
|
+
object = object.buffer;
|
|
3919
|
+
other = other.buffer;
|
|
3920
|
+
case arrayBufferTag4:
|
|
3921
|
+
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
|
|
3922
|
+
return false;
|
|
3923
|
+
}
|
|
3924
|
+
return true;
|
|
3925
|
+
case boolTag4:
|
|
3926
|
+
case dateTag4:
|
|
3927
|
+
case numberTag4:
|
|
3928
|
+
return eq_default(+object, +other);
|
|
3929
|
+
case errorTag3:
|
|
3930
|
+
return object.name == other.name && object.message == other.message;
|
|
3931
|
+
case regexpTag4:
|
|
3932
|
+
case stringTag4:
|
|
3933
|
+
return object == other + "";
|
|
3934
|
+
case mapTag6:
|
|
3935
|
+
var convert = mapToArray_default;
|
|
3936
|
+
case setTag6:
|
|
3937
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
|
|
3938
|
+
convert || (convert = setToArray_default);
|
|
3939
|
+
if (object.size != other.size && !isPartial) {
|
|
3940
|
+
return false;
|
|
3941
|
+
}
|
|
3942
|
+
var stacked = stack.get(object);
|
|
3943
|
+
if (stacked) {
|
|
3944
|
+
return stacked == other;
|
|
3945
|
+
}
|
|
3946
|
+
bitmask |= COMPARE_UNORDERED_FLAG2;
|
|
3947
|
+
stack.set(object, other);
|
|
3948
|
+
var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
3949
|
+
stack["delete"](object);
|
|
3950
|
+
return result;
|
|
3951
|
+
case symbolTag3:
|
|
3952
|
+
if (symbolValueOf2) {
|
|
3953
|
+
return symbolValueOf2.call(object) == symbolValueOf2.call(other);
|
|
3954
|
+
}
|
|
3942
3955
|
}
|
|
3943
|
-
|
|
3944
|
-
|
|
3956
|
+
return false;
|
|
3957
|
+
}
|
|
3958
|
+
var equalByTag_default = equalByTag;
|
|
3959
|
+
|
|
3960
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js
|
|
3961
|
+
var COMPARE_PARTIAL_FLAG3 = 1;
|
|
3962
|
+
var objectProto15 = Object.prototype;
|
|
3963
|
+
var hasOwnProperty12 = objectProto15.hasOwnProperty;
|
|
3964
|
+
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
3965
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
|
|
3966
|
+
if (objLength != othLength && !isPartial) {
|
|
3967
|
+
return false;
|
|
3945
3968
|
}
|
|
3946
|
-
|
|
3947
|
-
|
|
3969
|
+
var index = objLength;
|
|
3970
|
+
while (index--) {
|
|
3971
|
+
var key = objProps[index];
|
|
3972
|
+
if (!(isPartial ? key in other : hasOwnProperty12.call(other, key))) {
|
|
3973
|
+
return false;
|
|
3974
|
+
}
|
|
3948
3975
|
}
|
|
3949
|
-
var
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3976
|
+
var objStacked = stack.get(object);
|
|
3977
|
+
var othStacked = stack.get(other);
|
|
3978
|
+
if (objStacked && othStacked) {
|
|
3979
|
+
return objStacked == other && othStacked == object;
|
|
3980
|
+
}
|
|
3981
|
+
var result = true;
|
|
3982
|
+
stack.set(object, other);
|
|
3983
|
+
stack.set(other, object);
|
|
3984
|
+
var skipCtor = isPartial;
|
|
3985
|
+
while (++index < objLength) {
|
|
3986
|
+
key = objProps[index];
|
|
3987
|
+
var objValue = object[key], othValue = other[key];
|
|
3988
|
+
if (customizer) {
|
|
3989
|
+
var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
|
|
3954
3990
|
}
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
return cloneBuffer_default(value, isDeep);
|
|
3991
|
+
if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
|
|
3992
|
+
result = false;
|
|
3993
|
+
break;
|
|
3959
3994
|
}
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
if (!cloneableTags[tag]) {
|
|
3967
|
-
return object ? value : {};
|
|
3968
|
-
}
|
|
3969
|
-
result = initCloneByTag_default(value, tag, isDeep);
|
|
3995
|
+
skipCtor || (skipCtor = key == "constructor");
|
|
3996
|
+
}
|
|
3997
|
+
if (result && !skipCtor) {
|
|
3998
|
+
var objCtor = object.constructor, othCtor = other.constructor;
|
|
3999
|
+
if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
|
|
4000
|
+
result = false;
|
|
3970
4001
|
}
|
|
3971
4002
|
}
|
|
3972
|
-
stack
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
4003
|
+
stack["delete"](object);
|
|
4004
|
+
stack["delete"](other);
|
|
4005
|
+
return result;
|
|
4006
|
+
}
|
|
4007
|
+
var equalObjects_default = equalObjects;
|
|
4008
|
+
|
|
4009
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js
|
|
4010
|
+
var COMPARE_PARTIAL_FLAG4 = 1;
|
|
4011
|
+
var argsTag4 = "[object Arguments]";
|
|
4012
|
+
var arrayTag3 = "[object Array]";
|
|
4013
|
+
var objectTag5 = "[object Object]";
|
|
4014
|
+
var objectProto16 = Object.prototype;
|
|
4015
|
+
var hasOwnProperty13 = objectProto16.hasOwnProperty;
|
|
4016
|
+
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
4017
|
+
var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag3 : getTag_default(object), othTag = othIsArr ? arrayTag3 : getTag_default(other);
|
|
4018
|
+
objTag = objTag == argsTag4 ? objectTag5 : objTag;
|
|
4019
|
+
othTag = othTag == argsTag4 ? objectTag5 : othTag;
|
|
4020
|
+
var objIsObj = objTag == objectTag5, othIsObj = othTag == objectTag5, isSameTag = objTag == othTag;
|
|
4021
|
+
if (isSameTag && isBuffer_default(object)) {
|
|
4022
|
+
if (!isBuffer_default(other)) {
|
|
4023
|
+
return false;
|
|
4024
|
+
}
|
|
4025
|
+
objIsArr = true;
|
|
4026
|
+
objIsObj = false;
|
|
3976
4027
|
}
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
|
3981
|
-
});
|
|
3982
|
-
} else if (isMap_default(value)) {
|
|
3983
|
-
value.forEach(function(subValue, key2) {
|
|
3984
|
-
result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
|
3985
|
-
});
|
|
4028
|
+
if (isSameTag && !objIsObj) {
|
|
4029
|
+
stack || (stack = new Stack_default());
|
|
4030
|
+
return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
3986
4031
|
}
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
4032
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
|
|
4033
|
+
var objIsWrapped = objIsObj && hasOwnProperty13.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty13.call(other, "__wrapped__");
|
|
4034
|
+
if (objIsWrapped || othIsWrapped) {
|
|
4035
|
+
var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
|
|
4036
|
+
stack || (stack = new Stack_default());
|
|
4037
|
+
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
3993
4038
|
}
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
4039
|
+
}
|
|
4040
|
+
if (!isSameTag) {
|
|
4041
|
+
return false;
|
|
4042
|
+
}
|
|
4043
|
+
stack || (stack = new Stack_default());
|
|
4044
|
+
return equalObjects_default(object, other, bitmask, customizer, equalFunc, stack);
|
|
3997
4045
|
}
|
|
3998
|
-
var
|
|
4046
|
+
var baseIsEqualDeep_default = baseIsEqualDeep;
|
|
3999
4047
|
|
|
4000
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4048
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js
|
|
4049
|
+
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
4050
|
+
if (value === other) {
|
|
4051
|
+
return true;
|
|
4052
|
+
}
|
|
4053
|
+
if (value == null || other == null || !isObjectLike_default(value) && !isObjectLike_default(other)) {
|
|
4054
|
+
return value !== value && other !== other;
|
|
4055
|
+
}
|
|
4056
|
+
return baseIsEqualDeep_default(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
4005
4057
|
}
|
|
4006
|
-
var
|
|
4058
|
+
var baseIsEqual_default = baseIsEqual;
|
|
4059
|
+
|
|
4060
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js
|
|
4061
|
+
function isEqual(value, other) {
|
|
4062
|
+
return baseIsEqual_default(value, other);
|
|
4063
|
+
}
|
|
4064
|
+
var isEqual_default = isEqual;
|
|
4065
|
+
|
|
4066
|
+
// src/hooks/useStableValue.ts
|
|
4067
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react9.useLayoutEffect : import_react9.useEffect;
|
|
4068
|
+
function useStableValue(value) {
|
|
4069
|
+
const ref = (0, import_react9.useRef)(value);
|
|
4070
|
+
const prev = ref.current;
|
|
4071
|
+
const stableValue = isEqual_default(prev, value) ? prev : value;
|
|
4072
|
+
useIsomorphicLayoutEffect(() => {
|
|
4073
|
+
ref.current = stableValue;
|
|
4074
|
+
}, [stableValue]);
|
|
4075
|
+
return stableValue;
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
// src/hooks/useReferenceFlipWarning.ts
|
|
4079
|
+
var import_react10 = require("react");
|
|
4080
|
+
var __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV !== "production";
|
|
4081
|
+
var FLIP_THRESHOLD = 3;
|
|
4082
|
+
var WARN_COOLDOWN_MS = 5e3;
|
|
4083
|
+
function trackFlip(state, value, propName, now) {
|
|
4084
|
+
if (state.prev === value) return;
|
|
4085
|
+
state.flips++;
|
|
4086
|
+
state.prev = value;
|
|
4087
|
+
if (state.flips < FLIP_THRESHOLD) return;
|
|
4088
|
+
if (now - state.lastWarnAt < WARN_COOLDOWN_MS) return;
|
|
4089
|
+
state.lastWarnAt = now;
|
|
4090
|
+
console.warn(
|
|
4091
|
+
`[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.`
|
|
4092
|
+
);
|
|
4093
|
+
}
|
|
4094
|
+
function useReferenceFlipWarning(value, propName) {
|
|
4095
|
+
const stateRef = (0, import_react10.useRef)({ prev: value, flips: 0, lastWarnAt: -Infinity });
|
|
4096
|
+
if (!__DEV__) return;
|
|
4097
|
+
trackFlip(stateRef.current, value, propName, Date.now());
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
// src/components/typography/Default.tsx
|
|
4101
|
+
var import_react11 = require("react");
|
|
4102
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4103
|
+
var DefaultTypography = (0, import_react11.memo)(({ children, fontSize, variant, colorScheme, style }) => {
|
|
4104
|
+
const className = (0, import_react11.useMemo)(
|
|
4105
|
+
() => ["aim-typography-root", variant, colorScheme].filter(Boolean).join(" "),
|
|
4106
|
+
[variant, colorScheme]
|
|
4107
|
+
);
|
|
4108
|
+
const mergedStyle = (0, import_react11.useMemo)(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
|
|
4109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className, style: mergedStyle, children });
|
|
4110
|
+
});
|
|
4111
|
+
DefaultTypography.displayName = "DefaultTypography";
|
|
4112
|
+
var Default_default = DefaultTypography;
|
|
4007
4113
|
|
|
4008
4114
|
// src/components/extendSanitizeSchema.ts
|
|
4009
4115
|
function extendSanitizeSchema(modifier) {
|
|
@@ -4032,7 +4138,7 @@ var AIMarkdownComponent = ({
|
|
|
4032
4138
|
sanitizeSchema: sanitizeSchema2
|
|
4033
4139
|
}) => {
|
|
4034
4140
|
const usedFontSize = fontSize === void 0 ? "0.9375rem" : typeof fontSize === "number" ? `${fontSize}px` : fontSize;
|
|
4035
|
-
const generatedId = (0,
|
|
4141
|
+
const generatedId = (0, import_react12.useId)();
|
|
4036
4142
|
const usedDocumentId = documentId && documentId.length > 0 ? documentId : generatedId;
|
|
4037
4143
|
useReferenceFlipWarning(urlTransform, "urlTransform");
|
|
4038
4144
|
useReferenceFlipWarning(sanitizeSchema2, "sanitizeSchema");
|
|
@@ -4041,11 +4147,11 @@ var AIMarkdownComponent = ({
|
|
|
4041
4147
|
const stablePreprocessors = useStableValue(contentPreprocessors);
|
|
4042
4148
|
const stableCustomComponents = useStableValue(customComponents);
|
|
4043
4149
|
const stableSanitizeSchema = useStableValue(sanitizeSchema2);
|
|
4044
|
-
const usedContent = (0,
|
|
4150
|
+
const usedContent = (0, import_react12.useMemo)(
|
|
4045
4151
|
() => content ? preprocessAIMDContent(content, stablePreprocessors) : content,
|
|
4046
4152
|
[content, stablePreprocessors]
|
|
4047
4153
|
);
|
|
4048
|
-
const typographyStyle = (0,
|
|
4154
|
+
const typographyStyle = (0, import_react12.useMemo)(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
|
|
4049
4155
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4050
4156
|
context_default,
|
|
4051
4157
|
{
|
|
@@ -4085,7 +4191,7 @@ var AIMarkdownComponent = ({
|
|
|
4085
4191
|
}
|
|
4086
4192
|
) });
|
|
4087
4193
|
};
|
|
4088
|
-
var AIMarkdown = (0,
|
|
4194
|
+
var AIMarkdown = (0, import_react12.memo)(AIMarkdownComponent);
|
|
4089
4195
|
AIMarkdown.displayName = "AIMarkdown";
|
|
4090
4196
|
var index_default = AIMarkdown;
|
|
4091
4197
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -4096,7 +4202,6 @@ var index_default = AIMarkdown;
|
|
|
4096
4202
|
defaultAIMarkdownRenderConfig,
|
|
4097
4203
|
defaultUrlTransform,
|
|
4098
4204
|
extendSanitizeSchema,
|
|
4099
|
-
sanitizeSchema,
|
|
4100
4205
|
useAIMarkdownMetadata,
|
|
4101
4206
|
useAIMarkdownRenderState,
|
|
4102
4207
|
useDocumentRegistry,
|