@e-llm-studio/citation 0.0.252 → 0.0.253

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cjs/features/PdfViewer/PdfContainer.js +1 -1
  2. package/dist/cjs/features/PdfViewer/PdfContainer.js.map +1 -1
  3. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  4. package/dist/cjs/features/PdfViewer/PdfViewer.js.map +1 -1
  5. package/dist/cjs/features/SegmentReviewComponents/ApprovalDescriptionBanner.js +2 -0
  6. package/dist/cjs/features/SegmentReviewComponents/ApprovalDescriptionBanner.js.map +1 -0
  7. package/dist/cjs/features/SegmentReviewComponents/RevertCard.js +1 -1
  8. package/dist/cjs/features/SegmentReviewComponents/RevertCard.js.map +1 -1
  9. package/dist/cjs/features/SegmentReviewComponents/SaveAsLearningCard.js +2 -0
  10. package/dist/cjs/features/SegmentReviewComponents/SaveAsLearningCard.js.map +1 -0
  11. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  12. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
  13. package/dist/cjs/hooks/useOnDemandCitationFetch.js +1 -1
  14. package/dist/cjs/hooks/useOnDemandCitationFetch.js.map +1 -1
  15. package/dist/cjs/service/onDemandApi.js +1 -1
  16. package/dist/cjs/service/onDemandApi.js.map +1 -1
  17. package/dist/features/PdfViewer/PdfContainer.js +1 -1
  18. package/dist/features/PdfViewer/PdfContainer.js.map +1 -1
  19. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  20. package/dist/features/PdfViewer/PdfViewer.js.map +1 -1
  21. package/dist/features/SegmentReviewComponents/ApprovalDescriptionBanner.js +2 -0
  22. package/dist/features/SegmentReviewComponents/ApprovalDescriptionBanner.js.map +1 -0
  23. package/dist/features/SegmentReviewComponents/RevertCard.js +1 -1
  24. package/dist/features/SegmentReviewComponents/RevertCard.js.map +1 -1
  25. package/dist/features/SegmentReviewComponents/SaveAsLearningCard.js +2 -0
  26. package/dist/features/SegmentReviewComponents/SaveAsLearningCard.js.map +1 -0
  27. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  28. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
  29. package/dist/hooks/useOnDemandCitationFetch.js +1 -1
  30. package/dist/hooks/useOnDemandCitationFetch.js.map +1 -1
  31. package/dist/service/onDemandApi.js +1 -1
  32. package/dist/service/onDemandApi.js.map +1 -1
  33. package/dist/types/features/PdfViewer/PdfContainer.d.ts +3 -2
  34. package/dist/types/features/PdfViewer/PdfContainer.d.ts.map +1 -1
  35. package/dist/types/features/PdfViewer/PdfViewer.d.ts +3 -2
  36. package/dist/types/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  37. package/dist/types/features/SegmentReviewComponents/ApprovalDescriptionBanner.d.ts +11 -0
  38. package/dist/types/features/SegmentReviewComponents/ApprovalDescriptionBanner.d.ts.map +1 -0
  39. package/dist/types/features/SegmentReviewComponents/RevertCard.d.ts +9 -1
  40. package/dist/types/features/SegmentReviewComponents/RevertCard.d.ts.map +1 -1
  41. package/dist/types/features/SegmentReviewComponents/SaveAsLearningCard.d.ts +15 -0
  42. package/dist/types/features/SegmentReviewComponents/SaveAsLearningCard.d.ts.map +1 -0
  43. package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +12 -1
  44. package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  45. package/dist/types/hooks/useOnDemandCitationFetch.d.ts.map +1 -1
  46. package/dist/types/service/onDemandApi.d.ts.map +1 -1
  47. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@react-pdf-viewer/core"),t=require("./PdfStyle.js");const n="https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js";exports.default=({pdfUrl:d,plugins:s,onLoad:o,customStyles:a,onPageChange:l,defaultScale:i,renderPage:p,setRenderRange:u})=>e.jsx("div",{style:{...t.pdfStyles.pdfConatiner,...a?.pdfContainer},children:e.jsx(r.Worker,{workerUrl:n,children:e.jsx(r.Viewer,{fileUrl:d,defaultScale:i,plugins:s,onDocumentLoad:o,onPageChange:l,renderPage:p,setRenderRange:u})})}),exports.pdfWorker=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@react-pdf-viewer/core"),n=require("./PdfStyle.js"),t=require("react");const o="https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js",d=({error:r,onError:n})=>(t.useEffect(()=>{n?.(r)},[r,n]),e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",color:"#ef4444"},children:e.jsx("span",{children:"Error loading PDF document. The link may have expired."})}));exports.default=({pdfUrl:t,plugins:s,onLoad:i,customStyles:l,onPageChange:a,defaultScale:c,renderPage:u,setRenderRange:f,onError:p})=>e.jsx("div",{style:{...n.pdfStyles.pdfConatiner,...l?.pdfContainer},children:e.jsx(r.Worker,{workerUrl:o,children:e.jsx(r.Viewer,{fileUrl:t,defaultScale:c,plugins:s,onDocumentLoad:i,onPageChange:a,renderPage:u,setRenderRange:f,renderError:r=>e.jsx(d,{error:r,onError:p})})})}),exports.pdfWorker=o;
2
2
  //# sourceMappingURL=PdfContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfContainer.js","sources":["../../../../src/features/PdfViewer/PdfContainer.tsx"],"sourcesContent":["import { Worker, Viewer, SpecialZoomLevel, PageChangeEvent, DocumentLoadEvent, RenderPage, SetRenderRange } from \"@react-pdf-viewer/core\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport { CustomStylesType } from \"./PdfViewer\";\nexport const pdfWorker: string = \"https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js\";\n\ntype Props = {\n pdfUrl: string;\n plugins: any[];\n onLoad: (e: DocumentLoadEvent) => void;\n customStyles?: CustomStylesType;\n onPageChange : (e : PageChangeEvent) => void;\n defaultScale?: SpecialZoomLevel | number | undefined;\n renderPage?: RenderPage;\n setRenderRange?: SetRenderRange;\n};\n\nconst PdfContainer = ({ pdfUrl, plugins, onLoad, customStyles,onPageChange, defaultScale, renderPage, setRenderRange }: Props) => {\n return (\n <div style={{ ...pdfStyles.pdfConatiner, ...customStyles?.pdfContainer }}>\n <Worker workerUrl={pdfWorker}>\n <Viewer\n fileUrl={pdfUrl}\n defaultScale={defaultScale}\n plugins={plugins}\n onDocumentLoad={onLoad}\n onPageChange={onPageChange}\n renderPage={renderPage}\n setRenderRange={setRenderRange}\n />\n </Worker>\n </div>\n );\n};\n\nexport default PdfContainer;\n"],"names":["pdfWorker","pdfUrl","plugins","onLoad","customStyles","onPageChange","defaultScale","renderPage","setRenderRange","jsx","style","pdfStyles","pdfConatiner","pdfContainer","children","Worker","workerUrl","Viewer","fileUrl","onDocumentLoad"],"mappings":"sKAGO,MAAMA,EAAoB,gFAaZ,EAAGC,SAAQC,UAASC,SAAQC,eAAaC,eAAcC,eAAcC,aAAYC,oBAEjGC,EAAAA,IAAA,MAAA,CAAIC,MAAO,IAAKC,EAAAA,UAAUC,gBAAiBR,GAAcS,cACxDC,SAACL,MAAAM,EAAAA,OAAA,CAAOC,UAAWhB,EACjBc,SAAAL,EAAAA,IAACQ,EAAAA,OAAA,CACCC,QAASjB,EACTK,eACAJ,UACAiB,eAAgBhB,EAChBE,eACAE,aACAC"}
1
+ {"version":3,"file":"PdfContainer.js","sources":["../../../../src/features/PdfViewer/PdfContainer.tsx"],"sourcesContent":["import { Worker, Viewer, SpecialZoomLevel, PageChangeEvent, DocumentLoadEvent, RenderPage, SetRenderRange, type LoadError } from \"@react-pdf-viewer/core\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport { CustomStylesType } from \"./PdfViewer\";\nimport { useEffect } from \"react\";\nexport const pdfWorker: string = \"https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js\";\n\ntype Props = {\n pdfUrl: string;\n plugins: any[];\n onLoad: (e: DocumentLoadEvent) => void;\n customStyles?: CustomStylesType;\n onPageChange : (e : PageChangeEvent) => void;\n defaultScale?: SpecialZoomLevel | number | undefined;\n renderPage?: RenderPage;\n setRenderRange?: SetRenderRange;\n onError?: (error: LoadError) => void;\n};\n\nconst PdfErrorHandler = ({ error, onError }: { error: LoadError; onError?: (error: LoadError) => void }) => {\n useEffect(() => {\n onError?.(error);\n }, [error, onError]);\n\n\n return (\n <div style={{ display: \"flex\", justifyContent: \"center\", alignItems: 'center', height: \"100%\", color: \"#ef4444\"}}>\n <span>Error loading PDF document. The link may have expired.</span>\n </div>\n );\n};\n\nconst PdfContainer = ({ pdfUrl, plugins, onLoad, customStyles,onPageChange, defaultScale, renderPage, setRenderRange, onError }: Props) => {\n return (\n <div style={{ ...pdfStyles.pdfConatiner, ...customStyles?.pdfContainer }}>\n <Worker workerUrl={pdfWorker}>\n <Viewer\n fileUrl={pdfUrl}\n defaultScale={defaultScale}\n plugins={plugins}\n onDocumentLoad={onLoad}\n onPageChange={onPageChange}\n renderPage={renderPage}\n setRenderRange={setRenderRange}\n renderError={(error)=> <PdfErrorHandler error={error} onError={onError} />}\n />\n </Worker>\n </div>\n );\n};\n\nexport default PdfContainer;\n"],"names":["pdfWorker","PdfErrorHandler","error","onError","useEffect","style","display","justifyContent","alignItems","height","color","children","jsx","pdfUrl","plugins","onLoad","customStyles","onPageChange","defaultScale","renderPage","setRenderRange","pdfStyles","pdfConatiner","pdfContainer","Worker","workerUrl","Viewer","fileUrl","onDocumentLoad","renderError"],"mappings":"yLAIO,MAAMA,EAAoB,gEAc3BC,EAAkB,EAAGC,QAAOC,cAChCC,EAAAA,UAAU,KACRD,IAAUD,IACT,CAACA,EAAOC,UAIR,MAAI,CAAAE,MAAO,CAAEC,QAAS,OAAQC,eAAgB,SAAUC,WAAY,SAAUC,OAAQ,OAAQC,MAAO,WACpGC,SAACC,EAAAA,IAAA,OAAA,CAAKD,uFAKS,EAAGE,SAAQC,UAASC,SAAQC,eAAaC,eAAcC,eAAcC,aAAYC,iBAAgBjB,aAEjHS,EAAAA,IAAA,MAAA,CAAIP,MAAO,IAAKgB,EAAAA,UAAUC,gBAAiBN,GAAcO,cACxDZ,SAACC,MAAAY,EAAAA,OAAA,CAAOC,UAAWzB,EACjBW,SAAAC,EAAAA,IAACc,EAAAA,OAAA,CACCC,QAASd,EACTK,eACAJ,UACAc,eAAgBb,EAChBE,eACAE,aACAC,iBACAS,YAAc3B,GAAUU,EAAAA,IAAAX,EAAA,CAAgBC,QAAcC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@react-pdf-viewer/core"),r=require("./PdfContainer.js"),n=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),i=require("./usePdfHighlight.js"),a=require("./rotationManager.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var s=require("react"),c=require("../ScannedDocCitation/ScannedDocCitation.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./PdfViewer.css.js");var u=l(s);exports.default=({pdfUrl:l,highlightText:d,highlightPages:g,highlightCordinatePages:h,highlightColor:f="yellow",activeHighlightColor:p="#f7dc51",jumpToPageValue:m=0,pdfName:v,onClose:y,customStyles:w,customClasses:x,customIcons:P,useCoordinates:S,fallbackPages:T,activeCitationIndex:C,onActiveCitationChange:b,headerAction:q,isZoomEnabled:R=!0,showHighlightsAction:A=!0,defaultScale:_=t.SpecialZoomLevel.ActualSize,useRange:j=!1,rangeOfPages:I=null,showFullScreenAction:L=!0,showRotateButton:M=!1,segments:E=[{title:"Document 2",start_page:52,end_page:52,page_count:1}],segmentTooltipText:F,onCurrentPageChange:H,navigationRequest:N,onNavigationSettled:B,disablePdfAnnotations:Z=!1,disablePdfTextLayer:V=!1,renderPage:k,setRenderRange:z})=>{const D=s.useRef(null),O=(e=>{switch(e){case"ActualSize":return t.SpecialZoomLevel.ActualSize;case"PageFit":return t.SpecialZoomLevel.PageFit;case"PageWidth":return t.SpecialZoomLevel.PageWidth;default:return e??t.SpecialZoomLevel.PageWidth}})(_),[W,U]=s.useState(0),[$,J]=s.useState(0),[K,G]=s.useState(0),Q=s.useRef(null),X=s.useRef(null),Y=s.useRef(0),ee=s.useRef(null),te=s.useMemo(()=>{if(!l)return"";try{return new URL(l,window.location.origin).pathname.split("/").pop()||"default"}catch{return"default"}},[l]);s.useEffect(()=>{te&&a.rotationManager.setPdfIdentifier(te)},[te]);s.useEffect(()=>a.rotationManager.onRotationChange((e,t)=>{e===W+1&&G(t)}),[W]),s.useEffect(()=>{const e=new MutationObserver(()=>{const e=D.current?.querySelectorAll('[data-testid^="core__page-layer-"]'),t=new Set;e?.forEach(e=>{const r=e.getAttribute("data-testid")?.match(/core__page-layer-(\d+)/);if(r&&r.length>=2){const n=parseInt(r[1],10)+1;t.has(n)||(a.rotationManager.registerPageElement(n,e),t.add(n))}})});return D.current&&(e.observe(D.current,{childList:!0,subtree:!0,attributes:!1}),ee.current=e),()=>{e.disconnect(),ee.current=null}},[]),s.useEffect(()=>()=>{a.rotationManager.clearAll(),ee.current&&ee.current.disconnect()},[]),s.useEffect(()=>{const e=W+1;G(a.rotationManager.getRotation(e))},[W]);const re=s.useMemo(()=>Z||V?t=>{const r=V?e.jsx("div",{"aria-hidden":"true",style:{display:"none"},children:t.textLayer.children}):t.textLayer.children,n={...t,annotationLayer:{...t.annotationLayer,children:Z?null:t.annotationLayer.children},textLayer:{...t.textLayer,children:r}};return k?k(n):e.jsxs(e.Fragment,{children:[t.canvasLayer.children,r,!Z&&t.annotationLayer.children]})}:k,[Z,V,k]),ne=s.useMemo(()=>{if(S)return new Set(h.map(e=>e.pageIndex));{const e=new Set;return Object.values(g).forEach(t=>{t>0&&e.add(t-1)}),e}},[h,g,S]),oe=(ie=d)&&0!==ie.length?ie.filter(e=>!ie.some(t=>t!==e&&t.includes(e))):ie;var ie;const{highlightIndex:ae,setHighlightIndex:se,cursorIndex:ce,setCursorIndex:le,orderedKeys:ue,totalHighlights:de,getValidPosition:ge,tryJump:he,jumpToPage:fe,zoomTo:pe,plugins:me,controls:ve,hideNonTargetHighlights:ye,deduplicateHighlights:we,scrollToCoord:xe}=i.PdfHighlightControls(oe,S?{}:g,D,ne,S,S?h:[],f,p),Pe=ge(ce),Se=s.useMemo(()=>{const e=W+1;return E.find(t=>e>=t.start_page&&e<=t.end_page)},[W,E]);s.useEffect(()=>{void 0!==C&&C!==ce&&le(C)},[C]);const Te={...ve,goToNext:()=>{ce>=de-1||(ve.goToNext(),b&&b(ce+1))},goToPrevious:()=>{ce<=0||(ve.goToPrevious(),b&&b(ce-1))}},Ce=u.default.useCallback((e,t)=>{Y.current+=1;const r=Y.current;null!=X.current&&window.clearTimeout(X.current);let n=null,o=0,i=0;const a=()=>{if(Y.current!==r)return;i+=1;const s=D.current?.querySelector(".rpv-core__inner-pages"),c=D.current?.querySelector(`[data-testid="core__page-layer-${t-1}"]`);if(!s||!c)return i>=40?(X.current=null,void B?.({pageNumber:t,requestId:e.requestId})):void(X.current=window.setTimeout(a,50));n===s.scrollTop?o+=1:(n=s.scrollTop,o=0);const l=s.getBoundingClientRect(),u=c.getBoundingClientRect(),d=Boolean(l&&u&&u.bottom>l.top&&u.top<l.bottom);if(o>=2&&d||i>=40)return X.current=null,void B?.({pageNumber:t,requestId:e.requestId});X.current=window.setTimeout(a,50)};X.current=window.setTimeout(a,50)},[B]);if(s.useEffect(()=>()=>{Y.current+=1,null!=X.current&&window.clearTimeout(X.current)},[]),s.useEffect(()=>{if(!N||$<=0)return;const e=Math.min(Math.max(Math.trunc(N.pageNumber),1),$),t=`${N.requestId??e}:${e}`;Q.current!==t&&(Q.current=t,U(e-1),fe(e-1),Ce(N,e))},[fe,N,$,Ce]),!l)return e.jsx(c.default,{pages:T,activeCitationIndex:C,onActiveCitationChange:b,headerAction:q});return e.jsxs("div",{ref:D,className:["citation-pdf-viewer",x?.pdfViewerWrapper].filter(Boolean).join(" "),"data-disable-pdf-annotations":Z?"true":void 0,"data-pdf-page-fit":O===t.SpecialZoomLevel.PageFit?"true":void 0,style:{height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column",...o.pdfStyles.pdfViewer,display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA",...w?.pdfViewer,backgroundColor:"#F1F5F9"},children:[e.jsx(n.default,{highlightIndex:ae,totalHighlights:de,controls:Te,currentPosition:Pe,pdfName:v,onClose:y,pdfUrl:l,viewerRef:D,customStyles:w,customClasses:x,customIcons:P,headerAction:q,isZoomEnabled:R,showHighlightsAction:A,showFullScreenAction:L,currentSegment:Se,segmentTooltipText:F,currentPage:W+1,totalPages:$,onPageNavigate:e=>{const t=Math.min(Math.max(e,1),$||e);U(t-1),fe(t-1)},onRotatePage:()=>{const e=W+1;a.rotationManager.rotatePageBy90(e),G(a.rotationManager.getRotation(e))},currentPageRotation:K,showRotateButton:M}),e.jsx(r.default,{defaultScale:O,pdfUrl:l,plugins:me,customStyles:w,onLoad:e=>{J(e.doc.numPages);const t=!S&&!j&&m<=0;if(m>0&&!j){const e=m-1,t=ue[e],r=g[t],n=h[e];le(e),console.log(n,"cordinateTargetHighlight"),S&&n.pageIndex>0&&fe(n.pageIndex),r>0&&(setTimeout(()=>{ye(ne),we(r-1)},1e3),S||fe(r-1))}else if(j&&I&&2===I.length){(async()=>{const[e,t]=I;for(let r=e;r<=t;r++){const e=r-1;fe(e),await new Promise(e=>setTimeout(e,1e3)),ye(ne);const t=we(e);if(t&&t>0)break}})()}else if(!S&&g){const e=ue.find(e=>g[e]>0);if(void 0!==e){const t=g[e]-1;fe(t),setTimeout(()=>{ye(ne),we(t)},1e3)}}requestAnimationFrame(()=>{t&&he(),!S&&m>0&&!j&&(()=>{if(!D.current)return;const e=m-1,t=ue[e],r=g[t],n=r>0?r-1:0,o={};ue.forEach((e,t)=>{const r=g[e];r>0&&(o[r]||(o[r]=[]),o[r].push(t))});const i=(o[r]||[]).indexOf(e);let a=0;const s=()=>{if(a++,a>40)return;const e=D.current?.querySelector(".rpv-core__inner-pages");if(!e)return void setTimeout(s,100);const t=D.current?.querySelector(`[data-testid="core__page-layer-${n}"]`);if(!t)return void setTimeout(s,100);const r=e.getBoundingClientRect(),o=t.getBoundingClientRect();if(!(o.top<r.bottom&&o.bottom>r.top))return void setTimeout(s,100);const c=t.querySelectorAll(".rpv-search__highlight")[i];if(!c)return void setTimeout(s,100);const l=c.getBoundingClientRect(),u=e.scrollTop+(l.top-r.top)-e.clientHeight/2+l.height/2;e.scrollTo({top:u,behavior:"smooth"})};setTimeout(s,500)})()})},onPageChange:e=>{const t=e.currentPage;U(t),H?.(t+1),ne.has(t)?(we(t),ye(ne)):ye(ne)},renderPage:re,setRenderRange:z})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@react-pdf-viewer/core"),r=require("./PdfContainer.js"),n=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),i=require("./usePdfHighlight.js"),a=require("./rotationManager.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var s=require("react"),c=require("../ScannedDocCitation/ScannedDocCitation.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./PdfViewer.css.js");var u=l(s);exports.default=({pdfUrl:l,highlightText:d,highlightPages:g,highlightCordinatePages:h,highlightColor:f="yellow",activeHighlightColor:p="#f7dc51",jumpToPageValue:m=0,pdfName:v,onClose:y,customStyles:w,customClasses:x,customIcons:P,useCoordinates:S,fallbackPages:T,activeCitationIndex:C,onActiveCitationChange:b,headerAction:q,isZoomEnabled:R=!0,showHighlightsAction:A=!0,defaultScale:_=t.SpecialZoomLevel.ActualSize,useRange:j=!1,rangeOfPages:I=null,showFullScreenAction:L=!0,showRotateButton:M=!1,segments:E=[{title:"Document 2",start_page:52,end_page:52,page_count:1}],segmentTooltipText:F,onCurrentPageChange:H,navigationRequest:N,onNavigationSettled:B,disablePdfAnnotations:Z=!1,disablePdfTextLayer:V=!1,renderPage:k,setRenderRange:z,onError:D})=>{const O=s.useRef(null),W=(e=>{switch(e){case"ActualSize":return t.SpecialZoomLevel.ActualSize;case"PageFit":return t.SpecialZoomLevel.PageFit;case"PageWidth":return t.SpecialZoomLevel.PageWidth;default:return e??t.SpecialZoomLevel.PageWidth}})(_),[U,$]=s.useState(0),[J,K]=s.useState(0),[G,Q]=s.useState(0),X=s.useRef(null),Y=s.useRef(null),ee=s.useRef(0),te=s.useRef(null),re=s.useMemo(()=>{if(!l)return"";try{return new URL(l,window.location.origin).pathname.split("/").pop()||"default"}catch{return"default"}},[l]);s.useEffect(()=>{re&&a.rotationManager.setPdfIdentifier(re)},[re]);s.useEffect(()=>a.rotationManager.onRotationChange((e,t)=>{e===U+1&&Q(t)}),[U]),s.useEffect(()=>{const e=new MutationObserver(()=>{const e=O.current?.querySelectorAll('[data-testid^="core__page-layer-"]'),t=new Set;e?.forEach(e=>{const r=e.getAttribute("data-testid")?.match(/core__page-layer-(\d+)/);if(r&&r.length>=2){const n=parseInt(r[1],10)+1;t.has(n)||(a.rotationManager.registerPageElement(n,e),t.add(n))}})});return O.current&&(e.observe(O.current,{childList:!0,subtree:!0,attributes:!1}),te.current=e),()=>{e.disconnect(),te.current=null}},[]),s.useEffect(()=>()=>{a.rotationManager.clearAll(),te.current&&te.current.disconnect()},[]),s.useEffect(()=>{const e=U+1;Q(a.rotationManager.getRotation(e))},[U]);const ne=s.useMemo(()=>Z||V?t=>{const r=V?e.jsx("div",{"aria-hidden":"true",style:{display:"none"},children:t.textLayer.children}):t.textLayer.children,n={...t,annotationLayer:{...t.annotationLayer,children:Z?null:t.annotationLayer.children},textLayer:{...t.textLayer,children:r}};return k?k(n):e.jsxs(e.Fragment,{children:[t.canvasLayer.children,r,!Z&&t.annotationLayer.children]})}:k,[Z,V,k]),oe=s.useMemo(()=>{if(S)return new Set(h.map(e=>e.pageIndex));{const e=new Set;return Object.values(g).forEach(t=>{t>0&&e.add(t-1)}),e}},[h,g,S]),ie=(ae=d)&&0!==ae.length?ae.filter(e=>!ae.some(t=>t!==e&&t.includes(e))):ae;var ae;const{highlightIndex:se,setHighlightIndex:ce,cursorIndex:le,setCursorIndex:ue,orderedKeys:de,totalHighlights:ge,getValidPosition:he,tryJump:fe,jumpToPage:pe,zoomTo:me,plugins:ve,controls:ye,hideNonTargetHighlights:we,deduplicateHighlights:xe,scrollToCoord:Pe}=i.PdfHighlightControls(ie,S?{}:g,O,oe,S,S?h:[],f,p),Se=he(le),Te=s.useMemo(()=>{const e=U+1;return E.find(t=>e>=t.start_page&&e<=t.end_page)},[U,E]);s.useEffect(()=>{void 0!==C&&C!==le&&ue(C)},[C]);const Ce={...ye,goToNext:()=>{le>=ge-1||(ye.goToNext(),b&&b(le+1))},goToPrevious:()=>{le<=0||(ye.goToPrevious(),b&&b(le-1))}},be=u.default.useCallback((e,t)=>{ee.current+=1;const r=ee.current;null!=Y.current&&window.clearTimeout(Y.current);let n=null,o=0,i=0;const a=()=>{if(ee.current!==r)return;i+=1;const s=O.current?.querySelector(".rpv-core__inner-pages"),c=O.current?.querySelector(`[data-testid="core__page-layer-${t-1}"]`);if(!s||!c)return i>=40?(Y.current=null,void B?.({pageNumber:t,requestId:e.requestId})):void(Y.current=window.setTimeout(a,50));n===s.scrollTop?o+=1:(n=s.scrollTop,o=0);const l=s.getBoundingClientRect(),u=c.getBoundingClientRect(),d=Boolean(l&&u&&u.bottom>l.top&&u.top<l.bottom);if(o>=2&&d||i>=40)return Y.current=null,void B?.({pageNumber:t,requestId:e.requestId});Y.current=window.setTimeout(a,50)};Y.current=window.setTimeout(a,50)},[B]);if(s.useEffect(()=>()=>{ee.current+=1,null!=Y.current&&window.clearTimeout(Y.current)},[]),s.useEffect(()=>{if(!N||J<=0)return;const e=Math.min(Math.max(Math.trunc(N.pageNumber),1),J),t=`${N.requestId??e}:${e}`;X.current!==t&&(X.current=t,$(e-1),pe(e-1),be(N,e))},[pe,N,J,be]),!l)return e.jsx(c.default,{pages:T,activeCitationIndex:C,onActiveCitationChange:b,headerAction:q});return e.jsxs("div",{ref:O,className:["citation-pdf-viewer",x?.pdfViewerWrapper].filter(Boolean).join(" "),"data-disable-pdf-annotations":Z?"true":void 0,"data-pdf-page-fit":W===t.SpecialZoomLevel.PageFit?"true":void 0,style:{height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column",...o.pdfStyles.pdfViewer,display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA",...w?.pdfViewer,backgroundColor:"#F1F5F9"},children:[e.jsx(n.default,{highlightIndex:se,totalHighlights:ge,controls:Ce,currentPosition:Se,pdfName:v,onClose:y,pdfUrl:l,viewerRef:O,customStyles:w,customClasses:x,customIcons:P,headerAction:q,isZoomEnabled:R,showHighlightsAction:A,showFullScreenAction:L,currentSegment:Te,segmentTooltipText:F,currentPage:U+1,totalPages:J,onPageNavigate:e=>{const t=Math.min(Math.max(e,1),J||e);$(t-1),pe(t-1)},onRotatePage:()=>{const e=U+1;a.rotationManager.rotatePageBy90(e),Q(a.rotationManager.getRotation(e))},currentPageRotation:G,showRotateButton:M}),e.jsx(r.default,{defaultScale:W,pdfUrl:l,plugins:ve,customStyles:w,onError:D,onLoad:e=>{K(e.doc.numPages);const t=!S&&!j&&m<=0;if(m>0&&!j){const e=m-1,t=de[e],r=g[t],n=h[e];ue(e),console.log(n,"cordinateTargetHighlight"),S&&n.pageIndex>0&&pe(n.pageIndex),r>0&&(setTimeout(()=>{we(oe),xe(r-1)},1e3),S||pe(r-1))}else if(j&&I&&2===I.length){(async()=>{const[e,t]=I;for(let r=e;r<=t;r++){const e=r-1;pe(e),await new Promise(e=>setTimeout(e,1e3)),we(oe);const t=xe(e);if(t&&t>0)break}})()}else if(!S&&g){const e=de.find(e=>g[e]>0);if(void 0!==e){const t=g[e]-1;pe(t),setTimeout(()=>{we(oe),xe(t)},1e3)}}requestAnimationFrame(()=>{t&&fe(),!S&&m>0&&!j&&(()=>{if(!O.current)return;const e=m-1,t=de[e],r=g[t],n=r>0?r-1:0,o={};de.forEach((e,t)=>{const r=g[e];r>0&&(o[r]||(o[r]=[]),o[r].push(t))});const i=(o[r]||[]).indexOf(e);let a=0;const s=()=>{if(a++,a>40)return;const e=O.current?.querySelector(".rpv-core__inner-pages");if(!e)return void setTimeout(s,100);const t=O.current?.querySelector(`[data-testid="core__page-layer-${n}"]`);if(!t)return void setTimeout(s,100);const r=e.getBoundingClientRect(),o=t.getBoundingClientRect();if(!(o.top<r.bottom&&o.bottom>r.top))return void setTimeout(s,100);const c=t.querySelectorAll(".rpv-search__highlight")[i];if(!c)return void setTimeout(s,100);const l=c.getBoundingClientRect(),u=e.scrollTop+(l.top-r.top)-e.clientHeight/2+l.height/2;e.scrollTo({top:u,behavior:"smooth"})};setTimeout(s,500)})()})},onPageChange:e=>{const t=e.currentPage;$(t),H?.(t+1),oe.has(t)?(xe(t),we(oe)):we(oe)},renderPage:ne,setRenderRange:z})]})};
2
2
  //# sourceMappingURL=PdfViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewer.js","sources":["../../../../src/features/PdfViewer/PdfViewer.tsx"],"sourcesContent":["import { DocumentLoadEvent, PageChangeEvent, RenderPage, SetRenderRange, SpecialZoomLevel } from \"@react-pdf-viewer/core\";\nimport PdfContainer from \"./PdfContainer\";\nimport PdfToolbar from \"./PdfToolbar\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport { PdfHighlightControls } from \"./usePdfHighlight\";\nimport { rotationManager } from \"./rotationManager\";\nimport \"@react-pdf-viewer/zoom/lib/styles/index.css\";\nimport \"@react-pdf-viewer/page-navigation/lib/styles/index.css\";\nimport \"@react-pdf-viewer/core/lib/styles/index.css\";\nimport \"@react-pdf-viewer/search/lib/styles/index.css\";\nimport React, { useMemo, useRef, useEffect, useState } from \"react\";\nimport ScannedDocCitation, { CitationPage } from \"../ScannedDocCitation/ScannedDocCitation\";\nimport \"./PdfViewer.css\";\n\nexport type CustomIconsType = {\n pdfIcon?: React.ReactNode;\n fullScreenIcon?: React.ReactNode;\n downloadIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n};\n\nexport type CustomStylesType = {\n pdfViewer?: React.CSSProperties;\n header?: React.CSSProperties;\n pdfIconWrapper?: React.CSSProperties;\n pdfName?: React.CSSProperties;\n pdfContainer?: React.CSSProperties;\n emptyState?: React.CSSProperties;\n};\n\nexport type CustomClassesType = {\n header?: string;\n pdfName?: string;\n actionButton?: string;\n pdfViewerWrapper?: string;\n};\n\nexport type PdfSegment = {\n title: string;\n start_page: number;\n end_page: number;\n page_count: number;\n};\n\ntype PdfScaleOption =\n | \"ActualSize\"\n | \"PageFit\"\n | \"PageWidth\"\n | number;\nexport interface PdfNavigationRequest {\n pageNumber: number;\n /** Change this value to navigate to the same page more than once. */\n requestId?: string | number;\n}\n\nexport interface PdfNavigationSettledEvent extends PdfNavigationRequest {\n pageNumber: number;\n}\n\nexport interface PdfViewerProps {\n pdfUrl?: string;\n highlightText: string[];\n highlightPages?: any;\n highlightCordinatePages: HighlightArea[];\n highlightColor?: string;\n activeHighlightColor?: string;\n jumpToPageValue?: number;\n pdfName?: string;\n onClose?: () => void;\n item?: any;\n customStyles?: CustomStylesType;\n customClasses?: CustomClassesType;\n customIcons?: CustomIconsType;\n useCoordinates: boolean;\n fallbackPages?: CitationPage[];\n activeCitationIndex?: number;\n onActiveCitationChange?: (index: number) => void;\n headerAction?: {\n icon?: React.ReactNode;\n onClick?: () => void;\n tooltip?: string;\n };\n isZoomEnabled?: boolean;\n showHighlightsAction?: boolean;\n defaultScale?: PdfScaleOption;\n useRange?: boolean; //\n rangeOfPages?: number[] | null;\n showFullScreenAction?: boolean;\n showRotateButton?: boolean;\n segments?: PdfSegment[];\n segmentTooltipText?: string;\n onCurrentPageChange?: (pageNumber: number) => void;\n navigationRequest?: PdfNavigationRequest | null;\n onNavigationSettled?: (event: PdfNavigationSettledEvent) => void;\n disablePdfAnnotations?: boolean;\n disablePdfTextLayer?: boolean;\n renderPage?: RenderPage;\n setRenderRange?: SetRenderRange;\n}\n\nconst getResolvedScale = (\n scale?: PdfScaleOption\n): SpecialZoomLevel | number => {\n switch (scale) {\n case \"ActualSize\":\n return SpecialZoomLevel.ActualSize;\n\n case \"PageFit\":\n return SpecialZoomLevel.PageFit;\n\n case \"PageWidth\":\n return SpecialZoomLevel.PageWidth;\n\n default:\n return scale ?? SpecialZoomLevel.PageWidth;\n }\n};\n\nexport type HighlightArea = {\n pageIndex: number;\n left: number;\n top: number;\n width: number;\n height: number;\n pageNumber?: number;\n};\n\nconst PdfViewer = ({\n pdfUrl,\n highlightText,\n highlightPages,\n highlightCordinatePages,\n highlightColor = \"yellow\",\n activeHighlightColor = \"#f7dc51\",\n jumpToPageValue = 0,\n pdfName,\n onClose,\n customStyles,\n customClasses,\n customIcons,\n useCoordinates,\n fallbackPages,\n activeCitationIndex,\n onActiveCitationChange,\n headerAction,\n isZoomEnabled = true,\n showHighlightsAction = true,\n defaultScale = SpecialZoomLevel.ActualSize,\n useRange = false,\n rangeOfPages = null,\n showFullScreenAction=true,\n showRotateButton = false,\n segments = [\n {\n title: \"Document 2\",\n start_page: 52,\n end_page: 52,\n page_count: 1,\n },\n ],\n segmentTooltipText,\n onCurrentPageChange,\n navigationRequest,\n onNavigationSettled,\n disablePdfAnnotations = false,\n disablePdfTextLayer = false,\n renderPage,\n setRenderRange,\n}: PdfViewerProps) => {\n\n const viewerRef = useRef<HTMLDivElement | null>(null);\n const resolvedDefaultScale = getResolvedScale(defaultScale);\n const [currentPage, setCurrentPage] = useState(0);\n const [totalPages, setTotalPages] = useState(0);\n const [currentPageRotation, setCurrentPageRotation] = useState(0);\n const lastNavigationRequestRef = useRef<string | null>(null);\n const navigationSettleTimerRef = useRef<number | null>(null);\n const navigationSettleSequenceRef = useRef(0);\n const mutationObserverRef = useRef<MutationObserver | null>(null);\n\n // Generate PDF identifier for localStorage from URL\n const pdfIdentifier = useMemo(() => {\n if (!pdfUrl) return '';\n // Use last part of URL or hash it\n try {\n const url = new URL(pdfUrl, window.location.origin);\n return url.pathname.split('/').pop() || 'default';\n } catch {\n return 'default';\n }\n }, [pdfUrl]);\n\n // Set up rotation manager with PDF identifier\n useEffect(() => {\n if (pdfIdentifier) {\n rotationManager.setPdfIdentifier(pdfIdentifier);\n }\n }, [pdfIdentifier]);\n\n // Handler for rotating current page (no state update)\n const handleRotatePage = () => {\n const pageNumber = currentPage + 1;\n rotationManager.rotatePageBy90(pageNumber);\n // Manually update state to reflect rotation in UI\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n };\n\n // Subscribe to rotation changes to sync UI state\n useEffect(() => {\n const unsubscribe = rotationManager.onRotationChange((pageNum, angle) => {\n // Only update state if current page rotated\n if (pageNum === currentPage + 1) {\n setCurrentPageRotation(angle);\n }\n });\n\n return unsubscribe;\n }, [currentPage]);\n\n // Register page elements with rotation manager\n useEffect(() => {\n const observer = new MutationObserver(() => {\n // Find all newly rendered page elements\n const pageElements = viewerRef.current?.querySelectorAll(\n '[data-testid^=\"core__page-layer-\"]'\n );\n\n const registeredPages = new Set<number>();\n\n pageElements?.forEach((pageElement) => {\n const match = (pageElement as HTMLElement)\n .getAttribute('data-testid')\n ?.match(/core__page-layer-(\\d+)/);\n if (match && match.length >= 2) {\n const pageIndex = parseInt(match[1], 10);\n const pageNumber = pageIndex + 1;\n\n // Only register once per page\n if (!registeredPages.has(pageNumber)) {\n rotationManager.registerPageElement(pageNumber, pageElement as HTMLElement);\n registeredPages.add(pageNumber);\n }\n }\n });\n });\n\n if (viewerRef.current) {\n observer.observe(viewerRef.current, {\n childList: true,\n subtree: true,\n attributes: false,\n });\n mutationObserverRef.current = observer;\n }\n\n return () => {\n observer.disconnect();\n mutationObserverRef.current = null;\n };\n }, []);\n\n // Clean up when unmounting\n useEffect(() => {\n return () => {\n rotationManager.clearAll();\n if (mutationObserverRef.current) {\n mutationObserverRef.current.disconnect();\n }\n };\n }, []);\n\n // Update current page rotation when page changes\n useEffect(() => {\n const pageNumber = currentPage + 1;\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n }, [currentPage]);\n const resolvedRenderPage = useMemo<RenderPage | undefined>(() => {\n if (!disablePdfAnnotations && !disablePdfTextLayer) return renderPage;\n\n return (props) => {\n const resolvedTextLayerChildren = disablePdfTextLayer ? (\n <div aria-hidden=\"true\" style={{ display: \"none\" }}>\n {props.textLayer.children}\n </div>\n ) : props.textLayer.children;\n const resolvedProps = {\n ...props,\n annotationLayer: {\n ...props.annotationLayer,\n children: disablePdfAnnotations ? null : props.annotationLayer.children,\n },\n textLayer: {\n ...props.textLayer,\n children: resolvedTextLayerChildren,\n },\n };\n\n const renderedPage = renderPage\n ? renderPage(resolvedProps)\n : (\n <>\n {props.canvasLayer.children}\n {resolvedTextLayerChildren}\n {!disablePdfAnnotations && props.annotationLayer.children}\n </>\n );\n\n return renderedPage;\n };\n }, [disablePdfAnnotations, disablePdfTextLayer, renderPage]);\n\n const cleanHighlightTexts = (texts: string[]): string[] => {\n if (!texts || texts.length === 0) return texts;\n return texts.filter((text) => {\n return !texts.some(\n (otherText) => otherText !== text && otherText.includes(text)\n );\n });\n };\n\n const highlightPageSet = useMemo(() => {\n if (useCoordinates) {\n return new Set(highlightCordinatePages.map((h: any) => h.pageIndex));\n } else {\n const set = new Set<number>();\n Object.values(highlightPages).forEach((p: any) => {\n if (p > 0) set.add(p - 1);\n });\n return set;\n }\n }, [highlightCordinatePages, highlightPages, useCoordinates]);\n\n const removeRedundantHighlightTexts = cleanHighlightTexts(highlightText);\n\n const {\n highlightIndex,\n setHighlightIndex,\n cursorIndex,\n setCursorIndex,\n orderedKeys,\n totalHighlights,\n getValidPosition,\n tryJump,\n jumpToPage,\n zoomTo,\n plugins,\n controls,\n hideNonTargetHighlights,\n deduplicateHighlights,\n scrollToCoord,\n } = PdfHighlightControls(\n removeRedundantHighlightTexts,\n !useCoordinates ? highlightPages : {},\n viewerRef,\n highlightPageSet,\n useCoordinates,\n useCoordinates ? highlightCordinatePages : [],\n highlightColor,\n activeHighlightColor\n );\n\n const currentPosition = getValidPosition(cursorIndex);\n const currentSegment = useMemo(() => {\n const pageNumber = currentPage + 1;\n return segments.find(\n (segment) =>\n pageNumber >= segment.start_page && pageNumber <= segment.end_page\n );\n }, [currentPage, segments]);\n\n // sync external activeCitationIndex → cursorIndex\n useEffect(() => {\n if (activeCitationIndex === undefined) return;\n if (activeCitationIndex === cursorIndex) return;\n setCursorIndex(activeCitationIndex);\n }, [activeCitationIndex]);\n\n // wrap controls to fire onActiveCitationChange\n const handleGoToNext = () => {\n if (cursorIndex >= totalHighlights - 1) return;\n controls.goToNext();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex + 1);\n };\n\n const handleGoToPrevious = () => {\n if (cursorIndex <= 0) return;\n controls.goToPrevious();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex - 1);\n };\n\n const modifiedControls = {\n ...controls,\n goToNext: handleGoToNext,\n goToPrevious: handleGoToPrevious,\n };\n\n const handlePageNavigate = (pageNumber: number) => {\n const nextPage = Math.min(Math.max(pageNumber, 1), totalPages || pageNumber);\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n };\n\n const waitForNavigationToSettle = React.useCallback((\n request: PdfNavigationRequest,\n pageNumber: number\n ) => {\n navigationSettleSequenceRef.current += 1;\n const settleSequence = navigationSettleSequenceRef.current;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n\n let previousScrollTop: number | null = null;\n let stableChecks = 0;\n let attempts = 0;\n\n const checkScrollPosition = () => {\n if (navigationSettleSequenceRef.current !== settleSequence) return;\n\n attempts += 1;\n\n const scrollContainer = viewerRef.current?.querySelector(\n '.rpv-core__inner-pages'\n ) as HTMLElement | null;\n const targetPage = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${pageNumber - 1}\"]`\n ) as HTMLElement | null;\n\n // Virtualized page layers are not guaranteed to be mounted on the first\n // check after jumpToPage. Keep polling so navigation completion is not\n // lost while React PDF Viewer is creating the target page DOM.\n if (!scrollContainer || !targetPage) {\n if (attempts >= 40) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n return;\n }\n\n if (previousScrollTop === scrollContainer.scrollTop) {\n stableChecks += 1;\n } else {\n previousScrollTop = scrollContainer.scrollTop;\n stableChecks = 0;\n }\n\n const scrollRect = scrollContainer.getBoundingClientRect();\n const pageRect = targetPage.getBoundingClientRect();\n const isTargetVisible = Boolean(\n scrollRect &&\n pageRect &&\n pageRect.bottom > scrollRect.top &&\n pageRect.top < scrollRect.bottom\n );\n const hasSettled = stableChecks >= 2 && isTargetVisible;\n const reachedTimeout = attempts >= 40;\n\n if (hasSettled || reachedTimeout) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n };\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n }, [onNavigationSettled]);\n\n useEffect(() => () => {\n navigationSettleSequenceRef.current += 1;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n }, []);\n\n useEffect(() => {\n if (!navigationRequest || totalPages <= 0) return;\n\n const nextPage = Math.min(\n Math.max(Math.trunc(navigationRequest.pageNumber), 1),\n totalPages\n );\n const requestKey = `${navigationRequest.requestId ?? nextPage}:${nextPage}`;\n if (lastNavigationRequestRef.current === requestKey) return;\n\n lastNavigationRequestRef.current = requestKey;\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n waitForNavigationToSettle(navigationRequest, nextPage);\n }, [jumpToPage, navigationRequest, totalPages, waitForNavigationToSettle]);\n\n if (!pdfUrl) {\n return (\n <ScannedDocCitation\n pages={fallbackPages}\n activeCitationIndex={activeCitationIndex}\n onActiveCitationChange={onActiveCitationChange}\n headerAction={headerAction}\n />\n );\n }\n\n const defaultViewerStyles: React.CSSProperties = {\n display: \"flex\",\n flexDirection: \"column\",\n height: \"100%\",\n width: \"100%\",\n backgroundColor: \"#FAFAFA\",\n };\n\n const scrollToHighlight = () => {\n if (!viewerRef.current) return;\n\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const targetPage = page > 0 ? page - 1 : 0;\n\n const pageVisitMap: Record<number, number[]> = {};\n orderedKeys.forEach((k, i) => {\n const p = highlightPages[k];\n if (p > 0) {\n if (!pageVisitMap[p]) pageVisitMap[p] = [];\n pageVisitMap[p].push(i);\n }\n });\n const visits = pageVisitMap[page] || [];\n const occurrence = visits.indexOf(index);\n\n let attempts = 0;\n const maxAttempts = 40;\n\n const doScrollToHighlight = () => {\n attempts++;\n if (attempts > maxAttempts) return;\n\n const scrollContainer = viewerRef.current?.querySelector(\n \".rpv-core__inner-pages\"\n ) as HTMLElement;\n if (!scrollContainer) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const pageElement = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${targetPage}\"]`\n );\n if (!pageElement) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const scrollContainerRect = scrollContainer.getBoundingClientRect();\n const pageRect = pageElement.getBoundingClientRect();\n const isPageVisible =\n pageRect.top < scrollContainerRect.bottom &&\n pageRect.bottom > scrollContainerRect.top;\n\n if (!isPageVisible) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const allHighlights = pageElement.querySelectorAll(\".rpv-search__highlight\");\n const target = allHighlights[occurrence] as HTMLElement;\n\n if (!target) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const highlightRect = target.getBoundingClientRect();\n const scrollTop =\n scrollContainer.scrollTop +\n (highlightRect.top - scrollContainerRect.top) -\n scrollContainer.clientHeight / 2 +\n highlightRect.height / 2;\n\n scrollContainer.scrollTo({ top: scrollTop, behavior: \"smooth\" });\n };\n\n setTimeout(doScrollToHighlight, 500);\n };\n\n return (\n <div\n ref={viewerRef}\n className={[\"citation-pdf-viewer\", customClasses?.pdfViewerWrapper]\n .filter(Boolean)\n .join(\" \")}\n data-disable-pdf-annotations={\n disablePdfAnnotations ? \"true\" : undefined\n }\n data-pdf-page-fit={\n resolvedDefaultScale === SpecialZoomLevel.PageFit ? \"true\" : undefined\n }\n style={{\n height: \"100%\",\n minHeight: 0,\n minWidth: 0,\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n ...pdfStyles.pdfViewer,\n ...defaultViewerStyles,\n ...customStyles?.pdfViewer,\n backgroundColor: \"#F1F5F9\",\n }}\n >\n <PdfToolbar\n highlightIndex={highlightIndex}\n totalHighlights={totalHighlights}\n controls={modifiedControls}\n currentPosition={currentPosition}\n pdfName={pdfName}\n onClose={onClose}\n pdfUrl={pdfUrl}\n viewerRef={viewerRef}\n customStyles={customStyles}\n customClasses={customClasses}\n customIcons={customIcons}\n headerAction={headerAction}\n isZoomEnabled={isZoomEnabled}\n showHighlightsAction={showHighlightsAction}\n showFullScreenAction={showFullScreenAction} \n currentSegment={currentSegment}\n segmentTooltipText={segmentTooltipText}\n currentPage={currentPage + 1}\n totalPages={totalPages}\n onPageNavigate={handlePageNavigate}\n onRotatePage={handleRotatePage}\n currentPageRotation={currentPageRotation}\n showRotateButton={showRotateButton}\n />\n <PdfContainer\n defaultScale={resolvedDefaultScale}\n pdfUrl={pdfUrl}\n plugins={plugins}\n customStyles={customStyles}\n onLoad={(e: DocumentLoadEvent) => {\n setTotalPages(e.doc.numPages);\n\n const shouldAutoJumpToFirstMatch =\n !useCoordinates && !useRange && jumpToPageValue <= 0;\n\n if (jumpToPageValue > 0 && !useRange) {\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const cordinateTargetHighlight = highlightCordinatePages[index];\n setCursorIndex(index);\n\n console.log(cordinateTargetHighlight, \"cordinateTargetHighlight\");\n if (useCoordinates && cordinateTargetHighlight.pageIndex > 0)\n jumpToPage(cordinateTargetHighlight.pageIndex);\n\n if (page > 0) {\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(page - 1);\n }, 1000);\n if (!useCoordinates) {\n jumpToPage(page - 1);\n }\n }\n } else if (useRange && rangeOfPages && rangeOfPages.length === 2) {\n \n // Async function to handle sequential jumping and waiting\n const scanRangeSequence = async () => {\n const [startPage, endPage] = rangeOfPages;\n \n for (let p = startPage; p <= endPage; p++) {\n const targetPageIndex = p - 1;\n \n jumpToPage(targetPageIndex);\n \n // Pause execution for 1 second to let the DOM render the highlights\n await new Promise((resolve) => setTimeout(resolve, 1000));\n \n hideNonTargetHighlights(highlightPageSet);\n const matchSize = deduplicateHighlights(targetPageIndex);\n \n // If the returned size is greater than 0, a match was found. Stop the loop.\n if (matchSize && matchSize > 0) {\n break; \n }\n }\n };\n\n scanRangeSequence();\n\n } else if (!useCoordinates && highlightPages) {\n const firstKey = orderedKeys.find(k => highlightPages[k] > 0);\n if (firstKey !== undefined) {\n const firstPage = highlightPages[firstKey] - 1;\n jumpToPage(firstPage);\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(firstPage);\n }, 1000);\n }\n }\n\n requestAnimationFrame(() => {\n if (shouldAutoJumpToFirstMatch) {\n tryJump();\n }\n if (!useCoordinates && jumpToPageValue > 0 && !useRange) {\n scrollToHighlight();\n }\n });\n }}\n onPageChange={(e: PageChangeEvent) => {\n const currentPage = e.currentPage;\n setCurrentPage(currentPage);\n onCurrentPageChange?.(currentPage + 1);\n if (!highlightPageSet.has(currentPage)) {\n hideNonTargetHighlights(highlightPageSet);\n return;\n }\n deduplicateHighlights(currentPage);\n hideNonTargetHighlights(highlightPageSet);\n }}\n renderPage={resolvedRenderPage}\n setRenderRange={setRenderRange}\n />\n </div>\n );\n};\n\nexport default PdfViewer;\n"],"names":["pdfUrl","highlightText","highlightPages","highlightCordinatePages","highlightColor","activeHighlightColor","jumpToPageValue","pdfName","onClose","customStyles","customClasses","customIcons","useCoordinates","fallbackPages","activeCitationIndex","onActiveCitationChange","headerAction","isZoomEnabled","showHighlightsAction","defaultScale","SpecialZoomLevel","ActualSize","useRange","rangeOfPages","showFullScreenAction","showRotateButton","segments","title","start_page","end_page","page_count","segmentTooltipText","onCurrentPageChange","navigationRequest","onNavigationSettled","disablePdfAnnotations","disablePdfTextLayer","renderPage","setRenderRange","viewerRef","useRef","resolvedDefaultScale","scale","PageFit","PageWidth","getResolvedScale","currentPage","setCurrentPage","useState","totalPages","setTotalPages","currentPageRotation","setCurrentPageRotation","lastNavigationRequestRef","navigationSettleTimerRef","navigationSettleSequenceRef","mutationObserverRef","pdfIdentifier","useMemo","URL","window","location","origin","pathname","split","pop","useEffect","rotationManager","setPdfIdentifier","onRotationChange","pageNum","angle","observer","MutationObserver","pageElements","current","querySelectorAll","registeredPages","Set","forEach","pageElement","match","getAttribute","length","pageNumber","parseInt","has","registerPageElement","add","observe","childList","subtree","attributes","disconnect","clearAll","getRotation","resolvedRenderPage","props","resolvedTextLayerChildren","jsx","style","display","children","textLayer","resolvedProps","annotationLayer","jsxs","Fragment","canvasLayer","highlightPageSet","map","h","pageIndex","set","Object","values","p","removeRedundantHighlightTexts","texts","filter","text","some","otherText","includes","highlightIndex","setHighlightIndex","cursorIndex","setCursorIndex","orderedKeys","totalHighlights","getValidPosition","tryJump","jumpToPage","zoomTo","plugins","controls","hideNonTargetHighlights","deduplicateHighlights","scrollToCoord","PdfHighlightControls","currentPosition","currentSegment","find","segment","modifiedControls","goToNext","goToPrevious","waitForNavigationToSettle","React","useCallback","request","settleSequence","clearTimeout","previousScrollTop","stableChecks","attempts","checkScrollPosition","scrollContainer","querySelector","targetPage","requestId","setTimeout","scrollTop","scrollRect","getBoundingClientRect","pageRect","isTargetVisible","Boolean","bottom","top","nextPage","Math","min","max","trunc","requestKey","ScannedDocCitation","pages","ref","className","pdfViewerWrapper","join","height","minHeight","minWidth","overflow","flexDirection","pdfStyles","pdfViewer","width","backgroundColor","PdfToolbar","onPageNavigate","onRotatePage","rotatePageBy90","PdfContainer","onLoad","e","doc","numPages","shouldAutoJumpToFirstMatch","index","key","page","cordinateTargetHighlight","console","log","async","startPage","endPage","targetPageIndex","Promise","resolve","matchSize","scanRangeSequence","firstKey","k","firstPage","requestAnimationFrame","pageVisitMap","i","push","occurrence","indexOf","doScrollToHighlight","scrollContainerRect","target","highlightRect","clientHeight","scrollTo","behavior","scrollToHighlight","onPageChange"],"mappings":"guBA+HkB,EAChBA,SACAC,gBACAC,iBACAC,0BACAC,iBAAiB,SACjBC,uBAAuB,UACvBC,kBAAkB,EAClBC,UACAC,UACAC,eACAC,gBACAC,cACAC,iBACAC,gBACAC,sBACAC,yBACAC,eACAC,iBAAgB,EAChBC,wBAAuB,EACvBC,eAAeC,EAAiBA,iBAAAC,WAChCC,YAAW,EACXC,eAAe,KACfC,wBAAqB,EACrBC,oBAAmB,EACnBC,WAAW,CACT,CACEC,MAAO,aACPC,WAAY,GACZC,SAAU,GACVC,WAAY,IAGhBC,qBACAC,sBACAC,oBACAC,sBACAC,yBAAwB,EACxBC,uBAAsB,EACtBC,aACAC,qBAGM,MAAAC,EAAYC,SAA8B,MAC1CC,EAvEiB,CACvBC,IAEA,OAAQA,GACN,IAAK,aACH,OAAOtB,EAAAA,iBAAiBC,WAE1B,IAAK,UACH,OAAOD,EAAAA,iBAAiBuB,QAE1B,IAAK,YACH,OAAOvB,EAAAA,iBAAiBwB,UAE1B,QACE,OAAOF,GAAStB,EAAiBA,iBAA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ASyD,EAAoBxD,KAItC,YADAR,WAAW+D,EAAqB,KAI5B,MACAE,EADgBlJ,EAAYJ,iBAAiB,0BACtBkJ,GAE7B,IAAKI,EAEH,YADAjE,WAAW+D,EAAqB,KAI5B,MAAAG,EAAgBD,EAAO9D,wBACvBF,EACJL,EAAgBK,WACfiE,EAAc1D,IAAMwD,EAAoBxD,KACzCZ,EAAgBuE,aAAe,EAC/BD,EAAc7C,OAAS,EAEzBzB,EAAgBwE,SAAS,CAAE5D,IAAKP,EAAWoE,SAAU,YAGvDrE,WAAW+D,EAAqB,MA+HJO,MAIxBC,aAAenC,IACb,MAAMvJ,EAAcuJ,EAAEvJ,YACtBC,EAAeD,GACfd,IAAsBc,EAAc,GAC/B+D,GAAiBvB,IAAIxC,IAI1B2F,GAAsB3F,GACtB0F,GAAwB3B,KAJtB2B,GAAwB3B,KAM5BxE,WAAY2D,GACZ1D"}
1
+ {"version":3,"file":"PdfViewer.js","sources":["../../../../src/features/PdfViewer/PdfViewer.tsx"],"sourcesContent":["import { DocumentLoadEvent, PageChangeEvent, RenderPage, SetRenderRange, SpecialZoomLevel, type LoadError } from \"@react-pdf-viewer/core\";\nimport PdfContainer from \"./PdfContainer\";\nimport PdfToolbar from \"./PdfToolbar\";\nimport { pdfStyles } from \"./PdfStyle\";\nimport { PdfHighlightControls } from \"./usePdfHighlight\";\nimport { rotationManager } from \"./rotationManager\";\nimport \"@react-pdf-viewer/zoom/lib/styles/index.css\";\nimport \"@react-pdf-viewer/page-navigation/lib/styles/index.css\";\nimport \"@react-pdf-viewer/core/lib/styles/index.css\";\nimport \"@react-pdf-viewer/search/lib/styles/index.css\";\nimport React, { useMemo, useRef, useEffect, useState } from \"react\";\nimport ScannedDocCitation, { CitationPage } from \"../ScannedDocCitation/ScannedDocCitation\";\nimport \"./PdfViewer.css\";\n\nexport type CustomIconsType = {\n pdfIcon?: React.ReactNode;\n fullScreenIcon?: React.ReactNode;\n downloadIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n};\n\nexport type CustomStylesType = {\n pdfViewer?: React.CSSProperties;\n header?: React.CSSProperties;\n pdfIconWrapper?: React.CSSProperties;\n pdfName?: React.CSSProperties;\n pdfContainer?: React.CSSProperties;\n emptyState?: React.CSSProperties;\n};\n\nexport type CustomClassesType = {\n header?: string;\n pdfName?: string;\n actionButton?: string;\n pdfViewerWrapper?: string;\n};\n\nexport type PdfSegment = {\n title: string;\n start_page: number;\n end_page: number;\n page_count: number;\n};\n\ntype PdfScaleOption =\n | \"ActualSize\"\n | \"PageFit\"\n | \"PageWidth\"\n | number;\nexport interface PdfNavigationRequest {\n pageNumber: number;\n /** Change this value to navigate to the same page more than once. */\n requestId?: string | number;\n}\n\nexport interface PdfNavigationSettledEvent extends PdfNavigationRequest {\n pageNumber: number;\n}\n\nexport interface PdfViewerProps {\n pdfUrl?: string;\n highlightText: string[];\n highlightPages?: any;\n highlightCordinatePages: HighlightArea[];\n highlightColor?: string;\n activeHighlightColor?: string;\n jumpToPageValue?: number;\n pdfName?: string;\n onClose?: () => void;\n item?: any;\n customStyles?: CustomStylesType;\n customClasses?: CustomClassesType;\n customIcons?: CustomIconsType;\n useCoordinates: boolean;\n fallbackPages?: CitationPage[];\n activeCitationIndex?: number;\n onActiveCitationChange?: (index: number) => void;\n headerAction?: {\n icon?: React.ReactNode;\n onClick?: () => void;\n tooltip?: string;\n };\n isZoomEnabled?: boolean;\n showHighlightsAction?: boolean;\n defaultScale?: PdfScaleOption;\n useRange?: boolean; //\n rangeOfPages?: number[] | null;\n showFullScreenAction?: boolean;\n showRotateButton?: boolean;\n segments?: PdfSegment[];\n segmentTooltipText?: string;\n onCurrentPageChange?: (pageNumber: number) => void;\n navigationRequest?: PdfNavigationRequest | null;\n onNavigationSettled?: (event: PdfNavigationSettledEvent) => void;\n disablePdfAnnotations?: boolean;\n disablePdfTextLayer?: boolean;\n renderPage?: RenderPage;\n setRenderRange?: SetRenderRange;\n onError?: (error: LoadError) => void;\n}\n\nconst getResolvedScale = (\n scale?: PdfScaleOption\n): SpecialZoomLevel | number => {\n switch (scale) {\n case \"ActualSize\":\n return SpecialZoomLevel.ActualSize;\n\n case \"PageFit\":\n return SpecialZoomLevel.PageFit;\n\n case \"PageWidth\":\n return SpecialZoomLevel.PageWidth;\n\n default:\n return scale ?? SpecialZoomLevel.PageWidth;\n }\n};\n\nexport type HighlightArea = {\n pageIndex: number;\n left: number;\n top: number;\n width: number;\n height: number;\n pageNumber?: number;\n};\n\nconst PdfViewer = ({\n pdfUrl,\n highlightText,\n highlightPages,\n highlightCordinatePages,\n highlightColor = \"yellow\",\n activeHighlightColor = \"#f7dc51\",\n jumpToPageValue = 0,\n pdfName,\n onClose,\n customStyles,\n customClasses,\n customIcons,\n useCoordinates,\n fallbackPages,\n activeCitationIndex,\n onActiveCitationChange,\n headerAction,\n isZoomEnabled = true,\n showHighlightsAction = true,\n defaultScale = SpecialZoomLevel.ActualSize,\n useRange = false,\n rangeOfPages = null,\n showFullScreenAction=true,\n showRotateButton = false,\n segments = [\n {\n title: \"Document 2\",\n start_page: 52,\n end_page: 52,\n page_count: 1,\n },\n ],\n segmentTooltipText,\n onCurrentPageChange,\n navigationRequest,\n onNavigationSettled,\n disablePdfAnnotations = false,\n disablePdfTextLayer = false,\n renderPage,\n setRenderRange,\n onError\n}: PdfViewerProps) => {\n\n const viewerRef = useRef<HTMLDivElement | null>(null);\n const resolvedDefaultScale = getResolvedScale(defaultScale);\n const [currentPage, setCurrentPage] = useState(0);\n const [totalPages, setTotalPages] = useState(0);\n const [currentPageRotation, setCurrentPageRotation] = useState(0);\n const lastNavigationRequestRef = useRef<string | null>(null);\n const navigationSettleTimerRef = useRef<number | null>(null);\n const navigationSettleSequenceRef = useRef(0);\n const mutationObserverRef = useRef<MutationObserver | null>(null);\n\n // Generate PDF identifier for localStorage from URL\n const pdfIdentifier = useMemo(() => {\n if (!pdfUrl) return '';\n // Use last part of URL or hash it\n try {\n const url = new URL(pdfUrl, window.location.origin);\n return url.pathname.split('/').pop() || 'default';\n } catch {\n return 'default';\n }\n }, [pdfUrl]);\n\n // Set up rotation manager with PDF identifier\n useEffect(() => {\n if (pdfIdentifier) {\n rotationManager.setPdfIdentifier(pdfIdentifier);\n }\n }, [pdfIdentifier]);\n\n // Handler for rotating current page (no state update)\n const handleRotatePage = () => {\n const pageNumber = currentPage + 1;\n rotationManager.rotatePageBy90(pageNumber);\n // Manually update state to reflect rotation in UI\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n };\n\n // Subscribe to rotation changes to sync UI state\n useEffect(() => {\n const unsubscribe = rotationManager.onRotationChange((pageNum, angle) => {\n // Only update state if current page rotated\n if (pageNum === currentPage + 1) {\n setCurrentPageRotation(angle);\n }\n });\n\n return unsubscribe;\n }, [currentPage]);\n\n // Register page elements with rotation manager\n useEffect(() => {\n const observer = new MutationObserver(() => {\n // Find all newly rendered page elements\n const pageElements = viewerRef.current?.querySelectorAll(\n '[data-testid^=\"core__page-layer-\"]'\n );\n\n const registeredPages = new Set<number>();\n\n pageElements?.forEach((pageElement) => {\n const match = (pageElement as HTMLElement)\n .getAttribute('data-testid')\n ?.match(/core__page-layer-(\\d+)/);\n if (match && match.length >= 2) {\n const pageIndex = parseInt(match[1], 10);\n const pageNumber = pageIndex + 1;\n\n // Only register once per page\n if (!registeredPages.has(pageNumber)) {\n rotationManager.registerPageElement(pageNumber, pageElement as HTMLElement);\n registeredPages.add(pageNumber);\n }\n }\n });\n });\n\n if (viewerRef.current) {\n observer.observe(viewerRef.current, {\n childList: true,\n subtree: true,\n attributes: false,\n });\n mutationObserverRef.current = observer;\n }\n\n return () => {\n observer.disconnect();\n mutationObserverRef.current = null;\n };\n }, []);\n\n // Clean up when unmounting\n useEffect(() => {\n return () => {\n rotationManager.clearAll();\n if (mutationObserverRef.current) {\n mutationObserverRef.current.disconnect();\n }\n };\n }, []);\n\n // Update current page rotation when page changes\n useEffect(() => {\n const pageNumber = currentPage + 1;\n setCurrentPageRotation(rotationManager.getRotation(pageNumber));\n }, [currentPage]);\n const resolvedRenderPage = useMemo<RenderPage | undefined>(() => {\n if (!disablePdfAnnotations && !disablePdfTextLayer) return renderPage;\n\n return (props) => {\n const resolvedTextLayerChildren = disablePdfTextLayer ? (\n <div aria-hidden=\"true\" style={{ display: \"none\" }}>\n {props.textLayer.children}\n </div>\n ) : props.textLayer.children;\n const resolvedProps = {\n ...props,\n annotationLayer: {\n ...props.annotationLayer,\n children: disablePdfAnnotations ? null : props.annotationLayer.children,\n },\n textLayer: {\n ...props.textLayer,\n children: resolvedTextLayerChildren,\n },\n };\n\n const renderedPage = renderPage\n ? renderPage(resolvedProps)\n : (\n <>\n {props.canvasLayer.children}\n {resolvedTextLayerChildren}\n {!disablePdfAnnotations && props.annotationLayer.children}\n </>\n );\n\n return renderedPage;\n };\n }, [disablePdfAnnotations, disablePdfTextLayer, renderPage]);\n\n const cleanHighlightTexts = (texts: string[]): string[] => {\n if (!texts || texts.length === 0) return texts;\n return texts.filter((text) => {\n return !texts.some(\n (otherText) => otherText !== text && otherText.includes(text)\n );\n });\n };\n\n const highlightPageSet = useMemo(() => {\n if (useCoordinates) {\n return new Set(highlightCordinatePages.map((h: any) => h.pageIndex));\n } else {\n const set = new Set<number>();\n Object.values(highlightPages).forEach((p: any) => {\n if (p > 0) set.add(p - 1);\n });\n return set;\n }\n }, [highlightCordinatePages, highlightPages, useCoordinates]);\n\n const removeRedundantHighlightTexts = cleanHighlightTexts(highlightText);\n\n const {\n highlightIndex,\n setHighlightIndex,\n cursorIndex,\n setCursorIndex,\n orderedKeys,\n totalHighlights,\n getValidPosition,\n tryJump,\n jumpToPage,\n zoomTo,\n plugins,\n controls,\n hideNonTargetHighlights,\n deduplicateHighlights,\n scrollToCoord,\n } = PdfHighlightControls(\n removeRedundantHighlightTexts,\n !useCoordinates ? highlightPages : {},\n viewerRef,\n highlightPageSet,\n useCoordinates,\n useCoordinates ? highlightCordinatePages : [],\n highlightColor,\n activeHighlightColor\n );\n\n const currentPosition = getValidPosition(cursorIndex);\n const currentSegment = useMemo(() => {\n const pageNumber = currentPage + 1;\n return segments.find(\n (segment) =>\n pageNumber >= segment.start_page && pageNumber <= segment.end_page\n );\n }, [currentPage, segments]);\n\n // sync external activeCitationIndex → cursorIndex\n useEffect(() => {\n if (activeCitationIndex === undefined) return;\n if (activeCitationIndex === cursorIndex) return;\n setCursorIndex(activeCitationIndex);\n }, [activeCitationIndex]);\n\n // wrap controls to fire onActiveCitationChange\n const handleGoToNext = () => {\n if (cursorIndex >= totalHighlights - 1) return;\n controls.goToNext();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex + 1);\n };\n\n const handleGoToPrevious = () => {\n if (cursorIndex <= 0) return;\n controls.goToPrevious();\n if (onActiveCitationChange) onActiveCitationChange(cursorIndex - 1);\n };\n\n const modifiedControls = {\n ...controls,\n goToNext: handleGoToNext,\n goToPrevious: handleGoToPrevious,\n };\n\n const handlePageNavigate = (pageNumber: number) => {\n const nextPage = Math.min(Math.max(pageNumber, 1), totalPages || pageNumber);\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n };\n\n const waitForNavigationToSettle = React.useCallback((\n request: PdfNavigationRequest,\n pageNumber: number\n ) => {\n navigationSettleSequenceRef.current += 1;\n const settleSequence = navigationSettleSequenceRef.current;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n\n let previousScrollTop: number | null = null;\n let stableChecks = 0;\n let attempts = 0;\n\n const checkScrollPosition = () => {\n if (navigationSettleSequenceRef.current !== settleSequence) return;\n\n attempts += 1;\n\n const scrollContainer = viewerRef.current?.querySelector(\n '.rpv-core__inner-pages'\n ) as HTMLElement | null;\n const targetPage = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${pageNumber - 1}\"]`\n ) as HTMLElement | null;\n\n // Virtualized page layers are not guaranteed to be mounted on the first\n // check after jumpToPage. Keep polling so navigation completion is not\n // lost while React PDF Viewer is creating the target page DOM.\n if (!scrollContainer || !targetPage) {\n if (attempts >= 40) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n return;\n }\n\n if (previousScrollTop === scrollContainer.scrollTop) {\n stableChecks += 1;\n } else {\n previousScrollTop = scrollContainer.scrollTop;\n stableChecks = 0;\n }\n\n const scrollRect = scrollContainer.getBoundingClientRect();\n const pageRect = targetPage.getBoundingClientRect();\n const isTargetVisible = Boolean(\n scrollRect &&\n pageRect &&\n pageRect.bottom > scrollRect.top &&\n pageRect.top < scrollRect.bottom\n );\n const hasSettled = stableChecks >= 2 && isTargetVisible;\n const reachedTimeout = attempts >= 40;\n\n if (hasSettled || reachedTimeout) {\n navigationSettleTimerRef.current = null;\n onNavigationSettled?.({\n pageNumber,\n requestId: request.requestId,\n });\n return;\n }\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n };\n\n navigationSettleTimerRef.current = window.setTimeout(checkScrollPosition, 50);\n }, [onNavigationSettled]);\n\n useEffect(() => () => {\n navigationSettleSequenceRef.current += 1;\n if (navigationSettleTimerRef.current != null) {\n window.clearTimeout(navigationSettleTimerRef.current);\n }\n }, []);\n\n useEffect(() => {\n if (!navigationRequest || totalPages <= 0) return;\n\n const nextPage = Math.min(\n Math.max(Math.trunc(navigationRequest.pageNumber), 1),\n totalPages\n );\n const requestKey = `${navigationRequest.requestId ?? nextPage}:${nextPage}`;\n if (lastNavigationRequestRef.current === requestKey) return;\n\n lastNavigationRequestRef.current = requestKey;\n setCurrentPage(nextPage - 1);\n jumpToPage(nextPage - 1);\n waitForNavigationToSettle(navigationRequest, nextPage);\n }, [jumpToPage, navigationRequest, totalPages, waitForNavigationToSettle]);\n\n if (!pdfUrl) {\n return (\n <ScannedDocCitation\n pages={fallbackPages}\n activeCitationIndex={activeCitationIndex}\n onActiveCitationChange={onActiveCitationChange}\n headerAction={headerAction}\n />\n );\n }\n\n const defaultViewerStyles: React.CSSProperties = {\n display: \"flex\",\n flexDirection: \"column\",\n height: \"100%\",\n width: \"100%\",\n backgroundColor: \"#FAFAFA\",\n };\n\n const scrollToHighlight = () => {\n if (!viewerRef.current) return;\n\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const targetPage = page > 0 ? page - 1 : 0;\n\n const pageVisitMap: Record<number, number[]> = {};\n orderedKeys.forEach((k, i) => {\n const p = highlightPages[k];\n if (p > 0) {\n if (!pageVisitMap[p]) pageVisitMap[p] = [];\n pageVisitMap[p].push(i);\n }\n });\n const visits = pageVisitMap[page] || [];\n const occurrence = visits.indexOf(index);\n\n let attempts = 0;\n const maxAttempts = 40;\n\n const doScrollToHighlight = () => {\n attempts++;\n if (attempts > maxAttempts) return;\n\n const scrollContainer = viewerRef.current?.querySelector(\n \".rpv-core__inner-pages\"\n ) as HTMLElement;\n if (!scrollContainer) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const pageElement = viewerRef.current?.querySelector(\n `[data-testid=\"core__page-layer-${targetPage}\"]`\n );\n if (!pageElement) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const scrollContainerRect = scrollContainer.getBoundingClientRect();\n const pageRect = pageElement.getBoundingClientRect();\n const isPageVisible =\n pageRect.top < scrollContainerRect.bottom &&\n pageRect.bottom > scrollContainerRect.top;\n\n if (!isPageVisible) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const allHighlights = pageElement.querySelectorAll(\".rpv-search__highlight\");\n const target = allHighlights[occurrence] as HTMLElement;\n\n if (!target) {\n setTimeout(doScrollToHighlight, 100);\n return;\n }\n\n const highlightRect = target.getBoundingClientRect();\n const scrollTop =\n scrollContainer.scrollTop +\n (highlightRect.top - scrollContainerRect.top) -\n scrollContainer.clientHeight / 2 +\n highlightRect.height / 2;\n\n scrollContainer.scrollTo({ top: scrollTop, behavior: \"smooth\" });\n };\n\n setTimeout(doScrollToHighlight, 500);\n };\n\n return (\n <div\n ref={viewerRef}\n className={[\"citation-pdf-viewer\", customClasses?.pdfViewerWrapper]\n .filter(Boolean)\n .join(\" \")}\n data-disable-pdf-annotations={\n disablePdfAnnotations ? \"true\" : undefined\n }\n data-pdf-page-fit={\n resolvedDefaultScale === SpecialZoomLevel.PageFit ? \"true\" : undefined\n }\n style={{\n height: \"100%\",\n minHeight: 0,\n minWidth: 0,\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n ...pdfStyles.pdfViewer,\n ...defaultViewerStyles,\n ...customStyles?.pdfViewer,\n backgroundColor: \"#F1F5F9\",\n }}\n >\n <PdfToolbar\n highlightIndex={highlightIndex}\n totalHighlights={totalHighlights}\n controls={modifiedControls}\n currentPosition={currentPosition}\n pdfName={pdfName}\n onClose={onClose}\n pdfUrl={pdfUrl}\n viewerRef={viewerRef}\n customStyles={customStyles}\n customClasses={customClasses}\n customIcons={customIcons}\n headerAction={headerAction}\n isZoomEnabled={isZoomEnabled}\n showHighlightsAction={showHighlightsAction}\n showFullScreenAction={showFullScreenAction} \n currentSegment={currentSegment}\n segmentTooltipText={segmentTooltipText}\n currentPage={currentPage + 1}\n totalPages={totalPages}\n onPageNavigate={handlePageNavigate}\n onRotatePage={handleRotatePage}\n currentPageRotation={currentPageRotation}\n showRotateButton={showRotateButton}\n />\n <PdfContainer\n defaultScale={resolvedDefaultScale}\n pdfUrl={pdfUrl}\n plugins={plugins}\n customStyles={customStyles}\n onError={onError}\n onLoad={(e: DocumentLoadEvent) => {\n setTotalPages(e.doc.numPages);\n\n const shouldAutoJumpToFirstMatch =\n !useCoordinates && !useRange && jumpToPageValue <= 0;\n\n if (jumpToPageValue > 0 && !useRange) {\n const index = jumpToPageValue - 1;\n const key = orderedKeys[index];\n const page = highlightPages[key];\n const cordinateTargetHighlight = highlightCordinatePages[index];\n setCursorIndex(index);\n\n console.log(cordinateTargetHighlight, \"cordinateTargetHighlight\");\n if (useCoordinates && cordinateTargetHighlight.pageIndex > 0)\n jumpToPage(cordinateTargetHighlight.pageIndex);\n\n if (page > 0) {\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(page - 1);\n }, 1000);\n if (!useCoordinates) {\n jumpToPage(page - 1);\n }\n }\n } else if (useRange && rangeOfPages && rangeOfPages.length === 2) {\n \n // Async function to handle sequential jumping and waiting\n const scanRangeSequence = async () => {\n const [startPage, endPage] = rangeOfPages;\n \n for (let p = startPage; p <= endPage; p++) {\n const targetPageIndex = p - 1;\n \n jumpToPage(targetPageIndex);\n \n // Pause execution for 1 second to let the DOM render the highlights\n await new Promise((resolve) => setTimeout(resolve, 1000));\n \n hideNonTargetHighlights(highlightPageSet);\n const matchSize = deduplicateHighlights(targetPageIndex);\n \n // If the returned size is greater than 0, a match was found. Stop the loop.\n if (matchSize && matchSize > 0) {\n break; \n }\n }\n };\n\n scanRangeSequence();\n\n } else if (!useCoordinates && highlightPages) {\n const firstKey = orderedKeys.find(k => highlightPages[k] > 0);\n if (firstKey !== undefined) {\n const firstPage = highlightPages[firstKey] - 1;\n jumpToPage(firstPage);\n setTimeout(() => {\n hideNonTargetHighlights(highlightPageSet);\n deduplicateHighlights(firstPage);\n }, 1000);\n }\n }\n\n requestAnimationFrame(() => {\n if (shouldAutoJumpToFirstMatch) {\n tryJump();\n }\n if (!useCoordinates && jumpToPageValue > 0 && !useRange) {\n scrollToHighlight();\n }\n });\n }}\n onPageChange={(e: PageChangeEvent) => {\n const currentPage = e.currentPage;\n setCurrentPage(currentPage);\n onCurrentPageChange?.(currentPage + 1);\n if (!highlightPageSet.has(currentPage)) {\n hideNonTargetHighlights(highlightPageSet);\n return;\n }\n deduplicateHighlights(currentPage);\n hideNonTargetHighlights(highlightPageSet);\n }}\n renderPage={resolvedRenderPage}\n setRenderRange={setRenderRange}\n />\n </div>\n );\n};\n\nexport default PdfViewer;\n"],"names":["pdfUrl","highlightText","highlightPages","highlightCordinatePages","highlightColor","activeHighlightColor","jumpToPageValue","pdfName","onClose","customStyles","customClasses","customIcons","useCoordinates","fallbackPages","activeCitationIndex","onActiveCitationChange","headerAction","isZoomEnabled","showHighlightsAction","defaultScale","SpecialZoomLevel","ActualSize","useRange","rangeOfPages","showFullScreenAction","showRotateButton","segments","title","start_page","end_page","page_count","segmentTooltipText","onCurrentPageChange","navigationRequest","onNavigationSettled","disablePdfAnnotations","disablePdfTextLayer","renderPage","setRenderRange","onError","viewerRef","useRef","resolvedDefaultScale","scale","PageFit","PageWidth","getResolvedScale","currentPage","setCurrentPage","useState","totalPages","setTotalPages","currentPageRotation","setCurrentPageRotation","lastNavigationRequestRef","navigationSettleTimerRef","navigationSettleSequenceRef","mutationObserverRef","pdfIdentifier","useMemo","URL","window","location","origin","pathname","split","pop","useEffect","rotationManager","setPdfIdentifier","onRotationChange","pageNum","angle","observer","MutationObserver","pageElements","current","querySelectorAll","registeredPages","Set","forEach","pageElement","match","getAttribute","length","pageNumber","parseInt","has","registerPageElement","add","observe","childList","subtree","attributes","disconnect","clearAll","getRotation","resolvedRenderPage","props","resolvedTextLayerChildren","jsx","style","display","children","textLayer","resolvedProps","annotationLayer","jsxs","Fragment","canvasLayer","highlightPageSet","map","h","pageIndex","set","Object","values","p","removeRedundantHighlightTexts","texts","filter","text","some","otherText","includes","highlightIndex","setHighlightIndex","cursorIndex","setCursorIndex","orderedKeys","totalHighlights","getValidPosition","tryJump","jumpToPage","zoomTo","plugins","controls","hideNonTargetHighlights","deduplicateHighlights","scrollToCoord","PdfHighlightControls","currentPosition","currentSegment","find","segment","modifiedControls","goToNext","goToPrevious","waitForNavigationToSettle","React","useCallback","request","settleSequence","clearTimeout","previousScrollTop","stableChecks","attempts","checkScrollPosition","scrollContainer","querySelector","targetPage","requestId","setTimeout","scrollTop","scrollRect","getBoundingClientRect","pageRect","isTargetVisible","Boolean","bottom","top","nextPage","Math","min","max","trunc","requestKey","ScannedDocCitation","pages","ref","className","pdfViewerWrapper","join","height","minHeight","minWidth","overflow","flexDirection","pdfStyles","pdfViewer","width","backgroundColor","PdfToolbar","onPageNavigate","onRotatePage","rotatePageBy90","PdfContainer","onLoad","e","doc","numPages","shouldAutoJumpToFirstMatch","index","key","page","cordinateTargetHighlight","console","log","async","startPage","endPage","targetPageIndex","Promise","resolve","matchSize","scanRangeSequence","firstKey","k","firstPage","requestAnimationFrame","pageVisitMap","i","push","occurrence","indexOf","doScrollToHighlight","scrollContainerRect","target","highlightRect","clientHeight","scrollTo","behavior","scrollToHighlight","onPageChange"],"mappings":"guBAgIkB,EAChBA,SACAC,gBACAC,iBACAC,0BACAC,iBAAiB,SACjBC,uBAAuB,UACvBC,kBAAkB,EAClBC,UACAC,UACAC,eACAC,gBACAC,cACAC,iBACAC,gBACAC,sBACAC,yBACAC,eACAC,iBAAgB,EAChBC,wBAAuB,EACvBC,eAAeC,EAAiBA,iBAAAC,WAChCC,YAAW,EACXC,eAAe,KACfC,wBAAqB,EACrBC,oBAAmB,EACnBC,WAAW,CACT,CACEC,MAAO,aACPC,WAAY,GACZC,SAAU,GACVC,WAAY,IAGhBC,qBACAC,sBACAC,oBACAC,sBACAC,yBAAwB,EACxBC,uBAAsB,EACtBC,aACAC,iBACAC,cAGM,MAAAC,EAAYC,SAA8B,MAC1CC,EAxEiB,CACvBC,IAEA,OAAQA,GACN,IAAK,aACH,OAAOvB,EAAAA,iBAAiBC,WAE1B,IAAK,UACH,OAAOD,EAAAA,iBAAiBwB,QAE1B,IAAK,YACH,OAAOxB,EAAAA,iBAAiByB,UAE1B,QACE,OAAOF,GAASvB,EAAiBA,iBAAAyB,YA0DRC,CAAiB3B,IACvC4B,EAAaC,GAAkBC,WAAS,IACxCC,EAAYC,GAAiBF,WAAS,IACtCG,EAAqBC,GAA0BJ,WAAS,GACzDK,EAA2Bb,SAAsB,MACjDc,EAA2Bd,SAAsB,MACjDe,GAA8Bf,SAAO,GACrCgB,GAAsBhB,SAAgC,MAGtDiB,GAAgBC,EAAAA,QAAQ,KACxB,IAAC3D,EAAe,MAAA,GAEhB,IAEF,OADY,IAAI4D,IAAI5D,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,SAAS,CAAE5D,IAAKP,EAAWoE,SAAU,YAGvDrE,WAAW+D,EAAqB,MAgIJO,MAIxBC,aAAenC,IACb,MAAMvJ,EAAcuJ,EAAEvJ,YACtBC,EAAeD,GACff,IAAsBe,EAAc,GAC/B+D,GAAiBvB,IAAIxC,IAI1B2F,GAAsB3F,GACtB0F,GAAwB3B,KAJtB2B,GAAwB3B,KAM5BzE,WAAY4D,GACZ3D"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Stack"),t=require("@mui/material/Typography");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(r),l=a(i),n=a(t);exports.default=function({icon:r,description:i}){return e.jsxs(l.default,{direction:"row",alignItems:"flex-start",spacing:.625,sx:{px:.75,py:.625,border:"1px solid #86EFAC",borderRadius:2,bgcolor:"#FFFFFF",color:"#16A34A"},children:[e.jsx(o.default,{"aria-hidden":"true",sx:{display:"flex",flexShrink:0,mt:"1px",fontSize:14},children:r}),e.jsx(n.default,{sx:{minWidth:0,color:"inherit",fontSize:11,lineHeight:1.5,overflowWrap:"anywhere"},children:i})]})};
2
+ //# sourceMappingURL=ApprovalDescriptionBanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalDescriptionBanner.js","sources":["../../../../src/features/SegmentReviewComponents/ApprovalDescriptionBanner.tsx"],"sourcesContent":["import { type ReactNode } from 'react';\nimport Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nexport interface ApprovalDescriptionBannerProps {\n icon: ReactNode;\n description: string;\n}\n\n/**\n * Green confirmation banner shown above the revert action, e.g.\n * \"A reviewer confirmed this document's page range.\"\n */\nexport default function ApprovalDescriptionBanner({\n icon,\n description,\n}: ApprovalDescriptionBannerProps) {\n return (\n <Stack\n direction=\"row\"\n alignItems=\"flex-start\"\n spacing={0.625}\n sx={{\n px: 0.75,\n py: 0.625,\n border: '1px solid #86EFAC',\n borderRadius: 2,\n bgcolor: '#FFFFFF',\n color: '#16A34A',\n }}\n >\n <Box\n aria-hidden=\"true\"\n sx={{ display: 'flex', flexShrink: 0, mt: '1px', fontSize: 14 }}\n >\n {icon}\n </Box>\n <Typography\n sx={{\n minWidth: 0,\n color: 'inherit',\n fontSize: 11,\n lineHeight: 1.5,\n overflowWrap: 'anywhere',\n }}\n >\n {description}\n </Typography>\n </Stack>\n );\n}"],"names":["icon","description","jsxs","Stack","direction","alignItems","spacing","sx","px","py","border","borderRadius","bgcolor","color","children","jsx","Box","display","flexShrink","mt","fontSize","Typography","minWidth","lineHeight","overflowWrap"],"mappings":"8TAcA,UAAkDA,KAChDA,EAAAC,YACAA,IAGE,OAAAC,EAAAA,KAACC,EAAA,QAAA,CACCC,UAAU,MACVC,WAAW,aACXC,QAAS,KACTC,GAAI,CACFC,GAAI,IACJC,GAAI,KACJC,OAAQ,oBACRC,aAAc,EACdC,QAAS,UACTC,MAAO,WAGTC,SAAA,CAAAC,EAAAA,IAACC,EAAA,QAAA,CACC,cAAY,OACZT,GAAI,CAAEU,QAAS,OAAQC,WAAY,EAAGC,GAAI,MAAOC,SAAU,IAE1DN,SAAAd,IAEHe,EAAAA,IAACM,EAAA,QAAA,CACCd,GAAI,CACFe,SAAU,EACVT,MAAO,UACPO,SAAU,GACVG,WAAY,IACZC,aAAc,YAGfV,SAAAb,MAIT"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Box"),i=require("@mui/material/Button"),n=require("@mui/material/ButtonBase"),o=require("@mui/material/Divider"),l=require("@mui/material/Stack"),a=require("@mui/material/Tooltip"),d=require("@mui/material/Typography"),s=require("lucide-react");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=c(t),u=c(i),f=c(n),h=c(o),m=c(l),g=c(a),p=c(d);const b=({startPage:e,endPage:r})=>`Pages ${e}-${r}`,j=({segment:r})=>e.jsxs(x.default,{sx:{px:.75,py:.625,minWidth:0},children:[e.jsx(p.default,{sx:{color:"text.secondary",fontSize:11,lineHeight:1.3,overflowWrap:"anywhere"},children:r.title}),e.jsx(p.default,{sx:{color:"text.primary",fontSize:12,fontWeight:400,lineHeight:1.3},children:b(r)})]});const v={minHeight:34,borderColor:"#94A3B8",color:"#64748B",borderRadius:"8px",fontSize:12,fontWeight:500,textTransform:"none"},y={minHeight:34,borderRadius:"8px",bgcolor:"#4F46E5",fontSize:12,fontWeight:500,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:"#4338CA",boxShadow:"none"}};exports.default=function({icon:t,title:i,pageRange:n,description:o,onRevert:l,onRevertComplete:a,onRevertError:d,revertData:c,confirmDisabled:b=!1,showDocumentHeader:C=!0}){const[S,R]=r.useState(!1),[w,W]=r.useState(!1),F=c.previousSegments.length>0,z=async()=>{if(!w&&!b){W(!0);try{const e=await l();a?.(e)}catch(e){d?.(e)}finally{W(!1)}}};return e.jsxs(m.default,{spacing:.875,sx:{minWidth:0},children:[C&&e.jsxs(x.default,{sx:{minWidth:0},children:[e.jsx(p.default,{sx:{color:"text.primary",fontSize:14,fontWeight:500,lineHeight:1.4,overflowWrap:"anywhere"},children:i}),e.jsx(p.default,{sx:{color:"text.secondary",fontSize:12,lineHeight:1.4},children:n})]}),o&&e.jsxs(m.default,{direction:"row",alignItems:"flex-start",spacing:.625,sx:{px:.75,py:.625,border:"1px solid #86EFAC",borderRadius:2,bgcolor:"#FFFFFF",color:"#16A34A"},children:[e.jsx(x.default,{"aria-hidden":"true",sx:{display:"flex",flexShrink:0,mt:"1px",fontSize:14},children:t}),e.jsx(p.default,{sx:{minWidth:0,color:"inherit",fontSize:11,lineHeight:1.5,overflowWrap:"anywhere"},children:o})]}),e.jsx(h.default,{sx:{borderStyle:"dashed",borderColor:"#CBD5E1"}}),S?e.jsxs(m.default,{spacing:.75,children:[e.jsxs(f.default,{onClick:()=>R(!1),"aria-label":"Back from revert confirmation",sx:{width:"fit-content",borderRadius:.5,color:"text.primary",fontSize:13,fontWeight:500,lineHeight:1.3,textAlign:"left"},children:[e.jsx(x.default,{component:"span","aria-hidden":"true",sx:{mr:.625,alignItems:"center",display:"flex"},children:e.jsx(s.ChevronLeft,{size:16})}),"Revert"]}),F?e.jsxs(x.default,{sx:{p:.75,borderRadius:1,bgcolor:"#F8FAFC"},children:[e.jsx(p.default,{sx:{mb:.375,color:"text.secondary",fontSize:12},children:"Current"}),e.jsx(x.default,{sx:{mb:.75,border:"1px solid #E2E8F0",borderRadius:1,bgcolor:"background.paper"},children:e.jsx(j,{segment:c.currentSegment})}),e.jsx(p.default,{sx:{mb:.375,color:"text.secondary",fontSize:12},children:"After Revert"}),e.jsx(x.default,{sx:{border:"1px solid #E2E8F0",borderRadius:1,bgcolor:"background.paper",overflow:"hidden"},children:c.previousSegments.map((r,t)=>e.jsxs(x.default,{children:[t>0&&e.jsx(h.default,{sx:{borderColor:"#E2E8F0"}}),e.jsx(j,{segment:r})]},`${r.title}-${r.startPage}-${r.endPage}-${t}`))}),e.jsxs(m.default,{direction:"row",spacing:1,sx:{mt:.875},children:[e.jsx(u.default,{variant:"outlined",fullWidth:!0,disabled:w,onClick:()=>R(!1),sx:v,children:"Cancel"}),e.jsx(g.default,{title:b?"Revert data is not present, cannot revert this":"",disableHoverListener:!b,arrow:!0,children:e.jsx("span",{style:{flex:1},children:e.jsx(u.default,{variant:"contained",fullWidth:!0,disabled:w||b,onClick:()=>{z()},sx:y,children:w?"Reverting…":"Confirm"})})})]})]}):e.jsxs(x.default,{sx:{p:.875,borderRadius:1,bgcolor:"#F8FAFC"},children:[e.jsx(p.default,{sx:{color:"text.secondary",fontSize:12,fontWeight:500},children:"Revert approval?"}),e.jsx(p.default,{sx:{mt:.75,color:"text.secondary",fontSize:13,lineHeight:1.45},children:"This document will be moved back to pending review and will need to be confirmed again."}),e.jsxs(m.default,{direction:"row",spacing:1,sx:{mt:1},children:[e.jsx(u.default,{variant:"outlined",fullWidth:!0,disabled:w,onClick:()=>R(!1),sx:v,children:"Cancel"}),e.jsx(g.default,{title:b?"Revert data is not present, cannot revert this":"",disableHoverListener:!b,arrow:!0,children:e.jsx("span",{style:{flex:1},children:e.jsx(u.default,{variant:"contained",fullWidth:!0,disabled:w||b,onClick:()=>{z()},sx:y,children:w?"Reverting…":"Confirm"})})})]})]})]}):e.jsx(u.default,{variant:"outlined",fullWidth:!0,onClick:()=>R(!0),sx:{minHeight:36,borderColor:"#9B8AFB",color:"#5925DC",borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none","&:hover":{borderColor:"secondary.dark",bgcolor:"rgba(79, 70, 229, 0.04)"}},children:"Revert"})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Box"),i=require("@mui/material/Button"),n=require("@mui/material/ButtonBase"),o=require("@mui/material/Divider"),a=require("@mui/material/Stack"),l=require("@mui/material/Tooltip"),d=require("@mui/material/Typography"),s=require("lucide-react");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(t),x=c(i),f=c(n),h=c(o),g=c(a),m=c(l),b=c(d);const p=({startPage:e,endPage:r})=>`Pages ${e}-${r}`,v=({segment:r})=>e.jsxs(u.default,{sx:{px:.75,py:.625,minWidth:0},children:[e.jsx(b.default,{sx:{color:"text.secondary",fontSize:11,lineHeight:1.3,overflowWrap:"anywhere"},children:r.title}),e.jsx(b.default,{sx:{color:"text.primary",fontSize:12,fontWeight:400,lineHeight:1.3},children:p(r)})]});const j={minHeight:34,borderColor:"#94A3B8",color:"#64748B",borderRadius:"8px",fontSize:12,fontWeight:500,textTransform:"none"},y={minHeight:34,borderRadius:"8px",bgcolor:"#4F46E5",fontSize:12,fontWeight:500,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:"#4338CA",boxShadow:"none"}};exports.default=function({icon:t,title:i,pageRange:n,description:o,onRevert:a,onRevertComplete:l,onRevertError:d,revertData:c,confirmDisabled:p=!1,showDocumentHeader:C=!0,onSaveAsLearning:S,onSaveAsLearningError:R,saveAsLearningDisabled:w=!1}){const[W,z]=r.useState(!1),[k,H]=r.useState(!1),F=c.previousSegments.length>0,q=async()=>{if(!k&&!p){H(!0);try{const e=await a();l?.(e)}catch(e){d?.(e)}finally{H(!1)}}};return e.jsxs(g.default,{spacing:.875,sx:{minWidth:0},children:[C&&e.jsxs(u.default,{sx:{minWidth:0},children:[e.jsx(b.default,{sx:{color:"text.primary",fontSize:14,fontWeight:500,lineHeight:1.4,overflowWrap:"anywhere"},children:i}),e.jsx(b.default,{sx:{color:"text.secondary",fontSize:12,lineHeight:1.4},children:n})]}),e.jsx(h.default,{sx:{borderStyle:"dashed",borderColor:"#CBD5E1"}}),W?e.jsxs(g.default,{spacing:.75,children:[e.jsxs(f.default,{onClick:()=>z(!1),"aria-label":"Back from revert confirmation",sx:{width:"fit-content",borderRadius:.5,color:"text.primary",fontSize:13,fontWeight:500,lineHeight:1.3,textAlign:"left"},children:[e.jsx(u.default,{component:"span","aria-hidden":"true",sx:{mr:.625,alignItems:"center",display:"flex"},children:e.jsx(s.ChevronLeft,{size:16})}),"Revert"]}),F?e.jsxs(u.default,{sx:{p:.75,borderRadius:1,bgcolor:"#F8FAFC"},children:[e.jsx(b.default,{sx:{mb:.375,color:"text.secondary",fontSize:12},children:"Current"}),e.jsx(u.default,{sx:{mb:.75,border:"1px solid #E2E8F0",borderRadius:1,bgcolor:"background.paper"},children:e.jsx(v,{segment:c.currentSegment})}),e.jsx(b.default,{sx:{mb:.375,color:"text.secondary",fontSize:12},children:"After Revert"}),e.jsx(u.default,{sx:{border:"1px solid #E2E8F0",borderRadius:1,bgcolor:"background.paper",overflow:"hidden"},children:c.previousSegments.map((r,t)=>e.jsxs(u.default,{children:[t>0&&e.jsx(h.default,{sx:{borderColor:"#E2E8F0"}}),e.jsx(v,{segment:r})]},`${r.title}-${r.startPage}-${r.endPage}-${t}`))}),e.jsxs(g.default,{direction:"row",spacing:1,sx:{mt:.875},children:[e.jsx(x.default,{variant:"outlined",fullWidth:!0,disabled:k,onClick:()=>z(!1),sx:j,children:"Cancel"}),e.jsx(m.default,{title:p?"Revert data is not present, cannot revert this":"",disableHoverListener:!p,arrow:!0,children:e.jsx("span",{style:{flex:1},children:e.jsx(x.default,{variant:"contained",fullWidth:!0,disabled:k||p,onClick:()=>{q()},sx:y,children:k?"Reverting…":"Confirm"})})})]})]}):e.jsxs(u.default,{sx:{p:.875,borderRadius:1,bgcolor:"#F8FAFC"},children:[e.jsx(b.default,{sx:{color:"text.secondary",fontSize:12,fontWeight:500},children:"Revert approval?"}),e.jsx(b.default,{sx:{mt:.75,color:"text.secondary",fontSize:13,lineHeight:1.45},children:"This document will be moved back to pending review and will need to be confirmed again."}),e.jsxs(g.default,{direction:"row",spacing:1,sx:{mt:1},children:[e.jsx(x.default,{variant:"outlined",fullWidth:!0,disabled:k,onClick:()=>z(!1),sx:j,children:"Cancel"}),e.jsx(m.default,{title:p?"Revert data is not present, cannot revert this":"",disableHoverListener:!p,arrow:!0,children:e.jsx("span",{style:{flex:1},children:e.jsx(x.default,{variant:"contained",fullWidth:!0,disabled:k||p,onClick:()=>{q()},sx:y,children:k?"Reverting…":"Confirm"})})})]})]})]}):e.jsx(x.default,{variant:"outlined",fullWidth:!0,onClick:()=>z(!0),sx:{minHeight:36,borderColor:"#9B8AFB",color:"#5925DC",borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none","&:hover":{borderColor:"secondary.dark",bgcolor:"rgba(79, 70, 229, 0.04)"}},children:"Revert"})]})};
2
2
  //# sourceMappingURL=RevertCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RevertCard.js","sources":["../../../../src/features/SegmentReviewComponents/RevertCard.tsx"],"sourcesContent":["import { useState, type ReactNode } from 'react';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport ButtonBase from '@mui/material/ButtonBase';\nimport Divider from '@mui/material/Divider';\nimport Stack from '@mui/material/Stack';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport { ChevronLeft } from 'lucide-react';\n\nexport interface SegmentData {\n title: string;\n startPage: number;\n endPage: number;\n}\n\nexport interface RevertData {\n currentSegment: SegmentData;\n previousSegments: SegmentData[];\n}\n\n/** Value returned by the host after the revert request and refresh complete. */\nexport interface RevertActionResult {\n message?: string | null;\n}\n\nexport interface RevertCardProps {\n icon: ReactNode;\n title: string;\n pageRange: string;\n description: string | null;\n onRevert: () => void | RevertActionResult | Promise<void | RevertActionResult>;\n /** Called only after `onRevert` completes successfully. */\n onRevertComplete?: (result: void | RevertActionResult) => void;\n onRevertError?: (error: unknown) => void;\n revertData: RevertData;\n /** Prevent submission when the host cannot provide a valid revert request. */\n confirmDisabled?: boolean;\n /** Hide when the surrounding reviewed-card shell already renders it. */\n showDocumentHeader?: boolean;\n}\n\nconst formatPageRange = ({ startPage, endPage }: SegmentData) =>\n `Pages ${startPage}-${endPage}`;\n\nconst SegmentSummary = ({ segment }: { segment: SegmentData }) => (\n <Box sx={{ px: 0.75, py: 0.625, minWidth: 0 }}>\n <Typography\n sx={{\n color: 'text.secondary',\n fontSize: 11,\n lineHeight: 1.3,\n overflowWrap: 'anywhere',\n }}\n >\n {segment.title}\n </Typography>\n <Typography\n sx={{\n color: 'text.primary',\n fontSize: 12,\n fontWeight: 400,\n lineHeight: 1.3,\n }}\n >\n {formatPageRange(segment)}\n </Typography>\n </Box>\n);\n\n/**\n * Displays an approved action summary and reveals the appropriate revert\n * confirmation after the user selects Revert. An empty `previousSegments`\n * collection represents keep-as-is; structural changes provide the segments\n * that will be restored after reverting.\n */\nexport default function RevertCard({\n icon,\n title,\n pageRange,\n description,\n onRevert,\n onRevertComplete,\n onRevertError,\n revertData,\n confirmDisabled = false,\n showDocumentHeader = true,\n}: RevertCardProps) {\n const [isConfirming, setIsConfirming] = useState(false);\n const [isReverting, setIsReverting] = useState(false);\n const hasStructuralChanges = revertData.previousSegments.length > 0;\n const handleConfirm = async () => {\n if (isReverting || confirmDisabled) return;\n setIsReverting(true);\n\n try {\n const result = await onRevert();\n onRevertComplete?.(result);\n } catch (error) {\n onRevertError?.(error);\n } finally {\n setIsReverting(false);\n }\n };\n\n return (\n <Stack spacing={0.875} sx={{ minWidth: 0 }}>\n {showDocumentHeader && (\n <Box sx={{ minWidth: 0 }}>\n <Typography\n sx={{\n color: 'text.primary',\n fontSize: 14,\n fontWeight: 500,\n lineHeight: 1.4,\n overflowWrap: 'anywhere',\n }}\n >\n {title}\n </Typography>\n <Typography\n sx={{ color: 'text.secondary', fontSize: 12, lineHeight: 1.4 }}\n >\n {pageRange}\n </Typography>\n </Box>\n )}\n\n {description && <Stack\n direction=\"row\"\n alignItems=\"flex-start\"\n spacing={0.625}\n sx={{\n px: 0.75,\n py: 0.625,\n border: '1px solid #86EFAC',\n borderRadius: 2,\n bgcolor: '#FFFFFF',\n color: '#16A34A',\n }}\n >\n <Box\n aria-hidden=\"true\"\n sx={{ display: 'flex', flexShrink: 0, mt: '1px', fontSize: 14 }}\n >\n {icon}\n </Box>\n <Typography\n sx={{\n minWidth: 0,\n color: 'inherit',\n fontSize: 11,\n lineHeight: 1.5,\n overflowWrap: 'anywhere',\n }}\n >\n {description}\n </Typography>\n </Stack>}\n\n <Divider sx={{ borderStyle: 'dashed', borderColor: '#CBD5E1' }} />\n\n {!isConfirming ? (\n <Button\n variant=\"outlined\"\n fullWidth\n onClick={() => setIsConfirming(true)}\n sx={{\n minHeight: 36,\n borderColor: '#9B8AFB',\n color: '#5925DC',\n borderRadius: 2,\n fontSize: 13,\n fontWeight: 600,\n textTransform: 'none',\n '&:hover': {\n borderColor: 'secondary.dark',\n bgcolor: 'rgba(79, 70, 229, 0.04)',\n },\n }}\n >\n Revert\n </Button>\n ) : (\n <Stack spacing={0.75}>\n <ButtonBase\n onClick={() => setIsConfirming(false)}\n aria-label=\"Back from revert confirmation\"\n sx={{\n width: 'fit-content',\n borderRadius: 0.5,\n color: 'text.primary',\n fontSize: 13,\n fontWeight: 500,\n lineHeight: 1.3,\n textAlign: 'left',\n }}\n >\n <Box component=\"span\" aria-hidden=\"true\" sx={{ mr: 0.625, alignItems :'center', display: \"flex\" }}>\n <ChevronLeft size={16} />\n </Box>\n Revert\n </ButtonBase>\n\n {hasStructuralChanges ? (\n <Box\n sx={{\n p: 0.75,\n borderRadius: 1,\n bgcolor: '#F8FAFC',\n }}\n >\n <Typography sx={{ mb: 0.375, color: 'text.secondary', fontSize: 12 }}>\n Current\n </Typography>\n <Box\n sx={{\n mb: 0.75,\n border: '1px solid #E2E8F0',\n borderRadius: 1,\n bgcolor: 'background.paper',\n }}\n >\n <SegmentSummary segment={revertData.currentSegment} />\n </Box>\n\n <Typography sx={{ mb: 0.375, color: 'text.secondary', fontSize: 12 }}>\n After Revert\n </Typography>\n <Box\n sx={{\n border: '1px solid #E2E8F0',\n borderRadius: 1,\n bgcolor: 'background.paper',\n overflow: 'hidden',\n }}\n >\n {revertData.previousSegments.map((segment, index) => (\n <Box key={`${segment.title}-${segment.startPage}-${segment.endPage}-${index}`}>\n {index > 0 && <Divider sx={{ borderColor: '#E2E8F0' }} />}\n <SegmentSummary segment={segment} />\n </Box>\n ))}\n </Box>\n\n <Stack direction=\"row\" spacing={1} sx={{ mt: 0.875 }}>\n <Button\n variant=\"outlined\"\n fullWidth\n disabled={isReverting}\n onClick={() => setIsConfirming(false)}\n sx={confirmationButtonSx}\n >\n Cancel\n </Button>\n <Tooltip\n title={confirmDisabled ? 'Revert data is not present, cannot revert this' : ''}\n disableHoverListener={!confirmDisabled}\n arrow\n >\n <span style={{ flex: 1 }}>\n <Button\n variant=\"contained\"\n fullWidth\n disabled={isReverting || confirmDisabled}\n onClick={() => { void handleConfirm(); }}\n sx={confirmButtonSx}\n >\n {isReverting ? 'Reverting…' : 'Confirm'}\n </Button>\n </span>\n </Tooltip>\n </Stack>\n </Box>\n ) : (\n <Box\n sx={{\n p: 0.875,\n borderRadius: 1,\n bgcolor: '#F8FAFC',\n }}\n >\n <Typography\n sx={{ color: 'text.secondary', fontSize: 12, fontWeight: 500 }}\n >\n Revert approval?\n </Typography>\n <Typography\n sx={{ mt: 0.75, color: 'text.secondary', fontSize: 13, lineHeight: 1.45 }}\n >\n This document will be moved back to pending review and will need\n to be confirmed again.\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ mt: 1 }}>\n <Button\n variant=\"outlined\"\n fullWidth\n disabled={isReverting}\n onClick={() => setIsConfirming(false)}\n sx={confirmationButtonSx}\n >\n Cancel\n </Button>\n <Tooltip\n title={confirmDisabled ? 'Revert data is not present, cannot revert this' : ''}\n disableHoverListener={!confirmDisabled}\n arrow\n >\n <span style={{ flex: 1 }}>\n <Button\n variant=\"contained\"\n fullWidth\n disabled={isReverting || confirmDisabled}\n onClick={() => { void handleConfirm(); }}\n sx={confirmButtonSx}\n >\n {isReverting ? 'Reverting…' : 'Confirm'}\n </Button>\n </span>\n </Tooltip>\n </Stack>\n </Box>\n )}\n </Stack>\n )}\n </Stack>\n );\n}\n\nconst confirmationButtonSx = {\n minHeight: 34,\n borderColor: '#94A3B8',\n color: '#64748B',\n borderRadius: \"8px\",\n fontSize: 12,\n fontWeight: 500,\n textTransform: 'none',\n};\n\nconst confirmButtonSx = {\n minHeight: 34,\n borderRadius: \"8px\",\n bgcolor: '#4F46E5',\n fontSize: 12,\n fontWeight: 500,\n textTransform: 'none',\n boxShadow: 'none',\n '&:hover': { bgcolor: '#4338CA', boxShadow: 'none' },\n};\n"],"names":["formatPageRange","startPage","endPage","SegmentSummary","segment","jsxs","Box","sx","px","py","minWidth","children","jsx","Typography","color","fontSize","lineHeight","overflowWrap","title","fontWeight","confirmationButtonSx","minHeight","borderColor","borderRadius","textTransform","confirmButtonSx","bgcolor","boxShadow","icon","pageRange","description","onRevert","onRevertComplete","onRevertError","revertData","confirmDisabled","showDocumentHeader","isConfirming","setIsConfirming","useState","isReverting","setIsReverting","hasStructuralChanges","previousSegments","length","handleConfirm","async","result","error","Stack","spacing","direction","alignItems","border","display","flexShrink","mt","Divider","borderStyle","ButtonBase","onClick","width","textAlign","component","mr","ChevronLeft","size","p","mb","currentSegment","overflow","map","index","Button","variant","fullWidth","disabled","Tooltip","disableHoverListener","arrow","style","flex"],"mappings":"qgBA0CA,MAAMA,EAAkB,EAAGC,YAAWC,aACpC,SAASD,KAAaC,IAElBC,EAAiB,EAAGC,aACvBC,EAAAA,KAAAC,EAAAA,QAAA,CAAIC,GAAI,CAAEC,GAAI,IAAMC,GAAI,KAAOC,SAAU,GACxCC,SAAA,CAAAC,EAAAA,IAACC,EAAA,QAAA,CACCN,GAAI,CACFO,MAAO,iBACPC,SAAU,GACVC,WAAY,IACZC,aAAc,YAGfN,SAAQP,EAAAc,QAEXN,EAAAA,IAACC,EAAA,QAAA,CACCN,GAAI,CACFO,MAAO,eACPC,SAAU,GACVI,WAAY,IACZH,WAAY,KAGbL,WAAgBP,QAwQvB,MAAMgB,EAAuB,CAC3BC,UAAW,GACXC,YAAa,UACbR,MAAO,UACPS,aAAc,MACdR,SAAU,GACVI,WAAY,IACZK,cAAe,QAGXC,EAAkB,CACtBJ,UAAW,GACXE,aAAc,MACdG,QAAS,UACTX,SAAU,GACVI,WAAY,IACZK,cAAe,OACfG,UAAW,OACX,UAAW,CAAED,QAAS,UAAWC,UAAW,yBA/Q9C,UAAmCC,KACjCA,EAAAV,MACAA,EAAAW,UACAA,EAAAC,YACAA,EAAAC,SACAA,EAAAC,iBACAA,EAAAC,cACAA,EAAAC,WACAA,EAAAC,gBACAA,GAAkB,EAAAC,mBAClBA,GAAqB,IAErB,MAAOC,EAAcC,GAAmBC,YAAS,IAC1CC,EAAaC,GAAkBF,YAAS,GACzCG,EAAuBR,EAAWS,iBAAiBC,OAAS,EAC5DC,EAAgBC,UACpB,IAAIN,IAAeL,EAAnB,CACAM,GAAe,GAEX,IACI,MAAAM,QAAehB,IACrBC,IAAmBe,SACZC,GACPf,IAAgBe,EAAK,CAC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cAAe,OACf,UAAW,CACTF,YAAa,iBACbI,QAAS,4BAGdf,SAAA,aAmJT"}
1
+ {"version":3,"file":"RevertCard.js","sources":["../../../../src/features/SegmentReviewComponents/RevertCard.tsx"],"sourcesContent":["import { useState, type ReactNode } from 'react';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport ButtonBase from '@mui/material/ButtonBase';\nimport Divider from '@mui/material/Divider';\nimport Stack from '@mui/material/Stack';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport { ChevronLeft } from 'lucide-react';\nimport ApprovalDescriptionBanner from './ApprovalDescriptionBanner';\nimport SaveAsLearningCard, { type SaveAsLearningResult } from './SaveAsLearningCard';\n\nexport interface SegmentData {\n title: string;\n startPage: number;\n endPage: number;\n}\n\nexport interface RevertData {\n currentSegment: SegmentData;\n previousSegments: SegmentData[];\n}\n\n/** Value returned by the host after the revert request and refresh complete. */\nexport interface RevertActionResult {\n message?: string | null;\n}\n\nexport interface RevertCardProps {\n icon: ReactNode;\n title: string;\n pageRange: string;\n description: string | null;\n onRevert: () => void | RevertActionResult | Promise<void | RevertActionResult>;\n /** Called only after `onRevert` completes successfully. */\n onRevertComplete?: (result: void | RevertActionResult) => void;\n onRevertError?: (error: unknown) => void;\n revertData: RevertData;\n /** Prevent submission when the host cannot provide a valid revert request. */\n confirmDisabled?: boolean;\n /** Hide when the surrounding reviewed-card shell already renders it. */\n showDocumentHeader?: boolean;\n /**\n * When provided, renders the \"save as learning example\" affordance\n * above the revert button, right below the description banner.\n */\n onSaveAsLearning?: () => void | SaveAsLearningResult | Promise<void | SaveAsLearningResult>;\n onSaveAsLearningError?: (error: unknown) => void;\n saveAsLearningDisabled?: boolean;\n}\n\nconst formatPageRange = ({ startPage, endPage }: SegmentData) =>\n `Pages ${startPage}-${endPage}`;\n\nconst SegmentSummary = ({ segment }: { segment: SegmentData }) => (\n <Box sx={{ px: 0.75, py: 0.625, minWidth: 0 }}>\n <Typography\n sx={{\n color: 'text.secondary',\n fontSize: 11,\n lineHeight: 1.3,\n overflowWrap: 'anywhere',\n }}\n >\n {segment.title}\n </Typography>\n <Typography\n sx={{\n color: 'text.primary',\n fontSize: 12,\n fontWeight: 400,\n lineHeight: 1.3,\n }}\n >\n {formatPageRange(segment)}\n </Typography>\n </Box>\n);\n\n/**\n * Displays an approved action summary and reveals the appropriate revert\n * confirmation after the user selects Revert. An empty `previousSegments`\n * collection represents keep-as-is; structural changes provide the segments\n * that will be restored after reverting.\n */\nexport default function RevertCard({\n icon,\n title,\n pageRange,\n description,\n onRevert,\n onRevertComplete,\n onRevertError,\n revertData,\n confirmDisabled = false,\n showDocumentHeader = true,\n onSaveAsLearning,\n onSaveAsLearningError,\n saveAsLearningDisabled = false,\n}: RevertCardProps) {\n const [isConfirming, setIsConfirming] = useState(false);\n const [isReverting, setIsReverting] = useState(false);\n const hasStructuralChanges = revertData.previousSegments.length > 0;\n const handleConfirm = async () => {\n if (isReverting || confirmDisabled) return;\n setIsReverting(true);\n\n try {\n const result = await onRevert();\n onRevertComplete?.(result);\n } catch (error) {\n onRevertError?.(error);\n } finally {\n setIsReverting(false);\n }\n };\n\n return (\n <Stack spacing={0.875} sx={{ minWidth: 0 }}>\n {showDocumentHeader && (\n <Box sx={{ minWidth: 0 }}>\n <Typography\n sx={{\n color: 'text.primary',\n fontSize: 14,\n fontWeight: 500,\n lineHeight: 1.4,\n overflowWrap: 'anywhere',\n }}\n >\n {title}\n </Typography>\n <Typography\n sx={{ color: 'text.secondary', fontSize: 12, lineHeight: 1.4 }}\n >\n {pageRange}\n </Typography>\n </Box>\n )}\n\n \n\n <Divider sx={{ borderStyle: 'dashed', borderColor: '#CBD5E1' }} />\n\n {!isConfirming ? (\n <Button\n variant=\"outlined\"\n fullWidth\n onClick={() => setIsConfirming(true)}\n sx={{\n minHeight: 36,\n borderColor: '#9B8AFB',\n color: '#5925DC',\n borderRadius: 2,\n fontSize: 13,\n fontWeight: 600,\n textTransform: 'none',\n '&:hover': {\n borderColor: 'secondary.dark',\n bgcolor: 'rgba(79, 70, 229, 0.04)',\n },\n }}\n >\n Revert\n </Button>\n ) : (\n <Stack spacing={0.75}>\n <ButtonBase\n onClick={() => setIsConfirming(false)}\n aria-label=\"Back from revert confirmation\"\n sx={{\n width: 'fit-content',\n borderRadius: 0.5,\n color: 'text.primary',\n fontSize: 13,\n fontWeight: 500,\n lineHeight: 1.3,\n textAlign: 'left',\n }}\n >\n <Box component=\"span\" aria-hidden=\"true\" sx={{ mr: 0.625, alignItems: 'center', display: 'flex' }}>\n <ChevronLeft size={16} />\n </Box>\n Revert\n </ButtonBase>\n\n {hasStructuralChanges ? (\n <Box sx={{ p: 0.75, borderRadius: 1, bgcolor: '#F8FAFC' }}>\n <Typography sx={{ mb: 0.375, color: 'text.secondary', fontSize: 12 }}>\n Current\n </Typography>\n <Box\n sx={{\n mb: 0.75,\n border: '1px solid #E2E8F0',\n borderRadius: 1,\n bgcolor: 'background.paper',\n }}\n >\n <SegmentSummary segment={revertData.currentSegment} />\n </Box>\n\n <Typography sx={{ mb: 0.375, color: 'text.secondary', fontSize: 12 }}>\n After Revert\n </Typography>\n <Box\n sx={{\n border: '1px solid #E2E8F0',\n borderRadius: 1,\n bgcolor: 'background.paper',\n overflow: 'hidden',\n }}\n >\n {revertData.previousSegments.map((segment, index) => (\n <Box key={`${segment.title}-${segment.startPage}-${segment.endPage}-${index}`}>\n {index > 0 && <Divider sx={{ borderColor: '#E2E8F0' }} />}\n <SegmentSummary segment={segment} />\n </Box>\n ))}\n </Box>\n\n <Stack direction=\"row\" spacing={1} sx={{ mt: 0.875 }}>\n <Button\n variant=\"outlined\"\n fullWidth\n disabled={isReverting}\n onClick={() => setIsConfirming(false)}\n sx={confirmationButtonSx}\n >\n Cancel\n </Button>\n <Tooltip\n title={confirmDisabled ? 'Revert data is not present, cannot revert this' : ''}\n disableHoverListener={!confirmDisabled}\n arrow\n >\n <span style={{ flex: 1 }}>\n <Button\n variant=\"contained\"\n fullWidth\n disabled={isReverting || confirmDisabled}\n onClick={() => { void handleConfirm(); }}\n sx={confirmButtonSx}\n >\n {isReverting ? 'Reverting…' : 'Confirm'}\n </Button>\n </span>\n </Tooltip>\n </Stack>\n </Box>\n ) : (\n <Box sx={{ p: 0.875, borderRadius: 1, bgcolor: '#F8FAFC' }}>\n <Typography sx={{ color: 'text.secondary', fontSize: 12, fontWeight: 500 }}>\n Revert approval?\n </Typography>\n <Typography sx={{ mt: 0.75, color: 'text.secondary', fontSize: 13, lineHeight: 1.45 }}>\n This document will be moved back to pending review and will need\n to be confirmed again.\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ mt: 1 }}>\n <Button\n variant=\"outlined\"\n fullWidth\n disabled={isReverting}\n onClick={() => setIsConfirming(false)}\n sx={confirmationButtonSx}\n >\n Cancel\n </Button>\n <Tooltip\n title={confirmDisabled ? 'Revert data is not present, cannot revert this' : ''}\n disableHoverListener={!confirmDisabled}\n arrow\n >\n <span style={{ flex: 1 }}>\n <Button\n variant=\"contained\"\n fullWidth\n disabled={isReverting || confirmDisabled}\n onClick={() => { void handleConfirm(); }}\n sx={confirmButtonSx}\n >\n {isReverting ? 'Reverting…' : 'Confirm'}\n </Button>\n </span>\n </Tooltip>\n </Stack>\n </Box>\n )}\n </Stack>\n )}\n </Stack>\n );\n}\n\nconst confirmationButtonSx = {\n minHeight: 34,\n borderColor: '#94A3B8',\n color: '#64748B',\n borderRadius: '8px',\n fontSize: 12,\n fontWeight: 500,\n textTransform: 'none',\n};\n\nconst confirmButtonSx = {\n minHeight: 34,\n borderRadius: '8px',\n bgcolor: '#4F46E5',\n fontSize: 12,\n fontWeight: 500,\n textTransform: 'none',\n boxShadow: 'none',\n '&:hover': { bgcolor: '#4338CA', boxShadow: 'none' },\n};"],"names":["formatPageRange","startPage","endPage","SegmentSummary","segment","jsxs","Box","sx","px","py","minWidth","children","jsx","Typography","color","fontSize","lineHeight","overflowWrap","title","fontWeight","confirmationButtonSx","minHeight","borderColor","borderRadius","textTransform","confirmButtonSx","bgcolor","boxShadow","icon","pageRange","description","onRevert","onRevertComplete","onRevertError","revertData","confirmDisabled","showDocumentHeader","onSaveAsLearning","onSaveAsLearningError","saveAsLearningDisabled","isConfirming","setIsConfirming","useState","isReverting","setIsReverting","hasStructuralChanges","previousSegments","length","handleConfirm","async","result","error","Stack","spacing","Divider","borderStyle","ButtonBase","onClick","width","textAlign","component","mr","alignItems","display","ChevronLeft","size","p","mb","border","currentSegment","overflow","map","index","direction","mt","Button","variant","fullWidth","disabled","Tooltip","disableHoverListener","arrow","style","flex"],"mappings":"qgBAmDA,MAAMA,EAAkB,EAAGC,YAAWC,aACpC,SAASD,KAAaC,IAElBC,EAAiB,EAAGC,aACvBC,EAAAA,KAAAC,EAAAA,QAAA,CAAIC,GAAI,CAAEC,GAAI,IAAMC,GAAI,KAAOC,SAAU,GACxCC,SAAA,CAAAC,EAAAA,IAACC,EAAA,QAAA,CACCN,GAAI,CACFO,MAAO,iBACPC,SAAU,GACVC,WAAY,IACZC,aAAc,YAGfN,SAAQP,EAAAc,QAEXN,EAAAA,IAACC,EAAA,QAAA,CACCN,GAAI,CACFO,MAAO,eACPC,SAAU,GACVI,WAAY,IACZH,WAAY,KAGbL,WAAgBP,QA6NvB,MAAMgB,EAAuB,CAC3BC,UAAW,GACXC,YAAa,UACbR,MAAO,UACPS,aAAc,MACdR,SAAU,GACVI,WAAY,IACZK,cAAe,QAGXC,EAAkB,CACtBJ,UAAW,GACXE,aAAc,MACdG,QAAS,UACTX,SAAU,GACVI,WAAY,IACZK,cAAe,OACfG,UAAW,OACX,UAAW,CAAED,QAAS,UAAWC,UAAW,yBApO9C,UAAmCC,KACjCA,EAAAV,MACAA,EAAAW,UACAA,EAAAC,YACAA,EAAAC,SACAA,EAAAC,iBACAA,EAAAC,cACAA,EAAAC,WACAA,EAAAC,gBACAA,GAAkB,EAAAC,mBAClBA,GAAqB,EAAAC,iBACrBA,EAAAC,sBACAA,EAAAC,uBACAA,GAAyB,I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AAc,aAAe,sBAOvCN,EAAAA,KAAAC,UAAA,CAAIC,GAAI,CAAE2D,EAAG,KAAO3C,aAAc,EAAGG,QAAS,WAC7Cf,SAAA,CAACC,EAAAA,IAAAC,EAAAA,QAAA,CAAWN,GAAI,CAAEO,MAAO,iBAAkBC,SAAU,GAAII,WAAY,KAAOR,SAE5E,qBACCC,EAAAA,IAAAC,EAAA,QAAA,CAAWN,GAAI,CAAEmE,GAAI,IAAM5D,MAAO,iBAAkBC,SAAU,GAAIC,WAAY,MAAQL,SAGvF,4FACAN,EAAAA,KAAC+C,EAAM,QAAA,CAAAqB,UAAU,MAAMpB,QAAS,EAAG9C,GAAI,CAAEmE,GAAI,GAC3C/D,SAAA,CAAAC,EAAAA,IAAC+D,EAAA,QAAA,CACCC,QAAQ,WACRC,WAAS,EACTC,SAAUnC,EACVc,QAAS,IAAMhB,GAAgB,GAC/BlC,GAAIa,EACLT,SAAA,WAGDC,EAAAA,IAACmE,EAAA,QAAA,CACC7D,MAAOiB,EAAkB,iDAAmD,GAC5E6C,sBAAuB7C,EACvB8C,OAAK,EAELtE,eAAC,OAAK,CAAAuE,MAAO,CAAEC,KAAM,GACnBxE,SAAAC,EAAAA,IAAC+D,EAAA,QAAA,CACCC,QAAQ,YACRC,WAAS,EACTC,SAAUnC,GAAeR,EACzBsB,QAAS,KAAaT,KACtBzC,GAAIkB,EAEHd,WAAc,aAAe,yBAzI5CC,EAAAA,IAAC+D,EAAA,QAAA,CACCC,QAAQ,WACRC,WAAS,EACTpB,QAAS,IAAMhB,GAAgB,GAC/BlC,GAAI,CACFc,UAAW,GACXC,YAAa,UACbR,MAAO,UACPS,aAAc,EACdR,SAAU,GACVI,WAAY,IACZK,cAAe,OACf,UAAW,CACTF,YAAa,iBACbI,QAAS,4BAGdf,SAAA,aAmIT"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),t=require("@mui/material/Box"),r=require("@mui/material/Button"),i=require("@mui/material/CircularProgress"),n=require("@mui/material/Tooltip"),s=require("lucide-react");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(t),c=o(r),d=o(i),u=o(n);const p={minHeight:40,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1,px:2,borderRadius:2.5,background:"linear-gradient(135deg, #6366F1 0%, #4F46E5 100%)",color:"#FFFFFF",fontSize:13.5,fontWeight:600,letterSpacing:.1,textTransform:"none",boxShadow:"0 2px 8px rgba(79, 70, 229, 0.28)",transition:"box-shadow 0.2s ease, transform 0.15s ease, background 0.2s ease","&:hover":{background:"linear-gradient(135deg, #5457E8 0%, #4338CA 100%)",boxShadow:"0 4px 12px rgba(79, 70, 229, 0.36)"},"&:active":{transform:"scale(0.99)"},"&.Mui-disabled":{background:"linear-gradient(135deg, #A5A6F0 0%, #9092E8 100%)",color:"#FFFFFF",opacity:.75}};exports.default=function({onSave:t,onSaveComplete:r,onSaveError:i,disabled:n=!1,label:o="Save as learning",savingLabel:x="Saving your feedback…",tooltip:f="Use this decision to improve future automatic reviews."}){const[g,m]=a.useState(!1),[F,b]=a.useState(!1);return F?null:e.jsx(l.default,{sx:{mt:2},children:e.jsxs(c.default,{variant:"contained",fullWidth:!0,disabled:g||n,onClick:()=>{(async()=>{if(!g&&!n){m(!0);try{const e=await t();e&&!1===e.success||(b(!0),r?.(e))}catch(e){console.error("Failed to save as learning:",e),i?.(e)}finally{m(!1)}}})()},sx:p,children:[e.jsxs(l.default,{component:"span",sx:{display:"flex",alignItems:"center",gap:1},children:[g?e.jsx(d.default,{size:15,thickness:5,sx:{color:"#FFFFFF"}}):e.jsx(s.Sparkles,{size:16,strokeWidth:2.25}),e.jsx(l.default,{component:"span",children:g?x:o})]}),e.jsx(u.default,{title:f,arrow:!0,children:e.jsx(l.default,{component:"span","aria-label":f,onClick:e=>e.stopPropagation(),sx:{display:"flex",alignItems:"center",flexShrink:0,opacity:.85},children:e.jsx(s.Info,{size:16})})})]})})};
2
+ //# sourceMappingURL=SaveAsLearningCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaveAsLearningCard.js","sources":["../../../../src/features/SegmentReviewComponents/SaveAsLearningCard.tsx"],"sourcesContent":["import { useState } from 'react';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Tooltip from '@mui/material/Tooltip';\nimport { Sparkles, Info } from 'lucide-react';\n\nexport interface SaveAsLearningResult {\n success?: boolean;\n message?: string | null;\n}\n\nexport interface SaveAsLearningCardProps {\n onSave: () => void | SaveAsLearningResult | Promise<void | SaveAsLearningResult>;\n onSaveComplete?: (result: void | SaveAsLearningResult) => void;\n onSaveError?: (error: unknown) => void;\n disabled?: boolean;\n label?: string;\n savingLabel?: string;\n tooltip?: string;\n}\n\nexport default function SaveAsLearningCard({\n onSave,\n onSaveComplete,\n onSaveError,\n disabled = false,\n label = 'Save as learning',\n savingLabel = 'Saving your feedback…',\n tooltip = 'Use this decision to improve future automatic reviews.',\n}: SaveAsLearningCardProps) {\n const [isSaving, setIsSaving] = useState(false);\n const [isSaved, setIsSaved] = useState(false);\n\n\n const handleClick = async () => {\n if (isSaving || disabled) return;\n setIsSaving(true);\n try {\n const result = await onSave();\n // Hosts may return an explicit failure result instead of throwing.\n // Keep the card available in that case so the reviewer can retry.\n if (!result || result.success !== false) {\n setIsSaved(true);\n onSaveComplete?.(result);\n }\n } catch (error) {\n console.error('Failed to save as learning:', error);\n onSaveError?.(error);\n } finally {\n setIsSaving(false);\n }\n };\n\n if (isSaved) return null;\n\n return (\n <Box sx={{ mt: 2 }}>\n <Button\n variant=\"contained\"\n fullWidth\n disabled={isSaving || disabled}\n onClick={() => { void handleClick(); }}\n sx={buttonSx}\n >\n <Box component=\"span\" sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>\n {isSaving ? (\n <CircularProgress size={15} thickness={5} sx={{ color: '#FFFFFF' }} />\n ) : (\n <Sparkles size={16} strokeWidth={2.25} />\n )}\n <Box component=\"span\">{isSaving ? savingLabel : label}</Box>\n </Box>\n\n <Tooltip title={tooltip} arrow>\n <Box\n component=\"span\"\n aria-label={tooltip}\n onClick={(e) => e.stopPropagation()}\n sx={{ display: 'flex', alignItems: 'center', flexShrink: 0, opacity: 0.85 }}\n >\n <Info size={16} />\n </Box>\n </Tooltip>\n </Button>\n </Box>\n );\n}\n\nconst buttonSx = {\n minHeight: 40,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 1,\n px: 2,\n borderRadius: 2.5,\n background: 'linear-gradient(135deg, #6366F1 0%, #4F46E5 100%)',\n color: '#FFFFFF',\n fontSize: 13.5,\n fontWeight: 600,\n letterSpacing: 0.1,\n textTransform: 'none',\n boxShadow: '0 2px 8px rgba(79, 70, 229, 0.28)',\n transition: 'box-shadow 0.2s ease, transform 0.15s ease, background 0.2s ease',\n '&:hover': {\n background: 'linear-gradient(135deg, #5457E8 0%, #4338CA 100%)',\n boxShadow: '0 4px 12px rgba(79, 70, 229, 0.36)',\n },\n '&:active': { transform: 'scale(0.99)' },\n '&.Mui-disabled': {\n background: 'linear-gradient(135deg, #A5A6F0 0%, #9092E8 100%)',\n color: '#FFFFFF',\n opacity: 0.75,\n },\n};"],"names":["buttonSx","minHeight","display","alignItems","justifyContent","gap","px","borderRadius","background","color","fontSize","fontWeight","letterSpacing","textTransform","boxShadow","transition","transform","opacity","onSave","onSaveComplete","onSaveError","disabled","label","savingLabel","tooltip","isSaving","setIsSaving","useState","isSaved","setIsSaved","Box","sx","mt","children","jsxs","Button","variant","fullWidth","onClick","async","result","success","error","console","handleClick","component","CircularProgress","size","thickness","jsx","Sparkles","strokeWidth","Tooltip","title","arrow","e","stopPropagation","flexShrink","Info"],"mappings":"4YAyFA,MAAMA,EAAW,CACfC,UAAW,GACXC,QAAS,OACTC,WAAY,SACZC,eAAgB,gBAChBC,IAAK,EACLC,GAAI,EACJC,aAAc,IACdC,WAAY,oDACZC,MAAO,UACPC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