@nypl/web-reader 3.0.0 → 3.2.1

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/esm/index.js CHANGED
@@ -1259,6 +1259,7 @@ var require_tslib = __commonJS({
1259
1259
  var __importDefault2;
1260
1260
  var __classPrivateFieldGet2;
1261
1261
  var __classPrivateFieldSet2;
1262
+ var __classPrivateFieldIn2;
1262
1263
  var __createBinding2;
1263
1264
  (function(factory2) {
1264
1265
  var root2 = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
@@ -1451,9 +1452,13 @@ var require_tslib = __commonJS({
1451
1452
  __createBinding2 = Object.create ? function(o, m, k, k2) {
1452
1453
  if (k2 === void 0)
1453
1454
  k2 = k;
1454
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
1455
- return m[k];
1456
- } });
1455
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1456
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1457
+ desc = { enumerable: true, get: function() {
1458
+ return m[k];
1459
+ } };
1460
+ }
1461
+ Object.defineProperty(o, k2, desc);
1457
1462
  } : function(o, m, k, k2) {
1458
1463
  if (k2 === void 0)
1459
1464
  k2 = k;
@@ -1634,6 +1639,11 @@ var require_tslib = __commonJS({
1634
1639
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
1635
1640
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state2.set(receiver, value), value;
1636
1641
  };
1642
+ __classPrivateFieldIn2 = function(state2, receiver) {
1643
+ if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function")
1644
+ throw new TypeError("Cannot use 'in' operator on non-object");
1645
+ return typeof state2 === "function" ? receiver === state2 : state2.has(receiver);
1646
+ };
1637
1647
  exporter("__extends", __extends2);
1638
1648
  exporter("__assign", __assign3);
1639
1649
  exporter("__rest", __rest3);
@@ -1658,6 +1668,7 @@ var require_tslib = __commonJS({
1658
1668
  exporter("__importDefault", __importDefault2);
1659
1669
  exporter("__classPrivateFieldGet", __classPrivateFieldGet2);
1660
1670
  exporter("__classPrivateFieldSet", __classPrivateFieldSet2);
1671
+ exporter("__classPrivateFieldIn", __classPrivateFieldIn2);
1661
1672
  });
1662
1673
  }
1663
1674
  });
@@ -13735,7 +13746,7 @@ var require_debounce = __commonJS({
13735
13746
  });
13736
13747
 
13737
13748
  // src/index.tsx
13738
- import React67 from "react";
13749
+ import React68 from "react";
13739
13750
 
13740
13751
  // node_modules/@emotion/react/dist/emotion-react.browser.esm.js
13741
13752
  import * as React2 from "react";
@@ -24002,7 +24013,8 @@ var {
24002
24013
  __importStar,
24003
24014
  __importDefault,
24004
24015
  __classPrivateFieldGet,
24005
- __classPrivateFieldSet
24016
+ __classPrivateFieldSet,
24017
+ __classPrivateFieldIn
24006
24018
  } = import_tslib.default;
24007
24019
 
24008
24020
  // node_modules/framer-motion/dist/es/motion/index.js
@@ -36628,6 +36640,9 @@ var ErrorBoundary = class extends React40.Component {
36628
36640
  var ErrorBoundary_default = ErrorBoundary;
36629
36641
 
36630
36642
  // src/ui/manager.tsx
36643
+ import * as React43 from "react";
36644
+
36645
+ // src/ui/Footer.tsx
36631
36646
  import * as React42 from "react";
36632
36647
 
36633
36648
  // src/ui/PageButton.tsx
@@ -36648,12 +36663,55 @@ function PageButton(props) {
36648
36663
  }
36649
36664
  var PageButton_default = PageButton;
36650
36665
 
36666
+ // src/ui/Footer.tsx
36667
+ var Footer = (_a) => {
36668
+ var _b = _a, {
36669
+ state: state2,
36670
+ navigator: navigator2
36671
+ } = _b, rest = __objRest(_b, [
36672
+ "state",
36673
+ "navigator"
36674
+ ]);
36675
+ const bgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
36676
+ const isAtStart = state2 == null ? void 0 : state2.atStart;
36677
+ const isAtEnd = state2 == null ? void 0 : state2.atEnd;
36678
+ return /* @__PURE__ */ React42.createElement(Flex, __spreadValues({
36679
+ as: "footer",
36680
+ position: "sticky",
36681
+ height: `${FOOTER_HEIGHT}px`,
36682
+ zIndex: "sticky",
36683
+ bottom: "0",
36684
+ justifyContent: "space-between",
36685
+ w: "100%",
36686
+ bg: bgColor,
36687
+ borderTop: "1px solid",
36688
+ borderColor: "gray.100"
36689
+ }, rest), /* @__PURE__ */ React42.createElement(PageButton_default, {
36690
+ onClick: navigator2 == null ? void 0 : navigator2.goBackward,
36691
+ "aria-label": "Previous Page",
36692
+ disabled: isAtStart
36693
+ }, /* @__PURE__ */ React42.createElement(Icon, {
36694
+ as: MdKeyboardArrowLeft,
36695
+ w: 6,
36696
+ h: 6
36697
+ }), "Previous"), /* @__PURE__ */ React42.createElement(PageButton_default, {
36698
+ onClick: navigator2 == null ? void 0 : navigator2.goForward,
36699
+ "aria-label": "Next Page",
36700
+ disabled: isAtEnd
36701
+ }, "Next ", /* @__PURE__ */ React42.createElement(Icon, {
36702
+ as: MdKeyboardArrowRight,
36703
+ w: 6,
36704
+ h: 6
36705
+ })));
36706
+ };
36707
+ var Footer_default = Footer;
36708
+
36651
36709
  // src/ui/manager.tsx
36652
36710
  var ManagerUI = (props) => {
36653
36711
  var _a, _b;
36654
- return /* @__PURE__ */ React42.createElement(ThemeProvider3, {
36712
+ return /* @__PURE__ */ React43.createElement(ThemeProvider3, {
36655
36713
  theme: getTheme3((_b = (_a = props.state) == null ? void 0 : _a.settings) == null ? void 0 : _b.colorMode)
36656
- }, /* @__PURE__ */ React42.createElement(WebReaderContent, __spreadValues({}, props)));
36714
+ }, /* @__PURE__ */ React43.createElement(WebReaderContent, __spreadValues({}, props)));
36657
36715
  };
36658
36716
  var WebReaderContent = (_a) => {
36659
36717
  var _b = _a, {
@@ -36663,19 +36721,16 @@ var WebReaderContent = (_a) => {
36663
36721
  "children",
36664
36722
  "headerLeft"
36665
36723
  ]);
36666
- var _a2, _b2, _c, _d;
36667
36724
  const bgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
36668
- const containerRef = React42.useRef(null);
36669
- const isAtStart = (_a2 = props.state) == null ? void 0 : _a2.atStart;
36670
- const isAtEnd = (_b2 = props.state) == null ? void 0 : _b2.atEnd;
36671
- return /* @__PURE__ */ React42.createElement(Flex, {
36725
+ const containerRef = React43.useRef(null);
36726
+ return /* @__PURE__ */ React43.createElement(Flex, {
36672
36727
  flexDir: "column",
36673
36728
  w: "100%",
36674
36729
  position: "relative"
36675
- }, !props.isLoading && /* @__PURE__ */ React42.createElement(Header, __spreadValues({
36730
+ }, !props.isLoading && /* @__PURE__ */ React43.createElement(Header, __spreadValues({
36676
36731
  headerLeft,
36677
36732
  containerRef
36678
- }, props)), /* @__PURE__ */ React42.createElement(Flex, {
36733
+ }, props)), /* @__PURE__ */ React43.createElement(Flex, {
36679
36734
  as: "main",
36680
36735
  ref: containerRef,
36681
36736
  position: "relative",
@@ -36683,39 +36738,15 @@ var WebReaderContent = (_a) => {
36683
36738
  flexDir: "column",
36684
36739
  alignItems: "stretch",
36685
36740
  flex: "1 1 auto"
36686
- }, children), /* @__PURE__ */ React42.createElement(Flex, {
36687
- as: "footer",
36688
- position: "sticky",
36689
- height: `${FOOTER_HEIGHT}px`,
36690
- zIndex: "docked",
36691
- bottom: "0",
36692
- justifyContent: "space-between",
36693
- w: "100%",
36694
- bg: bgColor,
36695
- borderTop: "1px solid",
36696
- borderColor: "gray.100"
36697
- }, /* @__PURE__ */ React42.createElement(PageButton_default, {
36698
- onClick: (_c = props.navigator) == null ? void 0 : _c.goBackward,
36699
- "aria-label": "Previous Page",
36700
- disabled: isAtStart
36701
- }, /* @__PURE__ */ React42.createElement(Icon, {
36702
- as: MdKeyboardArrowLeft,
36703
- w: 6,
36704
- h: 6
36705
- }), "Previous"), /* @__PURE__ */ React42.createElement(PageButton_default, {
36706
- onClick: (_d = props.navigator) == null ? void 0 : _d.goForward,
36707
- "aria-label": "Next Page",
36708
- disabled: isAtEnd
36709
- }, "Next ", /* @__PURE__ */ React42.createElement(Icon, {
36710
- as: MdKeyboardArrowRight,
36711
- w: 6,
36712
- h: 6
36713
- }))));
36741
+ }, children), /* @__PURE__ */ React43.createElement(Footer_default, {
36742
+ state: props.state,
36743
+ navigator: props.navigator
36744
+ }));
36714
36745
  };
36715
36746
  var manager_default = ManagerUI;
36716
36747
 
36717
36748
  // src/useWebReader.tsx
36718
- import React65 from "react";
36749
+ import React66 from "react";
36719
36750
 
36720
36751
  // src/utils/fetch.ts
36721
36752
  function fetchJson(url) {
@@ -36875,7 +36906,7 @@ function _getPrototypeOf(o) {
36875
36906
  // node_modules/react-pdf/dist/esm/Document.js
36876
36907
  var import_prop_types3 = __toESM(require_prop_types());
36877
36908
  var import_make_event_props2 = __toESM(require_entry());
36878
- import React44, { PureComponent } from "react";
36909
+ import React45, { PureComponent } from "react";
36879
36910
 
36880
36911
  // node_modules/make-cancellable-promise/dist/esm/index.js
36881
36912
  function makeCancellablePromise(promise) {
@@ -36913,10 +36944,10 @@ var DocumentContext_default = /* @__PURE__ */ createContext13(null);
36913
36944
 
36914
36945
  // node_modules/react-pdf/dist/esm/Message.js
36915
36946
  var import_prop_types = __toESM(require_prop_types());
36916
- import React43 from "react";
36947
+ import React44 from "react";
36917
36948
  function Message(_ref) {
36918
36949
  var children = _ref.children, type = _ref.type;
36919
- return /* @__PURE__ */ React43.createElement("div", {
36950
+ return /* @__PURE__ */ React44.createElement("div", {
36920
36951
  className: "react-pdf__message react-pdf__message--".concat(type)
36921
36952
  }, children);
36922
36953
  }
@@ -37740,7 +37771,7 @@ var Document = /* @__PURE__ */ function(_PureComponent) {
37740
37771
  key: "renderChildren",
37741
37772
  value: function renderChildren() {
37742
37773
  var children = this.props.children;
37743
- return /* @__PURE__ */ React44.createElement(DocumentContext_default.Provider, {
37774
+ return /* @__PURE__ */ React45.createElement(DocumentContext_default.Provider, {
37744
37775
  value: this.childContext
37745
37776
  }, children);
37746
37777
  }
@@ -37751,19 +37782,19 @@ var Document = /* @__PURE__ */ function(_PureComponent) {
37751
37782
  var pdf = this.state.pdf;
37752
37783
  if (!file) {
37753
37784
  var noData = this.props.noData;
37754
- return /* @__PURE__ */ React44.createElement(Message, {
37785
+ return /* @__PURE__ */ React45.createElement(Message, {
37755
37786
  type: "no-data"
37756
37787
  }, typeof noData === "function" ? noData() : noData);
37757
37788
  }
37758
37789
  if (pdf === null) {
37759
37790
  var loading = this.props.loading;
37760
- return /* @__PURE__ */ React44.createElement(Message, {
37791
+ return /* @__PURE__ */ React45.createElement(Message, {
37761
37792
  type: "loading"
37762
37793
  }, typeof loading === "function" ? loading() : loading);
37763
37794
  }
37764
37795
  if (pdf === false) {
37765
37796
  var error2 = this.props.error;
37766
- return /* @__PURE__ */ React44.createElement(Message, {
37797
+ return /* @__PURE__ */ React45.createElement(Message, {
37767
37798
  type: "error"
37768
37799
  }, typeof error2 === "function" ? error2() : error2);
37769
37800
  }
@@ -37773,7 +37804,7 @@ var Document = /* @__PURE__ */ function(_PureComponent) {
37773
37804
  key: "render",
37774
37805
  value: function render() {
37775
37806
  var _this$props2 = this.props, className = _this$props2.className, inputRef = _this$props2.inputRef;
37776
- return /* @__PURE__ */ React44.createElement("div", _extends({
37807
+ return /* @__PURE__ */ React45.createElement("div", _extends({
37777
37808
  className: mergeClassNames("react-pdf__Document", className),
37778
37809
  ref: inputRef
37779
37810
  }, this.eventProps), this.renderContent());
@@ -37848,7 +37879,7 @@ Document.propTypes = _objectSpread(_objectSpread({}, eventProps), {}, {
37848
37879
  // node_modules/react-pdf/dist/esm/Outline.js
37849
37880
  var import_regenerator4 = __toESM(require_regenerator());
37850
37881
  var import_prop_types5 = __toESM(require_prop_types());
37851
- import React46, { PureComponent as PureComponent3 } from "react";
37882
+ import React47, { PureComponent as PureComponent3 } from "react";
37852
37883
  var import_make_event_props3 = __toESM(require_entry());
37853
37884
 
37854
37885
  // node_modules/react-pdf/dist/esm/OutlineContext.js
@@ -37858,7 +37889,7 @@ var OutlineContext_default = /* @__PURE__ */ createContext14(null);
37858
37889
  // node_modules/react-pdf/dist/esm/OutlineItem.js
37859
37890
  var import_regenerator3 = __toESM(require_regenerator());
37860
37891
  var import_prop_types4 = __toESM(require_prop_types());
37861
- import React45, { PureComponent as PureComponent2 } from "react";
37892
+ import React46, { PureComponent as PureComponent2 } from "react";
37862
37893
 
37863
37894
  // node_modules/react-pdf/dist/esm/Ref.js
37864
37895
  var Ref = /* @__PURE__ */ function() {
@@ -38052,8 +38083,8 @@ var OutlineItemInternal = /* @__PURE__ */ function(_PureComponent) {
38052
38083
  return null;
38053
38084
  }
38054
38085
  var subitems = item.items;
38055
- return /* @__PURE__ */ React45.createElement("ul", null, subitems.map(function(subitem, subitemIndex) {
38056
- return /* @__PURE__ */ React45.createElement(OutlineItemInternal2, _extends({
38086
+ return /* @__PURE__ */ React46.createElement("ul", null, subitems.map(function(subitem, subitemIndex) {
38087
+ return /* @__PURE__ */ React46.createElement(OutlineItemInternal2, _extends({
38057
38088
  key: typeof subitem.destination === "string" ? subitem.destination : subitemIndex,
38058
38089
  item: subitem
38059
38090
  }, otherProps));
@@ -38063,7 +38094,7 @@ var OutlineItemInternal = /* @__PURE__ */ function(_PureComponent) {
38063
38094
  key: "render",
38064
38095
  value: function render() {
38065
38096
  var item = this.props.item;
38066
- return /* @__PURE__ */ React45.createElement("li", null, /* @__PURE__ */ React45.createElement("a", {
38097
+ return /* @__PURE__ */ React46.createElement("li", null, /* @__PURE__ */ React46.createElement("a", {
38067
38098
  href: "#",
38068
38099
  onClick: this.onClick
38069
38100
  }, item.title), this.renderSubitems());
@@ -38085,9 +38116,9 @@ OutlineItemInternal.propTypes = {
38085
38116
  pdf: isPdf.isRequired
38086
38117
  };
38087
38118
  var OutlineItem = function OutlineItem2(props) {
38088
- return /* @__PURE__ */ React45.createElement(DocumentContext_default.Consumer, null, function(documentContext) {
38089
- return /* @__PURE__ */ React45.createElement(OutlineContext_default.Consumer, null, function(outlineContext) {
38090
- return /* @__PURE__ */ React45.createElement(OutlineItemInternal, _extends({}, documentContext, outlineContext, props));
38119
+ return /* @__PURE__ */ React46.createElement(DocumentContext_default.Consumer, null, function(documentContext) {
38120
+ return /* @__PURE__ */ React46.createElement(OutlineContext_default.Consumer, null, function(outlineContext) {
38121
+ return /* @__PURE__ */ React46.createElement(OutlineItemInternal, _extends({}, documentContext, outlineContext, props));
38091
38122
  });
38092
38123
  });
38093
38124
  };
@@ -38255,8 +38286,8 @@ var OutlineInternal = /* @__PURE__ */ function(_PureComponent) {
38255
38286
  key: "renderOutline",
38256
38287
  value: function renderOutline() {
38257
38288
  var outline5 = this.state.outline;
38258
- return /* @__PURE__ */ React46.createElement("ul", null, outline5.map(function(item, itemIndex) {
38259
- return /* @__PURE__ */ React46.createElement(OutlineItem_default, {
38289
+ return /* @__PURE__ */ React47.createElement("ul", null, outline5.map(function(item, itemIndex) {
38290
+ return /* @__PURE__ */ React47.createElement(OutlineItem_default, {
38260
38291
  key: typeof item.destination === "string" ? item.destination : itemIndex,
38261
38292
  item
38262
38293
  });
@@ -38271,10 +38302,10 @@ var OutlineInternal = /* @__PURE__ */ function(_PureComponent) {
38271
38302
  return null;
38272
38303
  }
38273
38304
  var _this$props = this.props, className = _this$props.className, inputRef = _this$props.inputRef;
38274
- return /* @__PURE__ */ React46.createElement("div", _extends({
38305
+ return /* @__PURE__ */ React47.createElement("div", _extends({
38275
38306
  className: mergeClassNames("react-pdf__Outline", className),
38276
38307
  ref: inputRef
38277
- }, this.eventProps), /* @__PURE__ */ React46.createElement(OutlineContext_default.Provider, {
38308
+ }, this.eventProps), /* @__PURE__ */ React47.createElement(OutlineContext_default.Provider, {
38278
38309
  value: this.childContext
38279
38310
  }, this.renderOutline()));
38280
38311
  }
@@ -38308,7 +38339,7 @@ OutlineInternal.propTypes = _objectSpread2({
38308
38339
  // node_modules/react-pdf/dist/esm/Page.js
38309
38340
  var import_regenerator8 = __toESM(require_regenerator());
38310
38341
  var import_prop_types11 = __toESM(require_prop_types());
38311
- import React52, { PureComponent as PureComponent9 } from "react";
38342
+ import React53, { PureComponent as PureComponent9 } from "react";
38312
38343
  var import_make_event_props4 = __toESM(require_entry());
38313
38344
 
38314
38345
  // node_modules/merge-refs/dist/esm/index.js
@@ -38337,7 +38368,7 @@ var PageContext_default = /* @__PURE__ */ createContext15(null);
38337
38368
 
38338
38369
  // node_modules/react-pdf/dist/esm/Page/PageCanvas.js
38339
38370
  var import_prop_types6 = __toESM(require_prop_types());
38340
- import React47, { PureComponent as PureComponent4 } from "react";
38371
+ import React48, { PureComponent as PureComponent4 } from "react";
38341
38372
  function _createSuper4(Derived) {
38342
38373
  var hasNativeReflectConstruct = _isNativeReflectConstruct4();
38343
38374
  return function _createSuperInternal() {
@@ -38452,7 +38483,7 @@ var PageCanvasInternal = /* @__PURE__ */ function(_PureComponent) {
38452
38483
  value: function render() {
38453
38484
  var _this2 = this;
38454
38485
  var canvasRef = this.props.canvasRef;
38455
- return /* @__PURE__ */ React47.createElement("canvas", {
38486
+ return /* @__PURE__ */ React48.createElement("canvas", {
38456
38487
  className: "react-pdf__Page__canvas",
38457
38488
  dir: "ltr",
38458
38489
  ref: mergeRefs2(canvasRef, function(ref) {
@@ -38496,15 +38527,15 @@ PageCanvasInternal.propTypes = {
38496
38527
  scale: import_prop_types6.default.number.isRequired
38497
38528
  };
38498
38529
  function PageCanvas(props) {
38499
- return /* @__PURE__ */ React47.createElement(PageContext_default.Consumer, null, function(context) {
38500
- return /* @__PURE__ */ React47.createElement(PageCanvasInternal, _extends({}, context, props));
38530
+ return /* @__PURE__ */ React48.createElement(PageContext_default.Consumer, null, function(context) {
38531
+ return /* @__PURE__ */ React48.createElement(PageCanvasInternal, _extends({}, context, props));
38501
38532
  });
38502
38533
  }
38503
38534
 
38504
38535
  // node_modules/react-pdf/dist/esm/Page/PageSVG.js
38505
38536
  var import_prop_types7 = __toESM(require_prop_types());
38506
38537
  var pdfjs2 = __toESM(require_pdf());
38507
- import React48, { PureComponent as PureComponent5 } from "react";
38538
+ import React49, { PureComponent as PureComponent5 } from "react";
38508
38539
  function _createSuper5(Derived) {
38509
38540
  var hasNativeReflectConstruct = _isNativeReflectConstruct5();
38510
38541
  return function _createSuperInternal() {
@@ -38597,7 +38628,7 @@ var PageSVGInternal = /* @__PURE__ */ function(_PureComponent) {
38597
38628
  value: function render() {
38598
38629
  var _this2 = this;
38599
38630
  var _this$viewport2 = this.viewport, width = _this$viewport2.width, height = _this$viewport2.height;
38600
- return /* @__PURE__ */ React48.createElement("div", {
38631
+ return /* @__PURE__ */ React49.createElement("div", {
38601
38632
  className: "react-pdf__Page__svg",
38602
38633
  ref: function ref(_ref) {
38603
38634
  return _this2.drawPageOnContainer(_ref);
@@ -38632,20 +38663,20 @@ PageSVGInternal.propTypes = {
38632
38663
  scale: import_prop_types7.default.number.isRequired
38633
38664
  };
38634
38665
  function PageSVG(props) {
38635
- return /* @__PURE__ */ React48.createElement(PageContext_default.Consumer, null, function(context) {
38636
- return /* @__PURE__ */ React48.createElement(PageSVGInternal, _extends({}, context, props));
38666
+ return /* @__PURE__ */ React49.createElement(PageContext_default.Consumer, null, function(context) {
38667
+ return /* @__PURE__ */ React49.createElement(PageSVGInternal, _extends({}, context, props));
38637
38668
  });
38638
38669
  }
38639
38670
 
38640
38671
  // node_modules/react-pdf/dist/esm/Page/TextLayer.js
38641
38672
  var import_regenerator6 = __toESM(require_regenerator());
38642
38673
  var import_prop_types9 = __toESM(require_prop_types());
38643
- import React50, { PureComponent as PureComponent7 } from "react";
38674
+ import React51, { PureComponent as PureComponent7 } from "react";
38644
38675
 
38645
38676
  // node_modules/react-pdf/dist/esm/Page/TextLayerItem.js
38646
38677
  var import_regenerator5 = __toESM(require_regenerator());
38647
38678
  var import_prop_types8 = __toESM(require_prop_types());
38648
- import React49, { PureComponent as PureComponent6 } from "react";
38679
+ import React50, { PureComponent as PureComponent6 } from "react";
38649
38680
  function _createSuper6(Derived) {
38650
38681
  var hasNativeReflectConstruct = _isNativeReflectConstruct6();
38651
38682
  return function _createSuperInternal() {
@@ -38781,7 +38812,7 @@ var TextLayerItemInternal = /* @__PURE__ */ function(_PureComponent) {
38781
38812
  var _this2 = this;
38782
38813
  var fontSize = this.fontSize, top2 = this.top, left2 = this.left;
38783
38814
  var _this$props2 = this.props, customTextRenderer = _this$props2.customTextRenderer, scale2 = _this$props2.scale, text = _this$props2.str;
38784
- return /* @__PURE__ */ React49.createElement("span", {
38815
+ return /* @__PURE__ */ React50.createElement("span", {
38785
38816
  ref: function ref(_ref) {
38786
38817
  _this2.item = _ref;
38787
38818
  },
@@ -38865,8 +38896,8 @@ TextLayerItemInternal.propTypes = {
38865
38896
  width: import_prop_types8.default.number.isRequired
38866
38897
  };
38867
38898
  function TextLayerItem(props) {
38868
- return /* @__PURE__ */ React49.createElement(PageContext_default.Consumer, null, function(context) {
38869
- return /* @__PURE__ */ React49.createElement(TextLayerItemInternal, _extends({}, context, props));
38899
+ return /* @__PURE__ */ React50.createElement(PageContext_default.Consumer, null, function(context) {
38900
+ return /* @__PURE__ */ React50.createElement(TextLayerItemInternal, _extends({}, context, props));
38870
38901
  });
38871
38902
  }
38872
38903
 
@@ -38990,7 +39021,7 @@ var TextLayerInternal = /* @__PURE__ */ function(_PureComponent) {
38990
39021
  return null;
38991
39022
  }
38992
39023
  return textItems.map(function(textItem, itemIndex) {
38993
- return /* @__PURE__ */ React50.createElement(TextLayerItem, _extends({
39024
+ return /* @__PURE__ */ React51.createElement(TextLayerItem, _extends({
38994
39025
  key: itemIndex,
38995
39026
  itemIndex
38996
39027
  }, textItem));
@@ -39000,7 +39031,7 @@ var TextLayerInternal = /* @__PURE__ */ function(_PureComponent) {
39000
39031
  key: "render",
39001
39032
  value: function render() {
39002
39033
  var viewport2 = this.unrotatedViewport, rotate = this.rotate;
39003
- return /* @__PURE__ */ React50.createElement("div", {
39034
+ return /* @__PURE__ */ React51.createElement("div", {
39004
39035
  className: "react-pdf__Page__textContent",
39005
39036
  style: {
39006
39037
  position: "absolute",
@@ -39040,8 +39071,8 @@ TextLayerInternal.propTypes = {
39040
39071
  scale: import_prop_types9.default.number
39041
39072
  };
39042
39073
  function TextLayer(props) {
39043
- return /* @__PURE__ */ React50.createElement(PageContext_default.Consumer, null, function(context) {
39044
- return /* @__PURE__ */ React50.createElement(TextLayerInternal, _extends({}, context, props));
39074
+ return /* @__PURE__ */ React51.createElement(PageContext_default.Consumer, null, function(context) {
39075
+ return /* @__PURE__ */ React51.createElement(TextLayerInternal, _extends({}, context, props));
39045
39076
  });
39046
39077
  }
39047
39078
 
@@ -39049,7 +39080,7 @@ function TextLayer(props) {
39049
39080
  var import_regenerator7 = __toESM(require_regenerator());
39050
39081
  var import_prop_types10 = __toESM(require_prop_types());
39051
39082
  var pdfjs3 = __toESM(require_pdf());
39052
- import React51, { PureComponent as PureComponent8 } from "react";
39083
+ import React52, { PureComponent as PureComponent8 } from "react";
39053
39084
  function _createSuper8(Derived) {
39054
39085
  var hasNativeReflectConstruct = _isNativeReflectConstruct8();
39055
39086
  return function _createSuperInternal() {
@@ -39203,7 +39234,7 @@ var AnnotationLayerInternal = /* @__PURE__ */ function(_PureComponent) {
39203
39234
  key: "render",
39204
39235
  value: function render() {
39205
39236
  var _this2 = this;
39206
- return /* @__PURE__ */ React51.createElement("div", {
39237
+ return /* @__PURE__ */ React52.createElement("div", {
39207
39238
  className: "react-pdf__Page__annotations annotationLayer",
39208
39239
  ref: function ref(_ref2) {
39209
39240
  _this2.annotationLayer = _ref2;
@@ -39235,9 +39266,9 @@ AnnotationLayerInternal.propTypes = {
39235
39266
  scale: import_prop_types10.default.number
39236
39267
  };
39237
39268
  var AnnotationLayer2 = function AnnotationLayer3(props) {
39238
- return /* @__PURE__ */ React51.createElement(DocumentContext_default.Consumer, null, function(documentContext) {
39239
- return /* @__PURE__ */ React51.createElement(PageContext_default.Consumer, null, function(pageContext) {
39240
- return /* @__PURE__ */ React51.createElement(AnnotationLayerInternal, _extends({}, documentContext, pageContext, props));
39269
+ return /* @__PURE__ */ React52.createElement(DocumentContext_default.Consumer, null, function(documentContext) {
39270
+ return /* @__PURE__ */ React52.createElement(PageContext_default.Consumer, null, function(pageContext) {
39271
+ return /* @__PURE__ */ React52.createElement(AnnotationLayerInternal, _extends({}, documentContext, pageContext, props));
39241
39272
  });
39242
39273
  });
39243
39274
  };
@@ -39439,12 +39470,12 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
39439
39470
  case "none":
39440
39471
  return null;
39441
39472
  case "svg":
39442
- return /* @__PURE__ */ React52.createElement(PageSVG, {
39473
+ return /* @__PURE__ */ React53.createElement(PageSVG, {
39443
39474
  key: "".concat(this.pageKeyNoScale, "_svg")
39444
39475
  });
39445
39476
  case "canvas":
39446
39477
  default:
39447
- return /* @__PURE__ */ React52.createElement(PageCanvas, {
39478
+ return /* @__PURE__ */ React53.createElement(PageCanvas, {
39448
39479
  key: "".concat(this.pageKey, "_canvas"),
39449
39480
  canvasRef
39450
39481
  });
@@ -39457,7 +39488,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
39457
39488
  if (!renderTextLayer2) {
39458
39489
  return null;
39459
39490
  }
39460
- return /* @__PURE__ */ React52.createElement(TextLayer, {
39491
+ return /* @__PURE__ */ React53.createElement(TextLayer, {
39461
39492
  key: "".concat(this.pageKey, "_text")
39462
39493
  });
39463
39494
  }
@@ -39468,7 +39499,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
39468
39499
  if (!renderAnnotationLayer2) {
39469
39500
  return null;
39470
39501
  }
39471
- return /* @__PURE__ */ React52.createElement(AnnotationLayer_default, {
39502
+ return /* @__PURE__ */ React53.createElement(AnnotationLayer_default, {
39472
39503
  key: "".concat(this.pageKey, "_annotations")
39473
39504
  });
39474
39505
  }
@@ -39476,7 +39507,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
39476
39507
  key: "renderChildren",
39477
39508
  value: function renderChildren() {
39478
39509
  var children = this.props.children;
39479
- return /* @__PURE__ */ React52.createElement(PageContext_default.Provider, {
39510
+ return /* @__PURE__ */ React53.createElement(PageContext_default.Provider, {
39480
39511
  value: this.childContext
39481
39512
  }, this.renderMainLayer(), this.renderTextLayer(), this.renderAnnotationLayer(), children);
39482
39513
  }
@@ -39488,19 +39519,19 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
39488
39519
  var page = this.state.page;
39489
39520
  if (!pageNumber) {
39490
39521
  var noData = this.props.noData;
39491
- return /* @__PURE__ */ React52.createElement(Message, {
39522
+ return /* @__PURE__ */ React53.createElement(Message, {
39492
39523
  type: "no-data"
39493
39524
  }, typeof noData === "function" ? noData() : noData);
39494
39525
  }
39495
39526
  if (pdf === null || page === null) {
39496
39527
  var loading = this.props.loading;
39497
- return /* @__PURE__ */ React52.createElement(Message, {
39528
+ return /* @__PURE__ */ React53.createElement(Message, {
39498
39529
  type: "loading"
39499
39530
  }, typeof loading === "function" ? loading() : loading);
39500
39531
  }
39501
39532
  if (pdf === false || page === false) {
39502
39533
  var error2 = this.props.error;
39503
- return /* @__PURE__ */ React52.createElement(Message, {
39534
+ return /* @__PURE__ */ React53.createElement(Message, {
39504
39535
  type: "error"
39505
39536
  }, typeof error2 === "function" ? error2() : error2);
39506
39537
  }
@@ -39511,7 +39542,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
39511
39542
  value: function render() {
39512
39543
  var pageNumber = this.pageNumber;
39513
39544
  var _this$props3 = this.props, className = _this$props3.className, inputRef = _this$props3.inputRef;
39514
- return /* @__PURE__ */ React52.createElement("div", _extends({
39545
+ return /* @__PURE__ */ React53.createElement("div", _extends({
39515
39546
  className: mergeClassNames("react-pdf__Page", className),
39516
39547
  "data-page-number": pageNumber,
39517
39548
  ref: mergeRefs2(inputRef, this.ref),
@@ -39655,13 +39686,13 @@ PageInternal.propTypes = _objectSpread3(_objectSpread3({}, eventProps), {}, {
39655
39686
  width: import_prop_types11.default.number
39656
39687
  });
39657
39688
  function Page(props, ref) {
39658
- return /* @__PURE__ */ React52.createElement(DocumentContext_default.Consumer, null, function(context) {
39659
- return /* @__PURE__ */ React52.createElement(PageInternal, _extends({
39689
+ return /* @__PURE__ */ React53.createElement(DocumentContext_default.Consumer, null, function(context) {
39690
+ return /* @__PURE__ */ React53.createElement(PageInternal, _extends({
39660
39691
  ref
39661
39692
  }, context, props));
39662
39693
  });
39663
39694
  }
39664
- var Page_default = /* @__PURE__ */ React52.forwardRef(Page);
39695
+ var Page_default = /* @__PURE__ */ React53.forwardRef(Page);
39665
39696
 
39666
39697
  // node_modules/react-pdf/dist/esm/entry.js
39667
39698
  if (isLocalFileSystem) {
@@ -39670,10 +39701,10 @@ if (isLocalFileSystem) {
39670
39701
  pdfjs4.GlobalWorkerOptions.workerSrc = "pdf.worker.js";
39671
39702
 
39672
39703
  // src/PdfReader/index.tsx
39673
- import * as React56 from "react";
39704
+ import * as React57 from "react";
39674
39705
 
39675
39706
  // src/PdfReader/useMeasure.tsx
39676
- import * as React53 from "react";
39707
+ import * as React54 from "react";
39677
39708
  var DEFAULT_DIMENSION = {
39678
39709
  x: 0,
39679
39710
  y: 0,
@@ -39685,9 +39716,9 @@ var DEFAULT_DIMENSION = {
39685
39716
  right: 0
39686
39717
  };
39687
39718
  function useMeasure() {
39688
- const [element, ref] = React53.useState(null);
39689
- const [rect, setRect] = React53.useState(DEFAULT_DIMENSION);
39690
- const observer = React53.useMemo(() => new window.ResizeObserver((entries) => {
39719
+ const [element, ref] = React54.useState(null);
39720
+ const [rect, setRect] = React54.useState(DEFAULT_DIMENSION);
39721
+ const observer = React54.useMemo(() => new window.ResizeObserver((entries) => {
39691
39722
  if (entries[0]) {
39692
39723
  const {
39693
39724
  x,
@@ -39702,7 +39733,7 @@ function useMeasure() {
39702
39733
  setRect({ x, y, width, height, top: top2, left: left2, bottom: bottom2, right: right2 });
39703
39734
  }
39704
39735
  }), []);
39705
- React53.useLayoutEffect(() => {
39736
+ React54.useLayoutEffect(() => {
39706
39737
  if (!element)
39707
39738
  return;
39708
39739
  observer.observe(element);
@@ -39731,10 +39762,10 @@ var ChakraPage = chakra(Page_default, {
39731
39762
  var ChakraPage_default = ChakraPage;
39732
39763
 
39733
39764
  // src/PdfReader/ScrollPage.tsx
39734
- import React54 from "react";
39765
+ import React55 from "react";
39735
39766
 
39736
39767
  // node_modules/react-intersection-observer/react-intersection-observer.m.js
39737
- import { createElement as createElement32, Component as Component3, useRef as useRef19, useState as useState18, useCallback as useCallback15, useEffect as useEffect20 } from "react";
39768
+ import { createElement as createElement33, Component as Component3, useRef as useRef19, useState as useState18, useCallback as useCallback15, useEffect as useEffect20 } from "react";
39738
39769
  function _extends22() {
39739
39770
  _extends22 = Object.assign || function(target) {
39740
39771
  for (var i = 1; i < arguments.length; i++) {
@@ -39925,7 +39956,7 @@ var InView = /* @__PURE__ */ function(_React$Component) {
39925
39956
  });
39926
39957
  }
39927
39958
  var _this$props2 = this.props, children = _this$props2.children, as = _this$props2.as, tag2 = _this$props2.tag, props = _objectWithoutPropertiesLoose17(_this$props2, ["children", "as", "tag", "triggerOnce", "threshold", "root", "rootMargin", "onChange", "skip", "trackVisibility", "delay", "initialInView"]);
39928
- return /* @__PURE__ */ createElement32(as || tag2 || "div", _extends22({
39959
+ return /* @__PURE__ */ createElement33(as || tag2 || "div", _extends22({
39929
39960
  ref: this.handleNode
39930
39961
  }, props), children);
39931
39962
  };
@@ -39993,7 +40024,7 @@ function useInView(_temp) {
39993
40024
 
39994
40025
  // src/PdfReader/ScrollPage.tsx
39995
40026
  var Placeholder = ({ width, height, pageNumber }) => {
39996
- return /* @__PURE__ */ React54.createElement("div", {
40027
+ return /* @__PURE__ */ React55.createElement("div", {
39997
40028
  "data-page-number": pageNumber,
39998
40029
  style: { width, height }
39999
40030
  });
@@ -40010,15 +40041,15 @@ var ScrollPage = ({
40010
40041
  threshold: 0,
40011
40042
  triggerOnce: true
40012
40043
  });
40013
- return /* @__PURE__ */ React54.createElement("div", {
40044
+ return /* @__PURE__ */ React55.createElement("div", {
40014
40045
  ref
40015
- }, inView ? /* @__PURE__ */ React54.createElement(ChakraPage_default, {
40046
+ }, inView ? /* @__PURE__ */ React55.createElement(ChakraPage_default, {
40016
40047
  "data-page-number": pageNumber,
40017
40048
  pageNumber,
40018
40049
  scale: scale2,
40019
40050
  width,
40020
40051
  onLoadSuccess
40021
- }) : /* @__PURE__ */ React54.createElement(Placeholder, {
40052
+ }) : /* @__PURE__ */ React55.createElement(Placeholder, {
40022
40053
  width: placeholderWidth,
40023
40054
  height: placeholderHeight,
40024
40055
  pageNumber
@@ -40027,38 +40058,57 @@ var ScrollPage = ({
40027
40058
  var ScrollPage_default = ScrollPage;
40028
40059
 
40029
40060
  // src/ui/LoadingSkeleton.tsx
40030
- import React55 from "react";
40031
- function LoadingSkeleton({
40061
+ import React56 from "react";
40062
+ var LoadingSkeletonContent = ({
40032
40063
  height
40033
- }) {
40034
- return /* @__PURE__ */ React55.createElement(React55.Fragment, null, /* @__PURE__ */ React55.createElement(HeaderWrapper, null), /* @__PURE__ */ React55.createElement(Box, {
40064
+ }) => {
40065
+ const bgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
40066
+ return /* @__PURE__ */ React56.createElement(React56.Fragment, null, /* @__PURE__ */ React56.createElement(HeaderWrapper, {
40067
+ bg: bgColor
40068
+ }), /* @__PURE__ */ React56.createElement(Box, {
40035
40069
  padding: "6",
40036
- bg: "white",
40037
- mt: "7",
40070
+ bg: bgColor,
40071
+ mt: "0",
40038
40072
  height,
40039
40073
  "aria-label": "Loading book...",
40040
40074
  "aria-busy": "true",
40041
40075
  role: "progressbar"
40042
- }, /* @__PURE__ */ React55.createElement(Flex, {
40076
+ }, /* @__PURE__ */ React56.createElement(Flex, {
40043
40077
  justifyContent: "center"
40044
- }, /* @__PURE__ */ React55.createElement(Skeleton, {
40078
+ }, /* @__PURE__ */ React56.createElement(Skeleton, {
40045
40079
  height: "20px",
40046
40080
  mb: "7",
40047
40081
  w: "30%"
40048
- })), /* @__PURE__ */ React55.createElement(SkeletonText, {
40082
+ })), /* @__PURE__ */ React56.createElement(SkeletonText, {
40049
40083
  mb: "7",
40050
40084
  noOfLines: 10,
40051
40085
  spacing: "4"
40052
- }), /* @__PURE__ */ React55.createElement(SkeletonText, {
40086
+ }), /* @__PURE__ */ React56.createElement(SkeletonText, {
40053
40087
  mb: "7",
40054
40088
  noOfLines: 5,
40055
40089
  spacing: "4"
40056
- })));
40090
+ })), /* @__PURE__ */ React56.createElement(Footer_default, {
40091
+ state: null,
40092
+ navigator: null,
40093
+ zIndex: "tooltip"
40094
+ }));
40095
+ };
40096
+ function LoadingSkeleton({
40097
+ height,
40098
+ state: state2
40099
+ }) {
40100
+ var _a;
40101
+ return /* @__PURE__ */ React56.createElement(ThemeProvider3, {
40102
+ theme: getTheme3((_a = state2 == null ? void 0 : state2.settings) == null ? void 0 : _a.colorMode)
40103
+ }, /* @__PURE__ */ React56.createElement(LoadingSkeletonContent, {
40104
+ height
40105
+ }));
40057
40106
  }
40058
40107
 
40059
40108
  // src/PdfReader/index.tsx
40060
40109
  var IFRAME_WRAPPER_ID = "iframe-wrapper";
40061
40110
  var SCALE_STEP = 0.1;
40111
+ var START_QUERY = "start";
40062
40112
  function pdfReducer(state2, action) {
40063
40113
  switch (action.type) {
40064
40114
  case "ARGS_CHANGED": {
@@ -40146,6 +40196,11 @@ var loadResource = (resourceUrl, proxyUrl) => __async(void 0, null, function* ()
40146
40196
  }
40147
40197
  return array;
40148
40198
  });
40199
+ var getStartPage = (resourceUrl) => {
40200
+ const params = new URL(resourceUrl).searchParams;
40201
+ const startPage = params.get(START_QUERY);
40202
+ return startPage ? parseInt(startPage) : 1;
40203
+ };
40149
40204
  function usePdfReader(args) {
40150
40205
  var _a;
40151
40206
  if (args == null ? void 0 : args.pdfWorkerSrc) {
@@ -40161,7 +40216,7 @@ function usePdfReader(args) {
40161
40216
  height = DEFAULT_HEIGHT,
40162
40217
  growWhenScrolling = DEFAULT_SHOULD_GROW_WHEN_SCROLLING
40163
40218
  } = args != null ? args : {};
40164
- const [state2, dispatch] = React56.useReducer(pdfReducer, {
40219
+ const [state2, dispatch] = React57.useReducer(pdfReducer, {
40165
40220
  state: "INACTIVE",
40166
40221
  resourceIndex: 0,
40167
40222
  resource: null,
@@ -40180,7 +40235,7 @@ function usePdfReader(args) {
40180
40235
  const isParsed = typeof state2.numPages === "number";
40181
40236
  const isSinglePDF = manifest && (manifest == null ? void 0 : manifest.readingOrder.length) === 1;
40182
40237
  const [containerRef, containerSize] = useMeasure();
40183
- React56.useEffect(() => {
40238
+ React57.useEffect(() => {
40184
40239
  if (!webpubManifestUrl || !manifest) {
40185
40240
  return dispatch({ type: "ARGS_CHANGED", args: void 0 });
40186
40241
  }
@@ -40205,7 +40260,7 @@ function usePdfReader(args) {
40205
40260
  height,
40206
40261
  growWhenScrolling
40207
40262
  ]);
40208
- React56.useEffect(() => {
40263
+ React57.useEffect(() => {
40209
40264
  if (!manifest)
40210
40265
  return;
40211
40266
  if (!manifest.readingOrder || !manifest.readingOrder.length) {
@@ -40219,7 +40274,7 @@ function usePdfReader(args) {
40219
40274
  });
40220
40275
  });
40221
40276
  }, [state2.resourceIndex, manifest, proxyUrl]);
40222
- const resizePage = React56.useCallback((pdfWidth, pdfHeight, containerSize2) => {
40277
+ const resizePage = React57.useCallback((pdfWidth, pdfHeight, containerSize2) => {
40223
40278
  const wRatio = pdfWidth / containerSize2.width;
40224
40279
  const hRatio = pdfHeight / containerSize2.height;
40225
40280
  const fitHorizontal = wRatio > hRatio;
@@ -40227,10 +40282,10 @@ function usePdfReader(args) {
40227
40282
  const height2 = !fitHorizontal ? Math.round(containerSize2.height) : void 0;
40228
40283
  dispatch({ type: "RESIZE_PAGE", width, height: height2 });
40229
40284
  }, []);
40230
- React56.useEffect(() => {
40285
+ React57.useEffect(() => {
40231
40286
  resizePage(state2.pdfWidth, state2.pdfHeight, containerSize);
40232
40287
  }, [containerSize, state2.pdfWidth, state2.pdfHeight, resizePage]);
40233
- React56.useEffect(() => {
40288
+ React57.useEffect(() => {
40234
40289
  var _a2;
40235
40290
  if (!manifest || state2.state !== "ACTIVE")
40236
40291
  return;
@@ -40260,7 +40315,7 @@ function usePdfReader(args) {
40260
40315
  state2.resourceIndex,
40261
40316
  isSinglePDF
40262
40317
  ]);
40263
- const goForward = React56.useCallback(() => __async(this, null, function* () {
40318
+ const goForward = React57.useCallback(() => __async(this, null, function* () {
40264
40319
  var _a2;
40265
40320
  if (!state2.numPages)
40266
40321
  return;
@@ -40278,6 +40333,13 @@ function usePdfReader(args) {
40278
40333
  index: nextIndex,
40279
40334
  shouldNavigateToEnd: false
40280
40335
  });
40336
+ if (manifest == null ? void 0 : manifest.readingOrder[nextIndex]) {
40337
+ const pageNum = getStartPage(manifest == null ? void 0 : manifest.readingOrder[nextIndex].href);
40338
+ dispatch({
40339
+ type: "NAVIGATE_PAGE",
40340
+ pageNum
40341
+ });
40342
+ }
40281
40343
  }
40282
40344
  }), [
40283
40345
  state2.state,
@@ -40287,12 +40349,13 @@ function usePdfReader(args) {
40287
40349
  state2.pageNumber,
40288
40350
  state2.resourceIndex
40289
40351
  ]);
40290
- const goBackward = React56.useCallback(() => __async(this, null, function* () {
40352
+ const goBackward = React57.useCallback(() => __async(this, null, function* () {
40291
40353
  if (!isParsed)
40292
40354
  return;
40293
40355
  if (state2.state !== "ACTIVE")
40294
40356
  return;
40295
- if (state2.pageNumber > 1 && !state2.settings.isScrolling) {
40357
+ const startPage = (manifest == null ? void 0 : manifest.readingOrder) && (manifest == null ? void 0 : manifest.readingOrder[state2.resourceIndex]) ? getStartPage(manifest == null ? void 0 : manifest.readingOrder[state2.resourceIndex].href) : 1;
40358
+ if (state2.pageNumber > startPage && !state2.settings.isScrolling) {
40296
40359
  dispatch({
40297
40360
  type: "NAVIGATE_PAGE",
40298
40361
  pageNum: state2.pageNumber - 1
@@ -40313,38 +40376,46 @@ function usePdfReader(args) {
40313
40376
  state2.pageNumber,
40314
40377
  state2.resourceIndex
40315
40378
  ]);
40316
- const setScroll = React56.useCallback((val) => __async(this, null, function* () {
40379
+ const setScroll = React57.useCallback((val) => __async(this, null, function* () {
40317
40380
  const isScrolling = val === "scrolling";
40318
40381
  dispatch({ type: "SET_SCROLL", isScrolling });
40319
40382
  }), []);
40320
- const zoomIn = React56.useCallback(() => __async(this, null, function* () {
40383
+ const zoomIn = React57.useCallback(() => __async(this, null, function* () {
40321
40384
  dispatch({
40322
40385
  type: "SET_SCALE",
40323
40386
  scale: state2.scale + SCALE_STEP
40324
40387
  });
40325
40388
  }), [state2.scale]);
40326
- const zoomOut = React56.useCallback(() => __async(this, null, function* () {
40389
+ const zoomOut = React57.useCallback(() => __async(this, null, function* () {
40327
40390
  dispatch({
40328
40391
  type: "SET_SCALE",
40329
40392
  scale: state2.scale - SCALE_STEP
40330
40393
  });
40331
40394
  }), [state2.scale]);
40332
- const goToPage = React56.useCallback((href) => __async(this, null, function* () {
40395
+ const goToPage = React57.useCallback((href) => __async(this, null, function* () {
40333
40396
  const getIndexFromHref = (href2) => {
40334
40397
  var _a2;
40335
40398
  const index = (_a2 = manifest == null ? void 0 : manifest.readingOrder) == null ? void 0 : _a2.findIndex((link2) => {
40336
40399
  return link2.href === href2;
40337
40400
  });
40338
- if (!index) {
40401
+ if (index < 0) {
40339
40402
  throw new Error("Cannot find resource in readingOrder");
40340
40403
  }
40341
40404
  return index;
40342
40405
  };
40406
+ const resourceIndex = getIndexFromHref(href);
40343
40407
  dispatch({
40344
40408
  type: "SET_CURRENT_RESOURCE",
40345
- index: getIndexFromHref(href),
40409
+ index: resourceIndex,
40346
40410
  shouldNavigateToEnd: false
40347
40411
  });
40412
+ if ((manifest == null ? void 0 : manifest.readingOrder) && (manifest == null ? void 0 : manifest.readingOrder[resourceIndex])) {
40413
+ const startPage = getStartPage(manifest == null ? void 0 : manifest.readingOrder[resourceIndex].href);
40414
+ dispatch({
40415
+ type: "NAVIGATE_PAGE",
40416
+ pageNum: startPage
40417
+ });
40418
+ }
40348
40419
  }), [manifest == null ? void 0 : manifest.readingOrder]);
40349
40420
  if (!webpubManifestUrl || !manifest)
40350
40421
  return null;
@@ -40352,8 +40423,9 @@ function usePdfReader(args) {
40352
40423
  return {
40353
40424
  type: null,
40354
40425
  isLoading: true,
40355
- content: /* @__PURE__ */ React56.createElement(LoadingSkeleton, {
40356
- height
40426
+ content: /* @__PURE__ */ React57.createElement(LoadingSkeleton, {
40427
+ height,
40428
+ state: state2
40357
40429
  }),
40358
40430
  navigator: null,
40359
40431
  manifest: null,
@@ -40383,7 +40455,7 @@ function usePdfReader(args) {
40383
40455
  return {
40384
40456
  type: "PDF",
40385
40457
  isLoading: false,
40386
- content: /* @__PURE__ */ React56.createElement(Flex, {
40458
+ content: /* @__PURE__ */ React57.createElement(Flex, {
40387
40459
  as: "main",
40388
40460
  zIndex: "base",
40389
40461
  flex: "1 0 auto",
@@ -40393,16 +40465,16 @@ function usePdfReader(args) {
40393
40465
  id: IFRAME_WRAPPER_ID,
40394
40466
  ref: containerRef,
40395
40467
  height: finalHeight
40396
- }, /* @__PURE__ */ React56.createElement("style", null, `
40468
+ }, /* @__PURE__ */ React57.createElement("style", null, `
40397
40469
  .react-pdf__Document {
40398
40470
  height: calc(100vh - ${HEADER_HEIGHT + FOOTER_HEIGHT}px);
40399
40471
  overflow-x: hidden;
40400
40472
  overflow-y: auto;
40401
40473
  }
40402
- `), /* @__PURE__ */ React56.createElement(Document, {
40474
+ `), /* @__PURE__ */ React57.createElement(Document, {
40403
40475
  file: state2.resource,
40404
40476
  onLoadSuccess: onDocumentLoadSuccess
40405
- }, isParsed && state2.numPages && /* @__PURE__ */ React56.createElement(React56.Fragment, null, state2.settings.isScrolling && Array.from(new Array(state2.numPages), (_, index) => /* @__PURE__ */ React56.createElement(ScrollPage_default, {
40477
+ }, isParsed && state2.numPages && /* @__PURE__ */ React57.createElement(React57.Fragment, null, state2.settings.isScrolling && Array.from(new Array(state2.numPages), (_, index) => /* @__PURE__ */ React57.createElement(ScrollPage_default, {
40406
40478
  key: `page_${index + 1}`,
40407
40479
  width: containerSize.width,
40408
40480
  placeholderHeight: state2.pdfHeight,
@@ -40410,13 +40482,13 @@ function usePdfReader(args) {
40410
40482
  scale: state2.scale,
40411
40483
  pageNumber: index + 1,
40412
40484
  onLoadSuccess: onRenderSuccess
40413
- })), !state2.settings.isScrolling && /* @__PURE__ */ React56.createElement(ChakraPage_default, {
40485
+ })), !state2.settings.isScrolling && /* @__PURE__ */ React57.createElement(ChakraPage_default, {
40414
40486
  pageNumber: state2.pageNumber,
40415
40487
  onLoadSuccess: onRenderSuccess,
40416
40488
  width: state2.pageWidth,
40417
40489
  height: state2.pageHeight,
40418
40490
  scale: state2.scale,
40419
- loading: /* @__PURE__ */ React56.createElement(React56.Fragment, null)
40491
+ loading: /* @__PURE__ */ React57.createElement(React57.Fragment, null)
40420
40492
  })))),
40421
40493
  state: state2,
40422
40494
  manifest,
@@ -40436,7 +40508,7 @@ function handleInvalidTransition(state2, action) {
40436
40508
  }
40437
40509
 
40438
40510
  // src/HtmlReader/index.tsx
40439
- import React64 from "react";
40511
+ import React65 from "react";
40440
40512
 
40441
40513
  // src/HtmlReader/lib.ts
40442
40514
  var FONT_SIZE_STEP = 4;
@@ -40454,8 +40526,18 @@ function makeInjectableElement(document2, injectable) {
40454
40526
  }
40455
40527
  return el;
40456
40528
  }
40529
+ case "script": {
40530
+ const el = document2.createElement("script");
40531
+ el.setAttribute("type", "text/javascript");
40532
+ if (injectable.url) {
40533
+ el.setAttribute("src", injectable.url);
40534
+ } else {
40535
+ console.warn("Injectable missing url", injectable);
40536
+ }
40537
+ return el;
40538
+ }
40457
40539
  default:
40458
- return;
40540
+ return void 0;
40459
40541
  }
40460
40542
  }
40461
40543
  function getCurrentIndex(manifest, state2, baseUrl) {
@@ -40478,10 +40560,15 @@ function getFromReadingOrder(href, manifest, baseUrl) {
40478
40560
  } : void 0;
40479
40561
  }
40480
40562
  function isSameResource(href1, href2, baseUrl) {
40481
- const url1 = new URL(href1, baseUrl);
40482
- const url2 = new URL(href2, baseUrl);
40483
- const doMatch = url1.origin === url2.origin && url1.pathname === url2.pathname;
40484
- return doMatch;
40563
+ try {
40564
+ const url1 = new URL(href1, baseUrl);
40565
+ const url2 = new URL(href2, baseUrl);
40566
+ const doMatch = url1.origin === url2.origin && url1.pathname === url2.pathname;
40567
+ return doMatch;
40568
+ } catch (e) {
40569
+ console.error(e);
40570
+ }
40571
+ return false;
40485
40572
  }
40486
40573
  function linkToLocator(link2, baseUrl, locations = {}) {
40487
40574
  var _a;
@@ -40600,7 +40687,7 @@ var familyToReadiumFamily = {
40600
40687
  };
40601
40688
 
40602
40689
  // src/utils/localstorage.ts
40603
- import React57 from "react";
40690
+ import React58 from "react";
40604
40691
  function getLocalStorageLocation(identifier2, args) {
40605
40692
  if (!(args == null ? void 0 : args.persistLastLocation))
40606
40693
  return void 0;
@@ -40623,7 +40710,7 @@ function getLocalStorageSettings(args) {
40623
40710
  return void 0;
40624
40711
  }
40625
40712
  function useUpdateLocalStorage(identifier2, state2, args) {
40626
- React57.useEffect(() => {
40713
+ React58.useEffect(() => {
40627
40714
  if (!identifier2 || !(args == null ? void 0 : args.persistLastLocation))
40628
40715
  return;
40629
40716
  if (state2.location) {
@@ -40644,7 +40731,7 @@ function useUpdateLocalStorage(identifier2, state2, args) {
40644
40731
  }
40645
40732
  }
40646
40733
  }, [state2.location, identifier2, args == null ? void 0 : args.persistLastLocation]);
40647
- React57.useEffect(() => {
40734
+ React58.useEffect(() => {
40648
40735
  if (!identifier2 || !state2.settings || !(args == null ? void 0 : args.persistSettings))
40649
40736
  return;
40650
40737
  const settings = {
@@ -40663,10 +40750,10 @@ function clearWebReaderLocalStorage() {
40663
40750
  }
40664
40751
 
40665
40752
  // src/HtmlReader/useLocationQuery.ts
40666
- import React58 from "react";
40753
+ import React59 from "react";
40667
40754
  var LOCATION_QUERY_TITLE = "location";
40668
40755
  function useLocationQuery(state2) {
40669
- React58.useEffect(() => {
40756
+ React59.useEffect(() => {
40670
40757
  if (state2.state === "READY")
40671
40758
  updateQuery(state2.location);
40672
40759
  }, [state2.location, state2.state]);
@@ -41133,11 +41220,11 @@ function extractContentContainerSize(container3) {
41133
41220
  }
41134
41221
 
41135
41222
  // src/HtmlReader/useResource.tsx
41136
- import React59 from "react";
41223
+ import React60 from "react";
41137
41224
  function useResource(manifest, state2, getContent, injectables, dispatch) {
41138
41225
  var _a, _b;
41139
41226
  const currentResourceUrl = (_b = (_a = state2.location) == null ? void 0 : _a.href) != null ? _b : null;
41140
- React59.useEffect(() => {
41227
+ React60.useEffect(() => {
41141
41228
  if (!currentResourceUrl) {
41142
41229
  return;
41143
41230
  }
@@ -41192,8 +41279,11 @@ function injectJS(body) {
41192
41279
  function handleLinkClick(evt) {
41193
41280
  // don't navigate
41194
41281
  evt.preventDefault();
41195
- // send message to parent
41196
- window.parent.postMessage( { type: 'LINK_CLICKED', href: evt.target.href } );
41282
+ const href = evt.currentTarget.href;
41283
+ if(href) {
41284
+ // send message to parent
41285
+ window.parent.postMessage( { type: 'LINK_CLICKED', href } );
41286
+ }
41197
41287
  };
41198
41288
  for ( var i = 0; i < links.length; i ++ ) {
41199
41289
  links[i].addEventListener('click', handleLinkClick);
@@ -41207,9 +41297,9 @@ function injectJS(body) {
41207
41297
 
41208
41298
  // src/HtmlReader/useWindowResize.ts
41209
41299
  var import_debounce2 = __toESM(require_debounce());
41210
- import React60 from "react";
41300
+ import React61 from "react";
41211
41301
  function useWindowResize(manifest, state2, dispatch) {
41212
- React60.useEffect(() => {
41302
+ React61.useEffect(() => {
41213
41303
  if (state2.state !== "NAVIGATING" && state2.state !== "READY")
41214
41304
  return;
41215
41305
  function handleResize() {
@@ -41230,11 +41320,11 @@ function useWindowResize(manifest, state2, dispatch) {
41230
41320
  }
41231
41321
 
41232
41322
  // src/HtmlReader/useUpdateScroll.ts
41233
- import * as React61 from "react";
41323
+ import * as React62 from "react";
41234
41324
  var SCROLL_STOP_DEBOUNCE = 100;
41235
41325
  function useUpdateScroll(state2, dispatch) {
41236
- const timeout = React61.useRef();
41237
- React61.useLayoutEffect(() => {
41326
+ const timeout = React62.useRef();
41327
+ React62.useLayoutEffect(() => {
41238
41328
  if (state2.state !== "READY")
41239
41329
  return;
41240
41330
  const iframeDocument = state2.iframe.contentDocument;
@@ -41253,9 +41343,9 @@ function useUpdateScroll(state2, dispatch) {
41253
41343
  }
41254
41344
 
41255
41345
  // src/HtmlReader/useUpdateCSS.ts
41256
- import React62 from "react";
41346
+ import React63 from "react";
41257
41347
  function useUpdateCSS(state2, manifest) {
41258
- React62.useEffect(() => {
41348
+ React63.useEffect(() => {
41259
41349
  if (!manifest)
41260
41350
  return;
41261
41351
  if (state2.state !== "NAVIGATING" && state2.state !== "READY")
@@ -41268,19 +41358,32 @@ function useUpdateCSS(state2, manifest) {
41268
41358
  }
41269
41359
 
41270
41360
  // src/HtmlReader/useIframeLinkClick.ts
41271
- import React63 from "react";
41272
- function useIframeLinkClick(dispatch) {
41273
- React63.useEffect(() => {
41361
+ import React64 from "react";
41362
+ function useIframeLinkClick(baseUrl, manifest, dispatch) {
41363
+ React64.useEffect(() => {
41364
+ if (!baseUrl || !manifest)
41365
+ return;
41274
41366
  window.addEventListener("message", ({ data }) => {
41275
41367
  if (typeof data === "object" && data !== null && "type" in data) {
41276
41368
  switch (data.type) {
41277
41369
  case "LINK_CLICKED":
41278
- dispatch({ type: "GO_TO_HREF", href: data.href });
41370
+ handleIframeLink(data.href, manifest, baseUrl, dispatch);
41279
41371
  }
41280
41372
  }
41281
41373
  });
41282
- }, [dispatch]);
41374
+ }, [dispatch, baseUrl, manifest]);
41283
41375
  }
41376
+ var handleIframeLink = (href, manifest, baseUrl, dispatch) => {
41377
+ if (isExternalLink(href, manifest, baseUrl)) {
41378
+ window.open(href, "_blank");
41379
+ } else {
41380
+ dispatch({ type: "GO_TO_HREF", href });
41381
+ }
41382
+ };
41383
+ var isExternalLink = (href, manifest, baseUrl) => {
41384
+ const resource = getFromReadingOrder(href, manifest, baseUrl);
41385
+ return resource === void 0;
41386
+ };
41284
41387
 
41285
41388
  // src/HtmlReader/index.tsx
41286
41389
  var IFRAME_ID_SELECTOR = "html-reader-iframe";
@@ -41297,7 +41400,7 @@ function useHtmlReader(args) {
41297
41400
  persistLastLocation = true,
41298
41401
  persistSettings = true
41299
41402
  } = args != null ? args : {};
41300
- const [state2, dispatch] = React64.useReducer(makeHtmlReducer(args), inactiveState);
41403
+ const [state2, dispatch] = React65.useReducer(makeHtmlReducer(args), inactiveState);
41301
41404
  const currentResourceUrl = (_b = (_a = state2.location) == null ? void 0 : _a.href) != null ? _b : null;
41302
41405
  const injectables = ((_d = (_c = manifest == null ? void 0 : manifest.metadata) == null ? void 0 : _c.presentation) == null ? void 0 : _d.layout) === "fixed" ? injectablesFixed : injectablesReflowable;
41303
41406
  useResource(manifest, state2, getContent, injectables, dispatch);
@@ -41307,8 +41410,8 @@ function useHtmlReader(args) {
41307
41410
  useLocationQuery(state2);
41308
41411
  useWindowResize(manifest, state2, dispatch);
41309
41412
  useUpdateCSS(state2, manifest);
41310
- useIframeLinkClick(dispatch);
41311
- React64.useEffect(() => {
41413
+ useIframeLinkClick(webpubManifestUrl, manifest, dispatch);
41414
+ React65.useEffect(() => {
41312
41415
  if (!webpubManifestUrl || !manifest) {
41313
41416
  return dispatch({ type: "ARGS_CHANGED", args: void 0 });
41314
41417
  }
@@ -41337,7 +41440,7 @@ function useHtmlReader(args) {
41337
41440
  persistLastLocation,
41338
41441
  persistSettings
41339
41442
  ]);
41340
- React64.useEffect(() => {
41443
+ React65.useEffect(() => {
41341
41444
  process.nextTick(() => {
41342
41445
  if (state2.state === "NAVIGATING") {
41343
41446
  const { fragment, progression, position: position3 } = state2.location.locations;
@@ -41359,7 +41462,7 @@ function useHtmlReader(args) {
41359
41462
  (_g = state2.settings) == null ? void 0 : _g.isScrolling,
41360
41463
  (_h = state2.location) == null ? void 0 : _h.locations
41361
41464
  ]);
41362
- const navigator2 = React64.useRef({
41465
+ const navigator2 = React65.useRef({
41363
41466
  goToPage(href) {
41364
41467
  dispatch({ type: "GO_TO_HREF", href });
41365
41468
  },
@@ -41400,7 +41503,7 @@ function useHtmlReader(args) {
41400
41503
  });
41401
41504
  }
41402
41505
  }).current;
41403
- const setIframe = React64.useRef((el) => {
41506
+ const setIframe = React65.useRef((el) => {
41404
41507
  dispatch({ type: "SET_IFRAME", iframe: el });
41405
41508
  }).current;
41406
41509
  if (!webpubManifestUrl || !manifest)
@@ -41409,8 +41512,9 @@ function useHtmlReader(args) {
41409
41512
  return {
41410
41513
  type: null,
41411
41514
  isLoading: true,
41412
- content: /* @__PURE__ */ React64.createElement(LoadingSkeleton, {
41413
- height
41515
+ content: /* @__PURE__ */ React65.createElement(LoadingSkeleton, {
41516
+ height,
41517
+ state: state2
41414
41518
  }),
41415
41519
  navigator: null,
41416
41520
  manifest: null,
@@ -41432,7 +41536,7 @@ function useHtmlReader(args) {
41432
41536
  return {
41433
41537
  type: "HTML",
41434
41538
  isLoading: false,
41435
- content: /* @__PURE__ */ React64.createElement(React64.Fragment, null, /* @__PURE__ */ React64.createElement("iframe", {
41539
+ content: /* @__PURE__ */ React65.createElement(React65.Fragment, null, /* @__PURE__ */ React65.createElement("iframe", {
41436
41540
  id: IFRAME_ID_SELECTOR,
41437
41541
  onLoad: () => dispatch({ type: "IFRAME_LOADED" }),
41438
41542
  ref: setIframe,
@@ -41484,8 +41588,8 @@ function useWebReader(args) {
41484
41588
  persistLastLocation = true,
41485
41589
  persistSettings = true
41486
41590
  } = args;
41487
- const [manifest, setManifest] = React65.useState(null);
41488
- const [error2, setError] = React65.useState(null);
41591
+ const [manifest, setManifest] = React66.useState(null);
41592
+ const [error2, setError] = React66.useState(null);
41489
41593
  if (error2) {
41490
41594
  throw error2;
41491
41595
  }
@@ -41511,14 +41615,15 @@ function useWebReader(args) {
41511
41615
  persistLastLocation,
41512
41616
  persistSettings
41513
41617
  } : void 0);
41514
- React65.useEffect(() => {
41618
+ React66.useEffect(() => {
41515
41619
  fetchJson(webpubManifestUrl).then(setManifest).catch(setError);
41516
41620
  }, [webpubManifestUrl]);
41517
41621
  if (manifest === null) {
41518
41622
  return {
41519
41623
  isLoading: true,
41520
- content: /* @__PURE__ */ React65.createElement(LoadingSkeleton, {
41521
- height
41624
+ content: /* @__PURE__ */ React66.createElement(LoadingSkeleton, {
41625
+ height,
41626
+ state: htmlReader == null ? void 0 : htmlReader.state
41522
41627
  }),
41523
41628
  manifest: null,
41524
41629
  navigator: null,
@@ -41536,7 +41641,7 @@ function useWebReader(args) {
41536
41641
  }
41537
41642
 
41538
41643
  // src/ServiceWorker/client.ts
41539
- import React66 from "react";
41644
+ import React67 from "react";
41540
41645
 
41541
41646
  // src/ServiceWorker/constants.ts
41542
41647
  var PRECACHE_PUBLICATIONS = "PRECACHE_PUBLICATIONS";
@@ -41544,7 +41649,7 @@ var CACHE_EXPIRATION_SECONDS = 7 * 24 * 60 * 60;
41544
41649
 
41545
41650
  // src/ServiceWorker/client.ts
41546
41651
  function usePublicationSW(publications) {
41547
- React66.useEffect(() => {
41652
+ React67.useEffect(() => {
41548
41653
  var _a;
41549
41654
  if ("serviceWorker" in navigator) {
41550
41655
  const message = {
@@ -41575,12 +41680,12 @@ var WebReaderWithoutBoundary = (_a) => {
41575
41680
  getContent
41576
41681
  }, props));
41577
41682
  const { content } = webReader;
41578
- return /* @__PURE__ */ React67.createElement(manager_default, __spreadValues({
41683
+ return /* @__PURE__ */ React68.createElement(manager_default, __spreadValues({
41579
41684
  headerLeft
41580
41685
  }, webReader), content);
41581
41686
  };
41582
41687
  var WebReader = (props) => {
41583
- return /* @__PURE__ */ React67.createElement(ErrorBoundary_default, __spreadValues({}, props), /* @__PURE__ */ React67.createElement(WebReaderWithoutBoundary, __spreadValues({}, props)));
41688
+ return /* @__PURE__ */ React68.createElement(ErrorBoundary_default, __spreadValues({}, props), /* @__PURE__ */ React68.createElement(WebReaderWithoutBoundary, __spreadValues({}, props)));
41584
41689
  };
41585
41690
  var src_default = WebReader;
41586
41691
  export {
@@ -41604,20 +41709,6 @@ export {
41604
41709
  usePublicationSW,
41605
41710
  useWebReader
41606
41711
  };
41607
- /*! *****************************************************************************
41608
- Copyright (c) Microsoft Corporation.
41609
-
41610
- Permission to use, copy, modify, and/or distribute this software for any
41611
- purpose with or without fee is hereby granted.
41612
-
41613
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
41614
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
41615
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
41616
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
41617
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
41618
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41619
- PERFORMANCE OF THIS SOFTWARE.
41620
- ***************************************************************************** */
41621
41712
  /** @license React v16.13.1
41622
41713
  * react-is.production.min.js
41623
41714
  *