@e-llm-studio/citation 0.0.229 → 0.0.231

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.
Files changed (97) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CitationRenderer.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +2 -0
  7. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
  8. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +2 -0
  9. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -0
  10. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/helper.js +2 -0
  11. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/helper.js.map +1 -0
  12. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +2 -0
  13. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -0
  14. package/dist/cjs/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  15. package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  16. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  17. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  18. package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  19. package/dist/cjs/features/CognitiveCompare/components/connectedLines.js +1 -1
  20. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  21. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  22. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  23. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  24. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveNonWebSearchReasoning.module.css.js +1 -1
  25. package/dist/cjs/hooks/useOnDemandCitationFetch.js +1 -1
  26. package/dist/cjs/service/onDemandApi.js +1 -1
  27. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  28. package/dist/features/CognitiveCompare/CitationRenderer.js +1 -1
  29. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  30. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  31. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  32. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +2 -0
  33. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
  34. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +2 -0
  35. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -0
  36. package/dist/features/CognitiveCompare/Guidelines/utils/helper.js +2 -0
  37. package/dist/features/CognitiveCompare/Guidelines/utils/helper.js.map +1 -0
  38. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +2 -0
  39. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -0
  40. package/dist/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  41. package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  42. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  43. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  44. package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  45. package/dist/features/CognitiveCompare/components/connectedLines.js +1 -1
  46. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  47. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  48. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  49. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  50. package/dist/features/CognitiveInternalgptReasoning/CognitiveNonWebSearchReasoning.module.css.js +1 -1
  51. package/dist/hooks/useOnDemandCitationFetch.js +1 -1
  52. package/dist/service/onDemandApi.js +1 -1
  53. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  54. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts +3 -0
  55. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  56. package/dist/types/src/features/CognitiveCompare/CitationRenderer.d.ts +3 -1
  57. package/dist/types/src/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
  58. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  59. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  60. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +19 -0
  61. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  62. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +21 -3
  63. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  64. package/dist/types/src/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
  65. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts +5 -1
  66. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
  67. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts +3 -0
  68. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -0
  69. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts +8 -0
  70. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -0
  71. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +2001 -0
  72. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -0
  73. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/helper.d.ts +11 -0
  74. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/helper.d.ts.map +1 -0
  75. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +6 -0
  76. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -0
  77. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts +2 -0
  78. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts.map +1 -1
  79. package/dist/types/src/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
  80. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  81. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts +1 -0
  82. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  83. package/dist/types/src/features/CognitiveCompare/components/SvgConnectors.d.ts +2 -1
  84. package/dist/types/src/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
  85. package/dist/types/src/features/CognitiveCompare/components/connectedLines.d.ts +1 -0
  86. package/dist/types/src/features/CognitiveCompare/components/connectedLines.d.ts.map +1 -1
  87. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  88. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +2 -1
  89. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  90. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +1 -0
  91. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
  92. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts +1 -1
  93. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  94. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts +1 -1
  95. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  96. package/dist/types/src/service/onDemandApi.d.ts.map +1 -1
  97. 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"),i=require("lucide-react"),l=require("react"),t=require("./ResizableSplitPane.js"),o=require("../PdfViewer/PdfViewer.js"),d=require("../../assests/svg/PdfViewerIcons.js"),r=function(i){var d,r,a,u,s,c,g,v=i.href,p=i.metaData,h=i.citationTitle,_=i.isFullscreen,f=function(e){try{return new URL(e,window.location.origin).searchParams.get("citationNumber")}catch(e){return null}}(v),m=f&&(null===(d=null==p?void 0:p.citations)||void 0===d?void 0:d[f])||{},x=(null===(r=null==p?void 0:p.docData)||void 0===r?void 0:r.documents)||{},b=(null===(a=null==p?void 0:p.docData)||void 0===a?void 0:a.input_index_map)||{},j=null==b?void 0:b[0],y=null==b?void 0:b[1],C=j?x[j]:null,w=y?x[y]:null,F=j?m[j]:null,P=y?m[y]:null,S=l.useMemo(function(){var e,i,l,t;return F&&C?n.jsx(o.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==C?void 0:C.title,pdfUrl:null==C?void 0:C.signed_url,highlightText:[null!==(e=null==F?void 0:F.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(i=null==F?void 0:F.custom_metadata)||void 0===i?void 0:i.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(l=null==F?void 0:F.custom_metadata)||void 0===l?void 0:l.pdf_start_page_number,null===(t=null==F?void 0:F.custom_metadata)||void 0===t?void 0:t.pdf_end_page_number]}):null},[null==C?void 0:C.title,null==C?void 0:C.signed_url,null==F?void 0:F.highlighted_text,null===(u=null==F?void 0:F.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number,null===(s=null==F?void 0:F.custom_metadata)||void 0===s?void 0:s.pdf_end_page_number]),D=l.useMemo(function(){var e,i,l,t;return P&&w?n.jsx(o.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==w?void 0:w.title,pdfUrl:null==w?void 0:w.signed_url,jumpToPageValue:1,highlightText:[null!==(e=null==P?void 0:P.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(i=null==P?void 0:P.custom_metadata)||void 0===i?void 0:i.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(l=null==P?void 0:P.custom_metadata)||void 0===l?void 0:l.pdf_start_page_number,null===(t=null==P?void 0:P.custom_metadata)||void 0===t?void 0:t.pdf_end_page_number]}):null},[null==w?void 0:w.title,null==w?void 0:w.signed_url,null==P?void 0:P.highlighted_text,null===(c=null==P?void 0:P.custom_metadata)||void 0===c?void 0:c.pdf_start_page_number,null===(g=null==P?void 0:P.custom_metadata)||void 0===g?void 0:g.pdf_end_page_number]),k=l.useMemo(function(){return S||D?n.jsx(t.default,{leftComponent:S,rightComponent:D,isFullscreen:_}):null},[S,D,_]);return f?["contract","clause"].includes(h)?F||P?n.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:k})):n.jsx("div",{children:"Missing PDF Citation. Please try again later"}):n.jsx("div",{children:"No Citation Found. Please try again later"}):null};exports.default=function(t){var o,a,u,s=t.href,c=t.children,g=t.metaData,v=t.chevronUpComponent,p=void 0===v?null:v,h=t.chevronDownComponent,_=void 0===h?null:h,f=t.customStyle,m=void 0===f?{}:f,x=t.defaultState,b=void 0!==x&&x,j=l.useState(b),y=j[0],C=j[1],w=l.useState(!1),F=w[0],P=w[1],S="string"==typeof c&&(null===(o=null==c?void 0:c.split("\n"))||void 0===o?void 0:o.length)>1?c.split("\n").join(" "):c,D="string"==typeof c?c:c[0],k=null!=p?p:function(e){var l,t;return n.jsx(i.ChevronUp,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(a=null==m?void 0:m.arrow)&&void 0!==a?a:{}),z=null!=_?_:function(e){var l,t;return n.jsx(i.ChevronDown,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(u=null==m?void 0:m.arrow)&&void 0!==u?u:{});return n.jsxs("span",e.__assign({style:e.__assign({display:"inline"},m.relativeWrapper||{})},{children:[n.jsx("div",e.__assign({style:e.__assign({display:"inline",marginTop:0},m.citationButtonWrapper||{})},{children:n.jsxs("button",e.__assign({type:"button",onClick:function(){return C(function(e){return!e})},style:e.__assign({display:"inline-flex",alignItems:"center",gap:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:700,color:"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},m.citationButton||{})},{children:[n.jsx("span",{children:S}),n.jsx("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:y?k:z}))]}))})),y&&n.jsxs("div",e.__assign({style:F?{position:"fixed",inset:0,zIndex:999999,backgroundColor:"#FAFAFA",display:"flex",flexDirection:"column"}:{boxSizing:"border-box",border:"1px solid #E4E7EC",borderRadius:"8px",overflow:"hidden",marginTop:"8px",display:"flex",flexDirection:"column",width:"100%"}},{children:[n.jsx("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:n.jsx("button",e.__assign({onClick:function(){P(function(e){return!e})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:F?n.jsx(d.DefaultFullScreenCloseIcon,{}):n.jsx(d.DefaultFullScreenIcon,{})}))})),n.jsx("div",e.__assign({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:n.jsx(r,{href:s,children:c,metaData:g,citationTitle:D,isFullscreen:F})}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("lucide-react"),t=require("react"),o=require("./ResizableSplitPane.js"),l=require("../PdfViewer/PdfViewer.js"),a=require("../../assests/svg/PdfViewerIcons.js"),r=require("react-markdown"),u=require("rehype-raw"),d=require("@mui/material"),s=require("./CognitiveCompareConfig.js");require("react-dom");var c=require("./CompareContext.js"),v=require("./Guidelines/utils/processGuidelinesMarkdown.js"),p=require("../GptWebCitation/GptWebCitation.js"),g=require("../GptWebCitation/types.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./MoreFunctionsPopup.js"),require("./components/SubSectionAccordion.js"),require("./components/LHSSectionRow.js"),require("./components/RHSSectionRow.js");var x=h(r),m=h(u),f=function(e){var i,n,t;return(null===(t=null===(n=null===(i=(null==e?void 0:e.extraMetaData)||e)||void 0===i?void 0:i.aiReasoningCitation)||void 0===n?void 0:n.gpt_citation)||void 0===t?void 0:t[0])||null},_="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",b="sai.siddhartha@techolution.com",y="672e32f7a0e8fe2e8e50bcba",C="TNV Sai Siddhartha",w="90vh",j="calc(".concat(w," - 120px)"),D=function(){var e;return"function"==typeof(null===(e=globalThis.crypto)||void 0===e?void 0:e.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var i=Math.floor(16*Math.random());return("x"===e?i:i%4+8).toString(16)})},F=function(e,i){var n=function(e){var i;return(null==e?void 0:e.payloadCitationId)||(null===(i=null==e?void 0:e.extraMetaData)||void 0===i?void 0:i.payloadCitationId)||""}(e)||i||D();return function(e,i){e&&"object"==typeof e&&(e.payloadCitationId=i,e.extraMetaData&&"object"==typeof e.extraMetaData&&(e.extraMetaData.payloadCitationId=i))}(e,n),n},S=function(o){var l,a=o.metaData,r=o.isFullscreen,u=void 0!==r&&r,d=c.useCompareContext().gptWebCitationConfig,s=t.useMemo(function(){return function(e){return{endpoint:(null==e?void 0:e.endpoint)||_,userEmail:(null==e?void 0:e.userEmail)||b,userId:(null==e?void 0:e.userId)||y,userName:(null==e?void 0:e.userName)||C,headers:null==e?void 0:e.headers}}(d)},[d]),v=null==a?void 0:a.webGpt,h=t.useRef(null);h.current||(h.current=D());var x=t.useMemo(function(){return function(e,i,n){var t,o,l=f(e),a=(null==l?void 0:l.customMetaData)||{},r=(null==a?void 0:a.value)||{},u=(null==e?void 0:e.webSearchAnswer)||{},d=(null==e?void 0:e.extraMetaData)||e||{};return{userEmail:(null==e?void 0:e.userEmail)||(null==u?void 0:u.userEmail)||(null==i?void 0:i.userEmail)||"",userId:(null==e?void 0:e.userId)||(null==u?void 0:u.userId)||(null==i?void 0:i.userId)||"",userName:(null==e?void 0:e.userName)||(null==u?void 0:u.userName)||(null==i?void 0:i.userName)||"",citationId:F(e,n),citationUrl:(null==r?void 0:r.citationUrl)||(null==u?void 0:u.citationUrl)||"",content:(null==d?void 0:d.Reasoning)||(null==u?void 0:u.enhanced_content)||"",citationType:(null==r?void 0:r.citationType)||"web",citatioNumber:null!==(o=null!==(t=null==a?void 0:a.citation_number)&&void 0!==t?t:null==l?void 0:l.citation_number)&&void 0!==o?o:Number((null==e?void 0:e.reasoningId)||0)}}(v,s,h.current||void 0)},[v,s]),m=t.useMemo(function(){return f(v)},[v]),w=(null===(l=null==m?void 0:m.customMetaData)||void 0===l?void 0:l.value)||{},S=(null==v?void 0:v.extraMetaData)||v||{},P=t.useState(),M=P[0],T=P[1],k=t.useState("pending"),I=k[0],R=k[1],G=t.useState(!0),E=G[0],N=G[1];t.useEffect(function(){var i=!0;return e.__awaiter(void 0,void 0,void 0,function(){var n,t,o,l;return e.__generator(this,function(a){switch(a.label){case 0:if(!s.endpoint||!(null==x?void 0:x.citationUrl)||!(null==x?void 0:x.content))return R("error"),[2];R("pending"),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,fetch(s.endpoint,{method:"POST",headers:e.__assign({"actor-id":x.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},s.headers||{}),body:JSON.stringify(x)})];case 2:if(!(n=a.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return t=a.sent(),o=(null==t?void 0:t.responseData)||(null==t?void 0:t.result)||(null==t?void 0:t.data)||t,i?(T(o),R("success"),[3,5]):[2];case 4:return l=a.sent(),i?(console.error("Failed to load GPT web citation",l),R("error"),[3,5]):[2];case 5:return[2]}})}),function(){i=!1}},[x,s]);var q=t.useMemo(function(){return{item:{confidence_score:Number((null==S?void 0:S.Confidence_score)||0),text:(null==w?void 0:w.paraphrase)||"Web citation reasoning",dataSource:(null==w?void 0:w.text)||(null==S?void 0:S.Reasoning)||"",paraphrase:(null==w?void 0:w.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==x?void 0:x.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:n.ChevronDown,ChevronUpIcon:n.ChevronUp,MaximizeIcon:n.Maximize2,CloseIcon:n.X}}},[w,null==x?void 0:x.citatioNumber,S]),A=t.useMemo(function(){return e.__assign(e.__assign({},q),u?{bodyHeight:j}:{})},[q,u]);return i.jsx(p.default,{gptCitation:A,defaultCitationUrl:(null==x?void 0:x.citationUrl)||"",citationType:g.CitationType.GPT_WEB,webCitationData:M,webCitationStatus:I,showWebCitation:E,onToggleCitationView:function(){return N(function(e){return!e})},iconsConfig:{MaximizeIcon:n.Maximize2,ExternalLinkIcon:n.ExternalLink},isFixedHeight:!0})},P=function(n){var a,r,u,p,g,h,f,_=n.href,b=n.metaData,y=n.citationTitle,C=n.citationType,w=n.citationReason,j=n.isFullscreen,D=c.useCompareContext().guidelinesData,F=function(e){try{var i=new URL(e,window.location.origin);return{citationNumber:i.searchParams.get("citationNumber"),phraseToHighlight:i.searchParams.get("phrase_to_highlight")}}catch(e){return{citationNumber:null,phraseToHighlight:null}}}(_),P=F.citationNumber,M=F.phraseToHighlight,T=P&&(null===(a=null==b?void 0:b.citations)||void 0===a?void 0:a[P])||{},k=(null===(r=null==b?void 0:b.docData)||void 0===r?void 0:r.documents)||{},I=(null===(u=null==b?void 0:b.docData)||void 0===u?void 0:u.input_index_map)||{},R=Object.keys((null==b?void 0:b.citations)||{}).length>0||Object.keys((null==b?void 0:b.docData)||{}).length>0,G=null==I?void 0:I[0],E=null==I?void 0:I[1],N=G?k[G]:null,q=E?k[E]:null,A=G?T[G]:null,U=E?T[E]:null,W=t.useMemo(function(){var e,n,t,o;return A&&N?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==N?void 0:N.title,pdfUrl:null==N?void 0:N.signed_url,highlightText:[null!==(e=null==A?void 0:A.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==A?void 0:A.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==A?void 0:A.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==A?void 0:A.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==N?void 0:N.title,null==N?void 0:N.signed_url,null==A?void 0:A.highlighted_text,null===(p=null==A?void 0:A.custom_metadata)||void 0===p?void 0:p.pdf_start_page_number,null===(g=null==A?void 0:A.custom_metadata)||void 0===g?void 0:g.pdf_end_page_number]),z=t.useMemo(function(){var e,n,t,o;return U&&q?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==q?void 0:q.title,pdfUrl:null==q?void 0:q.signed_url,jumpToPageValue:1,highlightText:[null!==(e=null==U?void 0:U.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==U?void 0:U.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==U?void 0:U.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==U?void 0:U.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==q?void 0:q.title,null==q?void 0:q.signed_url,null==U?void 0:U.highlighted_text,null===(h=null==U?void 0:U.custom_metadata)||void 0===h?void 0:h.pdf_start_page_number,null===(f=null==U?void 0:U.custom_metadata)||void 0===f?void 0:f.pdf_end_page_number]),H="dual_citation"===C,O=H&&!!(null==b?void 0:b.webGpt),B=t.useMemo(function(){if(!W)return null;var n=O?i.jsx(S,{metaData:b,isFullscreen:j}):"rulebook_citation"===C?i.jsx(i.Fragment,{children:i.jsx(d.Box,e.__assign({sx:e.__assign(e.__assign({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},s.SHARED_MARKDOWN_STYLES),{overflow:"auto"})},{children:i.jsx(x.default,e.__assign({rehypePlugins:[m.default]},{children:v.processGuidelinesMarkdown({guidelinesData:D,targetHighlights:[M],labelColor:"#FEF08A"})}))}))}):z;return n?i.jsx(o.default,{leftComponent:W,rightComponent:n,isFullscreen:j}):W},[W,z,C,O,b,j]);return(null==b?void 0:b.webGpt)&&!R?i.jsx(S,{metaData:b,isFullscreen:j}):P?"rulebook_citation"===C?A?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:B})):i.jsx("div",e.__assign({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:w||"Rulebook citation selected."})):H?A||U?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:B})):(null==b?void 0:b.webGpt)?i.jsx(S,{metaData:b,isFullscreen:j}):i.jsx("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(y)?A||U?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:B})):i.jsx("div",{children:"Missing PDF Citation. Please try again later"}):i.jsx("div",{children:"No Citation Found. Please try again later"}):null};exports.default=function(o){var l,r,u,s,c,v,p,g=o.href,h=o.children,x=o.citationType,m=o.citationReason,f=o.metaData,_=o.chevronUpComponent,b=void 0===_?null:_,y=o.chevronDownComponent,C=void 0===y?null:y,j=o.customStyle,D=void 0===j?{}:j,F=o.defaultState,S=void 0!==F&&F,M=o.onFullscreenChange,T=t.useState(S),k=T[0],I=T[1],R=t.useState(!1),G=R[0],E=R[1],N="string"==typeof h&&(null===(l=null==h?void 0:h.split("\n"))||void 0===l?void 0:l.length)>1?h.split("\n").join(" "):h;t.useEffect(function(){if(null==M||M(G),G)return function(){null==M||M(!1)}},[G,M]);var q="string"==typeof h?h:h[0],A=null!=b?b:function(e){var t,o;return i.jsx(n.ChevronUp,{size:null!==(t=null==e?void 0:e.fontSize)&&void 0!==t?t:16,color:null!==(o=null==e?void 0:e.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(r=null==D?void 0:D.arrow)&&void 0!==r?r:{}),U=null!=C?C:function(e){var t,o;return i.jsx(n.ChevronDown,{size:null!==(t=null==e?void 0:e.fontSize)&&void 0!==t?t:16,color:null!==(o=null==e?void 0:e.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(u=null==D?void 0:D.arrow)&&void 0!==u?u:{}),W=i.jsxs("div",e.__assign({style:{boxSizing:"border-box",border:G?"none":"1px solid #E4E7EC",borderRadius:G?0:"8px",overflow:"hidden",marginTop:G?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:G?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[i.jsx("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:i.jsx("button",e.__assign({onClick:function(){E(function(e){return!e})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:G?i.jsx(a.DefaultFullScreenCloseIcon,{}):i.jsx(a.DefaultFullScreenIcon,{})}))})),i.jsx("div",e.__assign({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:i.jsx(P,{href:g,children:h,metaData:f,citationTitle:q,citationType:x,citationReason:m,isFullscreen:G})}))]}));return i.jsxs("span",e.__assign({style:e.__assign({display:"inline"},D.relativeWrapper||{})},{children:[i.jsx("div",e.__assign({style:e.__assign({display:"inline",marginTop:0},D.citationButtonWrapper||{})},{children:i.jsxs("button",e.__assign({type:"button",onClick:function(){return I(function(e){return!e})},style:e.__assign({display:(null==f?void 0:f.webGpt)?"inline":"inline-flex",alignItems:(null==f?void 0:f.webGpt)?void 0:"center",gap:(null==f?void 0:f.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==f?void 0:f.webGpt)?600:700,color:(null==f?void 0:f.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},D.citationButton||{})},{children:[(null==f?void 0:f.webGpt)&&i.jsx(n.Globe,{size:null!==(c=null===(s=D.arrow)||void 0===s?void 0:s.fontSize)&&void 0!==c?c:"1em",color:null!==(p=null===(v=D.arrow)||void 0===v?void 0:v.color)&&void 0!==p?p:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),i.jsx("span",{children:N}),i.jsx("span",e.__assign({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==f?void 0:f.webGpt)?"3px":void 0,verticalAlign:(null==f?void 0:f.webGpt)?"-0.125em":void 0}},{children:k?A:U}))]}))})),k&&(G?i.jsx(d.Dialog,e.__assign({open:G,onClose:function(){return E(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:w,m:0,maxHeight:w,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:W})):W)]}))};
2
2
  //# sourceMappingURL=CitationAnchor.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),i=require("react"),n=require("@mui/material"),t=require("react-markdown"),o=require("./CitationAnchor.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(t);exports.default=function(t){var s=t.content,a=void 0===s?"":s,c=t.title,d=void 0===c?"":c,l=t.citations,x=void 0===l?{}:l,f=t.styles,p=void 0===f?{}:f,_=t.docData,g=void 0===_?{}:_;t.open;var h=i.useMemo(function(){return JSON.stringify(x||{})},[x]),m=i.useMemo(function(){return x},[h]),v=i.useMemo(function(){return JSON.stringify(g||{})},[g]),y=i.useMemo(function(){return g},[v]),j=i.useMemo(function(){return{citations:m,docData:y}},[m,y]),b=i.useMemo(function(){return{a:function(e){var i=e.href,n=void 0===i?"":i,t=e.children;return r.jsx(o.default,{href:n,children:t,metaData:j})}}},[j]);return r.jsxs(n.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[r.jsx(n.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:r.jsx(n.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:d}))})),r.jsx(n.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:r.jsx(n.Box,e.__assign({sx:{display:"flex",flexDirection:"column"}},{children:r.jsx(n.Typography,e.__assign({component:"div",sx:e.__assign({},p)},{children:r.jsx(u.default,e.__assign({components:b},{children:a}))}))}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material"),t=require("react-markdown"),o=require("rehype-raw"),a=require("./CitationAnchor.js"),s=require("./Guidelines/utils/helper.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(t),c=u(o),d=function(e){return e?"./dual-citation?citationNumber=".concat(encodeURIComponent(e)):""};exports.default=function(t){var o=t.content,u=void 0===o?"":o,f=t.title,x=void 0===f?"":f,p=t.citations,v=void 0===p?{}:p,_=t.styles,g=void 0===_?{}:_,h=t.docData,m=void 0===h?{}:h,y=t.deviationData,b=void 0===y?null:y;t.open;var j=t.onCitationFullscreenChange,M=r.useMemo(function(){return JSON.stringify(v||{})},[v]),D=r.useMemo(function(){return v},[M]),w=r.useMemo(function(){return JSON.stringify(m||{})},[m]),C=r.useMemo(function(){return m},[w]),q=r.useMemo(function(){return{citations:D,docData:C}},[D,C]),S=r.useMemo(function(){var e=null==b?void 0:b.web_search_answer,n=(null==e?void 0:e.extraMetaData)||{};return Object.keys(n).reduce(function(e,n){var r=function(e,n){var r;if(!e||!n)return null;var i=null==e?void 0:e.web_search_answer,t=null===(r=null==i?void 0:i.extraMetaData)||void 0===r?void 0:r[n];return i&&t?{reasoningId:n,evaluation:e,webSearchAnswer:i,extraMetaData:t}:null}(b,n);return r&&(e[n]=r),e},{})},[b]),F=r.useMemo(function(){return s.mergeRulebookCitationsIntoMatchingLinks(u)},[u]),B=r.useMemo(function(){return{a:function(r){var i,t=r.href,o=void 0===t?"":t,s=r.children,u=r.type,l=r.reason,c=e.__rest(r,["href","children","type","reason"]),f=null==c?void 0:c["data-cognitive-reasoning"],x=!0===(i=null==c?void 0:c["dual-citation"])||"true"===i,p=x&&f?S[String(f)]:null;return n.jsx(a.default,{href:x?d(String(f||"")):o,children:s,citationType:x?"dual_citation":u,citationReason:l,metaData:e.__assign(e.__assign({},q),p?{webGpt:p}:{}),customStyle:p?{arrow:{color:"#6D28D9"}}:{},onFullscreenChange:j})}}},[q,S,j]);return n.jsxs(i.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[n.jsx(i.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:x}))})),n.jsx(i.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",flexDirection:"column"}},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:e.__assign({},g)},{children:n.jsx(l.default,e.__assign({components:B,rehypePlugins:[c.default]},{children:F}))}))}))}))]}))};
2
2
  //# sourceMappingURL=CitationRenderer.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),s=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(T){var D,O,F,j,P,N,k,L,M,q,H,V,z,G,W,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe=T.componentHeaderText,ve=void 0===fe?a.DEFAULT_COMPONENT_HEADER_TEXT:fe,ge=T.treeData,pe=T.comparisonConfig,he=T.leftColumnTitleText,me=T.rightColumnTitleText,Se=T.markdownStyles,Re=T.resetTrigger,xe=T.displayConfig,_e=void 0===xe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:xe,ye=T.onMaintainRelativeOrderChange,be=T.popupConfig,Ce=T.deviationData,Ee=void 0===Ce?{}:Ce,Ae=T.deviationNodeIdToView,Be=T.resetDeviationNodeId,we=T.isProposingFix,Ie=void 0!==we&&we,Te=T.proposingFixNodeId,De=T.isRedlineFlow,Oe=T.badgeStyleOverride,Fe=i.useState(_e.maintainRelativeOrder),je=Fe[0],Pe=Fe[1],Ne=null!==(D=null==_e?void 0:_e.expandLevels)&&void 0!==D?D:0,ke=!!(null==_e?void 0:_e.expandAllSections),Le=!!je||!!(null==_e?void 0:_e.showDeviationBadges),Me=i.useState(!1),qe=Me[0],He=Me[1],Ve=i.useState(null),ze=Ve[0],Ge=Ve[1],We=i.useState(null===(F=null!==(O=null==ge?void 0:ge.newEvaluationResult)&&void 0!==O?O:null==_e?void 0:_e.enableDeviationSchemaBackwardCompatibility)||void 0===F||F)[0],Ke=i.useState(new Set),Ue=Ke[0],Ye=Ke[1],Je=i.useState([]),Xe=Je[0],$e=Je[1],Qe=i.useState(!1),Ze=Qe[0],en=Qe[1],nn=i.useRef(null),tn=i.useRef(null),on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),un=i.useRef(!1),sn=i.useRef(null),an=i.useRef({}),cn=i.useRef([]),dn=i.useRef(function(){}),fn=i.useRef(null),vn=i.useRef(function(){}),gn=i.useMemo(function(){return JSON.stringify(Ee||{})},[JSON.stringify(Ee)]),pn=i.useMemo(function(){return Ee||{}},[gn]),hn=i.useMemo(function(){return(null==ge?void 0:ge.cognitive_decisioning)||{}},[ge]),mn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),Se)},[Se]),Sn=i.useRef(null),Rn=i.useRef(null),xn=i.useRef(null),_n=i.useRef(null),yn=i.useRef(null),bn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=p.useComparePopups(Sn),In=wn.cognitivePopup,Tn=wn.setCognitivePopup,Dn=wn.moreFunctions,On=wn.setMoreFunctions,Fn=wn.position,jn=wn.setPosition,Pn=wn.activeBadgeId,Nn=wn.summaryPopup,kn=wn.setSummaryPopup,Ln=wn.closeSummaryPopup,Mn=wn.setActiveBadgeId,qn=wn.popupRef,Hn=wn.handleOpenCognitiveCompare,Vn=wn.openCognitivePopupFromState,zn=wn.closeCognitivePopup,Gn=wn.closeMoreFunctionsPopup,Wn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==pe?void 0:pe.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==pe?void 0:pe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==pe?void 0:pe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==pe?void 0:pe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[pe]),Kn=i.useState(null),Un=Kn[0];Kn[1];var Yn=null===(N=null===(j=null==ge?void 0:ge.documents)||void 0===j?void 0:j[null===(P=null==ge?void 0:ge.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,Jn=null===(M=null===(k=null==ge?void 0:ge.documents)||void 0===k?void 0:k[null===(L=null==ge?void 0:ge.input_index_map)||void 0===L?void 0:L[1]])||void 0===M?void 0:M.title,Xn=u.safeStringify(he||Yn||"Uploaded Contract"),$n=null===(z=null===(V=null===(q=null==ge?void 0:ge.documents)||void 0===q?void 0:q[null===(H=null==ge?void 0:ge.input_index_map)||void 0===H?void 0:H[0]])||void 0===V?void 0:V.metadata)||void 0===z?void 0:z.file_name,Qn=u.safeStringify($n),Zn=null===(U=null===(K=null===(G=null==ge?void 0:ge.documents)||void 0===G?void 0:G[null===(W=null==ge?void 0:ge.input_index_map)||void 0===W?void 0:W[1]])||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.file_name,ei=u.safeStringify(Zn),ni=u.safeStringify(me||Jn||"Reference Template"),ii=g.useCognitiveTreeData(ge,je,pn,Wn,We),ti=ii.activeProposed,oi=ii.existingRule,ri=ii.proposedSections,li=ii.existingSections,ui=ii.visibleFields,si=ii.parentDeviationRecord,ai=ii.deviationNumberRegistry,ci=ii.deviationParentRegistry,di=ii.parseError;i.useEffect(function(){di&&Ge("Failed to load comparison: ".concat(di))},[di]);var fi=ri.length>0||li.length>0,vi=i.useMemo(function(){if(!De)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";u.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(ri),i(li),"".concat(e,":").concat(n)},[De,ri,li]);i.useEffect(function(){if(ri.length||li.length)if(ke){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=je?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(ri,"left"),i(li,"right"),Yi(e),Xi(n)}else if(Ne>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=je?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(ri,"left",Ne),r(li,"right",Ne),Yi(t),Xi(o)}},[ke,Ne,ri,li,je]);var gi=h.useSectionRefs(ui.map(function(e){return e.key}),Math.max(ri.length,li.length)),pi=gi.leftRefs,hi=gi.rightRefs,mi=gi.sectionLeftRefs,Si=gi.sectionRightRefs,Ri=gi.lhsBadgeRefs,xi=gi.rhsBadgeRefs,_i=gi.sectionRightRowRefs,yi=gi.subSectionLeftRefs,bi=gi.subSectionRightRefs,Ci=gi.sectionRowRefs,Ei=gi.getSectionRowRef,Ai=gi.getSubSectionRef,Bi=gi.getBadgeRef,wi=w.useSideBySide({maintainRelativeOrder:je,proposedSections:ri,existingSections:li,leftContainerRef:En,rightContainerRef:xn,scrollContainerRef:Sn,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,sectionRowRefs:Ci,sectionRightRowRefs:_i,rhsTopSpacerRef:_n,rhsBottomSpacerRef:yn,lhsTopSpacerRef:bn,lhsBottomSpacerRef:Cn,calculateLinesRef:dn,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,closeMoreFunctionsPopup:Gn,setErrorToast:Ge,moreFunctions:Dn,closeSummaryPopup:Ln}),Ii=wi.isSideBySide,Ti=wi.isArrowVisible,Di=wi.setIsArrowVisible,Oi=wi.isResizing,Fi=wi.setIsResizing,ji=wi.isSideBySideLoading,Pi=wi.activeSideBySideSection,Ni=wi.scrollLock,ki=wi.sideBySideCacheRef,Li=wi.isSideBySideRef,Mi=wi.activeSideBySideRightSectionRef,qi=wi.activeSideBySideSectionRef,Hi=wi.sideBySideLineRef,Vi=wi.highlightedClauseRefs,zi=wi.clearClauseHighlight,Gi=wi.resetSideBySide,Wi=wi.activateSideBySide,Ki=m.useAccordionState({maintainRelativeOrder:!!je,proposedSections:ri,existingSections:li,activeSideBySideSection:Pi,connectedSections:Ue,resetSideBySide:Gi,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,svgContainerRef:nn,isAnimatingRef:un,animationTimerRef:sn,calculateLinesRef:dn,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi}),Ui=Ki.expandedSections,Yi=Ki.setExpandedSections,Ji=Ki.expandedSubSections,Xi=Ki.setExpandedSubSections,$i=Ki.handleSubSectionToggle,Qi=Ki.toggleSection,Zi=Ki.forceExpandCrossWiredSections,et=function(){var e,n;if(null!=Pi){var i=null===(e=mi.current[Pi])||void 0===e?void 0:e.current,t=null===(n=Si.current[Pi])||void 0===n?void 0:n.current,o=xn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},nt=i.useCallback(function(e){null==e||e.stopPropagation(),en(function(e){var n=!e;return n&&requestAnimationFrame(function(){et()}),n})},[et]);i.useEffect(function(){De&&"off"!==vi&&"0:0"!==vi&&(ki.current=null,cn.current=[],requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)}))},[De,vi]);var it=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(je)ri.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),li.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ri.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(ri.length,li.length),o=0;o<t;o++){var r=ri[o],l=li[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[ri,li,je]),tt=oi.analysis,ot=u.safeStringify(null===(J=null===(Y=null==tt?void 0:tt.rule_difference_comparison)||void 0===Y?void 0:Y.summary)||void 0===J?void 0:J.overall_summary),rt=!!ot.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),lt=null!==(X=null==ge?void 0:ge.base_root_id)&&void 0!==X?X:"-1";null==ge||ge[lt];var ut=We?null!==(se=null!==(re=Ee&&(null===(oe=null==Ee?void 0:Ee[lt])||void 0===oe?void 0:oe.evaluation_result))&&void 0!==re?re:null===(ue=null===(le=null==ge?void 0:ge.nodes)||void 0===le?void 0:le[lt])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==se?se:null:null!==(te=null!==(Z=Ee&&(null===(Q=null===($=null==Ee?void 0:Ee[lt])||void 0===$?void 0:$.evaluation_result)||void 0===Q?void 0:Q[0]))&&void 0!==Z?Z:null===(ie=null===(ne=null===(ee=null==ge?void 0:ge.nodes)||void 0===ee?void 0:ee[lt])||void 0===ne?void 0:ne.evaluation_result)||void 0===ie?void 0:ie[0])&&void 0!==te?te:null,st=u.extractDeviationScore(ut),at=u.generateColorPalette(null!==(de=null===(ce=null===(ae=null==ut?void 0:ut.evaluation_outputs)||void 0===ae?void 0:ae.metadata)||void 0===ce?void 0:ce.label_color)&&void 0!==de?de:a.DEFAULT_DEVIAION_COLOR);if(Oe){var ct=Oe(st);ct&&(at=e.__assign(e.__assign({},at),{badgeBg:ct.bg,badgeText:ct.text,badgeBorder:ct.border}))}var dt=i.useRef(Gi);i.useEffect(function(){dt.current=Gi},[Gi]);var ft=i.useRef(zn);i.useEffect(function(){ft.current=zn},[zn]);var vt=i.useCallback(function(e,n,i,t,o,r){return So.current(e,n,i,t,o,r)},[]),gt=i.useCallback(function(e,n,i,t,o){return xo.current(e,n,i,t,o)},[]),pt=i.useCallback(function(){return _o.current()},[]),ht=i.useCallback(function(e,n){return yo.current(e,n)},[]),mt=i.useCallback(function(e){return bo.current(e)},[]),St=i.useCallback(function(e){return Co.current(e)},[]),Rt=i.useCallback(function(){return Eo.current()},[]),xt=i.useCallback(function(){var e,n;zi(),null===(e=dt.current)||void 0===e||e.call(dt),en(!1),Ye(new Set),$e([]),cn.current=[],Mt([]),Ht(null),kn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=ft.current)||void 0===n||n.call(ft),requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)})},[]),_t=i.useRef(xt);i.useEffect(function(){_t.current=xt},[xt]),i.useEffect(function(){Re&&_t.current()},[Re]);var yt=i.useMemo(function(){return{documents:null==ge?void 0:ge.documents,input_index_map:null==ge?void 0:ge.input_index_map}},[JSON.stringify(null==ge?void 0:ge.documents),JSON.stringify(null==ge?void 0:ge.input_index_map)]),bt=i.useRef(ge);i.useEffect(function(){bt.current=ge},[ge]);var Ct=i.useRef(hn);i.useEffect(function(){Ct.current=hn},[hn]);var Et=i.useCallback(function(n,i,t,o,r,l,s){var a,c,d,f,v,g,p,h,m,S,R=u.safeStringify(null==i?void 0:i.id)||u.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Ct.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=Ci.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,s=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return s(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):s(l)}(),b=(null!==(g=null===(v=null===(f=null==y?void 0:y.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(S=null==_e?void 0:_e.isLoading)&&void 0!==S&&S&&!b,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:_,badgeStyle:l||null,sectionIdx:o,docData:yt,deviationData:y,isOrphan:!!r}},[yt,null==_e?void 0:_e.isLoading]),At=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Dn.open&&Dn.sectionIdx===o)Gn();else{var s=e.currentTarget,a="left";(null===(l=xn.current)||void 0===l?void 0:l.contains(s))&&(a="right");zi(),Li.current&&Gi(),Ye(new Set),$e([]),cn.current=[],zn(),Nn.open?Qt():Ln(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=xi.current[l])||void 0===e?void 0:e.current:null===(n=Ri.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=xi.current[o])||void 0===i?void 0:i.current:null===(t=Ri.current[o])||void 0===t?void 0:t.current}()||s;On(Et(e,n,t,o,i,r))})}},[Dn.open,Dn.sectionIdx,Gn,Ln,Et]),Bt=i.useCallback(function(){var e=Dn.sectionIdx;Dn.isOrphan,Gn(),Ln(),null!==e&&(Zi(e),zi(),Li.current&&Gi(),$e([]),cn.current=[],Ye(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){dn.current&&dn.current()},50))},[Dn.sectionIdx,Dn.isOrphan,Gn,Ln,Gi]),wt=i.useCallback(function(){var e=ln.current;if(e){ln.current=null;var n=ri.findIndex(function(n){return n.id===e}),i=li.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(ri,e):null,o=-1===i?u.findKeyPathByNodeId(li,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Vi.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(je)-1!==r&&En.current&&a(function(){return s(n,t,mi,yi)},En.current),-1!==l&&xn.current&&a(function(){return s(i,o,Si,bi)},xn.current);else{var c=Sn.current;if(!c)return;a(function(){return-1!==r?s(n,t,mi,yi):s(i,o,Si,bi)},c)}}},[ri,li,je,mi,Si,yi,bi,En,xn,Sn]),It=i.useCallback(function(n){if(n){zi(),Gi(),Ye(new Set),$e([]),cn.current=[],Ln(),zn();var i=ri.findIndex(function(e){return e.id===n}),t=li.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(ri,n):null,r=-1===t?u.findKeyPathByNodeId(li,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=-1!==t?t:r?Number(r.split("-")[0]):-1;ln.current=n,Yi(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=je?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=je?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),Xi(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){ln.current===n&&Tt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ri,li,je,Yi,Xi,Gi,Ln,zn]),Tt=i.useRef(wt);i.useEffect(function(){Tt.current=wt},[wt]);var Dt=i.useRef(null);i.useEffect(function(){if(Un){var e=Wn.fields.find(function(e){return e.analysisKey===Un||e.key===Un});if(e){var n=pi.current[e.key]||hi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Un,Wn.fields]);var Ot=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==tt?void 0:tt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=v.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[tt]),Ft=E.useStyleHelpers({proposedSections:ri,existingSections:li,maintainRelativeOrder:je,cognitiveMap:hn,deviationData:pn,treeData:ge,resolvedComparisonConfig:Wn,badgeStyleOverride:Oe}),jt=Ft.getSectionCompareStyle,Pt=Ft.getSubSectionCompareStyle,Nt=Ft.getDeviationStyleByKey,kt=B.useLinesCalculator({containerRef:tn,leftContainerRef:En,rightContainerRef:xn,svgContainerRef:nn,pathRefs:an,leftHeaderRef:on,rightHeaderRef:rn,proposedSections:ri,existingSections:li,visibleFields:ui,leftRefs:pi,rightRefs:hi,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,sectionRowRefs:Ci,expandedSections:Ui,expandedSubSections:Ji,connectedSections:Ue,isSideBySide:Ii,activeSideBySideSection:Pi,maintainRelativeOrder:je,cognitiveMap:hn,getSectionCompareStyle:jt,getSubSectionCompareStyle:Pt,getDeviationStyleByKey:Nt,isArrowVisible:Ti,isAnimatingRef:un,isSideBySideRef:Li,sideBySideCacheRef:ki,sideBySideLineRef:Hi,activeSideBySideSectionRef:qi,activeSideBySideRightSectionRef:Mi,connectedLines:Xe,setConnectedLines:$e,cachedConnectedPositions:cn,calculateLinesRef:dn,resizeTimerRef:fn,scrollLock:Ni,scrollSyncLocked:Ze,handleResizeRef:vn,activeProposed:ti,existingRule:oi,analysisData:tt,pendingScrollTargetRef:An,pendingScrollCallbackRef:Bn,resolvedComparisonConfig:Wn,getFieldData:Ot}),Lt=kt.lines,Mt=kt.setLines,qt=kt.overallConnector,Ht=kt.setOverallConnector,Vt=kt.svgDimensions,zt=kt.handleColumnScroll;i.useEffect(function(){Nn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)})})},[Nn.anchorEl,Ze]);var Gt=i.useCallback(function(){zi(),en(!1),Yi({}),Xi({}),Gi(),Ye(new Set),$e([]),cn.current=[],Ln(),zn(),Gn(),requestAnimationFrame(function(){dn.current&&dn.current()})},[Yi,Xi,Gi,Ln,zn,Gn]);i.useEffect(function(){Ii||0!==Ue.size||en(!1)},[Ii,Ue]);var Wt=i.useMemo(function(){return Object.values(Ui).some(Boolean)||Object.values(Ji).some(Boolean)},[Ui,Ji]),Kt=i.useRef(null),Ut=i.useRef(0),Yt=i.useRef(0),Jt=i.useRef(0),Xt=A.useResizeHandler({timerRef:Kt,ruleComponentRef:Rn,scrollContainerRef:Sn,containerRef:tn,maintainRelativeOrder:je,proposedSections:ri,existingSections:li,isSideBySideRef:Li,activeSideBySideSectionRef:qi,activeSideBySideRightSectionRef:Mi,sectionRowRefs:Ci,sectionRightRowRefs:_i,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,leftContainerRef:En,rightContainerRef:xn,calculateLinesRef:dn,handleResizeRef:vn,setIsResizing:Fi,setIsArrowVisible:Di,sideBySideCacheRef:ki,cachedConnectedPositions:cn}).handleResize;i.useEffect(function(){vn.current=Xt},[Xt,vn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var s=e[e.length-1];if(s){var a=null!==(u=null===(l=null===(r=s.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:s.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Rn.current&&o.push(e(Rn.current,Ut,n,function(){return vn.current()},function(){})),Sn.current&&o.push(e(Sn.current,Yt,i,function(){return vn.current()},function(){return dn.current()})),tn.current&&o.push(e(tn.current,Jt,t,function(){return vn.current()},function(){return dn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Li.current=Ii},[Ii]),i.useEffect(function(){qi.current=Pi},[Pi]);var $t=i.useCallback(function(){var e,n=Dn.sectionIdx,i=Dn.isOrphan;if(Ln(),null!=n){var t="left";Dn.anchorEl&&(null===(e=xn.current)||void 0===e?void 0:e.contains(Dn.anchorEl))&&(t="right"),Zi(n),Wi(n,i,{sourceSide:t})}},[Wi,Dn.isOrphan,Dn.sectionIdx,Dn.anchorEl,Ln]),Qt=i.useCallback(function(){Ln(),Gi(),Ye(new Set),$e([]),cn.current=[]},[Ln,Gi]),Zt=null!==Dn.sectionIdx&&Ue.has(Dn.sectionIdx),eo=S.useDeviationNavigation({proposedSections:ri,existingSections:li,parentDeviationRecord:si,expandedSections:Ui,maintainRelativeOrder:!!je,scrollContainerRef:Sn,leftContainerRef:En,rightContainerRef:xn,lhsBadgeRefs:Ri,rhsBadgeRefs:xi}),no=eo.showDeviationNavigation,io=eo.showOpenNodeRef,to=eo.adjustScrollForPopup,oo=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?u.safeStringify(t).trim():u.safeStringify(null==t?void 0:t.deviation_summary).trim(),s=e.currentTarget;zn();var a="left";(null===(r=xn.current)||void 0===r?void 0:r.contains(s))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=xi.current[l])||void 0===e?void 0:e.current:null===(i=Ri.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=xi.current[n])||void 0===t?void 0:t.current:null===(o=Ri.current[n])||void 0===o?void 0:o.current};if(i)return Gi(),Ye(new Set),$e([]),cn.current=[],void(l&&(Zi(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));kn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Zi(n),l?setTimeout(function(){Wi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||s;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var u=l.top-window.innerHeight/2;je?(null===(e=En.current)||void 0===e||e.scrollBy({top:u,behavior:"smooth"}),null===(n=xn.current)||void 0===n||n.scrollBy({top:u,behavior:"smooth"})):null===(i=Sn.current)||void 0===i||i.scrollBy({top:u,behavior:"smooth"})}}kn({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Wi(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Wi,zn,kn,Gi,Zi]),ro=i.useMemo(function(){var e;if(!Ae)return null;var n=null===(e=null==Ae?void 0:Ae.id)||void 0===e?void 0:e.split(":")[0];for(var i in si){if((si[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ae,si]),lo=i.useRef({id:null,triggerMs:null}),uo=i.useRef(null);i.useEffect(function(){if(null==Ae?void 0:Ae.id){var n=Number(Ae.trigger),i=lo.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Ae.id.includes(":")&&/:\d+$/.test(Ae.id)))return lo.current={id:Ae.id,triggerMs:n},void It(Ae.id);var t=Ae.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";uo.current!==Ae.id&&(Ln(),zn(),Gi(),Ye(new Set),$e([]),cn.current=[],uo.current=Ae.id);var s=!1,a=0,c=null,d=null,f=!1,v=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},g=function(){var i,t,r,p;if(!s){var h=function(){lo.current={id:Ae.id,triggerMs:n}},m=null,S=null;for(var R in si){var x=si[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ri.findIndex(function(e){return e.id===m}),y=li.findIndex(function(e){return e.id===m}),b=-1===_&&-1!==y,C=v(ri,S.id),E=v(li,S.id);if(C&&!E&&!b){var A=C.split("-"),B=Number(A[0]);if(je){var w=null===(t=null===(i=ri[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=li.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):y,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ri[T],j=li[O],P=F&&!F.title&&!F.content,N=j&&!j.title&&!j.content,k=b||(!C&&!!E||P&&!N);if(k){if(!(je?!!Ro.current["right-".concat(D)]:!!Ro.current[String(D)])&&D>=0)return Qi(D,"right"),void(c=setTimeout(g,200))}else if(!(je?!!Ro.current["left-".concat(T)]:!!Ro.current[String(T)])&&T>=0)return Qi(T,"left"),void(c=setTimeout(g,200));var L=C||"",M=E||"",q="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l).concat(u.DEVIATION_BADGE_SEPARATOR).concat(L).concat(u.DEVIATION_BADGE_SEPARATOR).concat(M),H="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l);if(!f){Zi(q),f=!0,a=0;var V=function(){var e,n,i=null===(e=Ri.current[H])||void 0===e?void 0:e.current,t=null===(n=xi.current[H])||void 0===n?void 0:n.current;return k||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;s||(e=V,n=function(){s||(d=null,g())},t=0,o=null,r=null,l=function(){if(!s){var u=e();if(u&&0!==u.getBoundingClientRect().height){var a=u.getBoundingClientRect(),c=a.top,d=a.height,f=null!==o&&Math.abs(c-o)<.5,v=null!==r&&Math.abs(d-r)<.5;if(f&&v){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var z=null===(r=Ri.current[H])||void 0===r?void 0:r.current,G=null===(p=xi.current[H])||void 0===p?void 0:p.current;if(z||G){var W=k||!z&&!!G,K=W?G:z,U=je?W?xn.current:En.current:Sn.current;if(K&&U){var Y=K.getBoundingClientRect();if(0!==Y.height){var J=U.getBoundingClientRect(),X=Y.top-J.top+U.scrollTop-J.height/2+Y.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,f,v;return e.__generator(this,function(g){switch(g.label){case 0:return s?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[z,G].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[z,G].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!z&&!!G?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},je?[4,Promise.all([En.current?r(u.waitForScrollIdle(En.current),600):Promise.resolve(),xn.current?r(u.waitForScrollIdle(xn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(f=xi.current[$?H:D])||void 0===f?void 0:f.current)||G:(null===(v=Ri.current[$?H:T])||void 0===v?void 0:v.current)||z,to(o,function(){kn({open:!0,anchorEl:o,displayImpact:Ae.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Be||Be(),[2]));case 1:g.sent(),g.label=2;case 2:return Wi(q,!1,{toggleIfSame:!1,sourceSide:b?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=xi.current[H])||void 0===n?void 0:n.current)||G:(null===(t=Ri.current[H])||void 0===t?void 0:t.current)||z,u=(null===(o=Ri.current[H])||void 0===o?void 0:o.current)||z,s=(null===(r=xi.current[H])||void 0===r?void 0:r.current)||G;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),kn({open:!0,anchorEl:l,displayImpact:Ae.displayImpact,summary:e.__assign({},i)}),null==Be||Be()}}),[2]}})})};Math.abs(U.scrollTop-X)<=2?Q():u.scrollAndWait(U,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){s=!0,c&&clearTimeout(c),null==d||d()}}}},[Ae,si,ri,li,je,Ui,Wi,kn,It]),i.useEffect(function(){var n,i,t;if(Nn.open){var o=Nn.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Ri.current)||r(xi.current);if(l){var u=(null===(i=xi.current[l])||void 0===i?void 0:i.current)||(null===(t=Ri.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&kn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Nn.open,Nn.anchorEl,Ze,Ue,Ui]);var so=In.open,ao=In.sectionIdx,co=In.isOrphan,fo=In.badgeStyle,vo=In.anchorEl,go=In.sectionAnchorEl;i.useEffect(function(){var n;if(_e.isStreamingEnabled&&so&&null!=ao&&ao!==lt){var i="string"==typeof ao?ao.split(u.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(ri,i):null,r=i&&"string"==typeof i?t(li,i):null,l="number"==typeof ao?ri[ao]||null:o||i&&((null===(n=null==ge?void 0:ge.nodes)||void 0===n?void 0:n[i])||(null==ge?void 0:ge[i]))||null,s="number"==typeof ao?li[ao]||null:r,a=Et(vo,l,s,ao,co,fo);Tn(function(n){return n.open?u.safeStringify(n.cognitiveData)===u.safeStringify(a.cognitiveData)&&u.safeStringify(n.deviationData)===u.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[so,ao,co,fo,vo,go,ri,li,Et]);var po=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,s=e.parentNodeId,a=void 0===s?"":s,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:c})},[]),ho=i.useMemo(function(){return ri.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&je?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ri]),mo=i.useMemo(function(){return li.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&je?null:n.jsx(y.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[li]),So=i.useRef(At);i.useEffect(function(){So.current=At},[At]);var Ro=i.useRef(Ui);i.useEffect(function(){Ro.current=Ui},[Ui]);var xo=i.useRef(oo);i.useEffect(function(){xo.current=oo},[oo]);var _o=i.useRef(Qt);i.useEffect(function(){_o.current=Qt},[Qt]);var yo=i.useRef(Qi);i.useEffect(function(){yo.current=Qi},[Qi]);var bo=i.useRef($i);i.useEffect(function(){bo.current=$i},[$i]);var Co=i.useRef(po);i.useEffect(function(){Co.current=po},[po]);var Eo=i.useRef(Gi);i.useEffect(function(){Eo.current=Gi},[Gi]);var Ao=i.useMemo(function(){return{maintainRelativeOrder:!!je,showDeviationBadges:Le,isProposingFix:Ie,proposingFixNodeId:Te,isRedlineFlow:De,isSideBySide:Ii,activeSideBySideSection:Pi,scrollSyncLocked:Ze,toggleScrollSyncLocked:nt,summaryPopupAnchorEl:Nn.anchorEl,connectedSections:Ue,proposedSections:ri,existingSections:li,deviationNumberRegistry:ai,deviationParentRegistry:ci,treeData:ge,displayConfig:_e,resolvedMarkdownStyles:mn,unifiedNumbering:it,expandedSections:Ui,expandedSubSections:Ji,setExpandedSubSections:Xi,getSectionCompareStyle:jt,getSubSectionCompareStyle:Pt,getBadgeRef:Bi,getSectionRowRef:Ei,getSubSectionRef:Ai,sectionLeftRefs:mi,sectionRightRefs:Si,sectionRowRefs:Ci,sectionRightRowRefs:_i,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,openMoreFunctionsPopup:vt,handleOpenSummaryPopup:gt,openSummaryPopup:gt,handleCloseSummaryPopup:pt,toggleSection:ht,handleSubSectionToggle:mt,renderSubSectionAccordion:St,resetSideBySide:Rt,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,showDeviationNavigation:no,showOpenNodeRef:io,deviationNodeIdToView:null==Ae?void 0:Ae.id,deviationTargetParentId:ro}},[je,Le,Ie,Te,De,Ii,Pi,Ze,nt,Nn.anchorEl,Ue,ri,li,ai,_e,mn,it,Ui,Ji,Xi,jt,Pt,Bi,Ei,Ai,no,io,Ae,ro]);return n.jsx(C.CompareContextProvider,e.__assign({value:Ao},{children:n.jsxs(t.Box,e.__assign({ref:Rn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[qe&&n.jsx(t.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(f.default,{})})),Nn.open&&n.jsx(b.default,{open:Nn.open,anchorEl:Nn.anchorEl,containerEl:Dt.current,clipTopEl:on.current,scrollContainerEl:Sn.current,onClose:Qt,summary:Nn.summary,displayImpact:Nn.displayImpact,isScrollLocked:Ze}),n.jsx(d.default,{open:Dn.open,anchorEl:Dn.anchorEl,maintainRelativeOrder:!!je,sectionTitle:Dn.sectionTitle,referenceSectionTitle:Dn.refSectionTitle,onClose:Gn,onOpenCognitiveCompare:Hn,onOpenSideBySide:$t,onConnect:Bt,isConnected:Zt,isOrphan:Dn.isOrphan}),In.open&&n.jsx(c.default,{open:In.open,popupRef:qn,position:Fn,popupConfig:be,onClose:function(){jn(null),Tn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Mn(null)},markdownStyles:Se,sectionTitle:Qn,referenceSectionTitle:ei,cognitiveData:In.cognitiveData,anchorEl:In.anchorEl,sectionAnchorEl:In.sectionAnchorEl,scrollContainerEl:Sn.current,badgeStyle:In.badgeStyle,docData:In.docData,deviationData:In.deviationData,isLoading:In.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!ze,autoHideDuration:8e3,onClose:function(){return Ge(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ge(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ze}))})),n.jsx(R.default,{componentHeaderText:ve,displayConfig:_e,maintainRelativeOrder:je,onCollapseAll:Gt,showCollapseAll:Wt,onToggleView:function(e){He(!0),setTimeout(function(){Pe(!e),null==ye||ye(!e),en(!1),Gi(),Ln(),Ye(new Set),$e([]),cn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){He(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:Sn,onScroll:zt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:je?"visible":"auto",borderTop:ot&&rt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},je?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:tn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},je?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:nn,svgDimensions:Vt,isResizing:Oi,overallConnector:qt,rootDeviationStyle:at,lines:Lt,isSideBySide:Ii,activeSideBySideSection:Pi,isArrowVisible:Ti,maintainRelativeOrder:je,proposedSections:ri,existingSections:li,cognitivePopup:In,activeBadgeId:Pn,closeCognitivePopup:zn,setActiveBadgeId:Mn,openCognitivePopupFromState:Vn,buildSectionPopupState:Et,connectedLines:Xe,pathRefs:an}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},je?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:on,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:Xn,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Xn}))}))})),n.jsxs(t.Box,e.__assign({ref:En,onScroll:zt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},je?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:bn,style:{width:"100%",height:"0px",flexShrink:0}}),fi&&ho,n.jsx("div",{ref:Cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:Dt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),In.open&&Pn===lt?zn():(Mn(lt),Vn(Et(n.currentTarget,{title:"",content:"",evaluationResult:ut,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,lt,!0,e.__assign(e.__assign({},at),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:at.badgeBg,color:at.badgeText,border:"1px solid ".concat(at.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=st?st:n.jsx(v.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&Pn===lt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},je?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ji&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:rn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(t.Tooltip,e.__assign({title:ni,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ni}))}))})),n.jsxs(t.Box,e.__assign({ref:xn,onScroll:zt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},je?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}}),fi&&mo,n.jsx("div",{ref:yn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),s=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),b=require("./components/RHSSectionRow.js"),y=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),T=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),B=require("./Guidelines/components/GuidelinePanel.js"),D=require("./Guidelines/components/WebGptPanel.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(O){var F,j,P,k,N,M,L,q,H,G,V,W,z,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe,ve,ge=O.componentHeaderText,pe=void 0===ge?a.DEFAULT_COMPONENT_HEADER_TEXT:ge,he=O.treeData,me=O.comparisonConfig,Se=O.leftColumnTitleText,Re=O.rightColumnTitleText,xe=O.markdownStyles,_e=O.resetTrigger,be=O.displayConfig,ye=void 0===be?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:be,Ce=O.onMaintainRelativeOrderChange,Ee=O.popupConfig,Ae=O.deviationData,Te=void 0===Ae?{}:Ae,we=O.deviationNodeIdToView,Ie=O.resetDeviationNodeId,Be=O.isProposingFix,De=void 0!==Be&&Be,Oe=O.proposingFixNodeId,Fe=O.isRedlineFlow,je=O.badgeStyleOverride,Pe=O.guidelinesData,ke=O.gptWebCitationConfig,Ne=i.useState(ye.maintainRelativeOrder),Me=Ne[0],Le=Ne[1],qe=null!==(F=null==ye?void 0:ye.expandLevels)&&void 0!==F?F:0,He=!!(null==ye?void 0:ye.expandAllSections),Ge=!!Me||!!(null==ye?void 0:ye.showDeviationBadges),Ve=i.useState(!1),We=Ve[0],ze=Ve[1],Ke=i.useState(null),Ue=Ke[0],Ye=Ke[1],Je=i.useState(null===(P=null!==(j=null==he?void 0:he.newEvaluationResult)&&void 0!==j?j:null==ye?void 0:ye.enableDeviationSchemaBackwardCompatibility)||void 0===P||P)[0],Xe=i.useState(new Set),$e=Xe[0],Qe=Xe[1],Ze=i.useState([]),en=Ze[0],nn=Ze[1],tn=i.useState(!1),on=tn[0],rn=tn[1],ln=i.useState(0),un=ln[0],sn=ln[1],an=i.useRef(null),cn=i.useRef(null),dn=i.useRef(null),fn=i.useRef(null),vn=i.useRef(null),gn=i.useRef(!1),pn=i.useRef(null),hn=i.useRef({}),mn=i.useRef([]),Sn=i.useRef(function(){}),Rn=i.useRef(null),xn=i.useRef(function(){}),_n=i.useMemo(function(){return JSON.stringify(Te||{})},[JSON.stringify(Te)]),bn=i.useMemo(function(){return Te||{}},[_n]),yn=i.useMemo(function(){return(null==he?void 0:he.cognitive_decisioning)||{}},[he]),Cn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),xe)},[xe]),En=i.useRef(null),An=i.useRef(null),Tn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Bn=i.useRef(null),Dn=i.useRef(null),On=i.useRef(null),Fn=i.useRef(null),jn=i.useRef(null),Pn=p.useComparePopups(En),kn=Pn.cognitivePopup,Nn=Pn.setCognitivePopup,Mn=Pn.moreFunctions,Ln=Pn.setMoreFunctions,qn=Pn.position,Hn=Pn.setPosition,Gn=Pn.activeBadgeId,Vn=Pn.summaryPopup,Wn=Pn.setSummaryPopup,zn=Pn.closeSummaryPopup,Kn=Pn.setActiveBadgeId,Un=Pn.popupRef,Yn=Pn.handleOpenCognitiveCompare,Jn=Pn.openCognitivePopupFromState,Xn=Pn.closeCognitivePopup,$n=Pn.closeMoreFunctionsPopup,Qn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==me?void 0:me.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==me?void 0:me.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==me?void 0:me.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==me?void 0:me.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[me]),Zn=i.useState(null),ei=Zn[0];Zn[1];var ni=null===(M=null===(k=null==he?void 0:he.documents)||void 0===k?void 0:k[null===(N=null==he?void 0:he.input_index_map)||void 0===N?void 0:N[0]])||void 0===M?void 0:M.title,ii=null===(H=null===(L=null==he?void 0:he.documents)||void 0===L?void 0:L[null===(q=null==he?void 0:he.input_index_map)||void 0===q?void 0:q[1]])||void 0===H?void 0:H.title,ti=u.safeStringify(Se||ni||"Uploaded Contract"),oi=null===(z=null===(W=null===(G=null==he?void 0:he.documents)||void 0===G?void 0:G[null===(V=null==he?void 0:he.input_index_map)||void 0===V?void 0:V[0]])||void 0===W?void 0:W.metadata)||void 0===z?void 0:z.file_name,ri=u.safeStringify(oi),li=null===(J=null===(Y=null===(K=null==he?void 0:he.documents)||void 0===K?void 0:K[null===(U=null==he?void 0:he.input_index_map)||void 0===U?void 0:U[1]])||void 0===Y?void 0:Y.metadata)||void 0===J?void 0:J.file_name,ui=u.safeStringify(li),si=u.safeStringify(Re||ii||"Reference Template"),ai=g.useCognitiveTreeData(he,Me,bn,Qn,Je,Pe),ci=ai.isGuidelineMode,di=ai.activeProposed,fi=ai.existingRule,vi=ai.proposedSections,gi=ai.existingSections,pi=ai.visibleFields,hi=ai.parentDeviationRecord,mi=ai.deviationNumberRegistry,Si=ai.deviationParentRegistry,Ri=ai.parseError;i.useEffect(function(){Ri&&Ye("Failed to load comparison: ".concat(Ri))},[Ri]);var xi=vi.length>0||gi.length>0,_i=i.useMemo(function(){if(!Fe)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";u.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(vi),i(gi),"".concat(e,":").concat(n)},[Fe,vi,gi]);i.useEffect(function(){if(vi.length||gi.length)if(He){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Me?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(vi,"left"),i(gi,"right"),tt(e),rt(n)}else if(qe>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Me?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(vi,"left",qe),r(gi,"right",qe),tt(t),rt(o)}},[He,qe,vi,gi,Me]);var bi=h.useSectionRefs(pi.map(function(e){return e.key}),Math.max(vi.length,gi.length)),yi=bi.leftRefs,Ci=bi.rightRefs,Ei=bi.sectionLeftRefs,Ai=bi.sectionRightRefs,Ti=bi.lhsBadgeRefs,wi=bi.rhsBadgeRefs,Ii=bi.sectionRightRowRefs,Bi=bi.subSectionLeftRefs,Di=bi.subSectionRightRefs,Oi=bi.sectionRowRefs,Fi=bi.getSectionRowRef,ji=bi.getSubSectionRef,Pi=bi.getBadgeRef,ki=w.useSideBySide({isGuidelineMode:ci,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,leftContainerRef:On,rightContainerRef:Tn,scrollContainerRef:En,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,sectionRowRefs:Oi,sectionRightRowRefs:Ii,rhsTopSpacerRef:wn,rhsBottomSpacerRef:In,lhsTopSpacerRef:Bn,lhsBottomSpacerRef:Dn,calculateLinesRef:Sn,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,closeMoreFunctionsPopup:$n,setErrorToast:Ye,moreFunctions:Mn,closeSummaryPopup:zn}),Ni=ki.isSideBySide,Mi=ki.isArrowVisible,Li=ki.setIsArrowVisible,qi=ki.isResizing,Hi=ki.setIsResizing,Gi=ki.isSideBySideLoading,Vi=ki.activeSideBySideSection,Wi=ki.scrollLock,zi=ki.sideBySideCacheRef,Ki=ki.isSideBySideRef,Ui=ki.activeSideBySideRightSectionRef,Yi=ki.activeSideBySideSectionRef,Ji=ki.sideBySideLineRef,Xi=ki.highlightedClauseRefs,$i=ki.clearClauseHighlight,Qi=ki.resetSideBySide,Zi=ki.activateSideBySide,et=i.useRef(Zi);i.useEffect(function(){et.current=Zi},[Zi]);var nt=m.useAccordionState({maintainRelativeOrder:!!Me,proposedSections:vi,existingSections:gi,activeSideBySideSection:Vi,connectedSections:$e,resetSideBySide:Qi,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,svgContainerRef:an,isAnimatingRef:gn,animationTimerRef:pn,calculateLinesRef:Sn,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di}),it=nt.expandedSections,tt=nt.setExpandedSections,ot=nt.expandedSubSections,rt=nt.setExpandedSubSections,lt=nt.handleSubSectionToggle,ut=nt.toggleSection,st=nt.forceExpandCrossWiredSections,at=function(){var e,n;if(null!=Vi){var i=null===(e=Ei.current[Vi])||void 0===e?void 0:e.current,t=null===(n=Ai.current[Vi])||void 0===n?void 0:n.current,o=Tn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},ct=i.useCallback(function(e){null==e||e.stopPropagation(),rn(function(e){var n=!e;return n&&requestAnimationFrame(function(){at()}),n})},[at]);i.useEffect(function(){Fe&&"off"!==_i&&"0:0"!==_i&&(zi.current=null,mn.current=[],requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)}))},[Fe,_i]);var dt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Me)vi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),gi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=vi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(vi.length,gi.length),o=0;o<t;o++){var r=vi[o],l=gi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[vi,gi,Me]),ft=fi.analysis,vt=u.safeStringify(null===($=null===(X=null==ft?void 0:ft.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===$?void 0:$.overall_summary),gt=!!vt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),pt=null!==(Q=null==he?void 0:he.base_root_id)&&void 0!==Q?Q:"-1";null==he||he[pt];var ht=Je?null!==(ce=null!==(ue=Te&&(null===(le=null==Te?void 0:Te[pt])||void 0===le?void 0:le.evaluation_result))&&void 0!==ue?ue:null===(ae=null===(se=null==he?void 0:he.nodes)||void 0===se?void 0:se[pt])||void 0===ae?void 0:ae.evaluation_result)&&void 0!==ce?ce:null:null!==(re=null!==(ne=Te&&(null===(ee=null===(Z=null==Te?void 0:Te[pt])||void 0===Z?void 0:Z.evaluation_result)||void 0===ee?void 0:ee[0]))&&void 0!==ne?ne:null===(oe=null===(te=null===(ie=null==he?void 0:he.nodes)||void 0===ie?void 0:ie[pt])||void 0===te?void 0:te.evaluation_result)||void 0===oe?void 0:oe[0])&&void 0!==re?re:null,mt=u.extractDeviationScore(ht),St=u.generateColorPalette(null!==(ve=null===(fe=null===(de=null==ht?void 0:ht.evaluation_outputs)||void 0===de?void 0:de.metadata)||void 0===fe?void 0:fe.label_color)&&void 0!==ve?ve:a.DEFAULT_DEVIAION_COLOR);if(je){var Rt=je(mt);Rt&&(St=e.__assign(e.__assign({},St),{badgeBg:Rt.bg,badgeText:Rt.text,badgeBorder:Rt.border}))}var xt=i.useRef(Qi);i.useEffect(function(){xt.current=Qi},[Qi]);var _t=i.useRef(Xn);i.useEffect(function(){_t.current=Xn},[Xn]);var bt=i.useCallback(function(e,n,i,t,o,r){return Io.current(e,n,i,t,o,r)},[]),yt=i.useCallback(function(e,n,i,t,o){return Do.current(e,n,i,t,o)},[]),Ct=i.useCallback(function(){return Oo.current()},[]),Et=i.useCallback(function(e,n){return Fo.current(e,n)},[]),At=i.useCallback(function(e){return jo.current(e)},[]),Tt=i.useCallback(function(e){return Po.current(e)},[]),wt=i.useCallback(function(){return ko.current()},[]),It=i.useCallback(function(){var e,n;$i(),null===(e=xt.current)||void 0===e||e.call(xt),rn(!1),Qe(new Set),nn([]),mn.current=[],Yt([]),Xt(null),Wn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=_t.current)||void 0===n||n.call(_t),requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)})},[]),Bt=i.useRef(It);i.useEffect(function(){Bt.current=It},[It]),i.useEffect(function(){_e&&Bt.current()},[_e]);var Dt=i.useMemo(function(){return{documents:null==he?void 0:he.documents,input_index_map:null==he?void 0:he.input_index_map}},[JSON.stringify(null==he?void 0:he.documents),JSON.stringify(null==he?void 0:he.input_index_map)]),Ot=i.useRef(he);i.useEffect(function(){Ot.current=he},[he]);var Ft=i.useRef(yn);i.useEffect(function(){Ft.current=yn},[yn]);var jt=i.useCallback(function(n,i,t,o,r,l,s){var a,c,d,f,v,g,p,h,m,S,R=u.safeStringify(null==i?void 0:i.id)||u.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Ft.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=Oi.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,b=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,s=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return s(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):s(l)}(),y=(null!==(g=null===(v=null===(f=null==b?void 0:b.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==b?void 0:b.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0,C=null!==(S=null==ye?void 0:ye.isLoading)&&void 0!==S&&S,E=!0;if(ci){var A=null==b?void 0:b.deviation_highlights;if(A&&"object"==typeof A)E=Object.values(A).some(function(e){return Array.isArray(e)&&e.length>0});else E=!1}return{isLoading:C&&!y,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:_,badgeStyle:l||null,sectionIdx:o,docData:Dt,deviationData:b,isOrphan:!!r,hasGuidelineMatches:E}},[Dt,null==ye?void 0:ye.isLoading,ci]),Pt=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Mn.open&&Mn.sectionIdx===o)$n();else{var s=e.currentTarget,a="left";(null===(l=Tn.current)||void 0===l?void 0:l.contains(s))&&(a="right");$i(),Ki.current&&Qi(),Qe(new Set),nn([]),mn.current=[],Xn(),Vn.open?ao():zn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=wi.current[l])||void 0===e?void 0:e.current:null===(n=Ti.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=wi.current[o])||void 0===i?void 0:i.current:null===(t=Ti.current[o])||void 0===t?void 0:t.current}()||s;Ln(jt(e,n,t,o,i,r))})}},[Mn.open,Mn.sectionIdx,$n,zn,jt]),kt=i.useCallback(function(){var e=Mn.sectionIdx;Mn.isOrphan,$n(),zn(),null!==e&&(st(e),$i(),Ki.current&&Qi(),nn([]),mn.current=[],ci&&null!==e&&sn(lo(e)),Qe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Sn.current&&Sn.current()},50))},[Mn.sectionIdx,Mn.isOrphan,$n,zn,Qi]),Nt=i.useCallback(function(){var e=vn.current;if(e){vn.current=null;var n=vi.findIndex(function(n){return n.id===e}),i=gi.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(vi,e):null,o=-1===i?u.findKeyPathByNodeId(gi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Xi.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Me)-1!==r&&On.current&&a(function(){return s(n,t,Ei,Bi)},On.current),-1!==l&&Tn.current&&a(function(){return s(i,o,Ai,Di)},Tn.current);else{var c=En.current;if(!c)return;a(function(){return-1!==r?s(n,t,Ei,Bi):s(i,o,Ai,Di)},c)}}},[vi,gi,Me,Ei,Ai,Bi,Di,On,Tn,En]),Mt=i.useCallback(function(n){if(n){$i(),Qi(),Qe(new Set),nn([]),mn.current=[],zn(),Xn();var i=vi.findIndex(function(e){return e.id===n}),t=gi.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(vi,n):null,r=-1===t?u.findKeyPathByNodeId(gi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=-1!==t?t:r?Number(r.split("-")[0]):-1;vn.current=n,tt(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Me?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=Me?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),rt(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){vn.current===n&&Lt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[vi,gi,Me,tt,rt,Qi,zn,Xn]),Lt=i.useRef(Nt);i.useEffect(function(){Lt.current=Nt},[Nt]);var qt=i.useRef(null);i.useEffect(function(){if(ei){var e=Qn.fields.find(function(e){return e.analysisKey===ei||e.key===ei});if(e){var n=yi.current[e.key]||Ci.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ei,Qn.fields]);var Ht=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==ft?void 0:ft.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=v.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[ft]),Gt=E.useStyleHelpers({proposedSections:vi,existingSections:gi,maintainRelativeOrder:Me,cognitiveMap:yn,deviationData:bn,treeData:he,resolvedComparisonConfig:Qn,badgeStyleOverride:je}),Vt=Gt.getSectionCompareStyle,Wt=Gt.getSubSectionCompareStyle,zt=Gt.getDeviationStyleByKey,Kt=T.useLinesCalculator({containerRef:cn,leftContainerRef:On,rightContainerRef:Tn,svgContainerRef:an,pathRefs:hn,leftHeaderRef:dn,rightHeaderRef:fn,proposedSections:vi,existingSections:gi,visibleFields:pi,leftRefs:yi,rightRefs:Ci,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,sectionRowRefs:Oi,expandedSections:it,expandedSubSections:ot,connectedSections:$e,isSideBySide:Ni,activeSideBySideSection:Vi,maintainRelativeOrder:Me,isGuidelineMode:ci,cognitiveMap:yn,getSectionCompareStyle:Vt,getSubSectionCompareStyle:Wt,getDeviationStyleByKey:zt,isArrowVisible:Mi,isAnimatingRef:gn,isSideBySideRef:Ki,sideBySideCacheRef:zi,sideBySideLineRef:Ji,activeSideBySideSectionRef:Yi,activeSideBySideRightSectionRef:Ui,connectedLines:en,setConnectedLines:nn,cachedConnectedPositions:mn,calculateLinesRef:Sn,resizeTimerRef:Rn,scrollLock:Wi,scrollSyncLocked:on,handleResizeRef:xn,activeProposed:di,existingRule:fi,analysisData:ft,pendingScrollTargetRef:Fn,pendingScrollCallbackRef:jn,resolvedComparisonConfig:Qn,getFieldData:Ht}),Ut=Kt.lines,Yt=Kt.setLines,Jt=Kt.overallConnector,Xt=Kt.setOverallConnector,$t=Kt.svgDimensions,Qt=Kt.handleColumnScroll;i.useEffect(function(){Vn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)})})},[Vn.anchorEl,on]);var Zt=i.useCallback(function(){$i(),rn(!1),tt({}),rt({}),Qi(),Qe(new Set),nn([]),mn.current=[],zn(),Xn(),$n(),requestAnimationFrame(function(){Sn.current&&Sn.current()})},[tt,rt,Qi,zn,Xn,$n]);i.useEffect(function(){Ni||0!==$e.size||rn(!1)},[Ni,$e]);var eo=i.useMemo(function(){return Object.values(it).some(Boolean)||Object.values(ot).some(Boolean)},[it,ot]),no=i.useRef(null),io=i.useRef(0),to=i.useRef(0),oo=i.useRef(0),ro=A.useResizeHandler({timerRef:no,ruleComponentRef:An,scrollContainerRef:En,containerRef:cn,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,isSideBySideRef:Ki,activeSideBySideSectionRef:Yi,activeSideBySideRightSectionRef:Ui,sectionRowRefs:Oi,sectionRightRowRefs:Ii,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,leftContainerRef:On,rightContainerRef:Tn,calculateLinesRef:Sn,handleResizeRef:xn,setIsResizing:Hi,setIsArrowVisible:Li,sideBySideCacheRef:zi,cachedConnectedPositions:mn}).handleResize;i.useEffect(function(){xn.current=ro},[ro,xn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var s=e[e.length-1];if(s){var a=null!==(u=null===(l=null===(r=s.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:s.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return An.current&&o.push(e(An.current,io,n,function(){return xn.current()},function(){})),En.current&&o.push(e(En.current,to,i,function(){return xn.current()},function(){return Sn.current()})),cn.current&&o.push(e(cn.current,oo,t,function(){return xn.current()},function(){return Sn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Ki.current=Ni},[Ni]),i.useEffect(function(){Yi.current=Vi},[Vi]);var lo=i.useCallback(function(e){var n,i,t,o,r,l="",s="0";if("number"==typeof e)l=(null===(n=vi[e])||void 0===n?void 0:n.nodeId)||(null===(i=vi[e])||void 0===i?void 0:i.id)||"";else{var a=String(e).split(u.DEVIATION_BADGE_SEPARATOR);l=a[0],s=a[1]||"0"}var c=null===(t=null==bn?void 0:bn[l])||void 0===t?void 0:t.evaluation_result,d=Array.isArray(c)?c[parseInt(s,10)]:null==c?void 0:c[s];return!1===(null===(r=null===(o=null==d?void 0:d.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[vi,bn]),uo=i.useCallback(function(e){var n,i,t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),o=On.current,r=Tn.current,l="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=e;if(l){var a=e.split(u.DEVIATION_BADGE_SEPARATOR);a.length>=2&&(s="".concat(a[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a[1]))}var c=(null===(n=Ti.current[s])||void 0===n?void 0:n.current)||(null===(i=Ti.current[e])||void 0===i?void 0:i.current);if(t.length>0&&c&&o&&r){var d=t[0];Bn.current&&(Bn.current.style.height="0px"),wn.current&&(wn.current.style.height="0px"),Dn.current&&(Dn.current.style.height="0px"),In.current&&(In.current.style.height="0px"),requestAnimationFrame(function(){var e=c.getBoundingClientRect(),n=d.getBoundingClientRect(),i=o.getBoundingClientRect(),t=r.getBoundingClientRect(),l=o.scrollTop+(e.top-i.top)+e.height/2,u=r.scrollTop+(n.top-t.top)+n.height/2,s=l-i.height/2,a=Math.max(0,s),f=o.scrollHeight-o.clientHeight,v=a>f?a-f:0,g=i.top+l-a,p=t.top+u-g,h=0;p<0&&(h=Math.abs(p),p=0);var m=r.scrollHeight-r.clientHeight+h,S=p>m?p-m:0;Dn.current&&(Dn.current.style.height="".concat(v,"px")),wn.current&&(wn.current.style.height="".concat(h,"px")),In.current&&(In.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){o.scrollTo({top:a,behavior:"smooth"}),r.scrollTo({top:p,behavior:"smooth"}),Sn.current&&setTimeout(function(){return Sn.current()},50)})})}},[u.DEVIATION_BADGE_SEPARATOR]),so=i.useCallback(function(){var e,n=Mn.sectionIdx,i=Mn.isOrphan;if(zn(),null!=n){var t="left";Mn.anchorEl&&(null===(e=Tn.current)||void 0===e?void 0:e.contains(Mn.anchorEl))&&(t="right"),st(n),ci&&(sn(lo(n)),Qe(new Set([n]))),Zi(n,i,{sourceSide:t,onReady:function(){ci&&setTimeout(function(){return uo(String(n))},150)}})}},[Zi,Mn.isOrphan,Mn.sectionIdx,Mn.anchorEl,zn,st,ci,uo,lo]),ao=i.useCallback(function(){zn(),Qi(),Qe(new Set),nn([]),mn.current=[]},[zn,Qi]),co=null!==Mn.sectionIdx&&$e.has(Mn.sectionIdx),fo=S.useDeviationNavigation({proposedSections:vi,existingSections:gi,parentDeviationRecord:hi,expandedSections:it,maintainRelativeOrder:!!Me,scrollContainerRef:En,leftContainerRef:On,rightContainerRef:Tn,lhsBadgeRefs:Ti,rhsBadgeRefs:wi}),vo=fo.showDeviationNavigation,go=fo.showOpenNodeRef,po=fo.adjustScrollForPopup,ho=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?u.safeStringify(t).trim():u.safeStringify(null==t?void 0:t.deviation_summary).trim(),s=e.currentTarget;Xn();var a="left";(null===(r=Tn.current)||void 0===r?void 0:r.contains(s))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=wi.current[l])||void 0===e?void 0:e.current:null===(i=Ti.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=wi.current[n])||void 0===t?void 0:t.current:null===(o=Ti.current[n])||void 0===o?void 0:o.current};if(i&&!ci)return Qi(),Qe(new Set),nn([]),mn.current=[],void(l&&(st(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Wn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));st(n),ci&&(sn(lo(n)),Qe(new Set([n]))),l?setTimeout(function(){Zi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,i,r,l=c()||s;if(ci)setTimeout(function(){return uo(n)},150);else if(l){var u=l.getBoundingClientRect();if(u.top>.8*window.innerHeight||u.top<100){var a=u.top-window.innerHeight/2;Me?(null===(e=On.current)||void 0===e||e.scrollBy({top:a,behavior:"smooth"}),null===(i=Tn.current)||void 0===i||i.scrollBy({top:a,behavior:"smooth"})):null===(r=En.current)||void 0===r||r.scrollBy({top:a,behavior:"smooth"})}}Wn({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Zi(n,i,{toggleIfSame:!1,sourceSide:a}),ci&&setTimeout(function(){return uo(n)},150)},350)},[Zi,Xn,Wn,Qi,st,ci,Me,uo,bn]),mo=i.useMemo(function(){var e;if(!we)return null;var n=null===(e=null==we?void 0:we.id)||void 0===e?void 0:e.split(":")[0];for(var i in hi){if((hi[i]||[]).some(function(e){return e.id===n}))return i}return null},[we,hi]),So=i.useRef({id:null,triggerMs:null}),Ro=i.useRef(null);i.useEffect(function(){if(null==we?void 0:we.id){var n=Number(we.trigger),i=So.current;if((null==i?void 0:i.id)!==we.id||(null==i?void 0:i.triggerMs)!==n){if(we.id.includes(":")&&/:\d+$/.test(we.id)){var t=we.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0",s="".concat(we.id,":").concat(n);Ro.current!==s&&(zn(),Xn(),Qi(),Qe(new Set),nn([]),mn.current=[],Ro.current=s);var a=!1,c=0,d=null,f=null,v=!1,g=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},p=function(){var i,t,r;if(!a){var s=function(){So.current={id:we.id,triggerMs:n}},h=null,m=null;for(var S in hi){var R=hi[S].find(function(e){var n;return e.id===o||e.nodeId===o||e.contentId===o||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===o});if(R){h=S,m=R;break}}if(m&&h){var x=Array.from(new Set([o,m.id,m.nodeId,m.contentId,null===(i=m.evaluationResult)||void 0===i?void 0:i.nodeId].filter(Boolean))),_=vi.findIndex(function(e){return e.id===h}),b=gi.findIndex(function(e){return e.id===h}),y=-1===_&&-1!==b,C=g(vi,x),E=g(gi,x);if(C&&!E&&!y){var A=C.split("-"),T=Number(A[0]);if(Me){var w=null===(r=null===(t=vi[T])||void 0===t?void 0:t.refIndexes)||void 0===r?void 0:r[0],I=gi.findIndex(function(e){return e.selfIndex===w});-1!==I&&(T=I)}E=e.__spreadArray([T],A.slice(1),!0).join("-")}if(C||E){var B=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):b,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=vi[B],j=gi[O],P=F&&!F.title&&!F.content,k=j&&!j.title&&!j.content,N=y||(!C&&!!E||P&&!k);if(N){if(!(Me?!!Bo.current["right-".concat(D)]:!!Bo.current[String(D)])&&D>=0)return ut(D,"right"),void(d=setTimeout(p,200))}else if(!(Me?!!Bo.current["left-".concat(B)]:!!Bo.current[String(B)])&&B>=0)return ut(B,"left"),void(d=setTimeout(p,200));var M=C||"",L=E||"",q=x.map(function(e){return"".concat(e).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l)}),H=q[0],G=function(){for(var e,n,i=0,t=q;i<t.length;i++){var o=t[i],r=(null===(e=Ti.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=wi.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:H,left:null,right:null}},V=function(e){return"".concat(e).concat(u.DEVIATION_BADGE_SEPARATOR).concat(M).concat(u.DEVIATION_BADGE_SEPARATOR).concat(L)};if(!v){st(V(H)),v=!0,c=0;var W=function(){var e=G(),n=e.left,i=e.right;return N||!n&&!!i?i:n};return null==f||f(),void(d=setTimeout(function(){var e,n,i,t,o,r,l,u;a||(e=W,n=function(){a||(f=null,p())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!a)if(performance.now()-l>3e3)n();else{var s=e();if(s&&0!==s.getBoundingClientRect().height){var c=s.getBoundingClientRect(),d=c.top,f=c.height,v=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(f-r)<.5;if(v&&g){if(++t>=5)return void n()}else t=0;o=d,r=f,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),f=function(){return cancelAnimationFrame(i)})},300))}var z=G(),K=z.refId,U=z.left,Y=z.right,J=V(K);if(U||Y){var X=N||!U&&!!Y,$=X?Y:U,Q=Me?X?Tn.current:On.current:En.current;if($&&Q){var Z=$.getBoundingClientRect();if(0!==Z.height){var ee=Q.getBoundingClientRect(),ne=Z.top-ee.top+Q.scrollTop-ee.height/2+Z.height/2,ie=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),te=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,c,d,f,v,g;return e.__generator(this,function(p){switch(p.label){case 0:return a?[2]:(s(),n=$ instanceof Element?window.getComputedStyle($).color:"",[U,Y].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[U,Y].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(d=null===(c=m.evaluationResult)||void 0===c?void 0:c.deviations)||void 0===d?void 0:d[l])||m,t=(null===(f=m.evaluationResult)||void 0===f?void 0:f.evaluation_outputs)||m.evaluation_outputs,!!U&&!!Y||ci?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Me?[4,Promise.all([On.current?r(u.waitForScrollIdle(On.current),600):Promise.resolve(),Tn.current?r(u.waitForScrollIdle(Tn.current),600):Promise.resolve()])]:[3,2]):(o=X?(null===(v=wi.current[ie?K:D])||void 0===v?void 0:v.current)||Y:(null===(g=Ti.current[ie?K:B])||void 0===g?void 0:g.current)||U,po(o,function(){Wn({open:!0,anchorEl:o,displayImpact:we.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Ie||Ie(),[2]));case 1:p.sent(),p.label=2;case 2:return ci&&(sn(lo(J)),Qe(new Set([J]))),et.current(J,!1,{toggleIfSame:!1,sourceSide:y?"right":"left",onReady:function(){var n,t,o,r;s();var l=X?(null===(n=wi.current[K])||void 0===n?void 0:n.current)||Y:(null===(t=Ti.current[K])||void 0===t?void 0:t.current)||U;if(ci)setTimeout(function(){return uo(J)},150);else{var u=(null===(o=Ti.current[K])||void 0===o?void 0:o.current)||U,a=(null===(r=wi.current[K])||void 0===r?void 0:r.current)||Y;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),a&&(a.style.scrollMarginTop="150px",a.scrollIntoView({behavior:"smooth",block:"start"}))}Wn({open:!0,anchorEl:l,displayImpact:we.displayImpact,summary:e.__assign({},i)}),null==Ie||Ie()}}),[2]}})})};Math.abs(Q.scrollTop-ne)<=2?te():u.scrollAndWait(Q,ne,te)}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}};return d=setTimeout(p,100),function(){a=!0,d&&clearTimeout(d),null==f||f()}}So.current={id:we.id,triggerMs:n},Mt(we.id);var h=vi.findIndex(function(e){return e.id===we.id}),m=gi.findIndex(function(e){return e.id===we.id});-1===h&&-1===m||setTimeout(function(){var e=-1!==h?h:m,n=-1===h;ci&&sn(lo(e)),Qe(new Set([e])),et.current(e,n,{sourceSide:n?"right":"left",onReady:function(){ci&&setTimeout(function(){return uo(String(e))},150)}})},400)}}},[null==we?void 0:we.id,null==we?void 0:we.trigger,null==we?void 0:we.displayImpact,hi,vi,gi,Me,Wn,Mt,ci,lo,uo]),i.useEffect(function(){var n,i,t;if(Vn.open){var o=Vn.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Ti.current)||r(wi.current);if(l){var u=(null===(i=wi.current[l])||void 0===i?void 0:i.current)||(null===(t=Ti.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Wn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Vn.open,Vn.anchorEl,on,$e,it]);var xo=kn.open,_o=kn.sectionIdx,bo=kn.isOrphan,yo=kn.badgeStyle,Co=kn.anchorEl,Eo=kn.sectionAnchorEl;i.useEffect(function(){var n;if(ye.isStreamingEnabled&&xo&&null!=_o&&_o!==pt){var i="string"==typeof _o?_o.split(u.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(vi,i):null,r=i&&"string"==typeof i?t(gi,i):null,l="number"==typeof _o?vi[_o]||null:o||i&&((null===(n=null==he?void 0:he.nodes)||void 0===n?void 0:n[i])||(null==he?void 0:he[i]))||null,s="number"==typeof _o?gi[_o]||null:r,a=jt(Co,l,s,_o,bo,yo);Nn(function(n){return n.open?u.safeStringify(n.cognitiveData)===u.safeStringify(a.cognitiveData)&&u.safeStringify(n.deviationData)===u.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[xo,_o,bo,yo,Co,Eo,vi,gi,jt]);var Ao=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,s=e.parentNodeId,a=void 0===s?"":s,c=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:c,rhsOrphanVisualIndexes:d})},[]),To=i.useMemo(function(){return vi.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Me?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[vi]),wo=i.useMemo(function(){return gi.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Me?null:n.jsx(b.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[gi]),Io=i.useRef(Pt);i.useEffect(function(){Io.current=Pt},[Pt]);var Bo=i.useRef(it);i.useEffect(function(){Bo.current=it},[it]);var Do=i.useRef(ho);i.useEffect(function(){Do.current=ho},[ho]);var Oo=i.useRef(ao);i.useEffect(function(){Oo.current=ao},[ao]);var Fo=i.useRef(ut);i.useEffect(function(){Fo.current=ut},[ut]);var jo=i.useRef(lt);i.useEffect(function(){jo.current=lt},[lt]);var Po=i.useRef(Ao);i.useEffect(function(){Po.current=Ao},[Ao]);var ko=i.useRef(Qi);i.useEffect(function(){ko.current=Qi},[Qi]);var No=i.useMemo(function(){return{isGuidelineMode:ci,maintainRelativeOrder:!!Me,showDeviationBadges:Ge,isProposingFix:De,proposingFixNodeId:Oe,isRedlineFlow:Fe,isSideBySide:Ni,activeSideBySideSection:Vi,scrollSyncLocked:on,toggleScrollSyncLocked:ct,summaryPopupAnchorEl:Vn.anchorEl,connectedSections:$e,proposedSections:vi,existingSections:gi,deviationNumberRegistry:mi,deviationParentRegistry:Si,treeData:he,displayConfig:ye,resolvedMarkdownStyles:Cn,unifiedNumbering:dt,expandedSections:it,expandedSubSections:ot,setExpandedSubSections:rt,getSectionCompareStyle:Vt,getSubSectionCompareStyle:Wt,getBadgeRef:Pi,getSectionRowRef:Fi,getSubSectionRef:ji,sectionLeftRefs:Ei,sectionRightRefs:Ai,sectionRowRefs:Oi,sectionRightRowRefs:Ii,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,openMoreFunctionsPopup:bt,handleOpenSummaryPopup:yt,openSummaryPopup:yt,handleCloseSummaryPopup:Ct,toggleSection:Et,handleSubSectionToggle:At,renderSubSectionAccordion:Tt,resetSideBySide:wt,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,showDeviationNavigation:vo,showOpenNodeRef:go,deviationNodeIdToView:null==we?void 0:we.id,deviationTargetParentId:mo,guidelinesData:Pe,gptWebCitationConfig:ke}},[ci,Me,Ge,De,Oe,Fe,Ni,Vi,on,ct,Vn.anchorEl,$e,vi,gi,mi,ye,Cn,dt,it,ot,rt,Vt,Wt,Pi,Fi,ji,vo,go,we,mo,Pe,ke]),Mo=u.safeStringify(kn.sectionTitle||ri||ti),Lo=u.safeStringify(ci?ui||si||kn.refSectionTitle:kn.refSectionTitle||ui||si);return n.jsx(C.CompareContextProvider,e.__assign({value:No},{children:n.jsxs(t.Box,e.__assign({ref:An,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[We&&n.jsx(t.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(f.default,{})})),Vn.open&&n.jsx(y.default,{open:Vn.open,anchorEl:Vn.anchorEl,containerEl:qt.current,clipTopEl:dn.current,scrollContainerEl:En.current,onClose:ao,summary:Vn.summary,displayImpact:Vn.displayImpact,isScrollLocked:on}),n.jsx(d.default,{open:Mn.open,anchorEl:Mn.anchorEl,maintainRelativeOrder:!!Me,sectionTitle:Mn.sectionTitle,referenceSectionTitle:Mn.refSectionTitle,onClose:$n,onOpenCognitiveCompare:Yn,onOpenSideBySide:so,onConnect:kt,isConnected:co,isOrphan:!ci&&!!Mn.isOrphan,isGuidelineMode:ci,hasGuidelineMatches:Mn.hasGuidelineMatches}),kn.open&&n.jsx(c.default,{open:kn.open,popupRef:Un,position:qn,popupConfig:Ee,onClose:function(){Hn(null),Nn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Kn(null)},markdownStyles:xe,sectionTitle:Mo,referenceSectionTitle:Lo,cognitiveData:kn.cognitiveData,anchorEl:kn.anchorEl,sectionAnchorEl:kn.sectionAnchorEl,scrollContainerEl:En.current,badgeStyle:kn.badgeStyle,docData:kn.docData,deviationData:kn.deviationData,isLoading:kn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!Ue,autoHideDuration:8e3,onClose:function(){return Ye(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ye(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ue}))})),n.jsx(R.default,{componentHeaderText:pe,displayConfig:ye,maintainRelativeOrder:Me,onCollapseAll:Zt,showCollapseAll:eo,onToggleView:function(e){ze(!0),setTimeout(function(){Le(!e),null==Ce||Ce(!e),rn(!1),Qi(),zn(),Qe(new Set),nn([]),mn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ze(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:En,onScroll:Qt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Me?"visible":"auto",borderTop:vt&&gt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Me?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:cn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Me?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:an,svgDimensions:$t,isResizing:qi,overallConnector:Jt,rootDeviationStyle:St,lines:Ut,isSideBySide:Ni,activeSideBySideSection:Vi,isArrowVisible:Mi,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,cognitivePopup:kn,activeBadgeId:Gn,closeCognitivePopup:Xn,setActiveBadgeId:Kn,openCognitivePopupFromState:Jn,buildSectionPopupState:jt,connectedLines:en,isGuidelineMode:ci,pathRefs:hn}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Me?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:dn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:ti,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:On,onScroll:Qt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Me?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Bn,style:{width:"100%",height:"0px",flexShrink:0}}),xi&&To,n.jsx("div",{ref:Dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:qt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),kn.open&&Gn===pt?Xn():(Kn(pt),Jn(jt(n.currentTarget,{title:"",content:"",evaluationResult:ht,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,pt,!0,e.__assign(e.__assign({},St),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:St.badgeBg,color:St.badgeText,border:"1px solid ".concat(St.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=mt?mt:n.jsx(v.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:kn.open&&Gn===pt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Me?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Gi&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:fn,sx:e.__assign({p:"8px",bgcolor:ci?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Me?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ci?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:ci?n.jsxs(t.Tabs,e.__assign({value:un,onChange:function(e,n){return sn(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[n.jsx(t.Tab,{label:n.jsx(t.Tooltip,e.__assign({title:si,placement:"top"},{children:n.jsx(t.Box,e.__assign({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),n.jsx(t.Tab,{label:n.jsx(t.Tooltip,e.__assign({title:"Web & GPT Sources",placement:"top"},{children:n.jsx(t.Box,e.__assign({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):n.jsx(t.Tooltip,e.__assign({title:si,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:si}))}))})),n.jsxs(t.Box,e.__assign({ref:Tn,onScroll:Qt,sx:e.__assign({p:ci?"0px":"12px",display:"flex",flexDirection:"column"},Me?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ci&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:wn,style:{width:"100%",height:"0px",flexShrink:0}}),ci?0===un?n.jsx(B.default,{guidelinesData:Pe,deviationData:Te,connectedSections:$e,proposedSections:vi}):n.jsx(D.default,{deviationData:Te,connectedSections:$e,proposedSections:vi}):xi&&wo,n.jsx("div",{ref:In,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./CognitiveCompareConstants.js"),e=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(e).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},n=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return n(t)}))};var o=["#B91C1C","#A16207","#1D4ED8","#000000"],r=function(t){var e=o.findIndex(function(e){return e.toLowerCase()===t.toLowerCase()});return-1===e?o.length:e},i=function(t,e,n){if(!t)return null;if(t.id===n)return e;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=i(t.subsections[o],"".concat(e,"-").concat(o),n);if(r)return r}return null},l=new WeakMap,u=function(t){if(t){var e=l.get(t);null!=e&&(clearTimeout(e),l.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},a=function(t){if(t){var e=l.get(t);null!=e&&clearTimeout(e),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var n=window.setTimeout(function(){u(t)},3e3);l.set(t,n)}};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,e){var n,o,r,i,l,u;if(t.content!==e.content)return!1;if(t.overlayContent!==e.overlayContent)return!1;if(t.sxStyles!==e.sxStyles)return!1;if(t.maintainRelativeOrder!==e.maintainRelativeOrder)return!1;if(t.highlightBg!==e.highlightBg)return!1;if(t.suppressHighlightBg!==e.suppressHighlightBg)return!1;if(t.collisionKey!==e.collisionKey)return!1;var a=t.highlights||[],s=e.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var d=t.deviationBadges||[],v=e.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if(d[c].showScrollLockToggle!==v[c].showScrollLockToggle)return!1;if(d[c].scrollSyncLocked!==v[c].scrollSyncLocked)return!1;if((null===(n=d[c].style)||void 0===n?void 0:n.badgeBg)!==(null===(o=v[c].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=d[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(l=d[c].style)||void 0===l?void 0:l.badgeText)!==(null===(u=v[c].style)||void 0===u?void 0:u.badgeText))return!1}return!0},exports.debounce=function(t,e){var n;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(n),n=setTimeout(function(){return t.apply(i,o)},e)}},exports.extractDeviationScore=function(t,e){var n,o,r,i,l,u,a;if(!t)return e;var s=null!==(u=null!==(i=null!==(o=null===(n=t.evaluation_output)||void 0===n?void 0:n.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(l=t.evaluation_outputs)||void 0===l?void 0:l.output_value)&&void 0!==u?u:t.output_score;return null!==(a=null!=s?s:e)&&void 0!==a?a:""},exports.findKeyPathByNodeId=function(t,e){for(var n=0;n<t.length;n++){var o=i(t[n],String(n),e);if(o)return o}return null},exports.generateColorPalette=function(t){var e=function(t,e){var n=function(t){var e=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),n=parseInt(e,16);return{r:n>>16&255,g:n>>8&255,b:255&n}}(t),o=n.r,r=n.g,i=n.b;return function(t,e,n){return"#"+[t,e,n].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*e),Math.round(r+(255-r)*e),Math.round(i+(255-i)*e))};return{bg:e(t,.8),border:e(t,.5),badgeBg:e(t,.8),badgeBorder:e(t,.5),badgeText:t.toUpperCase(),highlightBg:e(t,.8)}},exports.getBentArrowPath=function(t,e,n,o,r){void 0===r&&(r=14);var i=t+.5*(n-t),l=o-e;if(Math.abs(l)<3)return"M ".concat(t," ").concat(e," H ").concat(n);var u=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(i-t)/2,Math.abs(n-i)/2);return["M ".concat(t," ").concat(e),"H ".concat(i-a),"Q ".concat(i," ").concat(e," ").concat(i," ").concat(e+u*a),"V ".concat(o-u*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(n)].join(" ")},exports.getFirstDeviationColor=function(e){for(var n,o,i,l,u,a,s,c,d,v,f,g,p,h=[],b=0,m=Object.keys((null==e?void 0:e.deviations)||{}).sort(function(t,e){return Number(t)-Number(e)});b<m.length;b++){var y=m[b];(S=null===(l=null===(i=null===(o=null===(n=null==e?void 0:e.deviations)||void 0===n?void 0:n[y])||void 0===o?void 0:o.evaluation_outputs)||void 0===i?void 0:i.metadata)||void 0===l?void 0:l.label_color)&&h.push(S)}for(var _=0,x=Object.keys((null==e?void 0:e.deviation_entries)||{}).sort(function(t,e){return Number(t)-Number(e)});_<x.length;_++){y=x[_];(S=null===(c=null===(s=null===(a=null===(u=null==e?void 0:e.deviation_entries)||void 0===u?void 0:u[y])||void 0===a?void 0:a.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===c?void 0:c.label_color)&&h.push(S)}for(var T=0,A=Object.keys(e||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,e){return Number(t)-Number(e)});T<A.length;T++){var S;y=A[T];(S=null===(f=null===(v=null===(d=null==e?void 0:e[y])||void 0===d?void 0:d.evaluation_outputs)||void 0===v?void 0:v.metadata)||void 0===f?void 0:f.label_color)&&h.push(S)}return 0===h.length?(null===(p=null===(g=null==e?void 0:e.evaluation_outputs)||void 0===g?void 0:g.metadata)||void 0===p?void 0:p.label_color)?e.evaluation_outputs.metadata.label_color:t.DEFAULT_DEVIAION_COLOR:h.sort(function(t,e){return r(t)-r(e)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var e,n,o,r,i,l,u,a,s,c=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,e){return Number(t)-Number(e)});c<d.length;c++){var v=d[c];if(b=null===(o=null===(n=null===(e=null==t?void 0:t.deviations)||void 0===e?void 0:e[v])||void 0===n?void 0:n.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,e){return Number(t)-Number(e)});f<g.length;f++){v=g[f];if(b=null===(l=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[v])||void 0===i?void 0:i.evaluation_outputs)||void 0===l?void 0:l.output_value)return b}for(var p=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,e){return Number(t)-Number(e)});p<h.length;p++){var b;v=h[p];if(b=null===(a=null===(u=null==t?void 0:t[v])||void 0===u?void 0:u.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var e=t.mapping_rationale,n=parseInt(e.decision_strength||"0");return{cognitiveData:{decisioning:e.decisioning_factors||[],gap:e.gaps_in_decision||[],relevance_score:n,citations:e.citations},score:0,relation:"N/A"}},exports.getSideData=function(t,n,o){var r,i=o[n],l=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return{title:e((null==l?void 0:l.title)||""),content:e((null==l?void 0:l.content)||""),change_history:e((null==l?void 0:l.change_history)||""),attributes:(null==l?void 0:l.additional_attributes)||null,subsections:(null==l?void 0:l.subsections)||[]}},exports.hasMeaningfulRedlineTags=function(t){var e;if("string"!=typeof t||!t)return!1;for(var n=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=n.exec(t));){if((null!==(e=o[2])&&void 0!==e?e:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},exports.hasValue=n,exports.highlightClause=a,exports.isMissingStr=function(t){if(!t)return!0;var e=t.trim().toLowerCase();return e.includes("no equivalent")||"n/a"===e||"na"===e||"none"===e},exports.mixHexColors=function(t,e){var n=function(t){var e=t.replace("#","");return[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16)]},o=function(t){var e=Math.round(t).toString(16);return 1===e.length?"0"+e:e};try{var r=n(t),i=n(e),l=(r[0]+i[0])/2*.95,u=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(l)).concat(o(u)).concat(o(a))}catch(t){return"#FDE68A"}},exports.recursivelyFindSubSectionIdxById=i,exports.resetClauseHighlight=u,exports.safeStringify=e,exports.scrollAndHighlightClause=function(t,e){var n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=e.scrollTop+o.top-n.top-n.height/2+o.height/2;e.scrollTo({top:r,behavior:"smooth"});var i=function(){return a(t)};if("onscrollend"in e)e.addEventListener("scrollend",i,{once:!0});else{var l=e.scrollTop,u=function(){e.scrollTop===l?i():(l=e.scrollTop,requestAnimationFrame(u))};requestAnimationFrame(u)}},exports.scrollAndWait=function(t,e,n){if(Math.abs(t.scrollTop-e)<=2)n();else{var o,r=!1,i=function(){r||(r=!0,clearTimeout(o),t.removeEventListener("scrollend",l),n())},l=function(){return i()};t.addEventListener("scrollend",l),t.scrollTo({top:e,behavior:"smooth"}),o=setTimeout(i,800)}},exports.smoothScrollTo=function(t,e,n,o,r){void 0===n&&(n=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var l=t.scrollTop,u=e-l,a=null,s=function(c){null===a&&(a=c);var d,v=c-a;v<n?(t.scrollTop=(d=v,d/=n,u*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(s)):(t.scrollTop=e,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},exports.stripRedlineTags=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},exports.waitForScrollIdle=function(t,e){return void 0===e&&(e=100),new Promise(function(n){var o,r=!1,i=function(){r||(r=!0,t.removeEventListener("scroll",l),n())},l=function(){clearTimeout(o),o=setTimeout(i,e)};t.addEventListener("scroll",l),o=setTimeout(i,e)})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./CognitiveCompareConstants.js"),n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))},o=function(t){for(var n=t+1,e="";n>0;){n-=1;e=String.fromCharCode(97+n%26)+e,n=Math.floor(n/26)}return e},r=function(t,n,e,o){var r;void 0===o&&(o={});var i=e[n],l=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return l?(Array.isArray(l)?l:[l]).map(function(t,n){if(t&&"string"==typeof t&&t.trim()){var e=o[t];return e&&"object"==typeof e&&e?{contentId:t,data:e,attributes:e.additional_attributes||{}}:null}return t&&"object"==typeof t?{contentId:t.content_id||t.id||"".concat(i,"-direct-").concat(n),data:t,attributes:t.additional_attributes||{}}:null}).filter(Boolean):[]};var i=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},l=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},u=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},a=["#B91C1C","#A16207","#1D4ED8","#000000"],s=function(t){var n=a.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?a.length:n},c=function(t,n,e){if(!t)return null;if(t.id===e||t.nodeId===e||t.contentId===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=c(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},d=new WeakMap,v=function(t){if(t){var n=d.get(t);null!=n&&(clearTimeout(n),d.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},f=function(t){if(t){var n=d.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){v(t)},3e3);d.set(t,e)}};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,o,r,i,l,u;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if(d[c].showScrollLockToggle!==v[c].showScrollLockToggle)return!1;if(d[c].scrollSyncLocked!==v[c].scrollSyncLocked)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=v[c].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=d[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(l=d[c].style)||void 0===l?void 0:l.badgeText)!==(null===(u=v[c].style)||void 0===u?void 0:u.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,o)},n)}},exports.extractDeviationScore=function(t,n){var e,o,r,i,l,u,a;if(!t)return n;var s=null!==(u=null!==(i=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(l=t.evaluation_outputs)||void 0===l?void 0:l.output_value)&&void 0!==u?u:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},exports.findKeyPathByNodeId=function(t,n){for(var e=0;e<t.length;e++){var o=c(t[e],String(e),n);if(o)return o}return null},exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,r=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getAlphabeticSuffix=o,exports.getBentArrowPath=function(t,n,e,o,r){void 0===r&&(r=14);var i=t+.5*(e-t),l=o-n;if(Math.abs(l)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var u=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+u*a),"V ".concat(o-u*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(e)].join(" ")},exports.getFirstDeviationColor=function(n){for(var e,o,r,i,l,u,a,c,d,v,f,p,g,h=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(T=null===(i=null===(r=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[y])||void 0===o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&h.push(T)}for(var x=0,_=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});x<_.length;x++){y=_[x];(T=null===(c=null===(a=null===(u=null===(l=null==n?void 0:n.deviation_entries)||void 0===l?void 0:l[y])||void 0===u?void 0:u.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===c?void 0:c.label_color)&&h.push(T)}for(var I=0,A=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});I<A.length;I++){var T;y=A[I];(T=null===(f=null===(v=null===(d=null==n?void 0:n[y])||void 0===d?void 0:d.evaluation_outputs)||void 0===v?void 0:v.metadata)||void 0===f?void 0:f.label_color)&&h.push(T)}return 0===h.length?(null===(g=null===(p=null==n?void 0:n.evaluation_outputs)||void 0===p?void 0:p.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t.DEFAULT_DEVIAION_COLOR:h.sort(function(t,n){return s(t)-s(n)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var n,e,o,r,i,l,u,a,s,c=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<d.length;c++){var v=d[c];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[v])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,p=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<p.length;f++){v=p[f];if(b=null===(l=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[v])||void 0===i?void 0:i.evaluation_outputs)||void 0===l?void 0:l.output_value)return b}for(var g=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});g<h.length;g++){var b;v=h[g];if(b=null===(a=null===(u=null==t?void 0:t[v])||void 0===u?void 0:u.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},exports.getLhsDeviationDisplayIndexes=function(t,e,o){var r=new Map;if(!e)return r;var a=function(t){var e=l(t)?u(t):n(t||"");return n(e).replace(/\\n/g,"\n")};return(t||[]).forEach(function(t){var n=new Map,l=function(t){var r;if(t){var u=a(t.content);((null===(r=t.evaluationResults)||void 0===r?void 0:r.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(r){var l=(null==r?void 0:r.nodeId)||t.nodeId||t.id;Object.entries((null==r?void 0:r.deviations)||{}).forEach(function(t){var r=t[0],s=t[1][e],c=a(s);if(c&&!i(s)&&u.includes(c)){var d="".concat(l).concat("::").concat(r),v=o[d];null!=v&&n.set(d,v)}})}),(t.subsections||[]).forEach(l)}};if(l(t),0!==n.size){var u=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){r.set(n,t-u+1)})}}),r},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getRhsMappedSectionNumber=function(t){var n=t.section,e=t.proposedSections,r=t.leftNums,i=t.fallbackNumber,l=t.firstOnly,u=void 0!==l&&l;if(!(null==n?void 0:n.id))return i;var a=(e||[]).map(function(t){var e=Array.isArray(null==t?void 0:t.refIndexes)?t.refIndexes:[],i=e.findIndex(function(t){return t===n.selfIndex});if(-1===i)return null;var l=(null==t?void 0:t.id)?r.get(t.id):void 0;return null==l?null:e.length>1?"".concat(l).concat(o(i)):String(l)}).filter(Boolean);return 0===a.length?i:u?a[0]:a.join(", ")},exports.getSideData=function(t,e,o,i){var l,u,a;void 0===i&&(i={});var s=r(t,e,o,i),c=(null===(l=s[0])||void 0===l?void 0:l.data)||{},d=(null===(u=s[0])||void 0===u?void 0:u.attributes)||null;return{title:n((null==c?void 0:c.title)||""),content:n((null==c?void 0:c.content)||""),change_history:n((null==c?void 0:c.change_history)||""),attributes:d,subsections:(null==c?void 0:c.subsections)||[],contentId:null===(a=s[0])||void 0===a?void 0:a.contentId,allItems:s}},exports.hasMeaningfulRedlineTags=l,exports.hasSingleMappedLhsSection=function(t,n){return null!=(null==t?void 0:t.selfIndex)&&1===(n||[]).filter(function(n){return Array.isArray(null==n?void 0:n.refIndexes)&&n.refIndexes.includes(t.selfIndex)}).length},exports.hasValue=e,exports.highlightClause=f,exports.isMissingStr=i,exports.mixHexColors=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=e(t),i=e(n),l=(r[0]+i[0])/2*.95,u=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(l)).concat(o(u)).concat(o(a))}catch(t){return"#FDE68A"}},exports.recursivelyFindSubSectionIdxById=c,exports.resetClauseHighlight=v,exports.resolveComparisonInputItems=r,exports.safeStringify=n,exports.scrollAndHighlightClause=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return f(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var l=n.scrollTop,u=function(){n.scrollTop===l?i():(l=n.scrollTop,requestAnimationFrame(u))};requestAnimationFrame(u)}},exports.scrollAndWait=function(t,n,e){if(Math.abs(t.scrollTop-n)<=2)e();else{var o,r=!1,i=function(){r||(r=!0,clearTimeout(o),t.removeEventListener("scrollend",l),e())},l=function(){return i()};t.addEventListener("scrollend",l),t.scrollTo({top:n,behavior:"smooth"}),o=setTimeout(i,800)}},exports.smoothScrollTo=function(t,n,e,o,r){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var l=t.scrollTop,u=n-l,a=null,s=function(c){null===a&&(a=c);var d,v=c-a;v<e?(t.scrollTop=(d=v,d/=e,u*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},exports.stripRedlineTags=u,exports.waitForScrollIdle=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var o,r=!1,i=function(){r||(r=!0,t.removeEventListener("scroll",l),e())},l=function(){clearTimeout(o),o=setTimeout(i,n)};t.addEventListener("scroll",l),o=setTimeout(i,n)})};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),o=require("react/jsx-runtime"),e=require("react"),n=require("@mui/material"),t=require("lucide-react"),s=require("react-dom"),a=require("../../assests/svg/SparkleIcon.js"),r=require("./CognitiveCompareConfig.js"),l=require("./CitationRenderer.js");function c(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var d=c(s),x=10;exports.default=function(s){var c,p,g,u,v,h,b,f,_,m,y,F,j,w,k,B,S,C,D,E,T=s.open,I=s.onClose,R=s.sectionTitle,A=s.referenceSectionTitle,L=s.cognitiveData,P=s.relevanceScore,z=s.anchorEl,O=s.badgeStyle,W=s.popupRef,q=s.position,U=s.markdownStyles,H=s.docData,M=s.popupConfig,N=s.deviationData,G=void 0===N?null:N,Y=s.isLoading,K=i.__assign(i.__assign({},r.SHARED_MARKDOWN_STYLES),U),X=e.useMemo(function(){var o,e;return i.__assign(i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG),M),{tabs:{deviation:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.deviation),null===(o=null==M?void 0:M.tabs)||void 0===o?void 0:o.deviation),association:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.association),null===(e=null==M?void 0:M.tabs)||void 0===e?void 0:e.association)},sectionTitles:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.sectionTitles),null==M?void 0:M.sectionTitles)})},[M]),J=null==L?void 0:L.isMissingRationale,Q=e.useState(J?X.tabs.deviation.key:X.tabs.association.key),V=Q[0],Z=Q[1];e.useEffect(function(){T&&Z(J?X.tabs.deviation.key:X.tabs.association.key)},[T,J,X.tabs.deviation.key,X.tabs.association.key]);var $=e.useMemo(function(){if(!O)return{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")};var i=O.badgeText;return"#9F1239"===i||"#B42318"===i?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===i?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===i?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")}},[O,X.accentColor]);e.useEffect(function(){if(T){var i=function(i){var o;(null===(o=W.current)||void 0===o?void 0:o.contains(i.target))||(null==z?void 0:z.contains(i.target))||I()};return document.addEventListener("mousedown",i),function(){return document.removeEventListener("mousedown",i)}}},[T,I,z,W]);var ii=J?[]:[X.tabs.deviation,X.tabs.association];if(1===ii.length&&ii[0].key===X.tabs.deviation.key)return null;if(!T||!L)return null;var oi=null!==(g=null!==(p=V===X.tabs.deviation.key?null===(c=null==G?void 0:G.cognitive_decisioning)||void 0===c?void 0:c.decision_strength:L.relevance_score)&&void 0!==p?p:P)&&void 0!==g?g:0,ei=L.decisioning,ni=Array.isArray(ei)?ei:"string"==typeof ei&&ei.trim()?[ei]:[],ti=L.gap,si=Array.isArray(ti)?ti:"string"==typeof ti&&ti.trim()?[ti]:[],ai=q?q.left-150:-9999,ri=(null!==(u=null==q?void 0:q.arrowLeft)&&void 0!==u?u:60)+150,li=o.jsxs(n.Box,i.__assign({ref:W,sx:{position:"fixed",top:null!==(v=null==q?void 0:q.top)&&void 0!==v?v:-9999,left:ai,zIndex:9999,width:"".concat(1050,"px"),maxWidth:"min(".concat(1050,"px, calc(100vw - ").concat(ai>0?ai:0,"px - ").concat(12,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat($.border),boxShadow:"0px 8px 32px ".concat($.shadow,", 0px 0px 0px 3px ").concat($.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==q?void 0:q.maxHeight)?"min(60vh, ".concat(q.maxHeight,"px)"):"60vh",visibility:q?"visible":"hidden"}},{children:[q&&(q.openAbove?o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",bottom:-11,left:ri-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat($.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",bottom:-9,left:ri-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]}):o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",top:-11,left:ri-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat($.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",top:-9,left:ri-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]})),o.jsxs(n.Box,i.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{flex:1,minWidth:0}},{children:[("no counterpart"!==R||"no counterpart"!==A)&&o.jsxs(n.Typography,i.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[o.jsx(n.Box,i.__assign({component:"span",title:R,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:R})),o.jsx(n.Box,i.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),o.jsx(n.Box,i.__assign({component:"span",title:A||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:A||"Reference Section"}))]})),o.jsx(n.Box,i.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"no counterpart"!==R||"no counterpart"!==A?"13px":"16px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(h=Object.values(X.tabs).find(function(i){return i.key===V}))||void 0===h?void 0:h.subtitle}))}))]})),o.jsxs(n.Box,i.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[o.jsx(a.default,{}),X.decisionStrengthLabel," ",oi,"%"]})),o.jsx(n.IconButton,i.__assign({onClick:I,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:o.jsx(t.X,{size:22})}))]}))]})),o.jsx(n.Box,i.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:ii.map(function(e){var t=V===e.key,s=e.key===X.tabs.deviation.key,a=ii.length>1&&s&&Y,r=o.jsx(n.Box,i.__assign({onClick:function(){a||Z(e.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:a?"not-allowed":"pointer",opacity:a?.5:1,fontSize:"14px",fontWeight:t?600:400,color:t?X.accentColor:"#667085",backgroundColor:t?"".concat(X.accentColor,"14"):"transparent",borderBottom:t?"2px solid ".concat(X.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none"}},{children:e.label}),e.key);return a?o.jsx(n.Tooltip,i.__assign({title:"Fetching deviation data",arrow:!0,placement:"top"},{children:o.jsx("span",{children:r})}),e.key):r})})),o.jsx(n.Box,i.__assign({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat($.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:$.border},scrollbarWidth:"thin",scrollbarColor:"".concat($.border,"55 transparent")}},{children:V===X.tabs.deviation.key?G?o.jsxs(o.Fragment,{children:[(null===(f=(null===(b=null==G?void 0:G.cognitive_decisioning)||void 0===b?void 0:b.decisioning_factors)||[])||void 0===f?void 0:f.length)>0&&o.jsx(l.default,{title:"Decision Making Factors",content:null===(m=null===(_=null==G?void 0:G.cognitive_decisioning)||void 0===_?void 0:_.decisioning_factors)||void 0===m?void 0:m.join("\n\n"),citations:null===(y=null==G?void 0:G.cognitive_decisioning)||void 0===y?void 0:y.citations,styles:K,docData:H,open:T}),(null===(j=(null===(F=null==G?void 0:G.cognitive_decisioning)||void 0===F?void 0:F.gaps_in_decision)||[])||void 0===j?void 0:j.length)>0&&o.jsx(l.default,{title:"Gaps in Decision",content:null===(k=null===(w=null==G?void 0:G.cognitive_decisioning)||void 0===w?void 0:w.gaps_in_decision)||void 0===k?void 0:k.join("\n\n"),citations:null===(B=null==G?void 0:G.cognitive_decisioning)||void 0===B?void 0:B.citations,styles:K,docData:H,open:T}),0===(null===(C=(null===(S=null==G?void 0:G.cognitive_decisioning)||void 0===S?void 0:S.decisioning_factors)||[])||void 0===C?void 0:C.length)&&0===(null===(E=(null===(D=null==G?void 0:G.cognitive_decisioning)||void 0===D?void 0:D.gaps_in_decision)||[])||void 0===E?void 0:E.length)&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):o.jsx(l.default,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:K,docData:H,open:T}):o.jsxs(o.Fragment,{children:[ni.length>0&&o.jsx(l.default,{title:X.sectionTitles.decisioningFactors,content:ni.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H}),si.length>0&&o.jsx(l.default,{title:X.sectionTitles.gaps,content:si.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H}),0===ni.length&&0===si.length&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:X.emptyStateMessage}))}))]})}))]}));return d.default.createPortal(li,document.body)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),o=require("react/jsx-runtime"),e=require("react"),n=require("@mui/material"),t=require("lucide-react"),s=require("react-dom"),a=require("../../assests/svg/SparkleIcon.js"),r=require("./CognitiveCompareConfig.js"),l=require("./CitationRenderer.js");function c(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var d=c(s),x=10;exports.default=function(s){var c,p,g,u,v,h,b,f,_,m,y,F,j,w,C,k,B,D,S,E,T=s.open,I=s.onClose,R=s.sectionTitle,A=s.referenceSectionTitle,L=s.cognitiveData,P=s.relevanceScore,z=s.anchorEl,O=s.badgeStyle,W=s.popupRef,q=s.position,U=s.markdownStyles,H=s.docData,M=s.popupConfig,N=s.deviationData,G=void 0===N?null:N,Y=s.isLoading,K=i.__assign(i.__assign({},r.SHARED_MARKDOWN_STYLES),U),X=e.useMemo(function(){var o,e;return i.__assign(i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG),M),{tabs:{deviation:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.deviation),null===(o=null==M?void 0:M.tabs)||void 0===o?void 0:o.deviation),association:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.association),null===(e=null==M?void 0:M.tabs)||void 0===e?void 0:e.association)},sectionTitles:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.sectionTitles),null==M?void 0:M.sectionTitles)})},[M]),J=null==L?void 0:L.isMissingRationale,Q=e.useState(J?X.tabs.deviation.key:X.tabs.association.key),V=Q[0],Z=Q[1],$=e.useState(!1),ii=$[0],oi=$[1],ei=e.useCallback(function(i){oi(i)},[]);e.useEffect(function(){T?Z(J?X.tabs.deviation.key:X.tabs.association.key):oi(!1)},[T,J,X.tabs.deviation.key,X.tabs.association.key]);var ni=e.useMemo(function(){if(!O)return{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")};var i=O.badgeText;return"#9F1239"===i||"#B42318"===i?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===i?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===i?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")}},[O,X.accentColor]);e.useEffect(function(){if(T&&!ii){var i=function(i){var o;(null===(o=W.current)||void 0===o?void 0:o.contains(i.target))||(null==z?void 0:z.contains(i.target))||I()};return document.addEventListener("mousedown",i),function(){return document.removeEventListener("mousedown",i)}}},[T,I,z,W,ii]);var ti=J?[]:[X.tabs.deviation,X.tabs.association];if(1===ti.length&&ti[0].key===X.tabs.deviation.key)return null;if(!T||!L)return null;var si=null!==(g=null!==(p=V===X.tabs.deviation.key?null===(c=null==G?void 0:G.cognitive_decisioning)||void 0===c?void 0:c.decision_strength:L.relevance_score)&&void 0!==p?p:P)&&void 0!==g?g:0,ai=L.decisioning,ri=Array.isArray(ai)?ai:"string"==typeof ai&&ai.trim()?[ai]:[],li=L.gap,ci=Array.isArray(li)?li:"string"==typeof li&&li.trim()?[li]:[],di=q?q.left-150:-9999,xi=(null!==(u=null==q?void 0:q.arrowLeft)&&void 0!==u?u:60)+150,pi=o.jsxs(n.Box,i.__assign({ref:W,sx:{position:"fixed",top:null!==(v=null==q?void 0:q.top)&&void 0!==v?v:-9999,left:di,zIndex:9999,width:"".concat(1050,"px"),maxWidth:"min(".concat(1050,"px, calc(100vw - ").concat(di>0?di:0,"px - ").concat(12,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(ni.border),boxShadow:"0px 8px 32px ".concat(ni.shadow,", 0px 0px 0px 3px ").concat(ni.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==q?void 0:q.maxHeight)?"min(60vh, ".concat(q.maxHeight,"px)"):"60vh",visibility:!ii&&q?"visible":"hidden",pointerEvents:ii?"none":"auto"}},{children:[q&&(q.openAbove?o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",bottom:-11,left:xi-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(ni.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",bottom:-9,left:xi-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]}):o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",top:-11,left:xi-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(ni.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",top:-9,left:xi-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]})),o.jsxs(n.Box,i.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{flex:1,minWidth:0}},{children:[("no counterpart"!==R||"no counterpart"!==A)&&o.jsxs(n.Typography,i.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[o.jsx(n.Box,i.__assign({component:"span",title:R,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:R})),o.jsx(n.Box,i.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),o.jsx(n.Box,i.__assign({component:"span",title:A||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:A||"Reference Section"}))]})),o.jsx(n.Box,i.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"no counterpart"!==R||"no counterpart"!==A?"13px":"16px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(h=Object.values(X.tabs).find(function(i){return i.key===V}))||void 0===h?void 0:h.subtitle}))}))]})),o.jsxs(n.Box,i.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[o.jsx(a.default,{}),X.decisionStrengthLabel," ",si,"%"]})),o.jsx(n.IconButton,i.__assign({onClick:I,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:o.jsx(t.X,{size:22})}))]}))]})),o.jsx(n.Box,i.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:ti.map(function(e){var t=V===e.key,s=e.key===X.tabs.deviation.key,a=ti.length>1&&s&&Y,r=o.jsx(n.Box,i.__assign({onClick:function(){a||Z(e.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:a?"not-allowed":"pointer",opacity:a?.5:1,fontSize:"14px",fontWeight:t?600:400,color:t?X.accentColor:"#667085",backgroundColor:t?"".concat(X.accentColor,"14"):"transparent",borderBottom:t?"2px solid ".concat(X.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none"}},{children:e.label}),e.key);return a?o.jsx(n.Tooltip,i.__assign({title:"Fetching deviation data",arrow:!0,placement:"top"},{children:o.jsx("span",{children:r})}),e.key):r})})),o.jsx(n.Box,i.__assign({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(ni.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:ni.border},scrollbarWidth:"thin",scrollbarColor:"".concat(ni.border,"55 transparent")}},{children:V===X.tabs.deviation.key?G?o.jsxs(o.Fragment,{children:[(null===(f=(null===(b=null==G?void 0:G.cognitive_decisioning)||void 0===b?void 0:b.decisioning_factors)||[])||void 0===f?void 0:f.length)>0&&o.jsx(l.default,{title:"Decision Making Factors",content:null===(m=null===(_=null==G?void 0:G.cognitive_decisioning)||void 0===_?void 0:_.decisioning_factors)||void 0===m?void 0:m.join("\n\n"),citations:null===(y=null==G?void 0:G.cognitive_decisioning)||void 0===y?void 0:y.citations,styles:K,docData:H,deviationData:G,open:T,onCitationFullscreenChange:ei}),(null===(j=(null===(F=null==G?void 0:G.cognitive_decisioning)||void 0===F?void 0:F.gaps_in_decision)||[])||void 0===j?void 0:j.length)>0&&o.jsx(l.default,{title:"Gaps in Decision",content:null===(C=null===(w=null==G?void 0:G.cognitive_decisioning)||void 0===w?void 0:w.gaps_in_decision)||void 0===C?void 0:C.join("\n\n"),citations:null===(k=null==G?void 0:G.cognitive_decisioning)||void 0===k?void 0:k.citations,styles:K,docData:H,deviationData:G,open:T,onCitationFullscreenChange:ei}),0===(null===(D=(null===(B=null==G?void 0:G.cognitive_decisioning)||void 0===B?void 0:B.decisioning_factors)||[])||void 0===D?void 0:D.length)&&0===(null===(E=(null===(S=null==G?void 0:G.cognitive_decisioning)||void 0===S?void 0:S.gaps_in_decision)||[])||void 0===E?void 0:E.length)&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):o.jsx(l.default,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:K,docData:H,open:T,onCitationFullscreenChange:ei}):o.jsxs(o.Fragment,{children:[ri.length>0&&o.jsx(l.default,{title:X.sectionTitles.decisioningFactors,content:ri.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H,onCitationFullscreenChange:ei}),ci.length>0&&o.jsx(l.default,{title:X.sectionTitles.gaps,content:ci.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H,onCitationFullscreenChange:ei}),0===ri.length&&0===ci.length&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:X.emptyStateMessage}))}))]})}))]}));return d.default.createPortal(pi,document.body)};
2
2
  //# sourceMappingURL=CognitivePopup.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),l=require("react-markdown"),t=require("rehype-raw"),a=require("../../CognitiveCompareConfig.js"),n=require("../../CognitiveComparehelpers.js"),u=require("../utils/processGuidelinesMarkdown.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(l),g=s(t);exports.default=function(l){var t=l.guidelinesData,s=l.deviationData,v=l.connectedSections,_=l.proposedSections,p=Array.from(v)[0],c=i.useMemo(function(){var r;if(null==p||!s)return{targetHighlights:[],labelColor:""};var i="";"number"==typeof p?i=(null===(r=_[p])||void 0===r?void 0:r.nodeId)||"":"string"==typeof p&&(i=p.includes(n.DEVIATION_BADGE_SEPARATOR)?p.split(n.DEVIATION_BADGE_SEPARATOR)[0]:p.split("::")[0].split(":")[0]);var o=s[i];if(!o)return{targetHighlights:[],labelColor:""};var l=[],t=o.evaluation_result||{},a="";return Object.values(t).forEach(function(r){var i,o,t,u,s;(null===(i=null==r?void 0:r.deviation_highlights)||void 0===i?void 0:i.rulebook_guidelines)&&(l=e.__spreadArray(e.__spreadArray([],l,!0),r.deviation_highlights.rulebook_guidelines,!0),a=(null===(t=null===(o=r.evaluation_outputs)||void 0===o?void 0:o.metadata)||void 0===t?void 0:t.label_color)?n.generateColorPalette(null===(s=null===(u=r.evaluation_outputs)||void 0===u?void 0:u.metadata)||void 0===s?void 0:s.label_color).bg:"")}),{targetHighlights:l.filter(Boolean),labelColor:a}},[p,s,_]),h=c.targetHighlights,f=c.labelColor,b=i.useMemo(function(){return u.processGuidelinesMarkdown({guidelinesData:t,targetHighlights:h,labelColor:f||"#FEF08A"})},[t,h,f]);return r.jsx(o.Box,e.__assign({sx:e.__assign(e.__assign({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},a.SHARED_MARKDOWN_STYLES),{overflow:"visible"})},{children:r.jsx(d.default,e.__assign({rehypePlugins:[g.default]},{children:b}))}))};
2
+ //# sourceMappingURL=GuidelinePanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuidelinePanel.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),n=require("react"),t=require("@mui/material"),a=require("react-markdown"),o=require("rehype-raw"),i=require("../../CognitiveCompareConfig.js"),u=require("../../CognitiveComparehelpers.js"),d=require("../../CitationAnchor.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=l(a),c=l(o),v=function(e){var r,n,t=e.evalNode;return!1===(null===(n=null===(r=null==t?void 0:t.evaluation_outputs)||void 0===r?void 0:r.guideline_flag)||void 0===n?void 0:n.rulebook_used)},p=function(e,r,n){return"".concat(e,"::").concat(r,"::").concat(n)},f=function(e,r){return"".concat(e,"::").concat(r)},y={relativeWrapper:{verticalAlign:"baseline"},arrow:{color:"#6D28D9"}};exports.default=function(a){var o=a.deviationData,l=a.connectedSections,b=a.proposedSections,w=Array.from(l||[])[0],_=n.useMemo(function(){return function(e,r){var n;return"number"==typeof e?(null===(n=r[e])||void 0===n?void 0:n.nodeId)||"":e&&"string"==typeof e&&e.trim()?e.includes(u.DEVIATION_BADGE_SEPARATOR)?e.split(u.DEVIATION_BADGE_SEPARATOR)[0]:e.split("::")[0].split(":")[0]:""}(w,b||[])},[w,b]),g=n.useMemo(function(){if(!o||"object"!=typeof o)return[];return Object.entries(o).flatMap(function(e){var r=e[0];return function(e){var r=e&&"object"==typeof e?e.evaluation_result:null;return!r||"object"!=typeof r&&!Array.isArray(r)?[]:Array.isArray(r)?r.map(function(e,r){return{evalNode:e,evaluationKey:String(r)}}):"object"==typeof r?Object.entries(r).map(function(e){var r=e[0];return{evalNode:e[1],evaluationKey:r}}):[]}(e[1]).filter(v).map(function(e){var n,t,a,o=e.evalNode,i=e.evaluationKey;return{nodeId:r,evaluationKey:i,answerKey:f(r,i),evaluation:o,webSearchAnswer:o.web_search_answer,colorPalette:null!==(a=u.generateColorPalette((null===(t=null===(n=null==o?void 0:o.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===t?void 0:t.label_color)||""))&&void 0!==a?a:{border:y.arrow.color}}}).filter(function(e){var r=e.webSearchAnswer;return!!(null==r?void 0:r.enhanced_content)})}).map(function(r,n){return e.__assign(e.__assign({},r),{answerOrder:n})})},[o]),h=n.useMemo(function(){return g.reduce(function(e,r){var n,t=(null===(n=r.webSearchAnswer)||void 0===n?void 0:n.extraMetaData)||{};return Object.entries(t).forEach(function(n){var t=n[0],a=n[1],o=p(r.nodeId,r.evaluationKey,t);e[o]={nodeId:r.nodeId,evaluationKey:r.evaluationKey,answerKey:r.answerKey,answerOrder:r.answerOrder,reasoningId:t,evaluation:r.evaluation,webSearchAnswer:r.webSearchAnswer,extraMetaData:a}}),e},{})},[g]),x=n.useMemo(function(){return g.reduce(function(n,t){return n[t.answerKey]={a:function(n){var a=n.href,o=void 0===a?"":a,i=n.children,u=n.type,l=n.reason,s=e.__rest(n,["href","children","type","reason"]),c=null==s?void 0:s["data-cognitive-reasoning"],v=c?p(t.nodeId,t.evaluationKey,String(c)):"",f=v?h[v]:null;return r.jsx(d.default,{href:o,children:i,citationType:u,citationReason:l,metaData:{webGpt:f,webGptMetaKey:v},customStyle:y})}},n},{})},[g,h]);return r.jsx(t.Box,e.__assign({sx:e.__assign(e.__assign({padding:"12px 12px 12px 0px",backgroundColor:"#FFFFFF",borderRadius:"8px"},i.SHARED_MARKDOWN_STYLES),{overflow:"visible"})},{children:g.length>0?g.map(function(n,a){return r.jsx(t.Box,e.__assign({id:n.nodeId===_?"guideline-target-0":void 0,"data-web-gpt-node-id":n.nodeId,"data-web-gpt-evaluation-key":n.evaluationKey,"data-web-gpt-answer-order":n.answerOrder,"data-web-gpt-active":n.nodeId===_?"true":"false",sx:{mb:1.5,border:n.nodeId===_?"2px solid ".concat(n.colorPalette.border):"1px solid #d3d3d3",borderRadius:"6px",padding:"8px",backgroundColor:"#FFFFFF"}},{children:r.jsx(s.default,e.__assign({rehypePlugins:[c.default],components:x[n.answerKey]},{children:n.webSearchAnswer.enhanced_content}))}),n.answerKey)}):r.jsx(t.Typography,e.__assign({sx:{color:"#64748B",fontSize:"14px",py:1}},{children:"No web GPT data available."}))}))};
2
+ //# sourceMappingURL=WebGptPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebGptPanel.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){if("string"!=typeof t||""===t.trim())return null;try{var r="undefined"!=typeof window?window.location.origin:"http://localhost";return new URL(t,r)}catch(t){return null}},r=function(t,r){var e;if("string"!=typeof t||"string"!=typeof r||""===r.trim())return"";try{var n=t.match(new RegExp("\\b".concat(r,"\\s*=\\s*(['\"])(.*?)\\1"),"i"));return null!==(e=null==n?void 0:n[2])&&void 0!==e?e:""}catch(t){return""}},e=function(t){if("string"!=typeof t||""===t)return"";try{return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}catch(r){return t}},n=function(t,r,n){if("string"!=typeof t||""===t.trim())return t;if("string"!=typeof r||""===r.trim())return t;if(!n||"string"!=typeof n)return t;try{var a=e(n),i=new RegExp("\\b".concat(r,"\\s*=\\s*(['\"])(.*?)\\1"),"i");return i.test(t)?t.replace(i,function(){return"".concat(r,'="').concat(a,'"')}):t.replace(/<a\b/i,function(){return"<a ".concat(r,'="').concat(a,'"')})}catch(r){return t}};exports.mergeRulebookCitationsIntoMatchingLinks=function(a){if("string"!=typeof a||!a||!a.includes("rulebook_citation"))return a;try{var i=a;return Array.from(a.matchAll(/<a\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/a>/gi)).forEach(function(a){var c,o=a[0],u=a[1]||"",s=r(u,"type");if("rulebook_citation"===s){var l=r(u,"reason"),f=r(u,"href").replace(/&amp;/gi,"&"),p=t(f),h=null===(c=((null==p?void 0:p.searchParams.get("citationNumber"))||"").match(/^rb_(.+)$/))||void 0===c?void 0:c[1];if(h){var g={citation_type:(null==p?void 0:p.searchParams.get("citation_type"))||"",phrase_to_highlight:(null==p?void 0:p.searchParams.get("phrase_to_highlight"))||""};if(g.citation_type||g.phrase_to_highlight){var v=!1,y=function(r){var e=t(r.replace(/&amp;/gi,"&"));return(null==e?void 0:e.searchParams.get("citationNumber"))!==h?r:(v=!0,function(r,e){if("string"!=typeof r||""===r.trim())return r;if(!e||"object"!=typeof e)return r;try{var n=t(r);if(!n)return r;Object.entries(e).forEach(function(t){var r=t[0],e=t[1];e&&n.searchParams.set(r,e)});var a="".concat(n.pathname).concat(n.search).concat(n.hash);return r.startsWith("./")?".".concat(a):!r.startsWith("/")&&a.startsWith("/")?a.slice(1):a}catch(t){return r}}(r,g))};i=i.replace(/\[([^\]]+)\]\(([^)\n]+)\)/g,function(t,r,n){var a=y(n);return a===n?t:'<a type="'.concat(e(s),'" reason="').concat(e(l),'" href="').concat(e(a),'">').concat(r,"</a>")}),v||(i=i.replace(/<a\b((?:[^>"']|"[^"]*"|'[^']*')*)>/gi,function(t,e){if("rulebook_citation"===r(e,"type"))return t;var a=r(e,"href"),i=y(a);if(i===a)return t;var c=t.replace(/\bhref\s*=\s*(['"])(.*?)\1/i,function(t,r){return"href=".concat(r).concat(i).concat(r)});return n(n(c,"type",s),"reason",l)})),i=i.split(o).join("")}else i=i.split(o).join("")}else i=i.split(o).join("")}}),i}catch(t){return a}};
2
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.processGuidelinesMarkdown=function(e){var t,a,n=e.guidelinesData,o=e.targetHighlights,r=void 0===o?[]:o,i=e.labelColor,c=void 0===i?"#FEF08A":i,l=(null===(a=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.artifactData)||void 0===a?void 0:a.userStorySnapshot)||[],u="";return l.forEach(function(e){var t;e.title&&(u+="### ".concat(e.title,"\n\n")),e.value&&(u+="".concat(e.value,"\n\n")),null===(t=e.sub_features)||void 0===t||t.forEach(function(e){e.title&&(u+="#### ".concat(e.title,"\n\n")),e.value&&(u+="".concat(e.value,"\n\n"))})}),r.forEach(function(e,t){var a=e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),n=new RegExp("(".concat(a,")"),"g");u=u.replace(n,'<mark id="guideline-target-'.concat(t,'" style="background-color: ').concat(c,'; border-radius: 3px; padding: 2px;">$1</mark>'))}),u};
2
+ //# sourceMappingURL=processGuidelinesMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processGuidelinesMarkdown.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),s=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},o=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var a=t.onClose,c=t.onOpenCognitiveCompare,d=t.onOpenSideBySide,C=t.onConnect,x=t.isConnected,g=void 0!==x&&x,h=t.isOrphan,p=t.maintainRelativeOrder;return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:a,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:o.filter(function(e){return p||"side-by-side"!==e.key}).map(function(t){var o="connect"===t.key,r=o&&g,l=h&&("connect"===t.key||"side-by-side"===t.key),a=i.jsxs(i.Fragment,{children:[i.jsx(n.Box,e.__assign({sx:e.__assign(e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},l&&{opacity:.15}),r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsxs(n.Box,e.__assign({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:l?"#98A2B3":r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:o?g?"Disconnect":"Connect":t.title})),l&&i.jsx(n.Typography,e.__assign({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:"No counterpart exists to connect to."}))]})),r&&!l&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(s,{})}))]});return l?i.jsx(n.Box,e.__assign({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:a}),t.key):i.jsx(n.MenuItem,e.__assign({onClick:function(){return e=t.key,void(h&&("connect"===e||"side-by-side"===e)||("connect"!==e?"side-by-side"!==e?c():d():C()));var e},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:a}),t.key)})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),s=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},o=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var a=t.onClose,c=t.onOpenCognitiveCompare,d=t.onOpenSideBySide,C=t.onConnect,x=t.isConnected,h=void 0!==x&&x,g=t.isOrphan,p=void 0!==g&&g,u=t.maintainRelativeOrder,y=t.isGuidelineMode,f=t.hasGuidelineMatches,v=y?!(void 0===f||f):p,_=y?"No highlights found in guidelines.":"No counterpart exists to connect to.";return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:a,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:o.filter(function(e){return u||"side-by-side"!==e.key}).map(function(t){var o="connect"===t.key,r=o&&h,l=("connect"===t.key||"side-by-side"===t.key)&&v,a=i.jsxs(i.Fragment,{children:[i.jsx(n.Box,e.__assign({sx:e.__assign(e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},l&&{opacity:.15}),r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsxs(n.Box,e.__assign({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:l?"#98A2B3":r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:o?h?"Disconnect":"Connect":t.title})),l&&i.jsx(n.Typography,e.__assign({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:_}))]})),r&&!l&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(s,{})}))]});return l?i.jsx(n.Box,e.__assign({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:a}),t.key):i.jsx(n.MenuItem,e.__assign({onClick:function(){var e;("connect"===(e=t.key)||"side-by-side"===e)&&v||("connect"!==e?"side-by-side"!==e?c():d():C())},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:a}),t.key)})}))};
2
2
  //# sourceMappingURL=MoreFunctionsPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),o=require("react"),i=require("@mui/material"),t=require("lucide-react"),r=require("./SectionAccordion.js"),a=require("./ThreeDotsLoader.js"),l=require("./ScrollLockToggle.js"),d=require("../CompareContext.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(o).default.memo(function(o){var s,c,u,x=o.section,p=o.idx,g=d.useCompareContext(),v=g.maintainRelativeOrder;g.existingSections;var f=g.proposedSections,h=g.connectedSections,b=g.expandedSections,m=g.displayConfig,S=g.treeData;g.deviationNumberRegistry;var B=g.getSectionCompareStyle;g.getBadgeRef;var _=g.getSectionRowRef,j=g.sectionRightRefs,y=g.rhsBadgeRefs,R=g.openMoreFunctionsPopup,I=g.handleOpenSummaryPopup,w=g.handleCloseSummaryPopup,C=g.toggleSection;g.showDeviationBadges,g.renderSubSectionAccordion,g.isProposingFix,g.proposingFixNodeId,g.isRedlineFlow;var k=g.isSideBySide,T=g.activeSideBySideSection,q=g.scrollSyncLocked,P=g.toggleScrollSyncLocked,N=g.summaryPopupAnchorEl;g.deviationNodeIdToView,g.deviationTargetParentId;var D=g.showDeviationNavigation;g.showOpenNodeRef,g.resolvedMarkdownStyles;var z=g.unifiedNumbering,F=x,L=!1,O=null,A=-1;if(v){A=f.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(F.selfIndex))&&e.selfIndex>=0});var E=f.findIndex(function(e,n){var o;return h.has(n)&&(null===(o=e.refIndexes)||void 0===o?void 0:o.includes(F.selfIndex))});(L=-1!==E)&&(O=B(E,"left"))}else(L=h.has(p))&&(O=B(p,"right"));var M=v&&-1!==A?B(A,"left"):B(p,"right"),V=v?-1!==A||!(null===(s=F.refIndexes)||void 0===s?void 0:s.length)&&f.some(function(e){return e.id&&e.id===F.id}):Boolean(f[p]),W=v?F.selfIndex<0||!V:!f[p],K=z.rightNums.get(F.id),X=null===(c=y.current[p])||void 0===c?void 0:c.current,Y=L||k&&(T===p||T===A)||!!N&&N===X;return n.jsx(i.Box,e.__assign({ref:_(p),sx:{mb:1,width:"100%"}},{children:n.jsx(i.Box,e.__assign({ref:j.current[p],sx:e.__assign({width:"100%",display:"flex"},L&&O&&{borderRadius:"6px",outline:"2px solid ".concat(O.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(r.default,{section:x,idx:p,columnKey:"right",colRef:_("right-accordion-".concat(p)),mb:0,parentNodeId:(null===(u=null==S?void 0:S.input_index_map)||void 0===u?void 0:u[1])||"",isExpanded:v?!!b["right-".concat(p)]:!!b[String(p)],onToggle:function(){w(),C(p,"right")},navigation:x.id?D[x.id]:null}),v&&M&&n.jsx(i.Box,e.__assign({ref:y.current[p],"data-section-id":F.id,onClick:function(e){var n,o,i;if(W){var t=m.enableDeviationSchemaBackwardCompatibility?null!==(n=F.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(o=F.evaluationResult)||void 0===o?void 0:o[0])&&void 0!==i?i:null;I(e,String(p),W,t)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:W?"4px":"0px",fontSize:"11px",bgcolor:M.badgeBg,color:M.badgeText,border:"1px solid ".concat(M.badgeBorder),borderRadius:W?"12px":"10px",px:W?1.2:1,py:.3,fontWeight:W?600:700,cursor:W?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:W?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:W?n.jsxs(n.Fragment,{children:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,o,i;e.stopPropagation();var t=m.enableDeviationSchemaBackwardCompatibility?null!==(n=F.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(o=F.evaluationResult)||void 0===o?void 0:o[0])&&void 0!==i?i:null;I(e,String(p),W,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(M.badgeBorder),"&:hover":{bgcolor:"".concat(M.badgeBorder,"22")}}},{children:[null!=K&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(M.badgeBorder)}},{children:K})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!m.isLoading||null!=F.evaluationResult&&void 0!==F.evaluationResult?M.label?"".concat(M.label):"100% Deviation":n.jsx(a.default,{color:M.badgeText})}))]})),n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=v?f.find(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(F.selfIndex)})||{title:"",content:""}:f[p]||{title:"",content:""};R(e,n,W,F,p,M)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(M.badgeBorder,"22")}}},{children:[n.jsx(t.EllipsisVertical,{size:11,color:M.badgeText}),Y&&n.jsx(l.default,{locked:q,onToggle:P,color:M.badgeText,borderColor:M.badgeBorder,size:11})]}))]}):n.jsx(n.Fragment,{children:n.jsx(i.Box,e.__assign({component:"span",sx:{px:.2}},{children:null!=K?K:""}))})}))]}))}))}),"right-row-".concat(p))});exports.default=c;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("./SectionAccordion.js"),l=require("./ThreeDotsLoader.js"),a=require("./ScrollLockToggle.js"),s=require("../CognitiveComparehelpers.js"),d=require("../CompareContext.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(i),x=u.default.memo(function(i){var c,x,p=i.section,g=i.idx,f=d.useCompareContext(),v=f.maintainRelativeOrder;f.existingSections;var h=f.proposedSections,m=f.connectedSections,S=f.expandedSections,b=f.displayConfig,_=f.treeData;f.deviationNumberRegistry;var I=f.getSectionCompareStyle;f.getBadgeRef;var j=f.getSectionRowRef,B=f.sectionRightRefs,y=f.rhsBadgeRefs,R=f.openMoreFunctionsPopup,w=f.handleOpenSummaryPopup,C=f.handleCloseSummaryPopup,N=f.toggleSection;f.showDeviationBadges,f.renderSubSectionAccordion,f.isProposingFix,f.proposingFixNodeId,f.isRedlineFlow;var T=f.isSideBySide,k=f.activeSideBySideSection,q=f.scrollSyncLocked,M=f.toggleScrollSyncLocked;f.deviationNodeIdToView,f.deviationTargetParentId;var P=f.showDeviationNavigation;f.showOpenNodeRef,f.resolvedMarkdownStyles;var z=f.unifiedNumbering,D=p,A=!1,F=null,L=-1,O=function(e,n){return String(null!=e?e:"")===String(n)},E=-1;v?(E=h.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(D.selfIndex))&&e.selfIndex>=0}),L=h.findIndex(function(e,n){var i;return function(e){return m.has(e)||m.has(String(e))||null!=k&&!String(k).includes("::")&&O(k,e)}(n)&&(null===(i=e.refIndexes)||void 0===i?void 0:i.includes(D.selfIndex))}),(A=-1!==L)&&(F=I(L,"left"))):(A=m.has(g)||m.has(String(g))||O(k,g))&&(F=I(g,"right"));var U=v&&-1!==E?I(E,"left"):I(g,"right"),V=F||U,W=v?-1!==E||!(null===(c=D.refIndexes)||void 0===c?void 0:c.length)&&h.some(function(e){return e.id&&e.id===D.id}):Boolean(h[g]),H=v?D.selfIndex<0||!W:!h[g],K=u.default.useMemo(function(){var e=z.rightNums.get(D.id);return v&&D.id?s.getRhsMappedSectionNumber({section:D,proposedSections:h,leftNums:z.leftNums,fallbackNumber:e}):e},[v,h,D.id,D.selfIndex,z]),X=u.default.useMemo(function(){if(!v||null==D.selfIndex)return null!=K?[{label:String(K),title:D.title||"Untitled Section",lhsIdx:-1}]:[];var n=h.map(function(e,n){var i=Array.isArray(null==e?void 0:e.refIndexes)?e.refIndexes:[],t=i.findIndex(function(e){return e===D.selfIndex});if(-1===t)return null;var o=(null==e?void 0:e.id)?z.leftNums.get(e.id):void 0;return null==o?null:{label:i.length>1?"".concat(o).concat(s.getAlphabeticSuffix(t)):String(o),title:(null==e?void 0:e.title)||"Untitled Section",lhsIdx:n}}).filter(Boolean);return-1===L?n:e.__spreadArray([],n,!0).sort(function(e,n){return e.lhsIdx===L?-1:n.lhsIdx===L?1:0})},[v,h,D.selfIndex,D.title,K,z.leftNums,L]),Y=u.default.useMemo(function(){var e,n=null===(e=X[0])||void 0===e?void 0:e.label;if(!n)return null!=K?String(K):"";var i=X.length-1;return i>0?"".concat(n," + ").concat(i):n},[X,K]),G=u.default.useMemo(function(){return 0===X.length?"":X.map(function(e){return"".concat(e.label,": ").concat(e.title)}).join("\n")},[X]),J=A||T&&(O(k,g)||-1!==E&&O(k,E));return n.jsx(t.Box,e.__assign({ref:j(g),sx:{mb:1,width:"100%"}},{children:n.jsx(t.Box,e.__assign({ref:B.current[g],sx:e.__assign({width:"100%",display:"flex"},A&&F&&{borderRadius:"6px",outline:"2px solid ".concat(F.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(t.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(r.default,{section:p,idx:g,columnKey:"right",colRef:j("right-accordion-".concat(g)),mb:0,parentNodeId:(null===(x=null==_?void 0:_.input_index_map)||void 0===x?void 0:x[1])||"",isExpanded:v?!!S["right-".concat(g)]:!!S[String(g)],onToggle:function(){C(),N(g,"right")},navigation:p.id?P[p.id]:null}),v&&V&&n.jsx(t.Tooltip,e.__assign({title:G?n.jsx(t.Box,e.__assign({sx:{whiteSpace:"pre-line"}},{children:n.jsx(t.Typography,e.__assign({component:"span",sx:{fontSize:"11px",lineHeight:1.5}},{children:G}))})):"",placement:"top",arrow:!0},{children:n.jsx(t.Box,e.__assign({ref:y.current[g],"data-section-id":D.id,onClick:function(e){var n,i,t;if(H){var o=b.enableDeviationSchemaBackwardCompatibility?null!==(n=D.evaluationResult)&&void 0!==n?n:null:null!==(t=null===(i=D.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==t?t:null;w(e,String(g),H,o)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:H?"4px":"0px",fontSize:"11px",bgcolor:V.badgeBg,color:V.badgeText,border:"1px solid ".concat(V.badgeBorder),borderRadius:H?"12px":"10px",px:H?1.2:1,py:.3,fontWeight:H?600:700,cursor:H?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:H?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:H?n.jsxs(n.Fragment,{children:[n.jsxs(t.Box,e.__assign({component:"span",onClick:function(e){var n,i,t;e.stopPropagation();var o=b.enableDeviationSchemaBackwardCompatibility?null!==(n=D.evaluationResult)&&void 0!==n?n:null:null!==(t=null===(i=D.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==t?t:null;w(e,String(g),H,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(V.badgeBorder),"&:hover":{bgcolor:"".concat(V.badgeBorder,"22")}}},{children:[null!=K&&n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(V.badgeBorder)}},{children:K})),n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!b.isLoading||null!=D.evaluationResult&&void 0!==D.evaluationResult?V.label?"".concat(V.label):"100% Deviation":n.jsx(l.default,{color:V.badgeText})}))]})),n.jsxs(t.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=v?h.find(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(D.selfIndex)})||{title:"",content:""}:h[g]||{title:"",content:""};R(e,n,H,D,g,V)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(V.badgeBorder,"22")}}},{children:[n.jsx(o.EllipsisVertical,{size:11,color:V.badgeText}),J&&n.jsx(a.default,{locked:q,onToggle:M,color:V.badgeText,borderColor:V.badgeBorder,size:11})]}))]}):n.jsx(n.Fragment,{children:n.jsx(t.Box,e.__assign({component:"span",sx:{px:.2}},{children:Y}))})}))}))]}))}))}),"right-row-".concat(g))});exports.default=x;
2
2
  //# sourceMappingURL=RHSSectionRow.js.map