@prose-reader/react-reader 1.181.0 → 1.185.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 CHANGED
@@ -2,8 +2,8 @@ import { jsx as t, jsxs as a, Fragment as E } from "react/jsx-runtime";
2
2
  import * as C from "react";
3
3
  import ie, { createContext as le, memo as b, useMemo as se, useEffect as B, useContext as _, useState as R, useCallback as q } from "react";
4
4
  import { signal as ce, useSignal as U, useLiveRef as ae, useSubscribe as Y, useObserve as v, useSignalValue as de } from "reactjrx";
5
- import { tap as ue, NEVER as he, combineLatest as ge, map as fe } from "rxjs";
6
- import { Box as z, Text as f, Popover as I, Portal as Q, IconButton as p, Progress as O, Stack as y, HStack as x, Presence as L, chakra as me, Collapsible as M, Dialog as g, Heading as j, Kbd as N, Button as G, List as w, Link as pe } from "@chakra-ui/react";
5
+ import { tap as ue, NEVER as he, combineLatest as ge, map as me } from "rxjs";
6
+ import { Box as z, Text as m, Popover as I, Portal as Q, IconButton as p, Progress as O, Stack as y, HStack as x, Presence as L, chakra as fe, Collapsible as M, Dialog as g, Heading as j, Kbd as N, Button as G, List as w, Link as pe } from "@chakra-ui/react";
7
7
  import { LuChevronDown as be, LuCircleHelp as xe, LuTableOfContents as Ce, LuX as Ie, LuArrowBigRight as ve, LuArrowBigLeft as Pe, LuCircleCheck as V } from "react-icons/lu";
8
8
  import { RxDoubleArrowUp as Se, RxDoubleArrowLeft as Te, RxDoubleArrowDown as ke, RxDoubleArrowRight as we } from "react-icons/rx";
9
9
  import { HiOutlineInformationCircle as Re } from "react-icons/hi";
@@ -14,7 +14,7 @@ import { MdFullscreenExit as Ae, MdFullscreen as Be } from "react-icons/md";
14
14
  const F = le({
15
15
  reader: void 0,
16
16
  quickMenuSignal: ce({ default: !1 })
17
- }), mt = b(
17
+ }), ft = b(
18
18
  ({
19
19
  children: e,
20
20
  reader: n,
@@ -44,7 +44,7 @@ const F = le({
44
44
  const e = D();
45
45
  return v(
46
46
  () => e ? ge([e.pagination.state$, e.context.state$]).pipe(
47
- fe(([n, r]) => {
47
+ me(([n, r]) => {
48
48
  var o;
49
49
  const i = (o = r.manifest) == null ? void 0 : o.spineItems.every(
50
50
  (l) => {
@@ -64,7 +64,7 @@ const F = le({
64
64
  const e = P(), n = Math.floor(
65
65
  ((e == null ? void 0 : e.percentageEstimateOfBook) ?? 0) * 100
66
66
  ), r = n > 0 ? n : 1;
67
- return (e == null ? void 0 : e.percentageEstimateOfBook) === void 0 ? null : /* @__PURE__ */ t(z, { position: "absolute", right: 0, bottom: 0, p: 2, color: "black", children: /* @__PURE__ */ a(f, { fontSize: "sm", children: [
67
+ return (e == null ? void 0 : e.percentageEstimateOfBook) === void 0 ? null : /* @__PURE__ */ t(z, { position: "absolute", right: 0, bottom: 0, p: 2, color: "black", children: /* @__PURE__ */ a(m, { fontSize: "sm", children: [
68
68
  r,
69
69
  " %"
70
70
  ] }) });
@@ -78,7 +78,7 @@ const F = le({
78
78
  }, []), e;
79
79
  }, Le = (e) => {
80
80
  const n = Me();
81
- return /* @__PURE__ */ t(f, { fontSize: "xs", ...e, children: n.toLocaleTimeString(navigator.language, {
81
+ return /* @__PURE__ */ t(m, { fontSize: "xs", ...e, children: n.toLocaleTimeString(navigator.language, {
82
82
  hour: "2-digit",
83
83
  minute: "2-digit"
84
84
  }) });
@@ -160,7 +160,7 @@ const We = O.Root, je = O.ValueText, H = () => {
160
160
  const e = P(), n = (e == null ? void 0 : e.numberOfTotalPages) === 1, r = ((e == null ? void 0 : e.beginNumberOfPagesInSpineItem) ?? 0) > 1, i = ((e == null ? void 0 : e.endNumberOfPagesInSpineItem) ?? 0) > 1, o = (e != null && e.hasChapters ? e == null ? void 0 : e.beginPageIndexInSpineItem : e == null ? void 0 : e.beginAbsolutePageIndex) ?? 0, l = (e != null && e.hasChapters ? e == null ? void 0 : e.endPageIndexInSpineItem : e == null ? void 0 : e.endAbsolutePageIndex) ?? 0, [c = 0, d = 0] = [
161
161
  o,
162
162
  l
163
- ].sort((m, h) => m - h), u = (e == null ? void 0 : e.beginPageIndexInSpineItem) !== (e == null ? void 0 : e.endPageIndexInSpineItem) || (e == null ? void 0 : e.beginSpineItemIndex) !== (e == null ? void 0 : e.endSpineItemIndex), s = e != null && e.hasChapters ? e == null ? void 0 : e.beginNumberOfPagesInSpineItem : e == null ? void 0 : e.numberOfTotalPages;
163
+ ].sort((f, h) => f - h), u = (e == null ? void 0 : e.beginPageIndexInSpineItem) !== (e == null ? void 0 : e.endPageIndexInSpineItem) || (e == null ? void 0 : e.beginSpineItemIndex) !== (e == null ? void 0 : e.endSpineItemIndex), s = e != null && e.hasChapters ? e == null ? void 0 : e.beginNumberOfPagesInSpineItem : e == null ? void 0 : e.numberOfTotalPages;
164
164
  return {
165
165
  hasOnlyOnePage: n,
166
166
  beginPageIndex: o,
@@ -185,12 +185,12 @@ const We = O.Root, je = O.ValueText, H = () => {
185
185
  /* @__PURE__ */ t(He, { width: 110 }),
186
186
  /* @__PURE__ */ t(je, { children: `${c}%` })
187
187
  ] }) }),
188
- /* @__PURE__ */ t(f, { truncate: !0, maxWidth: "100%", fontSize: "sm", mt: 1, children: u ? `Chapter: ${u}` : " " }),
188
+ /* @__PURE__ */ t(m, { truncate: !0, maxWidth: "100%", fontSize: "sm", mt: 1, children: u ? `Chapter: ${u}` : " " }),
189
189
  !n && /* @__PURE__ */ a(x, { children: [
190
- /* @__PURE__ */ t(f, { fontSize: "xs", children: l ? `${r + 1} - ${i + 1} of ${o}` : `${r + 1} of ${o}` }),
190
+ /* @__PURE__ */ t(m, { fontSize: "xs", children: l ? `${r + 1} - ${i + 1} of ${o}` : `${r + 1} of ${o}` }),
191
191
  !!(e != null && e.hasChapters) && /* @__PURE__ */ a(E, { children: [
192
- /* @__PURE__ */ t(f, { children: "-" }),
193
- /* @__PURE__ */ a(f, { fontSize: "xs", children: [
192
+ /* @__PURE__ */ t(m, { children: "-" }),
193
+ /* @__PURE__ */ a(m, { fontSize: "xs", children: [
194
194
  "(",
195
195
  ((e == null ? void 0 : e.beginAbsolutePageIndex) ?? 0) + 1,
196
196
  ")"
@@ -228,7 +228,7 @@ const We = O.Root, je = O.ValueText, H = () => {
228
228
  children: e
229
229
  }
230
230
  )
231
- ), Ve = me(Oe), _e = b((e) => /* @__PURE__ */ t(
231
+ ), Ve = fe(Oe), _e = b((e) => /* @__PURE__ */ t(
232
232
  z,
233
233
  {
234
234
  display: "contents",
@@ -298,10 +298,10 @@ const We = O.Root, je = O.ValueText, H = () => {
298
298
  max: u
299
299
  };
300
300
  }, Ue = () => {
301
- const e = D(), n = P(), { manifest: r } = v(() => e == null ? void 0 : e.context.state$, []) ?? {}, i = (r == null ? void 0 : r.readingDirection) === "rtl", o = n == null ? void 0 : n.isUsingSpread, { totalApproximatePages: l = 0, isBeginWithinChapter: c } = H(), d = 1, u = c, { value: s, valueSignal: m, min: h, max: S } = qe(), A = q(
301
+ const e = D(), n = P(), { manifest: r } = v(() => e == null ? void 0 : e.context.state$, []) ?? {}, i = (r == null ? void 0 : r.readingDirection) === "rtl", o = n == null ? void 0 : n.isUsingSpread, { totalApproximatePages: l = 0, isBeginWithinChapter: c } = H(), d = 1, u = c, { value: s, valueSignal: f, min: h, max: S } = qe(), A = q(
302
302
  (T) => {
303
303
  const [k = 0] = Array.isArray(T) ? T : [T];
304
- m.setValue(k);
304
+ f.setValue(k);
305
305
  const W = o ? Math.floor(k) * 2 : Math.floor(k);
306
306
  u ? e == null || e.navigation.goToPageOfSpineItem({
307
307
  pageIndex: W,
@@ -312,14 +312,14 @@ const We = O.Root, je = O.ValueText, H = () => {
312
312
  animation: !1
313
313
  });
314
314
  },
315
- [e, o, m, u]
315
+ [e, o, f, u]
316
316
  );
317
317
  return Y(
318
318
  () => e == null ? void 0 : e.navigation.throttleLock({
319
319
  duration: 100,
320
- trigger: m.subject
320
+ trigger: f.subject
321
321
  }),
322
- [e, m]
322
+ [e, f]
323
323
  ), l === 1 || o && l === 2 ? null : /* @__PURE__ */ t(
324
324
  _e,
325
325
  {
@@ -514,7 +514,7 @@ const We = O.Root, je = O.ValueText, H = () => {
514
514
  alignItems: "center",
515
515
  overflow: "auto",
516
516
  px: 4,
517
- children: /* @__PURE__ */ t(f, { truncate: !0, maxWidth: "100%", children: o == null ? void 0 : o.title })
517
+ children: /* @__PURE__ */ t(m, { truncate: !0, maxWidth: "100%", children: o == null ? void 0 : o.title })
518
518
  }
519
519
  ),
520
520
  /* @__PURE__ */ a(x, { children: [
@@ -571,7 +571,7 @@ const We = O.Root, je = O.ValueText, H = () => {
571
571
  )
572
572
  ] });
573
573
  }
574
- ), Xe = "@prose-reader/react-reader", Je = "1.180.0", Ze = C.forwardRef(function(n, r) {
574
+ ), Xe = "@prose-reader/react-reader", Je = "1.184.0", Ze = C.forwardRef(function(n, r) {
575
575
  return /* @__PURE__ */ t(p, { variant: "ghost", "aria-label": "Close", ref: r, ...n, children: n.children ?? /* @__PURE__ */ t(Ie, {}) });
576
576
  }), X = C.forwardRef(function(n, r) {
577
577
  const {
@@ -622,15 +622,15 @@ const re = g.ActionTrigger, et = b(
622
622
  /* @__PURE__ */ a(x, { mb: 1, children: [
623
623
  /* @__PURE__ */ t(N, { children: /* @__PURE__ */ t(ve, {}) }),
624
624
  " ",
625
- /* @__PURE__ */ t(f, { children: "Navigate to right page" })
625
+ /* @__PURE__ */ t(m, { children: "Navigate to right page" })
626
626
  ] }),
627
627
  /* @__PURE__ */ a(x, { mb: 1, children: [
628
628
  /* @__PURE__ */ t(N, { children: /* @__PURE__ */ t(Pe, {}) }),
629
629
  " ",
630
- /* @__PURE__ */ t(f, { children: "Navigate to left page" })
630
+ /* @__PURE__ */ t(m, { children: "Navigate to left page" })
631
631
  ] }),
632
632
  /* @__PURE__ */ t(j, { mb: 2, mt: 4, as: "h3", size: "lg", children: "About" }),
633
- /* @__PURE__ */ a(f, { children: [
633
+ /* @__PURE__ */ a(m, { children: [
634
634
  Xe,
635
635
  " version: ",
636
636
  Je
@@ -652,7 +652,7 @@ const re = g.ActionTrigger, et = b(
652
652
  let s = l == null ? void 0 : l.beginChapterInfo;
653
653
  for (; s != null && s.subChapter; )
654
654
  s = s == null ? void 0 : s.subChapter;
655
- const m = (h, S, A) => /* @__PURE__ */ a(ie.Fragment, { children: [
655
+ const f = (h, S, A) => /* @__PURE__ */ a(ie.Fragment, { children: [
656
656
  /* @__PURE__ */ t(
657
657
  w.Item,
658
658
  {
@@ -672,9 +672,9 @@ const re = g.ActionTrigger, et = b(
672
672
  (s == null ? void 0 : s.path) === h.path && /* @__PURE__ */ t(w.Indicator, { asChild: !0, children: /* @__PURE__ */ t(V, {}) }),
673
673
  (s == null ? void 0 : s.path) !== h.path && /* @__PURE__ */ t(w.Indicator, { asChild: !0, visibility: "hidden", children: /* @__PURE__ */ t(V, {}) }),
674
674
  /* @__PURE__ */ a(y, { gap: 0, children: [
675
- /* @__PURE__ */ t(f, { fontSize: "md", children: h.title || h.path }),
675
+ /* @__PURE__ */ t(m, { fontSize: "md", children: h.title || h.path }),
676
676
  (s == null ? void 0 : s.path) === h.path && /* @__PURE__ */ t(
677
- f,
677
+ m,
678
678
  {
679
679
  fontStyle: "italic",
680
680
  fontWeight: "bold",
@@ -689,10 +689,10 @@ const re = g.ActionTrigger, et = b(
689
689
  }
690
690
  ),
691
691
  h.contents.length > 0 && /* @__PURE__ */ t(w.Root, { as: "div", gap: 2, children: h.contents.map(
692
- (T, k) => m(T, k, A + 1)
692
+ (T, k) => f(T, k, A + 1)
693
693
  ) })
694
694
  ] }, S);
695
- return /* @__PURE__ */ t(w.Root, { gap: 3, overflowY: "auto", py: 4, flex: 1, children: o == null ? void 0 : o.toc.map((h, S) => m(h, S, 0)) });
695
+ return /* @__PURE__ */ t(w.Root, { gap: 3, overflowY: "auto", py: 4, flex: 1, children: o == null ? void 0 : o.toc.map((h, S) => f(h, S, 0)) });
696
696
  }
697
697
  ), nt = b(
698
698
  ({
@@ -765,6 +765,6 @@ const re = g.ActionTrigger, et = b(
765
765
  };
766
766
  export {
767
767
  pt as ReactReader,
768
- mt as ReactReaderProvider
768
+ ft as ReactReaderProvider
769
769
  };
770
770
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- (function(f,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),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-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],o):(f=typeof globalThis<"u"?globalThis:f||self,o(f["prose-react-reader"]={},f.jsxRuntime,f.React,f.reactjrx,f.rxjs,f.react,f.lu,f.rx,f.hi,f.RcSlider,null,f.io,f.md))})(this,function(f,o,a,p,k,n,x,w,_,V,xe,m,L){"use strict";function j(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(s,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return s.default=e,Object.freeze(s)}const C=j(a),D=a.createContext({reader:void 0,quickMenuSignal:p.signal({default:!1})}),U=a.memo(({children:e,reader:s,quickMenuOpen:r,onQuickMenuOpenChange:l})=>{const[,t]=p.useSignal({default:r}),i=p.useLiveRef(l),d=a.useMemo(()=>({quickMenuSignal:t,reader:s}),[t,s]);return a.useEffect(()=>{t.setValue(r)},[r,t]),p.useSubscribe(()=>t.subject.pipe(k.tap(i.current)),[t,i]),o.jsx(D.Provider,{value:d,children:e})}),I=()=>{const{reader:e}=a.useContext(D);return e},v=()=>{const e=I();return p.useObserve(()=>e?k.combineLatest([e.pagination.state$,e.context.state$]).pipe(k.map(([s,r])=>{var t;const l=(t=r.manifest)==null?void 0:t.spineItems.every(i=>{var d;return(d=i.mediaType)==null?void 0:d.startsWith("image/")});return{...s,hasChapters:!r.isFullyPrePaginated&&!l}})):k.NEVER,[e])},Y=()=>{const e=v(),s=Math.floor(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),r=s>0?s:1;return(e==null?void 0:e.percentageEstimateOfBook)===void 0?null:o.jsx(n.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:o.jsxs(n.Text,{fontSize:"sm",children:[r," %"]})})},Q=()=>{const[e,s]=a.useState(new Date);return a.useEffect(()=>{const r=setInterval(()=>{s(new Date)},6e4);return()=>clearInterval(r)},[]),e},G=e=>{const s=Q();return o.jsx(n.Text,{fontSize:"xs",...e,children:s.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},y=()=>{const{quickMenuSignal:e}=a.useContext(D);return[p.useSignalValue(e),e.setValue,e]},K=()=>{const[e]=y();return o.jsx(n.Box,{position:"absolute",left:0,bottom:0,p:2,color:e?void 0:"colorPalette.contrast",children:o.jsx(G,{})})},X=C.forwardRef(function(s,r){const{showArrow:l,children:t,portalled:i=!0,content:d,portalRef:h,...g}=s;return o.jsxs(n.Popover.Root,{...g,positioning:{...g.positioning,gutter:4},children:[o.jsx(n.Popover.Trigger,{asChild:!0,children:t}),o.jsx(n.Portal,{disabled:!i,container:h,children:o.jsx(n.Popover.Positioner,{children:o.jsxs(n.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:r,children:[l&&o.jsx(n.Popover.Arrow,{children:o.jsx(n.Popover.ArrowTip,{})}),d]})})})]})}),J=C.forwardRef(function(s,r){const{children:l,...t}=s;return o.jsx(X,{content:l,...t,ref:r,children:o.jsx(n.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:o.jsx(_.HiOutlineInformationCircle,{})})})}),Z=C.forwardRef(function(s,r){return o.jsx(n.Progress.Track,{...s,ref:r,children:o.jsx(n.Progress.Range,{})})});C.forwardRef(function(s,r){const{children:l,info:t,...i}=s;return o.jsxs(n.Progress.Label,{...i,ref:r,children:[l,t&&o.jsx(J,{children:t})]})});const R=n.Progress.Root,ee=n.Progress.ValueText,B=()=>{const e=v(),s=(e==null?void 0:e.numberOfTotalPages)===1,r=((e==null?void 0:e.beginNumberOfPagesInSpineItem)??0)>1,l=((e==null?void 0:e.endNumberOfPagesInSpineItem)??0)>1,t=(e!=null&&e.hasChapters?e==null?void 0:e.beginPageIndexInSpineItem:e==null?void 0:e.beginAbsolutePageIndex)??0,i=(e!=null&&e.hasChapters?e==null?void 0:e.endPageIndexInSpineItem:e==null?void 0:e.endAbsolutePageIndex)??0,[d=0,h=0]=[t,i].sort((b,u)=>b-u),g=(e==null?void 0:e.beginPageIndexInSpineItem)!==(e==null?void 0:e.endPageIndexInSpineItem)||(e==null?void 0:e.beginSpineItemIndex)!==(e==null?void 0:e.endSpineItemIndex),c=e!=null&&e.hasChapters?e==null?void 0:e.beginNumberOfPagesInSpineItem:e==null?void 0:e.numberOfTotalPages;return{hasOnlyOnePage:s,beginPageIndex:t,endPageIndex:i,isBeginWithinChapter:r,isEndWithinChapter:l,beginAndEndAreDifferent:g,totalApproximatePages:c,leftPageIndex:d,rightPageIndex:h}},oe=()=>{const e=v(),{hasOnlyOnePage:s,leftPageIndex:r,rightPageIndex:l,totalApproximatePages:t,beginAndEndAreDifferent:i}=B(),d=Math.round(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),h=c=>c!=null&&c.subChapter?`${c.title} / ${h(c.subChapter)}`:(c==null?void 0:c.title)||"",g=h(e==null?void 0:e.beginChapterInfo);return o.jsxs(n.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[o.jsx(R,{value:d,size:"xs",width:150,children:o.jsxs(n.HStack,{justifyContent:"space-between",children:[o.jsx(Z,{width:110}),o.jsx(ee,{children:`${d}%`})]})}),o.jsx(n.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:g?`Chapter: ${g}`:" "}),!s&&o.jsxs(n.HStack,{children:[o.jsx(n.Text,{fontSize:"xs",children:i?`${r+1} - ${l+1} of ${t}`:`${r+1} of ${t}`}),!!(e!=null&&e.hasChapters)&&o.jsxs(o.Fragment,{children:[o.jsx(n.Text,{children:"-"}),o.jsxs(n.Text,{fontSize:"xs",children:["(",((e==null?void 0:e.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},z=a.memo(({children:e,position:s,...r})=>o.jsx(n.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...s==="bottom"?{bottom:0}:{top:0},animationName:s==="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,...r,children:e})),ne=n.chakra(V),se=a.memo(e=>o.jsx(n.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:o.jsx(ne,{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(${e.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...e})})),te=()=>{const e=v(),s=e==null?void 0:e.isUsingSpread,{beginPageIndex:r,totalApproximatePages:l=0}=B(),t=s?Math.floor((r||0)/2):r,[i,d]=p.useSignal({default:t||0}),h=0,g=Math.max(0,s?Math.floor((l-1)/2):l-1);return a.useEffect(()=>{d.setValue(t||0)},[t,d]),{value:i,valueSignal:d,min:h,max:g}},re=()=>{const e=I(),s=v(),{manifest:r}=p.useObserve(()=>e==null?void 0:e.context.state$,[])??{},l=(r==null?void 0:r.readingDirection)==="rtl",t=s==null?void 0:s.isUsingSpread,{totalApproximatePages:i=0,isBeginWithinChapter:d}=B(),h=1,g=d,{value:c,valueSignal:b,min:u,max:S}=te(),O=a.useCallback(P=>{const[T=0]=Array.isArray(P)?P:[P];b.setValue(T);const W=t?Math.floor(T)*2:Math.floor(T);g?e==null||e.navigation.goToPageOfSpineItem({pageIndex:W,spineItemId:e.pagination.getState().beginSpineItemIndex??0,animation:!1}):e==null||e.navigation.goToAbsolutePageIndex({absolutePageIndex:W,animation:!1})},[e,t,b,g]);return p.useSubscribe(()=>e==null?void 0:e.navigation.throttleLock({duration:100,trigger:b.subject}),[e,b]),i===1||t&&i===2?null:o.jsx(se,{value:[c],max:S,min:u,reverse:l,step:h,onChange:O})},le=a.memo(({open:e,onTableOfContentsClick:s,onHelpClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.navigation.state$,[l]),i=p.useObserve(()=>l==null?void 0:l.settings.values$,[l]),d=(i==null?void 0:i.computedPageTurnDirection)==="vertical",[h,g]=a.useState(!0);return o.jsx(z,{present:e,position:"bottom",children:o.jsxs(n.Stack,{flex:1,children:[o.jsxs(n.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>l==null?void 0:l.navigation.goToLeftOrTopSpineItem(),disabled:!(t!=null&&t.canGoLeftSpineItem)&&!(t!=null&&t.canGoTopSpineItem),children:d?o.jsx(w.RxDoubleArrowUp,{}):o.jsx(w.RxDoubleArrowLeft,{})}),o.jsxs(n.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"visible",px:4,children:[o.jsx(oe,{}),o.jsx(n.Box,{height:5,maxW:300,width:"100%",overflow:"visible",children:o.jsx(re,{})})]}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(t!=null&&t.canGoRightSpineItem)&&!(t!=null&&t.canGoBottomSpineItem),onClick:()=>{l==null||l.navigation.goToRightOrBottomSpineItem()},children:d?o.jsx(w.RxDoubleArrowDown,{}):o.jsx(w.RxDoubleArrowRight,{})})]}),o.jsx(n.HStack,{alignItems:"center",justifyContent:"center",children:o.jsxs(n.Collapsible.Root,{open:h,flex:1,onOpenChange:({open:c})=>{g(c)},children:[o.jsx(n.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:o.jsx(x.LuChevronDown,{style:{transform:h?"rotate(0deg)":"rotate(180deg)"}})}),o.jsxs(n.Collapsible.Content,{display:"flex",justifyContent:"center",gap:2,children:[o.jsx(n.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:r,children:o.jsx(x.LuCircleHelp,{})}),o.jsx(n.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:s,children:o.jsx(x.LuTableOfContents,{})})]})]})})]})})}),ie=()=>{const[e,s]=a.useState(!1),r=a.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{s(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{s(!0)}),[]);return a.useEffect(()=>{function l(){s(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:e,onToggleFullscreenClick:r}},ce=({open:e,onBackClick:s,onMoreClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.context.manifest$,[l]),{isFullscreen:i,onToggleFullscreenClick:d}=ie();return o.jsxs(z,{present:e,position:"top",height:"80px",justifyContent:"space-between",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:s,children:o.jsx(m.IoIosArrowBack,{})}),o.jsx(n.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:o.jsx(n.Text,{truncate:!0,maxWidth:"100%",children:t==null?void 0:t.title})}),o.jsxs(n.HStack,{children:[o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:r,children:o.jsx(m.IoMdMore,{})}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:d,children:i?o.jsx(L.MdFullscreenExit,{}):o.jsx(L.MdFullscreen,{})})]})]})},de=a.memo(({onBackClick:e,onMoreClick:s,onTableOfContentsClick:r,onHelpClick:l})=>{const[t]=y();return o.jsxs(o.Fragment,{children:[o.jsx(ce,{open:t,onBackClick:e,onMoreClick:s}),o.jsx(le,{open:t,onTableOfContentsClick:r,onHelpClick:l})]})}),ae="@prose-reader/react-reader",he="1.180.0",ge=C.forwardRef(function(s,r){return o.jsx(n.IconButton,{variant:"ghost","aria-label":"Close",ref:r,...s,children:s.children??o.jsx(x.LuX,{})})}),A=C.forwardRef(function(s,r){const{children:l,portalled:t=!0,portalRef:i,backdrop:d=!0,...h}=s;return o.jsxs(n.Portal,{disabled:!t,container:i,children:[d&&o.jsx(n.Dialog.Backdrop,{}),o.jsx(n.Dialog.Positioner,{children:o.jsx(n.Dialog.Content,{ref:r,...h,asChild:!1,children:l})})]})}),M=C.forwardRef(function(s,r){return o.jsx(n.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...s,asChild:!0,children:o.jsx(ge,{size:"sm",ref:r,children:s.children})})}),E=n.Dialog.Root,F=n.Dialog.Footer,H=n.Dialog.Header,q=n.Dialog.Body;n.Dialog.Backdrop;const $=n.Dialog.Title;n.Dialog.Description,n.Dialog.Trigger;const N=n.Dialog.ActionTrigger,fe=a.memo(({open:e,setOpen:s})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>s(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Help"})}),o.jsxs(q,{overflowY:"auto",flex:1,children:[o.jsx(n.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigRight,{})})," ",o.jsx(n.Text,{children:"Navigate to right page"})]}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigLeft,{})})," ",o.jsx(n.Text,{children:"Navigate to left page"})]}),o.jsx(n.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),o.jsxs(n.Text,{children:[ae," version: ",he]})]}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),ue=a.memo(({onNavigate:e})=>{const s=I(),{manifest:r,assumedRenditionLayout:l}=p.useObserve(()=>s==null?void 0:s.context.state$,[s])??{},{nav:t}=r??{},i=v();t!=null&&t.toc;const{beginSpineItemIndex:d,beginPageIndexInSpineItem:h}=i??{},g=(l==="reflowable"?h:d)||0;console.log({assumedRenditionLayout:l,currentSpineItemOrChapterPageIndex:g});let c=i==null?void 0:i.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const b=(u,S,O)=>o.jsxs(a.Fragment,{children:[o.jsx(n.List.Item,{pl:4*(O+1),style:{display:"flex",alignItems:"center"},children:o.jsxs(n.Link,{onClick:()=>{e(),s==null||s.navigation.goToUrl(u.href)},href:"#",children:[(c==null?void 0:c.path)===u.path&&o.jsx(n.List.Indicator,{asChild:!0,children:o.jsx(x.LuCircleCheck,{})}),(c==null?void 0:c.path)!==u.path&&o.jsx(n.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(x.LuCircleCheck,{})}),o.jsxs(n.Stack,{gap:0,children:[o.jsx(n.Text,{fontSize:"md",children:u.title||u.path}),(c==null?void 0:c.path)===u.path&&o.jsx(n.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${g+1}`})]})]})}),u.contents.length>0&&o.jsx(n.List.Root,{as:"div",gap:2,children:u.contents.map((P,T)=>b(P,T,O+1))})]},S);return o.jsx(n.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:t==null?void 0:t.toc.map((u,S)=>b(u,S,0))})}),pe=a.memo(({open:e,setOpen:s,onNavigate:r})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:l=>s(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Table of Contents"})}),o.jsx(q,{overflowY:"auto",flex:1,children:o.jsx(ue,{onNavigate:r})}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),be=({enableFloatingTime:e=!0,enableFloatingProgress:s=!0,...r})=>{const[l,t]=a.useState(!1),[i,d]=a.useState(!1),[h,g]=y();return o.jsxs(o.Fragment,{children:[s&&o.jsx(n.Presence,{present:!h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(Y,{})}),o.jsx(de,{...r,onTableOfContentsClick:()=>t(!0),onHelpClick:()=>d(!0)}),o.jsx(fe,{open:i,setOpen:d}),o.jsx(pe,{open:l,setOpen:t,onNavigate:()=>{t(!1),g(!1)}}),o.jsx(n.Presence,{present:e||h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:o.jsx(K,{})})]})};f.ReactReader=be,f.ReactReaderProvider=U,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
1
+ (function(f,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),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-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],o):(f=typeof globalThis<"u"?globalThis:f||self,o(f["prose-react-reader"]={},f.jsxRuntime,f.React,f.reactjrx,f.rxjs,f.react,f.lu,f.rx,f.hi,f.RcSlider,null,f.io,f.md))})(this,function(f,o,d,p,k,n,x,w,_,V,xe,m,L){"use strict";function j(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(s,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return s.default=e,Object.freeze(s)}const C=j(d),D=d.createContext({reader:void 0,quickMenuSignal:p.signal({default:!1})}),U=d.memo(({children:e,reader:s,quickMenuOpen:r,onQuickMenuOpenChange:l})=>{const[,t]=p.useSignal({default:r}),i=p.useLiveRef(l),a=d.useMemo(()=>({quickMenuSignal:t,reader:s}),[t,s]);return d.useEffect(()=>{t.setValue(r)},[r,t]),p.useSubscribe(()=>t.subject.pipe(k.tap(i.current)),[t,i]),o.jsx(D.Provider,{value:a,children:e})}),I=()=>{const{reader:e}=d.useContext(D);return e},v=()=>{const e=I();return p.useObserve(()=>e?k.combineLatest([e.pagination.state$,e.context.state$]).pipe(k.map(([s,r])=>{var t;const l=(t=r.manifest)==null?void 0:t.spineItems.every(i=>{var a;return(a=i.mediaType)==null?void 0:a.startsWith("image/")});return{...s,hasChapters:!r.isFullyPrePaginated&&!l}})):k.NEVER,[e])},Y=()=>{const e=v(),s=Math.floor(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),r=s>0?s:1;return(e==null?void 0:e.percentageEstimateOfBook)===void 0?null:o.jsx(n.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:o.jsxs(n.Text,{fontSize:"sm",children:[r," %"]})})},Q=()=>{const[e,s]=d.useState(new Date);return d.useEffect(()=>{const r=setInterval(()=>{s(new Date)},6e4);return()=>clearInterval(r)},[]),e},G=e=>{const s=Q();return o.jsx(n.Text,{fontSize:"xs",...e,children:s.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},y=()=>{const{quickMenuSignal:e}=d.useContext(D);return[p.useSignalValue(e),e.setValue,e]},K=()=>{const[e]=y();return o.jsx(n.Box,{position:"absolute",left:0,bottom:0,p:2,color:e?void 0:"colorPalette.contrast",children:o.jsx(G,{})})},X=C.forwardRef(function(s,r){const{showArrow:l,children:t,portalled:i=!0,content:a,portalRef:h,...g}=s;return o.jsxs(n.Popover.Root,{...g,positioning:{...g.positioning,gutter:4},children:[o.jsx(n.Popover.Trigger,{asChild:!0,children:t}),o.jsx(n.Portal,{disabled:!i,container:h,children:o.jsx(n.Popover.Positioner,{children:o.jsxs(n.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:r,children:[l&&o.jsx(n.Popover.Arrow,{children:o.jsx(n.Popover.ArrowTip,{})}),a]})})})]})}),J=C.forwardRef(function(s,r){const{children:l,...t}=s;return o.jsx(X,{content:l,...t,ref:r,children:o.jsx(n.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:o.jsx(_.HiOutlineInformationCircle,{})})})}),Z=C.forwardRef(function(s,r){return o.jsx(n.Progress.Track,{...s,ref:r,children:o.jsx(n.Progress.Range,{})})});C.forwardRef(function(s,r){const{children:l,info:t,...i}=s;return o.jsxs(n.Progress.Label,{...i,ref:r,children:[l,t&&o.jsx(J,{children:t})]})});const R=n.Progress.Root,ee=n.Progress.ValueText,B=()=>{const e=v(),s=(e==null?void 0:e.numberOfTotalPages)===1,r=((e==null?void 0:e.beginNumberOfPagesInSpineItem)??0)>1,l=((e==null?void 0:e.endNumberOfPagesInSpineItem)??0)>1,t=(e!=null&&e.hasChapters?e==null?void 0:e.beginPageIndexInSpineItem:e==null?void 0:e.beginAbsolutePageIndex)??0,i=(e!=null&&e.hasChapters?e==null?void 0:e.endPageIndexInSpineItem:e==null?void 0:e.endAbsolutePageIndex)??0,[a=0,h=0]=[t,i].sort((b,u)=>b-u),g=(e==null?void 0:e.beginPageIndexInSpineItem)!==(e==null?void 0:e.endPageIndexInSpineItem)||(e==null?void 0:e.beginSpineItemIndex)!==(e==null?void 0:e.endSpineItemIndex),c=e!=null&&e.hasChapters?e==null?void 0:e.beginNumberOfPagesInSpineItem:e==null?void 0:e.numberOfTotalPages;return{hasOnlyOnePage:s,beginPageIndex:t,endPageIndex:i,isBeginWithinChapter:r,isEndWithinChapter:l,beginAndEndAreDifferent:g,totalApproximatePages:c,leftPageIndex:a,rightPageIndex:h}},oe=()=>{const e=v(),{hasOnlyOnePage:s,leftPageIndex:r,rightPageIndex:l,totalApproximatePages:t,beginAndEndAreDifferent:i}=B(),a=Math.round(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),h=c=>c!=null&&c.subChapter?`${c.title} / ${h(c.subChapter)}`:(c==null?void 0:c.title)||"",g=h(e==null?void 0:e.beginChapterInfo);return o.jsxs(n.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[o.jsx(R,{value:a,size:"xs",width:150,children:o.jsxs(n.HStack,{justifyContent:"space-between",children:[o.jsx(Z,{width:110}),o.jsx(ee,{children:`${a}%`})]})}),o.jsx(n.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:g?`Chapter: ${g}`:" "}),!s&&o.jsxs(n.HStack,{children:[o.jsx(n.Text,{fontSize:"xs",children:i?`${r+1} - ${l+1} of ${t}`:`${r+1} of ${t}`}),!!(e!=null&&e.hasChapters)&&o.jsxs(o.Fragment,{children:[o.jsx(n.Text,{children:"-"}),o.jsxs(n.Text,{fontSize:"xs",children:["(",((e==null?void 0:e.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},z=d.memo(({children:e,position:s,...r})=>o.jsx(n.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...s==="bottom"?{bottom:0}:{top:0},animationName:s==="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,...r,children:e})),ne=n.chakra(V),se=d.memo(e=>o.jsx(n.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:o.jsx(ne,{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(${e.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...e})})),te=()=>{const e=v(),s=e==null?void 0:e.isUsingSpread,{beginPageIndex:r,totalApproximatePages:l=0}=B(),t=s?Math.floor((r||0)/2):r,[i,a]=p.useSignal({default:t||0}),h=0,g=Math.max(0,s?Math.floor((l-1)/2):l-1);return d.useEffect(()=>{a.setValue(t||0)},[t,a]),{value:i,valueSignal:a,min:h,max:g}},re=()=>{const e=I(),s=v(),{manifest:r}=p.useObserve(()=>e==null?void 0:e.context.state$,[])??{},l=(r==null?void 0:r.readingDirection)==="rtl",t=s==null?void 0:s.isUsingSpread,{totalApproximatePages:i=0,isBeginWithinChapter:a}=B(),h=1,g=a,{value:c,valueSignal:b,min:u,max:S}=te(),O=d.useCallback(P=>{const[T=0]=Array.isArray(P)?P:[P];b.setValue(T);const W=t?Math.floor(T)*2:Math.floor(T);g?e==null||e.navigation.goToPageOfSpineItem({pageIndex:W,spineItemId:e.pagination.getState().beginSpineItemIndex??0,animation:!1}):e==null||e.navigation.goToAbsolutePageIndex({absolutePageIndex:W,animation:!1})},[e,t,b,g]);return p.useSubscribe(()=>e==null?void 0:e.navigation.throttleLock({duration:100,trigger:b.subject}),[e,b]),i===1||t&&i===2?null:o.jsx(se,{value:[c],max:S,min:u,reverse:l,step:h,onChange:O})},le=d.memo(({open:e,onTableOfContentsClick:s,onHelpClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.navigation.state$,[l]),i=p.useObserve(()=>l==null?void 0:l.settings.values$,[l]),a=(i==null?void 0:i.computedPageTurnDirection)==="vertical",[h,g]=d.useState(!0);return o.jsx(z,{present:e,position:"bottom",children:o.jsxs(n.Stack,{flex:1,children:[o.jsxs(n.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>l==null?void 0:l.navigation.goToLeftOrTopSpineItem(),disabled:!(t!=null&&t.canGoLeftSpineItem)&&!(t!=null&&t.canGoTopSpineItem),children:a?o.jsx(w.RxDoubleArrowUp,{}):o.jsx(w.RxDoubleArrowLeft,{})}),o.jsxs(n.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"visible",px:4,children:[o.jsx(oe,{}),o.jsx(n.Box,{height:5,maxW:300,width:"100%",overflow:"visible",children:o.jsx(re,{})})]}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(t!=null&&t.canGoRightSpineItem)&&!(t!=null&&t.canGoBottomSpineItem),onClick:()=>{l==null||l.navigation.goToRightOrBottomSpineItem()},children:a?o.jsx(w.RxDoubleArrowDown,{}):o.jsx(w.RxDoubleArrowRight,{})})]}),o.jsx(n.HStack,{alignItems:"center",justifyContent:"center",children:o.jsxs(n.Collapsible.Root,{open:h,flex:1,onOpenChange:({open:c})=>{g(c)},children:[o.jsx(n.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:o.jsx(x.LuChevronDown,{style:{transform:h?"rotate(0deg)":"rotate(180deg)"}})}),o.jsxs(n.Collapsible.Content,{display:"flex",justifyContent:"center",gap:2,children:[o.jsx(n.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:r,children:o.jsx(x.LuCircleHelp,{})}),o.jsx(n.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:s,children:o.jsx(x.LuTableOfContents,{})})]})]})})]})})}),ie=()=>{const[e,s]=d.useState(!1),r=d.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{s(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{s(!0)}),[]);return d.useEffect(()=>{function l(){s(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:e,onToggleFullscreenClick:r}},ce=({open:e,onBackClick:s,onMoreClick:r})=>{const l=I(),t=p.useObserve(()=>l==null?void 0:l.context.manifest$,[l]),{isFullscreen:i,onToggleFullscreenClick:a}=ie();return o.jsxs(z,{present:e,position:"top",height:"80px",justifyContent:"space-between",children:[o.jsx(n.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:s,children:o.jsx(m.IoIosArrowBack,{})}),o.jsx(n.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:o.jsx(n.Text,{truncate:!0,maxWidth:"100%",children:t==null?void 0:t.title})}),o.jsxs(n.HStack,{children:[o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:r,children:o.jsx(m.IoMdMore,{})}),o.jsx(n.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:a,children:i?o.jsx(L.MdFullscreenExit,{}):o.jsx(L.MdFullscreen,{})})]})]})},ae=d.memo(({onBackClick:e,onMoreClick:s,onTableOfContentsClick:r,onHelpClick:l})=>{const[t]=y();return o.jsxs(o.Fragment,{children:[o.jsx(ce,{open:t,onBackClick:e,onMoreClick:s}),o.jsx(le,{open:t,onTableOfContentsClick:r,onHelpClick:l})]})}),de="@prose-reader/react-reader",he="1.184.0",ge=C.forwardRef(function(s,r){return o.jsx(n.IconButton,{variant:"ghost","aria-label":"Close",ref:r,...s,children:s.children??o.jsx(x.LuX,{})})}),A=C.forwardRef(function(s,r){const{children:l,portalled:t=!0,portalRef:i,backdrop:a=!0,...h}=s;return o.jsxs(n.Portal,{disabled:!t,container:i,children:[a&&o.jsx(n.Dialog.Backdrop,{}),o.jsx(n.Dialog.Positioner,{children:o.jsx(n.Dialog.Content,{ref:r,...h,asChild:!1,children:l})})]})}),M=C.forwardRef(function(s,r){return o.jsx(n.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...s,asChild:!0,children:o.jsx(ge,{size:"sm",ref:r,children:s.children})})}),E=n.Dialog.Root,F=n.Dialog.Footer,H=n.Dialog.Header,q=n.Dialog.Body;n.Dialog.Backdrop;const $=n.Dialog.Title;n.Dialog.Description,n.Dialog.Trigger;const N=n.Dialog.ActionTrigger,fe=d.memo(({open:e,setOpen:s})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>s(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Help"})}),o.jsxs(q,{overflowY:"auto",flex:1,children:[o.jsx(n.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigRight,{})})," ",o.jsx(n.Text,{children:"Navigate to right page"})]}),o.jsxs(n.HStack,{mb:1,children:[o.jsx(n.Kbd,{children:o.jsx(x.LuArrowBigLeft,{})})," ",o.jsx(n.Text,{children:"Navigate to left page"})]}),o.jsx(n.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),o.jsxs(n.Text,{children:[de," version: ",he]})]}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),ue=d.memo(({onNavigate:e})=>{const s=I(),{manifest:r,assumedRenditionLayout:l}=p.useObserve(()=>s==null?void 0:s.context.state$,[s])??{},{nav:t}=r??{},i=v();t!=null&&t.toc;const{beginSpineItemIndex:a,beginPageIndexInSpineItem:h}=i??{},g=(l==="reflowable"?h:a)||0;console.log({assumedRenditionLayout:l,currentSpineItemOrChapterPageIndex:g});let c=i==null?void 0:i.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const b=(u,S,O)=>o.jsxs(d.Fragment,{children:[o.jsx(n.List.Item,{pl:4*(O+1),style:{display:"flex",alignItems:"center"},children:o.jsxs(n.Link,{onClick:()=>{e(),s==null||s.navigation.goToUrl(u.href)},href:"#",children:[(c==null?void 0:c.path)===u.path&&o.jsx(n.List.Indicator,{asChild:!0,children:o.jsx(x.LuCircleCheck,{})}),(c==null?void 0:c.path)!==u.path&&o.jsx(n.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(x.LuCircleCheck,{})}),o.jsxs(n.Stack,{gap:0,children:[o.jsx(n.Text,{fontSize:"md",children:u.title||u.path}),(c==null?void 0:c.path)===u.path&&o.jsx(n.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${g+1}`})]})]})}),u.contents.length>0&&o.jsx(n.List.Root,{as:"div",gap:2,children:u.contents.map((P,T)=>b(P,T,O+1))})]},S);return o.jsx(n.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:t==null?void 0:t.toc.map((u,S)=>b(u,S,0))})}),pe=d.memo(({open:e,setOpen:s,onNavigate:r})=>o.jsx(E,{lazyMount:!0,placement:"center",open:e,onOpenChange:l=>s(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(A,{children:[o.jsx(H,{children:o.jsx($,{children:"Table of Contents"})}),o.jsx(q,{overflowY:"auto",flex:1,children:o.jsx(ue,{onNavigate:r})}),o.jsx(F,{children:o.jsx(N,{asChild:!0,children:o.jsx(n.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(M,{})]})})),be=({enableFloatingTime:e=!0,enableFloatingProgress:s=!0,...r})=>{const[l,t]=d.useState(!1),[i,a]=d.useState(!1),[h,g]=y();return o.jsxs(o.Fragment,{children:[s&&o.jsx(n.Presence,{present:!h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(Y,{})}),o.jsx(ae,{...r,onTableOfContentsClick:()=>t(!0),onHelpClick:()=>a(!0)}),o.jsx(fe,{open:i,setOpen:a}),o.jsx(pe,{open:l,setOpen:t,onNavigate:()=>{t(!1),g(!1)}}),o.jsx(n.Presence,{present:e||h,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:o.jsx(K,{})})]})};f.ReactReader=be,f.ReactReaderProvider=U,Object.defineProperty(f,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.181.0",
4
+ "version": "1.185.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
@@ -23,7 +23,7 @@
23
23
  "react": "^19.0.0",
24
24
  "react-dom": "^19.0.0",
25
25
  "rollup-plugin-node-externals": "^8.0.0",
26
- "typescript": "~5.6.2",
26
+ "typescript": "*",
27
27
  "vite": "^6.0.5"
28
28
  },
29
29
  "peerDependencies": {
@@ -36,5 +36,5 @@
36
36
  "react-icons": "^5.4.0",
37
37
  "reactjrx": "1.x"
38
38
  },
39
- "gitHead": "468603245df9b98713baa40f30846caeb75eefd4"
39
+ "gitHead": "8a1b7236ea277b81b31801ce31f3771fd2240048"
40
40
  }