@viswa-test/test-citation 0.0.375 → 0.0.377

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 (32) hide show
  1. package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
  2. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  3. package/dist/cjs/features/PdfViewer/rotationManager.js +2 -0
  4. package/dist/cjs/features/PdfViewer/rotationManager.js.map +1 -0
  5. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  6. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  7. package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
  8. package/dist/features/PdfViewer/PdfToolbar.js +1 -1
  9. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  10. package/dist/features/PdfViewer/rotationManager.js +2 -0
  11. package/dist/features/PdfViewer/rotationManager.js.map +1 -0
  12. package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  13. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  14. package/dist/features/SegmentReviewComponents/helper.js +1 -1
  15. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
  16. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
  17. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts +4 -1
  18. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
  19. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +2 -1
  20. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  21. package/dist/types/src/features/PdfViewer/coordinateTransformer.d.ts +41 -0
  22. package/dist/types/src/features/PdfViewer/coordinateTransformer.d.ts.map +1 -0
  23. package/dist/types/src/features/PdfViewer/rotationManager.d.ts +23 -0
  24. package/dist/types/src/features/PdfViewer/rotationManager.d.ts.map +1 -0
  25. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts +3 -1
  26. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
  27. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +2 -1
  28. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  29. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewRedirectionTest.d.ts.map +1 -1
  30. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts +1 -1
  31. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts.map +1 -1
  32. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("./PdfStyle.js"),s=require("../../assests/svg/PdfViewerIcons.js"),l=require("@mui/material/Tooltip"),r=require("lucide-react");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t),d=o(l);exports.default=function(t){t.highlightIndex;var l=t.totalHighlights,o=t.controls,c=t.currentPosition,p=t.pdfName,g=t.onClose,x=t.pdfUrl,u=t.viewerRef,h=t.customStyles,f=t.customClasses,_=t.customIcons,v=t.headerAction,m=t.isZoomEnabled,j=void 0===m||m,y=t.showHighlightsAction,w=void 0===y||y,b=t.showFullScreenAction,S=void 0===b||b,k=t.currentSegment,I=t.segmentTooltipText,F=void 0===I?"Details of current segment":I,C=t.currentPage,D=t.totalPages,W=t.onPageNavigate,E=o.ZoomInButton,B=o.ZoomOutButton,P=o.ZoomPopover,L=o.goToPrevious,z=o.goToNext,A=a.default.useState(String(C)),T=A[0],q=A[1];a.default.useEffect(function(){q(String(C))},[C]);var N={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},R=function(e){return String(e).padStart(2,"0")};return n.jsxs("div",e.__assign({style:e.__assign(e.__assign(e.__assign({marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},i.pdfStyles.header),null==h?void 0:h.header),{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"})},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0}},{children:[n.jsx("div",e.__assign({style:e.__assign(e.__assign(e.__assign({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==h?void 0:h.pdfIconWrapper),{flexShrink:0})},{children:(null==_?void 0:_.pdfIcon)||n.jsx(s.DefaultPdfIcon,{})})),n.jsx(d.default,e.__assign({title:p||"",arrow:!0,placement:"top"},{children:n.jsx("div",e.__assign({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:n.jsx("span",e.__assign({style:e.__assign({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==h?void 0:h.pdfName),className:null==f?void 0:f.pdfName},{children:p}))}))}))]})),n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:w?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"}},{children:[D>0&&n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"}},{children:[n.jsx("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:T,onChange:function(e){var n=e.target.value.replace(/\D/g,"");q(n)},onBlur:function(){var e=Number(T);if(!Number.isInteger(e)||e<1)q(String(C));else{var n=D?Math.min(e,D):e;W(n),q(String(n))}},onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(q(String(C)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),n.jsx("span",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:"/"})),n.jsx("span",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:String(D)}))]})),j&&n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n.jsx(B,{}),n.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:n.jsx(P,{})})),n.jsx(E,{})]})),!!l&&w&&n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n.jsxs("span",e.__assign({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[c," of ",l]})),n.jsx("button",e.__assign({style:{background:"none",border:"none",cursor:c<=1?"not-allowed":"pointer",padding:"2px 4px",color:c<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:L,disabled:c<=1},{children:n.jsx("svg",e.__assign({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n.jsx("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),n.jsx("button",e.__assign({style:{background:"none",border:"none",cursor:c===l?"not-allowed":"pointer",padding:"2px 4px",color:c===l?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:z,disabled:c===l},{children:n.jsx("svg",e.__assign({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n.jsx("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),n.jsx("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==S&&((null==v?void 0:v.icon)&&(null==v?void 0:v.onClick)?n.jsx(d.default,e.__assign({title:(null==v?void 0:v.tooltip)||"",arrow:!0,placement:"top"},{children:n.jsx("div",e.__assign({onClick:v.onClick,style:e.__assign({display:"flex",alignItems:"center",cursor:"pointer"},N)},{children:v.icon}))})):n.jsx("button",e.__assign({onClick:function(){var e=null==u?void 0:u.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:N,title:"Full Screen"},{children:(null==_?void 0:_.fullScreenIcon)||n.jsx(s.DefaultFullScreenIcon,{})}))),x&&n.jsx("a",e.__assign({href:x,target:"_blank",rel:"noopener noreferrer",style:N,title:"Open in new tab"},{children:(null==_?void 0:_.downloadIcon)||n.jsx(s.DefaultDownloadIcon,{})})),g&&n.jsx("button",e.__assign({onClick:g,style:N,title:"Close"},{children:(null==_?void 0:_.closeIcon)||n.jsx(s.DefaultCloseIcon,{})}))]}))]}))]})),k&&n.jsxs("div",e.__assign({style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:[n.jsx(d.default,e.__assign({title:F,arrow:!0,placement:"top"},{children:n.jsx(r.Info,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})})),n.jsx("span",e.__assign({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:n.jsx(d.default,e.__assign({title:k.title,arrow:!0,placement:"top"},{children:n.jsxs("span",{children:["Viewing ",k.title," • Pages ",R(k.start_page),"-",R(k.end_page)]})}))}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("./PdfStyle.js"),o=require("../../assests/svg/PdfViewerIcons.js"),r=require("@mui/material/Tooltip"),s=require("lucide-react"),l=require("@mui/icons-material/RotateRight");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=a(t),c=a(r),p=a(l);exports.default=function(t){t.highlightIndex;var r=t.totalHighlights,l=t.controls,a=t.currentPosition,g=t.pdfName,u=t.onClose,x=t.pdfUrl,h=t.viewerRef,f=t.customStyles,_=t.customClasses,v=t.customIcons,m=t.headerAction,y=t.isZoomEnabled,j=void 0===y||y,b=t.showHighlightsAction,w=void 0===b||b,S=t.showFullScreenAction,k=void 0===S||S,I=t.currentSegment,F=t.segmentTooltipText,C=void 0===F?"Details of current segment":F,D=t.currentPage,W=t.totalPages,E=t.onPageNavigate,R=t.onRotatePage,P=t.currentPageRotation,T=void 0===P?0:P,B=t.showRotateButton,L=void 0===B||B,z=l.ZoomInButton,q=l.ZoomOutButton,A=l.ZoomPopover,N=l.goToPrevious,M=l.goToNext,H=d.default.useState(String(D)),O=H[0],Z=H[1];d.default.useEffect(function(){Z(String(D))},[D]);var G={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},V=function(e){return String(e).padStart(2,"0")};return n.jsxs("div",e.__assign({style:e.__assign(e.__assign(e.__assign({marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},i.pdfStyles.header),null==f?void 0:f.header),{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"})},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0}},{children:[n.jsx("div",e.__assign({style:e.__assign(e.__assign(e.__assign({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==f?void 0:f.pdfIconWrapper),{flexShrink:0})},{children:(null==v?void 0:v.pdfIcon)||n.jsx(o.DefaultPdfIcon,{})})),n.jsx(c.default,e.__assign({title:g||"",arrow:!0,placement:"top"},{children:n.jsx("div",e.__assign({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:n.jsx("span",e.__assign({style:e.__assign({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==f?void 0:f.pdfName),className:null==_?void 0:_.pdfName},{children:g}))}))}))]})),n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:w?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"}},{children:[W>0&&n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"}},{children:[n.jsx("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:O,onChange:function(e){var n=e.target.value.replace(/\D/g,"");Z(n)},onBlur:function(){var e=Number(O);if(!Number.isInteger(e)||e<1)Z(String(D));else{var n=W?Math.min(e,W):e;E(n),Z(String(n))}},onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(Z(String(D)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),n.jsx("span",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:"/"})),n.jsx("span",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:String(W)}))]})),j&&n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n.jsx(q,{}),n.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:n.jsx(A,{})})),n.jsx(z,{})]})),L&&R&&W>0&&n.jsx(c.default,e.__assign({title:"Rotate page (".concat(T,"°)")},{children:n.jsx("button",e.__assign({onClick:R,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:0!==T?"#1976d2":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:function(e){e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:function(e){e.currentTarget&&(e.currentTarget.style.color=0!==T?"#1976d2":"#475467")},"aria-label":"Rotate current page"},{children:n.jsx(p.default,{sx:{fontSize:"18px"}})}))})),!!r&&w&&n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n.jsxs("span",e.__assign({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[a," of ",r]})),n.jsx("button",e.__assign({style:{background:"none",border:"none",cursor:a<=1?"not-allowed":"pointer",padding:"2px 4px",color:a<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:N,disabled:a<=1},{children:n.jsx("svg",e.__assign({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n.jsx("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),n.jsx("button",e.__assign({style:{background:"none",border:"none",cursor:a===r?"not-allowed":"pointer",padding:"2px 4px",color:a===r?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:M,disabled:a===r},{children:n.jsx("svg",e.__assign({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n.jsx("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),n.jsx("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==k&&((null==m?void 0:m.icon)&&(null==m?void 0:m.onClick)?n.jsx(c.default,e.__assign({title:(null==m?void 0:m.tooltip)||"",arrow:!0,placement:"top"},{children:n.jsx("div",e.__assign({onClick:m.onClick,style:e.__assign({display:"flex",alignItems:"center",cursor:"pointer"},G)},{children:m.icon}))})):n.jsx("button",e.__assign({onClick:function(){var e=null==h?void 0:h.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:G,title:"Full Screen"},{children:(null==v?void 0:v.fullScreenIcon)||n.jsx(o.DefaultFullScreenIcon,{})}))),x&&n.jsx("a",e.__assign({href:x,target:"_blank",rel:"noopener noreferrer",style:G,title:"Open in new tab"},{children:(null==v?void 0:v.downloadIcon)||n.jsx(o.DefaultDownloadIcon,{})})),u&&n.jsx("button",e.__assign({onClick:u,style:G,title:"Close"},{children:(null==v?void 0:v.closeIcon)||n.jsx(o.DefaultCloseIcon,{})}))]}))]}))]})),I&&n.jsxs("div",e.__assign({style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:[n.jsx(c.default,e.__assign({title:C,arrow:!0,placement:"top"},{children:n.jsx(s.Info,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})})),n.jsx("span",e.__assign({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:n.jsx(c.default,e.__assign({title:I.title,arrow:!0,placement:"top"},{children:n.jsxs("span",{children:["Viewing ",I.title," • Pages ",V(I.start_page),"-",V(I.end_page)]})}))}))]}))]}))};
2
2
  //# sourceMappingURL=PdfToolbar.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@react-pdf-viewer/core"),i=require("./PdfContainer.js"),r=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),a=require("./usePdfHighlight.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 u=require("react"),l=require("../ScannedDocCitation/ScannedDocCitation.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(u);exports.default=function(s){var d,g=s.pdfUrl,f=s.highlightText,v=s.highlightPages,h=s.highlightCordinatePages,p=s.highlightColor,m=void 0===p?"yellow":p,_=s.activeHighlightColor,x=void 0===_?"#f7dc51":_,y=s.jumpToPageValue,P=void 0===y?0:y,w=s.pdfName,T=s.onClose,S=s.customStyles,C=s.customClasses,b=s.customIcons,q=s.useCoordinates,A=s.fallbackPages,j=s.activeCitationIndex,L=s.onActiveCitationChange,I=s.headerAction,R=s.isZoomEnabled,H=void 0===R||R,N=s.showHighlightsAction,F=void 0===N||N,M=s.defaultScale,Z=void 0===M?n.SpecialZoomLevel.ActualSize:M,E=s.useRange,B=void 0!==E&&E,D=s.rangeOfPages,V=void 0===D?null:D,W=s.showFullScreenAction,z=void 0===W||W,O=s.segments,k=void 0===O?[{title:"Document 2",start_page:52,end_page:52,page_count:1}]:O,U=s.segmentTooltipText,J=s.onCurrentPageChange,K=s.navigationRequest,G=s.onNavigationSettled,Q=s.disablePdfAnnotations,X=void 0!==Q&&Q,Y=s.disablePdfTextLayer,$=void 0!==Y&&Y,ee=s.renderPage,te=s.setRenderRange,ne=u.useRef(null),ie=function(e){switch(e){case"ActualSize":return n.SpecialZoomLevel.ActualSize;case"PageFit":return n.SpecialZoomLevel.PageFit;case"PageWidth":return n.SpecialZoomLevel.PageWidth;default:return null!=e?e:n.SpecialZoomLevel.PageWidth}}(Z),re=u.useState(0),oe=re[0],ae=re[1],ue=u.useState(0),le=ue[0],se=ue[1],ce=u.useRef(null),de=u.useRef(null),ge=u.useRef(0),fe=u.useMemo(function(){return X||$?function(n){var i=$?t.jsx("div",e.__assign({"aria-hidden":"true",style:{display:"none"}},{children:n.textLayer.children})):n.textLayer.children,r=e.__assign(e.__assign({},n),{annotationLayer:e.__assign(e.__assign({},n.annotationLayer),{children:X?null:n.annotationLayer.children}),textLayer:e.__assign(e.__assign({},n.textLayer),{children:i})});return ee?ee(r):t.jsxs(t.Fragment,{children:[n.canvasLayer.children,i,!X&&n.annotationLayer.children]})}:ee},[X,$,ee]),ve=u.useMemo(function(){if(q)return new Set(h.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(v).forEach(function(t){t>0&&e.add(t-1)}),e},[h,v,q]),he=(d=f)&&0!==d.length?d.filter(function(e){return!d.some(function(t){return t!==e&&t.includes(e)})}):d,pe=a.PdfHighlightControls(he,q?{}:v,ne,ve,q,q?h:[],m,x),me=pe.highlightIndex,_e=pe.cursorIndex,xe=pe.setCursorIndex,ye=pe.orderedKeys,Pe=pe.totalHighlights,we=pe.getValidPosition,Te=pe.tryJump,Se=pe.jumpToPage,Ce=pe.plugins,be=pe.controls,qe=pe.hideNonTargetHighlights,Ae=pe.deduplicateHighlights,je=we(_e),Le=u.useMemo(function(){var e=oe+1;return k.find(function(t){return e>=t.start_page&&e<=t.end_page})},[oe,k]);u.useEffect(function(){void 0!==j&&j!==_e&&xe(j)},[j]);var Ie=e.__assign(e.__assign({},be),{goToNext:function(){_e>=Pe-1||(be.goToNext(),L&&L(_e+1))},goToPrevious:function(){_e<=0||(be.goToPrevious(),L&&L(_e-1))}}),Re=c.default.useCallback(function(e,t){ge.current+=1;var n=ge.current;null!=de.current&&window.clearTimeout(de.current);var i=null,r=0,o=0,a=function(){var u,l;if(ge.current===n){o+=1;var s=null===(u=ne.current)||void 0===u?void 0:u.querySelector(".rpv-core__inner-pages"),c=null===(l=ne.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(t-1,'"]'));if(!s||!c)return o>=40?(de.current=null,void(null==G||G({pageNumber:t,requestId:e.requestId}))):void(de.current=window.setTimeout(a,50));i===s.scrollTop?r+=1:(i=s.scrollTop,r=0);var d=s.getBoundingClientRect(),g=c.getBoundingClientRect(),f=Boolean(d&&g&&g.bottom>d.top&&g.top<d.bottom);if(r>=2&&f||o>=40)return de.current=null,void(null==G||G({pageNumber:t,requestId:e.requestId}));de.current=window.setTimeout(a,50)}};de.current=window.setTimeout(a,50)},[G]);if(u.useEffect(function(){return function(){ge.current+=1,null!=de.current&&window.clearTimeout(de.current)}},[]),u.useEffect(function(){var e;if(K&&!(le<=0)){var t=Math.min(Math.max(Math.trunc(K.pageNumber),1),le),n="".concat(null!==(e=K.requestId)&&void 0!==e?e:t,":").concat(t);ce.current!==n&&(ce.current=n,ae(t-1),Se(t-1),Re(K,t))}},[Se,K,le,Re]),!g)return t.jsx(l.default,{pages:A,activeCitationIndex:j,onActiveCitationChange:L,headerAction:I});return t.jsxs("div",e.__assign({ref:ne,className:(null==C?void 0:C.pdfViewerWrapper)||"","data-disable-pdf-annotations":X?"true":void 0,"data-pdf-page-fit":ie===n.SpecialZoomLevel.PageFit?"true":void 0,style:e.__assign(e.__assign(e.__assign({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"}),null==S?void 0:S.pdfViewer)},{children:[t.jsx(r.default,{highlightIndex:me,totalHighlights:Pe,controls:Ie,currentPosition:je,pdfName:w,onClose:T,pdfUrl:g,viewerRef:ne,customStyles:S,customClasses:C,customIcons:b,headerAction:I,isZoomEnabled:H,showHighlightsAction:F,showFullScreenAction:z,currentSegment:Le,segmentTooltipText:U,currentPage:oe+1,totalPages:le,onPageNavigate:function(e){var t=Math.min(Math.max(e,1),le||e);ae(t-1),Se(t-1)}}),t.jsx(i.default,{defaultScale:ie,pdfUrl:g,plugins:Ce,customStyles:S,onLoad:function(t){se(t.doc.numPages);var n=!q&&!B&&P<=0;if(P>0&&!B){var i=P-1,r=ye[i],o=v[r],a=h[i];xe(i),console.log(a,"cordinateTargetHighlight"),q&&a.pageIndex>0&&Se(a.pageIndex),o>0&&(setTimeout(function(){qe(ve),Ae(o-1)},1e3),q||Se(o-1))}else if(B&&V&&2===V.length){e.__awaiter(void 0,void 0,void 0,function(){var t,n,i,r,o;return e.__generator(this,function(e){switch(e.label){case 0:t=V[0],n=V[1],i=t,e.label=1;case 1:return i<=n?(Se(r=i-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(e.sent(),qe(ve),(o=Ae(r))&&o>0)return[3,4];e.label=3;case 3:return i++,[3,1];case 4:return[2]}})})}else if(!q&&v){var u=ye.find(function(e){return v[e]>0});if(void 0!==u){var l=v[u]-1;Se(l),setTimeout(function(){qe(ve),Ae(l)},1e3)}}requestAnimationFrame(function(){n&&Te(),!q&&P>0&&!B&&function(){if(ne.current){var e=P-1,t=ye[e],n=v[t],i=n>0?n-1:0,r={};ye.forEach(function(e,t){var n=v[e];n>0&&(r[n]||(r[n]=[]),r[n].push(t))});var o=(r[n]||[]).indexOf(e),a=0,u=function(){var e,t;if(!(++a>40)){var n=null===(e=ne.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(n){var r=null===(t=ne.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(i,'"]'));if(r){var l=n.getBoundingClientRect(),s=r.getBoundingClientRect();if(s.top<l.bottom&&s.bottom>l.top){var c=r.querySelectorAll(".rpv-search__highlight")[o];if(c){var d=c.getBoundingClientRect(),g=n.scrollTop+(d.top-l.top)-n.clientHeight/2+d.height/2;n.scrollTo({top:g,behavior:"smooth"})}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}};setTimeout(u,500)}}()})},onPageChange:function(e){var t=e.currentPage;ae(t),null==J||J(t+1),ve.has(t)?(Ae(t),qe(ve)):qe(ve)},renderPage:fe,setRenderRange:te})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@react-pdf-viewer/core"),r=require("./PdfContainer.js"),i=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),a=require("./usePdfHighlight.js"),u=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 l=require("react"),s=require("../ScannedDocCitation/ScannedDocCitation.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(l);exports.default=function(c){var g=c.pdfUrl,f=c.highlightText,v=c.highlightPages,h=c.highlightCordinatePages,p=c.highlightColor,m=void 0===p?"yellow":p,_=c.activeHighlightColor,y=void 0===_?"#f7dc51":_,w=c.jumpToPageValue,x=void 0===w?0:w,P=c.pdfName,S=c.onClose,b=c.customStyles,T=c.customClasses,C=c.customIcons,q=c.useCoordinates,R=c.fallbackPages,A=c.activeCitationIndex,L=c.onActiveCitationChange,M=c.headerAction,j=c.isZoomEnabled,I=void 0===j||j,E=c.showHighlightsAction,H=void 0===E||E,N=c.defaultScale,F=void 0===N?n.SpecialZoomLevel.ActualSize:N,B=c.useRange,Z=void 0!==B&&B,D=c.rangeOfPages,O=void 0===D?null:D,V=c.showFullScreenAction,W=void 0===V||V,z=c.showRotateButton,U=void 0!==z&&z,k=c.segments,J=void 0===k?[{title:"Document 2",start_page:52,end_page:52,page_count:1}]:k,K=c.segmentTooltipText,G=c.onCurrentPageChange,Q=c.navigationRequest,X=c.onNavigationSettled,Y=c.disablePdfAnnotations,$=void 0!==Y&&Y,ee=c.disablePdfTextLayer,te=void 0!==ee&&ee,ne=c.renderPage,re=c.setRenderRange,ie=l.useRef(null),oe=function(e){switch(e){case"ActualSize":return n.SpecialZoomLevel.ActualSize;case"PageFit":return n.SpecialZoomLevel.PageFit;case"PageWidth":return n.SpecialZoomLevel.PageWidth;default:return null!=e?e:n.SpecialZoomLevel.PageWidth}}(F),ae=l.useState(0),ue=ae[0],le=ae[1],se=l.useState(0),ce=se[0],de=se[1],ge=l.useState(0),fe=ge[0],ve=ge[1],he=l.useRef(null),pe=l.useRef(null),me=l.useRef(0),_e=l.useRef(null),ye=l.useMemo(function(){if(!g)return"";try{return new URL(g,window.location.origin).pathname.split("/").pop()||"default"}catch(e){return"default"}},[g]);l.useEffect(function(){ye&&u.rotationManager.setPdfIdentifier(ye)},[ye]);l.useEffect(function(){return u.rotationManager.onRotationChange(function(e,t){e===ue+1&&ve(t)})},[ue]),l.useEffect(function(){var e=new MutationObserver(function(){var e,t=null===(e=ie.current)||void 0===e?void 0:e.querySelectorAll('[data-testid^="core__page-layer-"]'),n=new Set;null==t||t.forEach(function(e){var t,r=null===(t=e.getAttribute("data-testid"))||void 0===t?void 0:t.match(/core__page-layer-(\d+)/);if(r){var i=parseInt(r[1],10)+1;n.has(i)||(u.rotationManager.registerPageElement(i,e),n.add(i))}})});return ie.current&&(e.observe(ie.current,{childList:!0,subtree:!0,attributes:!1}),_e.current=e),function(){e.disconnect(),_e.current=null}},[]),l.useEffect(function(){return function(){u.rotationManager.clearAll(),_e.current&&_e.current.disconnect()}},[]),l.useEffect(function(){var e=ue+1;ve(u.rotationManager.getRotation(e))},[ue]);var we,xe=l.useMemo(function(){return $||te?function(n){var r=te?t.jsx("div",e.__assign({"aria-hidden":"true",style:{display:"none"}},{children:n.textLayer.children})):n.textLayer.children,i=e.__assign(e.__assign({},n),{annotationLayer:e.__assign(e.__assign({},n.annotationLayer),{children:$?null:n.annotationLayer.children}),textLayer:e.__assign(e.__assign({},n.textLayer),{children:r})});return ne?ne(i):t.jsxs(t.Fragment,{children:[n.canvasLayer.children,r,!$&&n.annotationLayer.children]})}:ne},[$,te,ne]),Pe=l.useMemo(function(){if(q)return new Set(h.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(v).forEach(function(t){t>0&&e.add(t-1)}),e},[h,v,q]),Se=(we=f)&&0!==we.length?we.filter(function(e){return!we.some(function(t){return t!==e&&t.includes(e)})}):we,be=a.PdfHighlightControls(Se,q?{}:v,ie,Pe,q,q?h:[],m,y),Te=be.highlightIndex,Ce=be.cursorIndex,qe=be.setCursorIndex,Re=be.orderedKeys,Ae=be.totalHighlights,Le=be.getValidPosition,Me=be.tryJump,je=be.jumpToPage,Ie=be.plugins,Ee=be.controls,He=be.hideNonTargetHighlights,Ne=be.deduplicateHighlights,Fe=Le(Ce),Be=l.useMemo(function(){var e=ue+1;return J.find(function(t){return e>=t.start_page&&e<=t.end_page})},[ue,J]);l.useEffect(function(){void 0!==A&&A!==Ce&&qe(A)},[A]);var Ze=e.__assign(e.__assign({},Ee),{goToNext:function(){Ce>=Ae-1||(Ee.goToNext(),L&&L(Ce+1))},goToPrevious:function(){Ce<=0||(Ee.goToPrevious(),L&&L(Ce-1))}}),De=d.default.useCallback(function(e,t){me.current+=1;var n=me.current;null!=pe.current&&window.clearTimeout(pe.current);var r=null,i=0,o=0,a=function(){var u,l;if(me.current===n){o+=1;var s=null===(u=ie.current)||void 0===u?void 0:u.querySelector(".rpv-core__inner-pages"),c=null===(l=ie.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(t-1,'"]'));if(!s||!c)return o>=40?(pe.current=null,void(null==X||X({pageNumber:t,requestId:e.requestId}))):void(pe.current=window.setTimeout(a,50));r===s.scrollTop?i+=1:(r=s.scrollTop,i=0);var d=s.getBoundingClientRect(),g=c.getBoundingClientRect(),f=Boolean(d&&g&&g.bottom>d.top&&g.top<d.bottom);if(i>=2&&f||o>=40)return pe.current=null,void(null==X||X({pageNumber:t,requestId:e.requestId}));pe.current=window.setTimeout(a,50)}};pe.current=window.setTimeout(a,50)},[X]);if(l.useEffect(function(){return function(){me.current+=1,null!=pe.current&&window.clearTimeout(pe.current)}},[]),l.useEffect(function(){var e;if(Q&&!(ce<=0)){var t=Math.min(Math.max(Math.trunc(Q.pageNumber),1),ce),n="".concat(null!==(e=Q.requestId)&&void 0!==e?e:t,":").concat(t);he.current!==n&&(he.current=n,le(t-1),je(t-1),De(Q,t))}},[je,Q,ce,De]),!g)return t.jsx(s.default,{pages:R,activeCitationIndex:A,onActiveCitationChange:L,headerAction:M});return t.jsxs("div",e.__assign({ref:ie,className:(null==T?void 0:T.pdfViewerWrapper)||"","data-disable-pdf-annotations":$?"true":void 0,"data-pdf-page-fit":oe===n.SpecialZoomLevel.PageFit?"true":void 0,style:e.__assign(e.__assign(e.__assign({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"}),null==b?void 0:b.pdfViewer)},{children:[t.jsx(i.default,{highlightIndex:Te,totalHighlights:Ae,controls:Ze,currentPosition:Fe,pdfName:P,onClose:S,pdfUrl:g,viewerRef:ie,customStyles:b,customClasses:T,customIcons:C,headerAction:M,isZoomEnabled:I,showHighlightsAction:H,showFullScreenAction:W,currentSegment:Be,segmentTooltipText:K,currentPage:ue+1,totalPages:ce,onPageNavigate:function(e){var t=Math.min(Math.max(e,1),ce||e);le(t-1),je(t-1)},onRotatePage:function(){var e=ue+1;u.rotationManager.rotatePageBy90(e),ve(u.rotationManager.getRotation(e))},currentPageRotation:fe,showRotateButton:U}),t.jsx(r.default,{defaultScale:oe,pdfUrl:g,plugins:Ie,customStyles:b,onLoad:function(t){de(t.doc.numPages);var n=!q&&!Z&&x<=0;if(x>0&&!Z){var r=x-1,i=Re[r],o=v[i],a=h[r];qe(r),console.log(a,"cordinateTargetHighlight"),q&&a.pageIndex>0&&je(a.pageIndex),o>0&&(setTimeout(function(){He(Pe),Ne(o-1)},1e3),q||je(o-1))}else if(Z&&O&&2===O.length){e.__awaiter(void 0,void 0,void 0,function(){var t,n,r,i,o;return e.__generator(this,function(e){switch(e.label){case 0:t=O[0],n=O[1],r=t,e.label=1;case 1:return r<=n?(je(i=r-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(e.sent(),He(Pe),(o=Ne(i))&&o>0)return[3,4];e.label=3;case 3:return r++,[3,1];case 4:return[2]}})})}else if(!q&&v){var u=Re.find(function(e){return v[e]>0});if(void 0!==u){var l=v[u]-1;je(l),setTimeout(function(){He(Pe),Ne(l)},1e3)}}requestAnimationFrame(function(){n&&Me(),!q&&x>0&&!Z&&function(){if(ie.current){var e=x-1,t=Re[e],n=v[t],r=n>0?n-1:0,i={};Re.forEach(function(e,t){var n=v[e];n>0&&(i[n]||(i[n]=[]),i[n].push(t))});var o=(i[n]||[]).indexOf(e),a=0,u=function(){var e,t;if(!(++a>40)){var n=null===(e=ie.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(n){var i=null===(t=ie.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(r,'"]'));if(i){var l=n.getBoundingClientRect(),s=i.getBoundingClientRect();if(s.top<l.bottom&&s.bottom>l.top){var c=i.querySelectorAll(".rpv-search__highlight")[o];if(c){var d=c.getBoundingClientRect(),g=n.scrollTop+(d.top-l.top)-n.clientHeight/2+d.height/2;n.scrollTo({top:g,behavior:"smooth"})}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}};setTimeout(u,500)}}()})},onPageChange:function(e){var t=e.currentPage;le(t),null==G||G(t+1),Pe.has(t)?(Ne(t),He(Pe)):He(Pe)},renderPage:xe,setRenderRange:re})]}))};
2
2
  //# sourceMappingURL=PdfViewer.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(){this.rotations=new WeakMap,this.pageMap=new Map,this.rotationChangeListeners=new Set,this.pdfIdentifier=""}return t.prototype.setPdfIdentifier=function(t){this.pdfIdentifier=t},t.prototype.registerPageElement=function(t,e){this.pageMap.get(t),this.pageMap.set(t,e);var o=this.getPersistedRotation(t);0!==o&&this.applyRotation(e,t,o)},t.prototype.unregisterPageElement=function(t){this.pageMap.delete(t)},t.prototype.getRotation=function(t){var e=this.pageMap.get(t);return e&&this.rotations.get(e)||0},t.prototype.rotatePageBy90=function(t){var e=this.pageMap.get(t);if(e){var o=((this.rotations.get(e)||0)+90)%360;this.applyRotation(e,t,o)}},t.prototype.setRotation=function(t,e){var o=(e%360+360)%360,i=this.pageMap.get(t);i&&this.applyRotation(i,t,o)},t.prototype.applyRotation=function(t,e,o){this.rotations.set(t,o);var i=t.closest(".rpv-core__page-layer");i&&(0===o?(i.style.transform="",i.style.transformOrigin="",i.style.transition=""):(i.style.transform="rotate(".concat(o,"deg)"),i.style.transformOrigin="center center",i.style.transition="transform 0.2s ease")),this.notifyRotationChange(e,o),this.persistRotation(e,o)},t.prototype.onRotationChange=function(t){var e=this;return this.rotationChangeListeners.add(t),function(){e.rotationChangeListeners.delete(t)}},t.prototype.notifyRotationChange=function(t,e){this.rotationChangeListeners.forEach(function(o){try{o(t,e)}catch(t){console.error("Error in rotation change listener:",t)}})},t.prototype.getPersistedRotation=function(t){if(!this.pdfIdentifier)return 0;var e="pdf-rotation-".concat(this.pdfIdentifier,"-").concat(t),o=localStorage.getItem(e);if(!o)return 0;var i=parseInt(o,10);return Number.isFinite(i)?i:0},t.prototype.persistRotation=function(t,e){if(this.pdfIdentifier){var o="pdf-rotation-".concat(this.pdfIdentifier,"-").concat(t);0===e?localStorage.removeItem(o):localStorage.setItem(o,e.toString())}},t.prototype.loadPersistedRotations=function(t){var e=this;this.pdfIdentifier&&t.forEach(function(t){var o=e.getPersistedRotation(t);if(0!==o){var i=e.pageMap.get(t);i&&e.applyRotation(i,t,o)}})},t.prototype.clearAll=function(){var t=this;this.pageMap.forEach(function(e,o){var i=e.closest(".rpv-core__page-layer");if(i&&(i.style.transform="",i.style.transformOrigin="",i.style.transition=""),t.pdfIdentifier){var n="pdf-rotation-".concat(t.pdfIdentifier,"-").concat(o);localStorage.removeItem(n)}}),this.pageMap.clear(),this.rotations=new WeakMap},t.prototype.resetPage=function(t){var e=this.pageMap.get(t);e&&this.applyRotation(e,t,0)},t.prototype.getRotatedPages=function(){var t=this,e=new Map;return this.pageMap.forEach(function(o,i){var n=t.rotations.get(o);void 0!==n&&0!==n&&e.set(i,n)}),e},t}(),e=new t;exports.RotationManager=t,exports.rotationManager=e;
2
+ //# sourceMappingURL=rotationManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rotationManager.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("@mui/icons-material/ChevronRight"),r=require("@mui/icons-material/Close"),o=require("@mui/icons-material/ExpandMore"),a=require("@mui/material/Box"),s=require("@mui/material/Button"),l=require("@mui/material/ButtonBase"),d=require("@mui/material/Divider"),u=require("@mui/material/IconButton"),c=require("@mui/material/Paper"),x=require("@mui/material/Radio"),g=require("@mui/material/Stack"),f=require("@mui/material/TextField"),p=require("@mui/material/Typography"),h=require("./RevertSummaryNotice.js"),m=require("./CognitiveIcon.js"),_=require("./CognitiveScoreBadge.js"),b=require("../../assests/icons/InfoAlert.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E,C=v(n),j=v(r),y=v(o),F=v(a),S=v(s),w=v(l),R=v(d),A=v(u),M=v(c),I=v(x),B=v(g),k=v(f),z=v(p),T=function(i,t){return e.__spreadArray([i],Array.isArray(t)?t:null==t?[]:[t],!0)},P="MERGE_ADJACENT";exports.BoundaryReviewActionEnum=void 0,(E=exports.BoundaryReviewActionEnum||(exports.BoundaryReviewActionEnum={})).KEEP="KEEP",E.SPLIT_HERE="SPLIT_HERE",E.MERGE_NEXT="MERGE_NEXT",E.MERGE_PREV="MERGE_PREV",E.MERGE_PREVIOUS="MERGE_PREVIOUS",E.SET_RANGE="SET_RANGE";var W=function(e){return Object.values(exports.BoundaryReviewActionEnum).includes(e)},N=function(i,t,n,r){if(!t||!i)return[];var o=t.additional_decisions,a=Array.isArray(o)?o:o?Object.values(o).flat():[],s=Array.from(new Set(e.__spreadArray(e.__spreadArray([],t.allowed_decisions,!0),a,!0)));return s.flatMap(function(e){var t=i.focus_page,o=s.find(function(e){return e.toLowerCase().includes("merge")}),a=null!=t&&null!=n&&null!=r&&t===n&&t===r,l=null!=t&&null!=n&&t===n,d=null!=t&&null!=r&&(t===r||t===r+1),u=l||d||!(null!=t&&(!(null!=n&&null!=r)||t>n&&t<r));switch(e){case exports.BoundaryReviewActionEnum.SET_RANGE:return[];case"KEEP":return[{id:e,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:e,title:"Split to a separate document",description:u?"A valid page inside the document is required to split it.":t?"Start a new document at page ".concat(t,"."):"Create a new document at this boundary.",disabled:u}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return e!==o?[]:a?[{id:P,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]:l?[{id:exports.BoundaryReviewActionEnum.MERGE_PREVIOUS,title:"Merge with previous document",description:"Combine this document with the previous document."}]:d?[{id:exports.BoundaryReviewActionEnum.MERGE_NEXT,title:"Merge with next document",description:"Combine this document with the next document."}]:[{id:P,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};exports.createBoundaryCardOptions=N,exports.default=function(n){var r=n.headerName,o=void 0===r?"Boundary Check":r,a=n.title,s=n.pageNo,l=n.content,d=n.revertSummary,u=n.cognitiveScore,c=n.config,x=n.metadata,g=n.previousSegmentTitle,f=n.nextSegmentTitle,p=n.selectedIndex,v=n.defaultSelectedIndex,E=void 0===v?null:v,G=n.defaultStartPage,D=n.defaultEndPage,q=n.onSelectionChange,H=n.onConfirm,O=n.onActionConfirm,V=n.onCognitiveClick,U=n.onAdjustManually,L=n.onClose,X=n.confirmLabel,K=void 0===X?"Confirm":X,$=n.manualPrompt,J=void 0===$?"Didn't find the right option?":$,Y=n.manualActionLabel,Q=void 0===Y?"Adjust Manually":Y,Z=n.cognitiveLabel,ee=void 0===Z?"Cognitive Integrity":Z,ie=n.showAdjustManually,te=void 0===ie||ie,ne=n.showCognitiveIntegrity,re=void 0===ne||ne,oe=n.showCloseButton,ae=void 0===oe||oe,se=n.confirmDisabled,le=void 0!==se&&se,de=n.width,ue=void 0===de?260:de,ce=n.maxWidth,xe=void 0===ce?260:ce,ge=n.className,fe=n.styles,pe=n.reviewAction,he=t.useMemo(function(){return(null!=c?c:x?N(x,pe,G,D):[]).filter(function(e){return e.id!==exports.BoundaryReviewActionEnum.SET_RANGE})},[c,D,G,x,pe]),me=t.useState(E),_e=me[0],be=me[1],ve=t.useState(null==G?"":String(G)),Ee=ve[0],Ce=ve[1],je=t.useState(null==D?"":String(D)),ye=je[0],Fe=je[1],Se=t.useState(!1),we=Se[0],Re=Se[1],Ae=t.useState(!1),Me=Ae[0],Ie=Ae[1],Be=t.useState(null),ke=Be[0],ze=Be[1],Te=void 0===p?_e:p,Pe=null==Te?void 0:he[Te],We=(null==Pe?void 0:Pe.id)===P,Ne=null!=g,Ge=null!=f,De=function(e){return!0===e.disabled||e.id===exports.BoundaryReviewActionEnum.MERGE_PREV&&!Ne||e.id===exports.BoundaryReviewActionEnum.MERGE_PREVIOUS&&!Ne||e.id===exports.BoundaryReviewActionEnum.MERGE_NEXT&&!Ge||e.id===P&&!Ne&&!Ge},qe=Number(Ee),He=Number(ye),Oe=Ee.trim().length>0&&ye.trim().length>0&&Number.isInteger(qe)&&Number.isInteger(He)&&qe>0&&He>0&&qe<=He,Ve=le||!Pe||De(Pe)||We&&null==ke||!H&&!O;return i.jsx(M.default,e.__assign({className:ge,elevation:4,sx:T({width:ue,maxWidth:xe,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},null==fe?void 0:fe.root)},{children:i.jsxs(B.default,e.__assign({spacing:.75,sx:{p:1}},{children:[i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:.75,sx:null==fe?void 0:fe.header},{children:[i.jsx(b.default,{color:"error",height:16,width:16}),i.jsx(z.default,e.__assign({sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"}},{children:o})),ae&&i.jsx(A.default,e.__assign({size:"small",onClick:L,disabled:!L,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}}},{children:i.jsx(j.default,{sx:{fontSize:17}})}))]})),i.jsxs(F.default,{children:[i.jsx(z.default,e.__assign({sx:{color:"text.primary",fontSize:14,fontWeight:500}},{children:a})),null!=s&&i.jsx(z.default,e.__assign({sx:{mt:.125,color:"text.secondary",fontSize:12}},{children:s})),i.jsx(R.default,{sx:{my:.625}}),null!=d?i.jsx(h.default,{children:d}):null!=l&&i.jsx(z.default,e.__assign({component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3}},{children:l}))]}),i.jsxs(B.default,e.__assign({spacing:.625,role:"radiogroup","aria-label":"Boundary options"},{children:[he.map(function(t,n){var r=Te===n,o=De(t);return i.jsxs(M.default,e.__assign({variant:"outlined",sx:T({borderColor:r?"#1976d2":"divider",borderRadius:2,bgcolor:o?"#F8FAFC":"background.paper",overflow:"hidden"},null==fe?void 0:fe.option)},{children:[i.jsxs(w.default,e.__assign({role:"radio","aria-checked":r,disabled:le||o,onClick:function(){return function(e,i){le||De(i)||(void 0===p&&be(e),i.id!==P&&ze(null),we&&(Re(!1),Ie(!1)),null==q||q(e,i))}(n,t)},sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"}},{children:[i.jsx(I.default,{checked:r,disabled:le||o,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),i.jsxs(F.default,e.__assign({sx:{minWidth:0}},{children:[i.jsx(z.default,e.__assign({sx:{color:o?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500}},{children:t.title})),null!=t.description&&i.jsx(z.default,e.__assign({sx:{mt:.125,color:o?"#94A3B8":"text.secondary",fontSize:11}},{children:t.description}))]}))]})),r&&t.id===P&&i.jsx(B.default,e.__assign({direction:"row",spacing:.75,sx:T({px:.75,pb:.75},null==fe?void 0:fe.adjacentSelector)},{children:[{direction:"previous",title:null!=g?g:"No Previous document",caption:"← Merge into Previous",available:Ne},{direction:"next",title:null!=f?f:"No Next document",caption:"Merge into Next →",available:Ge}].map(function(t){var n=ke===t.direction;return i.jsxs(B.default,e.__assign({sx:{flex:1,minWidth:0}},{children:[i.jsx(w.default,e.__assign({disabled:le||!t.available,onClick:function(){return ze(t.direction)},"aria-pressed":n,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:n?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:n?"#E0E7FF":"background.paper",color:n?"#7F56D9":t.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}}},{children:i.jsx(z.default,e.__assign({sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"}},{children:t.title}))})),i.jsx(z.default,e.__assign({sx:{mt:.5,color:n?"#5925DC":"text.secondary",fontSize:9.5,lineHeight:1.2,whiteSpace:"nowrap",textAlign:"next"===t.direction?"right":"left"}},{children:t.caption}))]}),t.direction)})}))]}),t.id)}),We&&null!=ke&&i.jsxs(B.default,e.__assign({direction:"row",alignItems:"flex-start",spacing:.625,sx:T({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},null==fe?void 0:fe.impactWarning)},{children:[i.jsx(b.default,{color:"error",height:14,width:14,sx:{mt:.125}}),i.jsxs(z.default,e.__assign({sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4}},{children:["This will impact the ",ke," document. Its content and page range will change."]}))]})),i.jsx(S.default,e.__assign({variant:"contained",fullWidth:!0,disabled:Ve,onClick:function(){if(!Ve&&null!=Te&&Pe){var i=We?"previous"===ke?exports.BoundaryReviewActionEnum.MERGE_PREVIOUS:exports.BoundaryReviewActionEnum.MERGE_NEXT:Pe.id,t=We?e.__assign(e.__assign({},Pe),{id:i}):Pe,n={selectedIndex:Te,option:t,metadata:x};null==H||H(Te,t,n),O&&W(i)&&O(i,n)}},sx:T({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},null==fe?void 0:fe.confirmButton)},{children:K}))]})),te&&i.jsxs(B.default,e.__assign({spacing:.625,sx:null==fe?void 0:fe.manualSection},{children:[i.jsxs(w.default,e.__assign({disabled:le,onClick:function(){var e=!we;Re(e),Ie(!1),e&&(void 0===p&&be(null),null==U||U())},"aria-expanded":we,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"}},{children:[i.jsx(F.default,{children:i.jsx(z.default,e.__assign({sx:{color:"text.primary",fontSize:12,fontWeight:600}},{children:J}))}),i.jsx(y.default,{sx:{color:"text.secondary",fontSize:16,transform:we?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]})),we&&!Me&&i.jsxs(F.default,e.__assign({sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'}},{children:[i.jsxs(F.default,e.__assign({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[i.jsx(z.default,e.__assign({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Starts"})),i.jsx(z.default,e.__assign({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Ends"}))]})),i.jsxs(F.default,e.__assign({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[i.jsx(k.default,{size:"small",type:"text",value:Ee,disabled:le,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&Ce(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),i.jsx(k.default,{size:"small",type:"text",value:ye,disabled:le,error:Ee.trim().length>0&&ye.trim().length>0&&qe>He,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&Fe(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}})]})),i.jsx(F.default,{children:i.jsx(S.default,e.__assign({onClick:function(){Oe&&Ie(!0)},disabled:le||!Oe,sx:{height:"30px",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",backgroundColor:"#FFFFFF",border:"1px solid #8E80F3",borderRadius:"6px",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif',fontSize:"12px",fontWeight:600,lineHeight:"1",color:"#4A24CF",outline:"none",cursor:"pointer",textTransform:"none",transition:"all 150ms ease-in-out","&:hover":Oe?{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"}:{},"&:active":Oe?{transform:"translateY(1px)"}:{},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}}},{children:"Apply"}))}),i.jsx(F.default,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]})),we&&Me&&i.jsxs(B.default,e.__assign({spacing:.75,sx:T({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},null==fe?void 0:fe.manualConfirmation)},{children:[i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:.5},{children:[i.jsx(b.default,{color:"warning",height:14,width:14}),i.jsx(z.default,e.__assign({sx:{color:"#EA580C",fontSize:11,fontWeight:600}},{children:"Confirm this change?"}))]})),i.jsxs(z.default,e.__assign({sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4}},{children:["Pages ",qe,"-",He," will become part of ",a,", including pages from other documents in this range."]})),i.jsxs(B.default,e.__assign({direction:"row",spacing:.75},{children:[i.jsx(S.default,e.__assign({variant:"outlined",fullWidth:!0,onClick:function(){return Ie(!1)},sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"}},{children:"Cancel"})),i.jsx(S.default,e.__assign({variant:"contained",fullWidth:!0,disabled:le||!H,onClick:function(){if(Oe&&H){var e={id:exports.BoundaryReviewActionEnum.SET_RANGE,title:Q};H(-1,e,{selectedIndex:-1,option:e,startPage:qe,endPage:He,metadata:x})}},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}}},{children:"Confirm"}))]}))]}))]})),i.jsx(B.default,e.__assign({spacing:.625,sx:null==fe?void 0:fe.footer},{children:re&&i.jsxs(i.Fragment,{children:[i.jsx(R.default,{}),i.jsxs(w.default,e.__assign({onClick:V,disabled:!V,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:V?"pointer":"not-allowed"}},{children:[i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:1},{children:[i.jsx(m.default,{sx:{color:"text.secondary"}}),i.jsx(z.default,e.__assign({sx:{color:"text.primary",fontSize:12}},{children:ee}))]})),i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:.5},{children:[i.jsx(_.default,{score:u}),i.jsx(C.default,{sx:{color:"text.secondary"}})]}))]}))]})}))]}))}))},exports.isBoundaryReviewAction=W;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("@mui/icons-material/ChevronRight"),r=require("@mui/icons-material/Close"),o=require("@mui/icons-material/ExpandMore"),a=require("@mui/material/Box"),l=require("@mui/material/Button"),s=require("@mui/material/ButtonBase"),d=require("@mui/material/Divider"),u=require("@mui/material/IconButton"),c=require("@mui/material/Paper"),x=require("@mui/material/Radio"),g=require("@mui/material/Stack"),f=require("@mui/material/TextField"),p=require("@mui/material/Typography"),h=require("./RevertSummaryNotice.js"),m=require("./CognitiveIcon.js"),_=require("./CognitiveScoreBadge.js"),E=require("../../assests/icons/InfoAlert.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v,C=b(n),j=b(r),F=b(o),y=b(a),S=b(l),w=b(s),R=b(d),A=b(u),M=b(c),I=b(x),B=b(g),z=b(f),T=b(p),k=function(i,t){return e.__spreadArray([i],Array.isArray(t)?t:null==t?[]:[t],!0)},P="MERGE_ADJACENT";exports.BoundaryReviewActionEnum=void 0,(v=exports.BoundaryReviewActionEnum||(exports.BoundaryReviewActionEnum={})).KEEP="KEEP",v.SPLIT_HERE="SPLIT_HERE",v.MERGE_NEXT="MERGE_NEXT",v.MERGE_PREV="MERGE_PREV",v.MERGE_PREVIOUS="MERGE_PREVIOUS",v.SET_RANGE="SET_RANGE";var W=function(e){return Object.values(exports.BoundaryReviewActionEnum).includes(e)},N=function(i,t,n,r){if(!t||!i)return[];var o=t.additional_decisions,a=Array.isArray(o)?o:o?Object.values(o).flat():[],l=Array.from(new Set(e.__spreadArray(e.__spreadArray([],t.allowed_decisions,!0),a,!0)));return l.flatMap(function(e){var t=i.focus_page,o=l.find(function(e){return e.toLowerCase().includes("merge")}),a=null!=t&&null!=n&&null!=r&&t===n&&t===r,s=null!=t&&null!=n&&t===n,d=null!=t&&null!=r&&(t===r||t===r+1),u=s||d||!(null!=t&&(!(null!=n&&null!=r)||t>n&&t<r));switch(e){case exports.BoundaryReviewActionEnum.SET_RANGE:return[];case"KEEP":return[{id:e,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:e,title:"Split to a separate document",description:u?"A valid page inside the document is required to split it.":t?"Start a new document at page ".concat(t,"."):"Create a new document at this boundary.",disabled:u}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return e!==o?[]:a?[{id:P,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]:s?[{id:exports.BoundaryReviewActionEnum.MERGE_PREVIOUS,title:"Merge with previous document",description:"Combine this document with the previous document."}]:d?[{id:exports.BoundaryReviewActionEnum.MERGE_NEXT,title:"Merge with next document",description:"Combine this document with the next document."}]:[{id:P,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};exports.createBoundaryCardOptions=N,exports.default=function(n){var r=n.headerName,o=void 0===r?"Boundary Check":r,a=n.title,l=n.pageNo,s=n.content,d=n.revertSummary,u=n.cognitiveScore,c=n.config,x=n.metadata,g=n.previousSegmentTitle,f=n.nextSegmentTitle,p=n.selectedIndex,b=n.defaultSelectedIndex,v=void 0===b?null:b,G=n.defaultStartPage,D=n.defaultEndPage,q=n.onSelectionChange,H=n.onConfirm,O=n.onActionConfirm,V=n.onCognitiveClick,U=n.onAdjustManually,L=n.onClose,X=n.confirmLabel,K=void 0===X?"Confirm":X,$=n.manualPrompt,J=void 0===$?"Didn't find the right option?":$,Y=n.manualActionLabel,Q=void 0===Y?"Adjust Manually":Y,Z=n.cognitiveLabel,ee=void 0===Z?"Cognitive Integrity":Z,ie=n.showAdjustManually,te=void 0===ie||ie,ne=n.showCognitiveIntegrity,re=void 0===ne||ne,oe=n.showCloseButton,ae=void 0===oe||oe,le=n.confirmDisabled,se=void 0!==le&&le,de=n.width,ue=void 0===de?260:de,ce=n.maxWidth,xe=void 0===ce?260:ce,ge=n.className,fe=n.styles,pe=n.reviewAction,he=n.totalPages,me=t.useMemo(function(){return(null!=c?c:x?N(x,pe,G,D):[]).filter(function(e){return e.id!==exports.BoundaryReviewActionEnum.SET_RANGE})},[c,D,G,x,pe]),_e=t.useState(v),Ee=_e[0],be=_e[1],ve=t.useState(null==G?"":String(G)),Ce=ve[0],je=ve[1],Fe=t.useState(null==D?"":String(D)),ye=Fe[0],Se=Fe[1],we=t.useState(!1),Re=we[0],Ae=we[1],Me=t.useState(!1),Ie=Me[0],Be=Me[1],ze=t.useState(null),Te=ze[0],ke=ze[1],Pe=void 0===p?Ee:p,We=null==Pe?void 0:me[Pe],Ne=(null==We?void 0:We.id)===P,Ge=null!=g,De=null!=f,qe=function(e){return!0===e.disabled||e.id===exports.BoundaryReviewActionEnum.MERGE_PREV&&!Ge||e.id===exports.BoundaryReviewActionEnum.MERGE_PREVIOUS&&!Ge||e.id===exports.BoundaryReviewActionEnum.MERGE_NEXT&&!De||e.id===P&&!Ge&&!De},He=Number(Ce),Oe=Number(ye),Ve=Ce.trim().length>0&&ye.trim().length>0&&Number.isInteger(He)&&Number.isInteger(Oe)&&He>0&&Oe>0,Ue=null!=he&&He>he,Le=null!=he&&Oe>he,Xe=Ve&&He<=Oe&&!Ue&&!Le,Ke=se||!We||qe(We)||Ne&&null==Te||!H&&!O;return i.jsx(M.default,e.__assign({className:ge,elevation:4,sx:k({width:ue,maxWidth:xe,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},null==fe?void 0:fe.root)},{children:i.jsxs(B.default,e.__assign({spacing:.75,sx:{p:1}},{children:[i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:.75,sx:null==fe?void 0:fe.header},{children:[i.jsx(E.default,{color:"error",height:16,width:16}),i.jsx(T.default,e.__assign({sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"}},{children:o})),ae&&i.jsx(A.default,e.__assign({size:"small",onClick:L,disabled:!L,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}}},{children:i.jsx(j.default,{sx:{fontSize:17}})}))]})),i.jsxs(y.default,{children:[i.jsx(T.default,e.__assign({sx:{color:"text.primary",fontSize:14,fontWeight:500}},{children:a})),null!=l&&i.jsx(T.default,e.__assign({sx:{mt:.125,color:"text.secondary",fontSize:12}},{children:l})),i.jsx(R.default,{sx:{my:.625}}),null!=d?i.jsx(h.default,{children:d}):null!=s&&i.jsx(T.default,e.__assign({component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3}},{children:s}))]}),i.jsxs(B.default,e.__assign({spacing:.625,role:"radiogroup","aria-label":"Boundary options"},{children:[me.map(function(t,n){var r=Pe===n,o=qe(t);return i.jsxs(M.default,e.__assign({variant:"outlined",sx:k({borderColor:r?"#1976d2":"divider",borderRadius:2,bgcolor:o?"#F8FAFC":"background.paper",overflow:"hidden"},null==fe?void 0:fe.option)},{children:[i.jsxs(w.default,e.__assign({role:"radio","aria-checked":r,disabled:se||o,onClick:function(){return function(e,i){se||qe(i)||(void 0===p&&be(e),i.id!==P&&ke(null),Re&&(Ae(!1),Be(!1)),null==q||q(e,i))}(n,t)},sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"}},{children:[i.jsx(I.default,{checked:r,disabled:se||o,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),i.jsxs(y.default,e.__assign({sx:{minWidth:0}},{children:[i.jsx(T.default,e.__assign({sx:{color:o?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500}},{children:t.title})),null!=t.description&&i.jsx(T.default,e.__assign({sx:{mt:.125,color:o?"#94A3B8":"text.secondary",fontSize:11}},{children:t.description}))]}))]})),r&&t.id===P&&i.jsx(B.default,e.__assign({direction:"row",spacing:.75,sx:k({px:.75,pb:.75},null==fe?void 0:fe.adjacentSelector)},{children:[{direction:"previous",title:null!=g?g:"No Previous document",caption:"← Merge into Previous",available:Ge},{direction:"next",title:null!=f?f:"No Next document",caption:"Merge into Next →",available:De}].map(function(t){var n=Te===t.direction;return i.jsxs(B.default,e.__assign({sx:{flex:1,minWidth:0}},{children:[i.jsx(w.default,e.__assign({disabled:se||!t.available,onClick:function(){return ke(t.direction)},"aria-pressed":n,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:n?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:n?"#E0E7FF":"background.paper",color:n?"#7F56D9":t.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}}},{children:i.jsx(T.default,e.__assign({sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"}},{children:t.title}))})),i.jsx(T.default,e.__assign({sx:{mt:.5,color:n?"#5925DC":"text.secondary",fontSize:9.5,lineHeight:1.2,whiteSpace:"nowrap",textAlign:"next"===t.direction?"right":"left"}},{children:t.caption}))]}),t.direction)})}))]}),t.id)}),Ne&&null!=Te&&i.jsxs(B.default,e.__assign({direction:"row",alignItems:"flex-start",spacing:.625,sx:k({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},null==fe?void 0:fe.impactWarning)},{children:[i.jsx(E.default,{color:"error",height:14,width:14,sx:{mt:.125}}),i.jsxs(T.default,e.__assign({sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4}},{children:["This will impact the ",Te," document. Its content and page range will change."]}))]})),i.jsx(S.default,e.__assign({variant:"contained",fullWidth:!0,disabled:Ke,onClick:function(){if(!Ke&&null!=Pe&&We){var i=Ne?"previous"===Te?exports.BoundaryReviewActionEnum.MERGE_PREVIOUS:exports.BoundaryReviewActionEnum.MERGE_NEXT:We.id,t=Ne?e.__assign(e.__assign({},We),{id:i}):We,n={selectedIndex:Pe,option:t,metadata:x};null==H||H(Pe,t,n),O&&W(i)&&O(i,n)}},sx:k({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},null==fe?void 0:fe.confirmButton)},{children:K}))]})),te&&i.jsxs(B.default,e.__assign({spacing:.625,sx:null==fe?void 0:fe.manualSection},{children:[i.jsxs(w.default,e.__assign({disabled:se,onClick:function(){var e=!Re;Ae(e),Be(!1),e&&(void 0===p&&be(null),null==U||U())},"aria-expanded":Re,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"}},{children:[i.jsx(y.default,{children:i.jsx(T.default,e.__assign({sx:{color:"text.primary",fontSize:12,fontWeight:600}},{children:J}))}),i.jsx(F.default,{sx:{color:"text.secondary",fontSize:16,transform:Re?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]})),Re&&!Ie&&i.jsxs(y.default,e.__assign({sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'}},{children:[i.jsxs(y.default,e.__assign({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[i.jsx(T.default,e.__assign({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Starts"})),i.jsx(T.default,e.__assign({sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0}},{children:"Ends"}))]})),i.jsxs(y.default,e.__assign({sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"}},{children:[i.jsxs(y.default,{children:[i.jsx(z.default,{size:"small",type:"text",value:Ce,disabled:se,error:Ue,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&je(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Ue?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Ue?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Ue?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Ue&&i.jsxs(T.default,e.__assign({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:["Must be ≤ ",he," (total pages)"]}))]}),i.jsxs(y.default,{children:[i.jsx(z.default,{size:"small",type:"text",value:ye,disabled:se,error:Le||Ce.trim().length>0&&ye.trim().length>0&&He>Oe,onChange:function(e){var i=e.target.value;/^\d*$/.test(i)&&Se(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Le||Ce.trim().length>0&&ye.trim().length>0&&He>Oe?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Le||Ce.trim().length>0&&ye.trim().length>0&&He>Oe?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Le||Ce.trim().length>0&&ye.trim().length>0&&He>Oe?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Le&&i.jsxs(T.default,e.__assign({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:["Must be ≤ ",he," (total pages)"]})),!Le&&Ce.trim().length>0&&ye.trim().length>0&&He>Oe&&i.jsx(T.default,e.__assign({sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500}},{children:"End page must be ≥ start page"}))]})]})),i.jsx(y.default,{children:i.jsx(S.default,e.__assign({onClick:function(){Xe&&Be(!0)},disabled:se||!Xe,sx:{height:"30px",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",backgroundColor:"#FFFFFF",border:"1px solid #8E80F3",borderRadius:"6px",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif',fontSize:"12px",fontWeight:600,lineHeight:"1",color:"#4A24CF",outline:"none",cursor:"pointer",textTransform:"none",transition:"all 150ms ease-in-out","&:hover":Xe?{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"}:{},"&:active":Xe?{transform:"translateY(1px)"}:{},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}}},{children:"Apply"}))}),i.jsx(y.default,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]})),Re&&Ie&&i.jsxs(B.default,e.__assign({spacing:.75,sx:k({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},null==fe?void 0:fe.manualConfirmation)},{children:[i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:.5},{children:[i.jsx(E.default,{color:"warning",height:14,width:14}),i.jsx(T.default,e.__assign({sx:{color:"#EA580C",fontSize:11,fontWeight:600}},{children:"Confirm this change?"}))]})),i.jsxs(T.default,e.__assign({sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4}},{children:["Pages ",He,"-",Oe," will become part of ",a,", including pages from other documents in this range."]})),i.jsxs(B.default,e.__assign({direction:"row",spacing:.75},{children:[i.jsx(S.default,e.__assign({variant:"outlined",fullWidth:!0,onClick:function(){return Be(!1)},sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"}},{children:"Cancel"})),i.jsx(S.default,e.__assign({variant:"contained",fullWidth:!0,disabled:se||!H,onClick:function(){if(Xe&&H){var e={id:exports.BoundaryReviewActionEnum.SET_RANGE,title:Q};H(-1,e,{selectedIndex:-1,option:e,startPage:He,endPage:Oe,metadata:x})}},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}}},{children:"Confirm"}))]}))]}))]})),i.jsx(B.default,e.__assign({spacing:.625,sx:null==fe?void 0:fe.footer},{children:re&&i.jsxs(i.Fragment,{children:[i.jsx(R.default,{}),i.jsxs(w.default,e.__assign({onClick:V,disabled:!V,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:V?"pointer":"not-allowed"}},{children:[i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:1},{children:[i.jsx(m.default,{sx:{color:"text.secondary"}}),i.jsx(T.default,e.__assign({sx:{color:"text.primary",fontSize:12}},{children:ee}))]})),i.jsxs(B.default,e.__assign({direction:"row",alignItems:"center",spacing:.5},{children:[i.jsx(_.default,{score:u}),i.jsx(C.default,{sx:{color:"text.secondary"}})]}))]}))]})}))]}))}))},exports.isBoundaryReviewAction=W;
2
2
  //# sourceMappingURL=BoundaryCard.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n,t=require("tslib"),i=require("react/jsx-runtime"),r=require("react"),o=require("@react-pdf-viewer/core"),a=require("../PdfViewer/PdfViewer.js"),l=require("./BoundaryCard.js"),u=require("./CardWrapper.js"),d=require("./CognitiveIntegrity.js"),s=require("./LabelCheck.js"),g=require("./PageCheck.js"),c=require("./reviewStepAdapters.js"),v=require("lucide-react"),m=require("@mui/material"),p=require("./ReviewedCard.js"),f=require("./ReviewedBoundaryActions.js"),_=require("./RevertCard.js"),w=require("./RevertSuccessCard.js"),h=require("./helper.js"),y=require("./ChartBreakoutCircle.js"),b=260;exports.SegmentPdfSpecialZoomLevel=void 0,(n=exports.SegmentPdfSpecialZoomLevel||(exports.SegmentPdfSpecialZoomLevel={})).ActualSize="ActualSize",n.PageFit="PageFit",n.PageWidth="PageWidth";var x=((e={})[exports.SegmentPdfSpecialZoomLevel.ActualSize]=o.SpecialZoomLevel.ActualSize,e[exports.SegmentPdfSpecialZoomLevel.PageFit]=o.SpecialZoomLevel.PageFit,e[exports.SegmentPdfSpecialZoomLevel.PageWidth]=o.SpecialZoomLevel.PageWidth,e),S=function(e){return{reviewId:e.id,segment:e.segment,pageNumber:e.pageNumber}};exports.default=function(e){var n,R,E,C,P,k,A,M,I,j,B,N,L,F,T,q,K,W,z,G,O,D,V,H,U,Z,X,Y,J,Q,$,ee,ne,te,ie=this,re=e.pdfUrl,oe=e.pdfName,ae=e.segments,le=e.styles,ue=e.pdfViewerProps,de=e.specialZoomLevel,se=e.showBadges,ge=void 0===se||se,ce=e.sortByConfidence,ve=void 0===ce?"low":ce,me=e.filterByConfidence,pe=void 0===me?"all":me,fe=e.showBadgeNavigation,_e=void 0===fe||fe,we=e.autoSelectReviewOnPageChange,he=void 0!==we&&we,ye=e.autoAdvanceAfterConfirm,be=void 0===ye||ye,xe=e.autoAdvanceScoreBand,Se=e.badgePreloadPages,Re=void 0===Se?8:Se,Ee=e.badgeOffsetTop,Ce=void 0===Ee?20:Ee,Pe=e.badgeOffsetRight,ke=void 0===Pe?68:Pe,Ae=e.badgeOffsetLeft,Me=void 0===Ae?0:Ae,Ie=e.initialReviewId,je=e.manualPrompt,Be=e.heightBuffer,Ne=e.onBoundaryAction,Le=e.onLabelAction,Fe=e.onPageAction,Te=e.onPageTypeRevert,qe=e.onRevert,Ke=e.onActiveReviewChange,We=e.onCurrentPageChange,ze=e.onActionError,Ge=e.disableAllActions,Oe=void 0!==Ge&&Ge,De=e.disablePdfAnnotations,Ve=void 0!==De&&De,He=e.disablePdfTextLayer,Ue=void 0===He||He,Ze=e.disableTitleCheckUntilBoundaryCheckCompleted,Xe=void 0!==Ze&&Ze,Ye=e.onAdjustManually,Je=e.onCognitiveClick,Qe=e.className,$e=e.style,en=e.viewerStyle,nn=e.railStyle,tn=e.redirectionData,rn=e.onBadgeSelected,on=r.useMemo(function(){return c.extractSegmentReviewData(ae)},[ae]),an=on.boundaryReviews,ln=on.labelReviews,un=on.pageReviews,dn=r.useState(function(){return new Map}),sn=dn[0],gn=dn[1],cn=r.useMemo(function(){var e=new Map,n=1;return ae.forEach(function(t,i){var r=c.getSegmentReviewKey(t,i);e.has(r)||(e.set(r,n),n+=1)}),e},[ae]),vn=r.useMemo(function(){return new Set(ln.map(function(e){return c.getSegmentReviewKey(e.segment)}))},[ln]),mn=r.useMemo(function(){return h.getPendingMergeImpactedSegmentKeys(ae)},[ae]);r.useEffect(function(){gn(function(e){var n=!1,t=new Map(e);return e.forEach(function(e,i){var r=ae.find(function(e){return c.getSegmentReviewKey(e)===i});r&&!h.hasPolledStructuralAction(r,e)||(t.delete(i),n=!0)}),n?t:e})},[ae]);var pn=r.useMemo(function(){return h.getOptimisticMergeImpactedSegmentKeys(ae,sn)},[sn,ae]),fn=r.useRef(null),_n=r.useMemo(function(){return t.__spreadArray(t.__spreadArray(t.__spreadArray([],an.filter(function(e){return!mn.has(c.getSegmentReviewKey(e.segment))&&!pn.has(c.getSegmentReviewKey(e.segment))&&!h.shouldHideStructuralBoundaryReview(e.review_step,e.segment,vn.has(c.getSegmentReviewKey(e.segment)),sn.get(c.getSegmentReviewKey(e.segment)))}).map(function(e){var n;return t.__assign(t.__assign({},e),{kind:"boundary",pageNumber:null!==(n=e.metadata.focus_page)&&void 0!==n?n:e.segment.start_page})}),!0),ln.filter(function(e){return!mn.has(c.getSegmentReviewKey(e.segment))&&!pn.has(c.getSegmentReviewKey(e.segment))}).map(function(e){return t.__assign(t.__assign({},e),{kind:"label",pageNumber:e.segment.start_page})}),!0),un.filter(function(e){return!mn.has(c.getSegmentReviewKey(e.segment))&&!pn.has(c.getSegmentReviewKey(e.segment))}).map(function(e){var n;return t.__assign(t.__assign({},e),{kind:"page",pageNumber:null!==(n=e.metadata.page_num)&&void 0!==n?n:e.segment.start_page})}),!0).sort(function(e,n){var t,i,r=null!==(t=cn.get(c.getSegmentReviewKey(e.segment)))&&void 0!==t?t:Number.MAX_SAFE_INTEGER,o=null!==(i=cn.get(c.getSegmentReviewKey(n.segment)))&&void 0!==i?i:Number.MAX_SAFE_INTEGER;return e.pageNumber-n.pageNumber||r-o||e.reviewStepIndex-n.reviewStepIndex||e.id.localeCompare(n.id)})},[an,ln,un,pn,sn,mn,cn,vn]),wn=r.useMemo(function(){return ae.map(function(e){var n,i;return t.__assign(t.__assign({},e),{title:(null===(n=e.label)||void 0===n?void 0:n.trim())||e.title,page_count:null!==(i=e.page_count)&&void 0!==i?i:e.end_page-e.start_page+1})})},[ae]),hn=r.useState(1),yn=hn[0],bn=hn[1],xn=r.useState(null!=Ie?Ie:null),Sn=xn[0],Rn=xn[1],En=r.useState(null!=Ie?Ie:null),Cn=En[0],Pn=En[1],kn=r.useState(!1),An=kn[0],Mn=kn[1],In=r.useState(null),jn=In[0],Bn=In[1],Nn=r.useState(null),Ln=Nn[0],Fn=Nn[1],Tn=r.useState(function(){return new Set}),qn=Tn[0],Kn=Tn[1],Wn=r.useState(null),zn=Wn[0],Gn=Wn[1],On=r.useState(null),Dn=On[0],Vn=On[1],Hn=r.useState(null),Un=Hn[0],Zn=Hn[1],Xn=r.useState(!1),Yn=Xn[0],Jn=Xn[1],Qn=r.useRef(0),$n=r.useRef(null),et=r.useRef(null),nt=r.useRef(new Map),tt=r.useRef(null),it=r.useRef(null),rt=r.useRef(null),ot=r.useState(b),at=ot[0],lt=ot[1],ut=null!==(R=null===(n=null==le?void 0:le.aside)||void 0===n?void 0:n.width)&&void 0!==R?R:"40%",dt="min(".concat("number"==typeof ut?"".concat(ut,"px"):ut,", ").concat(b,"px, 100%)");r.useEffect(function(){Kn(function(e){if(0===e.size)return e;var n=new Set(e),t=!1;return _n.forEach(function(e){var i;null!=(null===(i=e.review_step.review)||void 0===i?void 0:i.action)&&n.has(e.id)&&(n.delete(e.id),t=!0)}),t?n:e})},[_n]),r.useEffect(function(){var e=fn.current;if(e&&ge){var n=function(){var n=e.getBoundingClientRect().width;n>0&&lt(n)};n();var t="undefined"==typeof ResizeObserver?null:new ResizeObserver(n);return null==t||t.observe(e),function(){return null==t?void 0:t.disconnect()}}},[ge]);var st=r.useMemo(function(){var e=new Set;return _n.forEach(function(n){var t;null!=(null===(t=n.review_step.review)||void 0===t?void 0:t.action)&&e.add(n.id)}),e},[_n]),gt=r.useMemo(function(){var e;return null!==(e=_n.find(function(e){return e.id===Sn}))&&void 0!==e?e:null},[Sn,_n]),ct=r.useMemo(function(){return!(!Xe||"label"!==(null==gt?void 0:gt.kind))&&an.some(function(e){if(c.getSegmentReviewKey(e.segment)!==c.getSegmentReviewKey(gt.segment)||st.has(e.id))return!1;var n=h.getResolvedScore(e.review_step.score,e.review_step.confidence);return null==n||n<85})},[gt,an,Xe,st]),vt=null==gt?-1:ae.findIndex(function(e){return c.getSegmentReviewKey(e)===c.getSegmentReviewKey(gt.segment)}),mt=vt>0?ae[vt-1]:void 0,pt=vt>=0?ae[vt+1]:void 0,ft=(null===(E=null==mt?void 0:mt.label)||void 0===E?void 0:E.trim())||(null==mt?void 0:mt.title),_t=(null===(C=null==pt?void 0:pt.label)||void 0===C?void 0:C.trim())||(null==pt?void 0:pt.title),wt=h.getConfidenceColors(null==gt?void 0:gt.review_step.score,null==gt?void 0:gt.review_step.confidence,null===(P=null==gt?void 0:gt.segment.confidence)||void 0===P?void 0:P.awaiting_llm),ht=(null===(k=null==gt?void 0:gt.review_step.reasons)||void 0===k?void 0:k.length)?gt.review_step.reasons:null!==(M=null===(A=null==gt?void 0:gt.segment.confidence)||void 0===A?void 0:A.reasons)&&void 0!==M?M:[],yt=Boolean(ht.some(function(e){return e.text.trim()&&["evidence","gap"].includes(e.type.trim().toLowerCase())})||(null===(I=null==gt?void 0:gt.review_step.reason)||void 0===I?void 0:I.trim())||(null===(j=null==gt?void 0:gt.review_step.gap)||void 0===j?void 0:j.trim())),bt=null==gt?null:"boundary"===gt.kind?h.getBoundaryReviewActionBadgeLabel(gt.review_step,gt.segment,sn.get(null!==(B=gt.segment.stable_key)&&void 0!==B?B:"")):h.getTitleReviewActionBadgeLabel(gt.review_step,gt.segment,sn.get(null!==(N=gt.segment.stable_key)&&void 0!==N?N:"")),xt="label"===(null==gt?void 0:gt.kind)?[bt,gt.review_step.human_action_enum,null===(L=gt.review_step.review)||void 0===L?void 0:L.action,null===(F=gt.review_step.human_resolution)||void 0===F?void 0:F.action]:[],St="label"===(null==gt?void 0:gt.kind)&&xt.some(function(e){var n,t=null!==(n=null==e?void 0:e.trim().toUpperCase())&&void 0!==n?n:"";return t.includes("MERGE")||t.includes("SPLIT")}),Rt=null!=gt&&_n.some(function(e){return"boundary"===e.kind&&c.getSegmentReviewKey(e.segment)===c.getSegmentReviewKey(gt.segment)}),Et=St&&!Rt,Ct=("boundary"===(null==gt?void 0:gt.kind)||Et)&&null!=gt?function(){var e,n,i,r,o,a;if("boundary"===gt.kind)return gt;var l=an.find(function(e){return c.getSegmentReviewKey(e.segment)===c.getSegmentReviewKey(gt.segment)});return l?t.__assign(t.__assign({},l),{kind:"boundary",pageNumber:null!==(e=l.metadata.focus_page)&&void 0!==e?e:l.segment.start_page}):t.__assign(t.__assign({},gt),{kind:"boundary",pageNumber:null!==(i=null===(n=gt.segment.review_action)||void 0===n?void 0:n.focus_page)&&void 0!==i?i:gt.segment.start_page,metadata:{focus_page:null!==(o=null===(r=gt.segment.review_action)||void 0===r?void 0:r.focus_page)&&void 0!==o?o:null,boundary_margin:null!==(a=gt.segment.boundary_margin)&&void 0!==a?a:null,user_actions:[]}})}():void 0,Pt=null==gt?"":(null===(T=gt.segment.label)||void 0===T?void 0:T.trim())||gt.segment.title,kt=null==gt?void 0:gt.review_step.revert,At=null==gt?void 0:gt.segment.revert,Mt=function(e){return null==e?void 0:e.trim().toLowerCase()},It=null==gt||null===(K=t.__spreadArray([],null!==(q=gt.segment.review_steps)&&void 0!==q?q:[],!0).reverse().find(function(e){var n,t,i=null===(n=e.type)||void 0===n?void 0:n.trim().toLowerCase();return("page_boundary"===i||"page boundary review"===i)&&"boundary"===Mt(null===(t=e.revert)||void 0===t?void 0:t.type)}))||void 0===K?void 0:K.revert,jt=null!==(W=null!=kt?kt:null==gt?void 0:gt.segment.revert)&&void 0!==W?W:It,Bt=null==jt?void 0:jt.decision.trim().toUpperCase(),Nt=null!=bt?bt:(null==Bt?void 0:Bt.includes("SPLIT"))?"Split":(null==Bt?void 0:Bt.includes("MERGE"))?"Merged":null,Lt="label"===(null==gt?void 0:gt.kind)&&"SET_RANGE"===(null===(z=null==It?void 0:It.decision)||void 0===z?void 0:z.trim().toUpperCase())&&It.current_segment_ids.length!==It.previous_state.length,Ft="Merged"===bt||"Split"===bt||Lt,Tt=null==gt?void 0:Ft?"boundary"===Mt(null==It?void 0:It.type)?It:"boundary"===Mt(null==At?void 0:At.type)?At:"boundary"===Mt(null==kt?void 0:kt.type)?kt:void 0:"label"===gt.kind?"label"===Mt(null==kt?void 0:kt.type)?kt:void 0:"boundary"===gt.kind?"boundary"===Mt(null==kt?void 0:kt.type)?kt:"boundary"===Mt(null==It?void 0:It.type)?It:"boundary"===Mt(null==At?void 0:At.type)?At:void 0:void 0,qt=Ft&&(null==Tt?void 0:Tt.operation_id)?ae.flatMap(function(e){var n;return null!==(n=e.review_steps)&&void 0!==n?n:[]}).find(function(e){var n,t,i,r,o,a,l,u=null===(n=e.type)||void 0===n?void 0:n.trim().toLowerCase();return("page_boundary"===u||"page boundary review"===u)&&((null!==(o=null!==(i=null===(t=e.human_resolution)||void 0===t?void 0:t.operation_id)&&void 0!==i?i:null===(r=e.revert)||void 0===r?void 0:r.operation_id)&&void 0!==o?o:e.operation_id)===Tt.operation_id&&Boolean(null===(l=null===(a=e.human_resolution)||void 0===a?void 0:a.change_summary)||void 0===l?void 0:l.trim()))}):void 0,Kt=(null===(G=null==Tt?void 0:Tt.summary)||void 0===G?void 0:G.trim())||null,Wt=Ft?(null===(D=null===(O=null==qt?void 0:qt.human_resolution)||void 0===O?void 0:O.change_summary)||void 0===D?void 0:D.trim())||(null===(V=null==Tt?void 0:Tt.summary)||void 0===V?void 0:V.trim())||"":(null===(Z=null===(U=null===(H=null==gt?void 0:gt.review_step)||void 0===H?void 0:H.human_resolution)||void 0===U?void 0:U.change_summary)||void 0===Z?void 0:Z.trim())||(null===(Y=null===(X=null==gt?void 0:gt.review_step)||void 0===X?void 0:X.summary)||void 0===Y?void 0:Y.trim())||"",zt=null==gt?null:Tt?{currentSegment:{title:Pt,startPage:gt.segment.start_page,endPage:gt.segment.end_page},previousSegments:Tt.previous_state.map(function(e){var n,t;return{title:(null===(n=e.label)||void 0===n?void 0:n.trim())||(null===(t=e.title)||void 0===t?void 0:t.trim())||"Untitled document",startPage:e.start_page,endPage:e.end_page}})}:"Split"===Nt?{currentSegment:{title:Pt,startPage:gt.segment.start_page,endPage:gt.segment.end_page},previousSegments:[{title:"Advice of Award",startPage:1,endPage:25},{title:Pt,startPage:gt.segment.start_page,endPage:gt.segment.end_page}]}:"Merged"===Nt?{currentSegment:{title:Pt,startPage:gt.segment.start_page,endPage:gt.segment.end_page},previousSegments:[{title:"Advice of Award",startPage:1,endPage:25},{title:"Request for proposal (RFP)",startPage:26,endPage:76}]}:{currentSegment:{title:Pt,startPage:gt.segment.start_page,endPage:gt.segment.end_page},previousSegments:[]},Gt="page"===(null==gt?void 0:gt.kind)&&null!==(J=gt.metadata.classification_id)&&void 0!==J?J:null,Ot="page"===(null==gt?void 0:gt.kind)?Boolean(Te&&Gt):Boolean((null==Tt?void 0:Tt.operation_id)&&(null==Tt?void 0:Tt.type)&&!1!==(null==Tt?void 0:Tt.revertable));Boolean(zt&&Ot&&("page"!==(null==gt?void 0:gt.kind)||Gt));var Dt=r.useCallback(function(e,n){Qn.current+=1,$n.current={requestId:Qn.current,pageNumber:e,reviewId:n},Fn({pageNumber:e,requestId:Qn.current})},[]),Vt=r.useCallback(function(e){var n,t;!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)&&(null==rn||rn({reviewId:e.id,segment_id:null!==(t=e.segment.segment_id)&&void 0!==t?t:null,reviewStepIndex:e.reviewStepIndex,kind:e.kind,pageNumber:e.pageNumber,metadata:e.metadata}),Vn(null),Zn(null),Rn(e.id),Pn(e.id),Mn(!1),Bn(null),Dt(e.pageNumber,e.id),null==Ke||Ke(e.id,e.segment))},[Ke,rn,Dt]);r.useEffect(function(){if(Un){var e=requestAnimationFrame(function(){return Jn(!0)}),n=window.setTimeout(function(){Jn(!1)},3500),t=window.setTimeout(function(){Zn(null)},4e3);return function(){cancelAnimationFrame(e),window.clearTimeout(n),window.clearTimeout(t)}}},[Un]),r.useEffect(function(){var e,n,t,i;if(tn){if("pageGroup"===tn.type){var r=null!==(e=tn.pages)&&void 0!==e?e:[],o=null!==(n=tn.pageIndex)&&void 0!==n?n:0,a=r[o];if(null==a)return;return Ht(),Vn({pages:r,index:o,label:null!==(t=tn.groupLabel)&&void 0!==t?t:""}),Qn.current+=1,void Fn({pageNumber:a,requestId:Qn.current})}if(Vn(null),tn.reviewId){var l=_n.find(function(e){return e.id===tn.reviewId&&(!tn.type||e.kind===tn.type)});if(l)return void Vt(l)}if(tn.classificationId){var u=_n.find(function(e){return!("page"!==e.kind||e.metadata.classification_id!==tn.classificationId||tn.segmentId&&e.segment.segment_id!==tn.segmentId||tn.type&&e.kind!==tn.type)});if(u)return void Vt(u)}if(tn.pageNumber&&tn.type){var d=Number(tn.pageNumber);if(Number.isInteger(d)&&!(d<1)){var s=null===(i=tn.pageType)||void 0===i?void 0:i.trim().toLowerCase(),g=_n.find(function(e){var n="page"===e.kind?e.pageNumber:e.segment.start_page,t="page"!==e.kind||!s||e.metadata.page_type===s;return(!tn.segmentId||e.segment.segment_id===tn.segmentId)&&n===d&&e.kind===tn.type&&t});g?Vt(g):"page"===tn.type&&(Ht(),Qn.current+=1,Fn({pageNumber:d,requestId:Qn.current}))}}}},[tn,Vt,_n]);var Ht=r.useCallback(function(){$n.current=null,Mn(!1),Rn(null),Bn(null),null==Ke||Ke(null,null)},[Ke]),Ut=r.useCallback(function(e){var n;Jn(!1),Zn(null);var t=null!==(n=_n.find(function(n){return!st.has(n.id)&&"boundary"===n.kind&&n.segment.start_page===e.startPage&&n.segment.end_page===e.endPage}))&&void 0!==n?n:_n.find(function(n){return!st.has(n.id)&&n.segment.start_page<=e.startPage&&n.segment.end_page>=e.startPage});t?Vt(t):(Ht(),Qn.current+=1,Fn({pageNumber:e.startPage,requestId:Qn.current}))},[Ht,st,_n,Vt]),Zt=r.useCallback(function(e,n){var t,i=h.getReviewScoreBand(e.review_step.score),r=null==xe||i===xe,o=qn.has(e.id)&&h.isReviewStepResolutionCurrent(e.review_step,e.segment);return e.id!==n&&r&&!0!==(null===(t=e.segment.confidence)||void 0===t?void 0:t.awaiting_llm)&&!h.isReviewStepResolved(e.review_step,e.segment)&&!o},[xe,qn]),Xt=r.useCallback(function(e){var n;if(be){var t=_n.findIndex(function(n){return n.id===e}),i=null!==(n=_n.find(function(n,i){return i>t&&Zt(n,e)}))&&void 0!==n?n:_n.find(function(n){return Zt(n,e)});i?requestAnimationFrame(function(){return Vt(i)}):Ht()}else Ht()},[be,Ht,Zt,_n,Vt]),Yt=r.useCallback(function(e,n,i){return t.__awaiter(ie,void 0,void 0,function(){var r,o,a,u,d,s,g,v,m;return t.__generator(this,function(t){switch(t.label){case 0:if(Oe)return[2];if("boundary"===e.kind&&!Ne)return[2];if("label"===e.kind&&!Le)return[2];if("page"===e.kind&&!Fe)return[2];r=S(e),a=i,u=(o=n)===l.BoundaryReviewActionEnum.SET_RANGE?function(){var n=a.startPage,t=a.endPage;if(null==n||null==t)return null;var i=n<e.segment.start_page||t>e.segment.end_page,r=n>e.segment.start_page||t<e.segment.end_page;return i&&!r?n<e.segment.start_page?l.BoundaryReviewActionEnum.MERGE_PREV:l.BoundaryReviewActionEnum.MERGE_NEXT:r?l.BoundaryReviewActionEnum.SPLIT_HERE:null}():o,d="boundary"===e.kind&&null!=Ne&&be&&(u===l.BoundaryReviewActionEnum.SPLIT_HERE||u===l.BoundaryReviewActionEnum.MERGE_NEXT||u===l.BoundaryReviewActionEnum.MERGE_PREV||u===l.BoundaryReviewActionEnum.MERGE_PREVIOUS),s=d?ae.findIndex(function(n){return c.getSegmentReviewKey(n)===c.getSegmentReviewKey(e.segment)}):-1,d&&s>=0&&u&&(et.current={action:u,originalSegmentIndex:s,segmentSignature:JSON.stringify(ae.map(function(e,n){var t;return{key:c.getSegmentReviewKey(e,n),startPage:e.start_page,endPage:e.end_page,version:null!==(t=e.version)&&void 0!==t?t:null}})),ready:!1}),Gn(e.id),t.label=1;case 1:return t.trys.push([1,8,9,10]),"boundary"!==e.kind?[3,3]:[4,null==Ne?void 0:Ne(n,i,r)];case 2:return t.sent(),[3,7];case 3:return"label"!==e.kind?[3,5]:[4,null==Le?void 0:Le(n,i,r)];case 4:return t.sent(),[3,7];case 5:return"page"!==e.kind?[3,7]:[4,null==Fe?void 0:Fe(n,i,r)];case 6:t.sent(),t.label=7;case 7:return Kn(function(n){var t=new Set(n);return t.add(e.id),t}),g="boundary"===e.kind&&(u===l.BoundaryReviewActionEnum.MERGE_NEXT||u===l.BoundaryReviewActionEnum.MERGE_PREV||u===l.BoundaryReviewActionEnum.MERGE_PREVIOUS),("boundary"===e.kind&&u===l.BoundaryReviewActionEnum.SPLIT_HERE||g)&&u&&gn(function(n){var t=new Map(n);return t.set(c.getSegmentReviewKey(e.segment),u),t}),et.current?(et.current.ready=!0,g&&(v=_n.find(function(n){return"label"===n.kind&&c.getSegmentReviewKey(n.segment)===c.getSegmentReviewKey(e.segment)}))&&requestAnimationFrame(function(){return Vt(v)})):Xt(e.id),[3,10];case 8:return m=t.sent(),d&&(et.current=null),null==ze||ze(m,r),[3,10];case 9:return Gn(null),[7];case 10:return[2]}})})},[be,Oe,ze,Ne,Le,Fe,Te,_n,ae,Vt,Xt]);r.useEffect(function(){var e=et.current;if(null==e?void 0:e.ready){var n=JSON.stringify(ae.map(function(e,n){var t;return{key:c.getSegmentReviewKey(e,n),startPage:e.start_page,endPage:e.end_page,version:null!==(t=e.version)&&void 0!==t?t:null}}));if(n!==e.segmentSignature){var t=e.action===l.BoundaryReviewActionEnum.SPLIT_HERE?e.originalSegmentIndex+1:e.action===l.BoundaryReviewActionEnum.MERGE_PREV||e.action===l.BoundaryReviewActionEnum.MERGE_PREVIOUS?Math.max(0,e.originalSegmentIndex-1):e.originalSegmentIndex,i=new Map(ae.map(function(e,n){return[c.getSegmentReviewKey(e,n),n]})),r=_n.find(function(e){var n=i.get(c.getSegmentReviewKey(e.segment));return null!=n&&n>=t&&Zt(e)});if(!r)return et.current=null,void Ht();requestAnimationFrame(function(){et.current=null,Vt(r)})}}},[Ht,Zt,_n,ae,Vt]),r.useEffect(function(){et.current||Sn&&!_n.some(function(e){return e.id===Sn})&&Ht()},[Sn,Ht,_n]),r.useEffect(function(){if(he&&!et.current){var e=_n.find(function(e){return e.pageNumber===yn});e&&e.id!==Sn&&Vt(e)}},[Sn,he,yn,Vt,_n]),r.useEffect(function(){et.current||Sn&&!_n.some(function(e){var n;return e.id===Sn&&!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)})&&Ht()},[Sn,Ht,_n]);var Jt=r.useMemo(function(){var e=_n.filter(function(e){var n;return!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)});if("all"===pe)return e;var n=["low","medium","high"].filter(function(e){return e!==ve}),i=t.__spreadArray([ve],n,!0),r=new Map(i.map(function(e,n){return[e,n]}));return e.map(function(e,n){return{item:e,index:n}}).sort(function(e,n){var t,o,a,l,u=null===(t=e.item.review_step.confidence)||void 0===t?void 0:t.trim().toLowerCase(),d=null===(o=n.item.review_step.confidence)||void 0===o?void 0:o.trim().toLowerCase();return(null==u?i.length:null!==(a=r.get(u))&&void 0!==a?a:i.length)-(null==d?i.length:null!==(l=r.get(d))&&void 0!==l?l:i.length)||e.index-n.index}).map(function(e){return e.item})},[pe,ve,_n]),Qt=Jt.findIndex(function(e){return e.id===Cn}),$t=r.useState(null),ei=$t[0],ni=$t[1],ti=r.useRef(!1),ii=r.useCallback(function(e){var n=Jt[e];n&&Vt(n)},[Jt,Vt]);r.useCallback(function(e){if(!(!Dn||e<0||e>=Dn.pages.length)){var n=Dn.pages[e];null!=n&&(Ht(),Vn(function(n){return null==n?n:t.__assign(t.__assign({},n),{index:e})}),Qn.current+=1,Fn({pageNumber:n,requestId:Qn.current}))}},[Dn,Ht]),r.useEffect(function(){Cn&&!Jt.some(function(e){return e.id===Cn})&&Pn(null)},[Jt,Cn]),r.useEffect(function(){ti.current=!1,ni(Qt>=0?String(Qt+1):null)},[Qt,Jt.length]),r.useEffect(function(){if(ti.current&&null!=ei){var e=window.setTimeout(function(){var e=Number(ei.trim()),n=e-1;Number.isInteger(e)&&n>=0&&n<Jt.length&&(ti.current=!1,ii(n))},300);return function(){return window.clearTimeout(e)}}},[ii,ei,Jt.length]);var ri=r.useMemo(function(){var e=new Map;_n.forEach(function(n){var t,i=null!==(t=e.get(c.getSegmentReviewKey(n.segment)))&&void 0!==t?t:[];i.push(n),e.set(c.getSegmentReviewKey(n.segment),i)});var n=new Map;return e.forEach(function(e,t){var i,r=null!==(i=cn.get(t))&&void 0!==i?i:1;e.sort(function(e,n){return e.reviewStepIndex-n.reviewStepIndex}).forEach(function(e,t){n.set(e.id,"".concat(r).concat(function(e){for(var n=e+1,t="";n>0;)n-=1,t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26);return t}(t)))})}),n},[_n,cn]),oi=r.useMemo(function(){var e=new Map;_n.forEach(function(n){var t,i=null!==(t=e.get(n.pageNumber))&&void 0!==t?t:[];i.push(n),e.set(n.pageNumber,i)});var n=new Map;return e.forEach(function(e){e.forEach(function(e,t){return n.set(e.id,t)})}),n},[_n]),ai=r.useCallback(function(e){return{startPage:Math.max(0,e.startPage-Re),endPage:Math.min(e.numPages-1,e.endPage+Re)}},[Re]),li=r.useCallback(function(){var e,n=it.current,t=rt.current;if(n&&t){var i=n.getBoundingClientRect(),r=t.querySelector(".rpv-core__inner-pages"),o=null!==(e=null==r?void 0:r.getBoundingClientRect())&&void 0!==e?e:t.getBoundingClientRect();_n.forEach(function(e){var n,r=nt.current.get(e.id);if(r){var a=t.querySelector('[data-testid="core__page-layer-'.concat(e.pageNumber-1,'"]'));if(a){var l=a.getBoundingClientRect(),u=null!==(n=oi.get(e.id))&&void 0!==n?n:0,d=l.top+Ce+40*u,s=d+(r.offsetHeight||32),g=d>=o.top&&s<=o.bottom;r.style.top="".concat(d-i.top,"px"),r.style.visibility=g?"visible":"hidden"}else r.style.visibility="hidden"}});var a=tt.current;if(a){var l=null==Dn?void 0:Dn.pages[Dn.index],u=null==l?null:t.querySelector('[data-testid="core__page-layer-'.concat(l-1,'"]'));if(Dn&&u){var d=u.getBoundingClientRect().top+Ce,s=d+(a.offsetHeight||25),g=d>=o.top&&s<=o.bottom;a.style.top="".concat(d-i.top,"px"),a.style.visibility=g?"visible":"hidden"}else a.style.visibility="hidden"}if(Sn&&null==$n.current){var c=nt.current.get(Sn);c&&"hidden"!==c.style.visibility&&Bn(function(e){return e===c?e:c})}}},[Dn,Sn,Ce,oi,_n]),ui=r.useCallback(function(e){var n=$n.current;n&&n.requestId===e.requestId&&n.pageNumber===e.pageNumber&&($n.current=null,li(),requestAnimationFrame(function(){if(null==$n.current){var e=nt.current.get(n.reviewId);e&&"hidden"!==e.style.visibility&&Bn(e)}}))},[li]);return r.useEffect(function(){var e=rt.current;if(e&&ge){var n=null,t=function(){null==n&&(n=requestAnimationFrame(function(){n=null,li()}))};e.addEventListener("scroll",t,!0),window.addEventListener("resize",t);var i=new MutationObserver(t);i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]});var r="undefined"==typeof ResizeObserver?null:new ResizeObserver(t);return null==r||r.observe(e),t(),function(){null!=n&&cancelAnimationFrame(n),e.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t),i.disconnect(),null==r||r.disconnect()}}},[ge,li]),i.jsxs("div",t.__assign({ref:it,className:Qe,style:t.__assign(t.__assign({},$e),{display:"block",position:"relative",width:"100%",height:"100%",minWidth:0,overflowX:"auto",overflowY:"hidden"})},{children:[i.jsxs("div",t.__assign({className:"segment-review-wrapper__container",style:{display:"flex",alignItems:"stretch",gap:0,width:"100%",minWidth:700,height:"100%"}},{children:[i.jsx("div",t.__assign({ref:rt,style:t.__assign(t.__assign({},en),{flex:"1 1 auto",width:ge?"auto":"100%",minWidth:0,height:"100%",boxSizing:"border-box"})},{children:i.jsx(a.default,t.__assign({highlightText:[],highlightPages:{},highlightCordinatePages:[],useCoordinates:!1},ue,{defaultScale:void 0===de?null!==(Q=null==ue?void 0:ue.defaultScale)&&void 0!==Q?Q:o.SpecialZoomLevel.PageFit:x[de],disablePdfAnnotations:Ve,disablePdfTextLayer:Ue,pdfUrl:re,pdfName:oe,segments:wn,navigationRequest:Ln,onNavigationSettled:ui,setRenderRange:ai,onCurrentPageChange:function(e){bn(e),null==$n.current&&gt&&gt.pageNumber!==e&&Ht(),null==We||We(e)}}))})),ge&&i.jsxs("aside",t.__assign({"aria-label":"Page review badges",ref:fn,style:t.__assign(t.__assign({},nn),{position:"relative",width:dt,maxWidth:b,flex:"0 1 ".concat(dt),minHeight:0,overflow:"hidden",boxSizing:"border-box"})},{children:[Dn&&i.jsx("span",t.__assign({ref:tt,style:{position:"absolute",top:0,left:10,visibility:"hidden",zIndex:2,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,minHeight:25,padding:"2px 8px",border:"1px solid #E2E8F0",borderRadius:16,backgroundColor:"#F8FAFC",boxSizing:"border-box",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.08)",font:"inherit"}},{children:i.jsxs(m.Typography,t.__assign({fontFamily:"Inter",sx:{fontSize:11,fontWeight:500,color:"#475569",whiteSpace:"nowrap"}},{children:[Dn.label||"Pages"," Pg: ",Dn.index+1]}))})),_e&&Jt.length>0&&!Dn&&i.jsxs("nav",t.__assign({"aria-label":"Review badge navigation",style:{position:"absolute",top:8,right:ke||"auto",left:Me||"auto",zIndex:2,display:"flex",alignItems:"center",gap:7,width:128,minHeight:40,padding:"4px 6px",border:"1px solid #CBD5E1",borderRadius:6,backgroundColor:"#FFFFFF",boxSizing:"border-box",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.06)",font:"inherit"}},{children:[i.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:null!=ei?ei:"-","aria-label":"Review badge number",onChange:function(e){ti.current=!0,ni(e.target.value)},style:{width:30,height:28,padding:0,border:"1px solid #A5B4FC",borderRadius:3,color:"#4F46E5",backgroundColor:"#FFFFFF",textAlign:"center",font:"inherit",fontSize:15,outline:"none"}}),i.jsxs("span",t.__assign({"aria-label":"".concat(Jt.length," reviews"),style:{flex:1,color:"#4F46E5",fontSize:14,whiteSpace:"nowrap",textAlign:"center"}},{children:["of ",Jt.length]})),["previous","next"].map(function(e){var n="previous"===e,r=Qt+(n?-1:1),o=r<0||r>=Jt.length;return i.jsx("button",t.__assign({type:"button","aria-label":"".concat(n?"Previous":"Next"," review badge"),disabled:o,onClick:function(){return ii(r)},style:{display:"grid",placeItems:"center",width:17,height:28,padding:0,border:0,background:"transparent",color:o?"#C7D2FE":"#4F46E5",cursor:o?"default":"pointer"}},{children:i.jsx("svg",t.__assign({width:"12",height:"8",viewBox:"0 0 12 8",fill:"none"},{children:i.jsx("path",{d:n?"M1 7L6 2L11 7":"M1 1L6 6L11 1",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}))}),e)})]})),!Dn&&_n.map(function(e){var n,r,o=Sn===e.id,a=null!==(n=ri.get(e.id))&&void 0!==n?n:"1A",l=e.review_step.score,u=e.review_step.confidence,d=h.formatScore(l,u),s="boundary"===e.kind?h.getBoundaryReviewActionBadgeLabel(e.review_step,e.segment,sn.get(c.getSegmentReviewKey(e.segment))):"label"===e.kind?h.getTitleReviewActionBadgeLabel(e.review_step,e.segment,sn.get(c.getSegmentReviewKey(e.segment))):null,g=null!=s?s:"N/A"===d?d:"".concat(d,"%"),p=!0===(null===(r=e.segment.confidence)||void 0===r?void 0:r.awaiting_llm),f=h.getConfidenceColors(l,u,p),_=st.has(e.id),w=p;return i.jsx(m.Tooltip,t.__assign({title:p?"data is being processed":"",arrow:!0},{children:i.jsx("span",t.__assign({ref:function(n){n?nt.current.set(e.id,n):nt.current.delete(e.id)},style:{position:"absolute",top:0,left:10,visibility:"hidden",display:"inline-flex",cursor:w?"not-allowed":"pointer"}},{children:i.jsx("button",t.__assign({disabled:w,type:"button","aria-pressed":o,"aria-label":p?"".concat(e.review_step.type," · Page ").concat(e.pageNumber," · Data is being processed"):"".concat(e.review_step.type," · Page ").concat(e.pageNumber),onClick:function(){return Vt(e)},style:{cursor:"inherit",display:"flex",alignItems:"center",justifyContent:"space-around",gap:4,width:s?_&&!p?115:90:_&&!p?105:80,minHeight:25,padding:"2px 5px",border:"1px solid ".concat(_&&!p?"#E2E8F0":f.border),borderRadius:16,backgroundColor:_&&!p?"#F8FAFC":f.background,color:_&&!p?"#475569":f.text,font:"inherit",alignContent:"center",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.08)"}},{children:_&&!p?i.jsxs(m.Typography,t.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),i.jsxs("span",t.__assign({style:{display:"flex",alignItems:"center"}},{children:[i.jsx("svg",t.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:g}))]})),i.jsxs("span",t.__assign({style:{fontSize:11,fontWeight:500,display:"flex",alignItems:"center"}},{children:[i.jsx("svg",t.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),i.jsx("span",t.__assign({style:{display:"flex",marginLeft:"7px",alignItems:"center"}},{children:i.jsx(v.CircleCheck,{height:14,width:14,strokeWidth:2,color:"#16A34A"})}))]}))]})):i.jsxs(m.Typography,t.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),i.jsxs("span",t.__assign({style:{display:"flex",alignItems:"center"}},{children:[i.jsx("svg",t.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M0.399902 0V14",stroke:f.divider,strokeWidth:"0.8"})})),i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:g}))]}))]}))}))}))}),e.id)})]}))]})),gt&&jn&&i.jsxs(u.default,t.__assign({anchorElement:jn,placement:"bottom-start",offset:{top:8},width:Math.min(at,b),maxWidth:b,heightBuffer:null!=Be?Be:25},{children:[An&&i.jsx(d.default,{width:"100%",maxWidth:"100%",score:gt.review_step.score,reasons:ht,reason:gt.review_step.reason,gap:gt.review_step.gap,onBack:function(){return Mn(!1)},onClose:Ht}),i.jsx("div",t.__assign({style:{display:An?"none":"block"}},{children:st.has(gt.id)?i.jsx(p.default,{width:"100%",maxWidth:"100%",headerName:"page"===gt.kind?"Page format approved":"Split"===bt?"Split approved":"Merged"===bt?"Merge approved":"User approved",headerIcon:"page"===gt.kind?i.jsx(v.Check,{size:18,strokeWidth:2}):"Merged"===bt?i.jsx(v.GitMerge,{size:18,strokeWidth:2}):"Split"===bt?i.jsx(y.default,{width:18,height:18}):i.jsx(v.CircleCheck,{size:18,strokeWidth:2}),title:Pt,pageNo:"Page ".concat(gt.segment.start_page,"-").concat(gt.segment.end_page),summary:zt?i.jsx(_.default,{icon:i.jsx(v.CircleCheck,{size:14,strokeWidth:2}),title:Pt,pageRange:"Page ".concat(gt.segment.start_page,"-").concat(gt.segment.end_page),description:null!=Wt?Wt:null,revertData:zt,confirmDisabled:"page"===gt.kind?!Ot:null==qe||!Ot,showDocumentHeader:!1,onRevert:function(){if("page"===gt.kind){if(!Te||!Gt){var e=new Error("SegmentReviewPdfWrapper requires onPageTypeRevert and a classification id to revert a page-type decision.");return null==ze||ze(e,S(gt)),Promise.reject(e)}return Te({classification_id:Gt,human_verdict:"No"},S(gt))}if(!qe)throw new Error("SegmentReviewPdfWrapper requires onRevert to handle a revert confirmation.");if(!Tt)throw new Error("There is no valid revert operation for this review.");var n=Ft?"boundary":"label"===gt.kind?"label":"boundary"===gt.kind?"boundary":null,t=Mt(Tt.type);if(n&&t!==n)throw new Error("Cannot use ".concat(null!=t?t:"unknown"," revert metadata for this review. Expected ").concat(n,"."));return qe(Tt,S(gt))},onRevertError:function(e){null==ze||ze(e,S(gt))},onRevertComplete:function(e){var n,t,i,r,o,a;Kn(function(){return new Set}),"page"!==gt.kind&&gn(function(){return new Map}),gt.id;var l=null!==(n=zt.previousSegments[0])&&void 0!==n?n:zt.currentSegment,u=null==jn?void 0:jn.getBoundingClientRect(),d=null===(t=rt.current)||void 0===t?void 0:t.getBoundingClientRect(),s=Math.min(b,Math.max(220,at)),g=null!==(i=null==u?void 0:u.left)&&void 0!==i?i:(null!==(r=null==d?void 0:d.right)&&void 0!==r?r:window.innerWidth-s-8)+8,c=Math.max(8,Math.min(g,window.innerWidth-s-8)),v=null==(null==u?void 0:u.bottom)?Math.max(8,null!==(o=null==d?void 0:d.top)&&void 0!==o?o:8):u.bottom+8;Kn(function(){return new Set}),"page"!==gt.kind&&(et.current=null),Jn(!1),Zn({title:"Split"===bt?"Split reverted":"Merged"===bt?"Merge reverted":"Approval reverted",description:(null===(a=null==e?void 0:e.message)||void 0===a?void 0:a.trim())||("Split"===bt?"Pages ".concat(gt.segment.start_page,"-").concat(gt.segment.end_page," are now part of “Advice of Award” again. Review the boundary and title to confirm the document."):"Merged"===bt?"The documents have been separated again. Review their boundaries and titles to confirm them.":"“".concat(Pt,"” is pending review again. Review the boundary and title to confirm the document.")),segment:l,position:{top:v,left:c,width:s}}),Ht()}},gt.id):void 0,additionalActions:Ct?i.jsx(f.default,{metadata:Ct.metadata,reviewAction:null!==($=gt.segment.review_action)&&void 0!==$?$:void 0,startPage:gt.segment.start_page,endPage:gt.segment.end_page,title:Pt,previousSegmentTitle:ft,nextSegmentTitle:_t,disabled:Oe||!Ne||zn===gt.id,onConfirm:function(e,n){Yt(Ct,e,n)}}):void 0,cognitiveScore:gt.review_step.score,styles:{root:{borderColor:"#16A34A"},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:"#16A34A"}}},onCognitiveClick:yt?function(){Mn(!0),null==Je||Je(S(gt))}:void 0,onClose:Ht}):"boundary"===gt.kind?i.jsx(l.default,{width:"100%",maxWidth:"100%",title:gt.segment.label||gt.segment.title,pageNo:"Page ".concat(gt.pageNumber),content:null!==(ee=gt.review_step.question)&&void 0!==ee?ee:null,revertSummary:Kt,cognitiveScore:gt.review_step.score,metadata:gt.metadata,reviewAction:null!==(ne=gt.segment.review_action)&&void 0!==ne?ne:void 0,previousSegmentTitle:ft,nextSegmentTitle:_t,manualPrompt:null!=je?je:"Set a custom boundary",defaultStartPage:gt.segment.start_page,defaultEndPage:gt.segment.end_page,styles:{root:{borderColor:wt.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:wt.text}}},confirmDisabled:Oe||!Ne||zn===gt.id,onConfirm:function(e,n,t){t&&l.isBoundaryReviewAction(n.id)&&Yt(gt,n.id,t)},onAdjustManually:function(){return null==Ye?void 0:Ye(S(gt))},onCognitiveClick:yt?function(){Mn(!0),null==Je||Je(S(gt))}:void 0,onClose:Ht},gt.id):"label"===gt.kind?i.jsx(s.default,{width:"100%",maxWidth:"100%",title:gt.metadata.current_label||gt.segment.label||gt.segment.title,pageNo:"Pages ".concat(gt.segment.start_page,"-").concat(gt.segment.end_page),content:null!==(te=gt.review_step.question)&&void 0!==te?te:null,revertSummary:Kt,cognitiveScore:gt.review_step.score,metadata:gt.metadata,styles:{root:{borderColor:wt.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:wt.text}}},confirmDisabled:Oe||!Le||zn===gt.id,confirmationBlocked:ct,confirmationWarning:ct?"Please confirm the boundary before confirming the title.":void 0,onActionConfirm:function(e,n){Yt(gt,e,n)},onAdjustManually:function(){return null==Ye?void 0:Ye(S(gt))},onCognitiveClick:yt?function(){Mn(!0),null==Je||Je(S(gt))}:void 0,onClose:Ht},gt.id):i.jsx(g.default,{width:"100%",maxWidth:"100%",title:gt.segment.label||gt.segment.title,pageNo:"Page ".concat(gt.pageNumber),content:gt.review_step.reason,cognitiveScore:gt.review_step.score,pageType:gt.metadata.page_type,metadata:gt.metadata,styles:{root:{borderColor:wt.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:wt.text}}},confirmDisabled:Oe||!Fe||zn===gt.id,onActionConfirm:function(e,n){Yt(gt,e,n)},onCognitiveClick:yt?function(){Mn(!0),null==Je||Je(S(gt))}:void 0,onClose:Ht},gt.id)}))]})),Un&&i.jsx(m.Portal,{children:i.jsx(m.Box,t.__assign({"aria-live":"polite",sx:{position:"fixed",top:Un.position.top,left:Un.position.left,zIndex:1600,width:Un.position.width,maxWidth:"calc(100vw - 16px)",opacity:Yn?1:0,transform:Yn?"translateY(0)":"translateY(-6px)",transition:"opacity 500ms ease, transform 500ms ease",filter:"drop-shadow(0 12px 24px rgba(15, 23, 42, 0.18))",pointerEvents:Yn?"auto":"none"}},{children:i.jsx(w.default,{title:Un.title,description:Un.description,onReview:function(){return Ut(Un.segment)}})}))})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n,t=require("tslib"),i=require("react/jsx-runtime"),r=require("react"),o=require("@react-pdf-viewer/core"),a=require("../PdfViewer/PdfViewer.js"),l=require("./BoundaryCard.js"),u=require("./CardWrapper.js"),d=require("./CognitiveIntegrity.js"),s=require("./LabelCheck.js"),g=require("./PageCheck.js"),c=require("./reviewStepAdapters.js"),v=require("lucide-react"),m=require("@mui/material"),p=require("./ReviewedCard.js"),f=require("./ReviewedBoundaryActions.js"),w=require("./RevertCard.js"),_=require("./RevertSuccessCard.js"),h=require("./helper.js"),y=require("./ChartBreakoutCircle.js"),b=260;exports.SegmentPdfSpecialZoomLevel=void 0,(n=exports.SegmentPdfSpecialZoomLevel||(exports.SegmentPdfSpecialZoomLevel={})).ActualSize="ActualSize",n.PageFit="PageFit",n.PageWidth="PageWidth";var S=((e={})[exports.SegmentPdfSpecialZoomLevel.ActualSize]=o.SpecialZoomLevel.ActualSize,e[exports.SegmentPdfSpecialZoomLevel.PageFit]=o.SpecialZoomLevel.PageFit,e[exports.SegmentPdfSpecialZoomLevel.PageWidth]=o.SpecialZoomLevel.PageWidth,e),x=function(e){return{reviewId:e.id,segment:e.segment,pageNumber:e.pageNumber}};exports.default=function(e){var n,R,E,C,P,k,A,M,I,j,B,N,L,F,T,q,K,W,z,G,O,D,V,H,U,Z,X,Y,J,Q,$,ee,ne,te,ie=this,re=e.pdfUrl,oe=e.pdfName,ae=e.segments,le=e.totalPages,ue=e.styles,de=e.pdfViewerProps,se=e.specialZoomLevel,ge=e.showBadges,ce=void 0===ge||ge,ve=e.sortByConfidence,me=void 0===ve?"low":ve,pe=e.filterByConfidence,fe=void 0===pe?"all":pe,we=e.showBadgeNavigation,_e=void 0===we||we,he=e.autoSelectReviewOnPageChange,ye=void 0!==he&&he,be=e.autoAdvanceAfterConfirm,Se=void 0===be||be,xe=e.autoAdvanceScoreBand,Re=e.badgePreloadPages,Ee=void 0===Re?8:Re,Ce=e.badgeOffsetTop,Pe=void 0===Ce?20:Ce,ke=e.badgeOffsetRight,Ae=void 0===ke?68:ke,Me=e.badgeOffsetLeft,Ie=void 0===Me?0:Me,je=e.initialReviewId,Be=e.manualPrompt,Ne=e.heightBuffer,Le=e.onBoundaryAction,Fe=e.onLabelAction,Te=e.onPageAction,qe=e.onPageTypeRevert,Ke=e.onRevert,We=e.onActiveReviewChange,ze=e.onCurrentPageChange,Ge=e.onActionError,Oe=e.disableAllActions,De=void 0!==Oe&&Oe,Ve=e.disablePdfAnnotations,He=void 0!==Ve&&Ve,Ue=e.disablePdfTextLayer,Ze=void 0===Ue||Ue,Xe=e.disableTitleCheckUntilBoundaryCheckCompleted,Ye=void 0!==Xe&&Xe,Je=e.onAdjustManually,Qe=e.onCognitiveClick,$e=e.className,en=e.style,nn=e.viewerStyle,tn=e.railStyle,rn=e.redirectionData,on=e.onBadgeSelected,an=r.useMemo(function(){return c.extractSegmentReviewData(ae)},[ae]),ln=an.boundaryReviews,un=an.labelReviews,dn=an.pageReviews,sn=r.useState(function(){return new Map}),gn=sn[0],cn=sn[1],vn=r.useState(function(){return new Set}),mn=vn[0],pn=vn[1],fn=r.useMemo(function(){var e=new Map,n=1;return ae.forEach(function(t,i){var r=c.getSegmentReviewKey(t,i);e.has(r)||(e.set(r,n),n+=1)}),e},[ae]),wn=r.useMemo(function(){return new Set(un.map(function(e){return c.getSegmentReviewKey(e.segment)}))},[un]),_n=r.useMemo(function(){return h.getPendingMergeImpactedSegmentKeys(ae)},[ae]);r.useEffect(function(){cn(function(e){var n=!1,t=new Map(e);return e.forEach(function(e,i){var r=ae.find(function(e){return c.getSegmentReviewKey(e)===i});r&&!h.hasPolledStructuralAction(r,e)||(t.delete(i),n=!0)}),n?t:e})},[ae]),r.useEffect(function(){pn(function(e){var n=!1,t=new Set(e);return e.forEach(function(e){gn.has(e)||(t.delete(e),n=!0)}),n?t:e})},[gn]);var hn=r.useMemo(function(){return h.getOptimisticMergeImpactedSegmentKeys(ae,gn,mn)},[mn,gn,ae]),yn=r.useRef(null),bn=r.useMemo(function(){return t.__spreadArray(t.__spreadArray(t.__spreadArray([],ln.filter(function(e){return!_n.has(c.getSegmentReviewKey(e.segment))&&!hn.has(c.getSegmentReviewKey(e.segment))&&!h.shouldHideStructuralBoundaryReview(e.review_step,e.segment,wn.has(c.getSegmentReviewKey(e.segment)),gn.get(c.getSegmentReviewKey(e.segment)))}).map(function(e){var n;return t.__assign(t.__assign({},e),{kind:"boundary",pageNumber:null!==(n=e.metadata.focus_page)&&void 0!==n?n:e.segment.start_page})}),!0),un.filter(function(e){return!_n.has(c.getSegmentReviewKey(e.segment))&&!hn.has(c.getSegmentReviewKey(e.segment))}).map(function(e){return t.__assign(t.__assign({},e),{kind:"label",pageNumber:e.segment.start_page})}),!0),dn.filter(function(e){return!_n.has(c.getSegmentReviewKey(e.segment))&&!hn.has(c.getSegmentReviewKey(e.segment))}).map(function(e){var n;return t.__assign(t.__assign({},e),{kind:"page",pageNumber:null!==(n=e.metadata.page_num)&&void 0!==n?n:e.segment.start_page})}),!0).sort(function(e,n){var t,i,r=null!==(t=fn.get(c.getSegmentReviewKey(e.segment)))&&void 0!==t?t:Number.MAX_SAFE_INTEGER,o=null!==(i=fn.get(c.getSegmentReviewKey(n.segment)))&&void 0!==i?i:Number.MAX_SAFE_INTEGER;return e.pageNumber-n.pageNumber||r-o||e.reviewStepIndex-n.reviewStepIndex||e.id.localeCompare(n.id)})},[ln,un,dn,hn,gn,_n,fn,wn]),Sn=r.useMemo(function(){return ae.map(function(e){var n,i;return t.__assign(t.__assign({},e),{title:(null===(n=e.label)||void 0===n?void 0:n.trim())||e.title,page_count:null!==(i=e.page_count)&&void 0!==i?i:e.end_page-e.start_page+1})})},[ae]),xn=r.useState(1),Rn=xn[0],En=xn[1],Cn=r.useState(null!=je?je:null),Pn=Cn[0],kn=Cn[1],An=r.useState(null!=je?je:null),Mn=An[0],In=An[1],jn=r.useState(!1),Bn=jn[0],Nn=jn[1],Ln=r.useState(null),Fn=Ln[0],Tn=Ln[1],qn=r.useState(null),Kn=qn[0],Wn=qn[1],zn=r.useState(function(){return new Set}),Gn=zn[0],On=zn[1],Dn=r.useState(null),Vn=Dn[0],Hn=Dn[1],Un=r.useState(null),Zn=Un[0],Xn=Un[1],Yn=r.useState(null),Jn=Yn[0],Qn=Yn[1],$n=r.useState(!1),et=$n[0],nt=$n[1],tt=r.useRef(0),it=r.useRef(null),rt=r.useRef(null),ot=r.useRef(new Map),at=r.useRef(null),lt=r.useRef(null),ut=r.useRef(null),dt=r.useState(b),st=dt[0],gt=dt[1],ct=null!==(R=null===(n=null==ue?void 0:ue.aside)||void 0===n?void 0:n.width)&&void 0!==R?R:"40%",vt="min(".concat("number"==typeof ct?"".concat(ct,"px"):ct,", ").concat(b,"px, 100%)");r.useEffect(function(){On(function(e){if(0===e.size)return e;var n=new Set(e),t=!1;return bn.forEach(function(e){var i;null!=(null===(i=e.review_step.review)||void 0===i?void 0:i.action)&&n.has(e.id)&&(n.delete(e.id),t=!0)}),t?n:e})},[bn]),r.useEffect(function(){var e=yn.current;if(e&&ce){var n=function(){var n=e.getBoundingClientRect().width;n>0&&gt(n)};n();var t="undefined"==typeof ResizeObserver?null:new ResizeObserver(n);return null==t||t.observe(e),function(){return null==t?void 0:t.disconnect()}}},[ce]);var mt=r.useMemo(function(){var e=new Set;return bn.forEach(function(n){var t;null!=(null===(t=n.review_step.review)||void 0===t?void 0:t.action)&&e.add(n.id)}),e},[bn]),pt=r.useMemo(function(){var e;return null!==(e=bn.find(function(e){return e.id===Pn}))&&void 0!==e?e:null},[Pn,bn]),ft=r.useMemo(function(){return!(!Ye||"label"!==(null==pt?void 0:pt.kind))&&ln.some(function(e){if(c.getSegmentReviewKey(e.segment)!==c.getSegmentReviewKey(pt.segment)||mt.has(e.id))return!1;var n=h.getResolvedScore(e.review_step.score,e.review_step.confidence);return null==n||n<85})},[pt,ln,Ye,mt]),wt=null==pt?-1:ae.findIndex(function(e){return c.getSegmentReviewKey(e)===c.getSegmentReviewKey(pt.segment)}),_t=wt>0?ae[wt-1]:void 0,ht=wt>=0?ae[wt+1]:void 0,yt=(null===(E=null==_t?void 0:_t.label)||void 0===E?void 0:E.trim())||(null==_t?void 0:_t.title),bt=(null===(C=null==ht?void 0:ht.label)||void 0===C?void 0:C.trim())||(null==ht?void 0:ht.title),St=h.getConfidenceColors(null==pt?void 0:pt.review_step.score,null==pt?void 0:pt.review_step.confidence,null===(P=null==pt?void 0:pt.segment.confidence)||void 0===P?void 0:P.awaiting_llm),xt=(null===(k=null==pt?void 0:pt.review_step.reasons)||void 0===k?void 0:k.length)?pt.review_step.reasons:null!==(M=null===(A=null==pt?void 0:pt.segment.confidence)||void 0===A?void 0:A.reasons)&&void 0!==M?M:[],Rt=Boolean(xt.some(function(e){return e.text.trim()&&["evidence","gap"].includes(e.type.trim().toLowerCase())})||(null===(I=null==pt?void 0:pt.review_step.reason)||void 0===I?void 0:I.trim())||(null===(j=null==pt?void 0:pt.review_step.gap)||void 0===j?void 0:j.trim())),Et=null==pt?null:"boundary"===pt.kind?h.getBoundaryReviewActionBadgeLabel(pt.review_step,pt.segment,gn.get(null!==(B=pt.segment.stable_key)&&void 0!==B?B:"")):h.getTitleReviewActionBadgeLabel(pt.review_step,pt.segment,gn.get(null!==(N=pt.segment.stable_key)&&void 0!==N?N:"")),Ct="label"===(null==pt?void 0:pt.kind)?[Et,pt.review_step.human_action_enum,null===(L=pt.review_step.review)||void 0===L?void 0:L.action,null===(F=pt.review_step.human_resolution)||void 0===F?void 0:F.action]:[],Pt="label"===(null==pt?void 0:pt.kind)&&Ct.some(function(e){var n,t=null!==(n=null==e?void 0:e.trim().toUpperCase())&&void 0!==n?n:"";return t.includes("MERGE")||t.includes("SPLIT")}),kt=null!=pt&&bn.some(function(e){return"boundary"===e.kind&&c.getSegmentReviewKey(e.segment)===c.getSegmentReviewKey(pt.segment)}),At=Pt&&!kt,Mt=("boundary"===(null==pt?void 0:pt.kind)||At)&&null!=pt?function(){var e,n,i,r,o,a;if("boundary"===pt.kind)return pt;var l=ln.find(function(e){return c.getSegmentReviewKey(e.segment)===c.getSegmentReviewKey(pt.segment)});return l?t.__assign(t.__assign({},l),{kind:"boundary",pageNumber:null!==(e=l.metadata.focus_page)&&void 0!==e?e:l.segment.start_page}):t.__assign(t.__assign({},pt),{kind:"boundary",pageNumber:null!==(i=null===(n=pt.segment.review_action)||void 0===n?void 0:n.focus_page)&&void 0!==i?i:pt.segment.start_page,metadata:{focus_page:null!==(o=null===(r=pt.segment.review_action)||void 0===r?void 0:r.focus_page)&&void 0!==o?o:null,boundary_margin:null!==(a=pt.segment.boundary_margin)&&void 0!==a?a:null,user_actions:[]}})}():void 0,It=null==pt?"":(null===(T=pt.segment.label)||void 0===T?void 0:T.trim())||pt.segment.title,jt=null==pt?void 0:pt.review_step.revert,Bt=null==pt?void 0:pt.segment.revert,Nt=function(e){return null==e?void 0:e.trim().toLowerCase()},Lt=null==pt||null===(K=t.__spreadArray([],null!==(q=pt.segment.review_steps)&&void 0!==q?q:[],!0).reverse().find(function(e){var n,t,i=null===(n=e.type)||void 0===n?void 0:n.trim().toLowerCase();return("page_boundary"===i||"page boundary review"===i)&&"boundary"===Nt(null===(t=e.revert)||void 0===t?void 0:t.type)}))||void 0===K?void 0:K.revert,Ft=null!==(W=null!=jt?jt:null==pt?void 0:pt.segment.revert)&&void 0!==W?W:Lt,Tt=null==Ft?void 0:Ft.decision.trim().toUpperCase(),qt=null!=Et?Et:(null==Tt?void 0:Tt.includes("SPLIT"))?"Split":(null==Tt?void 0:Tt.includes("MERGE"))?"Merged":null,Kt="label"===(null==pt?void 0:pt.kind)&&"SET_RANGE"===(null===(z=null==Lt?void 0:Lt.decision)||void 0===z?void 0:z.trim().toUpperCase())&&Lt.current_segment_ids.length!==Lt.previous_state.length,Wt="Merged"===Et||"Split"===Et||Kt,zt=null==pt?void 0:Wt?"boundary"===Nt(null==Lt?void 0:Lt.type)?Lt:"boundary"===Nt(null==Bt?void 0:Bt.type)?Bt:"boundary"===Nt(null==jt?void 0:jt.type)?jt:void 0:"label"===pt.kind?"label"===Nt(null==jt?void 0:jt.type)?jt:void 0:"boundary"===pt.kind?"boundary"===Nt(null==jt?void 0:jt.type)?jt:"boundary"===Nt(null==Lt?void 0:Lt.type)?Lt:"boundary"===Nt(null==Bt?void 0:Bt.type)?Bt:void 0:void 0,Gt=Wt&&(null==zt?void 0:zt.operation_id)?ae.flatMap(function(e){var n;return null!==(n=e.review_steps)&&void 0!==n?n:[]}).find(function(e){var n,t,i,r,o,a,l,u=null===(n=e.type)||void 0===n?void 0:n.trim().toLowerCase();return("page_boundary"===u||"page boundary review"===u)&&((null!==(o=null!==(i=null===(t=e.human_resolution)||void 0===t?void 0:t.operation_id)&&void 0!==i?i:null===(r=e.revert)||void 0===r?void 0:r.operation_id)&&void 0!==o?o:e.operation_id)===zt.operation_id&&Boolean(null===(l=null===(a=e.human_resolution)||void 0===a?void 0:a.change_summary)||void 0===l?void 0:l.trim()))}):void 0,Ot=(null===(G=null==zt?void 0:zt.summary)||void 0===G?void 0:G.trim())||null,Dt=Wt?(null===(D=null===(O=null==Gt?void 0:Gt.human_resolution)||void 0===O?void 0:O.change_summary)||void 0===D?void 0:D.trim())||(null===(V=null==zt?void 0:zt.summary)||void 0===V?void 0:V.trim())||"":(null===(Z=null===(U=null===(H=null==pt?void 0:pt.review_step)||void 0===H?void 0:H.human_resolution)||void 0===U?void 0:U.change_summary)||void 0===Z?void 0:Z.trim())||(null===(Y=null===(X=null==pt?void 0:pt.review_step)||void 0===X?void 0:X.summary)||void 0===Y?void 0:Y.trim())||"",Vt=null==pt?null:zt?{currentSegment:{title:It,startPage:pt.segment.start_page,endPage:pt.segment.end_page},previousSegments:zt.previous_state.map(function(e){var n,t;return{title:(null===(n=e.label)||void 0===n?void 0:n.trim())||(null===(t=e.title)||void 0===t?void 0:t.trim())||"Untitled document",startPage:e.start_page,endPage:e.end_page}})}:"Split"===qt?{currentSegment:{title:It,startPage:pt.segment.start_page,endPage:pt.segment.end_page},previousSegments:[{title:"Advice of Award",startPage:1,endPage:25},{title:It,startPage:pt.segment.start_page,endPage:pt.segment.end_page}]}:"Merged"===qt?{currentSegment:{title:It,startPage:pt.segment.start_page,endPage:pt.segment.end_page},previousSegments:[{title:"Advice of Award",startPage:1,endPage:25},{title:"Request for proposal (RFP)",startPage:26,endPage:76}]}:{currentSegment:{title:It,startPage:pt.segment.start_page,endPage:pt.segment.end_page},previousSegments:[]},Ht="page"===(null==pt?void 0:pt.kind)&&null!==(J=pt.metadata.classification_id)&&void 0!==J?J:null,Ut="page"===(null==pt?void 0:pt.kind)?Boolean(qe&&Ht):Boolean((null==zt?void 0:zt.operation_id)&&(null==zt?void 0:zt.type)&&!1!==(null==zt?void 0:zt.revertable));Boolean(Vt&&Ut&&("page"!==(null==pt?void 0:pt.kind)||Ht));var Zt=r.useCallback(function(e,n){tt.current+=1,it.current={requestId:tt.current,pageNumber:e,reviewId:n},Wn({pageNumber:e,requestId:tt.current})},[]),Xt=r.useCallback(function(e){var n,t;!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)&&(null==on||on({reviewId:e.id,segment_id:null!==(t=e.segment.segment_id)&&void 0!==t?t:null,reviewStepIndex:e.reviewStepIndex,kind:e.kind,pageNumber:e.pageNumber,metadata:e.metadata}),Xn(null),Qn(null),kn(e.id),In(e.id),Nn(!1),Tn(null),Zt(e.pageNumber,e.id),null==We||We(e.id,e.segment))},[We,on,Zt]);r.useEffect(function(){if(Jn){var e=requestAnimationFrame(function(){return nt(!0)}),n=window.setTimeout(function(){nt(!1)},3500),t=window.setTimeout(function(){Qn(null)},4e3);return function(){cancelAnimationFrame(e),window.clearTimeout(n),window.clearTimeout(t)}}},[Jn]),r.useEffect(function(){var e,n,t,i;if(rn){if("pageGroup"===rn.type){var r=null!==(e=rn.pages)&&void 0!==e?e:[],o=null!==(n=rn.pageIndex)&&void 0!==n?n:0,a=r[o];if(null==a)return;return Yt(),Xn({pages:r,index:o,label:null!==(t=rn.groupLabel)&&void 0!==t?t:""}),tt.current+=1,void Wn({pageNumber:a,requestId:tt.current})}if(Xn(null),rn.reviewId){var l=bn.find(function(e){return e.id===rn.reviewId&&(!rn.type||e.kind===rn.type)});if(l)return void Xt(l)}if(rn.classificationId){var u=bn.find(function(e){return!("page"!==e.kind||e.metadata.classification_id!==rn.classificationId||rn.segmentId&&e.segment.segment_id!==rn.segmentId||rn.type&&e.kind!==rn.type)});if(u)return void Xt(u)}if(rn.pageNumber&&rn.type){var d=Number(rn.pageNumber);if(Number.isInteger(d)&&!(d<1)){var s=null===(i=rn.pageType)||void 0===i?void 0:i.trim().toLowerCase(),g=bn.find(function(e){var n="page"===e.kind?e.pageNumber:e.segment.start_page,t="page"!==e.kind||!s||e.metadata.page_type===s;return(!rn.segmentId||e.segment.segment_id===rn.segmentId)&&n===d&&e.kind===rn.type&&t});g?Xt(g):"page"===rn.type&&(Yt(),tt.current+=1,Wn({pageNumber:d,requestId:tt.current}))}}}},[rn,Xt,bn]);var Yt=r.useCallback(function(){it.current=null,Nn(!1),kn(null),Tn(null),null==We||We(null,null)},[We]),Jt=r.useCallback(function(e){var n;nt(!1),Qn(null);var t=null!==(n=bn.find(function(n){return!mt.has(n.id)&&"boundary"===n.kind&&n.segment.start_page===e.startPage&&n.segment.end_page===e.endPage}))&&void 0!==n?n:bn.find(function(n){return!mt.has(n.id)&&n.segment.start_page<=e.startPage&&n.segment.end_page>=e.startPage});t?Xt(t):(Yt(),tt.current+=1,Wn({pageNumber:e.startPage,requestId:tt.current}))},[Yt,mt,bn,Xt]),Qt=r.useCallback(function(e,n){var t,i=h.getReviewScoreBand(e.review_step.score),r=null==xe||i===xe,o=Gn.has(e.id)&&h.isReviewStepResolutionCurrent(e.review_step,e.segment);return e.id!==n&&r&&!0!==(null===(t=e.segment.confidence)||void 0===t?void 0:t.awaiting_llm)&&!h.isReviewStepResolved(e.review_step,e.segment)&&!o},[xe,Gn]),$t=r.useCallback(function(e){var n;if(Se){var t=bn.findIndex(function(n){return n.id===e}),i=null!==(n=bn.find(function(n,i){return i>t&&Qt(n,e)}))&&void 0!==n?n:bn.find(function(n){return Qt(n,e)});i?requestAnimationFrame(function(){return Xt(i)}):Yt()}else Yt()},[Se,Yt,Qt,bn,Xt]),ei=r.useCallback(function(e,n,i){return t.__awaiter(ie,void 0,void 0,function(){var r,o,a,u,d,s,g,v,m,p;return t.__generator(this,function(t){switch(t.label){case 0:if(De)return[2];if("boundary"===e.kind&&!Le)return[2];if("label"===e.kind&&!Fe)return[2];if("page"===e.kind&&!Te)return[2];r=x(e),a=i,u=(o=n)===l.BoundaryReviewActionEnum.SET_RANGE?function(){var n=a.startPage,t=a.endPage;if(null==n||null==t)return null;var i=n<e.segment.start_page||t>e.segment.end_page,r=n>e.segment.start_page||t<e.segment.end_page;return i&&!r?n<e.segment.start_page?l.BoundaryReviewActionEnum.MERGE_PREV:l.BoundaryReviewActionEnum.MERGE_NEXT:r?l.BoundaryReviewActionEnum.SPLIT_HERE:null}():o,d="boundary"===e.kind&&null!=Le&&Se&&(u===l.BoundaryReviewActionEnum.SPLIT_HERE||u===l.BoundaryReviewActionEnum.MERGE_NEXT||u===l.BoundaryReviewActionEnum.MERGE_PREV||u===l.BoundaryReviewActionEnum.MERGE_PREVIOUS),s=d?ae.findIndex(function(n){return c.getSegmentReviewKey(n)===c.getSegmentReviewKey(e.segment)}):-1,d&&s>=0&&u&&(rt.current={action:u,originalSegmentIndex:s,segmentSignature:JSON.stringify(ae.map(function(e,n){var t;return{key:c.getSegmentReviewKey(e,n),startPage:e.start_page,endPage:e.end_page,version:null!==(t=e.version)&&void 0!==t?t:null}})),ready:!1}),Hn(e.id),t.label=1;case 1:return t.trys.push([1,8,9,10]),"boundary"!==e.kind?[3,3]:[4,null==Le?void 0:Le(n,i,r)];case 2:return t.sent(),[3,7];case 3:return"label"!==e.kind?[3,5]:[4,null==Fe?void 0:Fe(n,i,r)];case 4:return t.sent(),[3,7];case 5:return"page"!==e.kind?[3,7]:[4,null==Te?void 0:Te(n,i,r)];case 6:t.sent(),t.label=7;case 7:return On(function(n){var t=new Set(n);return t.add(e.id),t}),g="boundary"===e.kind&&(u===l.BoundaryReviewActionEnum.MERGE_NEXT||u===l.BoundaryReviewActionEnum.MERGE_PREV||u===l.BoundaryReviewActionEnum.MERGE_PREVIOUS),("boundary"===e.kind&&u===l.BoundaryReviewActionEnum.SPLIT_HERE||g)&&u&&(v=c.getSegmentReviewKey(e.segment),pn(function(e){var n=new Set(e);return o===l.BoundaryReviewActionEnum.SET_RANGE?n.add(v):n.delete(v),n}),cn(function(e){var n=new Map(e);return n.set(v,u),n})),rt.current?(rt.current.ready=!0,g&&(m=bn.find(function(n){return"label"===n.kind&&c.getSegmentReviewKey(n.segment)===c.getSegmentReviewKey(e.segment)}))&&requestAnimationFrame(function(){return Xt(m)})):$t(e.id),[3,10];case 8:return p=t.sent(),d&&(rt.current=null),null==Ge||Ge(p,r),[3,10];case 9:return Hn(null),[7];case 10:return[2]}})})},[Se,De,Ge,Le,Fe,Te,qe,bn,ae,Xt,$t]);r.useEffect(function(){var e=rt.current;if(null==e?void 0:e.ready){var n=JSON.stringify(ae.map(function(e,n){var t;return{key:c.getSegmentReviewKey(e,n),startPage:e.start_page,endPage:e.end_page,version:null!==(t=e.version)&&void 0!==t?t:null}}));if(n!==e.segmentSignature){var t=e.action===l.BoundaryReviewActionEnum.SPLIT_HERE?e.originalSegmentIndex+1:e.action===l.BoundaryReviewActionEnum.MERGE_PREV||e.action===l.BoundaryReviewActionEnum.MERGE_PREVIOUS?Math.max(0,e.originalSegmentIndex-1):e.originalSegmentIndex,i=new Map(ae.map(function(e,n){return[c.getSegmentReviewKey(e,n),n]})),r=bn.find(function(e){var n=i.get(c.getSegmentReviewKey(e.segment));return null!=n&&n>=t&&Qt(e)});if(!r)return rt.current=null,void Yt();requestAnimationFrame(function(){rt.current=null,Xt(r)})}}},[Yt,Qt,bn,ae,Xt]),r.useEffect(function(){rt.current||Pn&&!bn.some(function(e){return e.id===Pn})&&Yt()},[Pn,Yt,bn]),r.useEffect(function(){if(ye&&!rt.current){var e=bn.find(function(e){return e.pageNumber===Rn});e&&e.id!==Pn&&Xt(e)}},[Pn,ye,Rn,Xt,bn]),r.useEffect(function(){rt.current||Pn&&!bn.some(function(e){var n;return e.id===Pn&&!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)})&&Yt()},[Pn,Yt,bn]);var ni=r.useMemo(function(){var e=bn.filter(function(e){var n;return!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)});if("all"===fe)return e;var n=["low","medium","high"].filter(function(e){return e!==me}),i=t.__spreadArray([me],n,!0),r=new Map(i.map(function(e,n){return[e,n]}));return e.map(function(e,n){return{item:e,index:n}}).sort(function(e,n){var t,o,a,l,u=null===(t=e.item.review_step.confidence)||void 0===t?void 0:t.trim().toLowerCase(),d=null===(o=n.item.review_step.confidence)||void 0===o?void 0:o.trim().toLowerCase();return(null==u?i.length:null!==(a=r.get(u))&&void 0!==a?a:i.length)-(null==d?i.length:null!==(l=r.get(d))&&void 0!==l?l:i.length)||e.index-n.index}).map(function(e){return e.item})},[fe,me,bn]),ti=ni.findIndex(function(e){return e.id===Mn}),ii=r.useState(null),ri=ii[0],oi=ii[1],ai=r.useRef(!1),li=r.useCallback(function(e){var n=ni[e];n&&Xt(n)},[ni,Xt]);r.useCallback(function(e){if(!(!Zn||e<0||e>=Zn.pages.length)){var n=Zn.pages[e];null!=n&&(Yt(),Xn(function(n){return null==n?n:t.__assign(t.__assign({},n),{index:e})}),tt.current+=1,Wn({pageNumber:n,requestId:tt.current}))}},[Zn,Yt]),r.useEffect(function(){Mn&&!ni.some(function(e){return e.id===Mn})&&In(null)},[ni,Mn]),r.useEffect(function(){ai.current=!1,oi(ti>=0?String(ti+1):null)},[ti,ni.length]),r.useEffect(function(){if(ai.current&&null!=ri){var e=window.setTimeout(function(){var e=Number(ri.trim()),n=e-1;Number.isInteger(e)&&n>=0&&n<ni.length&&(ai.current=!1,li(n))},300);return function(){return window.clearTimeout(e)}}},[li,ri,ni.length]);var ui=r.useMemo(function(){var e=new Map;bn.forEach(function(n){var t,i=null!==(t=e.get(c.getSegmentReviewKey(n.segment)))&&void 0!==t?t:[];i.push(n),e.set(c.getSegmentReviewKey(n.segment),i)});var n=new Map;return e.forEach(function(e,t){var i,r=null!==(i=fn.get(t))&&void 0!==i?i:1;e.sort(function(e,n){return e.reviewStepIndex-n.reviewStepIndex}).forEach(function(e,t){n.set(e.id,"".concat(r).concat(function(e){for(var n=e+1,t="";n>0;)n-=1,t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26);return t}(t)))})}),n},[bn,fn]),di=r.useMemo(function(){var e=new Map;bn.forEach(function(n){var t,i=null!==(t=e.get(n.pageNumber))&&void 0!==t?t:[];i.push(n),e.set(n.pageNumber,i)});var n=new Map;return e.forEach(function(e){e.forEach(function(e,t){return n.set(e.id,t)})}),n},[bn]),si=r.useCallback(function(e){return{startPage:Math.max(0,e.startPage-Ee),endPage:Math.min(e.numPages-1,e.endPage+Ee)}},[Ee]),gi=r.useCallback(function(){var e,n=lt.current,t=ut.current;if(n&&t){var i=n.getBoundingClientRect(),r=t.querySelector(".rpv-core__inner-pages"),o=null!==(e=null==r?void 0:r.getBoundingClientRect())&&void 0!==e?e:t.getBoundingClientRect();bn.forEach(function(e){var n,r=ot.current.get(e.id);if(r){var a=t.querySelector('[data-testid="core__page-layer-'.concat(e.pageNumber-1,'"]'));if(a){var l=a.getBoundingClientRect(),u=null!==(n=di.get(e.id))&&void 0!==n?n:0,d=l.top+Pe+40*u,s=d+(r.offsetHeight||32),g=d>=o.top&&s<=o.bottom;r.style.top="".concat(d-i.top,"px"),r.style.visibility=g?"visible":"hidden"}else r.style.visibility="hidden"}});var a=at.current;if(a){var l=null==Zn?void 0:Zn.pages[Zn.index],u=null==l?null:t.querySelector('[data-testid="core__page-layer-'.concat(l-1,'"]'));if(Zn&&u){var d=u.getBoundingClientRect().top+Pe,s=d+(a.offsetHeight||25),g=d>=o.top&&s<=o.bottom;a.style.top="".concat(d-i.top,"px"),a.style.visibility=g?"visible":"hidden"}else a.style.visibility="hidden"}if(Pn&&null==it.current){var c=ot.current.get(Pn);c&&"hidden"!==c.style.visibility&&Tn(function(e){return e===c?e:c})}}},[Zn,Pn,Pe,di,bn]),ci=r.useCallback(function(e){var n=it.current;n&&n.requestId===e.requestId&&n.pageNumber===e.pageNumber&&(it.current=null,gi(),requestAnimationFrame(function(){if(null==it.current){var e=ot.current.get(n.reviewId);e&&"hidden"!==e.style.visibility&&Tn(e)}}))},[gi]);return r.useEffect(function(){var e=ut.current;if(e&&ce){var n=null,t=function(){null==n&&(n=requestAnimationFrame(function(){n=null,gi()}))};e.addEventListener("scroll",t,!0),window.addEventListener("resize",t);var i=new MutationObserver(t);i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]});var r="undefined"==typeof ResizeObserver?null:new ResizeObserver(t);return null==r||r.observe(e),t(),function(){null!=n&&cancelAnimationFrame(n),e.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t),i.disconnect(),null==r||r.disconnect()}}},[ce,gi]),i.jsxs("div",t.__assign({ref:lt,className:$e,style:t.__assign(t.__assign({},en),{display:"block",position:"relative",width:"100%",height:"100%",minWidth:0,overflowX:"auto",overflowY:"hidden"})},{children:[i.jsxs("div",t.__assign({className:"segment-review-wrapper__container",style:{display:"flex",alignItems:"stretch",gap:0,width:"100%",minWidth:700,height:"100%"}},{children:[i.jsx("div",t.__assign({ref:ut,style:t.__assign(t.__assign({},nn),{flex:"1 1 auto",width:ce?"auto":"100%",minWidth:0,height:"100%",boxSizing:"border-box"})},{children:i.jsx(a.default,t.__assign({highlightText:[],highlightPages:{},highlightCordinatePages:[],useCoordinates:!1,showRotateButton:!0},de,{defaultScale:void 0===se?null!==(Q=null==de?void 0:de.defaultScale)&&void 0!==Q?Q:o.SpecialZoomLevel.PageFit:S[se],disablePdfAnnotations:He,disablePdfTextLayer:Ze,pdfUrl:re,pdfName:oe,segments:Sn,navigationRequest:Kn,onNavigationSettled:ci,setRenderRange:si,onCurrentPageChange:function(e){En(e),null==it.current&&pt&&pt.pageNumber!==e&&Yt(),null==ze||ze(e)}}))})),ce&&i.jsxs("aside",t.__assign({"aria-label":"Page review badges",ref:yn,style:t.__assign(t.__assign({},tn),{position:"relative",width:vt,maxWidth:b,flex:"0 1 ".concat(vt),minHeight:0,overflow:"hidden",boxSizing:"border-box"})},{children:[Zn&&i.jsx("span",t.__assign({ref:at,style:{position:"absolute",top:0,left:10,visibility:"hidden",zIndex:2,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,minHeight:25,padding:"2px 8px",border:"1px solid #E2E8F0",borderRadius:16,backgroundColor:"#F8FAFC",boxSizing:"border-box",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.08)",font:"inherit"}},{children:i.jsxs(m.Typography,t.__assign({fontFamily:"Inter",sx:{fontSize:11,fontWeight:500,color:"#475569",whiteSpace:"nowrap"}},{children:[Zn.label||"Pages"," Pg: ",Zn.index+1]}))})),_e&&ni.length>0&&!Zn&&i.jsxs("nav",t.__assign({"aria-label":"Review badge navigation",style:{position:"absolute",top:8,right:Ae||"auto",left:Ie||"auto",zIndex:2,display:"flex",alignItems:"center",gap:7,width:128,minHeight:40,padding:"4px 6px",border:"1px solid #CBD5E1",borderRadius:6,backgroundColor:"#FFFFFF",boxSizing:"border-box",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.06)",font:"inherit"}},{children:[i.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:null!=ri?ri:"-","aria-label":"Review badge number",onChange:function(e){ai.current=!0,oi(e.target.value)},style:{width:30,height:28,padding:0,border:"1px solid #A5B4FC",borderRadius:3,color:"#4F46E5",backgroundColor:"#FFFFFF",textAlign:"center",font:"inherit",fontSize:15,outline:"none"}}),i.jsxs("span",t.__assign({"aria-label":"".concat(ni.length," reviews"),style:{flex:1,color:"#4F46E5",fontSize:14,whiteSpace:"nowrap",textAlign:"center"}},{children:["of ",ni.length]})),["previous","next"].map(function(e){var n="previous"===e,r=ti+(n?-1:1),o=r<0||r>=ni.length;return i.jsx("button",t.__assign({type:"button","aria-label":"".concat(n?"Previous":"Next"," review badge"),disabled:o,onClick:function(){return li(r)},style:{display:"grid",placeItems:"center",width:17,height:28,padding:0,border:0,background:"transparent",color:o?"#C7D2FE":"#4F46E5",cursor:o?"default":"pointer"}},{children:i.jsx("svg",t.__assign({width:"12",height:"8",viewBox:"0 0 12 8",fill:"none"},{children:i.jsx("path",{d:n?"M1 7L6 2L11 7":"M1 1L6 6L11 1",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}))}),e)})]})),!Zn&&bn.map(function(e){var n,r,o=Pn===e.id,a=null!==(n=ui.get(e.id))&&void 0!==n?n:"1A",l=e.review_step.score,u=e.review_step.confidence,d=h.formatScore(l,u),s="boundary"===e.kind?h.getBoundaryReviewActionBadgeLabel(e.review_step,e.segment,gn.get(c.getSegmentReviewKey(e.segment))):"label"===e.kind?h.getTitleReviewActionBadgeLabel(e.review_step,e.segment,gn.get(c.getSegmentReviewKey(e.segment))):null,g=null!=s?s:"N/A"===d?d:"".concat(d,"%"),p=!0===(null===(r=e.segment.confidence)||void 0===r?void 0:r.awaiting_llm),f=h.getConfidenceColors(l,u,p),w=mt.has(e.id),_=p;return i.jsx(m.Tooltip,t.__assign({title:p?"data is being processed":"",arrow:!0},{children:i.jsx("span",t.__assign({ref:function(n){n?ot.current.set(e.id,n):ot.current.delete(e.id)},style:{position:"absolute",top:0,left:10,visibility:"hidden",display:"inline-flex",cursor:_?"not-allowed":"pointer"}},{children:i.jsx("button",t.__assign({disabled:_,type:"button","aria-pressed":o,"aria-label":p?"".concat(e.review_step.type," · Page ").concat(e.pageNumber," · Data is being processed"):"".concat(e.review_step.type," · Page ").concat(e.pageNumber),onClick:function(){return Xt(e)},style:{cursor:"inherit",display:"flex",alignItems:"center",justifyContent:"space-around",gap:4,width:s?w&&!p?115:90:w&&!p?105:80,minHeight:25,padding:"2px 5px",border:"1px solid ".concat(w&&!p?"#E2E8F0":f.border),borderRadius:16,backgroundColor:w&&!p?"#F8FAFC":f.background,color:w&&!p?"#475569":f.text,font:"inherit",alignContent:"center",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.08)"}},{children:w&&!p?i.jsxs(m.Typography,t.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),i.jsxs("span",t.__assign({style:{display:"flex",alignItems:"center"}},{children:[i.jsx("svg",t.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:g}))]})),i.jsxs("span",t.__assign({style:{fontSize:11,fontWeight:500,display:"flex",alignItems:"center"}},{children:[i.jsx("svg",t.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),i.jsx("span",t.__assign({style:{display:"flex",marginLeft:"7px",alignItems:"center"}},{children:i.jsx(v.CircleCheck,{height:14,width:14,strokeWidth:2,color:"#16A34A"})}))]}))]})):i.jsxs(m.Typography,t.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),i.jsxs("span",t.__assign({style:{display:"flex",alignItems:"center"}},{children:[i.jsx("svg",t.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M0.399902 0V14",stroke:f.divider,strokeWidth:"0.8"})})),i.jsx("span",t.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:g}))]}))]}))}))}))}),e.id)})]}))]})),pt&&Fn&&i.jsxs(u.default,t.__assign({anchorElement:Fn,placement:"bottom-start",offset:{top:8},width:Math.min(st,b),maxWidth:b,heightBuffer:null!=Ne?Ne:25},{children:[Bn&&i.jsx(d.default,{width:"100%",maxWidth:"100%",score:pt.review_step.score,reasons:xt,reason:pt.review_step.reason,gap:pt.review_step.gap,onBack:function(){return Nn(!1)},onClose:Yt}),i.jsx("div",t.__assign({style:{display:Bn?"none":"block"}},{children:mt.has(pt.id)?i.jsx(p.default,{width:"100%",maxWidth:"100%",headerName:"page"===pt.kind?"Page format approved":"Split"===Et?"Split approved":"Merged"===Et?"Merge approved":"User approved",headerIcon:"page"===pt.kind?i.jsx(v.Check,{size:18,strokeWidth:2}):"Merged"===Et?i.jsx(v.GitMerge,{size:18,strokeWidth:2}):"Split"===Et?i.jsx(y.default,{width:18,height:18}):i.jsx(v.CircleCheck,{size:18,strokeWidth:2}),title:It,pageNo:"Page ".concat(pt.segment.start_page,"-").concat(pt.segment.end_page),summary:Vt?i.jsx(w.default,{icon:i.jsx(v.CircleCheck,{size:14,strokeWidth:2}),title:It,pageRange:"Page ".concat(pt.segment.start_page,"-").concat(pt.segment.end_page),description:null!=Dt?Dt:null,revertData:Vt,confirmDisabled:"page"===pt.kind?!Ut:null==Ke||!Ut,showDocumentHeader:!1,onRevert:function(){if("page"===pt.kind){if(!qe||!Ht){var e=new Error("SegmentReviewPdfWrapper requires onPageTypeRevert and a classification id to revert a page-type decision.");return null==Ge||Ge(e,x(pt)),Promise.reject(e)}return qe({classification_id:Ht,human_verdict:"No"},x(pt))}if(!Ke)throw new Error("SegmentReviewPdfWrapper requires onRevert to handle a revert confirmation.");if(!zt)throw new Error("There is no valid revert operation for this review.");var n=Wt?"boundary":"label"===pt.kind?"label":"boundary"===pt.kind?"boundary":null,t=Nt(zt.type);if(n&&t!==n)throw new Error("Cannot use ".concat(null!=t?t:"unknown"," revert metadata for this review. Expected ").concat(n,"."));return Ke(zt,x(pt))},onRevertError:function(e){null==Ge||Ge(e,x(pt))},onRevertComplete:function(e){var n,t,i,r,o,a;On(function(){return new Set}),"page"!==pt.kind&&(pn(function(){return new Set}),cn(function(){return new Map})),pt.id;var l=null!==(n=Vt.previousSegments[0])&&void 0!==n?n:Vt.currentSegment,u=null==Fn?void 0:Fn.getBoundingClientRect(),d=null===(t=ut.current)||void 0===t?void 0:t.getBoundingClientRect(),s=Math.min(b,Math.max(220,st)),g=null!==(i=null==u?void 0:u.left)&&void 0!==i?i:(null!==(r=null==d?void 0:d.right)&&void 0!==r?r:window.innerWidth-s-8)+8,c=Math.max(8,Math.min(g,window.innerWidth-s-8)),v=null==(null==u?void 0:u.bottom)?Math.max(8,null!==(o=null==d?void 0:d.top)&&void 0!==o?o:8):u.bottom+8;On(function(){return new Set}),"page"!==pt.kind&&(rt.current=null),nt(!1),Qn({title:"Split"===Et?"Split reverted":"Merged"===Et?"Merge reverted":"Approval reverted",description:(null===(a=null==e?void 0:e.message)||void 0===a?void 0:a.trim())||("Split"===Et?"Pages ".concat(pt.segment.start_page,"-").concat(pt.segment.end_page," are now part of “Advice of Award” again. Review the boundary and title to confirm the document."):"Merged"===Et?"The documents have been separated again. Review their boundaries and titles to confirm them.":"“".concat(It,"” is pending review again. Review the boundary and title to confirm the document.")),segment:l,position:{top:v,left:c,width:s}}),Yt()}},pt.id):void 0,additionalActions:Mt?i.jsx(f.default,{metadata:Mt.metadata,reviewAction:null!==($=pt.segment.review_action)&&void 0!==$?$:void 0,startPage:pt.segment.start_page,endPage:pt.segment.end_page,title:It,previousSegmentTitle:yt,nextSegmentTitle:bt,disabled:De||!Le||Vn===pt.id,onConfirm:function(e,n){ei(Mt,e,n)}}):void 0,cognitiveScore:pt.review_step.score,styles:{root:{borderColor:"#16A34A"},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:"#16A34A"}}},onCognitiveClick:Rt?function(){Nn(!0),null==Qe||Qe(x(pt))}:void 0,onClose:Yt}):"boundary"===pt.kind?i.jsx(l.default,{width:"100%",maxWidth:"100%",totalPages:le,title:pt.segment.label||pt.segment.title,pageNo:"Page ".concat(pt.pageNumber),content:null!==(ee=pt.review_step.question)&&void 0!==ee?ee:null,revertSummary:Ot,cognitiveScore:pt.review_step.score,metadata:pt.metadata,reviewAction:null!==(ne=pt.segment.review_action)&&void 0!==ne?ne:void 0,previousSegmentTitle:yt,nextSegmentTitle:bt,manualPrompt:null!=Be?Be:"Set a custom boundary",defaultStartPage:pt.segment.start_page,defaultEndPage:pt.segment.end_page,styles:{root:{borderColor:St.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:St.text}}},confirmDisabled:De||!Le||Vn===pt.id,onConfirm:function(e,n,t){t&&l.isBoundaryReviewAction(n.id)&&ei(pt,n.id,t)},onAdjustManually:function(){return null==Je?void 0:Je(x(pt))},onCognitiveClick:Rt?function(){Nn(!0),null==Qe||Qe(x(pt))}:void 0,onClose:Yt},pt.id):"label"===pt.kind?i.jsx(s.default,{width:"100%",maxWidth:"100%",title:pt.metadata.current_label||pt.segment.label||pt.segment.title,pageNo:"Pages ".concat(pt.segment.start_page,"-").concat(pt.segment.end_page),content:null!==(te=pt.review_step.question)&&void 0!==te?te:null,revertSummary:Ot,cognitiveScore:pt.review_step.score,metadata:pt.metadata,styles:{root:{borderColor:St.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:St.text}}},confirmDisabled:De||!Fe||Vn===pt.id,confirmationBlocked:ft,confirmationWarning:ft?"Please confirm the boundary before confirming the title.":void 0,onActionConfirm:function(e,n){ei(pt,e,n)},onAdjustManually:function(){return null==Je?void 0:Je(x(pt))},onCognitiveClick:Rt?function(){Nn(!0),null==Qe||Qe(x(pt))}:void 0,onClose:Yt},pt.id):i.jsx(g.default,{width:"100%",maxWidth:"100%",title:pt.segment.label||pt.segment.title,pageNo:"Page ".concat(pt.pageNumber),content:pt.review_step.reason,cognitiveScore:pt.review_step.score,pageType:pt.metadata.page_type,metadata:pt.metadata,styles:{root:{borderColor:St.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:St.text}}},confirmDisabled:De||!Te||Vn===pt.id,onActionConfirm:function(e,n){ei(pt,e,n)},onCognitiveClick:Rt?function(){Nn(!0),null==Qe||Qe(x(pt))}:void 0,onClose:Yt},pt.id)}))]})),Jn&&i.jsx(m.Portal,{children:i.jsx(m.Box,t.__assign({"aria-live":"polite",sx:{position:"fixed",top:Jn.position.top,left:Jn.position.left,zIndex:1600,width:Jn.position.width,maxWidth:"calc(100vw - 16px)",opacity:et?1:0,transform:et?"translateY(0)":"translateY(-6px)",transition:"opacity 500ms ease, transform 500ms ease",filter:"drop-shadow(0 12px 24px rgba(15, 23, 42, 0.18))",pointerEvents:et?"auto":"none"}},{children:i.jsx(_.default,{title:Jn.title,description:Jn.description,onReview:function(){return Jt(Jn.segment)}})}))})]}))};
2
2
  //# sourceMappingURL=SegmentReviewPdfWrapper.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("./reviewStepAdapters.js"),n=function(e){if(null==e)return null;if("number"==typeof e)return Number.isFinite(e)?e:null;var r=e.trim();if(!r)return null;var n=Number.parseFloat(r);return Number.isFinite(n)?n:null},t=function(e){switch(null==e?void 0:e.trim().toLowerCase()){case"low":return 40;case"medium":return 70;case"high":return 95;default:return null}},i=function(e,r){var i;return null!==(i=n(e))&&void 0!==i?i:t(r)},u=function(e){var r=n(e);return null==r?null:r<=40?"low":r<=70?"medium":"high"},l=function(e){switch(null==e?void 0:e.trim().toUpperCase()){case"SPLIT":case"SPLIT_HERE":return"Split";case"MERGE":case"MERGE_NEXT":case"MERGE_PREV":case"MERGE_PREVIOUS":return"Merged";default:return null}},o=function(e){var r,n,t,i;if(![e.human_action_enum,null===(r=e.human_resolution)||void 0===r?void 0:r.action,null===(n=e.review)||void 0===n?void 0:n.action].some(function(e){return"SET_RANGE"===(null==e?void 0:e.trim().toUpperCase())}))return null;var u=null===(t=e.human_resolution)||void 0===t?void 0:t.before,l=null===(i=e.human_resolution)||void 0===i?void 0:i.after;if(null==(null==u?void 0:u.start_page)||null==u.end_page||null==(null==l?void 0:l.start_page)||null==l.end_page)return null;var o=l.start_page<u.start_page||l.end_page>u.end_page,a=l.start_page>u.start_page||l.end_page<u.end_page;if(o&&!a)return"Merged";if(a&&!o)return"Split";var d=u.end_page-u.start_page+1,v=l.end_page-l.start_page+1;return v>d?"Merged":v<d?"Split":null},a=function(e){switch(null==e?void 0:e.trim().toUpperCase()){case"SPLIT":case"SPLIT_HERE":return"SPLIT_HERE";case"MERGE_NEXT":return"MERGE_NEXT";case"MERGE_PREV":case"MERGE_PREVIOUS":return"MERGE_PREV";case"SET_RANGE":return"SET_RANGE";default:return null}},d=function(e){var r,n=null===(r=e.type)||void 0===r?void 0:r.trim().toLowerCase();return"page_boundary"===n||"page boundary review"===n},v=function(r){var n,t,i,u=(null!==(n=r.review_steps)&&void 0!==n?n:[]).filter(d);return null!==(i=null!==(t=e.__spreadArray([],u,!0).reverse().find(function(e){return null!=l(e.human_action_enum)}))&&void 0!==t?t:e.__spreadArray([],u,!0).reverse().find(c))&&void 0!==i?i:u[u.length-1]},s=function(e){var r,n,t,i,u;return null!==(i=null!==(n=null!==(r=o(e))&&void 0!==r?r:l(e.human_action_enum))&&void 0!==n?n:l(null===(t=e.human_resolution)||void 0===t?void 0:t.action))&&void 0!==i?i:l(null===(u=e.review)||void 0===u?void 0:u.action)},_=function(e,r){var n,t=e.type.trim().toLowerCase();if(!("label"===t||"label review"===t))return!0;var i=null===(n=e.human_resolution)||void 0===n?void 0:n.segment_version,u=r.version;return null==i||null==u||i===u},c=function(e){var r,n,t,i;return null!=l(e.human_action_enum)||null!=l(null===(r=e.human_resolution)||void 0===r?void 0:r.action)||null!=l(null===(n=e.review)||void 0===n?void 0:n.action)||!0===(null===(i=null===(t=e.metadata)||void 0===t?void 0:t.performed_actions)||void 0===i?void 0:i.some(function(e){return null!=l(e.action)}))},p=function(r){var n,t,i,u,d,s,_=v(r);if(!_)return null;var c=a(null===(n=_.human_resolution)||void 0===n?void 0:n.action),p=null===(t=_.human_resolution)||void 0===t?void 0:t.after,g=(null==p?void 0:p.start_page)===r.start_page&&(null==p?void 0:p.end_page)===r.end_page,f=o(_);if(f)return g?f:null;if("SPLIT_HERE"===c)return g?null:"Split";if("MERGE_NEXT"===c||"MERGE_PREV"===c)return g?"Merged":null;var m=function(e,r){var n,t,i,u=e.revert,l=r.revert,o="boundary"===(null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.trim().toLowerCase())?u:"boundary"===(null===(t=null==l?void 0:l.type)||void 0===t?void 0:t.trim().toLowerCase())?l:null;if(!o)return null;var a=null===(i=o.decision)||void 0===i?void 0:i.trim().toUpperCase();if(null==a?void 0:a.includes("SPLIT"))return"Split";if(null==a?void 0:a.includes("MERGE"))return"Merged";if("SET_RANGE"===a){if(o.current_segment_ids.length>o.previous_state.length)return"Split";if(o.current_segment_ids.length<o.previous_state.length)return"Merged"}return null}(_,r);if(m)return m;var E=l(_.human_action_enum);if(E)return E;var R=l(null===(i=_.review)||void 0===i?void 0:i.action);if(R)return R;var h=e.__spreadArray([],null!==(u=r.human_action_log)&&void 0!==u?u:[],!0).filter(function(e){return null!=l(e.action)}).sort(function(e,r){var n,t;return r.human_revision-e.human_revision||(null===(n=r.performed_at)||void 0===n?void 0:n.localeCompare(null!==(t=e.performed_at)&&void 0!==t?t:""))})[0];if(!h)return null;var S=l(h.action),w=(null===(d=h.after)||void 0===d?void 0:d.start_page)===r.start_page&&(null===(s=h.after)||void 0===s?void 0:s.end_page)===r.end_page;return"Split"===S?w?null:S:w?S:null},g=function(e,r){return null!=l(r)||null!=p(e)},f=function(e,r){var n,t,i,u,o,d,s=a(r),_=v(e),c=null!==(i=null!==(n=a(null==_?void 0:_.human_action_enum))&&void 0!==n?n:a(null===(t=null==_?void 0:_.human_resolution)||void 0===t?void 0:t.action))&&void 0!==i?i:a(null===(u=null==_?void 0:_.review)||void 0===u?void 0:u.action),g=l(r),f=null===(o=null==_?void 0:_.human_resolution)||void 0===o?void 0:o.after,m="SPLIT_HERE"===s&&null!=(null===(d=null==_?void 0:_.human_resolution)||void 0===d?void 0:d.action)&&(null==f?void 0:f.start_page)===e.start_page&&(null==f?void 0:f.end_page)===e.end_page;return null!=s&&c===s&&null!=g&&(m||p(e)===g)};exports.formatScore=function(e,r){var n=i(e,r);return null==n?"N/A":Number.isInteger(n)?String(n):n.toFixed(2).replace(/\.?0+$/,"")},exports.getBoundaryReviewActionBadgeLabel=function(e,r,n){var t,i;return null!==(i=null!==(t=l(n))&&void 0!==t?t:s(e))&&void 0!==i?i:p(r)},exports.getConfidenceColors=function(e,r,n){var t={border:"#E5E7EB",cardBorder:"#374151",background:"#F9FAFB",text:"#374151",divider:"#D1D5DB"};if(n)return t;switch(u(e)){case"low":return{border:"#FECACA",cardBorder:"#B91C1C",background:"#FEF2F2",text:"#B91C1C",divider:"#FCA5A5"};case"medium":return{border:"#d9cda2",cardBorder:"#997800",background:"#fff1bf",text:"#997800",divider:"#e6b400"};case"high":return{border:"#16A34A",cardBorder:"#4F9E6C",background:"#F0FDF4",text:"#4F9E6C",divider:"#00A43C"}}return t},exports.getFallbackScore=t,exports.getHumanActionBadgeLabel=l,exports.getNumericScore=n,exports.getOptimisticMergeImpactedSegmentKeys=function(n,t){var i=e.__spreadArray([],n,!0).sort(function(e,r){return e.start_page-r.start_page||e.end_page-r.end_page}),u=new Set;return t.forEach(function(e,n){var l=i.findIndex(function(e){return r.getSegmentReviewKey(e)===n});if(!(l<0)){var o=i[l];if(!f(o,e)){var d=a(e),v=i["MERGE_PREV"===d?l-1:"MERGE_NEXT"===d?l+1:-1];if(v){var s=r.getSegmentReviewKey(v);g(v,t.get(s))||u.add(s)}}}}),u},exports.getPendingMergeImpactedSegmentKeys=function(n){var t=e.__spreadArray([],n,!0).sort(function(e,r){return e.start_page-r.start_page||e.end_page-r.end_page}),i=new Set;return t.forEach(function(e,n){var u,l=(null!==(u=e.review_steps)&&void 0!==u?u:[]).find(function(r){var n,t,i;if(!d(r))return!1;var u=a(r.human_action_enum),l=a(null===(n=r.human_resolution)||void 0===n?void 0:n.action),o=null===(t=r.human_resolution)||void 0===t?void 0:t.before,v=null===(i=r.human_resolution)||void 0===i?void 0:i.after,s=null!=(null==o?void 0:o.start_page)&&null!=o.end_page&&null!=(null==v?void 0:v.start_page)&&null!=v.end_page&&(o.start_page!==v.start_page||o.end_page!==v.end_page),_=(null==v?void 0:v.start_page)===e.start_page&&(null==v?void 0:v.end_page)===e.end_page;return("MERGE_NEXT"===u||"MERGE_PREV"===u)&&!(l===u&&s&&_)});if(l){var o=a(l.human_action_enum),v=t["MERGE_PREV"===o?n-1:n+1];v&&!g(v)&&i.add(r.getSegmentReviewKey(v))}}),i},exports.getResolvedScore=i,exports.getReviewScoreBand=u,exports.getReviewStepActionBadgeLabel=s,exports.getStructuralResultBadgeLabel=p,exports.getTitleReviewActionBadgeLabel=function(e,r,n){var t=l(n);if(t)return t;var i=s(e);return i||p(r)},exports.hasPolledStructuralAction=f,exports.hasStructuralBoundaryAction=c,exports.isReviewStepResolutionCurrent=_,exports.isReviewStepResolved=function(e,r){var n,t,i;if(!_(e,r))return!1;if(null!=(null===(n=e.review)||void 0===n?void 0:n.action))return!0;var u=null===(i=null===(t=e.human_resolution)||void 0===t?void 0:t.state)||void 0===i?void 0:i.trim().toLowerCase();return"resolved_by_human"===u||"approved"===u||"confirmed"===u},exports.shouldHideStructuralBoundaryReview=function(e,r,n,t){var i=l(t);if("Merged"===i)return n;if("Split"===i)return!0;if(function(e,r){var n,t,i;if("affected"!==(null===(n=r.sensitivity)||void 0===n?void 0:n.trim().toLowerCase()))return!1;var u=null!==(t=e.revert)&&void 0!==t?t:r.revert;if(!u)return!1;var l=null===(i=u.decision)||void 0===i?void 0:i.trim().toUpperCase();return u.current_segment_ids.length>u.previous_state.length&&("SET_RANGE"===l||"SPLIT"===l||"SPLIT_HERE"===l)}(e,r))return!0;var u=s(e);if("Split"===u)return!0;var o=p(r);return"Split"===o||"Merged"===u&&("Merged"!==o||n)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("./reviewStepAdapters.js"),n=function(e){if(null==e)return null;if("number"==typeof e)return Number.isFinite(e)?e:null;var r=e.trim();if(!r)return null;var n=Number.parseFloat(r);return Number.isFinite(n)?n:null},t=function(e){switch(null==e?void 0:e.trim().toLowerCase()){case"low":return 40;case"medium":return 70;case"high":return 95;default:return null}},i=function(e,r){var i;return null!==(i=n(e))&&void 0!==i?i:t(r)},u=function(e){var r=n(e);return null==r?null:r<=40?"low":r<=70?"medium":"high"},o=function(e){switch(null==e?void 0:e.trim().toUpperCase()){case"SPLIT":case"SPLIT_HERE":return"Split";case"MERGE":case"MERGE_NEXT":case"MERGE_PREV":case"MERGE_PREVIOUS":return"Merged";default:return null}},l=function(e){var r,n,t,i;if(![e.human_action_enum,null===(r=e.human_resolution)||void 0===r?void 0:r.action,null===(n=e.review)||void 0===n?void 0:n.action].some(function(e){return"SET_RANGE"===(null==e?void 0:e.trim().toUpperCase())}))return null;var u=null===(t=e.human_resolution)||void 0===t?void 0:t.before,o=null===(i=e.human_resolution)||void 0===i?void 0:i.after;if(null==(null==u?void 0:u.start_page)||null==u.end_page||null==(null==o?void 0:o.start_page)||null==o.end_page)return null;var l=o.start_page<u.start_page||o.end_page>u.end_page,a=o.start_page>u.start_page||o.end_page<u.end_page;if(l&&!a)return"Merged";if(a&&!l)return"Split";var d=u.end_page-u.start_page+1,v=o.end_page-o.start_page+1;return v>d?"Merged":v<d?"Split":null},a=function(e){switch(null==e?void 0:e.trim().toUpperCase()){case"SPLIT":case"SPLIT_HERE":return"SPLIT_HERE";case"MERGE_NEXT":return"MERGE_NEXT";case"MERGE_PREV":case"MERGE_PREVIOUS":return"MERGE_PREV";case"SET_RANGE":return"SET_RANGE";default:return null}},d=function(e){var r,n=null===(r=e.type)||void 0===r?void 0:r.trim().toLowerCase();return"page_boundary"===n||"page boundary review"===n},v=function(r){var n,t,i,u=(null!==(n=r.review_steps)&&void 0!==n?n:[]).filter(d);return null!==(i=null!==(t=e.__spreadArray([],u,!0).reverse().find(function(e){return null!=o(e.human_action_enum)}))&&void 0!==t?t:e.__spreadArray([],u,!0).reverse().find(c))&&void 0!==i?i:u[u.length-1]},s=function(e){var r,n,t,i,u;return null!==(i=null!==(n=null!==(r=l(e))&&void 0!==r?r:o(e.human_action_enum))&&void 0!==n?n:o(null===(t=e.human_resolution)||void 0===t?void 0:t.action))&&void 0!==i?i:o(null===(u=e.review)||void 0===u?void 0:u.action)},_=function(e,r){var n,t=e.type.trim().toLowerCase();if(!("label"===t||"label review"===t))return!0;var i=null===(n=e.human_resolution)||void 0===n?void 0:n.segment_version,u=r.version;return null==i||null==u||i===u},c=function(e){var r,n,t,i;return null!=o(e.human_action_enum)||null!=o(null===(r=e.human_resolution)||void 0===r?void 0:r.action)||null!=o(null===(n=e.review)||void 0===n?void 0:n.action)||!0===(null===(i=null===(t=e.metadata)||void 0===t?void 0:t.performed_actions)||void 0===i?void 0:i.some(function(e){return null!=o(e.action)}))},p=function(r){var n,t,i,u,d,s,_=v(r);if(!_)return null;var c=a(null===(n=_.human_resolution)||void 0===n?void 0:n.action),p=null===(t=_.human_resolution)||void 0===t?void 0:t.after,g=(null==p?void 0:p.start_page)===r.start_page&&(null==p?void 0:p.end_page)===r.end_page,f=l(_);if(f)return g?f:null;if("SPLIT_HERE"===c)return g?null:"Split";if("MERGE_NEXT"===c||"MERGE_PREV"===c)return g?"Merged":null;var m=function(e,r){var n,t,i,u=e.revert,o=r.revert,l="boundary"===(null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.trim().toLowerCase())?u:"boundary"===(null===(t=null==o?void 0:o.type)||void 0===t?void 0:t.trim().toLowerCase())?o:null;if(!l)return null;var a=null===(i=l.decision)||void 0===i?void 0:i.trim().toUpperCase();if(null==a?void 0:a.includes("SPLIT"))return"Split";if(null==a?void 0:a.includes("MERGE"))return"Merged";if("SET_RANGE"===a){if(l.current_segment_ids.length>l.previous_state.length)return"Split";if(l.current_segment_ids.length<l.previous_state.length)return"Merged"}return null}(_,r);if(m)return m;var E=o(_.human_action_enum);if(E)return E;var R=o(null===(i=_.review)||void 0===i?void 0:i.action);if(R)return R;var h=e.__spreadArray([],null!==(u=r.human_action_log)&&void 0!==u?u:[],!0).filter(function(e){return null!=o(e.action)}).sort(function(e,r){var n,t;return r.human_revision-e.human_revision||(null===(n=r.performed_at)||void 0===n?void 0:n.localeCompare(null!==(t=e.performed_at)&&void 0!==t?t:""))})[0];if(!h)return null;var S=o(h.action),w=(null===(d=h.after)||void 0===d?void 0:d.start_page)===r.start_page&&(null===(s=h.after)||void 0===s?void 0:s.end_page)===r.end_page;return"Split"===S?w?null:S:w?S:null},g=function(e,r){return null!=o(r)||null!=p(e)},f=function(e,r){var n,t,i,u,l,d,s=a(r),_=v(e),c=null!==(i=null!==(n=a(null==_?void 0:_.human_action_enum))&&void 0!==n?n:a(null===(t=null==_?void 0:_.human_resolution)||void 0===t?void 0:t.action))&&void 0!==i?i:a(null===(u=null==_?void 0:_.review)||void 0===u?void 0:u.action),g=o(r),f=null===(l=null==_?void 0:_.human_resolution)||void 0===l?void 0:l.after,m="SPLIT_HERE"===s&&null!=(null===(d=null==_?void 0:_.human_resolution)||void 0===d?void 0:d.action)&&(null==f?void 0:f.start_page)===e.start_page&&(null==f?void 0:f.end_page)===e.end_page;return null!=s&&c===s&&null!=g&&(m||p(e)===g)};exports.formatScore=function(e,r){var n=i(e,r);return null==n?"N/A":Number.isInteger(n)?String(n):n.toFixed(2).replace(/\.?0+$/,"")},exports.getBoundaryReviewActionBadgeLabel=function(e,r,n){var t,i;return null!==(i=null!==(t=o(n))&&void 0!==t?t:s(e))&&void 0!==i?i:p(r)},exports.getConfidenceColors=function(e,r,n){var t={border:"#E5E7EB",cardBorder:"#374151",background:"#F9FAFB",text:"#374151",divider:"#D1D5DB"};if(n)return t;switch(u(e)){case"low":return{border:"#FECACA",cardBorder:"#B91C1C",background:"#FEF2F2",text:"#B91C1C",divider:"#FCA5A5"};case"medium":return{border:"#d9cda2",cardBorder:"#997800",background:"#fff1bf",text:"#997800",divider:"#e6b400"};case"high":return{border:"#16A34A",cardBorder:"#4F9E6C",background:"#F0FDF4",text:"#4F9E6C",divider:"#00A43C"}}return t},exports.getFallbackScore=t,exports.getHumanActionBadgeLabel=o,exports.getNumericScore=n,exports.getOptimisticMergeImpactedSegmentKeys=function(n,t,i){void 0===i&&(i=new Set);var u=e.__spreadArray([],n,!0).sort(function(e,r){return e.start_page-r.start_page||e.end_page-r.end_page}),o=new Set;return t.forEach(function(e,n){if(!i.has(n)){var l=u.findIndex(function(e){return r.getSegmentReviewKey(e)===n});if(!(l<0)){var d=u[l];if(!f(d,e)){var v=a(e),s=u["MERGE_PREV"===v?l-1:"MERGE_NEXT"===v?l+1:-1];if(s){var _=r.getSegmentReviewKey(s);g(s,t.get(_))||o.add(_)}}}}}),o},exports.getPendingMergeImpactedSegmentKeys=function(n){var t=e.__spreadArray([],n,!0).sort(function(e,r){return e.start_page-r.start_page||e.end_page-r.end_page}),i=new Set;return t.forEach(function(e,n){var u,o=(null!==(u=e.review_steps)&&void 0!==u?u:[]).find(function(r){var n,t,i;if(!d(r))return!1;var u=a(r.human_action_enum),o=a(null===(n=r.human_resolution)||void 0===n?void 0:n.action),l=null===(t=r.human_resolution)||void 0===t?void 0:t.before,v=null===(i=r.human_resolution)||void 0===i?void 0:i.after,s=null!=(null==l?void 0:l.start_page)&&null!=l.end_page&&null!=(null==v?void 0:v.start_page)&&null!=v.end_page&&(l.start_page!==v.start_page||l.end_page!==v.end_page),_=(null==v?void 0:v.start_page)===e.start_page&&(null==v?void 0:v.end_page)===e.end_page;return("MERGE_NEXT"===u||"MERGE_PREV"===u)&&!(o===u&&s&&_)});if(o){var l=a(o.human_action_enum),v=t["MERGE_PREV"===l?n-1:n+1];v&&!g(v)&&i.add(r.getSegmentReviewKey(v))}}),i},exports.getResolvedScore=i,exports.getReviewScoreBand=u,exports.getReviewStepActionBadgeLabel=s,exports.getStructuralResultBadgeLabel=p,exports.getTitleReviewActionBadgeLabel=function(e,r,n){var t=o(n);if(t)return t;var i=s(e);return i||p(r)},exports.hasPolledStructuralAction=f,exports.hasStructuralBoundaryAction=c,exports.isReviewStepResolutionCurrent=_,exports.isReviewStepResolved=function(e,r){var n,t,i;if(!_(e,r))return!1;if(null!=(null===(n=e.review)||void 0===n?void 0:n.action))return!0;var u=null===(i=null===(t=e.human_resolution)||void 0===t?void 0:t.state)||void 0===i?void 0:i.trim().toLowerCase();return"resolved_by_human"===u||"approved"===u||"confirmed"===u},exports.shouldHideStructuralBoundaryReview=function(e,r,n,t){var i=o(t);if("Merged"===i)return n;if("Split"===i)return!0;if(function(e,r){var n,t,i;if("affected"!==(null===(n=r.sensitivity)||void 0===n?void 0:n.trim().toLowerCase()))return!1;var u=null!==(t=e.revert)&&void 0!==t?t:r.revert;if(!u)return!1;var o=null===(i=u.decision)||void 0===i?void 0:i.trim().toUpperCase();return u.current_segment_ids.length>u.previous_state.length&&("SET_RANGE"===o||"SPLIT"===o||"SPLIT_HERE"===o)}(e,r))return!0;var u=s(e);if("Split"===u)return!0;var l=p(r);return"Split"===l||"Merged"===u&&("Merged"!==l||n)};
2
2
  //# sourceMappingURL=helper.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import i from"react";import{pdfStyles as o}from"./PdfStyle.js";import{DefaultPdfIcon as r,DefaultFullScreenIcon as l,DefaultDownloadIcon as d,DefaultCloseIcon as a}from"../../assests/svg/PdfViewerIcons.js";import s from"@mui/material/Tooltip";import{Info as c}from"lucide-react";var p=function(p){p.highlightIndex;var h=p.totalHighlights,u=p.controls,g=p.currentPosition,f=p.pdfName,x=p.onClose,m=p.pdfUrl,v=p.viewerRef,y=p.customStyles,w=p.customClasses,b=p.customIcons,k=p.headerAction,S=p.isZoomEnabled,F=void 0===S||S,I=p.showHighlightsAction,C=void 0===I||I,W=p.showFullScreenAction,D=void 0===W||W,E=p.currentSegment,B=p.segmentTooltipText,j=void 0===B?"Details of current segment":B,L=p.currentPage,z=p.totalPages,A=p.onPageNavigate,P=u.ZoomInButton,T=u.ZoomOutButton,N=u.ZoomPopover,R=u.goToPrevious,H=u.goToNext,O=i.useState(String(L)),M=O[0],Z=O[1];i.useEffect(function(){Z(String(L))},[L]);var _={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},G=function(e){return String(e).padStart(2,"0")};return t("div",e({style:e(e(e({marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},o.header),null==y?void 0:y.header),{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"})},{children:[t("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0}},{children:[n("div",e({style:e(e(e({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==y?void 0:y.pdfIconWrapper),{flexShrink:0})},{children:(null==b?void 0:b.pdfIcon)||n(r,{})})),n(s,e({title:f||"",arrow:!0,placement:"top"},{children:n("div",e({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:n("span",e({style:e({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==y?void 0:y.pdfName),className:null==w?void 0:w.pdfName},{children:f}))}))}))]})),t("div",e({style:{display:"flex",alignItems:"center",gap:C?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"}},{children:[z>0&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"}},{children:[n("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:M,onChange:function(e){var t=e.target.value.replace(/\D/g,"");Z(t)},onBlur:function(){var e=Number(M);if(!Number.isInteger(e)||e<1)Z(String(L));else{var t=z?Math.min(e,z):e;A(t),Z(String(t))}},onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(Z(String(L)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:"/"})),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:String(z)}))]})),F&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n(T,{}),n("div",e({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:n(N,{})})),n(P,{})]})),!!h&&C&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[t("span",e({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[g," of ",h]})),n("button",e({style:{background:"none",border:"none",cursor:g<=1?"not-allowed":"pointer",padding:"2px 4px",color:g<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:R,disabled:g<=1},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),n("button",e({style:{background:"none",border:"none",cursor:g===h?"not-allowed":"pointer",padding:"2px 4px",color:g===h?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:H,disabled:g===h},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),n("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),t("div",e({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==D&&((null==k?void 0:k.icon)&&(null==k?void 0:k.onClick)?n(s,e({title:(null==k?void 0:k.tooltip)||"",arrow:!0,placement:"top"},{children:n("div",e({onClick:k.onClick,style:e({display:"flex",alignItems:"center",cursor:"pointer"},_)},{children:k.icon}))})):n("button",e({onClick:function(){var e=null==v?void 0:v.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:_,title:"Full Screen"},{children:(null==b?void 0:b.fullScreenIcon)||n(l,{})}))),m&&n("a",e({href:m,target:"_blank",rel:"noopener noreferrer",style:_,title:"Open in new tab"},{children:(null==b?void 0:b.downloadIcon)||n(d,{})})),x&&n("button",e({onClick:x,style:_,title:"Close"},{children:(null==b?void 0:b.closeIcon)||n(a,{})}))]}))]}))]})),E&&t("div",e({style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:[n(s,e({title:j,arrow:!0,placement:"top"},{children:n(c,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})})),n("span",e({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:n(s,e({title:E.title,arrow:!0,placement:"top"},{children:t("span",{children:["Viewing ",E.title," • Pages ",G(E.start_page),"-",G(E.end_page)]})}))}))]}))]}))};export{p as default};
1
+ import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import o from"react";import{pdfStyles as i}from"./PdfStyle.js";import{DefaultPdfIcon as r,DefaultFullScreenIcon as l,DefaultDownloadIcon as a,DefaultCloseIcon as d}from"../../assests/svg/PdfViewerIcons.js";import c from"@mui/material/Tooltip";import{Info as s}from"lucide-react";import p from"@mui/icons-material/RotateRight";var u=function(u){u.highlightIndex;var h=u.totalHighlights,g=u.controls,f=u.currentPosition,x=u.pdfName,m=u.onClose,v=u.pdfUrl,y=u.viewerRef,b=u.customStyles,w=u.customClasses,k=u.customIcons,S=u.headerAction,F=u.isZoomEnabled,I=void 0===F||F,C=u.showHighlightsAction,W=void 0===C||C,D=u.showFullScreenAction,E=void 0===D||D,R=u.currentSegment,T=u.segmentTooltipText,B=void 0===T?"Details of current segment":T,j=u.currentPage,L=u.totalPages,P=u.onPageNavigate,z=u.onRotatePage,A=u.currentPageRotation,N=void 0===A?0:A,H=u.showRotateButton,M=void 0===H||H,O=g.ZoomInButton,Z=g.ZoomOutButton,_=g.ZoomPopover,G=g.goToPrevious,V=g.goToNext,q=o.useState(String(j)),K=q[0],U=q[1];o.useEffect(function(){U(String(j))},[j]);var X={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},Y=function(e){return String(e).padStart(2,"0")};return t("div",e({style:e(e(e({marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},i.header),null==b?void 0:b.header),{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"})},{children:[t("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0}},{children:[n("div",e({style:e(e(e({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==b?void 0:b.pdfIconWrapper),{flexShrink:0})},{children:(null==k?void 0:k.pdfIcon)||n(r,{})})),n(c,e({title:x||"",arrow:!0,placement:"top"},{children:n("div",e({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:n("span",e({style:e({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==b?void 0:b.pdfName),className:null==w?void 0:w.pdfName},{children:x}))}))}))]})),t("div",e({style:{display:"flex",alignItems:"center",gap:W?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"}},{children:[L>0&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"}},{children:[n("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:K,onChange:function(e){var t=e.target.value.replace(/\D/g,"");U(t)},onBlur:function(){var e=Number(K);if(!Number.isInteger(e)||e<1)U(String(j));else{var t=L?Math.min(e,L):e;P(t),U(String(t))}},onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(U(String(j)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:"/"})),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:String(L)}))]})),I&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n(Z,{}),n("div",e({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:n(_,{})})),n(O,{})]})),M&&z&&L>0&&n(c,e({title:"Rotate page (".concat(N,"°)")},{children:n("button",e({onClick:z,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:0!==N?"#1976d2":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px",transition:"color 0.2s ease"},onMouseEnter:function(e){e.currentTarget&&(e.currentTarget.style.color="#1976d2")},onMouseLeave:function(e){e.currentTarget&&(e.currentTarget.style.color=0!==N?"#1976d2":"#475467")},"aria-label":"Rotate current page"},{children:n(p,{sx:{fontSize:"18px"}})}))})),!!h&&W&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[t("span",e({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[f," of ",h]})),n("button",e({style:{background:"none",border:"none",cursor:f<=1?"not-allowed":"pointer",padding:"2px 4px",color:f<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:G,disabled:f<=1},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),n("button",e({style:{background:"none",border:"none",cursor:f===h?"not-allowed":"pointer",padding:"2px 4px",color:f===h?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:V,disabled:f===h},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),n("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),t("div",e({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==E&&((null==S?void 0:S.icon)&&(null==S?void 0:S.onClick)?n(c,e({title:(null==S?void 0:S.tooltip)||"",arrow:!0,placement:"top"},{children:n("div",e({onClick:S.onClick,style:e({display:"flex",alignItems:"center",cursor:"pointer"},X)},{children:S.icon}))})):n("button",e({onClick:function(){var e=null==y?void 0:y.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:X,title:"Full Screen"},{children:(null==k?void 0:k.fullScreenIcon)||n(l,{})}))),v&&n("a",e({href:v,target:"_blank",rel:"noopener noreferrer",style:X,title:"Open in new tab"},{children:(null==k?void 0:k.downloadIcon)||n(a,{})})),m&&n("button",e({onClick:m,style:X,title:"Close"},{children:(null==k?void 0:k.closeIcon)||n(d,{})}))]}))]}))]})),R&&t("div",e({style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:[n(c,e({title:B,arrow:!0,placement:"top"},{children:n(s,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})})),n("span",e({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:n(c,e({title:R.title,arrow:!0,placement:"top"},{children:t("span",{children:["Viewing ",R.title," • Pages ",Y(R.start_page),"-",Y(R.end_page)]})}))}))]}))]}))};export{u as default};
2
2
  //# sourceMappingURL=PdfToolbar.js.map