@viswa-test/test-citation 0.0.226 → 0.0.227
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +270 -0
- package/dist/assests/svg/NeuralNetworkIcon.js +2 -0
- package/dist/assests/svg/NeuralNetworkIcon.js.map +1 -0
- package/dist/cjs/assests/svg/NeuralNetworkIcon.js +2 -0
- package/dist/cjs/assests/svg/NeuralNetworkIcon.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useStyles.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitation.js +2 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitation.js.map +1 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitation.module.css.js +2 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitation.module.css.js.map +1 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +2 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js.map +1 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationImageFullScreenView.js +2 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationImageFullScreenView.js.map +1 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationSkeleton.js +2 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationSkeleton.js.map +1 -0
- package/dist/cjs/features/GptWebCitation/utils/citationData.utils.js +2 -0
- package/dist/cjs/features/GptWebCitation/utils/citationData.utils.js.map +1 -0
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/AttachedContext.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/AttachedContext.module.css.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/UserStoryCard.module.css.js +1 -1
- package/dist/cjs/features/RequirementAI/components/ai-reasoning/AiReasoningCitation.js +1 -1
- package/dist/cjs/features/RequirementAI/components/ai-reasoning/AiReasoningCitationContent.js +1 -1
- package/dist/cjs/features/RequirementAI/components/ai-reasoning/ScannedCitationRenderer.js +1 -1
- package/dist/cjs/features/RequirementAI/components/segment/Segment.js +1 -1
- package/dist/cjs/features/RequirementAI/components/segment/segment-common.css.js +1 -1
- package/dist/cjs/features/RequirementAI/components/segment/segment.module.css.js +1 -1
- package/dist/cjs/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
- package/dist/cjs/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.module.css.js +1 -1
- package/dist/cjs/features/RequirementAiCitations/WebCitation/WebCitationWithImageContent.js +1 -1
- package/dist/cjs/features/RequirementAiCitations/WebCitation/WebCitationWithImageContent.module.css.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useStyles.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitation.js +2 -0
- package/dist/features/GptWebCitation/GptWebCitation.js.map +1 -0
- package/dist/features/GptWebCitation/GptWebCitation.module.css.js +2 -0
- package/dist/features/GptWebCitation/GptWebCitation.module.css.js.map +1 -0
- package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +2 -0
- package/dist/features/GptWebCitation/GptWebCitationImageCitation.js.map +1 -0
- package/dist/features/GptWebCitation/GptWebCitationImageFullScreenView.js +2 -0
- package/dist/features/GptWebCitation/GptWebCitationImageFullScreenView.js.map +1 -0
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
- package/dist/features/GptWebCitation/GptWebCitationSkeleton.js +2 -0
- package/dist/features/GptWebCitation/GptWebCitationSkeleton.js.map +1 -0
- package/dist/features/GptWebCitation/utils/citationData.utils.js +2 -0
- package/dist/features/GptWebCitation/utils/citationData.utils.js.map +1 -0
- package/dist/features/RequirementAI/components/UserStoryCard/AttachedContext.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/AttachedContext.module.css.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/UserStoryCard.module.css.js +1 -1
- package/dist/features/RequirementAI/components/ai-reasoning/AiReasoningCitation.js +1 -1
- package/dist/features/RequirementAI/components/ai-reasoning/AiReasoningCitationContent.js +1 -1
- package/dist/features/RequirementAI/components/ai-reasoning/ScannedCitationRenderer.js +1 -1
- package/dist/features/RequirementAI/components/segment/Segment.js +1 -1
- package/dist/features/RequirementAI/components/segment/segment-common.css.js +1 -1
- package/dist/features/RequirementAI/components/segment/segment.module.css.js +1 -1
- package/dist/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
- package/dist/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.module.css.js +1 -1
- package/dist/features/RequirementAiCitations/WebCitation/WebCitationWithImageContent.js +1 -1
- package/dist/features/RequirementAiCitations/WebCitation/WebCitationWithImageContent.module.css.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts +0 -10476
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/DeviationSummaryTest.d.ts +2 -0
- package/dist/types/src/DeviationSummaryTest.d.ts.map +1 -0
- package/dist/types/src/assests/svg/NeuralNetworkIcon.d.ts +9 -0
- package/dist/types/src/assests/svg/NeuralNetworkIcon.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +6 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useStyles.d.ts +3 -2
- package/dist/types/src/features/CognitiveCompare/hooks/useStyles.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts +5 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +8 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageFullScreenView.d.ts +8 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageFullScreenView.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationMarkdown.d.ts +9 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationMarkdown.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationSkeleton.d.ts +3 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationSkeleton.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationTest.d.ts +4 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitationTest.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/WebCitationSampleResponse.d.ts +4 -0
- package/dist/types/src/features/GptWebCitation/WebCitationSampleResponse.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/types.d.ts +112 -0
- package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/utils/citationData.utils.d.ts +8 -0
- package/dist/types/src/features/GptWebCitation/utils/citationData.utils.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/AttachedContext.d.ts +1 -3
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/AttachedContext.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts +6 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts +13 -3
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/ai-reasoning/AiReasoningCitationContent.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/ai-reasoning/ScannedCitationRenderer.d.ts +1 -1
- package/dist/types/src/features/RequirementAI/components/ai-reasoning/ScannedCitationRenderer.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/segment/Segment.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts +3 -1
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
- [CognitiveDecisioningCard](#cognitivedecisioningcard) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/CognitiveDecisioning/CognitiveDecisioningReadme.md)
|
|
14
14
|
- [CognitiveCompare](#cognitivecompare) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/new-compare-ui/citation/src/features/CognitiveCompare/README.md)
|
|
15
15
|
- [CognitiveInternalGPTReasoning](#cognitiveinternalgptreasoning) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/CognitiveInternalgptReasoning/README.md)
|
|
16
|
+
- [GptWebCitation](#gptwebcitation)
|
|
16
17
|
- [CodeCitation](#codecitation) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/CodeCitation/README.md)
|
|
17
18
|
- [ChatDrawer](#chatdrawer) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/ChatDrawer/ChatDrawerReadme.md)
|
|
18
19
|
- [CitationsViewer](#citationsviewer) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/CitationViewer/CitationViewerReadme.md)
|
|
@@ -672,6 +673,275 @@ const reasoningData = {
|
|
|
672
673
|
|
|
673
674
|
---
|
|
674
675
|
|
|
676
|
+
## GptWebCitation
|
|
677
|
+
|
|
678
|
+
### Overview
|
|
679
|
+
|
|
680
|
+
`GptWebCitation` is a composite React component that wraps the GPT reasoning citation (`CognitiveInternalgptCoreComponent`) and adds an optional **Web Citation** view. Users can toggle between GPT and web-based citations without modifying the underlying GPT citation code.
|
|
681
|
+
|
|
682
|
+
In **GPT view**, the component renders the standard GPT citation panel with a **View Web Citation** button on the left and the document source link on the right (inside the GPT citation footer). In **Web Citation view**, it shows a web snapshot (image or markdown content) with highlight navigation, relevance score, and a **View GPT Citation** toggle to switch back.
|
|
683
|
+
|
|
684
|
+
### Features
|
|
685
|
+
|
|
686
|
+
- **Dual citation views** — Toggle between GPT reasoning and web-based citation
|
|
687
|
+
- **Non-invasive GPT integration** — Wraps `CognitiveInternalgptCoreComponent` via props; no changes to GPT citation code required
|
|
688
|
+
- **Image & markdown web citations** — Supports screenshot snapshots (`imageMetadata.signed_url`) or HTML/markdown content
|
|
689
|
+
- **Highlight pagination** — Navigate between highlighted anchors in web citation markdown
|
|
690
|
+
- **Relevance score badge** — Auto-extracted from web citation content (e.g. "decision strength is 85%")
|
|
691
|
+
- **Loading skeleton** — Built-in loading state while web citation is being generated
|
|
692
|
+
- **Expand screenshot button** — Optional full-screen image view (`showExpandImageButton`)
|
|
693
|
+
- **Style overrides** — Customize layout via the `styles` prop without editing component internals
|
|
694
|
+
|
|
695
|
+
### Installation / Import
|
|
696
|
+
|
|
697
|
+
```tsx
|
|
698
|
+
import GptWebCitation from '@e-llm-studio/citation/GptWebCitation';
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
### Usage 1: Basic GPT + Web Citation Toggle
|
|
702
|
+
|
|
703
|
+
```tsx
|
|
704
|
+
import { useState } from 'react';
|
|
705
|
+
import { ChevronDown, ChevronUp, Maximize2, X } from 'lucide-react';
|
|
706
|
+
import GptWebCitation from '@e-llm-studio/citation/GptWebCitation';
|
|
707
|
+
|
|
708
|
+
const gptCitation = {
|
|
709
|
+
item: {
|
|
710
|
+
confidence_score: 100,
|
|
711
|
+
text: 'Standard financial data interpretation patterns.',
|
|
712
|
+
dataSource:
|
|
713
|
+
'Title: Commodity Market Analysis\n\n- <highlight>Verify the most recent timestamp in search results.</highlight>\n- Analyze safe-haven asset demand and geopolitical triggers.',
|
|
714
|
+
paraphrase: 'Market interpretation patterns for commodity price reporting.',
|
|
715
|
+
},
|
|
716
|
+
headerTitle: 'Summary Citations',
|
|
717
|
+
index: 0,
|
|
718
|
+
iconsConfig: {
|
|
719
|
+
ChevronDownIcon: ChevronDown,
|
|
720
|
+
ChevronUpIcon: ChevronUp,
|
|
721
|
+
MaximizeIcon: Maximize2,
|
|
722
|
+
CloseIcon: X,
|
|
723
|
+
},
|
|
724
|
+
DocumentTitle: 'Source : Employee Handbook - Code of Conduct Section.pdf',
|
|
725
|
+
previewCallback: () => window.open('/preview/document'),
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
function CitationPanel() {
|
|
729
|
+
const [showWebCitation, setShowWebCitation] = useState(false);
|
|
730
|
+
const [webCitationData, setWebCitationData] = useState(undefined);
|
|
731
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
732
|
+
|
|
733
|
+
const handleGenerateWebCitation = async () => {
|
|
734
|
+
setShowWebCitation(true);
|
|
735
|
+
setIsLoading(true);
|
|
736
|
+
|
|
737
|
+
const response = await fetch('/api/web-citation/generate');
|
|
738
|
+
const data = await response.json();
|
|
739
|
+
|
|
740
|
+
setWebCitationData(data);
|
|
741
|
+
setIsLoading(false);
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
return (
|
|
745
|
+
<GptWebCitation
|
|
746
|
+
gptCitation={gptCitation}
|
|
747
|
+
isWebCitation={true}
|
|
748
|
+
webCitationData={webCitationData}
|
|
749
|
+
showWebCitation={showWebCitation}
|
|
750
|
+
isWebCitationLoading={isLoading}
|
|
751
|
+
onGenerateWebCitation={handleGenerateWebCitation}
|
|
752
|
+
onToggleCitationView={() => setShowWebCitation((prev) => !prev)}
|
|
753
|
+
/>
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
### Usage 2: Web Citation API Response Shape
|
|
759
|
+
|
|
760
|
+
Pass the API response from your web citation service as `webCitationData`:
|
|
761
|
+
|
|
762
|
+
```tsx
|
|
763
|
+
const webCitationData = {
|
|
764
|
+
citationId: '550e8400-e29b-41d4-a716-446655440061',
|
|
765
|
+
content:
|
|
766
|
+
'The decision strength is 85% because:<ol><li>The exact <a href="https://example.com/article">valuation of SpaceX</a> fluctuates between sources.</li></ol>',
|
|
767
|
+
citationType: 'web',
|
|
768
|
+
citationUrl: 'https://example.com/article',
|
|
769
|
+
imageMetadata: {
|
|
770
|
+
signed_url: 'https://storage.example.com/image_citations/screenshot.png',
|
|
771
|
+
blob_path: 'image_citations/screenshot.png',
|
|
772
|
+
gs_uri: 'gs://bucket/image_citations/screenshot.png',
|
|
773
|
+
},
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
<GptWebCitation
|
|
777
|
+
gptCitation={gptCitation}
|
|
778
|
+
isWebCitation={true}
|
|
779
|
+
webCitationData={webCitationData}
|
|
780
|
+
showWebCitation={true}
|
|
781
|
+
/>
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
When `imageMetadata.signed_url` is present, the component renders a screenshot snapshot. Otherwise it falls back to rendering the `content` field as markdown/HTML.
|
|
785
|
+
|
|
786
|
+
### Usage 3: GPT-Only Mode (No Web Citation)
|
|
787
|
+
|
|
788
|
+
Set `isWebCitation={false}` to render only the GPT citation with no toggle button:
|
|
789
|
+
|
|
790
|
+
```tsx
|
|
791
|
+
<GptWebCitation
|
|
792
|
+
gptCitation={gptCitation}
|
|
793
|
+
isWebCitation={false}
|
|
794
|
+
/>
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
### Usage 4: Hide Expand Buttons
|
|
798
|
+
|
|
799
|
+
Hide the web citation screenshot expand button:
|
|
800
|
+
|
|
801
|
+
```tsx
|
|
802
|
+
<GptWebCitation
|
|
803
|
+
gptCitation={gptCitation}
|
|
804
|
+
isWebCitation={true}
|
|
805
|
+
webCitationData={webCitationData}
|
|
806
|
+
showWebCitation={true}
|
|
807
|
+
showExpandImageButton={false}
|
|
808
|
+
/>
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
Hide the GPT citation header maximize/expand icon:
|
|
812
|
+
|
|
813
|
+
```tsx
|
|
814
|
+
<GptWebCitation
|
|
815
|
+
gptCitation={gptCitation}
|
|
816
|
+
isWebCitation={true}
|
|
817
|
+
showGptMaximizeButton={false}
|
|
818
|
+
/>
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
You can also use `gptCitation.disableMaximize: true` directly on the GPT config.
|
|
822
|
+
|
|
823
|
+
### Usage 5: Custom Styling via Props (matched heights)
|
|
824
|
+
|
|
825
|
+
Layout, borders, and heights for **both GPT and web views** can be controlled from the parent without modifying component internals:
|
|
826
|
+
|
|
827
|
+
```tsx
|
|
828
|
+
const sharedPanelHeight = '520px';
|
|
829
|
+
const sharedContentHeight = '384px';
|
|
830
|
+
|
|
831
|
+
<GptWebCitation
|
|
832
|
+
gptCitation={{
|
|
833
|
+
...gptCitation,
|
|
834
|
+
bodyHeight: sharedContentHeight,
|
|
835
|
+
}}
|
|
836
|
+
isWebCitation={true}
|
|
837
|
+
webCitationData={webCitationData}
|
|
838
|
+
showGptMaximizeButton={true}
|
|
839
|
+
styles={{
|
|
840
|
+
container: { maxWidth: 900 },
|
|
841
|
+
gptCitation: {
|
|
842
|
+
wrapper: {
|
|
843
|
+
minHeight: sharedPanelHeight,
|
|
844
|
+
border: '1px solid #e5e7eb',
|
|
845
|
+
borderRadius: 8,
|
|
846
|
+
},
|
|
847
|
+
footerAction: { left: '1.5rem' },
|
|
848
|
+
toggleButton: { minWidth: 180, fontSize: 14 },
|
|
849
|
+
},
|
|
850
|
+
webCitation: {
|
|
851
|
+
panel: {
|
|
852
|
+
minHeight: sharedPanelHeight,
|
|
853
|
+
border: '1px solid #e5e7eb',
|
|
854
|
+
borderRadius: 8,
|
|
855
|
+
},
|
|
856
|
+
header: { padding: '8px 16px' },
|
|
857
|
+
content: {
|
|
858
|
+
minHeight: sharedContentHeight,
|
|
859
|
+
maxHeight: sharedContentHeight,
|
|
860
|
+
overflowY: 'auto',
|
|
861
|
+
},
|
|
862
|
+
footer: { padding: '8px 16px' },
|
|
863
|
+
toggleButton: { minWidth: 180, fontSize: 14 },
|
|
864
|
+
learnedFrom: { fontSize: 13 },
|
|
865
|
+
},
|
|
866
|
+
}}
|
|
867
|
+
/>
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
#### Style keys
|
|
871
|
+
|
|
872
|
+
| Key | Applies to | Description |
|
|
873
|
+
|-----|------------|-------------|
|
|
874
|
+
| `container` | Both views | Shared outer wrapper (`overlay` in GPT view, merged into web `panel`) |
|
|
875
|
+
| `gptCitation.wrapper` | GPT view | Border card around GPT citation (left/right borders restored here) |
|
|
876
|
+
| `gptCitation.footerAction` | GPT view | View Web Citation button row in footer |
|
|
877
|
+
| `gptCitation.toggleButton` | GPT view | View Web Citation button styles |
|
|
878
|
+
| `webCitation.panel` | Web view | Outer web citation card |
|
|
879
|
+
| `webCitation.header` | Web view | Source label + pagination + score badge row |
|
|
880
|
+
| `webCitation.content` | Web view | Main content area (markdown, image, skeleton) |
|
|
881
|
+
| `webCitation.footer` | Web view | View GPT Citation + Learned From row |
|
|
882
|
+
| `webCitation.toggleButton` | Web view | View GPT Citation button styles |
|
|
883
|
+
| `webCitation.learnedFrom` | Web view | "Learned From …" text styles |
|
|
884
|
+
|
|
885
|
+
Legacy flat keys (`gptCitationWrapper`, `footerAction`, `webCitationButton`) still work for backward compatibility.
|
|
886
|
+
|
|
887
|
+
### Props
|
|
888
|
+
|
|
889
|
+
| Prop | Type | Default | Description |
|
|
890
|
+
|------|------|---------|-------------|
|
|
891
|
+
| `gptCitation` | `IGptCitationConfig` | **required** | GPT citation config passed to `CognitiveInternalgptCoreComponent` (`item`, `headerTitle`, `iconsConfig`, `DocumentTitle`, `previewCallback`, etc.) |
|
|
892
|
+
| `isWebCitation` | `boolean` | `false` | When `true`, enables web citation toggle and web view. When `false`, only GPT citation is shown. |
|
|
893
|
+
| `webCitationData` | `IWebCitationApiResponse` | — | Web citation API response (content, image snapshot, URL) |
|
|
894
|
+
| `showWebCitation` | `boolean` | — | Controls which view is active. Omit for uncontrolled internal state. |
|
|
895
|
+
| `onGenerateWebCitation` | `() => void` | — | Called when user clicks **View Web Citation** and no cached web data exists yet |
|
|
896
|
+
| `isWebCitationLoading` | `boolean` | `false` | Parent-controlled loading state while web citation is being fetched |
|
|
897
|
+
| `onToggleCitationView` | `() => void` | — | Called when user toggles between GPT and web views |
|
|
898
|
+
| `showExpandImageButton` | `boolean` | `true` | Show/hide the full-screen expand button on web citation image snapshots |
|
|
899
|
+
| `showGptMaximizeButton` | `boolean` | `true` | Show/hide the GPT citation header maximize/expand icon (`gptCitation.disableMaximize: true` when `false`) |
|
|
900
|
+
| `topic` | `string` | auto | Override topic label in web citation header (auto-extracted from content if omitted) |
|
|
901
|
+
| `sourceLabel` | `string` | auto | Override header source label in web view |
|
|
902
|
+
| `relevanceScore` | `number` | auto | Override relevance/decision strength score (auto-extracted from content if omitted) |
|
|
903
|
+
| `learnedFrom` | `string` | auto | Site name shown in web citation footer (auto-extracted from `citationUrl` if omitted) |
|
|
904
|
+
| `styles` | `IGptWebCitationStyleOverrides` | — | Style overrides for GPT and web citation views (see Usage 5) |
|
|
905
|
+
|
|
906
|
+
### `IGptCitationConfig` (gptCitation prop)
|
|
907
|
+
|
|
908
|
+
| Field | Type | Description |
|
|
909
|
+
|-------|------|-------------|
|
|
910
|
+
| `item` | `INonReasoningSource` | GPT reasoning data (`dataSource`, `confidence_score`, highlights, etc.) |
|
|
911
|
+
| `headerTitle` | `string` | Panel header title |
|
|
912
|
+
| `index` | `number` | Citation index |
|
|
913
|
+
| `iconsConfig` | `object` | Icon components (`ChevronDownIcon`, `ChevronUpIcon`, `MaximizeIcon`, `CloseIcon`) |
|
|
914
|
+
| `DocumentTitle` | `string` | Source document label shown in the GPT footer (right side) |
|
|
915
|
+
| `previewCallback` | `() => void` | Called when the source link is clicked |
|
|
916
|
+
| `bodyHeight` | `string` | Optional fixed GPT content body height (use with `styles.webCitation.content` to match web view height) |
|
|
917
|
+
| `disableMaximize` | `boolean` | Disable GPT header fullscreen maximize button (or use `showGptMaximizeButton={false}`) |
|
|
918
|
+
|
|
919
|
+
### `IWebCitationApiResponse` (webCitationData prop)
|
|
920
|
+
|
|
921
|
+
| Field | Type | Description |
|
|
922
|
+
|-------|------|-------------|
|
|
923
|
+
| `citationId` | `string` | Unique citation identifier |
|
|
924
|
+
| `content` | `string` | HTML/markdown web citation content |
|
|
925
|
+
| `citationType` | `string` | Citation type (e.g. `"web"`) |
|
|
926
|
+
| `citationUrl` | `string` | Original source URL |
|
|
927
|
+
| `imageMetadata` | `object` | Image snapshot metadata |
|
|
928
|
+
| `imageMetadata.signed_url` | `string` | Signed URL for screenshot image (preferred) |
|
|
929
|
+
| `imageMetadata.gs_uri` | `string` | GCS URI fallback for image |
|
|
930
|
+
| `db` | `object` | Database metadata (`citation_id`, `blob_path`) |
|
|
931
|
+
|
|
932
|
+
### View Behavior
|
|
933
|
+
|
|
934
|
+
| State | What renders |
|
|
935
|
+
|-------|--------------|
|
|
936
|
+
| `isWebCitation={false}` | GPT citation only |
|
|
937
|
+
| `isWebCitation={true}`, `showWebCitation={false}` | GPT citation + **View Web Citation** button (left footer) + source link (right footer) |
|
|
938
|
+
| `isWebCitation={true}`, `showWebCitation={true}` | Web citation panel with snapshot/markdown, highlight nav, and **View GPT Citation** button |
|
|
939
|
+
|
|
940
|
+
### Local Test Component
|
|
941
|
+
|
|
942
|
+
A test harness is available at `src/features/GptWebCitation/GptWebCitationTest.tsx`. Run the citation dev server with `GptWebCitationTest` mounted in `src/index.tsx` to preview the component interactively.
|
|
943
|
+
|
|
944
|
+
---
|
|
675
945
|
|
|
676
946
|
## CodeCitation
|
|
677
947
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as C}from"tslib";import{jsxs as r,jsx as o}from"react/jsx-runtime";var e=function(e){var i=e.className,t=e.size,a=void 0===t?24:t,n=e.color,s=void 0===n?"currentColor":n,d=e["aria-hidden"];return r("svg",C({xmlns:"http://www.w3.org/2000/svg",width:a,height:a,viewBox:"0 0 16 16",fill:"none","aria-hidden":void 0===d||d,className:i},{children:[o("path",{d:"M14.3327 7.9974C14.3327 8.21627 14.2896 8.43299 14.2058 8.6352C14.1221 8.83741 13.9993 9.02114 13.8445 9.17591C13.6898 9.33067 13.506 9.45344 13.3038 9.5372C13.1016 9.62095 12.8849 9.66406 12.666 9.66406C12.4471 9.66406 12.2304 9.62095 12.0282 9.5372C11.826 9.45344 11.6423 9.33067 11.4875 9.17591C11.3327 9.02114 11.21 8.83741 11.1262 8.6352C11.0425 8.43299 10.9993 8.21627 10.9993 7.9974C10.9993 7.55537 11.1749 7.13145 11.4875 6.81888C11.8001 6.50632 12.224 6.33073 12.666 6.33073C13.108 6.33073 13.532 6.50632 13.8445 6.81888C14.1571 7.13145 14.3327 7.55537 14.3327 7.9974ZM8.99935 2.66406C8.99935 2.92928 8.89399 3.18363 8.70646 3.37117C8.51892 3.55871 8.26457 3.66406 7.99935 3.66406C7.73413 3.66406 7.47978 3.55871 7.29224 3.37117C7.10471 3.18363 6.99935 2.92928 6.99935 2.66406C6.99935 2.39885 7.10471 2.14449 7.29224 1.95696C7.47978 1.76942 7.73413 1.66406 7.99935 1.66406C8.26457 1.66406 8.51892 1.76942 8.70646 1.95696C8.89399 2.14449 8.99935 2.39885 8.99935 2.66406ZM8.33268 7.66406C8.33268 7.79538 8.30682 7.92542 8.25656 8.04675C8.20631 8.16807 8.13265 8.27831 8.03979 8.37117C7.94693 8.46403 7.83669 8.53769 7.71537 8.58794C7.59404 8.6382 7.464 8.66406 7.33268 8.66406C7.20136 8.66406 7.07132 8.6382 6.95 8.58794C6.82867 8.53769 6.71843 8.46403 6.62558 8.37117C6.53272 8.27831 6.45906 8.16807 6.4088 8.04675C6.35855 7.92542 6.33268 7.79538 6.33268 7.66406C6.33268 7.39885 6.43804 7.14449 6.62558 6.95696C6.81311 6.76942 7.06747 6.66406 7.33268 6.66406C7.5979 6.66406 7.85225 6.76942 8.03979 6.95696C8.22733 7.144449 8.33268 7.39885 8.33268 7.66406ZM4.33268 4.9974C4.33268 5.35102 4.19221 5.69016 3.94216 5.9402C3.69211 6.19025 3.35297 6.33073 2.99935 6.33073C2.64573 6.33073 2.30659 6.19025 2.05654 5.9402C1.80649 5.69016 1.66602 5.35102 1.66602 4.9974C1.66602 4.64377 1.80649 4.30464 2.05654 4.05459C2.30659 3.80454 2.64573 3.66406 2.99935 3.66406C3.35297 3.66406 3.69211 3.80454 3.94216 4.05459C4.19221 4.30464 4.33268 4.64377 4.33268 4.9974ZM6.99935 12.9974C6.99935 13.351 6.85887 13.6902 6.60882 13.9402C6.35878 14.1903 6.01964 14.3307 5.66602 14.3307C5.31239 14.3307 4.97326 14.1903 4.72321 13.9402C4.47316 13.6902 4.33268 13.351 4.33268 12.9974C4.33268 12.6438 4.47316 12.3046 4.72321 12.0546C4.97326 11.8045 5.31239 11.6641 5.66602 11.6641C6.01964 11.6641 6.35878 11.8045 6.60882 12.0546C6.85887 12.3046 6.99935 12.6438 6.99935 12.9974Z",stroke:s}),o("path",{d:"M9.00065 3.33333L11.6673 6.66667M9.66732 10.3333L7.00065 12.3333M5.33398 11.6667L3.33398 6.33333M4.20932 4.436L7.00065 3M8.33398 7.66667L11.004 7.896M8.00065 3.66667L7.33398 6.66667",stroke:s,strokeWidth:"0.666667",strokeLinecap:"round",strokeLinejoin:"round"})]}))};export{e as default};
|
|
2
|
+
//# sourceMappingURL=NeuralNetworkIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeuralNetworkIcon.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var C=require("tslib"),e=require("react/jsx-runtime");exports.default=function(r){var s=r.className,i=r.size,t=void 0===i?24:i,o=r.color,n=void 0===o?"currentColor":o,a=r["aria-hidden"],d=void 0===a||a;return e.jsxs("svg",C.__assign({xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 16 16",fill:"none","aria-hidden":d,className:s},{children:[e.jsx("path",{d:"M14.3327 7.9974C14.3327 8.21627 14.2896 8.43299 14.2058 8.6352C14.1221 8.83741 13.9993 9.02114 13.8445 9.17591C13.6898 9.33067 13.506 9.45344 13.3038 9.5372C13.1016 9.62095 12.8849 9.66406 12.666 9.66406C12.4471 9.66406 12.2304 9.62095 12.0282 9.5372C11.826 9.45344 11.6423 9.33067 11.4875 9.17591C11.3327 9.02114 11.21 8.83741 11.1262 8.6352C11.0425 8.43299 10.9993 8.21627 10.9993 7.9974C10.9993 7.55537 11.1749 7.13145 11.4875 6.81888C11.8001 6.50632 12.224 6.33073 12.666 6.33073C13.108 6.33073 13.532 6.50632 13.8445 6.81888C14.1571 7.13145 14.3327 7.55537 14.3327 7.9974ZM8.99935 2.66406C8.99935 2.92928 8.89399 3.18363 8.70646 3.37117C8.51892 3.55871 8.26457 3.66406 7.99935 3.66406C7.73413 3.66406 7.47978 3.55871 7.29224 3.37117C7.10471 3.18363 6.99935 2.92928 6.99935 2.66406C6.99935 2.39885 7.10471 2.14449 7.29224 1.95696C7.47978 1.76942 7.73413 1.66406 7.99935 1.66406C8.26457 1.66406 8.51892 1.76942 8.70646 1.95696C8.89399 2.14449 8.99935 2.39885 8.99935 2.66406ZM8.33268 7.66406C8.33268 7.79538 8.30682 7.92542 8.25656 8.04675C8.20631 8.16807 8.13265 8.27831 8.03979 8.37117C7.94693 8.46403 7.83669 8.53769 7.71537 8.58794C7.59404 8.6382 7.464 8.66406 7.33268 8.66406C7.20136 8.66406 7.07132 8.6382 6.95 8.58794C6.82867 8.53769 6.71843 8.46403 6.62558 8.37117C6.53272 8.27831 6.45906 8.16807 6.4088 8.04675C6.35855 7.92542 6.33268 7.79538 6.33268 7.66406C6.33268 7.39885 6.43804 7.14449 6.62558 6.95696C6.81311 6.76942 7.06747 6.66406 7.33268 6.66406C7.5979 6.66406 7.85225 6.76942 8.03979 6.95696C8.22733 7.144449 8.33268 7.39885 8.33268 7.66406ZM4.33268 4.9974C4.33268 5.35102 4.19221 5.69016 3.94216 5.9402C3.69211 6.19025 3.35297 6.33073 2.99935 6.33073C2.64573 6.33073 2.30659 6.19025 2.05654 5.9402C1.80649 5.69016 1.66602 5.35102 1.66602 4.9974C1.66602 4.64377 1.80649 4.30464 2.05654 4.05459C2.30659 3.80454 2.64573 3.66406 2.99935 3.66406C3.35297 3.66406 3.69211 3.80454 3.94216 4.05459C4.19221 4.30464 4.33268 4.64377 4.33268 4.9974ZM6.99935 12.9974C6.99935 13.351 6.85887 13.6902 6.60882 13.9402C6.35878 14.1903 6.01964 14.3307 5.66602 14.3307C5.31239 14.3307 4.97326 14.1903 4.72321 13.9402C4.47316 13.6902 4.33268 13.351 4.33268 12.9974C4.33268 12.6438 4.47316 12.3046 4.72321 12.0546C4.97326 11.8045 5.31239 11.6641 5.66602 11.6641C6.01964 11.6641 6.35878 11.8045 6.60882 12.0546C6.85887 12.3046 6.99935 12.6438 6.99935 12.9974Z",stroke:n}),e.jsx("path",{d:"M9.00065 3.33333L11.6673 6.66667M9.66732 10.3333L7.00065 12.3333M5.33398 11.6667L3.33398 6.33333M4.20932 4.436L7.00065 3M8.33398 7.66667L11.004 7.896M8.00065 3.66667L7.33398 6.66667",stroke:n,strokeWidth:"0.666667",strokeLinecap:"round",strokeLinejoin:"round"})]}))};
|
|
2
|
+
//# sourceMappingURL=NeuralNetworkIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeuralNetworkIcon.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),s=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(T){var D,O,F,j,P,N,k,L,M,q,H,V,z,G,W,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe=T.componentHeaderText,ve=void 0===fe?a.DEFAULT_COMPONENT_HEADER_TEXT:fe,ge=T.treeData,pe=T.comparisonConfig,he=T.leftColumnTitleText,me=T.rightColumnTitleText,Se=T.markdownStyles,Re=T.resetTrigger,xe=T.displayConfig,_e=void 0===xe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:xe,ye=T.onMaintainRelativeOrderChange,be=T.popupConfig,Ce=T.deviationData,Ee=void 0===Ce?{}:Ce,Ae=T.deviationNodeIdToView,Be=T.resetDeviationNodeId,we=T.isProposingFix,Ie=void 0!==we&&we,Te=T.proposingFixNodeId,De=T.isRedlineFlow,Oe=i.useState(_e.maintainRelativeOrder),Fe=Oe[0],je=Oe[1],Pe=null!==(D=null==_e?void 0:_e.expandLevels)&&void 0!==D?D:0,Ne=!!(null==_e?void 0:_e.expandAllSections),ke=!!Fe||!!(null==_e?void 0:_e.showDeviationBadges),Le=i.useState(!1),Me=Le[0],qe=Le[1],He=i.useState(null),Ve=He[0],ze=He[1],Ge=i.useState(null===(F=null!==(O=null==ge?void 0:ge.newEvaluationResult)&&void 0!==O?O:null==_e?void 0:_e.enableDeviationSchemaBackwardCompatibility)||void 0===F||F)[0],We=i.useState(new Set),Ke=We[0],Ue=We[1],Ye=i.useState([]),Je=Ye[0],Xe=Ye[1],$e=i.useState(!1),Qe=$e[0],Ze=$e[1],en=i.useRef(null),nn=i.useRef(null),tn=i.useRef(null),on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(!1),un=i.useRef(null),sn=i.useRef({}),an=i.useRef([]),cn=i.useRef(function(){}),dn=i.useRef(null),fn=i.useRef(function(){}),vn=i.useMemo(function(){return JSON.stringify(Ee||{})},[JSON.stringify(Ee)]),gn=i.useMemo(function(){return Ee||{}},[vn]),pn=i.useMemo(function(){return(null==ge?void 0:ge.cognitive_decisioning)||{}},[ge]),hn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),Se)},[Se]),mn=i.useRef(null),Sn=i.useRef(null),Rn=i.useRef(null),xn=i.useRef(null),_n=i.useRef(null),yn=i.useRef(null),bn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=p.useComparePopups(mn),wn=Bn.cognitivePopup,In=Bn.setCognitivePopup,Tn=Bn.moreFunctions,Dn=Bn.setMoreFunctions,On=Bn.position,Fn=Bn.setPosition,jn=Bn.activeBadgeId,Pn=Bn.summaryPopup,Nn=Bn.setSummaryPopup,kn=Bn.closeSummaryPopup,Ln=Bn.setActiveBadgeId,Mn=Bn.popupRef,qn=Bn.handleOpenCognitiveCompare,Hn=Bn.openCognitivePopupFromState,Vn=Bn.closeCognitivePopup,zn=Bn.closeMoreFunctionsPopup,Gn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==pe?void 0:pe.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==pe?void 0:pe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==pe?void 0:pe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==pe?void 0:pe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[pe]),Wn=i.useState(null),Kn=Wn[0];Wn[1];var Un=null===(N=null===(j=null==ge?void 0:ge.documents)||void 0===j?void 0:j[null===(P=null==ge?void 0:ge.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,Yn=null===(M=null===(k=null==ge?void 0:ge.documents)||void 0===k?void 0:k[null===(L=null==ge?void 0:ge.input_index_map)||void 0===L?void 0:L[1]])||void 0===M?void 0:M.title,Jn=u.safeStringify(he||Un||"Uploaded Contract"),Xn=null===(z=null===(V=null===(q=null==ge?void 0:ge.documents)||void 0===q?void 0:q[null===(H=null==ge?void 0:ge.input_index_map)||void 0===H?void 0:H[0]])||void 0===V?void 0:V.metadata)||void 0===z?void 0:z.file_name,$n=u.safeStringify(Xn),Qn=null===(U=null===(K=null===(G=null==ge?void 0:ge.documents)||void 0===G?void 0:G[null===(W=null==ge?void 0:ge.input_index_map)||void 0===W?void 0:W[1]])||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.file_name,Zn=u.safeStringify(Qn),ei=u.safeStringify(me||Yn||"Reference Template"),ni=g.useCognitiveTreeData(ge,Fe,gn,Gn,Ge),ii=ni.activeProposed,ti=ni.existingRule,oi=ni.proposedSections,ri=ni.existingSections,li=ni.visibleFields,ui=ni.parentDeviationRecord,si=ni.deviationNumberRegistry,ai=ni.deviationParentRegistry,ci=ni.parseError;i.useEffect(function(){ci&&ze("Failed to load comparison: ".concat(ci))},[ci]);var di=oi.length>0||ri.length>0,fi=i.useMemo(function(){if(!De)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";u.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(oi),i(ri),"".concat(e,":").concat(n)},[De,oi,ri]);i.useEffect(function(){if(oi.length||ri.length)if(Ne){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Fe?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(oi,"left"),i(ri,"right"),Ui(e),Ji(n)}else if(Pe>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Fe?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(oi,"left",Pe),r(ri,"right",Pe),Ui(t),Ji(o)}},[Ne,Pe,oi,ri,Fe]);var vi=h.useSectionRefs(li.map(function(e){return e.key}),Math.max(oi.length,ri.length)),gi=vi.leftRefs,pi=vi.rightRefs,hi=vi.sectionLeftRefs,mi=vi.sectionRightRefs,Si=vi.lhsBadgeRefs,Ri=vi.rhsBadgeRefs,xi=vi.sectionRightRowRefs,_i=vi.subSectionLeftRefs,yi=vi.subSectionRightRefs,bi=vi.sectionRowRefs,Ci=vi.getSectionRowRef,Ei=vi.getSubSectionRef,Ai=vi.getBadgeRef,Bi=w.useSideBySide({maintainRelativeOrder:Fe,proposedSections:oi,existingSections:ri,leftContainerRef:Cn,rightContainerRef:Rn,scrollContainerRef:mn,sectionLeftRefs:hi,sectionRightRefs:mi,subSectionLeftRefs:_i,subSectionRightRefs:yi,lhsBadgeRefs:Si,rhsBadgeRefs:Ri,sectionRowRefs:bi,sectionRightRowRefs:xi,rhsTopSpacerRef:xn,rhsBottomSpacerRef:_n,lhsTopSpacerRef:yn,lhsBottomSpacerRef:bn,calculateLinesRef:cn,setConnectedSections:Ue,setConnectedLines:Xe,cachedConnectedPositions:an,closeMoreFunctionsPopup:zn,setErrorToast:ze,moreFunctions:Tn,closeSummaryPopup:kn}),wi=Bi.isSideBySide,Ii=Bi.isArrowVisible,Ti=Bi.setIsArrowVisible,Di=Bi.isResizing,Oi=Bi.setIsResizing,Fi=Bi.isSideBySideLoading,ji=Bi.activeSideBySideSection,Pi=Bi.scrollLock,Ni=Bi.sideBySideCacheRef,ki=Bi.isSideBySideRef,Li=Bi.activeSideBySideRightSectionRef,Mi=Bi.activeSideBySideSectionRef,qi=Bi.sideBySideLineRef,Hi=Bi.highlightedClauseRefs,Vi=Bi.clearClauseHighlight,zi=Bi.resetSideBySide,Gi=Bi.activateSideBySide,Wi=m.useAccordionState({maintainRelativeOrder:!!Fe,proposedSections:oi,existingSections:ri,activeSideBySideSection:ji,connectedSections:Ke,resetSideBySide:zi,setConnectedSections:Ue,setConnectedLines:Xe,cachedConnectedPositions:an,svgContainerRef:en,isAnimatingRef:ln,animationTimerRef:un,calculateLinesRef:cn,sectionLeftRefs:hi,sectionRightRefs:mi,subSectionLeftRefs:_i,subSectionRightRefs:yi}),Ki=Wi.expandedSections,Ui=Wi.setExpandedSections,Yi=Wi.expandedSubSections,Ji=Wi.setExpandedSubSections,Xi=Wi.handleSubSectionToggle,$i=Wi.toggleSection,Qi=Wi.forceExpandCrossWiredSections,Zi=function(){var e,n;if(null!=ji){var i=null===(e=hi.current[ji])||void 0===e?void 0:e.current,t=null===(n=mi.current[ji])||void 0===n?void 0:n.current,o=Rn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},et=i.useCallback(function(e){null==e||e.stopPropagation(),Ze(function(e){var n=!e;return n&&requestAnimationFrame(function(){Zi()}),n})},[Zi]);i.useEffect(function(){De&&"off"!==fi&&"0:0"!==fi&&(Ni.current=null,an.current=[],requestAnimationFrame(function(){var e;null===(e=cn.current)||void 0===e||e.call(cn)}))},[De,fi]);var nt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Fe)oi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),ri.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=oi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(oi.length,ri.length),o=0;o<t;o++){var r=oi[o],l=ri[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[oi,ri,Fe]),it=ti.analysis,tt=u.safeStringify(null===(J=null===(Y=null==it?void 0:it.rule_difference_comparison)||void 0===Y?void 0:Y.summary)||void 0===J?void 0:J.overall_summary),ot=!!tt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),rt=null!==(X=null==ge?void 0:ge.base_root_id)&&void 0!==X?X:"-1";null==ge||ge[rt];var lt=Ge?null!==(se=null!==(re=Ee&&(null===(oe=null==Ee?void 0:Ee[rt])||void 0===oe?void 0:oe.evaluation_result))&&void 0!==re?re:null===(ue=null===(le=null==ge?void 0:ge.nodes)||void 0===le?void 0:le[rt])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==se?se:null:null!==(te=null!==(Z=Ee&&(null===(Q=null===($=null==Ee?void 0:Ee[rt])||void 0===$?void 0:$.evaluation_result)||void 0===Q?void 0:Q[0]))&&void 0!==Z?Z:null===(ie=null===(ne=null===(ee=null==ge?void 0:ge.nodes)||void 0===ee?void 0:ee[rt])||void 0===ne?void 0:ne.evaluation_result)||void 0===ie?void 0:ie[0])&&void 0!==te?te:null,ut=u.extractDeviationScore(lt),st=u.generateColorPalette(null!==(de=null===(ce=null===(ae=null==lt?void 0:lt.evaluation_outputs)||void 0===ae?void 0:ae.metadata)||void 0===ce?void 0:ce.label_color)&&void 0!==de?de:a.DEFAULT_DEVIAION_COLOR),at=i.useRef(zi);i.useEffect(function(){at.current=zi},[zi]);var ct=i.useRef(Vn);i.useEffect(function(){ct.current=Vn},[Vn]);var dt=i.useCallback(function(e,n,i,t,o,r){return ho.current(e,n,i,t,o,r)},[]),ft=i.useCallback(function(e,n,i,t,o){return So.current(e,n,i,t,o)},[]),vt=i.useCallback(function(){return Ro.current()},[]),gt=i.useCallback(function(e,n){return xo.current(e,n)},[]),pt=i.useCallback(function(e){return _o.current(e)},[]),ht=i.useCallback(function(e){return yo.current(e)},[]),mt=i.useCallback(function(){return bo.current()},[]),St=i.useCallback(function(){var e,n;Vi(),null===(e=at.current)||void 0===e||e.call(at),Ze(!1),Ue(new Set),Xe([]),an.current=[],kt([]),Mt(null),Nn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=ct.current)||void 0===n||n.call(ct),requestAnimationFrame(function(){var e;null===(e=cn.current)||void 0===e||e.call(cn)})},[]),Rt=i.useRef(St);i.useEffect(function(){Rt.current=St},[St]),i.useEffect(function(){Re&&Rt.current()},[Re]);var xt=i.useMemo(function(){return{documents:null==ge?void 0:ge.documents,input_index_map:null==ge?void 0:ge.input_index_map}},[JSON.stringify(null==ge?void 0:ge.documents),JSON.stringify(null==ge?void 0:ge.input_index_map)]),_t=i.useRef(ge);i.useEffect(function(){_t.current=ge},[ge]);var yt=i.useRef(pn);i.useEffect(function(){yt.current=pn},[pn]);var bt=i.useCallback(function(n,i,t,o,r,l,s){var a,c,d,f,v,g,p,h,m,S,R=u.safeStringify(null==i?void 0:i.id)||u.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=yt.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=bi.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,s=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return s(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):s(l)}(),b=(null!==(g=null===(v=null===(f=null==y?void 0:y.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(S=null==_e?void 0:_e.isLoading)&&void 0!==S&&S&&!b,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:_,badgeStyle:l||null,sectionIdx:o,docData:xt,deviationData:y,isOrphan:!!r}},[xt,null==_e?void 0:_e.isLoading]),Ct=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Tn.open&&Tn.sectionIdx===o)zn();else{var s=e.currentTarget,a="left";(null===(l=Rn.current)||void 0===l?void 0:l.contains(s))&&(a="right");Vi(),ki.current&&zi(),Ue(new Set),Xe([]),an.current=[],Vn(),Pn.open?Xt():kn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=Ri.current[l])||void 0===e?void 0:e.current:null===(n=Si.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=Ri.current[o])||void 0===i?void 0:i.current:null===(t=Si.current[o])||void 0===t?void 0:t.current}()||s;Dn(bt(e,n,t,o,i,r))})}},[Tn.open,Tn.sectionIdx,zn,kn,bt]),Et=i.useCallback(function(){var e=Tn.sectionIdx;Tn.isOrphan,zn(),kn(),null!==e&&(Qi(e),Vi(),ki.current&&zi(),Xe([]),an.current=[],Ue(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){cn.current&&cn.current()},50))},[Tn.sectionIdx,Tn.isOrphan,zn,kn,zi]),At=i.useCallback(function(){var e=rn.current;if(e){rn.current=null;var n=oi.findIndex(function(n){return n.id===e}),i=ri.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(oi,e):null,o=-1===i?u.findKeyPathByNodeId(ri,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Hi.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Fe)-1!==r&&Cn.current&&a(function(){return s(n,t,hi,_i)},Cn.current),-1!==l&&Rn.current&&a(function(){return s(i,o,mi,yi)},Rn.current);else{var c=mn.current;if(!c)return;a(function(){return-1!==r?s(n,t,hi,_i):s(i,o,mi,yi)},c)}}},[oi,ri,Fe,hi,mi,_i,yi,Cn,Rn,mn]),Bt=i.useCallback(function(n){if(n){Vi(),zi(),Ue(new Set),Xe([]),an.current=[],kn(),Vn();var i=oi.findIndex(function(e){return e.id===n}),t=ri.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(oi,n):null,r=-1===t?u.findKeyPathByNodeId(ri,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=-1!==t?t:r?Number(r.split("-")[0]):-1;rn.current=n,Ui(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Fe?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=Fe?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),Ji(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){rn.current===n&&wt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[oi,ri,Fe,Ui,Ji,zi,kn,Vn]),wt=i.useRef(At);i.useEffect(function(){wt.current=At},[At]);var It=i.useRef(null);i.useEffect(function(){if(Kn){var e=Gn.fields.find(function(e){return e.analysisKey===Kn||e.key===Kn});if(e){var n=gi.current[e.key]||pi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Kn,Gn.fields]);var Tt=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==it?void 0:it.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=v.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[it]),Dt=E.useStyleHelpers({proposedSections:oi,existingSections:ri,maintainRelativeOrder:Fe,cognitiveMap:pn,deviationData:gn,treeData:ge,resolvedComparisonConfig:Gn}),Ot=Dt.getSectionCompareStyle,Ft=Dt.getSubSectionCompareStyle,jt=Dt.getDeviationStyleByKey,Pt=B.useLinesCalculator({containerRef:nn,leftContainerRef:Cn,rightContainerRef:Rn,svgContainerRef:en,pathRefs:sn,leftHeaderRef:tn,rightHeaderRef:on,proposedSections:oi,existingSections:ri,visibleFields:li,leftRefs:gi,rightRefs:pi,sectionLeftRefs:hi,sectionRightRefs:mi,subSectionLeftRefs:_i,subSectionRightRefs:yi,lhsBadgeRefs:Si,rhsBadgeRefs:Ri,sectionRowRefs:bi,expandedSections:Ki,expandedSubSections:Yi,connectedSections:Ke,isSideBySide:wi,activeSideBySideSection:ji,maintainRelativeOrder:Fe,cognitiveMap:pn,getSectionCompareStyle:Ot,getSubSectionCompareStyle:Ft,getDeviationStyleByKey:jt,isArrowVisible:Ii,isAnimatingRef:ln,isSideBySideRef:ki,sideBySideCacheRef:Ni,sideBySideLineRef:qi,activeSideBySideSectionRef:Mi,activeSideBySideRightSectionRef:Li,connectedLines:Je,setConnectedLines:Xe,cachedConnectedPositions:an,calculateLinesRef:cn,resizeTimerRef:dn,scrollLock:Pi,scrollSyncLocked:Qe,handleResizeRef:fn,activeProposed:ii,existingRule:ti,analysisData:it,pendingScrollTargetRef:En,pendingScrollCallbackRef:An,resolvedComparisonConfig:Gn,getFieldData:Tt}),Nt=Pt.lines,kt=Pt.setLines,Lt=Pt.overallConnector,Mt=Pt.setOverallConnector,qt=Pt.svgDimensions,Ht=Pt.handleColumnScroll;i.useEffect(function(){Pn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=cn.current)||void 0===e||e.call(cn)})})},[Pn.anchorEl,Qe]);var Vt=i.useCallback(function(){Vi(),Ze(!1),Ui({}),Ji({}),zi(),Ue(new Set),Xe([]),an.current=[],kn(),Vn(),zn(),requestAnimationFrame(function(){cn.current&&cn.current()})},[Ui,Ji,zi,kn,Vn,zn]);i.useEffect(function(){wi||0!==Ke.size||Ze(!1)},[wi,Ke]);var zt=i.useMemo(function(){return Object.values(Ki).some(Boolean)||Object.values(Yi).some(Boolean)},[Ki,Yi]),Gt=i.useRef(null),Wt=i.useRef(0),Kt=i.useRef(0),Ut=i.useRef(0),Yt=A.useResizeHandler({timerRef:Gt,ruleComponentRef:Sn,scrollContainerRef:mn,containerRef:nn,maintainRelativeOrder:Fe,proposedSections:oi,existingSections:ri,isSideBySideRef:ki,activeSideBySideSectionRef:Mi,activeSideBySideRightSectionRef:Li,sectionRowRefs:bi,sectionRightRowRefs:xi,sectionLeftRefs:hi,sectionRightRefs:mi,subSectionLeftRefs:_i,subSectionRightRefs:yi,lhsBadgeRefs:Si,rhsBadgeRefs:Ri,leftContainerRef:Cn,rightContainerRef:Rn,calculateLinesRef:cn,handleResizeRef:fn,setIsResizing:Oi,setIsArrowVisible:Ti,sideBySideCacheRef:Ni,cachedConnectedPositions:an}).handleResize;i.useEffect(function(){fn.current=Yt},[Yt,fn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var s=e[e.length-1];if(s){var a=null!==(u=null===(l=null===(r=s.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:s.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Sn.current&&o.push(e(Sn.current,Wt,n,function(){return fn.current()},function(){})),mn.current&&o.push(e(mn.current,Kt,i,function(){return fn.current()},function(){return cn.current()})),nn.current&&o.push(e(nn.current,Ut,t,function(){return fn.current()},function(){return cn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){ki.current=wi},[wi]),i.useEffect(function(){Mi.current=ji},[ji]);var Jt=i.useCallback(function(){var e,n=Tn.sectionIdx,i=Tn.isOrphan;if(kn(),null!=n){var t="left";Tn.anchorEl&&(null===(e=Rn.current)||void 0===e?void 0:e.contains(Tn.anchorEl))&&(t="right"),Qi(n),Gi(n,i,{sourceSide:t})}},[Gi,Tn.isOrphan,Tn.sectionIdx,Tn.anchorEl,kn]),Xt=i.useCallback(function(){kn(),zi(),Ue(new Set),Xe([]),an.current=[]},[kn,zi]),$t=null!==Tn.sectionIdx&&Ke.has(Tn.sectionIdx),Qt=S.useDeviationNavigation({proposedSections:oi,existingSections:ri,parentDeviationRecord:ui,expandedSections:Ki,maintainRelativeOrder:!!Fe,scrollContainerRef:mn,leftContainerRef:Cn,rightContainerRef:Rn,lhsBadgeRefs:Si,rhsBadgeRefs:Ri}),Zt=Qt.showDeviationNavigation,eo=Qt.showOpenNodeRef,no=Qt.adjustScrollForPopup,io=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?u.safeStringify(t).trim():u.safeStringify(null==t?void 0:t.deviation_summary).trim(),s=e.currentTarget;Vn();var a="left";(null===(r=Rn.current)||void 0===r?void 0:r.contains(s))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=Ri.current[l])||void 0===e?void 0:e.current:null===(i=Si.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=Ri.current[n])||void 0===t?void 0:t.current:null===(o=Si.current[n])||void 0===o?void 0:o.current};if(i)return zi(),Ue(new Set),Xe([]),an.current=[],void(l&&(Qi(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Nn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Qi(n),l?setTimeout(function(){Gi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||s;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var u=l.top-window.innerHeight/2;Fe?(null===(e=Cn.current)||void 0===e||e.scrollBy({top:u,behavior:"smooth"}),null===(n=Rn.current)||void 0===n||n.scrollBy({top:u,behavior:"smooth"})):null===(i=mn.current)||void 0===i||i.scrollBy({top:u,behavior:"smooth"})}}Nn({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Gi(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Gi,Vn,Nn,zi,Qi]),to=i.useMemo(function(){var e;if(!Ae)return null;var n=null===(e=null==Ae?void 0:Ae.id)||void 0===e?void 0:e.split(":")[0];for(var i in ui){if((ui[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ae,ui]),oo=i.useRef({id:null,triggerMs:null}),ro=i.useRef(null);i.useEffect(function(){if(null==Ae?void 0:Ae.id){var n=Number(Ae.trigger),i=oo.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Ae.id.includes(":")&&/:\d+$/.test(Ae.id)))return oo.current={id:Ae.id,triggerMs:n},void Bt(Ae.id);var t=Ae.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";ro.current!==Ae.id&&(kn(),Vn(),zi(),Ue(new Set),Xe([]),an.current=[],ro.current=Ae.id);var s=!1,a=0,c=null,d=null,f=!1,v=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},g=function(){var i,t,r,p;if(!s){var h=function(){oo.current={id:Ae.id,triggerMs:n}},m=null,S=null;for(var R in ui){var x=ui[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=oi.findIndex(function(e){return e.id===m}),y=ri.findIndex(function(e){return e.id===m}),b=-1===_&&-1!==y,C=v(oi,S.id),E=v(ri,S.id);if(C&&!E&&!b){var A=C.split("-"),B=Number(A[0]);if(Fe){var w=null===(t=null===(i=oi[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=ri.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):y,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=oi[T],j=ri[O],P=F&&!F.title&&!F.content,N=j&&!j.title&&!j.content,k=b||(!C&&!!E||P&&!N);if(k){if(!(Fe?!!mo.current["right-".concat(D)]:!!mo.current[String(D)])&&D>=0)return $i(D,"right"),void(c=setTimeout(g,200))}else if(!(Fe?!!mo.current["left-".concat(T)]:!!mo.current[String(T)])&&T>=0)return $i(T,"left"),void(c=setTimeout(g,200));var L=C||"",M=E||"",q="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l).concat(u.DEVIATION_BADGE_SEPARATOR).concat(L).concat(u.DEVIATION_BADGE_SEPARATOR).concat(M),H="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l);if(!f){Qi(q),f=!0,a=0;var V=function(){var e,n,i=null===(e=Si.current[H])||void 0===e?void 0:e.current,t=null===(n=Ri.current[H])||void 0===n?void 0:n.current;return k||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;s||(e=V,n=function(){s||(d=null,g())},t=0,o=null,r=null,l=function(){if(!s){var u=e();if(u&&0!==u.getBoundingClientRect().height){var a=u.getBoundingClientRect(),c=a.top,d=a.height,f=null!==o&&Math.abs(c-o)<.5,v=null!==r&&Math.abs(d-r)<.5;if(f&&v){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var z=null===(r=Si.current[H])||void 0===r?void 0:r.current,G=null===(p=Ri.current[H])||void 0===p?void 0:p.current;if(z||G){var W=k||!z&&!!G,K=W?G:z,U=Fe?W?Rn.current:Cn.current:mn.current;if(K&&U){var Y=K.getBoundingClientRect();if(0!==Y.height){var J=U.getBoundingClientRect(),X=Y.top-J.top+U.scrollTop-J.height/2+Y.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,f,v;return e.__generator(this,function(g){switch(g.label){case 0:return s?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[z,G].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[z,G].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!z&&!!G?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Fe?[4,Promise.all([Cn.current?r(u.waitForScrollIdle(Cn.current),600):Promise.resolve(),Rn.current?r(u.waitForScrollIdle(Rn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(f=Ri.current[$?H:D])||void 0===f?void 0:f.current)||G:(null===(v=Si.current[$?H:T])||void 0===v?void 0:v.current)||z,no(o,function(){Nn({open:!0,anchorEl:o,displayImpact:Ae.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Be||Be(),[2]));case 1:g.sent(),g.label=2;case 2:return Gi(q,!1,{toggleIfSame:!1,sourceSide:b?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=Ri.current[H])||void 0===n?void 0:n.current)||G:(null===(t=Si.current[H])||void 0===t?void 0:t.current)||z,u=(null===(o=Si.current[H])||void 0===o?void 0:o.current)||z,s=(null===(r=Ri.current[H])||void 0===r?void 0:r.current)||G;u&&(u.style.scrollMarginTop="80px",u.scrollIntoView({behavior:"smooth",block:"start"})),s&&(s.style.scrollMarginTop="80px",s.scrollIntoView({behavior:"smooth",block:"start"})),Nn({open:!0,anchorEl:l,displayImpact:Ae.displayImpact,summary:e.__assign({},i)}),null==Be||Be()}}),[2]}})})};Math.abs(U.scrollTop-X)<=2?Q():u.scrollAndWait(U,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){s=!0,c&&clearTimeout(c),null==d||d()}}}},[Ae,ui,oi,ri,Fe,Ki,Gi,Nn,Bt]),i.useEffect(function(){var n,i,t;if(Pn.open){var o=Pn.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Si.current)||r(Ri.current);if(l){var u=(null===(i=Ri.current[l])||void 0===i?void 0:i.current)||(null===(t=Si.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Nn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Pn.open,Pn.anchorEl,Qe,Ke,Ki]);var lo=wn.open,uo=wn.sectionIdx,so=wn.isOrphan,ao=wn.badgeStyle,co=wn.anchorEl,fo=wn.sectionAnchorEl;i.useEffect(function(){var n;if(lo&&null!=uo&&uo!==rt){var i="string"==typeof uo?uo.split(u.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(oi,i):null,r=i&&"string"==typeof i?t(ri,i):null,l="number"==typeof uo?oi[uo]||null:o||i&&((null===(n=null==ge?void 0:ge.nodes)||void 0===n?void 0:n[i])||(null==ge?void 0:ge[i]))||null,s="number"==typeof uo?ri[uo]||null:r,a=bt(co,l,s,uo,so,ao);In(function(n){return n.open?u.safeStringify(n.cognitiveData)===u.safeStringify(a.cognitiveData)&&u.safeStringify(n.deviationData)===u.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[lo,uo,so,ao,co,fo,oi,ri,bt]);var vo=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,s=e.parentNodeId,a=void 0===s?"":s,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:c})},[]),go=i.useMemo(function(){return oi.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Fe?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[oi]),po=i.useMemo(function(){return ri.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Fe?null:n.jsx(y.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[ri]),ho=i.useRef(Ct);i.useEffect(function(){ho.current=Ct},[Ct]);var mo=i.useRef(Ki);i.useEffect(function(){mo.current=Ki},[Ki]);var So=i.useRef(io);i.useEffect(function(){So.current=io},[io]);var Ro=i.useRef(Xt);i.useEffect(function(){Ro.current=Xt},[Xt]);var xo=i.useRef($i);i.useEffect(function(){xo.current=$i},[$i]);var _o=i.useRef(Xi);i.useEffect(function(){_o.current=Xi},[Xi]);var yo=i.useRef(vo);i.useEffect(function(){yo.current=vo},[vo]);var bo=i.useRef(zi);i.useEffect(function(){bo.current=zi},[zi]);var Co=i.useMemo(function(){return{maintainRelativeOrder:!!Fe,showDeviationBadges:ke,isProposingFix:Ie,proposingFixNodeId:Te,isRedlineFlow:De,isSideBySide:wi,activeSideBySideSection:ji,scrollSyncLocked:Qe,toggleScrollSyncLocked:et,summaryPopupAnchorEl:Pn.anchorEl,connectedSections:Ke,proposedSections:oi,existingSections:ri,deviationNumberRegistry:si,deviationParentRegistry:ai,treeData:ge,displayConfig:_e,resolvedMarkdownStyles:hn,unifiedNumbering:nt,expandedSections:Ki,expandedSubSections:Yi,setExpandedSubSections:Ji,getSectionCompareStyle:Ot,getSubSectionCompareStyle:Ft,getBadgeRef:Ai,getSectionRowRef:Ci,getSubSectionRef:Ei,sectionLeftRefs:hi,sectionRightRefs:mi,sectionRowRefs:bi,sectionRightRowRefs:xi,subSectionLeftRefs:_i,subSectionRightRefs:yi,lhsBadgeRefs:Si,rhsBadgeRefs:Ri,openMoreFunctionsPopup:dt,handleOpenSummaryPopup:ft,openSummaryPopup:ft,handleCloseSummaryPopup:vt,toggleSection:gt,handleSubSectionToggle:pt,renderSubSectionAccordion:ht,resetSideBySide:mt,setConnectedSections:Ue,setConnectedLines:Xe,cachedConnectedPositions:an,showDeviationNavigation:Zt,showOpenNodeRef:eo,deviationNodeIdToView:null==Ae?void 0:Ae.id,deviationTargetParentId:to}},[Fe,ke,Ie,Te,De,wi,ji,Qe,et,Pn.anchorEl,Ke,oi,ri,si,_e,hn,nt,Ki,Yi,Ji,Ot,Ft,Ai,Ci,Ei,Zt,eo,Ae,to]);return n.jsx(C.CompareContextProvider,e.__assign({value:Co},{children:n.jsxs(t.Box,e.__assign({ref:Sn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[Me&&n.jsx(t.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(f.default,{})})),Pn.open&&n.jsx(b.default,{open:Pn.open,anchorEl:Pn.anchorEl,containerEl:It.current,clipTopEl:tn.current,scrollContainerEl:mn.current,onClose:Xt,summary:Pn.summary,displayImpact:Pn.displayImpact,isScrollLocked:Qe}),n.jsx(d.default,{open:Tn.open,anchorEl:Tn.anchorEl,maintainRelativeOrder:!!Fe,sectionTitle:Tn.sectionTitle,referenceSectionTitle:Tn.refSectionTitle,onClose:zn,onOpenCognitiveCompare:qn,onOpenSideBySide:Jt,onConnect:Et,isConnected:$t,isOrphan:Tn.isOrphan}),wn.open&&n.jsx(c.default,{open:wn.open,popupRef:Mn,position:On,popupConfig:be,onClose:function(){Fn(null),In(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Ln(null)},markdownStyles:Se,sectionTitle:$n,referenceSectionTitle:Zn,cognitiveData:wn.cognitiveData,anchorEl:wn.anchorEl,sectionAnchorEl:wn.sectionAnchorEl,scrollContainerEl:mn.current,badgeStyle:wn.badgeStyle,docData:wn.docData,deviationData:wn.deviationData,isLoading:wn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!Ve,autoHideDuration:8e3,onClose:function(){return ze(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return ze(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ve}))})),n.jsx(R.default,{componentHeaderText:ve,displayConfig:_e,maintainRelativeOrder:Fe,onCollapseAll:Vt,showCollapseAll:zt,onToggleView:function(e){qe(!0),setTimeout(function(){je(!e),null==ye||ye(!e),Ze(!1),zi(),kn(),Ue(new Set),Xe([]),an.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){qe(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:mn,onScroll:Ht,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Fe?"visible":"auto",borderTop:tt&&ot?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Fe?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:nn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Fe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:en,svgDimensions:qt,isResizing:Di,overallConnector:Lt,rootDeviationStyle:st,lines:Nt,isSideBySide:wi,activeSideBySideSection:ji,isArrowVisible:Ii,maintainRelativeOrder:Fe,proposedSections:oi,existingSections:ri,cognitivePopup:wn,activeBadgeId:jn,closeCognitivePopup:Vn,setActiveBadgeId:Ln,openCognitivePopupFromState:Hn,buildSectionPopupState:bt,connectedLines:Je,pathRefs:sn}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Fe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:tn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:Jn,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Jn}))}))})),n.jsxs(t.Box,e.__assign({ref:Cn,onScroll:Ht,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Fe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:yn,style:{width:"100%",height:"0px",flexShrink:0}}),di&&go,n.jsx("div",{ref:bn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:It,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),wn.open&&jn===rt?Vn():(Ln(rt),Hn(bt(n.currentTarget,{title:"",content:"",evaluationResult:lt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,rt,!0,e.__assign(e.__assign({},st),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:st.badgeBg,color:st.badgeText,border:"1px solid ".concat(st.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=ut?ut:n.jsx(v.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:wn.open&&jn===rt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Fe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Fi&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:on,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(t.Tooltip,e.__assign({title:ei,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ei}))}))})),n.jsxs(t.Box,e.__assign({ref:Rn,onScroll:Ht,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Fe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:xn,style:{width:"100%",height:"0px",flexShrink:0}}),di&&po,n.jsx("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),s=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(T){var D,O,F,j,P,N,k,L,M,q,H,V,z,G,W,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe=T.componentHeaderText,ve=void 0===fe?a.DEFAULT_COMPONENT_HEADER_TEXT:fe,ge=T.treeData,pe=T.comparisonConfig,he=T.leftColumnTitleText,me=T.rightColumnTitleText,Se=T.markdownStyles,Re=T.resetTrigger,xe=T.displayConfig,_e=void 0===xe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:xe,ye=T.onMaintainRelativeOrderChange,be=T.popupConfig,Ce=T.deviationData,Ee=void 0===Ce?{}:Ce,Ae=T.deviationNodeIdToView,Be=T.resetDeviationNodeId,we=T.isProposingFix,Ie=void 0!==we&&we,Te=T.proposingFixNodeId,De=T.isRedlineFlow,Oe=T.badgeStyleOverride,Fe=i.useState(_e.maintainRelativeOrder),je=Fe[0],Pe=Fe[1],Ne=null!==(D=null==_e?void 0:_e.expandLevels)&&void 0!==D?D:0,ke=!!(null==_e?void 0:_e.expandAllSections),Le=!!je||!!(null==_e?void 0:_e.showDeviationBadges),Me=i.useState(!1),qe=Me[0],He=Me[1],Ve=i.useState(null),ze=Ve[0],Ge=Ve[1],We=i.useState(null===(F=null!==(O=null==ge?void 0:ge.newEvaluationResult)&&void 0!==O?O:null==_e?void 0:_e.enableDeviationSchemaBackwardCompatibility)||void 0===F||F)[0],Ke=i.useState(new Set),Ue=Ke[0],Ye=Ke[1],Je=i.useState([]),Xe=Je[0],$e=Je[1],Qe=i.useState(!1),Ze=Qe[0],en=Qe[1],nn=i.useRef(null),tn=i.useRef(null),on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),un=i.useRef(!1),sn=i.useRef(null),an=i.useRef({}),cn=i.useRef([]),dn=i.useRef(function(){}),fn=i.useRef(null),vn=i.useRef(function(){}),gn=i.useMemo(function(){return JSON.stringify(Ee||{})},[JSON.stringify(Ee)]),pn=i.useMemo(function(){return Ee||{}},[gn]),hn=i.useMemo(function(){return(null==ge?void 0:ge.cognitive_decisioning)||{}},[ge]),mn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),Se)},[Se]),Sn=i.useRef(null),Rn=i.useRef(null),xn=i.useRef(null),_n=i.useRef(null),yn=i.useRef(null),bn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=p.useComparePopups(Sn),In=wn.cognitivePopup,Tn=wn.setCognitivePopup,Dn=wn.moreFunctions,On=wn.setMoreFunctions,Fn=wn.position,jn=wn.setPosition,Pn=wn.activeBadgeId,Nn=wn.summaryPopup,kn=wn.setSummaryPopup,Ln=wn.closeSummaryPopup,Mn=wn.setActiveBadgeId,qn=wn.popupRef,Hn=wn.handleOpenCognitiveCompare,Vn=wn.openCognitivePopupFromState,zn=wn.closeCognitivePopup,Gn=wn.closeMoreFunctionsPopup,Wn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==pe?void 0:pe.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==pe?void 0:pe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==pe?void 0:pe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==pe?void 0:pe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[pe]),Kn=i.useState(null),Un=Kn[0];Kn[1];var Yn=null===(N=null===(j=null==ge?void 0:ge.documents)||void 0===j?void 0:j[null===(P=null==ge?void 0:ge.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,Jn=null===(M=null===(k=null==ge?void 0:ge.documents)||void 0===k?void 0:k[null===(L=null==ge?void 0:ge.input_index_map)||void 0===L?void 0:L[1]])||void 0===M?void 0:M.title,Xn=u.safeStringify(he||Yn||"Uploaded Contract"),$n=null===(z=null===(V=null===(q=null==ge?void 0:ge.documents)||void 0===q?void 0:q[null===(H=null==ge?void 0:ge.input_index_map)||void 0===H?void 0:H[0]])||void 0===V?void 0:V.metadata)||void 0===z?void 0:z.file_name,Qn=u.safeStringify($n),Zn=null===(U=null===(K=null===(G=null==ge?void 0:ge.documents)||void 0===G?void 0:G[null===(W=null==ge?void 0:ge.input_index_map)||void 0===W?void 0:W[1]])||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.file_name,ei=u.safeStringify(Zn),ni=u.safeStringify(me||Jn||"Reference Template"),ii=g.useCognitiveTreeData(ge,je,pn,Wn,We),ti=ii.activeProposed,oi=ii.existingRule,ri=ii.proposedSections,li=ii.existingSections,ui=ii.visibleFields,si=ii.parentDeviationRecord,ai=ii.deviationNumberRegistry,ci=ii.deviationParentRegistry,di=ii.parseError;i.useEffect(function(){di&&Ge("Failed to load comparison: ".concat(di))},[di]);var fi=ri.length>0||li.length>0,vi=i.useMemo(function(){if(!De)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";u.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(ri),i(li),"".concat(e,":").concat(n)},[De,ri,li]);i.useEffect(function(){if(ri.length||li.length)if(ke){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=je?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(ri,"left"),i(li,"right"),Yi(e),Xi(n)}else if(Ne>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=je?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(ri,"left",Ne),r(li,"right",Ne),Yi(t),Xi(o)}},[ke,Ne,ri,li,je]);var gi=h.useSectionRefs(ui.map(function(e){return e.key}),Math.max(ri.length,li.length)),pi=gi.leftRefs,hi=gi.rightRefs,mi=gi.sectionLeftRefs,Si=gi.sectionRightRefs,Ri=gi.lhsBadgeRefs,xi=gi.rhsBadgeRefs,_i=gi.sectionRightRowRefs,yi=gi.subSectionLeftRefs,bi=gi.subSectionRightRefs,Ci=gi.sectionRowRefs,Ei=gi.getSectionRowRef,Ai=gi.getSubSectionRef,Bi=gi.getBadgeRef,wi=w.useSideBySide({maintainRelativeOrder:je,proposedSections:ri,existingSections:li,leftContainerRef:En,rightContainerRef:xn,scrollContainerRef:Sn,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,sectionRowRefs:Ci,sectionRightRowRefs:_i,rhsTopSpacerRef:_n,rhsBottomSpacerRef:yn,lhsTopSpacerRef:bn,lhsBottomSpacerRef:Cn,calculateLinesRef:dn,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,closeMoreFunctionsPopup:Gn,setErrorToast:Ge,moreFunctions:Dn,closeSummaryPopup:Ln}),Ii=wi.isSideBySide,Ti=wi.isArrowVisible,Di=wi.setIsArrowVisible,Oi=wi.isResizing,Fi=wi.setIsResizing,ji=wi.isSideBySideLoading,Pi=wi.activeSideBySideSection,Ni=wi.scrollLock,ki=wi.sideBySideCacheRef,Li=wi.isSideBySideRef,Mi=wi.activeSideBySideRightSectionRef,qi=wi.activeSideBySideSectionRef,Hi=wi.sideBySideLineRef,Vi=wi.highlightedClauseRefs,zi=wi.clearClauseHighlight,Gi=wi.resetSideBySide,Wi=wi.activateSideBySide,Ki=m.useAccordionState({maintainRelativeOrder:!!je,proposedSections:ri,existingSections:li,activeSideBySideSection:Pi,connectedSections:Ue,resetSideBySide:Gi,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,svgContainerRef:nn,isAnimatingRef:un,animationTimerRef:sn,calculateLinesRef:dn,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi}),Ui=Ki.expandedSections,Yi=Ki.setExpandedSections,Ji=Ki.expandedSubSections,Xi=Ki.setExpandedSubSections,$i=Ki.handleSubSectionToggle,Qi=Ki.toggleSection,Zi=Ki.forceExpandCrossWiredSections,et=function(){var e,n;if(null!=Pi){var i=null===(e=mi.current[Pi])||void 0===e?void 0:e.current,t=null===(n=Si.current[Pi])||void 0===n?void 0:n.current,o=xn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},nt=i.useCallback(function(e){null==e||e.stopPropagation(),en(function(e){var n=!e;return n&&requestAnimationFrame(function(){et()}),n})},[et]);i.useEffect(function(){De&&"off"!==vi&&"0:0"!==vi&&(ki.current=null,cn.current=[],requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)}))},[De,vi]);var it=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(je)ri.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),li.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ri.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(ri.length,li.length),o=0;o<t;o++){var r=ri[o],l=li[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[ri,li,je]),tt=oi.analysis,ot=u.safeStringify(null===(J=null===(Y=null==tt?void 0:tt.rule_difference_comparison)||void 0===Y?void 0:Y.summary)||void 0===J?void 0:J.overall_summary),rt=!!ot.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),lt=null!==(X=null==ge?void 0:ge.base_root_id)&&void 0!==X?X:"-1";null==ge||ge[lt];var ut=We?null!==(se=null!==(re=Ee&&(null===(oe=null==Ee?void 0:Ee[lt])||void 0===oe?void 0:oe.evaluation_result))&&void 0!==re?re:null===(ue=null===(le=null==ge?void 0:ge.nodes)||void 0===le?void 0:le[lt])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==se?se:null:null!==(te=null!==(Z=Ee&&(null===(Q=null===($=null==Ee?void 0:Ee[lt])||void 0===$?void 0:$.evaluation_result)||void 0===Q?void 0:Q[0]))&&void 0!==Z?Z:null===(ie=null===(ne=null===(ee=null==ge?void 0:ge.nodes)||void 0===ee?void 0:ee[lt])||void 0===ne?void 0:ne.evaluation_result)||void 0===ie?void 0:ie[0])&&void 0!==te?te:null,st=u.extractDeviationScore(ut),at=u.generateColorPalette(null!==(de=null===(ce=null===(ae=null==ut?void 0:ut.evaluation_outputs)||void 0===ae?void 0:ae.metadata)||void 0===ce?void 0:ce.label_color)&&void 0!==de?de:a.DEFAULT_DEVIAION_COLOR);if(Oe){var ct=Oe(st);ct&&(at=e.__assign(e.__assign({},at),{badgeBg:ct.bg,badgeText:ct.text,badgeBorder:ct.border}))}var dt=i.useRef(Gi);i.useEffect(function(){dt.current=Gi},[Gi]);var ft=i.useRef(zn);i.useEffect(function(){ft.current=zn},[zn]);var vt=i.useCallback(function(e,n,i,t,o,r){return So.current(e,n,i,t,o,r)},[]),gt=i.useCallback(function(e,n,i,t,o){return xo.current(e,n,i,t,o)},[]),pt=i.useCallback(function(){return _o.current()},[]),ht=i.useCallback(function(e,n){return yo.current(e,n)},[]),mt=i.useCallback(function(e){return bo.current(e)},[]),St=i.useCallback(function(e){return Co.current(e)},[]),Rt=i.useCallback(function(){return Eo.current()},[]),xt=i.useCallback(function(){var e,n;zi(),null===(e=dt.current)||void 0===e||e.call(dt),en(!1),Ye(new Set),$e([]),cn.current=[],Mt([]),Ht(null),kn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=ft.current)||void 0===n||n.call(ft),requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)})},[]),_t=i.useRef(xt);i.useEffect(function(){_t.current=xt},[xt]),i.useEffect(function(){Re&&_t.current()},[Re]);var yt=i.useMemo(function(){return{documents:null==ge?void 0:ge.documents,input_index_map:null==ge?void 0:ge.input_index_map}},[JSON.stringify(null==ge?void 0:ge.documents),JSON.stringify(null==ge?void 0:ge.input_index_map)]),bt=i.useRef(ge);i.useEffect(function(){bt.current=ge},[ge]);var Ct=i.useRef(hn);i.useEffect(function(){Ct.current=hn},[hn]);var Et=i.useCallback(function(n,i,t,o,r,l,s){var a,c,d,f,v,g,p,h,m,S,R=u.safeStringify(null==i?void 0:i.id)||u.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Ct.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=Ci.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,s=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return s(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):s(l)}(),b=(null!==(g=null===(v=null===(f=null==y?void 0:y.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(S=null==_e?void 0:_e.isLoading)&&void 0!==S&&S&&!b,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:_,badgeStyle:l||null,sectionIdx:o,docData:yt,deviationData:y,isOrphan:!!r}},[yt,null==_e?void 0:_e.isLoading]),At=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Dn.open&&Dn.sectionIdx===o)Gn();else{var s=e.currentTarget,a="left";(null===(l=xn.current)||void 0===l?void 0:l.contains(s))&&(a="right");zi(),Li.current&&Gi(),Ye(new Set),$e([]),cn.current=[],zn(),Nn.open?Qt():Ln(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=xi.current[l])||void 0===e?void 0:e.current:null===(n=Ri.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=xi.current[o])||void 0===i?void 0:i.current:null===(t=Ri.current[o])||void 0===t?void 0:t.current}()||s;On(Et(e,n,t,o,i,r))})}},[Dn.open,Dn.sectionIdx,Gn,Ln,Et]),Bt=i.useCallback(function(){var e=Dn.sectionIdx;Dn.isOrphan,Gn(),Ln(),null!==e&&(Zi(e),zi(),Li.current&&Gi(),$e([]),cn.current=[],Ye(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){dn.current&&dn.current()},50))},[Dn.sectionIdx,Dn.isOrphan,Gn,Ln,Gi]),wt=i.useCallback(function(){var e=ln.current;if(e){ln.current=null;var n=ri.findIndex(function(n){return n.id===e}),i=li.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(ri,e):null,o=-1===i?u.findKeyPathByNodeId(li,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Vi.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(je)-1!==r&&En.current&&a(function(){return s(n,t,mi,yi)},En.current),-1!==l&&xn.current&&a(function(){return s(i,o,Si,bi)},xn.current);else{var c=Sn.current;if(!c)return;a(function(){return-1!==r?s(n,t,mi,yi):s(i,o,Si,bi)},c)}}},[ri,li,je,mi,Si,yi,bi,En,xn,Sn]),It=i.useCallback(function(n){if(n){zi(),Gi(),Ye(new Set),$e([]),cn.current=[],Ln(),zn();var i=ri.findIndex(function(e){return e.id===n}),t=li.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(ri,n):null,r=-1===t?u.findKeyPathByNodeId(li,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=-1!==t?t:r?Number(r.split("-")[0]):-1;ln.current=n,Yi(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=je?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=je?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),Xi(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){ln.current===n&&Tt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ri,li,je,Yi,Xi,Gi,Ln,zn]),Tt=i.useRef(wt);i.useEffect(function(){Tt.current=wt},[wt]);var Dt=i.useRef(null);i.useEffect(function(){if(Un){var e=Wn.fields.find(function(e){return e.analysisKey===Un||e.key===Un});if(e){var n=pi.current[e.key]||hi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Un,Wn.fields]);var Ot=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==tt?void 0:tt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=v.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[tt]),Ft=E.useStyleHelpers({proposedSections:ri,existingSections:li,maintainRelativeOrder:je,cognitiveMap:hn,deviationData:pn,treeData:ge,resolvedComparisonConfig:Wn,badgeStyleOverride:Oe}),jt=Ft.getSectionCompareStyle,Pt=Ft.getSubSectionCompareStyle,Nt=Ft.getDeviationStyleByKey,kt=B.useLinesCalculator({containerRef:tn,leftContainerRef:En,rightContainerRef:xn,svgContainerRef:nn,pathRefs:an,leftHeaderRef:on,rightHeaderRef:rn,proposedSections:ri,existingSections:li,visibleFields:ui,leftRefs:pi,rightRefs:hi,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,sectionRowRefs:Ci,expandedSections:Ui,expandedSubSections:Ji,connectedSections:Ue,isSideBySide:Ii,activeSideBySideSection:Pi,maintainRelativeOrder:je,cognitiveMap:hn,getSectionCompareStyle:jt,getSubSectionCompareStyle:Pt,getDeviationStyleByKey:Nt,isArrowVisible:Ti,isAnimatingRef:un,isSideBySideRef:Li,sideBySideCacheRef:ki,sideBySideLineRef:Hi,activeSideBySideSectionRef:qi,activeSideBySideRightSectionRef:Mi,connectedLines:Xe,setConnectedLines:$e,cachedConnectedPositions:cn,calculateLinesRef:dn,resizeTimerRef:fn,scrollLock:Ni,scrollSyncLocked:Ze,handleResizeRef:vn,activeProposed:ti,existingRule:oi,analysisData:tt,pendingScrollTargetRef:An,pendingScrollCallbackRef:Bn,resolvedComparisonConfig:Wn,getFieldData:Ot}),Lt=kt.lines,Mt=kt.setLines,qt=kt.overallConnector,Ht=kt.setOverallConnector,Vt=kt.svgDimensions,zt=kt.handleColumnScroll;i.useEffect(function(){Nn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)})})},[Nn.anchorEl,Ze]);var Gt=i.useCallback(function(){zi(),en(!1),Yi({}),Xi({}),Gi(),Ye(new Set),$e([]),cn.current=[],Ln(),zn(),Gn(),requestAnimationFrame(function(){dn.current&&dn.current()})},[Yi,Xi,Gi,Ln,zn,Gn]);i.useEffect(function(){Ii||0!==Ue.size||en(!1)},[Ii,Ue]);var Wt=i.useMemo(function(){return Object.values(Ui).some(Boolean)||Object.values(Ji).some(Boolean)},[Ui,Ji]),Kt=i.useRef(null),Ut=i.useRef(0),Yt=i.useRef(0),Jt=i.useRef(0),Xt=A.useResizeHandler({timerRef:Kt,ruleComponentRef:Rn,scrollContainerRef:Sn,containerRef:tn,maintainRelativeOrder:je,proposedSections:ri,existingSections:li,isSideBySideRef:Li,activeSideBySideSectionRef:qi,activeSideBySideRightSectionRef:Mi,sectionRowRefs:Ci,sectionRightRowRefs:_i,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,leftContainerRef:En,rightContainerRef:xn,calculateLinesRef:dn,handleResizeRef:vn,setIsResizing:Fi,setIsArrowVisible:Di,sideBySideCacheRef:ki,cachedConnectedPositions:cn}).handleResize;i.useEffect(function(){vn.current=Xt},[Xt,vn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var s=e[e.length-1];if(s){var a=null!==(u=null===(l=null===(r=s.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:s.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Rn.current&&o.push(e(Rn.current,Ut,n,function(){return vn.current()},function(){})),Sn.current&&o.push(e(Sn.current,Yt,i,function(){return vn.current()},function(){return dn.current()})),tn.current&&o.push(e(tn.current,Jt,t,function(){return vn.current()},function(){return dn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Li.current=Ii},[Ii]),i.useEffect(function(){qi.current=Pi},[Pi]);var $t=i.useCallback(function(){var e,n=Dn.sectionIdx,i=Dn.isOrphan;if(Ln(),null!=n){var t="left";Dn.anchorEl&&(null===(e=xn.current)||void 0===e?void 0:e.contains(Dn.anchorEl))&&(t="right"),Zi(n),Wi(n,i,{sourceSide:t})}},[Wi,Dn.isOrphan,Dn.sectionIdx,Dn.anchorEl,Ln]),Qt=i.useCallback(function(){Ln(),Gi(),Ye(new Set),$e([]),cn.current=[]},[Ln,Gi]),Zt=null!==Dn.sectionIdx&&Ue.has(Dn.sectionIdx),eo=S.useDeviationNavigation({proposedSections:ri,existingSections:li,parentDeviationRecord:si,expandedSections:Ui,maintainRelativeOrder:!!je,scrollContainerRef:Sn,leftContainerRef:En,rightContainerRef:xn,lhsBadgeRefs:Ri,rhsBadgeRefs:xi}),no=eo.showDeviationNavigation,io=eo.showOpenNodeRef,to=eo.adjustScrollForPopup,oo=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?u.safeStringify(t).trim():u.safeStringify(null==t?void 0:t.deviation_summary).trim(),s=e.currentTarget;zn();var a="left";(null===(r=xn.current)||void 0===r?void 0:r.contains(s))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=xi.current[l])||void 0===e?void 0:e.current:null===(i=Ri.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=xi.current[n])||void 0===t?void 0:t.current:null===(o=Ri.current[n])||void 0===o?void 0:o.current};if(i)return Gi(),Ye(new Set),$e([]),cn.current=[],void(l&&(Zi(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));kn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Zi(n),l?setTimeout(function(){Wi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||s;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var u=l.top-window.innerHeight/2;je?(null===(e=En.current)||void 0===e||e.scrollBy({top:u,behavior:"smooth"}),null===(n=xn.current)||void 0===n||n.scrollBy({top:u,behavior:"smooth"})):null===(i=Sn.current)||void 0===i||i.scrollBy({top:u,behavior:"smooth"})}}kn({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Wi(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Wi,zn,kn,Gi,Zi]),ro=i.useMemo(function(){var e;if(!Ae)return null;var n=null===(e=null==Ae?void 0:Ae.id)||void 0===e?void 0:e.split(":")[0];for(var i in si){if((si[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ae,si]),lo=i.useRef({id:null,triggerMs:null}),uo=i.useRef(null);i.useEffect(function(){if(null==Ae?void 0:Ae.id){var n=Number(Ae.trigger),i=lo.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Ae.id.includes(":")&&/:\d+$/.test(Ae.id)))return lo.current={id:Ae.id,triggerMs:n},void It(Ae.id);var t=Ae.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";uo.current!==Ae.id&&(Ln(),zn(),Gi(),Ye(new Set),$e([]),cn.current=[],uo.current=Ae.id);var s=!1,a=0,c=null,d=null,f=!1,v=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},g=function(){var i,t,r,p;if(!s){var h=function(){lo.current={id:Ae.id,triggerMs:n}},m=null,S=null;for(var R in si){var x=si[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ri.findIndex(function(e){return e.id===m}),y=li.findIndex(function(e){return e.id===m}),b=-1===_&&-1!==y,C=v(ri,S.id),E=v(li,S.id);if(C&&!E&&!b){var A=C.split("-"),B=Number(A[0]);if(je){var w=null===(t=null===(i=ri[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=li.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):y,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ri[T],j=li[O],P=F&&!F.title&&!F.content,N=j&&!j.title&&!j.content,k=b||(!C&&!!E||P&&!N);if(k){if(!(je?!!Ro.current["right-".concat(D)]:!!Ro.current[String(D)])&&D>=0)return Qi(D,"right"),void(c=setTimeout(g,200))}else if(!(je?!!Ro.current["left-".concat(T)]:!!Ro.current[String(T)])&&T>=0)return Qi(T,"left"),void(c=setTimeout(g,200));var L=C||"",M=E||"",q="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l).concat(u.DEVIATION_BADGE_SEPARATOR).concat(L).concat(u.DEVIATION_BADGE_SEPARATOR).concat(M),H="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l);if(!f){Zi(q),f=!0,a=0;var V=function(){var e,n,i=null===(e=Ri.current[H])||void 0===e?void 0:e.current,t=null===(n=xi.current[H])||void 0===n?void 0:n.current;return k||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;s||(e=V,n=function(){s||(d=null,g())},t=0,o=null,r=null,l=function(){if(!s){var u=e();if(u&&0!==u.getBoundingClientRect().height){var a=u.getBoundingClientRect(),c=a.top,d=a.height,f=null!==o&&Math.abs(c-o)<.5,v=null!==r&&Math.abs(d-r)<.5;if(f&&v){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var z=null===(r=Ri.current[H])||void 0===r?void 0:r.current,G=null===(p=xi.current[H])||void 0===p?void 0:p.current;if(z||G){var W=k||!z&&!!G,K=W?G:z,U=je?W?xn.current:En.current:Sn.current;if(K&&U){var Y=K.getBoundingClientRect();if(0!==Y.height){var J=U.getBoundingClientRect(),X=Y.top-J.top+U.scrollTop-J.height/2+Y.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,f,v;return e.__generator(this,function(g){switch(g.label){case 0:return s?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[z,G].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[z,G].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!z&&!!G?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},je?[4,Promise.all([En.current?r(u.waitForScrollIdle(En.current),600):Promise.resolve(),xn.current?r(u.waitForScrollIdle(xn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(f=xi.current[$?H:D])||void 0===f?void 0:f.current)||G:(null===(v=Ri.current[$?H:T])||void 0===v?void 0:v.current)||z,to(o,function(){kn({open:!0,anchorEl:o,displayImpact:Ae.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Be||Be(),[2]));case 1:g.sent(),g.label=2;case 2:return Wi(q,!1,{toggleIfSame:!1,sourceSide:b?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=xi.current[H])||void 0===n?void 0:n.current)||G:(null===(t=Ri.current[H])||void 0===t?void 0:t.current)||z,u=(null===(o=Ri.current[H])||void 0===o?void 0:o.current)||z,s=(null===(r=xi.current[H])||void 0===r?void 0:r.current)||G;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),kn({open:!0,anchorEl:l,displayImpact:Ae.displayImpact,summary:e.__assign({},i)}),null==Be||Be()}}),[2]}})})};Math.abs(U.scrollTop-X)<=2?Q():u.scrollAndWait(U,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){s=!0,c&&clearTimeout(c),null==d||d()}}}},[Ae,si,ri,li,je,Ui,Wi,kn,It]),i.useEffect(function(){var n,i,t;if(Nn.open){var o=Nn.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Ri.current)||r(xi.current);if(l){var u=(null===(i=xi.current[l])||void 0===i?void 0:i.current)||(null===(t=Ri.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&kn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Nn.open,Nn.anchorEl,Ze,Ue,Ui]);var so=In.open,ao=In.sectionIdx,co=In.isOrphan,fo=In.badgeStyle,vo=In.anchorEl,go=In.sectionAnchorEl;i.useEffect(function(){var n;if(so&&null!=ao&&ao!==lt){var i="string"==typeof ao?ao.split(u.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(ri,i):null,r=i&&"string"==typeof i?t(li,i):null,l="number"==typeof ao?ri[ao]||null:o||i&&((null===(n=null==ge?void 0:ge.nodes)||void 0===n?void 0:n[i])||(null==ge?void 0:ge[i]))||null,s="number"==typeof ao?li[ao]||null:r,a=Et(vo,l,s,ao,co,fo);Tn(function(n){return n.open?u.safeStringify(n.cognitiveData)===u.safeStringify(a.cognitiveData)&&u.safeStringify(n.deviationData)===u.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[so,ao,co,fo,vo,go,ri,li,Et]);var po=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,s=e.parentNodeId,a=void 0===s?"":s,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:c})},[]),ho=i.useMemo(function(){return ri.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&je?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ri]),mo=i.useMemo(function(){return li.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&je?null:n.jsx(y.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[li]),So=i.useRef(At);i.useEffect(function(){So.current=At},[At]);var Ro=i.useRef(Ui);i.useEffect(function(){Ro.current=Ui},[Ui]);var xo=i.useRef(oo);i.useEffect(function(){xo.current=oo},[oo]);var _o=i.useRef(Qt);i.useEffect(function(){_o.current=Qt},[Qt]);var yo=i.useRef(Qi);i.useEffect(function(){yo.current=Qi},[Qi]);var bo=i.useRef($i);i.useEffect(function(){bo.current=$i},[$i]);var Co=i.useRef(po);i.useEffect(function(){Co.current=po},[po]);var Eo=i.useRef(Gi);i.useEffect(function(){Eo.current=Gi},[Gi]);var Ao=i.useMemo(function(){return{maintainRelativeOrder:!!je,showDeviationBadges:Le,isProposingFix:Ie,proposingFixNodeId:Te,isRedlineFlow:De,isSideBySide:Ii,activeSideBySideSection:Pi,scrollSyncLocked:Ze,toggleScrollSyncLocked:nt,summaryPopupAnchorEl:Nn.anchorEl,connectedSections:Ue,proposedSections:ri,existingSections:li,deviationNumberRegistry:ai,deviationParentRegistry:ci,treeData:ge,displayConfig:_e,resolvedMarkdownStyles:mn,unifiedNumbering:it,expandedSections:Ui,expandedSubSections:Ji,setExpandedSubSections:Xi,getSectionCompareStyle:jt,getSubSectionCompareStyle:Pt,getBadgeRef:Bi,getSectionRowRef:Ei,getSubSectionRef:Ai,sectionLeftRefs:mi,sectionRightRefs:Si,sectionRowRefs:Ci,sectionRightRowRefs:_i,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,openMoreFunctionsPopup:vt,handleOpenSummaryPopup:gt,openSummaryPopup:gt,handleCloseSummaryPopup:pt,toggleSection:ht,handleSubSectionToggle:mt,renderSubSectionAccordion:St,resetSideBySide:Rt,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,showDeviationNavigation:no,showOpenNodeRef:io,deviationNodeIdToView:null==Ae?void 0:Ae.id,deviationTargetParentId:ro}},[je,Le,Ie,Te,De,Ii,Pi,Ze,nt,Nn.anchorEl,Ue,ri,li,ai,_e,mn,it,Ui,Ji,Xi,jt,Pt,Bi,Ei,Ai,no,io,Ae,ro]);return n.jsx(C.CompareContextProvider,e.__assign({value:Ao},{children:n.jsxs(t.Box,e.__assign({ref:Rn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[qe&&n.jsx(t.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(f.default,{})})),Nn.open&&n.jsx(b.default,{open:Nn.open,anchorEl:Nn.anchorEl,containerEl:Dt.current,clipTopEl:on.current,scrollContainerEl:Sn.current,onClose:Qt,summary:Nn.summary,displayImpact:Nn.displayImpact,isScrollLocked:Ze}),n.jsx(d.default,{open:Dn.open,anchorEl:Dn.anchorEl,maintainRelativeOrder:!!je,sectionTitle:Dn.sectionTitle,referenceSectionTitle:Dn.refSectionTitle,onClose:Gn,onOpenCognitiveCompare:Hn,onOpenSideBySide:$t,onConnect:Bt,isConnected:Zt,isOrphan:Dn.isOrphan}),In.open&&n.jsx(c.default,{open:In.open,popupRef:qn,position:Fn,popupConfig:be,onClose:function(){jn(null),Tn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Mn(null)},markdownStyles:Se,sectionTitle:Qn,referenceSectionTitle:ei,cognitiveData:In.cognitiveData,anchorEl:In.anchorEl,sectionAnchorEl:In.sectionAnchorEl,scrollContainerEl:Sn.current,badgeStyle:In.badgeStyle,docData:In.docData,deviationData:In.deviationData,isLoading:In.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!ze,autoHideDuration:8e3,onClose:function(){return Ge(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ge(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ze}))})),n.jsx(R.default,{componentHeaderText:ve,displayConfig:_e,maintainRelativeOrder:je,onCollapseAll:Gt,showCollapseAll:Wt,onToggleView:function(e){He(!0),setTimeout(function(){Pe(!e),null==ye||ye(!e),en(!1),Gi(),Ln(),Ye(new Set),$e([]),cn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){He(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:Sn,onScroll:zt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:je?"visible":"auto",borderTop:ot&&rt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},je?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:tn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},je?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:nn,svgDimensions:Vt,isResizing:Oi,overallConnector:qt,rootDeviationStyle:at,lines:Lt,isSideBySide:Ii,activeSideBySideSection:Pi,isArrowVisible:Ti,maintainRelativeOrder:je,proposedSections:ri,existingSections:li,cognitivePopup:In,activeBadgeId:Pn,closeCognitivePopup:zn,setActiveBadgeId:Mn,openCognitivePopupFromState:Vn,buildSectionPopupState:Et,connectedLines:Xe,pathRefs:an}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},je?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:on,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:Xn,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Xn}))}))})),n.jsxs(t.Box,e.__assign({ref:En,onScroll:zt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},je?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:bn,style:{width:"100%",height:"0px",flexShrink:0}}),fi&&ho,n.jsx("div",{ref:Cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:Dt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),In.open&&Pn===lt?zn():(Mn(lt),Vn(Et(n.currentTarget,{title:"",content:"",evaluationResult:ut,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,lt,!0,e.__assign(e.__assign({},at),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:at.badgeBg,color:at.badgeText,border:"1px solid ".concat(at.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=st?st:n.jsx(v.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&Pn===lt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},je?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ji&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:rn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(t.Tooltip,e.__assign({title:ni,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ni}))}))})),n.jsxs(t.Box,e.__assign({ref:xn,onScroll:zt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},je?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}}),fi&&mo,n.jsx("div",{ref:yn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(i);exports.default=function(s){var c,v,f,p,x,g,h,m,_,I,y,b,A,S=s.section,R=s.idx,w=s.columnKey,E=s.colRef,O=s.mb,B=void 0===O?1:O,j=s.isExpanded,C=s.onToggle,T=s.navigation,D=s.parentNodeId,F=void 0===D?"":D,k=r.useCompareContext(),M=k.showOpenNodeRef,P=k.resolvedMarkdownStyles,N=k.maintainRelativeOrder,V=k.showDeviationBadges,W=void 0!==V&&V,q=k.renderSubSectionAccordion,G=k.treeData,L=k.proposedSections,K=k.existingSections,z=k.deviationNumberRegistry,H=k.deviationParentRegistry,U=k.getBadgeRef,X=k.openSummaryPopup,Y=k.getSectionCompareStyle,J=k.connectedSections,Q=k.openMoreFunctionsPopup,Z=k.isProposingFix,$=k.proposingFixNodeId,ee=k.isRedlineFlow,ne=k.isSideBySide,ie=k.activeSideBySideSection,oe=k.scrollSyncLocked,te=k.toggleScrollSyncLocked,le=k.summaryPopupAnchorEl,re="".concat(ne?"1":"0","-").concat(String(null!=ie?ie:"")),de=(null===(c=S.displayTitle)||void 0===c||c)&&d.hasValue(S.title),ae=!!Z&&!!$&&"left"===w&&S.id===$,se=d.hasMeaningfulRedlineTags(S.content),ue="boolean"==typeof ee?ee:se,ce=se,ve=ue&&se,fe=ve?d.stripRedlineTags(S.content):S.content,pe=ve?S.content:void 0,xe=(null===(v=S.displayContent)||void 0===v||v||se)&&d.hasValue(S.content),ge=!de&&!xe,he=S.title;de||(he=xe?"No Title Found":"No Matching Section Found");var me=S.evaluationResult;if(!me&&"right"===w)if(N){var _e=null===(f=S.refIndexes)||void 0===f?void 0:f[0],Ie=L.find(function(e){return e.selfIndex===_e});me=null==Ie?void 0:Ie.evaluationResult}else me=null===(p=L[R])||void 0===p?void 0:p.evaluationResult;var ye=null===(x=null==G?void 0:G.input_index_map)||void 0===x?void 0:x[0],be=null===(g=null==G?void 0:G.input_index_map)||void 0===g?void 0:g[1],Ae="left"===w?be:ye,Se=function(e,n){var i;if(!n||!e)return null;for(var o=0,t=e;o<t.length;o++){var l=t[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Se(l.subsections,n);if(r)return r}}return null},Re="left"===w?S:Se(L,S.id),we="right"===w?S:Se(K,S.id),Ee=u.default.useMemo(function(){if(!N)return 0;var e=1/0,n=function(i,o,t,l){var r;if(i){var a=i.id;if(l&&"right"===w){var s=L.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(i.selfIndex)});s.length>0&&(a=s[0].id)}var u=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),c=(null===(r=i.evaluationResult)||void 0===r?void 0:r.deviations)||{};Object.keys(c).forEach(function(n){var i="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(n),o=null==z?void 0:z[i];null!=o&&o<e&&(e=o);var t="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(n),l=null==z?void 0:z[t];null!=l&&l<e&&(e=l)});for(var v=i.subsections||[],f=(null==o?void 0:o.subsections)||[],p=(null==t?void 0:t.subsections)||[],x=Math.max(v.length,f.length,p.length),g=0;g<x;g++)n(v[g],f[g],p[g],!1)}};return n(S,Re,we,!0),e!==1/0?e-1:0},[S,Re,we,w,z,N,L]);if(N)if("left"===w){var Oe=null===(h=S.refIndexes)||void 0===h?void 0:h[0],Be=K.findIndex(function(e){return e.selfIndex===Oe});we=-1!==Be?K[Be]:Se(K,S.id)}else{var je=null===(m=S.refIndexes)||void 0===m?void 0:m[0],Ce=L.findIndex(function(e){return e.selfIndex===je});Re=-1!==Ce?L[Ce]:Se(L,S.id)}var Te="left"===w?!we:!Re,De=me||(null==Re?void 0:Re.evaluationResult)||(null==we?void 0:we.evaluationResult),Fe=null!==(y=null===(I=null===(_=null==De?void 0:De.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===I?void 0:I.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR,ke=d.generateColorPalette(Fe).highlightBg,Me=(null==De?void 0:De.deviations)||{},Pe=S.id;if(N&&"left"!==w){var Ne=L.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(S.selfIndex)});Ne.length>0?Pe=Ne[0].id:(null==Re?void 0:Re.id)&&(Pe=Re.id)}var Ve=Object.keys(Me)[0],We=Ve?"".concat(Pe).concat(d.DEVIATION_BADGE_SEPARATOR).concat(Ve):null,qe=We?null==H?void 0:H[We]:null,Ge=null!=qe?qe:R+1;if(null==qe&&N)if("left"===w)Ge=void 0!==S.selfIndex&&S.selfIndex>=0?S.selfIndex+1:R+1;else{Ne=L.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(S.selfIndex)});Ge=Ne.length>0?void 0!==Ne[0].selfIndex&&Ne[0].selfIndex>=0?Ne[0].selfIndex+1:R+1:void 0!==S.selfIndex&&S.selfIndex>=0?S.selfIndex+1:R+1}var Le=Object.entries(Me).map(function(e){var n=e[0],i=e[1],o="".concat(Pe).concat(d.DEVIATION_BADGE_SEPARATOR).concat(n);return{deviationKey:n,deviationMap:i,refId:o,currentIndex:z[o]}}).filter(function(e){return void 0!==e.currentIndex&&null!==e.currentIndex});Le.sort(function(e,n){return e.currentIndex-n.currentIndex});var Ke,ze=Le.map(function(n){var i,o,t,l,r,a,s=n.deviationKey,u=n.deviationMap,c=n.refId,v=n.currentIndex;N&&void 0!==Ee&&(v-=Ee);var f=u[F],p=d.isMissingStr(f);if(p)f="";else if(!f)return null;var x=R,g=R;if(N)if("left"===w){var h=null===(i=S.refIndexes)||void 0===i?void 0:i[0],m=K.findIndex(function(e){return e.selfIndex===h});if(-1!==m)g=m;else{var _=K.findIndex(function(e){return e.id===S.id});g=-1!==_?_:R}}else{var I=null===(o=S.refIndexes)||void 0===o?void 0:o[0],y=L.findIndex(function(e){return e.selfIndex===I});if(-1!==y)x=y;else x=-1!==(j=L.findIndex(function(e){return e.id===S.id}))?j:R}var b="".concat(Pe).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(x).concat(d.DEVIATION_BADGE_SEPARATOR).concat(g),A=u[Ae],E=Te||d.isMissingStr(A),O="".concat(Ge,".").concat(v),B=R;if("right"===w&&N){var j,C=null===(t=S.refIndexes)||void 0===t?void 0:t[0],T=L.findIndex(function(e){return e.selfIndex===C});if(-1!==T)B=T;else-1!==(j=L.findIndex(function(e){return e.id===S.id}))&&(B=j)}var D=Y?Y(B):null,k=(null==u?void 0:u.evaluation_outputs)||(null==De?void 0:De.evaluation_outputs),M=null!==(l=null==k?void 0:k.output_value)&&void 0!==l?l:null,P=null!==(a=null===(r=null==k?void 0:k.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Fe,V=d.generateColorPalette(P),W=D?e.__assign(e.__assign({},D),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):e.__assign({},V),q=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==De?void 0:De.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==De?void 0:De.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==De?void 0:De.deviation_explanation),evaluation_outputs:k,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==De?void 0:De.cognitive_decisioning)}:null,G=0,z=fe||"";if(f&&z){var H=z.split(/\n{2,}/),Z=H.findIndex(function(e){return e.includes(f)});if(-1!==Z){var $=Object.entries(Me).filter(function(e){e[0];var n=e[1][F];return n&&H[Z].includes(n)}).sort(function(e,n){return H[Z].indexOf(e[1][F])-H[Z].indexOf(n[1][F])}),ee=$.filter(function(e){e[0];var n=e[1][F];return n&&(n.includes(f)||f.includes(n))});ee.length>1&&(G=Math.max(0,ee.findIndex(function(e){return e[0]===s})))}}var re=U(w,c);return{id:c,actionId:b,label:O,highlight:f,side:w,style:W,stackIndex:G,score:M,isConnected:null==J?void 0:J.has(b),showScrollLockToggle:(null==J?void 0:J.has(b))||ne&&ie===b||!!le&&le===re.current,scrollSyncLocked:oe,toggleScrollSyncLocked:te,isOrphan:E,isMissingClause:p,badgeRef:re,onClick:function(e){e.stopPropagation(),Q&&Q(e,Re||{id:"orphan-left",title:"",content:""},E,we||{id:"orphan-right",title:"",content:""},b,W)},onSummaryClick:function(e){e.stopPropagation(),X(e,b,E,q)}}}).filter(Boolean),He=W||!ue&&ae?ze:[],Ue=ze.map(function(e){return e.highlight}).filter(Boolean),Xe=S.id&&w===(null==T?void 0:T.columnKey)?T:null,Ye=u.default.useRef(!1);return i.useEffect(function(){j||(Ye.current=!1)},[j]),n.jsxs(o.Box,e.__assign({ref:E,sx:{mb:B,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[j&&(null==Xe?void 0:Xe.showAbove)&&n.jsx("div",e.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Xe?void 0:Xe.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===w?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===w?{right:"-20px"}:{left:"-20px"})},{children:n.jsx(t.ChevronUp,{color:(null===(b=null==Xe?void 0:Xe.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(Xe.showAboveRef.current).color:void 0})}))})),n.jsxs(o.Accordion,e.__assign({disableGutters:!0,expanded:!ge&&j,onChange:function(){ge||(C(),M.current=S.id)},sx:{boxShadow:"none",border:ge?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:ge?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:ge?null:n.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:ge?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:de&&n.jsx(o.Tooltip,e.__assign({title:he,placement:"top"},{children:n.jsx(o.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:ge?"#94A3B8":"#19213D",fontWeight:ge?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Ke=he,Ke?d.safeStringify(Ke).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(u.default.Fragment,{children:e},i)}):null)}))}))})),!ge&&n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[xe&&n.jsx(l.MemoizedMarkdown,{content:fe,overlayContent:pe,sxStyles:P,highlights:Ue,maintainRelativeOrder:N,highlightBg:ke,suppressHighlightBg:ce,deviationBadges:He,collisionKey:re}),(S.subsections||[]).map(function(e,n){return q({section:e,keyPath:"".concat(R,"-").concat(n),depth:0,columnKey:w,parentNodeId:F,sectionOffset:Ee})})]}))]})),j&&(null==Xe?void 0:Xe.showBelow)&&n.jsx("div",e.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Xe?void 0:Xe.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===w?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===w?{right:"-20px"}:{left:"-20px"})},{children:n.jsx(t.ChevronDown,{color:(null===(A=null==Xe?void 0:Xe.showBelowRef)||void 0===A?void 0:A.current)?window.getComputedStyle(Xe.showBelowRef.current).color:void 0})}))}))]}),"".concat(w,"-sec-").concat(R))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function u(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var s=u(i);exports.default=function(u){var c,v,f,p,g,x,h,m,_,I,y,b,A,S=u.section,R=u.idx,w=u.columnKey,E=u.colRef,O=u.mb,B=void 0===O?1:O,j=u.isExpanded,C=u.onToggle,T=u.navigation,D=u.parentNodeId,F=void 0===D?"":D,k=r.useCompareContext(),M=k.showOpenNodeRef,N=k.resolvedMarkdownStyles,P=k.maintainRelativeOrder,V=k.showDeviationBadges,W=void 0!==V&&V,q=k.renderSubSectionAccordion,G=k.treeData,L=k.proposedSections,K=k.existingSections,z=k.deviationNumberRegistry,H=k.deviationParentRegistry,U=k.getBadgeRef,X=k.openSummaryPopup,Y=k.getSectionCompareStyle,J=k.connectedSections,Q=k.openMoreFunctionsPopup,Z=k.isProposingFix,$=k.proposingFixNodeId,nn=k.isRedlineFlow,en=k.isSideBySide,on=k.activeSideBySideSection,tn=k.scrollSyncLocked,ln=k.unifiedNumbering,rn=k.toggleScrollSyncLocked,dn=k.summaryPopupAnchorEl,an="".concat(en?"1":"0","-").concat(String(null!=on?on:"")),un=(null===(c=S.displayTitle)||void 0===c||c)&&d.hasValue(S.title),sn=!!Z&&!!$&&"left"===w&&S.id===$,cn=d.hasMeaningfulRedlineTags(S.content),vn="boolean"==typeof nn?nn:cn,fn=cn,pn=vn&&cn,gn=pn?d.stripRedlineTags(S.content):S.content,xn=pn?S.content:void 0,hn=(null===(v=S.displayContent)||void 0===v||v||cn)&&d.hasValue(S.content),mn=!un&&!hn,_n=S.title;un||(_n=hn?"No Title Found":"No Matching Section Found");var In=S.evaluationResult;if(!In&&"right"===w)if(P){var yn=null===(f=S.refIndexes)||void 0===f?void 0:f[0],bn=L.find(function(n){return n.selfIndex===yn});In=null==bn?void 0:bn.evaluationResult}else In=null===(p=L[R])||void 0===p?void 0:p.evaluationResult;var An=null===(g=null==G?void 0:G.input_index_map)||void 0===g?void 0:g[0],Sn=null===(x=null==G?void 0:G.input_index_map)||void 0===x?void 0:x[1],Rn="left"===w?Sn:An,wn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=wn(l.subsections,e);if(r)return r}}return null},En="left"===w?S:wn(L,S.id),On="right"===w?S:wn(K,S.id),Bn=s.default.useMemo(function(){if(!P)return 0;var n=1/0,e=function(i,o,t,l){var r;if(i){var a=i.id;if(l&&"right"===w){var u=L.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});u.length>0&&(a=u[0].id)}var s=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),c=(null===(r=i.evaluationResult)||void 0===r?void 0:r.deviations)||{};Object.keys(c).forEach(function(e){var i="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),o=null==z?void 0:z[i];null!=o&&o<n&&(n=o);var t="".concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),l=null==z?void 0:z[t];null!=l&&l<n&&(n=l)});for(var v=i.subsections||[],f=(null==o?void 0:o.subsections)||[],p=(null==t?void 0:t.subsections)||[],g=Math.max(v.length,f.length,p.length),x=0;x<g;x++)e(v[x],f[x],p[x],!1)}};return e(S,En,On,!0),n!==1/0?n-1:0},[S,En,On,w,z,P,L]);if(P)if("left"===w){var jn=null===(h=S.refIndexes)||void 0===h?void 0:h[0],Cn=K.findIndex(function(n){return n.selfIndex===jn});On=-1!==Cn?K[Cn]:wn(K,S.id)}else{var Tn=null===(m=S.refIndexes)||void 0===m?void 0:m[0],Dn=L.findIndex(function(n){return n.selfIndex===Tn});En=-1!==Dn?L[Dn]:wn(L,S.id)}var Fn="left"===w?!On:!En,kn=In||(null==En?void 0:En.evaluationResult)||(null==On?void 0:On.evaluationResult),Mn=null!==(y=null===(I=null===(_=null==kn?void 0:kn.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===I?void 0:I.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR,Nn=d.generateColorPalette(Mn).highlightBg,Pn=(null==kn?void 0:kn.deviations)||{},Vn=S.id;if(P&&"left"!==w){var Wn=L.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(S.selfIndex)});Wn.length>0?Vn=Wn[0].id:(null==En?void 0:En.id)&&(Vn=En.id)}var qn=Object.keys(Pn)[0],Gn=qn?"".concat(Vn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(qn):null,Ln=Gn?null==H?void 0:H[Gn]:null,Kn=R+1;if(P&&ln){var zn="left"===w?ln.leftNums.get(null==S?void 0:S.id):ln.rightNums.get(null==S?void 0:S.id);Fn&&void 0!==zn?Kn=zn:null!=Ln&&Ln>=0?Kn=Ln:void 0!==zn&&(Kn=zn)}else null!=Ln&&Ln>=0&&(Kn=Ln);var Hn=Object.entries(Pn).map(function(n){var e=n[0],i=n[1],o="".concat(Vn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:z[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});Hn.sort(function(n,e){return n.currentIndex-e.currentIndex});var Un,Xn=Hn.map(function(e){var i,o,t,l,r,a,u=e.deviationKey,s=e.deviationMap,c=e.refId,v=e.currentIndex;P&&void 0!==Bn&&(v-=Bn);var f=s[F],p=d.isMissingStr(f);if(p)f="";else if(!f)return null;var g=R,x=R;if(P)if("left"===w){var h=null===(i=S.refIndexes)||void 0===i?void 0:i[0],m=K.findIndex(function(n){return n.selfIndex===h});if(-1!==m)x=m;else{var _=K.findIndex(function(n){return n.id===S.id});x=-1!==_?_:R}}else{var I=null===(o=S.refIndexes)||void 0===o?void 0:o[0],y=L.findIndex(function(n){return n.selfIndex===I});if(-1!==y)g=y;else g=-1!==(j=L.findIndex(function(n){return n.id===S.id}))?j:R}var b="".concat(Vn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(g).concat(d.DEVIATION_BADGE_SEPARATOR).concat(x),A=s[Rn],E=Fn||d.isMissingStr(A),O="".concat(Kn,".").concat(v),B=R;if("right"===w&&P){var j,C=null===(t=S.refIndexes)||void 0===t?void 0:t[0],T=L.findIndex(function(n){return n.selfIndex===C});if(-1!==T)B=T;else-1!==(j=L.findIndex(function(n){return n.id===S.id}))&&(B=j)}var D=Y?Y(B):null,k=(null==s?void 0:s.evaluation_outputs)||(null==kn?void 0:kn.evaluation_outputs),M=null!==(l=null==k?void 0:k.output_value)&&void 0!==l?l:null,N=null!==(a=null===(r=null==k?void 0:k.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Mn,V=d.generateColorPalette(N),W=D?n.__assign(n.__assign({},D),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):n.__assign({},V),q=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary,deviation_title:(null==s?void 0:s.deviation_title)||(null==kn?void 0:kn.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==kn?void 0:kn.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==kn?void 0:kn.deviation_explanation),evaluation_outputs:k,cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==kn?void 0:kn.cognitive_decisioning)}:null,G=0,z=gn||"";if(f&&z){var H=z.split(/\n{2,}/),Z=H.findIndex(function(n){return n.includes(f)});if(-1!==Z){var $=Object.entries(Pn).filter(function(n){n[0];var e=n[1][F];return e&&H[Z].includes(e)}).sort(function(n,e){return H[Z].indexOf(n[1][F])-H[Z].indexOf(e[1][F])}),nn=$.filter(function(n){n[0];var e=n[1][F];return e&&(e.includes(f)||f.includes(e))});nn.length>1&&(G=Math.max(0,nn.findIndex(function(n){return n[0]===u})))}}var ln=U(w,c);return{id:c,actionId:b,label:O,highlight:f,side:w,style:W,stackIndex:G,score:M,isConnected:null==J?void 0:J.has(b),showScrollLockToggle:(null==J?void 0:J.has(b))||en&&on===b||!!dn&&dn===ln.current,scrollSyncLocked:tn,toggleScrollSyncLocked:rn,isOrphan:E,isMissingClause:p,badgeRef:ln,onClick:function(n){n.stopPropagation(),Q&&Q(n,En||{id:"orphan-left",title:"",content:""},E,On||{id:"orphan-right",title:"",content:""},b,W)},onSummaryClick:function(n){n.stopPropagation(),X(n,b,E,q)}}}).filter(Boolean),Yn=W||!vn&&sn?Xn:[],Jn=Xn.map(function(n){return n.highlight}).filter(Boolean),Qn=S.id&&w===(null==T?void 0:T.columnKey)?T:null,Zn=s.default.useRef(!1);return i.useEffect(function(){j||(Zn.current=!1)},[j]),e.jsxs(o.Box,n.__assign({ref:E,sx:{mb:B,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[j&&(null==Qn?void 0:Qn.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==Qn?void 0:Qn.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===w?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===w?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronUp,{color:(null===(b=null==Qn?void 0:Qn.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(Qn.showAboveRef.current).color:void 0})}))})),e.jsxs(o.Accordion,n.__assign({disableGutters:!0,expanded:!mn&&j,onChange:function(){mn||(C(),M.current=S.id)},sx:{boxShadow:"none",border:mn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:mn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(o.AccordionSummary,n.__assign({expandIcon:mn?null:e.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:mn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:un&&e.jsx(o.Tooltip,n.__assign({title:_n,placement:"top"},{children:e.jsx(o.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:mn?"#94A3B8":"#19213D",fontWeight:mn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Un=_n,Un?d.safeStringify(Un).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,i){return n.startsWith("**")&&n.endsWith("**")?e.jsx("strong",{children:n.slice(2,-2)},i):e.jsx(s.default.Fragment,{children:n},i)}):null)}))}))})),!mn&&e.jsxs(o.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[hn&&e.jsx(l.MemoizedMarkdown,{content:gn,overlayContent:xn,sxStyles:N,highlights:Jn,maintainRelativeOrder:P,highlightBg:Nn,suppressHighlightBg:fn,deviationBadges:Yn,collisionKey:an}),(S.subsections||[]).map(function(n,e){return q({section:n,keyPath:"".concat(R,"-").concat(e),depth:0,columnKey:w,parentNodeId:F,sectionOffset:Bn})})]}))]})),j&&(null==Qn?void 0:Qn.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==Qn?void 0:Qn.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===w?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===w?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronDown,{color:(null===(A=null==Qn?void 0:Qn.showBelowRef)||void 0===A?void 0:A.current)?window.getComputedStyle(Qn.showBelowRef.current).color:void 0})}))}))]}),"".concat(w,"-sec-").concat(R))};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|