@d-i-t-a/reader 2.4.3 → 2.4.5

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
@@ -5225,7 +5225,7 @@ var require_metadata_encrypted = __commonJS({
5225
5225
  exports2.Encrypted = void 0;
5226
5226
  var tslib_1 = (init_tslib_es62(), __toCommonJS(tslib_es6_exports2));
5227
5227
  var ta_json_x_1 = require_cjs();
5228
- var Encrypted = exports2.Encrypted = class Encrypted {
5228
+ var Encrypted = class Encrypted {
5229
5229
  constructor() {
5230
5230
  this.DecryptedLengthBeforeInflate = -1;
5231
5231
  this.CypherBlockPadding = -1;
@@ -5240,6 +5240,7 @@ var require_metadata_encrypted = __commonJS({
5240
5240
  }
5241
5241
  }
5242
5242
  };
5243
+ exports2.Encrypted = Encrypted;
5243
5244
  tslib_1.__decorate([
5244
5245
  (0, ta_json_x_1.JsonProperty)("scheme"),
5245
5246
  tslib_1.__metadata("design:type", String)
@@ -5312,8 +5313,9 @@ var require_metadata_properties = __commonJS({
5312
5313
  SpreadEnum2["Landscape"] = "landscape";
5313
5314
  })(SpreadEnum || (exports2.SpreadEnum = SpreadEnum = {}));
5314
5315
  exports2.PropertiesSupportedKeys = ["contains", "layout", "orientation", "overflow", "page", "spread", "encrypted", "media-overlay"];
5315
- var Properties = exports2.Properties = class Properties {
5316
+ var Properties = class Properties {
5316
5317
  };
5318
+ exports2.Properties = Properties;
5317
5319
  tslib_1.__decorate([
5318
5320
  (0, ta_json_x_1.JsonProperty)("contains"),
5319
5321
  (0, ta_json_x_1.JsonElementType)(String),
@@ -5358,7 +5360,6 @@ var require_publication_link = __commonJS({
5358
5360
  "node_modules/r2-shared-js/dist/es6-es2015/src/models/publication-link.js"(exports2) {
5359
5361
  "use strict";
5360
5362
  init_polyfills();
5361
- var Link_1;
5362
5363
  Object.defineProperty(exports2, "__esModule", { value: true });
5363
5364
  exports2.Link = void 0;
5364
5365
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
@@ -5369,7 +5370,7 @@ var require_publication_link = __commonJS({
5369
5370
  var PROPERTIES_JSON_PROP = "properties";
5370
5371
  var CHILDREN_JSON_PROP = "children";
5371
5372
  var ALTERNATE_JSON_PROP = "alternate";
5372
- var Link2 = exports2.Link = Link_1 = class Link {
5373
+ var Link2 = class Link {
5373
5374
  get Href() {
5374
5375
  return this.Href1;
5375
5376
  }
@@ -5422,6 +5423,7 @@ var require_publication_link = __commonJS({
5422
5423
  }
5423
5424
  }
5424
5425
  };
5426
+ exports2.Link = Link2;
5425
5427
  tslib_1.__decorate([
5426
5428
  (0, ta_json_x_1.JsonProperty)("type"),
5427
5429
  tslib_1.__metadata("design:type", String)
@@ -5456,12 +5458,12 @@ var require_publication_link = __commonJS({
5456
5458
  ], Link2.prototype, "Templated", void 0);
5457
5459
  tslib_1.__decorate([
5458
5460
  (0, ta_json_x_1.JsonProperty)(CHILDREN_JSON_PROP),
5459
- (0, ta_json_x_1.JsonElementType)(Link_1),
5461
+ (0, ta_json_x_1.JsonElementType)(Link2),
5460
5462
  tslib_1.__metadata("design:type", Array)
5461
5463
  ], Link2.prototype, "Children", void 0);
5462
5464
  tslib_1.__decorate([
5463
5465
  (0, ta_json_x_1.JsonProperty)(ALTERNATE_JSON_PROP),
5464
- (0, ta_json_x_1.JsonElementType)(Link_1),
5466
+ (0, ta_json_x_1.JsonElementType)(Link2),
5465
5467
  tslib_1.__metadata("design:type", Array)
5466
5468
  ], Link2.prototype, "Alternate", void 0);
5467
5469
  tslib_1.__decorate([
@@ -5480,7 +5482,7 @@ var require_publication_link = __commonJS({
5480
5482
  tslib_1.__metadata("design:paramtypes", []),
5481
5483
  tslib_1.__metadata("design:returntype", void 0)
5482
5484
  ], Link2.prototype, "_OnDeserialized", null);
5483
- exports2.Link = Link2 = Link_1 = tslib_1.__decorate([
5485
+ exports2.Link = Link2 = tslib_1.__decorate([
5484
5486
  (0, ta_json_x_1.JsonObject)()
5485
5487
  ], Link2);
5486
5488
  }
@@ -5498,7 +5500,7 @@ var require_metadata_contributor = __commonJS({
5498
5500
  var ta_json_string_converter_1 = require_ta_json_string_converter();
5499
5501
  var publication_link_1 = require_publication_link();
5500
5502
  var LINKS_JSON_PROP = "links";
5501
- var Contributor = exports2.Contributor = class Contributor {
5503
+ var Contributor = class Contributor {
5502
5504
  get SortAs() {
5503
5505
  return this.SortAs2 ? this.SortAs2 : this.SortAs1;
5504
5506
  }
@@ -5514,6 +5516,7 @@ var require_metadata_contributor = __commonJS({
5514
5516
  }
5515
5517
  }
5516
5518
  };
5519
+ exports2.Contributor = Contributor;
5517
5520
  tslib_1.__decorate([
5518
5521
  (0, ta_json_x_1.JsonProperty)("name"),
5519
5522
  tslib_1.__metadata("design:type", Object)
@@ -5624,8 +5627,9 @@ var require_metadata_belongsto = __commonJS({
5624
5627
  var metadata_contributor_json_converter_1 = require_metadata_contributor_json_converter();
5625
5628
  var SERIES_JSON_PROP = "series";
5626
5629
  var COLLECTION_JSON_PROP = "collection";
5627
- var BelongsTo = exports2.BelongsTo = class BelongsTo {
5630
+ var BelongsTo = class BelongsTo {
5628
5631
  };
5632
+ exports2.BelongsTo = BelongsTo;
5629
5633
  tslib_1.__decorate([
5630
5634
  (0, ta_json_x_1.JsonProperty)(SERIES_JSON_PROP),
5631
5635
  (0, ta_json_x_1.JsonElementType)(metadata_contributor_1.Contributor),
@@ -5653,8 +5657,9 @@ var require_metadata_media_overlay = __commonJS({
5653
5657
  exports2.MediaOverlay = void 0;
5654
5658
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
5655
5659
  var ta_json_x_1 = require_cjs();
5656
- var MediaOverlay = exports2.MediaOverlay = class MediaOverlay {
5660
+ var MediaOverlay = class MediaOverlay {
5657
5661
  };
5662
+ exports2.MediaOverlay = MediaOverlay;
5658
5663
  tslib_1.__decorate([
5659
5664
  (0, ta_json_x_1.JsonProperty)("active-class"),
5660
5665
  tslib_1.__metadata("design:type", String)
@@ -5680,7 +5685,7 @@ var require_metadata_subject = __commonJS({
5680
5685
  var ta_json_x_1 = require_cjs();
5681
5686
  var publication_link_1 = require_publication_link();
5682
5687
  var LINKS_JSON_PROP = "links";
5683
- var Subject = exports2.Subject = class Subject {
5688
+ var Subject = class Subject {
5684
5689
  get SortAs() {
5685
5690
  return this.SortAs2 ? this.SortAs2 : this.SortAs1;
5686
5691
  }
@@ -5696,6 +5701,7 @@ var require_metadata_subject = __commonJS({
5696
5701
  }
5697
5702
  }
5698
5703
  };
5704
+ exports2.Subject = Subject;
5699
5705
  tslib_1.__decorate([
5700
5706
  (0, ta_json_x_1.JsonProperty)("name"),
5701
5707
  tslib_1.__metadata("design:type", Object)
@@ -5777,8 +5783,9 @@ var require_metadata_accessibility_certification = __commonJS({
5777
5783
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
5778
5784
  var ta_json_x_1 = require_cjs();
5779
5785
  var ta_json_string_converter_1 = require_ta_json_string_converter();
5780
- var AccessibilityCertification = exports2.AccessibilityCertification = class AccessibilityCertification {
5786
+ var AccessibilityCertification = class AccessibilityCertification {
5781
5787
  };
5788
+ exports2.AccessibilityCertification = AccessibilityCertification;
5782
5789
  tslib_1.__decorate([
5783
5790
  (0, ta_json_x_1.JsonProperty)("certifiedBy"),
5784
5791
  (0, ta_json_x_1.JsonConverter)(ta_json_string_converter_1.JsonStringConverter),
@@ -5814,8 +5821,9 @@ var require_metadata_accessibility = __commonJS({
5814
5821
  var ta_json_x_1 = require_cjs();
5815
5822
  var ta_json_string_converter_1 = require_ta_json_string_converter();
5816
5823
  var metadata_accessibility_certification_1 = require_metadata_accessibility_certification();
5817
- var AccessibilityMetadata = exports2.AccessibilityMetadata = class AccessibilityMetadata {
5824
+ var AccessibilityMetadata = class AccessibilityMetadata {
5818
5825
  };
5826
+ exports2.AccessibilityMetadata = AccessibilityMetadata;
5819
5827
  tslib_1.__decorate([
5820
5828
  (0, ta_json_x_1.JsonProperty)("certification"),
5821
5829
  tslib_1.__metadata("design:type", metadata_accessibility_certification_1.AccessibilityCertification)
@@ -5935,7 +5943,7 @@ var require_metadata = __commonJS({
5935
5943
  "source",
5936
5944
  "subject"
5937
5945
  ];
5938
- var Metadata = exports2.Metadata = class Metadata {
5946
+ var Metadata = class Metadata {
5939
5947
  get SortAs() {
5940
5948
  return this.SortAs2 ? this.SortAs2 : this.SortAs1;
5941
5949
  }
@@ -5969,6 +5977,7 @@ var require_metadata = __commonJS({
5969
5977
  }
5970
5978
  }
5971
5979
  };
5980
+ exports2.Metadata = Metadata;
5972
5981
  tslib_1.__decorate([
5973
5982
  (0, ta_json_x_1.JsonProperty)("accessibility"),
5974
5983
  tslib_1.__metadata("design:type", metadata_accessibility_1.AccessibilityMetadata)
@@ -6241,7 +6250,7 @@ var require_publication = __commonJS({
6241
6250
  var LOA_JSON_PROP = "loa";
6242
6251
  var LOV_JSON_PROP = "lov";
6243
6252
  var LOT_JSON_PROP = "lot";
6244
- var Publication2 = exports2.Publication = class Publication {
6253
+ var Publication2 = class Publication {
6245
6254
  get Spine() {
6246
6255
  return this.Spine2 ? this.Spine2 : this.Spine1;
6247
6256
  }
@@ -6348,6 +6357,7 @@ var require_publication = __commonJS({
6348
6357
  }
6349
6358
  }
6350
6359
  };
6360
+ exports2.Publication = Publication2;
6351
6361
  tslib_1.__decorate([
6352
6362
  (0, ta_json_x_1.JsonProperty)("@context"),
6353
6363
  (0, ta_json_x_1.JsonElementType)(String),
@@ -15309,6 +15319,8 @@ var require_loglevel = __commonJS({
15309
15319
  "warn",
15310
15320
  "error"
15311
15321
  ];
15322
+ var _loggersByName = {};
15323
+ var defaultLogger = null;
15312
15324
  function bindMethod(obj, methodName) {
15313
15325
  var method = obj[methodName];
15314
15326
  if (typeof method.bind === "function") {
@@ -15350,28 +15362,33 @@ var require_loglevel = __commonJS({
15350
15362
  return noop;
15351
15363
  }
15352
15364
  }
15353
- function replaceLoggingMethods(level, loggerName) {
15365
+ function replaceLoggingMethods() {
15366
+ var level = this.getLevel();
15354
15367
  for (var i = 0; i < logMethods.length; i++) {
15355
15368
  var methodName = logMethods[i];
15356
- this[methodName] = i < level ? noop : this.methodFactory(methodName, level, loggerName);
15369
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
15357
15370
  }
15358
15371
  this.log = this.debug;
15372
+ if (typeof console === undefinedType && level < this.levels.SILENT) {
15373
+ return "No console available for logging";
15374
+ }
15359
15375
  }
15360
- function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
15376
+ function enableLoggingWhenConsoleArrives(methodName) {
15361
15377
  return function() {
15362
15378
  if (typeof console !== undefinedType) {
15363
- replaceLoggingMethods.call(this, level, loggerName);
15379
+ replaceLoggingMethods.call(this);
15364
15380
  this[methodName].apply(this, arguments);
15365
15381
  }
15366
15382
  };
15367
15383
  }
15368
- function defaultMethodFactory(methodName, level, loggerName) {
15384
+ function defaultMethodFactory(methodName, _level, _loggerName) {
15369
15385
  return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
15370
15386
  }
15371
- function Logger(name, defaultLevel, factory) {
15387
+ function Logger(name, factory) {
15372
15388
  var self2 = this;
15373
- var currentLevel;
15374
- defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
15389
+ var inheritedLevel;
15390
+ var defaultLevel;
15391
+ var userLevel;
15375
15392
  var storageKey = "loglevel";
15376
15393
  if (typeof name === "string") {
15377
15394
  storageKey += ":" + name;
@@ -15403,11 +15420,12 @@ var require_loglevel = __commonJS({
15403
15420
  if (typeof storedLevel === undefinedType) {
15404
15421
  try {
15405
15422
  var cookie = window.document.cookie;
15406
- var location = cookie.indexOf(
15407
- encodeURIComponent(storageKey) + "="
15408
- );
15423
+ var cookieName = encodeURIComponent(storageKey);
15424
+ var location = cookie.indexOf(cookieName + "=");
15409
15425
  if (location !== -1) {
15410
- storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
15426
+ storedLevel = /^([^;]+)/.exec(
15427
+ cookie.slice(location + cookieName.length + 1)
15428
+ )[1];
15411
15429
  }
15412
15430
  } catch (ignore) {
15413
15431
  }
@@ -15422,7 +15440,6 @@ var require_loglevel = __commonJS({
15422
15440
  return;
15423
15441
  try {
15424
15442
  window.localStorage.removeItem(storageKey);
15425
- return;
15426
15443
  } catch (ignore) {
15427
15444
  }
15428
15445
  try {
@@ -15430,6 +15447,17 @@ var require_loglevel = __commonJS({
15430
15447
  } catch (ignore) {
15431
15448
  }
15432
15449
  }
15450
+ function normalizeLevel(input) {
15451
+ var level = input;
15452
+ if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
15453
+ level = self2.levels[level.toUpperCase()];
15454
+ }
15455
+ if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
15456
+ return level;
15457
+ } else {
15458
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
15459
+ }
15460
+ }
15433
15461
  self2.name = name;
15434
15462
  self2.levels = {
15435
15463
  "TRACE": 0,
@@ -15441,34 +15469,31 @@ var require_loglevel = __commonJS({
15441
15469
  };
15442
15470
  self2.methodFactory = factory || defaultMethodFactory;
15443
15471
  self2.getLevel = function() {
15444
- return currentLevel;
15472
+ if (userLevel != null) {
15473
+ return userLevel;
15474
+ } else if (defaultLevel != null) {
15475
+ return defaultLevel;
15476
+ } else {
15477
+ return inheritedLevel;
15478
+ }
15445
15479
  };
15446
15480
  self2.setLevel = function(level, persist) {
15447
- if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
15448
- level = self2.levels[level.toUpperCase()];
15449
- }
15450
- if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
15451
- currentLevel = level;
15452
- if (persist !== false) {
15453
- persistLevelIfPossible(level);
15454
- }
15455
- replaceLoggingMethods.call(self2, level, name);
15456
- if (typeof console === undefinedType && level < self2.levels.SILENT) {
15457
- return "No console available for logging";
15458
- }
15459
- } else {
15460
- throw "log.setLevel() called with invalid level: " + level;
15481
+ userLevel = normalizeLevel(level);
15482
+ if (persist !== false) {
15483
+ persistLevelIfPossible(userLevel);
15461
15484
  }
15485
+ return replaceLoggingMethods.call(self2);
15462
15486
  };
15463
15487
  self2.setDefaultLevel = function(level) {
15464
- defaultLevel = level;
15488
+ defaultLevel = normalizeLevel(level);
15465
15489
  if (!getPersistedLevel()) {
15466
15490
  self2.setLevel(level, false);
15467
15491
  }
15468
15492
  };
15469
15493
  self2.resetLevel = function() {
15470
- self2.setLevel(defaultLevel, false);
15494
+ userLevel = null;
15471
15495
  clearPersistedLevel();
15496
+ replaceLoggingMethods.call(self2);
15472
15497
  };
15473
15498
  self2.enableAll = function(persist) {
15474
15499
  self2.setLevel(self2.levels.TRACE, persist);
@@ -15476,14 +15501,27 @@ var require_loglevel = __commonJS({
15476
15501
  self2.disableAll = function(persist) {
15477
15502
  self2.setLevel(self2.levels.SILENT, persist);
15478
15503
  };
15504
+ self2.rebuild = function() {
15505
+ if (defaultLogger !== self2) {
15506
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
15507
+ }
15508
+ replaceLoggingMethods.call(self2);
15509
+ if (defaultLogger === self2) {
15510
+ for (var childName in _loggersByName) {
15511
+ _loggersByName[childName].rebuild();
15512
+ }
15513
+ }
15514
+ };
15515
+ inheritedLevel = normalizeLevel(
15516
+ defaultLogger ? defaultLogger.getLevel() : "WARN"
15517
+ );
15479
15518
  var initialLevel = getPersistedLevel();
15480
- if (initialLevel == null) {
15481
- initialLevel = defaultLevel;
15519
+ if (initialLevel != null) {
15520
+ userLevel = normalizeLevel(initialLevel);
15482
15521
  }
15483
- self2.setLevel(initialLevel, false);
15522
+ replaceLoggingMethods.call(self2);
15484
15523
  }
15485
- var defaultLogger = new Logger();
15486
- var _loggersByName = {};
15524
+ defaultLogger = new Logger();
15487
15525
  defaultLogger.getLogger = function getLogger(name) {
15488
15526
  if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
15489
15527
  throw new TypeError("You must supply a name when creating a logger.");
@@ -15492,7 +15530,6 @@ var require_loglevel = __commonJS({
15492
15530
  if (!logger) {
15493
15531
  logger = _loggersByName[name] = new Logger(
15494
15532
  name,
15495
- defaultLogger.getLevel(),
15496
15533
  defaultLogger.methodFactory
15497
15534
  );
15498
15535
  }
@@ -21344,7 +21381,6 @@ var require_media_overlay = __commonJS({
21344
21381
  "node_modules/r2-shared-js/dist/es6-es2015/src/models/media-overlay.js"(exports2) {
21345
21382
  "use strict";
21346
21383
  init_polyfills();
21347
- var MediaOverlayNode_1;
21348
21384
  Object.defineProperty(exports2, "__esModule", { value: true });
21349
21385
  exports2.MediaOverlayNode = exports2.timeStrToSeconds = void 0;
21350
21386
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
@@ -21407,11 +21443,12 @@ var require_media_overlay = __commonJS({
21407
21443
  return hours * 3600 + minutes * 60 + seconds;
21408
21444
  }
21409
21445
  exports2.timeStrToSeconds = timeStrToSeconds;
21410
- var MediaOverlayNode2 = exports2.MediaOverlayNode = MediaOverlayNode_1 = class MediaOverlayNode {
21446
+ var MediaOverlayNode2 = class MediaOverlayNode {
21411
21447
  constructor() {
21412
21448
  this.initialized = false;
21413
21449
  }
21414
21450
  };
21451
+ exports2.MediaOverlayNode = MediaOverlayNode2;
21415
21452
  tslib_1.__decorate([
21416
21453
  (0, ta_json_x_1.JsonProperty)("text"),
21417
21454
  tslib_1.__metadata("design:type", String)
@@ -21428,10 +21465,10 @@ var require_media_overlay = __commonJS({
21428
21465
  ], MediaOverlayNode2.prototype, "Role", void 0);
21429
21466
  tslib_1.__decorate([
21430
21467
  (0, ta_json_x_1.JsonProperty)("narration"),
21431
- (0, ta_json_x_1.JsonElementType)(MediaOverlayNode_1),
21468
+ (0, ta_json_x_1.JsonElementType)(MediaOverlayNode2),
21432
21469
  tslib_1.__metadata("design:type", Array)
21433
21470
  ], MediaOverlayNode2.prototype, "Children", void 0);
21434
- exports2.MediaOverlayNode = MediaOverlayNode2 = MediaOverlayNode_1 = tslib_1.__decorate([
21471
+ exports2.MediaOverlayNode = MediaOverlayNode2 = tslib_1.__decorate([
21435
21472
  (0, ta_json_x_1.JsonObject)()
21436
21473
  ], MediaOverlayNode2);
21437
21474
  }
@@ -46067,6 +46104,7 @@ _ReadiumCSS.SCROLL_REF = "scroll";
46067
46104
  // static readonly PUBLISHER_DEFAULT_REF = "advancedSettings";
46068
46105
  _ReadiumCSS.TEXT_ALIGNMENT_REF = "textAlign";
46069
46106
  _ReadiumCSS.COLUMN_COUNT_REF = "colCount";
46107
+ _ReadiumCSS.DIRECTION_REF = "direction";
46070
46108
  _ReadiumCSS.WORD_SPACING_REF = "wordSpacing";
46071
46109
  _ReadiumCSS.LETTER_SPACING_REF = "letterSpacing";
46072
46110
  _ReadiumCSS.PAGE_MARGINS_REF = "pageMargins";
@@ -46080,6 +46118,7 @@ _ReadiumCSS.SCROLL_KEY = "--USER__" + _ReadiumCSS.SCROLL_REF;
46080
46118
  // "--USER__" + ReadiumCSS.PUBLISHER_DEFAULT_REF;
46081
46119
  _ReadiumCSS.TEXT_ALIGNMENT_KEY = "--USER__" + _ReadiumCSS.TEXT_ALIGNMENT_REF;
46082
46120
  _ReadiumCSS.COLUMN_COUNT_KEY = "--USER__" + _ReadiumCSS.COLUMN_COUNT_REF;
46121
+ _ReadiumCSS.DIRECTION_KEY = "--USER__" + _ReadiumCSS.DIRECTION_REF;
46083
46122
  _ReadiumCSS.WORD_SPACING_KEY = "--USER__" + _ReadiumCSS.WORD_SPACING_REF;
46084
46123
  _ReadiumCSS.LETTER_SPACING_KEY = "--USER__" + _ReadiumCSS.LETTER_SPACING_REF;
46085
46124
  _ReadiumCSS.PAGE_MARGINS_KEY = "--USER__" + _ReadiumCSS.PAGE_MARGINS_REF;
@@ -47019,6 +47058,7 @@ var _UserSettings = class _UserSettings {
47019
47058
  // publisherDefaults = true;
47020
47059
  this.textAlignment = 0;
47021
47060
  this.columnCount = 0;
47061
+ this.direction = 0;
47022
47062
  this.wordSpacing = 0;
47023
47063
  this.letterSpacing = 0;
47024
47064
  this.pageMargins = 2;
@@ -47082,7 +47122,9 @@ var _UserSettings = class _UserSettings {
47082
47122
  import_loglevel2.default.log(settings.verticalScroll);
47083
47123
  }
47084
47124
  if (initialUserSettings.appearance) {
47085
- settings.appearance = _UserSettings.parseAppearanceSetting(initialUserSettings.appearance);
47125
+ settings.appearance = _UserSettings.parseAppearanceSetting(
47126
+ initialUserSettings.appearance
47127
+ );
47086
47128
  let prop = settings.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF);
47087
47129
  if (prop) {
47088
47130
  prop.value = settings.appearance;
@@ -47139,6 +47181,17 @@ var _UserSettings = class _UserSettings {
47139
47181
  }
47140
47182
  import_loglevel2.default.log(settings.columnCount);
47141
47183
  }
47184
+ if (initialUserSettings.direction) {
47185
+ settings.direction = _UserSettings.directionValues.findIndex(
47186
+ (el) => el === initialUserSettings.direction
47187
+ );
47188
+ let prop = settings.userProperties.getByRef(ReadiumCSS.DIRECTION_REF);
47189
+ if (prop) {
47190
+ prop.value = settings.direction;
47191
+ await settings.saveProperty(prop);
47192
+ }
47193
+ import_loglevel2.default.log(settings.direction);
47194
+ }
47142
47195
  if (initialUserSettings.wordSpacing) {
47143
47196
  settings.wordSpacing = initialUserSettings.wordSpacing;
47144
47197
  let prop = settings.userProperties.getByRef(
@@ -47214,6 +47267,10 @@ var _UserSettings = class _UserSettings {
47214
47267
  "columnCount",
47215
47268
  ReadiumCSS.COLUMN_COUNT_KEY
47216
47269
  );
47270
+ this.direction = await this.getPropertyAndFallback(
47271
+ "direction",
47272
+ ReadiumCSS.DIRECTION_KEY
47273
+ );
47217
47274
  this.fontSize = await this.getPropertyAndFallback(
47218
47275
  "fontSize",
47219
47276
  ReadiumCSS.FONT_SIZE_KEY
@@ -47244,6 +47301,7 @@ var _UserSettings = class _UserSettings {
47244
47301
  this.fontFamily = 0;
47245
47302
  this.textAlignment = 0;
47246
47303
  this.columnCount = 0;
47304
+ this.direction = 0;
47247
47305
  this.wordSpacing = 0;
47248
47306
  this.letterSpacing = 0;
47249
47307
  this.pageMargins = 2;
@@ -47256,18 +47314,21 @@ var _UserSettings = class _UserSettings {
47256
47314
  "html"
47257
47315
  );
47258
47316
  if (html) {
47259
- const rootElement = document.documentElement;
47260
- const body = findRequiredElement(rootElement, "body");
47317
+ const rootElement = findElement(document, "#root") || document.documentElement;
47318
+ const body = findElement(html, "body");
47261
47319
  html.style.removeProperty(ReadiumCSS.FONT_SIZE_KEY);
47262
47320
  html.style.removeProperty(ReadiumCSS.WORD_SPACING_KEY);
47263
47321
  html.style.removeProperty(ReadiumCSS.LETTER_SPACING_KEY);
47264
47322
  html.style.removeProperty(ReadiumCSS.COLUMN_COUNT_KEY);
47323
+ html.style.removeProperty(ReadiumCSS.DIRECTION_KEY);
47265
47324
  html.style.removeProperty(ReadiumCSS.TEXT_ALIGNMENT_KEY);
47266
47325
  html.style.removeProperty(ReadiumCSS.LINE_HEIGHT_KEY);
47267
47326
  html.style.removeProperty(ReadiumCSS.PAGE_MARGINS_KEY);
47268
47327
  html.style.removeProperty(ReadiumCSS.APPEARANCE_KEY);
47269
- setAttr(rootElement, "data-viewer-theme", "day");
47270
- setAttr(body, "data-viewer-theme", "day");
47328
+ if (rootElement)
47329
+ setAttr(rootElement, "data-viewer-theme", "day");
47330
+ if (body)
47331
+ setAttr(body, "data-viewer-theme", "day");
47271
47332
  html.style.removeProperty(ReadiumCSS.FONT_FAMILY_KEY);
47272
47333
  setAttr(html, "data-viewer-font", "publisher");
47273
47334
  html.style.setProperty(
@@ -47286,7 +47347,7 @@ var _UserSettings = class _UserSettings {
47286
47347
  );
47287
47348
  }
47288
47349
  async applyProperties() {
47289
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
47350
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
47290
47351
  this.userProperties = this.getUserSettings();
47291
47352
  let doc = this.iframe.contentDocument;
47292
47353
  if (doc) {
@@ -47295,8 +47356,8 @@ var _UserSettings = class _UserSettings {
47295
47356
  "html"
47296
47357
  );
47297
47358
  if (html) {
47298
- const rootElement = document.documentElement;
47299
- const body = findRequiredElement(rootElement, "body");
47359
+ const rootElement = findElement(document, "#root") || document.documentElement;
47360
+ const body = findElement(html, "body");
47300
47361
  if ((_a = this.view) == null ? void 0 : _a.navigator.publication.isReflowable) {
47301
47362
  if (await this.getProperty(ReadiumCSS.FONT_SIZE_KEY)) {
47302
47363
  html.style.setProperty(
@@ -47353,42 +47414,57 @@ var _UserSettings = class _UserSettings {
47353
47414
  ((_k = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _k.toString()) ?? null
47354
47415
  );
47355
47416
  if (((_l = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _l.value) === 0) {
47356
- setAttr(rootElement, "data-viewer-theme", "day");
47357
- setAttr(body, "data-viewer-theme", "day");
47417
+ if (rootElement)
47418
+ setAttr(rootElement, "data-viewer-theme", "day");
47419
+ if (body)
47420
+ setAttr(body, "data-viewer-theme", "day");
47358
47421
  } else if (((_m = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _m.value) === 1) {
47359
- setAttr(rootElement, "data-viewer-theme", "sepia");
47360
- setAttr(body, "data-viewer-theme", "sepia");
47422
+ if (rootElement)
47423
+ setAttr(rootElement, "data-viewer-theme", "sepia");
47424
+ if (body)
47425
+ setAttr(body, "data-viewer-theme", "sepia");
47361
47426
  } else if (((_n = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _n.value) === 2) {
47362
- setAttr(rootElement, "data-viewer-theme", "night");
47363
- setAttr(body, "data-viewer-theme", "night");
47427
+ if (rootElement)
47428
+ setAttr(rootElement, "data-viewer-theme", "night");
47429
+ if (body)
47430
+ setAttr(body, "data-viewer-theme", "night");
47364
47431
  }
47365
47432
  } else {
47366
47433
  html.style.setProperty(
47367
47434
  ReadiumCSS.APPEARANCE_KEY,
47368
47435
  ((_o = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _o.toString()) ?? null
47369
47436
  );
47370
- setAttr(rootElement, "data-viewer-theme", "day");
47371
- setAttr(body, "data-viewer-theme", "day");
47437
+ if (rootElement)
47438
+ setAttr(rootElement, "data-viewer-theme", "day");
47439
+ if (body)
47440
+ setAttr(body, "data-viewer-theme", "day");
47441
+ }
47442
+ if ((_p = this.view) == null ? void 0 : _p.navigator.publication.isFixedLayout) {
47443
+ if (await this.getProperty(ReadiumCSS.DIRECTION_KEY)) {
47444
+ let value = ((_q = this.userProperties.getByRef(ReadiumCSS.DIRECTION_REF)) == null ? void 0 : _q.toString()) ?? null;
47445
+ html.style.setProperty(ReadiumCSS.DIRECTION_KEY, value);
47446
+ this.view.navigator.setDirection(value);
47447
+ }
47372
47448
  }
47373
- if ((_p = this.view) == null ? void 0 : _p.navigator.publication.isReflowable) {
47449
+ if ((_r = this.view) == null ? void 0 : _r.navigator.publication.isReflowable) {
47374
47450
  if (await this.getProperty(ReadiumCSS.FONT_FAMILY_KEY)) {
47375
47451
  html.style.setProperty(
47376
47452
  ReadiumCSS.FONT_FAMILY_KEY,
47377
- ((_q = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _q.toString()) ?? null
47453
+ ((_s = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _s.toString()) ?? null
47378
47454
  );
47379
- if (((_r = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _r.value) === 0) {
47455
+ if (((_t = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _t.value) === 0) {
47380
47456
  setAttr(html, "data-viewer-font", "publisher");
47381
47457
  html.style.setProperty(
47382
47458
  ReadiumCSS.FONT_OVERRIDE_KEY,
47383
47459
  "readium-font-off"
47384
47460
  );
47385
- } else if (((_s = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _s.value) === 1) {
47461
+ } else if (((_u = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _u.value) === 1) {
47386
47462
  setAttr(html, "data-viewer-font", "serif");
47387
47463
  html.style.setProperty(
47388
47464
  ReadiumCSS.FONT_OVERRIDE_KEY,
47389
47465
  "readium-font-on"
47390
47466
  );
47391
- } else if (((_t = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _t.value) === 2) {
47467
+ } else if (((_v = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _v.value) === 2) {
47392
47468
  setAttr(html, "data-viewer-font", "sans");
47393
47469
  html.style.setProperty(
47394
47470
  ReadiumCSS.FONT_OVERRIDE_KEY,
@@ -47413,7 +47489,7 @@ var _UserSettings = class _UserSettings {
47413
47489
  } else {
47414
47490
  html.style.setProperty(
47415
47491
  ReadiumCSS.FONT_FAMILY_KEY,
47416
- ((_u = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _u.toString()) ?? null
47492
+ ((_w = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _w.toString()) ?? null
47417
47493
  );
47418
47494
  setAttr(html, "data-viewer-font", "publisher");
47419
47495
  html.style.setProperty(
@@ -47422,7 +47498,7 @@ var _UserSettings = class _UserSettings {
47422
47498
  );
47423
47499
  }
47424
47500
  if (await this.getProperty(ReadiumCSS.SCROLL_KEY)) {
47425
- if (((_v = this.userProperties.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _v.value) === true) {
47501
+ if (((_x = this.userProperties.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _x.value) === true) {
47426
47502
  html.style.setProperty("--USER__scroll", "readium-scroll-on");
47427
47503
  } else {
47428
47504
  html.style.setProperty("--USER__scroll", "readium-scroll-off");
@@ -47489,24 +47565,25 @@ var _UserSettings = class _UserSettings {
47489
47565
  this.applyProperties();
47490
47566
  }
47491
47567
  async updateUserSettings() {
47492
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
47568
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
47493
47569
  let userSettings = {
47494
47570
  fontFamily: _UserSettings.fontFamilyValues[await ((_b = (_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _b.value)],
47495
47571
  fontSize: (_d = (_c = this.userProperties) == null ? void 0 : _c.getByRef(ReadiumCSS.FONT_SIZE_REF)) == null ? void 0 : _d.value,
47496
47572
  appearance: _UserSettings.appearanceValues[await ((_f = (_e = this.userProperties) == null ? void 0 : _e.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _f.value)],
47497
47573
  textAlignment: _UserSettings.textAlignmentValues[await ((_h = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.TEXT_ALIGNMENT_REF)) == null ? void 0 : _h.value)],
47498
47574
  columnCount: _UserSettings.columnCountValues[await ((_j = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.COLUMN_COUNT_REF)) == null ? void 0 : _j.value)],
47499
- wordSpacing: (_l = (_k = this.userProperties) == null ? void 0 : _k.getByRef(ReadiumCSS.WORD_SPACING_REF)) == null ? void 0 : _l.value,
47500
- letterSpacing: (_n = (_m = this.userProperties) == null ? void 0 : _m.getByRef(
47575
+ direction: _UserSettings.directionValues[await ((_l = (_k = this.userProperties) == null ? void 0 : _k.getByRef(ReadiumCSS.DIRECTION_REF)) == null ? void 0 : _l.value)],
47576
+ wordSpacing: (_n = (_m = this.userProperties) == null ? void 0 : _m.getByRef(ReadiumCSS.WORD_SPACING_REF)) == null ? void 0 : _n.value,
47577
+ letterSpacing: (_p = (_o = this.userProperties) == null ? void 0 : _o.getByRef(
47501
47578
  ReadiumCSS.LETTER_SPACING_REF
47502
- )) == null ? void 0 : _n.value,
47579
+ )) == null ? void 0 : _p.value,
47503
47580
  // publisherDefault: this.userProperties.getByRef(
47504
47581
  // ReadiumCSS.PUBLISHER_DEFAULT_REF
47505
47582
  // ).value,
47506
- verticalScroll: (_p = (_o = this.userProperties) == null ? void 0 : _o.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _p.value
47583
+ verticalScroll: (_r = (_q = this.userProperties) == null ? void 0 : _q.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _r.value
47507
47584
  };
47508
- if ((_q = this.api) == null ? void 0 : _q.updateSettings) {
47509
- (_r = this.api) == null ? void 0 : _r.updateSettings(userSettings).then((_) => {
47585
+ if ((_s = this.api) == null ? void 0 : _s.updateSettings) {
47586
+ (_t = this.api) == null ? void 0 : _t.updateSettings(userSettings).then((_) => {
47510
47587
  import_loglevel2.default.log("api updated user settings", JSON.stringify(userSettings));
47511
47588
  });
47512
47589
  }
@@ -47526,6 +47603,12 @@ var _UserSettings = class _UserSettings {
47526
47603
  ReadiumCSS.COLUMN_COUNT_REF,
47527
47604
  ReadiumCSS.COLUMN_COUNT_KEY
47528
47605
  );
47606
+ userProperties.addEnumerable(
47607
+ this.direction,
47608
+ _UserSettings.directionValues,
47609
+ ReadiumCSS.DIRECTION_REF,
47610
+ ReadiumCSS.DIRECTION_KEY
47611
+ );
47529
47612
  userProperties.addEnumerable(
47530
47613
  this.appearance,
47531
47614
  _UserSettings.appearanceValues,
@@ -47634,12 +47717,13 @@ var _UserSettings = class _UserSettings {
47634
47717
  return ((_a = await this.getProperty(key)) == null ? void 0 : _a.value) ?? this[name];
47635
47718
  }
47636
47719
  async resetUserSettings() {
47637
- await this.store.remove(this.USERSETTINGS);
47720
+ this.store.remove(this.USERSETTINGS);
47638
47721
  await this.reset();
47722
+ this.viewChangeCallback();
47639
47723
  this.settingsChangeCallback();
47640
47724
  }
47641
47725
  get currentSettings() {
47642
- var _a, _b, _c, _d, _e, _f, _g, _h;
47726
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
47643
47727
  return {
47644
47728
  appearance: _UserSettings.appearanceValues[(_b = (_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _b.value],
47645
47729
  //readium-default-on, readium-night-on, readium-sepia-on
@@ -47649,6 +47733,8 @@ var _UserSettings = class _UserSettings {
47649
47733
  //"auto", "justify", "start"
47650
47734
  columnCount: _UserSettings.columnCountValues[(_h = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.COLUMN_COUNT_REF)) == null ? void 0 : _h.value],
47651
47735
  // "auto", "1", "2"
47736
+ direction: _UserSettings.directionValues[(_j = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.DIRECTION_REF)) == null ? void 0 : _j.value],
47737
+ // "auto", "ltr", "rtl"
47652
47738
  verticalScroll: this.verticalScroll,
47653
47739
  fontSize: this.fontSize,
47654
47740
  wordSpacing: this.wordSpacing,
@@ -47658,9 +47744,11 @@ var _UserSettings = class _UserSettings {
47658
47744
  };
47659
47745
  }
47660
47746
  async applyUserSettings(userSettings) {
47661
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
47747
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
47662
47748
  if (userSettings.appearance) {
47663
- this.appearance = _UserSettings.parseAppearanceSetting(userSettings.appearance);
47749
+ this.appearance = _UserSettings.parseAppearanceSetting(
47750
+ userSettings.appearance
47751
+ );
47664
47752
  let prop = (_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.APPEARANCE_REF);
47665
47753
  if (prop) {
47666
47754
  prop.value = this.appearance;
@@ -47712,11 +47800,21 @@ var _UserSettings = class _UserSettings {
47712
47800
  }
47713
47801
  this.settingsColumnsChangeCallback();
47714
47802
  }
47803
+ if (userSettings.direction) {
47804
+ this.direction = _UserSettings.directionValues.findIndex(
47805
+ (el) => el === userSettings.direction
47806
+ );
47807
+ let prop = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.DIRECTION_REF);
47808
+ if (prop) {
47809
+ prop.value = this.direction;
47810
+ await this.storeProperty(prop);
47811
+ }
47812
+ }
47715
47813
  if (userSettings.textAlignment) {
47716
47814
  this.textAlignment = _UserSettings.textAlignmentValues.findIndex(
47717
47815
  (el) => el === userSettings.textAlignment
47718
47816
  );
47719
- let prop = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.TEXT_ALIGNMENT_REF);
47817
+ let prop = (_h = this.userProperties) == null ? void 0 : _h.getByRef(ReadiumCSS.TEXT_ALIGNMENT_REF);
47720
47818
  if (prop) {
47721
47819
  prop.value = this.textAlignment;
47722
47820
  await this.storeProperty(prop);
@@ -47724,7 +47822,7 @@ var _UserSettings = class _UserSettings {
47724
47822
  }
47725
47823
  if (userSettings.lineHeight) {
47726
47824
  this.lineHeight = userSettings.lineHeight;
47727
- let prop = (_h = this.userProperties) == null ? void 0 : _h.getByRef(ReadiumCSS.LINE_HEIGHT_REF);
47825
+ let prop = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.LINE_HEIGHT_REF);
47728
47826
  if (prop) {
47729
47827
  prop.value = this.lineHeight;
47730
47828
  await this.storeProperty(prop);
@@ -47732,25 +47830,25 @@ var _UserSettings = class _UserSettings {
47732
47830
  }
47733
47831
  if (userSettings.pageMargins) {
47734
47832
  this.pageMargins = userSettings.pageMargins;
47735
- let prop = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.PAGE_MARGINS_REF);
47833
+ let prop = (_j = this.userProperties) == null ? void 0 : _j.getByRef(ReadiumCSS.PAGE_MARGINS_REF);
47736
47834
  if (prop) {
47737
47835
  prop.value = this.pageMargins;
47738
47836
  await this.storeProperty(prop);
47739
47837
  }
47740
47838
  }
47741
47839
  if (userSettings.verticalScroll !== void 0) {
47742
- const position = (_j = this.view) == null ? void 0 : _j.getCurrentPosition();
47840
+ const position = (_k = this.view) == null ? void 0 : _k.getCurrentPosition();
47743
47841
  this.verticalScroll = _UserSettings.parseScrollSetting(
47744
47842
  userSettings.verticalScroll
47745
47843
  );
47746
- let prop = (_k = this.userProperties) == null ? void 0 : _k.getByRef(ReadiumCSS.SCROLL_REF);
47844
+ let prop = (_l = this.userProperties) == null ? void 0 : _l.getByRef(ReadiumCSS.SCROLL_REF);
47747
47845
  if (prop) {
47748
47846
  prop.value = this.verticalScroll;
47749
47847
  await this.saveProperty(prop);
47750
47848
  }
47751
- (_m = (_l = this.view) == null ? void 0 : _l.setMode) == null ? void 0 : _m.call(_l, this.verticalScroll);
47849
+ (_n = (_m = this.view) == null ? void 0 : _m.setMode) == null ? void 0 : _n.call(_m, this.verticalScroll);
47752
47850
  if (position) {
47753
- (_n = this.view) == null ? void 0 : _n.goToProgression(position);
47851
+ (_o = this.view) == null ? void 0 : _o.goToProgression(position);
47754
47852
  }
47755
47853
  this.viewChangeCallback();
47756
47854
  }
@@ -47785,9 +47883,7 @@ var _UserSettings = class _UserSettings {
47785
47883
  } else {
47786
47884
  a = inputSetting;
47787
47885
  }
47788
- return _UserSettings.appearanceValues.findIndex(
47789
- (el) => el === a
47790
- );
47886
+ return _UserSettings.appearanceValues.findIndex((el) => el === a);
47791
47887
  }
47792
47888
  async scroll(scroll) {
47793
47889
  var _a, _b, _c, _d, _e;
@@ -47809,7 +47905,9 @@ var _UserSettings = class _UserSettings {
47809
47905
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
47810
47906
  if (incremental === "fontSize") {
47811
47907
  ((_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.FONT_SIZE_REF)).increment();
47812
- this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(ReadiumCSS.FONT_SIZE_REF)) == null ? void 0 : _c.value;
47908
+ this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(
47909
+ ReadiumCSS.FONT_SIZE_REF
47910
+ )) == null ? void 0 : _c.value;
47813
47911
  let prop = (_d = this.userProperties) == null ? void 0 : _d.getByRef(ReadiumCSS.FONT_SIZE_REF);
47814
47912
  if (prop) {
47815
47913
  await this.storeProperty(prop);
@@ -47853,7 +47951,9 @@ var _UserSettings = class _UserSettings {
47853
47951
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
47854
47952
  if (incremental === "fontSize") {
47855
47953
  ((_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.FONT_SIZE_REF)).decrement();
47856
- this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(ReadiumCSS.FONT_SIZE_REF)) == null ? void 0 : _c.value;
47954
+ this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(
47955
+ ReadiumCSS.FONT_SIZE_REF
47956
+ )) == null ? void 0 : _c.value;
47857
47957
  let prop = (_d = this.userProperties) == null ? void 0 : _d.getByRef(ReadiumCSS.FONT_SIZE_REF);
47858
47958
  if (prop) {
47859
47959
  await this.storeProperty(prop);
@@ -47909,6 +48009,7 @@ _UserSettings.appearanceValues = [
47909
48009
  _UserSettings.fontFamilyValues = ["Original", "serif", "sans-serif"];
47910
48010
  _UserSettings.textAlignmentValues = ["auto", "justify", "start"];
47911
48011
  _UserSettings.columnCountValues = ["auto", "1", "2"];
48012
+ _UserSettings.directionValues = ["auto", "ltr", "rtl"];
47912
48013
  var UserSettings = _UserSettings;
47913
48014
 
47914
48015
  // src/modules/AnnotationModule.ts
@@ -49642,17 +49743,13 @@ var TextHighlighter = class _TextHighlighter {
49642
49743
  );
49643
49744
  return new Promise((resolve) => resolve(module2));
49644
49745
  }
49645
- async initialize() {
49746
+ async initialize(iframe) {
49646
49747
  var _a;
49647
- let doc = this.navigator.iframes[0].contentDocument;
49748
+ let doc = iframe.contentDocument;
49648
49749
  if (doc) {
49649
49750
  this.dom(doc.body).addClass(this.options.contextClass);
49650
49751
  }
49651
- this.bindEvents(
49652
- (_a = this.navigator.iframes[0].contentDocument) == null ? void 0 : _a.body,
49653
- this,
49654
- this.hasEventListener
49655
- );
49752
+ this.bindEvents((_a = iframe.contentDocument) == null ? void 0 : _a.body, this, this.hasEventListener);
49656
49753
  this.initializeToolbox();
49657
49754
  lastMouseDownX = -1;
49658
49755
  lastMouseDownY = -1;
@@ -49665,7 +49762,7 @@ var TextHighlighter = class _TextHighlighter {
49665
49762
  }
49666
49763
  setTimeout(async () => {
49667
49764
  var _a2;
49668
- let doc2 = this.navigator.iframes[0].contentDocument;
49765
+ let doc2 = iframe.contentDocument;
49669
49766
  if (doc2) {
49670
49767
  await ((_a2 = doc2.body) == null ? void 0 : _a2.addEventListener("click", unselect));
49671
49768
  }
@@ -52294,8 +52391,8 @@ var ConsumptionModule = class {
52294
52391
  import_loglevel7.default.log("Consumption module stop");
52295
52392
  this.endResearchSession();
52296
52393
  }
52297
- initialize() {
52298
- let win = this.navigator.iframes[0].contentWindow;
52394
+ initialize(iframe) {
52395
+ let win = iframe.contentWindow;
52299
52396
  if (win) {
52300
52397
  const self2 = this;
52301
52398
  win.onload = function() {
@@ -52529,7 +52626,7 @@ var AnnotationModule = class _AnnotationModule {
52529
52626
  await this.showHighlights();
52530
52627
  }, 200);
52531
52628
  }
52532
- initialize() {
52629
+ initialize(iframe) {
52533
52630
  return new Promise(async (resolve) => {
52534
52631
  await document.fonts.ready;
52535
52632
  if (this.rights.enableAnnotations) {
@@ -52538,7 +52635,7 @@ var AnnotationModule = class _AnnotationModule {
52538
52635
  this.drawHighlights();
52539
52636
  this.showHighlights();
52540
52637
  addEventListenerOptional(
52541
- (_a = this.navigator.iframes[0].contentDocument) == null ? void 0 : _a.body,
52638
+ (_a = iframe.contentDocument) == null ? void 0 : _a.body,
52542
52639
  "click",
52543
52640
  this.click.bind(this)
52544
52641
  );
@@ -54260,7 +54357,9 @@ var MediaOverlaySettings = class {
54260
54357
  var _a, _b;
54261
54358
  if (incremental === "mo_volume") {
54262
54359
  this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF).increment();
54263
- this.volume = (_a = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF)) == null ? void 0 : _a.value;
54360
+ this.volume = (_a = this.userProperties.getByRef(
54361
+ MEDIAOVERLAYREFS.VOLUME_REF
54362
+ )) == null ? void 0 : _a.value;
54264
54363
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF);
54265
54364
  if (prop) {
54266
54365
  this.storeProperty(prop);
@@ -54268,7 +54367,9 @@ var MediaOverlaySettings = class {
54268
54367
  this.settingsChangeCallback();
54269
54368
  } else if (incremental === "mo_rate") {
54270
54369
  this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF).increment();
54271
- this.rate = (_b = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF)) == null ? void 0 : _b.value;
54370
+ this.rate = (_b = this.userProperties.getByRef(
54371
+ MEDIAOVERLAYREFS.RATE_REF
54372
+ )) == null ? void 0 : _b.value;
54272
54373
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF);
54273
54374
  if (prop) {
54274
54375
  this.storeProperty(prop);
@@ -54280,7 +54381,9 @@ var MediaOverlaySettings = class {
54280
54381
  var _a, _b;
54281
54382
  if (incremental === "mo_volume") {
54282
54383
  this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF).decrement();
54283
- this.volume = (_a = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF)) == null ? void 0 : _a.value;
54384
+ this.volume = (_a = this.userProperties.getByRef(
54385
+ MEDIAOVERLAYREFS.VOLUME_REF
54386
+ )) == null ? void 0 : _a.value;
54284
54387
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF);
54285
54388
  if (prop) {
54286
54389
  this.storeProperty(prop);
@@ -54288,7 +54391,9 @@ var MediaOverlaySettings = class {
54288
54391
  this.settingsChangeCallback();
54289
54392
  } else if (incremental === "mo_rate") {
54290
54393
  this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF).decrement();
54291
- this.rate = (_b = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF)) == null ? void 0 : _b.value;
54394
+ this.rate = (_b = this.userProperties.getByRef(
54395
+ MEDIAOVERLAYREFS.RATE_REF
54396
+ )) == null ? void 0 : _b.value;
54292
54397
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF);
54293
54398
  if (prop) {
54294
54399
  this.storeProperty(prop);
@@ -57080,35 +57185,33 @@ var ContentProtectionModule = class {
57080
57185
  this.preventDrag(true);
57081
57186
  }
57082
57187
  }
57083
- async initialize() {
57188
+ async initialize(iframe) {
57084
57189
  var _a;
57085
57190
  if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
57086
57191
  return new Promise(async (resolve) => {
57087
57192
  await document.fonts.ready;
57088
- for (const iframe of this.navigator.iframes) {
57089
- if (iframe.contentDocument) {
57090
- const body = findRequiredIframeElement(
57091
- iframe.contentDocument,
57092
- "body"
57193
+ if (iframe.contentDocument) {
57194
+ const body = findRequiredIframeElement(
57195
+ iframe.contentDocument,
57196
+ "body"
57197
+ );
57198
+ this.observe();
57199
+ setTimeout(() => {
57200
+ this.rects = this.findRects(body);
57201
+ this.rects.forEach(
57202
+ (rect) => this.toggleRect(rect, this.securityContainer, this.isHacked)
57093
57203
  );
57094
- this.observe();
57095
- setTimeout(() => {
57096
- this.rects = this.findRects(body);
57097
- this.rects.forEach(
57098
- (rect) => this.toggleRect(rect, this.securityContainer, this.isHacked)
57204
+ this.setupEvents();
57205
+ if (!this.hasEventListener) {
57206
+ this.hasEventListener = true;
57207
+ addEventListenerOptional(
57208
+ this.wrapper,
57209
+ "scroll",
57210
+ this.handleScroll.bind(this)
57099
57211
  );
57100
- this.setupEvents();
57101
- if (!this.hasEventListener) {
57102
- this.hasEventListener = true;
57103
- addEventListenerOptional(
57104
- this.wrapper,
57105
- "scroll",
57106
- this.handleScroll.bind(this)
57107
- );
57108
- }
57109
- resolve();
57110
- }, 10);
57111
- }
57212
+ }
57213
+ resolve();
57214
+ }, 10);
57112
57215
  }
57113
57216
  });
57114
57217
  }
@@ -57489,8 +57592,18 @@ var ContentProtectionModule = class {
57489
57592
  const windowRight = windowLeft + this.wrapper.clientWidth;
57490
57593
  const right = rect.left + rect.width;
57491
57594
  const bottom = rect.top + rect.height;
57492
- const windowTop = this.wrapper.scrollTop;
57493
- const windowBottom = windowTop + this.wrapper.clientHeight;
57595
+ const windowTop = this.wrapper.scrollTop - (rect.node.parentElement ? parseInt(
57596
+ getComputedStyle(rect.node.parentElement).lineHeight.replace(
57597
+ "px",
57598
+ ""
57599
+ )
57600
+ ) : 10);
57601
+ const windowBottom = windowTop + this.wrapper.clientHeight + (rect.node.parentElement ? parseInt(
57602
+ getComputedStyle(rect.node.parentElement).lineHeight.replace(
57603
+ "px",
57604
+ ""
57605
+ )
57606
+ ) : 10);
57494
57607
  const isAbove = bottom < windowTop;
57495
57608
  const isBelow = rect.top > windowBottom;
57496
57609
  const isLeft = right < windowLeft - window.innerWidth;
@@ -58898,6 +59011,7 @@ var KeyboardEventHandler = class {
58898
59011
  // when removing the event listeners
58899
59012
  this.handlers = {};
58900
59013
  this.navigator = navigator2;
59014
+ this.rtl = false;
58901
59015
  }
58902
59016
  onFocusIn(self2) {
58903
59017
  return this.handlers["onFocusIn"] || (this.handlers["onFocusIn"] = function(event) {
@@ -58920,10 +59034,10 @@ var KeyboardEventHandler = class {
58920
59034
  const key = event.key;
58921
59035
  switch (key) {
58922
59036
  case "ArrowRight":
58923
- self2.onForwardSwipe(event);
59037
+ self2.rtl ? self2.onBackwardSwipe(event) : self2.onForwardSwipe(event);
58924
59038
  break;
58925
59039
  case "ArrowLeft":
58926
- self2.onBackwardSwipe(event);
59040
+ self2.rtl ? self2.onForwardSwipe(event) : self2.onBackwardSwipe(event);
58927
59041
  break;
58928
59042
  }
58929
59043
  switch (event.code) {
@@ -60513,7 +60627,7 @@ var LineFocusModule = class {
60513
60627
  }
60514
60628
  }
60515
60629
  }
60516
- initialize() {
60630
+ initialize(iframe) {
60517
60631
  return new Promise(async (resolve) => {
60518
60632
  await document.fonts.ready;
60519
60633
  if (!this.hasEventListener) {
@@ -60521,12 +60635,12 @@ var LineFocusModule = class {
60521
60635
  addEventListenerOptional(document, "keydown", this.keydown.bind(this));
60522
60636
  addEventListenerOptional(document, "keyup", this.keyup.bind(this));
60523
60637
  addEventListenerOptional(
60524
- this.navigator.iframes[0].contentDocument,
60638
+ iframe.contentDocument,
60525
60639
  "keydown",
60526
60640
  this.keydown.bind(this)
60527
60641
  );
60528
60642
  addEventListenerOptional(
60529
- this.navigator.iframes[0].contentDocument,
60643
+ iframe.contentDocument,
60530
60644
  "keyup",
60531
60645
  this.keyup.bind(this)
60532
60646
  );
@@ -61022,7 +61136,6 @@ var HistoryModule = class {
61022
61136
  }
61023
61137
  }
61024
61138
  async push(locator, history) {
61025
- let lastInHistory;
61026
61139
  if (history && this.annotator) {
61027
61140
  let lastReadingPosition = await this.annotator.getLastReadingPosition();
61028
61141
  if (lastReadingPosition) {
@@ -61037,12 +61150,18 @@ var HistoryModule = class {
61037
61150
  } else if ((lastReadingPosition == null ? void 0 : lastReadingPosition.locations.progression) && (lastReadingPosition == null ? void 0 : lastReadingPosition.locations.progression) > 0) {
61038
61151
  this.history.push(lastReadingPosition);
61039
61152
  this.historyCurrentIndex = this.history.length - 1;
61153
+ } else {
61154
+ const lastInHistory2 = this.history[this.history.length - 1];
61155
+ if (lastInHistory2 && lastInHistory2.href !== locator.href && lastInHistory2.locations !== locator.locations || lastInHistory2 === void 0) {
61156
+ this.history.push(lastReadingPosition);
61157
+ this.historyCurrentIndex = this.history.length - 1;
61158
+ }
61040
61159
  }
61041
61160
  }
61042
61161
  if (this.historyCurrentIndex < this.history.length - 1) {
61043
61162
  this.history = this.history.slice(0, this.historyCurrentIndex);
61044
61163
  }
61045
- lastInHistory = this.history[this.history.length - 1];
61164
+ const lastInHistory = this.history[this.history.length - 1];
61046
61165
  if (lastInHistory && lastInHistory.href !== locator.href || lastInHistory === void 0) {
61047
61166
  this.history.push(locator);
61048
61167
  this.historyCurrentIndex = this.history.length - 1;
@@ -61587,6 +61706,24 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61587
61706
  if (this.didInitKeyboardEventHandler)
61588
61707
  this.keyboardEventHandler.removeEvents(document);
61589
61708
  }
61709
+ setDirection(direction) {
61710
+ var _a, _b;
61711
+ let dir = "";
61712
+ if (direction === "rtl" || direction === "ltr")
61713
+ dir = direction;
61714
+ if (direction === "auto")
61715
+ dir = this.publication.Metadata.Direction2;
61716
+ if (dir) {
61717
+ if (dir === "rtl")
61718
+ this.spreads.style.flexDirection = "row-reverse";
61719
+ if (dir === "ltr")
61720
+ this.spreads.style.flexDirection = "row";
61721
+ this.keyboardEventHandler.rtl = dir === "rtl";
61722
+ if ((_a = this.api) == null ? void 0 : _a.direction)
61723
+ (_b = this.api) == null ? void 0 : _b.direction(dir);
61724
+ this.emit("direction", dir);
61725
+ }
61726
+ }
61590
61727
  async start(mainElement, headerMenu, footerMenu) {
61591
61728
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
61592
61729
  this.headerMenu = headerMenu;
@@ -61626,6 +61763,19 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61626
61763
  this.spreads.appendChild(this.firstSpread);
61627
61764
  this.firstSpread.appendChild(this.iframes[0]);
61628
61765
  wrapper.appendChild(this.spreads);
61766
+ let dir = "";
61767
+ switch (this.settings.direction) {
61768
+ case 0:
61769
+ dir = "auto";
61770
+ break;
61771
+ case 1:
61772
+ dir = "ltr";
61773
+ break;
61774
+ case 2:
61775
+ dir = "rtl";
61776
+ break;
61777
+ }
61778
+ this.setDirection(dir);
61629
61779
  } else {
61630
61780
  iframe3.setAttribute("height", "100%");
61631
61781
  iframe3.setAttribute("width", "100%");
@@ -61897,7 +62047,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61897
62047
  addEventListenerOptional(
61898
62048
  iframe,
61899
62049
  "load",
61900
- this.handleIFrameLoad.bind(this)
62050
+ this.handleIFrameLoad.bind(this, iframe)
61901
62051
  );
61902
62052
  }
61903
62053
  addEventListenerOptional(
@@ -62269,8 +62419,8 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62269
62419
  });
62270
62420
  }
62271
62421
  }
62272
- async handleIFrameLoad() {
62273
- var _a, _b, _c, _d, _e, _f;
62422
+ async handleIFrameLoad(iframe) {
62423
+ var _a, _b, _c, _d, _e, _f, _g;
62274
62424
  if (this.errorMessage)
62275
62425
  this.errorMessage.style.display = "none";
62276
62426
  this.showLoadingMessageAfterDelay();
@@ -62360,54 +62510,52 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62360
62510
  if (this.chapterTitle)
62361
62511
  this.chapterTitle.innerHTML = "(Current Chapter)";
62362
62512
  }
62363
- await this.injectInjectablesIntoIframeHead();
62364
- if (this.highlighter !== void 0) {
62365
- await this.highlighter.initialize();
62513
+ await this.injectInjectablesIntoIframeHead(iframe);
62514
+ if (((_a = this.view) == null ? void 0 : _a.layout) !== "fixed" && this.highlighter !== void 0) {
62515
+ await this.highlighter.initialize(iframe);
62366
62516
  }
62367
- const body = (_a = this.iframes[0].contentDocument) == null ? void 0 : _a.body;
62517
+ const body = (_b = iframe.contentDocument) == null ? void 0 : _b.body;
62368
62518
  let details = body == null ? void 0 : body.querySelector("details");
62369
62519
  if (details) {
62370
62520
  let self2 = this;
62371
62521
  details.addEventListener("toggle", async (_event) => {
62372
62522
  var _a2, _b2;
62373
- await ((_b2 = (_a2 = self2.view) == null ? void 0 : _a2.setIframeHeight) == null ? void 0 : _b2.call(_a2, this.iframes[0]));
62523
+ await ((_b2 = (_a2 = self2.view) == null ? void 0 : _a2.setIframeHeight) == null ? void 0 : _b2.call(_a2, iframe));
62374
62524
  });
62375
62525
  }
62376
62526
  if (this.eventHandler) {
62377
- for (const iframe of this.iframes) {
62378
- this.eventHandler.setupEvents(iframe.contentDocument);
62379
- this.touchEventHandler.setupEvents(iframe.contentDocument);
62380
- this.keyboardEventHandler.setupEvents(iframe.contentDocument);
62381
- }
62527
+ this.eventHandler.setupEvents(iframe.contentDocument);
62528
+ this.touchEventHandler.setupEvents(iframe.contentDocument);
62529
+ this.keyboardEventHandler.setupEvents(iframe.contentDocument);
62382
62530
  this.touchEventHandler.setupEvents(this.errorMessage);
62383
62531
  if (!this.didInitKeyboardEventHandler) {
62384
62532
  this.keyboardEventHandler.keydown(document);
62385
62533
  this.didInitKeyboardEventHandler = true;
62386
62534
  }
62387
62535
  }
62388
- if (((_b = this.view) == null ? void 0 : _b.layout) !== "fixed") {
62389
- if ((_c = this.view) == null ? void 0 : _c.isScrollMode()) {
62390
- this.iframes[0].height = "0";
62391
- (_e = (_d = this.view) == null ? void 0 : _d.setIframeHeight) == null ? void 0 : _e.call(_d, this.iframes[0]);
62536
+ if (((_c = this.view) == null ? void 0 : _c.layout) !== "fixed") {
62537
+ if ((_d = this.view) == null ? void 0 : _d.isScrollMode()) {
62538
+ iframe.height = "0";
62539
+ (_f = (_e = this.view) == null ? void 0 : _e.setIframeHeight) == null ? void 0 : _f.call(_e, iframe);
62392
62540
  }
62393
62541
  }
62394
62542
  if (this.rights.enableContentProtection && this.contentProtectionModule) {
62395
- await this.contentProtectionModule.initialize();
62543
+ await this.contentProtectionModule.initialize(iframe);
62396
62544
  }
62397
62545
  if (this.rights.enableConsumption && this.consumptionModule) {
62398
- await this.consumptionModule.initialize();
62546
+ await this.consumptionModule.initialize(iframe);
62399
62547
  }
62400
62548
  if (this.rights.enableAnnotations && this.annotationModule) {
62401
- await this.annotationModule.initialize();
62549
+ await this.annotationModule.initialize(iframe);
62402
62550
  }
62403
62551
  if (this.rights.enableBookmarks && this.bookmarkModule) {
62404
62552
  await this.bookmarkModule.initialize();
62405
62553
  }
62406
62554
  if (this.rights.enableLineFocus && this.lineFocusModule) {
62407
- await this.lineFocusModule.initialize();
62555
+ await this.lineFocusModule.initialize(iframe);
62408
62556
  }
62409
62557
  if (this.rights.enableTTS && this.ttsModule) {
62410
- const body2 = (_f = this.iframes[0].contentDocument) == null ? void 0 : _f.body;
62558
+ const body2 = (_g = iframe.contentDocument) == null ? void 0 : _g.body;
62411
62559
  const ttsModule = this.ttsModule;
62412
62560
  await ttsModule.initialize(body2);
62413
62561
  }
@@ -62418,9 +62566,11 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62418
62566
  await this.mediaOverlayModule.initialize();
62419
62567
  }
62420
62568
  setTimeout(async () => {
62421
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h;
62569
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h;
62422
62570
  if (this.newElementId) {
62423
- const element = this.iframes[0].contentDocument.getElementById(this.newElementId);
62571
+ const element = iframe.contentDocument.getElementById(
62572
+ this.newElementId
62573
+ );
62424
62574
  (_b2 = (_a2 = this.view) == null ? void 0 : _a2.goToElement) == null ? void 0 : _b2.call(_a2, element);
62425
62575
  this.newElementId = void 0;
62426
62576
  } else if (this.newPosition && this.newPosition.highlight) {
@@ -62438,10 +62588,10 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62438
62588
  }
62439
62589
  }
62440
62590
  this.hideLoadingMessage();
62441
- this.showIframeContents();
62591
+ this.showIframeContents(iframe);
62442
62592
  if (this.rights.enableMediaOverlays && this.mediaOverlayModule && this.hasMediaOverlays) {
62443
62593
  let link = this.currentLink();
62444
- await ((_g = this.mediaOverlayModule) == null ? void 0 : _g.initializeResource(link));
62594
+ await ((_g2 = this.mediaOverlayModule) == null ? void 0 : _g2.initializeResource(link));
62445
62595
  }
62446
62596
  await this.updatePositionInfo();
62447
62597
  await ((_h = this.view) == null ? void 0 : _h.setSize());
@@ -62458,7 +62608,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62458
62608
  return Promise.reject(err);
62459
62609
  }
62460
62610
  }
62461
- async injectInjectablesIntoIframeHead() {
62611
+ async injectInjectablesIntoIframeHead(iframe) {
62462
62612
  var _a, _b;
62463
62613
  const injectablesToLoad = [];
62464
62614
  const addLoadingInjectable = (injectable) => {
@@ -62473,55 +62623,53 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62473
62623
  });
62474
62624
  injectablesToLoad.push(loadPromise);
62475
62625
  };
62476
- for (const iframe of this.iframes) {
62477
- const head = (_a = iframe.contentDocument) == null ? void 0 : _a.head;
62478
- if (head) {
62479
- const bases = iframe.contentDocument.getElementsByTagName("base");
62480
- if (bases.length === 0) {
62481
- head.insertBefore(
62482
- _IFrameNavigator.createBase(this.currentChapterLink.href),
62483
- head.firstChild
62484
- );
62485
- }
62486
- (_b = this.injectables) == null ? void 0 : _b.forEach((injectable) => {
62487
- if (injectable.type === "style") {
62488
- if (injectable.fontFamily) {
62489
- this.settings.initAddedFont();
62490
- if (!injectable.systemFont && injectable.url) {
62491
- const link = _IFrameNavigator.createCssLink(injectable.url);
62492
- head.appendChild(link);
62493
- addLoadingInjectable(link);
62494
- }
62495
- } else if (injectable.r2before && injectable.url) {
62496
- const link = _IFrameNavigator.createCssLink(injectable.url);
62497
- head.insertBefore(link, head.firstChild);
62498
- addLoadingInjectable(link);
62499
- } else if (injectable.r2default && injectable.url) {
62500
- const link = _IFrameNavigator.createCssLink(injectable.url);
62501
- head.insertBefore(link, head.childNodes[1]);
62502
- addLoadingInjectable(link);
62503
- } else if (injectable.r2after && injectable.url) {
62504
- if (injectable.appearance) {
62505
- this.settings.initAddedAppearance();
62506
- }
62507
- const link = _IFrameNavigator.createCssLink(injectable.url);
62508
- head.appendChild(link);
62509
- addLoadingInjectable(link);
62510
- } else if (injectable.url) {
62626
+ const head = (_a = iframe.contentDocument) == null ? void 0 : _a.head;
62627
+ if (head) {
62628
+ const bases = iframe.contentDocument.getElementsByTagName("base");
62629
+ if (bases.length === 0) {
62630
+ head.insertBefore(
62631
+ _IFrameNavigator.createBase(this.currentChapterLink.href),
62632
+ head.firstChild
62633
+ );
62634
+ }
62635
+ (_b = this.injectables) == null ? void 0 : _b.forEach((injectable) => {
62636
+ if (injectable.type === "style") {
62637
+ if (injectable.fontFamily) {
62638
+ this.settings.initAddedFont();
62639
+ if (!injectable.systemFont && injectable.url) {
62511
62640
  const link = _IFrameNavigator.createCssLink(injectable.url);
62512
62641
  head.appendChild(link);
62513
62642
  addLoadingInjectable(link);
62514
62643
  }
62515
- } else if (injectable.type === "script" && injectable.url) {
62516
- const script = _IFrameNavigator.createJavascriptLink(
62517
- injectable.url,
62518
- injectable.async ?? false
62519
- );
62520
- head.appendChild(script);
62521
- addLoadingInjectable(script);
62522
- }
62523
- });
62524
- }
62644
+ } else if (injectable.r2before && injectable.url) {
62645
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62646
+ head.insertBefore(link, head.firstChild);
62647
+ addLoadingInjectable(link);
62648
+ } else if (injectable.r2default && injectable.url) {
62649
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62650
+ head.insertBefore(link, head.childNodes[1]);
62651
+ addLoadingInjectable(link);
62652
+ } else if (injectable.r2after && injectable.url) {
62653
+ if (injectable.appearance) {
62654
+ this.settings.initAddedAppearance();
62655
+ }
62656
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62657
+ head.appendChild(link);
62658
+ addLoadingInjectable(link);
62659
+ } else if (injectable.url) {
62660
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62661
+ head.appendChild(link);
62662
+ addLoadingInjectable(link);
62663
+ }
62664
+ } else if (injectable.type === "script" && injectable.url) {
62665
+ const script = _IFrameNavigator.createJavascriptLink(
62666
+ injectable.url,
62667
+ injectable.async ?? false
62668
+ );
62669
+ head.appendChild(script);
62670
+ addLoadingInjectable(script);
62671
+ }
62672
+ });
62525
62673
  }
62526
62674
  if (injectablesToLoad.length === 0) {
62527
62675
  return;
@@ -62839,21 +62987,21 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62839
62987
  }
62840
62988
  } else {
62841
62989
  this.iframes[0].src = "about:blank";
62842
- }
62843
- if (this.iframes.length === 2) {
62844
- this.currentSpreadLinks.right = {
62845
- href: this.currentChapterLink.href
62846
- };
62847
- if (isSameOrigin) {
62848
- this.iframes[1].src = this.currentChapterLink.href;
62849
- } else {
62850
- fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
62851
- writeIframe2Doc.call(
62852
- this,
62853
- content,
62854
- this.currentChapterLink.href
62855
- );
62856
- });
62990
+ if (this.iframes.length === 2) {
62991
+ this.currentSpreadLinks.right = {
62992
+ href: this.currentChapterLink.href
62993
+ };
62994
+ if (isSameOrigin) {
62995
+ this.iframes[1].src = this.currentChapterLink.href;
62996
+ } else {
62997
+ fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
62998
+ writeIframe2Doc.call(
62999
+ this,
63000
+ content,
63001
+ this.currentChapterLink.href
63002
+ );
63003
+ });
63004
+ }
62857
63005
  }
62858
63006
  }
62859
63007
  }
@@ -63780,15 +63928,13 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
63780
63928
  }
63781
63929
  }
63782
63930
  }
63783
- showIframeContents() {
63931
+ showIframeContents(iframe) {
63784
63932
  this.isBeingStyled = false;
63785
63933
  setTimeout(() => {
63786
63934
  if (!this.isBeingStyled) {
63787
- this.iframes.forEach((iframe) => {
63788
- iframe.style.opacity = "1";
63789
- iframe.style.border = "none";
63790
- iframe.style.overflow = "hidden";
63791
- });
63935
+ iframe.style.opacity = "1";
63936
+ iframe.style.border = "none";
63937
+ iframe.style.overflow = "hidden";
63792
63938
  }
63793
63939
  }, 150);
63794
63940
  }
@@ -64409,16 +64555,20 @@ var LocalStorageStore = class {
64409
64555
  constructor(config2) {
64410
64556
  this.prefix = config2.prefix;
64411
64557
  this.useLocalStorage = config2.useLocalStorage;
64558
+ this.useStorageType = config2.useStorageType;
64412
64559
  try {
64413
64560
  const testKey = config2.prefix + "-" + String(Math.random());
64414
- if (this.useLocalStorage) {
64561
+ if (this.useStorageType === "memory") {
64562
+ this.fallbackStore = new MemoryStore();
64563
+ } else if (this.useStorageType === "local" || this.useLocalStorage) {
64415
64564
  window.localStorage.setItem(testKey, "test");
64416
64565
  window.localStorage.removeItem(testKey);
64417
- } else {
64566
+ this.fallbackStore = null;
64567
+ } else if (this.useStorageType === "session" || !this.useLocalStorage) {
64418
64568
  window.sessionStorage.setItem(testKey, "test");
64419
64569
  window.sessionStorage.removeItem(testKey);
64570
+ this.fallbackStore = null;
64420
64571
  }
64421
- this.fallbackStore = null;
64422
64572
  } catch (e) {
64423
64573
  this.fallbackStore = new MemoryStore();
64424
64574
  }
@@ -64429,7 +64579,7 @@ var LocalStorageStore = class {
64429
64579
  get(key) {
64430
64580
  let value;
64431
64581
  if (!this.fallbackStore) {
64432
- if (this.useLocalStorage) {
64582
+ if (this.useStorageType === "local" || this.useLocalStorage) {
64433
64583
  value = window.localStorage.getItem(this.getLocalStorageKey(key));
64434
64584
  } else {
64435
64585
  value = window.sessionStorage.getItem(this.getLocalStorageKey(key));
@@ -64441,7 +64591,7 @@ var LocalStorageStore = class {
64441
64591
  }
64442
64592
  set(key, value) {
64443
64593
  if (!this.fallbackStore) {
64444
- if (this.useLocalStorage) {
64594
+ if (this.useStorageType === "local" || this.useLocalStorage) {
64445
64595
  window.localStorage.setItem(this.getLocalStorageKey(key), value);
64446
64596
  } else {
64447
64597
  window.sessionStorage.setItem(this.getLocalStorageKey(key), value);
@@ -64452,7 +64602,7 @@ var LocalStorageStore = class {
64452
64602
  }
64453
64603
  remove(key) {
64454
64604
  if (!this.fallbackStore) {
64455
- if (this.useLocalStorage) {
64605
+ if (this.useStorageType === "local" || this.useLocalStorage) {
64456
64606
  window.localStorage.removeItem(this.getLocalStorageKey(key));
64457
64607
  } else {
64458
64608
  window.sessionStorage.removeItem(this.getLocalStorageKey(key));
@@ -65399,15 +65549,18 @@ var D2Reader = class _D2Reader {
65399
65549
  }
65400
65550
  const store = new LocalStorageStore({
65401
65551
  prefix: publication.manifestUrl,
65402
- useLocalStorage: initialConfig.useLocalStorage ?? false
65552
+ useLocalStorage: initialConfig.useLocalStorage ?? false,
65553
+ useStorageType: initialConfig.useStorageType
65403
65554
  });
65404
65555
  const settingsStore = new LocalStorageStore({
65405
65556
  prefix: "r2d2bc-reader",
65406
- useLocalStorage: initialConfig.useLocalStorage ?? false
65557
+ useLocalStorage: initialConfig.useLocalStorage ?? false,
65558
+ useStorageType: initialConfig.useStorageType
65407
65559
  });
65408
65560
  const layerStore = new LocalStorageStore({
65409
65561
  prefix: "r2d2bc-layers",
65410
- useLocalStorage: initialConfig.useLocalStorage ?? false
65562
+ useLocalStorage: initialConfig.useLocalStorage ?? false,
65563
+ useStorageType: initialConfig.useStorageType
65411
65564
  });
65412
65565
  const annotator = new LocalAnnotator({ store });
65413
65566
  publication.sample = initialConfig.sample;