@viswa-test/test-citation 0.0.386 → 0.0.387
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/utils/markdownTableSerialization.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/utils/normalizeRedlineMarkdown.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveMarkdownEscapes.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveMarkdownLineBreaks.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveReviewBlocks.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/RichTextEditor.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/utils/markdownTableSerialization.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/utils/normalizeRedlineMarkdown.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveMarkdownEscapes.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveMarkdownLineBreaks.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveReviewBlocks.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/RichTextEditor.js +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +261 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/markdownTableSerialization.d.ts +12 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/markdownTableSerialization.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/markdownTableStructure.test.d.ts +2 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/markdownTableStructure.test.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/normalizeRedlineMarkdown.d.ts +6 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/normalizeRedlineMarkdown.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveMarkdownEscapes.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveMarkdownLineBreaks.d.ts +7 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveMarkdownLineBreaks.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveReviewBlocks.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/reviewNodeSerialization.d.ts +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/reviewNodeSerialization.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableMarkdownReviewRoundTrip.test.d.ts +2 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableMarkdownReviewRoundTrip.test.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingFix.test.d.ts +2 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingFix.test.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingIssue.test.d.ts +2 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingIssue.test.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingSample.fixture.d.ts +2 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingSample.fixture.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingValidation.test.d.ts +2 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/utils/tableNumberingValidation.test.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/RichTextEditor.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/userstory.mock.data.d.ts +14156 -1197
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/userstory.mock.data.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("@mui/material"),i=require("react"),r=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),l=require("../CognitiveComparehelpers.js"),s=require("../utils/normalizeInlineMarkdown.js"),d=require("rehype-raw"),c=require("remark-gfm"),u=require("../utils/normalizeRedlineMarkdown.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=h(i),p=h(a),f=h(d),v=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},x=[v(h(c).default)],m=[v(f.default)],_=g.default.memo(function(a){var d=a.content,c=a.overlayContent,h=a.fallbackContent,f=a.sxStyles,v=a.deviationBadges,_=void 0===v?[]:v,b=a.highlights,y=void 0===b?[]:b;a.maintainRelativeOrder;var B=a.highlightBg,E=a.suppressHighlightBg,k=void 0!==E&&E,w=a.collisionKey,S=i.useRef(null),j=!!c,C=i.useMemo(function(){return _.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[_]),F=i.useRef({badgeMap:C,highlightBg:B,hideHighlightBg:j,suppressHighlightBg:k});F.current={badgeMap:C,highlightBg:B,hideHighlightBg:j,suppressHighlightBg:k};var M=function(n,t){return g.default.Children.map(n,function(n){var i;if(!g.default.isValidElement(n))return n;var r=(null===(i=n.props)||void 0===i?void 0:i.children)?M(n.props.children,t):n.props.children,o=g.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:r}));return t(o)})},T=i.useMemo(function(){return{mark:function(t){var i,r,o,a,l=t.children,s=e.__rest(t,["children"]),d=F.current,c=d.badgeMap,u=d.highlightBg,h=d.hideHighlightBg,g=d.suppressHighlightBg,p=s["data-badge-id"],f=p?c[p]:null,v=s["data-highlight-color"],x=null!==(a=null!==(r=null!=v?v:null===(i=null==f?void 0:f.style)||void 0===i?void 0:i.highlightBg)&&void 0!==r?r:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m="true"===s["data-is-suggested-deviation-fix"]||g;return n.jsx("span",e.__assign({style:e.__assign(e.__assign(e.__assign({},m?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),h?{color:"transparent"}:{})},{children:l}))},span:function(i){var a,l,s,d,c,u,h=i.children,g=e.__rest(i,["children"]),p=F.current.badgeMap,f=g["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},g,{children:h}));var v=p[f];if(!v)return n.jsx("span",e.__assign({},g,{children:h}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return n.jsxs(t.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(t.Box,e.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=v.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=v.style)||void 0===l?void 0:l.badgeText)||r.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(s=v.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===v.side?{right:"-16px",transform:"".concat(m," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(m," translateX(calc(-100% - 8px))")}),v.isConnected&&v.style&&{outline:"2px solid ".concat(v.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onClick&&v.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(o.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),h]}))},table:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:n.jsx(t.Box,e.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"thead"},{children:r}))},tbody:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"tbody"},{children:r}))},tr:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:i}))},pre:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:i}))},updated:function(e){var t=e.children;return n.jsx(n.Fragment,{children:t})},deleted:function(t){var i=t.children,r=M(i,function(e){return g.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:r}))},changed:function(t){var i=t.children,r=M(i,function(e){return g.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:r}))},ul:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},o,{children:r}))},ol:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},o,{children:r}))},li:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"li",sx:{mb:.5,display:"list-item"}},o,{children:r}))}}},[]),z=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,t,i){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(i)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,i){return"".concat(n," ").concat(i)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var i=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(i)?"\n":" "})}).join("")).trim()},A=i.useMemo(function(){return _.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[_]),R=function(e){return z(u.normalizeRedlineMarkdown(e||""))},q=i.useMemo(function(){var n=z(u.normalizeRedlineMarkdown(d||"")),t=h?z(u.normalizeRedlineMarkdown(h)):"",i=(_||[]).map(function(e){var n,t;return{id:null==e?void 0:e.id,highlight:R((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.badgeBg)||B}}).filter(function(e){return e.id&&e.highlight});if(t&&i.length>0){var r=function(e,n){return k?l.findRedlineTextAnchorRange(e,n):l.findTextMatchRange(e,n,!1)},o=i.some(function(e){var t=e.highlight;return!r(n,t)}),a=i.every(function(e){var n=e.highlight;return!!r(t,n)});o&&a&&(n=t)}var c={};i.forEach(function(e){c[e.highlight]||(c[e.highlight]=[]),c[e.highlight].push(e)});var g=function(e,n,t,i){void 0===n&&(n=""),void 0===i&&(i=[]);var r=!1,o=function(e){var o=function(e,n,t){var i,r,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var l=null!==(i=a[1])&&void 0!==i?i:"",s=null!==(r=a[2])&&void 0!==r?r:"",d=null!==(o=a[3])&&void 0!==o?o:"";return s?l+function(e,n){void 0===e&&(e="");var t=n?' data-highlight-color="'.concat(n,'"'):"",i=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(i).concat(t,">")}(n,t)+s+"</mark>"+d:e}(e,n,t),a=o;if(!r&&i.length>0){r=!0;var l="",s="";i.forEach(function(e){l+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),s="</span>"+s}),a=l+o+s}return""+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},p=[];Object.entries(c).forEach(function(e){var t=e[0],i=e[1],r=k?l.findRedlineTextAnchorRange(n,t):l.findTextMatchRange(n,t,!1);if(r||k||(r=s.findTextRangeWithFormatting(n,t)),r){for(var o=n.slice(r.start,r.end)!==t,a=i[0].highlightColor,d=1;d<i.length;d++)a=l.mixHexColors(a,i[d].highlightColor||"");p.push({highlight:t,start:r.start,end:r.end,badges:i,color:a,usedLooseMatch:o})}});var f=new Set(Object.keys(c));(y||[]).forEach(function(e){if(e){var t=R(e);if(t&&!f.has(t)){var i=k?l.findRedlineTextAnchorRange(n,t):l.findTextMatchRange(n,t,!1);if(i){var r=n.slice(i.start,i.end)!==t,o=n.slice(0,i.start);(o.match(/</g)||[]).length===(o.match(/>/g)||[]).length&&p.push({highlight:t,start:i.start,end:i.end,badges:[],color:B||"",usedLooseMatch:r})}}}}),p.sort(function(e,n){return e.start-n.start||n.end-e.end});var v=[],x={};p.forEach(function(e,n){for(var t=e.start,i=e.end,r=0,o=v;r<o.length;r++){var a=o[r],l=a.start,s=a.end,d=t<s&&i>s&&t>=l,c=t<l&&i>l&&i<=s;if(t>=l&&i<=s){e.orphaned=!0,x[n]=a.matchIdx;break}d&&(t=s),c&&(i=l)}e.trimmedStart=t,e.trimmedEnd=i,!e.orphaned&&t<i&&v.push({start:t,end:i,matchIdx:n})});var m={};Object.entries(x).forEach(function(e){var n=e[0],t=e[1],i=Number(n);m[t]||(m[t]=[]),m[t].push(i)});var b=p.map(function(n,t){return e.__assign(e.__assign({},n),{idx:t})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var t,i;return(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)-(null!==(i=e.trimmedStart)&&void 0!==i?i:e.start)});return b.forEach(function(e){var t,i,r,o,a=null!==(t=e.trimmedStart)&&void 0!==t?t:e.start,s=null!==(i=e.trimmedEnd)&&void 0!==i?i:e.end;if(!(a>=s)){var d=n.slice(a,s),c=function(e,n,t,i){if(!t.length)return e;var r=t.map(function(e){return p[e]}).sort(function(e,n){return e.start-n.start}),o="",a=0;return r.forEach(function(t){var r,s,d=Math.max(a,t.start-n),c=Math.max(d,t.end-n);if(!(d>=c)){var u=l.mixHexColors(i,t.color||"");o+=e.slice(a,d),o+=g(e.slice(d,c),(null===(s=null===(r=t.badges)||void 0===r?void 0:r[0])||void 0===s?void 0:s.id)||"",u,t.badges||[]),a=c}}),o+=e.slice(a)}(e.usedLooseMatch||a!==e.start||s!==e.end?d:e.highlight,e.start,m[e.idx]||[],e.color),u=g(c,(null===(o=null===(r=e.badges)||void 0===r?void 0:r[0])||void 0===o?void 0:o.id)||"",e.color,e.badges||[]);n=n.slice(0,a)+u+n.slice(s)}}),n},[d,h,_,y,B,k]),W=i.useMemo(function(){return c?z(u.normalizeRedlineMarkdown(c||"")):""},[c]),I=!!c,O=e.__assign(e.__assign(e.__assign({},f),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"}}),{position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),H=e.__assign(e.__assign(e.__assign({},O),{zIndex:2}),I?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),P=e.__assign(e.__assign({},O),{zIndex:1,pointerEvents:"auto"});return i.useLayoutEffect(function(){if(S.current){var e=function(){var e,n,t=Array.from(S.current.querySelectorAll(".deviation-badge"));if(0!==t.length){t.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var i=S.current.getBoundingClientRect(),r=i.bottom-4,o=i.top+4,a=S.current.querySelector('div[data-layer="base"]')||(null===(e=S.current.querySelector("div"))||void 0===e?void 0:e.firstElementChild),l=I?S.current.querySelector('div[data-layer="overlay"]')||(null===(n=S.current.querySelector("div"))||void 0===n?void 0:n.lastElementChild):null,s=a?Array.from(a.querySelectorAll(".deviation-badge")):[],d=l?Array.from(l.querySelectorAll(".deviation-badge")):[],c=t.length>0?t.filter(function(e){return"left"===e.dataset.side}):s.filter(function(e){return"left"===e.dataset.side}),u=t.length>0?t.filter(function(e){return"left"!==e.dataset.side}):s.filter(function(e){return"left"!==e.dataset.side}),h=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],i=[];n.forEach(function(e){if(0===i.length)i.push(e);else{var n=i[i.length-1],r=n.currentTop+n.height;e.naturalTop<r+8?(e.currentTop=r+8,i.push(e)):(t.push(i),i=[e])}}),i.length>0&&t.push(i),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>r){var i=t-r,a=e[0].currentTop-o,l=Math.max(0,Math.min(i,a));e.forEach(function(e){e.currentTop-=l})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};if(I&&(s.length>0||d.length>0)){var g=s.filter(function(e){return"left"===e.dataset.side}),p=s.filter(function(e){return"left"!==e.dataset.side}),f=d.filter(function(e){return"left"===e.dataset.side}),v=d.filter(function(e){return"left"!==e.dataset.side});h(g),h(p),h(f),h(v)}else h(c),h(u)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(S.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[q,w,A]),n.jsxs(t.Box,e.__assign({ref:S,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:H},{children:n.jsx(p.default,e.__assign({components:T,remarkPlugins:x,rehypePlugins:m},{children:q.replace(/#{3}/g,"")}))})),I&&n.jsx(t.Typography,e.__assign({component:"div",sx:P},{children:n.jsx(p.default,e.__assign({components:T,remarkPlugins:x,rehypePlugins:m},{children:W}))}))]}))},l.areMarkdownPropsEqual);exports.MemoizedMarkdown=_;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("@mui/material"),i=require("react"),r=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),l=require("../CognitiveComparehelpers.js"),s=require("../utils/normalizeInlineMarkdown.js"),d=require("rehype-raw"),c=require("remark-gfm"),u=require("../utils/normalizeRedlineMarkdown.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=h(i),p=h(a),f=h(d),v=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},x=[v(h(c).default)],m=[v(f.default)],_=g.default.memo(function(a){var d=a.content,c=a.overlayContent,h=a.fallbackContent,f=a.sxStyles,v=a.deviationBadges,_=void 0===v?[]:v,b=a.highlights,y=void 0===b?[]:b;a.maintainRelativeOrder;var B=a.highlightBg,w=a.suppressHighlightBg,E=void 0!==w&&w,k=a.collisionKey,S=i.useRef(null),j=!!c,C=i.useMemo(function(){return _.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[_]),F=i.useRef({badgeMap:C,highlightBg:B,hideHighlightBg:j,suppressHighlightBg:E});F.current={badgeMap:C,highlightBg:B,hideHighlightBg:j,suppressHighlightBg:E};var M=function(n,t){return g.default.Children.map(n,function(n){var i;if(!g.default.isValidElement(n))return n;var r=(null===(i=n.props)||void 0===i?void 0:i.children)?M(n.props.children,t):n.props.children,o=g.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:r}));return t(o)})},T=i.useMemo(function(){return{mark:function(t){var i,r,o,a,l=t.children,s=e.__rest(t,["children"]),d=F.current,c=d.badgeMap,u=d.highlightBg,h=d.hideHighlightBg,g=d.suppressHighlightBg,p=s["data-badge-id"],f=p?c[p]:null,v=s["data-highlight-color"],x=null!==(a=null!==(r=null!=v?v:null===(i=null==f?void 0:f.style)||void 0===i?void 0:i.highlightBg)&&void 0!==r?r:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m="true"===s["data-is-suggested-deviation-fix"]||g;return n.jsx("span",e.__assign({style:e.__assign(e.__assign(e.__assign({},m?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),h?{color:"transparent"}:{})},{children:l}))},span:function(i){var a,l,s,d,c,u,h=i.children,g=e.__rest(i,["children"]),p=F.current.badgeMap,f=g["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},g,{children:h}));var v=p[f];if(!v)return n.jsx("span",e.__assign({},g,{children:h}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return n.jsxs(t.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(t.Box,e.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=v.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=v.style)||void 0===l?void 0:l.badgeText)||r.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(s=v.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===v.side?{right:"-16px",transform:"".concat(m," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(m," translateX(calc(-100% - 8px))")}),v.isConnected&&v.style&&{outline:"2px solid ".concat(v.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onClick&&v.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(o.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),h]}))},table:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:n.jsx(t.Box,e.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"thead"},{children:r}))},tbody:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"tbody"},{children:r}))},tr:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:i}))},pre:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:i}))},updated:function(e){var t=e.children;return n.jsx(n.Fragment,{children:t})},deleted:function(t){var i=t.children,r=M(i,function(e){return g.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:r}))},changed:function(t){var i=t.children,r=M(i,function(e){return g.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:r}))},ul:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc",position:"relative",overflow:"visible"}},o,{children:r}))},ol:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal",position:"relative",overflow:"visible"}},o,{children:r}))},li:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"li",sx:{mb:.5,display:"list-item",position:"relative",pl:"8px"}},o,{children:r}))}}},[]),z=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,t,i){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(i)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,i){return"".concat(n," ").concat(i)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var i=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(i)?"\n":" "})}).join("")).trim()},A=i.useMemo(function(){return _.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[_]),R=function(e){return z(u.normalizeRedlineMarkdown(e||""))},q=i.useMemo(function(){var n=z(u.normalizeRedlineMarkdown(d||"")),t=h?z(u.normalizeRedlineMarkdown(h)):"",i=(_||[]).map(function(e){var n,t;return{id:null==e?void 0:e.id,highlight:R((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.badgeBg)||B}}).filter(function(e){return e.id&&e.highlight});if(t&&i.length>0){var r=function(e,n){return E?l.findRedlineTextAnchorRange(e,n):l.findTextMatchRange(e,n,!1)},o=i.some(function(e){var t=e.highlight;return!r(n,t)}),a=i.every(function(e){var n=e.highlight;return!!r(t,n)});o&&a&&(n=t)}var c={};i.forEach(function(e){c[e.highlight]||(c[e.highlight]=[]),c[e.highlight].push(e)});var g=function(e,n,t,i){void 0===n&&(n=""),void 0===i&&(i=[]);var r=!1,o=function(e){var o=function(e,n,t){var i,r,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var l=null!==(i=a[1])&&void 0!==i?i:"",s=null!==(r=a[2])&&void 0!==r?r:"",d=null!==(o=a[3])&&void 0!==o?o:"";return s?l+function(e,n){void 0===e&&(e="");var t=n?' data-highlight-color="'.concat(n,'"'):"",i=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(i).concat(t,">")}(n,t)+s+"</mark>"+d:e}(e,n,t),a=o;if(!r&&i.length>0){r=!0;var l="",s="";i.forEach(function(e){l+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),s="</span>"+s}),a=l+o+s}return""+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},p=[];Object.entries(c).forEach(function(e){var t=e[0],i=e[1],r=E?l.findRedlineTextAnchorRange(n,t):l.findTextMatchRange(n,t,!1);if(r||E||(r=s.findTextRangeWithFormatting(n,t)),r){for(var o=n.slice(r.start,r.end)!==t,a=i[0].highlightColor,d=1;d<i.length;d++)a=l.mixHexColors(a,i[d].highlightColor||"");p.push({highlight:t,start:r.start,end:r.end,badges:i,color:a,usedLooseMatch:o})}});var f=new Set(Object.keys(c));(y||[]).forEach(function(e){if(e){var t=R(e);if(t&&!f.has(t)){var i=E?l.findRedlineTextAnchorRange(n,t):l.findTextMatchRange(n,t,!1);if(i){var r=n.slice(i.start,i.end)!==t,o=n.slice(0,i.start);(o.match(/</g)||[]).length===(o.match(/>/g)||[]).length&&p.push({highlight:t,start:i.start,end:i.end,badges:[],color:B||"",usedLooseMatch:r})}}}}),p.sort(function(e,n){return e.start-n.start||n.end-e.end});var v=[],x={};p.forEach(function(e,n){for(var t=e.start,i=e.end,r=0,o=v;r<o.length;r++){var a=o[r],l=a.start,s=a.end,d=t<s&&i>s&&t>=l,c=t<l&&i>l&&i<=s;if(t>=l&&i<=s){e.orphaned=!0,x[n]=a.matchIdx;break}d&&(t=s),c&&(i=l)}e.trimmedStart=t,e.trimmedEnd=i,!e.orphaned&&t<i&&v.push({start:t,end:i,matchIdx:n})});var m={};Object.entries(x).forEach(function(e){var n=e[0],t=e[1],i=Number(n);m[t]||(m[t]=[]),m[t].push(i)});var b=p.map(function(n,t){return e.__assign(e.__assign({},n),{idx:t})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var t,i;return(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)-(null!==(i=e.trimmedStart)&&void 0!==i?i:e.start)});return b.forEach(function(e){var t,i,r,o,a=null!==(t=e.trimmedStart)&&void 0!==t?t:e.start,s=null!==(i=e.trimmedEnd)&&void 0!==i?i:e.end;if(!(a>=s)){var d=n.slice(a,s),c=function(e,n,t,i){if(!t.length)return e;var r=t.map(function(e){return p[e]}).sort(function(e,n){return e.start-n.start}),o="",a=0;return r.forEach(function(t){var r,s,d=Math.max(a,t.start-n),c=Math.max(d,t.end-n);if(!(d>=c)){var u=l.mixHexColors(i,t.color||"");o+=e.slice(a,d),o+=g(e.slice(d,c),(null===(s=null===(r=t.badges)||void 0===r?void 0:r[0])||void 0===s?void 0:s.id)||"",u,t.badges||[]),a=c}}),o+=e.slice(a)}(e.usedLooseMatch||a!==e.start||s!==e.end?d:e.highlight,e.start,m[e.idx]||[],e.color),u=g(c,(null===(o=null===(r=e.badges)||void 0===r?void 0:r[0])||void 0===o?void 0:o.id)||"",e.color,e.badges||[]);n=n.slice(0,a)+u+n.slice(s)}}),n},[d,h,_,y,B,E]),W=i.useMemo(function(){return c?z(u.normalizeRedlineMarkdown(c||"")):""},[c]),I=!!c,O=e.__assign(e.__assign(e.__assign({},f),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"}}),{position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),H=e.__assign(e.__assign(e.__assign({},O),{zIndex:2}),I?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),P=e.__assign(e.__assign({},O),{zIndex:1,pointerEvents:"auto"});return i.useLayoutEffect(function(){if(S.current){var e=function(){var e,n,t=Array.from(S.current.querySelectorAll(".deviation-badge"));if(0!==t.length){t.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var i=S.current.getBoundingClientRect(),r=i.bottom-4,o=i.top+4,a=S.current.querySelector('div[data-layer="base"]')||(null===(e=S.current.querySelector("div"))||void 0===e?void 0:e.firstElementChild),l=I?S.current.querySelector('div[data-layer="overlay"]')||(null===(n=S.current.querySelector("div"))||void 0===n?void 0:n.lastElementChild):null,s=a?Array.from(a.querySelectorAll(".deviation-badge")):[],d=l?Array.from(l.querySelectorAll(".deviation-badge")):[],c=t.length>0?t.filter(function(e){return"left"===e.dataset.side}):s.filter(function(e){return"left"===e.dataset.side}),u=t.length>0?t.filter(function(e){return"left"!==e.dataset.side}):s.filter(function(e){return"left"!==e.dataset.side}),h=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],i=[];n.forEach(function(e){if(0===i.length)i.push(e);else{var n=i[i.length-1],r=n.currentTop+n.height;e.naturalTop<r+8?(e.currentTop=r+8,i.push(e)):(t.push(i),i=[e])}}),i.length>0&&t.push(i),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>r){var i=t-r,a=e[0].currentTop-o,l=Math.max(0,Math.min(i,a));e.forEach(function(e){e.currentTop-=l})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};if(I&&(s.length>0||d.length>0)){var g=s.filter(function(e){return"left"===e.dataset.side}),p=s.filter(function(e){return"left"!==e.dataset.side}),f=d.filter(function(e){return"left"===e.dataset.side}),v=d.filter(function(e){return"left"!==e.dataset.side});h(g),h(p),h(f),h(v)}else h(c),h(u)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(S.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[q,k,A]),n.jsxs(t.Box,e.__assign({ref:S,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:H},{children:n.jsx(p.default,e.__assign({components:T,remarkPlugins:x,rehypePlugins:m},{children:q.replace(/#{3}/g,"")}))})),I&&n.jsx(t.Typography,e.__assign({component:"div",sx:P},{children:n.jsx(p.default,e.__assign({components:T,remarkPlugins:x,rehypePlugins:m},{children:W}))}))]}))},l.areMarkdownPropsEqual);exports.MemoizedMarkdown=_;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=(e,t)=>{let r=0;for(let l=t-1;l>=0&&"\\"===e[l];l-=1)r+=1;return r%2==1},t=new Set(["updated","upt","manual","deleted","changed","del","ins","preserved","mark"]),r=String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`,l=[new RegExp(String.raw`^<invisible\b${r}>[\s\S]*?<\/invisible\s*>`,"i"),new RegExp(String.raw`^<manual\b${r}>[\s\S]*?<\/manual\s*>`,"i"),new RegExp(String.raw`^<upt\b${r}>[\s\S]*?<\/upt\s*>`,"i")],n=e=>{let t=e.trim();for(;t;){const e=l.map(e=>t.match(e)).find(Boolean);if(!e)break;t=t.slice(e[0].length).trimStart()}return""===t},a=(t,r)=>{let l="";for(let n=r+1;n<t.length;n+=1){const r=t[n];if(l)r!==l||e(t,n)||(l="");else if('"'===r||"'"===r)l=r;else if(">"===r)return n}return-1},i=r=>{var l,i;const s=r.trimEnd(),o=[];let u="",c=0,h=0,d=-1,p=-1;for(let r=0;r<s.length;r+=1){if("<"===s[r]&&/[A-Za-z/]/.test(null!==(l=s[r+1])&&void 0!==l?l:"")){const e=a(s,r);if(-1!==e){const l=s.slice(r,e+1),n=l.match(/^<\s*(\/?)\s*([A-Za-z][\w:-]*)/),a=null!==(i=null==n?void 0:n[2].toLowerCase())&&void 0!==i?i:"";t.has(a)&&("/"===(null==n?void 0:n[1])?c=Math.max(0,c-1):/\/\s*>$/.test(l)||(c+=1)),u+=l,r=e;continue}}"|"!==s[r]||0!==c||e(s,r)?u+=s[r]:(o.push(u),u="",-1===d&&(d=r),p=r,h+=1)}if(o.push(u),!h)return null;const g=s.search(/\S/),f=g>=0&&"|"===s[g],v=!f&&n(o[0]),m=p===s.length-1,S=!m&&n(o[o.length-1]);return(f||v)&&o.shift(),(m||S)&&o.pop(),{cells:o,trailingPipe:m,firstStructuralPipe:d,lastStructuralPipe:p,hasLeadingMetadata:v,hasTrailingMetadata:S}},s=e=>!!e&&e.cells.length>0&&e.cells.every(e=>/^\s*:?-{3,}:?\s*$/.test(e)),o=(e,t,r)=>{var l,n;if(r<=0)return e;const a=null!==(n=null===(l=e.match(/\s*$/))||void 0===l?void 0:l[0])&&void 0!==n?n:"";return`${e.slice(0,e.length-a.length)}${t.trailingPipe?" |".repeat(r):` | |${" |".repeat(r-1)}`}${a}`},u=(e,t,r)=>{var l,n;if(r<=0)return e;const a=null!==(n=null===(l=e.match(/\s*$/))||void 0===l?void 0:l[0])&&void 0!==n?n:"";return`${e.slice(0,e.length-a.length)}${t.trailingPipe?" --- |".repeat(r):" | ---".repeat(r)}${a}`},c=e=>{const t=new Set;let r="",l=0;return e.forEach((e,n)=>{var a;const i=e.match(/^\s{0,3}(`{3,}|~{3,})/);r?(t.add(n),i&&i[1][0]===r&&i[1].length>=l&&/^\s*$/.test(e.slice((null!==(a=i.index)&&void 0!==a?a:0)+i[0].length))&&(r="",l=0)):i&&(r=i[1][0],l=i[1].length,t.add(n))}),t},h=e=>{var t;return{separators:null!==(t=e.match(/\r\n|\n|\r/g))&&void 0!==t?t:[],lines:e.split(/\r\n|\n|\r/)}},d=(e,t)=>e.map((e,r)=>{var l;return`${e}${null!==(l=t[r])&&void 0!==l?l:""}`}).join(""),p=e=>{let t=e,r=i(t);if(!r)return e;if(r.hasLeadingMetadata){const e=t.slice(0,r.firstStructuralPipe);t=t.slice(r.firstStructuralPipe,r.firstStructuralPipe+1)+e+t.slice(r.firstStructuralPipe+1),r=i(t)}if(null==r?void 0:r.hasTrailingMetadata){const e=t.slice(r.lastStructuralPipe+1);t=t.slice(0,r.lastStructuralPipe)+e+t.slice(r.lastStructuralPipe,r.lastStructuralPipe+1)}return t},g=t=>{var r;let l="",n=!1,a="";for(let i=0;i<t.length;i+=1){const s=t[i];n?(l+=s,a?s!==a||e(t,i)||(a=""):'"'===s||"'"===s?a=s:">"===s&&(n=!1)):"<"===s&&/[A-Za-z/!?]/.test(null!==(r=t[i+1])&&void 0!==r?r:"")?(n=!0,l+=s):l+="|"!==s||e(t,i)?s:"\\|"}return l};exports.ensureMarkdownTableColumnCounts=e=>{const{lines:t,separators:r}=h(e),l=c(t);for(let e=1;e<t.length;e+=1){if(l.has(e)||l.has(e-1))continue;const r=i(t[e]),n=i(t[e-1]);if(!s(r)||!n)continue;const a=Math.max(n.cells.length,r.cells.length);let c=a;for(let r=e+1;r<t.length&&(t[r].trim()&&!l.has(r));r+=1){const e=i(t[r]);if(!e||s(e))break;let l=e.cells.length;for(;l>a&&!e.cells[l-1].trim();)l-=1;c=Math.max(c,l)}t[e-1]=o(t[e-1],n,c-n.cells.length),t[e]=u(t[e],r,c-r.cells.length)}return d(t,r)},exports.escapeMarkdownTableCellPipes=g,exports.markdownTableCellReplacement=(e,t)=>{var r,l;const n=t,a=0===Array.from(null!==(l=null===(r=n.parentElement)||void 0===r?void 0:r.children)&&void 0!==l?l:[]).indexOf(n);let i=e.trim().replace(/\n{2,}/g,"<br><br>").replace(/\n/g,"<br>");return/^(?:<br>)+$/.test(i)&&(i=""),i=g(i),a?i?`| ${i} |`:"| |":i?` ${i} |`:" |"},exports.normalizeMarkdownTableBoundaryMetadataForRendering=e=>{const{lines:t,separators:r}=h(e),l=c(t);for(let e=1;e<t.length;e+=1){if(l.has(e)||l.has(e-1))continue;const r=i(t[e]),n=i(t[e-1]);if(s(r)&&n){t[e-1]=p(t[e-1]);for(let r=e+1;r<t.length&&(t[r].trim()&&!l.has(r));r+=1){const e=i(t[r]);if(!e||s(e))break;t[r]=p(t[r])}}}return d(t,r)};
|
|
2
2
|
//# sourceMappingURL=markdownTableSerialization.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./markdownTableSerialization.js");const t=String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`,n=new RegExp(String.raw`<updated\b(${t})>([\s\S]*?)<\/updated\s*>`,"gi"),r=new RegExp(String.raw`<upt\b(${t})>([\s\S]*?)<\/upt\s*>`,"gi"),i=new RegExp(String.raw`<(deleted|changed)\b(${t})>([\s\S]*?)<\/\1\s*>`,"gi"),l=new Set(["updated","upt","manual","deleted","changed","del","ins","preserved","mark"]),s=(e,t)=>{let n=0;for(let r=t-1;r>=0&&"\\"===e[r];r-=1)n+=1;return n%2==1},d=(e,t)=>{let n="";for(let r=t+1;r<e.length;r+=1){const t=e[r];if(n)t!==n||s(e,r)||(n="");else if('"'===t||"'"===t)n=t;else if(">"===t)return r}return-1},a=e=>{var t,n;let r="",i=0;for(let a=0;a<e.length;a+=1){if("<"===e[a]&&/[A-Za-z/]/.test(null!==(t=e[a+1])&&void 0!==t?t:"")){const t=d(e,a);if(-1!==t){const s=e.slice(a,t+1),d=s.match(/^<\s*(\/?)\s*([A-Za-z][\w:-]*)/),o=null!==(n=null==d?void 0:d[2].toLowerCase())&&void 0!==n?n:"",c=l.has(o),u="/"===(null==d?void 0:d[1]),g=/\/\s*>$/.test(s);r+=c||i>0?s.replace(/\|/g,"|"):s,c&&u?i=Math.max(0,i-1):c&&!g&&(i+=1),a=t;continue}}"|"===e[a]&&i>0?(s(e,a)&&(r=r.slice(0,-1)),r+="|"):r+=e[a]}return r},o=e=>{const t=e.trim();if(!t.includes("|"))return null;const n=[];let r="";for(let e=0;e<t.length;e+=1){const i=t[e],l=e>0&&"\\"===t[e-1];"|"!==i||l?r+=i:(n.push(r.trim()),r="")}return n.push(r.trim()),t.startsWith("|")&&n.shift(),t.endsWith("|")&&n.pop(),n},c=e=>!!(null==e?void 0:e.length)&&e.every(e=>/^:?-{3,}:?$/.test(e)),u=e=>`| ${e.join(" | ")} |`,g=e=>e.replace(r,(e,t,n)=>{if(!(e=>{const t=e.split("\n");return t.some((e,n)=>{var r;return n>0&&c(o(e))&&!!(null===(r=o(t[n-1]))||void 0===r?void 0:r.length)})})(n))return e;return`<updated${t}>${n.replace(/<del\b([^>]*)>/gi,"<deleted$1>").replace(/<\/del\s*>/gi,"</deleted>").replace(/<ins\b([^>]*)>/gi,"<changed$1>").replace(/<\/ins\s*>/gi,"</changed>")}</updated>`});exports.normalizeRedlineMarkdown=r=>{if(!r)return"";let l=g(r).replace(n,(e,t,n)=>{if(!n.includes("|"))return e;if(!/\bid\s*=\s*["']ai_reasoning\$/i.test(t))return n;const r=/\bdata-main\b/i.test(t)?"":" data-main",i=((e,t)=>{const n=t.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!n)return e;const r=encodeURIComponent(n[1]);return e.replace(/<(deleted|changed)\b([^>]*)>/gi,(e,t,n)=>/\bdata-upt-id\s*=/i.test(n)?e:`<${t}${n} data-upt-id="${r}">`)})(n,t);return`<upt${t}${r}></upt>\n\n${i}`});return l=(e=>{const n=new RegExp(String.raw`(<deleted\b${t}>(?:(?!<\/deleted\s*>)[\s\S])*?\|(?:(?!<\/deleted\s*>)[\s\S])*?<\/deleted\s*>)\s*(<changed\b${t}>[^|]*?<\/changed\s*>)\s*\|`,"gi"),r=e.replace(n,(e,t,n)=>{var r;return`${(null!==(r=t.replace(/<\/deleted\s*>$/i,"").trimEnd().split("\n").at(-1))&&void 0!==r?r:"").trimEnd().endsWith("|")?t:t.replace(/<\/deleted\s*>$/i," |</deleted>")}\n${n}`}),l=new RegExp(String.raw`(<deleted\b${t}>(?:(?!<\/deleted\s*>)[\s\S])*?\|(?:(?!<\/deleted\s*>)[\s\S])*?<\/deleted\s*>)\s*(?=<changed\b${t}>)`,"gi"),s=r.replace(l,"$1\n\n");return s.replace(i,(e,t,n,r,i)=>{if(!r.includes("|"))return e;const l=s.slice(0,i),d=/(?:^|\n)[ \t]*$/.test(l);return r.split("\n").map((e,r)=>{if(!e)return e;let i=e;i.includes("|")&&!/^\s*\|/.test(i)&&(r>0||d)&&(i=`| ${i}`);const l=o(i);return c(l)?i:i.split(/(\|)/).map(e=>"|"!==e&&e.trim()?`<${t}${n}>${e}</${t}>`:e).join("")}).join("\n")})})(l),l=l.replace(/([([])\s+(?=<(?:deleted|changed)>)/gi,"$1"),l=a(l),l=e.normalizeMarkdownTableBoundaryMetadataForRendering(l),(e=>{const t=e.split("\n");for(let e=1;e<t.length;e+=1){const n=o(t[e]);if(!c(n))continue;const r=o(t[e-1]);if(!(null==r?void 0:r.length))continue;for(;r.length>n.length;){const e=r.findIndex(e=>""===e);if(-1===e)break;r.splice(e,1)}const i=Math.max(r.length,n.length);let l=e+1,s=0;for(;l<t.length&&""!==t[l].trim();){const e=o(t[l]);if(!e)break;for(;e.length>i;){const t=e.findIndex(e=>""===e);if(-1===t)break;e.splice(t,1)}t[l]=u(e),s=Math.max(s,e.length),l+=1}const d=Math.max(r.length,n.length,s);for(;r.length<d;)r.push("");for(;n.length<d;)n.push("---");t[e-1]=u(r),t[e]=u(n)}return t.join("\n")})(l)},exports.protectReviewTagPipesForRendering=a;
|
|
2
2
|
//# sourceMappingURL=normalizeRedlineMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var n=e(require("showdown"));const t=new Set(["*","-","+","=","#","`","~","[","]",">","_","."]),r=new n.default.Converter({tables:!0,simpleLineBreaks:!0,literalMidWordUnderscores:!0}),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var n=e(require("showdown"));const t=new Set(["*","-","+","=","#","`","~","[","]",">","_","."]),r=/<!--\s*([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})\s*-->/gi,a=/<invisible\b[^>]*\bid=(["'])([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})\1[^>]*>\s*<\/invisible>/gi,l=new n.default.Converter({tables:!0,simpleLineBreaks:!0,literalMidWordUnderscores:!0}),o=e=>e.split(/\r?\n/).filter(e=>/^ {0,3}\[[^\]]+\]:\s*\S/.test(e)).join("\n"),s=e=>e.replace(r,(e,n)=>`ZXQDOCUMENTANCHOR${n.replace(/-/g,"")}QXZ`).replace(a,(e,n,t)=>`ZXQDOCUMENTANCHOR${t.replace(/-/g,"")}QXZ`),c=(e,n)=>l.makeHtml(n?`${s(e)}\n\n${n}`:s(e)).replace(/\r\n/g,"\n"),i=e=>{var n;let r="";for(let a=0;a<e.length;a+=1){if("\\"!==e[a]){r+=e[a];continue}let l=1;for(;"\\"===e[a+l];)l+=1;const o=null!==(n=e[a+l])&&void 0!==n?n:"",s=t.has(o),c=s?Math.floor(l/2):Math.ceil(l/2);r+="\\".repeat(c),s?(r+=o,a+=l):a+=l-1}return r.replace(/\r\n/g,"\n")},d=e=>e.split(/(\r?\n\r?\n)/),p=e=>/[\p{L}\p{N}]/u.test(e),f=e=>{var n,r,a;const l=[];for(let o=0;o<e.length;o+=1){const s=e[o];if("\\"===s){let r=1;for(;"\\"===e[o+r];)r+=1;const a=null!==(n=e[o+r])&&void 0!==n?n:"",s=t.has(a),c=r+(s?1:0),d=e.slice(o,o+c);l.push({comparable:i(d),escapeKind:s?a:"\\",raw:d}),o+=c-1;continue}if(p(s)){let n=o+1;for(;p(null!==(r=e[n])&&void 0!==r?r:"");)n+=1;const t=e.slice(o,n);l.push({comparable:t,escapeKind:"",raw:t}),o=n-1;continue}if(/\s/.test(s)){let n=o+1;for(;/\s/.test(null!==(a=e[n])&&void 0!==a?a:"");)n+=1;const t=e.slice(o,n);l.push({comparable:t,escapeKind:"",raw:t}),o=n-1;continue}l.push({comparable:s,escapeKind:s,raw:s})}return l};exports.preserveUnchangedMarkdownEscapesFromSource=(e,n)=>{const t=d(e),r=d(n),a=t.filter((e,n)=>n%2==0),l=r.filter((e,n)=>n%2==0),s=a.map(i),p=l.map(i),u=o(e),h=o(n),g=new Array(a.length),w=new Array(l.length),m=(e,n)=>{var t,r;return a[e]===l[n]||s[e]===p[n]&&(null!==(t=g[e])&&void 0!==t||(g[e]=c(a[e],u)),null!==(r=w[n])&&void 0!==r||(w[n]=c(l[n],h)),g[e]===w[n])},v=Array.from({length:a.length+1},()=>new Uint32Array(l.length+1));for(let e=a.length-1;e>=0;e-=1)for(let n=l.length-1;n>=0;n-=1)v[e][n]=m(e,n)?v[e+1][n+1]+1:Math.max(v[e+1][n],v[e][n+1]);const x=new Map,b=new Set,M=[];let I=0,y=0;for(;I<a.length&&y<l.length;)m(I,y)?(x.set(y,I),b.add(I),M.push({sourceIndex:I,generatedIndex:y}),I+=1,y+=1):v[I+1][y]>=v[I][y+1]?I+=1:y+=1;const A=new Map,E=[{sourceIndex:-1,generatedIndex:-1},...M,{sourceIndex:a.length,generatedIndex:l.length}];for(let e=1;e<E.length;e+=1){const n=E[e-1],t=E[e],r=t.sourceIndex-n.sourceIndex-1;if(r===t.generatedIndex-n.generatedIndex-1)for(let e=1;e<=r;e+=1)A.set(n.generatedIndex+e,n.sourceIndex+e)}for(let e=0;e<l.length;e+=1){if(x.has(e))continue;const n=a.findIndex((n,t)=>!b.has(t)&&m(t,e));-1!==n&&(x.set(e,n),b.add(n))}let K=0;return r.map((e,n)=>{if(n%2==1)return e;const t=x.get(K),r=A.get(K);return K+=1,void 0!==t?a[t]:void 0===r?e:((e,n,t)=>{const r=f(e),a=f(n),l=Array.from({length:r.length+1},()=>new Uint32Array(a.length+1));for(let e=r.length-1;e>=0;e-=1)for(let n=a.length-1;n>=0;n-=1)l[e][n]=r[e].comparable===a[n].comparable?l[e+1][n+1]+1:Math.max(l[e+1][n],l[e][n+1]);const o=new Map;let s=0,i=0;for(;s<r.length&&i<a.length;)r[s].comparable===a[i].comparable?(o.set(i,s),s+=1,i+=1):l[s+1][i]>=l[s][i+1]?s+=1:i+=1;const d=new Map;o.forEach((e,n)=>{var t;const l=r[e],o=a[n];if(l.raw===o.raw||!l.raw.includes("\\")&&!o.raw.includes("\\"))return;const s=o.escapeKind||l.escapeKind,c="["===s||"]"===s?"brackets":s,i=null!==(t=d.get(c))&&void 0!==t?t:new Map;i.set(n,l.raw),d.set(c,i)});let p=a.map(e=>e.raw),u=n;return d.forEach(e=>{const n=[...p];e.forEach((e,t)=>{n[t]=e});const r=n.join("");c(r,t)===c(u,t)&&(p=n,u=r)}),u})(a[r],e,h)}).join("")};
|
|
2
2
|
//# sourceMappingURL=preserveMarkdownEscapes.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/<br\s*\/?>|\r\n|\r|\n/gi,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/<br\s*\/?>|\r\n|\r|\n/gi,r=e=>e.replace(/<[^>]*>/g," ").replace(/\\([*+\-=#`~[\]>_.])/g,"$1").replace(/[*_`~]+/g,"").replace(/ |\u00a0/gi," ").replace(/>/gi,">").replace(/</gi,"<").replace(/"/gi,'"').replace(/'|'/gi,"'").replace(/&/gi,"&").replace(/\s+/g," ").trim().toLocaleLowerCase(),t=t=>{const l=Array.from(t.matchAll(new RegExp(e.source,"gi")));return l.map((e,n)=>{var i,s,g,c;const a=null!==(i=e.index)&&void 0!==i?i:0,h=n>0?(null!==(s=l[n-1].index)&&void 0!==s?s:0)+l[n-1][0].length:0,o=null!==(c=null===(g=l[n+1])||void 0===g?void 0:g.index)&&void 0!==c?c:t.length;return{raw:e[0],left:r(t.slice(h,a).slice(-100)),right:r(t.slice(a+e[0].length,o).slice(0,100))}})},l=/[^\S\r\n]*(?:\r?\n[^\S\r\n]*){2,}/g,n=e=>Array.from(e.matchAll(new RegExp(l.source,"g"))).map(t=>{var l;const n=null!==(l=t.index)&&void 0!==l?l:0,i=e.slice(0,n),s=e.slice(n+t[0].length);return{raw:t[0],left:r(i.slice(i.lastIndexOf("\n")+1).slice(-240)),right:r(s.split(/\r?\n/,1)[0].slice(0,240))}}),i=e=>{var r;return(null!==(r=e.match(/\r?\n/g))&&void 0!==r?r:[]).length};exports.preserveLineBreaksFromSource=(r,l)=>{if(!r||!l)return l;const n=t(r),i=t(l);if(!n.length||!i.length)return l;if(n.length===i.length){let r=0;return l.replace(e,()=>n[r++].raw)}let s=0,g=0;return l.replace(e,e=>{const r=i[g++],t=n.findIndex((e,t)=>t>=s&&((e,r)=>{const t=Boolean(e.left&&r.left&&(e.left.endsWith(r.left)||r.left.endsWith(e.left))),l=Boolean(e.right&&r.right&&(e.right.startsWith(r.right)||r.right.startsWith(e.right)));if(t||l)return!0;const n=e.left&&e.left.length>=50&&r.left&&r.left.length>=50,i=e.right&&e.right.length>=50&&r.right&&r.right.length>=50;if(n){const t=e.left.slice(-30),l=r.left.slice(-30);if(t.split("").filter((e,r)=>l[r]===e).length>=15)return!0}if(i){const t=e.right.slice(0,30),l=r.right.slice(0,30);if(t.split("").filter((e,r)=>l[r]===e).length>=15)return!0}return!1})(e,r));return-1===t?e:(s=t+1,n[t].raw)})},exports.preserveUnchangedWhitespaceRunsFromSource=(e,r)=>{if(!e||!r)return r;const t=n(e),s=n(r);if(!t.length||!s.length)return r;let g=0,c=0;return r.replace(l,e=>{const r=s[c++],l=t.findIndex((e,t)=>t>=g&&e.left===r.left&&e.right===r.right&&i(r.raw)<=i(e.raw)&&(e.raw.includes(" ")||i(r.raw)===i(e.raw)));return-1===l?e:(g=l+1,t[l].raw)})};
|
|
2
2
|
//# sourceMappingURL=preserveMarkdownLineBreaks.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./preserveMarkdownEmphasis.js");const r=new RegExp(String.raw`<(manual|upt)\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/\1\s*>`,"gi"),n=new RegExp(String.raw`<del\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/del\s*>[ \t\r\n]*<ins\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/ins\s*>`,"gi"),i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e=>{var r,n;return null!==(n=null===(r=e.match(/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/i))||void 0===r?void 0:r.slice(1).find(Boolean))&&void 0!==n?n:""},t=r=>e.markdownWithoutEmphasisMarkers(r).replace(/<(\/)?(del|ins|preserved)\b[^>]*>/gi,(e,r,n)=>` ZXQ${r?"CLOSE":"OPEN"}${String(n).toUpperCase()}QXZ `).replace(/<br\s*\/?>/gi,"\n").replace(/<[^>]*>/g,"").replace(/ |\u00a0/gi," ").replace(/>/gi,">").replace(/</gi,"<").replace(/"/gi,'"').replace(/'|'/gi,"'").replace(/&/gi,"&").replace(/\s+/g," ").trim();exports.getReviewId=s,exports.preserveUnchangedReviewBlocksFromSource=(e,a)=>{const l=Array.from(e.matchAll(new RegExp(r.source,"gi")));let
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./preserveMarkdownEmphasis.js");const r=new RegExp(String.raw`<(manual|upt)\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/\1\s*>`,"gi"),n=new RegExp(String.raw`<del\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/del\s*>[ \t\r\n]*<ins\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/ins\s*>`,"gi"),i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e=>{var r,n;return null!==(n=null===(r=e.match(/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/i))||void 0===r?void 0:r.slice(1).find(Boolean))&&void 0!==n?n:""},t=r=>e.markdownWithoutEmphasisMarkers(r).replace(/<(\/)?(del|ins|preserved)\b[^>]*>/gi,(e,r,n)=>` ZXQ${r?"CLOSE":"OPEN"}${String(n).toUpperCase()}QXZ `).replace(/<br\s*\/?>/gi,"\n").replace(/\\\|/g,"|").replace(/<[^>]*>/g,"").replace(/ |\u00a0/gi," ").replace(/>/gi,">").replace(/</gi,"<").replace(/"/gi,'"').replace(/'|'/gi,"'").replace(/&/gi,"&").replace(/\s+/g," ").trim();exports.getReviewId=s,exports.preserveUnchangedReviewBlocksFromSource=(e,a)=>{const l=Array.from(e.matchAll(new RegExp(r.source,"gi")));let c=a;return l.forEach(e=>{const[,r,a,l]=e,o=s(a);if(!o)return;const p=i(o),g=new RegExp(String.raw`<${r}\b(?=(?:[^>"']|"[^"]*"|'[^']*')*\bid\s*=\s*(?:"${p}"|'${p}'))((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/${r}\s*>`,"i");c=c.replace(g,(r,n,i)=>t(l)===t(i)?e[0]:r),c=((e,r,a,l)=>{var c;const o=s(r);if(!o)return l;const p=i(o);if(new RegExp(String.raw`<(?:manual|upt)\b(?=(?:[^>"']|"[^"]*"|'[^']*')*\bid\s*=\s*(?:"${p}"|'${p}'))`,"i").test(l))return l;const g=null===(c=a.match(new RegExp(`^\\s*(${n.source})\\s*$`,"i")))||void 0===c?void 0:c[1];if(!g)return l;const u=t(g),d=Array.from(l.matchAll(new RegExp(n.source,"gi"))).find(e=>{var r;return!((e,r)=>{const n=/<(\/)?(?:manual|upt)\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi;let i,s=0;for(;null!==(i=n.exec(e))&&i.index<r;)s+=i[1]?-1:1;return s>0})(l,null!==(r=e.index)&&void 0!==r?r:0)&&t(e[0])===u});if(!d||void 0===d.index)return l;const v=`<${e}${r}>${d[0]}</${e}>`;return l.slice(0,d.index)+v+l.slice(d.index+d[0].length)})(r,a,l,c)}),c};
|
|
2
2
|
//# sourceMappingURL=preserveReviewBlocks.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("./Editor/constants/editorConfig.js"),n=require("./Editor/Editor.js"),l=require("../../store/ref.context.js"),o=require("@lexical/html"),i=require("turndown"),s=require("turndown-plugin-gfm"),a=require("../UnsavedChangesPopup/UnsavedChangesPopup.js"),c=require("../../../../utils/tagHelper.js"),u=require("./Editor/constants/updateTags.js"),d=require("./Editor/utils/preserveMarkdownEmphasis.js"),h=require("./Editor/utils/preserveTableDelimiters.js"),p=require("./Editor/utils/preserveMarkdownLineBreaks.js"),g=require("./Editor/utils/preserveMarkdownListFormatting.js"),v=require("./Editor/utils/preserveReviewBlocks.js"),m=require("./Editor/utils/preserveMarkdownEscapes.js"),f=require("./Editor/utils/markdownTableSerialization.js"),E=require("./Editor/utils/reviewNodeSerialization.js");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const b=new(w(i).default)({headingStyle:"atx",codeBlockStyle:"fenced",emDelimiter:"*"}),x=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");b.keep(["ins","del","mark"]),b.keep(e=>["DELETED","CHANGED","PRESERVED"].includes(e.nodeName)),b.addRule("ai-reasoning-link-passthrough",{filter:e=>{var r,t;return"A"===e.nodeName&&null!==(t=null===(r=e.getAttribute("href"))||void 0===r?void 0:r.includes("ai_reasoning$"))&&void 0!==t&&t},replacement:(e,r)=>{const t=r,n=t.getAttribute("href")||"",l=t.textContent||"";return`<a href="${o=n,x(o).replace(/"/g,""")}">${x(l)}</a>`;var o}}),b.keep(e=>"SPAN"===e.nodeName&&e.hasAttribute("highlight-id")),b.addRule("md-table-passthrough",{filter:e=>"PRE"===e.nodeName&&"true"===e.getAttribute("data-md-table"),replacement:(e,r)=>r.textContent||""}),b.use(s.tables),b.addRule("stable-table-cell",{filter:["th","td"],replacement:f.markdownTableCellReplacement});const S=(e,r)=>{let t=0;for(let n=r-1;n>=0&&"\\"===e[n];n-=1)t+=1;return t%2==1};b.addRule("stable-line-break",{filter:"br",replacement:()=>"<br>"});const A=e=>{var r,t;const n=null!==(t=null===(r=e.match(/^\s*/))||void 0===r?void 0:r[0])&&void 0!==t?t:"";let l=e.slice(n.length).trimEnd();const o=l.startsWith("|"),i=l.endsWith("|")&&!S(l,l.length-1);o&&(l=l.slice(1)),i&&(l=l.slice(0,-1));const s=[];let a="",c=!1,u="";for(let e=0;e<l.length;e+=1){const r=l[e];c?(a+=r,u?r!==u||S(l,e)||(u=""):'"'===r||"'"===r?u=r:">"===r&&(c=!1)):"<"===r?(c=!0,a+=r):"|"!==r||S(l,e)?a+=r:(s.push(a),a="")}return s.push(a),s.length<2?null:{indent:n,leadingPipe:o,trailingPipe:i,rawCells:s,cells:s.map(e=>e.trim())}},y=e=>!!e&&e.cells.every(e=>/^:?-{3,}:?$/.test(e)),C=e=>{const r=[];for(let t=1;t<e.length;t+=1){const n=A(e[t]),l=A(e[t-1]);if(!y(n)||!l)continue;const o=[{lineIndex:t-1,row:l},{lineIndex:t,row:n}];for(t+=1;t<e.length;){const r=A(e[t]);if(!r||y(r))break;o.push({lineIndex:t,row:r}),t+=1}r.push(o),t-=1}return r},q=e=>e.trim().replace(/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,"<br>"),N=e=>e.replace(/<[^>]*>/g," ").replace(/[*_`~]+/g,"").replace(/ |\u00a0/gi," ").replace(/\s+/g," ").trim().toLocaleLowerCase(),R=(e,r)=>{const t=/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,n=Array.from(e.matchAll(t)),l=n.map((r,t)=>{var l,o,i,s,a;return{raw:r[0],left:N(e.slice(null!==(o=null===(l=n[t-1])||void 0===l?void 0:l.index)&&void 0!==o?o:0,r.index).slice(-80)),right:N(e.slice((null!==(i=r.index)&&void 0!==i?i:0)+r[0].length,null!==(a=null===(s=n[t+1])||void 0===s?void 0:s.index)&&void 0!==a?a:e.length).slice(0,80)),used:!1}}),o=Array.from(r.matchAll(t));let i=0;return r.replace(t,(t,n)=>{var s,a,c,u;const d=o.findIndex(e=>e.index===n),h=d>0?(null!==(s=o[d-1].index)&&void 0!==s?s:0)+o[d-1][0].length:0,p=null!==(c=null===(a=o[d+1])||void 0===a?void 0:a.index)&&void 0!==c?c:r.length,g=N(r.slice(h,n).slice(-80)),m=N(r.slice(n+t.length,p).slice(0,80)),f=l.findIndex((e,r)=>r>=i&&!e.used&&(e.left&&g.endsWith(e.left)||g&&e.left.endsWith(g)||e.right&&m.startsWith(e.right)||m&&e.right.startsWith(m))),E=l[f];if(E)return E.used=!0,i=f+1,E.raw;for(;null===(u=l[i])||void 0===u?void 0:u.used;)i+=1;const w=l[i];return w?(w.used=!0,i+=1,w.raw):(t=>{var n,l;const o=r.slice(0,t),i=o.lastIndexOf("<manual"),s=o.lastIndexOf("</manual"),a=o.lastIndexOf("<ins"),c=o.lastIndexOf("</ins");if(i<=s||a<=c)return!1;const u=null!==(l=null===(n=o.slice(i).match(/^<manual\b[^>]*>/i))||void 0===n?void 0:n[0])&&void 0!==l?l:"",d=v.getReviewId(u);return Boolean(d&&!e.includes(d))})(n)?t:""})},T=(e,r)=>{const t=((e,r)=>{if(e.cells.length===r.cells.length)return r.cells;const t=e.cells.filter(Boolean),n=r.cells.filter(Boolean);if(t.length!==n.length)return null;let l=0;return e.cells.map(e=>{if(!e)return"";const r=n[l];return l+=1,r})})(e,r);if(!t)return null;const n=t.map((t,n)=>{var l,o,i,s,a,c,u,d,h;const p=e.rawCells[n],g=null!==(o=null===(l=p.match(/^\s*/))||void 0===l?void 0:l[0])&&void 0!==o?o:"",v=null!==(s=null===(i=p.match(/\s*$/))||void 0===i?void 0:i[0])&&void 0!==s?s:"";if(!p.trim()){if(!t)return p;const e=null!==(a=r.rawCells[n])&&void 0!==a?a:t;return`${null!==(u=null===(c=e.match(/^\s*/))||void 0===c?void 0:c[0])&&void 0!==u?u:""}${t}${null!==(h=null===(d=e.match(/\s*$/))||void 0===d?void 0:d[0])&&void 0!==h?h:""}`}const m=e.cells[n];if(q(m)===q(t))return p;return`${g}${R(m,t)}${v}`});return`${e.indent}${e.leadingPipe?"|":""}${n.join("|")}${e.trailingPipe?"|":""}`},$=e=>(e||"").replace(/\r\n/g,"\n").trim(),I=r.forwardRef(({type:i,value:s,handleUpdateState:f,onBlur:w,placeholder:x,minHeight:S,height:A,mode:q,doNotShowBorderInViewMode:N,onEditBlocked:R,onSaveUnsavedChanges:I,onDiscardUnsavedChanges:k,isSavingUnsavedChanges:j=!1},B)=>{const L=r.useRef(null),[P,F]=r.useState({type:i,value:s}),[M,D]=r.useState(0),[_,U]=r.useState(!1),O=r.useRef(s),H=r.useRef(s),W=r.useRef(Boolean(s)),{contentRef:z,setContentRef:V}=l.useRefStore();r.useEffect(()=>{F(e=>({...e,value:s})),O.current=s,H.current=s,W.current=Boolean(s),U(!1)},[s]),r.useImperativeHandle(B,()=>({requestClose:()=>!("edit"===q&&$(O.current)!==$(H.current))||(U(!0),!1)}),[q]);return r.useEffect(()=>{const e=()=>{z&&z.current&&D(z.current.clientHeight-60)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[z]),e.jsxs("div",{style:{position:"relative",width:"100%",height:A,minHeight:S},children:[_&&e.jsx(a.UnsavedChangesPopup,{isSaving:j,onSave:async()=>{await(null==I?void 0:I()),O.current=H.current,U(!1)},onDiscard:()=>{H.current=O.current,null==k||k(),U(!1)}}),e.jsx(n.default,{minHeight:S,height:A,placeholder:x||"Enter some text...",onChange:(e,r,t)=>{e.read(()=>{const e=o.$generateHtmlFromNodes(r,null),n=(new DOMParser).parseFromString(e,"text/html");d.normalizeRedundantInlineFormattingElements(n),n.querySelectorAll("span").forEach(e=>{const r=e.getAttribute("style")||"";r.includes("background-color")&&(r.includes("rgb(219, 234, 254)")||r.includes("rgb(213, 232, 255)")||r.toLowerCase().includes("#d5e8ff"))&&e.setAttribute("data-review","insert"),r.includes("text-decoration")&&r.includes("line-through")&&e.setAttribute("data-review","delete")}),n.querySelectorAll("span[data-review]").forEach(e=>{const r="delete"===e.getAttribute("data-review")?"deleted":"changed",t=n.createElement(r);t.append(...Array.from(e.childNodes)),e.replaceWith(t)}),n.querySelectorAll("strong code").forEach(e=>{const r=e.parentElement;r&&r.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code strong").forEach(e=>{const r=e.parentElement;r&&r.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code").forEach(e=>{e.textContent=e.textContent||""}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{(e=>{const r=e.getAttribute("href")||"";e.setAttribute("href",r.replace(/^https?:\/\//,"")),e.removeAttribute("class"),e.textContent=e.textContent||""})(e)}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const r=e.getAttribute("href")||"";e.setAttribute("href",r.replace(/^https?:\/\//,""))});const l=[];n.querySelectorAll("invisible").forEach((e,r)=>{const t=`ZXQINVISIBLETOKEN${r}QXZ`;l.push({html:e.outerHTML,placeholder:t}),e.replaceWith(n.createTextNode(t))});const i=E.replaceReviewNodesWithMarkdownPlaceholders(n,b),s=[];n.querySelectorAll("p").forEach(e=>{if(e.closest("td, th"))return;if(!(""===e.textContent&&Array.from(e.childNodes).every(e=>"BR"===e.nodeName||e.nodeType===Node.TEXT_NODE&&""===e.textContent)))return;const r=`%%BLANKLINE${s.length}%%`;s.push(r),e.textContent=r}),n.querySelectorAll("table > colgroup").forEach(e=>{e.remove()});let a=b.turndown(n.body.innerHTML);s.forEach(e=>{a=a.replace(new RegExp(`\\n*${e}\\n*`,"g"),"\n\n")}),a=E.restoreReviewNodePlaceholders(a,i),l.forEach(({html:e,placeholder:r})=>{a=a.replace(r,e)}),a=a.replace(/\*{4}([^*]+)\*{4}/g,"**$1**"),a=a.replace(/\s+class="PlaygroundEditorTheme__[^"]*"/g,""),a=a.replace(/<span\s+style="white-space:\s*pre-wrap;?">([\s\S]*?)<\/span>/g,"$1"),a=a.replace(/\s+style="white-space:\s*pre-wrap;?"/g,""),a=a.replace(/<b>\s*<strong>([\s\S]*?)<\/strong>\s*<\/b>/g,"<strong>$1</strong>"),a=a.replace(/<code([^>]*)>\s*<span[^>]*>([\s\S]*?)<\/span>\s*<\/code>/g,"<code$1>$2</code>");if(["upt","manual","del","ins","preserved"].forEach(e=>{a=c.mergeTagAcrossParagraphs(a,e)}),a=c.unescapeTagIds(a,["manual","upt"]),a=v.preserveUnchangedReviewBlocksFromSource(O.current,a),O.current.includes("--\x3e")&&(a=a.replace(/-->/gi,"--\x3e")),a=c.preserveLegacyCommentRedlinesFromSource(O.current,a),a=c.preserveDocumentAnchorsFromSource(O.current,a),a=d.preserveEmphasisMarkersFromSource(O.current,a),a=d.preserveLiteralMidWordUnderscoresFromSource(O.current,a),a=((e,r)=>{const t=e.split("\n"),n=h.preserveTableDelimiterRowsFromSource(e,r).split("\n"),l=C(t);return C(n).forEach((e,r)=>{const o=l[r];if(!o)return;const i=o.length===e.length?e.length:Math.min(2,o.length,e.length);e.slice(0,i).forEach(({lineIndex:e,row:r},l)=>{const i=o[l];if(y(i.row)&&y(r))return void(n[e]=t[i.lineIndex]);const s=T(i.row,r);null!==s&&(n[e]=s)})}),n.join("\n")})(O.current,a),a=c.preserveInvisibleAnchorBeforeTablePipe(O.current,a),a=g.preserveListFormattingFromSource(O.current,a),a=p.preserveLineBreaksFromSource(O.current,a),a=d.preserveUnchangedEmphasisParagraphsFromSource(O.current,a),a=m.preserveUnchangedMarkdownEscapesFromSource(O.current,a),t.has(u.INITIAL_CONTENT_UPDATE_TAG))return H.current=O.current,void(W.current=!1);W.current&&(O.current=a,W.current=!1),H.current=a,((e,r)=>{f(e,r)})("prompt",a)})},toolbarConfig:t.DEFAULT_TOOLBAR_CONFIG,editorRef:L,mode:q,initialString:{type:P.type,value:P.value},dynamicHeight:M,onBlur:w,doNotShowBorderInViewMode:N||!1,onEditBlocked:R})]})});I.displayName="RichTextEditor",exports.default=I;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("./Editor/constants/editorConfig.js"),n=require("./Editor/Editor.js"),l=require("../../store/ref.context.js"),o=require("@lexical/html"),s=require("turndown"),i=require("turndown-plugin-gfm"),a=require("../UnsavedChangesPopup/UnsavedChangesPopup.js"),c=require("../../../../utils/tagHelper.js"),u=require("./Editor/constants/updateTags.js"),d=require("./Editor/utils/preserveMarkdownEmphasis.js"),h=require("./Editor/utils/preserveTableDelimiters.js"),p=require("./Editor/utils/preserveMarkdownLineBreaks.js"),g=require("./Editor/utils/preserveMarkdownListFormatting.js"),v=require("./Editor/utils/preserveReviewBlocks.js"),m=require("./Editor/utils/preserveMarkdownEscapes.js"),f=require("./Editor/utils/markdownTableSerialization.js"),E=require("./Editor/utils/reviewNodeSerialization.js");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const b=new(w(s).default)({headingStyle:"atx",codeBlockStyle:"fenced",emDelimiter:"*"}),x=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");b.keep(["ins","del","mark"]),b.keep(e=>["DELETED","CHANGED","PRESERVED"].includes(e.nodeName)),b.addRule("ai-reasoning-link-passthrough",{filter:e=>{var r,t;return"A"===e.nodeName&&null!==(t=null===(r=e.getAttribute("href"))||void 0===r?void 0:r.includes("ai_reasoning$"))&&void 0!==t&&t},replacement:(e,r)=>{const t=r,n=t.getAttribute("href")||"",l=t.textContent||"";return`<a href="${o=n,x(o).replace(/"/g,""")}">${x(l)}</a>`;var o}}),b.keep(e=>"SPAN"===e.nodeName&&e.hasAttribute("highlight-id")),b.addRule("md-table-passthrough",{filter:e=>"PRE"===e.nodeName&&"true"===e.getAttribute("data-md-table"),replacement:(e,r)=>r.textContent||""}),b.use(i.tables),b.addRule("stable-table-cell",{filter:["th","td"],replacement:f.markdownTableCellReplacement});const S=(e,r)=>{let t=0;for(let n=r-1;n>=0&&"\\"===e[n];n-=1)t+=1;return t%2==1};b.addRule("stable-line-break",{filter:"br",replacement:()=>"<br>"});const A=e=>{var r,t;const n=null!==(t=null===(r=e.match(/^\s*/))||void 0===r?void 0:r[0])&&void 0!==t?t:"";let l=e.slice(n.length).trimEnd();const o=l.startsWith("|"),s=l.endsWith("|")&&!S(l,l.length-1);o&&(l=l.slice(1)),s&&(l=l.slice(0,-1));const i=[];let a="",c=!1,u="";for(let e=0;e<l.length;e+=1){const r=l[e];c?(a+=r,u?r!==u||S(l,e)||(u=""):'"'===r||"'"===r?u=r:">"===r&&(c=!1)):"<"===r?(c=!0,a+=r):"|"!==r||S(l,e)?a+=r:(i.push(a),a="")}return i.push(a),i.length<2?null:{indent:n,leadingPipe:o,trailingPipe:s,rawCells:i,cells:i.map(e=>e.trim())}},C=e=>!!e&&e.cells.every(e=>/^:?-{3,}:?$/.test(e)),y=e=>{const r=[];for(let t=1;t<e.length;t+=1){const n=A(e[t]),l=A(e[t-1]);if(!C(n)||!l)continue;const o=[{lineIndex:t-1,row:l},{lineIndex:t,row:n}];for(t+=1;t<e.length;){const r=A(e[t]);if(!r||C(r))break;o.push({lineIndex:t,row:r}),t+=1}r.push(o),t-=1}return r},q=e=>e.trim().replace(/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,"<br>"),R=e=>e.replace(/<[^>]*>/g," ").replace(/[*_`~]+/g,"").replace(/ |\u00a0/gi," ").replace(/\s+/g," ").trim().toLocaleLowerCase(),N=(e,r)=>{const t=/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,n=Array.from(e.matchAll(t)),l=n.map((r,t)=>{var l,o,s,i,a;return{raw:r[0],left:R(e.slice(null!==(o=null===(l=n[t-1])||void 0===l?void 0:l.index)&&void 0!==o?o:0,r.index).slice(-80)),right:R(e.slice((null!==(s=r.index)&&void 0!==s?s:0)+r[0].length,null!==(a=null===(i=n[t+1])||void 0===i?void 0:i.index)&&void 0!==a?a:e.length).slice(0,80)),used:!1}}),o=Array.from(r.matchAll(t));let s=0;return r.replace(t,(t,n)=>{var i,a,c,u;const d=o.findIndex(e=>e.index===n),h=d>0?(null!==(i=o[d-1].index)&&void 0!==i?i:0)+o[d-1][0].length:0,p=null!==(c=null===(a=o[d+1])||void 0===a?void 0:a.index)&&void 0!==c?c:r.length,g=R(r.slice(h,n).slice(-80)),m=R(r.slice(n+t.length,p).slice(0,80)),f=l.findIndex((e,r)=>r>=s&&!e.used&&(e.left&&g.endsWith(e.left)||g&&e.left.endsWith(g)||e.right&&m.startsWith(e.right)||m&&e.right.startsWith(m))),E=l[f];if(E)return E.used=!0,s=f+1,E.raw;for(;null===(u=l[s])||void 0===u?void 0:u.used;)s+=1;const w=l[s];return w?(w.used=!0,s+=1,w.raw):(t=>{var n,l;const o=r.slice(0,t),s=o.lastIndexOf("<manual"),i=o.lastIndexOf("</manual"),a=o.lastIndexOf("<ins"),c=o.lastIndexOf("</ins");if(s<=i||a<=c)return!1;const u=null!==(l=null===(n=o.slice(s).match(/^<manual\b[^>]*>/i))||void 0===n?void 0:n[0])&&void 0!==l?l:"",d=v.getReviewId(u);return Boolean(d&&!e.includes(d))})(n)?t:""})},T=(e,r)=>{const t=((e,r)=>{if(e.cells.length===r.cells.length)return r.cells;const t=e.cells.filter(Boolean),n=r.cells.filter(Boolean);if(t.length!==n.length)return null;let l=0;return e.cells.map(e=>{if(!e)return"";const r=n[l];return l+=1,r})})(e,r);if(!t)return null;const n=t.map((t,n)=>{var l,o,s,i,a,c,u,d,h;const p=e.rawCells[n],g=null!==(o=null===(l=p.match(/^\s*/))||void 0===l?void 0:l[0])&&void 0!==o?o:"",v=null!==(i=null===(s=p.match(/\s*$/))||void 0===s?void 0:s[0])&&void 0!==i?i:"";if(!p.trim()){if(!t)return p;const e=null!==(a=r.rawCells[n])&&void 0!==a?a:t;return`${null!==(u=null===(c=e.match(/^\s*/))||void 0===c?void 0:c[0])&&void 0!==u?u:""}${t}${null!==(h=null===(d=e.match(/\s*$/))||void 0===d?void 0:d[0])&&void 0!==h?h:""}`}const m=e.cells[n];if(q(m)===q(t))return p;return`${g}${N(m,t)}${v}`});return`${e.indent}${e.leadingPipe?"|":""}${n.join("|")}${e.trailingPipe?"|":""}`},$=e=>(e||"").replace(/\r\n/g,"\n").trim(),k=r.forwardRef(({type:s,value:i,handleUpdateState:w,onBlur:x,placeholder:S,minHeight:A,height:q,mode:R,doNotShowBorderInViewMode:N,onEditBlocked:k,onSaveUnsavedChanges:I,onDiscardUnsavedChanges:j,isSavingUnsavedChanges:B=!1},L)=>{const F=r.useRef(null),[P,M]=r.useState({type:s,value:i}),[U,D]=r.useState(0),[_,O]=r.useState(!1),H=r.useRef(i),W=r.useRef(i),z=r.useRef(Boolean(i)),{contentRef:V,setContentRef:G}=l.useRefStore();r.useEffect(()=>{M(e=>({...e,value:i})),H.current=i,W.current=i,z.current=Boolean(i),O(!1)},[i]),r.useImperativeHandle(L,()=>({requestClose:()=>!("edit"===R&&$(H.current)!==$(W.current))||(O(!0),!1)}),[R]);return r.useEffect(()=>{const e=()=>{V&&V.current&&D(V.current.clientHeight-60)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[V]),e.jsxs("div",{style:{position:"relative",width:"100%",height:q,minHeight:A},children:[_&&e.jsx(a.UnsavedChangesPopup,{isSaving:B,onSave:async()=>{await(null==I?void 0:I()),H.current=W.current,O(!1)},onDiscard:()=>{W.current=H.current,null==j||j(),O(!1)}}),e.jsx(n.default,{minHeight:A,height:q,placeholder:S||"Enter some text...",onChange:(e,r,t)=>{e.read(()=>{const e=o.$generateHtmlFromNodes(r,null),n=(new DOMParser).parseFromString(e,"text/html");d.normalizeRedundantInlineFormattingElements(n),n.querySelectorAll("span").forEach(e=>{const r=e.getAttribute("style")||"";r.includes("background-color")&&(r.includes("rgb(219, 234, 254)")||r.includes("rgb(213, 232, 255)")||r.toLowerCase().includes("#d5e8ff"))&&e.setAttribute("data-review","insert"),r.includes("text-decoration")&&r.includes("line-through")&&e.setAttribute("data-review","delete")}),n.querySelectorAll("span[data-review]").forEach(e=>{const r="delete"===e.getAttribute("data-review")?"deleted":"changed",t=n.createElement(r);t.append(...Array.from(e.childNodes)),e.replaceWith(t)}),n.querySelectorAll("strong code").forEach(e=>{const r=e.parentElement;r&&r.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code strong").forEach(e=>{const r=e.parentElement;r&&r.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code").forEach(e=>{e.textContent=e.textContent||""}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{(e=>{const r=e.getAttribute("href")||"";e.setAttribute("href",r.replace(/^https?:\/\//,"")),e.removeAttribute("class"),e.textContent=e.textContent||""})(e)}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const r=e.getAttribute("href")||"";e.setAttribute("href",r.replace(/^https?:\/\//,""))});const l=[];n.querySelectorAll("invisible").forEach((e,r)=>{const t=`ZXQINVISIBLETOKEN${r}QXZ`;l.push({html:e.outerHTML,placeholder:t}),e.replaceWith(n.createTextNode(t))});const s=E.replaceReviewNodesWithMarkdownPlaceholders(n,b),i=[];n.querySelectorAll("p").forEach(e=>{if(e.closest("td, th"))return;if(!(""===e.textContent&&Array.from(e.childNodes).every(e=>"BR"===e.nodeName||e.nodeType===Node.TEXT_NODE&&""===e.textContent)))return;const r=`%%BLANKLINE${i.length}%%`;i.push(r),e.textContent=r}),n.querySelectorAll("table > colgroup").forEach(e=>{e.remove()});let a=b.turndown(n.body.innerHTML);i.forEach(e=>{a=a.replace(new RegExp(`\\n*${e}\\n*`,"g"),"\n\n")}),a=E.restoreReviewNodePlaceholders(a,s),l.forEach(({html:e,placeholder:r})=>{a=a.replace(r,e)}),a=a.replace(/\*{4}([^*]+)\*{4}/g,"**$1**"),a=a.replace(/\s+class="PlaygroundEditorTheme__[^"]*"/g,""),a=a.replace(/<span\s+style="white-space:\s*pre-wrap;?">([\s\S]*?)<\/span>/g,"$1"),a=a.replace(/\s+style="white-space:\s*pre-wrap;?"/g,""),a=a.replace(/<b>\s*<strong>([\s\S]*?)<\/strong>\s*<\/b>/g,"<strong>$1</strong>"),a=a.replace(/<code([^>]*)>\s*<span[^>]*>([\s\S]*?)<\/span>\s*<\/code>/g,"<code$1>$2</code>");if(["upt","manual","del","ins","preserved"].forEach(e=>{a=c.mergeTagAcrossParagraphs(a,e)}),a=c.unescapeTagIds(a,["manual","upt"]),a=v.preserveUnchangedReviewBlocksFromSource(H.current,a),H.current.includes("--\x3e")&&(a=a.replace(/-->/gi,"--\x3e")),a=c.preserveLegacyCommentRedlinesFromSource(H.current,a),a=c.preserveDocumentAnchorsFromSource(H.current,a),a=d.preserveEmphasisMarkersFromSource(H.current,a),a=d.preserveLiteralMidWordUnderscoresFromSource(H.current,a),a=((e,r)=>{const t=e.split("\n"),n=h.preserveTableDelimiterRowsFromSource(e,r).split("\n"),l=y(t);return y(n).forEach((e,r)=>{const o=l[r];if(!o)return;const s=o.length===e.length?e.length:Math.min(2,o.length,e.length);e.slice(0,s).forEach(({lineIndex:e,row:r},l)=>{const s=o[l];if(C(s.row)&&C(r))return void(n[e]=t[s.lineIndex]);const i=T(s.row,r);null!==i&&(n[e]=i)})}),n.join("\n")})(H.current,a),a=c.preserveInvisibleAnchorBeforeTablePipe(H.current,a),a=g.preserveListFormattingFromSource(H.current,a),a=p.preserveLineBreaksFromSource(H.current,a),a=d.preserveUnchangedEmphasisParagraphsFromSource(H.current,a),a=m.preserveUnchangedMarkdownEscapesFromSource(H.current,a),a=p.preserveUnchangedWhitespaceRunsFromSource(H.current,a),a=m.preserveUnchangedMarkdownEscapesFromSource(H.current,a),a=f.ensureMarkdownTableColumnCounts(a),t.has(u.INITIAL_CONTENT_UPDATE_TAG))return W.current=H.current,void(z.current=!1);z.current&&(H.current=a,z.current=!1),W.current=a,((e,r)=>{w(e,r)})("prompt",a)})},toolbarConfig:t.DEFAULT_TOOLBAR_CONFIG,editorRef:F,mode:R,initialString:{type:P.type,value:P.value},dynamicHeight:U,onBlur:x,doNotShowBorderInViewMode:N||!1,onEditBlocked:k})]})});k.displayName="RichTextEditor",exports.default=k;
|
|
2
2
|
//# sourceMappingURL=RichTextEditor.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__rest as n}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{findRedlineTextAnchorRange as f,findTextMatchRange as g,mixHexColors as v,areMarkdownPropsEqual as m}from"../CognitiveComparehelpers.js";import{findTextRangeWithFormatting as b}from"../utils/normalizeInlineMarkdown.js";import x from"rehype-raw";import y from"remark-gfm";import{normalizeRedlineMarkdown as S}from"../utils/normalizeRedlineMarkdown.js";var E=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},k=[E(y)],w=[E(x)],C=l.memo(function(m){var x=m.content,y=m.overlayContent,E=m.fallbackContent,C=m.sxStyles,B=m.deviationBadges,F=void 0===B?[]:B,z=m.highlights,A=void 0===z?[]:z;m.maintainRelativeOrder;var T=m.highlightBg,W=m.suppressHighlightBg,I=void 0!==W&&W,M=m.collisionKey,j=c(null),q=!!y,$=d(function(){return F.reduce(function(n,t){var r;return e(e({},n),((r={})[t.id]=t,r))},{})},[F]),H=c({badgeMap:$,highlightBg:T,hideHighlightBg:q,suppressHighlightBg:I});H.current={badgeMap:$,highlightBg:T,hideHighlightBg:q,suppressHighlightBg:I};var O=function(n,t){return l.Children.map(n,function(n){var r;if(!l.isValidElement(n))return n;var i=(null===(r=n.props)||void 0===r?void 0:r.children)?O(n.props.children,t):n.props.children,o=l.cloneElement(n,e(e({},n.props),{children:i}));return t(o)})},P=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=n(r,["children"]),s=H.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,f=s.suppressHighlightBg,g=d["data-badge-id"],v=g?u[g]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||f;return t("span",e({style:e(e(e({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,f=i.children,g=n(i,["children"]),v=H.current.badgeMap,m=g["data-badge-id"];if(!m)return t("span",e({},g,{children:f}));var b=v[m];if(!b)return t("span",e({},g,{children:f}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,e({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,e({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:e(e({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,e({onClick:function(e){e.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,e({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,e({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,e({onClick:function(e){e.stopPropagation(),b.onClick&&b.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),f]}))},table:function(n){var r=n.children;return t(o,e({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,e({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(n){var r=n.children;return t(o,e({component:"thead"},{children:r}))},tbody:function(n){var r=n.children;return t(o,e({component:"tbody"},{children:r}))},tr:function(n){var r=n.children;return t(o,e({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(n){var r=n.children;return t(o,e({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(n){var r=n.children;return t(o,e({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(e){var n=e.children;return t(i,{children:n})},deleted:function(n){var r=n.children,i=O(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(n){var r=n.children,i=O(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),R=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,t,r){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,r){return"".concat(n," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var r=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},D=d(function(){return F.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[F]),N=function(e){return R(S(e||""))},L=d(function(){var n=R(S(x||"")),t=E?R(S(E)):"",r=(F||[]).map(function(e){var n,t;return{id:null==e?void 0:e.id,highlight:N((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.badgeBg)||T}}).filter(function(e){return e.id&&e.highlight});if(t&&r.length>0){var i=function(e,n){return I?f(e,n):g(e,n,!1)},o=r.some(function(e){var t=e.highlight;return!i(n,t)}),a=r.every(function(e){var n=e.highlight;return!!i(t,n)});o&&a&&(n=t)}var l={};r.forEach(function(e){l[e.highlight]||(l[e.highlight]=[]),l[e.highlight].push(e)});var c=function(e,n,t,r){void 0===n&&(n=""),void 0===r&&(r=[]);var i=!1,o=function(e){var o=function(e,n,t){var r,i,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(e,n){void 0===e&&(e="");var t=n?' data-highlight-color="'.concat(n,'"'):"",r=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(r).concat(t,">")}(n,t)+c+"</mark>"+d:e}(e,n,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(e){l+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),c="</span>"+c}),a=l+o+c}return""+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},d=[];Object.entries(l).forEach(function(e){var t=e[0],r=e[1],i=I?f(n,t):g(n,t,!1);if(i||I||(i=b(n,t)),i){for(var o=n.slice(i.start,i.end)!==t,a=r[0].highlightColor,l=1;l<r.length;l++)a=v(a,r[l].highlightColor||"");d.push({highlight:t,start:i.start,end:i.end,badges:r,color:a,usedLooseMatch:o})}});var s=new Set(Object.keys(l));(A||[]).forEach(function(e){if(e){var t=N(e);if(t&&!s.has(t)){var r=I?f(n,t):g(n,t,!1);if(r){var i=n.slice(r.start,r.end)!==t,o=n.slice(0,r.start);(o.match(/</g)||[]).length===(o.match(/>/g)||[]).length&&d.push({highlight:t,start:r.start,end:r.end,badges:[],color:T||"",usedLooseMatch:i})}}}}),d.sort(function(e,n){return e.start-n.start||n.end-e.end});var u=[],h={};d.forEach(function(e,n){for(var t=e.start,r=e.end,i=0,o=u;i<o.length;i++){var a=o[i],l=a.start,c=a.end,d=t<c&&r>c&&t>=l,s=t<l&&r>l&&r<=c;if(t>=l&&r<=c){e.orphaned=!0,h[n]=a.matchIdx;break}d&&(t=c),s&&(r=l)}e.trimmedStart=t,e.trimmedEnd=r,!e.orphaned&&t<r&&u.push({start:t,end:r,matchIdx:n})});var p={};Object.entries(h).forEach(function(e){var n=e[0],t=e[1],r=Number(n);p[t]||(p[t]=[]),p[t].push(r)});var m=d.map(function(n,t){return e(e({},n),{idx:t})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var t,r;return(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)-(null!==(r=e.trimmedStart)&&void 0!==r?r:e.start)});return m.forEach(function(e){var t,r,i,o,a=null!==(t=e.trimmedStart)&&void 0!==t?t:e.start,l=null!==(r=e.trimmedEnd)&&void 0!==r?r:e.end;if(!(a>=l)){var s=n.slice(a,l),u=function(e,n,t,r){if(!t.length)return e;var i=t.map(function(e){return d[e]}).sort(function(e,n){return e.start-n.start}),o="",a=0;return i.forEach(function(t){var i,l,d=Math.max(a,t.start-n),s=Math.max(d,t.end-n);if(!(d>=s)){var u=v(r,t.color||"");o+=e.slice(a,d),o+=c(e.slice(d,s),(null===(l=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",u,t.badges||[]),a=s}}),o+=e.slice(a)}(e.usedLooseMatch||a!==e.start||l!==e.end?s:e.highlight,e.start,p[e.idx]||[],e.color),h=c(u,(null===(o=null===(i=e.badges)||void 0===i?void 0:i[0])||void 0===o?void 0:o.id)||"",e.color,e.badges||[]);n=n.slice(0,a)+h+n.slice(l)}}),n},[x,E,F,A,T,I]),X=d(function(){return y?R(S(y||"")):""},[y]),Y=!!y,K=e(e(e({},C),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"}}),{position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),V=e(e(e({},K),{zIndex:2}),Y?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),G=e(e({},K),{zIndex:1,pointerEvents:"auto"});return s(function(){if(j.current){var e=function(){var e,n,t=Array.from(j.current.querySelectorAll(".deviation-badge"));if(0!==t.length){t.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var r=j.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=j.current.querySelector('div[data-layer="base"]')||(null===(e=j.current.querySelector("div"))||void 0===e?void 0:e.firstElementChild),l=Y?j.current.querySelector('div[data-layer="overlay"]')||(null===(n=j.current.querySelector("div"))||void 0===n?void 0:n.lastElementChild):null,c=a?Array.from(a.querySelectorAll(".deviation-badge")):[],d=l?Array.from(l.querySelectorAll(".deviation-badge")):[],s=t.length>0?t.filter(function(e){return"left"===e.dataset.side}):c.filter(function(e){return"left"===e.dataset.side}),u=t.length>0?t.filter(function(e){return"left"!==e.dataset.side}):c.filter(function(e){return"left"!==e.dataset.side}),h=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],r=[];n.forEach(function(e){if(0===r.length)r.push(e);else{var n=r[r.length-1],i=n.currentTop+n.height;e.naturalTop<i+8?(e.currentTop=i+8,r.push(e)):(t.push(r),r=[e])}}),r.length>0&&t.push(r),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>i){var r=t-i,a=e[0].currentTop-o,l=Math.max(0,Math.min(r,a));e.forEach(function(e){e.currentTop-=l})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};if(Y&&(c.length>0||d.length>0)){var p=c.filter(function(e){return"left"===e.dataset.side}),f=c.filter(function(e){return"left"!==e.dataset.side}),g=d.filter(function(e){return"left"===e.dataset.side}),v=d.filter(function(e){return"left"!==e.dataset.side});h(p),h(f),h(g),h(v)}else h(s),h(u)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(j.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[L,M,D]),r(o,e({ref:j,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,e({component:"div",sx:V},{children:t(p,e({components:P,remarkPlugins:k,rehypePlugins:w},{children:L.replace(/#{3}/g,"")}))})),Y&&t(a,e({component:"div",sx:G},{children:t(p,e({components:P,remarkPlugins:k,rehypePlugins:w},{children:X}))}))]}))},m);export{C as MemoizedMarkdown};
|
|
1
|
+
import{__assign as e,__rest as n}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{findRedlineTextAnchorRange as f,findTextMatchRange as g,mixHexColors as v,areMarkdownPropsEqual as m}from"../CognitiveComparehelpers.js";import{findTextRangeWithFormatting as b}from"../utils/normalizeInlineMarkdown.js";import x from"rehype-raw";import y from"remark-gfm";import{normalizeRedlineMarkdown as S}from"../utils/normalizeRedlineMarkdown.js";var E=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},w=[E(y)],k=[E(x)],C=l.memo(function(m){var x=m.content,y=m.overlayContent,E=m.fallbackContent,C=m.sxStyles,B=m.deviationBadges,F=void 0===B?[]:B,z=m.highlights,A=void 0===z?[]:z;m.maintainRelativeOrder;var T=m.highlightBg,W=m.suppressHighlightBg,I=void 0!==W&&W,M=m.collisionKey,j=c(null),q=!!y,$=d(function(){return F.reduce(function(n,t){var r;return e(e({},n),((r={})[t.id]=t,r))},{})},[F]),H=c({badgeMap:$,highlightBg:T,hideHighlightBg:q,suppressHighlightBg:I});H.current={badgeMap:$,highlightBg:T,hideHighlightBg:q,suppressHighlightBg:I};var O=function(n,t){return l.Children.map(n,function(n){var r;if(!l.isValidElement(n))return n;var i=(null===(r=n.props)||void 0===r?void 0:r.children)?O(n.props.children,t):n.props.children,o=l.cloneElement(n,e(e({},n.props),{children:i}));return t(o)})},P=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=n(r,["children"]),s=H.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,f=s.suppressHighlightBg,g=d["data-badge-id"],v=g?u[g]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||f;return t("span",e({style:e(e(e({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,f=i.children,g=n(i,["children"]),v=H.current.badgeMap,m=g["data-badge-id"];if(!m)return t("span",e({},g,{children:f}));var b=v[m];if(!b)return t("span",e({},g,{children:f}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,e({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,e({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:e(e({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,e({onClick:function(e){e.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,e({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,e({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,e({onClick:function(e){e.stopPropagation(),b.onClick&&b.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),f]}))},table:function(n){var r=n.children;return t(o,e({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,e({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(n){var r=n.children;return t(o,e({component:"thead"},{children:r}))},tbody:function(n){var r=n.children;return t(o,e({component:"tbody"},{children:r}))},tr:function(n){var r=n.children;return t(o,e({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(n){var r=n.children;return t(o,e({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(n){var r=n.children;return t(o,e({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(e){var n=e.children;return t(i,{children:n})},deleted:function(n){var r=n.children,i=O(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(n){var r=n.children,i=O(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc",position:"relative",overflow:"visible"}},a,{children:i}))},ol:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal",position:"relative",overflow:"visible"}},a,{children:i}))},li:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"li",sx:{mb:.5,display:"list-item",position:"relative",pl:"8px"}},a,{children:i}))}}},[]),R=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,t,r){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,r){return"".concat(n," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var r=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},D=d(function(){return F.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[F]),N=function(e){return R(S(e||""))},L=d(function(){var n=R(S(x||"")),t=E?R(S(E)):"",r=(F||[]).map(function(e){var n,t;return{id:null==e?void 0:e.id,highlight:N((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.badgeBg)||T}}).filter(function(e){return e.id&&e.highlight});if(t&&r.length>0){var i=function(e,n){return I?f(e,n):g(e,n,!1)},o=r.some(function(e){var t=e.highlight;return!i(n,t)}),a=r.every(function(e){var n=e.highlight;return!!i(t,n)});o&&a&&(n=t)}var l={};r.forEach(function(e){l[e.highlight]||(l[e.highlight]=[]),l[e.highlight].push(e)});var c=function(e,n,t,r){void 0===n&&(n=""),void 0===r&&(r=[]);var i=!1,o=function(e){var o=function(e,n,t){var r,i,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(e,n){void 0===e&&(e="");var t=n?' data-highlight-color="'.concat(n,'"'):"",r=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(r).concat(t,">")}(n,t)+c+"</mark>"+d:e}(e,n,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(e){l+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),c="</span>"+c}),a=l+o+c}return""+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},d=[];Object.entries(l).forEach(function(e){var t=e[0],r=e[1],i=I?f(n,t):g(n,t,!1);if(i||I||(i=b(n,t)),i){for(var o=n.slice(i.start,i.end)!==t,a=r[0].highlightColor,l=1;l<r.length;l++)a=v(a,r[l].highlightColor||"");d.push({highlight:t,start:i.start,end:i.end,badges:r,color:a,usedLooseMatch:o})}});var s=new Set(Object.keys(l));(A||[]).forEach(function(e){if(e){var t=N(e);if(t&&!s.has(t)){var r=I?f(n,t):g(n,t,!1);if(r){var i=n.slice(r.start,r.end)!==t,o=n.slice(0,r.start);(o.match(/</g)||[]).length===(o.match(/>/g)||[]).length&&d.push({highlight:t,start:r.start,end:r.end,badges:[],color:T||"",usedLooseMatch:i})}}}}),d.sort(function(e,n){return e.start-n.start||n.end-e.end});var u=[],h={};d.forEach(function(e,n){for(var t=e.start,r=e.end,i=0,o=u;i<o.length;i++){var a=o[i],l=a.start,c=a.end,d=t<c&&r>c&&t>=l,s=t<l&&r>l&&r<=c;if(t>=l&&r<=c){e.orphaned=!0,h[n]=a.matchIdx;break}d&&(t=c),s&&(r=l)}e.trimmedStart=t,e.trimmedEnd=r,!e.orphaned&&t<r&&u.push({start:t,end:r,matchIdx:n})});var p={};Object.entries(h).forEach(function(e){var n=e[0],t=e[1],r=Number(n);p[t]||(p[t]=[]),p[t].push(r)});var m=d.map(function(n,t){return e(e({},n),{idx:t})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var t,r;return(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)-(null!==(r=e.trimmedStart)&&void 0!==r?r:e.start)});return m.forEach(function(e){var t,r,i,o,a=null!==(t=e.trimmedStart)&&void 0!==t?t:e.start,l=null!==(r=e.trimmedEnd)&&void 0!==r?r:e.end;if(!(a>=l)){var s=n.slice(a,l),u=function(e,n,t,r){if(!t.length)return e;var i=t.map(function(e){return d[e]}).sort(function(e,n){return e.start-n.start}),o="",a=0;return i.forEach(function(t){var i,l,d=Math.max(a,t.start-n),s=Math.max(d,t.end-n);if(!(d>=s)){var u=v(r,t.color||"");o+=e.slice(a,d),o+=c(e.slice(d,s),(null===(l=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",u,t.badges||[]),a=s}}),o+=e.slice(a)}(e.usedLooseMatch||a!==e.start||l!==e.end?s:e.highlight,e.start,p[e.idx]||[],e.color),h=c(u,(null===(o=null===(i=e.badges)||void 0===i?void 0:i[0])||void 0===o?void 0:o.id)||"",e.color,e.badges||[]);n=n.slice(0,a)+h+n.slice(l)}}),n},[x,E,F,A,T,I]),X=d(function(){return y?R(S(y||"")):""},[y]),Y=!!y,K=e(e(e({},C),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"}}),{position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),V=e(e(e({},K),{zIndex:2}),Y?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),G=e(e({},K),{zIndex:1,pointerEvents:"auto"});return s(function(){if(j.current){var e=function(){var e,n,t=Array.from(j.current.querySelectorAll(".deviation-badge"));if(0!==t.length){t.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var r=j.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=j.current.querySelector('div[data-layer="base"]')||(null===(e=j.current.querySelector("div"))||void 0===e?void 0:e.firstElementChild),l=Y?j.current.querySelector('div[data-layer="overlay"]')||(null===(n=j.current.querySelector("div"))||void 0===n?void 0:n.lastElementChild):null,c=a?Array.from(a.querySelectorAll(".deviation-badge")):[],d=l?Array.from(l.querySelectorAll(".deviation-badge")):[],s=t.length>0?t.filter(function(e){return"left"===e.dataset.side}):c.filter(function(e){return"left"===e.dataset.side}),u=t.length>0?t.filter(function(e){return"left"!==e.dataset.side}):c.filter(function(e){return"left"!==e.dataset.side}),h=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],r=[];n.forEach(function(e){if(0===r.length)r.push(e);else{var n=r[r.length-1],i=n.currentTop+n.height;e.naturalTop<i+8?(e.currentTop=i+8,r.push(e)):(t.push(r),r=[e])}}),r.length>0&&t.push(r),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>i){var r=t-i,a=e[0].currentTop-o,l=Math.max(0,Math.min(r,a));e.forEach(function(e){e.currentTop-=l})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};if(Y&&(c.length>0||d.length>0)){var p=c.filter(function(e){return"left"===e.dataset.side}),f=c.filter(function(e){return"left"!==e.dataset.side}),g=d.filter(function(e){return"left"===e.dataset.side}),v=d.filter(function(e){return"left"!==e.dataset.side});h(p),h(f),h(g),h(v)}else h(s),h(u)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(j.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[L,M,D]),r(o,e({ref:j,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,e({component:"div",sx:V},{children:t(p,e({components:P,remarkPlugins:w,rehypePlugins:k},{children:L.replace(/#{3}/g,"")}))})),Y&&t(a,e({component:"div",sx:G},{children:t(p,e({components:P,remarkPlugins:w,rehypePlugins:k},{children:X}))}))]}))},m);export{C as MemoizedMarkdown};
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const r=(r,e)=>{let t=0;for(let l=e-1;l>=0&&"
|
|
1
|
+
const t=(t,e)=>{let l=0;for(let r=e-1;r>=0&&"\\"===t[r];r-=1)l+=1;return l%2==1},e=new Set(["updated","upt","manual","deleted","changed","del","ins","preserved","mark"]),l=String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`,r=[new RegExp(String.raw`^<invisible\b${l}>[\s\S]*?<\/invisible\s*>`,"i"),new RegExp(String.raw`^<manual\b${l}>[\s\S]*?<\/manual\s*>`,"i"),new RegExp(String.raw`^<upt\b${l}>[\s\S]*?<\/upt\s*>`,"i")],n=t=>{let e=t.trim();for(;e;){const t=r.map(t=>e.match(t)).find(Boolean);if(!t)break;e=e.slice(t[0].length).trimStart()}return""===e},i=(e,l)=>{let r="";for(let n=l+1;n<e.length;n+=1){const l=e[n];if(r)l!==r||t(e,n)||(r="");else if('"'===l||"'"===l)r=l;else if(">"===l)return n}return-1},a=l=>{var r,a;const s=l.trimEnd(),c=[];let u="",o=0,h=0,g=-1,d=-1;for(let l=0;l<s.length;l+=1){if("<"===s[l]&&/[A-Za-z/]/.test(null!==(r=s[l+1])&&void 0!==r?r:"")){const t=i(s,l);if(-1!==t){const r=s.slice(l,t+1),n=r.match(/^<\s*(\/?)\s*([A-Za-z][\w:-]*)/),i=null!==(a=null==n?void 0:n[2].toLowerCase())&&void 0!==a?a:"";e.has(i)&&("/"===(null==n?void 0:n[1])?o=Math.max(0,o-1):/\/\s*>$/.test(r)||(o+=1)),u+=r,l=t;continue}}"|"!==s[l]||0!==o||t(s,l)?u+=s[l]:(c.push(u),u="",-1===g&&(g=l),d=l,h+=1)}if(c.push(u),!h)return null;const p=s.search(/\S/),f=p>=0&&"|"===s[p],v=!f&&n(c[0]),m=d===s.length-1,S=!m&&n(c[c.length-1]);return(f||v)&&c.shift(),(m||S)&&c.pop(),{cells:c,trailingPipe:m,firstStructuralPipe:g,lastStructuralPipe:d,hasLeadingMetadata:v,hasTrailingMetadata:S}},s=t=>!!t&&t.cells.length>0&&t.cells.every(t=>/^\s*:?-{3,}:?\s*$/.test(t)),c=(t,e,l)=>{var r,n;if(l<=0)return t;const i=null!==(n=null===(r=t.match(/\s*$/))||void 0===r?void 0:r[0])&&void 0!==n?n:"";return`${t.slice(0,t.length-i.length)}${e.trailingPipe?" |".repeat(l):` | |${" |".repeat(l-1)}`}${i}`},u=(t,e,l)=>{var r,n;if(l<=0)return t;const i=null!==(n=null===(r=t.match(/\s*$/))||void 0===r?void 0:r[0])&&void 0!==n?n:"";return`${t.slice(0,t.length-i.length)}${e.trailingPipe?" --- |".repeat(l):" | ---".repeat(l)}${i}`},o=t=>{const e=new Set;let l="",r=0;return t.forEach((t,n)=>{var i;const a=t.match(/^\s{0,3}(`{3,}|~{3,})/);l?(e.add(n),a&&a[1][0]===l&&a[1].length>=r&&/^\s*$/.test(t.slice((null!==(i=a.index)&&void 0!==i?i:0)+a[0].length))&&(l="",r=0)):a&&(l=a[1][0],r=a[1].length,e.add(n))}),e},h=t=>{var e;return{separators:null!==(e=t.match(/\r\n|\n|\r/g))&&void 0!==e?e:[],lines:t.split(/\r\n|\n|\r/)}},g=(t,e)=>t.map((t,l)=>{var r;return`${t}${null!==(r=e[l])&&void 0!==r?r:""}`}).join(""),d=t=>{let e=t,l=a(e);if(!l)return t;if(l.hasLeadingMetadata){const t=e.slice(0,l.firstStructuralPipe);e=e.slice(l.firstStructuralPipe,l.firstStructuralPipe+1)+t+e.slice(l.firstStructuralPipe+1),l=a(e)}if(null==l?void 0:l.hasTrailingMetadata){const t=e.slice(l.lastStructuralPipe+1);e=e.slice(0,l.lastStructuralPipe)+t+e.slice(l.lastStructuralPipe,l.lastStructuralPipe+1)}return e},p=t=>{const{lines:e,separators:l}=h(t),r=o(e);for(let t=1;t<e.length;t+=1){if(r.has(t)||r.has(t-1))continue;const l=a(e[t]),n=a(e[t-1]);if(s(l)&&n){e[t-1]=d(e[t-1]);for(let l=t+1;l<e.length&&(e[l].trim()&&!r.has(l));l+=1){const t=a(e[l]);if(!t||s(t))break;e[l]=d(e[l])}}}return g(e,l)},f=t=>{const{lines:e,separators:l}=h(t),r=o(e);for(let t=1;t<e.length;t+=1){if(r.has(t)||r.has(t-1))continue;const l=a(e[t]),n=a(e[t-1]);if(!s(l)||!n)continue;const i=Math.max(n.cells.length,l.cells.length);let o=i;for(let l=t+1;l<e.length&&(e[l].trim()&&!r.has(l));l+=1){const t=a(e[l]);if(!t||s(t))break;let r=t.cells.length;for(;r>i&&!t.cells[r-1].trim();)r-=1;o=Math.max(o,r)}e[t-1]=c(e[t-1],n,o-n.cells.length),e[t]=u(e[t],l,o-l.cells.length)}return g(e,l)},v=e=>{var l;let r="",n=!1,i="";for(let a=0;a<e.length;a+=1){const s=e[a];n?(r+=s,i?s!==i||t(e,a)||(i=""):'"'===s||"'"===s?i=s:">"===s&&(n=!1)):"<"===s&&/[A-Za-z/!?]/.test(null!==(l=e[a+1])&&void 0!==l?l:"")?(n=!0,r+=s):r+="|"!==s||t(e,a)?s:"\\|"}return r},m=(t,e)=>{var l,r;const n=e,i=0===Array.from(null!==(r=null===(l=n.parentElement)||void 0===l?void 0:l.children)&&void 0!==r?r:[]).indexOf(n);let a=t.trim().replace(/\n{2,}/g,"<br><br>").replace(/\n/g,"<br>");return/^(?:<br>)+$/.test(a)&&(a=""),a=v(a),i?a?`| ${a} |`:"| |":a?` ${a} |`:" |"};export{f as ensureMarkdownTableColumnCounts,v as escapeMarkdownTableCellPipes,m as markdownTableCellReplacement,p as normalizeMarkdownTableBoundaryMetadataForRendering};
|
|
2
2
|
//# sourceMappingURL=markdownTableSerialization.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{normalizeMarkdownTableBoundaryMetadataForRendering as e}from"./markdownTableSerialization.js";const t=String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`,n=new RegExp(String.raw`<updated\b(${t})>([\s\S]*?)<\/updated\s*>`,"gi"),r=new RegExp(String.raw`<upt\b(${t})>([\s\S]*?)<\/upt\s*>`,"gi"),l=new RegExp(String.raw`<(deleted|changed)\b(${t})>([\s\S]*?)<\/\1\s*>`,"gi"),i=new Set(["updated","upt","manual","deleted","changed","del","ins","preserved","mark"]),s=(e,t)=>{let n=0;for(let r=t-1;r>=0&&"\\"===e[r];r-=1)n+=1;return n%2==1},d=(e,t)=>{let n="";for(let r=t+1;r<e.length;r+=1){const t=e[r];if(n)t!==n||s(e,r)||(n="");else if('"'===t||"'"===t)n=t;else if(">"===t)return r}return-1},a=e=>{var t,n;let r="",l=0;for(let a=0;a<e.length;a+=1){if("<"===e[a]&&/[A-Za-z/]/.test(null!==(t=e[a+1])&&void 0!==t?t:"")){const t=d(e,a);if(-1!==t){const s=e.slice(a,t+1),d=s.match(/^<\s*(\/?)\s*([A-Za-z][\w:-]*)/),o=null!==(n=null==d?void 0:d[2].toLowerCase())&&void 0!==n?n:"",c=i.has(o),u="/"===(null==d?void 0:d[1]),g=/\/\s*>$/.test(s);r+=c||l>0?s.replace(/\|/g,"|"):s,c&&u?l=Math.max(0,l-1):c&&!g&&(l+=1),a=t;continue}}"|"===e[a]&&l>0?(s(e,a)&&(r=r.slice(0,-1)),r+="|"):r+=e[a]}return r},o=e=>{const t=e.trim();if(!t.includes("|"))return null;const n=[];let r="";for(let e=0;e<t.length;e+=1){const l=t[e],i=e>0&&"\\"===t[e-1];"|"!==l||i?r+=l:(n.push(r.trim()),r="")}return n.push(r.trim()),t.startsWith("|")&&n.shift(),t.endsWith("|")&&n.pop(),n},c=e=>!!(null==e?void 0:e.length)&&e.every(e=>/^:?-{3,}:?$/.test(e)),u=e=>`| ${e.join(" | ")} |`,g=e=>e.replace(r,(e,t,n)=>{if(!(e=>{const t=e.split("\n");return t.some((e,n)=>{var r;return n>0&&c(o(e))&&!!(null===(r=o(t[n-1]))||void 0===r?void 0:r.length)})})(n))return e;return`<updated${t}>${n.replace(/<del\b([^>]*)>/gi,"<deleted$1>").replace(/<\/del\s*>/gi,"</deleted>").replace(/<ins\b([^>]*)>/gi,"<changed$1>").replace(/<\/ins\s*>/gi,"</changed>")}</updated>`}),p=r=>{if(!r)return"";let i=g(r).replace(n,(e,t,n)=>{if(!n.includes("|"))return e;if(!/\bid\s*=\s*["']ai_reasoning\$/i.test(t))return n;const r=/\bdata-main\b/i.test(t)?"":" data-main",l=((e,t)=>{const n=t.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!n)return e;const r=encodeURIComponent(n[1]);return e.replace(/<(deleted|changed)\b([^>]*)>/gi,(e,t,n)=>/\bdata-upt-id\s*=/i.test(n)?e:`<${t}${n} data-upt-id="${r}">`)})(n,t);return`<upt${t}${r}></upt>\n\n${l}`});return i=(e=>{const n=new RegExp(String.raw`(<deleted\b${t}>(?:(?!<\/deleted\s*>)[\s\S])*?\|(?:(?!<\/deleted\s*>)[\s\S])*?<\/deleted\s*>)\s*(<changed\b${t}>[^|]*?<\/changed\s*>)\s*\|`,"gi"),r=e.replace(n,(e,t,n)=>{var r;return`${(null!==(r=t.replace(/<\/deleted\s*>$/i,"").trimEnd().split("\n").at(-1))&&void 0!==r?r:"").trimEnd().endsWith("|")?t:t.replace(/<\/deleted\s*>$/i," |</deleted>")}\n${n}`}),i=new RegExp(String.raw`(<deleted\b${t}>(?:(?!<\/deleted\s*>)[\s\S])*?\|(?:(?!<\/deleted\s*>)[\s\S])*?<\/deleted\s*>)\s*(?=<changed\b${t}>)`,"gi"),s=r.replace(i,"$1\n\n");return s.replace(l,(e,t,n,r,l)=>{if(!r.includes("|"))return e;const i=s.slice(0,l),d=/(?:^|\n)[ \t]*$/.test(i);return r.split("\n").map((e,r)=>{if(!e)return e;let l=e;l.includes("|")&&!/^\s*\|/.test(l)&&(r>0||d)&&(l=`| ${l}`);const i=o(l);return c(i)?l:l.split(/(\|)/).map(e=>"|"!==e&&e.trim()?`<${t}${n}>${e}</${t}>`:e).join("")}).join("\n")})})(i),i=i.replace(/([([])\s+(?=<(?:deleted|changed)>)/gi,"$1"),i=a(i),i=e(i),(e=>{const t=e.split("\n");for(let e=1;e<t.length;e+=1){const n=o(t[e]);if(!c(n))continue;const r=o(t[e-1]);if(!(null==r?void 0:r.length))continue;for(;r.length>n.length;){const e=r.findIndex(e=>""===e);if(-1===e)break;r.splice(e,1)}const l=Math.max(r.length,n.length);let i=e+1,s=0;for(;i<t.length&&""!==t[i].trim();){const e=o(t[i]);if(!e)break;for(;e.length>l;){const t=e.findIndex(e=>""===e);if(-1===t)break;e.splice(t,1)}t[i]=u(e),s=Math.max(s,e.length),i+=1}const d=Math.max(r.length,n.length,s);for(;r.length<d;)r.push("");for(;n.length<d;)n.push("---");t[e-1]=u(r),t[e]=u(n)}return t.join("\n")})(i)};export{p as normalizeRedlineMarkdown,a as protectReviewTagPipesForRendering};
|
|
2
2
|
//# sourceMappingURL=normalizeRedlineMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"showdown";const n=new Set(["*","-","+","=","#","`","~","[","]",">","_","."]),t=new e.Converter({tables:!0,simpleLineBreaks:!0,literalMidWordUnderscores:!0}),
|
|
1
|
+
import e from"showdown";const n=new Set(["*","-","+","=","#","`","~","[","]",">","_","."]),t=/<!--\s*([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})\s*-->/gi,r=/<invisible\b[^>]*\bid=(["'])([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})\1[^>]*>\s*<\/invisible>/gi,a=new e.Converter({tables:!0,simpleLineBreaks:!0,literalMidWordUnderscores:!0}),l=e=>e.split(/\r?\n/).filter(e=>/^ {0,3}\[[^\]]+\]:\s*\S/.test(e)).join("\n"),o=e=>e.replace(t,(e,n)=>`ZXQDOCUMENTANCHOR${n.replace(/-/g,"")}QXZ`).replace(r,(e,n,t)=>`ZXQDOCUMENTANCHOR${t.replace(/-/g,"")}QXZ`),s=(e,n)=>a.makeHtml(n?`${o(e)}\n\n${n}`:o(e)).replace(/\r\n/g,"\n"),c=e=>{var t;let r="";for(let a=0;a<e.length;a+=1){if("\\"!==e[a]){r+=e[a];continue}let l=1;for(;"\\"===e[a+l];)l+=1;const o=null!==(t=e[a+l])&&void 0!==t?t:"",s=n.has(o),c=s?Math.floor(l/2):Math.ceil(l/2);r+="\\".repeat(c),s?(r+=o,a+=l):a+=l-1}return r.replace(/\r\n/g,"\n")},i=e=>e.split(/(\r?\n\r?\n)/),d=e=>/[\p{L}\p{N}]/u.test(e),p=e=>{var t,r,a;const l=[];for(let o=0;o<e.length;o+=1){const s=e[o];if("\\"===s){let r=1;for(;"\\"===e[o+r];)r+=1;const a=null!==(t=e[o+r])&&void 0!==t?t:"",s=n.has(a),i=r+(s?1:0),d=e.slice(o,o+i);l.push({comparable:c(d),escapeKind:s?a:"\\",raw:d}),o+=i-1;continue}if(d(s)){let n=o+1;for(;d(null!==(r=e[n])&&void 0!==r?r:"");)n+=1;const t=e.slice(o,n);l.push({comparable:t,escapeKind:"",raw:t}),o=n-1;continue}if(/\s/.test(s)){let n=o+1;for(;/\s/.test(null!==(a=e[n])&&void 0!==a?a:"");)n+=1;const t=e.slice(o,n);l.push({comparable:t,escapeKind:"",raw:t}),o=n-1;continue}l.push({comparable:s,escapeKind:s,raw:s})}return l},f=(e,n)=>{const t=i(e),r=i(n),a=t.filter((e,n)=>n%2==0),o=r.filter((e,n)=>n%2==0),d=a.map(c),f=o.map(c),h=l(e),g=l(n),u=new Array(a.length),w=new Array(o.length),m=(e,n)=>{var t,r;return a[e]===o[n]||d[e]===f[n]&&(null!==(t=u[e])&&void 0!==t||(u[e]=s(a[e],h)),null!==(r=w[n])&&void 0!==r||(w[n]=s(o[n],g)),u[e]===w[n])},v=Array.from({length:a.length+1},()=>new Uint32Array(o.length+1));for(let e=a.length-1;e>=0;e-=1)for(let n=o.length-1;n>=0;n-=1)v[e][n]=m(e,n)?v[e+1][n+1]+1:Math.max(v[e+1][n],v[e][n+1]);const x=new Map,b=new Set,I=[];let M=0,A=0;for(;M<a.length&&A<o.length;)m(M,A)?(x.set(A,M),b.add(M),I.push({sourceIndex:M,generatedIndex:A}),M+=1,A+=1):v[M+1][A]>=v[M][A+1]?M+=1:A+=1;const y=new Map,K=[{sourceIndex:-1,generatedIndex:-1},...I,{sourceIndex:a.length,generatedIndex:o.length}];for(let e=1;e<K.length;e+=1){const n=K[e-1],t=K[e],r=t.sourceIndex-n.sourceIndex-1;if(r===t.generatedIndex-n.generatedIndex-1)for(let e=1;e<=r;e+=1)y.set(n.generatedIndex+e,n.sourceIndex+e)}for(let e=0;e<o.length;e+=1){if(x.has(e))continue;const n=a.findIndex((n,t)=>!b.has(t)&&m(t,e));-1!==n&&(x.set(e,n),b.add(n))}let C=0;return r.map((e,n)=>{if(n%2==1)return e;const t=x.get(C),r=y.get(C);return C+=1,void 0!==t?a[t]:void 0===r?e:((e,n,t)=>{const r=p(e),a=p(n),l=Array.from({length:r.length+1},()=>new Uint32Array(a.length+1));for(let e=r.length-1;e>=0;e-=1)for(let n=a.length-1;n>=0;n-=1)l[e][n]=r[e].comparable===a[n].comparable?l[e+1][n+1]+1:Math.max(l[e+1][n],l[e][n+1]);const o=new Map;let c=0,i=0;for(;c<r.length&&i<a.length;)r[c].comparable===a[i].comparable?(o.set(i,c),c+=1,i+=1):l[c+1][i]>=l[c][i+1]?c+=1:i+=1;const d=new Map;o.forEach((e,n)=>{var t;const l=r[e],o=a[n];if(l.raw===o.raw||!l.raw.includes("\\")&&!o.raw.includes("\\"))return;const s=o.escapeKind||l.escapeKind,c="["===s||"]"===s?"brackets":s,i=null!==(t=d.get(c))&&void 0!==t?t:new Map;i.set(n,l.raw),d.set(c,i)});let f=a.map(e=>e.raw),h=n;return d.forEach(e=>{const n=[...f];e.forEach((e,t)=>{n[t]=e});const r=n.join("");s(r,t)===s(h,t)&&(f=n,h=r)}),h})(a[r],e,g)}).join("")};export{f as preserveUnchangedMarkdownEscapesFromSource};
|
|
2
2
|
//# sourceMappingURL=preserveMarkdownEscapes.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=/<br\s*\/?>|\r\n|\r|\n/gi,t=e=>e.replace(/<[^>]*>/g," ").replace(/[*_`~]+/g,"").replace(/ |\u00a0/gi," ").replace(/>/gi,">").replace(/</gi,"<").replace(/"/gi,'"').replace(/'|'/gi,"'").replace(/&/gi,"&").replace(/\s+/g," ").trim().toLocaleLowerCase(),
|
|
1
|
+
const e=/<br\s*\/?>|\r\n|\r|\n/gi,t=e=>e.replace(/<[^>]*>/g," ").replace(/\\([*+\-=#`~[\]>_.])/g,"$1").replace(/[*_`~]+/g,"").replace(/ |\u00a0/gi," ").replace(/>/gi,">").replace(/</gi,"<").replace(/"/gi,'"').replace(/'|'/gi,"'").replace(/&/gi,"&").replace(/\s+/g," ").trim().toLocaleLowerCase(),r=r=>{const l=Array.from(r.matchAll(new RegExp(e.source,"gi")));return l.map((e,n)=>{var i,g,c,a;const s=null!==(i=e.index)&&void 0!==i?i:0,h=n>0?(null!==(g=l[n-1].index)&&void 0!==g?g:0)+l[n-1][0].length:0,f=null!==(a=null===(c=l[n+1])||void 0===c?void 0:c.index)&&void 0!==a?a:r.length;return{raw:e[0],left:t(r.slice(h,s).slice(-100)),right:t(r.slice(s+e[0].length,f).slice(0,100))}})},l=(t,l)=>{if(!t||!l)return l;const n=r(t),i=r(l);if(!n.length||!i.length)return l;if(n.length===i.length){let t=0;return l.replace(e,()=>n[t++].raw)}let g=0,c=0;return l.replace(e,e=>{const t=i[c++],r=n.findIndex((e,r)=>r>=g&&((e,t)=>{const r=Boolean(e.left&&t.left&&(e.left.endsWith(t.left)||t.left.endsWith(e.left))),l=Boolean(e.right&&t.right&&(e.right.startsWith(t.right)||t.right.startsWith(e.right)));if(r||l)return!0;const n=e.left&&e.left.length>=50&&t.left&&t.left.length>=50,i=e.right&&e.right.length>=50&&t.right&&t.right.length>=50;if(n){const r=e.left.slice(-30),l=t.left.slice(-30);if(r.split("").filter((e,t)=>l[t]===e).length>=15)return!0}if(i){const r=e.right.slice(0,30),l=t.right.slice(0,30);if(r.split("").filter((e,t)=>l[t]===e).length>=15)return!0}return!1})(e,t));return-1===r?e:(g=r+1,n[r].raw)})},n=/[^\S\r\n]*(?:\r?\n[^\S\r\n]*){2,}/g,i=e=>Array.from(e.matchAll(new RegExp(n.source,"g"))).map(r=>{var l;const n=null!==(l=r.index)&&void 0!==l?l:0,i=e.slice(0,n),g=e.slice(n+r[0].length);return{raw:r[0],left:t(i.slice(i.lastIndexOf("\n")+1).slice(-240)),right:t(g.split(/\r?\n/,1)[0].slice(0,240))}}),g=e=>{var t;return(null!==(t=e.match(/\r?\n/g))&&void 0!==t?t:[]).length},c=(e,t)=>{if(!e||!t)return t;const r=i(e),l=i(t);if(!r.length||!l.length)return t;let c=0,a=0;return t.replace(n,e=>{const t=l[a++],n=r.findIndex((e,r)=>r>=c&&e.left===t.left&&e.right===t.right&&g(t.raw)<=g(e.raw)&&(e.raw.includes(" ")||g(t.raw)===g(e.raw)));return-1===n?e:(c=n+1,r[n].raw)})};export{l as preserveLineBreaksFromSource,c as preserveUnchangedWhitespaceRunsFromSource};
|
|
2
2
|
//# sourceMappingURL=preserveMarkdownLineBreaks.js.map
|
package/dist/features/RequirementAI/components/RichTextEditor/Editor/utils/preserveReviewBlocks.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{markdownWithoutEmphasisMarkers as e}from"./preserveMarkdownEmphasis.js";const r=new RegExp(String.raw`<(manual|upt)\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/\1\s*>`,"gi"),n=new RegExp(String.raw`<del\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/del\s*>[ \t\r\n]*<ins\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/ins\s*>`,"gi"),i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e=>{var r,n;return null!==(n=null===(r=e.match(/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/i))||void 0===r?void 0:r.slice(1).find(Boolean))&&void 0!==n?n:""},t=r=>e(r).replace(/<(\/)?(del|ins|preserved)\b[^>]*>/gi,(e,r,n)=>` ZXQ${r?"CLOSE":"OPEN"}${String(n).toUpperCase()}QXZ `).replace(/<br\s*\/?>/gi,"\n").replace(/<[^>]*>/g,"").replace(/ |\u00a0/gi," ").replace(/>/gi,">").replace(/</gi,"<").replace(/"/gi,'"').replace(/'|'/gi,"'").replace(/&/gi,"&").replace(/\s+/g," ").trim(),l=(e,l)=>{const a=Array.from(e.matchAll(new RegExp(r.source,"gi")));let c=l;return a.forEach(e=>{const[,r,l,a]=e,o=s(l);if(!o)return;const p=i(o),g=new RegExp(String.raw`<${r}\b(?=(?:[^>"']|"[^"]*"|'[^']*')*\bid\s*=\s*(?:"${p}"|'${p}'))((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/${r}\s*>`,"i");c=c.replace(g,(r,n,i)=>t(a)===t(i)?e[0]:r),c=((e,r,l,a)=>{var c;const o=s(r);if(!o)return a;const p=i(o);if(new RegExp(String.raw`<(?:manual|upt)\b(?=(?:[^>"']|"[^"]*"|'[^']*')*\bid\s*=\s*(?:"${p}"|'${p}'))`,"i").test(a))return a;const g=null===(c=l.match(new RegExp(`^\\s*(${n.source})\\s*$`,"i")))||void 0===c?void 0:c[1];if(!g)return a;const u=t(g),d=Array.from(a.matchAll(new RegExp(n.source,"gi"))).find(e=>{var r;return!((e,r)=>{const n=/<(\/)?(?:manual|upt)\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi;let i,s=0;for(;null!==(i=n.exec(e))&&i.index<r;)s+=i[1]?-1:1;return s>0})(a,null!==(r=e.index)&&void 0!==r?r:0)&&t(e[0])===u});if(!d||void 0===d.index)return a;const $=`<${e}${r}>${d[0]}</${e}>`;return a.slice(0,d.index)+$+a.slice(d.index+d[0].length)})(r,l,a,c)}),c};export{s as getReviewId,l as preserveUnchangedReviewBlocksFromSource};
|
|
1
|
+
import{markdownWithoutEmphasisMarkers as e}from"./preserveMarkdownEmphasis.js";const r=new RegExp(String.raw`<(manual|upt)\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/\1\s*>`,"gi"),n=new RegExp(String.raw`<del\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/del\s*>[ \t\r\n]*<ins\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/ins\s*>`,"gi"),i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e=>{var r,n;return null!==(n=null===(r=e.match(/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/i))||void 0===r?void 0:r.slice(1).find(Boolean))&&void 0!==n?n:""},t=r=>e(r).replace(/<(\/)?(del|ins|preserved)\b[^>]*>/gi,(e,r,n)=>` ZXQ${r?"CLOSE":"OPEN"}${String(n).toUpperCase()}QXZ `).replace(/<br\s*\/?>/gi,"\n").replace(/\\\|/g,"|").replace(/<[^>]*>/g,"").replace(/ |\u00a0/gi," ").replace(/>/gi,">").replace(/</gi,"<").replace(/"/gi,'"').replace(/'|'/gi,"'").replace(/&/gi,"&").replace(/\s+/g," ").trim(),l=(e,l)=>{const a=Array.from(e.matchAll(new RegExp(r.source,"gi")));let c=l;return a.forEach(e=>{const[,r,l,a]=e,o=s(l);if(!o)return;const p=i(o),g=new RegExp(String.raw`<${r}\b(?=(?:[^>"']|"[^"]*"|'[^']*')*\bid\s*=\s*(?:"${p}"|'${p}'))((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/${r}\s*>`,"i");c=c.replace(g,(r,n,i)=>t(a)===t(i)?e[0]:r),c=((e,r,l,a)=>{var c;const o=s(r);if(!o)return a;const p=i(o);if(new RegExp(String.raw`<(?:manual|upt)\b(?=(?:[^>"']|"[^"]*"|'[^']*')*\bid\s*=\s*(?:"${p}"|'${p}'))`,"i").test(a))return a;const g=null===(c=l.match(new RegExp(`^\\s*(${n.source})\\s*$`,"i")))||void 0===c?void 0:c[1];if(!g)return a;const u=t(g),d=Array.from(a.matchAll(new RegExp(n.source,"gi"))).find(e=>{var r;return!((e,r)=>{const n=/<(\/)?(?:manual|upt)\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi;let i,s=0;for(;null!==(i=n.exec(e))&&i.index<r;)s+=i[1]?-1:1;return s>0})(a,null!==(r=e.index)&&void 0!==r?r:0)&&t(e[0])===u});if(!d||void 0===d.index)return a;const $=`<${e}${r}>${d[0]}</${e}>`;return a.slice(0,d.index)+$+a.slice(d.index+d[0].length)})(r,l,a,c)}),c};export{s as getReviewId,l as preserveUnchangedReviewBlocksFromSource};
|
|
2
2
|
//# sourceMappingURL=preserveReviewBlocks.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{forwardRef as r,useRef as n,useState as l,useEffect as o,useImperativeHandle as i}from"react";import{DEFAULT_TOOLBAR_CONFIG as s}from"./Editor/constants/editorConfig.js";import a from"./Editor/Editor.js";import{useRefStore as c}from"../../store/ref.context.js";import{$generateHtmlFromNodes as d}from"@lexical/html";import u from"turndown";import{tables as p}from"turndown-plugin-gfm";import{UnsavedChangesPopup as h}from"../UnsavedChangesPopup/UnsavedChangesPopup.js";import{mergeTagAcrossParagraphs as m,unescapeTagIds as g,preserveLegacyCommentRedlinesFromSource as f,preserveDocumentAnchorsFromSource as v,preserveInvisibleAnchorBeforeTablePipe as E}from"../../../../utils/tagHelper.js";import{INITIAL_CONTENT_UPDATE_TAG as w}from"./Editor/constants/updateTags.js";import{normalizeRedundantInlineFormattingElements as x,preserveEmphasisMarkersFromSource as b,preserveLiteralMidWordUnderscoresFromSource as A,preserveUnchangedEmphasisParagraphsFromSource as y}from"./Editor/utils/preserveMarkdownEmphasis.js";import{preserveTableDelimiterRowsFromSource as C}from"./Editor/utils/preserveTableDelimiters.js";import{preserveLineBreaksFromSource as S}from"./Editor/utils/preserveMarkdownLineBreaks.js";import{preserveListFormattingFromSource as $}from"./Editor/utils/preserveMarkdownListFormatting.js";import{preserveUnchangedReviewBlocksFromSource as N,getReviewId as k}from"./Editor/utils/preserveReviewBlocks.js";import{preserveUnchangedMarkdownEscapesFromSource as j}from"./Editor/utils/preserveMarkdownEscapes.js";import{markdownTableCellReplacement as B}from"./Editor/utils/markdownTableSerialization.js";import{replaceReviewNodesWithMarkdownPlaceholders as I,restoreReviewNodePlaceholders as T}from"./Editor/utils/reviewNodeSerialization.js";const R=new u({headingStyle:"atx",codeBlockStyle:"fenced",emDelimiter:"*"}),L=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");R.keep(["ins","del","mark"]),R.keep(e=>["DELETED","CHANGED","PRESERVED"].includes(e.nodeName)),R.addRule("ai-reasoning-link-passthrough",{filter:e=>{var t,r;return"A"===e.nodeName&&null!==(r=null===(t=e.getAttribute("href"))||void 0===t?void 0:t.includes("ai_reasoning$"))&&void 0!==r&&r},replacement:(e,t)=>{const r=t,n=r.getAttribute("href")||"",l=r.textContent||"";return`<a href="${o=n,L(o).replace(/"/g,""")}">${L(l)}</a>`;var o}}),R.keep(e=>"SPAN"===e.nodeName&&e.hasAttribute("highlight-id")),R.addRule("md-table-passthrough",{filter:e=>"PRE"===e.nodeName&&"true"===e.getAttribute("data-md-table"),replacement:(e,t)=>t.textContent||""}),R.use(p),R.addRule("stable-table-cell",{filter:["th","td"],replacement:B});const q=(e,t)=>{let r=0;for(let n=t-1;n>=0&&"\\"===e[n];n-=1)r+=1;return r%2==1};R.addRule("stable-line-break",{filter:"br",replacement:()=>"<br>"});const P=e=>{var t,r;const n=null!==(r=null===(t=e.match(/^\s*/))||void 0===t?void 0:t[0])&&void 0!==r?r:"";let l=e.slice(n.length).trimEnd();const o=l.startsWith("|"),i=l.endsWith("|")&&!q(l,l.length-1);o&&(l=l.slice(1)),i&&(l=l.slice(0,-1));const s=[];let a="",c=!1,d="";for(let e=0;e<l.length;e+=1){const t=l[e];c?(a+=t,d?t!==d||q(l,e)||(d=""):'"'===t||"'"===t?d=t:">"===t&&(c=!1)):"<"===t?(c=!0,a+=t):"|"!==t||q(l,e)?a+=t:(s.push(a),a="")}return s.push(a),s.length<2?null:{indent:n,leadingPipe:o,trailingPipe:i,rawCells:s,cells:s.map(e=>e.trim())}},D=e=>!!e&&e.cells.every(e=>/^:?-{3,}:?$/.test(e)),M=e=>{const t=[];for(let r=1;r<e.length;r+=1){const n=P(e[r]),l=P(e[r-1]);if(!D(n)||!l)continue;const o=[{lineIndex:r-1,row:l},{lineIndex:r,row:n}];for(r+=1;r<e.length;){const t=P(e[r]);if(!t||D(t))break;o.push({lineIndex:r,row:t}),r+=1}t.push(o),r-=1}return t},H=e=>e.trim().replace(/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,"<br>"),W=e=>e.replace(/<[^>]*>/g," ").replace(/[*_`~]+/g,"").replace(/ |\u00a0/gi," ").replace(/\s+/g," ").trim().toLocaleLowerCase(),O=(e,t)=>{const r=/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,n=Array.from(e.matchAll(r)),l=n.map((t,r)=>{var l,o,i,s,a;return{raw:t[0],left:W(e.slice(null!==(o=null===(l=n[r-1])||void 0===l?void 0:l.index)&&void 0!==o?o:0,t.index).slice(-80)),right:W(e.slice((null!==(i=t.index)&&void 0!==i?i:0)+t[0].length,null!==(a=null===(s=n[r+1])||void 0===s?void 0:s.index)&&void 0!==a?a:e.length).slice(0,80)),used:!1}}),o=Array.from(t.matchAll(r));let i=0;return t.replace(r,(r,n)=>{var s,a,c,d;const u=o.findIndex(e=>e.index===n),p=u>0?(null!==(s=o[u-1].index)&&void 0!==s?s:0)+o[u-1][0].length:0,h=null!==(c=null===(a=o[u+1])||void 0===a?void 0:a.index)&&void 0!==c?c:t.length,m=W(t.slice(p,n).slice(-80)),g=W(t.slice(n+r.length,h).slice(0,80)),f=l.findIndex((e,t)=>t>=i&&!e.used&&(e.left&&m.endsWith(e.left)||m&&e.left.endsWith(m)||e.right&&g.startsWith(e.right)||g&&e.right.startsWith(g))),v=l[f];if(v)return v.used=!0,i=f+1,v.raw;for(;null===(d=l[i])||void 0===d?void 0:d.used;)i+=1;const E=l[i];return E?(E.used=!0,i+=1,E.raw):(r=>{var n,l;const o=t.slice(0,r),i=o.lastIndexOf("<manual"),s=o.lastIndexOf("</manual"),a=o.lastIndexOf("<ins"),c=o.lastIndexOf("</ins");if(i<=s||a<=c)return!1;const d=null!==(l=null===(n=o.slice(i).match(/^<manual\b[^>]*>/i))||void 0===n?void 0:n[0])&&void 0!==l?l:"",u=k(d);return Boolean(u&&!e.includes(u))})(n)?r:""})},_=(e,t)=>{const r=((e,t)=>{if(e.cells.length===t.cells.length)return t.cells;const r=e.cells.filter(Boolean),n=t.cells.filter(Boolean);if(r.length!==n.length)return null;let l=0;return e.cells.map(e=>{if(!e)return"";const t=n[l];return l+=1,t})})(e,t);if(!r)return null;const n=r.map((r,n)=>{var l,o,i,s,a,c,d,u,p;const h=e.rawCells[n],m=null!==(o=null===(l=h.match(/^\s*/))||void 0===l?void 0:l[0])&&void 0!==o?o:"",g=null!==(s=null===(i=h.match(/\s*$/))||void 0===i?void 0:i[0])&&void 0!==s?s:"";if(!h.trim()){if(!r)return h;const e=null!==(a=t.rawCells[n])&&void 0!==a?a:r;return`${null!==(d=null===(c=e.match(/^\s*/))||void 0===c?void 0:c[0])&&void 0!==d?d:""}${r}${null!==(p=null===(u=e.match(/\s*$/))||void 0===u?void 0:u[0])&&void 0!==p?p:""}`}const f=e.cells[n];if(H(f)===H(r))return h;return`${m}${O(f,r)}${g}`});return`${e.indent}${e.leadingPipe?"|":""}${n.join("|")}${e.trailingPipe?"|":""}`},U=e=>(e||"").replace(/\r\n/g,"\n").trim(),z=r(({type:r,value:u,handleUpdateState:p,onBlur:k,placeholder:B,minHeight:L,height:q,mode:P,doNotShowBorderInViewMode:H,onEditBlocked:W,onSaveUnsavedChanges:O,onDiscardUnsavedChanges:z,isSavingUnsavedChanges:V=!1},X)=>{const F=n(null),[K,Q]=l({type:r,value:u}),[Z,G]=l(0),[J,Y]=l(!1),ee=n(u),te=n(u),re=n(Boolean(u)),{contentRef:ne,setContentRef:le}=c();o(()=>{Q(e=>({...e,value:u})),ee.current=u,te.current=u,re.current=Boolean(u),Y(!1)},[u]),i(X,()=>({requestClose:()=>!("edit"===P&&U(ee.current)!==U(te.current))||(Y(!0),!1)}),[P]);return o(()=>{const e=()=>{ne&&ne.current&&G(ne.current.clientHeight-60)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[ne]),e("div",{style:{position:"relative",width:"100%",height:q,minHeight:L},children:[J&&t(h,{isSaving:V,onSave:async()=>{await(null==O?void 0:O()),ee.current=te.current,Y(!1)},onDiscard:()=>{te.current=ee.current,null==z||z(),Y(!1)}}),t(a,{minHeight:L,height:q,placeholder:B||"Enter some text...",onChange:(e,t,r)=>{e.read(()=>{const e=d(t,null),n=(new DOMParser).parseFromString(e,"text/html");x(n),n.querySelectorAll("span").forEach(e=>{const t=e.getAttribute("style")||"";t.includes("background-color")&&(t.includes("rgb(219, 234, 254)")||t.includes("rgb(213, 232, 255)")||t.toLowerCase().includes("#d5e8ff"))&&e.setAttribute("data-review","insert"),t.includes("text-decoration")&&t.includes("line-through")&&e.setAttribute("data-review","delete")}),n.querySelectorAll("span[data-review]").forEach(e=>{const t="delete"===e.getAttribute("data-review")?"deleted":"changed",r=n.createElement(t);r.append(...Array.from(e.childNodes)),e.replaceWith(r)}),n.querySelectorAll("strong code").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code strong").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code").forEach(e=>{e.textContent=e.textContent||""}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,"")),e.removeAttribute("class"),e.textContent=e.textContent||""})(e)}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,""))});const l=[];n.querySelectorAll("invisible").forEach((e,t)=>{const r=`ZXQINVISIBLETOKEN${t}QXZ`;l.push({html:e.outerHTML,placeholder:r}),e.replaceWith(n.createTextNode(r))});const o=I(n,R),i=[];n.querySelectorAll("p").forEach(e=>{if(e.closest("td, th"))return;if(!(""===e.textContent&&Array.from(e.childNodes).every(e=>"BR"===e.nodeName||e.nodeType===Node.TEXT_NODE&&""===e.textContent)))return;const t=`%%BLANKLINE${i.length}%%`;i.push(t),e.textContent=t}),n.querySelectorAll("table > colgroup").forEach(e=>{e.remove()});let s=R.turndown(n.body.innerHTML);i.forEach(e=>{s=s.replace(new RegExp(`\\n*${e}\\n*`,"g"),"\n\n")}),s=T(s,o),l.forEach(({html:e,placeholder:t})=>{s=s.replace(t,e)}),s=s.replace(/\*{4}([^*]+)\*{4}/g,"**$1**"),s=s.replace(/\s+class="PlaygroundEditorTheme__[^"]*"/g,""),s=s.replace(/<span\s+style="white-space:\s*pre-wrap;?">([\s\S]*?)<\/span>/g,"$1"),s=s.replace(/\s+style="white-space:\s*pre-wrap;?"/g,""),s=s.replace(/<b>\s*<strong>([\s\S]*?)<\/strong>\s*<\/b>/g,"<strong>$1</strong>"),s=s.replace(/<code([^>]*)>\s*<span[^>]*>([\s\S]*?)<\/span>\s*<\/code>/g,"<code$1>$2</code>");if(["upt","manual","del","ins","preserved"].forEach(e=>{s=m(s,e)}),s=g(s,["manual","upt"]),s=N(ee.current,s),ee.current.includes("--\x3e")&&(s=s.replace(/-->/gi,"--\x3e")),s=f(ee.current,s),s=v(ee.current,s),s=b(ee.current,s),s=A(ee.current,s),s=((e,t)=>{const r=e.split("\n"),n=C(e,t).split("\n"),l=M(r);return M(n).forEach((e,t)=>{const o=l[t];if(!o)return;const i=o.length===e.length?e.length:Math.min(2,o.length,e.length);e.slice(0,i).forEach(({lineIndex:e,row:t},l)=>{const i=o[l];if(D(i.row)&&D(t))return void(n[e]=r[i.lineIndex]);const s=_(i.row,t);null!==s&&(n[e]=s)})}),n.join("\n")})(ee.current,s),s=E(ee.current,s),s=$(ee.current,s),s=S(ee.current,s),s=y(ee.current,s),s=j(ee.current,s),r.has(w))return te.current=ee.current,void(re.current=!1);re.current&&(ee.current=s,re.current=!1),te.current=s,((e,t)=>{p(e,t)})("prompt",s)})},toolbarConfig:s,editorRef:F,mode:P,initialString:{type:K.type,value:K.value},dynamicHeight:Z,onBlur:k,doNotShowBorderInViewMode:H||!1,onEditBlocked:W})]})});z.displayName="RichTextEditor";export{z as default};
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{forwardRef as r,useRef as n,useState as l,useEffect as o,useImperativeHandle as i}from"react";import{DEFAULT_TOOLBAR_CONFIG as s}from"./Editor/constants/editorConfig.js";import a from"./Editor/Editor.js";import{useRefStore as c}from"../../store/ref.context.js";import{$generateHtmlFromNodes as d}from"@lexical/html";import u from"turndown";import{tables as p}from"turndown-plugin-gfm";import{UnsavedChangesPopup as h}from"../UnsavedChangesPopup/UnsavedChangesPopup.js";import{mergeTagAcrossParagraphs as m,unescapeTagIds as g,preserveLegacyCommentRedlinesFromSource as f,preserveDocumentAnchorsFromSource as v,preserveInvisibleAnchorBeforeTablePipe as E}from"../../../../utils/tagHelper.js";import{INITIAL_CONTENT_UPDATE_TAG as w}from"./Editor/constants/updateTags.js";import{normalizeRedundantInlineFormattingElements as x,preserveEmphasisMarkersFromSource as b,preserveLiteralMidWordUnderscoresFromSource as A,preserveUnchangedEmphasisParagraphsFromSource as y}from"./Editor/utils/preserveMarkdownEmphasis.js";import{preserveTableDelimiterRowsFromSource as C}from"./Editor/utils/preserveTableDelimiters.js";import{preserveLineBreaksFromSource as S,preserveUnchangedWhitespaceRunsFromSource as $}from"./Editor/utils/preserveMarkdownLineBreaks.js";import{preserveListFormattingFromSource as N}from"./Editor/utils/preserveMarkdownListFormatting.js";import{preserveUnchangedReviewBlocksFromSource as k,getReviewId as j}from"./Editor/utils/preserveReviewBlocks.js";import{preserveUnchangedMarkdownEscapesFromSource as B}from"./Editor/utils/preserveMarkdownEscapes.js";import{markdownTableCellReplacement as I,ensureMarkdownTableColumnCounts as T}from"./Editor/utils/markdownTableSerialization.js";import{replaceReviewNodesWithMarkdownPlaceholders as R,restoreReviewNodePlaceholders as L}from"./Editor/utils/reviewNodeSerialization.js";const q=new u({headingStyle:"atx",codeBlockStyle:"fenced",emDelimiter:"*"}),P=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");q.keep(["ins","del","mark"]),q.keep(e=>["DELETED","CHANGED","PRESERVED"].includes(e.nodeName)),q.addRule("ai-reasoning-link-passthrough",{filter:e=>{var t,r;return"A"===e.nodeName&&null!==(r=null===(t=e.getAttribute("href"))||void 0===t?void 0:t.includes("ai_reasoning$"))&&void 0!==r&&r},replacement:(e,t)=>{const r=t,n=r.getAttribute("href")||"",l=r.textContent||"";return`<a href="${o=n,P(o).replace(/"/g,""")}">${P(l)}</a>`;var o}}),q.keep(e=>"SPAN"===e.nodeName&&e.hasAttribute("highlight-id")),q.addRule("md-table-passthrough",{filter:e=>"PRE"===e.nodeName&&"true"===e.getAttribute("data-md-table"),replacement:(e,t)=>t.textContent||""}),q.use(p),q.addRule("stable-table-cell",{filter:["th","td"],replacement:I});const D=(e,t)=>{let r=0;for(let n=t-1;n>=0&&"\\"===e[n];n-=1)r+=1;return r%2==1};q.addRule("stable-line-break",{filter:"br",replacement:()=>"<br>"});const M=e=>{var t,r;const n=null!==(r=null===(t=e.match(/^\s*/))||void 0===t?void 0:t[0])&&void 0!==r?r:"";let l=e.slice(n.length).trimEnd();const o=l.startsWith("|"),i=l.endsWith("|")&&!D(l,l.length-1);o&&(l=l.slice(1)),i&&(l=l.slice(0,-1));const s=[];let a="",c=!1,d="";for(let e=0;e<l.length;e+=1){const t=l[e];c?(a+=t,d?t!==d||D(l,e)||(d=""):'"'===t||"'"===t?d=t:">"===t&&(c=!1)):"<"===t?(c=!0,a+=t):"|"!==t||D(l,e)?a+=t:(s.push(a),a="")}return s.push(a),s.length<2?null:{indent:n,leadingPipe:o,trailingPipe:i,rawCells:s,cells:s.map(e=>e.trim())}},H=e=>!!e&&e.cells.every(e=>/^:?-{3,}:?$/.test(e)),W=e=>{const t=[];for(let r=1;r<e.length;r+=1){const n=M(e[r]),l=M(e[r-1]);if(!H(n)||!l)continue;const o=[{lineIndex:r-1,row:l},{lineIndex:r,row:n}];for(r+=1;r<e.length;){const t=M(e[r]);if(!t||H(t))break;o.push({lineIndex:r,row:t}),r+=1}t.push(o),r-=1}return t},O=e=>e.trim().replace(/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,"<br>"),_=e=>e.replace(/<[^>]*>/g," ").replace(/[*_`~]+/g,"").replace(/ |\u00a0/gi," ").replace(/\s+/g," ").trim().toLocaleLowerCase(),U=(e,t)=>{const r=/(?:[ \t\u00a0]| )*<br\s*\/?>(?:[ \t\u00a0]| )*/gi,n=Array.from(e.matchAll(r)),l=n.map((t,r)=>{var l,o,i,s,a;return{raw:t[0],left:_(e.slice(null!==(o=null===(l=n[r-1])||void 0===l?void 0:l.index)&&void 0!==o?o:0,t.index).slice(-80)),right:_(e.slice((null!==(i=t.index)&&void 0!==i?i:0)+t[0].length,null!==(a=null===(s=n[r+1])||void 0===s?void 0:s.index)&&void 0!==a?a:e.length).slice(0,80)),used:!1}}),o=Array.from(t.matchAll(r));let i=0;return t.replace(r,(r,n)=>{var s,a,c,d;const u=o.findIndex(e=>e.index===n),p=u>0?(null!==(s=o[u-1].index)&&void 0!==s?s:0)+o[u-1][0].length:0,h=null!==(c=null===(a=o[u+1])||void 0===a?void 0:a.index)&&void 0!==c?c:t.length,m=_(t.slice(p,n).slice(-80)),g=_(t.slice(n+r.length,h).slice(0,80)),f=l.findIndex((e,t)=>t>=i&&!e.used&&(e.left&&m.endsWith(e.left)||m&&e.left.endsWith(m)||e.right&&g.startsWith(e.right)||g&&e.right.startsWith(g))),v=l[f];if(v)return v.used=!0,i=f+1,v.raw;for(;null===(d=l[i])||void 0===d?void 0:d.used;)i+=1;const E=l[i];return E?(E.used=!0,i+=1,E.raw):(r=>{var n,l;const o=t.slice(0,r),i=o.lastIndexOf("<manual"),s=o.lastIndexOf("</manual"),a=o.lastIndexOf("<ins"),c=o.lastIndexOf("</ins");if(i<=s||a<=c)return!1;const d=null!==(l=null===(n=o.slice(i).match(/^<manual\b[^>]*>/i))||void 0===n?void 0:n[0])&&void 0!==l?l:"",u=j(d);return Boolean(u&&!e.includes(u))})(n)?r:""})},z=(e,t)=>{const r=((e,t)=>{if(e.cells.length===t.cells.length)return t.cells;const r=e.cells.filter(Boolean),n=t.cells.filter(Boolean);if(r.length!==n.length)return null;let l=0;return e.cells.map(e=>{if(!e)return"";const t=n[l];return l+=1,t})})(e,t);if(!r)return null;const n=r.map((r,n)=>{var l,o,i,s,a,c,d,u,p;const h=e.rawCells[n],m=null!==(o=null===(l=h.match(/^\s*/))||void 0===l?void 0:l[0])&&void 0!==o?o:"",g=null!==(s=null===(i=h.match(/\s*$/))||void 0===i?void 0:i[0])&&void 0!==s?s:"";if(!h.trim()){if(!r)return h;const e=null!==(a=t.rawCells[n])&&void 0!==a?a:r;return`${null!==(d=null===(c=e.match(/^\s*/))||void 0===c?void 0:c[0])&&void 0!==d?d:""}${r}${null!==(p=null===(u=e.match(/\s*$/))||void 0===u?void 0:u[0])&&void 0!==p?p:""}`}const f=e.cells[n];if(O(f)===O(r))return h;return`${m}${U(f,r)}${g}`});return`${e.indent}${e.leadingPipe?"|":""}${n.join("|")}${e.trailingPipe?"|":""}`},V=e=>(e||"").replace(/\r\n/g,"\n").trim(),X=r(({type:r,value:u,handleUpdateState:p,onBlur:j,placeholder:I,minHeight:P,height:D,mode:M,doNotShowBorderInViewMode:O,onEditBlocked:_,onSaveUnsavedChanges:U,onDiscardUnsavedChanges:X,isSavingUnsavedChanges:F=!1},K)=>{const Q=n(null),[Z,G]=l({type:r,value:u}),[J,Y]=l(0),[ee,te]=l(!1),re=n(u),ne=n(u),le=n(Boolean(u)),{contentRef:oe,setContentRef:ie}=c();o(()=>{G(e=>({...e,value:u})),re.current=u,ne.current=u,le.current=Boolean(u),te(!1)},[u]),i(K,()=>({requestClose:()=>!("edit"===M&&V(re.current)!==V(ne.current))||(te(!0),!1)}),[M]);return o(()=>{const e=()=>{oe&&oe.current&&Y(oe.current.clientHeight-60)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[oe]),e("div",{style:{position:"relative",width:"100%",height:D,minHeight:P},children:[ee&&t(h,{isSaving:F,onSave:async()=>{await(null==U?void 0:U()),re.current=ne.current,te(!1)},onDiscard:()=>{ne.current=re.current,null==X||X(),te(!1)}}),t(a,{minHeight:P,height:D,placeholder:I||"Enter some text...",onChange:(e,t,r)=>{e.read(()=>{const e=d(t,null),n=(new DOMParser).parseFromString(e,"text/html");x(n),n.querySelectorAll("span").forEach(e=>{const t=e.getAttribute("style")||"";t.includes("background-color")&&(t.includes("rgb(219, 234, 254)")||t.includes("rgb(213, 232, 255)")||t.toLowerCase().includes("#d5e8ff"))&&e.setAttribute("data-review","insert"),t.includes("text-decoration")&&t.includes("line-through")&&e.setAttribute("data-review","delete")}),n.querySelectorAll("span[data-review]").forEach(e=>{const t="delete"===e.getAttribute("data-review")?"deleted":"changed",r=n.createElement(t);r.append(...Array.from(e.childNodes)),e.replaceWith(r)}),n.querySelectorAll("strong code").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code strong").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),n.querySelectorAll("code").forEach(e=>{e.textContent=e.textContent||""}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,"")),e.removeAttribute("class"),e.textContent=e.textContent||""})(e)}),n.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,""))});const l=[];n.querySelectorAll("invisible").forEach((e,t)=>{const r=`ZXQINVISIBLETOKEN${t}QXZ`;l.push({html:e.outerHTML,placeholder:r}),e.replaceWith(n.createTextNode(r))});const o=R(n,q),i=[];n.querySelectorAll("p").forEach(e=>{if(e.closest("td, th"))return;if(!(""===e.textContent&&Array.from(e.childNodes).every(e=>"BR"===e.nodeName||e.nodeType===Node.TEXT_NODE&&""===e.textContent)))return;const t=`%%BLANKLINE${i.length}%%`;i.push(t),e.textContent=t}),n.querySelectorAll("table > colgroup").forEach(e=>{e.remove()});let s=q.turndown(n.body.innerHTML);i.forEach(e=>{s=s.replace(new RegExp(`\\n*${e}\\n*`,"g"),"\n\n")}),s=L(s,o),l.forEach(({html:e,placeholder:t})=>{s=s.replace(t,e)}),s=s.replace(/\*{4}([^*]+)\*{4}/g,"**$1**"),s=s.replace(/\s+class="PlaygroundEditorTheme__[^"]*"/g,""),s=s.replace(/<span\s+style="white-space:\s*pre-wrap;?">([\s\S]*?)<\/span>/g,"$1"),s=s.replace(/\s+style="white-space:\s*pre-wrap;?"/g,""),s=s.replace(/<b>\s*<strong>([\s\S]*?)<\/strong>\s*<\/b>/g,"<strong>$1</strong>"),s=s.replace(/<code([^>]*)>\s*<span[^>]*>([\s\S]*?)<\/span>\s*<\/code>/g,"<code$1>$2</code>");if(["upt","manual","del","ins","preserved"].forEach(e=>{s=m(s,e)}),s=g(s,["manual","upt"]),s=k(re.current,s),re.current.includes("--\x3e")&&(s=s.replace(/-->/gi,"--\x3e")),s=f(re.current,s),s=v(re.current,s),s=b(re.current,s),s=A(re.current,s),s=((e,t)=>{const r=e.split("\n"),n=C(e,t).split("\n"),l=W(r);return W(n).forEach((e,t)=>{const o=l[t];if(!o)return;const i=o.length===e.length?e.length:Math.min(2,o.length,e.length);e.slice(0,i).forEach(({lineIndex:e,row:t},l)=>{const i=o[l];if(H(i.row)&&H(t))return void(n[e]=r[i.lineIndex]);const s=z(i.row,t);null!==s&&(n[e]=s)})}),n.join("\n")})(re.current,s),s=E(re.current,s),s=N(re.current,s),s=S(re.current,s),s=y(re.current,s),s=B(re.current,s),s=$(re.current,s),s=B(re.current,s),s=T(s),r.has(w))return ne.current=re.current,void(le.current=!1);le.current&&(re.current=s,le.current=!1),ne.current=s,((e,t)=>{p(e,t)})("prompt",s)})},toolbarConfig:s,editorRef:Q,mode:M,initialString:{type:Z.type,value:Z.value},dynamicHeight:J,onBlur:j,doNotShowBorderInViewMode:O||!1,onEditBlocked:_})]})});X.displayName="RichTextEditor";export{X as default};
|
|
2
2
|
//# sourceMappingURL=RichTextEditor.js.map
|