@e-llm-studio/citation 0.0.213 → 0.0.215
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 +307 -38
- package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitation.module.css.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitationImageFullScreenView.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitationSkeleton.js +1 -1
- package/dist/cjs/features/GptWebCitation/utils/citationData.utils.js +1 -1
- package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js +2 -0
- package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js.map +1 -0
- package/dist/cjs/features/GptWebCitation/utils/styleOverrides.utils.js +2 -0
- package/dist/cjs/features/GptWebCitation/utils/styleOverrides.utils.js.map +1 -0
- package/dist/cjs/features/RulebookCitations/RuleBookCitationApi.js +2 -0
- package/dist/cjs/features/RulebookCitations/RuleBookCitationApi.js.map +1 -0
- package/dist/cjs/features/RulebookCitations/RuleBookCitationWrapper.js +2 -0
- package/dist/cjs/features/RulebookCitations/RuleBookCitationWrapper.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitation.module.css.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitationImageFullScreenView.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitationSkeleton.js +1 -1
- package/dist/features/GptWebCitation/utils/citationData.utils.js +1 -1
- package/dist/features/GptWebCitation/utils/fixedHeight.utils.js +2 -0
- package/dist/features/GptWebCitation/utils/fixedHeight.utils.js.map +1 -0
- package/dist/features/GptWebCitation/utils/styleOverrides.utils.js +2 -0
- package/dist/features/GptWebCitation/utils/styleOverrides.utils.js.map +1 -0
- package/dist/features/RulebookCitations/RuleBookCitationApi.js +2 -0
- package/dist/features/RulebookCitations/RuleBookCitationApi.js.map +1 -0
- package/dist/features/RulebookCitations/RuleBookCitationWrapper.js +2 -0
- package/dist/features/RulebookCitations/RuleBookCitationWrapper.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts +10 -0
- package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +9 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageFullScreenView.d.ts +3 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageFullScreenView.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationSkeleton.d.ts +12 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationSkeleton.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationTest.d.ts +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationTest.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/WebCitationSampleResponse.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/types.d.ts +289 -18
- package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/utils/citationData.utils.d.ts +2 -0
- package/dist/types/src/features/GptWebCitation/utils/citationData.utils.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +10 -0
- package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -0
- package/dist/types/src/features/GptWebCitation/utils/styleOverrides.utils.d.ts +6 -0
- package/dist/types/src/features/GptWebCitation/utils/styleOverrides.utils.d.ts.map +1 -0
- package/dist/types/src/features/RulebookCitations/RuleBookCitationApi.d.ts +31 -0
- package/dist/types/src/features/RulebookCitations/RuleBookCitationApi.d.ts.map +1 -0
- package/dist/types/src/features/RulebookCitations/RuleBookCitationWrapper.d.ts +11 -0
- package/dist/types/src/features/RulebookCitations/RuleBookCitationWrapper.d.ts.map +1 -0
- package/dist/types/src/features/RulebookCitations/RuleBookCitationWrapperTest.d.ts +3 -0
- package/dist/types/src/features/RulebookCitations/RuleBookCitationWrapperTest.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +6 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js +0 -2
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js.map +0 -1
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js +0 -2
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js.map +0 -1
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
- [ReviewPanel](#reviewpanel) [<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/ReviewPanel/README.md)
|
|
35
35
|
- [TableCitationContent](#tablecitationcontent) [<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/TableCitation/README.md)
|
|
36
36
|
- [SplitterCitationsComponent](#splittercitationscomponent) [<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/SplitterCitations/README.md)
|
|
37
|
+
- [RuleBookCitationWrapper](#RuleBookCitationWrapper) [<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/RuleBookCitations/README.md)
|
|
37
38
|
-[ManageReminders](#ManageReminders) [<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/ManageRemainders/README.md)
|
|
38
39
|
4. [Common Use Cases](#common-use-cases)
|
|
39
40
|
5. [Development & Contribution](#development--contribution)
|
|
@@ -680,31 +681,51 @@ const reasoningData = {
|
|
|
680
681
|
|
|
681
682
|
`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.
|
|
682
683
|
|
|
683
|
-
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
|
|
684
|
+
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 screenshot snapshot of the source page (when available), a relevance score badge, visit links, and a **View GPT Citation** toggle to switch back.
|
|
685
|
+
|
|
686
|
+
The component is **presentational** — it does not fetch web citations. The parent owns `webCitationData`, `webCitationStatus`, and view toggling.
|
|
684
687
|
|
|
685
688
|
### Features
|
|
686
689
|
|
|
687
690
|
- **Dual citation views** — Toggle between GPT reasoning and web-based citation
|
|
688
691
|
- **Non-invasive GPT integration** — Wraps `CognitiveInternalgptCoreComponent` via props; no changes to GPT citation code required
|
|
689
|
-
- **
|
|
690
|
-
- **
|
|
692
|
+
- **Screenshot web citations** — Renders `imageMetadata.signed_url` when the API returns a snapshot
|
|
693
|
+
- **Status-driven skeleton UI** — `"pending"` loading skeleton and `"error"` fallback with **Visit Link**
|
|
694
|
+
- **`defaultCitationUrl`** — Immediate visit link while fetch is in progress (before `highlightedUrl` arrives)
|
|
695
|
+
- **Visit link priority** — `highlightedUrl` from API response wins over `defaultCitationUrl` in pending/error states
|
|
691
696
|
- **Relevance score badge** — Auto-extracted from web citation content (e.g. "decision strength is 85%")
|
|
692
|
-
- **Loading skeleton** — Built-in loading state while web citation is being generated
|
|
693
697
|
- **Expand screenshot button** — Optional full-screen image view (`showExpandImageButton`)
|
|
698
|
+
- **Custom icons** — Override expand and external-link icons via `iconsConfig`
|
|
699
|
+
- **Fixed height mode** — Optional `isFixedHeight` keeps GPT and web panels the same size with contained screenshots
|
|
694
700
|
- **Style overrides** — Customize layout via the `styles` prop without editing component internals
|
|
695
701
|
|
|
696
702
|
### Installation / Import
|
|
697
703
|
|
|
698
704
|
```tsx
|
|
699
705
|
import GptWebCitation from '@e-llm-studio/citation/GptWebCitation';
|
|
706
|
+
|
|
707
|
+
// Optional utilities and types
|
|
708
|
+
import {
|
|
709
|
+
mapCitationDataToDisplay,
|
|
710
|
+
getWebCitationImageUrl,
|
|
711
|
+
resolveSkeletonVisitUrl,
|
|
712
|
+
type GptWebCitationStatus,
|
|
713
|
+
type IWebCitationApiResponse,
|
|
714
|
+
type IGptWebCitationStyleOverrides,
|
|
715
|
+
type IGptWebCitationImageStyles,
|
|
716
|
+
type IGptWebCitationSkeletonStyles,
|
|
717
|
+
type IGptWebCitationVisitLinkStyles,
|
|
718
|
+
type IGptWebCitationFullScreenStyles,
|
|
719
|
+
} from '@e-llm-studio/citation';
|
|
700
720
|
```
|
|
701
721
|
|
|
702
722
|
### Usage 1: Basic GPT + Web Citation Toggle
|
|
703
723
|
|
|
704
724
|
```tsx
|
|
705
725
|
import { useState } from 'react';
|
|
706
|
-
import { ChevronDown, ChevronUp, Maximize2, X } from 'lucide-react';
|
|
726
|
+
import { ChevronDown, ChevronUp, ExternalLink, Maximize2, X } from 'lucide-react';
|
|
707
727
|
import GptWebCitation from '@e-llm-studio/citation/GptWebCitation';
|
|
728
|
+
import type { GptWebCitationStatus } from '@e-llm-studio/citation';
|
|
708
729
|
|
|
709
730
|
const gptCitation = {
|
|
710
731
|
item: {
|
|
@@ -726,31 +747,42 @@ const gptCitation = {
|
|
|
726
747
|
previewCallback: () => window.open('/preview/document'),
|
|
727
748
|
};
|
|
728
749
|
|
|
750
|
+
const webCitationIcons = {
|
|
751
|
+
MaximizeIcon: Maximize2,
|
|
752
|
+
ExternalLinkIcon: ExternalLink,
|
|
753
|
+
};
|
|
754
|
+
|
|
729
755
|
function CitationPanel() {
|
|
730
756
|
const [showWebCitation, setShowWebCitation] = useState(false);
|
|
731
757
|
const [webCitationData, setWebCitationData] = useState(undefined);
|
|
732
|
-
const [
|
|
758
|
+
const [webCitationStatus, setWebCitationStatus] =
|
|
759
|
+
useState<GptWebCitationStatus>('pending');
|
|
733
760
|
|
|
734
761
|
const handleGenerateWebCitation = async () => {
|
|
735
762
|
setShowWebCitation(true);
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
763
|
+
setWebCitationStatus('pending');
|
|
764
|
+
|
|
765
|
+
try {
|
|
766
|
+
const response = await fetch('/api/web-citation/generate');
|
|
767
|
+
const data = await response.json();
|
|
768
|
+
setWebCitationData(data);
|
|
769
|
+
setWebCitationStatus('success');
|
|
770
|
+
} catch {
|
|
771
|
+
setWebCitationStatus('error');
|
|
772
|
+
}
|
|
743
773
|
};
|
|
744
774
|
|
|
745
775
|
return (
|
|
746
776
|
<GptWebCitation
|
|
747
777
|
gptCitation={gptCitation}
|
|
778
|
+
defaultCitationUrl="https://example.com/article"
|
|
748
779
|
isWebCitation={true}
|
|
749
780
|
webCitationData={webCitationData}
|
|
781
|
+
webCitationStatus={webCitationStatus}
|
|
750
782
|
showWebCitation={showWebCitation}
|
|
751
|
-
isWebCitationLoading={isLoading}
|
|
752
783
|
onGenerateWebCitation={handleGenerateWebCitation}
|
|
753
784
|
onToggleCitationView={() => setShowWebCitation((prev) => !prev)}
|
|
785
|
+
iconsConfig={webCitationIcons}
|
|
754
786
|
/>
|
|
755
787
|
);
|
|
756
788
|
}
|
|
@@ -767,6 +799,8 @@ const webCitationData = {
|
|
|
767
799
|
'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>',
|
|
768
800
|
citationType: 'web',
|
|
769
801
|
citationUrl: 'https://example.com/article',
|
|
802
|
+
highlightedUrl: 'https://example.com/article#highlight',
|
|
803
|
+
message: 'Citation processed successfully',
|
|
770
804
|
imageMetadata: {
|
|
771
805
|
signed_url: 'https://storage.example.com/image_citations/screenshot.png',
|
|
772
806
|
blob_path: 'image_citations/screenshot.png',
|
|
@@ -776,21 +810,33 @@ const webCitationData = {
|
|
|
776
810
|
|
|
777
811
|
<GptWebCitation
|
|
778
812
|
gptCitation={gptCitation}
|
|
813
|
+
defaultCitationUrl="https://example.com/article"
|
|
779
814
|
isWebCitation={true}
|
|
780
815
|
webCitationData={webCitationData}
|
|
816
|
+
webCitationStatus="success"
|
|
781
817
|
showWebCitation={true}
|
|
782
818
|
/>
|
|
783
819
|
```
|
|
784
820
|
|
|
785
|
-
When `imageMetadata.signed_url` is present
|
|
821
|
+
When `imageMetadata.signed_url` is present and `webCitationStatus` is `"success"`, the component renders a screenshot snapshot. If the image is unavailable or the fetch fails, an error skeleton is shown with a **Visit Link** (using `highlightedUrl` or `defaultCitationUrl`).
|
|
822
|
+
|
|
823
|
+
#### Visit link resolution
|
|
824
|
+
|
|
825
|
+
| UI state | Visit link source |
|
|
826
|
+
| --- | --- |
|
|
827
|
+
| Pending / error skeleton | `highlightedUrl` from `webCitationData` → else `defaultCitationUrl` prop |
|
|
828
|
+
| Screenshot footer (success) | `citationUrl` from `webCitationData` |
|
|
829
|
+
|
|
830
|
+
Use `resolveSkeletonVisitUrl(highlightedUrl, defaultCitationUrl)` from `@e-llm-studio/citation` if you need the same logic outside the component.
|
|
786
831
|
|
|
787
832
|
### Usage 3: GPT-Only Mode (No Web Citation)
|
|
788
833
|
|
|
789
|
-
Set `isWebCitation={false}` to render only the GPT citation with no toggle button:
|
|
834
|
+
Set `isWebCitation={false}` to render only the GPT citation with no toggle button. `defaultCitationUrl` is still required by the prop contract but is unused in GPT-only mode:
|
|
790
835
|
|
|
791
836
|
```tsx
|
|
792
837
|
<GptWebCitation
|
|
793
838
|
gptCitation={gptCitation}
|
|
839
|
+
defaultCitationUrl="https://example.com/article"
|
|
794
840
|
isWebCitation={false}
|
|
795
841
|
/>
|
|
796
842
|
```
|
|
@@ -802,8 +848,10 @@ Hide the web citation screenshot expand button:
|
|
|
802
848
|
```tsx
|
|
803
849
|
<GptWebCitation
|
|
804
850
|
gptCitation={gptCitation}
|
|
851
|
+
defaultCitationUrl="https://example.com/article"
|
|
805
852
|
isWebCitation={true}
|
|
806
853
|
webCitationData={webCitationData}
|
|
854
|
+
webCitationStatus="success"
|
|
807
855
|
showWebCitation={true}
|
|
808
856
|
showExpandImageButton={false}
|
|
809
857
|
/>
|
|
@@ -814,6 +862,7 @@ Hide the GPT citation header maximize/expand icon:
|
|
|
814
862
|
```tsx
|
|
815
863
|
<GptWebCitation
|
|
816
864
|
gptCitation={gptCitation}
|
|
865
|
+
defaultCitationUrl="https://example.com/article"
|
|
817
866
|
isWebCitation={true}
|
|
818
867
|
showGptMaximizeButton={false}
|
|
819
868
|
/>
|
|
@@ -823,7 +872,7 @@ You can also use `gptCitation.disableMaximize: true` directly on the GPT config.
|
|
|
823
872
|
|
|
824
873
|
### Usage 5: Custom Styling via Props (matched heights)
|
|
825
874
|
|
|
826
|
-
Layout, borders, and heights for **both GPT and web views** can be controlled from the parent without modifying component internals:
|
|
875
|
+
Layout, borders, and heights for **both GPT and web views** can be controlled from the parent without modifying component internals. Prefer **`isFixedHeight`** (Usage 6) when you only need equal panel size + contained screenshots; use `styles` when you need granular control over skeleton, image, visit-link, or full-screen elements:
|
|
827
876
|
|
|
828
877
|
```tsx
|
|
829
878
|
const sharedPanelHeight = '520px';
|
|
@@ -834,9 +883,15 @@ const sharedContentHeight = '384px';
|
|
|
834
883
|
...gptCitation,
|
|
835
884
|
bodyHeight: sharedContentHeight,
|
|
836
885
|
}}
|
|
886
|
+
defaultCitationUrl="https://example.com/article"
|
|
837
887
|
isWebCitation={true}
|
|
838
888
|
webCitationData={webCitationData}
|
|
889
|
+
webCitationStatus="success"
|
|
839
890
|
showGptMaximizeButton={true}
|
|
891
|
+
iconsConfig={{
|
|
892
|
+
MaximizeIcon: Maximize2,
|
|
893
|
+
ExternalLinkIcon: ExternalLink,
|
|
894
|
+
}}
|
|
840
895
|
styles={{
|
|
841
896
|
container: { maxWidth: 900 },
|
|
842
897
|
gptCitation: {
|
|
@@ -877,33 +932,143 @@ const sharedContentHeight = '384px';
|
|
|
877
932
|
| `gptCitation.footerAction` | GPT view | View Web Citation button row in footer |
|
|
878
933
|
| `gptCitation.toggleButton` | GPT view | View Web Citation button styles |
|
|
879
934
|
| `webCitation.panel` | Web view | Outer web citation card |
|
|
880
|
-
| `webCitation.header` | Web view | Source label +
|
|
881
|
-
| `webCitation.content` | Web view |
|
|
935
|
+
| `webCitation.header` | Web view | Source label + relevance score badge row |
|
|
936
|
+
| `webCitation.content` | Web view | Screenshot or loading/error skeleton |
|
|
882
937
|
| `webCitation.footer` | Web view | View GPT Citation + Learned From row |
|
|
883
938
|
| `webCitation.toggleButton` | Web view | View GPT Citation button styles |
|
|
884
939
|
| `webCitation.learnedFrom` | Web view | "Learned From …" text styles |
|
|
940
|
+
| `webCitation.visitLink.row` | Image + skeleton | Shared visit link row (merged with scoped overrides below) |
|
|
941
|
+
| `webCitation.visitLink.hint` | Image + skeleton | Shared visit link hint text |
|
|
942
|
+
| `webCitation.visitLink.link` | Image + skeleton | Shared visit link anchor styles |
|
|
943
|
+
| `webCitation.image.wrapper` | Screenshot view | Outer image citation wrapper |
|
|
944
|
+
| `webCitation.image.center` | Screenshot view | Center column (viewport or inline skeleton) |
|
|
945
|
+
| `webCitation.image.viewport` | Screenshot view | Viewport around scroll container |
|
|
946
|
+
| `webCitation.image.scrollContainer` | Screenshot view | Scrollable screenshot container |
|
|
947
|
+
| `webCitation.image.image` | Screenshot view | Screenshot `<img>` element |
|
|
948
|
+
| `webCitation.image.expandButton` | Screenshot view | Full-screen expand button |
|
|
949
|
+
| `webCitation.image.visitLink.*` | Screenshot footer | Image-specific visit link overrides (merged on top of `webCitation.visitLink`) |
|
|
950
|
+
| `webCitation.image.fullScreen.overlay` | Full-screen viewer | Portal overlay backdrop |
|
|
951
|
+
| `webCitation.image.fullScreen.content` | Full-screen viewer | Modal content card |
|
|
952
|
+
| `webCitation.image.fullScreen.closeButton` | Full-screen viewer | Close button |
|
|
953
|
+
| `webCitation.image.fullScreen.imageWrapper` | Full-screen viewer | Scrollable image wrapper |
|
|
954
|
+
| `webCitation.image.fullScreen.image` | Full-screen viewer | Full-screen `<img>` |
|
|
955
|
+
| `webCitation.skeleton.container` | Pending/error | Outer skeleton column |
|
|
956
|
+
| `webCitation.skeleton.frame` | Pending/error | Gray skeleton frame |
|
|
957
|
+
| `webCitation.skeleton.shimmer` | Pending | Shimmer animation overlay |
|
|
958
|
+
| `webCitation.skeleton.pending.content` | Pending | Centered pending content block |
|
|
959
|
+
| `webCitation.skeleton.pending.text` | Pending | Loading message text |
|
|
960
|
+
| `webCitation.skeleton.pending.actionRow` | Pending | Visit link row |
|
|
961
|
+
| `webCitation.skeleton.pending.actionHint` | Pending | "to view details" hint |
|
|
962
|
+
| `webCitation.skeleton.error.content` | Error | Error content block |
|
|
963
|
+
| `webCitation.skeleton.error.title` | Error | "No preview available" title |
|
|
964
|
+
| `webCitation.skeleton.error.message` | Error | Restriction message |
|
|
965
|
+
| `webCitation.skeleton.error.actionGroup` | Error | Action row wrapper |
|
|
966
|
+
| `webCitation.skeleton.error.detailsToggle` | Error | Error details expand button |
|
|
967
|
+
| `webCitation.skeleton.error.detailsMessage` | Error | Expanded error details text |
|
|
968
|
+
| `webCitation.skeleton.error.visitLinkGlow` | Error | Glowing visit link (merged on top of visit link styles) |
|
|
969
|
+
| `webCitation.skeleton.visitLink.*` | Pending/error | Skeleton-specific visit link overrides (merged on top of `webCitation.visitLink`) |
|
|
885
970
|
|
|
886
971
|
Legacy flat keys (`gptCitationWrapper`, `footerAction`, `webCitationButton`) still work for backward compatibility.
|
|
887
972
|
|
|
973
|
+
#### Example: customize screenshot and pending skeleton
|
|
974
|
+
|
|
975
|
+
```tsx
|
|
976
|
+
<GptWebCitation
|
|
977
|
+
gptCitation={gptCitation}
|
|
978
|
+
defaultCitationUrl="https://example.com/article"
|
|
979
|
+
isWebCitation
|
|
980
|
+
webCitationData={data}
|
|
981
|
+
webCitationStatus={status}
|
|
982
|
+
styles={{
|
|
983
|
+
webCitation: {
|
|
984
|
+
visitLink: {
|
|
985
|
+
link: { backgroundColor: 'rgba(37, 99, 235, 0.08)', borderRadius: 8 },
|
|
986
|
+
},
|
|
987
|
+
image: {
|
|
988
|
+
scrollContainer: { borderRadius: 16, borderColor: '#d1d5db' },
|
|
989
|
+
image: { objectFit: 'contain', maxHeight: 360 },
|
|
990
|
+
expandButton: { backgroundColor: '#111827' },
|
|
991
|
+
},
|
|
992
|
+
skeleton: {
|
|
993
|
+
frame: { minHeight: 320, backgroundColor: '#f8fafc' },
|
|
994
|
+
pending: {
|
|
995
|
+
text: { fontSize: 14, color: '#374151' },
|
|
996
|
+
},
|
|
997
|
+
error: {
|
|
998
|
+
title: { color: '#dc2626' },
|
|
999
|
+
visitLinkGlow: { borderColor: '#dc2626' },
|
|
1000
|
+
},
|
|
1001
|
+
},
|
|
1002
|
+
},
|
|
1003
|
+
}}
|
|
1004
|
+
/>
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
### Usage 6: Fixed height mode (matched GPT + web panels)
|
|
1008
|
+
|
|
1009
|
+
Set `isFixedHeight={true}` when you want GPT and web citation views to share the same panel dimensions. Screenshots use `object-fit: contain` so tall pages stay inside the box without layout shift when toggling views.
|
|
1010
|
+
|
|
1011
|
+
```tsx
|
|
1012
|
+
<GptWebCitation
|
|
1013
|
+
gptCitation={{
|
|
1014
|
+
...gptCitation,
|
|
1015
|
+
bodyHeight: '384px', // optional — customizes inner content height
|
|
1016
|
+
}}
|
|
1017
|
+
defaultCitationUrl="https://example.com/article"
|
|
1018
|
+
isWebCitation
|
|
1019
|
+
isFixedHeight
|
|
1020
|
+
webCitationData={webCitationData}
|
|
1021
|
+
webCitationStatus="success"
|
|
1022
|
+
showWebCitation={showWebCitation}
|
|
1023
|
+
onToggleCitationView={() => setShowWeb((v) => !v)}
|
|
1024
|
+
/>
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
| Scenario | Panel height |
|
|
1028
|
+
| --- | --- |
|
|
1029
|
+
| `isFixedHeight` + `isWebCitation` (toggle footer present) | `520px` default, or `calc(bodyHeight + 3.25rem)` when `gptCitation.bodyHeight` is set |
|
|
1030
|
+
| `isFixedHeight` + `isWebCitation={false}` (GPT only) | `520px` default, or `gptCitation.bodyHeight` when set |
|
|
1031
|
+
|
|
1032
|
+
`isFixedHeight` applies flex layout and contained images automatically. For manual per-element styling without fixed dimensions, use `styles` (Usage 5) instead.
|
|
1033
|
+
|
|
888
1034
|
### Props
|
|
889
1035
|
|
|
890
1036
|
| Prop | Type | Default | Description |
|
|
891
1037
|
|------|------|---------|-------------|
|
|
892
|
-
| `gptCitation` | `IGptCitationConfig` | **required** | GPT citation config passed to `CognitiveInternalgptCoreComponent`
|
|
893
|
-
| `
|
|
894
|
-
| `
|
|
895
|
-
| `
|
|
896
|
-
| `
|
|
897
|
-
| `
|
|
1038
|
+
| `gptCitation` | `IGptCitationConfig` | **required** | GPT citation config passed to `CognitiveInternalgptCoreComponent` |
|
|
1039
|
+
| `defaultCitationUrl` | `string` | **required** | Fallback source URL for **Visit Link** in pending/error skeletons. Used when `webCitationData.highlightedUrl` is not yet available |
|
|
1040
|
+
| `isWebCitation` | `boolean` | `false` | When `true`, enables web citation toggle and web view |
|
|
1041
|
+
| `webCitationData` | `IWebCitationApiResponse` | — | Web citation API response (screenshot metadata, URLs, optional message) |
|
|
1042
|
+
| `webCitationStatus` | `"pending"` \| `"success"` \| `"error"` | inferred | Lifecycle status from parent API call. Inferred from `webCitationData` when omitted |
|
|
1043
|
+
| `showWebCitation` | `boolean` | `true` (uncontrolled) | `false` = GPT view, `true` = web view. Omit for uncontrolled internal state |
|
|
1044
|
+
| `onGenerateWebCitation` | `() => void` | — | Called when web view opens and no cached screenshot exists. Parent should fetch and update status/data. Also invoked once on mount when `isWebCitation` + `showWebCitation` are true and no image is cached |
|
|
898
1045
|
| `onToggleCitationView` | `() => void` | — | Called when user toggles between GPT and web views |
|
|
899
|
-
| `showExpandImageButton` | `boolean` | `true` | Show/hide
|
|
900
|
-
| `showGptMaximizeButton` | `boolean` | `true` | Show/hide
|
|
901
|
-
| `
|
|
1046
|
+
| `showExpandImageButton` | `boolean` | `true` | Show/hide full-screen expand on screenshot |
|
|
1047
|
+
| `showGptMaximizeButton` | `boolean` | `true` | Show/hide GPT header maximize icon (`gptCitation.disableMaximize: true` when `false`) |
|
|
1048
|
+
| `iconsConfig` | `IGptWebCitationImageIconsConfig` | — | `MaximizeIcon` and `ExternalLinkIcon` overrides for web view |
|
|
1049
|
+
| `topic` | `string` | auto | Override topic label in web header |
|
|
902
1050
|
| `sourceLabel` | `string` | auto | Override header source label in web view |
|
|
903
|
-
| `relevanceScore` | `number` | auto | Override relevance/decision strength
|
|
904
|
-
| `learnedFrom` | `string` | auto | Site name
|
|
1051
|
+
| `relevanceScore` | `number` | auto | Override relevance/decision strength badge (%) |
|
|
1052
|
+
| `learnedFrom` | `string` | auto | Site name in web footer (auto-derived from `citationUrl`) |
|
|
1053
|
+
| `sourceModel` | `string` | — | **Deprecated.** Use `sourceLabel` instead |
|
|
1054
|
+
| `isFixedHeight` | `boolean` | `false` | When `true`, GPT and web panels share the same fixed height/width; screenshot uses `object-fit: contain` |
|
|
905
1055
|
| `styles` | `IGptWebCitationStyleOverrides` | — | Style overrides for GPT and web citation views (see Usage 5) |
|
|
906
1056
|
|
|
1057
|
+
When `isFixedHeight` is `true`, both views use the same panel height (`520px` by default, or `gptCitation.bodyHeight` + toggle footer). Pair with `gptCitation.bodyHeight` to customize the content area (e.g. `"384px"`).
|
|
1058
|
+
|
|
1059
|
+
#### `webCitationStatus` inference
|
|
1060
|
+
|
|
1061
|
+
When `webCitationStatus` is omitted, the component derives it in this order:
|
|
1062
|
+
|
|
1063
|
+
| Priority | Condition | Status |
|
|
1064
|
+
| --- | --- | --- |
|
|
1065
|
+
| 1 | Valid screenshot URL in `webCitationData` (`signed_url` or `gs_uri`) | `"success"` (always — image wins over explicit status) |
|
|
1066
|
+
| 2 | Explicit `webCitationStatus` prop | uses prop value |
|
|
1067
|
+
| 3 | `webCitationData` present but no image URL | `"error"` |
|
|
1068
|
+
| 4 | No `webCitationData` | `"pending"` |
|
|
1069
|
+
|
|
1070
|
+
Pass `webCitationStatus="pending"` explicitly while your fetch is in flight (before the image URL is available).
|
|
1071
|
+
|
|
907
1072
|
### `IGptCitationConfig` (gptCitation prop)
|
|
908
1073
|
|
|
909
1074
|
| Field | Type | Description |
|
|
@@ -912,35 +1077,87 @@ Legacy flat keys (`gptCitationWrapper`, `footerAction`, `webCitationButton`) sti
|
|
|
912
1077
|
| `headerTitle` | `string` | Panel header title |
|
|
913
1078
|
| `index` | `number` | Citation index |
|
|
914
1079
|
| `iconsConfig` | `object` | Icon components (`ChevronDownIcon`, `ChevronUpIcon`, `MaximizeIcon`, `CloseIcon`) |
|
|
915
|
-
| `DocumentTitle` | `string` | Source document label shown in the GPT footer (right side) |
|
|
1080
|
+
| `DocumentTitle` | `string` | Source document label shown in the GPT footer (right side). Hidden when `isWebCitation` is true |
|
|
916
1081
|
| `previewCallback` | `() => void` | Called when the source link is clicked |
|
|
917
|
-
| `bodyHeight` | `string` | Optional fixed GPT content body height (
|
|
1082
|
+
| `bodyHeight` | `string` | Optional fixed GPT content body height (pair with `styles.webCitation.content`) |
|
|
918
1083
|
| `disableMaximize` | `boolean` | Disable GPT header fullscreen maximize button (or use `showGptMaximizeButton={false}`) |
|
|
919
1084
|
|
|
1085
|
+
### `IGptWebCitationImageIconsConfig` (iconsConfig prop)
|
|
1086
|
+
|
|
1087
|
+
| Field | Type | Fallback |
|
|
1088
|
+
|-------|------|----------|
|
|
1089
|
+
| `MaximizeIcon` | `ElementType` | `gptCitation.iconsConfig.MaximizeIcon`, then `Maximize2` |
|
|
1090
|
+
| `ExternalLinkIcon` | `ElementType` | `ExternalLink` |
|
|
1091
|
+
|
|
1092
|
+
### Style override types (`styles` prop)
|
|
1093
|
+
|
|
1094
|
+
Nested under `styles.webCitation`:
|
|
1095
|
+
|
|
1096
|
+
| Type | Keys | Purpose |
|
|
1097
|
+
| --- | --- | --- |
|
|
1098
|
+
| `IGptWebCitationVisitLinkStyles` | `row`, `hint`, `link` | Visit link row shared by image footer and skeletons |
|
|
1099
|
+
| `IGptWebCitationImageStyles` | `wrapper`, `center`, `viewport`, `scrollContainer`, `image`, `expandButton`, `visitLink`, `fullScreen` | Screenshot view + inline loading skeleton while image decodes |
|
|
1100
|
+
| `IGptWebCitationSkeletonStyles` | `container`, `frame`, `shimmer`, `pending.*`, `error.*`, `visitLink` | Pending/error skeleton UI |
|
|
1101
|
+
| `IGptWebCitationFullScreenStyles` | `overlay`, `content`, `closeButton`, `imageWrapper`, `image` | Full-screen screenshot modal |
|
|
1102
|
+
|
|
1103
|
+
`webCitation.visitLink` merges with scoped `image.visitLink` or `skeleton.visitLink` overrides (scoped wins on conflict).
|
|
1104
|
+
|
|
920
1105
|
### `IWebCitationApiResponse` (webCitationData prop)
|
|
921
1106
|
|
|
922
1107
|
| Field | Type | Description |
|
|
923
1108
|
|-------|------|-------------|
|
|
924
1109
|
| `citationId` | `string` | Unique citation identifier |
|
|
925
|
-
| `content` | `string` | HTML/markdown
|
|
1110
|
+
| `content` | `string` | HTML/markdown explanation (used for topic/score extraction) |
|
|
926
1111
|
| `citationType` | `string` | Citation type (e.g. `"web"`) |
|
|
927
|
-
| `citationUrl` | `string` | Original source URL |
|
|
1112
|
+
| `citationUrl` | `string` | Original source URL (screenshot footer **Visit Link**) |
|
|
1113
|
+
| `highlightedUrl` | `string` | Highlighted URL from API (preferred for skeleton **Visit Link**) |
|
|
1114
|
+
| `message` | `string` | API status or error message |
|
|
928
1115
|
| `imageMetadata` | `object` | Image snapshot metadata |
|
|
929
|
-
| `imageMetadata.signed_url` | `string` | Signed URL for screenshot
|
|
1116
|
+
| `imageMetadata.signed_url` | `string` | Signed URL for screenshot (preferred) |
|
|
930
1117
|
| `imageMetadata.gs_uri` | `string` | GCS URI fallback for image |
|
|
931
1118
|
| `db` | `object` | Database metadata (`citation_id`, `blob_path`) |
|
|
932
1119
|
|
|
1120
|
+
### Utility helpers
|
|
1121
|
+
|
|
1122
|
+
Exported from `@e-llm-studio/citation`:
|
|
1123
|
+
|
|
1124
|
+
| Function | Purpose |
|
|
1125
|
+
| --- | --- |
|
|
1126
|
+
| `mapCitationDataToDisplay(data)` | Normalizes API response → display fields (`topic`, `highlightedUrl`, `relevanceScore`, etc.) |
|
|
1127
|
+
| `getWebCitationImageUrl(data)` | Resolves screenshot URL from `imageMetadata` |
|
|
1128
|
+
| `resolveSkeletonVisitUrl(highlightedUrl, defaultCitationUrl)` | Visit link for pending/error skeletons |
|
|
1129
|
+
| `extractTopicFromContent(content)` | First anchor text from content |
|
|
1130
|
+
| `extractRelevanceScoreFromContent(content)` | Parses decision strength / confidence % |
|
|
1131
|
+
| `extractLearnedFromUrl(citationUrl)` | Hostname → site name for footer |
|
|
1132
|
+
| `sanitizeExternalUrl(url)` | Safe http(s) URL for links |
|
|
1133
|
+
|
|
933
1134
|
### View Behavior
|
|
934
1135
|
|
|
935
1136
|
| State | What renders |
|
|
936
1137
|
|-------|--------------|
|
|
937
1138
|
| `isWebCitation={false}` | GPT citation only |
|
|
938
|
-
| `isWebCitation={true}`, `showWebCitation={false}` | GPT citation + **View Web Citation** button
|
|
939
|
-
| `isWebCitation={true}`, `showWebCitation={true}` |
|
|
1139
|
+
| `isWebCitation={true}`, `showWebCitation={false}` | GPT citation + **View Web Citation** button |
|
|
1140
|
+
| `isWebCitation={true}`, `showWebCitation={true}`, `webCitationStatus="pending"` | Shimmer skeleton + optional **Visit Link** (`highlightedUrl` → `defaultCitationUrl`) |
|
|
1141
|
+
| `isWebCitation={true}`, `showWebCitation={true}`, `webCitationStatus="success"` | Screenshot (pending skeleton while image loads) + footer **Visit Link** |
|
|
1142
|
+
| `isWebCitation={true}`, `showWebCitation={true}`, `webCitationStatus="error"` | Error skeleton ("No preview available") + inline **Visit Link** |
|
|
1143
|
+
| `isFixedHeight={true}` | GPT and web outer panels share height; screenshot `object-fit: contain`; skeleton fills content area |
|
|
1144
|
+
|
|
1145
|
+
#### Auto-fetch
|
|
1146
|
+
|
|
1147
|
+
When `isWebCitation` is true and the web view is open with no cached screenshot, `onGenerateWebCitation` is called:
|
|
1148
|
+
|
|
1149
|
+
1. Once on mount (per `webCitationData.citationId`)
|
|
1150
|
+
2. Again when the user clicks **View Web Citation** and no image is cached
|
|
1151
|
+
|
|
1152
|
+
The parent should set `webCitationStatus="pending"`, fetch, then update `webCitationData` and status.
|
|
1153
|
+
|
|
1154
|
+
#### Error skeleton
|
|
1155
|
+
|
|
1156
|
+
The error state shows a fixed title ("No preview available"), a restriction message ("This website restricts external previews"), and an inline **Visit Link** when a source URL is available.
|
|
940
1157
|
|
|
941
1158
|
### Local Test Component
|
|
942
1159
|
|
|
943
|
-
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.
|
|
1160
|
+
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. The harness uses `sampleWebCitationApiResponse` from `WebCitationSampleResponse.ts`, simulates a 2s fetch delay when **View Web Citation** is clicked, and accepts `isFixedHeight`, `webCitationStatus`, `iconsConfig`, and `styles` props for local experimentation.
|
|
944
1161
|
|
|
945
1162
|
---
|
|
946
1163
|
|
|
@@ -2378,6 +2595,58 @@ function App() {
|
|
|
2378
2595
|
|
|
2379
2596
|
---
|
|
2380
2597
|
|
|
2598
|
+
## RuleBookCitationWrapper
|
|
2599
|
+
|
|
2600
|
+
A React component used to render Rule Book citation content with highlighted citation phrases.
|
|
2601
|
+
|
|
2602
|
+
The component fetches citation metadata, resolves the associated Rule Book file, extracts textual guideline content, and displays it using the `TextualGuideLinesComponent`.
|
|
2603
|
+
|
|
2604
|
+
### Usage
|
|
2605
|
+
|
|
2606
|
+
```tsx
|
|
2607
|
+
import { RuleBookCitationWrapper } from "<library-name>";
|
|
2608
|
+
|
|
2609
|
+
const sourceAttachments = [
|
|
2610
|
+
{
|
|
2611
|
+
id: "file-001",
|
|
2612
|
+
name: "RuleBook.json",
|
|
2613
|
+
gcsUrl: "gs://bucket/rulebook.json",
|
|
2614
|
+
is_guideline_file: true,
|
|
2615
|
+
},
|
|
2616
|
+
];
|
|
2617
|
+
|
|
2618
|
+
<RuleBookCitationWrapper
|
|
2619
|
+
requestId="citation-request-id"
|
|
2620
|
+
citationIndex={0}
|
|
2621
|
+
accessToken="access-token"
|
|
2622
|
+
sourceAttachments={sourceAttachments}
|
|
2623
|
+
/>
|
|
2624
|
+
```
|
|
2625
|
+
|
|
2626
|
+
### Props
|
|
2627
|
+
|
|
2628
|
+
### `RuleBookCitationWrapperProps`
|
|
2629
|
+
|
|
2630
|
+
| Prop | Type | Default | Description |
|
|
2631
|
+
|---|---|---|---|
|
|
2632
|
+
| `requestId` | `string \| null` | `undefined` | Identifier used to fetch citation metadata |
|
|
2633
|
+
| `citationIndex` | `number` | `0` | Index of the citation to display |
|
|
2634
|
+
| `accessToken` | `string` | — | Authentication token used for citation API requests |
|
|
2635
|
+
| `sourceAttachments` | `SourceAttachment[] \| Record<string, SourceAttachment[]>` | `[]` | Source files containing Rule Book metadata |
|
|
2636
|
+
|
|
2637
|
+
---
|
|
2638
|
+
|
|
2639
|
+
### SourceAttachment
|
|
2640
|
+
|
|
2641
|
+
| Prop | Type | Description |
|
|
2642
|
+
|---|---|---|
|
|
2643
|
+
| `id` | `string` | File identifier matching citation `file_id` |
|
|
2644
|
+
| `gcsUrl` | `string` | GCS location of the Rule Book file |
|
|
2645
|
+
| `name` | `string` | Optional file name |
|
|
2646
|
+
| `is_guideline_file` | `boolean` | Indicates whether the file contains guideline/rule book content |
|
|
2647
|
+
|
|
2648
|
+
---
|
|
2649
|
+
|
|
2381
2650
|
## SplitterCitationsComponent
|
|
2382
2651
|
|
|
2383
2652
|
A responsive, draggable split-pane layout component for React. Renders two panels side-by-side (horizontal) or stacked (vertical) with a draggable divider. Automatically switches to vertical layout when the container is narrower than 500 px. Supports panel collapse/expand and an optional header with a confidence score badge.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("lucide-react"),o=require("../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js"),l=require("./GptWebCitationImageCitation.js"),a=require("./GptWebCitationSkeleton.js"),s=require("./utils/citationData.utils.js"),r=require("./utils/styleOverrides.utils.js"),u=require("./utils/fixedHeight.utils.js"),d=require("./GptWebCitation.module.css.js"),c=require("../../assests/svg/NeuralNetworkIcon.js"),g=function(t){var o=t.variant,l=t.disabled,a=t.onClick,s=t.title,r=t.style;return i.jsx("button",e.__assign({type:"button",className:d.default.webCitationButton,onClick:a,disabled:l,title:s,style:r},{children:"gpt"===o?i.jsxs(i.Fragment,{children:[i.jsx(c.default,{className:d.default.webCitationButtonIcon}),"View GPT Citation"]}):i.jsxs(i.Fragment,{children:[i.jsx(n.Globe,{size:24,className:d.default.webCitationButtonIcon}),"View Web Citation"]})}))};exports.default=function(c){var v,p,b,_=c.gptCitation,C=c.defaultCitationUrl,f=c.isWebCitation,m=void 0!==f&&f,x=c.webCitationData,w=c.topic,h=c.sourceLabel,k=c.relevanceScore,j=c.learnedFrom,y=c.webCitationStatus,F=c.onGenerateWebCitation,S=c.showWebCitation,I=c.onToggleCitationView,L=c.showExpandImageButton,W=void 0===L||L,B=c.showGptMaximizeButton,H=c.iconsConfig,N=c.isFixedHeight,M=void 0!==N&&N,V=c.styles,q=t.useMemo(function(){return function(i){var t,n,o,l,a,s,u,d,c,g,v;return{container:null==i?void 0:i.container,gptWrapper:e.__assign(e.__assign({},null===(t=null==i?void 0:i.gptCitation)||void 0===t?void 0:t.wrapper),null==i?void 0:i.gptCitationWrapper),gptFooterAction:e.__assign(e.__assign({},null===(n=null==i?void 0:i.gptCitation)||void 0===n?void 0:n.footerAction),null==i?void 0:i.footerAction),gptToggleButton:e.__assign(e.__assign({},null===(o=null==i?void 0:i.gptCitation)||void 0===o?void 0:o.toggleButton),null==i?void 0:i.webCitationButton),webPanel:e.__assign(e.__assign({},null==i?void 0:i.container),null===(l=null==i?void 0:i.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==i?void 0:i.webCitation)||void 0===a?void 0:a.header,webContent:null===(s=null==i?void 0:i.webCitation)||void 0===s?void 0:s.content,webFooter:null===(u=null==i?void 0:i.webCitation)||void 0===u?void 0:u.footer,webToggleButton:e.__assign(e.__assign({},null===(d=null==i?void 0:i.webCitation)||void 0===d?void 0:d.toggleButton),null==i?void 0:i.webCitationButton),webLearnedFrom:null===(c=null==i?void 0:i.webCitation)||void 0===c?void 0:c.learnedFrom,webImage:null===(g=null==i?void 0:i.webCitation)||void 0===g?void 0:g.image,webSkeleton:null===(v=null==i?void 0:i.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:r.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"image"),webSkeletonVisitLink:r.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"skeleton")}}(V)},[V]),E=t.useMemo(function(){return M?u.resolveFixedHeightLayout(_.bodyHeight,m):null},[M,_.bodyHeight,m]),T=t.useMemo(function(){return E?u.getFixedPanelStyle(E.panelHeight):void 0},[E]),z=t.useMemo(function(){var e,i;return{MaximizeIcon:null!==(e=null==H?void 0:H.MaximizeIcon)&&void 0!==e?e:null===(i=_.iconsConfig)||void 0===i?void 0:i.MaximizeIcon,ExternalLinkIcon:null==H?void 0:H.ExternalLinkIcon}},[H,null===(v=_.iconsConfig)||void 0===v?void 0:v.MaximizeIcon]),U=t.useMemo(function(){return e.__assign(e.__assign(e.__assign(e.__assign({},_),M&&E?{bodyHeight:E.gptBodyHeight}:{}),{disableMaximize:void 0!==B?!B:_.disableMaximize}),m?{DocumentTitle:void 0,previewCallback:void 0}:{})},[_,B,m,M,E]),A=t.useState(!0),D=A[0],G=A[1],P=t.useRef(!1),O=null!=S?S:D,R=void 0!==S,J=t.useMemo(function(){return x?s.mapCitationDataToDisplay(x):null},[x]),K=null!==(p=null!=w?w:null==J?void 0:J.topic)&&void 0!==p?p:"Web Citation",Q=null!==(b=null!=k?k:null==J?void 0:J.relevanceScore)&&void 0!==b?b:0,X=null!=j?j:null==J?void 0:J.learnedFrom,Y=null==J?void 0:J.citationUrl,Z=s.resolveSkeletonVisitUrl(null==J?void 0:J.highlightedUrl,C),$=s.getWebCitationImageUrl(x),ee=t.useMemo(function(){return function(e,i,t){return t?"success":e||(i?"error":"pending")}(y,x,$)},[y,x,$]);t.useEffect(function(){P.current=!1},[null==x?void 0:x.citationId]),t.useEffect(function(){m&&O&&($||P.current||(P.current=!0,null==F||F()))},[m,O,$,F,null==x?void 0:x.citationId]);var ie=t.useCallback(function(){I?I():R||G(!1)},[I,R]),te=t.useCallback(function(){I?I():R||G(!0),$||"success"===ee||null==F||F()},[I,R,$,ee,F]),ne=null!=h?h:"Source: Web Citation > ".concat(K),oe=function(t){var n=!!U.DocumentTitle,l=[d.default.gptCitationWrapper,n?d.default.gptCitationWrapperWithSource:"",M?d.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return i.jsxs("div",e.__assign({className:l,style:e.__assign(e.__assign({},q.gptWrapper),T)},{children:[i.jsx(o.default,e.__assign({},U,{splitterCustomStyle:!0})),t&&(n?i.jsx("div",e.__assign({className:d.default.gptCitationFooterAction,style:q.gptFooterAction},{children:t})):i.jsx("div",e.__assign({className:[d.default.gptCitationToggleFooter,M?d.default.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:q.gptFooterAction},{children:t})))]}))};return m?O?i.jsxs("div",e.__assign({className:[d.default.panel,M?d.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},q.webPanel),T)},{children:[i.jsxs("div",e.__assign({className:d.default.panelHeader,style:q.webHeader},{children:[i.jsx("span",e.__assign({className:d.default.panelSource},{children:ne})),i.jsx("div",e.__assign({className:d.default.panelHeaderActions},{children:Q>0&&i.jsxs("div",e.__assign({className:d.default.confidenceBadge,title:"Decision strength"},{children:[i.jsx(n.Sparkles,{size:14}),Q,"%"]}))}))]})),i.jsx("div",e.__assign({className:[d.default.panelContent,d.default.panelContentExpanded,M?d.default.panelContentFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},q.webContent),M?u.getFixedWebContentStyle():void 0)},{children:"pending"===ee?i.jsx(a.default,{status:"pending",citationUrl:Z,ExternalLinkIcon:z.ExternalLinkIcon,styles:q.webSkeleton,visitLinkStyles:q.webSkeletonVisitLink,isFixedHeight:M}):"success"===ee&&$?i.jsx(l.default,{citationImage:$,citationUrl:Y,skeletonVisitUrl:Z,showExpandImageButton:W,iconsConfig:z,styles:q.webImage,visitLinkStyles:q.webImageVisitLink,skeletonStyles:q.webSkeleton,skeletonVisitLinkStyles:q.webSkeletonVisitLink,isFixedHeight:M}):i.jsx(a.default,{status:"error",citationUrl:Z,ExternalLinkIcon:z.ExternalLinkIcon,styles:q.webSkeleton,visitLinkStyles:q.webSkeletonVisitLink,isFixedHeight:M})})),i.jsxs("div",e.__assign({className:d.default.panelFooter,style:q.webFooter},{children:[i.jsx(g,{variant:"gpt",onClick:ie,style:q.webToggleButton}),X&&i.jsxs("span",e.__assign({className:d.default.learnedFrom,style:q.webLearnedFrom},{children:["Learned From ",X]}))]}))]})):i.jsx("div",e.__assign({className:d.default.overlay,style:q.container},{children:oe(i.jsx(g,{variant:"web",onClick:te,title:"View web-based citation for this source.",style:q.gptToggleButton}))})):i.jsx("div",e.__assign({className:d.default.overlay,style:q.container},{children:oe()}))};
|
|
2
2
|
//# sourceMappingURL=GptWebCitation.js.map
|