@e-llm-studio/citation 0.0.245 → 0.0.247
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 +151 -0
- package/dist/cjs/features/BPACitationRenderer/BPACitationRenderer.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/cjs/features/PromptCitation/CitationDependencyGraph.js +2 -0
- package/dist/cjs/features/PromptCitation/CitationDependencyGraph.js.map +1 -0
- package/dist/cjs/features/PromptCitation/PromptCitation.js +2 -0
- package/dist/cjs/features/PromptCitation/PromptCitation.js.map +1 -0
- package/dist/cjs/features/PromptCitation/_components/CodeEditor.js +2 -0
- package/dist/cjs/features/PromptCitation/_components/CodeEditor.js.map +1 -0
- package/dist/cjs/features/PromptCitation/_components/Markdownrenderer.js +2 -0
- package/dist/cjs/features/PromptCitation/_components/Markdownrenderer.js.map +1 -0
- package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/CognitiveIntegrity.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/PageCheck.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/RevertSuccessCard.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewScore.js +2 -0
- package/dist/cjs/features/SegmentReviewComponents/reviewScore.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/features/BPACitationRenderer/BPACitationRenderer.js +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/PromptCitation/CitationDependencyGraph.js +2 -0
- package/dist/features/PromptCitation/CitationDependencyGraph.js.map +1 -0
- package/dist/features/PromptCitation/PromptCitation.js +2 -0
- package/dist/features/PromptCitation/PromptCitation.js.map +1 -0
- package/dist/features/PromptCitation/_components/CodeEditor.js +2 -0
- package/dist/features/PromptCitation/_components/CodeEditor.js.map +1 -0
- package/dist/features/PromptCitation/_components/Markdownrenderer.js +2 -0
- package/dist/features/PromptCitation/_components/Markdownrenderer.js.map +1 -0
- package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
- package/dist/features/SegmentReviewComponents/CognitiveIntegrity.js +1 -1
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/features/SegmentReviewComponents/PageCheck.js +1 -1
- package/dist/features/SegmentReviewComponents/RevertSuccessCard.js +1 -1
- package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/features/SegmentReviewComponents/helper.js +1 -1
- package/dist/features/SegmentReviewComponents/reviewScore.js +2 -0
- package/dist/features/SegmentReviewComponents/reviewScore.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/types/src/CitationDependencyGraphTest.d.ts +4 -0
- package/dist/types/src/CitationDependencyGraphTest.d.ts.map +1 -0
- package/dist/types/src/features/BPACitationRenderer/BPACitationRenderer.d.ts.map +1 -1
- package/dist/types/src/features/BPACitationRenderer/BPACitationRenderer.types.d.ts +1 -0
- package/dist/types/src/features/BPACitationRenderer/BPACitationRenderer.types.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts +1 -0
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/dist/types/src/features/PromptCitation/CitationDependencyGraph.d.ts +56 -0
- package/dist/types/src/features/PromptCitation/CitationDependencyGraph.d.ts.map +1 -0
- package/dist/types/src/features/PromptCitation/PromptCitation.d.ts +326 -0
- package/dist/types/src/features/PromptCitation/PromptCitation.d.ts.map +1 -0
- package/dist/types/src/features/PromptCitation/PromptCitationTest.d.ts +4 -0
- package/dist/types/src/features/PromptCitation/PromptCitationTest.d.ts.map +1 -0
- package/dist/types/src/features/PromptCitation/_components/CodeEditor.d.ts +30 -0
- package/dist/types/src/features/PromptCitation/_components/CodeEditor.d.ts.map +1 -0
- package/dist/types/src/features/PromptCitation/_components/HighlightedCodeDetails.d.ts +16 -0
- package/dist/types/src/features/PromptCitation/_components/HighlightedCodeDetails.d.ts.map +1 -0
- package/dist/types/src/features/PromptCitation/_components/Markdownrenderer.d.ts +23 -0
- package/dist/types/src/features/PromptCitation/_components/Markdownrenderer.d.ts.map +1 -0
- package/dist/types/src/features/PromptCitation/_components/ThemeToggle.d.ts +12 -0
- package/dist/types/src/features/PromptCitation/_components/ThemeToggle.d.ts.map +1 -0
- package/dist/types/src/features/PromptCitation/_components/TooltipComponent.d.ts +8 -0
- package/dist/types/src/features/PromptCitation/_components/TooltipComponent.d.ts.map +1 -0
- package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/CognitiveIntegrity.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/CognitiveScoreBadge.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/RevertSuccessCard.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/helper.d.ts +2 -4
- package/dist/types/src/features/SegmentReviewComponents/helper.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/reviewScore.d.ts +4 -0
- package/dist/types/src/features/SegmentReviewComponents/reviewScore.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +11 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsxs as t,jsx as n,Fragment as e}from"react/jsx-runtime";import{useState as o}from"react";import{ChevronDown as a,ChevronUp as l,Maximize2 as r,X as d,ExternalLink as c}from"lucide-react";import s from"@mui/material/Dialog";import u from"@mui/material/DialogTitle";import g from"@mui/material/DialogContent";import v from"@mui/material/IconButton";import h from"dayjs";import m from"../ScannedDocCitation/ScannedDocCitation.js";import C from"../InstantLearningCitation/InstantLearningCitationComponent.js";import p from"../InstantLearningCitation/SlashLoader.js";import f from"../CognitiveInternalgptReasoning/CognitiveInternalgptReasoningComponent.js";import D from"../RequirementAiCitations/ImageCitation/ImageCitationContent.js";import T from"../RequirementAiCitations/WebCitation/WebCitationWithImageContent.js";import I from"../ChatCitation/ChatCitationRenderer.js";import b from"../DualCitation/RuleBookCitationComponent.js";import _ from"../CitationRenderer/CitationRenderer.js";import P from"../SplitterCitations/SplitterCitationsComponent.js";import{SourcesBQCitation as R}from"../DualCitation/SourceBQDataCompnent.js";import{CITATION_TYPES as S}from"./citationTypes.js";var A=function(i,t,n){if(!i)throw new Error("[BPACitationRenderer] ".concat(t,': missing required field "').concat(n,'" in customMetaData'))},L=function(i,t){if(!Object.values(i).some(Boolean))throw new Error("[BPACitationRenderer] ".concat(t,': missing one of "').concat(Object.keys(i).join('", "'),'" in customMetaData'))},w=function(a){var l=a.children,r=a.content,c=o(!1),h=c[0],m=c[1];return t(e,{children:[n("span",i({style:{display:"inline-flex",alignItems:"center",cursor:"pointer",fontSize:"14px",fontWeight:400,color:"#526eff"},onClick:function(){return m(!0)}},{children:l})),t(s,i({open:h,onClose:function(){return m(!1)},maxWidth:"md",fullWidth:!0},{children:[t(u,i({style:{fontWeight:"bold"}},{children:["Guidelines",n(v,i({edge:"end",onClick:function(){return m(!1)},"aria-label":"close",style:{position:"absolute",top:5,right:16},size:"large"},{children:n(d,{})}))]})),n(g,i({style:{maxHeight:"70vh",overflow:"auto"}},{children:r}))]}))]})},x=function(e){var s,u,g,v,U,y,B,j,k,H,G,O,E,W,N,z,F,M,q,K,Q,J,V,X,Y,Z,$,ii=e.href,ti=e.children,ni=e.isStreaming,ei=e.onCitationToggle,oi=e.chatCitationConfig,ai=e.scannedDocCitationConfig,li=e.ruleBookCitationConfig,ri=e.ilCitationConfig,di=e.gptCitationConfig,ci=e.scannedDocCitationData,si=e.ilCitationData,ui=e.chatCitationData,gi=e.gptCitationData,vi=e.webCitationData,hi=e.imageCitationData,mi=e.bqCitationData,Ci=e.title,pi=e.citationIcon,fi=e.isDualCitationFlag,Di=void 0!==fi&&fi,Ti=o(!1),Ii=Ti[0],bi=Ti[1];if(ni)return t("span",i({style:{display:"inline-flex",alignItems:"center",gap:"0.25rem",fontWeight:500,color:"#6D28D9"}},{children:[n("span",{children:ti}),n(p,{})]}));try{var _i=new URL(ii,"http://example.com"),Pi=null!==(s=_i.searchParams.get("citationNumber"))&&void 0!==s?s:_i.searchParams.get("citation_number"),Ri=null!==(u=_i.searchParams.get("decisionStrength"))&&void 0!==u?u:_i.searchParams.get("decision_strength"),Si=_i.searchParams.get("citation_type"),Ai=Di||Si===S.DUAL;if(!Pi)return null;if(Si===S.SCANNED_DOC){var Li=null==ci?void 0:ci.pages;if(null==Li?void 0:Li.length)return n(m,i({pages:Li,subHeadingText:null==ci?void 0:ci.artifactTitle},ai));A(null==ci?void 0:ci.gsUrl,"scanned_doc_citation","gs_url");var wi=[ci.gsUrl],xi=(null!==(g=null==ci?void 0:ci.highlightedCoordinates)&&void 0!==g?g:[]).map(function(i,t){return{pageIndex:t,bboxes:[i]}});return n(m,i({images:wi,highlights:xi},ai))}if(Si===S.IL){A(null==si?void 0:si.ilLearning,"IL","il_learning");var Ui=ti||(null==si?void 0:si.linkText)||(null==si?void 0:si.citationSource)||String(null!==(v=null==si?void 0:si.citationNumber)&&void 0!==v?v:1);return n(C,{ilLearning:si.ilLearning,ilLearningHighlights:null==si?void 0:si.ilLearningHighlights,comparisonHighlights:null==si?void 0:si.comparisonHighlights,decisionStrength:Ri||(null==si?void 0:si.decisionStrength)||"",linkTitle:Ui,onCitationToggle:null!=ei?ei:function(){},config:ri})}if(Si===S.CHAT){var yi=null!=oi?oi:{},Bi=null===(y=null!==(U=null==ui?void 0:ui.chatData)&&void 0!==U?U:[])||void 0===y?void 0:y.map(function(t){return i(i({},t),{timeStamp:h(t.timeStamp)})}),ji=!!(null==ui?void 0:ui.ruleBookContent);return n(I,{showRootContainer:null===(B=yi.showRootContainer)||void 0===B||B,reversePanels:yi.reversePanels,isRenderedCustomComponent:yi.isRenderedCustomComponent,modalContainerStyle:yi.modalContainerStyle,additionalData:yi.additionalData,closePreview:yi.closePreview,selectedIdFromReason:null!==(j=yi.selectedIdFromReason)&&void 0!==j?j:void 0,rootContainer:i(i({},yi.rootContainer),{relevanceScore:null==ui?void 0:ui.relevanceScore}),chatContainer:i(i({},yi.chatContainer),{chatData:Bi,summarizedTab:i(i({},null===(k=yi.chatContainer)||void 0===k?void 0:k.summarizedTab),{chip:i({isActive:!0,show:!0},null===(G=null===(H=yi.chatContainer)||void 0===H?void 0:H.summarizedTab)||void 0===G?void 0:G.chip)}),detailedTab:i(i({},null===(O=yi.chatContainer)||void 0===O?void 0:O.detailedTab),{chip:i({isActive:!1},null===(W=null===(E=yi.chatContainer)||void 0===E?void 0:E.detailedTab)||void 0===W?void 0:W.chip)})}),ruleBookContainer:ji?i(i({},yi.ruleBookContainer),{data:{content:ui.ruleBookContent,highlighted_texts:null!==(N=null==ui?void 0:ui.ruleBookHighlights)&&void 0!==N?N:[]}}):void 0})}if(Si===S.GPT){var ki=null==gi?void 0:gi.value,Hi=null!==(z=null==ki?void 0:ki.text)&&void 0!==z?z:null===(F=null==gi?void 0:gi.dataSources)||void 0===F?void 0:F[0],Gi=null!==(M=null==ki?void 0:ki.label)&&void 0!==M?M:null===(q=null==gi?void 0:gi.trainingDataTitle)||void 0===q?void 0:q[0],Oi=null!==(K=null==ki?void 0:ki.paraphrase)&&void 0!==K?K:null===(Q=null==gi?void 0:gi.paraphrase)||void 0===Q?void 0:Q[0];L({data_sources:Hi,training_data_title:Gi},S.GPT);var Ei={text:"",dataSource:Hi,trainingDataTitle:Gi,paraphrase:Oi},Wi=null!==(J=null==di?void 0:di.iconsConfig)&&void 0!==J?J:{ChevronDownIcon:a,ChevronUpIcon:l,MaximizeIcon:r,CloseIcon:d};return n(f,{item:Ei,headerTitle:null!==(V=null==di?void 0:di.headerTitle)&&void 0!==V?V:"GPT - Gemini 3.5 Flash",iconsConfig:Wi,previewCallback:null==di?void 0:di.previewCallback,DocumentTitle:null==di?void 0:di.DocumentTitle,disableMaximize:Ai})}if(Si===S.WEB){!function(i,t,n){A(i,t,n);try{new URL(i)}catch(e){throw new Error("[BPACitationRenderer] ".concat(t,': "').concat(n,'" is not a valid URL: "').concat(i,'"'))}}(null==vi?void 0:vi.link,S.WEB,"link");var Ni=vi.link,zi=ti||(null==vi?void 0:vi.citationSource)||Ni;return(null==vi?void 0:vi.screenshotUrl)?n(T,{url:Ni,label:zi,gsUtilPath:null==vi?void 0:vi.gsUtilPath,signedUrl:vi.screenshotUrl,relevanceScore:null==vi?void 0:vi.relevanceScore,visitIcon:c,PreviewDialogCloseIcon:d}):n("a",i({href:Ni,target:"_blank",rel:"noreferrer"},{children:zi}))}if(Si===S.IMAGE)return L({gs_util_path:null==hi?void 0:hi.gsUtilPath,signed_url:null==hi?void 0:hi.signedUrl},S.IMAGE),n(D,{citationTitle:ti||(null==hi?void 0:hi.citationSource),gsUtilPath:null==hi?void 0:hi.gsUtilPath,signedUrl:null==hi?void 0:hi.signedUrl,relevanceScore:null==hi?void 0:hi.relevanceScore});if(Si===S.BQ_DATA)return L({href_params:null==mi?void 0:mi.hrefParams,source_obj:null==mi?void 0:mi.sourceObj},S.BQ_DATA),n(R,i({hrefParams:mi.hrefParams,sourceObj:mi.sourceObj,showChevron:!1,defaultOpen:!0},{children:ti||""}));if(Si===S.RULEBOOK||Si===S.RULEBOOK_CHUNK){var Fi=Pi?parseInt(Pi,10):0,Mi=n(b,{url:null!==(X=null==li?void 0:li.url)&&void 0!==X?X:"",data:{citationNumber:null!==(Z=null===(Y=null==li?void 0:li.data)||void 0===Y?void 0:Y.citationNumber)&&void 0!==Z?Z:Fi,fileDetails:null===($=null==li?void 0:li.data)||void 0===$?void 0:$.fileDetails},msg:null==li?void 0:li.msg,citationIndex:null==li?void 0:li.citationIndex,guidelines:null==li?void 0:li.guidelines,additionalClassNames:null==li?void 0:li.additionalClassNames,headerTitle:null==li?void 0:li.headerTitle,InternalGptReasoningData:null==li?void 0:li.InternalGptReasoningData,isDataProvided:null==li?void 0:li.isDataProvided,textualContent:null==li?void 0:li.textualContent,phraseToHighlight:null==li?void 0:li.phraseToHighlight,IgptHeaderTitle:null==li?void 0:li.IgptHeaderTitle,isInternalGptReasoningLoading:null==li?void 0:li.isInternalGptReasoningLoading,onAccordionToggle:null==li?void 0:li.onAccordionToggle});return Di?Mi:n(w,i({content:Mi},{children:ti}))}if(Si===S.IL_RULEBOOK){var qi=n(b,{headerTitle:null==li?void 0:li.headerTitle,InternalGptReasoningData:null==li?void 0:li.InternalGptReasoningData,isDataProvided:null==li?void 0:li.isDataProvided,textualContent:null==li?void 0:li.textualContent,phraseToHighlight:null==li?void 0:li.phraseToHighlight,IgptHeaderTitle:null==li?void 0:li.IgptHeaderTitle,onAccordionToggle:null==li?void 0:li.onAccordionToggle,isInternalGptReasoningLoading:null==li?void 0:li.isInternalGptReasoningLoading});return Di?qi:n(w,i({content:qi},{children:ti}))}if(Si===S.DUAL){var Ki=_i.searchParams.get("left_citation_type"),Qi=_i.searchParams.get("right_citation_type");if(Ki===S.DUAL||Qi===S.DUAL)return console.error("left or right citation type cant be dual_citation"),null;var Ji=function(i,t){var n="".concat(i,"."),e="left"===i?"right.":"left.",o=new URLSearchParams;return _i.searchParams.forEach(function(i,t){"citation_type"!==t&&"left_citation_type"!==t&&"right_citation_type"!==t&&(t.startsWith(n)||t.startsWith(e)||o.set(t,i))}),_i.searchParams.forEach(function(i,t){t.startsWith(n)&&o.set(t.slice(n.length),i)}),t&&o.set("citation_type",t),"?".concat(o.toString())},Vi=Ji("left",Ki),Xi=Ji("right",Qi),Yi=ti||Ci||"Source and Guidelines",Zi=function(i){switch(i){case S.SCANNED_DOC:return{scannedDocCitationData:ci,scannedDocCitationConfig:ai};case S.IL:return{ilCitationData:si,ilCitationConfig:ri};case S.CHAT:return{chatCitationData:ui,chatCitationConfig:oi};case S.GPT:return{gptCitationData:gi,gptCitationConfig:di};case S.WEB:return{webCitationData:vi};case S.IMAGE:return{imageCitationData:hi};case S.BQ_DATA:return{bqCitationData:mi};case S.RULEBOOK:return{ruleBookCitationConfig:li};default:return{}}};return n(_,{inLineCitation:!0,citationTitle:Yi,citationIcon:pi,isOpen:Ii,onToggle:function(){return bi(function(i){return!i})},styles:{pillButton:{fontSize:"14px",margin:"0px",padding:"0px",color:"#526eff",cursor:"pointer",verticalAlign:"middle",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",background:"white",border:"none"},citationContent:{width:"100%",background:"transparent",minHeight:"10px",height:"fit-content"}},citationComponent:n(P,{left:n(x,i({href:Vi,onCitationToggle:ei},Zi(Ki),{isDualCitationFlag:!0})),right:n(x,i({href:Xi,onCitationToggle:ei,isDualCitationFlag:!0},Zi(Qi))),header:{title:Yi,showDocIcon:!1},openInFullscreen:!0,fullscreenOnly:!0,onFullscreenClose:function(){return bi(!1)}})})}console.warn('[BPACitationRenderer] unhandled citation_type: "'.concat(Si,'"'))}catch(i){return console.error(i),null}return null};export{x as default};
|
|
1
|
+
import{__assign as i}from"tslib";import{jsxs as t,jsx as n,Fragment as e}from"react/jsx-runtime";import{useState as o}from"react";import{ChevronDown as a,ChevronUp as l,Maximize2 as r,X as d,ExternalLink as c}from"lucide-react";import s from"@mui/material/Dialog";import u from"@mui/material/DialogTitle";import g from"@mui/material/DialogContent";import v from"@mui/material/IconButton";import h from"dayjs";import m from"../ScannedDocCitation/ScannedDocCitation.js";import C from"../InstantLearningCitation/InstantLearningCitationComponent.js";import p from"../InstantLearningCitation/SlashLoader.js";import f from"../CognitiveInternalgptReasoning/CognitiveInternalgptReasoningComponent.js";import D from"../RequirementAiCitations/ImageCitation/ImageCitationContent.js";import T from"../RequirementAiCitations/WebCitation/WebCitationWithImageContent.js";import I from"../ChatCitation/ChatCitationRenderer.js";import b from"../DualCitation/RuleBookCitationComponent.js";import _ from"../CitationRenderer/CitationRenderer.js";import P from"../SplitterCitations/SplitterCitationsComponent.js";import{SourcesBQCitation as R}from"../DualCitation/SourceBQDataCompnent.js";import{CITATION_TYPES as S}from"./citationTypes.js";var A=function(i,t,n){if(!i)throw new Error("[BPACitationRenderer] ".concat(t,': missing required field "').concat(n,'" in customMetaData'))},L=function(i,t){if(!Object.values(i).some(Boolean))throw new Error("[BPACitationRenderer] ".concat(t,': missing one of "').concat(Object.keys(i).join('", "'),'" in customMetaData'))},w=function(a){var l=a.children,r=a.content,c=a.dialogTitle,h=void 0===c?"Guidelines":c,m=o(!1),C=m[0],p=m[1];return t(e,{children:[n("span",i({style:{display:"inline-flex",alignItems:"center",cursor:"pointer",fontSize:"14px",fontWeight:400,color:"#526eff"},onClick:function(){return p(!0)}},{children:l})),t(s,i({open:C,onClose:function(){return p(!1)},maxWidth:"md",fullWidth:!0},{children:[t(u,i({style:{fontWeight:"bold"}},{children:[h,n(v,i({edge:"end",onClick:function(){return p(!1)},"aria-label":"close",style:{position:"absolute",top:5,right:16},size:"large"},{children:n(d,{})}))]})),n(g,i({style:{maxHeight:"70vh",overflow:"auto"}},{children:r}))]}))]})},x=function(e){var s,u,g,v,U,y,B,j,k,H,G,O,E,W,N,z,F,M,q,K,Q,J,V,X,Y,Z,$,ii=e.href,ti=e.children,ni=e.isStreaming,ei=e.onCitationToggle,oi=e.chatCitationConfig,ai=e.scannedDocCitationConfig,li=e.ruleBookCitationConfig,ri=e.ilCitationConfig,di=e.gptCitationConfig,ci=e.scannedDocCitationData,si=e.ilCitationData,ui=e.chatCitationData,gi=e.gptCitationData,vi=e.webCitationData,hi=e.imageCitationData,mi=e.bqCitationData,Ci=e.title,pi=e.citationIcon,fi=e.isDualCitationFlag,Di=void 0!==fi&&fi,Ti=o(!1),Ii=Ti[0],bi=Ti[1];if(ni)return t("span",i({style:{display:"inline-flex",alignItems:"center",gap:"0.25rem",fontWeight:500,color:"#6D28D9"}},{children:[n("span",{children:ti}),n(p,{})]}));try{var _i=new URL(ii,"http://example.com"),Pi=null!==(s=_i.searchParams.get("citationNumber"))&&void 0!==s?s:_i.searchParams.get("citation_number"),Ri=null!==(u=_i.searchParams.get("decisionStrength"))&&void 0!==u?u:_i.searchParams.get("decision_strength"),Si=_i.searchParams.get("citation_type"),Ai=Di||Si===S.DUAL;if(!Pi)return null;if(Si===S.SCANNED_DOC){var Li=null==ci?void 0:ci.pages;if(null==Li?void 0:Li.length)return n(m,i({pages:Li,subHeadingText:null==ci?void 0:ci.artifactTitle},ai));A(null==ci?void 0:ci.gsUrl,"scanned_doc_citation","gs_url");var wi=[ci.gsUrl],xi=(null!==(g=null==ci?void 0:ci.highlightedCoordinates)&&void 0!==g?g:[]).map(function(i,t){return{pageIndex:t,bboxes:[i]}});return n(m,i({images:wi,highlights:xi},ai))}if(Si===S.IL){A(null==si?void 0:si.ilLearning,"IL","il_learning");var Ui=ti||(null==si?void 0:si.linkText)||(null==si?void 0:si.citationSource)||String(null!==(v=null==si?void 0:si.citationNumber)&&void 0!==v?v:1);return n(C,{ilLearning:si.ilLearning,ilLearningHighlights:null==si?void 0:si.ilLearningHighlights,comparisonHighlights:null==si?void 0:si.comparisonHighlights,decisionStrength:Ri||(null==si?void 0:si.decisionStrength)||"",linkTitle:Ui,onCitationToggle:null!=ei?ei:function(){},config:ri})}if(Si===S.CHAT){var yi=null!=oi?oi:{},Bi=null===(y=null!==(U=null==ui?void 0:ui.chatData)&&void 0!==U?U:[])||void 0===y?void 0:y.map(function(t){return i(i({},t),{timeStamp:h(t.timeStamp)})}),ji=!!(null==ui?void 0:ui.ruleBookContent);return n(I,{showRootContainer:null===(B=yi.showRootContainer)||void 0===B||B,reversePanels:yi.reversePanels,isRenderedCustomComponent:yi.isRenderedCustomComponent,modalContainerStyle:yi.modalContainerStyle,additionalData:yi.additionalData,closePreview:yi.closePreview,selectedIdFromReason:null!==(j=yi.selectedIdFromReason)&&void 0!==j?j:void 0,rootContainer:i(i({},yi.rootContainer),{relevanceScore:null==ui?void 0:ui.relevanceScore}),chatContainer:i(i({},yi.chatContainer),{chatData:Bi,summarizedTab:i(i({},null===(k=yi.chatContainer)||void 0===k?void 0:k.summarizedTab),{chip:i({isActive:!0,show:!0},null===(G=null===(H=yi.chatContainer)||void 0===H?void 0:H.summarizedTab)||void 0===G?void 0:G.chip)}),detailedTab:i(i({},null===(O=yi.chatContainer)||void 0===O?void 0:O.detailedTab),{chip:i({isActive:!1},null===(W=null===(E=yi.chatContainer)||void 0===E?void 0:E.detailedTab)||void 0===W?void 0:W.chip)})}),ruleBookContainer:ji?i(i({},yi.ruleBookContainer),{data:{content:ui.ruleBookContent,highlighted_texts:null!==(N=null==ui?void 0:ui.ruleBookHighlights)&&void 0!==N?N:[]}}):void 0})}if(Si===S.GPT){var ki=null==gi?void 0:gi.value,Hi=null!==(z=null==ki?void 0:ki.text)&&void 0!==z?z:null===(F=null==gi?void 0:gi.dataSources)||void 0===F?void 0:F[0],Gi=null!==(M=null==ki?void 0:ki.label)&&void 0!==M?M:null===(q=null==gi?void 0:gi.trainingDataTitle)||void 0===q?void 0:q[0],Oi=null!==(K=null==ki?void 0:ki.paraphrase)&&void 0!==K?K:null===(Q=null==gi?void 0:gi.paraphrase)||void 0===Q?void 0:Q[0];L({data_sources:Hi,training_data_title:Gi},S.GPT);var Ei={text:"",dataSource:Hi,trainingDataTitle:Gi,paraphrase:Oi},Wi=null!==(J=null==di?void 0:di.iconsConfig)&&void 0!==J?J:{ChevronDownIcon:a,ChevronUpIcon:l,MaximizeIcon:r,CloseIcon:d};return n(f,{item:Ei,headerTitle:null!==(V=null==di?void 0:di.headerTitle)&&void 0!==V?V:"GPT - Gemini 3.5 Flash",iconsConfig:Wi,previewCallback:null==di?void 0:di.previewCallback,DocumentTitle:null==di?void 0:di.DocumentTitle,disableMaximize:Ai})}if(Si===S.WEB){!function(i,t,n){A(i,t,n);try{new URL(i)}catch(e){throw new Error("[BPACitationRenderer] ".concat(t,': "').concat(n,'" is not a valid URL: "').concat(i,'"'))}}(null==vi?void 0:vi.link,S.WEB,"link");var Ni=vi.link,zi=ti||(null==vi?void 0:vi.citationSource)||Ni;return(null==vi?void 0:vi.screenshotUrl)?n(T,{url:Ni,label:zi,gsUtilPath:null==vi?void 0:vi.gsUtilPath,signedUrl:vi.screenshotUrl,relevanceScore:null==vi?void 0:vi.relevanceScore,visitIcon:c,PreviewDialogCloseIcon:d}):n("a",i({href:Ni,target:"_blank",rel:"noreferrer"},{children:zi}))}if(Si===S.IMAGE)return L({gs_util_path:null==hi?void 0:hi.gsUtilPath,signed_url:null==hi?void 0:hi.signedUrl},S.IMAGE),n(D,{citationTitle:ti||(null==hi?void 0:hi.citationSource),gsUtilPath:null==hi?void 0:hi.gsUtilPath,signedUrl:null==hi?void 0:hi.signedUrl,relevanceScore:null==hi?void 0:hi.relevanceScore});if(Si===S.BQ_DATA)return L({href_params:null==mi?void 0:mi.hrefParams,source_obj:null==mi?void 0:mi.sourceObj},S.BQ_DATA),n(R,i({hrefParams:mi.hrefParams,sourceObj:mi.sourceObj,showChevron:!1,defaultOpen:!0},{children:ti||""}));if(Si===S.RULEBOOK||Si===S.RULEBOOK_CHUNK){var Fi=Pi?parseInt(Pi,10):0,Mi=n(b,{url:null!==(X=null==li?void 0:li.url)&&void 0!==X?X:"",data:{citationNumber:null!==(Z=null===(Y=null==li?void 0:li.data)||void 0===Y?void 0:Y.citationNumber)&&void 0!==Z?Z:Fi,fileDetails:null===($=null==li?void 0:li.data)||void 0===$?void 0:$.fileDetails},msg:null==li?void 0:li.msg,citationIndex:null==li?void 0:li.citationIndex,guidelines:null==li?void 0:li.guidelines,additionalClassNames:null==li?void 0:li.additionalClassNames,headerTitle:null==li?void 0:li.headerTitle,InternalGptReasoningData:null==li?void 0:li.InternalGptReasoningData,isDataProvided:null==li?void 0:li.isDataProvided,textualContent:null==li?void 0:li.textualContent,phraseToHighlight:null==li?void 0:li.phraseToHighlight,IgptHeaderTitle:null==li?void 0:li.IgptHeaderTitle,isInternalGptReasoningLoading:null==li?void 0:li.isInternalGptReasoningLoading,onAccordionToggle:null==li?void 0:li.onAccordionToggle});return Di?Mi:n(w,i({content:Mi,dialogTitle:null==li?void 0:li.dialogTitle},{children:ti}))}if(Si===S.IL_RULEBOOK){var qi=n(b,{headerTitle:null==li?void 0:li.headerTitle,InternalGptReasoningData:null==li?void 0:li.InternalGptReasoningData,isDataProvided:null==li?void 0:li.isDataProvided,textualContent:null==li?void 0:li.textualContent,phraseToHighlight:null==li?void 0:li.phraseToHighlight,IgptHeaderTitle:null==li?void 0:li.IgptHeaderTitle,onAccordionToggle:null==li?void 0:li.onAccordionToggle,isInternalGptReasoningLoading:null==li?void 0:li.isInternalGptReasoningLoading});return Di?qi:n(w,i({content:qi,dialogTitle:null==li?void 0:li.dialogTitle},{children:ti}))}if(Si===S.DUAL){var Ki=_i.searchParams.get("left_citation_type"),Qi=_i.searchParams.get("right_citation_type");if(Ki===S.DUAL||Qi===S.DUAL)return console.error("left or right citation type cant be dual_citation"),null;var Ji=function(i,t){var n="".concat(i,"."),e="left"===i?"right.":"left.",o=new URLSearchParams;return _i.searchParams.forEach(function(i,t){"citation_type"!==t&&"left_citation_type"!==t&&"right_citation_type"!==t&&(t.startsWith(n)||t.startsWith(e)||o.set(t,i))}),_i.searchParams.forEach(function(i,t){t.startsWith(n)&&o.set(t.slice(n.length),i)}),t&&o.set("citation_type",t),"?".concat(o.toString())},Vi=Ji("left",Ki),Xi=Ji("right",Qi),Yi=ti||Ci||"Source and Guidelines",Zi=function(i){switch(i){case S.SCANNED_DOC:return{scannedDocCitationData:ci,scannedDocCitationConfig:ai};case S.IL:return{ilCitationData:si,ilCitationConfig:ri};case S.CHAT:return{chatCitationData:ui,chatCitationConfig:oi};case S.GPT:return{gptCitationData:gi,gptCitationConfig:di};case S.WEB:return{webCitationData:vi};case S.IMAGE:return{imageCitationData:hi};case S.BQ_DATA:return{bqCitationData:mi};case S.RULEBOOK:return{ruleBookCitationConfig:li};default:return{}}};return n(_,{inLineCitation:!0,citationTitle:Yi,citationIcon:pi,isOpen:Ii,onToggle:function(){return bi(function(i){return!i})},styles:{pillButton:{fontSize:"14px",margin:"0px",padding:"0px",color:"#526eff",cursor:"pointer",verticalAlign:"middle",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",background:"white",border:"none"},citationContent:{width:"100%",background:"transparent",minHeight:"10px",height:"fit-content"}},citationComponent:n(P,{left:n(x,i({href:Vi,onCitationToggle:ei},Zi(Ki),{isDualCitationFlag:!0})),right:n(x,i({href:Xi,onCitationToggle:ei,isDualCitationFlag:!0},Zi(Qi))),header:{title:Yi,showDocIcon:!1},openInFullscreen:!0,fullscreenOnly:!0,onFullscreenClose:function(){return bi(!1)}})})}console.warn('[BPACitationRenderer] unhandled citation_type: "'.concat(Si,'"'))}catch(i){return console.error(i),null}return null};export{x as default};
|
|
2
2
|
//# sourceMappingURL=BPACitationRenderer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import o from"react";import{pdfStyles as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import o from"react";import{pdfStyles as r}from"./PdfStyle.js";import{DefaultPdfIcon as i,DefaultDownloadIcon as l,DefaultCloseIcon as a}from"../../assests/svg/PdfViewerIcons.js";import c from"@mui/material/Tooltip";import{Minus as d,Plus as s,Expand as p,Info as u}from"lucide-react";import h from"@mui/icons-material/RotateRight";var g=function(g){g.highlightIndex;var f=g.totalHighlights,x=g.controls,m=g.currentPosition,y=g.pdfName,v=g.onClose,b=g.pdfUrl,w=g.viewerRef,k=g.customStyles,S=g.customClasses,C=g.customIcons,F=g.headerAction,I=g.isZoomEnabled,T=void 0===I||I,W=g.showHighlightsAction,E=void 0===W||W,z=g.showFullScreenAction,D=void 0===z||z,R=g.currentSegment,j=g.segmentTooltipText,L=void 0===j?"Details of current segment":j,P=g.currentPage,B=g.totalPages,M=g.onPageNavigate,H=g.onRotatePage,N=g.currentPageRotation,A=void 0===N?0:N,Z=g.showRotateButton,O=void 0===Z||Z,_=x.ZoomPopover,G=x.goToPrevious,V=x.goToNext,q=o.useState(String(P)),K=q[0],U=q[1];o.useEffect(function(){U(String(P))},[P]);var X={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},Y=function(e){return String(e).padStart(2,"0")};return t("div",e({style:e(e(e({marginBottom:"12px",backgroundColor:"#F1F5F9",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},r.header),null==k?void 0:k.header),{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"})},{children:[t("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0}},{children:[n("div",e({style:e(e(e({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==k?void 0:k.pdfIconWrapper),{flexShrink:0})},{children:(null==C?void 0:C.pdfIcon)||n(i,{})})),n(c,e({title:y||"",arrow:!0,placement:"top"},{children:n("div",e({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:n("span",e({style:e({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==k?void 0:k.pdfName),className:null==S?void 0:S.pdfName},{children:y}))}))}))]})),t("div",e({style:{display:"flex",alignItems:"center",gap:E?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"}},{children:[B>0&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"}},{children:[n("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:K,onChange:function(e){var t=e.target.value.replace(/\D/g,"");U(t)},onBlur:function(){var e=Number(K);if(!Number.isInteger(e)||e<1)U(String(P));else{var t=B?Math.min(e,B):e;M(t),U(String(t))}},onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(U(String(P)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:"/"})),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:String(B)}))]})),T&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n("button",e({onClick:function(){x&&"function"==typeof x.zoomTo&&x.zoomTo(function(e){return e-.1})},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:function(e){e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:function(e){e.currentTarget&&(e.currentTarget.style.color="#475467")},title:"Zoom Out","aria-label":"Zoom out"},{children:n(d,{size:16,strokeWidth:2})})),n("div",e({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:n(_,{})})),n("button",e({onClick:function(){x&&"function"==typeof x.zoomTo&&x.zoomTo(function(e){return e+.1})},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:function(e){e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:function(e){e.currentTarget&&(e.currentTarget.style.color="#475467")},title:"Zoom In","aria-label":"Zoom in"},{children:n(s,{size:16,strokeWidth:2})}))]})),O&&H&&B>0&&n(c,e({title:"Rotate page (".concat(A,"°)")},{children:n("button",e({onClick:function(){H&&"function"==typeof H&&H()},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:0!==A?"#1976d2":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:function(e){e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:function(e){e.currentTarget&&(e.currentTarget.style.color=0!==A?"#1976d2":"#475467")},"aria-label":"Rotate current page"},{children:n(h,{sx:{fontSize:"18px"}})}))})),!!f&&E&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[t("span",e({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[m," of ",f]})),n("button",e({style:{background:"none",border:"none",cursor:m<=1?"not-allowed":"pointer",padding:"2px 4px",color:m<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:G,disabled:m<=1},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),n("button",e({style:{background:"none",border:"none",cursor:m===f?"not-allowed":"pointer",padding:"2px 4px",color:m===f?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:V,disabled:m===f},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),n("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),t("div",e({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==D&&((null==F?void 0:F.icon)&&(null==F?void 0:F.onClick)?n(c,e({title:(null==F?void 0:F.tooltip)||"",arrow:!0,placement:"top"},{children:n("div",e({onClick:F.onClick,style:e({display:"flex",alignItems:"center",cursor:"pointer"},X)},{children:F.icon}))})):n("button",e({onClick:function(){var e=null==w?void 0:w.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:X,title:"Full Screen"},{children:(null==C?void 0:C.fullScreenIcon)||n(p,{size:20,color:"#475467",strokeWidth:2})}))),b&&n("a",e({href:b,target:"_blank",rel:"noopener noreferrer",style:X,title:"Open in new tab"},{children:(null==C?void 0:C.downloadIcon)||n(l,{})})),v&&n("button",e({onClick:v,style:X,title:"Close"},{children:(null==C?void 0:C.closeIcon)||n(a,{})}))]}))]}))]})),R&&t("div",e({style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:[n(c,e({title:L,arrow:!0,placement:"top"},{children:n(u,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})})),n("span",e({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:n(c,e({title:R.title,arrow:!0,placement:"top"},{children:t("span",{children:["Viewing ",R.title," • Pages ",Y(R.start_page),"-",Y(R.end_page)]})}))}))]}))]}))};export{g as default};
|
|
2
2
|
//# sourceMappingURL=PdfToolbar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as n}from"tslib";import{jsx as r,jsxs as i,Fragment as o}from"react/jsx-runtime";import{SpecialZoomLevel as a}from"@react-pdf-viewer/core";import u from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as c}from"./PdfStyle.js";import{PdfHighlightControls as d}from"./usePdfHighlight.js";import{rotationManager as s}from"./rotationManager.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import g,{useRef as f,useState as h,useMemo as v,useEffect as m}from"react";import p from"../ScannedDocCitation/ScannedDocCitation.js";var w=function(w){var y=w.pdfUrl,P=w.highlightText,
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as n}from"tslib";import{jsx as r,jsxs as i,Fragment as o}from"react/jsx-runtime";import{SpecialZoomLevel as a}from"@react-pdf-viewer/core";import u from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as c}from"./PdfStyle.js";import{PdfHighlightControls as d}from"./usePdfHighlight.js";import{rotationManager as s}from"./rotationManager.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import g,{useRef as f,useState as h,useMemo as v,useEffect as m}from"react";import p from"../ScannedDocCitation/ScannedDocCitation.js";var w=function(w){var y=w.pdfUrl,P=w.highlightText,b=w.highlightPages,x=w.highlightCordinatePages,T=w.highlightColor,C=void 0===T?"yellow":T,S=w.activeHighlightColor,A=void 0===S?"#f7dc51":S,R=w.jumpToPageValue,_=void 0===R?0:R,I=w.pdfName,q=w.onClose,L=w.customStyles,F=w.customClasses,H=w.customIcons,N=w.useCoordinates,j=w.fallbackPages,B=w.activeCitationIndex,M=w.onActiveCitationChange,E=w.headerAction,D=w.isZoomEnabled,V=void 0===D||D,W=w.showHighlightsAction,k=void 0===W||W,z=w.defaultScale,O=void 0===z?a.ActualSize:z,U=w.useRange,Z=void 0!==U&&U,J=w.rangeOfPages,K=void 0===J?null:J,G=w.showFullScreenAction,Q=void 0===G||G,X=w.showRotateButton,Y=void 0!==X&&X,$=w.segments,ee=void 0===$?[{title:"Document 2",start_page:52,end_page:52,page_count:1}]:$,te=w.segmentTooltipText,ne=w.onCurrentPageChange,re=w.navigationRequest,ie=w.onNavigationSettled,oe=w.disablePdfAnnotations,ae=void 0!==oe&&oe,ue=w.disablePdfTextLayer,le=void 0!==ue&&ue,ce=w.renderPage,de=w.setRenderRange,se=f(null),ge=function(e){switch(e){case"ActualSize":return a.ActualSize;case"PageFit":return a.PageFit;case"PageWidth":return a.PageWidth;default:return null!=e?e:a.PageWidth}}(O),fe=h(0),he=fe[0],ve=fe[1],me=h(0),pe=me[0],we=me[1],ye=h(0),Pe=ye[0],be=ye[1],xe=f(null),Te=f(null),Ce=f(0),Se=f(null),Ae=v(function(){if(!y)return"";try{return new URL(y,window.location.origin).pathname.split("/").pop()||"default"}catch(e){return"default"}},[y]);m(function(){Ae&&s.setPdfIdentifier(Ae)},[Ae]);m(function(){return s.onRotationChange(function(e,t){e===he+1&&be(t)})},[he]),m(function(){var e=new MutationObserver(function(){var e,t=null===(e=se.current)||void 0===e?void 0:e.querySelectorAll('[data-testid^="core__page-layer-"]'),n=new Set;null==t||t.forEach(function(e){var t,r=null===(t=e.getAttribute("data-testid"))||void 0===t?void 0:t.match(/core__page-layer-(\d+)/);if(r&&r.length>=2){var i=parseInt(r[1],10)+1;n.has(i)||(s.registerPageElement(i,e),n.add(i))}})});return se.current&&(e.observe(se.current,{childList:!0,subtree:!0,attributes:!1}),Se.current=e),function(){e.disconnect(),Se.current=null}},[]),m(function(){return function(){s.clearAll(),Se.current&&Se.current.disconnect()}},[]),m(function(){var e=he+1;be(s.getRotation(e))},[he]);var Re,_e=v(function(){return ae||le?function(t){var n=le?r("div",e({"aria-hidden":"true",style:{display:"none"}},{children:t.textLayer.children})):t.textLayer.children,a=e(e({},t),{annotationLayer:e(e({},t.annotationLayer),{children:ae?null:t.annotationLayer.children}),textLayer:e(e({},t.textLayer),{children:n})});return ce?ce(a):i(o,{children:[t.canvasLayer.children,n,!ae&&t.annotationLayer.children]})}:ce},[ae,le,ce]),Ie=v(function(){if(N)return new Set(x.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(b).forEach(function(t){t>0&&e.add(t-1)}),e},[x,b,N]),qe=(Re=P)&&0!==Re.length?Re.filter(function(e){return!Re.some(function(t){return t!==e&&t.includes(e)})}):Re,Le=d(qe,N?{}:b,se,Ie,N,N?x:[],C,A),Fe=Le.highlightIndex,He=Le.cursorIndex,Ne=Le.setCursorIndex,je=Le.orderedKeys,Be=Le.totalHighlights,Me=Le.getValidPosition,Ee=Le.tryJump,De=Le.jumpToPage,Ve=Le.plugins,We=Le.controls,ke=Le.hideNonTargetHighlights,ze=Le.deduplicateHighlights,Oe=Me(He),Ue=v(function(){var e=he+1;return ee.find(function(t){return e>=t.start_page&&e<=t.end_page})},[he,ee]);m(function(){void 0!==B&&B!==He&&Ne(B)},[B]);var Ze=e(e({},We),{goToNext:function(){He>=Be-1||(We.goToNext(),M&&M(He+1))},goToPrevious:function(){He<=0||(We.goToPrevious(),M&&M(He-1))}}),Je=g.useCallback(function(e,t){Ce.current+=1;var n=Ce.current;null!=Te.current&&window.clearTimeout(Te.current);var r=null,i=0,o=0,a=function(){var u,l;if(Ce.current===n){o+=1;var c=null===(u=se.current)||void 0===u?void 0:u.querySelector(".rpv-core__inner-pages"),d=null===(l=se.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(t-1,'"]'));if(!c||!d)return o>=40?(Te.current=null,void(null==ie||ie({pageNumber:t,requestId:e.requestId}))):void(Te.current=window.setTimeout(a,50));r===c.scrollTop?i+=1:(r=c.scrollTop,i=0);var s=c.getBoundingClientRect(),g=d.getBoundingClientRect(),f=Boolean(s&&g&&g.bottom>s.top&&g.top<s.bottom);if(i>=2&&f||o>=40)return Te.current=null,void(null==ie||ie({pageNumber:t,requestId:e.requestId}));Te.current=window.setTimeout(a,50)}};Te.current=window.setTimeout(a,50)},[ie]);if(m(function(){return function(){Ce.current+=1,null!=Te.current&&window.clearTimeout(Te.current)}},[]),m(function(){var e;if(re&&!(pe<=0)){var t=Math.min(Math.max(Math.trunc(re.pageNumber),1),pe),n="".concat(null!==(e=re.requestId)&&void 0!==e?e:t,":").concat(t);xe.current!==n&&(xe.current=n,ve(t-1),De(t-1),Je(re,t))}},[De,re,pe,Je]),!y)return r(p,{pages:j,activeCitationIndex:B,onActiveCitationChange:M,headerAction:E});return i("div",e({ref:se,className:(null==F?void 0:F.pdfViewerWrapper)||"","data-disable-pdf-annotations":ae?"true":void 0,"data-pdf-page-fit":ge===a.PageFit?"true":void 0,style:e(e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},c.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==L?void 0:L.pdfViewer),{backgroundColor:"#F1F5F9"})},{children:[r(l,{highlightIndex:Fe,totalHighlights:Be,controls:Ze,currentPosition:Oe,pdfName:I,onClose:q,pdfUrl:y,viewerRef:se,customStyles:L,customClasses:F,customIcons:H,headerAction:E,isZoomEnabled:V,showHighlightsAction:k,showFullScreenAction:Q,currentSegment:Ue,segmentTooltipText:te,currentPage:he+1,totalPages:pe,onPageNavigate:function(e){var t=Math.min(Math.max(e,1),pe||e);ve(t-1),De(t-1)},onRotatePage:function(){var e=he+1;s.rotatePageBy90(e),be(s.getRotation(e))},currentPageRotation:Pe,showRotateButton:Y}),r(u,{defaultScale:ge,pdfUrl:y,plugins:Ve,customStyles:L,onLoad:function(e){we(e.doc.numPages);var r=!N&&!Z&&_<=0;if(_>0&&!Z){var i=_-1,o=je[i],a=b[o],u=x[i];Ne(i),console.log(u,"cordinateTargetHighlight"),N&&u.pageIndex>0&&De(u.pageIndex),a>0&&(setTimeout(function(){ke(Ie),ze(a-1)},1e3),N||De(a-1))}else if(Z&&K&&2===K.length){t(void 0,void 0,void 0,function(){var e,t,r,i,o;return n(this,function(n){switch(n.label){case 0:e=K[0],t=K[1],r=e,n.label=1;case 1:return r<=t?(De(i=r-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(n.sent(),ke(Ie),(o=ze(i))&&o>0)return[3,4];n.label=3;case 3:return r++,[3,1];case 4:return[2]}})})}else if(!N&&b){var l=je.find(function(e){return b[e]>0});if(void 0!==l){var c=b[l]-1;De(c),setTimeout(function(){ke(Ie),ze(c)},1e3)}}requestAnimationFrame(function(){r&&Ee(),!N&&_>0&&!Z&&function(){if(se.current){var e=_-1,t=je[e],n=b[t],r=n>0?n-1:0,i={};je.forEach(function(e,t){var n=b[e];n>0&&(i[n]||(i[n]=[]),i[n].push(t))});var o=(i[n]||[]).indexOf(e),a=0,u=function(){var e,t;if(!(++a>40)){var n=null===(e=se.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(n){var i=null===(t=se.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(r,'"]'));if(i){var l=n.getBoundingClientRect(),c=i.getBoundingClientRect();if(c.top<l.bottom&&c.bottom>l.top){var d=i.querySelectorAll(".rpv-search__highlight")[o];if(d){var s=d.getBoundingClientRect(),g=n.scrollTop+(s.top-l.top)-n.clientHeight/2+s.height/2;n.scrollTo({top:g,behavior:"smooth"})}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}};setTimeout(u,500)}}()})},onPageChange:function(e){var t=e.currentPage;ve(t),null==ne||ne(t+1),Ie.has(t)?(ze(t),ke(Ie)):ke(Ie)},renderPage:_e,setRenderRange:de})]}))};export{w as default};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as e,__assign as t}from"tslib";import{jsx as r,Fragment as n}from"react/jsx-runtime";import{useState as i,useRef as o,useMemo as a}from"react";import{searchPlugin as l}from"@react-pdf-viewer/search";import{pageNavigationPlugin as c}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as u}from"@react-pdf-viewer/zoom";import{highlightPlugin as h}from"@react-pdf-viewer/highlight";var f=function(f,g,s,p,v,d,m,x){void 0===m&&(m="yellow"),void 0===x&&(x="#F6D739");var T=i(0),y=T[0],b=T[1],w=o(!1),M=i(0),I=M[0],_=M[1];o([]);var S=function(e){return e.replace(/[^\S\n]+/g," ").trim()},E=function(e){return(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},A=function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t},B=function(e){var t=E(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},k=function(e){return e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1")},j=function(e){return e?k(e).split(/\n+/).map(A).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return S(function(e){return e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2")}(e))}).filter(Boolean):[]},q=Object.keys(g).map(Number).sort(function(e,t){return e-t}),z=a(function(){return v?d.length:v?0:Object.values(g).filter(function(e){return e>0}).length},[d,g]),C=function(r){if(s.current){var n=s.current.querySelector('[data-testid="search__highlights-'.concat(r,'"]'));if(n){var i=Array.from(n.querySelectorAll(".rpv-search__highlight"));if(0!==i.length){var o=$.map(B),a=P.map(B);if(0!==o.length||0!==a.length){var l=i.map(function(e){var r=function(e){var t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};var r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}}(e),n=(e.textContent||"").trim(),i=(e.getAttribute("title")||"").trim();return t({el:e,text:n||i},r)}).filter(function(e){return e.text.length>0}).sort(function(e,t){return e.top-t.top||e.left-t.left});if(0!==l.length){var c=[],u=null,h=[],g=function(){if(u){var e=h.join(" ");u.title=E(e),u.title&&c.push(u),u=null,h=[]}};if(l.forEach(function(e){if(!u)return u={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(h=[e.text]);var t=Math.abs(e.top-u.lastTop)<=5,r=e.left<=u.lastRight+28;t&&r?(u.elements.push(e.el),u.lastTop=e.top,u.lastRight=Math.max(u.lastRight,e.right),h.push(e.text)):(g(),u={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},h=[e.text])}),g(),0!==c.length){for(var p=function(e,t){if(!e)return!1;if(t.has(e))return!0;for(var r=e.replace(/\s+/g,""),n=0,i=Array.from(t);n<i.length;n++){var o=i[n];if(o){var a=o.replace(/\s+/g,"");if(a===r)return!0;if(o.length>=8&&e.length>=5&&o.includes(e))return!0;if(a.length>=8&&r.length>=5&&a.includes(r))return!0;if(e.length>=10&&o.length>=8&&e.includes(o))return!0;if(r.length>=10&&a.length>=8&&r.includes(a))return!0}}return!1},v=0,d=new Set,m=function(e){if(!e||e.length<8)return null;for(var t=e.replace(/\s+/g,""),r=0;r<c.length;r++)for(var n="",i="",o=new Set,a=r;a<c.length&&a<r+20;a++){var l=c[a].title;if(n=n?"".concat(n," ").concat(l):l,i=i?"".concat(i).concat(l.replace(/\s+/g,"")):l.replace(/\s+/g,""),o.add(a),n.includes(e)||i.includes(t))return o;if(n.length>=15&&(e.includes(n)||t.includes(i)))return o;if(n.length>e.length+150)break}return null},x=0,T=Array.from(new Set(e(e([],$,!0),P,!0).map(E).filter(function(e){return e.length>=8}))).sort(function(e,t){return t.length-e.length});x<T.length;x++){var y=m(T[x]);y&&y.size>0&&(y.forEach(function(e){return d.add(e)}),v=d.size)}if(0===v){var b=function(e){if(0===e.length)return null;for(var t=null,r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,a=Array.from(i);o<a.length;o++){var l=a[o];if(l&&!(l.length<5))for(var u=l.replace(/\s+/g,""),h=0;h<c.length;h++)for(var f="",g="",s=new Set,p=h;p<c.length&&p<h+15;p++){var v=c[p].title;if(f=f?"".concat(f," ").concat(v):v,g=g?"".concat(g).concat(v.replace(/\s+/g,"")):v.replace(/\s+/g,""),s.add(p),f.includes(l)||g.includes(u)){var d=Math.max(0,f.length-l.length);(!t||d<t.extra)&&(t={blocks:new Set(s),extra:d});break}if(f.length>l.length+120)break}}return t?t.blocks:null}(o);b&&b.size>0&&(b.forEach(function(e){return d.add(e)}),v=d.size)}var w=function(e){if(e.length<2)return 40;for(var t=[],r=1;r<e.length;r++){var n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort(function(e,t){return e-t});var i=t[Math.floor(t.length/2)],o=Math.round(2.25*i);return Math.min(60,Math.max(24,o))}(c),M=P.map(E).filter(function(e){return e.length>=8}),I=M.map(function(e){return e.split(/\s+/).filter(function(e){return e.length>=2})});if(0===v)for(var _=a,S=0;S<c.length;S++)for(var A=c[S].title,k=0;k<_.length;k++)if(p(A,_[k])){for(var j=0,q=new Set,z=k,C=S-1,R=S;R<c.length&&z<_.length;R++){if(p(c[R].title,_[z])){if(C>=0){var H=c[C].lastTop,F=c[R].lastTop;if(Math.abs(F-H)>w)break}j++,q.add(R),C=R,z++}else if(z>0&&p(c[R].title,_[z-1])){H=c[C].lastTop,F=c[R].lastTop;Math.abs(F-H)<=3&&(q.add(R),C=R)}if(R-C>6)break}j>v&&(v=j,d=q)}if(v<Math.min(3,M.length)&&M.length>0){var N=new Set;c.forEach(function(e,t){var r=e.title.split(/\s+/).filter(function(e){return e.length>=2});if(!(r.length<2))for(var n=new Set(r),i=0,o=I;i<o.length;i++){var a=o[i];if(!(a.length<2)){for(var l=0,c=0,u=a;c<u.length;c++){var h=u[c];n.has(h)&&l++}var f=l/a.length;if(l>=3||f>=.5){N.add(t);break}}}}),N.size>0&&(d=N,v=Math.max(v,N.size))}var Z=new Set;if(O.forEach(function(e){var t=E(e);t&&(Z.add(t),Z.add(t.replace(/\s+/g,"")))}),0===v){var L=new Set;if(c.forEach(function(e,t){var r=e.title.replace(/\s+/g,"");if(Z.has(e.title)||Z.has(r))L.add(t);else for(var n=Array.from(Z),i=0;i<n.length;i++){var o=n[i];if(o.length>=10&&o.includes(e.title)&&e.title.length>=5){L.add(t);break}}}),0===L.size)return 0;d=L}c.forEach(function(e,t){var r=d.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})});var D=[];return c.forEach(function(e,t){d.has(t)&&e.elements.forEach(function(e){return D.push(e)})}),requestAnimationFrame(function(){var e=D.map(function(e){return{el:e,rect:e.getBoundingClientRect()}}).filter(function(e){return e.rect.width>0&&e.rect.height>0}).sort(function(e,t){return t.rect.width*t.rect.height-e.rect.width*e.rect.height}),t=[];e.forEach(function(e){var r=e.el,n=e.rect;t.some(function(e){return t=e.rect,r=n,i=Math.max(0,Math.min(t.right,r.right)-Math.max(t.left,r.left))*Math.max(0,Math.min(t.bottom,r.bottom)-Math.max(t.top,r.top)),((o=Math.min(t.width*t.height,r.width*r.height))>0?i/o:0)>.5;var t,r,i,o})?(r.style.display="none",r.classList.remove("verified-match")):t.push({el:r,rect:n})})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(r,"]")),console.log("input->",f),console.log("processed sentences->",$),console.log("processed lines->",P),console.log("Expected sentence count:",o.length),console.log("Expected line count:",a.length),console.log("Matched sequence length:",v),console.log("blocksToKeep",d,"size",d.size),console.groupEnd(),d.size}}}}}}},R=function(e){s.current&&s.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),i=t.querySelectorAll(".rpv-search__highlight");e.has(n)||i.forEach(function(e){e.style.display="none"})})},H=f.map(function(e){return function(e){return e?k(e).split(/\n{2,}/).map(function(e){return j(e).join(" ")}).map(function(e){return S(e)}).filter(Boolean):[]}(e)}).flat(),F=f.map(function(e){return j(e)}).flat(),N=H.some(function(e){return e.length>=3})?3:1,$=H.filter(function(e){return e.length>=N}),P=F.filter(function(e){return e.length>=N}),Z=P.flatMap(function(e){return function(e,t,r){void 0===t&&(t=6),void 0===r&&(r=4);var n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];for(var i=[],o=0;o+t<=n.length;o+=r)i.push(n.slice(o,o+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&i.push(n.slice(n.length-t).join(" ")),i}(e)}),O=Array.from(new Set(e(e(e([],$,!0),P,!0),Z,!0).flatMap(function(e){var t=S(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];var r=t.replace(/[\u2013\u2014]/g,"-"),n=S(r.replace(/(\w)-\s+(\w)/g,"$1$2")),i=S(r.replace(/-/g," ")),o=S(r.replace(/-/g,"")),a=S(t.replace(/[^\w\s]/g,"")),l=new Set([t,r,n,i,o,a]);return Array.from(l).filter(Boolean)}))).filter(function(e){var t=e.split(/\s+/).filter(Boolean);return!(e.length<N)&&(t.length>=3||e.length>=12)}),L=l({keyword:O}),D=c(),W=u(),K=L.jumpToMatch,J=D.jumpToPage,V=W.zoomTo,G=W.ZoomInButton,Q=W.ZoomOutButton,U=W.ZoomPopover,X=a(function(){return function(r){if(0===r.length)return[];var n=new Map;r.forEach(function(e,r){var i=null!=e.pageNumber?e.pageNumber-1:e.pageIndex;n.has(i)||n.set(i,[]),n.get(i).push(t(t({},e),{originalIndex:r}))});var i=[];return n.forEach(function(t){for(var r=e([],t,!0).sort(function(e,t){return e.top!==t.top?e.top-t.top:e.left-t.left}),n=new Array(r.length).fill(!1),o=0;o<r.length;o++)if(!n[o]){var a=r[o],l=a.left,c=a.top,u=a.width,h=a.height,f=a.pageIndex,g=a.pageNumber,s=l+u,p=c+h,v=[r[o].originalIndex];n[o]=!0;for(var d=!0;d;){d=!1;for(var m=o+1;m<r.length;m++)if(!n[m]){var x=r[m],T=x.left+x.width,y=x.top+x.height,b=Math.max(0,Math.min(s,T)-Math.max(l,x.left))*Math.max(0,Math.min(p,y)-Math.max(c,x.top)),w=Math.max(u*h,1e-4),M=Math.max(x.width*x.height,1e-4),I=Math.min(w,M);(I>0?b/I:0)>=.8&&(l=Math.min(l,x.left),c=Math.min(c,x.top),u=(s=Math.max(s,T))-l,h=(p=Math.max(p,y))-c,v.push(x.originalIndex),n[m]=!0,d=!0)}}i.push({pageIndex:f,pageNumber:g,left:l,top:c,width:u,height:h,originalIndexes:v})}}),i}(d)},[d]),Y=h({renderHighlights:function(e){return r(n,{children:X.filter(function(t){return null!=t.pageNumber?t.pageNumber-1===e.pageIndex:t.pageIndex===e.pageIndex}).map(function(e){var t=e.originalIndexes.includes(I);return r("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top+.08*e.height,"%"),width:"".concat(e.width,"%"),height:"".concat(.95*e.height,"%"),background:t?x:m,opacity:t?.7:.4,transition:"background 0.2s, opacity 0.2s",border:t?"1px solid ".concat("red"):"1px solid transparent"}},e.originalIndexes.join("-"))})})}}),ee=function(){if(!w.current)try{K(0),w.current=!0;var e=d[0];e&&v&&re(e.pageIndex,e.top)}catch(e){requestAnimationFrame(ee)}},te=function(e,t){if(s.current&&s.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var i,o,a=null===(i=s.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(o=s.current)||void 0===o?void 0:o.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.querySelectorAll(".rpv-search__highlight")[t];if(c){var u=a.getBoundingClientRect(),h=c.getBoundingClientRect(),f=a.scrollTop+(h.top-u.top)-a.clientHeight/2+h.height/2;a.scrollTo({top:f,behavior:"smooth"})}}}};setTimeout(n,300)}},re=function(e,t,r){if(void 0===r&&(r=0),s.current){var n=0,i=function(){var o,a;if(!(++n>60)){var l=null===(o=s.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(l){var c=null===(a=s.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(c){var u=c.getBoundingClientRect();if(0!==u.height){var h=l.getBoundingClientRect(),f=t/100*u.height,g=r/100*u.height,p=u.top-h.top+f,v=p+g;if(!(p>=80&&v<=l.clientHeight-80)){var d=p<80?l.scrollTop+p-80:l.scrollTop+v-l.clientHeight+80;l.scrollTo({top:d,behavior:"smooth"})}}else setTimeout(i,100)}else setTimeout(i,100)}else setTimeout(i,100)}};setTimeout(i,100)}},ne=a(function(){var e={};return q.forEach(function(t,r){var n=g[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[q,g]),ie=function(e){var t=g[q[e]];return(ne[t]||[]).indexOf(e)},oe=function(e,t,r){if(void 0===r&&(r=0),s.current){var n=-1,i=0,o=function(){var a,l;if(!(++i>60)){var c=null===(a=s.current)||void 0===a?void 0:a.querySelector(".rpv-core__inner-pages");if(c){if(c.scrollTop!==n)return n=c.scrollTop,void setTimeout(o,100);var u=null===(l=s.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(u){var h=u.getBoundingClientRect();if(0!==h.height){var f=c.getBoundingClientRect(),g=t/100*h.height,p=r/100*h.height,v=h.top-f.top+g,d=v+p;if(!(v>=80&&d<=c.clientHeight-80)){var m=v<80?c.scrollTop+v-80:c.scrollTop+d-c.clientHeight+80;c.scrollTo({top:m,behavior:"instant"})}}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}};return{setHighlightIndex:b,highlightIndex:y,cursorIndex:I,setCursorIndex:_,orderedKeys:q,totalHighlights:z,getValidPosition:function(e){if(v)return e+1;if(!g)return 0;for(var t=0,r=0;r<=e;r++)g[q[r]]>0&&t++;return t},tryJump:ee,jumpToPage:J,zoomTo:V,hideNonTargetHighlights:R,deduplicateHighlights:C,scrollToCoord:re,plugins:[v?Y:L,D,W],controls:{ZoomInButton:G,ZoomOutButton:Q,ZoomPopover:U,goToNext:function(){if(v&&d)for(var e=I+1;e<d.length;e++){var t=d[e],r=d[I];return _(e),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top,t.height)):re(t.pageIndex,t.top,t.height))}else{var n=function(e){var t=q[e];if(g[t]>0){var r=g[t]-1,n=ie(e);return _(e),J(g[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(g).length&&R(p),{value:void 0}}};for(e=I+1;e<q.length;e++){var i=n(e);if("object"==typeof i)return i.value}}},goToPrevious:function(){if(v&&d)for(var e=I-1;e>=0;e--){var t=d[e],r=d[I];return _(e),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top,t.height)):re(t.pageIndex,t.top,t.height))}else{var n=function(e){var t=q[e];if(g[t]>0){var r=g[t]-1,n=ie(e);return _(e),J(g[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(g).length&&R(p),{value:void 0}}};for(e=I-1;e>=0;e--){var i=n(e);if("object"==typeof i)return i.value}}}}}};export{f as PdfHighlightControls};
|
|
1
|
+
import{__spreadArray as e,__assign as t}from"tslib";import{jsx as r,Fragment as n}from"react/jsx-runtime";import{useState as i,useRef as o,useMemo as a}from"react";import{searchPlugin as l}from"@react-pdf-viewer/search";import{pageNavigationPlugin as c}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as u}from"@react-pdf-viewer/zoom";import{highlightPlugin as h}from"@react-pdf-viewer/highlight";var f=function(f,g,s,p,v,d,m,x){void 0===m&&(m="yellow"),void 0===x&&(x="#F6D739");var T=i(0),y=T[0],b=T[1],w=o(!1),M=i(0),I=M[0],_=M[1];o([]);var S=function(e){return e.replace(/[^\S\n]+/g," ").trim()},E=function(e){return(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},A=function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t},B=function(e){var t=E(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},k=function(e){return e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1")},z=function(e){return e?k(e).split(/\n+/).map(A).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return S(function(e){return e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2")}(e))}).filter(Boolean):[]},j=Object.keys(g).map(Number).sort(function(e,t){return e-t}),q=a(function(){return v?d.length:v?0:Object.values(g).filter(function(e){return e>0}).length},[d,g]),C=function(r){if(s.current){var n=s.current.querySelector('[data-testid="search__highlights-'.concat(r,'"]'));if(n){var i=Array.from(n.querySelectorAll(".rpv-search__highlight"));if(0!==i.length){var o=$.map(B),a=P.map(B);if(0!==o.length||0!==a.length){var l=i.map(function(e){var r=function(e){var t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};var r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}}(e),n=(e.textContent||"").trim(),i=(e.getAttribute("title")||"").trim();return t({el:e,text:n||i},r)}).filter(function(e){return e.text.length>0}).sort(function(e,t){return e.top-t.top||e.left-t.left});if(0!==l.length){var c=[],u=null,h=[],g=function(){if(u){var e=h.join(" ");u.title=E(e),u.title&&c.push(u),u=null,h=[]}};if(l.forEach(function(e){if(!u)return u={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(h=[e.text]);var t=Math.abs(e.top-u.lastTop)<=5,r=e.left<=u.lastRight+28;t&&r?(u.elements.push(e.el),u.lastTop=e.top,u.lastRight=Math.max(u.lastRight,e.right),h.push(e.text)):(g(),u={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},h=[e.text])}),g(),0!==c.length){for(var p=function(e,t){if(!e)return!1;if(t.has(e))return!0;for(var r=e.replace(/\s+/g,""),n=0,i=Array.from(t);n<i.length;n++){var o=i[n];if(o){var a=o.replace(/\s+/g,"");if(a===r)return!0;if(o.length>=8&&e.length>=5&&o.includes(e))return!0;if(a.length>=8&&r.length>=5&&a.includes(r))return!0;if(e.length>=10&&o.length>=8&&e.includes(o))return!0;if(r.length>=10&&a.length>=8&&r.includes(a))return!0}}return!1},v=0,d=new Set,m=function(e){if(!e||e.length<8)return null;for(var t=e.replace(/\s+/g,""),r=0;r<c.length;r++)for(var n="",i="",o=new Set,a=r;a<c.length&&a<r+20;a++){var l=c[a].title;if(n=n?"".concat(n," ").concat(l):l,i=i?"".concat(i).concat(l.replace(/\s+/g,"")):l.replace(/\s+/g,""),o.add(a),n.includes(e)||i.includes(t))return o;if(n.length>=15&&(e.includes(n)||t.includes(i)))return o;if(n.length>e.length+150)break}return null},x=0,T=Array.from(new Set(e(e([],$,!0),P,!0).map(E).filter(function(e){return e.length>=8}))).sort(function(e,t){return t.length-e.length});x<T.length;x++){var y=m(T[x]);y&&y.size>0&&(y.forEach(function(e){return d.add(e)}),v=d.size)}if(0===v){var b=function(e){if(0===e.length)return null;for(var t=null,r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,a=Array.from(i);o<a.length;o++){var l=a[o];if(l&&!(l.length<5))for(var u=l.replace(/\s+/g,""),h=0;h<c.length;h++)for(var f="",g="",s=new Set,p=h;p<c.length&&p<h+15;p++){var v=c[p].title;if(f=f?"".concat(f," ").concat(v):v,g=g?"".concat(g).concat(v.replace(/\s+/g,"")):v.replace(/\s+/g,""),s.add(p),f.includes(l)||g.includes(u)){var d=Math.max(0,f.length-l.length);(!t||d<t.extra)&&(t={blocks:new Set(s),extra:d});break}if(f.length>l.length+120)break}}return t?t.blocks:null}(o);b&&b.size>0&&(b.forEach(function(e){return d.add(e)}),v=d.size)}var w=function(e){if(e.length<2)return 40;for(var t=[],r=1;r<e.length;r++){var n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort(function(e,t){return e-t});var i=t[Math.floor(t.length/2)],o=Math.round(2.25*i);return Math.min(60,Math.max(24,o))}(c),M=P.map(E).filter(function(e){return e.length>=8}),I=M.map(function(e){return e.split(/\s+/).filter(function(e){return e.length>=2})});if(0===v)for(var _=a,S=0;S<c.length;S++)for(var A=c[S].title,k=0;k<_.length;k++)if(p(A,_[k])){for(var z=0,j=new Set,q=k,C=S-1,R=S;R<c.length&&q<_.length;R++){if(p(c[R].title,_[q])){if(C>=0){var H=c[C].lastTop,F=c[R].lastTop;if(Math.abs(F-H)>w)break}z++,j.add(R),C=R,q++}else if(q>0&&p(c[R].title,_[q-1])){H=c[C].lastTop,F=c[R].lastTop;Math.abs(F-H)<=3&&(j.add(R),C=R)}if(R-C>6)break}z>v&&(v=z,d=j)}if(v<Math.min(3,M.length)&&M.length>0){var N=new Set;c.forEach(function(e,t){var r=e.title.split(/\s+/).filter(function(e){return e.length>=2});if(!(r.length<2))for(var n=new Set(r),i=0,o=I;i<o.length;i++){var a=o[i];if(!(a.length<2)){for(var l=0,c=0,u=a;c<u.length;c++){var h=u[c];n.has(h)&&l++}var f=l/a.length;if(l>=3||f>=.5){N.add(t);break}}}}),N.size>0&&(d=N,v=Math.max(v,N.size))}var Z=new Set;if(O.forEach(function(e){var t=E(e);t&&(Z.add(t),Z.add(t.replace(/\s+/g,"")))}),0===v){var L=new Set;if(c.forEach(function(e,t){var r=e.title.replace(/\s+/g,"");if(Z.has(e.title)||Z.has(r))L.add(t);else for(var n=Array.from(Z),i=0;i<n.length;i++){var o=n[i];if(o.length>=10&&o.includes(e.title)&&e.title.length>=5){L.add(t);break}}}),0===L.size)return 0;d=L}c.forEach(function(e,t){var r=d.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})});var D=[];return c.forEach(function(e,t){d.has(t)&&e.elements.forEach(function(e){return D.push(e)})}),requestAnimationFrame(function(){var e=D.map(function(e){return{el:e,rect:e.getBoundingClientRect()}}).filter(function(e){return e.rect.width>0&&e.rect.height>0}).sort(function(e,t){return t.rect.width*t.rect.height-e.rect.width*e.rect.height}),t=[];e.forEach(function(e){var r=e.el,n=e.rect;t.some(function(e){return t=e.rect,r=n,i=Math.max(0,Math.min(t.right,r.right)-Math.max(t.left,r.left))*Math.max(0,Math.min(t.bottom,r.bottom)-Math.max(t.top,r.top)),((o=Math.min(t.width*t.height,r.width*r.height))>0?i/o:0)>.5;var t,r,i,o})?(r.style.display="none",r.classList.remove("verified-match")):t.push({el:r,rect:n})})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(r,"]")),console.log("input->",f),console.log("processed sentences->",$),console.log("processed lines->",P),console.log("Expected sentence count:",o.length),console.log("Expected line count:",a.length),console.log("Matched sequence length:",v),console.log("blocksToKeep",d,"size",d.size),console.groupEnd(),d.size}}}}}}},R=function(e){s.current&&s.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),i=t.querySelectorAll(".rpv-search__highlight");e.has(n)||i.forEach(function(e){e.style.display="none"})})},H=f.map(function(e){return function(e){return e?k(e).split(/\n{2,}/).map(function(e){return z(e).join(" ")}).map(function(e){return S(e)}).filter(Boolean):[]}(e)}).flat(),F=f.map(function(e){return z(e)}).flat(),N=H.some(function(e){return e.length>=3})?3:1,$=H.filter(function(e){return e.length>=N}),P=F.filter(function(e){return e.length>=N}),Z=P.flatMap(function(e){return function(e,t,r){void 0===t&&(t=6),void 0===r&&(r=4);var n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];for(var i=[],o=0;o+t<=n.length;o+=r)i.push(n.slice(o,o+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&i.push(n.slice(n.length-t).join(" ")),i}(e)}),O=Array.from(new Set(e(e(e([],$,!0),P,!0),Z,!0).flatMap(function(e){var t=S(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];var r=t.replace(/[\u2013\u2014]/g,"-"),n=S(r.replace(/(\w)-\s+(\w)/g,"$1$2")),i=S(r.replace(/-/g," ")),o=S(r.replace(/-/g,"")),a=S(t.replace(/[^\w\s]/g,"")),l=new Set([t,r,n,i,o,a]);return Array.from(l).filter(Boolean)}))).filter(function(e){var t=e.split(/\s+/).filter(Boolean);return!(e.length<N)&&(t.length>=3||e.length>=12)}),L=l({keyword:O}),D=c(),W=u(),K=L.jumpToMatch,J=D.jumpToPage,V=W.zoomTo,G=W.ZoomInButton,Q=W.ZoomOutButton,U=W.ZoomPopover,X=a(function(){return function(r){if(0===r.length)return[];var n=new Map;r.forEach(function(e,r){var i=null!=e.pageNumber?e.pageNumber-1:e.pageIndex;n.has(i)||n.set(i,[]),n.get(i).push(t(t({},e),{originalIndex:r}))});var i=[];return n.forEach(function(t){for(var r=e([],t,!0).sort(function(e,t){return e.top!==t.top?e.top-t.top:e.left-t.left}),n=new Array(r.length).fill(!1),o=0;o<r.length;o++)if(!n[o]){var a=r[o],l=a.left,c=a.top,u=a.width,h=a.height,f=a.pageIndex,g=a.pageNumber,s=l+u,p=c+h,v=[r[o].originalIndex];n[o]=!0;for(var d=!0;d;){d=!1;for(var m=o+1;m<r.length;m++)if(!n[m]){var x=r[m],T=x.left+x.width,y=x.top+x.height,b=Math.max(0,Math.min(s,T)-Math.max(l,x.left))*Math.max(0,Math.min(p,y)-Math.max(c,x.top)),w=Math.max(u*h,1e-4),M=Math.max(x.width*x.height,1e-4),I=Math.min(w,M);(I>0?b/I:0)>=.8&&(l=Math.min(l,x.left),c=Math.min(c,x.top),u=(s=Math.max(s,T))-l,h=(p=Math.max(p,y))-c,v.push(x.originalIndex),n[m]=!0,d=!0)}}i.push({pageIndex:f,pageNumber:g,left:l,top:c,width:u,height:h,originalIndexes:v})}}),i}(d)},[d]),Y=h({renderHighlights:function(e){return r(n,{children:X.filter(function(t){return null!=t.pageNumber?t.pageNumber-1===e.pageIndex:t.pageIndex===e.pageIndex}).map(function(e){var t=e.originalIndexes.includes(I);return r("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top+.08*e.height,"%"),width:"".concat(e.width,"%"),height:"".concat(.95*e.height,"%"),background:t?x:m,opacity:t?.7:.4,transition:"background 0.2s, opacity 0.2s",border:t?"1px solid ".concat("red"):"1px solid transparent"}},e.originalIndexes.join("-"))})})}}),ee=function(){if(!w.current)try{K(0),w.current=!0;var e=d[0];e&&v&&re(e.pageIndex,e.top)}catch(e){requestAnimationFrame(ee)}},te=function(e,t){if(s.current&&s.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var i,o,a=null===(i=s.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(o=s.current)||void 0===o?void 0:o.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.querySelectorAll(".rpv-search__highlight")[t];if(c){var u=a.getBoundingClientRect(),h=c.getBoundingClientRect(),f=a.scrollTop+(h.top-u.top)-a.clientHeight/2+h.height/2;a.scrollTo({top:f,behavior:"smooth"})}}}};setTimeout(n,300)}},re=function(e,t,r){if(void 0===r&&(r=0),s.current){var n=0,i=function(){var o,a;if(!(++n>60)){var l=null===(o=s.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(l){var c=null===(a=s.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(c){var u=c.getBoundingClientRect();if(0!==u.height){var h=l.getBoundingClientRect(),f=t/100*u.height,g=r/100*u.height,p=u.top-h.top+f,v=p+g;if(!(p>=80&&v<=l.clientHeight-80)){var d=p<80?l.scrollTop+p-80:l.scrollTop+v-l.clientHeight+80;l.scrollTo({top:d,behavior:"smooth"})}}else setTimeout(i,100)}else setTimeout(i,100)}else setTimeout(i,100)}};setTimeout(i,100)}},ne=a(function(){var e={};return j.forEach(function(t,r){var n=g[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[j,g]),ie=function(e){var t=g[j[e]];return(ne[t]||[]).indexOf(e)},oe=function(e,t,r){if(void 0===r&&(r=0),s.current){var n=-1,i=0,o=function(){var a,l;if(!(++i>60)){var c=null===(a=s.current)||void 0===a?void 0:a.querySelector(".rpv-core__inner-pages");if(c){if(c.scrollTop!==n)return n=c.scrollTop,void setTimeout(o,100);var u=null===(l=s.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(u){var h=u.getBoundingClientRect();if(0!==h.height){var f=c.getBoundingClientRect(),g=t/100*h.height,p=r/100*h.height,v=h.top-f.top+g,d=v+p;if(!(v>=80&&d<=c.clientHeight-80)){var m=v<80?c.scrollTop+v-80:c.scrollTop+d-c.clientHeight+80;c.scrollTo({top:m,behavior:"instant"})}}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}};return{setHighlightIndex:b,highlightIndex:y,cursorIndex:I,setCursorIndex:_,orderedKeys:j,totalHighlights:q,getValidPosition:function(e){if(v)return e+1;if(!g)return 0;for(var t=0,r=0;r<=e;r++)g[j[r]]>0&&t++;return t},tryJump:ee,jumpToPage:J,zoomTo:V,hideNonTargetHighlights:R,deduplicateHighlights:C,scrollToCoord:re,plugins:[v?Y:L,D,W],controls:{ZoomInButton:G,ZoomOutButton:Q,ZoomPopover:U,zoomTo:V,goToNext:function(){if(v&&d)for(var e=I+1;e<d.length;e++){var t=d[e],r=d[I];return _(e),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top,t.height)):re(t.pageIndex,t.top,t.height))}else{var n=function(e){var t=j[e];if(g[t]>0){var r=g[t]-1,n=ie(e);return _(e),J(g[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(g).length&&R(p),{value:void 0}}};for(e=I+1;e<j.length;e++){var i=n(e);if("object"==typeof i)return i.value}}},goToPrevious:function(){if(v&&d)for(var e=I-1;e>=0;e--){var t=d[e],r=d[I];return _(e),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top,t.height)):re(t.pageIndex,t.top,t.height))}else{var n=function(e){var t=j[e];if(g[t]>0){var r=g[t]-1,n=ie(e);return _(e),J(g[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(g).length&&R(p),{value:void 0}}};for(e=I-1;e>=0;e--){var i=n(e);if("object"==typeof i)return i.value}}}}}};export{f as PdfHighlightControls};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as n,__spreadArray as e}from"tslib";import{jsxs as t,jsx as r,Fragment as o}from"react/jsx-runtime";import{useMemo as i,useRef as l,useState as a,useCallback as d,useEffect as c}from"react";var u=170,s=48,f=["#ede9fe","#e0f2fe","#fef3c7","#dcfce7","#ffe4e6","#f0fdf4","#fef9c3","#e0e7ff","#fce7f3","#f1f5f9"],v=["#7c3aed","#0284c7","#b45309","#16a34a","#e11d48","#15803d","#a16207","#4338ca","#db2777","#475569"],p=["⚙","◈","⟐","✦","◎","⬡","◇","⊕","✶","◉"],g=["#a78bfa","#7dd3fc","#fbbf24","#86efac","#fda4af","#6ee7b7","#fde047","#a5b4fc","#f9a8d4","#94a3b8"],h=["linear-gradient(135deg,#7c3aed,#a78bfa)","linear-gradient(135deg,#0284c7,#38bdf8)","linear-gradient(135deg,#b45309,#fbbf24)","linear-gradient(135deg,#16a34a,#86efac)","linear-gradient(135deg,#e11d48,#fda4af)","linear-gradient(135deg,#15803d,#6ee7b7)","linear-gradient(135deg,#a16207,#fde047)","linear-gradient(135deg,#4338ca,#a5b4fc)","linear-gradient(135deg,#db2777,#f9a8d4)","linear-gradient(135deg,#475569,#94a3b8)"],y=["Context & Inputs","Core Logic & Rules","Outputs & Schema"];function b(t){var r=Array.isArray(null==t?void 0:t.clusters)?t.clusters:[],o=Array.isArray(null==t?void 0:t.nodes)?t.nodes:[],i=Array.isArray(null==t?void 0:t.edges)?t.edges:[],l=function(n,t,r){var o,i=n.length;if(0===i)return new Map;var l={};n.forEach(function(n,e){l[n.id]=e});var a={};n.forEach(function(n){a[n.id]=0});for(var d=0;d<i;d++){for(var c=!1,u=0,s=t;u<s.length;u++){var f=s[u],v=(a[f.source]||0)+1;v>(a[f.target]||0)&&v<i&&(a[f.target]=v,c=!0)}if(!c)break}var p={};r.forEach(function(n,e){p[n.id]=e});var g={};r.forEach(function(n){g[n.id]=[]}),n.forEach(function(n){var e;null===(e=g[n.cluster_id])||void 0===e||e.push(n)}),Object.values(g).forEach(function(n){return n.sort(function(n,e){return(a[n.id]||0)-(a[e.id]||0)})});for(var h=new Float64Array(i),y=new Float64Array(i),b=new Float64Array(i),x=new Float64Array(i),m=function(n){var e=null!==(o=p[n.id])&&void 0!==o?o:0;(g[n.id]||[]).forEach(function(n,t){var r=l[n.id];h[r]=520*e+280,y[r]=200*t+120})},w=0,M=r;w<M.length;w++)m(U=M[w]);for(var k=.0015,S=Math.max.apply(Math,e(e([],n.map(function(n){return a[n.id]||0}),!1),[1],!1)),C=new Float64Array(i),_=0;_<i;_++)C[_]=(a[n[_].id]||0)/S*(200*i*.6)+120;for(var A=0;A<350;A++){var z=Math.max(.015,1-A/350),E=new Float64Array(i),I=new Float64Array(i);for(_=0;_<i;_++)for(var j=_+1;j<i;j++){var R=(X=h[_]-h[j])*X+(H=y[_]-y[j])*H;R<400&&(R=(X=12*(_-j))*X+(H=8*(_+j))*H);var W=X/(L=Math.sqrt(R))*(O=48e4/R),P=H/L*O;E[_]+=W,I[_]+=P,E[j]-=W,I[j]-=P}for(var B=0,Y=t;B<Y.length;B++){f=Y[B];var F=l[f.source],D=l[f.target];if(void 0!==F&&void 0!==D){var L,O,X=h[D]-h[F],H=y[D]-y[F];if(!((L=Math.sqrt(X*X+H*H))<1))W=X/L*(O=.004*(L-380)),P=H/L*O,E[F]+=W,I[F]+=P,E[D]-=W,I[D]-=P}}var N={},T={},q={};for(_=0;_<i;_++)N[U=n[_].cluster_id]=(N[U]||0)+h[_],T[U]=(T[U]||0)+y[_],q[U]=(q[U]||0)+1;for(_=0;_<i;_++){var U=n[_].cluster_id;E[_]+=(N[U]/q[U]-h[_])*k,I[_]+=(T[U]/q[U]-y[_])*k}for(_=0;_<i;_++)I[_]+=.002*(C[_]-y[_]);for(_=0;_<i;_++)b[_]=.84*(b[_]+E[_])*z,x[_]=.84*(x[_]+I[_])*z,h[_]+=b[_],y[_]+=x[_]}for(d=0;d<40;d++){var G=!1;for(_=0;_<i;_++)for(j=_+1;j<i;j++){X=h[_]-h[j],H=y[_]-y[j];var Q=270-Math.abs(X),J=128-Math.abs(H);if(Q>0&&J>0)if(G=!0,Q<J){var K=Q/2+5;h[_]+=X>0?K:-K,h[j]-=X>0?K:-K}else K=J/2+5,y[_]+=H>0?K:-K,y[j]-=H>0?K:-K}if(!G)break}var V=1/0,Z=1/0;for(_=0;_<i;_++)V=Math.min(V,h[_]),Z=Math.min(Z,y[_]);var $=new Map;for(_=0;_<i;_++)$.set(n[_].id,{x:Math.round(h[_]-V+80),y:Math.round(y[_]-Z+80)});return $}(o,i,r),a=o.map(function(e){var t=l.get(e.id)||{x:0,y:0};return n(n({},e),{x:t.x,y:t.y})}),d={};r.forEach(function(n,e){d[n.id]=e});var c={};r.forEach(function(n){c[n.id]=[]}),a.forEach(function(n){var e;null===(e=c[n.cluster_id])||void 0===e||e.push(n)});var f=36,v=r.map(function(n){var e=c[n.id];if(!e.length)return null;var t=Math.min.apply(Math,e.map(function(n){return n.x})),r=Math.min.apply(Math,e.map(function(n){return n.y})),o=Math.max.apply(Math,e.map(function(n){return n.x+u})),i=Math.max.apply(Math,e.map(function(n){return n.y+s}));return{id:n.id,label:n.label,idx:d[n.id],x:t-f,y:r-f,width:o-t+72,height:i-r+72+22}}).filter(function(n){return null!==n});return{nodes:a.map(function(e){var t;return n(n({},e),{cluster:null!==(t=d[e.cluster_id])&&void 0!==t?t:0})}),edges:i,clusterBounds:v,canvasW:Math.max.apply(Math,a.map(function(n){return n.x+u}))+72,canvasH:Math.max.apply(Math,a.map(function(n){return n.y+s}))+72}}function x(n,e,t){var r=e[n.source],o=e[n.target];if(!r||!o)return"";var i=function(n,e){var t=n.x+85,r=n.y+24,o=e.x+85,i=e.y+24;function l(n,e,t,r){var o=t-n,i=r-e;return Math.abs(i)>.4*Math.abs(o)?i>0?{x:n,y:e+24}:{x:n,y:e-24}:o>0?{x:n+85,y:e}:{x:n-85,y:e}}return{source:l(t,r,o,i),target:l(o,i,t,r)}}(r,o),l=i.source,a=i.target,d=a.x-l.x,c=a.y-l.y,u=Math.sqrt(d*d+c*c);if(u<5)return"M ".concat(l.x," ").concat(l.y," L ").concat(a.x," ").concat(a.y);if(o.y+150<r.y&&o.y<r.y-s){var f=Math.min(r.x,o.x)-110;return"M ".concat(l.x," ").concat(l.y," C ").concat(f," ").concat(l.y,", ").concat(f," ").concat(a.y,", ").concat(a.x," ").concat(a.y)}var v=-c/u,p=d/u;if(t.some(function(e){return e.source===n.target&&e.target===n.source})){var g=n.source<n.target?1:-1,h=Math.max(.18*u,40)*g;return"M ".concat(l.x," ").concat(l.y," Q ").concat((l.x+a.x)/2+v*h," ").concat((l.y+a.y)/2+p*h," ").concat(a.x," ").concat(a.y)}var y=Math.min(.12*u,55);return"M ".concat(l.x," ").concat(l.y," Q ").concat((l.x+a.x)/2+v*y," ").concat((l.y+a.y)/2+p*y," ").concat(a.x," ").concat(a.y)}var m=function(e){var m,w,M,k,S,C,_,A,z,E,I,j,R=e.data,W=e.isDarkMode,P=void 0!==W&&W,B=e.height,Y=void 0===B?500:B,F=e.width,D=void 0===F?"100%":F,L=e.styles,O=i(function(){return function(e){if(!e||"object"!=typeof e)return null;if(Array.isArray(e.nodes)&&Array.isArray(e.edges)){var t=e.nodes,r=Array.isArray(e.clusters)&&e.clusters.length>0?e.clusters:null,o=new Set(t.map(function(n){return n.cluster_id}));if(!r||o.size<=1){var i=Math.max(1,Math.min(3,Math.ceil(t.length/3)));r=Array.from({length:i},function(n,e){return{id:"cl_".concat(e+1),label:y[e]||"Group ".concat(e+1)}}),t=t.map(function(e,t){var o=t%i,l=Math.floor(t/i);return n(n({},e),{cluster_id:r[o].id,x:450*o+200,y:180*l+100})})}return{graph_id:e.graph_id||"graph",prompt_id:e.prompt_id||"",last_analyzed_at:e.last_analyzed_at||(new Date).toISOString(),clusters:r,nodes:t,edges:e.edges}}var l=Object.keys(e);if(0===l.length)return null;var a=Math.max(1,Math.min(3,Math.ceil(l.length/3))),d=Array.from({length:a},function(n,e){return{id:"cl_".concat(e+1),label:y[e]||"Group ".concat(e+1)}}),c=[],u=[];return l.forEach(function(n,t){var r=t%a,o=Math.floor(t/a),i=n.split("_").map(function(n){return n.charAt(0).toUpperCase()+n.slice(1)}).join(" "),l="node_".concat(n);c.push({id:l,label:i,cluster_id:d[r].id,x:450*r+200,y:180*o+100,description:"Section: ".concat(i)});var s=e[n];Array.isArray(s)&&s.forEach(function(e,t){var r;if(e&&"object"==typeof e){var o=e.dependent_on;if(o){var i="";"string"==typeof e.reasoning?i=e.reasoning:Array.isArray(e.reasoning)?i=e.reasoning.map(function(n){return"string"==typeof n?n:(null==n?void 0:n.text)||""}).filter(Boolean).join(" "):(null===(r=e.reasoning)||void 0===r?void 0:r.text)&&(i=String(e.reasoning.text)),u.push({id:"e_".concat(n,"_").concat(o,"_").concat(t),source:l,target:"node_".concat(o),reasoning:i||"Depends on ".concat(o),score:"number"==typeof e.Score?e.Score:"number"==typeof e.score?e.score:80,gap:e.gap||"",dependency_type:e.dependency_type||"implicit"})}}})}),0===c.length?null:{graph_id:"converted_graph",prompt_id:"",last_analyzed_at:(new Date).toISOString(),clusters:d,nodes:c,edges:u}}(R)},[R]),X=i(function(){return O?b(O):null},[O]),H=i(function(){var n={};return null==X||X.nodes.forEach(function(e){n[e.id]=e}),n},[X]),N=i(function(){var n={};return null==O||O.clusters.forEach(function(e,t){n[e.id]=t}),n},[O]),T=l(null),q=a({x:0,y:0}),U=q[0],G=q[1],Q=a(.5),J=Q[0],K=Q[1],V=a(!1),Z=V[0],$=V[1],nn=l({x:0,y:0}),en=l({x:0,y:0}),tn=a(null),rn=tn[0],on=tn[1],ln=a(null),an=ln[0],dn=ln[1],cn=a(null),un=cn[0],sn=cn[1],fn=a(null),vn=fn[0],pn=fn[1],gn=i(function(){return vn&&X?new Set(X.edges.filter(function(n){return n.source===vn||n.target===vn}).map(function(n){return n.id})):new Set},[vn,X]),hn=i(function(){if(!vn||!X)return new Set;var n=new Set([vn]);return X.edges.forEach(function(e){e.source===vn&&n.add(e.target),e.target===vn&&n.add(e.source)}),n},[vn,X]);i(function(){return O?new Date(O.last_analyzed_at).toLocaleString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,day:"numeric",month:"short",year:"numeric"}):""},[O]);var yn=d(function(n){n.preventDefault(),K(function(e){return Math.min(2.5,Math.max(.2,e-.001*n.deltaY))})},[]);c(function(){var n=T.current;return n&&n.addEventListener("wheel",yn,{passive:!1}),function(){return null==n?void 0:n.removeEventListener("wheel",yn)}},[yn]);var bn=d(function(e){e.target.closest("[data-edge-hit]")||e.target.closest("[data-node]")||($(!0),nn.current={x:e.clientX,y:e.clientY},en.current=n({},U),e.currentTarget.style.cursor="grabbing")},[U]),xn=d(function(n){Z&&G({x:en.current.x+(n.clientX-nn.current.x),y:en.current.y+(n.clientY-nn.current.y)})},[Z]),mn=d(function(){$(!1),T.current&&(T.current.style.cursor="grab")},[]);var wn=function(n,e){return"string"==typeof n?n:e},Mn=null!==(k=null!==(w=null===(m=null==L?void 0:L.root)||void 0===m?void 0:m.backgroundColor)&&void 0!==w?w:null===(M=null==L?void 0:L.root)||void 0===M?void 0:M.background)&&void 0!==k?k:P?"#090d16":"#ffffff",kn=null!==(C=null===(S=null==L?void 0:L.root)||void 0===S?void 0:S.color)&&void 0!==C?C:P?"#f8fafc":"#1e293b",Sn=null!==(A=null===(_=null==L?void 0:L.subtitle)||void 0===_?void 0:_.color)&&void 0!==A?A:"#94a3b8",Cn=n({width:32,height:32,border:"none",background:"transparent",borderRadius:8,cursor:"pointer",fontSize:16,color:P?"#cbd5e1":"#475569",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:500},null==L?void 0:L.controlButton);return X&&O?t("div",n({style:n({width:D,height:Y,position:"relative",background:Mn,color:kn,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",overflow:"hidden"},null==L?void 0:L.root)},{children:[t("div",n({style:n({position:"absolute",top:0,left:0,right:0,zIndex:20,padding:"10px 14px",display:"flex",alignItems:"center",justifyContent:"space-between"},null==L?void 0:L.header)},{children:[r("p",n({style:n({margin:0,fontSize:12,color:Sn},null==L?void 0:L.subtitle)},{children:"· Click a node or connection to explore details."})),t("div",n({style:n({display:"flex",gap:2,background:P?"#1e293b":"#fff",borderRadius:10,padding:3,boxShadow:P?"0 1px 4px rgba(0,0,0,0.4)":"0 1px 4px rgba(0,0,0,0.08)"},null==L?void 0:L.controls)},{children:[r("button",n({onClick:function(){return K(function(n){return Math.max(.2,n-.15)})},style:Cn},{children:"−"})),t("button",n({onClick:function(){K(.5),G({x:0,y:0})},style:n(n({},Cn),{fontSize:11,width:52,fontWeight:600})},{children:[Math.round(100*J),"%"]})),r("button",n({onClick:function(){return K(function(n){return Math.min(2.5,n+.15)})},style:Cn},{children:"+"}))]}))]})),an&&function(){var e,o,i=an.node,l=null!==(e=N[i.cluster_id])&&void 0!==e?e:0;return t("div",n({style:n({position:"absolute",top:50,left:14,zIndex:20,width:"30%",minWidth:280,borderRadius:12,overflow:"hidden",boxShadow:"0 2px 12px rgba(0,0,0,0.07)",border:"1px solid ".concat(P?"#334155":"#e2e8f0"),animation:"cdg-slideDown 0.2s ease-out"},null==L?void 0:L.nodePopup)},{children:[t("div",n({style:n({padding:"10px 14px",background:h[l%h.length],color:"#fff",display:"flex",alignItems:"center",justifyContent:"space-between"},null==L?void 0:L.nodePopupHeader)},{children:[t("div",n({style:{display:"flex",alignItems:"center",gap:10}},{children:[r("span",n({style:{width:28,height:28,borderRadius:8,background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14}},{children:p[l%p.length]})),t("div",{children:[r("div",n({style:{fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",opacity:.75}},{children:(null===(o=O.clusters[l])||void 0===o?void 0:o.label)||""})),r("div",n({style:{fontSize:14,fontWeight:700,marginTop:1}},{children:i.label}))]})]})),r("button",n({onClick:function(){dn(null),pn(null)},style:n({background:"rgba(255,255,255,0.2)",border:"none",color:"#fff",borderRadius:6,width:24,height:24,cursor:"pointer",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center"},null==L?void 0:L.popupCloseButton)},{children:"×"}))]})),r("div",n({style:n({padding:"10px 14px",fontSize:13,lineHeight:1.6,color:P?"#cbd5e1":"#475569",background:P?"#1e293b":"#fff"},null==L?void 0:L.nodePopupBody)},{children:i.description||"No description available."}))]}))}(),t("div",n({ref:T,onPointerDown:bn,onPointerMove:xn,onPointerUp:mn,onPointerLeave:mn,onClick:function(){on(null),dn(null),pn(null)},style:{width:"100%",height:"100%",cursor:Z?"grabbing":"grab",position:"relative"}},{children:[r("div",n({style:{transform:"translate(".concat(U.x,"px,").concat(U.y,"px) scale(").concat(J,")"),transformOrigin:"top left",position:"absolute",top:50,left:20,transition:Z?"none":"transform 0.08s ease-out"}},{children:t("svg",n({width:X.canvasW,height:X.canvasH,style:{overflow:"visible"}},{children:[X.clusterBounds.map(function(e){var o,i,l,a,d,c,u;return t("g",{children:[r("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:"16",fill:wn(null!==(i=null===(o=null==L?void 0:L.cluster)||void 0===o?void 0:o.backgroundColor)&&void 0!==i?i:null===(l=null==L?void 0:L.cluster)||void 0===l?void 0:l.background,P?"rgba(30,41,59,0.35)":"none"),stroke:wn(null!==(d=null===(a=null==L?void 0:L.cluster)||void 0===a?void 0:a.borderColor)&&void 0!==d?d:null===(c=null==L?void 0:L.cluster)||void 0===c?void 0:c.border,P?"#334155":"#e2e8f0"),strokeWidth:"1.5",strokeDasharray:"8 4"}),r("text",n({x:e.x+14,y:e.y+e.height-10,fontSize:"11",fill:wn(null===(u=null==L?void 0:L.clusterLabel)||void 0===u?void 0:u.color,"#94a3b8"),fontFamily:"Inter, sans-serif",fontWeight:"500"},{children:e.label}))]},e.id)}),X.edges.map(function(e){var i,l,a,d,c,u,s,f,v,p,g,h,y,b,m,w,M,k,S=x(e,H,X.edges);if(!S)return null;var C=gn.has(e.id),_=(null==rn?void 0:rn.edge.id)===e.id,A=un===e.id,z=!!vn&&!C,E=C||_?null!==(d=null!==(l=null===(i=null==L?void 0:L.activeEdge)||void 0===i?void 0:i.color)&&void 0!==l?l:null===(a=null==L?void 0:L.activeEdge)||void 0===a?void 0:a.borderColor)&&void 0!==d?d:"#6366f1":A?null!==(u=null===(c=null==L?void 0:L.edge)||void 0===c?void 0:c.color)&&void 0!==u?u:"#818cf8":null!==(p=null!==(f=null===(s=null==L?void 0:L.edge)||void 0===s?void 0:s.borderColor)&&void 0!==f?f:null===(v=null==L?void 0:L.edge)||void 0===v?void 0:v.color)&&void 0!==p?p:P?"#475569":"#cbd5e1",I=C||_?2.5:A?2:1.5;return t("g",n({style:{opacity:z?.1:1,transition:"opacity 0.25s"}},{children:[r("path",{"data-edge-hit":"true",d:S,fill:"none",stroke:"transparent",strokeWidth:18,style:{cursor:"pointer"},onClick:function(n){return function(n,e){n.stopPropagation();var t=T.current.getBoundingClientRect();on({edge:e,screenX:n.clientX-t.left,screenY:n.clientY-t.top}),dn(null),pn(null)}(n,e)},onMouseEnter:function(){return sn(e.id)},onMouseLeave:function(){return sn(null)}}),r("path",{d:S,fill:"none",stroke:E,strokeWidth:I,style:{transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),(C||_)&&t(o,{children:[r("circle",n({r:4,fill:null!==(b=null!==(h=null===(g=null==L?void 0:L.edgeMarker)||void 0===g?void 0:g.color)&&void 0!==h?h:null===(y=null==L?void 0:L.activeEdge)||void 0===y?void 0:y.color)&&void 0!==b?b:"#6366f1"},{children:r("animateMotion",{dur:"1.8s",repeatCount:"indefinite",path:S})})),r("circle",n({r:6,fill:null!==(k=null!==(w=null===(m=null==L?void 0:L.edgeMarker)||void 0===m?void 0:m.color)&&void 0!==w?w:null===(M=null==L?void 0:L.activeEdge)||void 0===M?void 0:M.color)&&void 0!==k?k:"#6366f1",opacity:.2},{children:r("animateMotion",{dur:"1.8s",repeatCount:"indefinite",path:S})}))]})]}),e.id)}),X.nodes.map(function(e){var o,i,l,a,d,c,h,y,b,x,m,w,M,k,S,C,_,A=vn===e.id,z=hn.has(e.id),E=!!vn&&!z,I=(null!==(o=N[e.cluster_id])&&void 0!==o?o:0)%g.length,j=g[I];return r("g",n({"data-node":"true",onClick:function(n){return function(n,e){n.stopPropagation();var t=T.current.getBoundingClientRect();vn===e.id?(pn(null),dn(null)):(pn(e.id),dn({node:e,screenX:n.clientX-t.left,screenY:n.clientY-t.top}),on(null))}(n,e)},style:{cursor:"pointer",opacity:E?.15:1,transition:"opacity 0.25s"}},{children:r("foreignObject",n({x:e.x,y:e.y,width:u,height:s},{children:t("div",n({style:n(n({background:null!==(d=null!==(l=null===(i=null==L?void 0:L.node)||void 0===i?void 0:i.backgroundColor)&&void 0!==l?l:null===(a=null==L?void 0:L.node)||void 0===a?void 0:a.background)&&void 0!==d?d:P?"#1e293b":"#fff",border:A?null!==(h=null===(c=null==L?void 0:L.selectedNode)||void 0===c?void 0:c.border)&&void 0!==h?h:"2.5px solid ".concat(null!==(b=null===(y=null==L?void 0:L.selectedNode)||void 0===y?void 0:y.borderColor)&&void 0!==b?b:j):null!==(m=null===(x=null==L?void 0:L.node)||void 0===x?void 0:x.border)&&void 0!==m?m:"1.5px solid ".concat(null!==(M=null===(w=null==L?void 0:L.node)||void 0===w?void 0:w.borderColor)&&void 0!==M?M:P?"#334155":"#e2e8f0"),borderRadius:10,padding:"8px 14px",fontSize:13,fontWeight:600,color:P?"#f1f5f9":"#334155",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:8,boxShadow:A?null!==(S=null===(k=null==L?void 0:L.selectedNode)||void 0===k?void 0:k.boxShadow)&&void 0!==S?S:"0 0 0 3px ".concat(j,"33, 0 2px 8px rgba(0,0,0,0.4)"):null!==(_=null===(C=null==L?void 0:L.node)||void 0===C?void 0:C.boxShadow)&&void 0!==_?_:P?"0 2px 6px rgba(0,0,0,0.3)":"0 1px 3px rgba(0,0,0,0.05)",whiteSpace:"nowrap",userSelect:"none",height:46,boxSizing:"border-box",transition:"border 0.2s, box-shadow 0.2s"},null==L?void 0:L.node),A?null==L?void 0:L.selectedNode:{})},{children:[r("span",n({style:n({width:22,height:22,borderRadius:6,background:f[I],display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,flexShrink:0,color:v[I]},null==L?void 0:L.nodeIcon)},{children:p[I]})),r("span",n({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:e.label}))]}))}))}),e.id)})]}))})),rn&&t("div",n({onClick:function(n){return n.stopPropagation()},style:n(n(n({position:"absolute"},function(n,e,t,r){if(!T.current)return{};var o=T.current.getBoundingClientRect(),i=n+14,l=e-r/2;return i+t>o.width&&(i=n-t-14),l<8&&(l=8),l+r>o.height&&(l=o.height-r-8),{left:i,top:l}}(rn.screenX,rn.screenY,320,180)),{width:320,background:P?"#1e293b":"#fff",borderRadius:14,boxShadow:"0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06)",border:"1px solid ".concat(P?"#334155":"#e2e8f0"),zIndex:30,animation:"cdg-popIn 0.18s ease-out",overflow:"hidden"}),null==L?void 0:L.edgePopup)},{children:[t("div",n({style:n({padding:"12px 16px 10px",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",color:"#fff"},null==L?void 0:L.edgePopupHeader)},{children:[r("div",n({style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",opacity:.8}},{children:"Edge Reasoning"})),t("div",n({style:{fontSize:13,fontWeight:600,marginTop:4}},{children:[null!==(E=null===(z=H[rn.edge.source])||void 0===z?void 0:z.label)&&void 0!==E?E:"Source",r("span",n({style:{opacity:.6,margin:"0 6px"}},{children:"→"})),null!==(j=null===(I=H[rn.edge.target])||void 0===I?void 0:I.label)&&void 0!==j?j:"Target"]}))]})),r("div",n({style:n({padding:"12px 16px 14px",fontSize:13,lineHeight:1.6,color:P?"#cbd5e1":"#475569",whiteSpace:"pre-line"},null==L?void 0:L.edgePopupBody)},{children:rn.edge.reasoning||"No reasoning available."})),r("button",n({onClick:function(){return on(null)},style:n({position:"absolute",top:8,right:10,background:"rgba(255,255,255,0.2)",border:"none",color:"#fff",borderRadius:6,width:24,height:24,cursor:"pointer",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center"},null==L?void 0:L.popupCloseButton)},{children:"×"}))]}))]})),r("style",{children:"\n @keyframes cdg-popIn { from { opacity:0; transform:scale(0.95) translateY(4px); } to { opacity:1; transform:scale(1) translateY(0); } }\n @keyframes cdg-slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }\n "})]})):null};export{m as default};
|
|
2
|
+
//# sourceMappingURL=CitationDependencyGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CitationDependencyGraph.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as o}from"tslib";import{jsx as e,jsxs as n,Fragment as l}from"react/jsx-runtime";import i,{useState as t,useRef as r,useEffect as d}from"react";import a from"@mui/material/Dialog";import s from"@mui/material/DialogContent";import p from"@mui/material/IconButton";import{InfoOutlined as c,Close as u}from"@mui/icons-material";import f from"@mui/material/Accordion";import v from"@mui/material/AccordionSummary";import h from"@mui/material/AccordionDetails";import m from"@mui/icons-material/ExpandMore";import g from"./_components/CodeEditor.js";import{themeManager as y}from"../../utils/themeManager.js";import{MarkdownRenderer as x}from"./_components/Markdownrenderer.js";import b from"@mui/material/Tooltip";import k from"../SPBAnalysisPanel/DependencyGraph.js";function w(e){if(!e||"object"!=typeof e)return null;var n=["Context & Inputs","Core Logic & Rules","Outputs & Schema"];if(Array.isArray(e.nodes)&&Array.isArray(e.edges)){var l=e.nodes,i=Array.isArray(e.clusters)&&e.clusters.length>0?e.clusters:null,t=new Set(l.map(function(o){return o.cluster_id}));if(!i||t.size<=1){var r=Math.max(1,Math.min(3,Math.ceil(l.length/3)));i=Array.from({length:r},function(o,e){return{id:"cl_".concat(e+1),label:n[e]||"Group ".concat(e+1)}}),l=l.map(function(e,n){var l=n%r,d=Math.floor(n/r);return o(o({},e),{cluster_id:i[l].id,x:e.x&&t.size>1?e.x:450*l+200,y:e.y&&t.size>1?e.y:180*d+100})})}return{graph_id:e.graph_id||"spb_graph",prompt_id:e.prompt_id||"",last_analyzed_at:e.last_analyzed_at||(new Date).toISOString(),clusters:i,nodes:l,edges:e.edges}}var d=Object.keys(e);if(0===d.length)return null;var a=d.length,s=Math.max(1,Math.min(3,Math.ceil(a/3))),p=Array.from({length:s},function(o,e){return{id:"cl_".concat(e+1),label:n[e]||"Group ".concat(e+1)}}),c=[],u=[];return d.forEach(function(o,n){var l=n%s,i=Math.floor(n/s),t=p[l].id,r=450*l+200,d=180*i+100,a=o.split("_").map(function(o){return o.charAt(0).toUpperCase()+o.slice(1)}).join(" "),f="node_".concat(o);c.push({id:f,label:a,cluster_id:t,x:r,y:d,description:"Section: ".concat(a)});var v=e[o];Array.isArray(v)&&v.forEach(function(e,n){var l;if(e&&"object"==typeof e){var i=e.dependent_on;if(i){var t="node_".concat(i),r="";"string"==typeof e.reasoning?r=e.reasoning:Array.isArray(e.reasoning)?r=e.reasoning.map(function(o){return"string"==typeof o?o:(null==o?void 0:o.text)||""}).filter(Boolean).join(" "):(null===(l=e.reasoning)||void 0===l?void 0:l.text)&&(r=String(e.reasoning.text)),u.push({id:"e_".concat(o,"_").concat(i,"_").concat(n),source:f,target:t,reasoning:r||"Depends on ".concat(i),score:"number"==typeof e.Score?e.Score:"number"==typeof e.score?e.score:80,gap:e.gap||"",dependency_type:e.dependency_type||"implicit"})}}})}),0===c.length?null:{graph_id:"spb_converted_graph",prompt_id:"",last_analyzed_at:(new Date).toISOString(),clusters:p,nodes:c,edges:u}}var S=function(n){var l=n.children,i=n.style;return e("div",o({style:o({fontWeight:"700",fontSize:"0.9rem",color:"#1a1a1a",marginBottom:"0.6rem",fontFamily:"Plus Jakarta Sans, sans-serif"},i)},{children:l}))},C=function(C){var I,A,T,F,P,W,_,B,z,L,H,D,R,J,M,j,E,G,N,O,q,V,U,Y,Z,K,Q,X,$,oo,eo,no,lo,io,to,ro,ao,so,po,co,uo,fo,vo,ho,mo,go,yo,xo,bo,ko,wo,So,Co,Io,Ao,To,Fo,Po,Wo,_o,Bo,zo,Lo,Ho,Do,Ro,Jo,Mo,jo,Eo,Go,No,Oo;C.prompt_title;var qo=C.modename,Vo=C.description,Uo=C.customMetaData;C.chevronUpComponent,C.chevronDownComponent,C.editorHeight,C.editorWidth;var Yo=C.isDarkModeEnabled,Zo=void 0===Yo||Yo,Ko=C.isDarkMode,Qo=C.startLine,Xo=void 0===Qo?8:Qo,$o=C.endLine,oe=void 0===$o?12:$o,ee=C.constraints_and_rules,ne=C.input_analysis,le=C.output_analysis;C.extraMetaData;var ie=C.showEditor,te=void 0===ie||ie,re=C.alwaysFullscreen,de=void 0!==re&&re,ae=C.renderAsComponent,se=void 0!==ae&&ae,pe=C.isFpb,ce=void 0===pe||pe,ue=C.isSpb,fe=void 0!==ue&&ue,ve=C.spbFunctionality,he=C.showDependencyIcon,me=void 0!==he&&he,ge=C.onDependencyGraphOpen,ye=C.onSectionClick,xe=C.categoryFields,be=C.total_apbs,ke=C.titleText,we=C.titleIcon,Se=C.dependencyGraphIcon,Ce=C.dependencyGraphArrowIcon,Ie=C.whenToApplyIcon,Ae=C.whenToApplyExpandIcon,Te=C.whenNotToApplyIcon,Fe=C.whenNotToApplyExpandIcon,Pe=C.specificationsIcon,We=C.specificationsInfoIcon,_e=C.specificationsExpandIcon,Be=C.styles,ze=C.defaultAccordionsExpanded,Le=void 0===ze||ze,He=C.defaultWhenToApplyExpanded,De=C.defaultWhenNotToApplyExpanded,Re=C.defaultSpecificationsExpanded,Je=C.defaultSpbFunctionalityExpanded,Me=null!==(I=null!=Ko?Ko:null==Be?void 0:Be.isDarkMode)&&void 0!==I?I:Zo,je=t(!1),Ee=je[0];je[1];var Ge=t(!1),Ne=Ge[0],Oe=Ge[1],qe=t(!1),Ve=qe[0],Ue=qe[1],Ye=r(null),Ze=t(de),Ke=Ze[0],Qe=Ze[1],Xe=t(!1),$e=Xe[0],on=Xe[1],en=t({startIndex:-1,endIndex:-1}),nn=en[0],ln=en[1],tn=t({}),rn=tn[0],dn=tn[1],an=t(function(){return y.getTheme(Me)}),sn=an[0],pn=an[1];d(function(){return y.subscribe(pn)},[]);var cn=null!==(A=null!=ke?ke:null==Uo?void 0:Uo.title)&&void 0!==A?A:"Untitled Prompt",un=(null==Uo?void 0:Uo.description)||Vo,fn=null==Uo?void 0:Uo.prompt,vn=(null==Uo?void 0:Uo.modename)||qo||"";null==Uo||Uo.citation_number;var hn=fn.split("\n").length;null!=be||(null===(T=null==Uo?void 0:Uo.sections)||void 0===T||T.length);var mn={startIndex:Xo,endIndex:oe},gn=[{label:"Strict Rules",content:ee},{label:"Input",content:ne},{label:"Output",content:le}].filter(function(o){return o.content}),yn=gn.length>0,xn=null!=He?He:Le,bn=null!=De?De:Le,kn=null!=Re?Re:Le,wn=null!=Je?Je:Le,Sn=function(e,n,l){var i,t,r,d,a,s;return{tooltip:{style:o(o({backgroundColor:l,color:"#ffffff",fontFamily:"Plus Jakarta Sans, sans-serif"},null==Be?void 0:Be.tooltip),e)},arrow:{style:o(o({color:null!==(s=null!==(d=null!==(t=null!==(i=null==n?void 0:n.color)&&void 0!==i?i:null==e?void 0:e.backgroundColor)&&void 0!==t?t:null===(r=null==Be?void 0:Be.tooltipArrow)||void 0===r?void 0:r.color)&&void 0!==d?d:null===(a=null==Be?void 0:Be.tooltip)||void 0===a?void 0:a.backgroundColor)&&void 0!==s?s:l},null==Be?void 0:Be.tooltipArrow),n)}}},Cn=e("div",o({style:o(o({display:"flex",gap:"2.5rem",borderTop:"1px solid #ebebeb",marginTop:"1rem",paddingTop:"1rem",fontSize:"0.875rem",fontWeight:"600",color:sn?"#e2e8f0":"#333",fontFamily:"Plus Jakarta Sans, sans-serif"},null==Be?void 0:Be.footer),null==Be?void 0:Be.previewStats)},{children:n("span",o({style:null==Be?void 0:Be.previewStatsItem},{children:["Total Lines: ",hn]}))}));d(function(){var o=Ye.current;o&&Ue(o.scrollHeight>o.clientHeight)},[un]);var In=function(){Qe(!1)},An=e(g,{startIndex:mn.startIndex,endIndex:mn.endIndex,language:"xml",editorHeight:"100%",editorWidth:"100%",code:fn,isHighlightingEnabled:!0,isDarkModeEnabled:sn,highlightCodeStatsLine:nn,setHighlightCodeStatsLine:ln,highlightCodeStatsVariable:rn,setHighlightCodeStatsVariable:dn,isExpanded:Ee||Ke,highlightIndexes:mn}),Tn=n(l,{children:[n("div",o({style:o({width:te?"50%":"100%",padding:"2rem 2.25rem",display:"flex",flexDirection:"column",overflowY:"auto",borderRight:te?"1px solid #ebebeb":"none",boxSizing:"border-box"},null==Be?void 0:Be.leftPanel)},{children:[n("div",o({style:{marginBottom:"1.25rem",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"nowrap"}},{children:[e(b,o({title:e("span",o({style:o(o({},null==Be?void 0:Be.tooltipContent),null==Be?void 0:Be.titleTooltipContent)},{children:cn})),placement:"top",arrow:!0,componentsProps:Sn(o({fontSize:"0.75rem",maxWidth:320,padding:"6px 10px"},null==Be?void 0:Be.titleTooltip),null==Be?void 0:Be.titleTooltipArrow,sn?"#21262d":"#1a1a1a")},{children:n("span",o({style:o({fontWeight:"700",fontSize:"1.05rem",color:sn?"#ffffff":"#1a1a1a",fontFamily:"Plus Jakarta Sans, sans-serif",lineHeight:1.4,display:"flex",alignItems:"center",gap:"6px",minWidth:0,flexShrink:1},null==Be?void 0:Be.title)},{children:[null!=we?we:n("svg",o({width:null!==(P=null===(F=null==Be?void 0:Be.titleIcon)||void 0===F?void 0:F.width)&&void 0!==P?P:16,height:null!==(_=null===(W=null==Be?void 0:Be.titleIcon)||void 0===W?void 0:W.height)&&void 0!==_?_:16,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{color:null!==(z=null===(B=null==Be?void 0:Be.titleIcon)||void 0===B?void 0:B.color)&&void 0!==z?z:sn?"#ffffff":"#1a1a1a",flexShrink:0}},{children:[e("path",{d:"M4 6C4 4.895 4.895 4 6 4H14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e("path",{d:"M4 6V18C4 19.105 4.895 20 6 20H18C19.105 20 20 19.105 20 18V10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e("line",{x1:"8",y1:"10",x2:"14",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e("line",{x1:"8",y1:"13",x2:"11",y2:"13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e("line",{x1:"13",y1:"13",x2:"16",y2:"13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e("line",{x1:"8",y1:"16",x2:"14",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e("path",{d:"M19 1 L19.9 3.6 L22.5 4.5 L19.9 5.4 L19 8 L18.1 5.4 L15.5 4.5 L18.1 3.6 Z",fill:"currentColor"})]})),e("span",o({style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:cn.length>28?"".concat(cn.slice(0,28),".."):cn}))]}))})),ce&&!fe&&n("span",o({style:{display:"inline-flex",alignItems:"center",gap:"4px",background:null!==(H=null===(L=null==Be?void 0:Be.fpbBadge)||void 0===L?void 0:L.backgroundColor)&&void 0!==H?H:sn?"#e2e8f0":"#1a1a1a",borderRadius:"5px",padding:"2px 8px",fontSize:"0.72rem",fontWeight:"700",color:null!==(R=null===(D=null==Be?void 0:Be.fpbBadge)||void 0===D?void 0:D.color)&&void 0!==R?R:sn?"#0d1117":"#ffffff",letterSpacing:"0.08em",fontFamily:"Plus Jakarta Sans, sans-serif",textTransform:"uppercase",flexShrink:0}},{children:["FPB",e(b,o({title:n("span",o({style:o(o({fontSize:"0.7rem",lineHeight:1.5,fontFamily:"Plus Jakarta Sans, sans-serif",color:null!==(M=null===(J=null==Be?void 0:Be.fpbTooltip)||void 0===J?void 0:J.color)&&void 0!==M?M:"#ffffff"},null==Be?void 0:Be.tooltipContent),null==Be?void 0:Be.fpbTooltipContent)},{children:[e("strong",{children:"FPB (Functional Prompt Block):"})," A group of related prompt sections designed to perform a specific function or capability within the overall system prompt."]})),placement:"top",arrow:!0,componentsProps:Sn(o({maxWidth:280,padding:"8px 12px"},null==Be?void 0:Be.fpbTooltip),null==Be?void 0:Be.fpbTooltipArrow,"#1a1a1a")},{children:e(c,{style:{fontSize:"0.85rem",color:null!==(j=null==Be?void 0:Be.fpbInfoIconColor)&&void 0!==j?j:sn?"#1a1a1acc":"#ffffffcc",cursor:"default"}})}))]})),fe&&n("span",o({style:{display:"inline-flex",alignItems:"center",gap:"4px",background:null!==(G=null===(E=null==Be?void 0:Be.spbBadge)||void 0===E?void 0:E.backgroundColor)&&void 0!==G?G:sn?"#e2e8f0":"#1a1a1a",borderRadius:"5px",padding:"2px 8px",fontSize:"0.72rem",fontWeight:"700",color:null!==(O=null===(N=null==Be?void 0:Be.spbBadge)||void 0===N?void 0:N.color)&&void 0!==O?O:sn?"#0d1117":"#ffffff",letterSpacing:"0.08em",fontFamily:"Plus Jakarta Sans, sans-serif",textTransform:"uppercase",flexShrink:0}},{children:["SPB",e(b,o({title:n("span",o({style:o(o({fontSize:"0.7rem",lineHeight:1.5,fontFamily:"Plus Jakarta Sans, sans-serif",color:null!==(V=null===(q=null==Be?void 0:Be.spbTooltip)||void 0===q?void 0:q.color)&&void 0!==V?V:"#ffffff"},null==Be?void 0:Be.tooltipContent),null==Be?void 0:Be.spbTooltipContent)},{children:[e("strong",{children:"SPB (Shippable Prompt Block) :"})," is a complete system-level prompt that defines the overall behavior, instructions, guidelines, and context an AI system should follow when responding to users."]})),placement:"top",arrow:!0,componentsProps:Sn(o({maxWidth:280,padding:"8px 12px"},null==Be?void 0:Be.spbTooltip),null==Be?void 0:Be.spbTooltipArrow,"#1a1a1a")},{children:e(c,{style:{fontSize:"0.85rem",color:null!==(U=null==Be?void 0:Be.spbInfoIconColor)&&void 0!==U?U:sn?"#1a1a1acc":"#ffffffcc",cursor:"default"}})}))]})),vn&&e("span",o({style:{fontSize:"0.72rem",color:"#666",background:"#f0f0f0",borderRadius:"4px",padding:"1px 6px"}},{children:vn})),me&&e("div",{style:{flex:1}}),me&&e(b,o({title:e("span",o({style:o(o({fontSize:"0.7rem",fontFamily:"Plus Jakarta Sans, sans-serif"},null==Be?void 0:Be.tooltipContent),null==Be?void 0:Be.dependencyGraphTooltipContent)},{children:"Open dependency graph"})),placement:"top",arrow:!0,componentsProps:Sn(o({padding:"5px 10px"},null==Be?void 0:Be.dependencyGraphTooltip),null==Be?void 0:Be.dependencyGraphTooltipArrow,sn?"#21262d":"#1a1a1a")},{children:n("button",o({onClick:function(o){o.stopPropagation(),null==ge||ge("show dependency graph")},style:o({display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px 4px 8px",borderRadius:"8px",border:"1px solid ".concat(sn?"#30363d":"#d0d7de"),background:sn?"#21262d":"#f6f8fa",color:sn?"#e2e8f0":"#24292f",fontSize:"0.78rem",fontWeight:"600",fontFamily:"Plus Jakarta Sans, sans-serif",cursor:"pointer",flexShrink:0,whiteSpace:"nowrap"},null==Be?void 0:Be.dependencyGraphButton)},{children:[null!=Se?Se:n("svg",o({xmlns:"http://www.w3.org/2000/svg",width:"12px",height:"12px",viewBox:"0 0 48 48",fill:"none"},{children:[e("path",{d:"M24 33V15",stroke:null!==(Y=null==Be?void 0:Be.dependencyGraphIconStroke)&&void 0!==Y?Y:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),e("rect",{x:"10",y:"9",width:"28",height:"6",fill:null!==(Z=null==Be?void 0:Be.dependencyGraphIconFill)&&void 0!==Z?Z:"#2F88FF",stroke:null!==(K=null==Be?void 0:Be.dependencyGraphIconStroke)&&void 0!==K?K:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M8 32L14 25H33.9743L40 32",stroke:null!==(Q=null==Be?void 0:Be.dependencyGraphIconStroke)&&void 0!==Q?Q:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),e("rect",{x:"4",y:"33",width:"8",height:"8",fill:null!==(X=null==Be?void 0:Be.dependencyGraphIconFill)&&void 0!==X?X:"#2F88FF",stroke:null!==($=null==Be?void 0:Be.dependencyGraphIconStroke)&&void 0!==$?$:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),e("rect",{x:"20",y:"33",width:"8",height:"8",fill:null!==(oo=null==Be?void 0:Be.dependencyGraphIconFill)&&void 0!==oo?oo:"#2F88FF",stroke:null!==(eo=null==Be?void 0:Be.dependencyGraphIconStroke)&&void 0!==eo?eo:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),e("rect",{x:"36",y:"33",width:"8",height:"8",fill:null!==(no=null==Be?void 0:Be.dependencyGraphIconFill)&&void 0!==no?no:"#2F88FF",stroke:null!==(lo=null==Be?void 0:Be.dependencyGraphIconStroke)&&void 0!==lo?lo:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})),"Graph",null!=Ce?Ce:n("svg",o({width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},{children:[e("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),e("polyline",{points:"12 5 19 12 12 19"})]}))]}))}))]})),un&&n("div",o({style:{border:"1px solid ".concat(null!==(to=null===(io=null==Be?void 0:Be.descriptionCard)||void 0===io?void 0:io.borderColor)&&void 0!==to?to:"transparent"),borderRadius:null!==(ao=null===(ro=null==Be?void 0:Be.descriptionCard)||void 0===ro?void 0:ro.borderRadius)&&void 0!==ao?ao:"8px",padding:null!==(po=null===(so=null==Be?void 0:Be.descriptionCard)||void 0===so?void 0:so.padding)&&void 0!==po?po:"14px 16px",backgroundColor:null!==(uo=null===(co=null==Be?void 0:Be.descriptionCard)||void 0===co?void 0:co.backgroundColor)&&void 0!==uo?uo:"transparent",marginBottom:"1.5rem"}},{children:[e("div",o({style:o({fontWeight:"700",fontSize:"0.95rem",fontFamily:"Plus Jakarta Sans, sans-serif",marginBottom:"8px",color:sn?"#ffffff":"#111827"},null==Be?void 0:Be.descriptionHeading)},{children:"Prompt Overview"})),n("div",o({style:{position:"relative"}},{children:[e("p",o({ref:Ye,style:o({fontSize:"0.875rem",lineHeight:"1.7",margin:0,fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#c9d1d9":"#444",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:Ne?"unset":4,overflow:Ne?"visible":"hidden"},null==Be?void 0:Be.description)},{children:un})),Ve&&!Ne&&e("button",o({onClick:function(){return Oe(!0)},style:o({position:"absolute",bottom:0,right:0,background:"linear-gradient(to right, transparent, ".concat(sn?"#0d1117":"#ffffff"," 40%)"),border:"none",paddingLeft:"2rem",paddingRight:0,cursor:"pointer",fontSize:"0.875rem",fontWeight:"600",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#7dd3fc":"#2563eb",lineHeight:"1.7"},null==Be?void 0:Be.descriptionMoreButton)},{children:"...more"})),Ne&&e("button",o({onClick:function(){return Oe(!1)},style:o({background:"none",border:"none",padding:"2px 0 0",cursor:"pointer",fontSize:"0.875rem",fontWeight:"600",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#7dd3fc":"#2563eb",display:"block"},null==Be?void 0:Be.descriptionLessButton)},{children:"less"}))]}))]})),xe&&xe.length>0&&e("div",o({style:o({display:"flex",flexWrap:"wrap",borderTop:"1px solid ".concat(sn?"#ffffff18":"#1a1a1a18"),borderBottom:"1px solid ".concat(sn?"#ffffff18":"#1a1a1a18"),marginBottom:"1.5rem"},null==Be?void 0:Be.categoryRow)},{children:xe.map(function(l,t){return n(i.Fragment,{children:[t>0&&e("div",{style:o({width:"1px",alignSelf:"stretch",background:sn?"#ffffff18":"#1a1a1a18"},null==Be?void 0:Be.categoryDivider)}),n("div",o({style:o({flex:"1 1 120px",padding:"12px 16px"},null==Be?void 0:Be.categoryItem)},{children:[e("div",o({style:o({fontSize:"0.72rem",fontWeight:"500",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#8b949e":"#6b7280",marginBottom:"4px"},null==Be?void 0:Be.categoryLabel)},{children:l.label})),e("div",o({style:o({fontSize:"0.875rem",fontWeight:"600",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#e2e8f0":"#111827"},null==Be?void 0:Be.categoryValue)},{children:l.value}))]}))]},t)})})),""!==(null==Uo?void 0:Uo.when_to_apply)&&n(f,o({defaultExpanded:xn,style:o({marginBottom:"1rem",border:"1px solid ".concat(null!==(vo=null===(fo=null==Be?void 0:Be.whenToApplyAccordion)||void 0===fo?void 0:fo.borderColor)&&void 0!==vo?vo:sn?"#ffffff18":"#1a1a1a18"),borderRadius:"28px !important",boxShadow:"none",background:"transparent"},null==Be?void 0:Be.whenToApplyAccordion)},{children:[e(v,o({expandIcon:null!=Ae?Ae:e(m,{style:{color:null!==(ho=null==Be?void 0:Be.whenAccordionChevronColor)&&void 0!==ho?ho:sn?"#e2e8f0":"#374151"}}),style:o({minHeight:"36px",padding:"0 12px",background:"transparent"},null==Be?void 0:Be.whenToApplyHeader)},{children:n("div",o({style:{display:"flex",alignItems:"center",gap:"10px"}},{children:[e("span",o({style:o({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",borderRadius:"50%",border:"1.5px solid ".concat(null!==(mo=null==Be?void 0:Be.whenToApplyIconColor)&&void 0!==mo?mo:"#4ade80"),flexShrink:0},null==Be?void 0:Be.whenToApplyIconCircle)},{children:null!=Ie?Ie:e("svg",o({xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24"},{children:e("g",o({id:"Complete"},{children:e("g",o({id:"tick"},{children:e("polyline",{fill:"none",points:"3.7 14.3 9.6 19 20.3 5",stroke:null!==(go=null==Be?void 0:Be.whenToApplyIconColor)&&void 0!==go?go:"#4ade80",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})}))}))}))})),e("span",o({style:o({fontWeight:"600",fontSize:"0.9rem",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#e2e8f0":"#111827"},null==Be?void 0:Be.whenToApplyTitle)},{children:"When to apply"}))]}))})),e(h,o({style:o({padding:"12px 16px",background:null!==(xo=null===(yo=null==Be?void 0:Be.whenToApplyContent)||void 0===yo?void 0:yo.backgroundColor)&&void 0!==xo?xo:sn?"#ffffff08":"#1a1a1a06"},null==Be?void 0:Be.whenToApplyContent)},{children:e(x,{message:null==Uo?void 0:Uo.when_to_apply,style:null==Be?void 0:Be.markdownRenderer,codeStyle:null==Be?void 0:Be.markdownCode,preStyle:null==Be?void 0:Be.markdownPre,blockquoteStyle:null==Be?void 0:Be.markdownBlockquote,syntaxHighlighterTheme:null==Be?void 0:Be.syntaxHighlighterTheme,cognitiveDecisioningStyles:null==Be?void 0:Be.cognitiveDecisioning})}))]})),""!==(null==Uo?void 0:Uo.when_not_to_apply)&&n(f,o({defaultExpanded:bn,style:o({marginBottom:"1rem",border:"1px solid ".concat(null!==(ko=null===(bo=null==Be?void 0:Be.whenNotToApplyAccordion)||void 0===bo?void 0:bo.borderColor)&&void 0!==ko?ko:sn?"#ffffff18":"#1a1a1a18"),borderRadius:"8px !important",boxShadow:"none",background:"transparent"},null==Be?void 0:Be.whenNotToApplyAccordion)},{children:[e(v,o({expandIcon:null!=Fe?Fe:e(m,{style:{color:null!==(wo=null==Be?void 0:Be.whenAccordionChevronColor)&&void 0!==wo?wo:sn?"#e2e8f0":"#374151"}}),style:o({minHeight:"36px",padding:"0 12px",background:"transparent"},null==Be?void 0:Be.whenNotToApplyHeader)},{children:n("div",o({style:{display:"flex",alignItems:"center",gap:"10px"}},{children:[e("span",o({style:o({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",borderRadius:"50%",border:"1.5px solid ".concat(null!==(So=null==Be?void 0:Be.whenNotToApplyIconColor)&&void 0!==So?So:"#f87171"),flexShrink:0},null==Be?void 0:Be.whenNotToApplyIconCircle)},{children:null!=Te?Te:e("svg",o({xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none"},{children:e("path",{d:"M19 5L5 19M5.00001 5L19 19",stroke:null!==(Co=null==Be?void 0:Be.whenNotToApplyIconColor)&&void 0!==Co?Co:"#f87171",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))})),e("span",o({style:o({fontWeight:"600",fontSize:"0.9rem",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#e2e8f0":"#111827"},null==Be?void 0:Be.whenNotToApplyTitle)},{children:"When not to apply"}))]}))})),e(h,o({style:o({padding:"12px 16px",background:null!==(Ao=null===(Io=null==Be?void 0:Be.whenNotToApplyContent)||void 0===Io?void 0:Io.backgroundColor)&&void 0!==Ao?Ao:sn?"#ffffff08":"#1a1a1a06"},null==Be?void 0:Be.whenNotToApplyContent)},{children:e(x,{message:null==Uo?void 0:Uo.when_not_to_apply,style:null==Be?void 0:Be.markdownRenderer,codeStyle:null==Be?void 0:Be.markdownCode,preStyle:null==Be?void 0:Be.markdownPre,blockquoteStyle:null==Be?void 0:Be.markdownBlockquote,syntaxHighlighterTheme:null==Be?void 0:Be.syntaxHighlighterTheme,cognitiveDecisioningStyles:null==Be?void 0:Be.cognitiveDecisioning})}))]})),yn&&n(f,o({defaultExpanded:kn,style:o({marginBottom:"1rem",border:"1px solid ".concat(null!==(Fo=null===(To=null==Be?void 0:Be.specificationsSection)||void 0===To?void 0:To.borderColor)&&void 0!==Fo?Fo:sn?"#ffffff18":"#1a1a1a18"),borderRadius:"8px",boxShadow:"none",background:"transparent"},null==Be?void 0:Be.specificationsSection)},{children:[e(v,o({expandIcon:null!=_e?_e:e(m,{style:{color:null!==(Po=null==Be?void 0:Be.specificationsExpandIconColor)&&void 0!==Po?Po:sn?"#e2e8f0":"#374151"}}),style:{minHeight:"36px",padding:"0 12px",background:"transparent"}},{children:n("div",o({style:{display:"flex",alignItems:"center",gap:"10px"}},{children:[e("span",o({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"5px",flexShrink:0}},{children:null!=Pe?Pe:n("svg",o({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"#ffffff"},{children:[e("rect",{x:"4.5",y:"3.5",width:"15",height:"17",rx:"1.5",stroke:"#ffffff","stroke-width":"1.7"}),e("path",{d:"M8 8H16",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"}),e("path",{d:"M8 11.5H16",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"}),e("path",{d:"M8 15H13.5",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})]}))})),e("span",o({style:o({fontWeight:"600",fontSize:"0.9rem",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#e2e8f0":"#111827"},null==Be?void 0:Be.specificationsTitle)},{children:"Specifications"})),e(b,o({title:n("span",o({style:o(o({fontSize:"0.7rem",lineHeight:1.5,fontFamily:"Plus Jakarta Sans, sans-serif",color:null!==(_o=null===(Wo=null==Be?void 0:Be.specificationsTooltip)||void 0===Wo?void 0:Wo.color)&&void 0!==_o?_o:"#ffffff"},null==Be?void 0:Be.tooltipContent),null==Be?void 0:Be.specificationsTooltipContent)},{children:[e("strong",{children:"Specifications:"})," Specifications are the details that define a prompt’s guidelines, expected inputs, expected outputs, and constraints or rules."]})),placement:"top",arrow:!0,componentsProps:Sn(o({maxWidth:280,padding:"8px 12px"},null==Be?void 0:Be.specificationsTooltip),null==Be?void 0:Be.specificationsTooltipArrow,"#1a1a1a")},{children:e("span",{children:null!=We?We:e(c,{style:{fontSize:"0.95rem",color:sn?"#aaaaaa":"#666666",cursor:"default"}})})}))]}))})),e(h,o({style:o({padding:"12px 16px",background:null!==(zo=null===(Bo=null==Be?void 0:Be.specificationsDetails)||void 0===Bo?void 0:Bo.backgroundColor)&&void 0!==zo?zo:sn?"#ffffff08":"#1a1a1a06",display:"flex",flexDirection:"column",gap:"12px"},null==Be?void 0:Be.specificationsDetails)},{children:gn.map(function(l){var i=l.label,t=l.content;return n("div",{children:[e("div",o({style:o({fontSize:"0.72rem",fontWeight:"700",color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"0.3rem",fontFamily:"Plus Jakarta Sans, sans-serif"},null==Be?void 0:Be.specificationsItemLabel)},{children:i})),e(x,{message:t,fontSize:"0.83rem",style:null==Be?void 0:Be.markdownRenderer,codeStyle:null==Be?void 0:Be.markdownCode,preStyle:null==Be?void 0:Be.markdownPre,blockquoteStyle:null==Be?void 0:Be.markdownBlockquote,syntaxHighlighterTheme:null==Be?void 0:Be.syntaxHighlighterTheme,cognitiveDecisioningStyles:null==Be?void 0:Be.cognitiveDecisioning})]},i)})}))]})),(null==Uo?void 0:Uo.sections)&&Uo.sections.length>0&&n("div",o({style:{marginBottom:"1.5rem",marginTop:"0.6rem"}},{children:[n("div",o({style:{display:"flex",alignItems:"center",gap:"5px",marginBottom:"0.6rem",marginTop:"0.4rem"}},{children:[e(S,o({style:o(o({},null==Be?void 0:Be.sectionLabel),{marginBottom:0})},{children:"APB's"})),e(b,o({title:n("span",o({style:o(o({fontSize:"0.7rem",lineHeight:1.5,fontFamily:"Plus Jakarta Sans, sans-serif",color:null!==(Ro=null!==(Ho=null===(Lo=null==Be?void 0:Be.apbTooltip)||void 0===Lo?void 0:Lo.color)&&void 0!==Ho?Ho:null===(Do=null==Be?void 0:Be.fpbTooltip)||void 0===Do?void 0:Do.color)&&void 0!==Ro?Ro:"#ffffff"},null==Be?void 0:Be.tooltipContent),null==Be?void 0:Be.apbTooltipContent)},{children:[e("strong",{children:"APB (Atomic Prompt Block):"})," A self-contained prompt unit that handles one specific instruction, rule, or behavior within a Functional Prompt Block."]})),placement:"top",arrow:!0,componentsProps:Sn(o({maxWidth:280,padding:"8px 12px"},null!==(Jo=null==Be?void 0:Be.apbTooltip)&&void 0!==Jo?Jo:null==Be?void 0:Be.fpbTooltip),null!==(Mo=null==Be?void 0:Be.apbTooltipArrow)&&void 0!==Mo?Mo:null==Be?void 0:Be.fpbTooltipArrow,"#1a1a1a")},{children:e(c,{style:{fontSize:"0.95rem",color:sn?"#aaaaaa":"#666666",cursor:"default"}})}))]})),e("div",o({style:{display:"flex",flexDirection:"column",gap:"6px"}},{children:Uo.sections.map(function(l){var i,t,r,d,a,s,p,c,u,f;return n("div",o({style:{border:"1px solid ".concat(null!==(t=null===(i=null==Be?void 0:Be.sectionItem)||void 0===i?void 0:i.borderColor)&&void 0!==t?t:sn?"#ffffff22":"#1a1a1a22"),borderRadius:"8px",padding:"10px 14px"}},{children:[n("div",o({onClick:function(){return null==ye?void 0:ye(l.title)},style:{fontSize:"0.83rem",fontWeight:"600",color:null!==(d=null===(r=null==Be?void 0:Be.sectionItem)||void 0===r?void 0:r.titleColor)&&void 0!==d?d:sn?"#e2e8f0":"#111827",fontFamily:"Plus Jakarta Sans, sans-serif",cursor:ye?"pointer":"default",marginBottom:"4px",display:"inline-flex",alignItems:"center",gap:"5px"}},{children:[n("span",o({style:{fontSize:"0.68rem",fontWeight:"700",color:null!==(s=null===(a=null==Be?void 0:Be.sectionItem)||void 0===a?void 0:a.orderColor)&&void 0!==s?s:sn?"#6e7681":"#9CA3AF",fontFamily:"Plus Jakarta Sans, sans-serif",minWidth:"16px",flexShrink:0}},{children:[l.order,"."]})),e("span",o({style:{textDecoration:ye?"underline":"none",textDecorationColor:null!==(c=null===(p=null==Be?void 0:Be.sectionItem)||void 0===p?void 0:p.titleColor)&&void 0!==c?c:sn?"#e2e8f0":"#111827",textUnderlineOffset:"3px"}},{children:l.title})),ye&&n("svg",o({xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:.5}},{children:[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}))]})),e("div",o({style:{fontSize:"0.76rem",color:null!==(f=null===(u=null==Be?void 0:Be.sectionItem)||void 0===u?void 0:u.descriptionColor)&&void 0!==f?f:sn?"#8b949e":"#6B7280",fontFamily:"Plus Jakarta Sans, sans-serif",lineHeight:1.55,paddingLeft:"22px"}},{children:l.description}))]}),l.order)})}))]})),ve&&n(f,o({defaultExpanded:wn,style:o({marginBottom:"1rem",marginTop:"0.6rem",border:"1px solid ".concat(null!==(Eo=null===(jo=null==Be?void 0:Be.spbSection)||void 0===jo?void 0:jo.borderColor)&&void 0!==Eo?Eo:sn?"#ffffff18":"#1a1a1a18"),borderRadius:"8px",boxShadow:"none",background:"transparent"},null==Be?void 0:Be.spbSection)},{children:[e(v,o({expandIcon:e(m,{style:{color:null!==(Go=null==Be?void 0:Be.spbChevronColor)&&void 0!==Go?Go:sn?"#e2e8f0":"#374151"}}),style:o({minHeight:"36px",padding:"0 12px",background:"transparent"},null==Be?void 0:Be.spbSectionHeader)},{children:n("div",o({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[n("span",o({style:o({fontWeight:"600",fontSize:"0.9rem",fontFamily:"Plus Jakarta Sans, sans-serif",color:sn?"#e2e8f0":"#111827"},null==Be?void 0:Be.spbSectionTitle)},{children:["SPB Functionalities (",ve.total_functionalities,")"]})),e("span",o({style:{color:sn?"#6e7681":"#9CA3AF",fontSize:"0.75rem"}},{children:"•"})),n("span",o({style:{fontSize:"0.78rem",fontWeight:"500",color:sn?"#6e7681":"#9CA3AF",fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:[ve.total_apbs_identified," APBs"]}))]}))})),e(h,o({style:o({padding:"10px 12px",background:null!==(Oo=null===(No=null==Be?void 0:Be.spbSectionContent)||void 0===No?void 0:No.backgroundColor)&&void 0!==Oo?Oo:"transparent",display:"flex",flexDirection:"column",gap:"8px"},null==Be?void 0:Be.spbSectionContent)},{children:ve.functionality_analysis.map(function(l,i){var t,r,d,a,s,p,c,u,f;return n("div",o({style:o({border:"1px solid ".concat(null!==(r=null===(t=null==Be?void 0:Be.spbFunctionalityItem)||void 0===t?void 0:t.borderColor)&&void 0!==r?r:sn?"#ffffff14":"#1a1a1a14"),borderRadius:"10px",overflow:"hidden",padding:"4px",background:null!==(a=null===(d=null==Be?void 0:Be.spbFunctionalityItem)||void 0===d?void 0:d.backgroundColor)&&void 0!==a?a:sn?"#ffffff04":"#1a1a1a03"},null==Be?void 0:Be.spbFunctionalityItem)},{children:[n("div",o({style:o({padding:"12px 14px",borderRadius:"12px",background:null!==(p=null===(s=null==Be?void 0:Be.spbFunctionalityItemInner)||void 0===s?void 0:s.backgroundColor)&&void 0!==p?p:sn?"#ffffff08":"#1a1a1a07",borderBottom:"1px solid ".concat(null!==(u=null===(c=null==Be?void 0:Be.spbFunctionalityItemInner)||void 0===c?void 0:c.borderColor)&&void 0!==u?u:sn?"#ffffff10":"#1a1a1a10")},null==Be?void 0:Be.spbFunctionalityItemInner)},{children:[n("div",o({style:o({fontSize:"0.85rem",fontWeight:"700",color:sn?"#e2e8f0":"#111827",fontFamily:"Plus Jakarta Sans, sans-serif",marginBottom:"6px",lineHeight:1.4},null==Be?void 0:Be.spbFunctionalityItemName)},{children:[i+1,". ",l.name]})),e(x,{message:l.description,fontSize:"0.78rem",style:o({lineHeight:1.6,color:sn?"#8b949e":"#6B7280"},null!==(f=null==Be?void 0:Be.spbFunctionalityItemDescription)&&void 0!==f?f:{}),codeStyle:null==Be?void 0:Be.markdownCode,preStyle:null==Be?void 0:Be.markdownPre,blockquoteStyle:null==Be?void 0:Be.markdownBlockquote,syntaxHighlighterTheme:null==Be?void 0:Be.syntaxHighlighterTheme,cognitiveDecisioningStyles:null==Be?void 0:Be.cognitiveDecisioning})]})),l.apb_references&&l.apb_references.length>0&&n("div",o({style:o({display:"flex",alignItems:"center",flexWrap:"wrap",gap:"6px",padding:"8px 14px"},null==Be?void 0:Be.spbApbReferencesRow)},{children:[e("span",o({style:o({fontSize:"0.68rem",fontWeight:"500",color:sn?"#6e7681":"#9CA3AF",fontFamily:"Plus Jakarta Sans, sans-serif",flexShrink:0},null==Be?void 0:Be.spbApbReferencesLabel)},{children:"apb references:"})),l.apb_references.map(function(n,l){var i,t,r,d,a,s;return e(b,o({title:e("span",o({style:o(o({fontSize:"0.7rem",lineHeight:1.5,fontFamily:"Plus Jakarta Sans, sans-serif",color:null!==(d=null!==(t=null===(i=null==Be?void 0:Be.spbApbReferenceTooltip)||void 0===i?void 0:i.color)&&void 0!==t?t:null===(r=null==Be?void 0:Be.spbTooltip)||void 0===r?void 0:r.color)&&void 0!==d?d:"#ffffff"},null==Be?void 0:Be.tooltipContent),null==Be?void 0:Be.spbApbReferenceTooltipContent)},{children:n.context})),placement:"top",arrow:!0,componentsProps:Sn(o({maxWidth:240,padding:"6px 10px"},null!==(a=null==Be?void 0:Be.spbApbReferenceTooltip)&&void 0!==a?a:null==Be?void 0:Be.spbTooltip),null!==(s=null==Be?void 0:Be.spbApbReferenceTooltipArrow)&&void 0!==s?s:null==Be?void 0:Be.spbTooltipArrow,"#1a1a1a")},{children:e("span",o({style:o({display:"inline-flex",alignItems:"center",fontSize:"0.7rem",fontWeight:"500",fontFamily:"Plus Jakarta Sans, sans-serif",padding:"3px 10px",borderRadius:"6px",background:sn?"#ffffff0d":"#1a1a1a08",color:sn?"#c9d1d9":"#374151",cursor:"default",border:"1px solid ".concat(sn?"#ffffff18":"#1a1a1a14")},null==Be?void 0:Be.spbApbReference)},{children:e("span",o({style:o({},null==Be?void 0:Be.spbApbReferenceLabel)},{children:n.apb_name}))}))}),l)})]}))]}),i)})}))]})),!te&&n(l,{children:[e("div",{style:{flex:1}}),Cn]})]})),te&&n("div",o({style:o({width:"50%",padding:"1.75rem",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"},null==Be?void 0:Be.rightPanel)},{children:[e("div",o({style:{fontWeight:"700",fontSize:"1rem",marginBottom:"1rem",color:"#1a1a1a",fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:"Prompt Preview"})),e("div",o({style:{flex:1,border:"1px solid #e0e0e0",borderRadius:"0.875rem",overflow:"hidden",minHeight:0}},{children:An})),Cn]}))]});return n("div",o({style:null==Be?void 0:Be.root},{children:[se?e("div",o({style:o({display:"flex",width:"100%",fontFamily:"Plus Jakarta Sans, sans-serif",overflow:"hidden"},null==Be?void 0:Be.dialog)},{children:Tn})):n(a,o({open:Ke||de,onClose:In,maxWidth:"xl",fullWidth:!0,PaperProps:{style:o({borderRadius:"1rem",fontFamily:"Plus Jakarta Sans, sans-serif",height:"90vh",maxHeight:"90vh",overflow:"hidden"},null==Be?void 0:Be.dialog)}},{children:[e(p,o({onClick:In,size:"small",style:{position:"absolute",top:10,right:12,zIndex:20}},{children:e(u,{fontSize:"small"})})),e(s,o({style:{padding:0,display:"flex",height:"100%",overflow:"hidden"}},{children:Tn}))]})),$e&&(null==Uo?void 0:Uo.dependency_graph)&&n(a,o({open:$e,onClose:function(){return on(!1)},maxWidth:"xl",fullWidth:!0,PaperProps:{style:o({borderRadius:"1rem",height:"90vh",maxHeight:"90vh",overflow:"hidden"},null==Be?void 0:Be.graphDialog)}},{children:[e(p,o({onClick:function(){return on(!1)},size:"small",style:{position:"absolute",top:10,right:12,zIndex:20}},{children:e(u,{fontSize:"small"})})),e(s,o({style:{padding:"1rem",height:"100%",overflow:"hidden",boxSizing:"border-box"}},{children:e(k,{data:w(Uo.dependency_graph),isDarkMode:sn})}))]}))]}))};export{w as convertDependencyGraphData,C as default};
|
|
2
|
+
//# sourceMappingURL=PromptCitation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptCitation.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as n,jsxs as t,Fragment as i}from"react/jsx-runtime";import{useRef as r,useMemo as o,useState as a,useEffect as l,useCallback as d}from"react";import{generateClassName as u,cssPropertiesToString as s,getClassNameFromDiagnostic as c}from"../../../utils/codeCitations.utils.js";var g;!function(e){e[e.Error=0]="Error",e[e.Warning=1]="Warning",e[e.Information=2]="Information",e[e.Hint=3]="Hint"}(g||(g={}));var v=function(g){var v=g.startIndex,h=g.endIndex,f=g.language,m=g.editorHeight,p=g.editorWidth,x=g.code,I=g.isHighlightingEnabled,y=g.isDarkModeEnabled,S=g.openHighlightedCodeDetails,b=g.highlightCodeStatsLine;g.setHighlightCodeStatsLine;var C=g.highlightCodeStatsVariable;g.setHighlightCodeStatsVariable,g.setHighlightIndexes;var L=g.isExpanded,R=g.highlightIndexes,w=g.diagnostics,O=g.diagnosticStylesBySeverity,j=r(null),D=r([]);r([]);var H=r([]),k=r([]),E=o(function(){return v},[v]),M=o(function(){return h},[h]),N=a(null),V=N[0],W=N[1],z=a(null),A=z[0],F=z[1],T=a(null),q=T[0],_=T[1],B=a(void 0),J=B[0],P=B[1],G=a(null),K=G[0],Q=G[1];l(function(){Promise.all([import("@monaco-editor/react"),import("highlight.js/lib/core")]).then(function(e){var n=e[0],t=e[1];_(function(){return n.default});var i=t.default.highlightAuto(x).language;P(i)}).catch(function(){Q("Code editor dependencies not installed. Run: npm install @monaco-editor/react highlight.js")})},[x]);var U=o(function(){return O&&"object"==typeof O&&Object.entries(O).map(function(e){var n=e[0],t=e[1],i=[];return t.style&&i.push(".".concat(u(t.style,+n,!0)," {\n").concat(s(t.style),"\n}")),t.lightModeStyle&&i.push(".".concat(u(t.lightModeStyle,+n,!1)," {\n").concat(s(t.lightModeStyle),"\n}")),i.join("\n")}).join("\n")},[O]);l(function(){return function(){var e;(null===(e=j.current)||void 0===e?void 0:e._resizeObserver)&&j.current._resizeObserver.disconnect()}},[]),l(function(){if(I&&V&&j.current&&A){var e=V.start,n=V.end;if(X(j.current,e,n,b,C),-1===v&&w&&w.length>0){var t=w[0].range,i=t.lineStart,r=t.lineEnd;X(j.current,i,r,b,C)}}},[V,A,I,b,C]),l(function(){var e,n,t;if(A&&j.current&&I){var i=j.current;if(R&&(null===(e=Object.keys(R))||void 0===e?void 0:e.length)>0&&-1!==(null==R?void 0:R.startIndex)&&-1!==(null==R?void 0:R.endIndex)){var r=i.deltaDecorations(D.current,[{range:new A.Range(R.startIndex,1,R.endIndex,1),options:{isWholeLine:!0,className:"myLineHighlight"}}]);D.current=r}if(b&&(null===(n=Object.keys(b))||void 0===n?void 0:n.length)>0&&-1!==(null==b?void 0:b.startIndex)&&-1!==(null==b?void 0:b.endIndex)&&(null==b?void 0:b.name)){r=i.deltaDecorations(D.current,[{range:new A.Range(b.startIndex,1,b.endIndex,1),options:{isWholeLine:!0,className:"myLineHighlight"}}]);D.current=r}if(C&&(null===(t=Object.keys(C))||void 0===t?void 0:t.length)>0&&-1!==(null==C?void 0:C.startIndex)&&-1!==(null==C?void 0:C.endIndex)&&(null==b?void 0:b.name)){r=i.deltaDecorations(H.current,[{range:new A.Range(C.startIndex,1,C.endIndex,1),options:{isWholeLine:!0,className:"myLineHighlight"}}]);H.current=r}}},[v,h,I,A,b,JSON.stringify(C)]),l(function(){if(A&&j.current&&(null==w?void 0:w.length)&&O){var e=j.current,n=w.map(function(e){var n,t,i=c(e.severity,null==y||y,O);return{range:new A.Range(e.range.lineStart,null!==(n=e.range.columnStart)&&void 0!==n?n:1,e.range.lineEnd,null!==(t=e.range.columnEnd)&&void 0!==t?t:1),options:{className:i,isWholeLine:void 0===e.range.columnStart}}});k.current=e.deltaDecorations(k.current,n)}},[w,O,A,y]);var X=d(function(e,n,t,i,r){var o,a;if(A&&e&&I){var l=e.getModel();l&&(n=Math.max(-1,n),(t=Math.min(t,l.getLineCount()))<n&&(t=n),requestAnimationFrame(function(){e.revealRangeInCenterIfOutsideViewport(new A.Range(n,1,t,1),A.editor.ScrollType.Smooth),e.setSelection(new A.Range(n,1,t+1,1))}),i&&-1!==(null==i?void 0:i.startIndex)&&-1!==(null==i?void 0:i.endIndex)&&requestAnimationFrame(function(){e.revealRangeInCenterIfOutsideViewport(new A.Range(i.startIndex,1,i.endIndex,1),A.editor.ScrollType.Smooth),e.setSelection(new A.Range(i.startIndex,1,i.endIndex+1,1))}),0===(null===(o=Object.keys(r))||void 0===o?void 0:o.length)&&e.getContribution("editor.contrib.findController").getState().change({isRevealed:!1},!1),(null===(a=Object.keys(r))||void 0===a?void 0:a.length)>0&&(requestAnimationFrame(function(){e.revealRangeInCenterIfOutsideViewport(new A.Range(r.startIndex,1,r.endIndex,1),A.editor.ScrollType.Smooth),e.setSelection(new A.Range(r.startIndex,1,r.endIndex+1,1))}),e.trigger("keyboard","actions.find"),e.getAction("actions.find").run(),e.getContribution("editor.contrib.findController").getState().change({searchString:(null==r?void 0:r.variableName)||"",isRevealed:!0},!1)))}},[A,I,v,h,null==b?void 0:b.startIndex,null==b?void 0:b.endIndex,C]);l(function(){if(j.current&&A&&I){var e=j.current,n=e.onDidLayoutChange(function(){if(X(e,v,h,b,C),-1===v&&w&&w.length>0){var n=w[0].range,t=n.lineStart,i=n.lineEnd;X(e,t,i,b,C)}});return function(){return n.dispose()}}},[X,v,h,I,null==b?void 0:b.startIndex,null==b?void 0:b.endIndex,C,L]);var Y=d(function(e,n){X(e,E,M),j.current=e,F(n),W({start:E,end:M});var t=e.getContainerDomNode(),i=new ResizeObserver(function(){e.layout()});if(i.observe(t),j.current._resizeObserver=i,I){var r=e.getDomNode(),o=document.createElement("div");null==r||r.appendChild(o);var a=function(){var n=e.getTopForLineNumber(E)-e.getScrollTop();o.style.top="".concat(n,"px")};e.onDidScrollChange(a),a()}},[v,h,I,S]);return K?n("div",e({style:{color:"red",fontSize:"12px",padding:"8px"}},{children:K})):q?t(i,{children:[n(q,{height:m,width:p,defaultLanguage:J||f,defaultValue:x,theme:y?"vs-dark":"vs-light",onMount:Y,beforeMount:function(e){e.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0})},options:{minimap:{enabled:!1},overviewRulerLanes:3,fontFamily:"Plus Jakarta Sans, sans-serif",scrollBeyondLastLine:!1,readOnly:!0,smoothScrolling:!0,automaticLayout:!0,lineDecorationsWidth:10,padding:{top:20,bottom:20}}}),t("style",{children:[U,".myLineHighlight { background-color: rgba(0, 122, 204, 0.3); }"]})]}):n("div",e({style:{padding:"8px",color:"#666"}},{children:"Loading code editor..."}))};export{g as DiagnosticSeverity,v as default};
|
|
2
|
+
//# sourceMappingURL=CodeEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeEditor.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__rest as e,__assign as n,__awaiter as r,__generator as o}from"tslib";import{jsx as i,jsxs as t,Fragment as a}from"react/jsx-runtime";import l,{useState as d,useMemo as c,useRef as s,useEffect as u}from"react";import p from"react-markdown";import f from"rehype-raw";import{Tooltip as g,Box as h}from"@mui/material";import{Prism as v}from"react-syntax-highlighter";import{oneLight as m}from"react-syntax-highlighter/dist/esm/styles/prism";import{Check as y,ContentCopy as b,ExpandLess as x,ExpandMore as _}from"@mui/icons-material";import S from"@mui/icons-material/ExpandMoreOutlined";var k=function(e){var n,r,o;void 0===e&&(e="");var i=null==e?void 0:e.replace(/\\`/g,"`");return i=null==(i=null==(i=null===(o=null==(i=null===(r=null===(n=null==(i=null==i?void 0:i.replace(/```json\s*([\s\S]*?)```/g,function(e,n){return"<codebasename>".concat(n.trim(),"</codebasename>")}))?void 0:i.replace(/^```.*\n?/,""))||void 0===n?void 0:n.replace(/\n?```$/,""))||void 0===r?void 0:r.trim())?void 0:i.replace(/^```/,""))||void 0===o?void 0:o.replace(/```$/,""))?void 0:i.replace(/<\/summary>/g,"</summary>\n"))?void 0:i.replace(/<details>/g,"\n<details>")},w=function(e){var a=e.text,l=d(!1),c=l[0],s=l[1];return t("button",n({onClick:function(){return r(void 0,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,navigator.clipboard.writeText(a)];case 1:return e.sent(),s(!0),setTimeout(function(){return s(!1)},2e3),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}})})},"aria-label":"Copy code",style:{position:"absolute",top:8,right:8,display:"inline-flex",alignItems:"center",gap:4,padding:"3px 8px",fontSize:"0.68rem",fontWeight:500,fontFamily:"inherit",color:c?"#16a34a":"#6B7280",background:c?"#f0fdf4":"#f3f4f6",border:"1px solid ".concat(c?"#bbf7d0":"#e5e7eb"),borderRadius:6,cursor:"pointer",transition:"all 0.2s",opacity:.85},onMouseEnter:function(e){e.currentTarget.style.opacity="1"},onMouseLeave:function(e){e.currentTarget.style.opacity="0.85"}},{children:[i(c?y:b,{style:{fontSize:13}}),c?"Copied":"Copy"]}))},z=function(r){r.node;var o=e(r,["node"]),a=d(!1),c=a[0],p=a[1],f=s(null),g=l.Children.toArray(o.children),h=g.find(function(e){var n;return null===(n=null==e?void 0:e.props)||void 0===n?void 0:n["data-codebase-name"]}),v=!!h,m=v?h.props["data-codebase-name"]:"",y=g.map(function(e){var n;return"string"==typeof e?e:(null===(n=e.props)||void 0===n?void 0:n.children)||""}).join("").replace(/\*\*/g,"").trim(),b=v?"From ".concat(m," codebase"):y||"Accordion title not found";return u(function(){var e,n=null===(e=f.current)||void 0===e?void 0:e.parentElement;if(n){var r=function(){return p(n.open)};return r(),n.addEventListener("toggle",r),function(){return n.removeEventListener("toggle",r)}}},[]),t("summary",n({ref:f,style:{padding:"8px 12px",listStyleType:"none",cursor:"pointer",fontWeight:600,fontSize:"0.82rem",color:"#6932E2",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,borderRadius:8,background:c?"#f5f3ff":"transparent",transition:"background 0.2s"}},{children:[i("span",{children:b}),i("div",n({style:{display:"flex",alignItems:"center",flexShrink:0,color:"#6932E2"}},{children:i(c?x:_,{sx:{fontSize:"1.1rem"}})}))]}))},M=function(r){var o,s=r.message,u=r.fontSize,y=r.extraMetaData,b=r.style,x=r.codeStyle,_=r.preStyle,M=r.blockquoteStyle,C=r.syntaxHighlighterTheme,R=r.cognitiveDecisioningStyles,W=null!=u?u:"0.88rem",E=null!==(o=null==b?void 0:b.color)&&void 0!==o?o:"#1f2937",H=d({open:!1,data:null,activeKey:null}),T=H[0],L=H[1],K=c(function(){var e=function(e){var n={};return{processed:e.replace(/<!--\s*<ai_reasoning>\s*([\s\S]*?)\s*<\/ai_reasoning>\s*-->/g,function(e,r){try{var o=JSON.parse(r.trim()),i=o.id||"reasoning_".concat(Object.keys(n).length);return n[i]=o,'<aireasoning data-reasoning-key="'.concat(i,'">').concat(i,"</aireasoning>")}catch(e){return console.warn("[ai_reasoning] Failed to parse block:",e),""}}),reasoningMap:n}}(s||"");return{processedMessage:e.processed,inlineReasoningMap:e.reasoningMap}},[s]),j=K.processedMessage,B=K.inlineReasoningMap,F=c(function(){return{aireasoning:function(r){r.node;var o=e(r,["node"])["data-reasoning-key"],a=B[o];if(!a)return null;var l=T.open&&T.activeKey===o;return i("div",n({style:{margin:"6px 0"}},{children:t("span",n({onClick:function(e){e.stopPropagation();var n=function(e){var n,r,o,i,t,a,l,d=[];return(null!==(r=null===(n=e.aiReasoningCitation)||void 0===n?void 0:n.gpt_citation)&&void 0!==r?r:[]).forEach(function(e){var n,r,o,i,t,a,l,c,s,u,p,f=null!==(r=null===(n=e.customMetadata)||void 0===n?void 0:n.data_sources)&&void 0!==r?r:[],g=null!==(i=null===(o=e.customMetadata)||void 0===o?void 0:o.training_data_title)&&void 0!==i?i:[],h=null!==(a=null===(t=e.customMetadata)||void 0===t?void 0:t.paraphrase)&&void 0!==a?a:[],v=null===(l=f[0])||void 0===l?void 0:l.match(/<highlight>([\s\S]*?)<\/highlight>/),m=v?v[1].trim():null!==(c=f[0])&&void 0!==c?c:"";d.push({citation_number:Number(e.citation_number),section_ref:null!==(s=g[0])&&void 0!==s?s:"",training_data_title:null!==(u=g[0])&&void 0!==u?u:"",paraphrase:null!==(p=h[0])&&void 0!==p?p:"",data_sources:f,highlight:m})}),{block_cognitive_reasoning_html:null!==(i=null!==(o=e.Reasoning)&&void 0!==o?o:e.reasoning)&&void 0!==i?i:"",block_cognitive_gap_html:null!==(t=e.Gap)&&void 0!==t?t:"",block_cognitive_confidence:Number(null!==(l=null!==(a=e.Confidence_score)&&void 0!==a?a:e.decision_strength)&&void 0!==l?l:0),block_cognitive_citations:d}}(a);L(function(e){return e.open&&e.activeKey===o?{open:!1,data:null,activeKey:null}:{open:!0,data:n,activeKey:o}})},style:{display:"inline-flex",alignItems:"center",gap:6,cursor:"pointer",color:"#6932E2",fontWeight:500,fontSize:W,transition:"all 0.2s",padding:"2px 0"}},{children:[i("span",{children:o}),i("span",n({style:{display:"inline-flex",alignItems:"center",gap:2,border:"1px solid #e2e8f0",borderRadius:5,padding:"4px 2px"}},{children:i(S,{sx:{fontSize:"1rem",color:"#475569",transform:l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"}})}))]}))}))},codebasename:function(e){var r=e.children,o=("string"==typeof r[0]?r[0]:"").trim();return""!==o?t("div",n({"data-codebase-name":o,style:{position:"relative",margin:"12px 0"}},{children:[i(w,{text:String(r).replace(/\n$/,"")}),i(v,n({style:null!=C?C:m,language:"json",PreTag:"div",customStyle:n({borderRadius:8,padding:"1rem",fontSize:"0.8rem",border:"1px solid #e5e7eb",margin:0,lineHeight:1.6},_)},{children:String(r).replace(/\n$/,"")}))]})):i(a,{})},details:function(r){r.node;var o=e(r,["node"]);return i("details",n({},o,{style:{borderRadius:8,border:"1px solid #e9e5f5",backgroundColor:"transparent",margin:"8px 0",overflow:"hidden"}},{children:o.children}))},summary:z,p:function(r){r.node;var o=e(r,["node"]);return i("p",n({style:{wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",maxWidth:"100%",fontSize:W,lineHeight:1.7,margin:"4px 0",color:E}},{children:null==o?void 0:o.children}))},strong:function(r){r.node;var o=e(r,["node"]);return i("strong",n({style:{fontWeight:650,color:E}},{children:null==o?void 0:o.children}))},h1:function(r){r.node;var o=e(r,["node"]);return i("h1",n({style:{fontSize:"1.35rem",fontWeight:700,color:E,margin:"20px 0 8px",lineHeight:1.3,letterSpacing:"-0.01em"}},{children:o.children}))},h2:function(r){r.node;var o=e(r,["node"]);return i("h2",n({style:{fontSize:"1.15rem",fontWeight:650,color:E,margin:"16px 0 6px",lineHeight:1.35}},{children:o.children}))},h3:function(r){r.node;var o=e(r,["node"]);return i("h3",n({style:{fontSize:"1rem",fontWeight:600,color:E,margin:"14px 0 4px",lineHeight:1.4}},{children:o.children}))},h4:function(r){r.node;var o=e(r,["node"]);return i("h4",n({style:{fontSize:"0.92rem",fontWeight:600,color:E,margin:"12px 0 4px",lineHeight:1.4}},{children:o.children}))},ol:function(r){r.node;var o=e(r,["node"]);return i("ol",n({style:{listStyleType:"decimal",marginLeft:20,paddingLeft:4,display:"flex",flexDirection:"column",gap:2}},{children:null==o?void 0:o.children}))},ul:function(r){r.node;var o=e(r,["node"]);return i("ul",n({style:{listStyleType:"disc",marginLeft:20,paddingLeft:4,display:"flex",flexDirection:"column",gap:2}},{children:null==o?void 0:o.children}))},li:function(r){r.node;var o=e(r,["node"]);return i("li",n({style:{fontSize:W,lineHeight:1.7,color:E,paddingLeft:4}},{children:o.children}))},blockquote:function(r){r.node;var o=e(r,["node"]);return i("blockquote",n({style:n({margin:"12px 0",padding:"8px 16px",borderLeft:"3px solid #8b5cf6",background:"#faf5ff",borderRadius:"0 6px 6px 0",color:E,fontStyle:"italic",fontSize:W,lineHeight:1.65},M)},{children:o.children}))},hr:function(){return i("hr",{style:{border:"none",height:1,background:"linear-gradient(to right, transparent, #d1d5db, transparent)",margin:"16px 0"}})},table:function(r){r.node;var o=e(r,["node"]);return i("div",n({style:{overflowX:"auto",margin:"12px 0",borderRadius:8,border:"1px solid #e5e7eb"}},{children:i("table",n({style:{width:"100%",borderCollapse:"collapse",fontSize:"0.8rem",lineHeight:1.5}},{children:o.children}))}))},thead:function(r){r.node;var o=e(r,["node"]);return i("thead",n({style:{background:"#f9fafb",borderBottom:"2px solid #e5e7eb"}},{children:o.children}))},th:function(r){r.node;var o=e(r,["node"]);return i("th",n({style:{padding:"8px 12px",textAlign:"left",fontWeight:600,fontSize:"0.76rem",color:E,whiteSpace:"nowrap"}},{children:o.children}))},td:function(r){r.node;var o=e(r,["node"]);return i("td",n({style:{padding:"8px 12px",borderTop:"1px solid #f3f4f6",color:E,fontSize:"0.8rem"}},{children:o.children}))},a:function(r){var o=r.children;r.node;var l=e(r,["children","node"]),d=l["data-cognitive-reasoning"];if(d&&(null==y?void 0:y[d])){var c=T.open&&T.activeKey===d;return i(a,{children:t("span",n({onClick:function(e){e.stopPropagation();var n=function(e){var n,r,o,i,t;if(!e)return null;var a=[];return(null!==(r=null===(n=e.aiReasoningCitation)||void 0===n?void 0:n.gpt_citation)&&void 0!==r?r:[]).forEach(function(e){var n,r,o,i,t,l,d,c,s,u,p,f=null!==(r=null===(n=e.customMetadata)||void 0===n?void 0:n.data_sources)&&void 0!==r?r:[],g=null!==(i=null===(o=e.customMetadata)||void 0===o?void 0:o.training_data_title)&&void 0!==i?i:[],h=null!==(l=null===(t=e.customMetadata)||void 0===t?void 0:t.paraphrase)&&void 0!==l?l:[],v=null===(d=f[0])||void 0===d?void 0:d.match(/<highlight>([\s\S]*?)<\/highlight>/),m=v?v[1].trim():null!==(c=f[0])&&void 0!==c?c:"";a.push({citation_number:Number(e.citation_number),section_ref:null!==(s=g[0])&&void 0!==s?s:"",training_data_title:null!==(u=g[0])&&void 0!==u?u:"",paraphrase:null!==(p=h[0])&&void 0!==p?p:"",data_sources:f,highlight:m})}),{block_cognitive_reasoning_html:null!==(o=e.Reasoning)&&void 0!==o?o:"",block_cognitive_gap_html:null!==(i=e.Gap)&&void 0!==i?i:"",block_cognitive_confidence:Number(null!==(t=e.Confidence_score)&&void 0!==t?t:0),block_cognitive_citations:a}}(y[d]);L(function(e){return e.open&&e.activeKey===d?{open:!1,data:null,activeKey:null}:{open:!0,data:n,activeKey:d}})},style:{color:"#6932E2",fontWeight:500,cursor:"pointer",transition:"all 0.2s",padding:"0 2px",position:"relative",display:"inline-flex",alignItems:"center",gap:6}},{children:[o||"",i("span",n({style:{cursor:"pointer",padding:"4px 2px",display:"inline-flex",alignItems:"center",gap:2,border:"1px solid #e2e8f0",borderRadius:"5px"}},{children:i(S,{sx:{fontSize:"1rem",color:"#475569",transform:c?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"}})}))]}))})}var s=!1;try{s=new URL(null==l?void 0:l.href).protocol.startsWith("http")}catch(e){s=!1}return s?i("a",n({href:null==l?void 0:l.href,style:{color:"#6932E2",textDecoration:"none",fontWeight:500,borderBottom:"1px solid #c4b5fd",transition:"border-color 0.2s, color 0.2s"},target:"_blank",rel:"noopener noreferrer",onMouseEnter:function(e){e.currentTarget.style.borderBottomColor="#6932E2"},onMouseLeave:function(e){e.currentTarget.style.borderBottomColor="#c4b5fd"}},{children:o})):i("span",{children:o})},sup:function(r){r.node;var o=e(r,["node"]);return i(g,n({title:o.children,placement:"top",arrow:!0},{children:i(h,n({component:"span",sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,borderRadius:"50%",background:"#ede9fe",color:"#7c3aed",fontSize:"0.6rem",fontWeight:700,verticalAlign:"super",cursor:"pointer",userSelect:"none",lineHeight:1,transition:"all 0.2s","&:hover":{background:"#7c3aed",color:"#fff"}},"aria-label":"Info",role:"button"},{children:"i"}))}))},code:function(e){var r=e.children;return i("code",n({style:n({fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, monospace",fontSize:"0.82em",color:"#9333ea",background:"#faf5ff",padding:"1.5px 5px",borderRadius:4,border:"1px solid #f3e8ff",fontWeight:500},x)},{children:r}))},pre:function(e){var r=e.children,o=function(e){var n;return"string"==typeof e?e:(null===(n=null==e?void 0:e.props)||void 0===n?void 0:n.children)?(Array.isArray(e.props.children)?e.props.children:[e.props.children]).map(o).join(""):""},a=l.Children.toArray(r).map(o).join("");return t("div",n({style:{position:"relative",margin:"12px 0"}},{children:[i(w,{text:a}),i("pre",n({style:n({fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, monospace",fontSize:"0.8rem",lineHeight:1.6,color:"#1f2937",background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8,padding:"14px 16px",margin:0,overflowX:"auto",whiteSpace:"pre"},_)},{children:r}))]}))},img:function(r){r.node;var o=e(r,["node"]);return i("img",n({},o,{style:{maxWidth:"100%",height:"auto",borderRadius:8,margin:"8px 0",border:"1px solid #e5e7eb"},loading:"lazy"}))}}},[W,y,T.activeKey,T.open,B,E,x,_,M,C,R]);return i("div",n({className:"pg-markdown-renderer",style:n({fontSize:W,lineHeight:1.7,color:"#1f2937",wordBreak:"break-word",position:"relative"},b)},{children:i(p,n({components:F,rehypePlugins:[f],className:"react-markdown-renderer-with-overrides"},{children:k(j)}))}))};export{M as MarkdownRenderer,M as default};
|
|
2
|
+
//# sourceMappingURL=Markdownrenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Markdownrenderer.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as i}from"tslib";import{jsx as t,jsxs as o,Fragment as r}from"react/jsx-runtime";import{useMemo as n,useState as l}from"react";import d from"@mui/icons-material/ChevronRight";import a from"@mui/icons-material/Close";import c from"@mui/icons-material/ExpandMore";import s from"@mui/material/Box";import u from"@mui/material/Button";import m from"@mui/material/ButtonBase";import p from"@mui/material/Divider";import h from"@mui/material/IconButton";import g from"@mui/material/Paper";import f from"@mui/material/Radio";import x from"@mui/material/Stack";import b from"@mui/material/TextField";import E from"@mui/material/Typography";import C from"./RevertSummaryNotice.js";import v from"./CognitiveIcon.js";import F from"./CognitiveScoreBadge.js";import S from"../../assests/icons/InfoAlert.js";var y,w=function(e,t){return i([e],Array.isArray(t)?t:null==t?[]:[t],!0)},R="MERGE_ADJACENT";!function(e){e.KEEP="KEEP",e.SPLIT_HERE="SPLIT_HERE",e.MERGE_NEXT="MERGE_NEXT",e.MERGE_PREV="MERGE_PREV",e.MERGE_PREVIOUS="MERGE_PREVIOUS",e.SET_RANGE="SET_RANGE"}(y||(y={}));var A=function(e){return Object.values(y).includes(e)},M=function(e,t,o,r){if(!t||!e)return[];var n=t.additional_decisions,l=Array.isArray(n)?n:n?Object.values(n).flat():[],d=Array.from(new Set(i(i([],t.allowed_decisions,!0),l,!0)));return d.flatMap(function(i){var t=e.focus_page,n=d.find(function(e){return e.toLowerCase().includes("merge")}),l=null!=t&&null!=o&&null!=r&&t===o&&t===r,a=null!=t&&null!=o&&t===o,c=null!=t&&null!=r&&(t===r||t===r+1),s=a||c||!(null!=t&&(!(null!=o&&null!=r)||t>o&&t<r));switch(i){case y.SET_RANGE:return[];case"KEEP":return[{id:i,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:i,title:"Split to a separate document",description:s?"A valid page inside the document is required to split it.":t?"Start a new document at page ".concat(t,"."):"Create a new document at this boundary.",disabled:s}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return i!==n?[]:l?[{id:R,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]:a?[{id:y.MERGE_PREVIOUS,title:"Merge with previous document",description:"Combine this document with the previous document."}]:c?[{id:y.MERGE_NEXT,title:"Merge with next document",description:"Combine this document with the next document."}]:[{id:R,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};function I(i){var I=i.headerName,z=void 0===I?"Boundary Check":I,T=i.title,k=i.pageNo,W=i.content,P=i.revertSummary,_=i.cognitiveScore,N=i.config,G=i.metadata,D=i.previousSegmentTitle,B=i.nextSegmentTitle,j=i.selectedIndex,H=i.defaultSelectedIndex,O=void 0===H?null:H,V=i.defaultStartPage,U=i.defaultEndPage,L=i.onSelectionChange,X=i.onConfirm,K=i.onActionConfirm,$=i.onCognitiveClick,q=i.onAdjustManually,J=i.onClose,Y=i.confirmLabel,Q=void 0===Y?"Confirm":Y,Z=i.manualPrompt,ee=void 0===Z?"Didn't find the right option?":Z,ie=i.manualActionLabel,te=void 0===ie?"Adjust Manually":ie,oe=i.cognitiveLabel,re=void 0===oe?"Cognitive Integrity":oe,ne=i.showAdjustManually,le=void 0===ne||ne,de=i.showCognitiveIntegrity,ae=void 0===de||de,ce=i.showCloseButton,se=void 0===ce||ce,ue=i.confirmDisabled,me=void 0!==ue&&ue,pe=i.width,he=void 0===pe?260:pe,ge=i.maxWidth,fe=void 0===ge?260:ge,xe=i.className,be=i.styles,Ee=i.reviewAction,Ce=i.totalPages,ve=n(function(){return(null!=N?N:G?M(G,Ee,V,U):[]).filter(function(e){return e.id!==y.SET_RANGE})},[N,U,V,G,Ee]),Fe=l(O),Se=Fe[0],ye=Fe[1],we=l(null==V?"":String(V)),Re=we[0],Ae=we[1],Me=l(null==U?"":String(U)),Ie=Me[0],ze=Me[1],Te=l(!1),ke=Te[0],We=Te[1],Pe=l(!1),_e=Pe[0],Ne=Pe[1],Ge=l(null),De=Ge[0],Be=Ge[1],je=void 0===j?Se:j,He=null==je?void 0:ve[je],Oe=(null==He?void 0:He.id)===R,Ve=null!=D,Ue=null!=B,Le=function(e){return!0===e.disabled||e.id===y.MERGE_PREV&&!Ve||e.id===y.MERGE_PREVIOUS&&!Ve||e.id===y.MERGE_NEXT&&!Ue||e.id===R&&!Ve&&!Ue},Xe=Number(Re),Ke=Number(Ie),$e=Re.trim().length>0&&Ie.trim().length>0&&Number.isInteger(Xe)&&Number.isInteger(Ke)&&Xe>0&&Ke>0,qe=null!=Ce&&Xe>Ce,Je=null!=Ce&&Ke>Ce,Ye=$e&&Xe<=Ke&&!qe&&!Je,Qe=me||!He||Le(He)||Oe&&null==De||!X&&!K;return t(g,e({className:xe,elevation:4,sx:w({width:he,maxWidth:fe,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},null==be?void 0:be.root)},{children:o(x,e({spacing:.75,sx:{p:1}},{children:[o(x,e({direction:"row",alignItems:"center",spacing:.75,sx:null==be?void 0:be.header},{children:[t(S,{color:"error",height:16,width:16}),t(E,e({sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"}},{children:z})),se&&t(h,e({size:"small",onClick:J,disabled:!J,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}}},{children:t(a,{sx:{fontSize:17}})}))]})),o(s,{children:[t(E,e({sx:{color:"text.primary",fontSize:14,fontWeight:500}},{children:T})),null!=k&&t(E,e({sx:{mt:.125,color:"text.secondary",fontSize:12}},{children:k})),t(p,{sx:{my:.625}}),null!=P?t(C,{children:P}):null!=W&&t(E,e({component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3}},{children:W}))]}),o(x,e({spacing:.625,role:"radiogroup","aria-label":"Boundary options"},{children:[ve.map(function(i,r){var n=je===r,l=Le(i);return o(g,e({variant:"outlined",sx:w({borderColor:n?"#1976d2":"divider",borderRadius:2,bgcolor:l?"#F8FAFC":"background.paper",overflow:"hidden"},null==be?void 0:be.option)},{children:[o(m,e({role:"radio","aria-checked":n,disabled:me||l,onClick:function(){return function(e,i){me||Le(i)||(void 0===j&&ye(e),i.id!==R&&Be(null),ke&&(We(!1),Ne(!1)),null==L||L(e,i))}(r,i)},sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"}},{children:[t(f,{checked:n,disabled:me||l,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),o(s,e({sx:{minWidth:0}},{children:[t(E,e({sx:{color:l?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500}},{children:i.title})),null!=i.description&&t(E,e({sx:{mt:.125,color:l?"#94A3B8":"text.secondary",fontSize:11}},{children:i.description}))]}))]})),n&&i.id===R&&t(x,e({direction:"row",spacing:.75,sx:w({px:.75,pb:.75},null==be?void 0:be.adjacentSelector)},{children:[{direction:"previous",title:null!=D?D:"No Previous document",caption:"← Merge into Previous",available:Ve},{direction:"next",title:null!=B?B:"No Next document",caption:"Merge into Next →",available:Ue}].map(function(i){var r=De===i.direction;return o(x,e({sx:{flex:1,minWidth:0}},{children:[t(m,e({disabled:me||!i.available,onClick:function(){return Be(i.direction)},"aria-pressed":r,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:r?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:r?"#E0E7FF":"background.paper",color:r?"#7F56D9":i.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}}},{children:t(E,e({sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"}},{children:i.title}))})),t(E,e({sx:{mt:.5,color:r?"#5925DC":"text.secondary",fontSize:9.5,lineHeight:1.2,whiteSpace:"nowrap",textAlign:"next"===i.direction?"right":"left"}},{children:i.caption}))]}),i.direction)})}))]}),i.id)}),Oe&&null!=De&&o(x,e({direction:"row",alignItems:"flex-start",spacing:.625,sx:w({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},null==be?void 0:be.impactWarning)},{children:[t(S,{color:"error",height:14,width:14,sx:{mt:.125}}),o(E,e({sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4}},{children:["This will impact the ",De," document. Its content and page range will change."]}))]})),t(u,e({variant:"contained",fullWidth:!0,disabled:Qe,onClick:function(){if(!Qe&&null!=je&&He){var i=Oe?"previous"===De?y.MERGE_PREVIOUS:y.MERGE_NEXT:He.id,t=Oe?e(e({},He),{id:i}):He,o={selectedIndex:je,option:t,metadata:G};null==X||X(je,t,o),K&&A(i)&&K(i,o)}},sx:w({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},null==be?void 0:be.confirmButton)},{children:Q}))]})),le&&o(x,e({spacing:.625,sx:null==be?void 0:be.manualSection},{children:[o(m,e({disabled:me,onClick:function(){var e=!ke;We(e),Ne(!1),e&&(void 0===j&&ye(null),null==q||q())},"aria-expanded":ke,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"}},{children:[t(s,{children:t(E,e({sx:{color:"text.primary",fontSize:12,fontWeight:600}},{children:ee}))}),t(c,{sx:{color:"text.secondary",fontSize:16,transform:ke?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]})),ke&&!_e&&o(s,e({sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'}},{children:[o(s,e({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[t(E,e({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Starts"})),t(E,e({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Ends"}))]})),o(s,e({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[o(s,{children:[t(b,{size:"small",type:"text",value:Re,disabled:me,error:qe,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&Ae(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:qe?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:qe?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:qe?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),qe&&o(E,e({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:["Must be ≤ ",Ce," (total pages)"]}))]}),o(s,{children:[t(b,{size:"small",type:"text",value:Ie,disabled:me,error:Je||Re.trim().length>0&&Ie.trim().length>0&&Xe>Ke,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&ze(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Je||Re.trim().length>0&&Ie.trim().length>0&&Xe>Ke?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Je||Re.trim().length>0&&Ie.trim().length>0&&Xe>Ke?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Je||Re.trim().length>0&&Ie.trim().length>0&&Xe>Ke?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Je&&o(E,e({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:["Must be ≤ ",Ce," (total pages)"]})),!Je&&Re.trim().length>0&&Ie.trim().length>0&&Xe>Ke&&t(E,e({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:"End page must be ≥ start page"}))]})]})),t(s,{children:t(u,e({onClick:function(){Ye&&Ne(!0)},disabled:me||!Ye,sx:{height:"30px",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",backgroundColor:"#FFFFFF",border:"1px solid #8E80F3",borderRadius:"6px",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif',fontSize:"12px",fontWeight:600,lineHeight:"1",color:"#4A24CF",outline:"none",cursor:"pointer",textTransform:"none",transition:"all 150ms ease-in-out","&:hover":Ye?{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"}:{},"&:active":Ye?{transform:"translateY(1px)"}:{},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}}},{children:"Apply"}))}),t(s,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]})),ke&&_e&&o(x,e({spacing:.75,sx:w({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},null==be?void 0:be.manualConfirmation)},{children:[o(x,e({direction:"row",alignItems:"center",spacing:.5},{children:[t(S,{color:"warning",height:14,width:14}),t(E,e({sx:{color:"#EA580C",fontSize:11,fontWeight:600}},{children:"Confirm this change?"}))]})),o(E,e({sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4}},{children:["Pages ",Xe,"-",Ke," will become part of ",T,", including pages from other documents in this range."]})),o(x,e({direction:"row",spacing:.75},{children:[t(u,e({variant:"outlined",fullWidth:!0,onClick:function(){return Ne(!1)},sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"}},{children:"Cancel"})),t(u,e({variant:"contained",fullWidth:!0,disabled:me||!X,onClick:function(){if(Ye&&X){var e={id:y.SET_RANGE,title:te};X(-1,e,{selectedIndex:-1,option:e,startPage:Xe,endPage:Ke,metadata:G})}},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}}},{children:"Confirm"}))]}))]}))]})),t(x,e({spacing:.625,sx:null==be?void 0:be.footer},{children:ae&&o(r,{children:[t(p,{}),o(m,e({onClick:$,disabled:!$,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:$?"pointer":"not-allowed"}},{children:[o(x,e({direction:"row",alignItems:"center",spacing:1},{children:[t(v,{sx:{color:"text.secondary"}}),t(E,e({sx:{color:"text.primary",fontSize:12}},{children:re}))]})),o(x,e({direction:"row",alignItems:"center",spacing:.5},{children:[t(F,{score:_}),t(d,{sx:{color:"text.secondary"}})]}))]}))]})}))]}))}))}export{y as BoundaryReviewActionEnum,M as createBoundaryCardOptions,I as default,A as isBoundaryReviewAction};
|
|
1
|
+
import{__assign as e,__spreadArray as i}from"tslib";import{jsx as o,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useMemo as n,useState as l}from"react";import d from"@mui/icons-material/ChevronRight";import a from"@mui/icons-material/Close";import c from"@mui/icons-material/ExpandMore";import s from"@mui/material/Box";import u from"@mui/material/Button";import p from"@mui/material/ButtonBase";import m from"@mui/material/Divider";import h from"@mui/material/IconButton";import g from"@mui/material/Paper";import x from"@mui/material/Radio";import f from"@mui/material/Stack";import b from"@mui/material/TextField";import E from"@mui/material/Typography";import C from"./RevertSummaryNotice.js";import v from"./CognitiveIcon.js";import F from"./CognitiveScoreBadge.js";import S from"../../assests/icons/InfoAlert.js";var y,w=function(e,o){return i([e],Array.isArray(o)?o:null==o?[]:[o],!0)},R="MERGE_ADJACENT";!function(e){e.KEEP="KEEP",e.SPLIT_HERE="SPLIT_HERE",e.MERGE_NEXT="MERGE_NEXT",e.MERGE_PREV="MERGE_PREV",e.MERGE_PREVIOUS="MERGE_PREVIOUS",e.SET_RANGE="SET_RANGE"}(y||(y={}));var M=function(e){return Object.values(y).includes(e)},A=function(e,o,t,r){if(!o||!e)return[];var n=o.additional_decisions,l=Array.isArray(n)?n:n?Object.values(n).flat():[],d=Array.from(new Set(i(i([],o.allowed_decisions,!0),l,!0)));return d.flatMap(function(i){var o=e.focus_page,n=d.find(function(e){return e.toLowerCase().includes("merge")}),l=null!=o&&null!=t&&null!=r&&o===t&&o===r,a=null!=o&&null!=t&&o===t,c=null!=o&&null!=r&&(o===r||o===r+1),s=a||c||!(null!=o&&(!(null!=t&&null!=r)||o>t&&o<r));switch(i){case y.SET_RANGE:return[];case"KEEP":return[{id:i,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:i,title:"Split to a separate document",description:s?"A valid page inside the document is required to split it.":o?"Start a new document at page ".concat(o,"."):"Create a new document at this boundary.",disabled:s}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return i!==n?[]:l?[{id:R,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]:a?[{id:y.MERGE_PREVIOUS,title:"Merge with previous document",description:"Combine this document with the previous document."}]:c?[{id:y.MERGE_NEXT,title:"Merge with next document",description:"Combine this document with the next document."}]:[{id:R,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};function I(i){var I=i.headerName,T=void 0===I?"Boundary Check":I,z=i.title,W=i.pageNo,k=i.content,P=i.revertSummary,_=i.cognitiveScore,N=i.config,G=i.metadata,B=i.previousSegmentTitle,D=i.nextSegmentTitle,H=i.selectedIndex,j=i.defaultSelectedIndex,O=void 0===j?null:j,V=i.defaultStartPage,L=i.defaultEndPage,U=i.onSelectionChange,X=i.onConfirm,K=i.onActionConfirm,$=i.onCognitiveClick,q=i.onAdjustManually,J=i.onClose,Y=i.confirmLabel,Q=void 0===Y?"Confirm":Y,Z=i.manualPrompt,ee=void 0===Z?"Didn't find the right option?":Z,ie=i.manualActionLabel,oe=void 0===ie?"Adjust Manually":ie,te=i.cognitiveLabel,re=void 0===te?"Cognitive Integrity":te,ne=i.showAdjustManually,le=void 0===ne||ne,de=i.showCognitiveIntegrity,ae=void 0===de||de,ce=i.showCloseButton,se=void 0===ce||ce,ue=i.confirmDisabled,pe=void 0!==ue&&ue,me=i.width,he=void 0===me?260:me,ge=i.maxWidth,xe=void 0===ge?260:ge,fe=i.className,be=i.styles,Ee=i.reviewAction,Ce=i.totalPages;console.log("LOG: Total pages",Ce);var ve=n(function(){return(null!=N?N:G?A(G,Ee,V,L):[]).filter(function(e){return e.id!==y.SET_RANGE})},[N,L,V,G,Ee]),Fe=l(O),Se=Fe[0],ye=Fe[1],we=l(null==V?"":String(V)),Re=we[0],Me=we[1],Ae=l(null==L?"":String(L)),Ie=Ae[0],Te=Ae[1],ze=l(!1),We=ze[0],ke=ze[1],Pe=l(!1),_e=Pe[0],Ne=Pe[1],Ge=l(null),Be=Ge[0],De=Ge[1],He=l(!1),je=He[0],Oe=He[1],Ve=void 0===H?Se:H,Le=null==Ve?void 0:ve[Ve],Ue=(null==Le?void 0:Le.id)===R,Xe=null!=B,Ke=null!=D,$e=function(e){return!0===e.disabled||e.id===y.MERGE_PREV&&!Xe||e.id===y.MERGE_PREVIOUS&&!Xe||e.id===y.MERGE_NEXT&&!Ke||e.id===R&&!Xe&&!Ke},qe=Number(Re),Je=Number(Ie),Ye=Re.trim().length>0&&Ie.trim().length>0&&Number.isInteger(qe)&&Number.isInteger(Je)&&qe>0&&Je>0,Qe=null!=Ce&&qe>Ce,Ze=null!=Ce&&Je>Ce,ei=Re.trim().length>0&&Ie.trim().length>0&&Number.isInteger(qe)&&Number.isInteger(Je)&&qe>Je,ii=Ye&&qe<=Je&&!Qe&&!Ze,oi=ii&&qe===V&&Je===L,ti=pe||!Le||$e(Le)||Ue&&null==Be||!X&&!K;return o(g,e({className:fe,elevation:4,sx:w({width:he,maxWidth:xe,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},null==be?void 0:be.root)},{children:t(f,e({spacing:.75,sx:{p:1}},{children:[t(f,e({direction:"row",alignItems:"center",spacing:.75,sx:null==be?void 0:be.header},{children:[o(S,{color:"error",height:16,width:16}),o(E,e({sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"}},{children:T})),se&&o(h,e({size:"small",onClick:J,disabled:!J,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}}},{children:o(a,{sx:{fontSize:17}})}))]})),t(s,{children:[o(E,e({sx:{color:"text.primary",fontSize:14,fontWeight:500}},{children:z})),null!=W&&o(E,e({sx:{mt:.125,color:"text.secondary",fontSize:12}},{children:W})),o(m,{sx:{my:.625}}),null!=P?o(C,{children:P}):null!=k&&o(E,e({component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3}},{children:k}))]}),t(f,e({spacing:.625,role:"radiogroup","aria-label":"Boundary options"},{children:[ve.map(function(i,r){var n=Ve===r,l=$e(i);return t(g,e({variant:"outlined",sx:w({borderColor:n?"#1976d2":"divider",borderRadius:2,bgcolor:l?"#F8FAFC":"background.paper",overflow:"hidden"},null==be?void 0:be.option)},{children:[t(p,e({role:"radio","aria-checked":n,disabled:pe||l,onClick:function(){return function(e,i){pe||$e(i)||(void 0===H&&ye(e),i.id!==R&&De(null),We&&(ke(!1),Ne(!1)),null==U||U(e,i))}(r,i)},sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"}},{children:[o(x,{checked:n,disabled:pe||l,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),t(s,e({sx:{minWidth:0}},{children:[o(E,e({sx:{color:l?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500}},{children:i.title})),null!=i.description&&o(E,e({sx:{mt:.125,color:l?"#94A3B8":"text.secondary",fontSize:11}},{children:i.description}))]}))]})),n&&i.id===R&&o(f,e({direction:"row",spacing:.75,sx:w({px:.75,pb:.75},null==be?void 0:be.adjacentSelector)},{children:[{direction:"previous",title:null!=B?B:"No Previous document",caption:"← Merge into Previous",available:Xe},{direction:"next",title:null!=D?D:"No Next document",caption:"Merge into Next →",available:Ke}].map(function(i){var r=Be===i.direction;return t(f,e({sx:{flex:1,minWidth:0}},{children:[o(p,e({disabled:pe||!i.available,onClick:function(){return De(i.direction)},"aria-pressed":r,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:r?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:r?"#E0E7FF":"background.paper",color:r?"#7F56D9":i.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}}},{children:o(E,e({sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"}},{children:i.title}))})),o(E,e({sx:{mt:.5,color:r?"#5925DC":"text.secondary",fontSize:9.5,lineHeight:1.2,whiteSpace:"nowrap",textAlign:"next"===i.direction?"right":"left"}},{children:i.caption}))]}),i.direction)})}))]}),i.id)}),Ue&&null!=Be&&t(f,e({direction:"row",alignItems:"flex-start",spacing:.625,sx:w({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},null==be?void 0:be.impactWarning)},{children:[o(S,{color:"error",height:14,width:14,sx:{mt:.125}}),t(E,e({sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4}},{children:["This will impact the ",Be," document. Its content and page range will change."]}))]})),o(u,e({variant:"contained",fullWidth:!0,disabled:ti,onClick:function(){if(!ti&&null!=Ve&&Le){var i=Ue?"previous"===Be?y.MERGE_PREVIOUS:y.MERGE_NEXT:Le.id,o=Ue?e(e({},Le),{id:i}):Le,t={selectedIndex:Ve,option:o,metadata:G};null==X||X(Ve,o,t),K&&M(i)&&K(i,t)}},sx:w({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},null==be?void 0:be.confirmButton)},{children:Q}))]})),le&&t(f,e({spacing:.625,sx:null==be?void 0:be.manualSection},{children:[t(p,e({disabled:pe,onClick:function(){var e=!We;ke(e),Ne(!1),e&&(void 0===H&&ye(null),null==q||q())},"aria-expanded":We,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"}},{children:[o(s,{children:o(E,e({sx:{color:"text.primary",fontSize:12,fontWeight:600}},{children:ee}))}),o(c,{sx:{color:"text.secondary",fontSize:16,transform:We?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]})),We&&!_e&&t(s,e({sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'}},{children:[t(s,e({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[o(E,e({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Starts"})),o(E,e({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Ends"}))]})),t(s,e({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[t(s,{children:[o(b,{size:"small",type:"text",value:Re,disabled:pe,error:Qe||ei,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&Me(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Qe||ei?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Qe||ei?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Qe||ei?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Qe&&t(E,e({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:["Must be ≤ ",Ce," (total pages)"]})),ei&&!Qe&&o(E,e({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:"Must be ≤ end page"}))]}),t(s,{children:[o(b,{size:"small",type:"text",value:Ie,disabled:pe,error:Ze||ei,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&Te(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Ze||ei?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Ze||ei?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Ze||ei?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Ze&&t(E,e({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:["Must be ≤ ",Ce," (total pages)"]})),ei&&!Ze&&o(E,e({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:"Must be ≥ start page"}))]})]})),o(s,{children:o(u,e({onClick:function(){ii&&(oi?Oe(!0):Ne(!0))},disabled:pe||!ii||oi,sx:{height:"30px",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",backgroundColor:"#FFFFFF",border:"1px solid #8E80F3",borderRadius:"6px",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif',fontSize:"12px",fontWeight:600,lineHeight:"1",color:"#4A24CF",outline:"none",cursor:"pointer",textTransform:"none",transition:"all 150ms ease-in-out","&:hover":!ii||oi?{}:{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"},"&:active":!ii||oi?{}:{transform:"translateY(1px)"},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}}},{children:"Apply"}))}),oi&&je&&o(s,e({sx:{backgroundColor:"#FEF3C7",border:"1px solid #FBBF24",borderRadius:"6px",padding:"8px 10px",marginTop:"4px"}},{children:o(E,e({sx:{fontSize:"10px",color:"#B45309",fontWeight:500,lineHeight:1.4}},{children:"Please change the boundary to change the document boundary as no changes will be applied."}))})),o(s,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]})),We&&_e&&t(f,e({spacing:.75,sx:w({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},null==be?void 0:be.manualConfirmation)},{children:[t(f,e({direction:"row",alignItems:"center",spacing:.5},{children:[o(S,{color:"warning",height:14,width:14}),o(E,e({sx:{color:"#EA580C",fontSize:11,fontWeight:600}},{children:"Confirm this change?"}))]})),t(E,e({sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4}},{children:["Pages ",qe,"-",Je," will become part of ",z,", including pages from other documents in this range."]})),t(f,e({direction:"row",spacing:.75},{children:[o(u,e({variant:"outlined",fullWidth:!0,onClick:function(){return Ne(!1)},sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"}},{children:"Cancel"})),o(u,e({variant:"contained",fullWidth:!0,disabled:pe||!X||!ii||oi,onClick:function(){if(ii&&!oi&&X){var e={id:y.SET_RANGE,title:oe};X(-1,e,{selectedIndex:-1,option:e,startPage:qe,endPage:Je,metadata:G})}},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}}},{children:"Confirm"}))]}))]}))]})),o(f,e({spacing:.625,sx:null==be?void 0:be.footer},{children:ae&&t(r,{children:[o(m,{}),t(p,e({onClick:$,disabled:!$,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:$?"pointer":"not-allowed"}},{children:[t(f,e({direction:"row",alignItems:"center",spacing:1},{children:[o(v,{sx:{color:"text.secondary"}}),o(E,e({sx:{color:"text.primary",fontSize:12}},{children:re}))]})),t(f,e({direction:"row",alignItems:"center",spacing:.5},{children:[o(F,{score:_}),o(d,{sx:{color:"text.secondary"}})]}))]}))]})}))]}))}))}export{y as BoundaryReviewActionEnum,A as createBoundaryCardOptions,I as default,M as isBoundaryReviewAction};
|
|
2
2
|
//# sourceMappingURL=BoundaryCard.js.map
|