acsi-core 0.9.7 → 0.9.8

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.
@@ -688,6 +688,28 @@ function _catch(body, recover) {
688
688
  return result;
689
689
  }
690
690
 
691
+ function _arrayLikeToArray(r, a) {
692
+ (null == a || a > r.length) && (a = r.length);
693
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
694
+ return n;
695
+ }
696
+ function _createForOfIteratorHelperLoose(r, e) {
697
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
698
+ if (t) return (t = t.call(r)).next.bind(t);
699
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
700
+ t && (r = t);
701
+ var o = 0;
702
+ return function () {
703
+ return o >= r.length ? {
704
+ done: !0
705
+ } : {
706
+ done: !1,
707
+ value: r[o++]
708
+ };
709
+ };
710
+ }
711
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
712
+ }
691
713
  function _extends$1() {
692
714
  return _extends$1 = Object.assign ? Object.assign.bind() : function (n) {
693
715
  for (var e = 1; e < arguments.length; e++) {
@@ -706,6 +728,13 @@ function _objectWithoutPropertiesLoose(r, e) {
706
728
  }
707
729
  return t;
708
730
  }
731
+ function _unsupportedIterableToArray(r, a) {
732
+ if (r) {
733
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
734
+ var t = {}.toString.call(r).slice(8, -1);
735
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
736
+ }
737
+ }
709
738
 
710
739
  var styles = {"core-button":"_xvNBN","primary":"_U9Qyp","secondary":"_1VzMy","text":"_pZNuj","danger":"_2uYm1","light":"_wxH5S"};
711
740
 
@@ -1667,76 +1696,434 @@ var CoreTooltip = function CoreTooltip(_ref) {
1667
1696
 
1668
1697
  var LatexExtractor = /*#__PURE__*/function () {
1669
1698
  function LatexExtractor() {}
1670
- LatexExtractor.ApplyLatexFormat = function ApplyLatexFormat(content) {
1671
- var allComponents = LatexExtractor.extractAllLatexUltimate(content);
1672
- var multiLineFormulas = LatexExtractor.extractMultiLineFormulas(content);
1673
- var foundLatexStr = multiLineFormulas[0] || "";
1674
- if (foundLatexStr && foundLatexStr !== "" && allComponents.length > 0) {
1675
- var firstPosition = content.indexOf(allComponents[0]);
1676
- if (firstPosition > 0) {
1677
- var textPart = content.slice(0, firstPosition).trim();
1678
- var latexPart = content.slice(firstPosition).trim();
1679
- return textPart + (" $$" + latexPart + "$$");
1699
+ LatexExtractor.isLatexFormula = function isLatexFormula(text) {
1700
+ if (!text || text.trim().length === 0) {
1701
+ return false;
1702
+ }
1703
+ if (/^[a-zA-Z\s]+$/.test(text.trim()) && !/^[a-zA-Z]_|^[a-zA-Z]\^/.test(text.trim())) {
1704
+ return false;
1705
+ }
1706
+ if (text.length > 100 && text.split(' ').length > 15) {
1707
+ return false;
1708
+ }
1709
+ var englishPhrases = ['the surface of', 'acceleration caused by', 'force of gravity', 'measured value', 'approximately equal to', 'has a', 'is', 'are', 'will be', 'can be', 'may be', 'should be', 'would be'];
1710
+ for (var _i = 0, _englishPhrases = englishPhrases; _i < _englishPhrases.length; _i++) {
1711
+ var phrase = _englishPhrases[_i];
1712
+ if (text.toLowerCase().includes(phrase)) {
1713
+ return false;
1714
+ }
1715
+ }
1716
+ for (var _iterator = _createForOfIteratorHelperLoose(this.LATEX_COMMANDS), _step; !(_step = _iterator()).done;) {
1717
+ var command = _step.value;
1718
+ if (text.includes(command)) {
1719
+ return true;
1720
+ }
1721
+ }
1722
+ if (/_\{[^}]*\}/.test(text) || /\^\{[^}]*\}/.test(text)) {
1723
+ return true;
1724
+ }
1725
+ if (/^[a-zA-Z0-9_{}\\]+\s*[=~≈]\s*[a-zA-Z0-9_{}\\+\-*/^().\s]*$/.test(text.trim())) {
1726
+ return true;
1727
+ }
1728
+ if (/\\/.test(text) && /[=+\-*/^_{}[\]]/.test(text)) {
1729
+ return true;
1730
+ }
1731
+ if (/[≈~±∞∂∇∑∏∫]/.test(text)) {
1732
+ return true;
1733
+ }
1734
+ if (/^[a-zA-Z0-9_{}\\]*[a-zA-Z]_[a-zA-Z0-9{}\\]*$/.test(text.trim()) || /^[a-zA-Z0-9_{}\\]*[a-zA-Z]\^[a-zA-Z0-9{}\\]*$/.test(text.trim())) {
1735
+ return true;
1736
+ }
1737
+ if (/^[a-zA-Z0-9_{}\\]+\/[a-zA-Z0-9_{}\\^]+$/.test(text.trim()) && /[a-zA-Z]/.test(text)) {
1738
+ return true;
1739
+ }
1740
+ return false;
1741
+ };
1742
+ LatexExtractor.hasAnyMathematicalContent = function hasAnyMathematicalContent(content) {
1743
+ if (/\\[a-zA-Z]/.test(content)) return true;
1744
+ if (/_\{|\^\{/.test(content)) return true;
1745
+ if (/[a-zA-Z]\s*=\s*[a-zA-Z0-9]/.test(content)) return true;
1746
+ if (/(?:Relevant|Derived)\s+equation:/i.test(content)) return true;
1747
+ if (/[≈~±∞∂∇∑∏∫\\]/.test(content)) return true;
1748
+ if (/[a-zA-Z]_[a-zA-Z0-9]/.test(content)) return true;
1749
+ if (/[a-zA-Z]\^[a-zA-Z0-9]/.test(content)) return true;
1750
+ if (/\$[^$]+\$/.test(content)) return true;
1751
+ return false;
1752
+ };
1753
+ LatexExtractor.isAlreadyWrapped = function isAlreadyWrapped(content) {
1754
+ if (/^\$[^$]+\$$/.test(content.trim())) return true;
1755
+ if (/^\$\$[^$]+\$\$$/.test(content.trim())) return true;
1756
+ return false;
1757
+ };
1758
+ LatexExtractor.extractExistingMathContent = function extractExistingMathContent(content) {
1759
+ var mathBlocks = [];
1760
+ var displayMathPattern = /\$\$([^$]+)\$\$/g;
1761
+ var displayMatch;
1762
+ while ((displayMatch = displayMathPattern.exec(content)) !== null) {
1763
+ mathBlocks.push({
1764
+ text: displayMatch[1],
1765
+ start: displayMatch.index,
1766
+ end: displayMatch.index + displayMatch[0].length,
1767
+ type: 'display'
1768
+ });
1769
+ }
1770
+ var inlineMathPattern = /\$([^$]+)\$/g;
1771
+ var inlineMatch;
1772
+ var _loop = function _loop() {
1773
+ var matchStart = inlineMatch.index;
1774
+ var isOverlapping = mathBlocks.some(function (block) {
1775
+ return matchStart >= block.start && matchStart < block.end;
1776
+ });
1777
+ if (!isOverlapping) {
1778
+ mathBlocks.push({
1779
+ text: inlineMatch[1],
1780
+ start: inlineMatch.index,
1781
+ end: inlineMatch.index + inlineMatch[0].length,
1782
+ type: 'inline'
1783
+ });
1680
1784
  }
1681
- return content.replace(foundLatexStr, "$$" + foundLatexStr + "$$");
1785
+ };
1786
+ while ((inlineMatch = inlineMathPattern.exec(content)) !== null) {
1787
+ _loop();
1788
+ }
1789
+ return mathBlocks.sort(function (a, b) {
1790
+ return a.start - b.start;
1791
+ });
1792
+ };
1793
+ LatexExtractor.extractLatexFormulas = function extractLatexFormulas(content) {
1794
+ var _this = this;
1795
+ var formulas = [];
1796
+ for (var _iterator2 = _createForOfIteratorHelperLoose(this.LATEX_PATTERNS), _step2; !(_step2 = _iterator2()).done;) {
1797
+ var pattern = _step2.value;
1798
+ var matches = content.match(pattern);
1799
+ if (matches) {
1800
+ var processedMatches = matches.map(function (match) {
1801
+ if (match.startsWith(',')) {
1802
+ return match.substring(1).trim();
1803
+ }
1804
+ if (match.endsWith(',')) {
1805
+ return match.substring(0, match.length - 1).trim();
1806
+ }
1807
+ return match.trim();
1808
+ });
1809
+ formulas.push.apply(formulas, processedMatches);
1810
+ }
1811
+ }
1812
+ var lines = content.split(/\\\\/);
1813
+ for (var _iterator3 = _createForOfIteratorHelperLoose(lines), _step3; !(_step3 = _iterator3()).done;) {
1814
+ var line = _step3.value;
1815
+ var trimmed = line.trim().replace(/\.$/, '');
1816
+ if (trimmed && this.isLatexFormula(trimmed)) {
1817
+ formulas.push(trimmed);
1818
+ }
1819
+ }
1820
+ var commaSeparatedParts = content.split(',');
1821
+ for (var _iterator4 = _createForOfIteratorHelperLoose(commaSeparatedParts), _step4; !(_step4 = _iterator4()).done;) {
1822
+ var part = _step4.value;
1823
+ var _trimmed = part.trim();
1824
+ if (_trimmed && this.isLatexFormula(_trimmed)) {
1825
+ formulas.push(_trimmed);
1826
+ }
1827
+ }
1828
+ var uniqueFormulas = Array.from(new Set(formulas));
1829
+ return uniqueFormulas.filter(function (formula) {
1830
+ return formula.length > 1 && !formula.match(/^[,\s.]*$/) && _this.isLatexFormula(formula);
1831
+ });
1832
+ };
1833
+ LatexExtractor.findLatexExpressions = function findLatexExpressions(content) {
1834
+ var expressions = [];
1835
+ var mathStartPatterns = [/\\[a-zA-Z]+(?:\s*\{[^}]*\})*|\\[a-zA-Z]+/g, /[a-zA-Z][_^]\{[^}]*\}/g, /[a-zA-Z][_^][a-zA-Z0-9]/g, /[≈~±∞∂∇∑∏∫]/g, /\b[a-zA-Z]+\/[a-zA-Z]+\^?\{?[0-9]+\}?/g];
1836
+ for (var _i2 = 0, _mathStartPatterns = mathStartPatterns; _i2 < _mathStartPatterns.length; _i2++) {
1837
+ var pattern = _mathStartPatterns[_i2];
1838
+ var match = void 0;
1839
+ while ((match = pattern.exec(content)) !== null) {
1840
+ var startPos = match.index;
1841
+ var endPos = startPos + match[0].length;
1842
+ var remaining = content.substring(endPos);
1843
+ var limitedContinuationPattern = /^[\s]*[=~≈]\s*[a-zA-Z0-9_{}\\]+|^[\s]*[+\-*/]\s*[a-zA-Z0-9_{}\\]+/;
1844
+ var continuationMatch = remaining.match(limitedContinuationPattern);
1845
+ if (continuationMatch) {
1846
+ endPos += continuationMatch[0].length;
1847
+ }
1848
+ var expressionText = content.substring(startPos, endPos).trim();
1849
+ if (this.isLatexFormula(expressionText) && expressionText.length > 0) {
1850
+ expressions.push({
1851
+ text: expressionText,
1852
+ start: startPos,
1853
+ end: startPos + expressionText.length
1854
+ });
1855
+ }
1856
+ }
1857
+ }
1858
+ var equationPattern = /\b[a-zA-Z][a-zA-Z0-9_{}\\]*\s*[=~≈]\s*[a-zA-Z0-9_{}\\+\-*/^().\s]*?\b/g;
1859
+ var eqMatch;
1860
+ while ((eqMatch = equationPattern.exec(content)) !== null) {
1861
+ var _expressionText = eqMatch[0].trim();
1862
+ if (this.isLatexFormula(_expressionText) && _expressionText.length > 3) {
1863
+ expressions.push({
1864
+ text: _expressionText,
1865
+ start: eqMatch.index,
1866
+ end: eqMatch.index + eqMatch[0].length
1867
+ });
1868
+ }
1869
+ }
1870
+ this.findKeywordSeparatedExpressions(content, expressions);
1871
+ expressions.sort(function (a, b) {
1872
+ return a.start - b.start;
1873
+ });
1874
+ var merged = [];
1875
+ for (var _i3 = 0, _expressions = expressions; _i3 < _expressions.length; _i3++) {
1876
+ var expr = _expressions[_i3];
1877
+ var last = merged[merged.length - 1];
1878
+ if (last && expr.start <= last.end) {
1879
+ if (this.isLatexFormula(content.substring(last.start, expr.end).trim())) {
1880
+ last.end = Math.max(last.end, expr.end);
1881
+ last.text = content.substring(last.start, last.end).trim();
1882
+ }
1883
+ } else {
1884
+ merged.push(expr);
1885
+ }
1886
+ }
1887
+ return merged;
1888
+ };
1889
+ LatexExtractor.findKeywordSeparatedExpressions = function findKeywordSeparatedExpressions(content, expressions) {
1890
+ var afterCommaPattern = /,\s*([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g;
1891
+ var match;
1892
+ while ((match = afterCommaPattern.exec(content)) !== null) {
1893
+ var expression = match[1].trim();
1894
+ if (this.isLatexFormula(expression) && expression.length > 1) {
1895
+ var startPos = match.index + match[0].indexOf(expression);
1896
+ expressions.push({
1897
+ text: expression,
1898
+ start: startPos,
1899
+ end: startPos + expression.length
1900
+ });
1901
+ }
1902
+ }
1903
+ var beforeCommaPattern = /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s*,/g;
1904
+ while ((match = beforeCommaPattern.exec(content)) !== null) {
1905
+ var _expression = match[1].trim();
1906
+ if (this.isLatexFormula(_expression) && _expression.length > 1) {
1907
+ var _startPos = match.index;
1908
+ expressions.push({
1909
+ text: _expression,
1910
+ start: _startPos,
1911
+ end: _startPos + _expression.length
1912
+ });
1913
+ }
1914
+ }
1915
+ var afterToPattern = /\bto\s+([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g;
1916
+ while ((match = afterToPattern.exec(content)) !== null) {
1917
+ var _expression2 = match[1].trim();
1918
+ if (this.isLatexFormula(_expression2) && _expression2.length > 1) {
1919
+ var _startPos2 = match.index + match[0].indexOf(_expression2);
1920
+ expressions.push({
1921
+ text: _expression2,
1922
+ start: _startPos2,
1923
+ end: _startPos2 + _expression2.length
1924
+ });
1925
+ }
1926
+ }
1927
+ var beforeToPattern = /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s+to\b/g;
1928
+ while ((match = beforeToPattern.exec(content)) !== null) {
1929
+ var _expression3 = match[1].trim();
1930
+ if (this.isLatexFormula(_expression3) && _expression3.length > 1) {
1931
+ var _startPos3 = match.index;
1932
+ expressions.push({
1933
+ text: _expression3,
1934
+ start: _startPos3,
1935
+ end: _startPos3 + _expression3.length
1936
+ });
1937
+ }
1938
+ }
1939
+ };
1940
+ LatexExtractor.applyLatexFormat = function applyLatexFormat(content) {
1941
+ if (!content || content.trim().length === 0) {
1942
+ return content;
1943
+ }
1944
+ if (!this.hasAnyMathematicalContent(content)) {
1945
+ return content;
1946
+ }
1947
+ var existingMathBlocks = this.extractExistingMathContent(content);
1948
+ if (existingMathBlocks.length === 1 && existingMathBlocks[0].start === 0 && existingMathBlocks[0].end === content.length) {
1949
+ return content;
1950
+ }
1951
+ if (this.isAlreadyWrapped(content)) {
1952
+ return content;
1953
+ }
1954
+ var trimmedContent = content.trim();
1955
+ if (!trimmedContent.includes('\n') && this.hasAnyMathematicalContent(trimmedContent)) {
1956
+ var words = trimmedContent.toLowerCase().split(/\s+/);
1957
+ var englishWords = words.filter(function (word) {
1958
+ return /^[a-z]{3,}$/.test(word) && !['cos', 'sin', 'tan', 'log', 'exp', 'max', 'min'].includes(word);
1959
+ });
1960
+ if (englishWords.length === 0) {
1961
+ return "$$" + trimmedContent + "$$";
1962
+ }
1963
+ }
1964
+ if (!trimmedContent.includes('\n') && this.isLatexFormula(trimmedContent) && !/\b(?:the|is|are|and|or|of|to|in|on|at|by|for|with|from|into|onto|upon|over|under|above|below|between|among|through|during|before|after|since|until|while|where|when|why|how|what|who|which|that|this|these|those|some|many|few|all|no|not|very|more|most|less|least|better|best|worse|worst)\b/i.test(trimmedContent)) {
1965
+ return "$$" + trimmedContent + "$$";
1966
+ }
1967
+ var expressions = this.findLatexExpressions(content);
1968
+ var newExpressions = expressions.filter(function (expr) {
1969
+ return !existingMathBlocks.some(function (mathBlock) {
1970
+ return expr.start >= mathBlock.start && expr.end <= mathBlock.end;
1971
+ });
1972
+ });
1973
+ if (newExpressions.length === 0) {
1974
+ return content;
1975
+ }
1976
+ var result = content;
1977
+ var offset = 0;
1978
+ for (var _iterator5 = _createForOfIteratorHelperLoose(newExpressions), _step5; !(_step5 = _iterator5()).done;) {
1979
+ var expr = _step5.value;
1980
+ var adjustedStart = expr.start + offset;
1981
+ var adjustedEnd = expr.end + offset;
1982
+ var beforeStart = Math.max(0, adjustedStart - 2);
1983
+ var afterEnd = Math.min(result.length, adjustedEnd + 2);
1984
+ var context = result.substring(beforeStart, afterEnd);
1985
+ if (!context.includes('$$') && !context.includes('$')) {
1986
+ var wrappedExpr = "$$" + expr.text + "$$";
1987
+ result = result.substring(0, adjustedStart) + wrappedExpr + result.substring(adjustedEnd);
1988
+ offset += wrappedExpr.length - expr.text.length;
1989
+ }
1990
+ }
1991
+ return result;
1992
+ };
1993
+ LatexExtractor.applyLatexFormatSimple = function applyLatexFormatSimple(content) {
1994
+ if (!content || content.trim().length === 0) {
1995
+ return content;
1996
+ }
1997
+ if (!this.hasAnyMathematicalContent(content)) {
1998
+ return content;
1999
+ }
2000
+ if (this.isAlreadyWrapped(content)) {
2001
+ return content;
2002
+ }
2003
+ var trimmedContent = content.trim();
2004
+ if (!content.includes('\n') && this.hasAnyMathematicalContent(content)) {
2005
+ var words = content.toLowerCase().split(/\s+/);
2006
+ var englishWords = words.filter(function (word) {
2007
+ return /^[a-z]{3,}$/.test(word) && !['cos', 'sin', 'tan', 'log', 'exp', 'max', 'min'].includes(word);
2008
+ });
2009
+ if (englishWords.length === 0) {
2010
+ return "$$" + content + "$$";
2011
+ }
2012
+ }
2013
+ if (this.isLatexFormula(trimmedContent) && !/\b(?:the|is|are|and|or|of|to|in|on|at|by|for|with|from|that|this|these|those|states|theorem|equation|formula)\b/i.test(trimmedContent)) {
2014
+ return "$$" + trimmedContent + "$$";
2015
+ }
2016
+ if (/(?:Relevant|Derived)\s+equation:/i.test(content)) {
2017
+ var parts = content.split(/(?:Relevant|Derived)\s+equation:\s*/i);
2018
+ if (parts.length === 2) {
2019
+ var textPart = parts[0].trim();
2020
+ var formulaPart = parts[1].trim();
2021
+ if (this.isLatexFormula(formulaPart) && !this.isAlreadyWrapped(formulaPart)) {
2022
+ return textPart + "\n$$" + formulaPart + "$$";
2023
+ }
2024
+ }
2025
+ }
2026
+ var processedContent = this.processCommaSeparatedFormulas(content);
2027
+ if (processedContent !== content) {
2028
+ return processedContent;
2029
+ }
2030
+ var formulas = this.extractLatexFormulas(content);
2031
+ if (formulas.length > 0) {
2032
+ var result = content;
2033
+ var mainFormula = formulas.reduce(function (longest, current) {
2034
+ return current.length > longest.length ? current : longest;
2035
+ });
2036
+ if (!result.includes('$$') && !result.includes('$')) {
2037
+ var formulaIndex = result.indexOf(mainFormula);
2038
+ if (formulaIndex !== -1) {
2039
+ result = result.substring(0, formulaIndex) + ("$$" + mainFormula + "$$") + result.substring(formulaIndex + mainFormula.length);
2040
+ }
2041
+ }
2042
+ return result;
1682
2043
  }
1683
2044
  return content;
1684
2045
  };
2046
+ LatexExtractor.processCommaSeparatedFormulas = function processCommaSeparatedFormulas(content) {
2047
+ var _this2 = this;
2048
+ if (!this.hasAnyMathematicalContent(content)) {
2049
+ return content;
2050
+ }
2051
+ var result = content;
2052
+ var hasChanges = false;
2053
+ var beforeCommaPattern = /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]+)*)\s*,/g;
2054
+ result = result.replace(beforeCommaPattern, function (match, formula) {
2055
+ if (_this2.isLatexFormula(formula.trim()) && !match.includes('$$') && !match.includes('$')) {
2056
+ hasChanges = true;
2057
+ return "$$" + formula.trim() + "$$,";
2058
+ }
2059
+ return match;
2060
+ });
2061
+ var afterCommaPattern = /,\s*([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]+)*)/g;
2062
+ result = result.replace(afterCommaPattern, function (match, formula) {
2063
+ if (_this2.isLatexFormula(formula.trim()) && !match.includes('$$') && !match.includes('$')) {
2064
+ hasChanges = true;
2065
+ return ", $$" + formula.trim() + "$$";
2066
+ }
2067
+ return match;
2068
+ });
2069
+ return hasChanges ? result : content;
2070
+ };
1685
2071
  return LatexExtractor;
1686
2072
  }();
1687
- LatexExtractor.extractAllLatexUltimate = function (content) {
1688
- var latexRegex = /(\\[a-zA-Z]+\s*\{[^}]*\}(?:\s*\{[^}]*\})*|\\[a-zA-Z]+|\\[a-zA-Z]+\s*[^\\\s\{]+|[a-zA-Z]+\^{[^}]*}|[a-zA-Z]+\_{[^}]*}|\$[^$]+\$|\\\([^)]+\\\)|\\\[[^\]]+\\\]|\\[a-zA-Z]+\d*|(?:\\[a-zA-Z]+\s*)+[^\\]*(?=\\\\|\.|$))/g;
1689
- var matches = content.match(latexRegex) || [];
1690
- return matches.filter(function (match) {
1691
- return match.length > 1 && !match.match(/^[,\s\.]*$/) && (match.includes("\\") || match.includes("^{") || match.includes("_{") || match.includes("$") || !!match.match(/[a-zA-Z]\s*[=+\-*/]\s*[a-zA-Z0-9]/));
1692
- });
1693
- };
1694
- LatexExtractor.extractMultiLineFormulas = function (content) {
1695
- var formulas = content.split(/\\\\/);
1696
- return formulas.map(function (formula) {
1697
- var cleaned = formula.trim();
1698
- cleaned = cleaned.replace(/\.$/, "");
1699
- return cleaned;
1700
- }).filter(function (formula) {
1701
- return formula.length > 0 && LatexExtractor.isMathFormula(formula);
1702
- });
1703
- };
1704
- LatexExtractor.isMathFormula = function (text) {
1705
- return !!text && (text.includes("=") || text.includes("\\") || text.includes("^{") || text.includes("_{") || !!text.match(/[a-zA-Z]\s*[=+\-*/]\s*[a-zA-Z0-9]/));
1706
- };
2073
+ LatexExtractor.LATEX_COMMANDS = ['\\frac', '\\sqrt', '\\sum', '\\prod', '\\int', '\\oint', '\\lim', '\\sin', '\\cos', '\\tan', '\\log', '\\ln', '\\exp', '\\alpha', '\\beta', '\\gamma', '\\delta', '\\epsilon', '\\varepsilon', '\\zeta', '\\eta', '\\theta', '\\vartheta', '\\iota', '\\kappa', '\\lambda', '\\mu', '\\nu', '\\xi', '\\pi', '\\varpi', '\\rho', '\\varrho', '\\sigma', '\\varsigma', '\\tau', "\\upsilon", '\\phi', '\\varphi', '\\chi', '\\psi', '\\omega', '\\Gamma', '\\Delta', '\\Theta', '\\Lambda', '\\Xi', '\\Pi', '\\Sigma', "\\Upsilon", '\\Phi', '\\Psi', '\\Omega', '\\to', '\\gets', '\\mapsto', '\\implies', '\\iff', '\\leftrightarrow', '\\longleftarrow', '\\longrightarrow', '\\longleftrightarrow', '\\Leftarrow', '\\Rightarrow', '\\Leftrightarrow', '\\le', '\\ge', '\\leq', '\\geq', '\\lt', '\\gt', '\\neq', '\\approx', '\\equiv', '\\sim', '\\cong', '\\leqslant', '\\geqslant', '\\parallel', '\\perp', '\\in', '\\notin', '\\subset', '\\subseteq', '\\cup', '\\cap', '\\emptyset', '\\forall', '\\exists', '\\nexists', '\\wedge', '\\vee', '\\neg', '\\partial', '\\nabla', '\\infty', '\\pm', '\\mp', '\\vec', '\\overrightarrow', "\\underrightarrow", '\\overline', "\\underline", '\\widehat', '\\widetilde', '\\overbrace', "\\underbrace", '\\mathbb', '\\mathrm', '\\mathcal', '\\mathfrak', '\\mathscr', '\\text', '\\textbf', '\\textit', '\\left', '\\right', '\\lfloor', '\\rfloor', '\\lceil', '\\rceil', '\\langle', '\\rangle', '\\cdot', '\\times', '\\div', '\\parallel', '\\angle', '\\bot', '\\newline', '\\ldots', '\\cdots', '\\vdots', '\\ddots'];
2074
+ LatexExtractor.LATEX_PATTERNS = [/[a-zA-Z0-9]_\{[^}]*\}/g, /[a-zA-Z0-9]\^\{[^}]*\}/g, /\\[a-zA-Z]+\s*\{[^}]*\}(?:\s*\{[^}]*\})*/g, /\\[a-zA-Z]+(?![a-zA-Z])/g, /\\frac\s*\{[^}]*\}\s*\{[^}]*\}/g, /\\sqrt(?:\[[^\]]*\])?\s*\{[^}]*\}/g, /\\vec\s*\{[^}]*\}/g, /\\(?:alpha|beta|gamma|delta|epsilon|varepsilon|zeta|eta|theta|vartheta|iota|kappa|lambda|mu|nu|xi|pi|varpi|rho|varrho|sigma|varsigma|tau|upsilon|phi|varphi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?![a-zA-Z])/g, /[a-zA-Z0-9_{}\\]+\s*=\s*[a-zA-Z0-9_{}\\+\-*/^().\s]+/g, /\\Delta\s*[a-zA-Z]/g, /[a-zA-Z]+_\{[a-zA-Z0-9]+\}/g, /[a-zA-Z0-9_{}\\]+\s*[+\-*/]\s*[a-zA-Z0-9_{}\\().\s]+/g, /,\s*([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g, /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s*,/g, /\bto\s+([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g, /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s+to\b/g];
1707
2075
 
1708
- var _excluded$3 = ["node"];
1709
- var MarkdownLatexRender = function MarkdownLatexRender(_ref) {
2076
+ var MarkdownRenderer = function MarkdownRenderer(_ref) {
1710
2077
  var content = _ref.content;
1711
- var updatedMarkdown = formatContent(content);
1712
- return React.createElement("span", null, React.createElement(ReactMarkdown, {
2078
+ var formattedContent = formatContent(content);
2079
+ return React.createElement(ReactMarkdown, {
1713
2080
  remarkPlugins: [remarkMath],
1714
- rehypePlugins: [rehypeKatex, rehypeRaw],
1715
- components: {
1716
- p: function p(_ref2) {
1717
- var props = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
1718
- return React.createElement("span", Object.assign({}, props));
1719
- }
1720
- }
1721
- }, updatedMarkdown));
2081
+ rehypePlugins: [rehypeKatex, rehypeRaw]
2082
+ }, formattedContent);
1722
2083
  };
1723
2084
  function formatContent(content) {
1724
2085
  if (!content || content.trim() === "") {
1725
2086
  return content;
1726
2087
  }
1727
- var lines = content.split("\n");
2088
+ var processedContent = content.replace(/\s*\\\\\s*/g, '\n');
2089
+ var lines = processedContent.split("\n");
1728
2090
  var result = [];
1729
2091
  var i = 0;
1730
2092
  while (i < lines.length) {
1731
- var line = lines[i];
1732
- var formatText = LatexExtractor.ApplyLatexFormat(line);
1733
- var newline = formatText.trim();
1734
- if (newline !== line) {
1735
- result.push(newline);
2093
+ var line = lines[i].trim();
2094
+ if (line === '') {
2095
+ result.push('');
1736
2096
  i++;
1737
2097
  continue;
1738
2098
  }
1739
- result.push(line);
2099
+ var isEquationLabel = /\\textit\{.*(?:Relevant|Derived).*equation.*\}/i.test(line) || /^(?:Relevant|Derived)\s+equation:\s*$/i.test(line);
2100
+ if (isEquationLabel) {
2101
+ var processedLabel = line;
2102
+ if (line.includes('\\textit{') && !line.startsWith('$')) {
2103
+ processedLabel = "$" + line + "$";
2104
+ }
2105
+ result.push(processedLabel);
2106
+ i++;
2107
+ if (i < lines.length) {
2108
+ var equationLine = lines[i].trim();
2109
+ if (equationLine) {
2110
+ if (LatexExtractor.isAlreadyWrapped(equationLine)) {
2111
+ result.push(equationLine);
2112
+ } else {
2113
+ var formatText = LatexExtractor.applyLatexFormat(equationLine);
2114
+ result.push(formatText);
2115
+ }
2116
+ }
2117
+ i++;
2118
+ }
2119
+ continue;
2120
+ }
2121
+ if (LatexExtractor.isAlreadyWrapped(line)) {
2122
+ result.push(line);
2123
+ } else {
2124
+ var _formatText = LatexExtractor.applyLatexFormatSimple(line);
2125
+ result.push(_formatText);
2126
+ }
1740
2127
  i++;
1741
2128
  }
1742
2129
  return result.join("\n");
@@ -3337,7 +3724,7 @@ var CustomOption = function CustomOption(props) {
3337
3724
  }, props.data.label));
3338
3725
  };
3339
3726
 
3340
- var _excluded$4 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3727
+ var _excluded$3 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3341
3728
  var CustomSelect = function CustomSelect(_ref) {
3342
3729
  var isDefault = _ref.isDefault,
3343
3730
  options = _ref.options,
@@ -3345,7 +3732,7 @@ var CustomSelect = function CustomSelect(_ref) {
3345
3732
  scrollBottom = _ref.scrollBottom,
3346
3733
  value = _ref.value,
3347
3734
  isMulti = _ref.isMulti,
3348
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
3735
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
3349
3736
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3350
3737
  return value.includes(i.value);
3351
3738
  }) : isMulti ? options === null || options === void 0 ? void 0 : options.filter(function (i) {
@@ -3372,7 +3759,7 @@ var CustomSelect = function CustomSelect(_ref) {
3372
3759
  }, rest));
3373
3760
  };
3374
3761
 
3375
- var _excluded$5 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3762
+ var _excluded$4 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3376
3763
  var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3377
3764
  var isDefault = _ref.isDefault,
3378
3765
  options = _ref.options,
@@ -3380,7 +3767,7 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3380
3767
  scrollBottom = _ref.scrollBottom,
3381
3768
  value = _ref.value,
3382
3769
  isMulti = _ref.isMulti,
3383
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
3770
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
3384
3771
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3385
3772
  return value.includes(i.value);
3386
3773
  }) : isMulti ? options.filter(function (i) {
@@ -3407,14 +3794,14 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3407
3794
  }, rest));
3408
3795
  };
3409
3796
 
3410
- var _excluded$6 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3797
+ var _excluded$5 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3411
3798
  var CustomCreatable = function CustomCreatable(_ref) {
3412
3799
  var options = _ref.options,
3413
3800
  isDisabled = _ref.isDisabled,
3414
3801
  scrollBottom = _ref.scrollBottom,
3415
3802
  value = _ref.value,
3416
3803
  isMulti = _ref.isMulti,
3417
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
3804
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
3418
3805
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3419
3806
  return value.includes(i.value);
3420
3807
  }) : isMulti ? options.filter(function (i) {
@@ -3441,7 +3828,7 @@ var CustomCreatable = function CustomCreatable(_ref) {
3441
3828
  }, rest));
3442
3829
  };
3443
3830
 
3444
- var _excluded$7 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3831
+ var _excluded$6 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3445
3832
  var CustomSelectOption = function CustomSelectOption(_ref) {
3446
3833
  var defaultValue = _ref.defaultValue,
3447
3834
  options = _ref.options,
@@ -3449,7 +3836,7 @@ var CustomSelectOption = function CustomSelectOption(_ref) {
3449
3836
  scrollBottom = _ref.scrollBottom,
3450
3837
  value = _ref.value,
3451
3838
  isMulti = _ref.isMulti,
3452
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
3839
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
3453
3840
  var initialValues = defaultValue !== null && typeof defaultValue !== "undefined" ? options.find(function (option) {
3454
3841
  return option.value === defaultValue;
3455
3842
  }) || null : null;
@@ -3483,5 +3870,5 @@ var utcToLocalTime = (function (time, FORMAT) {
3483
3870
 
3484
3871
  var historyCore = createBrowserHistory();
3485
3872
 
3486
- export { ACCESS_TOKEN, AmplitudeEvent, BASE_URL, CommonDialog, ConfirmDialog, CoreButton, CoreInput$1 as CoreCheckbox, CoreError, CoreInput, CoreInputCompact, CoreModal, CoreRadio, CoreRange, CoreSearch, CoreSelect, CoreSelectCompact, CoreTextArea, CoreTitleInput, CoreTooltip, CustomAsyncSelect, CustomCreatable, CustomPagination, CustomSelect, CustomSelectOption, DATE_TIME_MIN_VALUE, LayoutContext, Loading, Login, MarkdownLatexRender, NotFound, OPENSALT_BASE_URL, ORGANIZATION_TEAM, ORGANIZATION_TENANT, Role, api, apiUpload, firstCheckToken, getAccessToken, getErrorMessage, getImageUrl, historyCore, initSentry, initializeAmplitude, setAddTenant, setAlert, setIsRefetchSidebar, setLoading, setLoadingPage, setMenuCollapse, setTeam, setTenant, setUser, store, useAmplitude, useGoogleSignOut, utcToLocalTime };
3873
+ export { ACCESS_TOKEN, AmplitudeEvent, BASE_URL, CommonDialog, ConfirmDialog, CoreButton, CoreInput$1 as CoreCheckbox, CoreError, CoreInput, CoreInputCompact, CoreModal, CoreRadio, CoreRange, CoreSearch, CoreSelect, CoreSelectCompact, CoreTextArea, CoreTitleInput, CoreTooltip, CustomAsyncSelect, CustomCreatable, CustomPagination, CustomSelect, CustomSelectOption, DATE_TIME_MIN_VALUE, LayoutContext, Loading, Login, MarkdownRenderer as MarkdownLatexRender, NotFound, OPENSALT_BASE_URL, ORGANIZATION_TEAM, ORGANIZATION_TENANT, Role, api, apiUpload, firstCheckToken, getAccessToken, getErrorMessage, getImageUrl, historyCore, initSentry, initializeAmplitude, setAddTenant, setAlert, setIsRefetchSidebar, setLoading, setLoadingPage, setMenuCollapse, setTeam, setTenant, setUser, store, useAmplitude, useGoogleSignOut, utcToLocalTime };
3487
3874
  //# sourceMappingURL=index.modern.js.map