@prose-reader/react-reader 1.226.0 → 1.228.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(b,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-dom"),require("react-icons/bs"),require("@prose-reader/core"),require("react-icons/ri"),require("react-icons/rx"),require("react-icons/hi"),require("rc-slider"),require("rc-slider/assets/index.css"),require("react-icons/io"),require("react-icons/md")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","reactjrx","rxjs","@chakra-ui/react","react-icons/lu","react-dom","react-icons/bs","@prose-reader/core","react-icons/ri","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],e):(b=typeof globalThis<"u"?globalThis:b||self,e(b["prose-react-reader"]={},b.jsxRuntime,b.React,b.reactjrx,b.rxjs,b.react,b.lu,b.reactDom,b.bs,b.core,b.ri,b.rx,b.hi,b.RcSlider,null,b.io,b.md))})(this,function(b,e,a,p,g,t,C,ne,F,q,se,N,te,le,to,Y,K){"use strict";function re(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const s in o)if(s!=="default"){const l=Object.getOwnPropertyDescriptor(o,s);Object.defineProperty(n,s,l.get?l:{enumerable:!0,get:()=>o[s]})}}return n.default=o,Object.freeze(n)}const w=re(a),Q=a.createContext({reader:void 0,quickMenuSignal:p.signal({default:!1}),notificationsSubject:new g.Subject}),ie=a.memo(({children:o,reader:n,quickMenuOpen:s,onQuickMenuOpenChange:l})=>{const[,r]=p.useSignalState(()=>p.signal({default:s})),i=p.useConstant(()=>new g.Subject),d=p.useLiveRef(l),h=a.useMemo(()=>({quickMenuSignal:r,reader:n,notificationsSubject:i}),[r,n,i]);return a.useEffect(()=>{r.setValue(s)},[s,r]),p.useSubscribe(()=>r.pipe(g.tap(d.current)),[r,d]),e.jsx(Q.Provider,{value:h,children:o})}),ae=w.forwardRef(function(n,s){return e.jsx(t.IconButton,{variant:"ghost","aria-label":"Close",ref:s,...n,children:n.children??e.jsx(C.LuX,{})})}),O=w.forwardRef(function(n,s){const{children:l,portalled:r=!0,portalRef:i,backdrop:d=!0,...h}=n;return e.jsxs(t.Portal,{disabled:!r,container:i,children:[d&&e.jsx(t.Dialog.Backdrop,{}),e.jsx(t.Dialog.Positioner,{children:e.jsx(t.Dialog.Content,{ref:s,...h,asChild:!1,children:l})})]})}),m=w.forwardRef(function(n,s){return e.jsx(t.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...n,asChild:!0,children:e.jsx(ae,{size:"sm",ref:s,children:n.children})})}),D=t.Dialog.Root,A=t.Dialog.Footer,E=t.Dialog.Header,z=t.Dialog.Body;t.Dialog.Backdrop;const L=t.Dialog.Title;t.Dialog.Description,t.Dialog.Trigger;const M=t.Dialog.ActionTrigger,_=()=>a.useContext(Q),k=()=>{const{reader:o}=_();return o},X=o=>!!o&&"__PROSE_READER_ENHANCER_SEARCH"in o,$=o=>!!o&&"__PROSE_READER_ENHANCER_ANNOTATIONS"in o,Z=o=>!!o&&"__PROSE_READER_ENHANCER_GALLERY"in o,ce=o=>{const n=k(),s=$(n)?n:void 0;return{data:p.useObserve(()=>s==null?void 0:s.annotations.annotations$.pipe(g.map(r=>r.find(i=>i.id===o)),g.filter(p.isDefined),g.switchMap(r=>s.locateResource(r))),[s])}},J=({id:o,onNavigate:n})=>{var r,i;const s=k(),{data:l}=ce(o);return e.jsx(t.List.Item,{children:e.jsxs(t.Link,{href:"#",onClick:()=>{n(),s==null||s.navigation.goToCfi((l==null?void 0:l.meta.cfi)??"")},children:[(r=l==null?void 0:l.resource)!=null&&r.notes?e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(C.LuNotebookPen,{})}):e.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(C.LuNotebookPen,{})}),e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{lineClamp:2,fontSize:"md",children:l!=null&&l.meta.range?l==null?void 0:l.meta.range.toString():e.jsx("i",{children:e.jsx("b",{children:"unknown (not loaded)"})})}),e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Book page: ${((i=l==null?void 0:l.meta)==null?void 0:i.absolutePageIndex)!==void 0?l.meta.absolutePageIndex+1:"unknown (not loaded)"}`})]})]})})},W=()=>{const o=k(),n=$(o)?o:void 0;return{data:p.useObserve(()=>n==null?void 0:n.annotations.annotations$.pipe(g.switchMap(l=>n.locateResource(l))),[n])}},de=({onNavigate:o})=>{const{data:n}=W();return e.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>e.jsx(J,{id:s.resource.id,onNavigate:o},s.resource.id))})},he=()=>{const{data:o}=W();return{data:o==null?void 0:o.filter(n=>!n.meta.range)}},ge=({onNavigate:o})=>{const{data:n}=he();return e.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>e.jsx(J,{id:s.resource.id,onNavigate:o},s.resource.id))})},pe=a.memo(({onNavigate:o,defaultTab:n})=>{const[s,l]=a.useState(n??"bookmarks");return e.jsxs(t.Tabs.Root,{value:s,onValueChange:r=>l(r.value),children:[e.jsxs(t.Tabs.List,{children:[e.jsxs(t.Tabs.Trigger,{value:"bookmarks",children:[e.jsx(C.LuBookmark,{}),"Bookmarks"]}),e.jsxs(t.Tabs.Trigger,{value:"annotations",children:[e.jsx(C.LuNotebookPen,{}),"Annotations"]}),e.jsx(t.Tabs.Indicator,{})]}),e.jsx(t.Tabs.Content,{value:"bookmarks",children:e.jsx(ge,{onNavigate:o})}),e.jsx(t.Tabs.Content,{value:"annotations",children:e.jsx(de,{onNavigate:o})})]})}),fe=a.memo(({openWith:o,setOpen:n,onNavigate:s})=>e.jsx(D,{lazyMount:!0,placement:"center",open:!!o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{height:"100%",children:[e.jsx(E,{children:e.jsx(L,{children:"Annotations"})}),e.jsx(z,{flex:1,children:e.jsx(pe,{onNavigate:s,defaultTab:o})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),ue=a.memo(({children:o})=>{const n=k(),s=p.useObserve(()=>n==null?void 0:n.spine.element$,[n]);return s?e.jsx(e.Fragment,{children:ne.createPortal(o,s)}):null}),be=({absolutePageIndex:o,itemIndex:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.spine.spineItemsManager.items$,[s]);return{spineItem:a.useMemo(()=>{if(n!==void 0)return s==null?void 0:s.spine.spineItemsManager.get(n);if(o!==void 0){const{itemIndex:i}=(s==null?void 0:s.spine.locator.getSpineInfoFromAbsolutePageIndex({absolutePageIndex:o}))??{};return s==null?void 0:s.spine.spineItemsManager.get(i)}},[n,o,s,l])}},ve=({absolutePageIndex:o,itemIndex:n})=>{const{spineItem:s}=be({absolutePageIndex:o,itemIndex:n});return p.useObserve(()=>(s==null?void 0:s.isReady$)??g.of(!1),[s])},j="data-bookmark-area",R=()=>{const o=k();return $(o)?o:void 0},ke=o=>{const n=R();return p.useObserve(()=>n==null?void 0:n.annotations.candidates$.pipe(g.map(s=>s[o])),[n])},Se=a.memo(({absolutePageIndex:o,left:n,top:s,width:l})=>{const r=R(),i=ve({absolutePageIndex:o}),{data:d}=W(),h=d==null?void 0:d.find(c=>{var v;return((v=c==null?void 0:c.meta)==null?void 0:v.absolutePageIndex)===o&&c.meta.range===void 0}),u=ke(o);return!i||!u?null:e.jsx(t.Presence,{present:!0,lazyMount:!0,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(t.Box,{"data-bookmark-area":j,position:"absolute",left:n+l,transform:"translateX(-100%)",top:s,p:2,children:h?e.jsx(t.IconButton,{"aria-label":"bookmark",opacity:.5,_hover:{opacity:1},onClick:()=>{r==null||r.annotations.delete(h.resource.id)},size:"lg",variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(F.BsBookmarkXFill,{})}):e.jsx(t.IconButton,{"aria-label":"bookmark",onClick:()=>{r==null||r.annotations.annotateAbsolutePage({absolutePageIndex:o})},size:"lg",bgColor:"white",opacity:.5,_hover:{opacity:1},variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(F.BsBookmarkPlus,{})})})})}),Ce=a.memo(()=>{const o=k(),n=p.useObserve(()=>o==null?void 0:o.layoutInfo$,[o]);return e.jsx(ue,{children:n==null?void 0:n.pages.map(({absoluteLayout:{left:s,top:l,width:r}},i)=>e.jsx(Se,{absolutePageIndex:i,left:s,top:l,width:r},i))})}),V=t.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),Te=()=>e.jsx(t.Portal,{children:e.jsx(t.Toaster,{toaster:V,insetInline:{mdDown:"4"},children:o=>{var n;return e.jsxs(t.Toast.Root,{width:{md:"sm"},children:[o.type==="loading"?e.jsx(t.Spinner,{size:"sm",color:"blue.solid"}):e.jsx(t.Toast.Indicator,{}),e.jsxs(t.Stack,{gap:"1",flex:"1",maxWidth:"100%",children:[o.title&&e.jsx(t.Toast.Title,{children:o.title}),o.description&&e.jsx(t.Toast.Description,{children:o.description})]}),o.action&&e.jsx(t.Toast.ActionTrigger,{children:o.action.label}),((n=o.meta)==null?void 0:n.closable)&&e.jsx(t.Toast.CloseTrigger,{})]})}})}),Ie={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function ye(){const[o,n]=a.useState(null),[s,l]=a.useState(Ie),r=a.useMemo(()=>new ResizeObserver(i=>{if(i[0]){const{x:d,y:h,width:u,height:c,top:v,left:f,bottom:T,right:I}=i[0].contentRect;l({x:d,y:h,width:u,height:c,top:v,left:f,bottom:T,right:I})}}),[]);return a.useLayoutEffect(()=>{if(o)return r.observe(o),()=>{r.disconnect()}},[o,r]),[n,s,o]}const xe=(o,n,s)=>{const l=k(),r=Z(l)?l:void 0;p.useSubscribe(()=>{if(!r||!o)return g.NEVER;const i=n.layout.layout$.pipe(g.startWith(n.layout.layoutInfo),g.distinctUntilChanged(q.isShallowEqual)),d=q.observeIntersection(o).pipe(g.map(h=>h.some(u=>u.isIntersecting)));return i.pipe(g.throttleTime(100,void 0,{trailing:!0}),g.switchMap(()=>d.pipe(g.tap(h=>{h||(o.innerHTML="")}),g.filter(h=>h),g.first()).pipe(g.switchMap(()=>(o.innerHTML="",r==null?void 0:r.gallery.snapshot(n,o,s))))))},[r,n,s,o])},Pe=a.memo(({item:o,onNavigated:n})=>{var h;const[s,l,r]=ye(),i=k();xe(r,o,l);const d=p.useObserve(()=>i==null?void 0:i.locateResource(o,{mode:"shallow"}),[i,o]);return e.jsxs(t.Box,{width:"100%",aspectRatio:"2/3",border:"1px solid",borderColor:"border",borderRadius:"md","data-grid-item":!0,cursor:"pointer",position:"relative",overflow:"hidden",onClick:()=>{n(),i==null||i.navigation.goToSpineItem({indexOrId:o})},children:[e.jsx(t.Box,{height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",ref:s}),e.jsxs(t.Text,{position:"absolute",bottom:0,left:"0",right:"0",textAlign:"center",bgColor:"white",p:4,fontSize:"xs",children:["Page ",(((h=d==null?void 0:d.meta)==null?void 0:h.absolutePageIndex)??0)+1]})]})}),we=a.memo(({open:o,setOpen:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.spineItemsManager.items$,[s]);return e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{height:"100%",children:[e.jsx(E,{children:e.jsx(L,{children:"Gallery"})}),e.jsx(z,{children:e.jsx(t.Box,{gridTemplateColumns:["repeat(2, minmax(0, 1fr))","repeat(3, minmax(0, 1fr))"],display:"grid",gap:[2,4],pt:2,"data-grid":!0,children:l==null?void 0:l.map(r=>e.jsx(Pe,{item:r,onNavigated:()=>{n(!1)}},r.item.id))})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})}),Be="@prose-reader/react-reader",Oe="1.225.0",me=a.memo(({open:o,setOpen:n})=>e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:s=>n(s.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{children:[e.jsx(E,{children:e.jsx(L,{children:"Help"})}),e.jsxs(z,{overflowY:"auto",flex:1,children:[e.jsx(t.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),e.jsxs(t.HStack,{mb:1,children:[e.jsx(t.Kbd,{children:e.jsx(C.LuArrowBigRight,{})})," ",e.jsx(t.Text,{children:"Navigate to right page"})]}),e.jsxs(t.HStack,{mb:1,children:[e.jsx(t.Kbd,{children:e.jsx(C.LuArrowBigLeft,{})})," ",e.jsx(t.Text,{children:"Navigate to left page"})]}),e.jsx(t.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),e.jsxs(t.Text,{children:[Be," version: ",Oe]})]}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),B=()=>{const o=k();return p.useObserve(()=>o?g.combineLatest([o.pagination.state$,o.context.state$]).pipe(g.map(([n,s])=>{var r;const l=(r=s.manifest)==null?void 0:r.spineItems.every(i=>{var d;return(d=i.mediaType)==null?void 0:d.startsWith("image/")});return{...n,hasChapters:!s.isFullyPrePaginated&&!l}})):g.NEVER,[o])},De=()=>{const o=B(),n=Math.floor(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),s=n>0?n:1;return(o==null?void 0:o.percentageEstimateOfBook)===void 0?null:e.jsx(t.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:e.jsxs(t.Text,{fontSize:"sm",children:[s," %"]})})},Ae=()=>{const[o,n]=a.useState(new Date);return a.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(s)},[]),o},Ee=o=>{const n=Ae();return e.jsx(t.Text,{fontSize:"xs",...o,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},G=()=>{const{quickMenuSignal:o}=_();return[p.useSignalValue(o),o.setValue,o]},ze=()=>{const[o]=G();return e.jsx(t.Box,{position:"absolute",left:0,bottom:0,p:2,color:o?void 0:"colorPalette.contrast",children:e.jsx(Ee,{})})},Le=()=>{const o=k();p.useSubscribe(()=>o==null?void 0:o.links$.subscribe(n=>{if(n.type==="click"&&q.isHtmlTagElement(n.target,"a")){if(!n.target.href)return;const s=new URL(n.target.href);window.location.host!==s.host&&confirm("You are going to be redirected to external link")&&window.open(n.target.href,"__blank")}}),[o])},Me=()=>{const o=k(),{notificationsSubject:n}=_();p.useSubscribe(()=>o==null?void 0:o.zoom.isZooming$.pipe(g.switchMap(s=>{if(!s)return g.EMPTY;const l=new g.Subject;return n.next({key:"zoom",title:"Zooming",duration:999999,abort:l}),g.NEVER.pipe(g.finalize(()=>{l.next(),l.complete()}))})),[o])},_e=()=>{const o=k(),{notificationsSubject:n}=_();p.useSubscribe(()=>o==null?void 0:o.settings.values$.pipe(g.map(({fontScale:s})=>s),g.distinctUntilChanged(),g.skip(1),g.tap(s=>{n.next({key:"fontScaleChange",title:"Font size changed",description:`${s*100} %`})})),[o,n])},$e=()=>{const{notificationsSubject:o}=_();_e(),Me(),p.useSubscribe(()=>o.pipe(g.filter(p.isDefined),g.mergeMap(n=>{const s=n.duration??3e3,l=V.create({title:n.title,description:n.description,duration:s}),r=o.pipe(g.skip(1),g.filter(i=>!!n.key&&(i==null?void 0:i.key)===n.key));return g.merge(g.timer(s),n.abort??g.NEVER,r).pipe(g.first(),g.finalize(()=>{V.dismiss(l)}))})),[o])},He=w.forwardRef(function(n,s){const{showArrow:l,children:r,portalled:i=!0,content:d,portalRef:h,...u}=n;return e.jsxs(t.Popover.Root,{...u,positioning:{...u.positioning,gutter:4},children:[e.jsx(t.Popover.Trigger,{asChild:!0,children:r}),e.jsx(t.Portal,{disabled:!i,container:h,children:e.jsx(t.Popover.Positioner,{children:e.jsxs(t.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:s,children:[l&&e.jsx(t.Popover.Arrow,{children:e.jsx(t.Popover.ArrowTip,{})}),d]})})})]})}),Ne=w.forwardRef(function(n,s){const{children:l,...r}=n;return e.jsx(He,{content:l,...r,ref:s,children:e.jsx(t.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:e.jsx(te.HiOutlineInformationCircle,{})})})}),Fe=w.forwardRef(function(n,s){return e.jsx(t.Progress.Track,{...n,ref:s,children:e.jsx(t.Progress.Range,{})})});w.forwardRef(function(n,s){const{children:l,info:r,...i}=n;return e.jsxs(t.Progress.Label,{...i,ref:s,children:[l,r&&e.jsx(Ne,{children:r})]})});const qe=t.Progress.Root,We=t.Progress.ValueText,U=()=>{const o=B(),n=(o==null?void 0:o.numberOfTotalPages)===1,s=((o==null?void 0:o.beginNumberOfPagesInSpineItem)??0)>1,l=((o==null?void 0:o.endNumberOfPagesInSpineItem)??0)>1,r=(o!=null&&o.hasChapters?o==null?void 0:o.beginPageIndexInSpineItem:o==null?void 0:o.beginAbsolutePageIndex)??0,i=(o!=null&&o.hasChapters?o==null?void 0:o.endPageIndexInSpineItem:o==null?void 0:o.endAbsolutePageIndex)??0,[d=0,h=0]=[r,i].sort((v,f)=>v-f),u=(o==null?void 0:o.beginPageIndexInSpineItem)!==(o==null?void 0:o.endPageIndexInSpineItem)||(o==null?void 0:o.beginSpineItemIndex)!==(o==null?void 0:o.endSpineItemIndex),c=o!=null&&o.hasChapters?o==null?void 0:o.beginNumberOfPagesInSpineItem:o==null?void 0:o.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:r,endPageIndex:i,isBeginWithinChapter:s,isEndWithinChapter:l,beginAndEndAreDifferent:u,totalApproximatePages:c,leftPageIndex:d,rightPageIndex:h}},Ve=()=>{const o=B(),{hasOnlyOnePage:n,leftPageIndex:s,rightPageIndex:l,totalApproximatePages:r,beginAndEndAreDifferent:i}=U(),d=Math.round(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),h=c=>c!=null&&c.subChapter?`${c.title} / ${h(c.subChapter)}`:(c==null?void 0:c.title)||"",u=h(o==null?void 0:o.beginChapterInfo);return e.jsxs(t.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[e.jsx(qe,{value:d,size:"xs",width:150,children:e.jsxs(t.HStack,{justifyContent:"space-between",children:[e.jsx(Fe,{width:110}),e.jsx(We,{children:`${d}%`})]})}),e.jsx(t.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:u?`Chapter: ${u}`:" "}),!n&&e.jsxs(t.HStack,{children:[e.jsx(t.Text,{fontSize:"xs",children:i?`${s+1} - ${l+1} of ${r}`:`${s+1} of ${r}`}),!!(o!=null&&o.hasChapters)&&e.jsxs(e.Fragment,{children:[e.jsx(t.Text,{children:"-"}),e.jsxs(t.Text,{fontSize:"xs",children:["(",((o==null?void 0:o.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},ee=a.memo(({children:o,position:n,...s})=>e.jsx(t.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...n==="bottom"?{bottom:0}:{top:0},animationName:n==="bottom"?{_open:"slide-from-bottom, fade-in",_closed:"slide-to-bottom, fade-out"}:{_open:"slide-from-top, fade-in",_closed:"slide-to-top, fade-out"},animationDuration:"moderate",bgColor:"bg.panel",alignItems:"center",justifyContent:"center",shadow:"md",p:4,...s,children:o})),Ge=t.chakra(le),Ue=a.memo(o=>e.jsx(t.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:e.jsx(Ge,{keyboard:!1,style:{padding:0},css:{"& > .rc-slider-handle:focus-visible":{boxShadow:"0 0 0 2px var(--color-solid) !important"},"& > .rc-slider-handle:active":{boxShadow:"0 0 5px var(--color-solid) !important"},"& > .rc-slider-handle.rc-slider-handle-dragging":{boxShadow:"0 0 0 3px var(--color-solid) !important"}},styles:{rail:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--bg-emphasized)"},track:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--color-solid)"},handle:{width:"24px",height:"24px",top:"50%",borderColor:"var(--color-solid)",transform:`translate(${o.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...o})})),Ye=()=>{const o=B(),n=o==null?void 0:o.isUsingSpread,{beginPageIndex:s,totalApproximatePages:l=0}=U(),r=n?Math.floor((s||0)/2):s,[i,d]=p.useSignalState(()=>p.signal({default:r||0})),h=0,u=Math.max(0,n?Math.floor((l-1)/2):l-1);return a.useEffect(()=>{d.update(r||0)},[r,d]),{value:i,valueSignal:d,min:h,max:u}},Ke=o=>{const n=k(),s=B(),{manifest:l}=p.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},r=(l==null?void 0:l.readingDirection)==="rtl",i=s==null?void 0:s.isUsingSpread,{totalApproximatePages:d=0,isBeginWithinChapter:h}=U(),u=1,c=h,{value:v,valueSignal:f,min:T,max:I}=Ye(),y=a.useCallback(P=>{const[S=0]=Array.isArray(P)?P:[P];f.setValue(S);const H=i?Math.floor(S)*2:Math.floor(S);c?n==null||n.navigation.goToPageOfSpineItem({pageIndex:H,spineItemId:n.pagination.state.beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:H,animation:!1})},[n,i,f,c]);return p.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:f.subject}),[n,f]),d===1||i&&d===2?e.jsx(t.Box,{style:o.style}):e.jsx(Ue,{value:[v],max:I,min:T,reverse:r,step:u,onChange:y,...o})},Qe=a.memo(({open:o,onItemClick:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.navigation.state$,[s]),r=p.useObserve(()=>s==null?void 0:s.settings.values$,[s]),i=(r==null?void 0:r.computedPageTurnDirection)==="vertical",[d,h]=a.useState(!0);return e.jsxs(ee,{present:o,position:"bottom",display:"flex",flexDirection:"column",overflow:"auto",pb:8,children:[e.jsxs(t.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[e.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>s==null?void 0:s.navigation.goToLeftOrTopSpineItem(),disabled:!(l!=null&&l.canGoLeftSpineItem)&&!(l!=null&&l.canGoTopSpineItem),children:i?e.jsx(N.RxDoubleArrowUp,{}):e.jsx(N.RxDoubleArrowLeft,{})}),e.jsxs(t.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"auto",px:4,children:[e.jsx(Ve,{}),e.jsx(Ke,{style:{width:"100%",maxWidth:"300px",height:"35px"}})]}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(l!=null&&l.canGoRightSpineItem)&&!(l!=null&&l.canGoBottomSpineItem),onClick:()=>{s==null||s.navigation.goToRightOrBottomSpineItem()},children:i?e.jsx(N.RxDoubleArrowDown,{}):e.jsx(N.RxDoubleArrowRight,{})})]}),e.jsx(t.HStack,{alignSelf:"stretch",alignItems:"center",justifyContent:"center",children:e.jsxs(t.Collapsible.Root,{open:d,flex:1,onOpenChange:({open:u})=>{h(u)},children:[e.jsx(t.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:e.jsx(C.LuChevronDown,{style:{transform:d?"rotate(0deg)":"rotate(180deg)"}})}),e.jsxs(t.Collapsible.Content,{display:"flex",justifyContent:"center",children:[e.jsx(t.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:()=>n("help"),children:e.jsx(C.LuCircleHelp,{})}),e.jsx(t.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:()=>n("toc"),children:e.jsx(C.LuTableOfContents,{})}),X(s)&&e.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("search"),children:e.jsx(C.LuSearch,{})}),$(s)&&e.jsx(t.IconButton,{"aria-label":"Bookmarks",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:e.jsx(F.BsBookmarks,{})}),$(s)&&e.jsx(t.IconButton,{"aria-label":"Annotations",size:"lg",variant:"ghost",onClick:()=>n("annotations"),children:e.jsx(C.LuNotebookPen,{})}),e.jsx(t.IconButton,{"aria-label":"Thumbnails",size:"lg",variant:(s==null?void 0:s.settings.values.viewportMode)==="thumbnails"?"solid":"ghost",onClick:()=>{s==null||s.settings.update({viewportMode:(s==null?void 0:s.settings.values.viewportMode)==="normal"?"thumbnails":"normal"})},children:e.jsx(C.LuGalleryHorizontal,{})}),Z(s)&&e.jsx(t.IconButton,{"aria-label":"Gallery",size:"lg",variant:"ghost",onClick:()=>n("gallery"),children:e.jsx(se.RiGalleryView2,{})})]})]})})]})}),Xe=()=>{const[o,n]=a.useState(!1),s=a.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{n(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{n(!0)}),[]);return a.useEffect(()=>{function l(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:o,onToggleFullscreenClick:s}},Ze=a.memo(({open:o,onItemClick:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.context.manifest$,[s]),{isFullscreen:r,onToggleFullscreenClick:i}=Xe();return e.jsxs(ee,{present:o,position:"top",height:"80px",justifyContent:"space-between",children:[e.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>n("back"),children:e.jsx(Y.IoIosArrowBack,{})}),e.jsx(t.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:e.jsx(t.Text,{truncate:!0,maxWidth:"100%",children:l==null?void 0:l.title})}),e.jsxs(t.HStack,{children:[e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:()=>n("more"),children:e.jsx(Y.IoMdMore,{})}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:i,children:r?e.jsx(K.MdFullscreenExit,{}):e.jsx(K.MdFullscreen,{})})]})]})}),Je=a.memo(({onItemClick:o})=>{const[n]=G();return e.jsxs(e.Fragment,{children:[e.jsx(Ze,{open:n,onItemClick:o}),e.jsx(Qe,{open:n,onItemClick:o})]})}),je=a.memo(({contextText:o="",startOffset:n=0,text:s,cfi:l="#",onClick:r,absolutePageIndex:i})=>{const h=o.substring(Math.max(n-15,0),Math.max(n,0)),u=o.substring(Math.min(n+s.length,o.length-1),Math.min(n+s.length+15,o.length-1));return e.jsxs(t.Link,{href:l,style:{margin:5,overflow:"hidden"},onClick:c=>{c.preventDefault(),r(l)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[e.jsxs(t.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',h,e.jsx("b",{children:s}),u,'"']}),e.jsx(t.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${i!==void 0?i+1:"unknown (not loaded)"}`})]})}),Re=a.memo(({onNavigate:o})=>{const[n,s]=a.useState(""),l=k(),r=X(l)?l:void 0,i=f=>{s(f.target.value)},d=a.useCallback(f=>{o(),l==null||l.navigation.goToCfi(f)},[l,o]),h=p.useObserve(()=>r==null?void 0:r.search.search(n).pipe(g.map(f=>({type:"end",data:f})),g.startWith({type:"start"})),[l,n]),u=(h==null?void 0:h.type)==="start",c=(h==null?void 0:h.type)==="end"?h.data:[],v=p.useObserve(()=>l==null?void 0:l.locateResource(c.slice(0,100)),[c]);return e.jsxs(t.Stack,{flex:1,height:"100%",children:[e.jsx(t.Box,{px:4,children:e.jsx(t.Input,{placeholder:"Type something...",value:n,onChange:i,borderRadius:0})}),e.jsxs(t.Box,{px:4,pb:4,mt:2,flex:1,style:{overflow:"hidden",overflowY:"auto"},children:[u&&e.jsx(t.Text,{children:"Searching ..."}),!u&&c.length===0&&e.jsx("p",{children:"There are no results"}),!u&&c.length>=0&&e.jsxs(t.Stack,{children:[e.jsxs(t.Heading,{as:"h2",size:"md",children:[c.length," result(s)"]}),e.jsx(t.Stack,{gap:0,children:v==null?void 0:v.map((f,T)=>{var I,y,x,P,S,H,oe;return e.jsx(je,{contextText:((x=(y=(I=f.meta)==null?void 0:I.range)==null?void 0:y.startContainer.parentElement)==null?void 0:x.textContent)??"",pageIndex:(P=f.meta)==null?void 0:P.itemPageIndex,startOffset:((H=(S=f.meta)==null?void 0:S.range)==null?void 0:H.startOffset)??0,text:n,cfi:f.meta.cfi,onClick:d,absolutePageIndex:(oe=f.meta)==null?void 0:oe.absolutePageIndex},T)})})]})]})]})}),eo=a.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{height:"100%",children:[e.jsx(E,{children:e.jsx(L,{children:"Search"})}),e.jsx(z,{flex:1,children:e.jsx(Re,{onNavigate:s})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),oo=a.memo(({onNavigate:o})=>{const n=k(),{manifest:s,assumedRenditionLayout:l}=p.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:r}=s??{},i=B();r!=null&&r.toc;const{beginSpineItemIndex:d,beginPageIndexInSpineItem:h}=i??{},u=(l==="reflowable"?h:d)||0;let c=i==null?void 0:i.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const v=(f,T,I)=>e.jsxs(a.Fragment,{children:[e.jsx(t.List.Item,{pl:4*(I+1),style:{display:"flex",alignItems:"center"},children:e.jsxs(t.Link,{onClick:()=>{o(),n==null||n.navigation.goToUrl(f.href)},href:"#",children:[(c==null?void 0:c.path)===f.path&&e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(C.LuCircleCheck,{})}),(c==null?void 0:c.path)!==f.path&&e.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(C.LuCircleCheck,{})}),e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{fontSize:"md",children:f.title||f.path}),(c==null?void 0:c.path)===f.path&&e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${u+1}`})]})]})}),f.contents.length>0&&e.jsx(t.List.Root,{as:"div",gap:2,children:f.contents.map((y,x)=>v(y,x,I+1))})]},T);return e.jsx(t.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:r==null?void 0:r.toc.map((f,T)=>v(f,T,0))})}),no=a.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{children:[e.jsx(E,{children:e.jsx(L,{children:"Table of Contents"})}),e.jsx(z,{overflowY:"auto",flex:1,children:e.jsx(oo,{onNavigate:s})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),so=({enableFloatingTime:o=!0,enableFloatingProgress:n=!0,onItemClick:s})=>{const[l,r]=a.useState(!1),[i,d]=a.useState(!1),[h,u]=a.useState(!1),[c,v]=a.useState(void 0),[f,T]=a.useState(!1),[I,y]=G(),x=a.useCallback(()=>{r(!1),d(!1),u(!1),v(void 0),y(!1),T(!1)},[y]),P=a.useCallback(S=>{S==="annotations"?v("annotations"):S==="search"?u(!0):S==="help"?d(!0):S==="toc"?r(!0):S==="bookmarks"?v("bookmarks"):S==="gallery"&&T(!0),s==null||s(S)},[s]);return Le(),$e(),e.jsxs(e.Fragment,{children:[n&&e.jsx(t.Presence,{present:!I,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(De,{})}),e.jsx(we,{open:f,setOpen:T}),e.jsx(Je,{onItemClick:P}),e.jsx(Ce,{}),e.jsx(me,{open:i,setOpen:d}),e.jsx(no,{open:l,setOpen:r,onNavigate:x}),e.jsx(eo,{open:h,setOpen:u,onNavigate:x}),e.jsx(fe,{openWith:c,setOpen:S=>v(S?"annotations":void 0),onNavigate:x}),e.jsx(t.Presence,{present:o||I,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:e.jsx(ze,{})}),e.jsx(Te,{})]})};b.BOOKMARK_AREA_DATA_ATTRIBUTE=j,b.ReactReader=so,b.ReactReaderProvider=ie,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(b,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-dom"),require("react-icons/bs"),require("@prose-reader/core"),require("react-icons/ri"),require("react-icons/rx"),require("react-icons/hi"),require("rc-slider"),require("rc-slider/assets/index.css"),require("react-icons/io"),require("react-icons/md")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","reactjrx","rxjs","@chakra-ui/react","react-icons/lu","react-dom","react-icons/bs","@prose-reader/core","react-icons/ri","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],e):(b=typeof globalThis<"u"?globalThis:b||self,e(b["prose-react-reader"]={},b.jsxRuntime,b.React,b.reactjrx,b.rxjs,b.react,b.lu,b.reactDom,b.bs,b.core,b.ri,b.rx,b.hi,b.RcSlider,null,b.io,b.md))})(this,function(b,e,a,p,g,t,C,ne,F,q,se,N,te,le,to,Y,K){"use strict";function re(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const s in o)if(s!=="default"){const l=Object.getOwnPropertyDescriptor(o,s);Object.defineProperty(n,s,l.get?l:{enumerable:!0,get:()=>o[s]})}}return n.default=o,Object.freeze(n)}const w=re(a),Q=a.createContext({reader:void 0,quickMenuSignal:p.signal({default:!1}),notificationsSubject:new g.Subject}),ie=a.memo(({children:o,reader:n,quickMenuOpen:s,onQuickMenuOpenChange:l})=>{const[,r]=p.useSignalState(()=>p.signal({default:s})),i=p.useConstant(()=>new g.Subject),d=p.useLiveRef(l),h=a.useMemo(()=>({quickMenuSignal:r,reader:n,notificationsSubject:i}),[r,n,i]);return a.useEffect(()=>{r.setValue(s)},[s,r]),p.useSubscribe(()=>r.pipe(g.tap(d.current)),[r,d]),e.jsx(Q.Provider,{value:h,children:o})}),ae=w.forwardRef(function(n,s){return e.jsx(t.IconButton,{variant:"ghost","aria-label":"Close",ref:s,...n,children:n.children??e.jsx(C.LuX,{})})}),O=w.forwardRef(function(n,s){const{children:l,portalled:r=!0,portalRef:i,backdrop:d=!0,...h}=n;return e.jsxs(t.Portal,{disabled:!r,container:i,children:[d&&e.jsx(t.Dialog.Backdrop,{}),e.jsx(t.Dialog.Positioner,{children:e.jsx(t.Dialog.Content,{ref:s,...h,asChild:!1,children:l})})]})}),m=w.forwardRef(function(n,s){return e.jsx(t.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...n,asChild:!0,children:e.jsx(ae,{size:"sm",ref:s,children:n.children})})}),D=t.Dialog.Root,A=t.Dialog.Footer,E=t.Dialog.Header,z=t.Dialog.Body;t.Dialog.Backdrop;const L=t.Dialog.Title;t.Dialog.Description,t.Dialog.Trigger;const M=t.Dialog.ActionTrigger,_=()=>a.useContext(Q),k=()=>{const{reader:o}=_();return o},X=o=>!!o&&"__PROSE_READER_ENHANCER_SEARCH"in o,$=o=>!!o&&"__PROSE_READER_ENHANCER_ANNOTATIONS"in o,Z=o=>!!o&&"__PROSE_READER_ENHANCER_GALLERY"in o,ce=o=>{const n=k(),s=$(n)?n:void 0;return{data:p.useObserve(()=>s==null?void 0:s.annotations.annotations$.pipe(g.map(r=>r.find(i=>i.id===o)),g.filter(p.isDefined),g.switchMap(r=>s.locateResource(r))),[s])}},J=({id:o,onNavigate:n})=>{var r,i;const s=k(),{data:l}=ce(o);return e.jsx(t.List.Item,{children:e.jsxs(t.Link,{href:"#",onClick:()=>{n(),s==null||s.navigation.goToCfi((l==null?void 0:l.meta.cfi)??"")},children:[(r=l==null?void 0:l.resource)!=null&&r.notes?e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(C.LuNotebookPen,{})}):e.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(C.LuNotebookPen,{})}),e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{lineClamp:2,fontSize:"md",children:l!=null&&l.meta.range?l==null?void 0:l.meta.range.toString():e.jsx("i",{children:e.jsx("b",{children:"unknown (not loaded)"})})}),e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Book page: ${((i=l==null?void 0:l.meta)==null?void 0:i.absolutePageIndex)!==void 0?l.meta.absolutePageIndex+1:"unknown (not loaded)"}`})]})]})})},W=()=>{const o=k(),n=$(o)?o:void 0;return{data:p.useObserve(()=>n==null?void 0:n.annotations.annotations$.pipe(g.switchMap(l=>n.locateResource(l))),[n])}},de=({onNavigate:o})=>{const{data:n}=W();return e.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>e.jsx(J,{id:s.resource.id,onNavigate:o},s.resource.id))})},he=()=>{const{data:o}=W();return{data:o==null?void 0:o.filter(n=>!n.meta.range)}},ge=({onNavigate:o})=>{const{data:n}=he();return e.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>e.jsx(J,{id:s.resource.id,onNavigate:o},s.resource.id))})},pe=a.memo(({onNavigate:o,defaultTab:n})=>{const[s,l]=a.useState(n??"bookmarks");return e.jsxs(t.Tabs.Root,{value:s,onValueChange:r=>l(r.value),children:[e.jsxs(t.Tabs.List,{children:[e.jsxs(t.Tabs.Trigger,{value:"bookmarks",children:[e.jsx(C.LuBookmark,{}),"Bookmarks"]}),e.jsxs(t.Tabs.Trigger,{value:"annotations",children:[e.jsx(C.LuNotebookPen,{}),"Annotations"]}),e.jsx(t.Tabs.Indicator,{})]}),e.jsx(t.Tabs.Content,{value:"bookmarks",children:e.jsx(ge,{onNavigate:o})}),e.jsx(t.Tabs.Content,{value:"annotations",children:e.jsx(de,{onNavigate:o})})]})}),fe=a.memo(({openWith:o,setOpen:n,onNavigate:s})=>e.jsx(D,{lazyMount:!0,placement:"center",open:!!o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{height:"100%",children:[e.jsx(E,{children:e.jsx(L,{children:"Annotations"})}),e.jsx(z,{flex:1,children:e.jsx(pe,{onNavigate:s,defaultTab:o})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),ue=a.memo(({children:o})=>{const n=k(),s=p.useObserve(()=>n==null?void 0:n.spine.element$,[n]);return s?e.jsx(e.Fragment,{children:ne.createPortal(o,s)}):null}),be=({absolutePageIndex:o,itemIndex:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.spine.spineItemsManager.items$,[s]);return{spineItem:a.useMemo(()=>{if(n!==void 0)return s==null?void 0:s.spine.spineItemsManager.get(n);if(o!==void 0){const{itemIndex:i}=(s==null?void 0:s.spine.locator.getSpineInfoFromAbsolutePageIndex({absolutePageIndex:o}))??{};return s==null?void 0:s.spine.spineItemsManager.get(i)}},[n,o,s,l])}},ve=({absolutePageIndex:o,itemIndex:n})=>{const{spineItem:s}=be({absolutePageIndex:o,itemIndex:n});return p.useObserve(()=>(s==null?void 0:s.isReady$)??g.of(!1),[s])},j="data-bookmark-area",R=()=>{const o=k();return $(o)?o:void 0},ke=o=>{const n=R();return p.useObserve(()=>n==null?void 0:n.annotations.candidates$.pipe(g.map(s=>s[o])),[n])},Se=a.memo(({absolutePageIndex:o,left:n,top:s,width:l})=>{const r=R(),i=ve({absolutePageIndex:o}),{data:d}=W(),h=d==null?void 0:d.find(c=>{var v;return((v=c==null?void 0:c.meta)==null?void 0:v.absolutePageIndex)===o&&c.meta.range===void 0}),u=ke(o);return!i||!u?null:e.jsx(t.Presence,{present:!0,lazyMount:!0,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(t.Box,{"data-bookmark-area":j,position:"absolute",left:n+l,transform:"translateX(-100%)",top:s,p:2,children:h?e.jsx(t.IconButton,{"aria-label":"bookmark",opacity:.5,_hover:{opacity:1},onClick:()=>{r==null||r.annotations.delete(h.resource.id)},size:"lg",variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(F.BsBookmarkXFill,{})}):e.jsx(t.IconButton,{"aria-label":"bookmark",onClick:()=>{r==null||r.annotations.annotateAbsolutePage({absolutePageIndex:o})},size:"lg",bgColor:"white",opacity:.5,_hover:{opacity:1},variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(F.BsBookmarkPlus,{})})})})}),Ce=a.memo(()=>{const o=k(),n=p.useObserve(()=>o==null?void 0:o.layoutInfo$,[o]);return e.jsx(ue,{children:n==null?void 0:n.pages.map(({absoluteLayout:{left:s,top:l,width:r}},i)=>e.jsx(Se,{absolutePageIndex:i,left:s,top:l,width:r},i))})}),V=t.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),Te=()=>e.jsx(t.Portal,{children:e.jsx(t.Toaster,{toaster:V,insetInline:{mdDown:"4"},children:o=>{var n;return e.jsxs(t.Toast.Root,{width:{md:"sm"},children:[o.type==="loading"?e.jsx(t.Spinner,{size:"sm",color:"blue.solid"}):e.jsx(t.Toast.Indicator,{}),e.jsxs(t.Stack,{gap:"1",flex:"1",maxWidth:"100%",children:[o.title&&e.jsx(t.Toast.Title,{children:o.title}),o.description&&e.jsx(t.Toast.Description,{children:o.description})]}),o.action&&e.jsx(t.Toast.ActionTrigger,{children:o.action.label}),((n=o.meta)==null?void 0:n.closable)&&e.jsx(t.Toast.CloseTrigger,{})]})}})}),Ie={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function ye(){const[o,n]=a.useState(null),[s,l]=a.useState(Ie),r=a.useMemo(()=>new ResizeObserver(i=>{if(i[0]){const{x:d,y:h,width:u,height:c,top:v,left:f,bottom:T,right:I}=i[0].contentRect;l({x:d,y:h,width:u,height:c,top:v,left:f,bottom:T,right:I})}}),[]);return a.useLayoutEffect(()=>{if(o)return r.observe(o),()=>{r.disconnect()}},[o,r]),[n,s,o]}const xe=(o,n,s)=>{const l=k(),r=Z(l)?l:void 0;p.useSubscribe(()=>{if(!r||!o)return g.NEVER;const i=n.layout.layout$.pipe(g.startWith(n.layout.layoutInfo),g.distinctUntilChanged(q.isShallowEqual)),d=q.observeIntersection(o).pipe(g.map(h=>h.some(u=>u.isIntersecting)));return i.pipe(g.throttleTime(100,void 0,{trailing:!0}),g.switchMap(()=>d.pipe(g.tap(h=>{h||(o.innerHTML="")}),g.filter(h=>h),g.first()).pipe(g.switchMap(()=>(o.innerHTML="",r==null?void 0:r.gallery.snapshot(n,o,s))))))},[r,n,s,o])},Pe=a.memo(({item:o,onNavigated:n})=>{var h;const[s,l,r]=ye(),i=k();xe(r,o,l);const d=p.useObserve(()=>i==null?void 0:i.locateResource(o,{mode:"shallow"}),[i,o]);return e.jsxs(t.Box,{width:"100%",aspectRatio:"2/3",border:"1px solid",borderColor:"border",borderRadius:"md","data-grid-item":!0,cursor:"pointer",position:"relative",overflow:"hidden",onClick:()=>{n(),i==null||i.navigation.goToSpineItem({indexOrId:o})},children:[e.jsx(t.Box,{height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",ref:s}),e.jsxs(t.Text,{position:"absolute",bottom:0,left:"0",right:"0",textAlign:"center",bgColor:"white",p:4,fontSize:"xs",children:["Page ",(((h=d==null?void 0:d.meta)==null?void 0:h.absolutePageIndex)??0)+1]})]})}),we=a.memo(({open:o,setOpen:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.spineItemsManager.items$,[s]);return e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{height:"100%",children:[e.jsx(E,{children:e.jsx(L,{children:"Gallery"})}),e.jsx(z,{children:e.jsx(t.Box,{gridTemplateColumns:["repeat(2, minmax(0, 1fr))","repeat(3, minmax(0, 1fr))"],display:"grid",gap:[2,4],pt:2,"data-grid":!0,children:l==null?void 0:l.map(r=>e.jsx(Pe,{item:r,onNavigated:()=>{n(!1)}},r.item.id))})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})}),Be="@prose-reader/react-reader",Oe="1.227.0",me=a.memo(({open:o,setOpen:n})=>e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:s=>n(s.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{children:[e.jsx(E,{children:e.jsx(L,{children:"Help"})}),e.jsxs(z,{overflowY:"auto",flex:1,children:[e.jsx(t.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),e.jsxs(t.HStack,{mb:1,children:[e.jsx(t.Kbd,{children:e.jsx(C.LuArrowBigRight,{})})," ",e.jsx(t.Text,{children:"Navigate to right page"})]}),e.jsxs(t.HStack,{mb:1,children:[e.jsx(t.Kbd,{children:e.jsx(C.LuArrowBigLeft,{})})," ",e.jsx(t.Text,{children:"Navigate to left page"})]}),e.jsx(t.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),e.jsxs(t.Text,{children:[Be," version: ",Oe]})]}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),B=()=>{const o=k();return p.useObserve(()=>o?g.combineLatest([o.pagination.state$,o.context.state$]).pipe(g.map(([n,s])=>{var r;const l=(r=s.manifest)==null?void 0:r.spineItems.every(i=>{var d;return(d=i.mediaType)==null?void 0:d.startsWith("image/")});return{...n,hasChapters:!s.isFullyPrePaginated&&!l}})):g.NEVER,[o])},De=()=>{const o=B(),n=Math.floor(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),s=n>0?n:1;return(o==null?void 0:o.percentageEstimateOfBook)===void 0?null:e.jsx(t.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:e.jsxs(t.Text,{fontSize:"sm",children:[s," %"]})})},Ae=()=>{const[o,n]=a.useState(new Date);return a.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(s)},[]),o},Ee=o=>{const n=Ae();return e.jsx(t.Text,{fontSize:"xs",...o,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},G=()=>{const{quickMenuSignal:o}=_();return[p.useSignalValue(o),o.setValue,o]},ze=()=>{const[o]=G();return e.jsx(t.Box,{position:"absolute",left:0,bottom:0,p:2,color:o?void 0:"colorPalette.contrast",children:e.jsx(Ee,{})})},Le=()=>{const o=k();p.useSubscribe(()=>o==null?void 0:o.links$.subscribe(n=>{if(n.type==="click"&&q.isHtmlTagElement(n.target,"a")){if(!n.target.href)return;const s=new URL(n.target.href);window.location.host!==s.host&&confirm("You are going to be redirected to external link")&&window.open(n.target.href,"__blank")}}),[o])},Me=()=>{const o=k(),{notificationsSubject:n}=_();p.useSubscribe(()=>o==null?void 0:o.zoom.isZooming$.pipe(g.switchMap(s=>{if(!s)return g.EMPTY;const l=new g.Subject;return n.next({key:"zoom",title:"Zooming",duration:999999,abort:l}),g.NEVER.pipe(g.finalize(()=>{l.next(),l.complete()}))})),[o])},_e=()=>{const o=k(),{notificationsSubject:n}=_();p.useSubscribe(()=>o==null?void 0:o.settings.values$.pipe(g.map(({fontScale:s})=>s),g.distinctUntilChanged(),g.skip(1),g.tap(s=>{n.next({key:"fontScaleChange",title:"Font size changed",description:`${s*100} %`})})),[o,n])},$e=()=>{const{notificationsSubject:o}=_();_e(),Me(),p.useSubscribe(()=>o.pipe(g.filter(p.isDefined),g.mergeMap(n=>{const s=n.duration??3e3,l=V.create({title:n.title,description:n.description,duration:s}),r=o.pipe(g.skip(1),g.filter(i=>!!n.key&&(i==null?void 0:i.key)===n.key));return g.merge(g.timer(s),n.abort??g.NEVER,r).pipe(g.first(),g.finalize(()=>{V.dismiss(l)}))})),[o])},He=w.forwardRef(function(n,s){const{showArrow:l,children:r,portalled:i=!0,content:d,portalRef:h,...u}=n;return e.jsxs(t.Popover.Root,{...u,positioning:{...u.positioning,gutter:4},children:[e.jsx(t.Popover.Trigger,{asChild:!0,children:r}),e.jsx(t.Portal,{disabled:!i,container:h,children:e.jsx(t.Popover.Positioner,{children:e.jsxs(t.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:s,children:[l&&e.jsx(t.Popover.Arrow,{children:e.jsx(t.Popover.ArrowTip,{})}),d]})})})]})}),Ne=w.forwardRef(function(n,s){const{children:l,...r}=n;return e.jsx(He,{content:l,...r,ref:s,children:e.jsx(t.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:e.jsx(te.HiOutlineInformationCircle,{})})})}),Fe=w.forwardRef(function(n,s){return e.jsx(t.Progress.Track,{...n,ref:s,children:e.jsx(t.Progress.Range,{})})});w.forwardRef(function(n,s){const{children:l,info:r,...i}=n;return e.jsxs(t.Progress.Label,{...i,ref:s,children:[l,r&&e.jsx(Ne,{children:r})]})});const qe=t.Progress.Root,We=t.Progress.ValueText,U=()=>{const o=B(),n=(o==null?void 0:o.numberOfTotalPages)===1,s=((o==null?void 0:o.beginNumberOfPagesInSpineItem)??0)>1,l=((o==null?void 0:o.endNumberOfPagesInSpineItem)??0)>1,r=(o!=null&&o.hasChapters?o==null?void 0:o.beginPageIndexInSpineItem:o==null?void 0:o.beginAbsolutePageIndex)??0,i=(o!=null&&o.hasChapters?o==null?void 0:o.endPageIndexInSpineItem:o==null?void 0:o.endAbsolutePageIndex)??0,[d=0,h=0]=[r,i].sort((v,f)=>v-f),u=(o==null?void 0:o.beginPageIndexInSpineItem)!==(o==null?void 0:o.endPageIndexInSpineItem)||(o==null?void 0:o.beginSpineItemIndex)!==(o==null?void 0:o.endSpineItemIndex),c=o!=null&&o.hasChapters?o==null?void 0:o.beginNumberOfPagesInSpineItem:o==null?void 0:o.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:r,endPageIndex:i,isBeginWithinChapter:s,isEndWithinChapter:l,beginAndEndAreDifferent:u,totalApproximatePages:c,leftPageIndex:d,rightPageIndex:h}},Ve=()=>{const o=B(),{hasOnlyOnePage:n,leftPageIndex:s,rightPageIndex:l,totalApproximatePages:r,beginAndEndAreDifferent:i}=U(),d=Math.round(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),h=c=>c!=null&&c.subChapter?`${c.title} / ${h(c.subChapter)}`:(c==null?void 0:c.title)||"",u=h(o==null?void 0:o.beginChapterInfo);return e.jsxs(t.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[e.jsx(qe,{value:d,size:"xs",width:150,children:e.jsxs(t.HStack,{justifyContent:"space-between",children:[e.jsx(Fe,{width:110}),e.jsx(We,{children:`${d}%`})]})}),e.jsx(t.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:u?`Chapter: ${u}`:" "}),!n&&e.jsxs(t.HStack,{children:[e.jsx(t.Text,{fontSize:"xs",children:i?`${s+1} - ${l+1} of ${r}`:`${s+1} of ${r}`}),!!(o!=null&&o.hasChapters)&&e.jsxs(e.Fragment,{children:[e.jsx(t.Text,{children:"-"}),e.jsxs(t.Text,{fontSize:"xs",children:["(",((o==null?void 0:o.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},ee=a.memo(({children:o,position:n,...s})=>e.jsx(t.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...n==="bottom"?{bottom:0}:{top:0},animationName:n==="bottom"?{_open:"slide-from-bottom, fade-in",_closed:"slide-to-bottom, fade-out"}:{_open:"slide-from-top, fade-in",_closed:"slide-to-top, fade-out"},animationDuration:"moderate",bgColor:"bg.panel",alignItems:"center",justifyContent:"center",shadow:"md",p:4,...s,children:o})),Ge=t.chakra(le),Ue=a.memo(o=>e.jsx(t.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:e.jsx(Ge,{keyboard:!1,style:{padding:0},css:{"& > .rc-slider-handle:focus-visible":{boxShadow:"0 0 0 2px var(--color-solid) !important"},"& > .rc-slider-handle:active":{boxShadow:"0 0 5px var(--color-solid) !important"},"& > .rc-slider-handle.rc-slider-handle-dragging":{boxShadow:"0 0 0 3px var(--color-solid) !important"}},styles:{rail:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--bg-emphasized)"},track:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--color-solid)"},handle:{width:"24px",height:"24px",top:"50%",borderColor:"var(--color-solid)",transform:`translate(${o.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...o})})),Ye=()=>{const o=B(),n=o==null?void 0:o.isUsingSpread,{beginPageIndex:s,totalApproximatePages:l=0}=U(),r=n?Math.floor((s||0)/2):s,[i,d]=p.useSignalState(()=>p.signal({default:r||0})),h=0,u=Math.max(0,n?Math.floor((l-1)/2):l-1);return a.useEffect(()=>{d.update(r||0)},[r,d]),{value:i,valueSignal:d,min:h,max:u}},Ke=o=>{const n=k(),s=B(),{manifest:l}=p.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},r=(l==null?void 0:l.readingDirection)==="rtl",i=s==null?void 0:s.isUsingSpread,{totalApproximatePages:d=0,isBeginWithinChapter:h}=U(),u=1,c=h,{value:v,valueSignal:f,min:T,max:I}=Ye(),y=a.useCallback(P=>{const[S=0]=Array.isArray(P)?P:[P];f.setValue(S);const H=i?Math.floor(S)*2:Math.floor(S);c?n==null||n.navigation.goToPageOfSpineItem({pageIndex:H,spineItemId:n.pagination.state.beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:H,animation:!1})},[n,i,f,c]);return p.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:f.subject}),[n,f]),d===1||i&&d===2?e.jsx(t.Box,{style:o.style}):e.jsx(Ue,{value:[v],max:I,min:T,reverse:r,step:u,onChange:y,...o})},Qe=a.memo(({open:o,onItemClick:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.navigation.state$,[s]),r=p.useObserve(()=>s==null?void 0:s.settings.values$,[s]),i=(r==null?void 0:r.computedPageTurnDirection)==="vertical",[d,h]=a.useState(!0);return e.jsxs(ee,{present:o,position:"bottom",display:"flex",flexDirection:"column",overflow:"auto",pb:8,children:[e.jsxs(t.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[e.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>s==null?void 0:s.navigation.goToLeftOrTopSpineItem(),disabled:!(l!=null&&l.canGoLeftSpineItem)&&!(l!=null&&l.canGoTopSpineItem),children:i?e.jsx(N.RxDoubleArrowUp,{}):e.jsx(N.RxDoubleArrowLeft,{})}),e.jsxs(t.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"auto",px:4,children:[e.jsx(Ve,{}),e.jsx(Ke,{style:{width:"100%",maxWidth:"300px",height:"35px"}})]}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(l!=null&&l.canGoRightSpineItem)&&!(l!=null&&l.canGoBottomSpineItem),onClick:()=>{s==null||s.navigation.goToRightOrBottomSpineItem()},children:i?e.jsx(N.RxDoubleArrowDown,{}):e.jsx(N.RxDoubleArrowRight,{})})]}),e.jsx(t.HStack,{alignSelf:"stretch",alignItems:"center",justifyContent:"center",children:e.jsxs(t.Collapsible.Root,{open:d,flex:1,onOpenChange:({open:u})=>{h(u)},children:[e.jsx(t.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:e.jsx(C.LuChevronDown,{style:{transform:d?"rotate(0deg)":"rotate(180deg)"}})}),e.jsxs(t.Collapsible.Content,{display:"flex",justifyContent:"center",children:[e.jsx(t.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:()=>n("help"),children:e.jsx(C.LuCircleHelp,{})}),e.jsx(t.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:()=>n("toc"),children:e.jsx(C.LuTableOfContents,{})}),X(s)&&e.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("search"),children:e.jsx(C.LuSearch,{})}),$(s)&&e.jsx(t.IconButton,{"aria-label":"Bookmarks",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:e.jsx(F.BsBookmarks,{})}),$(s)&&e.jsx(t.IconButton,{"aria-label":"Annotations",size:"lg",variant:"ghost",onClick:()=>n("annotations"),children:e.jsx(C.LuNotebookPen,{})}),e.jsx(t.IconButton,{"aria-label":"Thumbnails",size:"lg",variant:(s==null?void 0:s.settings.values.viewportMode)==="thumbnails"?"solid":"ghost",onClick:()=>{s==null||s.settings.update({viewportMode:(s==null?void 0:s.settings.values.viewportMode)==="normal"?"thumbnails":"normal"})},children:e.jsx(C.LuGalleryHorizontal,{})}),Z(s)&&e.jsx(t.IconButton,{"aria-label":"Gallery",size:"lg",variant:"ghost",onClick:()=>n("gallery"),children:e.jsx(se.RiGalleryView2,{})})]})]})})]})}),Xe=()=>{const[o,n]=a.useState(!1),s=a.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{n(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{n(!0)}),[]);return a.useEffect(()=>{function l(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:o,onToggleFullscreenClick:s}},Ze=a.memo(({open:o,onItemClick:n})=>{const s=k(),l=p.useObserve(()=>s==null?void 0:s.context.manifest$,[s]),{isFullscreen:r,onToggleFullscreenClick:i}=Xe();return e.jsxs(ee,{present:o,position:"top",height:"80px",justifyContent:"space-between",children:[e.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>n("back"),children:e.jsx(Y.IoIosArrowBack,{})}),e.jsx(t.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:e.jsx(t.Text,{truncate:!0,maxWidth:"100%",children:l==null?void 0:l.title})}),e.jsxs(t.HStack,{children:[e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:()=>n("more"),children:e.jsx(Y.IoMdMore,{})}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:i,children:r?e.jsx(K.MdFullscreenExit,{}):e.jsx(K.MdFullscreen,{})})]})]})}),Je=a.memo(({onItemClick:o})=>{const[n]=G();return e.jsxs(e.Fragment,{children:[e.jsx(Ze,{open:n,onItemClick:o}),e.jsx(Qe,{open:n,onItemClick:o})]})}),je=a.memo(({contextText:o="",startOffset:n=0,text:s,cfi:l="#",onClick:r,absolutePageIndex:i})=>{const h=o.substring(Math.max(n-15,0),Math.max(n,0)),u=o.substring(Math.min(n+s.length,o.length-1),Math.min(n+s.length+15,o.length-1));return e.jsxs(t.Link,{href:l,style:{margin:5,overflow:"hidden"},onClick:c=>{c.preventDefault(),r(l)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[e.jsxs(t.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',h,e.jsx("b",{children:s}),u,'"']}),e.jsx(t.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${i!==void 0?i+1:"unknown (not loaded)"}`})]})}),Re=a.memo(({onNavigate:o})=>{const[n,s]=a.useState(""),l=k(),r=X(l)?l:void 0,i=f=>{s(f.target.value)},d=a.useCallback(f=>{o(),l==null||l.navigation.goToCfi(f)},[l,o]),h=p.useObserve(()=>r==null?void 0:r.search.search(n).pipe(g.map(f=>({type:"end",data:f})),g.startWith({type:"start"})),[l,n]),u=(h==null?void 0:h.type)==="start",c=(h==null?void 0:h.type)==="end"?h.data:[],v=p.useObserve(()=>l==null?void 0:l.locateResource(c.slice(0,100)),[c]);return e.jsxs(t.Stack,{flex:1,height:"100%",children:[e.jsx(t.Box,{px:4,children:e.jsx(t.Input,{placeholder:"Type something...",value:n,onChange:i,borderRadius:0})}),e.jsxs(t.Box,{px:4,pb:4,mt:2,flex:1,style:{overflow:"hidden",overflowY:"auto"},children:[u&&e.jsx(t.Text,{children:"Searching ..."}),!u&&c.length===0&&e.jsx("p",{children:"There are no results"}),!u&&c.length>=0&&e.jsxs(t.Stack,{children:[e.jsxs(t.Heading,{as:"h2",size:"md",children:[c.length," result(s)"]}),e.jsx(t.Stack,{gap:0,children:v==null?void 0:v.map((f,T)=>{var I,y,x,P,S,H,oe;return e.jsx(je,{contextText:((x=(y=(I=f.meta)==null?void 0:I.range)==null?void 0:y.startContainer.parentElement)==null?void 0:x.textContent)??"",pageIndex:(P=f.meta)==null?void 0:P.itemPageIndex,startOffset:((H=(S=f.meta)==null?void 0:S.range)==null?void 0:H.startOffset)??0,text:n,cfi:f.meta.cfi,onClick:d,absolutePageIndex:(oe=f.meta)==null?void 0:oe.absolutePageIndex},T)})})]})]})]})}),eo=a.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{height:"100%",children:[e.jsx(E,{children:e.jsx(L,{children:"Search"})}),e.jsx(z,{flex:1,children:e.jsx(Re,{onNavigate:s})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),oo=a.memo(({onNavigate:o})=>{const n=k(),{manifest:s,assumedRenditionLayout:l}=p.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:r}=s??{},i=B();r!=null&&r.toc;const{beginSpineItemIndex:d,beginPageIndexInSpineItem:h}=i??{},u=(l==="reflowable"?h:d)||0;let c=i==null?void 0:i.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const v=(f,T,I)=>e.jsxs(a.Fragment,{children:[e.jsx(t.List.Item,{pl:4*(I+1),style:{display:"flex",alignItems:"center"},children:e.jsxs(t.Link,{onClick:()=>{o(),n==null||n.navigation.goToUrl(f.href)},href:"#",children:[(c==null?void 0:c.path)===f.path&&e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(C.LuCircleCheck,{})}),(c==null?void 0:c.path)!==f.path&&e.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(C.LuCircleCheck,{})}),e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{fontSize:"md",children:f.title||f.path}),(c==null?void 0:c.path)===f.path&&e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${u+1}`})]})]})}),f.contents.length>0&&e.jsx(t.List.Root,{as:"div",gap:2,children:f.contents.map((y,x)=>v(y,x,I+1))})]},T);return e.jsx(t.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:r==null?void 0:r.toc.map((f,T)=>v(f,T,0))})}),no=a.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(D,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(O,{children:[e.jsx(E,{children:e.jsx(L,{children:"Table of Contents"})}),e.jsx(z,{overflowY:"auto",flex:1,children:e.jsx(oo,{onNavigate:s})}),e.jsx(A,{children:e.jsx(M,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(m,{})]})})),so=({enableFloatingTime:o=!0,enableFloatingProgress:n=!0,onItemClick:s})=>{const[l,r]=a.useState(!1),[i,d]=a.useState(!1),[h,u]=a.useState(!1),[c,v]=a.useState(void 0),[f,T]=a.useState(!1),[I,y]=G(),x=a.useCallback(()=>{r(!1),d(!1),u(!1),v(void 0),y(!1),T(!1)},[y]),P=a.useCallback(S=>{S==="annotations"?v("annotations"):S==="search"?u(!0):S==="help"?d(!0):S==="toc"?r(!0):S==="bookmarks"?v("bookmarks"):S==="gallery"&&T(!0),s==null||s(S)},[s]);return Le(),$e(),e.jsxs(e.Fragment,{children:[n&&e.jsx(t.Presence,{present:!I,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(De,{})}),e.jsx(we,{open:f,setOpen:T}),e.jsx(Je,{onItemClick:P}),e.jsx(Ce,{}),e.jsx(me,{open:i,setOpen:d}),e.jsx(no,{open:l,setOpen:r,onNavigate:x}),e.jsx(eo,{open:h,setOpen:u,onNavigate:x}),e.jsx(fe,{openWith:c,setOpen:S=>v(S?"annotations":void 0),onNavigate:x}),e.jsx(t.Presence,{present:o||I,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:e.jsx(ze,{})}),e.jsx(Te,{})]})};b.BOOKMARK_AREA_DATA_ATTRIBUTE=j,b.ReactReader=so,b.ReactReaderProvider=ie,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.cjs.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prose-reader/react-reader",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.228.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"optional": true
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "f38af897428bb229420eab2bfa2e396d2a13e807"
|
|
54
54
|
}
|