@d-i-t-a/reader 2.1.0-beta.4 → 2.1.0-beta.7

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
@@ -13677,6 +13677,231 @@ and ensure you are accounting for this risk.
13677
13677
  }
13678
13678
  });
13679
13679
 
13680
+ // node_modules/loglevel/lib/loglevel.js
13681
+ var require_loglevel = __commonJS({
13682
+ "node_modules/loglevel/lib/loglevel.js"(exports, module) {
13683
+ init_polyfills();
13684
+ (function(root, definition) {
13685
+ "use strict";
13686
+ if (typeof define === "function" && define.amd) {
13687
+ define(definition);
13688
+ } else if (typeof module === "object" && module.exports) {
13689
+ module.exports = definition();
13690
+ } else {
13691
+ root.log = definition();
13692
+ }
13693
+ })(exports, function() {
13694
+ "use strict";
13695
+ var noop = function() {
13696
+ };
13697
+ var undefinedType = "undefined";
13698
+ var isIE2 = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
13699
+ var logMethods = [
13700
+ "trace",
13701
+ "debug",
13702
+ "info",
13703
+ "warn",
13704
+ "error"
13705
+ ];
13706
+ function bindMethod(obj, methodName) {
13707
+ var method = obj[methodName];
13708
+ if (typeof method.bind === "function") {
13709
+ return method.bind(obj);
13710
+ } else {
13711
+ try {
13712
+ return Function.prototype.bind.call(method, obj);
13713
+ } catch (e) {
13714
+ return function() {
13715
+ return Function.prototype.apply.apply(method, [obj, arguments]);
13716
+ };
13717
+ }
13718
+ }
13719
+ }
13720
+ function traceForIE() {
13721
+ if (console.log) {
13722
+ if (console.log.apply) {
13723
+ console.log.apply(console, arguments);
13724
+ } else {
13725
+ Function.prototype.apply.apply(console.log, [console, arguments]);
13726
+ }
13727
+ }
13728
+ if (console.trace)
13729
+ console.trace();
13730
+ }
13731
+ function realMethod(methodName) {
13732
+ if (methodName === "debug") {
13733
+ methodName = "log";
13734
+ }
13735
+ if (typeof console === undefinedType) {
13736
+ return false;
13737
+ } else if (methodName === "trace" && isIE2) {
13738
+ return traceForIE;
13739
+ } else if (console[methodName] !== void 0) {
13740
+ return bindMethod(console, methodName);
13741
+ } else if (console.log !== void 0) {
13742
+ return bindMethod(console, "log");
13743
+ } else {
13744
+ return noop;
13745
+ }
13746
+ }
13747
+ function replaceLoggingMethods(level, loggerName) {
13748
+ for (var i = 0; i < logMethods.length; i++) {
13749
+ var methodName = logMethods[i];
13750
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, loggerName);
13751
+ }
13752
+ this.log = this.debug;
13753
+ }
13754
+ function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
13755
+ return function() {
13756
+ if (typeof console !== undefinedType) {
13757
+ replaceLoggingMethods.call(this, level, loggerName);
13758
+ this[methodName].apply(this, arguments);
13759
+ }
13760
+ };
13761
+ }
13762
+ function defaultMethodFactory(methodName, level, loggerName) {
13763
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
13764
+ }
13765
+ function Logger(name, defaultLevel, factory) {
13766
+ var self2 = this;
13767
+ var currentLevel;
13768
+ defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
13769
+ var storageKey = "loglevel";
13770
+ if (typeof name === "string") {
13771
+ storageKey += ":" + name;
13772
+ } else if (typeof name === "symbol") {
13773
+ storageKey = void 0;
13774
+ }
13775
+ function persistLevelIfPossible(levelNum) {
13776
+ var levelName = (logMethods[levelNum] || "silent").toUpperCase();
13777
+ if (typeof window === undefinedType || !storageKey)
13778
+ return;
13779
+ try {
13780
+ window.localStorage[storageKey] = levelName;
13781
+ return;
13782
+ } catch (ignore) {
13783
+ }
13784
+ try {
13785
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
13786
+ } catch (ignore) {
13787
+ }
13788
+ }
13789
+ function getPersistedLevel() {
13790
+ var storedLevel;
13791
+ if (typeof window === undefinedType || !storageKey)
13792
+ return;
13793
+ try {
13794
+ storedLevel = window.localStorage[storageKey];
13795
+ } catch (ignore) {
13796
+ }
13797
+ if (typeof storedLevel === undefinedType) {
13798
+ try {
13799
+ var cookie = window.document.cookie;
13800
+ var location = cookie.indexOf(encodeURIComponent(storageKey) + "=");
13801
+ if (location !== -1) {
13802
+ storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
13803
+ }
13804
+ } catch (ignore) {
13805
+ }
13806
+ }
13807
+ if (self2.levels[storedLevel] === void 0) {
13808
+ storedLevel = void 0;
13809
+ }
13810
+ return storedLevel;
13811
+ }
13812
+ function clearPersistedLevel() {
13813
+ if (typeof window === undefinedType || !storageKey)
13814
+ return;
13815
+ try {
13816
+ window.localStorage.removeItem(storageKey);
13817
+ return;
13818
+ } catch (ignore) {
13819
+ }
13820
+ try {
13821
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
13822
+ } catch (ignore) {
13823
+ }
13824
+ }
13825
+ self2.name = name;
13826
+ self2.levels = {
13827
+ "TRACE": 0,
13828
+ "DEBUG": 1,
13829
+ "INFO": 2,
13830
+ "WARN": 3,
13831
+ "ERROR": 4,
13832
+ "SILENT": 5
13833
+ };
13834
+ self2.methodFactory = factory || defaultMethodFactory;
13835
+ self2.getLevel = function() {
13836
+ return currentLevel;
13837
+ };
13838
+ self2.setLevel = function(level, persist) {
13839
+ if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
13840
+ level = self2.levels[level.toUpperCase()];
13841
+ }
13842
+ if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
13843
+ currentLevel = level;
13844
+ if (persist !== false) {
13845
+ persistLevelIfPossible(level);
13846
+ }
13847
+ replaceLoggingMethods.call(self2, level, name);
13848
+ if (typeof console === undefinedType && level < self2.levels.SILENT) {
13849
+ return "No console available for logging";
13850
+ }
13851
+ } else {
13852
+ throw "log.setLevel() called with invalid level: " + level;
13853
+ }
13854
+ };
13855
+ self2.setDefaultLevel = function(level) {
13856
+ defaultLevel = level;
13857
+ if (!getPersistedLevel()) {
13858
+ self2.setLevel(level, false);
13859
+ }
13860
+ };
13861
+ self2.resetLevel = function() {
13862
+ self2.setLevel(defaultLevel, false);
13863
+ clearPersistedLevel();
13864
+ };
13865
+ self2.enableAll = function(persist) {
13866
+ self2.setLevel(self2.levels.TRACE, persist);
13867
+ };
13868
+ self2.disableAll = function(persist) {
13869
+ self2.setLevel(self2.levels.SILENT, persist);
13870
+ };
13871
+ var initialLevel = getPersistedLevel();
13872
+ if (initialLevel == null) {
13873
+ initialLevel = defaultLevel;
13874
+ }
13875
+ self2.setLevel(initialLevel, false);
13876
+ }
13877
+ var defaultLogger = new Logger();
13878
+ var _loggersByName = {};
13879
+ defaultLogger.getLogger = function getLogger(name) {
13880
+ if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
13881
+ throw new TypeError("You must supply a name when creating a logger.");
13882
+ }
13883
+ var logger = _loggersByName[name];
13884
+ if (!logger) {
13885
+ logger = _loggersByName[name] = new Logger(name, defaultLogger.getLevel(), defaultLogger.methodFactory);
13886
+ }
13887
+ return logger;
13888
+ };
13889
+ var _log = typeof window !== undefinedType ? window.log : void 0;
13890
+ defaultLogger.noConflict = function() {
13891
+ if (typeof window !== undefinedType && window.log === defaultLogger) {
13892
+ window.log = _log;
13893
+ }
13894
+ return defaultLogger;
13895
+ };
13896
+ defaultLogger.getLoggers = function getLoggers() {
13897
+ return _loggersByName;
13898
+ };
13899
+ defaultLogger["default"] = defaultLogger;
13900
+ return defaultLogger;
13901
+ });
13902
+ }
13903
+ });
13904
+
13680
13905
  // node_modules/debounce/index.js
13681
13906
  var require_debounce = __commonJS({
13682
13907
  "node_modules/debounce/index.js"(exports, module) {
@@ -34597,15 +34822,6 @@ function setAttr(element, attr, value) {
34597
34822
  element.setAttribute(attr, value);
34598
34823
  }
34599
34824
 
34600
- // src/utils/index.ts
34601
- init_polyfills();
34602
- function delay(t, v) {
34603
- return new Promise(function(resolve) {
34604
- setTimeout(resolve.bind(null, v), t);
34605
- });
34606
- }
34607
- var IS_DEV = false;
34608
-
34609
34825
  // src/utils/EventHandler.ts
34610
34826
  init_polyfills();
34611
34827
 
@@ -34811,6 +35027,7 @@ var Popup = class {
34811
35027
  };
34812
35028
 
34813
35029
  // src/utils/EventHandler.ts
35030
+ var import_loglevel = __toModule(require_loglevel());
34814
35031
  function addEventListenerOptional(element, eventType, eventListener) {
34815
35032
  if (element) {
34816
35033
  element.addEventListener(eventType, eventListener, true);
@@ -34842,20 +35059,17 @@ var EventHandler = class {
34842
35059
  return !link.Rel?.includes("external") && this.navigator.publication.getRelativeHref(clickedHref).includes(link.Href);
34843
35060
  });
34844
35061
  this.isReadingOrderInternal = (clickedLink) => {
34845
- if (IS_DEV)
34846
- console.log("clickedLink: ", clickedLink);
35062
+ import_loglevel.default.log("clickedLink: ", clickedLink);
34847
35063
  const isEpubInternal = this.linkInPublication(this.navigator.publication.readingOrder, clickedLink.href);
34848
35064
  return isEpubInternal;
34849
35065
  };
34850
35066
  this.isResourceInternal = (clickedLink) => {
34851
- if (IS_DEV)
34852
- console.log("clickedLink: ", clickedLink);
35067
+ import_loglevel.default.log("clickedLink: ", clickedLink);
34853
35068
  const isEpubInternal = this.linkInPublication(this.navigator.publication.resources, clickedLink.href);
34854
35069
  return isEpubInternal;
34855
35070
  };
34856
35071
  this.handleLinks = async (event) => {
34857
- if (IS_DEV)
34858
- console.log("R2 Click Handler");
35072
+ import_loglevel.default.log("R2 Click Handler");
34859
35073
  const link = this.checkForLink(event);
34860
35074
  if (link) {
34861
35075
  const isSameOrigin = window.location.protocol === link.protocol && window.location.port === link.port && window.location.hostname === link.hostname;
@@ -35352,6 +35566,7 @@ var FixedBookView = class {
35352
35566
  };
35353
35567
 
35354
35568
  // src/model/user-settings/UserSettings.ts
35569
+ var import_loglevel2 = __toModule(require_loglevel());
35355
35570
  var _UserSettings = class {
35356
35571
  constructor(store, headerMenu, api, injectables, layout) {
35357
35572
  this.USERSETTINGS = "userSetting";
@@ -35390,7 +35605,7 @@ var _UserSettings = class {
35390
35605
  }
35391
35606
  async isPaginated() {
35392
35607
  let scroll = await this.getPropertyAndFallback("verticalScroll", ReadiumCSS.SCROLL_KEY);
35393
- return scroll === false;
35608
+ return !scroll;
35394
35609
  }
35395
35610
  async isScrollMode() {
35396
35611
  return !await this.isPaginated();
@@ -35410,8 +35625,7 @@ var _UserSettings = class {
35410
35625
  prop.value = settings.verticalScroll;
35411
35626
  await settings.saveProperty(prop);
35412
35627
  }
35413
- if (IS_DEV)
35414
- console.log(settings.verticalScroll);
35628
+ import_loglevel2.default.log(settings.verticalScroll);
35415
35629
  }
35416
35630
  if (initialUserSettings.appearance) {
35417
35631
  settings.appearance = _UserSettings.appearanceValues.findIndex((el) => el === initialUserSettings.appearance);
@@ -35420,8 +35634,7 @@ var _UserSettings = class {
35420
35634
  prop.value = settings.appearance;
35421
35635
  await settings.saveProperty(prop);
35422
35636
  }
35423
- if (IS_DEV)
35424
- console.log(settings.appearance);
35637
+ import_loglevel2.default.log(settings.appearance);
35425
35638
  }
35426
35639
  if (initialUserSettings.fontSize) {
35427
35640
  settings.fontSize = initialUserSettings.fontSize;
@@ -35430,8 +35643,7 @@ var _UserSettings = class {
35430
35643
  prop.value = settings.fontSize;
35431
35644
  await settings.saveProperty(prop);
35432
35645
  }
35433
- if (IS_DEV)
35434
- console.log(settings.fontSize);
35646
+ import_loglevel2.default.log(settings.fontSize);
35435
35647
  }
35436
35648
  if (initialUserSettings.fontFamily) {
35437
35649
  settings.fontFamily = _UserSettings.fontFamilyValues.findIndex((el) => el === initialUserSettings.fontFamily);
@@ -35440,8 +35652,7 @@ var _UserSettings = class {
35440
35652
  prop.value = settings.fontFamily;
35441
35653
  await settings.saveProperty(prop);
35442
35654
  }
35443
- if (IS_DEV)
35444
- console.log(settings.fontFamily);
35655
+ import_loglevel2.default.log(settings.fontFamily);
35445
35656
  if (settings.fontFamily !== 0) {
35446
35657
  settings.fontOverride = true;
35447
35658
  }
@@ -35453,8 +35664,7 @@ var _UserSettings = class {
35453
35664
  prop.value = settings.textAlignment;
35454
35665
  await settings.saveProperty(prop);
35455
35666
  }
35456
- if (IS_DEV)
35457
- console.log(settings.textAlignment);
35667
+ import_loglevel2.default.log(settings.textAlignment);
35458
35668
  }
35459
35669
  if (initialUserSettings.columnCount) {
35460
35670
  settings.columnCount = _UserSettings.columnCountValues.findIndex((el) => el === initialUserSettings.columnCount);
@@ -35463,8 +35673,7 @@ var _UserSettings = class {
35463
35673
  prop.value = settings.columnCount;
35464
35674
  await settings.saveProperty(prop);
35465
35675
  }
35466
- if (IS_DEV)
35467
- console.log(settings.columnCount);
35676
+ import_loglevel2.default.log(settings.columnCount);
35468
35677
  }
35469
35678
  if (initialUserSettings.wordSpacing) {
35470
35679
  settings.wordSpacing = initialUserSettings.wordSpacing;
@@ -35473,8 +35682,7 @@ var _UserSettings = class {
35473
35682
  prop.value = settings.wordSpacing;
35474
35683
  await settings.saveProperty(prop);
35475
35684
  }
35476
- if (IS_DEV)
35477
- console.log(settings.wordSpacing);
35685
+ import_loglevel2.default.log(settings.wordSpacing);
35478
35686
  }
35479
35687
  if (initialUserSettings.letterSpacing) {
35480
35688
  settings.letterSpacing = initialUserSettings.letterSpacing;
@@ -35483,8 +35691,7 @@ var _UserSettings = class {
35483
35691
  prop.value = settings.letterSpacing;
35484
35692
  await settings.saveProperty(prop);
35485
35693
  }
35486
- if (IS_DEV)
35487
- console.log(settings.letterSpacing);
35694
+ import_loglevel2.default.log(settings.letterSpacing);
35488
35695
  }
35489
35696
  if (initialUserSettings.pageMargins) {
35490
35697
  settings.pageMargins = initialUserSettings.pageMargins;
@@ -35493,8 +35700,7 @@ var _UserSettings = class {
35493
35700
  prop.value = settings.pageMargins;
35494
35701
  await settings.saveProperty(prop);
35495
35702
  }
35496
- if (IS_DEV)
35497
- console.log(settings.pageMargins);
35703
+ import_loglevel2.default.log(settings.pageMargins);
35498
35704
  }
35499
35705
  if (initialUserSettings.lineHeight) {
35500
35706
  settings.lineHeight = initialUserSettings.lineHeight;
@@ -35503,8 +35709,7 @@ var _UserSettings = class {
35503
35709
  prop.value = settings.lineHeight;
35504
35710
  await settings.saveProperty(prop);
35505
35711
  }
35506
- if (IS_DEV)
35507
- console.log(settings.lineHeight);
35712
+ import_loglevel2.default.log(settings.lineHeight);
35508
35713
  }
35509
35714
  settings.userProperties = settings.getUserSettings();
35510
35715
  await settings.initialise();
@@ -35513,9 +35718,7 @@ var _UserSettings = class {
35513
35718
  return new Promise((resolve) => resolve(settings));
35514
35719
  }
35515
35720
  stop() {
35516
- if (IS_DEV) {
35517
- console.log("book settings stop");
35518
- }
35721
+ import_loglevel2.default.log("book settings stop");
35519
35722
  }
35520
35723
  async initialise() {
35521
35724
  this.appearance = await this.getPropertyAndFallback("appearance", ReadiumCSS.APPEARANCE_KEY);
@@ -35673,9 +35876,9 @@ var _UserSettings = class {
35673
35876
  this.view.iframe = iframe;
35674
35877
  }
35675
35878
  if (this.settingsView)
35676
- this.renderControls(this.settingsView);
35879
+ _UserSettings.renderControls(this.settingsView);
35677
35880
  }
35678
- renderControls(element) {
35881
+ static renderControls(element) {
35679
35882
  addEventListenerOptional(findElement(element, "ul"), "click", (event) => {
35680
35883
  event.stopPropagation();
35681
35884
  });
@@ -35722,9 +35925,7 @@ var _UserSettings = class {
35722
35925
  };
35723
35926
  if (this.api?.updateSettings) {
35724
35927
  this.api?.updateSettings(userSettings).then((_) => {
35725
- if (IS_DEV) {
35726
- console.log("api updated user settings", userSettings);
35727
- }
35928
+ import_loglevel2.default.log("api updated user settings", JSON.stringify(userSettings));
35728
35929
  });
35729
35930
  }
35730
35931
  }
@@ -36459,7 +36660,7 @@ var HighlightType;
36459
36660
 
36460
36661
  // src/modules/highlight/common/rect-utils.ts
36461
36662
  init_polyfills();
36462
- var IS_DEV2 = false;
36663
+ var import_loglevel3 = __toModule(require_loglevel());
36463
36664
  function getClientRectsNoOverlap(range, doNotMergeHorizontallyAlignedRects) {
36464
36665
  const rangeClientRects = range.getClientRects();
36465
36666
  return getClientRectsNoOverlap_(rangeClientRects, doNotMergeHorizontallyAlignedRects);
@@ -36486,24 +36687,16 @@ function getClientRectsNoOverlap_(clientRects, doNotMergeHorizontallyAlignedRect
36486
36687
  const bigEnough = rect.width * rect.height > minArea;
36487
36688
  if (!bigEnough) {
36488
36689
  if (newRects.length > 1) {
36489
- if (IS_DEV2) {
36490
- console.log("CLIENT RECT: remove small");
36491
- }
36690
+ import_loglevel3.default.log("CLIENT RECT: remove small");
36492
36691
  newRects.splice(j, 1);
36493
36692
  } else {
36494
- if (IS_DEV2) {
36495
- console.log("CLIENT RECT: remove small, but keep otherwise empty!");
36496
- }
36693
+ import_loglevel3.default.log("CLIENT RECT: remove small, but keep otherwise empty!");
36497
36694
  break;
36498
36695
  }
36499
36696
  }
36500
36697
  }
36501
- if (IS_DEV2) {
36502
- checkOverlaps(newRects);
36503
- }
36504
- if (IS_DEV2) {
36505
- console.log(`CLIENT RECT: reduced ${originalRects.length} --> ${newRects.length}`);
36506
- }
36698
+ checkOverlaps(newRects);
36699
+ import_loglevel3.default.log(`CLIENT RECT: reduced ${originalRects.length} --> ${newRects.length}`);
36507
36700
  return newRects;
36508
36701
  }
36509
36702
  function almostEqual(a, b, tolerance) {
@@ -36620,9 +36813,7 @@ function mergeTouchingRects(rects, tolerance, doNotMergeHorizontallyAlignedRects
36620
36813
  const rect1 = rects[i];
36621
36814
  const rect2 = rects[j];
36622
36815
  if (rect1 === rect2) {
36623
- if (IS_DEV2) {
36624
- console.log("mergeTouchingRects rect1 === rect2 ??!");
36625
- }
36816
+ import_loglevel3.default.log("mergeTouchingRects rect1 === rect2 ??!");
36626
36817
  continue;
36627
36818
  }
36628
36819
  const rectsLineUpVertically = almostEqual(rect1.top, rect2.top, tolerance) && almostEqual(rect1.bottom, rect2.bottom, tolerance);
@@ -36631,9 +36822,7 @@ function mergeTouchingRects(rects, tolerance, doNotMergeHorizontallyAlignedRects
36631
36822
  const aligned = rectsLineUpHorizontally && horizontalAllowed || rectsLineUpVertically && !rectsLineUpHorizontally;
36632
36823
  const canMerge = aligned && rectsTouchOrOverlap(rect1, rect2, tolerance);
36633
36824
  if (canMerge) {
36634
- if (IS_DEV2) {
36635
- console.log(`CLIENT RECT: merging two into one, VERTICAL: ${rectsLineUpVertically} HORIZONTAL: ${rectsLineUpHorizontally} (${doNotMergeHorizontallyAlignedRects})`);
36636
- }
36825
+ import_loglevel3.default.log(`CLIENT RECT: merging two into one, VERTICAL: ${rectsLineUpVertically} HORIZONTAL: ${rectsLineUpHorizontally} (${doNotMergeHorizontallyAlignedRects})`);
36637
36826
  const newRects = rects.filter((rect) => {
36638
36827
  return rect !== rect1 && rect !== rect2;
36639
36828
  });
@@ -36651,9 +36840,7 @@ function replaceOverlappingRects(rects) {
36651
36840
  const rect1 = rects[i];
36652
36841
  const rect2 = rects[j];
36653
36842
  if (rect1 === rect2) {
36654
- if (IS_DEV2) {
36655
- console.log("replaceOverlappingRects rect1 === rect2 ??!");
36656
- }
36843
+ import_loglevel3.default.log("replaceOverlappingRects rect1 === rect2 ??!");
36657
36844
  continue;
36658
36845
  }
36659
36846
  if (rectsTouchOrOverlap(rect1, rect2, -1)) {
@@ -36677,15 +36864,11 @@ function replaceOverlappingRects(rects) {
36677
36864
  toPreserve = rect1;
36678
36865
  }
36679
36866
  }
36680
- if (IS_DEV2) {
36681
- const toCheck = [];
36682
- toCheck.push(toPreserve);
36683
- Array.prototype.push.apply(toCheck, toAdd);
36684
- checkOverlaps(toCheck);
36685
- }
36686
- if (IS_DEV2) {
36687
- console.log(`CLIENT RECT: overlap, cut one rect into ${toAdd.length}`);
36688
- }
36867
+ const toCheck = [];
36868
+ toCheck.push(toPreserve);
36869
+ Array.prototype.push.apply(toCheck, toAdd);
36870
+ checkOverlaps(toCheck);
36871
+ import_loglevel3.default.log(`CLIENT RECT: overlap, cut one rect into ${toAdd.length}`);
36689
36872
  const newRects = rects.filter((rect) => {
36690
36873
  return rect !== toRemove;
36691
36874
  });
@@ -36707,9 +36890,7 @@ function removeContainedRects(rects, tolerance) {
36707
36890
  for (const rect of rects) {
36708
36891
  const bigEnough = rect.width > 1 && rect.height > 1;
36709
36892
  if (!bigEnough) {
36710
- if (IS_DEV2) {
36711
- console.log("CLIENT RECT: remove tiny");
36712
- }
36893
+ import_loglevel3.default.log("CLIENT RECT: remove tiny");
36713
36894
  rectsToKeep.delete(rect);
36714
36895
  continue;
36715
36896
  }
@@ -36721,9 +36902,7 @@ function removeContainedRects(rects, tolerance) {
36721
36902
  continue;
36722
36903
  }
36723
36904
  if (rectContains(possiblyContainingRect, rect, tolerance)) {
36724
- if (IS_DEV2) {
36725
- console.log("CLIENT RECT: remove contained");
36726
- }
36905
+ import_loglevel3.default.log("CLIENT RECT: remove contained");
36727
36906
  rectsToKeep.delete(rect);
36728
36907
  break;
36729
36908
  }
@@ -36748,46 +36927,38 @@ function checkOverlaps(rects) {
36748
36927
  if (!has2) {
36749
36928
  stillOverlappingRects.push(rect2);
36750
36929
  }
36751
- if (IS_DEV2) {
36752
- console.log("CLIENT RECT: overlap ---");
36753
- console.log(`#1 TOP:${rect1.top} BOTTOM:${rect1.bottom} LEFT:${rect1.left} RIGHT:${rect1.right} WIDTH:${rect1.width} HEIGHT:${rect1.height}`);
36754
- console.log(`#2 TOP:${rect2.top} BOTTOM:${rect2.bottom} LEFT:${rect2.left} RIGHT:${rect2.right} WIDTH:${rect2.width} HEIGHT:${rect2.height}`);
36755
- const xOverlap = getRectOverlapX(rect1, rect2);
36756
- console.log(`xOverlap: ${xOverlap}`);
36757
- const yOverlap = getRectOverlapY(rect1, rect2);
36758
- console.log(`yOverlap: ${yOverlap}`);
36759
- }
36930
+ import_loglevel3.default.log("CLIENT RECT: overlap ---");
36931
+ import_loglevel3.default.log(`#1 TOP:${rect1.top} BOTTOM:${rect1.bottom} LEFT:${rect1.left} RIGHT:${rect1.right} WIDTH:${rect1.width} HEIGHT:${rect1.height}`);
36932
+ import_loglevel3.default.log(`#2 TOP:${rect2.top} BOTTOM:${rect2.bottom} LEFT:${rect2.left} RIGHT:${rect2.right} WIDTH:${rect2.width} HEIGHT:${rect2.height}`);
36933
+ const xOverlap = getRectOverlapX(rect1, rect2);
36934
+ import_loglevel3.default.log(`xOverlap: ${xOverlap}`);
36935
+ const yOverlap = getRectOverlapY(rect1, rect2);
36936
+ import_loglevel3.default.log(`yOverlap: ${yOverlap}`);
36760
36937
  }
36761
36938
  }
36762
36939
  }
36763
36940
  }
36764
36941
  if (stillOverlappingRects.length) {
36765
- if (IS_DEV2) {
36766
- console.log(`CLIENT RECT: overlaps ${stillOverlappingRects.length}`);
36767
- }
36942
+ import_loglevel3.default.log(`CLIENT RECT: overlaps ${stillOverlappingRects.length}`);
36768
36943
  }
36769
36944
  }
36770
36945
 
36771
36946
  // src/modules/highlight/renderer/iframe/selection.ts
36772
36947
  init_polyfills();
36773
- var IS_DEV3 = false;
36948
+ var import_loglevel4 = __toModule(require_loglevel());
36774
36949
  function getCurrentSelectionInfo(win, getCssSelector) {
36775
36950
  const selection = win ? win.getSelection() : null;
36776
36951
  if (!selection) {
36777
36952
  return void 0;
36778
36953
  }
36779
36954
  if (selection.isCollapsed) {
36780
- if (IS_DEV3) {
36781
- console.log("^^^ SELECTION COLLAPSED.");
36782
- }
36955
+ import_loglevel4.default.log("^^^ SELECTION COLLAPSED.");
36783
36956
  return void 0;
36784
36957
  }
36785
36958
  const rawText = selection.toString();
36786
36959
  const cleanText = rawText.trim().replace(/\n/g, " ").replace(/\s\s+/g, " ");
36787
36960
  if (cleanText.length === 0) {
36788
- if (IS_DEV3) {
36789
- console.log("^^^ SELECTION TEXT EMPTY.");
36790
- }
36961
+ import_loglevel4.default.log("^^^ SELECTION TEXT EMPTY.");
36791
36962
  return void 0;
36792
36963
  }
36793
36964
  if (!selection.anchorNode || !selection.focusNode) {
@@ -36795,45 +36966,31 @@ function getCurrentSelectionInfo(win, getCssSelector) {
36795
36966
  }
36796
36967
  const r = selection.rangeCount === 1 ? selection.getRangeAt(0) : createOrderedRange(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
36797
36968
  if (!r || r.collapsed) {
36798
- if (IS_DEV3) {
36799
- console.log("$$$$$$$$$$$$$$$$$ CANNOT GET NON-COLLAPSED SELECTION RANGE?!");
36800
- }
36969
+ import_loglevel4.default.log("$$$$$$$$$$$$$$$$$ CANNOT GET NON-COLLAPSED SELECTION RANGE?!");
36801
36970
  return void 0;
36802
36971
  }
36803
36972
  const range = normalizeRange(r);
36804
- if (IS_DEV3) {
36805
- if (range.startContainer !== r.startContainer) {
36806
- if (IS_DEV3) {
36807
- console.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startContainer");
36808
- console.log(range.startContainer);
36809
- console.log(r.startContainer);
36810
- }
36811
- }
36812
- if (range.startOffset !== r.startOffset) {
36813
- if (IS_DEV3) {
36814
- console.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startOffset");
36815
- console.log(`${range.startOffset} !== ${r.startOffset}`);
36816
- }
36817
- }
36818
- if (range.endContainer !== r.endContainer) {
36819
- if (IS_DEV3) {
36820
- console.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endContainer");
36821
- console.log(range.endContainer);
36822
- console.log(r.endContainer);
36823
- }
36824
- }
36825
- if (range.endOffset !== r.endOffset) {
36826
- if (IS_DEV3) {
36827
- console.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endOffset");
36828
- console.log(`${range.endOffset} !== ${r.endOffset}`);
36829
- }
36830
- }
36973
+ if (range.startContainer !== r.startContainer) {
36974
+ import_loglevel4.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startContainer");
36975
+ import_loglevel4.default.log(range.startContainer);
36976
+ import_loglevel4.default.log(r.startContainer);
36977
+ }
36978
+ if (range.startOffset !== r.startOffset) {
36979
+ import_loglevel4.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startOffset");
36980
+ import_loglevel4.default.log(`${range.startOffset} !== ${r.startOffset}`);
36981
+ }
36982
+ if (range.endContainer !== r.endContainer) {
36983
+ import_loglevel4.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endContainer");
36984
+ import_loglevel4.default.log(range.endContainer);
36985
+ import_loglevel4.default.log(r.endContainer);
36986
+ }
36987
+ if (range.endOffset !== r.endOffset) {
36988
+ import_loglevel4.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endOffset");
36989
+ import_loglevel4.default.log(`${range.endOffset} !== ${r.endOffset}`);
36831
36990
  }
36832
36991
  const rangeInfo = convertRange(range, getCssSelector);
36833
36992
  if (!rangeInfo) {
36834
- if (IS_DEV3) {
36835
- console.log("^^^ SELECTION RANGE INFO FAIL?!");
36836
- }
36993
+ import_loglevel4.default.log("^^^ SELECTION RANGE INFO FAIL?!");
36837
36994
  return void 0;
36838
36995
  }
36839
36996
  return { rangeInfo, cleanText, rawText, range };
@@ -36844,26 +37001,18 @@ function createOrderedRange(startNode, startOffset, endNode, endOffset) {
36844
37001
  range.setStart(startNode, startOffset);
36845
37002
  range.setEnd(endNode, endOffset);
36846
37003
  if (!range.collapsed) {
36847
- if (IS_DEV3) {
36848
- console.log(">>> createOrderedRange RANGE OK");
36849
- }
37004
+ import_loglevel4.default.log(">>> createOrderedRange RANGE OK");
36850
37005
  return range;
36851
37006
  }
36852
- if (IS_DEV3) {
36853
- console.log(">>> createOrderedRange COLLAPSED ... RANGE REVERSE?");
36854
- }
37007
+ import_loglevel4.default.log(">>> createOrderedRange COLLAPSED ... RANGE REVERSE?");
36855
37008
  const rangeReverse = new Range();
36856
37009
  rangeReverse.setStart(endNode, endOffset);
36857
37010
  rangeReverse.setEnd(startNode, startOffset);
36858
37011
  if (!rangeReverse.collapsed) {
36859
- if (IS_DEV3) {
36860
- console.log(">>> createOrderedRange RANGE REVERSE OK.");
36861
- }
37012
+ import_loglevel4.default.log(">>> createOrderedRange RANGE REVERSE OK.");
36862
37013
  return range;
36863
37014
  }
36864
- if (IS_DEV3) {
36865
- console.log(">>> createOrderedRange RANGE REVERSE ALSO COLLAPSED?!");
36866
- }
37015
+ import_loglevel4.default.log(">>> createOrderedRange RANGE REVERSE ALSO COLLAPSED?!");
36867
37016
  return void 0;
36868
37017
  } catch (err) {
36869
37018
  console.warn(err.message);
@@ -36893,20 +37042,16 @@ function convertRange(range, getCssSelector) {
36893
37042
  const endContainerElementCssSelector = getCssSelector(endContainerElement);
36894
37043
  const commonElementAncestor = getCommonAncestorElement(range.startContainer, range.endContainer);
36895
37044
  if (!commonElementAncestor) {
36896
- if (IS_DEV3) {
36897
- console.log("^^^ NO RANGE COMMON ANCESTOR?!");
36898
- }
37045
+ import_loglevel4.default.log("^^^ NO RANGE COMMON ANCESTOR?!");
36899
37046
  return void 0;
36900
37047
  }
36901
37048
  if (range.commonAncestorContainer) {
36902
37049
  const rangeCommonAncestorElement = range.commonAncestorContainer.nodeType === Node.ELEMENT_NODE ? range.commonAncestorContainer : range.commonAncestorContainer.parentNode;
36903
37050
  if (rangeCommonAncestorElement && rangeCommonAncestorElement.nodeType === Node.ELEMENT_NODE) {
36904
37051
  if (commonElementAncestor !== rangeCommonAncestorElement) {
36905
- if (IS_DEV3) {
36906
- console.log(">>>>>> COMMON ANCESTOR CONTAINER DIFF??!");
36907
- console.log(getCssSelector(commonElementAncestor));
36908
- console.log(getCssSelector(rangeCommonAncestorElement));
36909
- }
37052
+ import_loglevel4.default.log(">>>>>> COMMON ANCESTOR CONTAINER DIFF??!");
37053
+ import_loglevel4.default.log(getCssSelector(commonElementAncestor));
37054
+ import_loglevel4.default.log(getCssSelector(rangeCommonAncestorElement));
36910
37055
  }
36911
37056
  }
36912
37057
  }
@@ -36926,47 +37071,35 @@ function convertRange(range, getCssSelector) {
36926
37071
  function convertRangeInfo(documant, rangeInfo) {
36927
37072
  const startElement = documant.querySelector(rangeInfo.startContainerElementCssSelector);
36928
37073
  if (!startElement) {
36929
- if (IS_DEV3) {
36930
- console.log("^^^ convertRangeInfo NO START ELEMENT CSS SELECTOR?!");
36931
- }
37074
+ import_loglevel4.default.log("^^^ convertRangeInfo NO START ELEMENT CSS SELECTOR?!");
36932
37075
  return void 0;
36933
37076
  }
36934
37077
  let startContainer = startElement;
36935
37078
  if (rangeInfo.startContainerChildTextNodeIndex >= 0) {
36936
37079
  if (rangeInfo.startContainerChildTextNodeIndex >= startElement.childNodes.length) {
36937
- if (IS_DEV3) {
36938
- console.log("^^^ convertRangeInfo rangeInfo.startContainerChildTextNodeIndex >= startElement.childNodes.length?!");
36939
- }
37080
+ import_loglevel4.default.log("^^^ convertRangeInfo rangeInfo.startContainerChildTextNodeIndex >= startElement.childNodes.length?!");
36940
37081
  return void 0;
36941
37082
  }
36942
37083
  startContainer = startElement.childNodes[rangeInfo.startContainerChildTextNodeIndex];
36943
37084
  if (startContainer.nodeType !== Node.TEXT_NODE) {
36944
- if (IS_DEV3) {
36945
- console.log("^^^ convertRangeInfo startContainer.nodeType !== Node.TEXT_NODE?!");
36946
- }
37085
+ import_loglevel4.default.log("^^^ convertRangeInfo startContainer.nodeType !== Node.TEXT_NODE?!");
36947
37086
  return void 0;
36948
37087
  }
36949
37088
  }
36950
37089
  const endElement = documant.querySelector(rangeInfo.endContainerElementCssSelector);
36951
37090
  if (!endElement) {
36952
- if (IS_DEV3) {
36953
- console.log("^^^ convertRangeInfo NO END ELEMENT CSS SELECTOR?!");
36954
- }
37091
+ import_loglevel4.default.log("^^^ convertRangeInfo NO END ELEMENT CSS SELECTOR?!");
36955
37092
  return void 0;
36956
37093
  }
36957
37094
  let endContainer = endElement;
36958
37095
  if (rangeInfo.endContainerChildTextNodeIndex >= 0) {
36959
37096
  if (rangeInfo.endContainerChildTextNodeIndex >= endElement.childNodes.length) {
36960
- if (IS_DEV3) {
36961
- console.log("^^^ convertRangeInfo rangeInfo.endContainerChildTextNodeIndex >= endElement.childNodes.length?!");
36962
- }
37097
+ import_loglevel4.default.log("^^^ convertRangeInfo rangeInfo.endContainerChildTextNodeIndex >= endElement.childNodes.length?!");
36963
37098
  return void 0;
36964
37099
  }
36965
37100
  endContainer = endElement.childNodes[rangeInfo.endContainerChildTextNodeIndex];
36966
37101
  if (endContainer.nodeType !== Node.TEXT_NODE) {
36967
- if (IS_DEV3) {
36968
- console.log("^^^ convertRangeInfo endContainer.nodeType !== Node.TEXT_NODE?!");
36969
- }
37102
+ import_loglevel4.default.log("^^^ convertRangeInfo endContainer.nodeType !== Node.TEXT_NODE?!");
36970
37103
  return void 0;
36971
37104
  }
36972
37105
  }
@@ -37373,6 +37506,7 @@ var icons = {
37373
37506
 
37374
37507
  // src/modules/highlight/TextHighlighter.ts
37375
37508
  var lodash = __toModule(require_lodash());
37509
+ var import_loglevel5 = __toModule(require_loglevel());
37376
37510
  var HighlightContainer;
37377
37511
  (function(HighlightContainer2) {
37378
37512
  HighlightContainer2["R2_ID_HIGHLIGHTS_CONTAINER"] = "R2_ID_HIGHLIGHTS_CONTAINER";
@@ -38150,9 +38284,7 @@ var TextHighlighter = class {
38150
38284
  anno.highlight.note = prompt("Add your note here:");
38151
38285
  }
38152
38286
  self3.delegate.annotationModule?.updateAnnotation(anno).then(async () => {
38153
- if (IS_DEV) {
38154
- console.log("update highlight " + anno.id);
38155
- }
38287
+ import_loglevel5.default.log("update highlight " + anno.id);
38156
38288
  });
38157
38289
  }
38158
38290
  });
@@ -38339,11 +38471,9 @@ var TextHighlighter = class {
38339
38471
  range.detach();
38340
38472
  return rect;
38341
38473
  } catch (error) {
38342
- if (IS_DEV) {
38343
- console.log("measureTextNode " + error);
38344
- console.log("measureTextNode " + node);
38345
- console.log(node.textContent);
38346
- }
38474
+ import_loglevel5.default.log("measureTextNode " + error);
38475
+ import_loglevel5.default.log("measureTextNode " + node);
38476
+ import_loglevel5.default.log(`${node.textContent}`);
38347
38477
  }
38348
38478
  };
38349
38479
  const body = findRequiredIframeElement(doc, "body");
@@ -38795,9 +38925,7 @@ var TextHighlighter = class {
38795
38925
  const payload = {
38796
38926
  highlight: foundHighlight
38797
38927
  };
38798
- if (IS_DEV) {
38799
- console.log(payload);
38800
- }
38928
+ import_loglevel5.default.log(JSON.stringify(payload));
38801
38929
  let self2 = this;
38802
38930
  let anno;
38803
38931
  if (self2.delegate.rights.enableAnnotations) {
@@ -38810,9 +38938,7 @@ var TextHighlighter = class {
38810
38938
  });
38811
38939
  }
38812
38940
  if (anno?.id) {
38813
- if (IS_DEV) {
38814
- console.log("selected highlight " + anno.id);
38815
- }
38941
+ import_loglevel5.default.log("selected highlight " + anno.id);
38816
38942
  self2.lastSelectedHighlight = anno.id;
38817
38943
  let toolbox = document.getElementById("highlight-toolbox");
38818
38944
  if (toolbox) {
@@ -38822,9 +38948,7 @@ var TextHighlighter = class {
38822
38948
  let noteH = function() {
38823
38949
  anno.highlight.note = prompt("Add your note here:");
38824
38950
  self2.delegate.annotationModule?.updateAnnotation(anno).then(async () => {
38825
- if (IS_DEV) {
38826
- console.log("update highlight " + anno.id);
38827
- }
38951
+ import_loglevel5.default.log("update highlight " + anno.id);
38828
38952
  if (toolbox) {
38829
38953
  toolbox.style.display = "none";
38830
38954
  }
@@ -38838,9 +38962,7 @@ var TextHighlighter = class {
38838
38962
  }, deleteH = function() {
38839
38963
  if (self2.delegate.rights.enableAnnotations) {
38840
38964
  self2.delegate.annotationModule?.deleteSelectedHighlight(anno).then(async () => {
38841
- if (IS_DEV) {
38842
- console.log("delete highlight " + anno.id);
38843
- }
38965
+ import_loglevel5.default.log("delete highlight " + anno.id);
38844
38966
  if (toolbox) {
38845
38967
  toolbox.style.display = "none";
38846
38968
  }
@@ -38848,9 +38970,7 @@ var TextHighlighter = class {
38848
38970
  });
38849
38971
  } else if (self2.delegate.rights.enableBookmarks) {
38850
38972
  self2.delegate.bookmarkModule?.deleteSelectedHighlight(anno).then(async () => {
38851
- if (IS_DEV) {
38852
- console.log("delete highlight " + anno.id);
38853
- }
38973
+ import_loglevel5.default.log("delete highlight " + anno.id);
38854
38974
  if (toolbox) {
38855
38975
  toolbox.style.display = "none";
38856
38976
  }
@@ -38919,7 +39039,7 @@ var TextHighlighter = class {
38919
39039
  popup.showPopup(foundElement.dataset.definition, ev);
38920
39040
  }
38921
39041
  let result = this.delegate.definitionsModule?.properties?.definitions?.filter((el) => el.order === Number(foundElement?.dataset.order))[0];
38922
- console.log(result);
39042
+ import_loglevel5.default.log(result);
38923
39043
  if (this.delegate.definitionsModule?.api?.click) {
38924
39044
  this.delegate.definitionsModule.api?.click(lodash.omit(result, "callbacks"), lodash.omit(foundHighlight, "definition"));
38925
39045
  this.delegate.emit("definition.click", result, foundHighlight);
@@ -39289,9 +39409,7 @@ var TextHighlighter = class {
39289
39409
  } else if (self2.delegate.rights.enableBookmarks) {
39290
39410
  anno = await self2.delegate.bookmarkModule?.getAnnotationByID(highlight.id);
39291
39411
  }
39292
- if (IS_DEV) {
39293
- console.log("selected highlight " + anno.id);
39294
- }
39412
+ import_loglevel5.default.log("selected highlight " + anno.id);
39295
39413
  self2.lastSelectedHighlight = anno.id;
39296
39414
  let toolbox = document.getElementById("highlight-toolbox");
39297
39415
  if (toolbox) {
@@ -39301,9 +39419,7 @@ var TextHighlighter = class {
39301
39419
  let noteH = function() {
39302
39420
  anno.highlight.note = prompt("Add your note here:");
39303
39421
  self2.delegate.annotationModule?.updateAnnotation(anno).then(async () => {
39304
- if (IS_DEV) {
39305
- console.log("update highlight " + anno.id);
39306
- }
39422
+ import_loglevel5.default.log("update highlight " + anno.id);
39307
39423
  toolbox.style.display = "none";
39308
39424
  self2.selectionMenuClosed();
39309
39425
  });
@@ -39312,17 +39428,13 @@ var TextHighlighter = class {
39312
39428
  }, deleteH = function() {
39313
39429
  if (self2.delegate.rights.enableAnnotations) {
39314
39430
  self2.delegate.annotationModule?.deleteSelectedHighlight(anno).then(async () => {
39315
- if (IS_DEV) {
39316
- console.log("delete highlight " + anno.id);
39317
- }
39431
+ import_loglevel5.default.log("delete highlight " + anno.id);
39318
39432
  toolbox.style.display = "none";
39319
39433
  self2.selectionMenuClosed();
39320
39434
  });
39321
39435
  } else if (self2.delegate.rights.enableBookmarks) {
39322
39436
  self2.delegate.bookmarkModule?.deleteSelectedHighlight(anno).then(async () => {
39323
- if (IS_DEV) {
39324
- console.log("delete highlight " + anno.id);
39325
- }
39437
+ import_loglevel5.default.log("delete highlight " + anno.id);
39326
39438
  toolbox.style.display = "none";
39327
39439
  self2.selectionMenuClosed();
39328
39440
  });
@@ -39441,6 +39553,7 @@ var import_uuid = __toModule(require_uuid());
39441
39553
 
39442
39554
  // src/modules/highlight/common/selection.ts
39443
39555
  init_polyfills();
39556
+ var import_loglevel6 = __toModule(require_loglevel());
39444
39557
  var _getCssSelectorOptions = {
39445
39558
  className: (_str) => {
39446
39559
  return true;
@@ -39455,6 +39568,7 @@ var _getCssSelectorOptions = {
39455
39568
 
39456
39569
  // src/modules/AnnotationModule.ts
39457
39570
  var lodash2 = __toModule(require_lodash());
39571
+ var import_loglevel7 = __toModule(require_loglevel());
39458
39572
  var AnnotationModule = class {
39459
39573
  constructor(annotator, rights, publication, delegate, initialAnnotations, properties, highlighter, api, headerMenu) {
39460
39574
  this.hide = findElement(document, "#menu-button-hide");
@@ -39475,9 +39589,7 @@ var AnnotationModule = class {
39475
39589
  return annotations;
39476
39590
  }
39477
39591
  async stop() {
39478
- if (IS_DEV) {
39479
- console.log("Annotation module stop");
39480
- }
39592
+ import_loglevel7.default.log("Annotation module stop");
39481
39593
  }
39482
39594
  async start() {
39483
39595
  this.delegate.annotationModule = this;
@@ -39560,8 +39672,8 @@ var AnnotationModule = class {
39560
39672
  return "";
39561
39673
  }
39562
39674
  } catch (err) {
39563
- console.log("uniqueCssSelector:");
39564
- console.log(err);
39675
+ import_loglevel7.default.log("uniqueCssSelector:");
39676
+ import_loglevel7.default.error(err);
39565
39677
  return "";
39566
39678
  }
39567
39679
  };
@@ -39582,9 +39694,7 @@ var AnnotationModule = class {
39582
39694
  let book = this.delegate.highlighter?.createHighlight(this.delegate.highlighter?.dom(doc.body).getWindow(), selectionInfo, menuItem.highlight.color, true, AnnotationMarker.Bookmark, menuItem.icon, menuItem.popup, menuItem.highlight.style);
39583
39695
  if (book) {
39584
39696
  this.saveAnnotation(book[0]).then((anno) => {
39585
- if (IS_DEV) {
39586
- console.log("saved bookmark " + anno.id);
39587
- }
39697
+ import_loglevel7.default.log("saved bookmark " + anno.id);
39588
39698
  });
39589
39699
  }
39590
39700
  }
@@ -39594,9 +39704,7 @@ var AnnotationModule = class {
39594
39704
  }
39595
39705
  }
39596
39706
  async scrollToHighlight(id2) {
39597
- if (IS_DEV) {
39598
- console.log("still need to scroll to " + id2);
39599
- }
39707
+ import_loglevel7.default.log("still need to scroll to " + id2);
39600
39708
  var position = await this.annotator?.getAnnotationPosition(id2, this.delegate.iframes[0].contentWindow);
39601
39709
  window.scrollTo(0, position - window.innerHeight / 3);
39602
39710
  }
@@ -39604,10 +39712,8 @@ var AnnotationModule = class {
39604
39712
  if (this.annotator) {
39605
39713
  let deleted = await this.annotator.deleteAnnotation(annotation.id);
39606
39714
  let added = await this.addAnnotation(annotation);
39607
- if (IS_DEV) {
39608
- console.log("Highlight deleted " + JSON.stringify(deleted));
39609
- console.log("Highlight added " + JSON.stringify(added));
39610
- }
39715
+ import_loglevel7.default.log("Highlight deleted " + JSON.stringify(deleted));
39716
+ import_loglevel7.default.log("Highlight added " + JSON.stringify(added));
39611
39717
  await this.showHighlights();
39612
39718
  await this.drawHighlights();
39613
39719
  return added;
@@ -39618,9 +39724,7 @@ var AnnotationModule = class {
39618
39724
  async deleteLocalHighlight(id2) {
39619
39725
  if (this.annotator) {
39620
39726
  var deleted = await this.annotator.deleteAnnotation(id2);
39621
- if (IS_DEV) {
39622
- console.log("Highlight deleted " + JSON.stringify(deleted));
39623
- }
39727
+ import_loglevel7.default.log("Highlight deleted " + JSON.stringify(deleted));
39624
39728
  await this.showHighlights();
39625
39729
  await this.drawHighlights();
39626
39730
  return deleted;
@@ -39983,23 +40087,17 @@ var AnnotationModule = class {
39983
40087
  this.delegate.stopReadAloud();
39984
40088
  this.delegate.navigate(locator);
39985
40089
  } else {
39986
- if (IS_DEV) {
39987
- console.log("annotation data missing: ", event);
39988
- }
40090
+ import_loglevel7.default.log("annotation data missing: ", event);
39989
40091
  }
39990
40092
  }
39991
40093
  handleAnnotationLinkDeleteClick(type, event, locator) {
39992
- if (IS_DEV) {
39993
- console.log("annotation data locator: ", locator);
39994
- }
40094
+ import_loglevel7.default.log("annotation data locator: ", locator);
39995
40095
  if (locator) {
39996
40096
  if (type === AnnotationType.Annotation) {
39997
40097
  this.deleteHighlight(locator);
39998
40098
  }
39999
40099
  } else {
40000
- if (IS_DEV) {
40001
- console.log("annotation data missing: ", event);
40002
- }
40100
+ import_loglevel7.default.log("annotation data missing: ", event);
40003
40101
  }
40004
40102
  }
40005
40103
  static readableTimestamp(timestamp) {
@@ -40017,6 +40115,7 @@ var AnnotationModule = class {
40017
40115
  // src/modules/BookmarkModule.ts
40018
40116
  init_polyfills();
40019
40117
  var import_uuid2 = __toModule(require_uuid());
40118
+ var import_loglevel8 = __toModule(require_loglevel());
40020
40119
  var BookmarkModule = class {
40021
40120
  static async create(config2) {
40022
40121
  const module = new this(config2.annotator, config2.rights || { enableBookmarks: false }, config2.publication, config2.delegate, config2, config2.initialAnnotations, config2.api, config2.headerMenu);
@@ -40034,9 +40133,7 @@ var BookmarkModule = class {
40034
40133
  this.api = api;
40035
40134
  }
40036
40135
  stop() {
40037
- if (IS_DEV) {
40038
- console.log("Bookmark module stop");
40039
- }
40136
+ import_loglevel8.default.log("Bookmark module stop");
40040
40137
  }
40041
40138
  async start() {
40042
40139
  this.delegate.bookmarkModule = this;
@@ -40086,17 +40183,13 @@ var BookmarkModule = class {
40086
40183
  if (this.api?.deleteBookmark) {
40087
40184
  await this.api?.deleteBookmark(bookmark);
40088
40185
  let deleted = await this.annotator.deleteBookmark(bookmark);
40089
- if (IS_DEV) {
40090
- console.log("Bookmark deleted " + JSON.stringify(deleted));
40091
- }
40186
+ import_loglevel8.default.log("Bookmark deleted " + JSON.stringify(deleted));
40092
40187
  await this.showBookmarks();
40093
40188
  await this.drawBookmarks();
40094
40189
  return deleted;
40095
40190
  } else {
40096
40191
  let deleted = await this.annotator.deleteBookmark(bookmark);
40097
- if (IS_DEV) {
40098
- console.log("Bookmark deleted " + JSON.stringify(deleted));
40099
- }
40192
+ import_loglevel8.default.log("Bookmark deleted " + JSON.stringify(deleted));
40100
40193
  await this.showBookmarks();
40101
40194
  await this.drawBookmarks();
40102
40195
  return deleted;
@@ -40153,20 +40246,15 @@ var BookmarkModule = class {
40153
40246
  if (result) {
40154
40247
  bookmark = result;
40155
40248
  }
40156
- if (IS_DEV)
40157
- console.log(bookmark);
40249
+ import_loglevel8.default.log(bookmark);
40158
40250
  let saved = this.annotator.saveBookmark(bookmark);
40159
- if (IS_DEV) {
40160
- console.log("Bookmark added " + JSON.stringify(saved));
40161
- }
40251
+ import_loglevel8.default.log("Bookmark added " + JSON.stringify(saved));
40162
40252
  this.showBookmarks();
40163
40253
  await this.drawBookmarks();
40164
40254
  return saved;
40165
40255
  } else {
40166
40256
  let saved = this.annotator.saveBookmark(bookmark);
40167
- if (IS_DEV) {
40168
- console.log("Bookmark added " + JSON.stringify(saved));
40169
- }
40257
+ import_loglevel8.default.log("Bookmark added " + JSON.stringify(saved));
40170
40258
  this.showBookmarks();
40171
40259
  await this.drawBookmarks();
40172
40260
  return saved;
@@ -40262,9 +40350,7 @@ var BookmarkModule = class {
40262
40350
  this.delegate.iframes[0].contentDocument?.getSelection()?.removeAllRanges();
40263
40351
  if (book) {
40264
40352
  return this.saveAnnotation(book[0]).then((anno) => {
40265
- if (IS_DEV) {
40266
- console.log("saved bookmark " + anno?.id);
40267
- }
40353
+ import_loglevel8.default.log("saved bookmark " + anno?.id);
40268
40354
  });
40269
40355
  }
40270
40356
  }
@@ -40442,9 +40528,7 @@ var BookmarkModule = class {
40442
40528
  async deleteLocalHighlight(id2) {
40443
40529
  if (this.annotator) {
40444
40530
  var deleted = await this.annotator.deleteAnnotation(id2);
40445
- if (IS_DEV) {
40446
- console.log("Highlight deleted " + JSON.stringify(deleted));
40447
- }
40531
+ import_loglevel8.default.log("Highlight deleted " + JSON.stringify(deleted));
40448
40532
  await this.showBookmarks();
40449
40533
  await this.drawBookmarks();
40450
40534
  return deleted;
@@ -40554,23 +40638,17 @@ var BookmarkModule = class {
40554
40638
  this.delegate.stopReadAloud();
40555
40639
  this.delegate.navigate(locator);
40556
40640
  } else {
40557
- if (IS_DEV) {
40558
- console.log("bookmark data missing: ", event);
40559
- }
40641
+ import_loglevel8.default.log("bookmark data missing: ", event);
40560
40642
  }
40561
40643
  }
40562
40644
  handleAnnotationLinkDeleteClick(type, event, locator) {
40563
- if (IS_DEV) {
40564
- console.log("bookmark data locator: ", locator);
40565
- }
40645
+ import_loglevel8.default.log("bookmark data locator: ", locator);
40566
40646
  if (locator) {
40567
40647
  if (type === AnnotationType.Bookmark) {
40568
40648
  this.deleteBookmark(locator);
40569
40649
  }
40570
40650
  } else {
40571
- if (IS_DEV) {
40572
- console.log("bookmark data missing: ", event);
40573
- }
40651
+ import_loglevel8.default.log("bookmark data missing: ", event);
40574
40652
  }
40575
40653
  }
40576
40654
  static readableTimestamp(timestamp) {
@@ -40591,6 +40669,7 @@ var import_media_overlay = __toModule(require_media_overlay());
40591
40669
 
40592
40670
  // src/modules/mediaoverlays/MediaOverlaySettings.ts
40593
40671
  init_polyfills();
40672
+ var import_loglevel9 = __toModule(require_loglevel());
40594
40673
  var R2_MO_CLASS_ACTIVE = "r2-mo-active";
40595
40674
  var _MEDIAOVERLAYREFS = class {
40596
40675
  };
@@ -40622,7 +40701,7 @@ var MediaOverlaySettings = class {
40622
40701
  this.api = api;
40623
40702
  this.headerMenu = headerMenu;
40624
40703
  this.initialise();
40625
- console.log(this.api);
40704
+ import_loglevel9.default.log(this.api);
40626
40705
  }
40627
40706
  static create(config2) {
40628
40707
  const settings = new this(config2.store, config2.api, config2.headerMenu);
@@ -40630,42 +40709,34 @@ var MediaOverlaySettings = class {
40630
40709
  let initialSettings = config2.initialMediaOverlaySettings;
40631
40710
  if (initialSettings?.color) {
40632
40711
  settings.color = initialSettings.color;
40633
- if (IS_DEV)
40634
- console.log(settings.color);
40712
+ import_loglevel9.default.log(settings.color);
40635
40713
  }
40636
40714
  if (initialSettings?.autoScroll) {
40637
40715
  settings.autoScroll = initialSettings.autoScroll;
40638
- if (IS_DEV)
40639
- console.log(settings.autoScroll);
40716
+ import_loglevel9.default.log(settings.autoScroll);
40640
40717
  }
40641
40718
  if (initialSettings?.autoTurn) {
40642
40719
  settings.autoTurn = initialSettings.autoTurn;
40643
- if (IS_DEV)
40644
- console.log(settings.autoTurn);
40720
+ import_loglevel9.default.log(settings.autoScroll);
40645
40721
  }
40646
40722
  if (initialSettings?.volume) {
40647
40723
  settings.volume = initialSettings.volume;
40648
- if (IS_DEV)
40649
- console.log(settings.volume);
40724
+ import_loglevel9.default.log(settings.volume);
40650
40725
  }
40651
40726
  if (initialSettings?.rate) {
40652
40727
  settings.rate = initialSettings.rate;
40653
- if (IS_DEV)
40654
- console.log(settings.rate);
40728
+ import_loglevel9.default.log(settings.rate);
40655
40729
  }
40656
40730
  if (initialSettings?.wait) {
40657
40731
  settings.wait = initialSettings.wait;
40658
- if (IS_DEV)
40659
- console.log(settings.wait);
40732
+ import_loglevel9.default.log(settings.wait);
40660
40733
  }
40661
40734
  }
40662
40735
  settings.initializeSelections();
40663
40736
  return settings;
40664
40737
  }
40665
40738
  stop() {
40666
- if (IS_DEV) {
40667
- console.log("MediaOverlay settings stop");
40668
- }
40739
+ import_loglevel9.default.log("MediaOverlay settings stop");
40669
40740
  }
40670
40741
  initialise() {
40671
40742
  this.autoScroll = this.getProperty(MEDIAOVERLAYREFS.AUTO_SCROLL_KEY) != null ? this.getProperty(MEDIAOVERLAYREFS.AUTO_SCROLL_KEY).value : this.autoScroll;
@@ -40731,9 +40802,7 @@ var MediaOverlaySettings = class {
40731
40802
  this.applyMediaOverlaySettings(syncSettings);
40732
40803
  if (this.api?.updateSettings) {
40733
40804
  this.api?.updateSettings(syncSettings).then(async (settings) => {
40734
- if (IS_DEV) {
40735
- console.log("api updated sync settings", settings);
40736
- }
40805
+ import_loglevel9.default.log("api updated sync settings", settings);
40737
40806
  });
40738
40807
  }
40739
40808
  }
@@ -40788,8 +40857,7 @@ var MediaOverlaySettings = class {
40788
40857
  this.settingsChangeCallback();
40789
40858
  }
40790
40859
  if (mediaOverlaySettings.autoScroll !== void 0) {
40791
- if (IS_DEV)
40792
- console.log("autoScroll " + this.autoScroll);
40860
+ import_loglevel9.default.log("autoScroll " + this.autoScroll);
40793
40861
  this.autoScroll = mediaOverlaySettings.autoScroll;
40794
40862
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.AUTO_SCROLL_REF);
40795
40863
  if (prop) {
@@ -40799,8 +40867,7 @@ var MediaOverlaySettings = class {
40799
40867
  this.settingsChangeCallback();
40800
40868
  }
40801
40869
  if (mediaOverlaySettings.autoTurn !== void 0) {
40802
- if (IS_DEV)
40803
- console.log("autoTurn " + this.autoTurn);
40870
+ import_loglevel9.default.log("autoTurn " + this.autoTurn);
40804
40871
  this.autoTurn = mediaOverlaySettings.autoTurn;
40805
40872
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.AUTO_TURN_REF);
40806
40873
  if (prop) {
@@ -40810,8 +40877,7 @@ var MediaOverlaySettings = class {
40810
40877
  this.settingsChangeCallback();
40811
40878
  }
40812
40879
  if (mediaOverlaySettings.volume) {
40813
- if (IS_DEV)
40814
- console.log("volume " + this.volume);
40880
+ import_loglevel9.default.log("volume " + this.volume);
40815
40881
  this.volume = mediaOverlaySettings.volume;
40816
40882
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF);
40817
40883
  if (prop) {
@@ -40821,8 +40887,7 @@ var MediaOverlaySettings = class {
40821
40887
  this.settingsChangeCallback();
40822
40888
  }
40823
40889
  if (mediaOverlaySettings.rate) {
40824
- if (IS_DEV)
40825
- console.log("rate " + this.rate);
40890
+ import_loglevel9.default.log("rate " + this.rate);
40826
40891
  this.rate = mediaOverlaySettings.rate;
40827
40892
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF);
40828
40893
  if (prop) {
@@ -40900,6 +40965,7 @@ var MediaOverlaySettings = class {
40900
40965
  };
40901
40966
 
40902
40967
  // src/modules/mediaoverlays/MediaOverlayModule.ts
40968
+ var import_loglevel10 = __toModule(require_loglevel());
40903
40969
  var MediaOverlayModule = class {
40904
40970
  constructor(delegate, publication, settings, properties) {
40905
40971
  this.play = findElement(document, "#menu-button-play");
@@ -40908,8 +40974,7 @@ var MediaOverlayModule = class {
40908
40974
  this.pid = void 0;
40909
40975
  this.__ontimeupdate = false;
40910
40976
  this.ontimeupdate = async (_v) => {
40911
- if (IS_DEV)
40912
- console.log("ontimeupdate");
40977
+ import_loglevel10.default.log("ontimeupdate");
40913
40978
  this.trackCurrentTime();
40914
40979
  };
40915
40980
  this.ensureOnTimeUpdate = (remove, replace) => {
@@ -40942,13 +41007,11 @@ var MediaOverlayModule = class {
40942
41007
  return mediaOverlay;
40943
41008
  }
40944
41009
  stop() {
40945
- if (IS_DEV)
40946
- console.log("MediaOverlay module stop");
41010
+ import_loglevel10.default.log("MediaOverlay module stop");
40947
41011
  }
40948
41012
  start() {
40949
41013
  this.delegate.mediaOverlayModule = this;
40950
- if (IS_DEV)
40951
- console.log("MediaOverlay module start");
41014
+ import_loglevel10.default.log("MediaOverlay module start");
40952
41015
  }
40953
41016
  async initialize() {
40954
41017
  return new Promise(async (resolve) => {
@@ -40981,8 +41044,7 @@ var MediaOverlayModule = class {
40981
41044
  return;
40982
41045
  }
40983
41046
  if (!response.ok) {
40984
- if (IS_DEV)
40985
- console.log("BAD RESPONSE?!");
41047
+ import_loglevel10.default.log("BAD RESPONSE?!");
40986
41048
  }
40987
41049
  let moJson;
40988
41050
  try {
@@ -40991,8 +41053,7 @@ var MediaOverlayModule = class {
40991
41053
  console.error(e);
40992
41054
  }
40993
41055
  if (!moJson) {
40994
- if (IS_DEV)
40995
- console.log("## moJson" + moJson);
41056
+ import_loglevel10.default.log("## moJson" + moJson);
40996
41057
  return;
40997
41058
  }
40998
41059
  link.MediaOverlays = TaJsonDeserialize(moJson, import_media_overlay.MediaOverlayNode);
@@ -41078,8 +41139,7 @@ var MediaOverlayModule = class {
41078
41139
  }
41079
41140
  }
41080
41141
  findDepthFirstTextAudioPair(textHref, mo, textFragmentIDChain) {
41081
- if (IS_DEV)
41082
- console.log("findDepthFirstTextAudioPair()");
41142
+ import_loglevel10.default.log("findDepthFirstTextAudioPair()");
41083
41143
  let isTextUrlMatch;
41084
41144
  let isFragmentIDMatch;
41085
41145
  if (mo.Text) {
@@ -41100,21 +41160,16 @@ var MediaOverlayModule = class {
41100
41160
  isTextUrlMatch = false;
41101
41161
  }
41102
41162
  }
41103
- if (IS_DEV) {
41104
- console.log("isFragmentIDMatch: " + isFragmentIDMatch);
41105
- console.log("isTextUrlMatch: " + isTextUrlMatch);
41106
- }
41163
+ import_loglevel10.default.log("isFragmentIDMatch: " + isFragmentIDMatch);
41164
+ import_loglevel10.default.log("isTextUrlMatch: " + isTextUrlMatch);
41107
41165
  if (!mo.Children || !mo.Children.length) {
41108
- if (IS_DEV)
41109
- console.log("findDepthFirstTextAudioPair() - leaf text/audio pair");
41166
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - leaf text/audio pair");
41110
41167
  if (!isTextUrlMatch) {
41111
- if (IS_DEV)
41112
- console.log("findDepthFirstTextAudioPair() - leaf - !isTextUrlMatch");
41168
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - leaf - !isTextUrlMatch");
41113
41169
  return void 0;
41114
41170
  }
41115
41171
  if (isFragmentIDMatch || isTextUrlMatch && !textFragmentIDChain) {
41116
- if (IS_DEV)
41117
- console.log("findDepthFirstTextAudioPair() - leaf - isFragmentIDMatch || (isTextUrlMatch && !textFragmentIDChain");
41172
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - leaf - isFragmentIDMatch || (isTextUrlMatch && !textFragmentIDChain");
41118
41173
  return mo;
41119
41174
  }
41120
41175
  return void 0;
@@ -41122,34 +41177,25 @@ var MediaOverlayModule = class {
41122
41177
  const textFragmentIDChainOriginal = textFragmentIDChain;
41123
41178
  let frags = textFragmentIDChain;
41124
41179
  for (const child of mo.Children) {
41125
- if (IS_DEV) {
41126
- console.log("findDepthFirstTextAudioPair() - child");
41127
- console.log(JSON.stringify(child));
41128
- }
41180
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - child");
41181
+ import_loglevel10.default.log(JSON.stringify(child));
41129
41182
  const match = this.findDepthFirstTextAudioPair(textHref, child, frags);
41130
41183
  if (match === null) {
41131
- if (IS_DEV) {
41132
- console.log("findDepthFirstTextAudioPair() - child - match null (skip)");
41133
- }
41184
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - child - match null (skip)");
41134
41185
  frags = void 0;
41135
41186
  }
41136
41187
  if (match) {
41137
- if (IS_DEV) {
41138
- console.log("findDepthFirstTextAudioPair() - child - match");
41139
- console.log(JSON.stringify(match));
41140
- }
41188
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - child - match");
41189
+ import_loglevel10.default.log(JSON.stringify(match));
41141
41190
  return match;
41142
41191
  }
41143
41192
  }
41144
41193
  if (isFragmentIDMatch) {
41145
- if (IS_DEV)
41146
- console.log("findDepthFirstTextAudioPair() - post isFragmentIDMatch");
41194
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - post isFragmentIDMatch");
41147
41195
  const match = this.findDepthFirstTextAudioPair(textHref, mo, void 0);
41148
41196
  if (match) {
41149
- if (IS_DEV) {
41150
- console.log("findDepthFirstTextAudioPair() - post isFragmentIDMatch - match");
41151
- console.log(JSON.stringify(match));
41152
- }
41197
+ import_loglevel10.default.log("findDepthFirstTextAudioPair() - post isFragmentIDMatch - match");
41198
+ import_loglevel10.default.log(JSON.stringify(match));
41153
41199
  return match;
41154
41200
  } else {
41155
41201
  return match;
@@ -41165,8 +41211,7 @@ var MediaOverlayModule = class {
41165
41211
  if (this.mediaOverlayTextAudioPair) {
41166
41212
  try {
41167
41213
  if (this.currentAudioEnd && this.audioElement.currentTime >= this.currentAudioEnd - 0.05) {
41168
- if (IS_DEV)
41169
- console.log("ontimeupdate - mediaOverlaysNext()");
41214
+ import_loglevel10.default.log("ontimeupdate - mediaOverlaysNext()");
41170
41215
  this.mediaOverlaysNext();
41171
41216
  }
41172
41217
  const match_i = this.mediaOverlayTextAudioPair.Text.lastIndexOf("#");
@@ -41178,13 +41223,11 @@ var MediaOverlayModule = class {
41178
41223
  }
41179
41224
  }
41180
41225
  mediaOverlaysNext(escape2) {
41181
- if (IS_DEV)
41182
- console.log("mediaOverlaysNext()");
41226
+ import_loglevel10.default.log("mediaOverlaysNext()");
41183
41227
  if (this.mediaOverlayRoot && this.mediaOverlayTextAudioPair) {
41184
41228
  const nextTextAudioPair = this.findNextTextAudioPair(this.mediaOverlayRoot, this.mediaOverlayTextAudioPair, { prev: void 0 }, escape2 ? true : false);
41185
41229
  if (!nextTextAudioPair) {
41186
- if (IS_DEV)
41187
- console.log("mediaOverlaysNext() - navLeftOrRight()");
41230
+ import_loglevel10.default.log("mediaOverlaysNext() - navLeftOrRight()");
41188
41231
  this.mediaOverlaysStop();
41189
41232
  if (this.currentLinks.length > 1 && this.currentLinkIndex === 0) {
41190
41233
  this.currentLinkIndex++;
@@ -41204,25 +41247,21 @@ var MediaOverlayModule = class {
41204
41247
  const hrefUrlObj1 = new URL("https://dita.digital/" + this.mediaOverlayTextAudioPair.Text);
41205
41248
  const hrefUrlObj2 = new URL("https://dita.digital/" + nextTextAudioPair.Text);
41206
41249
  if (hrefUrlObj1.pathname !== hrefUrlObj2.pathname) {
41207
- if (IS_DEV) {
41208
- console.log("mediaOverlaysNext() SWITCH! " + hrefUrlObj1.pathname + " != " + hrefUrlObj2.pathname);
41209
- }
41250
+ import_loglevel10.default.log("mediaOverlaysNext() SWITCH! " + hrefUrlObj1.pathname + " != " + hrefUrlObj2.pathname);
41210
41251
  switchDoc = true;
41211
41252
  }
41212
41253
  }
41213
41254
  if (switchDoc) {
41214
41255
  this.mediaOverlaysStop();
41215
41256
  } else {
41216
- if (IS_DEV)
41217
- console.log("mediaOverlaysNext() - playMediaOverlaysAudio()");
41257
+ import_loglevel10.default.log("mediaOverlaysNext() - playMediaOverlaysAudio()");
41218
41258
  setTimeout(async () => {
41219
41259
  await this.playMediaOverlaysAudio(nextTextAudioPair, void 0, void 0);
41220
41260
  }, 0);
41221
41261
  }
41222
41262
  }
41223
41263
  } else {
41224
- if (IS_DEV)
41225
- console.log("mediaOverlaysNext() - navLeftOrRight() 2");
41264
+ import_loglevel10.default.log("mediaOverlaysNext() - navLeftOrRight() 2");
41226
41265
  this.mediaOverlaysStop();
41227
41266
  if (this.currentLinks.length > 1 && this.currentLinkIndex === 0) {
41228
41267
  this.currentLinkIndex++;
@@ -41239,15 +41278,13 @@ var MediaOverlayModule = class {
41239
41278
  }
41240
41279
  }
41241
41280
  mediaOverlaysStop() {
41242
- if (IS_DEV)
41243
- console.log("mediaOverlaysStop()");
41281
+ import_loglevel10.default.log("mediaOverlaysStop()");
41244
41282
  this.mediaOverlaysPause();
41245
41283
  this.mediaOverlayRoot = void 0;
41246
41284
  this.mediaOverlayTextAudioPair = void 0;
41247
41285
  }
41248
41286
  mediaOverlaysPause() {
41249
- if (IS_DEV)
41250
- console.log("mediaOverlaysPause()");
41287
+ import_loglevel10.default.log("mediaOverlaysPause()");
41251
41288
  this.mediaOverlayHighlight(void 0);
41252
41289
  if (this.audioElement) {
41253
41290
  this.audioElement.pause();
@@ -41256,36 +41293,28 @@ var MediaOverlayModule = class {
41256
41293
  findNextTextAudioPair(mo, moToMatch, previousMo, escape2) {
41257
41294
  if (!mo.Children || !mo.Children.length) {
41258
41295
  if (previousMo?.prev === moToMatch) {
41259
- if (IS_DEV)
41260
- console.log("findNextTextAudioPair() - prevMo === moToMatch");
41296
+ import_loglevel10.default.log("findNextTextAudioPair() - prevMo === moToMatch");
41261
41297
  return mo;
41262
41298
  }
41263
- if (IS_DEV) {
41264
- console.log("findNextTextAudioPair() - set previous");
41265
- console.log(JSON.stringify(mo));
41266
- }
41299
+ import_loglevel10.default.log("findNextTextAudioPair() - set previous");
41300
+ import_loglevel10.default.log(JSON.stringify(mo));
41267
41301
  previousMo.prev = mo;
41268
41302
  return void 0;
41269
41303
  }
41270
41304
  for (const child of mo.Children) {
41271
- if (IS_DEV) {
41272
- console.log("findNextTextAudioPair() - child");
41273
- console.log(JSON.stringify(child));
41274
- }
41305
+ import_loglevel10.default.log("findNextTextAudioPair() - child");
41306
+ import_loglevel10.default.log(JSON.stringify(child));
41275
41307
  const match = this.findNextTextAudioPair(child, moToMatch, previousMo, escape2);
41276
41308
  if (match) {
41277
- if (IS_DEV) {
41278
- console.log("findNextTextAudioPair() - match");
41279
- console.log(JSON.stringify(match));
41280
- }
41309
+ import_loglevel10.default.log("findNextTextAudioPair() - match");
41310
+ import_loglevel10.default.log(JSON.stringify(match));
41281
41311
  return match;
41282
41312
  }
41283
41313
  }
41284
41314
  return void 0;
41285
41315
  }
41286
41316
  async playMediaOverlaysAudio(moTextAudioPair, begin, end) {
41287
- if (IS_DEV)
41288
- console.log("playMediaOverlaysAudio()");
41317
+ import_loglevel10.default.log("playMediaOverlaysAudio()");
41289
41318
  this.mediaOverlayTextAudioPair = moTextAudioPair;
41290
41319
  if (!moTextAudioPair.Audio) {
41291
41320
  return;
@@ -41309,14 +41338,14 @@ var MediaOverlayModule = class {
41309
41338
  try {
41310
41339
  this.currentAudioBegin = parseFloat(b);
41311
41340
  } catch (err) {
41312
- console.log(err);
41341
+ import_loglevel10.default.error(err);
41313
41342
  }
41314
41343
  if (matches.length >= 3) {
41315
41344
  const e = matches[3];
41316
41345
  try {
41317
41346
  this.currentAudioEnd = parseFloat(e);
41318
41347
  } catch (err) {
41319
- console.log(err);
41348
+ import_loglevel10.default.error(err);
41320
41349
  }
41321
41350
  }
41322
41351
  }
@@ -41325,9 +41354,7 @@ var MediaOverlayModule = class {
41325
41354
  this.currentAudioBegin = begin;
41326
41355
  this.currentAudioEnd = end;
41327
41356
  }
41328
- if (IS_DEV) {
41329
- console.log(`${urlFull} => [${this.currentAudioBegin}-${this.currentAudioEnd}]`);
41330
- }
41357
+ import_loglevel10.default.log(`${urlFull} => [${this.currentAudioBegin}-${this.currentAudioEnd}]`);
41331
41358
  const playClip = async (initial) => {
41332
41359
  if (!this.audioElement) {
41333
41360
  return;
@@ -41335,9 +41362,7 @@ var MediaOverlayModule = class {
41335
41362
  const timeToSeekTo = this.currentAudioBegin ? this.currentAudioBegin : 0;
41336
41363
  if (initial || this.audioElement.paused) {
41337
41364
  if (initial && !timeToSeekTo || this.audioElement.currentTime === timeToSeekTo) {
41338
- if (IS_DEV) {
41339
- console.log("playMediaOverlaysAudio() - playClip() - _currentAudioElement.play()");
41340
- }
41365
+ import_loglevel10.default.log("playMediaOverlaysAudio() - playClip() - _currentAudioElement.play()");
41341
41366
  this.ensureOnTimeUpdate(false, false);
41342
41367
  this.audioElement.playbackRate = this.settings.rate;
41343
41368
  this.audioElement.volume = this.settings.volume;
@@ -41356,14 +41381,10 @@ var MediaOverlayModule = class {
41356
41381
  checkReady();
41357
41382
  }
41358
41383
  } else {
41359
- if (IS_DEV) {
41360
- console.log("playMediaOverlaysAudio() - playClip() - ontimeupdateSeeked");
41361
- }
41384
+ import_loglevel10.default.log("playMediaOverlaysAudio() - playClip() - ontimeupdateSeeked");
41362
41385
  const ontimeupdateSeeked = async (_ev) => {
41363
41386
  this.audioElement.removeEventListener("timeupdate", ontimeupdateSeeked);
41364
- if (IS_DEV) {
41365
- console.log("playMediaOverlaysAudio() - playClip() - ontimeupdateSeeked - .play()");
41366
- }
41387
+ import_loglevel10.default.log("playMediaOverlaysAudio() - playClip() - ontimeupdateSeeked - .play()");
41367
41388
  this.ensureOnTimeUpdate(false, false);
41368
41389
  if (this.audioElement) {
41369
41390
  this.audioElement.playbackRate = this.settings.rate;
@@ -41391,13 +41412,9 @@ var MediaOverlayModule = class {
41391
41412
  const contiguous = this.previousAudioUrl === this.currentAudioUrl && typeof this.previousAudioEnd !== "undefined" && this.previousAudioEnd > timeToSeekTo - 0.02 && this.previousAudioEnd <= timeToSeekTo && this.audioElement.currentTime >= timeToSeekTo - 0.1;
41392
41413
  this.ensureOnTimeUpdate(false, false);
41393
41414
  if (contiguous) {
41394
- if (IS_DEV) {
41395
- console.log("playMediaOverlaysAudio() - playClip() - ensureOnTimeUpdate");
41396
- }
41415
+ import_loglevel10.default.log("playMediaOverlaysAudio() - playClip() - ensureOnTimeUpdate");
41397
41416
  } else {
41398
- if (IS_DEV) {
41399
- console.log("playMediaOverlaysAudio() - playClip() - currentTime = timeToSeekTo");
41400
- }
41417
+ import_loglevel10.default.log("playMediaOverlaysAudio() - playClip() - currentTime = timeToSeekTo");
41401
41418
  this.audioElement.currentTime = timeToSeekTo;
41402
41419
  }
41403
41420
  }
@@ -41405,9 +41422,7 @@ var MediaOverlayModule = class {
41405
41422
  this.previousAudioUrl = this.currentAudioUrl;
41406
41423
  if (!this.currentAudioUrl || urlNoQuery !== this.currentAudioUrl) {
41407
41424
  this.currentAudioUrl = urlNoQuery;
41408
- if (IS_DEV) {
41409
- console.log("playMediaOverlaysAudio() - RESET: " + this.previousAudioUrl + " => " + this.currentAudioUrl);
41410
- }
41425
+ import_loglevel10.default.log("playMediaOverlaysAudio() - RESET: " + this.previousAudioUrl + " => " + this.currentAudioUrl);
41411
41426
  this.audioElement = document.getElementById("AUDIO_MO_ID");
41412
41427
  if (this.audioElement) {
41413
41428
  this.audioElement.pause();
@@ -41424,23 +41439,21 @@ var MediaOverlayModule = class {
41424
41439
  this.audioElement.playbackRate = this.settings.rate;
41425
41440
  document.body.appendChild(this.audioElement);
41426
41441
  this.audioElement.addEventListener("error", (ev) => {
41427
- console.log("-1) error: " + (this.currentAudioUrl !== ev.currentTarget.src ? this.currentAudioUrl + " -- " : "") + ev.currentTarget.src.substr(ev.currentTarget.src.lastIndexOf("/")));
41442
+ import_loglevel10.default.log("-1) error: " + (this.currentAudioUrl !== ev.currentTarget.src ? this.currentAudioUrl + " -- " : "") + ev.currentTarget.src.substr(ev.currentTarget.src.lastIndexOf("/")));
41428
41443
  if (this.audioElement && this.audioElement.error) {
41429
- console.log(this.audioElement.error.code);
41430
- console.log(this.audioElement.error.message);
41444
+ import_loglevel10.default.log(this.audioElement.error.code);
41445
+ import_loglevel10.default.log(this.audioElement.error.message);
41431
41446
  }
41432
41447
  });
41433
41448
  const oncanplaythrough = async (ev) => {
41434
41449
  const currentAudioElement = ev.currentTarget;
41435
41450
  currentAudioElement.removeEventListener("canplaythrough", oncanplaythrough);
41436
- if (IS_DEV)
41437
- console.log("oncanplaythrough");
41451
+ import_loglevel10.default.log("oncanplaythrough");
41438
41452
  await playClip(true);
41439
41453
  };
41440
41454
  this.audioElement.addEventListener("canplaythrough", oncanplaythrough);
41441
41455
  const onended = async (_ev) => {
41442
- if (IS_DEV)
41443
- console.log("onended");
41456
+ import_loglevel10.default.log("onended");
41444
41457
  if (this.currentLinks.length > 1 && this.currentLinkIndex === 0) {
41445
41458
  this.currentLinkIndex++;
41446
41459
  await this.playLink();
@@ -41457,42 +41470,35 @@ var MediaOverlayModule = class {
41457
41470
  this.audioElement.playbackRate = this.settings.rate;
41458
41471
  this.audioElement.setAttribute("src", this.currentAudioUrl);
41459
41472
  } else {
41460
- if (IS_DEV)
41461
- console.log("playMediaOverlaysAudio() - playClip()");
41473
+ import_loglevel10.default.log("playMediaOverlaysAudio() - playClip()");
41462
41474
  await playClip(false);
41463
41475
  }
41464
41476
  }
41465
41477
  async playMediaOverlays(textHref, rootMo, textFragmentIDChain) {
41466
- if (IS_DEV)
41467
- console.log("playMediaOverlays()");
41478
+ import_loglevel10.default.log("playMediaOverlays()");
41468
41479
  let textFragmentIDChain_ = textFragmentIDChain ? textFragmentIDChain.filter((id2) => id2) : void 0;
41469
41480
  if (textFragmentIDChain_ && textFragmentIDChain_.length === 0) {
41470
41481
  textFragmentIDChain_ = void 0;
41471
41482
  }
41472
41483
  let moTextAudioPair = this.findDepthFirstTextAudioPair(textHref, rootMo, textFragmentIDChain_);
41473
41484
  if (!moTextAudioPair && textFragmentIDChain_) {
41474
- if (IS_DEV) {
41475
- console.log("playMediaOverlays() - findDepthFirstTextAudioPair() SECOND CHANCE ");
41476
- console.log(JSON.stringify(textFragmentIDChain_, null, 4));
41477
- console.log(JSON.stringify(rootMo, null, 4));
41478
- }
41485
+ import_loglevel10.default.log("playMediaOverlays() - findDepthFirstTextAudioPair() SECOND CHANCE ");
41486
+ import_loglevel10.default.log(JSON.stringify(textFragmentIDChain_, null, 4));
41487
+ import_loglevel10.default.log(JSON.stringify(rootMo, null, 4));
41479
41488
  moTextAudioPair = this.findDepthFirstTextAudioPair(textHref, rootMo, void 0);
41480
41489
  }
41481
41490
  if (moTextAudioPair) {
41482
41491
  if (moTextAudioPair.Audio) {
41483
- if (IS_DEV)
41484
- console.log("playMediaOverlays() - playMediaOverlaysAudio()");
41492
+ import_loglevel10.default.log("playMediaOverlays() - playMediaOverlaysAudio()");
41485
41493
  this.mediaOverlayRoot = rootMo;
41486
41494
  await this.playMediaOverlaysAudio(moTextAudioPair, void 0, void 0);
41487
41495
  }
41488
41496
  } else {
41489
- if (IS_DEV)
41490
- console.log("playMediaOverlays() - !moTextAudioPair " + textHref);
41497
+ import_loglevel10.default.log("playMediaOverlays() - !moTextAudioPair " + textHref);
41491
41498
  }
41492
41499
  }
41493
41500
  mediaOverlayHighlight(id2) {
41494
- if (IS_DEV)
41495
- console.log("moHighlight: ## " + id2);
41501
+ import_loglevel10.default.log("moHighlight: ## " + id2);
41496
41502
  let classActive = this.publication.Metadata?.MediaOverlay?.ActiveClass;
41497
41503
  if (!classActive) {
41498
41504
  classActive = this.settings.color;
@@ -41537,6 +41543,7 @@ var MediaOverlayModule = class {
41537
41543
 
41538
41544
  // src/modules/positions/TimelineModule.ts
41539
41545
  init_polyfills();
41546
+ var import_loglevel11 = __toModule(require_loglevel());
41540
41547
  var TimelineModule = class {
41541
41548
  static async create(config2) {
41542
41549
  const timeline = new this(config2.delegate, config2.publication);
@@ -41548,9 +41555,7 @@ var TimelineModule = class {
41548
41555
  this.publication = publication;
41549
41556
  }
41550
41557
  async stop() {
41551
- if (IS_DEV) {
41552
- console.log("Timeline module stop");
41553
- }
41558
+ import_loglevel11.default.log("Timeline module stop");
41554
41559
  }
41555
41560
  async start() {
41556
41561
  this.delegate.timelineModule = this;
@@ -41619,8 +41624,7 @@ var TimelineModule = class {
41619
41624
  title: link.Title
41620
41625
  };
41621
41626
  }
41622
- if (IS_DEV)
41623
- console.log(position);
41627
+ import_loglevel11.default.log(position);
41624
41628
  this.delegate.navigate(position);
41625
41629
  });
41626
41630
  if (tocHrefAbs === this.delegate.currentChapterLink.href) {
@@ -41640,8 +41644,22 @@ var TimelineModule = class {
41640
41644
  // src/modules/protection/ContentProtectionModule.ts
41641
41645
  init_polyfills();
41642
41646
  var import_debounce3 = __toModule(require_debounce());
41647
+
41648
+ // src/utils/index.ts
41649
+ init_polyfills();
41650
+ var import_loglevel12 = __toModule(require_loglevel());
41651
+ function delay(t, v) {
41652
+ return new Promise(function(resolve) {
41653
+ setTimeout(resolve.bind(null, v), t);
41654
+ });
41655
+ }
41656
+ var IS_DEV = false;
41657
+ import_loglevel12.default.setLevel(IS_DEV ? "trace" : "warn", true);
41658
+
41659
+ // src/modules/protection/ContentProtectionModule.ts
41643
41660
  var import_browserslist_useragent_regexp = __toModule(require_lib7());
41644
41661
  var import_devtools_detector = __toModule(require_devtools_detector());
41662
+ var import_loglevel13 = __toModule(require_loglevel());
41645
41663
  var ContentProtectionModule = class {
41646
41664
  constructor(delegate, properties) {
41647
41665
  this.hasEventListener = false;
@@ -41703,18 +41721,14 @@ var ContentProtectionModule = class {
41703
41721
  var self2 = this;
41704
41722
  this.mutationObserver = new MutationObserver(function(mutations) {
41705
41723
  mutations.forEach(function(mutation) {
41706
- if (IS_DEV) {
41707
- console.log(mutation.type);
41708
- }
41724
+ import_loglevel13.default.log(mutation.type);
41709
41725
  self2.isHacked = true;
41710
41726
  });
41711
41727
  });
41712
41728
  }
41713
41729
  }
41714
41730
  async stop() {
41715
- if (IS_DEV) {
41716
- console.log("Protection module stop");
41717
- }
41731
+ import_loglevel13.default.log("Protection module stop");
41718
41732
  this.mutationObserver.disconnect();
41719
41733
  if (this.properties?.disableKeys) {
41720
41734
  removeEventListenerOptional(this.delegate.mainElement, "keydown", this.disableSave);
@@ -41946,18 +41960,14 @@ var ContentProtectionModule = class {
41946
41960
  return true;
41947
41961
  }
41948
41962
  preventCopy(event) {
41949
- if (IS_DEV) {
41950
- console.log("copy action initiated");
41951
- }
41963
+ import_loglevel13.default.log("copy action initiated");
41952
41964
  event.clipboardData.setData("text/plain", "copy not allowed");
41953
41965
  event.stopPropagation();
41954
41966
  event.preventDefault();
41955
41967
  return false;
41956
41968
  }
41957
41969
  beforePrint(event) {
41958
- if (IS_DEV) {
41959
- console.log("before print");
41960
- }
41970
+ import_loglevel13.default.log("before print");
41961
41971
  if (this.delegate && this.delegate.headerMenu) {
41962
41972
  this.delegate.headerMenu.style.display = "none";
41963
41973
  this.delegate.mainElement.style.display = "none";
@@ -41967,9 +41977,7 @@ var ContentProtectionModule = class {
41967
41977
  return false;
41968
41978
  }
41969
41979
  afterPrint(event) {
41970
- if (IS_DEV) {
41971
- console.log("after print");
41972
- }
41980
+ import_loglevel13.default.log("after print");
41973
41981
  if (this.delegate && this.delegate.headerMenu) {
41974
41982
  this.delegate.headerMenu.style.removeProperty("display");
41975
41983
  this.delegate.mainElement.style.removeProperty("display");
@@ -42059,14 +42067,12 @@ var ContentProtectionModule = class {
42059
42067
  rect.width = width;
42060
42068
  rect.left = left;
42061
42069
  } catch (error) {
42062
- if (IS_DEV) {
42063
- console.log("error " + error);
42064
- console.log(rect);
42065
- console.log(rect.node);
42066
- console.log("scrambledTextContent " + rect.scrambledTextContent);
42067
- console.log("textContent " + rect.textContent);
42068
- console.log("isObfuscated " + rect.isObfuscated);
42069
- }
42070
+ import_loglevel13.default.log("error " + error);
42071
+ import_loglevel13.default.log(rect);
42072
+ import_loglevel13.default.log(rect.node);
42073
+ import_loglevel13.default.log("scrambledTextContent " + rect.scrambledTextContent);
42074
+ import_loglevel13.default.log("textContent " + rect.textContent);
42075
+ import_loglevel13.default.log("isObfuscated " + rect.isObfuscated);
42070
42076
  }
42071
42077
  });
42072
42078
  }
@@ -42122,17 +42128,14 @@ var ContentProtectionModule = class {
42122
42128
  range.detach();
42123
42129
  return rect;
42124
42130
  } catch (error) {
42125
- if (IS_DEV) {
42126
- console.log("measureTextNode " + error);
42127
- console.log("measureTextNode " + node);
42128
- console.log(node.textContent);
42129
- }
42131
+ import_loglevel13.default.log("measureTextNode " + error);
42132
+ import_loglevel13.default.log("measureTextNode " + node);
42133
+ import_loglevel13.default.log(node.textContent);
42130
42134
  }
42131
42135
  }
42132
42136
  isBeingHacked(element) {
42133
42137
  if (element.style.animation || element.style.transition || element.style.position || element.hasAttribute("style")) {
42134
- if (IS_DEV)
42135
- console.log("content being hacked");
42138
+ import_loglevel13.default.log("content being hacked");
42136
42139
  return true;
42137
42140
  }
42138
42141
  return false;
@@ -42296,6 +42299,7 @@ async function searchDocDomSeek(searchInput, doc, href, title, fullWordSearch =
42296
42299
  }
42297
42300
 
42298
42301
  // src/modules/search/SearchModule.ts
42302
+ var import_loglevel14 = __toModule(require_loglevel());
42299
42303
  var SearchModule = class {
42300
42304
  constructor(delegate, publication, properties, highlighter, requestConfig, api, headerMenu) {
42301
42305
  this.currentChapterSearchResult = [];
@@ -42315,9 +42319,7 @@ var SearchModule = class {
42315
42319
  return search;
42316
42320
  }
42317
42321
  async stop() {
42318
- if (IS_DEV) {
42319
- console.log("Search module stop");
42320
- }
42322
+ import_loglevel14.default.log("Search module stop");
42321
42323
  removeEventListenerOptional(this.searchInput, "keypress", this.handleSearch.bind(this));
42322
42324
  removeEventListenerOptional(this.searchGo, "click", this.handleSearch.bind(this));
42323
42325
  }
@@ -42844,6 +42846,7 @@ var SearchModule = class {
42844
42846
 
42845
42847
  // src/modules/TTS/TTSSettings.ts
42846
42848
  init_polyfills();
42849
+ var import_loglevel15 = __toModule(require_loglevel());
42847
42850
  var _TTSREFS = class {
42848
42851
  };
42849
42852
  var TTSREFS = _TTSREFS;
@@ -42885,42 +42888,34 @@ var TTSSettings = class {
42885
42888
  let initialTTSSettings = config2.initialTTSSettings;
42886
42889
  if (initialTTSSettings?.rate) {
42887
42890
  settings.rate = initialTTSSettings.rate;
42888
- if (IS_DEV)
42889
- console.log(settings.rate);
42891
+ import_loglevel15.default.log(settings.rate);
42890
42892
  }
42891
42893
  if (initialTTSSettings?.pitch) {
42892
42894
  settings.pitch = initialTTSSettings.pitch;
42893
- if (IS_DEV)
42894
- console.log(settings.pitch);
42895
+ import_loglevel15.default.log(settings.pitch);
42895
42896
  }
42896
42897
  if (initialTTSSettings?.volume) {
42897
42898
  settings.volume = initialTTSSettings.volume;
42898
- if (IS_DEV)
42899
- console.log(settings.volume);
42899
+ import_loglevel15.default.log(settings.volume);
42900
42900
  }
42901
42901
  if (initialTTSSettings?.color) {
42902
42902
  settings.color = initialTTSSettings.color;
42903
- if (IS_DEV)
42904
- console.log(settings.color);
42903
+ import_loglevel15.default.log(settings.color);
42905
42904
  }
42906
42905
  if (initialTTSSettings?.autoScroll) {
42907
42906
  settings.autoScroll = initialTTSSettings.autoScroll;
42908
- if (IS_DEV)
42909
- console.log(settings.autoScroll);
42907
+ import_loglevel15.default.log(settings.autoScroll);
42910
42908
  }
42911
42909
  if (initialTTSSettings?.voice) {
42912
42910
  settings.voice = initialTTSSettings.voice;
42913
- if (IS_DEV)
42914
- console.log(settings.voice);
42911
+ import_loglevel15.default.log(settings.voice);
42915
42912
  }
42916
42913
  }
42917
42914
  settings.initializeSelections();
42918
42915
  return settings;
42919
42916
  }
42920
42917
  stop() {
42921
- if (IS_DEV) {
42922
- console.log("tts settings stop");
42923
- }
42918
+ import_loglevel15.default.log("tts settings stop");
42924
42919
  }
42925
42920
  initialise() {
42926
42921
  this.autoScroll = this.getProperty(TTSREFS.AUTO_SCROLL_KEY) != null ? this.getProperty(TTSREFS.AUTO_SCROLL_KEY).value : this.autoScroll;
@@ -42993,9 +42988,7 @@ var TTSSettings = class {
42993
42988
  this.applyTTSSettings(ttsSettings);
42994
42989
  if (this.api?.updateSettings) {
42995
42990
  this.api?.updateSettings(ttsSettings).then(async (settings) => {
42996
- if (IS_DEV) {
42997
- console.log("api updated tts settings", settings);
42998
- }
42991
+ import_loglevel15.default.log("api updated tts settings", settings);
42999
42992
  });
43000
42993
  }
43001
42994
  }
@@ -43043,8 +43036,7 @@ var TTSSettings = class {
43043
43036
  }
43044
43037
  applyTTSSettings(ttsSettings) {
43045
43038
  if (ttsSettings.rate) {
43046
- if (IS_DEV)
43047
- console.log("rate " + this.rate);
43039
+ import_loglevel15.default.log("rate " + this.rate);
43048
43040
  this.rate = ttsSettings.rate;
43049
43041
  let prop = this.userProperties.getByRef(TTSREFS.RATE_REF);
43050
43042
  if (prop) {
@@ -43055,8 +43047,7 @@ var TTSSettings = class {
43055
43047
  this.restartCallback();
43056
43048
  }
43057
43049
  if (ttsSettings.pitch) {
43058
- if (IS_DEV)
43059
- console.log("pitch " + this.pitch);
43050
+ import_loglevel15.default.log("pitch " + this.pitch);
43060
43051
  this.pitch = ttsSettings.pitch;
43061
43052
  let prop = this.userProperties.getByRef(TTSREFS.PITCH_REF);
43062
43053
  if (prop) {
@@ -43067,8 +43058,7 @@ var TTSSettings = class {
43067
43058
  this.restartCallback();
43068
43059
  }
43069
43060
  if (ttsSettings.volume) {
43070
- if (IS_DEV)
43071
- console.log("volume " + this.volume);
43061
+ import_loglevel15.default.log("volume " + this.volume);
43072
43062
  this.volume = ttsSettings.volume;
43073
43063
  let prop = this.userProperties.getByRef(TTSREFS.VOLUME_REF);
43074
43064
  if (prop) {
@@ -43088,8 +43078,7 @@ var TTSSettings = class {
43088
43078
  this.settingsChangeCallback();
43089
43079
  }
43090
43080
  if (ttsSettings.autoScroll !== void 0) {
43091
- if (IS_DEV)
43092
- console.log("autoScroll " + this.autoScroll);
43081
+ import_loglevel15.default.log("autoScroll " + this.autoScroll);
43093
43082
  this.autoScroll = ttsSettings.autoScroll;
43094
43083
  let prop = this.userProperties.getByRef(TTSREFS.AUTO_SCROLL_REF);
43095
43084
  if (prop) {
@@ -43099,8 +43088,7 @@ var TTSSettings = class {
43099
43088
  this.settingsChangeCallback();
43100
43089
  }
43101
43090
  if (ttsSettings.voice) {
43102
- if (IS_DEV)
43103
- console.log("voice " + this.voice);
43091
+ import_loglevel15.default.log("voice " + this.voice);
43104
43092
  this.voice = ttsSettings.voice;
43105
43093
  let prop = this.userProperties.getByRef(TTSREFS.VOICE_REF);
43106
43094
  if (prop) {
@@ -43189,9 +43177,6 @@ init_polyfills();
43189
43177
 
43190
43178
  // src/utils/HTMLTemplates.ts
43191
43179
  init_polyfills();
43192
- var simpleUpLinkTemplate = (href, _label, ariaLabel) => `
43193
- <a rel="up" href='${href}' aria-label="${ariaLabel}" style="padding: 0px"><i class="material-icons show-on-large">arrow_back_ios</i></a>
43194
- `;
43195
43180
  var readerLoading = `${icons.loading}`;
43196
43181
  var readerError = `
43197
43182
  <span>
@@ -43439,14 +43424,14 @@ var SampleReadEventHandler = class {
43439
43424
 
43440
43425
  // src/navigator/IFrameNavigator.ts
43441
43426
  var import_eventemitter3 = __toModule(require_eventemitter3());
43427
+ var import_loglevel16 = __toModule(require_loglevel());
43442
43428
  var IFrameNavigator = class extends import_eventemitter3.default {
43443
- constructor(settings, annotator = void 0, upLinkConfig = void 0, initialLastReadingPosition = void 0, publication, api, rights, tts, injectables, attributes, services, sample, requestConfig) {
43429
+ constructor(settings, annotator = void 0, initialLastReadingPosition = void 0, publication, api, rights, tts, injectables, attributes, services, sample, requestConfig) {
43444
43430
  super();
43445
43431
  this.iframes = [];
43446
43432
  this.sideNavExpanded = false;
43447
43433
  this.currentChapterLink = { href: "" };
43448
43434
  this.currentSpreadLinks = {};
43449
- this.upLink = void 0;
43450
43435
  this.rights = {
43451
43436
  autoGeneratePositions: false,
43452
43437
  enableAnnotations: false,
@@ -43475,10 +43460,8 @@ var IFrameNavigator = class extends import_eventemitter3.default {
43475
43460
  }
43476
43461
  if (lastReadingPosition) {
43477
43462
  const linkHref = this.publication.getAbsoluteHref(lastReadingPosition.href);
43478
- if (IS_DEV)
43479
- console.log(lastReadingPosition.href);
43480
- if (IS_DEV)
43481
- console.log(linkHref);
43463
+ import_loglevel16.default.log(lastReadingPosition.href);
43464
+ import_loglevel16.default.log(linkHref);
43482
43465
  lastReadingPosition.href = linkHref;
43483
43466
  await this.navigate(lastReadingPosition);
43484
43467
  }
@@ -43511,7 +43494,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
43511
43494
  this.eventHandler = new EventHandler(this);
43512
43495
  this.touchEventHandler = new TouchEventHandler(this);
43513
43496
  this.keyboardEventHandler = new KeyboardEventHandler(this);
43514
- this.upLinkConfig = upLinkConfig;
43515
43497
  this.initialLastReadingPosition = initialLastReadingPosition;
43516
43498
  this.publication = publication;
43517
43499
  this.api = api;
@@ -43540,14 +43522,12 @@ var IFrameNavigator = class extends import_eventemitter3.default {
43540
43522
  this.sampleReadEventHandler = new SampleReadEventHandler(this);
43541
43523
  }
43542
43524
  static async create(config2) {
43543
- const navigator2 = new this(config2.settings, config2.annotator || void 0, config2.upLink || void 0, config2.initialLastReadingPosition || void 0, config2.publication, config2.api, config2.rights, config2.tts, config2.injectables, config2.attributes || { margin: 0 }, config2.services, config2.sample);
43525
+ const navigator2 = new this(config2.settings, config2.annotator || void 0, config2.initialLastReadingPosition || void 0, config2.publication, config2.api, config2.rights, config2.tts, config2.injectables, config2.attributes || { margin: 0 }, config2.services, config2.sample);
43544
43526
  await navigator2.start(config2.mainElement, config2.headerMenu, config2.footerMenu);
43545
43527
  return new Promise((resolve) => resolve(navigator2));
43546
43528
  }
43547
43529
  stop() {
43548
- if (IS_DEV) {
43549
- console.log("Iframe navigator stop");
43550
- }
43530
+ import_loglevel16.default.log("Iframe navigator stop");
43551
43531
  removeEventListenerOptional(this.previousChapterAnchorElement, "click", this.handlePreviousChapterClick.bind(this));
43552
43532
  removeEventListenerOptional(this.nextChapterAnchorElement, "click", this.handleNextChapterClick.bind(this));
43553
43533
  removeEventListenerOptional(this.previousChapterTopAnchorElement, "click", this.handlePreviousPageClick.bind(this));
@@ -43755,7 +43735,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
43755
43735
  this.setupEvents();
43756
43736
  return await this.loadManifest();
43757
43737
  } catch (err) {
43758
- console.error(err);
43738
+ import_loglevel16.default.error(err);
43759
43739
  this.abortOnError(err);
43760
43740
  return Promise.reject(err);
43761
43741
  }
@@ -44038,22 +44018,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
44038
44018
  this.landmarksSection.parentElement?.removeChild(this.landmarksSection);
44039
44019
  }
44040
44020
  }
44041
- if ((this.links || this.linksTopLeft) && this.upLinkConfig && this.upLinkConfig.url) {
44042
- const upUrl = this.upLinkConfig.url;
44043
- const upLabel = this.upLinkConfig.label || "";
44044
- const upAriaLabel = this.upLinkConfig.ariaLabel || upLabel;
44045
- var upHTML = simpleUpLinkTemplate(upUrl.href, upLabel, upAriaLabel);
44046
- const upParent = document.createElement("li");
44047
- upParent.classList.add("uplink-wrapper");
44048
- upParent.innerHTML = upHTML;
44049
- if (this.links) {
44050
- this.links.insertBefore(upParent, this.links.firstChild);
44051
- this.upLink = findRequiredElement(this.links, "a[rel=up]");
44052
- } else {
44053
- this.linksTopLeft.insertBefore(upParent, this.linksTopLeft.firstChild);
44054
- this.upLink = findRequiredElement(this.linksTopLeft, "a[rel=up]");
44055
- }
44056
- }
44057
44021
  let lastReadingPosition = void 0;
44058
44022
  if (this.annotator) {
44059
44023
  lastReadingPosition = await this.annotator.getLastReadingPosition();
@@ -44065,10 +44029,8 @@ var IFrameNavigator = class extends import_eventemitter3.default {
44065
44029
  }
44066
44030
  if (lastReadingPosition) {
44067
44031
  const linkHref = this.publication.getAbsoluteHref(lastReadingPosition.href);
44068
- if (IS_DEV)
44069
- console.log(lastReadingPosition.href);
44070
- if (IS_DEV)
44071
- console.log(linkHref);
44032
+ import_loglevel16.default.log(lastReadingPosition.href);
44033
+ import_loglevel16.default.log(linkHref);
44072
44034
  lastReadingPosition.href = linkHref;
44073
44035
  await this.navigate(lastReadingPosition);
44074
44036
  } else if (startUrl) {
@@ -44084,7 +44046,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
44084
44046
  }
44085
44047
  return new Promise((resolve) => resolve());
44086
44048
  } catch (err) {
44087
- console.error(err);
44049
+ import_loglevel16.default.error(err);
44088
44050
  this.abortOnError(err);
44089
44051
  return new Promise((_, reject) => reject(err)).catch(() => {
44090
44052
  });
@@ -44266,7 +44228,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
44266
44228
  }, 200);
44267
44229
  return new Promise((resolve) => resolve());
44268
44230
  } catch (err) {
44269
- console.error(err);
44231
+ import_loglevel16.default.error(err);
44270
44232
  this.abortOnError(err);
44271
44233
  return Promise.reject(err);
44272
44234
  }
@@ -44801,10 +44763,8 @@ var IFrameNavigator = class extends import_eventemitter3.default {
44801
44763
  const position = __spreadValues({}, locator);
44802
44764
  position.locations = locations;
44803
44765
  const linkHref = this.publication.getAbsoluteHref(locator.href);
44804
- if (IS_DEV)
44805
- console.log(locator.href);
44806
- if (IS_DEV)
44807
- console.log(linkHref);
44766
+ import_loglevel16.default.log(locator.href);
44767
+ import_loglevel16.default.log(linkHref);
44808
44768
  position.href = linkHref;
44809
44769
  this.stopReadAloud();
44810
44770
  this.navigate(position);
@@ -44855,7 +44815,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
44855
44815
  snapToSelector(selector2) {
44856
44816
  const doc = this.iframes[0].contentDocument;
44857
44817
  if (doc) {
44858
- console.log(selector2);
44818
+ import_loglevel16.default.log(selector2);
44859
44819
  let result = doc.querySelectorAll(selector2);
44860
44820
  if (result.length > 0)
44861
44821
  this.view?.snap(result[0]);
@@ -45551,15 +45511,11 @@ var IFrameNavigator = class extends import_eventemitter3.default {
45551
45511
  }
45552
45512
  if (this.api?.updateCurrentLocation) {
45553
45513
  this.api?.updateCurrentLocation(position).then(async (_) => {
45554
- if (IS_DEV) {
45555
- console.log("api updated current location", position);
45556
- }
45514
+ import_loglevel16.default.log("api updated current location", position);
45557
45515
  return this.annotator?.saveLastReadingPosition(position);
45558
45516
  });
45559
45517
  } else {
45560
- if (IS_DEV) {
45561
- console.log("save last reading position", position);
45562
- }
45518
+ import_loglevel16.default.log("save last reading position", position);
45563
45519
  this.annotator.saveLastReadingPosition(position);
45564
45520
  }
45565
45521
  }
@@ -46030,6 +45986,7 @@ function convertAndCamel(o) {
46030
45986
 
46031
45987
  // src/modules/highlight/LayerSettings.ts
46032
45988
  init_polyfills();
45989
+ var import_loglevel17 = __toModule(require_loglevel());
46033
45990
  var LayerSettings = class {
46034
45991
  constructor(store) {
46035
45992
  this.LAYERSETTINGS = "layerSetting";
@@ -46041,9 +45998,7 @@ var LayerSettings = class {
46041
45998
  return new Promise((resolve) => resolve(settings));
46042
45999
  }
46043
46000
  async stop() {
46044
- if (IS_DEV) {
46045
- console.log("MediaOverlay settings stop");
46046
- }
46001
+ import_loglevel17.default.log("MediaOverlay settings stop");
46047
46002
  }
46048
46003
  async initialize() {
46049
46004
  this.userProperties = await this.getLayerSettings();
@@ -46087,6 +46042,7 @@ var LayerSettings = class {
46087
46042
 
46088
46043
  // src/modules/pagebreak/PageBreakModule.ts
46089
46044
  init_polyfills();
46045
+ var import_loglevel18 = __toModule(require_loglevel());
46090
46046
  var PageBreakModule = class {
46091
46047
  static async create(config2) {
46092
46048
  const pageBreak = new this(config2.delegate, config2.publication, config2, config2.headerMenu);
@@ -46100,9 +46056,7 @@ var PageBreakModule = class {
46100
46056
  this.properties = properties;
46101
46057
  }
46102
46058
  async stop() {
46103
- if (IS_DEV) {
46104
- console.log("Page Break module stop");
46105
- }
46059
+ import_loglevel18.default.log("Page Break module stop");
46106
46060
  }
46107
46061
  async start() {
46108
46062
  this.delegate.pageBreakModule = this;
@@ -46168,16 +46122,15 @@ var PageBreakModule = class {
46168
46122
  return "";
46169
46123
  }
46170
46124
  } catch (err) {
46171
- console.log("uniqueCssSelector:");
46172
- console.log(err);
46125
+ import_loglevel18.default.log("uniqueCssSelector:");
46126
+ import_loglevel18.default.error(err);
46173
46127
  return "";
46174
46128
  }
46175
46129
  }
46176
46130
  if (pageBreaks) {
46177
46131
  for (let i = 0; i < pageBreaks.length; i++) {
46178
46132
  let img = pageBreaks[i];
46179
- if (IS_DEV)
46180
- console.log(img);
46133
+ import_loglevel18.default.log(img);
46181
46134
  let title = img.innerHTML;
46182
46135
  let hide = false;
46183
46136
  if (img.innerHTML.length === 0) {
@@ -46250,6 +46203,7 @@ var PageBreakModule = class {
46250
46203
  init_polyfills();
46251
46204
  var import_sanitize_html2 = __toModule(require_sanitize_html());
46252
46205
  var import_debounce6 = __toModule(require_debounce());
46206
+ var import_loglevel19 = __toModule(require_loglevel());
46253
46207
  var TTSModule2 = class {
46254
46208
  constructor(delegate, tts, rights, highlighter, properties, api, headerMenu) {
46255
46209
  this.voices = [];
@@ -46367,16 +46321,14 @@ var TTSModule2 = class {
46367
46321
  }
46368
46322
  let s = setSpeech();
46369
46323
  s.then(async (voices) => {
46370
- if (IS_DEV)
46371
- console.log(voices);
46324
+ import_loglevel19.default.log(voices);
46372
46325
  this.voices = [];
46373
46326
  voices.forEach((voice) => {
46374
46327
  if (voice.localService === true) {
46375
46328
  this.voices.push(voice);
46376
46329
  }
46377
46330
  });
46378
- if (IS_DEV)
46379
- console.log(this.voices);
46331
+ import_loglevel19.default.log(this.voices);
46380
46332
  if (first) {
46381
46333
  if (this.headerMenu) {
46382
46334
  var preferredLanguageSelector = findElement(this.headerMenu, "#preferred-languages");
@@ -46460,6 +46412,26 @@ var TTSModule2 = class {
46460
46412
  restOfTheText = restOfTheText.replace(textToBeSpoken, "").trim();
46461
46413
  }
46462
46414
  utterance = new SpeechSynthesisUtterance(textToBeSpoken);
46415
+ import_loglevel19.default.log(selectionInfo);
46416
+ import_loglevel19.default.log(textToBeSpoken, selectionInfo.range?.commonAncestorContainer.textContent);
46417
+ import_loglevel19.default.log(ttsQueueItem);
46418
+ import_loglevel19.default.log(ttsQueueItem.item.textNodes);
46419
+ import_loglevel19.default.log(startIndex);
46420
+ import_loglevel19.default.log(ttsQueueItem.item.combinedText);
46421
+ if (!ttsQueueItem.item.combinedText?.startsWith(textToBeSpoken)) {
46422
+ for (let i = 0; i < ttsQueueItem.item.textNodes.length; i++) {
46423
+ let node2 = ttsQueueItem.item.textNodes[i];
46424
+ if (node2 === selectionInfo.range?.commonAncestorContainer) {
46425
+ break;
46426
+ }
46427
+ import_loglevel19.default.log(node2.length);
46428
+ startIndex += node2.length;
46429
+ }
46430
+ }
46431
+ let node = ttsQueueItem.item.textNodes.filter((node2) => {
46432
+ return node2 === selectionInfo.range?.commonAncestorContainer;
46433
+ })[0];
46434
+ import_loglevel19.default.log(node);
46463
46435
  utterance.onboundary = (ev) => {
46464
46436
  this.updateTTSInfo(ttsQueueItem, ev.charIndex + startIndex, ev.charLength, utterance.text);
46465
46437
  };
@@ -46472,8 +46444,7 @@ var TTSModule2 = class {
46472
46444
  utterance.rate = this.tts.rate;
46473
46445
  utterance.pitch = this.tts.pitch;
46474
46446
  utterance.volume = this.tts.volume;
46475
- if (IS_DEV)
46476
- console.log("this.tts.voice.lang", this.tts.voice.lang);
46447
+ import_loglevel19.default.log("this.tts.voice.lang", this.tts.voice.lang);
46477
46448
  var initialVoiceHasHyphen = true;
46478
46449
  if (this.tts.voice && this.tts.voice.lang) {
46479
46450
  initialVoiceHasHyphen = this.tts.voice.lang.indexOf("-") !== -1;
@@ -46482,10 +46453,8 @@ var TTSModule2 = class {
46482
46453
  initialVoiceHasHyphen = true;
46483
46454
  }
46484
46455
  }
46485
- if (IS_DEV)
46486
- console.log("initialVoiceHasHyphen", initialVoiceHasHyphen);
46487
- if (IS_DEV)
46488
- console.log("voices", this.voices);
46456
+ import_loglevel19.default.log("initialVoiceHasHyphen", initialVoiceHasHyphen);
46457
+ import_loglevel19.default.log("voices", this.voices);
46489
46458
  var initialVoice;
46490
46459
  if (initialVoiceHasHyphen === true) {
46491
46460
  initialVoice = this.tts.voice && this.tts.voice.lang && this.tts.voice.name ? this.voices.filter((v) => {
@@ -46503,11 +46472,9 @@ var TTSModule2 = class {
46503
46472
  initialVoice = this.tts.voice && this.tts.voice.lang ? this.voices.filter((v) => v.lang === this.tts.voice.lang)[0] : void 0;
46504
46473
  }
46505
46474
  }
46506
- if (IS_DEV)
46507
- console.log("initialVoice", initialVoice);
46475
+ import_loglevel19.default.log("initialVoice", initialVoice);
46508
46476
  var publicationVoiceHasHyphen = self2.delegate.publication.Metadata.Language[0].indexOf("-") !== -1;
46509
- if (IS_DEV)
46510
- console.log("publicationVoiceHasHyphen", publicationVoiceHasHyphen);
46477
+ import_loglevel19.default.log("publicationVoiceHasHyphen", publicationVoiceHasHyphen);
46511
46478
  var publicationVoice;
46512
46479
  if (publicationVoiceHasHyphen === true) {
46513
46480
  publicationVoice = this.tts.voice && this.tts.voice.usePublication ? this.voices.filter((v) => {
@@ -46519,11 +46486,9 @@ var TTSModule2 = class {
46519
46486
  return v.lang.startsWith(self2.delegate.publication.Metadata.Language[0]) || v.lang.endsWith(self2.delegate.publication.Metadata.Language[0].toUpperCase());
46520
46487
  })[0] : void 0;
46521
46488
  }
46522
- if (IS_DEV)
46523
- console.log("publicationVoice", publicationVoice);
46489
+ import_loglevel19.default.log("publicationVoice", publicationVoice);
46524
46490
  var defaultVoiceHasHyphen = navigator.language.indexOf("-") !== -1;
46525
- if (IS_DEV)
46526
- console.log("defaultVoiceHasHyphen", defaultVoiceHasHyphen);
46491
+ import_loglevel19.default.log("defaultVoiceHasHyphen", defaultVoiceHasHyphen);
46527
46492
  var defaultVoice;
46528
46493
  if (defaultVoiceHasHyphen === true) {
46529
46494
  defaultVoice = this.voices.filter((voice) => {
@@ -46542,30 +46507,23 @@ var TTSModule2 = class {
46542
46507
  return lang.includes(navigator.language) && voice.localService === true;
46543
46508
  })[0];
46544
46509
  }
46545
- if (IS_DEV)
46546
- console.log("defaultVoice", defaultVoice);
46510
+ import_loglevel19.default.log("defaultVoice", defaultVoice);
46547
46511
  if (initialVoice) {
46548
- if (IS_DEV)
46549
- console.log("initialVoice");
46512
+ import_loglevel19.default.log("initialVoice");
46550
46513
  utterance.voice = initialVoice;
46551
46514
  } else if (publicationVoice) {
46552
- if (IS_DEV)
46553
- console.log("publicationVoice");
46515
+ import_loglevel19.default.log("publicationVoice");
46554
46516
  utterance.voice = publicationVoice;
46555
46517
  } else if (defaultVoice) {
46556
- if (IS_DEV)
46557
- console.log("defaultVoice");
46518
+ import_loglevel19.default.log("defaultVoice");
46558
46519
  utterance.voice = defaultVoice;
46559
46520
  }
46560
46521
  if (utterance.voice !== void 0 && utterance.voice !== null) {
46561
46522
  utterance.lang = utterance.voice.lang;
46562
- if (IS_DEV)
46563
- console.log("utterance.voice.lang", utterance.voice.lang);
46564
- if (IS_DEV)
46565
- console.log("utterance.lang", utterance.lang);
46523
+ import_loglevel19.default.log("utterance.voice.lang", utterance.voice.lang);
46524
+ import_loglevel19.default.log("utterance.lang", utterance.lang);
46566
46525
  }
46567
- if (IS_DEV)
46568
- console.log("navigator.language", navigator.language);
46526
+ import_loglevel19.default.log("navigator.language", navigator.language);
46569
46527
  setTimeout(() => {
46570
46528
  window.speechSynthesis.speak(utterance);
46571
46529
  }, 0);
@@ -46600,16 +46558,14 @@ var TTSModule2 = class {
46600
46558
  onend();
46601
46559
  }
46602
46560
  if (idx > idxEnd) {
46603
- if (IS_DEV)
46604
- console.log("utterance ended");
46561
+ import_loglevel19.default.log("utterance ended");
46605
46562
  self2.highlighter.doneSpeaking();
46606
46563
  self2.api?.finished();
46607
46564
  self2.delegate.emit("readaloud.finished", "finished");
46608
46565
  }
46609
46566
  }
46610
46567
  } else {
46611
- if (IS_DEV)
46612
- console.log("utterance ended");
46568
+ import_loglevel19.default.log("utterance ended");
46613
46569
  self2.highlighter.doneSpeaking();
46614
46570
  self2.api?.finished();
46615
46571
  self2.delegate.emit("readaloud.finished", "finished");
@@ -46726,9 +46682,7 @@ var TTSModule2 = class {
46726
46682
  }
46727
46683
  }
46728
46684
  stop() {
46729
- if (IS_DEV) {
46730
- console.log("TTS module stop");
46731
- }
46685
+ import_loglevel19.default.log("TTS module stop");
46732
46686
  removeEventListenerOptional(document, "wheel", this.wheel.bind(this));
46733
46687
  removeEventListenerOptional(this.body, "wheel", this.wheel.bind(this));
46734
46688
  removeEventListenerOptional(document, "keydown", this.wheel.bind(this));
@@ -46886,8 +46840,7 @@ var TTSModule2 = class {
46886
46840
  utterance.rate = this.tts.rate;
46887
46841
  utterance.pitch = this.tts.pitch;
46888
46842
  utterance.volume = this.tts.volume;
46889
- if (IS_DEV)
46890
- console.log("this.tts.voice.lang", this.tts.voice.lang);
46843
+ import_loglevel19.default.log("this.tts.voice.lang", this.tts.voice.lang);
46891
46844
  var initialVoiceHasHyphen = true;
46892
46845
  if (this.tts.voice && this.tts.voice.lang) {
46893
46846
  initialVoiceHasHyphen = this.tts.voice.lang.indexOf("-") !== -1;
@@ -46896,10 +46849,8 @@ var TTSModule2 = class {
46896
46849
  initialVoiceHasHyphen = true;
46897
46850
  }
46898
46851
  }
46899
- if (IS_DEV)
46900
- console.log("initialVoiceHasHyphen", initialVoiceHasHyphen);
46901
- if (IS_DEV)
46902
- console.log("voices", this.voices);
46852
+ import_loglevel19.default.log("initialVoiceHasHyphen", initialVoiceHasHyphen);
46853
+ import_loglevel19.default.log("voices", this.voices);
46903
46854
  var initialVoice;
46904
46855
  if (initialVoiceHasHyphen === true) {
46905
46856
  initialVoice = this.tts.voice && this.tts.voice.lang && this.tts.voice.name ? this.voices.filter((v) => {
@@ -46917,12 +46868,10 @@ var TTSModule2 = class {
46917
46868
  initialVoice = this.tts.voice && this.tts.voice.lang ? this.voices.filter((v) => v.lang === this.tts.voice.lang)[0] : void 0;
46918
46869
  }
46919
46870
  }
46920
- if (IS_DEV)
46921
- console.log("initialVoice", initialVoice);
46871
+ import_loglevel19.default.log("initialVoice", initialVoice);
46922
46872
  var self2 = this;
46923
46873
  var publicationVoiceHasHyphen = self2.delegate.publication.Metadata.Language[0].indexOf("-") !== -1;
46924
- if (IS_DEV)
46925
- console.log("publicationVoiceHasHyphen", publicationVoiceHasHyphen);
46874
+ import_loglevel19.default.log("publicationVoiceHasHyphen", publicationVoiceHasHyphen);
46926
46875
  var publicationVoice;
46927
46876
  if (publicationVoiceHasHyphen === true) {
46928
46877
  publicationVoice = this.tts.voice && this.tts.voice.usePublication ? this.voices.filter((v) => {
@@ -46934,11 +46883,9 @@ var TTSModule2 = class {
46934
46883
  return v.lang.startsWith(self2.delegate.publication.Metadata.Language[0]) || v.lang.endsWith(self2.delegate.publication.Metadata.Language[0].toUpperCase());
46935
46884
  })[0] : void 0;
46936
46885
  }
46937
- if (IS_DEV)
46938
- console.log("publicationVoice", publicationVoice);
46886
+ import_loglevel19.default.log("publicationVoice", publicationVoice);
46939
46887
  var defaultVoiceHasHyphen = navigator.language.indexOf("-") !== -1;
46940
- if (IS_DEV)
46941
- console.log("defaultVoiceHasHyphen", defaultVoiceHasHyphen);
46888
+ import_loglevel19.default.log("defaultVoiceHasHyphen", defaultVoiceHasHyphen);
46942
46889
  var defaultVoice;
46943
46890
  if (defaultVoiceHasHyphen === true) {
46944
46891
  defaultVoice = this.voices.filter((voice) => {
@@ -46957,32 +46904,25 @@ var TTSModule2 = class {
46957
46904
  return lang.includes(navigator.language) && voice.localService === true;
46958
46905
  })[0];
46959
46906
  }
46960
- if (IS_DEV)
46961
- console.log("defaultVoice", defaultVoice);
46907
+ import_loglevel19.default.log("defaultVoice", defaultVoice);
46962
46908
  if (initialVoice) {
46963
- if (IS_DEV)
46964
- console.log("initialVoice");
46909
+ import_loglevel19.default.log("initialVoice");
46965
46910
  utterance.voice = initialVoice;
46966
46911
  } else if (publicationVoice) {
46967
- if (IS_DEV)
46968
- console.log("publicationVoice");
46912
+ import_loglevel19.default.log("publicationVoice");
46969
46913
  utterance.voice = publicationVoice;
46970
46914
  } else if (defaultVoice) {
46971
- if (IS_DEV)
46972
- console.log("defaultVoice");
46915
+ import_loglevel19.default.log("defaultVoice");
46973
46916
  utterance.voice = defaultVoice;
46974
46917
  }
46975
46918
  if (utterance.voice !== void 0 && utterance.voice !== null) {
46976
46919
  utterance.lang = utterance.voice.lang;
46977
- if (IS_DEV)
46978
- console.log("utterance.voice.lang", utterance.voice.lang);
46979
- if (IS_DEV)
46980
- console.log("utterance.lang", utterance.lang);
46920
+ import_loglevel19.default.log("utterance.voice.lang", utterance.voice.lang);
46921
+ import_loglevel19.default.log("utterance.lang", utterance.lang);
46981
46922
  }
46982
- if (IS_DEV)
46983
- console.log("navigator.language", navigator.language);
46923
+ import_loglevel19.default.log("navigator.language", navigator.language);
46984
46924
  utterance.onboundary = (ev) => {
46985
- console.log(ev.name);
46925
+ import_loglevel19.default.log(ev.name);
46986
46926
  this.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, utterance.text);
46987
46927
  };
46988
46928
  setTimeout(() => {
@@ -47001,6 +46941,7 @@ var TTSModule2 = class {
47001
46941
  if (!ttsQueueItem) {
47002
46942
  return void 0;
47003
46943
  }
46944
+ import_loglevel19.default.log(ttsQueueItem, charIndex, charLength, utteranceText);
47004
46945
  const ttsQueueItemText = utteranceText ? utteranceText : getTtsQueueItemRefText(ttsQueueItem);
47005
46946
  if (charIndex >= 0 && utteranceText) {
47006
46947
  const start = utteranceText.slice(0, charIndex + 1).search(/\S+$/);
@@ -47019,6 +46960,9 @@ var TTSModule2 = class {
47019
46960
  return ttsQueueItemText;
47020
46961
  }
47021
46962
  wrapHighlightWord(ttsQueueItemRef, utteranceText, charIndex, charLength, word, start, end) {
46963
+ import_loglevel19.default.log(ttsQueueItemRef);
46964
+ import_loglevel19.default.log(utteranceText);
46965
+ import_loglevel19.default.log(charIndex, charLength, word, start, end);
47022
46966
  if (this._ttsQueueItemHighlightsWord) {
47023
46967
  this.delegate.highlighter?.destroyHighlights(HighlightType.ReadAloud);
47024
46968
  this._ttsQueueItemHighlightsWord = void 0;
@@ -47026,14 +46970,12 @@ var TTSModule2 = class {
47026
46970
  const ttsQueueItem = ttsQueueItemRef.item;
47027
46971
  let txtToCheck = ttsQueueItemRef.item.combinedText;
47028
46972
  let charIndexAdjusted = charIndex;
47029
- if (IS_DEV) {
47030
- if (utteranceText !== txtToCheck) {
47031
- console.log("TTS utteranceText DIFF?? ", `[[${utteranceText}]]`, `[[${txtToCheck}]]`);
47032
- }
47033
- const ttsWord = utteranceText.substr(charIndex, charLength);
47034
- if (ttsWord !== word) {
47035
- console.log("TTS word DIFF?? ", `[[${ttsWord}]]`, `[[${word}]]`, `${charIndex}--${charLength}`, `${start}--${end - start}`);
47036
- }
46973
+ if (utteranceText !== txtToCheck) {
46974
+ import_loglevel19.default.log("TTS utteranceText DIFF?? ", `[[${utteranceText}]]`, `[[${txtToCheck}]]`);
46975
+ }
46976
+ const ttsWord = utteranceText.substr(charIndex, charLength);
46977
+ if (ttsWord !== word) {
46978
+ import_loglevel19.default.log("TTS word DIFF?? ", `[[${ttsWord}]]`, `[[${word}]]`, `${charIndex}--${charLength}`, `${start}--${end - start}`);
47037
46979
  }
47038
46980
  let acc = 0;
47039
46981
  let rangeStartNode;
@@ -47071,8 +47013,8 @@ var TTSModule2 = class {
47071
47013
  return "";
47072
47014
  }
47073
47015
  } catch (err) {
47074
- console.log("uniqueCssSelector:");
47075
- console.log(err);
47016
+ import_loglevel19.default.log("uniqueCssSelector:");
47017
+ import_loglevel19.default.error(err);
47076
47018
  return "";
47077
47019
  }
47078
47020
  };
@@ -47179,6 +47121,7 @@ function getTtsQueueItemRefText(obj) {
47179
47121
  init_polyfills();
47180
47122
  var lodash3 = __toModule(require_lodash());
47181
47123
  var import_debounce7 = __toModule(require_debounce());
47124
+ var import_loglevel20 = __toModule(require_loglevel());
47182
47125
  var DefinitionsModule = class {
47183
47126
  constructor(delegate, publication, properties, highlighter, api) {
47184
47127
  this.currentChapterPopupResult = [];
@@ -47203,9 +47146,7 @@ var DefinitionsModule = class {
47203
47146
  return search;
47204
47147
  }
47205
47148
  async stop() {
47206
- if (IS_DEV) {
47207
- console.log("Definitions module stop");
47208
- }
47149
+ import_loglevel20.default.log("Definitions module stop");
47209
47150
  }
47210
47151
  async start() {
47211
47152
  this.delegate.definitionsModule = this;
@@ -47327,6 +47268,7 @@ var DefinitionsModule = class {
47327
47268
 
47328
47269
  // src/modules/linefocus/LineFocusModule.ts
47329
47270
  init_polyfills();
47271
+ var import_loglevel21 = __toModule(require_loglevel());
47330
47272
  var DEFAULT_BACKGROUND_COLOR_OPACITY2 = 0.5;
47331
47273
  var LineFocusModule = class {
47332
47274
  constructor(delegate, properties, highlighter, api) {
@@ -47351,9 +47293,7 @@ var LineFocusModule = class {
47351
47293
  return search;
47352
47294
  }
47353
47295
  async stop() {
47354
- if (IS_DEV) {
47355
- console.log("Definitions module stop");
47356
- }
47296
+ import_loglevel21.default.log("Definitions module stop");
47357
47297
  this.hasEventListener = false;
47358
47298
  removeEventListenerOptional(document, "keydown", this.keydown.bind(this));
47359
47299
  removeEventListenerOptional(document, "keyup", this.keyup.bind(this));
@@ -47748,11 +47688,9 @@ var LineFocusModule = class {
47748
47688
  range.detach();
47749
47689
  return rect;
47750
47690
  } catch (error) {
47751
- if (IS_DEV) {
47752
- console.log("measureTextNode " + error);
47753
- console.log("measureTextNode " + node);
47754
- console.log(node.textContent);
47755
- }
47691
+ import_loglevel21.default.log("measureTextNode " + error);
47692
+ import_loglevel21.default.log("measureTextNode " + node);
47693
+ import_loglevel21.default.log(`${node.textContent}`);
47756
47694
  }
47757
47695
  }
47758
47696
  measureImageNodes(node) {
@@ -47763,17 +47701,16 @@ var LineFocusModule = class {
47763
47701
  range.detach();
47764
47702
  return rect;
47765
47703
  } catch (error) {
47766
- if (IS_DEV) {
47767
- console.log("measureTextNode " + error);
47768
- console.log("measureTextNode " + node);
47769
- console.log(node.textContent);
47770
- }
47704
+ import_loglevel21.default.log("measureTextNode " + error);
47705
+ import_loglevel21.default.log("measureTextNode " + node);
47706
+ import_loglevel21.default.log(`${node.textContent}`);
47771
47707
  }
47772
47708
  }
47773
47709
  };
47774
47710
 
47775
47711
  // src/modules/history/HistoryModule.ts
47776
47712
  init_polyfills();
47713
+ var import_loglevel22 = __toModule(require_loglevel());
47777
47714
  var HistoryModule = class {
47778
47715
  constructor(annotator, delegate, publication, properties, headerMenu) {
47779
47716
  this.history = [];
@@ -47789,9 +47726,7 @@ var HistoryModule = class {
47789
47726
  return pageBreak;
47790
47727
  }
47791
47728
  async stop() {
47792
- if (IS_DEV) {
47793
- console.log("Page Break module stop");
47794
- }
47729
+ import_loglevel22.default.log("Page Break module stop");
47795
47730
  removeEventListenerOptional(this.historyForwardAnchorElement, "click", this.handleHistoryForwardClick.bind(this));
47796
47731
  removeEventListenerOptional(this.historyBackAnchorElement, "click", this.handleHistoryBackClick.bind(this));
47797
47732
  }
@@ -47829,10 +47764,8 @@ var HistoryModule = class {
47829
47764
  lastInHistory = this.history[this.history.length - 1];
47830
47765
  if (lastInHistory && lastInHistory.href !== lastReadingPosition.href || lastInHistory === void 0) {
47831
47766
  const linkHref = this.publication.getAbsoluteHref(lastReadingPosition.href);
47832
- if (IS_DEV)
47833
- console.log(lastReadingPosition.href);
47834
- if (IS_DEV)
47835
- console.log(linkHref);
47767
+ import_loglevel22.default.log(lastReadingPosition.href);
47768
+ import_loglevel22.default.log(linkHref);
47836
47769
  lastReadingPosition.href = linkHref;
47837
47770
  this.history.push(lastReadingPosition);
47838
47771
  this.historyCurrentIndex = this.history.length - 1;
@@ -47882,6 +47815,7 @@ var HistoryModule = class {
47882
47815
 
47883
47816
  // src/modules/citation/CitationModule.ts
47884
47817
  init_polyfills();
47818
+ var import_loglevel23 = __toModule(require_loglevel());
47885
47819
  var CitationStyle;
47886
47820
  (function(CitationStyle2) {
47887
47821
  CitationStyle2[CitationStyle2["Chicago"] = 0] = "Chicago";
@@ -47908,9 +47842,7 @@ var CitationModule = class {
47908
47842
  return module;
47909
47843
  }
47910
47844
  async stop() {
47911
- if (IS_DEV) {
47912
- console.log("Timeline module stop");
47913
- }
47845
+ import_loglevel23.default.log("Timeline module stop");
47914
47846
  }
47915
47847
  copyToClipboard(textToClipboard) {
47916
47848
  let success = true;
@@ -48346,7 +48278,6 @@ var D2Reader = class {
48346
48278
  useLocalStorage: initialConfig.useLocalStorage ?? false
48347
48279
  });
48348
48280
  const annotator = new LocalAnnotator({ store });
48349
- const upLink = initialConfig.upLinkUrl ?? void 0;
48350
48281
  publication.sample = initialConfig.sample;
48351
48282
  rights = updateConfig(rights, publication);
48352
48283
  if (rights.autoGeneratePositions) {
@@ -48375,7 +48306,6 @@ var D2Reader = class {
48375
48306
  publication,
48376
48307
  settings,
48377
48308
  annotator,
48378
- upLink,
48379
48309
  initialLastReadingPosition: initialConfig.lastReadingPosition,
48380
48310
  api: initialConfig.api,
48381
48311
  rights,