@viswa-test/test-citation 0.0.12 → 0.0.14
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.
|
@@ -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"),r=require("lucide-react"),o=require("react-dom"),s=require("../../assests/svg/SparkleIcon.js"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),a=require("react-markdown");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(i),u=c(o),x=c(a),g=function(e){return null==e?"":"string"==typeof e?e:Array.isArray(e)?e.map(g).join("\n\n"):"object"==typeof e?JSON.stringify(e):String(e)},p=function(e){return e?g(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(d.default.Fragment,{children:e},i)}):null},h=function(n,i,t,r){var o=100*(n||0),s=r.thresholds,l=r.relationStyles;if(!t)return null;var a=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(i),c=(i||"").toLowerCase();return c.includes("no_deviation")?e.__assign(e.__assign({},l.low),{label:a}):c.includes("deviation")||c.includes("high_risk")||c.includes("critical")?e.__assign(e.__assign({},l.high),{label:a}):o>=s.exact?e.__assign(e.__assign({},l.exact),{label:a}):o>=s.high?e.__assign(e.__assign({},l.high),{label:a}):o>=s.medium?e.__assign(e.__assign({},l.medium),{label:a}):e.__assign(e.__assign({},l.low),{label:a})},f=d.default.forwardRef(function(i,r){var o=i.label,s=i.content,l=i.highlights,a=void 0===l?[]:l,c=i.styleVariant,u=i.isHighlighted,x=void 0!==u&&u,h=Array.isArray(s)?s.map(g).join("\n"):g(s),f="#9F1239"===c.badgeText?{borderColor:"#E11D48",shadow:"rgba(225, 29, 72, 0.25)"}:"#B91C1C"===c.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#1D4ED8"===c.badgeText?{borderColor:"#3B82F6",shadow:"rgba(59, 130, 246, 0.25)"}:"#A16207"===c.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"};return n.jsxs(t.Box,e.__assign({sx:{mb:1.5}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:o})),n.jsx(t.Box,e.__assign({ref:r,sx:{p:"4px 12px",borderRadius:"6px",border:x?"1.5px solid ".concat(f.borderColor):"1px solid ".concat(c.border),boxShadow:x?"0px 0px 0px 2px ".concat(f.shadow):"none",bgcolor:c.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:n.jsx(t.Box,{children:function(){if(!h)return null;if(!a||0===a.length)return p(h);var i=a.filter(function(e){return e&&"string"==typeof e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===i.length)return p(h);var r=new RegExp("(".concat(i.join("|"),")"),"gi");return h.split(r).map(function(i,r){return a.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===i.toLowerCase()})?n.jsx(t.Box,e.__assign({component:"span",sx:{bgcolor:c.highlightBg,borderRadius:"2px",px:"2px"}},{children:p(i)}),r):n.jsx(d.default.Fragment,{children:p(i)},r)})}()})}))]}))}),v=10,_=function(o){var l,a,c,d,x,p,h,f=o.open,_=o.onClose,m=o.sectionTitle,b=o.referenceSectionTitle,y=o.cognitiveData,F=o.relevanceScore,w=o.anchorEl,B=o.badgeStyle,j=o.popupRef,E=o.position,S=i.useState("association"),C=S[0],D=S[1],k=i.useMemo(function(){if(!B)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=B.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[B]);if(i.useEffect(function(){if(f){var e=function(e){var n;(null===(n=j.current)||void 0===n?void 0:n.contains(e.target))||(null==w?void 0:w.contains(e.target))||_()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[f,_,w,j]),!f||!y)return null;var A=null!==(a=null!==(l=y.relevance_score)&&void 0!==l?l:F)&&void 0!==a?a:0,R=function(e){return e?e.split(/(?<=\.)(?:\s+(?=[A-Z])|\s+\d+\.\s)/).map(function(e){return e.trim()}).filter(function(e){return e.length>10}):[]},I=R(null!==(c=y.decisioning)&&void 0!==c?c:""),T=R(null!==(d=y.gap)&&void 0!==d?d:""),z=function(e){if(!e)return[];if(Array.isArray(e))return e.flatMap(function(e){if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e&&null!==e){var n=e,i={key:g(n.key),value:g(n.value),url:g(n.url)};return i.value||i.key||i.url?[i]:[]}return[]});if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e){var n=e;if("value"in n||"key"in n||"url"in n)return[{key:g(n.key),value:g(n.value),url:g(n.url)}]}return[]},W=function(e,n){var i,t,r=y,o="decisioning"===e?null!==(i=r.decisioning_metadata)&&void 0!==i?i:r.decisioningMetadata:null!==(t=r.gap_metadata)&&void 0!==t?t:r.gapMetadata;if(Array.isArray(o)){if((d=z(o[n])).length)return d;if((u=z(o)).length)return u}else{var s=z(o);if(s.length)return s}var l=r.metadata;if(l&&"object"==typeof l&&!Array.isArray(l)){var a=l,c="decisioning"===e?a.decisioning:a.gap;if(Array.isArray(c)){var d,u;if((d=z(c[n])).length)return d;if((u=z(c)).length)return u}else{var x=z(c);if(x.length)return x}}return[]},L=function(i){if(!i.length)return null;var o=i[0],s=o.key||"metadata",l=o.value||o.url||"",a=l?"".concat(s,": ").concat(l):s;return n.jsxs(t.Box,e.__assign({component:"span",sx:{display:"inline-flex",alignItems:"center",color:"#253AE4",fontWeight:600,ml:.5,whiteSpace:"nowrap"}},{children:["(",a,n.jsx(r.ChevronDown,{size:13,style:{marginLeft:2}}),")"]}))},H=null!==(x=null==E?void 0:E.arrowLeft)&&void 0!==x?x:60,M=n.jsxs(t.Box,e.__assign({ref:j,sx:{position:"fixed",top:null!==(p=null==E?void 0:E.top)&&void 0!==p?p:-9999,left:null!==(h=null==E?void 0:E.left)&&void 0!==h?h:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(k.border),boxShadow:"0px 8px 32px ".concat(k.shadow,", 0px 0px 0px 3px ").concat(k.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:"60vh",visibility:E?"visible":"hidden"}},{children:[E&&(E.openAbove?n.jsxs(n.Fragment,{children:[n.jsx(t.Box,{sx:{position:"absolute",bottom:-11,left:H-v,width:0,height:0,borderLeft:"".concat(v,"px solid transparent"),borderRight:"".concat(v,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(k.border),zIndex:1}}),n.jsx(t.Box,{sx:{position:"absolute",bottom:-9,left:H-v+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(v,"px solid #FFFFFF"),zIndex:2}})]}):n.jsxs(n.Fragment,{children:[n.jsx(t.Box,{sx:{position:"absolute",top:-11,left:H-v,width:0,height:0,borderLeft:"".concat(v,"px solid transparent"),borderRight:"".concat(v,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(k.border),zIndex:1}}),n.jsx(t.Box,{sx:{position:"absolute",top:-9,left:H-v+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(v,"px solid #FFFFFF"),zIndex:2}})]})),n.jsxs(t.Box,e.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[n.jsxs(t.Box,e.__assign({sx:{flex:1,minWidth:0}},{children:[n.jsxs(t.Typography,e.__assign({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[n.jsx(t.Box,e.__assign({component:"span",title:m,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:m})),n.jsx(t.Box,e.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),n.jsx(t.Box,e.__assign({component:"span",title:b||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:b||"Reference Section"}))]})),n.jsx(t.Box,e.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"Why this is a Deviation?"}))}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[n.jsxs(t.Box,e.__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:[n.jsx(s.default,{}),"Decision Strength ",A,"%"]})),n.jsx(t.IconButton,e.__assign({onClick:_,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:n.jsx(r.X,{size:22})}))]}))]})),n.jsx(t.Box,e.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(i){var r=C===i,o="deviation"===i?"Deviation Analysis":"Association Logic";return n.jsx(t.Box,e.__assign({onClick:function(){return D(i)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:r?600:400,color:r?"#5928ED":"#667085",backgroundColor:r?"rgba(89,40,237,0.08)":"transparent",borderBottom:r?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:o}),i)})})),n.jsx(t.Box,e.__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(k.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:k.border},scrollbarWidth:"thin",scrollbarColor:"".concat(k.border,"55 transparent")}},{children:"deviation"===C?n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):n.jsxs(n.Fragment,{children:[I.length>0&&n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[n.jsx(t.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),n.jsx(t.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:I.map(function(i,r){return n.jsxs(t.Typography,e.__assign({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[r+1,". ",i,L(W("decisioning",r))]}),r)})}))]})),T.length>0&&n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[n.jsx(t.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),n.jsx(t.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:T.map(function(i,r){return n.jsxs(t.Typography,e.__assign({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[r+1,". ",i,L(W("gap",r))]}),r)})}))]})),0===I.length&&0===T.length&&n.jsx(t.Box,e.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return u.default.createPortal(M,document.body)},m=function(i){var o=i.data,s=i.isSelected,a=i.isCognitiveOpen,c=i.onToggleCognitive,d=i.onClick,u=g(o.summaryText||o.description),x=u.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),p=x?u.replace(x[0],"").trim():u,h=!!x;return n.jsxs(t.Box,e.__assign({id:"variant-card-".concat(o.id),onClick:d,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:s?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:o.isLoading?.7:1,border:s?"1.4px solid #2563EB":void 0,boxShadow:s?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:s?"#2563EB":"#CBD5E1",boxShadow:s?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:o.isLoading?n.jsx(t.Skeleton,{variant:"rounded",width:80,height:20}):n.jsxs(t.Box,e.__assign({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==o.similarity?o.similarity:0,"% Similarity"]}))})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:g(o.title)}))})),o.isLoading?n.jsxs(t.Box,{children:[n.jsx(t.Skeleton,{width:"90%"}),n.jsx(t.Skeleton,{width:"60%"})]}):n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:p})),h&&n.jsxs(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),s||d(),c()},sx:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:12,style:{transform:s&&a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))},b=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],y={fields:b,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},F=function(e){return null!=e&&("string"==typeof e?e.trim().length>0:!Array.isArray(e)||e.length>0&&e.some(function(e){return F(e)}))},w=function(n){var i,t,r,o,s=[],l=[],a=n.base_root_id,c=n.input_index_map||{0:"left",1:"right"},d=n[a];if(!d||!1===d.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var u=function(e,n){var i,t=c[n],r=null===(i=null==e?void 0:e.comparison_inputs)||void 0===i?void 0:i[t];return{title:g((null==r?void 0:r.title)||""),content:g((null==r?void 0:r.content)||"")}};d.next&&Object.values(d.next).forEach(function(i){var t=n[i];if(t&&!1!==t.display_node){var r=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"not_defined"};var n=e.mapping_rationale,i=!n.decision_strength,t=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||"",gap:n.gaps_in_decision||"",relevance_score:t},score:i?100:t/100,relation:t>=70?"no_deviation":"deviation"}}(t),o=u(t,"0"),a=u(t,"1"),c=e.__assign({id:i,title:o.title,content:o.content,subsections:[]},r),d=e.__assign({id:i,title:a.title,content:a.content,subsections:[]},r);if(t.next)Object.values(t.next).forEach(function(e){var i=n[e];if(i&&!1!==i.display_node){var t=u(i,"0"),r=u(i,"1");t.content&&c.subsections.push(t.content),r.content&&d.subsections.push(r.content)}});s.push(c),l.push(d)}});return{activeProposed:{title:(null===(t=null===(i=d.comparison_inputs)||void 0===i?void 0:i[c[0]])||void 0===t?void 0:t.title)||"Uploaded Contract",description:d.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:(null===(o=null===(r=d.comparison_inputs)||void 0===r?void 0:r[c[1]])||void 0===o?void 0:o.title)||"Reference Template",similarity:s.length>0?Math.round(s.reduce(function(e,n){return e+(n.score||0)},0)/s.length*100):0,sections:l,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:d.decision_scope_description||""},fields:{}}}}]}};exports.DEFAULT_COMPARISON_CONFIG=y,exports.DEFAULT_FIELD_CONFIG=b,exports.default=function(o){var s,a,c,u=o.variants,B=void 0===u?[]:u,j=o.treeData,E=o.comparisonConfig,S=o.onSelectVariant,C=o.onSkip,D=o.onBack,k=o.targetVariantId,A=o.highlightedField;o.onBadgeClick,o.activeBadgeId;var R=i.useState(null),I=R[0],T=R[1],z=i.useMemo(function(){return(null==j?void 0:j.cognitive_decisioning)||{}},[j]),W=i.useRef(null),L=i.useState(null),H=L[0],M=L[1],O=i.useRef(null),P=i.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionId:""}),q=P[0],V=P[1],N=i.useRef(null),U=i.useRef(null),K=i.useRef(null),G=i.useRef(!1),Y=i.useCallback(function(){var e;if(q.anchorEl&&q.refSectionTitle){var n=q.anchorEl.getBoundingClientRect(),i=(null===(e=null==O?void 0:O.current)||void 0===e?void 0:e.offsetHeight)||0,t=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12,o=n.top-12,s=r<i&&o>r,l=s?n.top-12-i:n.bottom+12,a=n.left+n.width/2,c=a-t/2,d=Math.max(12,Math.min(c,window.innerWidth-t-12)),u=Math.max(14,Math.min(a-d,t-v-4));M({top:l,left:d,arrowLeft:u,openAbove:s})}},[q.anchorEl,q.refSectionTitle]);i.useEffect(function(){if(q.open){window.addEventListener("resize",Y);var e=requestAnimationFrame(Y);return function(){cancelAnimationFrame(e),window.removeEventListener("resize",Y)}}},[q.open,Y]),i.useEffect(function(){var n=U.current;if(n&&q.open){var i=function(n){console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),V(function(n){return e.__assign(e.__assign({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})})};return n.addEventListener("scroll",i,{capture:!0}),window.addEventListener("scroll",i,{capture:!0}),function(){n.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("scroll",i,{capture:!0})}}},[q.open]);var J=i.useMemo(function(){var n,i,t,r,o,s,l,a,c,d,u,x;return{fields:null!==(n=null==E?void 0:E.fields)&&void 0!==n?n:b,thresholds:{high:null!==(t=null===(i=null==E?void 0:E.thresholds)||void 0===i?void 0:i.high)&&void 0!==t?t:y.thresholds.high,medium:null!==(o=null===(r=null==E?void 0:E.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:y.thresholds.medium,exact:null!==(l=null===(s=null==E?void 0:E.thresholds)||void 0===s?void 0:s.exact)&&void 0!==l?l:y.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},y.relationStyles.noContent),(null===(a=null==E?void 0:E.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},y.relationStyles.high),(null===(c=null==E?void 0:E.relationStyles)||void 0===c?void 0:c.high)||{}),exact:e.__assign(e.__assign({},y.relationStyles.exact),(null===(d=null==E?void 0:E.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},y.relationStyles.medium),(null===(u=null==E?void 0:E.relationStyles)||void 0===u?void 0:u.medium)||{}),low:e.__assign(e.__assign({},y.relationStyles.low),(null===(x=null==E?void 0:E.relationStyles)||void 0===x?void 0:x.low)||{})}}},[E]),X=i.useMemo(function(){if(j&&Object.keys(j).length>0)try{var n=w(j);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:B||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:B||[],parseError:null}},[j,B]),$=X.activeProposed,Z=X.activeVariants,Q=X.parseError;i.useEffect(function(){Q&&T("Failed to load comparison: ".concat(Q))},[Q]);var ee=i.useState(k||null),ne=ee[0],ie=ee[1],te=i.useState(!1),re=te[0],oe=te[1],se=i.useState(null),le=se[0],ae=se[1],ce=i.useState({}),de=ce[0],ue=ce[1];i.useEffect(function(){if(k&&ie(k),ae(null!=A?A:null),A){var e=setTimeout(function(){return ae(null)},6e3);return function(){return clearTimeout(e)}}},[k,A]);var xe=function(e){var n;null===(n=N.current)||void 0===n||n.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},ge=i.useMemo(function(){return e.__spreadArray([],Z,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[Z]),pe=i.useMemo(function(){if(ne){var e=String(ne).trim();return Z.find(function(n){return n.id&&String(n.id).trim()===e})||ge[0]}return ge[0]||null},[ne,Z,ge]);i.useEffect(function(){ne&&N.current&&setTimeout(function(){var e=document.getElementById("variant-card-".concat(ne.trim())),n=N.current;if(e&&n){var i=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:i,behavior:"smooth"})}},150)},[ne,ge]);var he=pe||{id:"",title:""},fe=g($.title)||"Uploaded Contract",ve=g(he.title)||"Reference Template",_e=$.sections||[],me=he.sections||[],be=_e.length>0||me.length>0,ye=null==pe?void 0:pe.analysis,Fe=g(null===(a=null===(s=null==ye?void 0:ye.rule_difference_comparison)||void 0===s?void 0:s.summary)||void 0===a?void 0:a.overall_summary),we=!!Fe.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Be=null!==(c=null==pe?void 0:pe.similarity)&&void 0!==c?c:0,je=i.useRef({}),Ee=function(e){return je.current[e]||(je.current[e]=d.default.createRef()),je.current[e]};i.useEffect(function(){!ne&&!k&&ge.length>0&&!ge[0].isLoading&&ie(ge[0].id)},[ge,ne,k]);var Se=i.useRef(null),Ce=i.useRef(null),De=i.useRef(null),ke=i.useState([]),Ae=ke[0],Re=ke[1],Ie=i.useState(null),Te=Ie[0],ze=Ie[1],We=i.useState(!1),Le=We[0],He=We[1],Me=i.useState(!1),Oe=Me[0],Pe=Me[1];i.useEffect(function(){var e=N.current;if(e){var n=function(){He(e.scrollLeft>0),Pe(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[ge]);var qe=i.useMemo(function(){return J.fields.filter(function(e){var n=e.key;return(!be||"description"!==n)&&(F($[n])||F(he[n]))})},[$,he,be,J.fields]),Ve=i.useRef({}),Ne=i.useRef({}),Ue=i.useRef({}),Ke=i.useRef({});qe.forEach(function(e){var n=e.key;Ve.current[n]||(Ve.current[n]=d.default.createRef()),Ne.current[n]||(Ne.current[n]=d.default.createRef())});for(var Ge=0;Ge<Math.max(_e.length,me.length);Ge+=1)Ue.current[Ge]||(Ue.current[Ge]=d.default.createRef()),Ke.current[Ge]||(Ke.current[Ge]=d.default.createRef());i.useEffect(function(){if(le){var e=J.fields.find(function(e){return e.analysisKey===le||e.key===le});if(e){var n=Ve.current[e.key]||Ne.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[le,J.fields]);var Ye=function(e){var n,i,t,r,o,s,l,a,c,d=null===(n=null==ye?void 0:ye.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var u=d[e],x=(null==u?void 0:u.relation)||(null===(t=null===(i=null==u?void 0:u.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(o=null===(r=null==u?void 0:u.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==u?void 0:u.mappings)&&u.mappings.length>0;if(u.mappings){var g=u.mappings[0]||{};return{score:u.score,relation:g.relation||"",highlightsA:(null===(s=g.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(l=g.highlights)||void 0===l?void 0:l.ruleB_spans)||[],hasContent:!!x}}return{score:u.score,relation:u.relation||"",highlightsA:(null===(a=u.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=u.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!x}},Je=function(n){var i=me[n];if("not_defined"===(null==i?void 0:i.relation))return e.__assign(e.__assign({},J.relationStyles.noContent),{label:"Not Defined"});var t,r=Ye("description");if(null!=(null==i?void 0:i.cognitiveRelevanceScore)){var o=(t=i.cognitiveRelevanceScore)>=90?{score:1,relation:"exact_match"}:t>=70?{score:.8,relation:"high_match"}:t>=40?{score:.5,relation:"partial_match"}:{score:0,relation:"no_deviation"};return h(o.score,o.relation,!0,J)}var s=null!=(null==i?void 0:i.relation)&&""!==i.relation?i.relation:r.relation,l="number"==typeof(null==i?void 0:i.score)?i.score:r.score;return h(l,s,!0,J)},Xe=function(){var e,n,i;if(!G.current){G.current=!0;try{if(!Se.current)return;var t=Se.current.getBoundingClientRect(),r=[];qe.forEach(function(e){var n=e.key,i=e.analysisKey,o=Ve.current[n],s=Ne.current[n];if((null==o?void 0:o.current)&&(null==s?void 0:s.current)){o.current.style.height="auto",s.current.style.height="auto",o.current.style.minHeight="0px",s.current.style.minHeight="0px";var l=o.current.getBoundingClientRect().height,a=s.current.getBoundingClientRect().height,c=Math.max(l,a);o.current.style.minHeight="".concat(c,"px"),s.current.style.minHeight="".concat(c,"px");var d=o.current.getBoundingClientRect(),u=s.current.getBoundingClientRect(),x=Ye(i),g=h(x.score,x.relation,x.hasContent,J);if(!g)return;var p=d.top+d.height/2-t.top;r.push({id:"field-".concat(n),x1:d.right-t.left,y1:p,x2:u.left-t.left,y2:p,style:g})}});for(var o=Math.min(_e.length,me.length),s=0;s<o;s+=1){var l=Ue.current[s],a=Ke.current[s];if((null==l?void 0:l.current)&&(null==a?void 0:a.current)){l.current.style.height="auto",a.current.style.height="auto",l.current.style.minHeight="0px",a.current.style.minHeight="0px";var c=Math.max(l.current.getBoundingClientRect().height,a.current.getBoundingClientRect().height);l.current.style.minHeight="".concat(c,"px"),a.current.style.minHeight="".concat(c,"px");var d=l.current.querySelector(".MuiAccordionSummary-root"),u=a.current.querySelector(".MuiAccordionSummary-root");if(d&&u){var x=d.getBoundingClientRect(),g=u.getBoundingClientRect(),p=(x.top+x.height/2-t.top+g.top+g.height/2-t.top)/2,f=(null===(e=me[s])||void 0===e?void 0:e.id)||"sec-".concat(s),v=Je(s);v&&r.push({id:f,x1:x.right-t.left,y1:p,x2:g.left-t.left,y2:p,style:v,sectionIdx:s,hasCognitive:!(!(null===(n=_e[s])||void 0===n?void 0:n.cognitiveData)&&!(null===(i=me[s])||void 0===i?void 0:i.cognitiveData))})}}}if(Re(r),Ce.current&&De.current){var _=Ce.current.getBoundingClientRect(),m=De.current.getBoundingClientRect(),b=(_.top+_.height/2-t.top+m.top+m.height/2-t.top)/2;ze({x1:_.right-t.left,x2:m.left-t.left,y:b})}else ze(null)}catch(e){console.error("Line render safe fail: ",e)}finally{G.current=!1}}};i.useEffect(function(){var e=setTimeout(Xe,250);window.addEventListener("resize",Xe);var n=null;return U.current&&(n=new ResizeObserver(function(){return window.requestAnimationFrame(Xe)})).observe(U.current),function(){clearTimeout(e),window.removeEventListener("resize",Xe),null==n||n.disconnect()}},[$,he,ye,re,qe,de,_e,me,J]);var $e={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul, & ol":{mt:0,mb:1.5,pl:2.5},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}},Ze=function(i,o,s,l){return n.jsx(t.Box,e.__assign({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:n.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!!de[o],onChange:function(){return n=o,void ue(function(i){var t;return e.__assign(e.__assign({},i),((t={})[n]=!i[n],t))});var n},sx:{boxShadow:"none",border:"1px solid #E2E8F0",bgcolor:"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,"& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#19213D",fontWeight:500,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:p(i.title||"Section ".concat(o+1))}))})),n.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:$e},{children:n.jsx(x.default,{children:g(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(i,r){return n.jsx(t.Box,e.__assign({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:$e},{children:n.jsx(x.default,{children:g(i).replace(/\\n/g,"\n")})}))}),"".concat(s,"-sub-").concat(o,"-").concat(r))})]}))]}))}),"".concat(s,"-sec-").concat(o))};return n.jsxs(t.Box,e.__assign({ref:K,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[q.open&&n.jsx(_,{open:q.open,popupRef:O,position:H,onClose:function(){return V(function(n){return e.__assign(e.__assign({},n),{open:!1})})},sectionTitle:q.sectionTitle,referenceSectionTitle:q.refSectionTitle,cognitiveData:q.cognitiveData,anchorEl:q.anchorEl,sectionAnchorEl:q.sectionAnchorEl,scrollContainerEl:U.current,badgeStyle:q.badgeStyle}),n.jsx(t.Snackbar,e.__assign({open:!!I,autoHideDuration:8e3,onClose:function(){return T(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return T(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:I}))})),n.jsxs(t.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:[n.jsx(t.IconButton,e.__assign({onClick:D,size:"small"},{children:n.jsx(r.ArrowLeft,{})})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:"Learning Comparison"}))]})),n.jsx(t.IconButton,e.__assign({onClick:C,size:"small"},{children:n.jsx(t.Box,e.__assign({sx:{fontSize:24,lineHeight:.5}},{children:"×"}))}))]})),ge.length>1&&n.jsxs(t.Box,e.__assign({sx:{px:3,pb:.25},ref:W},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[n.jsx(t.IconButton,e.__assign({onClick:function(){return xe("left")},size:"small",disabled:!Le},{children:n.jsx(r.ArrowLeft,{size:18})})),n.jsx(t.IconButton,e.__assign({onClick:function(){return xe("right")},size:"small",disabled:!Oe},{children:n.jsx(r.ArrowRight,{size:18})}))]}))]})),n.jsx(t.Box,e.__assign({ref:N,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"}}},{children:ge.map(function(e){return n.jsx(m,{data:e,isSelected:(null==pe?void 0:pe.id)===e.id,isCognitiveOpen:re,onToggleCognitive:function(){return oe(function(e){return!e})},onClick:function(){return ie((n=e).id),S(n),void oe(!1);var n}},e.id)})}))]})),n.jsx(t.Box,e.__assign({ref:U,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:Fe&&we&&re?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:n.jsxs(t.Box,e.__assign({ref:Se,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[Te&&n.jsxs("g",{children:[n.jsx("line",{x1:Te.x1,y1:Te.y,x2:Math.max(Te.x1,(Te.x1+Te.x2)/2-70),y2:Te.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(Te.x2,(Te.x1+Te.x2)/2+70),y1:Te.y,x2:Te.x2,y2:Te.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Ae.map(function(i,o){var s=(i.x1+i.x2)/2;return i.id||"line-".concat(o),"Not Defined"===i.style.label?null:n.jsxs("g",{children:[n.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder,strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-75,y:i.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"},onClick:function(e){e.stopPropagation(),function(e,n,i,t,r){var o,s;e.stopPropagation();var l=g(n.id)||g(i.id)||"",a=(l?z[l]:null)||n.cognitiveData||i.cognitiveData||null,c=null!==(s=null===(o=je.current[t])||void 0===o?void 0:o.current)&&void 0!==s?s:null;V({open:!0,sectionTitle:n.title||"Section",refSectionTitle:i.title||"Reference Section",cognitiveData:a,anchorEl:e.currentTarget,sectionAnchorEl:c,badgeStyle:r||null,sectionId:l})}(e,_e[i.sectionIdx]||{title:"",content:""},me[i.sectionIdx]||{title:"",content:""},i.sectionIdx,i.style)}},{children:[i.style.label,i.hasCognitive&&void 0!==i.sectionIdx&&n.jsx(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",px:"4px",ml:"2px",color:i.style.badgeText,transition:"background 0.15s","&:hover":{backgroundColor:"rgba(0,0,0,0.05)"}}},{children:n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:n.jsx(l.ButtonCognitiveIcon,{})}))})),parseInt(i.sectionIdx)===parseInt(q.sectionId)?n.jsx(r.ChevronUp,{size:12,color:i.style.badgeText}):n.jsx(r.ChevronDown,{size:12,color:i.style.badgeText})]}))}))}))]},o)})]})),n.jsxs(t.Box,e.__assign({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:Ce,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:fe}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[qe.map(function(e){var i=e.key,t=e.label,r=e.analysisKey,o=Ye(r),s=$[i],l=he[i];if(!F(s)&&!F(l))return null;var a=h(o.score,o.relation,o.hasContent,J);return a?n.jsx(f,{ref:Ve.current[i],label:t,content:s,highlights:o.highlightsA,styleVariant:a,isHighlighted:le===r||le===i},"left-".concat(i)):null}),be&&_e.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return F(n.title)||F(n.content)||(n.subsections||[]).some(F)}).map(function(i){var r=i.section,o=i.idx;return n.jsx(t.Box,e.__assign({ref:Ee(o)},{children:Ze(r,o,"left",Ue.current[o]||d.default.createRef())}),"left-row-".concat(o))})]}))]})),n.jsx(t.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[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(l.ButtonCognitiveIcon,{})})),Be,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),n.jsxs(t.Box,e.__assign({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:De,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:ve}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[qe.map(function(e){var i=e.key,t=e.label,r=e.analysisKey,o=Ye(r),s=$[i],l=he[i];if(!F(s)&&!F(l))return null;var a=h(o.score,o.relation,o.hasContent,J);return a?n.jsx(f,{ref:Ne.current[i],label:t,content:l,highlights:o.highlightsB,styleVariant:a,isHighlighted:le===r||le===i},"right-".concat(i)):null}),be&&me.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return F(n.title)||F(n.content)||(n.subsections||[]).some(F)}).map(function(e){var n=e.section,i=e.idx;return Ze(n,i,"right",Ke.current[i]||d.default.createRef())})]}))]}))]}))}))}))]}))};
|
|
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"),r=require("lucide-react"),o=require("react-dom"),s=require("../../assests/svg/SparkleIcon.js"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),a=require("react-markdown");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(i),u=c(o),x=c(a),g=function(e){return null==e?"":"string"==typeof e?e:Array.isArray(e)?e.map(g).join("\n\n"):"object"==typeof e?JSON.stringify(e):String(e)},p=function(e){return e?g(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(d.default.Fragment,{children:e},i)}):null},h=function(n,i,t,r){var o=100*(n||0),s=r.thresholds,l=r.relationStyles;if(!t)return null;var a=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(i),c=(i||"").toLowerCase();return c.includes("no_deviation")?e.__assign(e.__assign({},l.low),{label:a}):c.includes("deviation")||c.includes("high_risk")||c.includes("critical")?e.__assign(e.__assign({},l.high),{label:a}):o>=s.exact?e.__assign(e.__assign({},l.exact),{label:a}):o>=s.high?e.__assign(e.__assign({},l.high),{label:a}):o>=s.medium?e.__assign(e.__assign({},l.medium),{label:a}):e.__assign(e.__assign({},l.low),{label:a})},f=d.default.forwardRef(function(i,r){var o=i.label,s=i.content,l=i.highlights,a=void 0===l?[]:l,c=i.styleVariant,u=i.isHighlighted,x=void 0!==u&&u,h=Array.isArray(s)?s.map(g).join("\n"):g(s),f="#9F1239"===c.badgeText?{borderColor:"#E11D48",shadow:"rgba(225, 29, 72, 0.25)"}:"#B91C1C"===c.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#1D4ED8"===c.badgeText?{borderColor:"#3B82F6",shadow:"rgba(59, 130, 246, 0.25)"}:"#A16207"===c.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"};return n.jsxs(t.Box,e.__assign({sx:{mb:1.5}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:o})),n.jsx(t.Box,e.__assign({ref:r,sx:{p:"4px 12px",borderRadius:"6px",border:x?"1.5px solid ".concat(f.borderColor):"1px solid ".concat(c.border),boxShadow:x?"0px 0px 0px 2px ".concat(f.shadow):"none",bgcolor:c.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:n.jsx(t.Box,{children:function(){if(!h)return null;if(!a||0===a.length)return p(h);var i=a.filter(function(e){return e&&"string"==typeof e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===i.length)return p(h);var r=new RegExp("(".concat(i.join("|"),")"),"gi");return h.split(r).map(function(i,r){return a.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===i.toLowerCase()})?n.jsx(t.Box,e.__assign({component:"span",sx:{bgcolor:c.highlightBg,borderRadius:"2px",px:"2px"}},{children:p(i)}),r):n.jsx(d.default.Fragment,{children:p(i)},r)})}()})}))]}))}),v=10,_=function(o){var l,a,c,d,x,p,h,f=o.open,_=o.onClose,m=o.sectionTitle,b=o.referenceSectionTitle,y=o.cognitiveData,F=o.relevanceScore,w=o.anchorEl,B=o.badgeStyle,j=o.popupRef,E=o.position,S=i.useState("association"),C=S[0],D=S[1],k=i.useMemo(function(){if(!B)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=B.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[B]);if(i.useEffect(function(){if(f){var e=function(e){var n;(null===(n=j.current)||void 0===n?void 0:n.contains(e.target))||(null==w?void 0:w.contains(e.target))||_()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[f,_,w,j]),!f||!y)return null;var A=null!==(a=null!==(l=y.relevance_score)&&void 0!==l?l:F)&&void 0!==a?a:0,R=function(e){return e?e.split(/(?<=\.)(?:\s+(?=[A-Z])|\s+\d+\.\s)/).map(function(e){return e.trim()}).filter(function(e){return e.length>10}):[]},T=R(null!==(c=y.decisioning)&&void 0!==c?c:""),I=R(null!==(d=y.gap)&&void 0!==d?d:""),z=function(e){if(!e)return[];if(Array.isArray(e))return e.flatMap(function(e){if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e&&null!==e){var n=e,i={key:g(n.key),value:g(n.value),url:g(n.url)};return i.value||i.key||i.url?[i]:[]}return[]});if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e){var n=e;if("value"in n||"key"in n||"url"in n)return[{key:g(n.key),value:g(n.value),url:g(n.url)}]}return[]},W=function(e,n){var i,t,r=y,o="decisioning"===e?null!==(i=r.decisioning_metadata)&&void 0!==i?i:r.decisioningMetadata:null!==(t=r.gap_metadata)&&void 0!==t?t:r.gapMetadata;if(Array.isArray(o)){if((d=z(o[n])).length)return d;if((u=z(o)).length)return u}else{var s=z(o);if(s.length)return s}var l=r.metadata;if(l&&"object"==typeof l&&!Array.isArray(l)){var a=l,c="decisioning"===e?a.decisioning:a.gap;if(Array.isArray(c)){var d,u;if((d=z(c[n])).length)return d;if((u=z(c)).length)return u}else{var x=z(c);if(x.length)return x}}return[]},L=function(i){if(!i.length)return null;var o=i[0],s=o.key||"metadata",l=o.value||o.url||"",a=l?"".concat(s,": ").concat(l):s;return n.jsxs(t.Box,e.__assign({component:"span",sx:{display:"inline-flex",alignItems:"center",color:"#253AE4",fontWeight:600,ml:.5,whiteSpace:"nowrap"}},{children:["(",a,n.jsx(r.ChevronDown,{size:13,style:{marginLeft:2}}),")"]}))},H=null!==(x=null==E?void 0:E.arrowLeft)&&void 0!==x?x:60,M=n.jsxs(t.Box,e.__assign({ref:j,sx:{position:"fixed",top:null!==(p=null==E?void 0:E.top)&&void 0!==p?p:-9999,left:null!==(h=null==E?void 0:E.left)&&void 0!==h?h:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(k.border),boxShadow:"0px 8px 32px ".concat(k.shadow,", 0px 0px 0px 3px ").concat(k.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:"60vh",visibility:E?"visible":"hidden"}},{children:[E&&(E.openAbove?n.jsxs(n.Fragment,{children:[n.jsx(t.Box,{sx:{position:"absolute",bottom:-11,left:H-v,width:0,height:0,borderLeft:"".concat(v,"px solid transparent"),borderRight:"".concat(v,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(k.border),zIndex:1}}),n.jsx(t.Box,{sx:{position:"absolute",bottom:-9,left:H-v+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(v,"px solid #FFFFFF"),zIndex:2}})]}):n.jsxs(n.Fragment,{children:[n.jsx(t.Box,{sx:{position:"absolute",top:-11,left:H-v,width:0,height:0,borderLeft:"".concat(v,"px solid transparent"),borderRight:"".concat(v,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(k.border),zIndex:1}}),n.jsx(t.Box,{sx:{position:"absolute",top:-9,left:H-v+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(v,"px solid #FFFFFF"),zIndex:2}})]})),n.jsxs(t.Box,e.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[n.jsxs(t.Box,e.__assign({sx:{flex:1,minWidth:0}},{children:[n.jsxs(t.Typography,e.__assign({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[n.jsx(t.Box,e.__assign({component:"span",title:m,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:m})),n.jsx(t.Box,e.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),n.jsx(t.Box,e.__assign({component:"span",title:b||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:b||"Reference Section"}))]})),n.jsx(t.Box,e.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"Why this is a Deviation?"}))}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[n.jsxs(t.Box,e.__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:[n.jsx(s.default,{}),"Decision Strength ",A,"%"]})),n.jsx(t.IconButton,e.__assign({onClick:_,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:n.jsx(r.X,{size:22})}))]}))]})),n.jsx(t.Box,e.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(i){var r=C===i,o="deviation"===i?"Deviation Analysis":"Association Logic";return n.jsx(t.Box,e.__assign({onClick:function(){return D(i)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:r?600:400,color:r?"#5928ED":"#667085",backgroundColor:r?"rgba(89,40,237,0.08)":"transparent",borderBottom:r?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:o}),i)})})),n.jsx(t.Box,e.__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(k.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:k.border},scrollbarWidth:"thin",scrollbarColor:"".concat(k.border,"55 transparent")}},{children:"deviation"===C?n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):n.jsxs(n.Fragment,{children:[T.length>0&&n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[n.jsx(t.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),n.jsx(t.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:T.map(function(i,r){return n.jsxs(t.Typography,e.__assign({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[r+1,". ",i,L(W("decisioning",r))]}),r)})}))]})),I.length>0&&n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[n.jsx(t.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),n.jsx(t.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:I.map(function(i,r){return n.jsxs(t.Typography,e.__assign({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[r+1,". ",i,L(W("gap",r))]}),r)})}))]})),0===T.length&&0===I.length&&n.jsx(t.Box,e.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return u.default.createPortal(M,document.body)},m=function(i){var o=i.data,s=i.isSelected,a=i.isCognitiveOpen,c=i.onToggleCognitive,d=i.onClick,u=g(o.summaryText||o.description),x=u.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),p=x?u.replace(x[0],"").trim():u,h=!!x;return n.jsxs(t.Box,e.__assign({id:"variant-card-".concat(o.id),onClick:d,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:s?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:o.isLoading?.7:1,border:s?"1.4px solid #2563EB":void 0,boxShadow:s?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:s?"#2563EB":"#CBD5E1",boxShadow:s?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:o.isLoading?n.jsx(t.Skeleton,{variant:"rounded",width:80,height:20}):n.jsxs(t.Box,e.__assign({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==o.similarity?o.similarity:0,"% Similarity"]}))})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:g(o.title)}))})),o.isLoading?n.jsxs(t.Box,{children:[n.jsx(t.Skeleton,{width:"90%"}),n.jsx(t.Skeleton,{width:"60%"})]}):n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:p})),h&&n.jsxs(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),s||d(),c()},sx:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:12,style:{transform:s&&a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))},b=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],y={fields:b,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},F=function(e){return null!=e&&("string"==typeof e?e.trim().length>0:!Array.isArray(e)||e.length>0&&e.some(function(e){return F(e)}))},w=function(n){var i,t,r,o,s=[],l=[],a=n.base_root_id,c=n.input_index_map||{0:"left",1:"right"},d=n[a];if(!d||!1===d.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var u=function(e,n){var i,t=c[n],r=null===(i=null==e?void 0:e.comparison_inputs)||void 0===i?void 0:i[t];return{title:g((null==r?void 0:r.title)||""),content:g((null==r?void 0:r.content)||"")}};d.next&&Object.values(d.next).forEach(function(i){var t=n[i];if(t&&!1!==t.display_node){var r=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"not_defined"};var n=e.mapping_rationale,i=!n.decision_strength,t=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||"",gap:n.gaps_in_decision||"",relevance_score:t},score:i?100:t/100,relation:t>=70?"no_deviation":"deviation"}}(t),o=u(t,"0"),a=u(t,"1"),c=e.__assign({id:i,title:o.title,content:o.content,subsections:[]},r),d=e.__assign({id:i,title:a.title,content:a.content,subsections:[]},r);if(t.next)Object.values(t.next).forEach(function(e){var i=n[e];if(i&&!1!==i.display_node){var t=u(i,"0"),r=u(i,"1");t.content&&c.subsections.push(t.content),r.content&&d.subsections.push(r.content)}});s.push(c),l.push(d)}});return{activeProposed:{title:(null===(t=null===(i=d.comparison_inputs)||void 0===i?void 0:i[c[0]])||void 0===t?void 0:t.title)||"Uploaded Contract",description:d.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:(null===(o=null===(r=d.comparison_inputs)||void 0===r?void 0:r[c[1]])||void 0===o?void 0:o.title)||"Reference Template",similarity:0,sections:l,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:d.decision_scope_description||""},fields:{}}}}]}};exports.DEFAULT_COMPARISON_CONFIG=y,exports.DEFAULT_FIELD_CONFIG=b,exports.default=function(o){var s,a,c,u=o.variants,B=void 0===u?[]:u,j=o.treeData,E=o.comparisonConfig,S=o.onSelectVariant;o.onSkip,o.onBack;var C=o.targetVariantId,D=o.highlightedField;o.onBadgeClick,o.activeBadgeId;var k=i.useState(null),A=k[0],R=k[1],T=i.useMemo(function(){return(null==j?void 0:j.cognitive_decisioning)||{}},[j]),I=i.useRef(null),z=i.useState(null),W=z[0],L=z[1],H=i.useRef(null),M=i.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null}),O=M[0],P=M[1],q=i.useRef(null),V=i.useRef(null),N=i.useRef(null),U=i.useRef(!1),K=i.useCallback(function(){var e;if(O.anchorEl&&O.refSectionTitle){var n=O.anchorEl.getBoundingClientRect(),i=(null===(e=null==H?void 0:H.current)||void 0===e?void 0:e.offsetHeight)||0,t=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12,o=n.top-12,s=r<i&&o>r,l=s?n.top-12-i:n.bottom+12,a=n.left+n.width/2,c=a-t/2,d=Math.max(12,Math.min(c,window.innerWidth-t-12)),u=Math.max(14,Math.min(a-d,t-v-4));L({top:l,left:d,arrowLeft:u,openAbove:s})}},[O.anchorEl,O.refSectionTitle]);i.useEffect(function(){if(O.open){window.addEventListener("resize",K);var e=requestAnimationFrame(K);return function(){cancelAnimationFrame(e),window.removeEventListener("resize",K)}}},[O.open,K]),i.useEffect(function(){var n=V.current;if(n&&O.open){var i=function(n){console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),P(function(n){return e.__assign(e.__assign({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})})};return n.addEventListener("scroll",i,{capture:!0}),window.addEventListener("scroll",i,{capture:!0}),function(){n.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("scroll",i,{capture:!0})}}},[O.open]);var G=i.useMemo(function(){var n,i,t,r,o,s,l,a,c,d,u,x;return{fields:null!==(n=null==E?void 0:E.fields)&&void 0!==n?n:b,thresholds:{high:null!==(t=null===(i=null==E?void 0:E.thresholds)||void 0===i?void 0:i.high)&&void 0!==t?t:y.thresholds.high,medium:null!==(o=null===(r=null==E?void 0:E.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:y.thresholds.medium,exact:null!==(l=null===(s=null==E?void 0:E.thresholds)||void 0===s?void 0:s.exact)&&void 0!==l?l:y.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},y.relationStyles.noContent),(null===(a=null==E?void 0:E.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},y.relationStyles.high),(null===(c=null==E?void 0:E.relationStyles)||void 0===c?void 0:c.high)||{}),exact:e.__assign(e.__assign({},y.relationStyles.exact),(null===(d=null==E?void 0:E.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},y.relationStyles.medium),(null===(u=null==E?void 0:E.relationStyles)||void 0===u?void 0:u.medium)||{}),low:e.__assign(e.__assign({},y.relationStyles.low),(null===(x=null==E?void 0:E.relationStyles)||void 0===x?void 0:x.low)||{})}}},[E]),Y=i.useMemo(function(){if(j&&Object.keys(j).length>0)try{var n=w(j);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:B||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:B||[],parseError:null}},[j,B]),J=Y.activeProposed,X=Y.activeVariants,$=Y.parseError;i.useEffect(function(){$&&R("Failed to load comparison: ".concat($))},[$]);var Z=i.useState(C||null),Q=Z[0],ee=Z[1],ne=i.useState(!1),ie=ne[0],te=ne[1],re=i.useState(null),oe=re[0],se=re[1],le=i.useState({}),ae=le[0],ce=le[1];i.useEffect(function(){if(C&&ee(C),se(null!=D?D:null),D){var e=setTimeout(function(){return se(null)},6e3);return function(){return clearTimeout(e)}}},[C,D]);var de=function(e){var n;null===(n=q.current)||void 0===n||n.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},ue=i.useMemo(function(){return e.__spreadArray([],X,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[X]),xe=i.useMemo(function(){if(Q){var e=String(Q).trim();return X.find(function(n){return n.id&&String(n.id).trim()===e})||ue[0]}return ue[0]||null},[Q,X,ue]);i.useEffect(function(){Q&&q.current&&setTimeout(function(){var e=document.getElementById("variant-card-".concat(Q.trim())),n=q.current;if(e&&n){var i=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:i,behavior:"smooth"})}},150)},[Q,ue]);var ge=xe||{id:"",title:""},pe=g(J.title)||"Uploaded Contract",he=g(ge.title)||"Reference Template",fe=J.sections||[],ve=ge.sections||[],_e=fe.length>0||ve.length>0,me=null==xe?void 0:xe.analysis,be=g(null===(a=null===(s=null==me?void 0:me.rule_difference_comparison)||void 0===s?void 0:s.summary)||void 0===a?void 0:a.overall_summary),ye=!!be.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Fe=null!==(c=null==xe?void 0:xe.similarity)&&void 0!==c?c:0,we=i.useRef({}),Be=function(e){return we.current[e]||(we.current[e]=d.default.createRef()),we.current[e]};i.useEffect(function(){!Q&&!C&&ue.length>0&&!ue[0].isLoading&&ee(ue[0].id)},[ue,Q,C]);var je=i.useRef(null),Ee=i.useRef(null),Se=i.useRef(null),Ce=i.useState([]),De=Ce[0],ke=Ce[1],Ae=i.useState(null),Re=Ae[0],Te=Ae[1],Ie=i.useState(!1),ze=Ie[0],We=Ie[1],Le=i.useState(!1),He=Le[0],Me=Le[1];i.useEffect(function(){var e=q.current;if(e){var n=function(){We(e.scrollLeft>0),Me(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[ue]);var Oe=i.useMemo(function(){return G.fields.filter(function(e){var n=e.key;return(!_e||"description"!==n)&&(F(J[n])||F(ge[n]))})},[J,ge,_e,G.fields]),Pe=i.useRef({}),qe=i.useRef({}),Ve=i.useRef({}),Ne=i.useRef({});Oe.forEach(function(e){var n=e.key;Pe.current[n]||(Pe.current[n]=d.default.createRef()),qe.current[n]||(qe.current[n]=d.default.createRef())});for(var Ue=0;Ue<Math.max(fe.length,ve.length);Ue+=1)Ve.current[Ue]||(Ve.current[Ue]=d.default.createRef()),Ne.current[Ue]||(Ne.current[Ue]=d.default.createRef());i.useEffect(function(){if(oe){var e=G.fields.find(function(e){return e.analysisKey===oe||e.key===oe});if(e){var n=Pe.current[e.key]||qe.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[oe,G.fields]);var Ke=function(e){var n,i,t,r,o,s,l,a,c,d=null===(n=null==me?void 0:me.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var u=d[e],x=(null==u?void 0:u.relation)||(null===(t=null===(i=null==u?void 0:u.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(o=null===(r=null==u?void 0:u.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==u?void 0:u.mappings)&&u.mappings.length>0;if(u.mappings){var g=u.mappings[0]||{};return{score:u.score,relation:g.relation||"",highlightsA:(null===(s=g.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(l=g.highlights)||void 0===l?void 0:l.ruleB_spans)||[],hasContent:!!x}}return{score:u.score,relation:u.relation||"",highlightsA:(null===(a=u.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=u.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!x}},Ge=function(n){var i=ve[n];if("not_defined"===(null==i?void 0:i.relation))return e.__assign(e.__assign({},G.relationStyles.noContent),{label:"Not Defined"});var t,r=Ke("description");if(null!=(null==i?void 0:i.cognitiveRelevanceScore)){var o=(t=i.cognitiveRelevanceScore)>=90?{score:1,relation:"exact_match"}:t>=70?{score:.8,relation:"high_match"}:t>=40?{score:.5,relation:"partial_match"}:{score:0,relation:"no_deviation"};return h(o.score,o.relation,!0,G)}var s=null!=(null==i?void 0:i.relation)&&""!==i.relation?i.relation:r.relation,l="number"==typeof(null==i?void 0:i.score)?i.score:r.score;return h(l,s,!0,G)},Ye=function(){var e,n,i;if(!U.current){U.current=!0;try{if(!je.current)return;var t=je.current.getBoundingClientRect(),r=[];Oe.forEach(function(e){var n=e.key,i=e.analysisKey,o=Pe.current[n],s=qe.current[n];if((null==o?void 0:o.current)&&(null==s?void 0:s.current)){o.current.style.height="auto",s.current.style.height="auto",o.current.style.minHeight="0px",s.current.style.minHeight="0px";var l=o.current.getBoundingClientRect().height,a=s.current.getBoundingClientRect().height,c=Math.max(l,a);o.current.style.minHeight="".concat(c,"px"),s.current.style.minHeight="".concat(c,"px");var d=o.current.getBoundingClientRect(),u=s.current.getBoundingClientRect(),x=Ke(i),g=h(x.score,x.relation,x.hasContent,G);if(!g)return;var p=d.top+d.height/2-t.top;r.push({id:"field-".concat(n),x1:d.right-t.left,y1:p,x2:u.left-t.left,y2:p,style:g})}});for(var o=Math.min(fe.length,ve.length),s=0;s<o;s+=1){var l=Ve.current[s],a=Ne.current[s];if((null==l?void 0:l.current)&&(null==a?void 0:a.current)){l.current.style.height="auto",a.current.style.height="auto",l.current.style.minHeight="0px",a.current.style.minHeight="0px";var c=Math.max(l.current.getBoundingClientRect().height,a.current.getBoundingClientRect().height);l.current.style.minHeight="".concat(c,"px"),a.current.style.minHeight="".concat(c,"px");var d=l.current.querySelector(".MuiAccordionSummary-root"),u=a.current.querySelector(".MuiAccordionSummary-root");if(d&&u){var x=d.getBoundingClientRect(),g=u.getBoundingClientRect(),p=(x.top+x.height/2-t.top+g.top+g.height/2-t.top)/2,f=(null===(e=ve[s])||void 0===e?void 0:e.id)||"sec-".concat(s),v=Ge(s);v&&r.push({id:f,x1:x.right-t.left,y1:p,x2:g.left-t.left,y2:p,style:v,sectionIdx:s,hasCognitive:!(!(null===(n=fe[s])||void 0===n?void 0:n.cognitiveData)&&!(null===(i=ve[s])||void 0===i?void 0:i.cognitiveData))})}}}if(ke(r),Ee.current&&Se.current){var _=Ee.current.getBoundingClientRect(),m=Se.current.getBoundingClientRect(),b=(_.top+_.height/2-t.top+m.top+m.height/2-t.top)/2;Te({x1:_.right-t.left,x2:m.left-t.left,y:b})}else Te(null)}catch(e){console.error("Line render safe fail: ",e)}finally{U.current=!1}}};i.useEffect(function(){var e=setTimeout(Ye,250);window.addEventListener("resize",Ye);var n=null;return V.current&&(n=new ResizeObserver(function(){return window.requestAnimationFrame(Ye)})).observe(V.current),function(){clearTimeout(e),window.removeEventListener("resize",Ye),null==n||n.disconnect()}},[J,ge,me,ie,Oe,ae,fe,ve,G]);var Je={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul, & ol":{mt:0,mb:1.5,pl:2.5},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}},Xe=function(i,o,s,l){return n.jsx(t.Box,e.__assign({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:n.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!!ae[o],onChange:function(){return n=o,void ce(function(i){var t;return e.__assign(e.__assign({},i),((t={})[n]=!i[n],t))});var n},sx:{boxShadow:"none",border:"1px solid #E2E8F0",bgcolor:"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,"& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#19213D",fontWeight:500,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:p(i.title||"Section ".concat(o+1))}))})),n.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:Je},{children:n.jsx(x.default,{children:g(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(i,r){return n.jsx(t.Box,e.__assign({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:Je},{children:n.jsx(x.default,{children:g(i).replace(/\\n/g,"\n")})}))}),"".concat(s,"-sub-").concat(o,"-").concat(r))})]}))]}))}),"".concat(s,"-sec-").concat(o))};return n.jsxs(t.Box,e.__assign({ref:N,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[O.open&&n.jsx(_,{open:O.open,popupRef:H,position:W,onClose:function(){return P(function(n){return e.__assign(e.__assign({},n),{open:!1})})},sectionTitle:O.sectionTitle,referenceSectionTitle:O.refSectionTitle,cognitiveData:O.cognitiveData,anchorEl:O.anchorEl,sectionAnchorEl:O.sectionAnchorEl,scrollContainerEl:V.current,badgeStyle:O.badgeStyle}),n.jsx(t.Snackbar,e.__assign({open:!!A,autoHideDuration:8e3,onClose:function(){return R(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return R(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:A}))})),n.jsx(t.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:"Learning Comparison"}))}))})),ue.length>1&&n.jsxs(t.Box,e.__assign({sx:{px:3,pb:.25},ref:I},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[n.jsx(t.IconButton,e.__assign({onClick:function(){return de("left")},size:"small",disabled:!ze},{children:n.jsx(r.ArrowLeft,{size:18})})),n.jsx(t.IconButton,e.__assign({onClick:function(){return de("right")},size:"small",disabled:!He},{children:n.jsx(r.ArrowRight,{size:18})}))]}))]})),n.jsx(t.Box,e.__assign({ref:q,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"}}},{children:ue.map(function(e){return n.jsx(m,{data:e,isSelected:(null==xe?void 0:xe.id)===e.id,isCognitiveOpen:ie,onToggleCognitive:function(){return te(function(e){return!e})},onClick:function(){return ee((n=e).id),S(n),void te(!1);var n}},e.id)})}))]})),n.jsx(t.Box,e.__assign({ref:V,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:be&&ye&&ie?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:n.jsxs(t.Box,e.__assign({ref:je,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[Re&&n.jsxs("g",{children:[n.jsx("line",{x1:Re.x1,y1:Re.y,x2:Math.max(Re.x1,(Re.x1+Re.x2)/2-70),y2:Re.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(Re.x2,(Re.x1+Re.x2)/2+70),y1:Re.y,x2:Re.x2,y2:Re.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),De.map(function(i,o){var s=(i.x1+i.x2)/2;return i.id||"line-".concat(o),"Not Defined"===i.style.label?null:n.jsxs("g",{children:[n.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder,strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-75,y:i.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"},onClick:function(e){e.stopPropagation(),function(e,n,i,t,r){var o,s;e.stopPropagation();var l=g(n.id)||g(i.id)||"",a=(l?T[l]:null)||n.cognitiveData||i.cognitiveData||null,c=null!==(s=null===(o=we.current[t])||void 0===o?void 0:o.current)&&void 0!==s?s:null;P({open:!0,sectionTitle:n.title||"Section",refSectionTitle:i.title||"Reference Section",cognitiveData:a,anchorEl:e.currentTarget,sectionAnchorEl:c,badgeStyle:r||null,sectionIdx:t})}(e,fe[i.sectionIdx]||{title:"",content:""},ve[i.sectionIdx]||{title:"",content:""},i.sectionIdx,i.style)}},{children:[i.style.label,i.hasCognitive&&void 0!==i.sectionIdx&&n.jsx(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",px:"4px",ml:"2px",color:i.style.badgeText,transition:"background 0.15s","&:hover":{backgroundColor:"rgba(0,0,0,0.05)"}}},{children:n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:n.jsx(l.ButtonCognitiveIcon,{})}))})),O.open&&O.sectionIdx===i.sectionIdx?n.jsx(r.ChevronUp,{size:12,color:i.style.badgeText}):n.jsx(r.ChevronDown,{size:12,color:i.style.badgeText})]}))}))}))]},o)})]})),n.jsxs(t.Box,e.__assign({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:Ee,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:pe}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Oe.map(function(e){var i=e.key,t=e.label,r=e.analysisKey,o=Ke(r),s=J[i],l=ge[i];if(!F(s)&&!F(l))return null;var a=h(o.score,o.relation,o.hasContent,G);return a?n.jsx(f,{ref:Pe.current[i],label:t,content:s,highlights:o.highlightsA,styleVariant:a,isHighlighted:oe===r||oe===i},"left-".concat(i)):null}),_e&&fe.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return F(n.title)||F(n.content)||(n.subsections||[]).some(F)}).map(function(i){var r=i.section,o=i.idx;return n.jsx(t.Box,e.__assign({ref:Be(o)},{children:Xe(r,o,"left",Ve.current[o]||d.default.createRef())}),"left-row-".concat(o))})]}))]})),n.jsx(t.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[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(l.ButtonCognitiveIcon,{})})),Fe,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),n.jsxs(t.Box,e.__assign({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:Se,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:he}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Oe.map(function(e){var i=e.key,t=e.label,r=e.analysisKey,o=Ke(r),s=J[i],l=ge[i];if(!F(s)&&!F(l))return null;var a=h(o.score,o.relation,o.hasContent,G);return a?n.jsx(f,{ref:qe.current[i],label:t,content:l,highlights:o.highlightsB,styleVariant:a,isHighlighted:oe===r||oe===i},"right-".concat(i)):null}),_e&&ve.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return F(n.title)||F(n.content)||(n.subsections||[]).some(F)}).map(function(e){var n=e.section,i=e.idx;return Xe(n,i,"right",Ne.current[i]||d.default.createRef())})]}))]}))]}))}))}))]}))};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i,Fragment as r}from"react/jsx-runtime";import o,{useState as l,useMemo as a,useRef as c,useCallback as s,useEffect as d}from"react";import{Box as u,Typography as p,Snackbar as h,Alert as g,IconButton as f,Skeleton as x,Accordion as v,AccordionSummary as m,AccordionDetails as b}from"@mui/material";import{ArrowLeft as y,ArrowRight as F,ChevronUp as w,ChevronDown as E,X as C}from"lucide-react";import S from"react-dom";import k from"../../assests/svg/SparkleIcon.js";import{ButtonCognitiveIcon as D}from"../../assests/svg/ButtonCognitiveIcon.js";import B from"react-markdown";var A=function(e){return null==e?"":"string"==typeof e?e:Array.isArray(e)?e.map(A).join("\n\n"):"object"==typeof e?JSON.stringify(e):String(e)},I=function(e){return e?A(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?i("strong",{children:e.slice(2,-2)},n):i(o.Fragment,{children:e},n)}):null},z=function(n,t,i,r){var o=100*(n||0),l=r.thresholds,a=r.relationStyles;if(!i)return null;var c=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(t),s=(t||"").toLowerCase();return s.includes("no_deviation")?e(e({},a.low),{label:c}):s.includes("deviation")||s.includes("high_risk")||s.includes("critical")?e(e({},a.high),{label:c}):o>=l.exact?e(e({},a.exact),{label:c}):o>=l.high?e(e({},a.high),{label:c}):o>=l.medium?e(e({},a.medium),{label:c}):e(e({},a.low),{label:c})},R=o.forwardRef(function(n,r){var l=n.label,a=n.content,c=n.highlights,s=void 0===c?[]:c,d=n.styleVariant,h=n.isHighlighted,g=void 0!==h&&h,f=Array.isArray(a)?a.map(A).join("\n"):A(a),x="#9F1239"===d.badgeText?{borderColor:"#E11D48",shadow:"rgba(225, 29, 72, 0.25)"}:"#B91C1C"===d.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#1D4ED8"===d.badgeText?{borderColor:"#3B82F6",shadow:"rgba(59, 130, 246, 0.25)"}:"#A16207"===d.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"};return t(u,e({sx:{mb:1.5}},{children:[i(p,e({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:l})),i(u,e({ref:r,sx:{p:"4px 12px",borderRadius:"6px",border:g?"1.5px solid ".concat(x.borderColor):"1px solid ".concat(d.border),boxShadow:g?"0px 0px 0px 2px ".concat(x.shadow):"none",bgcolor:d.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:i(u,{children:function(){if(!f)return null;if(!s||0===s.length)return I(f);var n=s.filter(function(e){return e&&"string"==typeof e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===n.length)return I(f);var t=new RegExp("(".concat(n.join("|"),")"),"gi");return f.split(t).map(function(n,t){return s.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===n.toLowerCase()})?i(u,e({component:"span",sx:{bgcolor:d.highlightBg,borderRadius:"2px",px:"2px"}},{children:I(n)}),t):i(o.Fragment,{children:I(n)},t)})}()})}))]}))}),_=10,W=function(n){var o,c,s,h,g,x,v,m=n.open,b=n.onClose,y=n.sectionTitle,F=n.referenceSectionTitle,w=n.cognitiveData,D=n.relevanceScore,B=n.anchorEl,I=n.badgeStyle,z=n.popupRef,R=n.position,W=l("association"),T=W[0],L=W[1],H=a(function(){if(!I)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=I.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[I]);if(d(function(){if(m){var e=function(e){var n;(null===(n=z.current)||void 0===n?void 0:n.contains(e.target))||(null==B?void 0:B.contains(e.target))||b()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[m,b,B,z]),!m||!w)return null;var j=null!==(c=null!==(o=w.relevance_score)&&void 0!==o?o:D)&&void 0!==c?c:0,M=function(e){return e?e.split(/(?<=\.)(?:\s+(?=[A-Z])|\s+\d+\.\s)/).map(function(e){return e.trim()}).filter(function(e){return e.length>10}):[]},O=M(null!==(s=w.decisioning)&&void 0!==s?s:""),P=M(null!==(h=w.gap)&&void 0!==h?h:""),V=function(e){if(!e)return[];if(Array.isArray(e))return e.flatMap(function(e){if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e&&null!==e){var n=e,t={key:A(n.key),value:A(n.value),url:A(n.url)};return t.value||t.key||t.url?[t]:[]}return[]});if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e){var n=e;if("value"in n||"key"in n||"url"in n)return[{key:A(n.key),value:A(n.value),url:A(n.url)}]}return[]},K=function(e,n){var t,i,r=w,o="decisioning"===e?null!==(t=r.decisioning_metadata)&&void 0!==t?t:r.decisioningMetadata:null!==(i=r.gap_metadata)&&void 0!==i?i:r.gapMetadata;if(Array.isArray(o)){if((d=V(o[n])).length)return d;if((u=V(o)).length)return u}else{var l=V(o);if(l.length)return l}var a=r.metadata;if(a&&"object"==typeof a&&!Array.isArray(a)){var c=a,s="decisioning"===e?c.decisioning:c.gap;if(Array.isArray(s)){var d,u;if((d=V(s[n])).length)return d;if((u=V(s)).length)return u}else{var p=V(s);if(p.length)return p}}return[]},N=function(n){if(!n.length)return null;var r=n[0],o=r.key||"metadata",l=r.value||r.url||"",a=l?"".concat(o,": ").concat(l):o;return t(u,e({component:"span",sx:{display:"inline-flex",alignItems:"center",color:"#253AE4",fontWeight:600,ml:.5,whiteSpace:"nowrap"}},{children:["(",a,i(E,{size:13,style:{marginLeft:2}}),")"]}))},U=null!==(g=null==R?void 0:R.arrowLeft)&&void 0!==g?g:60,q=t(u,e({ref:z,sx:{position:"fixed",top:null!==(x=null==R?void 0:R.top)&&void 0!==x?x:-9999,left:null!==(v=null==R?void 0:R.left)&&void 0!==v?v:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(H.border),boxShadow:"0px 8px 32px ".concat(H.shadow,", 0px 0px 0px 3px ").concat(H.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:"60vh",visibility:R?"visible":"hidden"}},{children:[R&&(R.openAbove?t(r,{children:[i(u,{sx:{position:"absolute",bottom:-11,left:U-_,width:0,height:0,borderLeft:"".concat(_,"px solid transparent"),borderRight:"".concat(_,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(H.border),zIndex:1}}),i(u,{sx:{position:"absolute",bottom:-9,left:U-_+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(_,"px solid #FFFFFF"),zIndex:2}})]}):t(r,{children:[i(u,{sx:{position:"absolute",top:-11,left:U-_,width:0,height:0,borderLeft:"".concat(_,"px solid transparent"),borderRight:"".concat(_,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(H.border),zIndex:1}}),i(u,{sx:{position:"absolute",top:-9,left:U-_+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(_,"px solid #FFFFFF"),zIndex:2}})]})),t(u,e({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[t(u,e({sx:{flex:1,minWidth:0}},{children:[t(p,e({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[i(u,e({component:"span",title:y,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:y})),i(u,e({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),i(u,e({component:"span",title:F||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:F||"Reference Section"}))]})),i(u,e({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:i(p,e({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"Why this is a Deviation?"}))}))]})),t(u,e({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[t(u,e({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:[i(k,{}),"Decision Strength ",j,"%"]})),i(f,e({onClick:b,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:i(C,{size:22})}))]}))]})),i(u,e({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(n){var t=T===n;return i(u,e({onClick:function(){return L(n)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:t?600:400,color:t?"#5928ED":"#667085",backgroundColor:t?"rgba(89,40,237,0.08)":"transparent",borderBottom:t?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:"deviation"===n?"Deviation Analysis":"Association Logic"}),n)})})),i(u,e({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(H.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:H.border},scrollbarWidth:"thin",scrollbarColor:"".concat(H.border,"55 transparent")}},{children:"deviation"===T?t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),i(p,e({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):t(r,{children:[O.length>0&&t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[i(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),i(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:O.map(function(n,i){return t(p,e({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[i+1,". ",n,N(K("decisioning",i))]}),i)})}))]})),P.length>0&&t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[i(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),i(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:P.map(function(n,i){return t(p,e({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[i+1,". ",n,N(K("gap",i))]}),i)})}))]})),0===O.length&&0===P.length&&i(u,e({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:i(p,e({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return S.createPortal(q,document.body)},T=function(n){var r=n.data,o=n.isSelected,l=n.isCognitiveOpen,a=n.onToggleCognitive,c=n.onClick,s=A(r.summaryText||r.description),d=s.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),h=d?s.replace(d[0],"").trim():s,g=!!d;return t(u,e({id:"variant-card-".concat(r.id),onClick:c,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:o?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:r.isLoading?.7:1,border:o?"1.4px solid #2563EB":void 0,boxShadow:o?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:o?"#2563EB":"#CBD5E1",boxShadow:o?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[i(u,e({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:r.isLoading?i(x,{variant:"rounded",width:80,height:20}):t(u,e({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==r.similarity?r.similarity:0,"% Similarity"]}))})),t(u,e({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[i(u,e({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:i(p,e({sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:A(r.title)}))})),r.isLoading?t(u,{children:[i(x,{width:"90%"}),i(x,{width:"60%"})]}):t(u,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[i(p,e({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:h})),g&&t(u,e({onClick:function(e){e.stopPropagation(),o||c(),a()},sx:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[i("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:i(D,{})})),i(E,{size:12,style:{transform:o&&l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))},L=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],H={fields:L,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},j=function(e){return null!=e&&("string"==typeof e?e.trim().length>0:!Array.isArray(e)||e.length>0&&e.some(function(e){return j(e)}))},M=function(n){var t,i,r,o,l=[],a=[],c=n.base_root_id,s=n.input_index_map||{0:"left",1:"right"},d=n[c];if(!d||!1===d.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var u=function(e,n){var t,i=s[n],r=null===(t=null==e?void 0:e.comparison_inputs)||void 0===t?void 0:t[i];return{title:A((null==r?void 0:r.title)||""),content:A((null==r?void 0:r.content)||"")}};d.next&&Object.values(d.next).forEach(function(t){var i=n[t];if(i&&!1!==i.display_node){var r=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"not_defined"};var n=e.mapping_rationale,t=!n.decision_strength,i=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||"",gap:n.gaps_in_decision||"",relevance_score:i},score:t?100:i/100,relation:i>=70?"no_deviation":"deviation"}}(i),o=u(i,"0"),c=u(i,"1"),s=e({id:t,title:o.title,content:o.content,subsections:[]},r),d=e({id:t,title:c.title,content:c.content,subsections:[]},r);if(i.next)Object.values(i.next).forEach(function(e){var t=n[e];if(t&&!1!==t.display_node){var i=u(t,"0"),r=u(t,"1");i.content&&s.subsections.push(i.content),r.content&&d.subsections.push(r.content)}});l.push(s),a.push(d)}});return{activeProposed:{title:(null===(i=null===(t=d.comparison_inputs)||void 0===t?void 0:t[s[0]])||void 0===i?void 0:i.title)||"Uploaded Contract",description:d.decision_scope_description||"",sections:l},activeVariants:[{id:"tree-variant-1",title:(null===(o=null===(r=d.comparison_inputs)||void 0===r?void 0:r[s[1]])||void 0===o?void 0:o.title)||"Reference Template",similarity:l.length>0?Math.round(l.reduce(function(e,n){return e+(n.score||0)},0)/l.length*100):0,sections:a,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:d.decision_scope_description||""},fields:{}}}}]}},O=function(r){var x,C,S,k=r.variants,O=void 0===k?[]:k,P=r.treeData,V=r.comparisonConfig,K=r.onSelectVariant,N=r.onSkip,U=r.onBack,q=r.targetVariantId,Y=r.highlightedField;r.onBadgeClick,r.activeBadgeId;var G=l(null),J=G[0],$=G[1],X=a(function(){return(null==P?void 0:P.cognitive_decisioning)||{}},[P]),Z=c(null),Q=l(null),ee=Q[0],ne=Q[1],te=c(null),ie=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionId:""}),re=ie[0],oe=ie[1],le=c(null),ae=c(null),ce=c(null),se=c(!1),de=s(function(){var e;if(re.anchorEl&&re.refSectionTitle){var n=re.anchorEl.getBoundingClientRect(),t=(null===(e=null==te?void 0:te.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12,o=n.top-12,l=r<t&&o>r,a=l?n.top-12-t:n.bottom+12,c=n.left+n.width/2,s=c-i/2,d=Math.max(12,Math.min(s,window.innerWidth-i-12)),u=Math.max(14,Math.min(c-d,i-_-4));ne({top:a,left:d,arrowLeft:u,openAbove:l})}},[re.anchorEl,re.refSectionTitle]);d(function(){if(re.open){window.addEventListener("resize",de);var e=requestAnimationFrame(de);return function(){cancelAnimationFrame(e),window.removeEventListener("resize",de)}}},[re.open,de]),d(function(){var n=ae.current;if(n&&re.open){var t=function(n){console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),oe(function(n){return e(e({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})})};return n.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){n.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[re.open]);var ue=a(function(){var n,t,i,r,o,l,a,c,s,d,u,p;return{fields:null!==(n=null==V?void 0:V.fields)&&void 0!==n?n:L,thresholds:{high:null!==(i=null===(t=null==V?void 0:V.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:H.thresholds.high,medium:null!==(o=null===(r=null==V?void 0:V.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:H.thresholds.medium,exact:null!==(a=null===(l=null==V?void 0:V.thresholds)||void 0===l?void 0:l.exact)&&void 0!==a?a:H.thresholds.exact},relationStyles:{noContent:e(e({},H.relationStyles.noContent),(null===(c=null==V?void 0:V.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e(e({},H.relationStyles.high),(null===(s=null==V?void 0:V.relationStyles)||void 0===s?void 0:s.high)||{}),exact:e(e({},H.relationStyles.exact),(null===(d=null==V?void 0:V.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},H.relationStyles.medium),(null===(u=null==V?void 0:V.relationStyles)||void 0===u?void 0:u.medium)||{}),low:e(e({},H.relationStyles.low),(null===(p=null==V?void 0:V.relationStyles)||void 0===p?void 0:p.low)||{})}}},[V]),pe=a(function(){if(P&&Object.keys(P).length>0)try{var n=M(P);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:O||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:O||[],parseError:null}},[P,O]),he=pe.activeProposed,ge=pe.activeVariants,fe=pe.parseError;d(function(){fe&&$("Failed to load comparison: ".concat(fe))},[fe]);var xe=l(q||null),ve=xe[0],me=xe[1],be=l(!1),ye=be[0],Fe=be[1],we=l(null),Ee=we[0],Ce=we[1],Se=l({}),ke=Se[0],De=Se[1];d(function(){if(q&&me(q),Ce(null!=Y?Y:null),Y){var e=setTimeout(function(){return Ce(null)},6e3);return function(){return clearTimeout(e)}}},[q,Y]);var Be=function(e){var n;null===(n=le.current)||void 0===n||n.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},Ae=a(function(){return n([],ge,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[ge]),Ie=a(function(){if(ve){var e=String(ve).trim();return ge.find(function(n){return n.id&&String(n.id).trim()===e})||Ae[0]}return Ae[0]||null},[ve,ge,Ae]);d(function(){ve&&le.current&&setTimeout(function(){var e=document.getElementById("variant-card-".concat(ve.trim())),n=le.current;if(e&&n){var t=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:t,behavior:"smooth"})}},150)},[ve,Ae]);var ze=Ie||{id:"",title:""},Re=A(he.title)||"Uploaded Contract",_e=A(ze.title)||"Reference Template",We=he.sections||[],Te=ze.sections||[],Le=We.length>0||Te.length>0,He=null==Ie?void 0:Ie.analysis,je=A(null===(C=null===(x=null==He?void 0:He.rule_difference_comparison)||void 0===x?void 0:x.summary)||void 0===C?void 0:C.overall_summary),Me=!!je.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Oe=null!==(S=null==Ie?void 0:Ie.similarity)&&void 0!==S?S:0,Pe=c({}),Ve=function(e){return Pe.current[e]||(Pe.current[e]=o.createRef()),Pe.current[e]};d(function(){!ve&&!q&&Ae.length>0&&!Ae[0].isLoading&&me(Ae[0].id)},[Ae,ve,q]);var Ke=c(null),Ne=c(null),Ue=c(null),qe=l([]),Ye=qe[0],Ge=qe[1],Je=l(null),$e=Je[0],Xe=Je[1],Ze=l(!1),Qe=Ze[0],en=Ze[1],nn=l(!1),tn=nn[0],rn=nn[1];d(function(){var e=le.current;if(e){var n=function(){en(e.scrollLeft>0),rn(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[Ae]);var on=a(function(){return ue.fields.filter(function(e){var n=e.key;return(!Le||"description"!==n)&&(j(he[n])||j(ze[n]))})},[he,ze,Le,ue.fields]),ln=c({}),an=c({}),cn=c({}),sn=c({});on.forEach(function(e){var n=e.key;ln.current[n]||(ln.current[n]=o.createRef()),an.current[n]||(an.current[n]=o.createRef())});for(var dn=0;dn<Math.max(We.length,Te.length);dn+=1)cn.current[dn]||(cn.current[dn]=o.createRef()),sn.current[dn]||(sn.current[dn]=o.createRef());d(function(){if(Ee){var e=ue.fields.find(function(e){return e.analysisKey===Ee||e.key===Ee});if(e){var n=ln.current[e.key]||an.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ee,ue.fields]);var un=function(e){var n,t,i,r,o,l,a,c,s,d=null===(n=null==He?void 0:He.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var u=d[e],p=(null==u?void 0:u.relation)||(null===(i=null===(t=null==u?void 0:u.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==u?void 0:u.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==u?void 0:u.mappings)&&u.mappings.length>0;if(u.mappings){var h=u.mappings[0]||{};return{score:u.score,relation:h.relation||"",highlightsA:(null===(l=h.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(a=h.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!p}}return{score:u.score,relation:u.relation||"",highlightsA:(null===(c=u.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(s=u.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!p}},pn=function(n){var t=Te[n];if("not_defined"===(null==t?void 0:t.relation))return e(e({},ue.relationStyles.noContent),{label:"Not Defined"});var i,r=un("description");if(null!=(null==t?void 0:t.cognitiveRelevanceScore)){var o=(i=t.cognitiveRelevanceScore)>=90?{score:1,relation:"exact_match"}:i>=70?{score:.8,relation:"high_match"}:i>=40?{score:.5,relation:"partial_match"}:{score:0,relation:"no_deviation"};return z(o.score,o.relation,!0,ue)}var l=null!=(null==t?void 0:t.relation)&&""!==t.relation?t.relation:r.relation,a="number"==typeof(null==t?void 0:t.score)?t.score:r.score;return z(a,l,!0,ue)},hn=function(){var e,n,t;if(!se.current){se.current=!0;try{if(!Ke.current)return;var i=Ke.current.getBoundingClientRect(),r=[];on.forEach(function(e){var n=e.key,t=e.analysisKey,o=ln.current[n],l=an.current[n];if((null==o?void 0:o.current)&&(null==l?void 0:l.current)){o.current.style.height="auto",l.current.style.height="auto",o.current.style.minHeight="0px",l.current.style.minHeight="0px";var a=o.current.getBoundingClientRect().height,c=l.current.getBoundingClientRect().height,s=Math.max(a,c);o.current.style.minHeight="".concat(s,"px"),l.current.style.minHeight="".concat(s,"px");var d=o.current.getBoundingClientRect(),u=l.current.getBoundingClientRect(),p=un(t),h=z(p.score,p.relation,p.hasContent,ue);if(!h)return;var g=d.top+d.height/2-i.top;r.push({id:"field-".concat(n),x1:d.right-i.left,y1:g,x2:u.left-i.left,y2:g,style:h})}});for(var o=Math.min(We.length,Te.length),l=0;l<o;l+=1){var a=cn.current[l],c=sn.current[l];if((null==a?void 0:a.current)&&(null==c?void 0:c.current)){a.current.style.height="auto",c.current.style.height="auto",a.current.style.minHeight="0px",c.current.style.minHeight="0px";var s=Math.max(a.current.getBoundingClientRect().height,c.current.getBoundingClientRect().height);a.current.style.minHeight="".concat(s,"px"),c.current.style.minHeight="".concat(s,"px");var d=a.current.querySelector(".MuiAccordionSummary-root"),u=c.current.querySelector(".MuiAccordionSummary-root");if(d&&u){var p=d.getBoundingClientRect(),h=u.getBoundingClientRect(),g=(p.top+p.height/2-i.top+h.top+h.height/2-i.top)/2,f=(null===(e=Te[l])||void 0===e?void 0:e.id)||"sec-".concat(l),x=pn(l);x&&r.push({id:f,x1:p.right-i.left,y1:g,x2:h.left-i.left,y2:g,style:x,sectionIdx:l,hasCognitive:!(!(null===(n=We[l])||void 0===n?void 0:n.cognitiveData)&&!(null===(t=Te[l])||void 0===t?void 0:t.cognitiveData))})}}}if(Ge(r),Ne.current&&Ue.current){var v=Ne.current.getBoundingClientRect(),m=Ue.current.getBoundingClientRect(),b=(v.top+v.height/2-i.top+m.top+m.height/2-i.top)/2;Xe({x1:v.right-i.left,x2:m.left-i.left,y:b})}else Xe(null)}catch(e){console.error("Line render safe fail: ",e)}finally{se.current=!1}}};d(function(){var e=setTimeout(hn,250);window.addEventListener("resize",hn);var n=null;return ae.current&&(n=new ResizeObserver(function(){return window.requestAnimationFrame(hn)})).observe(ae.current),function(){clearTimeout(e),window.removeEventListener("resize",hn),null==n||n.disconnect()}},[he,ze,He,ye,on,ke,We,Te,ue]);var gn={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul, & ol":{mt:0,mb:1.5,pl:2.5},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}},fn=function(n,r,o,l){return i(u,e({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:t(v,e({disableGutters:!0,expanded:!!ke[r],onChange:function(){return n=r,void De(function(t){var i;return e(e({},t),((i={})[n]=!t[n],i))});var n},sx:{boxShadow:"none",border:"1px solid #E2E8F0",bgcolor:"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[i(m,e({expandIcon:i(E,{size:16}),sx:{minHeight:"36px",flexShrink:0,"& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:i(p,e({sx:{fontSize:"12px",color:"#19213D",fontWeight:500,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:I(n.title||"Section ".concat(r+1))}))})),t(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[i(p,e({component:"div",sx:gn},{children:i(B,{children:A(n.content).replace(/\\n/g,"\n")})})),(n.subsections||[]).map(function(n,t){return i(u,e({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:i(p,e({component:"div",sx:gn},{children:i(B,{children:A(n).replace(/\\n/g,"\n")})}))}),"".concat(o,"-sub-").concat(r,"-").concat(t))})]}))]}))}),"".concat(o,"-sec-").concat(r))};return t(u,e({ref:ce,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[re.open&&i(W,{open:re.open,popupRef:te,position:ee,onClose:function(){return oe(function(n){return e(e({},n),{open:!1})})},sectionTitle:re.sectionTitle,referenceSectionTitle:re.refSectionTitle,cognitiveData:re.cognitiveData,anchorEl:re.anchorEl,sectionAnchorEl:re.sectionAnchorEl,scrollContainerEl:ae.current,badgeStyle:re.badgeStyle}),i(h,e({open:!!J,autoHideDuration:8e3,onClose:function(){return $(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(g,e({onClose:function(){return $(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:J}))})),t(u,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:[t(u,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:[i(f,e({onClick:U,size:"small"},{children:i(y,{})})),i(p,e({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:"Learning Comparison"}))]})),i(f,e({onClick:N,size:"small"},{children:i(u,e({sx:{fontSize:24,lineHeight:.5}},{children:"×"}))}))]})),Ae.length>1&&t(u,e({sx:{px:3,pb:.25},ref:Z},{children:[t(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[i(p,e({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),t(u,e({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[i(f,e({onClick:function(){return Be("left")},size:"small",disabled:!Qe},{children:i(y,{size:18})})),i(f,e({onClick:function(){return Be("right")},size:"small",disabled:!tn},{children:i(F,{size:18})}))]}))]})),i(u,e({ref:le,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"}}},{children:Ae.map(function(e){return i(T,{data:e,isSelected:(null==Ie?void 0:Ie.id)===e.id,isCognitiveOpen:ye,onToggleCognitive:function(){return Fe(function(e){return!e})},onClick:function(){return me((n=e).id),K(n),void Fe(!1);var n}},e.id)})}))]})),i(u,e({ref:ae,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:je&&Me&&ye?"none":"1.5px solid #EEF0F4"}},{children:i(u,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:t(u,e({ref:Ke,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[t("svg",e({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[$e&&t("g",{children:[i("line",{x1:$e.x1,y1:$e.y,x2:Math.max($e.x1,($e.x1+$e.x2)/2-70),y2:$e.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),i("line",{x1:Math.min($e.x2,($e.x1+$e.x2)/2+70),y1:$e.y,x2:$e.x2,y2:$e.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Ye.map(function(n,r){var o=(n.x1+n.x2)/2;return n.id||"line-".concat(r),"Not Defined"===n.style.label?null:t("g",{children:[i("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder,strokeWidth:"1.5"}),i("foreignObject",e({x:o-75,y:n.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(u,e({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"},onClick:function(e){e.stopPropagation(),function(e,n,t,i,r){var o,l;e.stopPropagation();var a=A(n.id)||A(t.id)||"",c=(a?X[a]:null)||n.cognitiveData||t.cognitiveData||null,s=null!==(l=null===(o=Pe.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;oe({open:!0,sectionTitle:n.title||"Section",refSectionTitle:t.title||"Reference Section",cognitiveData:c,anchorEl:e.currentTarget,sectionAnchorEl:s,badgeStyle:r||null,sectionId:a})}(e,We[n.sectionIdx]||{title:"",content:""},Te[n.sectionIdx]||{title:"",content:""},n.sectionIdx,n.style)}},{children:[n.style.label,n.hasCognitive&&void 0!==n.sectionIdx&&i(u,e({sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",px:"4px",ml:"2px",color:n.style.badgeText,transition:"background 0.15s","&:hover":{backgroundColor:"rgba(0,0,0,0.05)"}}},{children:i("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:i(D,{})}))})),parseInt(n.sectionIdx)===parseInt(re.sectionId)?i(w,{size:12,color:n.style.badgeText}):i(E,{size:12,color:n.style.badgeText})]}))}))}))]},r)})]})),t(u,e({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[i(u,e({ref:Ne,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:Re}))})),t(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[on.map(function(e){var n=e.key,t=e.label,r=e.analysisKey,o=un(r),l=he[n],a=ze[n];if(!j(l)&&!j(a))return null;var c=z(o.score,o.relation,o.hasContent,ue);return c?i(R,{ref:ln.current[n],label:t,content:l,highlights:o.highlightsA,styleVariant:c,isHighlighted:Ee===r||Ee===n},"left-".concat(n)):null}),Le&&We.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return j(n.title)||j(n.content)||(n.subsections||[]).some(j)}).map(function(n){var t=n.section,r=n.idx;return i(u,e({ref:Ve(r)},{children:fn(t,r,"left",cn.current[r]||o.createRef())}),"left-row-".concat(r))})]}))]})),i(u,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:i(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(u,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[i(u,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(D,{})})),Oe,"% Similarity",i(E,{size:11})]}))}))})),t(u,e({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[i(u,e({ref:Ue,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:_e}))})),t(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[on.map(function(e){var n=e.key,t=e.label,r=e.analysisKey,o=un(r),l=he[n],a=ze[n];if(!j(l)&&!j(a))return null;var c=z(o.score,o.relation,o.hasContent,ue);return c?i(R,{ref:an.current[n],label:t,content:a,highlights:o.highlightsB,styleVariant:c,isHighlighted:Ee===r||Ee===n},"right-".concat(n)):null}),Le&&Te.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return j(n.title)||j(n.content)||(n.subsections||[]).some(j)}).map(function(e){var n=e.section,t=e.idx;return fn(n,t,"right",sn.current[t]||o.createRef())})]}))]}))]}))}))}))]}))};export{H as DEFAULT_COMPARISON_CONFIG,L as DEFAULT_FIELD_CONFIG,O as default};
|
|
1
|
+
import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i,Fragment as r}from"react/jsx-runtime";import o,{useState as l,useMemo as a,useRef as c,useCallback as s,useEffect as d}from"react";import{Box as u,Typography as p,Snackbar as h,Alert as g,IconButton as f,Skeleton as x,Accordion as v,AccordionSummary as m,AccordionDetails as b}from"@mui/material";import{ArrowLeft as y,ArrowRight as F,ChevronUp as w,ChevronDown as E,X as C}from"lucide-react";import S from"react-dom";import k from"../../assests/svg/SparkleIcon.js";import{ButtonCognitiveIcon as D}from"../../assests/svg/ButtonCognitiveIcon.js";import B from"react-markdown";var A=function(e){return null==e?"":"string"==typeof e?e:Array.isArray(e)?e.map(A).join("\n\n"):"object"==typeof e?JSON.stringify(e):String(e)},R=function(e){return e?A(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?i("strong",{children:e.slice(2,-2)},n):i(o.Fragment,{children:e},n)}):null},I=function(n,t,i,r){var o=100*(n||0),l=r.thresholds,a=r.relationStyles;if(!i)return null;var c=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(t),s=(t||"").toLowerCase();return s.includes("no_deviation")?e(e({},a.low),{label:c}):s.includes("deviation")||s.includes("high_risk")||s.includes("critical")?e(e({},a.high),{label:c}):o>=l.exact?e(e({},a.exact),{label:c}):o>=l.high?e(e({},a.high),{label:c}):o>=l.medium?e(e({},a.medium),{label:c}):e(e({},a.low),{label:c})},_=o.forwardRef(function(n,r){var l=n.label,a=n.content,c=n.highlights,s=void 0===c?[]:c,d=n.styleVariant,h=n.isHighlighted,g=void 0!==h&&h,f=Array.isArray(a)?a.map(A).join("\n"):A(a),x="#9F1239"===d.badgeText?{borderColor:"#E11D48",shadow:"rgba(225, 29, 72, 0.25)"}:"#B91C1C"===d.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#1D4ED8"===d.badgeText?{borderColor:"#3B82F6",shadow:"rgba(59, 130, 246, 0.25)"}:"#A16207"===d.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"};return t(u,e({sx:{mb:1.5}},{children:[i(p,e({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:l})),i(u,e({ref:r,sx:{p:"4px 12px",borderRadius:"6px",border:g?"1.5px solid ".concat(x.borderColor):"1px solid ".concat(d.border),boxShadow:g?"0px 0px 0px 2px ".concat(x.shadow):"none",bgcolor:d.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:i(u,{children:function(){if(!f)return null;if(!s||0===s.length)return R(f);var n=s.filter(function(e){return e&&"string"==typeof e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===n.length)return R(f);var t=new RegExp("(".concat(n.join("|"),")"),"gi");return f.split(t).map(function(n,t){return s.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===n.toLowerCase()})?i(u,e({component:"span",sx:{bgcolor:d.highlightBg,borderRadius:"2px",px:"2px"}},{children:R(n)}),t):i(o.Fragment,{children:R(n)},t)})}()})}))]}))}),z=10,W=function(n){var o,c,s,h,g,x,v,m=n.open,b=n.onClose,y=n.sectionTitle,F=n.referenceSectionTitle,w=n.cognitiveData,D=n.relevanceScore,B=n.anchorEl,R=n.badgeStyle,I=n.popupRef,_=n.position,W=l("association"),T=W[0],L=W[1],H=a(function(){if(!R)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=R.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[R]);if(d(function(){if(m){var e=function(e){var n;(null===(n=I.current)||void 0===n?void 0:n.contains(e.target))||(null==B?void 0:B.contains(e.target))||b()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[m,b,B,I]),!m||!w)return null;var j=null!==(c=null!==(o=w.relevance_score)&&void 0!==o?o:D)&&void 0!==c?c:0,M=function(e){return e?e.split(/(?<=\.)(?:\s+(?=[A-Z])|\s+\d+\.\s)/).map(function(e){return e.trim()}).filter(function(e){return e.length>10}):[]},O=M(null!==(s=w.decisioning)&&void 0!==s?s:""),P=M(null!==(h=w.gap)&&void 0!==h?h:""),V=function(e){if(!e)return[];if(Array.isArray(e))return e.flatMap(function(e){if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e&&null!==e){var n=e,t={key:A(n.key),value:A(n.value),url:A(n.url)};return t.value||t.key||t.url?[t]:[]}return[]});if("string"==typeof e)return[{key:"metadata",value:e}];if("object"==typeof e){var n=e;if("value"in n||"key"in n||"url"in n)return[{key:A(n.key),value:A(n.value),url:A(n.url)}]}return[]},K=function(e,n){var t,i,r=w,o="decisioning"===e?null!==(t=r.decisioning_metadata)&&void 0!==t?t:r.decisioningMetadata:null!==(i=r.gap_metadata)&&void 0!==i?i:r.gapMetadata;if(Array.isArray(o)){if((d=V(o[n])).length)return d;if((u=V(o)).length)return u}else{var l=V(o);if(l.length)return l}var a=r.metadata;if(a&&"object"==typeof a&&!Array.isArray(a)){var c=a,s="decisioning"===e?c.decisioning:c.gap;if(Array.isArray(s)){var d,u;if((d=V(s[n])).length)return d;if((u=V(s)).length)return u}else{var p=V(s);if(p.length)return p}}return[]},N=function(n){if(!n.length)return null;var r=n[0],o=r.key||"metadata",l=r.value||r.url||"",a=l?"".concat(o,": ").concat(l):o;return t(u,e({component:"span",sx:{display:"inline-flex",alignItems:"center",color:"#253AE4",fontWeight:600,ml:.5,whiteSpace:"nowrap"}},{children:["(",a,i(E,{size:13,style:{marginLeft:2}}),")"]}))},U=null!==(g=null==_?void 0:_.arrowLeft)&&void 0!==g?g:60,q=t(u,e({ref:I,sx:{position:"fixed",top:null!==(x=null==_?void 0:_.top)&&void 0!==x?x:-9999,left:null!==(v=null==_?void 0:_.left)&&void 0!==v?v:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(H.border),boxShadow:"0px 8px 32px ".concat(H.shadow,", 0px 0px 0px 3px ").concat(H.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:"60vh",visibility:_?"visible":"hidden"}},{children:[_&&(_.openAbove?t(r,{children:[i(u,{sx:{position:"absolute",bottom:-11,left:U-z,width:0,height:0,borderLeft:"".concat(z,"px solid transparent"),borderRight:"".concat(z,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(H.border),zIndex:1}}),i(u,{sx:{position:"absolute",bottom:-9,left:U-z+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(z,"px solid #FFFFFF"),zIndex:2}})]}):t(r,{children:[i(u,{sx:{position:"absolute",top:-11,left:U-z,width:0,height:0,borderLeft:"".concat(z,"px solid transparent"),borderRight:"".concat(z,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(H.border),zIndex:1}}),i(u,{sx:{position:"absolute",top:-9,left:U-z+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(z,"px solid #FFFFFF"),zIndex:2}})]})),t(u,e({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[t(u,e({sx:{flex:1,minWidth:0}},{children:[t(p,e({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[i(u,e({component:"span",title:y,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:y})),i(u,e({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),i(u,e({component:"span",title:F||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:F||"Reference Section"}))]})),i(u,e({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:i(p,e({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"Why this is a Deviation?"}))}))]})),t(u,e({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[t(u,e({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:[i(k,{}),"Decision Strength ",j,"%"]})),i(f,e({onClick:b,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:i(C,{size:22})}))]}))]})),i(u,e({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(n){var t=T===n;return i(u,e({onClick:function(){return L(n)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:t?600:400,color:t?"#5928ED":"#667085",backgroundColor:t?"rgba(89,40,237,0.08)":"transparent",borderBottom:t?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:"deviation"===n?"Deviation Analysis":"Association Logic"}),n)})})),i(u,e({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(H.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:H.border},scrollbarWidth:"thin",scrollbarColor:"".concat(H.border,"55 transparent")}},{children:"deviation"===T?t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),i(p,e({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):t(r,{children:[O.length>0&&t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[i(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),i(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:O.map(function(n,i){return t(p,e({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[i+1,". ",n,N(K("decisioning",i))]}),i)})}))]})),P.length>0&&t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[i(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),i(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:P.map(function(n,i){return t(p,e({sx:{fontSize:"14px",color:"#344054",lineHeight:1.55,wordBreak:"break-word"}},{children:[i+1,". ",n,N(K("gap",i))]}),i)})}))]})),0===O.length&&0===P.length&&i(u,e({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:i(p,e({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return S.createPortal(q,document.body)},T=function(n){var r=n.data,o=n.isSelected,l=n.isCognitiveOpen,a=n.onToggleCognitive,c=n.onClick,s=A(r.summaryText||r.description),d=s.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),h=d?s.replace(d[0],"").trim():s,g=!!d;return t(u,e({id:"variant-card-".concat(r.id),onClick:c,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:o?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:r.isLoading?.7:1,border:o?"1.4px solid #2563EB":void 0,boxShadow:o?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:o?"#2563EB":"#CBD5E1",boxShadow:o?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[i(u,e({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:r.isLoading?i(x,{variant:"rounded",width:80,height:20}):t(u,e({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==r.similarity?r.similarity:0,"% Similarity"]}))})),t(u,e({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[i(u,e({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:i(p,e({sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:A(r.title)}))})),r.isLoading?t(u,{children:[i(x,{width:"90%"}),i(x,{width:"60%"})]}):t(u,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[i(p,e({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:h})),g&&t(u,e({onClick:function(e){e.stopPropagation(),o||c(),a()},sx:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[i("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:i(D,{})})),i(E,{size:12,style:{transform:o&&l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))},L=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],H={fields:L,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},j=function(e){return null!=e&&("string"==typeof e?e.trim().length>0:!Array.isArray(e)||e.length>0&&e.some(function(e){return j(e)}))},M=function(n){var t,i,r,o,l=[],a=[],c=n.base_root_id,s=n.input_index_map||{0:"left",1:"right"},d=n[c];if(!d||!1===d.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var u=function(e,n){var t,i=s[n],r=null===(t=null==e?void 0:e.comparison_inputs)||void 0===t?void 0:t[i];return{title:A((null==r?void 0:r.title)||""),content:A((null==r?void 0:r.content)||"")}};d.next&&Object.values(d.next).forEach(function(t){var i=n[t];if(i&&!1!==i.display_node){var r=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"not_defined"};var n=e.mapping_rationale,t=!n.decision_strength,i=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||"",gap:n.gaps_in_decision||"",relevance_score:i},score:t?100:i/100,relation:i>=70?"no_deviation":"deviation"}}(i),o=u(i,"0"),c=u(i,"1"),s=e({id:t,title:o.title,content:o.content,subsections:[]},r),d=e({id:t,title:c.title,content:c.content,subsections:[]},r);if(i.next)Object.values(i.next).forEach(function(e){var t=n[e];if(t&&!1!==t.display_node){var i=u(t,"0"),r=u(t,"1");i.content&&s.subsections.push(i.content),r.content&&d.subsections.push(r.content)}});l.push(s),a.push(d)}});return{activeProposed:{title:(null===(i=null===(t=d.comparison_inputs)||void 0===t?void 0:t[s[0]])||void 0===i?void 0:i.title)||"Uploaded Contract",description:d.decision_scope_description||"",sections:l},activeVariants:[{id:"tree-variant-1",title:(null===(o=null===(r=d.comparison_inputs)||void 0===r?void 0:r[s[1]])||void 0===o?void 0:o.title)||"Reference Template",similarity:0,sections:a,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:d.decision_scope_description||""},fields:{}}}}]}},O=function(r){var x,C,S,k=r.variants,O=void 0===k?[]:k,P=r.treeData,V=r.comparisonConfig,K=r.onSelectVariant;r.onSkip,r.onBack;var N=r.targetVariantId,U=r.highlightedField;r.onBadgeClick,r.activeBadgeId;var q=l(null),Y=q[0],G=q[1],J=a(function(){return(null==P?void 0:P.cognitive_decisioning)||{}},[P]),$=c(null),X=l(null),Z=X[0],Q=X[1],ee=c(null),ne=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null}),te=ne[0],ie=ne[1],re=c(null),oe=c(null),le=c(null),ae=c(!1),ce=s(function(){var e;if(te.anchorEl&&te.refSectionTitle){var n=te.anchorEl.getBoundingClientRect(),t=(null===(e=null==ee?void 0:ee.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12,o=n.top-12,l=r<t&&o>r,a=l?n.top-12-t:n.bottom+12,c=n.left+n.width/2,s=c-i/2,d=Math.max(12,Math.min(s,window.innerWidth-i-12)),u=Math.max(14,Math.min(c-d,i-z-4));Q({top:a,left:d,arrowLeft:u,openAbove:l})}},[te.anchorEl,te.refSectionTitle]);d(function(){if(te.open){window.addEventListener("resize",ce);var e=requestAnimationFrame(ce);return function(){cancelAnimationFrame(e),window.removeEventListener("resize",ce)}}},[te.open,ce]),d(function(){var n=oe.current;if(n&&te.open){var t=function(n){console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),ie(function(n){return e(e({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})})};return n.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){n.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[te.open]);var se=a(function(){var n,t,i,r,o,l,a,c,s,d,u,p;return{fields:null!==(n=null==V?void 0:V.fields)&&void 0!==n?n:L,thresholds:{high:null!==(i=null===(t=null==V?void 0:V.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:H.thresholds.high,medium:null!==(o=null===(r=null==V?void 0:V.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:H.thresholds.medium,exact:null!==(a=null===(l=null==V?void 0:V.thresholds)||void 0===l?void 0:l.exact)&&void 0!==a?a:H.thresholds.exact},relationStyles:{noContent:e(e({},H.relationStyles.noContent),(null===(c=null==V?void 0:V.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e(e({},H.relationStyles.high),(null===(s=null==V?void 0:V.relationStyles)||void 0===s?void 0:s.high)||{}),exact:e(e({},H.relationStyles.exact),(null===(d=null==V?void 0:V.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},H.relationStyles.medium),(null===(u=null==V?void 0:V.relationStyles)||void 0===u?void 0:u.medium)||{}),low:e(e({},H.relationStyles.low),(null===(p=null==V?void 0:V.relationStyles)||void 0===p?void 0:p.low)||{})}}},[V]),de=a(function(){if(P&&Object.keys(P).length>0)try{var n=M(P);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:O||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:O||[],parseError:null}},[P,O]),ue=de.activeProposed,pe=de.activeVariants,he=de.parseError;d(function(){he&&G("Failed to load comparison: ".concat(he))},[he]);var ge=l(N||null),fe=ge[0],xe=ge[1],ve=l(!1),me=ve[0],be=ve[1],ye=l(null),Fe=ye[0],we=ye[1],Ee=l({}),Ce=Ee[0],Se=Ee[1];d(function(){if(N&&xe(N),we(null!=U?U:null),U){var e=setTimeout(function(){return we(null)},6e3);return function(){return clearTimeout(e)}}},[N,U]);var ke=function(e){var n;null===(n=re.current)||void 0===n||n.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},De=a(function(){return n([],pe,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[pe]),Be=a(function(){if(fe){var e=String(fe).trim();return pe.find(function(n){return n.id&&String(n.id).trim()===e})||De[0]}return De[0]||null},[fe,pe,De]);d(function(){fe&&re.current&&setTimeout(function(){var e=document.getElementById("variant-card-".concat(fe.trim())),n=re.current;if(e&&n){var t=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:t,behavior:"smooth"})}},150)},[fe,De]);var Ae=Be||{id:"",title:""},Re=A(ue.title)||"Uploaded Contract",Ie=A(Ae.title)||"Reference Template",_e=ue.sections||[],ze=Ae.sections||[],We=_e.length>0||ze.length>0,Te=null==Be?void 0:Be.analysis,Le=A(null===(C=null===(x=null==Te?void 0:Te.rule_difference_comparison)||void 0===x?void 0:x.summary)||void 0===C?void 0:C.overall_summary),He=!!Le.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),je=null!==(S=null==Be?void 0:Be.similarity)&&void 0!==S?S:0,Me=c({}),Oe=function(e){return Me.current[e]||(Me.current[e]=o.createRef()),Me.current[e]};d(function(){!fe&&!N&&De.length>0&&!De[0].isLoading&&xe(De[0].id)},[De,fe,N]);var Pe=c(null),Ve=c(null),Ke=c(null),Ne=l([]),Ue=Ne[0],qe=Ne[1],Ye=l(null),Ge=Ye[0],Je=Ye[1],$e=l(!1),Xe=$e[0],Ze=$e[1],Qe=l(!1),en=Qe[0],nn=Qe[1];d(function(){var e=re.current;if(e){var n=function(){Ze(e.scrollLeft>0),nn(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[De]);var tn=a(function(){return se.fields.filter(function(e){var n=e.key;return(!We||"description"!==n)&&(j(ue[n])||j(Ae[n]))})},[ue,Ae,We,se.fields]),rn=c({}),on=c({}),ln=c({}),an=c({});tn.forEach(function(e){var n=e.key;rn.current[n]||(rn.current[n]=o.createRef()),on.current[n]||(on.current[n]=o.createRef())});for(var cn=0;cn<Math.max(_e.length,ze.length);cn+=1)ln.current[cn]||(ln.current[cn]=o.createRef()),an.current[cn]||(an.current[cn]=o.createRef());d(function(){if(Fe){var e=se.fields.find(function(e){return e.analysisKey===Fe||e.key===Fe});if(e){var n=rn.current[e.key]||on.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fe,se.fields]);var sn=function(e){var n,t,i,r,o,l,a,c,s,d=null===(n=null==Te?void 0:Te.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var u=d[e],p=(null==u?void 0:u.relation)||(null===(i=null===(t=null==u?void 0:u.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==u?void 0:u.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==u?void 0:u.mappings)&&u.mappings.length>0;if(u.mappings){var h=u.mappings[0]||{};return{score:u.score,relation:h.relation||"",highlightsA:(null===(l=h.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(a=h.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!p}}return{score:u.score,relation:u.relation||"",highlightsA:(null===(c=u.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(s=u.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!p}},dn=function(n){var t=ze[n];if("not_defined"===(null==t?void 0:t.relation))return e(e({},se.relationStyles.noContent),{label:"Not Defined"});var i,r=sn("description");if(null!=(null==t?void 0:t.cognitiveRelevanceScore)){var o=(i=t.cognitiveRelevanceScore)>=90?{score:1,relation:"exact_match"}:i>=70?{score:.8,relation:"high_match"}:i>=40?{score:.5,relation:"partial_match"}:{score:0,relation:"no_deviation"};return I(o.score,o.relation,!0,se)}var l=null!=(null==t?void 0:t.relation)&&""!==t.relation?t.relation:r.relation,a="number"==typeof(null==t?void 0:t.score)?t.score:r.score;return I(a,l,!0,se)},un=function(){var e,n,t;if(!ae.current){ae.current=!0;try{if(!Pe.current)return;var i=Pe.current.getBoundingClientRect(),r=[];tn.forEach(function(e){var n=e.key,t=e.analysisKey,o=rn.current[n],l=on.current[n];if((null==o?void 0:o.current)&&(null==l?void 0:l.current)){o.current.style.height="auto",l.current.style.height="auto",o.current.style.minHeight="0px",l.current.style.minHeight="0px";var a=o.current.getBoundingClientRect().height,c=l.current.getBoundingClientRect().height,s=Math.max(a,c);o.current.style.minHeight="".concat(s,"px"),l.current.style.minHeight="".concat(s,"px");var d=o.current.getBoundingClientRect(),u=l.current.getBoundingClientRect(),p=sn(t),h=I(p.score,p.relation,p.hasContent,se);if(!h)return;var g=d.top+d.height/2-i.top;r.push({id:"field-".concat(n),x1:d.right-i.left,y1:g,x2:u.left-i.left,y2:g,style:h})}});for(var o=Math.min(_e.length,ze.length),l=0;l<o;l+=1){var a=ln.current[l],c=an.current[l];if((null==a?void 0:a.current)&&(null==c?void 0:c.current)){a.current.style.height="auto",c.current.style.height="auto",a.current.style.minHeight="0px",c.current.style.minHeight="0px";var s=Math.max(a.current.getBoundingClientRect().height,c.current.getBoundingClientRect().height);a.current.style.minHeight="".concat(s,"px"),c.current.style.minHeight="".concat(s,"px");var d=a.current.querySelector(".MuiAccordionSummary-root"),u=c.current.querySelector(".MuiAccordionSummary-root");if(d&&u){var p=d.getBoundingClientRect(),h=u.getBoundingClientRect(),g=(p.top+p.height/2-i.top+h.top+h.height/2-i.top)/2,f=(null===(e=ze[l])||void 0===e?void 0:e.id)||"sec-".concat(l),x=dn(l);x&&r.push({id:f,x1:p.right-i.left,y1:g,x2:h.left-i.left,y2:g,style:x,sectionIdx:l,hasCognitive:!(!(null===(n=_e[l])||void 0===n?void 0:n.cognitiveData)&&!(null===(t=ze[l])||void 0===t?void 0:t.cognitiveData))})}}}if(qe(r),Ve.current&&Ke.current){var v=Ve.current.getBoundingClientRect(),m=Ke.current.getBoundingClientRect(),b=(v.top+v.height/2-i.top+m.top+m.height/2-i.top)/2;Je({x1:v.right-i.left,x2:m.left-i.left,y:b})}else Je(null)}catch(e){console.error("Line render safe fail: ",e)}finally{ae.current=!1}}};d(function(){var e=setTimeout(un,250);window.addEventListener("resize",un);var n=null;return oe.current&&(n=new ResizeObserver(function(){return window.requestAnimationFrame(un)})).observe(oe.current),function(){clearTimeout(e),window.removeEventListener("resize",un),null==n||n.disconnect()}},[ue,Ae,Te,me,tn,Ce,_e,ze,se]);var pn={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul, & ol":{mt:0,mb:1.5,pl:2.5},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}},hn=function(n,r,o,l){return i(u,e({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:t(v,e({disableGutters:!0,expanded:!!Ce[r],onChange:function(){return n=r,void Se(function(t){var i;return e(e({},t),((i={})[n]=!t[n],i))});var n},sx:{boxShadow:"none",border:"1px solid #E2E8F0",bgcolor:"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[i(m,e({expandIcon:i(E,{size:16}),sx:{minHeight:"36px",flexShrink:0,"& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:i(p,e({sx:{fontSize:"12px",color:"#19213D",fontWeight:500,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:R(n.title||"Section ".concat(r+1))}))})),t(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[i(p,e({component:"div",sx:pn},{children:i(B,{children:A(n.content).replace(/\\n/g,"\n")})})),(n.subsections||[]).map(function(n,t){return i(u,e({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:i(p,e({component:"div",sx:pn},{children:i(B,{children:A(n).replace(/\\n/g,"\n")})}))}),"".concat(o,"-sub-").concat(r,"-").concat(t))})]}))]}))}),"".concat(o,"-sec-").concat(r))};return t(u,e({ref:le,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[te.open&&i(W,{open:te.open,popupRef:ee,position:Z,onClose:function(){return ie(function(n){return e(e({},n),{open:!1})})},sectionTitle:te.sectionTitle,referenceSectionTitle:te.refSectionTitle,cognitiveData:te.cognitiveData,anchorEl:te.anchorEl,sectionAnchorEl:te.sectionAnchorEl,scrollContainerEl:oe.current,badgeStyle:te.badgeStyle}),i(h,e({open:!!Y,autoHideDuration:8e3,onClose:function(){return G(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(g,e({onClose:function(){return G(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Y}))})),i(u,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:i(u,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:"Learning Comparison"}))}))})),De.length>1&&t(u,e({sx:{px:3,pb:.25},ref:$},{children:[t(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[i(p,e({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),t(u,e({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[i(f,e({onClick:function(){return ke("left")},size:"small",disabled:!Xe},{children:i(y,{size:18})})),i(f,e({onClick:function(){return ke("right")},size:"small",disabled:!en},{children:i(F,{size:18})}))]}))]})),i(u,e({ref:re,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"}}},{children:De.map(function(e){return i(T,{data:e,isSelected:(null==Be?void 0:Be.id)===e.id,isCognitiveOpen:me,onToggleCognitive:function(){return be(function(e){return!e})},onClick:function(){return xe((n=e).id),K(n),void be(!1);var n}},e.id)})}))]})),i(u,e({ref:oe,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:Le&&He&&me?"none":"1.5px solid #EEF0F4"}},{children:i(u,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:t(u,e({ref:Pe,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[t("svg",e({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[Ge&&t("g",{children:[i("line",{x1:Ge.x1,y1:Ge.y,x2:Math.max(Ge.x1,(Ge.x1+Ge.x2)/2-70),y2:Ge.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),i("line",{x1:Math.min(Ge.x2,(Ge.x1+Ge.x2)/2+70),y1:Ge.y,x2:Ge.x2,y2:Ge.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Ue.map(function(n,r){var o=(n.x1+n.x2)/2;return n.id||"line-".concat(r),"Not Defined"===n.style.label?null:t("g",{children:[i("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder,strokeWidth:"1.5"}),i("foreignObject",e({x:o-75,y:n.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(u,e({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"},onClick:function(e){e.stopPropagation(),function(e,n,t,i,r){var o,l;e.stopPropagation();var a=A(n.id)||A(t.id)||"",c=(a?J[a]:null)||n.cognitiveData||t.cognitiveData||null,s=null!==(l=null===(o=Me.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;ie({open:!0,sectionTitle:n.title||"Section",refSectionTitle:t.title||"Reference Section",cognitiveData:c,anchorEl:e.currentTarget,sectionAnchorEl:s,badgeStyle:r||null,sectionIdx:i})}(e,_e[n.sectionIdx]||{title:"",content:""},ze[n.sectionIdx]||{title:"",content:""},n.sectionIdx,n.style)}},{children:[n.style.label,n.hasCognitive&&void 0!==n.sectionIdx&&i(u,e({sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",px:"4px",ml:"2px",color:n.style.badgeText,transition:"background 0.15s","&:hover":{backgroundColor:"rgba(0,0,0,0.05)"}}},{children:i("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:i(D,{})}))})),te.open&&te.sectionIdx===n.sectionIdx?i(w,{size:12,color:n.style.badgeText}):i(E,{size:12,color:n.style.badgeText})]}))}))}))]},r)})]})),t(u,e({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[i(u,e({ref:Ve,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:Re}))})),t(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[tn.map(function(e){var n=e.key,t=e.label,r=e.analysisKey,o=sn(r),l=ue[n],a=Ae[n];if(!j(l)&&!j(a))return null;var c=I(o.score,o.relation,o.hasContent,se);return c?i(_,{ref:rn.current[n],label:t,content:l,highlights:o.highlightsA,styleVariant:c,isHighlighted:Fe===r||Fe===n},"left-".concat(n)):null}),We&&_e.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return j(n.title)||j(n.content)||(n.subsections||[]).some(j)}).map(function(n){var t=n.section,r=n.idx;return i(u,e({ref:Oe(r)},{children:hn(t,r,"left",ln.current[r]||o.createRef())}),"left-row-".concat(r))})]}))]})),i(u,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:i(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(u,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[i(u,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(D,{})})),je,"% Similarity",i(E,{size:11})]}))}))})),t(u,e({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[i(u,e({ref:Ke,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:Ie}))})),t(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[tn.map(function(e){var n=e.key,t=e.label,r=e.analysisKey,o=sn(r),l=ue[n],a=Ae[n];if(!j(l)&&!j(a))return null;var c=I(o.score,o.relation,o.hasContent,se);return c?i(_,{ref:on.current[n],label:t,content:a,highlights:o.highlightsB,styleVariant:c,isHighlighted:Fe===r||Fe===n},"right-".concat(n)):null}),We&&ze.map(function(e,n){return{section:e,idx:n}}).filter(function(e){var n=e.section;return j(n.title)||j(n.content)||(n.subsections||[]).some(j)}).map(function(e){var n=e.section,t=e.idx;return hn(n,t,"right",an.current[t]||o.createRef())})]}))]}))]}))}))}))]}))};export{H as DEFAULT_COMPARISON_CONFIG,L as DEFAULT_FIELD_CONFIG,O as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;CACH;AAED,UAAU,kBAAkB;IAC1B,0BAA0B,EAAE;QAC1B,OAAO,EAAE;YACP,aAAa,EAAE,MAAM,CAAC;YACtB,eAAe,EAAE,MAAM,CAAC;SACzB,CAAC;QACF,MAAM,EAAE;YACN,CAAC,GAAG,EAAE,MAAM,GACR,uBAAuB,GACvB;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;aAAE,CAAC;SAC5D,CAAC;KACH,CAAC;CACH;AAED,UAAU,yBAAyB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE;QACT,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,aAAa,CAAC,EAAE,yBAAyB,CAAC;KAC3C,EAAE,CAAC;CACL;AAQD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACtC,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpE,eAAe,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC7C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,cAAc,EAAE;QACd,SAAS,EAAE,kBAAkB,CAAC;QAC9B,IAAI,EAAE,kBAAkB,CAAC;QACzB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,MAAM,EAAE,kBAAkB,CAAC;QAC3B,GAAG,EAAE,kBAAkB,CAAC;KACzB,CAAC;CACH,CAAC;AA67BF,eAAO,MAAM,oBAAoB,EAAE,eAAe,EAGjD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,gBA6CvC,CAAC;AAkIF,QAAA,MAAM,gBAAgB,+IAWnB,qBAAqB,4CAiyCvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|