@inappstory/react-sdk 1.9.4 → 1.9.6

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.
@@ -9,7 +9,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_debounce_js_35379ba8__ from "lodash/debounce.js";
10
10
  import * as __WEBPACK_EXTERNAL_MODULE__inappstory_slide_api_2e636188__ from "@inappstory/slide-api";
11
11
  import * as __WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__ from "async-mutex";
12
- import * as __WEBPACK_EXTERNAL_MODULE_lodash_isEmpty_js_f1e1789b__ from "lodash/isEmpty.js";
13
12
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_isObject_js_84bb7d23__ from "lodash/isObject.js";
14
13
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_isNumber_js_09f2ee09__ from "lodash/isNumber.js";
15
14
  import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_179142b8__ from "react/jsx-runtime";
@@ -21,8 +20,8 @@ import * as __WEBPACK_EXTERNAL_MODULE_mobx_react_lite_9dacf130__ from "mobx-reac
21
20
  import * as __WEBPACK_EXTERNAL_MODULE_react_dom_7dac9eee__ from "react-dom";
22
21
  import * as __WEBPACK_EXTERNAL_MODULE_lit__ from "lit";
23
22
  import * as __WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__ from "lit/decorators.js";
24
- import * as __WEBPACK_EXTERNAL_MODULE_lit_static_html_js_21a342d6__ from "lit/static-html.js";
25
23
  import * as __WEBPACK_EXTERNAL_MODULE_lit_directives_style_map_js_4fbc7c29__ from "lit/directives/style-map.js";
24
+ import * as __WEBPACK_EXTERNAL_MODULE_lit_static_html_js_21a342d6__ from "lit/static-html.js";
26
25
  import * as __WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643__ from "lit/directives/class-map.js";
27
26
  import * as __WEBPACK_EXTERNAL_MODULE_lit_directives_unsafe_html_js_56553e3e__ from "lit/directives/unsafe-html.js";
28
27
  /******/ var __webpack_modules__ = ({
@@ -904,7 +903,7 @@ ___CSS_LOADER_EXPORT___.locals = {
904
903
 
905
904
  var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0___default()));
906
905
  // Module
907
- ___CSS_LOADER_EXPORT___.push([module.id, ".loader--O0iuj{position:absolute;z-index:1;top:0;bottom:0;left:0;right:0;display:flex;justify-content:center;align-items:center;background:var(--loader-background, black)}.loader--O0iuj .loader__refresh-btn--RtExV{color:#fff;cursor:pointer;position:absolute;left:50%;top:50%;transform:translate3d(-50%, -50%, 0);pointer-events:auto;padding:20px;width:32px;height:32px;box-sizing:content-box}.loader--O0iuj .loader__spinner--cKqH0{-ms-flex-negative:0;flex-shrink:0;display:inline-block;width:32px;height:32px;border-radius:50%;border:solid 2px var(--loaderBackgroundColor, white);border-color:var(--loaderBackgroundAccentColor, transparent) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white);-webkit-animation:loading-spinner--7I4aU .6s infinite linear;animation:loading-spinner--7I4aU .6s infinite linear}@keyframes loading-spinner--7I4aU{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}", "",{"version":3,"sources":["webpack://./src/UI/Loader/loader.module.scss"],"names":[],"mappings":"AAAA,eACI,iBAAA,CACA,SAAA,CACA,KAAA,CACA,QAAA,CACA,MAAA,CACA,OAAA,CACA,YAAA,CACA,sBAAA,CACA,kBAAA,CACA,0CAAA,CAEA,2CACI,UAAA,CACA,cAAA,CACA,iBAAA,CACA,QAAA,CACA,OAAA,CACA,oCAAA,CACA,mBAAA,CACA,YAAA,CACA,UAAA,CACA,WAAA,CACA,sBAAA,CAGJ,uCACI,mBAAA,CACA,aAAA,CACA,oBAAA,CACA,UAAA,CACA,WAAA,CACA,iBAAA,CACA,oDAAA,CACA,wKAAA,CACA,4DAAA,CACA,oDAAA,CAIR,kCACI,KACI,8BAAA,CACA,sBAAA,CAGJ,GACI,gCAAA,CACA,wBAAA,CAAA","sourcesContent":[".loader {\n position: absolute;\n z-index: 1;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n background: var(--loader-background, black);\n\n .loader__refresh-btn {\n color: white;\n cursor: pointer;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate3d(-50%, -50%, 0);\n pointer-events: auto;\n padding: 20px;\n width: 32px;\n height: 32px;\n box-sizing: content-box;\n }\n\n .loader__spinner {\n -ms-flex-negative: 0;\n flex-shrink: 0;\n display: inline-block;\n width: 32px;\n height: 32px;\n border-radius: 50%;\n border: solid 2px var(--loaderBackgroundColor, white);\n border-color: var(--loaderBackgroundAccentColor, transparent) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white);\n -webkit-animation: loading-spinner .6s infinite linear;\n animation: loading-spinner .6s infinite linear;\n }\n}\n\n@keyframes loading-spinner {\n from {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n\n to {\n -webkit-transform: rotate(359deg);\n transform: rotate(359deg);\n }\n}"],"sourceRoot":""}]);
906
+ ___CSS_LOADER_EXPORT___.push([module.id, ".loader--O0iuj{position:absolute;z-index:10001;top:0;bottom:0;left:0;right:0;display:flex;justify-content:center;align-items:center;background:var(--loader-background, black)}.loader--O0iuj .loader__refresh-btn--RtExV{color:#fff;cursor:pointer;position:absolute;left:50%;top:50%;transform:translate3d(-50%, -50%, 0);pointer-events:auto;padding:20px;width:32px;height:32px;box-sizing:content-box}.loader--O0iuj .loader__spinner--cKqH0{-ms-flex-negative:0;flex-shrink:0;display:inline-block;width:32px;height:32px;border-radius:50%;border:solid 2px var(--loaderBackgroundColor, white);border-color:var(--loaderBackgroundAccentColor, transparent) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white);-webkit-animation:loading-spinner--7I4aU .6s infinite linear;animation:loading-spinner--7I4aU .6s infinite linear}@keyframes loading-spinner--7I4aU{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}", "",{"version":3,"sources":["webpack://./src/UI/Loader/loader.module.scss"],"names":[],"mappings":"AAAA,eACI,iBAAA,CACA,aAAA,CACA,KAAA,CACA,QAAA,CACA,MAAA,CACA,OAAA,CACA,YAAA,CACA,sBAAA,CACA,kBAAA,CACA,0CAAA,CAEA,2CACI,UAAA,CACA,cAAA,CACA,iBAAA,CACA,QAAA,CACA,OAAA,CACA,oCAAA,CACA,mBAAA,CACA,YAAA,CACA,UAAA,CACA,WAAA,CACA,sBAAA,CAGJ,uCACI,mBAAA,CACA,aAAA,CACA,oBAAA,CACA,UAAA,CACA,WAAA,CACA,iBAAA,CACA,oDAAA,CACA,wKAAA,CACA,4DAAA,CACA,oDAAA,CAIR,kCACI,KACI,8BAAA,CACA,sBAAA,CAGJ,GACI,gCAAA,CACA,wBAAA,CAAA","sourcesContent":[".loader {\n position: absolute;\n z-index: 10001;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n background: var(--loader-background, black);\n\n .loader__refresh-btn {\n color: white;\n cursor: pointer;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate3d(-50%, -50%, 0);\n pointer-events: auto;\n padding: 20px;\n width: 32px;\n height: 32px;\n box-sizing: content-box;\n }\n\n .loader__spinner {\n -ms-flex-negative: 0;\n flex-shrink: 0;\n display: inline-block;\n width: 32px;\n height: 32px;\n border-radius: 50%;\n border: solid 2px var(--loaderBackgroundColor, white);\n border-color: var(--loaderBackgroundAccentColor, transparent) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white) var(--loaderBackgroundColor, white);\n -webkit-animation: loading-spinner .6s infinite linear;\n animation: loading-spinner .6s infinite linear;\n }\n}\n\n@keyframes loading-spinner {\n from {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n\n to {\n -webkit-transform: rotate(359deg);\n transform: rotate(359deg);\n }\n}"],"sourceRoot":""}]);
908
907
  // Exports
909
908
  ___CSS_LOADER_EXPORT___.locals = {
910
909
  "loader": "loader--O0iuj",
@@ -3689,6 +3688,12 @@ class IamAppearanceCommonOptions {
3689
3688
  writable: true,
3690
3689
  value: {}
3691
3690
  });
3691
+ Object.defineProperty(this, "zIndex", {
3692
+ enumerable: true,
3693
+ configurable: true,
3694
+ writable: true,
3695
+ value: void 0
3696
+ });
3692
3697
  this.background = this.mapBackgroundDtoToModel(optionsDto.background);
3693
3698
  this.cardAppearance = (_a = optionsDto.card_appearance) !== null && _a !== void 0 ? _a : {};
3694
3699
  }
@@ -5706,26 +5711,6 @@ let Story = (() => {
5706
5711
  get wasShown() {
5707
5712
  return this._wasShown;
5708
5713
  }
5709
- getImagesPerSlide(index) {
5710
- var _b, _c;
5711
- this.parseHtmlSlidesForMainImage();
5712
- return (_c = (_b = this._parsedSlideImage) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : null;
5713
- }
5714
- parseHtmlSlidesForMainImage() {
5715
- if (this._parsedSlideImage || !this.slidesLoaded)
5716
- return;
5717
- this._parsedSlideImage = this._slides.map((slide) => this.parseSlideNarrativeImageSrc(slide.html) ||
5718
- this.parseSlideNarrativeVideoPosterSrc(slide.html) ||
5719
- null);
5720
- }
5721
- parseSlideNarrativeImageSrc(slideHtml) {
5722
- const results = slideHtml.match(/<[^<]*narrative-element-image.*<img[^<]*src="([^"]*)"[^<]*>/i);
5723
- return results === null || results === void 0 ? void 0 : results[1];
5724
- }
5725
- parseSlideNarrativeVideoPosterSrc(slideHtml) {
5726
- const results = slideHtml.match(/<[^<]*narrative-element-video.*<video[^<]*poster\-remote\-src="([^"]*)"[^<]*>/i);
5727
- return results === null || results === void 0 ? void 0 : results[1];
5728
- }
5729
5714
  get videoCover() {
5730
5715
  return this._videoCover;
5731
5716
  }
@@ -7962,12 +7947,6 @@ let SharePanelViewModel = (() => {
7962
7947
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/sharePanelViewModel/index.ts
7963
7948
 
7964
7949
 
7965
- ;// CONCATENATED MODULE: external "async-mutex"
7966
- var external_async_mutex_x = (y) => {
7967
- var x = {}; __webpack_require__.d(x, y); return x
7968
- }
7969
- var external_async_mutex_y = (x) => (() => (x))
7970
- const external_async_mutex_namespaceObject = external_async_mutex_x({ ["Mutex"]: () => (__WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__.Mutex), ["Semaphore"]: () => (__WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__.Semaphore) });
7971
7950
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storySlideViewModel/storySlideViewModel.ts
7972
7951
  var storySlideViewModel_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
7973
7952
  var useValue = arguments.length > 2;
@@ -8017,21 +7996,35 @@ var storySlideViewModel_classPrivateFieldSet = (undefined && undefined.__classPr
8017
7996
 
8018
7997
 
8019
7998
 
8020
-
8021
7999
  const SWIPE_UP_THRESHOLD = 10;
8022
8000
  const SLIDE_CLICK_THRESHOLD = 0.3;
8023
8001
  const SHOW_SLIDE_TIMEOUT = 500;
8024
8002
  const STORY_LOADER_TIMEOUT = 500;
8003
+ var StorySlideEmodji;
8004
+ (function (StorySlideEmodji) {
8005
+ StorySlideEmodji["Init"] = "\uD83D\uDD27";
8006
+ StorySlideEmodji["Start"] = "\uD83D\uDE80";
8007
+ StorySlideEmodji["Pause"] = "\u23F8\uFE0F";
8008
+ StorySlideEmodji["Resume"] = "\u21A9\uFE0F";
8009
+ StorySlideEmodji["Stop"] = "\uD83D\uDED1";
8010
+ StorySlideEmodji["Destroy"] = "\uD83D\uDDD1\uFE0F";
8011
+ StorySlideEmodji["Restart"] = "\uD83D\uDD04";
8012
+ })(StorySlideEmodji || (StorySlideEmodji = {}));
8025
8013
  let StorySlideViewModel = (() => {
8026
- var _a, _StorySlideViewModel__disabledNextClick_accessor_storage;
8014
+ var _a, _StorySlideViewModel__disabledNextClick_accessor_storage, _StorySlideViewModel__cover_accessor_storage;
8027
8015
  let _instanceExtraInitializers = [];
8028
8016
  let __disabledNextClick_decorators;
8029
8017
  let __disabledNextClick_initializers = [];
8030
8018
  let __disabledNextClick_extraInitializers = [];
8031
- let _start_decorators;
8019
+ let __cover_decorators;
8020
+ let __cover_initializers = [];
8021
+ let __cover_extraInitializers = [];
8022
+ let _commit_decorators;
8032
8023
  return _a = class StorySlideViewModel {
8033
8024
  get _disabledNextClick() { return storySlideViewModel_classPrivateFieldGet(this, _StorySlideViewModel__disabledNextClick_accessor_storage, "f"); }
8034
8025
  set _disabledNextClick(value) { storySlideViewModel_classPrivateFieldSet(this, _StorySlideViewModel__disabledNextClick_accessor_storage, value, "f"); }
8026
+ get _cover() { return storySlideViewModel_classPrivateFieldGet(this, _StorySlideViewModel__cover_accessor_storage, "f"); }
8027
+ set _cover(value) { storySlideViewModel_classPrivateFieldSet(this, _StorySlideViewModel__cover_accessor_storage, value, "f"); }
8035
8028
  constructor(_story, _index, slideApi, slide, cacheManager) {
8036
8029
  Object.defineProperty(this, "_story", {
8037
8030
  enumerable: true,
@@ -8064,35 +8057,28 @@ let StorySlideViewModel = (() => {
8064
8057
  value: cacheManager
8065
8058
  });
8066
8059
  _StorySlideViewModel__disabledNextClick_accessor_storage.set(this, storySlideViewModel_runInitializers(this, __disabledNextClick_initializers, false));
8067
- Object.defineProperty(this, "mutex", {
8068
- enumerable: true,
8069
- configurable: true,
8070
- writable: true,
8071
- value: (storySlideViewModel_runInitializers(this, __disabledNextClick_extraInitializers), new external_async_mutex_namespaceObject.Mutex())
8072
- });
8073
- Object.defineProperty(this, "isInited", {
8074
- enumerable: true,
8075
- configurable: true,
8076
- writable: true,
8077
- value: false
8078
- });
8079
- Object.defineProperty(this, "isStarted", {
8060
+ _StorySlideViewModel__cover_accessor_storage.set(this, (storySlideViewModel_runInitializers(this, __disabledNextClick_extraInitializers), storySlideViewModel_runInitializers(this, __cover_initializers, null)));
8061
+ Object.defineProperty(this, "preloaded", {
8080
8062
  enumerable: true,
8081
8063
  configurable: true,
8082
8064
  writable: true,
8083
- value: false
8065
+ value: (storySlideViewModel_runInitializers(this, __cover_extraInitializers), false)
8084
8066
  });
8085
- Object.defineProperty(this, "preloaded", {
8067
+ Object.defineProperty(this, "isPreloading", {
8086
8068
  enumerable: true,
8087
8069
  configurable: true,
8088
8070
  writable: true,
8089
8071
  value: false
8090
8072
  });
8091
- Object.defineProperty(this, "isPreloading", {
8073
+ Object.defineProperty(this, "state", {
8092
8074
  enumerable: true,
8093
8075
  configurable: true,
8094
8076
  writable: true,
8095
- value: false
8077
+ value: external_mobx_namespaceObject.observable.object({
8078
+ inited: false,
8079
+ started: false,
8080
+ paused: false
8081
+ })
8096
8082
  });
8097
8083
  Object.defineProperty(this, "handleTouchEnd", {
8098
8084
  enumerable: true,
@@ -8133,6 +8119,9 @@ let StorySlideViewModel = (() => {
8133
8119
  get disabledNextClick() {
8134
8120
  return this._disabledNextClick;
8135
8121
  }
8122
+ get cover() {
8123
+ return this._cover;
8124
+ }
8136
8125
  mute() {
8137
8126
  this.slideApi.disableAudio();
8138
8127
  }
@@ -8152,8 +8141,7 @@ let StorySlideViewModel = (() => {
8152
8141
  this.slideApi.setWidgetGoodsComplete(elementId);
8153
8142
  }
8154
8143
  async init() {
8155
- const release = await this.mutex.acquire();
8156
- if (this.isInited)
8144
+ if (this.state.inited)
8157
8145
  return;
8158
8146
  let loaderShown = this.story.needShowLoaderScreen;
8159
8147
  let startTime = Date.now();
@@ -8162,12 +8150,12 @@ let StorySlideViewModel = (() => {
8162
8150
  loaderShown = true;
8163
8151
  startTime = Date.now();
8164
8152
  }, SHOW_SLIDE_TIMEOUT);
8153
+ let result = false;
8165
8154
  try {
8166
- debug(`[SLIDE][INIT]:${this.story.id}:${this.slide.index}`);
8167
- const { result, reason } = await this.slideApi.showSlide(this.html);
8168
- if (!result)
8169
- throw new Error(reason);
8170
- this.isInited = true;
8155
+ const data = await this.slideApi.showSlide(this.html);
8156
+ result = data.result;
8157
+ if (!data.result)
8158
+ throw new Error(data.reason);
8171
8159
  }
8172
8160
  catch (error) {
8173
8161
  this.handleSlideError(error);
@@ -8175,124 +8163,112 @@ let StorySlideViewModel = (() => {
8175
8163
  finally {
8176
8164
  clearTimeout(loaderTimeout);
8177
8165
  await this.cleanupLoaderIfNeeded(Date.now() - startTime, loaderShown);
8178
- release();
8166
+ if (result)
8167
+ this._cover = this.getCoverByLayer();
8179
8168
  }
8169
+ this.commit({ inited: true });
8170
+ this.debug(`${StorySlideEmodji.Init} [Slide Lifecycle] inited: `);
8180
8171
  }
8181
8172
  async start() {
8182
- const release = await this.mutex.acquire();
8173
+ if (!this.state.inited || this.state.started)
8174
+ return;
8183
8175
  try {
8184
- if (!this.isInited || this.isStarted)
8185
- return;
8186
- debug(`[SLIDE][START]:${this.story.id}:${this.slide.index}`);
8187
8176
  await this.slideApi.slideStart({ muted: this._story.muted });
8188
8177
  this.story.touchController.on(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
8189
- this.isStarted = true;
8190
8178
  }
8191
8179
  catch (error) {
8192
8180
  this.handleSlideError(error);
8193
8181
  }
8194
- finally {
8195
- release();
8196
- }
8182
+ this.commit({ started: true });
8183
+ this.debug(`${StorySlideEmodji.Start} [Slide Lifecycle] started: `);
8197
8184
  }
8198
8185
  async restart() {
8199
- const release = await this.mutex.acquire();
8200
8186
  try {
8201
8187
  this.story.hideErrorScreen();
8202
8188
  this.story.showLoaderScreen();
8203
8189
  await this.slideApi.slideRestart({ muted: this._story.muted });
8204
- this.isInited = true;
8205
- this.isStarted = true;
8190
+ this.commit({ inited: true, started: true, paused: false });
8206
8191
  }
8207
8192
  catch (error) {
8208
8193
  this.handleSlideError(error);
8209
8194
  }
8210
8195
  finally {
8211
8196
  this.story.hideLoaderScreen();
8212
- release();
8213
8197
  }
8198
+ this.debug(`${StorySlideEmodji.Restart} [Slide Lifecycle] restarted: `);
8214
8199
  }
8215
8200
  async resumeByApp() {
8216
- const release = await this.mutex.acquire();
8201
+ if (!this.state.paused)
8202
+ return;
8217
8203
  try {
8218
- if (!this.isStarted)
8219
- return;
8220
- debug(`[SLIDE][RESUME-BY-APP]:${this.story.id}:${this.slide.index}`);
8221
8204
  await this.slideApi.slideAppResume();
8222
8205
  }
8223
8206
  catch (error) {
8224
8207
  this.handleSlideError(error);
8225
8208
  }
8226
- finally {
8227
- release();
8228
- }
8209
+ this.commit({ paused: false });
8210
+ this.debug(`${StorySlideEmodji.Resume} [Slide Lifecycle] resume by app: `);
8229
8211
  }
8230
8212
  async pauseByApp() {
8231
- const release = await this.mutex.acquire();
8213
+ if (this.state.paused)
8214
+ return;
8232
8215
  try {
8233
- if (!this.isStarted)
8234
- return;
8235
- debug(`[SLIDE][PAUSE-BY-APP]:${this.story.id}:${this.slide.index}`);
8236
8216
  await this.slideApi.slideAppPause();
8237
8217
  }
8238
8218
  catch (error) {
8239
8219
  this.handleSlideError(error);
8240
8220
  }
8241
- finally {
8242
- release();
8243
- }
8221
+ this.debug(`${StorySlideEmodji.Pause} [Slide Lifecycle] pause by app: `);
8222
+ this.commit({ paused: true });
8244
8223
  }
8245
8224
  async resumeByUser() {
8246
- const release = await this.mutex.acquire();
8225
+ if (!this.state.paused)
8226
+ return;
8247
8227
  try {
8248
- if (!this.isStarted)
8249
- return;
8250
- debug(`[SLIDE][RESUME-BY-USER]:${this.story.id}:${this.slide.index}`);
8251
8228
  await this.slideApi.slideUserResume();
8252
8229
  }
8253
8230
  catch (error) {
8254
8231
  this.handleSlideError(error);
8255
8232
  }
8256
- finally {
8257
- release();
8258
- }
8233
+ this.commit({ paused: false });
8234
+ this.debug(`${StorySlideEmodji.Resume} [Slide Lifecycle] resume by user: `);
8259
8235
  }
8260
8236
  async pauseByUser() {
8261
- const release = await this.mutex.acquire();
8237
+ if (this.state.paused)
8238
+ return;
8262
8239
  try {
8263
- if (!this.isStarted)
8264
- return;
8265
- debug(`[SLIDE][PAUSE-BY-USER]:${this.story.id}:${this.slide.index}`);
8266
8240
  await this.slideApi.slideUserPause();
8267
8241
  }
8268
8242
  catch (error) {
8269
8243
  this.handleSlideError(error);
8270
8244
  }
8271
- finally {
8272
- release();
8273
- }
8245
+ this.commit({ paused: true });
8246
+ this.debug(`${StorySlideEmodji.Pause} [Slide Lifecycle] pause by user: `);
8274
8247
  }
8275
8248
  async stop(params) {
8276
- const release = await this.mutex.acquire();
8249
+ if (!this.state.started)
8250
+ return;
8251
+ await this.stopAndCleanup(params);
8252
+ if (params.prepareForRestart === 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */) {
8253
+ this.commit({ started: false, paused: false });
8254
+ }
8255
+ else {
8256
+ this.commit({ started: false, inited: false, paused: false });
8257
+ }
8258
+ this.debug(`${StorySlideEmodji.Stop} [Slide Lifecycle] stopped: `);
8259
+ }
8260
+ async stopAndCleanup(params) {
8277
8261
  try {
8278
- if (!this.isInited || !this.isStarted)
8279
- return;
8280
- debug(`[SLIDE][STOP]:${this.story.id}:${this.slide.index}`);
8262
+ this.story.touchController.off(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
8281
8263
  await this.slideApi.slideStop(params);
8282
8264
  }
8283
8265
  catch (error) {
8284
8266
  this.handleSlideError(error);
8285
8267
  }
8286
- finally {
8287
- this.isStarted = false;
8288
- if (params.prepareForRestart === 2 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.NOT_PREPARE */)
8289
- this.isInited = false;
8290
- this.story.touchController.off(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
8291
- release();
8292
- }
8293
8268
  }
8294
8269
  showLayerByIndex(index) {
8295
8270
  this.slideApi.showLayer(index);
8271
+ this._cover = this.getCoverByLayer();
8296
8272
  }
8297
8273
  canGoNext() {
8298
8274
  const { canClickNext } = this.slideApi.slideClickHandler(null, "forward");
@@ -8335,20 +8311,17 @@ let StorySlideViewModel = (() => {
8335
8311
  }
8336
8312
  }
8337
8313
  async destroy() {
8338
- const release = await this.mutex.acquire();
8339
8314
  try {
8340
- this.isStarted = false;
8341
- this.isInited = false;
8342
- this.story.touchController.off(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
8343
8315
  if (this.cacheManager)
8344
8316
  this.slide.restoreOriginalResourceUrls();
8317
+ this.story.touchController.off(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
8318
+ this.commit({ inited: false, started: false, paused: false });
8319
+ this.debug(`${StorySlideEmodji.Destroy} [Slide Lifecycle] destroyed: `);
8320
+ await this.slideApi.slideStop({ prepareForRestart: 2 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.NOT_PREPARE */ });
8345
8321
  }
8346
8322
  catch (error) {
8347
8323
  console.error(error);
8348
8324
  }
8349
- finally {
8350
- release();
8351
- }
8352
8325
  }
8353
8326
  getNavigationDirection(event, currentTarget) {
8354
8327
  const xPercent = this.getClickPosition(event, currentTarget);
@@ -8392,14 +8365,37 @@ let StorySlideViewModel = (() => {
8392
8365
  this.story.hideLoaderScreen();
8393
8366
  }
8394
8367
  }
8368
+ getCoverByLayer() {
8369
+ var _b, _c;
8370
+ const activeLayer = this.slideApi.activeLayer.nodeRef;
8371
+ const imageSrc = (_b = activeLayer.querySelector(".narrative-element-image img")) === null || _b === void 0 ? void 0 : _b.src;
8372
+ const videoPosterSrc = (_c = activeLayer.querySelector(".narrative-element-video video")) === null || _c === void 0 ? void 0 : _c.getAttribute("poster-remote-src");
8373
+ return imageSrc || videoPosterSrc || null;
8374
+ }
8375
+ commit(partial) {
8376
+ Object.assign(this.state, partial);
8377
+ if (!this.state.inited) {
8378
+ this.state.started = false;
8379
+ this.state.paused = false;
8380
+ }
8381
+ if (!this.state.started) {
8382
+ this.state.paused = false;
8383
+ }
8384
+ }
8385
+ debug(message) {
8386
+ debug(message, { cardId: this.story.id, slideIndex: this.index });
8387
+ }
8395
8388
  },
8396
8389
  _StorySlideViewModel__disabledNextClick_accessor_storage = new WeakMap(),
8390
+ _StorySlideViewModel__cover_accessor_storage = new WeakMap(),
8397
8391
  (() => {
8398
8392
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
8399
8393
  __disabledNextClick_decorators = [external_mobx_namespaceObject.observable];
8400
- _start_decorators = [noConcurrent];
8394
+ __cover_decorators = [external_mobx_namespaceObject.observable];
8395
+ _commit_decorators = [external_mobx_namespaceObject.action];
8401
8396
  storySlideViewModel_esDecorate(_a, null, __disabledNextClick_decorators, { kind: "accessor", name: "_disabledNextClick", static: false, private: false, access: { has: obj => "_disabledNextClick" in obj, get: obj => obj._disabledNextClick, set: (obj, value) => { obj._disabledNextClick = value; } }, metadata: _metadata }, __disabledNextClick_initializers, __disabledNextClick_extraInitializers);
8402
- storySlideViewModel_esDecorate(_a, null, _start_decorators, { kind: "method", name: "start", static: false, private: false, access: { has: obj => "start" in obj, get: obj => obj.start }, metadata: _metadata }, null, _instanceExtraInitializers);
8397
+ storySlideViewModel_esDecorate(_a, null, __cover_decorators, { kind: "accessor", name: "_cover", static: false, private: false, access: { has: obj => "_cover" in obj, get: obj => obj._cover, set: (obj, value) => { obj._cover = value; } }, metadata: _metadata }, __cover_initializers, __cover_extraInitializers);
8398
+ storySlideViewModel_esDecorate(_a, null, _commit_decorators, { kind: "method", name: "commit", static: false, private: false, access: { has: obj => "commit" in obj, get: obj => obj.commit }, metadata: _metadata }, null, _instanceExtraInitializers);
8403
8399
  if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
8404
8400
  })(),
8405
8401
  _a;
@@ -9637,6 +9633,12 @@ let TextInputViewModel = (() => {
9637
9633
  const SLIDE_RATIO = 310 / 480;
9638
9634
  const MOBILE_ASPECT_RATIO = 428 / 805;
9639
9635
 
9636
+ ;// CONCATENATED MODULE: external "async-mutex"
9637
+ var external_async_mutex_x = (y) => {
9638
+ var x = {}; __webpack_require__.d(x, y); return x
9639
+ }
9640
+ var external_async_mutex_y = (x) => (() => (x))
9641
+ const external_async_mutex_namespaceObject = external_async_mutex_x({ ["Mutex"]: () => (__WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__.Mutex), ["Semaphore"]: () => (__WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__.Semaphore) });
9640
9642
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyViewModel/storyViewModel.ts
9641
9643
  var storyViewModel_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
9642
9644
  var useValue = arguments.length > 2;
@@ -9700,11 +9702,22 @@ var storyViewModel_classPrivateFieldSet = (undefined && undefined.__classPrivate
9700
9702
 
9701
9703
  var StoryEvent;
9702
9704
  (function (StoryEvent) {
9703
- StoryEvent["ShowToast"] = "showToast";
9705
+ StoryEvent["Started"] = "started";
9704
9706
  })(StoryEvent || (StoryEvent = {}));
9707
+ var StoryEmodji;
9708
+ (function (StoryEmodji) {
9709
+ StoryEmodji["Prefetch"] = "\uD83D\uDD04";
9710
+ StoryEmodji["Init"] = "\uD83D\uDD27";
9711
+ StoryEmodji["Start"] = "\uD83D\uDFE2";
9712
+ StoryEmodji["Stop"] = "\uD83D\uDED1";
9713
+ StoryEmodji["Attach"] = "\uD83D\uDD17";
9714
+ StoryEmodji["Detach"] = "\uD83D\uDDD1\uFE0F";
9715
+ })(StoryEmodji || (StoryEmodji = {}));
9705
9716
  const ACTIVE_SLIDE_PRELOAD_PRIORITY = 1000;
9717
+ const ACTIVE_STORY_PRELOAD_PRIORITY = 1000;
9718
+ const NON_ACTIVE_STORY_PRELOAD_PRIORITY = 0;
9706
9719
  let StoryViewModel = (() => {
9707
- var _a, _StoryViewModel__activeSlideIndex_accessor_storage, _StoryViewModel__slides_accessor_storage, _StoryViewModel__needShowErrorScreen_accessor_storage, _StoryViewModel__needShowLoaderScreen_accessor_storage, _StoryViewModel__$root_accessor_storage, _StoryViewModel_isInited_accessor_storage;
9720
+ var _a, _StoryViewModel__activeSlideIndex_accessor_storage, _StoryViewModel__slides_accessor_storage, _StoryViewModel__needShowErrorScreen_accessor_storage, _StoryViewModel__needShowLoaderScreen_accessor_storage, _StoryViewModel__$root_accessor_storage;
9708
9721
  var _b;
9709
9722
  let _classSuper = ViewModel;
9710
9723
  let _instanceExtraInitializers = [];
@@ -9723,13 +9736,9 @@ let StoryViewModel = (() => {
9723
9736
  let __$root_decorators;
9724
9737
  let __$root_initializers = [];
9725
9738
  let __$root_extraInitializers = [];
9726
- let _isInited_decorators;
9727
- let _isInited_initializers = [];
9728
- let _isInited_extraInitializers = [];
9729
9739
  let _get_needShowErrorScreen_decorators;
9730
9740
  let _get_needShowLoaderScreen_decorators;
9731
9741
  let _get_activeSlide_decorators;
9732
- let _get_displayedSlideImage_decorators;
9733
9742
  let _get_reachEnd_decorators;
9734
9743
  let _get_reachStart_decorators;
9735
9744
  let _get_pauseState_decorators;
@@ -9742,6 +9751,7 @@ let StoryViewModel = (() => {
9742
9751
  let _showSlide_decorators;
9743
9752
  let _markAsOpened_decorators;
9744
9753
  let _markWasShown_decorators;
9754
+ let _commit_decorators;
9745
9755
  return _a = class StoryViewModel extends _classSuper {
9746
9756
  get _activeSlideIndex() { return storyViewModel_classPrivateFieldGet(this, _StoryViewModel__activeSlideIndex_accessor_storage, "f"); }
9747
9757
  set _activeSlideIndex(value) { storyViewModel_classPrivateFieldSet(this, _StoryViewModel__activeSlideIndex_accessor_storage, value, "f"); }
@@ -9753,9 +9763,7 @@ let StoryViewModel = (() => {
9753
9763
  set _needShowLoaderScreen(value) { storyViewModel_classPrivateFieldSet(this, _StoryViewModel__needShowLoaderScreen_accessor_storage, value, "f"); }
9754
9764
  get _$root() { return storyViewModel_classPrivateFieldGet(this, _StoryViewModel__$root_accessor_storage, "f"); }
9755
9765
  set _$root(value) { storyViewModel_classPrivateFieldSet(this, _StoryViewModel__$root_accessor_storage, value, "f"); }
9756
- get isInited() { return storyViewModel_classPrivateFieldGet(this, _StoryViewModel_isInited_accessor_storage, "f"); }
9757
- set isInited(value) { storyViewModel_classPrivateFieldSet(this, _StoryViewModel_isInited_accessor_storage, value, "f"); }
9758
- constructor(storyManager, storyReader, story, storySlideApiHandlersFactory, storyReaderStatisticV1Service, storyReaderStatisticV2Service, cacheManager) {
9766
+ constructor(storyManager, storyReader, story, storySlideApiHandlersFactory, statisticV1Service, statisticV2Service, cacheManager) {
9759
9767
  super();
9760
9768
  Object.defineProperty(this, "storyManager", {
9761
9769
  enumerable: true,
@@ -9781,17 +9789,17 @@ let StoryViewModel = (() => {
9781
9789
  writable: true,
9782
9790
  value: storySlideApiHandlersFactory
9783
9791
  });
9784
- Object.defineProperty(this, "storyReaderStatisticV1Service", {
9792
+ Object.defineProperty(this, "statisticV1Service", {
9785
9793
  enumerable: true,
9786
9794
  configurable: true,
9787
9795
  writable: true,
9788
- value: storyReaderStatisticV1Service
9796
+ value: statisticV1Service
9789
9797
  });
9790
- Object.defineProperty(this, "storyReaderStatisticV2Service", {
9798
+ Object.defineProperty(this, "statisticV2Service", {
9791
9799
  enumerable: true,
9792
9800
  configurable: true,
9793
9801
  writable: true,
9794
- value: storyReaderStatisticV2Service
9802
+ value: statisticV2Service
9795
9803
  });
9796
9804
  Object.defineProperty(this, "cacheManager", {
9797
9805
  enumerable: true,
@@ -9804,24 +9812,11 @@ let StoryViewModel = (() => {
9804
9812
  _StoryViewModel__needShowErrorScreen_accessor_storage.set(this, (storyViewModel_runInitializers(this, __slides_extraInitializers), storyViewModel_runInitializers(this, __needShowErrorScreen_initializers, false)));
9805
9813
  _StoryViewModel__needShowLoaderScreen_accessor_storage.set(this, (storyViewModel_runInitializers(this, __needShowErrorScreen_extraInitializers), storyViewModel_runInitializers(this, __needShowLoaderScreen_initializers, false)));
9806
9814
  _StoryViewModel__$root_accessor_storage.set(this, (storyViewModel_runInitializers(this, __needShowLoaderScreen_extraInitializers), storyViewModel_runInitializers(this, __$root_initializers, null)));
9807
- _StoryViewModel_isInited_accessor_storage.set(this, (storyViewModel_runInitializers(this, __$root_extraInitializers), storyViewModel_runInitializers(this, _isInited_initializers, false)));
9808
- Object.defineProperty(this, "isStarted", {
9809
- enumerable: true,
9810
- configurable: true,
9811
- writable: true,
9812
- value: (storyViewModel_runInitializers(this, _isInited_extraInitializers), false)
9813
- });
9814
9815
  Object.defineProperty(this, "_activeSlideStartTime", {
9815
9816
  enumerable: true,
9816
9817
  configurable: true,
9817
9818
  writable: true,
9818
- value: 0
9819
- });
9820
- Object.defineProperty(this, "mutex", {
9821
- enumerable: true,
9822
- configurable: true,
9823
- writable: true,
9824
- value: new external_async_mutex_namespaceObject.Mutex()
9819
+ value: (storyViewModel_runInitializers(this, __$root_extraInitializers), 0)
9825
9820
  });
9826
9821
  // internal services
9827
9822
  Object.defineProperty(this, "slideApi", {
@@ -9836,12 +9831,6 @@ let StoryViewModel = (() => {
9836
9831
  writable: true,
9837
9832
  value: void 0
9838
9833
  });
9839
- Object.defineProperty(this, "storySlidesReactionDisposer", {
9840
- enumerable: true,
9841
- configurable: true,
9842
- writable: true,
9843
- value: void 0
9844
- });
9845
9834
  // UI
9846
9835
  Object.defineProperty(this, "timeline", {
9847
9836
  enumerable: true,
@@ -9885,23 +9874,37 @@ let StoryViewModel = (() => {
9885
9874
  writable: true,
9886
9875
  value: void 0
9887
9876
  });
9877
+ Object.defineProperty(this, "mutex", {
9878
+ enumerable: true,
9879
+ configurable: true,
9880
+ writable: true,
9881
+ value: new external_async_mutex_namespaceObject.Mutex()
9882
+ });
9888
9883
  Object.defineProperty(this, "toast", {
9889
9884
  enumerable: true,
9890
9885
  configurable: true,
9891
9886
  writable: true,
9892
9887
  value: null
9893
9888
  });
9894
- Object.defineProperty(this, "attachRoot", {
9889
+ Object.defineProperty(this, "state", {
9895
9890
  enumerable: true,
9896
9891
  configurable: true,
9897
9892
  writable: true,
9898
- value: async (el) => {
9899
- this._$root = el;
9900
- // Reaction to `layout` (modern or classic) change
9901
- // TODO: add test with example
9902
- await this.reinit();
9903
- await this.restart();
9904
- }
9893
+ value: external_mobx_namespaceObject.observable.object({
9894
+ attached: false,
9895
+ inited: false,
9896
+ started: false,
9897
+ prefetched: false
9898
+ })
9899
+ });
9900
+ /**
9901
+ * The story content are loaded at the time the instance is created (e.g. when the story reader is reopened)
9902
+ */
9903
+ Object.defineProperty(this, "isLoaded", {
9904
+ enumerable: true,
9905
+ configurable: true,
9906
+ writable: true,
9907
+ value: false
9905
9908
  });
9906
9909
  Object.defineProperty(this, "handleKeydown", {
9907
9910
  enumerable: true,
@@ -9926,18 +9929,20 @@ let StoryViewModel = (() => {
9926
9929
  this.pauseManager = new StoryPauseManager(this);
9927
9930
  this.touchController = this.storyReader.touchController;
9928
9931
  this.slideApiHandlers = this.storySlideApiHandlersFactory.create(this);
9929
- this.goodsWidget = new StoryGoodsWidgetViewModel(this.storyManager, this, this.storyReaderStatisticV2Service);
9930
- this.textInput = new TextInputViewModel(this, this.storyReaderStatisticV2Service);
9932
+ this.goodsWidget = new StoryGoodsWidgetViewModel(this.storyManager, this, this.statisticV2Service);
9933
+ this.textInput = new TextInputViewModel(this, this.statisticV2Service);
9931
9934
  this.timeline = new StoryTimelineViewModel(this);
9932
9935
  this.sharePanel = new SharePanelViewModel(this.storyManager, this, this.storyReader.touchController);
9933
- this.actionPanel = new StoryActionPanelViewModel(this.storyManager, this, this.sharePanel, this.storyReaderStatisticV2Service);
9934
- this.storySlidesReactionDisposer = this.observeStorySlides();
9936
+ this.actionPanel = new StoryActionPanelViewModel(this.storyManager, this, this.sharePanel, this.statisticV2Service);
9937
+ this.isLoaded = this.story.canBeShown && Boolean(this.story.slides.length > 0);
9935
9938
  }
9936
9939
  get needShowErrorScreen() {
9937
9940
  return this._needShowErrorScreen || Boolean(this.error);
9938
9941
  }
9939
9942
  get needShowLoaderScreen() {
9940
- return !this.story.canBeShown || this._needShowLoaderScreen;
9943
+ if (this.isLoaded)
9944
+ return !this.slides.length || this._needShowLoaderScreen;
9945
+ return !this.slides.length || !this.state.inited || this._needShowLoaderScreen;
9941
9946
  }
9942
9947
  get id() {
9943
9948
  return this.story.id;
@@ -9960,9 +9965,6 @@ let StoryViewModel = (() => {
9960
9965
  get displayStrategy() {
9961
9966
  return this.storyReader.displayStrategy;
9962
9967
  }
9963
- get canBeShown() {
9964
- return this.story.canBeShown && this.slides.length > 0 && Boolean(this._$root);
9965
- }
9966
9968
  get context() {
9967
9969
  return this.story.context;
9968
9970
  }
@@ -9987,9 +9989,6 @@ let StoryViewModel = (() => {
9987
9989
  get slidesCount() {
9988
9990
  return this.story.slidesCount;
9989
9991
  }
9990
- get displayedSlideImage() {
9991
- return this.story.getImagesPerSlide(this.activeSlideIndex);
9992
- }
9993
9992
  get reachEnd() {
9994
9993
  return this.slides.length === 0 || this.activeSlideIndex === this.slides.length - 1;
9995
9994
  }
@@ -10019,7 +10018,10 @@ let StoryViewModel = (() => {
10019
10018
  return this.storyReader.dir;
10020
10019
  }
10021
10020
  get isSlideRendered() {
10022
- return this.isInited;
10021
+ return this.state.inited;
10022
+ }
10023
+ get cover() {
10024
+ return this.activeSlide.cover;
10023
10025
  }
10024
10026
  get isNextDisabled() {
10025
10027
  return ((this.storyReader.reachEnd && this.reachEnd) ||
@@ -10076,6 +10078,8 @@ let StoryViewModel = (() => {
10076
10078
  }
10077
10079
  setError(error) {
10078
10080
  this.story.setError(error);
10081
+ if (error)
10082
+ this.handleStoryError(error);
10079
10083
  }
10080
10084
  async reset() {
10081
10085
  this.textInput.close();
@@ -10092,7 +10096,7 @@ let StoryViewModel = (() => {
10092
10096
  }
10093
10097
  async prevSlideOrStory() {
10094
10098
  if (this.reachStart && this.storyReader.reachStart) {
10095
- if (!this.isStarted)
10099
+ if (!this.state.started)
10096
10100
  return;
10097
10101
  await this.activeSlide.restart();
10098
10102
  return;
@@ -10110,6 +10114,17 @@ let StoryViewModel = (() => {
10110
10114
  this.storyReader.unmute();
10111
10115
  this.activeSlide.unmute();
10112
10116
  }
10117
+ showLayer(index) {
10118
+ var _b;
10119
+ this.statisticV2Service.sendSlideLayout({
10120
+ layoutIndex: index,
10121
+ storyId: this.id,
10122
+ activeSlideIndex: this.activeSlideIndex,
10123
+ feedSlug: (_b = this.feed) === null || _b === void 0 ? void 0 : _b.slug
10124
+ });
10125
+ this.resumeUser();
10126
+ this.activeSlide.showLayerByIndex(index);
10127
+ }
10113
10128
  pauseUser() {
10114
10129
  if (this.timeline.paused)
10115
10130
  return;
@@ -10140,22 +10155,56 @@ let StoryViewModel = (() => {
10140
10155
  async updateNarrativeData(data) {
10141
10156
  await this.storyManager.rootStore.storyStore.updateNarrativeData(this.id, data);
10142
10157
  }
10143
- detachRoot() {
10144
- var _b;
10158
+ async detach(ui) {
10159
+ var _b, _c;
10160
+ if (ui.container || !this.state.attached)
10161
+ return;
10145
10162
  this._$root = null;
10146
- const isInited = this.isInited;
10147
- const isStarted = this.isStarted;
10148
- this.stop();
10149
- (_b = this.slideApi) === null || _b === void 0 ? void 0 : _b.destroy();
10163
+ (_b = this.toast) === null || _b === void 0 ? void 0 : _b.destroy();
10164
+ this.slideApiHandlers.clearNarrativeSessionDataCache();
10165
+ this.resumeAll();
10166
+ document.removeEventListener("visibilitychange", this.handleVisibilityChange);
10167
+ document.removeEventListener("keydown", this.handleKeydown);
10168
+ (_c = this.slideApi) === null || _c === void 0 ? void 0 : _c.destroy();
10150
10169
  for (const slide of this._slides)
10151
- slide.destroy();
10152
- this.isInited = isInited;
10153
- this.isStarted = isStarted;
10170
+ await slide.destroy();
10171
+ this.debug(`${StoryEmodji.Detach} [Story Lifecycle] detached: `);
10172
+ this.commit({ attached: false, inited: false, started: false });
10173
+ }
10174
+ async attach(ui) {
10175
+ if (!ui.container || this.state.attached)
10176
+ return;
10177
+ this._$root = ui.container;
10178
+ await (0,external_mobx_namespaceObject.when)(() => this.story.canBeShown && Boolean(this.story.slides.length));
10179
+ this.slideApi = this.createSlideApi(ui.container);
10180
+ this.createSlidesViewModels(this.story.slides, this.slideApi);
10181
+ this.debug(`${StoryEmodji.Attach} [Story Lifecycle] attached: `);
10182
+ this.commit({ attached: true });
10183
+ }
10184
+ async prefetch(ui) {
10185
+ if (!ui.canBeInited || this.state.prefetched)
10186
+ return;
10187
+ if (this === ui.activeStory) {
10188
+ await this.preload(ACTIVE_STORY_PRELOAD_PRIORITY);
10189
+ }
10190
+ else {
10191
+ await this.preload(NON_ACTIVE_STORY_PRELOAD_PRIORITY, 2);
10192
+ }
10193
+ this.debug(`${StoryEmodji.Prefetch} [Story Lifecycle] prefetched: `);
10194
+ this.commit({ prefetched: true });
10195
+ }
10196
+ async preload(priority = 1000, count = this.slidesCount) {
10197
+ const cacheConfig = this.storyManager.config.cache;
10198
+ if (!cacheConfig)
10199
+ return;
10200
+ if (cacheConfig.prefetch) {
10201
+ await this.preloadSlides(0, count, priority);
10202
+ }
10203
+ else {
10204
+ await this.preloadActiveSlide(priority);
10205
+ }
10154
10206
  }
10155
10207
  async preloadSlides(start, end, priority) {
10156
- if (!this.story.canBeShown)
10157
- this.showLoaderScreen();
10158
- await (0,external_mobx_namespaceObject.when)(() => this.story.canBeShown);
10159
10208
  end = end !== null && end !== void 0 ? end : this._slides.length;
10160
10209
  priority = priority !== null && priority !== void 0 ? priority : 0;
10161
10210
  await Promise.all(this._slides.slice(start, end).map((slide, index) => slide.preload(end - index + priority)));
@@ -10163,41 +10212,36 @@ let StoryViewModel = (() => {
10163
10212
  async preloadActiveSlide(priority) {
10164
10213
  this.preloadSlides(this._activeSlideIndex, this._activeSlideIndex + 1, priority);
10165
10214
  }
10166
- async init() {
10167
- await this.mutex.runExclusive(async () => {
10168
- if (this.isInited)
10169
- return;
10170
- if (!this.story.canBeShown)
10171
- this.showLoaderScreen();
10172
- await (0,external_mobx_namespaceObject.when)(() => this.canBeShown);
10173
- await this.activeSlide.init();
10174
- this.isInited = true;
10175
- });
10215
+ async init(ui) {
10216
+ if (!ui.canBeInited || !this.state.attached || this.state.inited)
10217
+ return;
10218
+ await this.activeSlide.init();
10219
+ this.debug(`${StoryEmodji.Init} [Story Lifecycle] inited: `);
10220
+ this.commit({ inited: true });
10176
10221
  }
10177
- async start() {
10178
- await this.mutex.runExclusive(async () => {
10179
- if (this.isStarted || !this.isInited)
10180
- return;
10181
- await this.activeSlide.start();
10182
- document.addEventListener("visibilitychange", this.handleVisibilityChange);
10183
- document.addEventListener("keydown", this.handleKeydown);
10184
- this.isStarted = true;
10185
- this._activeSlideStartTime = Date.now();
10186
- });
10222
+ async start(ui) {
10223
+ if (!ui.canBeStarted || !this.state.inited || this.state.started)
10224
+ return;
10225
+ this.emit(StoryEvent.Started);
10226
+ await this.activeSlide.start();
10227
+ document.addEventListener("visibilitychange", this.handleVisibilityChange);
10228
+ document.addEventListener("keydown", this.handleKeydown);
10229
+ this._activeSlideStartTime = Date.now();
10230
+ this.debug(`${StoryEmodji.Start} [Story Lifecycle] started: `);
10231
+ this.commit({ started: true });
10187
10232
  }
10188
- async stop() {
10189
- await this.mutex.runExclusive(async () => {
10190
- var _b;
10191
- if (!this.isStarted || !this.isInited)
10192
- return;
10193
- (_b = this.toast) === null || _b === void 0 ? void 0 : _b.destroy();
10194
- this.isStarted = false;
10195
- this.slideApiHandlers.clearNarrativeSessionDataCache();
10196
- this.resumeAll();
10197
- document.removeEventListener("visibilitychange", this.handleVisibilityChange);
10198
- document.removeEventListener("keydown", this.handleKeydown);
10199
- await this.activeSlide.stop({ prepareForRestart: 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */ });
10200
- });
10233
+ async stop(ui) {
10234
+ var _b;
10235
+ if (ui.canBeStarted || !this.state.started)
10236
+ return;
10237
+ (_b = this.toast) === null || _b === void 0 ? void 0 : _b.destroy();
10238
+ this.slideApiHandlers.clearNarrativeSessionDataCache();
10239
+ this.resumeAll();
10240
+ document.removeEventListener("visibilitychange", this.handleVisibilityChange);
10241
+ document.removeEventListener("keydown", this.handleKeydown);
10242
+ await this.activeSlide.stop({ prepareForRestart: 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */ });
10243
+ this.debug(`${StoryEmodji.Stop} [Story Lifecycle] stopped: `);
10244
+ this.commit({ started: false });
10201
10245
  }
10202
10246
  canGoNext() {
10203
10247
  return this.activeSlide.canGoNext();
@@ -10213,23 +10257,15 @@ let StoryViewModel = (() => {
10213
10257
  }
10214
10258
  async destroy() {
10215
10259
  var _b, _c;
10216
- this._$root = null;
10217
10260
  document.removeEventListener("visibilitychange", this.handleVisibilityChange);
10218
10261
  document.removeEventListener("keydown", this.handleKeydown);
10219
- this.storySlidesReactionDisposer();
10220
10262
  this.sharePanel.close();
10221
10263
  this.textInput.close();
10222
10264
  this.timeline.destroy();
10223
10265
  this.goodsWidget.close();
10224
- const activeSlide = this.getSlideByIndex(this._activeSlideIndex);
10225
10266
  this.slideApiHandlers.clearNarrativeSessionDataCache();
10226
- if (this.isStarted)
10227
- await activeSlide.stop({ prepareForRestart: 2 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.NOT_PREPARE */ });
10228
- await activeSlide.destroy();
10229
10267
  (_b = this.slideApi) === null || _b === void 0 ? void 0 : _b.destroy();
10230
10268
  (_c = this.toast) === null || _c === void 0 ? void 0 : _c.destroy();
10231
- this.isInited = false;
10232
- this.isStarted = false;
10233
10269
  }
10234
10270
  notifyPauseStateChange() {
10235
10271
  if (this.pauseManager.isUserPaused)
@@ -10243,7 +10279,7 @@ let StoryViewModel = (() => {
10243
10279
  }
10244
10280
  emitSlideV2Stat(index, durationMs) {
10245
10281
  var _b;
10246
- this.storyReaderStatisticV2Service.sendSlideEvent({
10282
+ this.statisticV2Service.sendSlideEvent({
10247
10283
  durationMs,
10248
10284
  storyId: this.id,
10249
10285
  activeSlideIndex: index,
@@ -10253,21 +10289,11 @@ let StoryViewModel = (() => {
10253
10289
  emitSlideV1Stat(index) {
10254
10290
  const event = new ShowSlideEvent(this);
10255
10291
  this.storyManager.emit(event.name, event.toJSON());
10256
- this.storyReaderStatisticV1Service.sendOpenStoryEvent({
10292
+ this.statisticV1Service.sendOpenStoryEvent({
10257
10293
  storyId: this.id,
10258
10294
  slideIndex: index
10259
10295
  });
10260
10296
  }
10261
- observeStorySlides() {
10262
- return (0,external_mobx_namespaceObject.reaction)(() => ({ storySlides: this.story.slides, canBeShown: this.story.canBeShown && Boolean(this._$root) }), ({ storySlides, canBeShown }) => {
10263
- if (!this._$root || !canBeShown || !storySlides.length)
10264
- return [];
10265
- this.slideApi = this.createSlideApi(this._$root);
10266
- return this.createSlidesViewModels(storySlides, this.slideApi);
10267
- }, {
10268
- fireImmediately: true
10269
- });
10270
- }
10271
10297
  createSlideApi(root) {
10272
10298
  const slideApi = new slide_api_namespaceObject.SlideApi(this.slideApiHandlers, {
10273
10299
  root,
@@ -10321,17 +10347,39 @@ let StoryViewModel = (() => {
10321
10347
  console.error(error);
10322
10348
  }
10323
10349
  }
10324
- async reinit() {
10325
- if (this.isInited) {
10326
- this.isInited = false;
10327
- await this.init();
10328
- }
10350
+ handleStoryError(error) {
10351
+ const event = new ShowStoryFailed({
10352
+ id: this.id,
10353
+ title: this.title,
10354
+ name: error.name,
10355
+ message: error.message
10356
+ });
10357
+ this.storyManager.emit(event.name, event.toJSON());
10329
10358
  }
10330
- async restart() {
10331
- if (this.isStarted) {
10332
- this.isStarted = false;
10333
- await this.start();
10359
+ async update(uiState) {
10360
+ await this.mutex.runExclusive(async () => {
10361
+ await this.detach(uiState);
10362
+ await this.attach(uiState);
10363
+ await this.prefetch(uiState);
10364
+ await this.init(uiState);
10365
+ await this.stop(uiState);
10366
+ await this.start(uiState);
10367
+ });
10368
+ }
10369
+ commit(partial) {
10370
+ Object.assign(this.state, partial);
10371
+ if (!this.state.attached) {
10372
+ this.state.inited = false;
10373
+ this.state.started = false;
10374
+ this.state.prefetched = false;
10334
10375
  }
10376
+ if (!this.state.inited) {
10377
+ this.state.started = false;
10378
+ this.state.prefetched = false;
10379
+ }
10380
+ }
10381
+ debug(message) {
10382
+ //debug(message, { storyId: this.id });
10335
10383
  }
10336
10384
  },
10337
10385
  _StoryViewModel__activeSlideIndex_accessor_storage = new WeakMap(),
@@ -10339,7 +10387,6 @@ let StoryViewModel = (() => {
10339
10387
  _StoryViewModel__needShowErrorScreen_accessor_storage = new WeakMap(),
10340
10388
  _StoryViewModel__needShowLoaderScreen_accessor_storage = new WeakMap(),
10341
10389
  _StoryViewModel__$root_accessor_storage = new WeakMap(),
10342
- _StoryViewModel_isInited_accessor_storage = new WeakMap(),
10343
10390
  (() => {
10344
10391
  var _b;
10345
10392
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
@@ -10348,11 +10395,9 @@ let StoryViewModel = (() => {
10348
10395
  __needShowErrorScreen_decorators = [external_mobx_namespaceObject.observable];
10349
10396
  __needShowLoaderScreen_decorators = [external_mobx_namespaceObject.observable];
10350
10397
  __$root_decorators = [external_mobx_namespaceObject.observable];
10351
- _isInited_decorators = [external_mobx_namespaceObject.observable];
10352
10398
  _get_needShowErrorScreen_decorators = [external_mobx_namespaceObject.computed];
10353
10399
  _get_needShowLoaderScreen_decorators = [external_mobx_namespaceObject.computed];
10354
10400
  _get_activeSlide_decorators = [external_mobx_namespaceObject.computed];
10355
- _get_displayedSlideImage_decorators = [external_mobx_namespaceObject.computed];
10356
10401
  _get_reachEnd_decorators = [external_mobx_namespaceObject.computed];
10357
10402
  _get_reachStart_decorators = [external_mobx_namespaceObject.computed];
10358
10403
  _get_pauseState_decorators = [(_b = external_mobx_namespaceObject.computed).struct.bind(_b)];
@@ -10365,16 +10410,15 @@ let StoryViewModel = (() => {
10365
10410
  _showSlide_decorators = [external_mobx_namespaceObject.action];
10366
10411
  _markAsOpened_decorators = [external_mobx_namespaceObject.action];
10367
10412
  _markWasShown_decorators = [external_mobx_namespaceObject.action];
10413
+ _commit_decorators = [external_mobx_namespaceObject.action];
10368
10414
  storyViewModel_esDecorate(_a, null, __activeSlideIndex_decorators, { kind: "accessor", name: "_activeSlideIndex", static: false, private: false, access: { has: obj => "_activeSlideIndex" in obj, get: obj => obj._activeSlideIndex, set: (obj, value) => { obj._activeSlideIndex = value; } }, metadata: _metadata }, __activeSlideIndex_initializers, __activeSlideIndex_extraInitializers);
10369
10415
  storyViewModel_esDecorate(_a, null, __slides_decorators, { kind: "accessor", name: "_slides", static: false, private: false, access: { has: obj => "_slides" in obj, get: obj => obj._slides, set: (obj, value) => { obj._slides = value; } }, metadata: _metadata }, __slides_initializers, __slides_extraInitializers);
10370
10416
  storyViewModel_esDecorate(_a, null, __needShowErrorScreen_decorators, { kind: "accessor", name: "_needShowErrorScreen", static: false, private: false, access: { has: obj => "_needShowErrorScreen" in obj, get: obj => obj._needShowErrorScreen, set: (obj, value) => { obj._needShowErrorScreen = value; } }, metadata: _metadata }, __needShowErrorScreen_initializers, __needShowErrorScreen_extraInitializers);
10371
10417
  storyViewModel_esDecorate(_a, null, __needShowLoaderScreen_decorators, { kind: "accessor", name: "_needShowLoaderScreen", static: false, private: false, access: { has: obj => "_needShowLoaderScreen" in obj, get: obj => obj._needShowLoaderScreen, set: (obj, value) => { obj._needShowLoaderScreen = value; } }, metadata: _metadata }, __needShowLoaderScreen_initializers, __needShowLoaderScreen_extraInitializers);
10372
10418
  storyViewModel_esDecorate(_a, null, __$root_decorators, { kind: "accessor", name: "_$root", static: false, private: false, access: { has: obj => "_$root" in obj, get: obj => obj._$root, set: (obj, value) => { obj._$root = value; } }, metadata: _metadata }, __$root_initializers, __$root_extraInitializers);
10373
- storyViewModel_esDecorate(_a, null, _isInited_decorators, { kind: "accessor", name: "isInited", static: false, private: false, access: { has: obj => "isInited" in obj, get: obj => obj.isInited, set: (obj, value) => { obj.isInited = value; } }, metadata: _metadata }, _isInited_initializers, _isInited_extraInitializers);
10374
10419
  storyViewModel_esDecorate(_a, null, _get_needShowErrorScreen_decorators, { kind: "getter", name: "needShowErrorScreen", static: false, private: false, access: { has: obj => "needShowErrorScreen" in obj, get: obj => obj.needShowErrorScreen }, metadata: _metadata }, null, _instanceExtraInitializers);
10375
10420
  storyViewModel_esDecorate(_a, null, _get_needShowLoaderScreen_decorators, { kind: "getter", name: "needShowLoaderScreen", static: false, private: false, access: { has: obj => "needShowLoaderScreen" in obj, get: obj => obj.needShowLoaderScreen }, metadata: _metadata }, null, _instanceExtraInitializers);
10376
10421
  storyViewModel_esDecorate(_a, null, _get_activeSlide_decorators, { kind: "getter", name: "activeSlide", static: false, private: false, access: { has: obj => "activeSlide" in obj, get: obj => obj.activeSlide }, metadata: _metadata }, null, _instanceExtraInitializers);
10377
- storyViewModel_esDecorate(_a, null, _get_displayedSlideImage_decorators, { kind: "getter", name: "displayedSlideImage", static: false, private: false, access: { has: obj => "displayedSlideImage" in obj, get: obj => obj.displayedSlideImage }, metadata: _metadata }, null, _instanceExtraInitializers);
10378
10422
  storyViewModel_esDecorate(_a, null, _get_reachEnd_decorators, { kind: "getter", name: "reachEnd", static: false, private: false, access: { has: obj => "reachEnd" in obj, get: obj => obj.reachEnd }, metadata: _metadata }, null, _instanceExtraInitializers);
10379
10423
  storyViewModel_esDecorate(_a, null, _get_reachStart_decorators, { kind: "getter", name: "reachStart", static: false, private: false, access: { has: obj => "reachStart" in obj, get: obj => obj.reachStart }, metadata: _metadata }, null, _instanceExtraInitializers);
10380
10424
  storyViewModel_esDecorate(_a, null, _get_pauseState_decorators, { kind: "getter", name: "pauseState", static: false, private: false, access: { has: obj => "pauseState" in obj, get: obj => obj.pauseState }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -10387,18 +10431,13 @@ let StoryViewModel = (() => {
10387
10431
  storyViewModel_esDecorate(_a, null, _showSlide_decorators, { kind: "method", name: "showSlide", static: false, private: false, access: { has: obj => "showSlide" in obj, get: obj => obj.showSlide }, metadata: _metadata }, null, _instanceExtraInitializers);
10388
10432
  storyViewModel_esDecorate(_a, null, _markAsOpened_decorators, { kind: "method", name: "markAsOpened", static: false, private: false, access: { has: obj => "markAsOpened" in obj, get: obj => obj.markAsOpened }, metadata: _metadata }, null, _instanceExtraInitializers);
10389
10433
  storyViewModel_esDecorate(_a, null, _markWasShown_decorators, { kind: "method", name: "markWasShown", static: false, private: false, access: { has: obj => "markWasShown" in obj, get: obj => obj.markWasShown }, metadata: _metadata }, null, _instanceExtraInitializers);
10434
+ storyViewModel_esDecorate(_a, null, _commit_decorators, { kind: "method", name: "commit", static: false, private: false, access: { has: obj => "commit" in obj, get: obj => obj.commit }, metadata: _metadata }, null, _instanceExtraInitializers);
10390
10435
  if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
10391
10436
  })(),
10392
10437
  _a;
10393
10438
  })();
10394
10439
 
10395
10440
 
10396
- ;// CONCATENATED MODULE: external "lodash/isEmpty.js"
10397
- var isEmpty_js_x = (y) => {
10398
- var x = {}; __webpack_require__.d(x, y); return x
10399
- }
10400
- var isEmpty_js_y = (x) => (() => (x))
10401
- const isEmpty_js_namespaceObject = isEmpty_js_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_lodash_isEmpty_js_f1e1789b__["default"]) });
10402
10441
  ;// CONCATENATED MODULE: external "lodash/isObject.js"
10403
10442
  var isObject_js_x = (y) => {
10404
10443
  var x = {}; __webpack_require__.d(x, y); return x
@@ -10510,7 +10549,7 @@ class GameClientConfig {
10510
10549
  value: void 0
10511
10550
  });
10512
10551
  const storyManagerConfig = this.storyManager.config;
10513
- const sdkVersion = "1.9.4";
10552
+ const sdkVersion = "1.9.6";
10514
10553
  const placeholders = this.storyManager.rootStore.placeholderStore.placeholders;
10515
10554
  const session = this.storyManager.rootStore.sessionStore.session;
10516
10555
  this.sessionId = session.id;
@@ -10967,8 +11006,10 @@ class GameSession extends events.EventEmitter {
10967
11006
  if (event.origin !== this.origin)
10968
11007
  return;
10969
11008
  try {
10970
- if (!Array.isArray(event.data))
10971
- throw new Error(`[IAS]: Invalid MessageEvent data format ${event.data}`);
11009
+ if (!Array.isArray(event.data)) {
11010
+ console.warn(`[IAS]: Invalid game MessageEvent data format ${event.data}`);
11011
+ return;
11012
+ }
10972
11013
  const [gameEvent, ...restData] = event.data;
10973
11014
  this.emit(gameEvent, ...restData);
10974
11015
  }
@@ -11471,7 +11512,6 @@ var gameReaderViewModel_classPrivateFieldSet = (undefined && undefined.__classPr
11471
11512
 
11472
11513
 
11473
11514
 
11474
-
11475
11515
  var GameReaderEvent;
11476
11516
  (function (GameReaderEvent) {
11477
11517
  GameReaderEvent["Close"] = "close";
@@ -11730,7 +11770,7 @@ let GameReaderViewModel = (() => {
11730
11770
  if (this._isGameInited)
11731
11771
  (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.closeGameReader();
11732
11772
  else
11733
- this.finishGame({ result: {} });
11773
+ this.finishGame();
11734
11774
  return true;
11735
11775
  }
11736
11776
  async reloadGame() {
@@ -11753,7 +11793,7 @@ let GameReaderViewModel = (() => {
11753
11793
  }
11754
11794
  subscribeToGameSession(session) {
11755
11795
  session.on("gameComplete" /* GameSessionEvent.GameComplete */, (result, arg1, arg2, openStory, gameInstance) => {
11756
- this.finishGame({ result, openStory, gameInstance });
11796
+ this.finishGame({ openStory, gameInstance });
11757
11797
  });
11758
11798
  session.on("reloadGameReader" /* GameSessionEvent.ReloadGameReader */, () => {
11759
11799
  this.restartGame();
@@ -11807,17 +11847,14 @@ let GameReaderViewModel = (() => {
11807
11847
  this.resetFlags();
11808
11848
  this.resetGameData();
11809
11849
  }
11810
- finishGame({ result, openStory, gameInstance }) {
11811
- var _b;
11812
- const gameId = (_b = this.game) === null || _b === void 0 ? void 0 : _b.id;
11850
+ finishGame(params = {}) {
11813
11851
  this.resetScrollbar();
11814
11852
  this.closeSession();
11815
11853
  this.resetFlags();
11816
11854
  this.resetGameData();
11817
11855
  this.resetCounters();
11818
- if (gameId)
11819
- this.emitGameCompletion(gameId, result);
11820
- this.navigateAfterGame({ gameInstance, openStory });
11856
+ this.storyManager.emit("closeGame");
11857
+ this.navigateAfterGame(params);
11821
11858
  }
11822
11859
  resetScrollbar() {
11823
11860
  this.scrollbarHelper.disable();
@@ -11839,11 +11876,6 @@ let GameReaderViewModel = (() => {
11839
11876
  resetCounters() {
11840
11877
  this.retryAttempts = 0;
11841
11878
  }
11842
- emitGameCompletion(gameId, result) {
11843
- const event = (0,isEmpty_js_namespaceObject["default"])(result) ? "closeGame" : "finishGame";
11844
- const payload = (0,isEmpty_js_namespaceObject["default"])(result) ? { id: gameId } : { id: gameId, result };
11845
- this.storyManager.emit(event, payload);
11846
- }
11847
11879
  navigateAfterGame(params) {
11848
11880
  var _b, _c;
11849
11881
  if ((_b = params.gameInstance) === null || _b === void 0 ? void 0 : _b.id) {
@@ -12530,15 +12562,7 @@ class StorySlideApiHandlers {
12530
12562
  });
12531
12563
  }
12532
12564
  showLayer(index) {
12533
- var _a;
12534
- this.statisticV2Service.sendSlideLayout({
12535
- layoutIndex: index,
12536
- storyId: this.story.id,
12537
- activeSlideIndex: this.story.activeSlideIndex,
12538
- feedSlug: (_a = this.storyReader.feed) === null || _a === void 0 ? void 0 : _a.slug
12539
- });
12540
- this.story.resumeUser();
12541
- this.story.activeSlide.showLayerByIndex(index);
12565
+ this.story.showLayer(index);
12542
12566
  }
12543
12567
  showCardSlide(slideIndex) {
12544
12568
  this.story.showSlide(slideIndex);
@@ -12889,592 +12913,40 @@ class SafeAreaFrameCalculator {
12889
12913
 
12890
12914
 
12891
12915
 
12892
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/baseStoryReaderEvent.ts
12893
-
12916
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/showOnboardingStoriesStrategy.ts
12894
12917
 
12895
- class BaseStoryReaderEvent {
12896
- constructor(story, payload = {}) {
12897
- var _a, _b, _c, _d;
12898
- Object.defineProperty(this, "story", {
12899
- enumerable: true,
12900
- configurable: true,
12901
- writable: true,
12902
- value: story
12903
- });
12904
- Object.defineProperty(this, "payload", {
12905
- enumerable: true,
12906
- configurable: true,
12907
- writable: true,
12908
- value: payload
12909
- });
12910
- Object.defineProperty(this, "title", {
12918
+ class ShowOnboardingStoriesStrategy {
12919
+ constructor(showMultipleStoriesStrategy, storyManager) {
12920
+ Object.defineProperty(this, "showMultipleStoriesStrategy", {
12911
12921
  enumerable: true,
12912
12922
  configurable: true,
12913
12923
  writable: true,
12914
- value: null
12924
+ value: showMultipleStoriesStrategy
12915
12925
  });
12916
- Object.defineProperty(this, "tags", {
12926
+ Object.defineProperty(this, "storyManager", {
12917
12927
  enumerable: true,
12918
12928
  configurable: true,
12919
12929
  writable: true,
12920
- value: []
12930
+ value: storyManager
12921
12931
  });
12922
- Object.defineProperty(this, "slidesCount", {
12932
+ Object.defineProperty(this, "_feed", {
12923
12933
  enumerable: true,
12924
12934
  configurable: true,
12925
12935
  writable: true,
12926
12936
  value: null
12927
12937
  });
12928
- Object.defineProperty(this, "feedSlug", {
12929
- enumerable: true,
12930
- configurable: true,
12931
- writable: true,
12932
- value: null
12933
- });
12934
- Object.defineProperty(this, "filter", {
12935
- enumerable: true,
12936
- configurable: true,
12937
- writable: true,
12938
- value: null
12939
- });
12940
- Object.defineProperty(this, "actionSource", {
12941
- enumerable: true,
12942
- configurable: true,
12943
- writable: true,
12944
- value: StoryActionSource.list
12945
- });
12946
- Object.defineProperty(this, "ugcPayload", {
12947
- enumerable: true,
12948
- configurable: true,
12949
- writable: true,
12950
- value: null
12951
- });
12952
- Object.defineProperty(this, "slideEventPayload", {
12953
- enumerable: true,
12954
- configurable: true,
12955
- writable: true,
12956
- value: null
12957
- });
12958
- const feed = (_a = this.story.displayStrategy) === null || _a === void 0 ? void 0 : _a.feed;
12959
- const feedType = feed === null || feed === void 0 ? void 0 : feed.type;
12960
- const feedSlug = (_b = feed === null || feed === void 0 ? void 0 : feed.slug) !== null && _b !== void 0 ? _b : null;
12961
- const filter = feed instanceof UgcStoryFeed ? feed.filter : null;
12962
- this.title = this.story.statTitle;
12963
- this.slidesCount = this.story.slidesCount;
12964
- this.ugcPayload = feedType === StoryFeedType.UGC ? this.story.ugcPayload : null;
12965
- this.feedSlug = feedType === StoryFeedType.DEFAULT ? feedSlug : null;
12966
- this.filter = filter;
12967
- this.actionSource = feedType != null ? this.getStorySourceByFeedType(feedType) : StoryActionSource.direct;
12968
- this.slideEventPayload = (_d = (_c = story.activeSlide.eventPayload) === null || _c === void 0 ? void 0 : _c.payload) !== null && _d !== void 0 ? _d : null;
12969
- }
12970
- toJSON() {
12971
- return Object.assign({ id: this.story.id, index: this.story.activeSlideIndex, title: this.title, tags: this.tags, slidesCount: this.slidesCount, feed: this.feedSlug, filter: this.filter, source: this.actionSource, ugcPayload: this.ugcPayload, payload: this.slideEventPayload }, this.payload);
12972
- }
12973
- getStorySourceByFeedType(feedType) {
12974
- switch (feedType) {
12975
- case StoryFeedType.DEFAULT:
12976
- return StoryActionSource.list;
12977
- case StoryFeedType.UGC:
12978
- return StoryActionSource.list;
12979
- case StoryFeedType.FAVORITE:
12980
- return StoryActionSource.favorite;
12981
- case StoryFeedType.ONBOARDING:
12982
- return StoryActionSource.onboarding;
12983
- default:
12984
- return StoryActionSource.list;
12985
- }
12986
- }
12987
- }
12988
-
12989
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/closeStoryEvent.ts
12990
-
12991
- class CloseStoryEvent extends BaseStoryReaderEvent {
12992
- get name() {
12993
- return "closeStory";
12994
- }
12995
- toJSON() {
12996
- return Object.assign(Object.assign({}, super.toJSON()), { action: this.payload.action });
12997
- }
12998
- }
12999
-
13000
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/closeStoryReaderEvent.ts
13001
-
13002
- class CloseStoryReaderEvent extends BaseStoryReaderEvent {
13003
- get name() {
13004
- return "closeStoryReader";
13005
- }
13006
- toJSON() {
13007
- return Object.assign(Object.assign({}, super.toJSON()), { action: this.payload.action });
13008
- }
13009
- }
13010
-
13011
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/dislikeStoryEvent.ts
13012
-
13013
- class DislikeStoryEvent extends BaseStoryReaderEvent {
13014
- get name() {
13015
- return "dislikeStory";
13016
- }
13017
- toJSON() {
13018
- return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.value });
13019
- }
13020
- }
13021
-
13022
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/favoriteStoryEvent.ts
13023
-
13024
- class FavoriteStoryEvent extends BaseStoryReaderEvent {
13025
- get name() {
13026
- return "favoriteStory";
13027
- }
13028
- toJSON() {
13029
- return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.value });
13030
- }
13031
- }
13032
-
13033
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/likeStoryEvent.ts
13034
-
13035
- class LikeStoryEvent extends BaseStoryReaderEvent {
13036
- get name() {
13037
- return "likeStory";
13038
- }
13039
- toJSON() {
13040
- return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.value });
13041
- }
13042
- }
13043
-
13044
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/shareStoryEvent.ts
13045
-
13046
- class ShareStoryEvent extends BaseStoryReaderEvent {
13047
- get name() {
13048
- return "shareStory";
13049
- }
13050
- }
13051
-
13052
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/shareStoryWithPathEvent.ts
13053
-
13054
- class ShareStoryWithPathEvent extends BaseStoryReaderEvent {
13055
- get name() {
13056
- return "shareStoryWithPath";
13057
- }
13058
- toJSON() {
13059
- return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.url });
13060
- }
13061
- }
13062
-
13063
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/showSlideEvent.ts
13064
-
13065
- class ShowSlideEvent extends BaseStoryReaderEvent {
13066
- get name() {
13067
- return "showSlide";
13068
- }
13069
- }
13070
-
13071
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/showStoryEvent.ts
13072
-
13073
- class ShowStoryEvent extends BaseStoryReaderEvent {
13074
- get name() {
13075
- return "showStory";
13076
- }
13077
- toJSON() {
13078
- const data = super.toJSON();
13079
- data.payload = null;
13080
- return data;
13081
- }
13082
- }
13083
-
13084
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/showStoryFailed.ts
13085
- class ShowStoryFailed {
13086
- constructor(payload) {
13087
- Object.defineProperty(this, "payload", {
13088
- enumerable: true,
13089
- configurable: true,
13090
- writable: true,
13091
- value: payload
13092
- });
13093
- }
13094
- get name() {
13095
- return "showStoryFailed";
13096
- }
13097
- toJSON() {
13098
- return {
13099
- id: this.payload.id,
13100
- title: this.payload.title,
13101
- name: this.payload.name,
13102
- message: this.payload.message
13103
- };
13104
- }
13105
- }
13106
-
13107
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/index.ts
13108
-
13109
-
13110
-
13111
-
13112
-
13113
-
13114
-
13115
-
13116
-
13117
-
13118
-
13119
-
13120
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyReaderNavigationController.ts
13121
- var storyReaderNavigationController_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
13122
- var useValue = arguments.length > 2;
13123
- for (var i = 0; i < initializers.length; i++) {
13124
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
13125
- }
13126
- return useValue ? value : void 0;
13127
- };
13128
- var storyReaderNavigationController_esDecorate = (undefined && undefined.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
13129
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
13130
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
13131
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13132
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13133
- var _, done = false;
13134
- for (var i = decorators.length - 1; i >= 0; i--) {
13135
- var context = {};
13136
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
13137
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
13138
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13139
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13140
- if (kind === "accessor") {
13141
- if (result === void 0) continue;
13142
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
13143
- if (_ = accept(result.get)) descriptor.get = _;
13144
- if (_ = accept(result.set)) descriptor.set = _;
13145
- if (_ = accept(result.init)) initializers.unshift(_);
13146
- }
13147
- else if (_ = accept(result)) {
13148
- if (kind === "field") initializers.unshift(_);
13149
- else descriptor[key] = _;
13150
- }
13151
- }
13152
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
13153
- done = true;
13154
- };
13155
- var storyReaderNavigationController_classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13156
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13157
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
13158
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13159
- };
13160
- var storyReaderNavigationController_classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13161
- if (kind === "m") throw new TypeError("Private method is not writable");
13162
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13163
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
13164
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
13165
- };
13166
-
13167
-
13168
-
13169
- const STORY_INIT_RANGE = 1;
13170
- const ACTIVE_STORY_PRELOAD_PRIORITY = 1000;
13171
- const NON_ACTIVE_STORY_PRELOAD_PRIORITY = 0;
13172
- let StoryReaderNavigationController = (() => {
13173
- var _a, _StoryReaderNavigationController__activeStory_accessor_storage, _StoryReaderNavigationController__currentIndex_accessor_storage, _StoryReaderNavigationController__targetTransitionIndex_accessor_storage;
13174
- let _instanceExtraInitializers = [];
13175
- let __activeStory_decorators;
13176
- let __activeStory_initializers = [];
13177
- let __activeStory_extraInitializers = [];
13178
- let __currentIndex_decorators;
13179
- let __currentIndex_initializers = [];
13180
- let __currentIndex_extraInitializers = [];
13181
- let __targetTransitionIndex_decorators;
13182
- let __targetTransitionIndex_initializers = [];
13183
- let __targetTransitionIndex_extraInitializers = [];
13184
- let _get_reachStart_decorators;
13185
- let _get_reachEnd_decorators;
13186
- let _get_targetTransitionStory_decorators;
13187
- let _nextStory_decorators;
13188
- let _prevStory_decorators;
13189
- let _nextStoryWithAnimation_decorators;
13190
- let _prevStoryWithAnimation_decorators;
13191
- let _navigateStoryWithAnimation_decorators;
13192
- let _handleTransitionEnd_decorators;
13193
- return _a = class StoryReaderNavigationController {
13194
- get _activeStory() { return storyReaderNavigationController_classPrivateFieldGet(this, _StoryReaderNavigationController__activeStory_accessor_storage, "f"); }
13195
- set _activeStory(value) { storyReaderNavigationController_classPrivateFieldSet(this, _StoryReaderNavigationController__activeStory_accessor_storage, value, "f"); }
13196
- get _currentIndex() { return storyReaderNavigationController_classPrivateFieldGet(this, _StoryReaderNavigationController__currentIndex_accessor_storage, "f"); }
13197
- set _currentIndex(value) { storyReaderNavigationController_classPrivateFieldSet(this, _StoryReaderNavigationController__currentIndex_accessor_storage, value, "f"); }
13198
- get _targetTransitionIndex() { return storyReaderNavigationController_classPrivateFieldGet(this, _StoryReaderNavigationController__targetTransitionIndex_accessor_storage, "f"); }
13199
- set _targetTransitionIndex(value) { storyReaderNavigationController_classPrivateFieldSet(this, _StoryReaderNavigationController__targetTransitionIndex_accessor_storage, value, "f"); }
13200
- constructor(storyManager, storyReader, statistics) {
13201
- Object.defineProperty(this, "storyManager", {
13202
- enumerable: true,
13203
- configurable: true,
13204
- writable: true,
13205
- value: (storyReaderNavigationController_runInitializers(this, _instanceExtraInitializers), storyManager)
13206
- });
13207
- Object.defineProperty(this, "storyReader", {
13208
- enumerable: true,
13209
- configurable: true,
13210
- writable: true,
13211
- value: storyReader
13212
- });
13213
- Object.defineProperty(this, "statistics", {
13214
- enumerable: true,
13215
- configurable: true,
13216
- writable: true,
13217
- value: statistics
13218
- });
13219
- _StoryReaderNavigationController__activeStory_accessor_storage.set(this, storyReaderNavigationController_runInitializers(this, __activeStory_initializers, null));
13220
- _StoryReaderNavigationController__currentIndex_accessor_storage.set(this, (storyReaderNavigationController_runInitializers(this, __activeStory_extraInitializers), storyReaderNavigationController_runInitializers(this, __currentIndex_initializers, 0)));
13221
- _StoryReaderNavigationController__targetTransitionIndex_accessor_storage.set(this, (storyReaderNavigationController_runInitializers(this, __currentIndex_extraInitializers), storyReaderNavigationController_runInitializers(this, __targetTransitionIndex_initializers, -1)));
13222
- Object.defineProperty(this, "animatedNavigationController", {
13223
- enumerable: true,
13224
- configurable: true,
13225
- writable: true,
13226
- value: (storyReaderNavigationController_runInitializers(this, __targetTransitionIndex_extraInitializers), null)
13227
- });
13228
- Object.defineProperty(this, "currentStoryDisplayStrategy", {
13229
- enumerable: true,
13230
- configurable: true,
13231
- writable: true,
13232
- value: null
13233
- });
13234
- Object.defineProperty(this, "_activeStoryStartTime", {
13235
- enumerable: true,
13236
- configurable: true,
13237
- writable: true,
13238
- value: 0
13239
- });
13240
- }
13241
- get reachStart() {
13242
- return this._currentIndex === 0;
13243
- }
13244
- get reachEnd() {
13245
- return this._currentIndex === this.storyReader.stories.length - 1;
13246
- }
13247
- get targetTransitionStory() {
13248
- return this.storyReader.stories[this._targetTransitionIndex];
13249
- }
13250
- get targetTransitionIndex() {
13251
- return this._targetTransitionIndex;
13252
- }
13253
- get activeStory() {
13254
- return this._activeStory;
13255
- }
13256
- get currentIndex() {
13257
- return this._currentIndex;
13258
- }
13259
- get activeStoryDuration() {
13260
- return Date.now() - this._activeStoryStartTime;
13261
- }
13262
- setAnimatedNavigationController(animatedNavigationController) {
13263
- this.animatedNavigationController = animatedNavigationController;
13264
- }
13265
- setCurrentStoryDisplayStrategy(currentStoryDisplayStrategy) {
13266
- this.currentStoryDisplayStrategy = currentStoryDisplayStrategy;
13267
- }
13268
- nextStory() {
13269
- if (this.reachEnd)
13270
- return;
13271
- this.setActiveStoryByIndex(this._currentIndex + 1);
13272
- }
13273
- prevStory() {
13274
- if (this.reachStart)
13275
- return;
13276
- this.setActiveStoryByIndex(this._currentIndex - 1);
13277
- }
13278
- nextStoryWithAnimation(action) {
13279
- if (this.storyReader.reachEnd)
13280
- this.handleStoryReaderReachEnd(action);
13281
- else
13282
- this.navigateStoryWithAnimation(this._currentIndex + 1, action);
13283
- }
13284
- prevStoryWithAnimation(action) {
13285
- if (!this.reachStart)
13286
- this.navigateStoryWithAnimation(this.currentIndex - 1, action);
13287
- }
13288
- destroy() {
13289
- this._activeStory = null;
13290
- }
13291
- setActiveStoryById(storyId) {
13292
- const stories = this.storyReader.stories;
13293
- const index = stories.findIndex(story => story.id === storyId);
13294
- if (index === -1)
13295
- throw new Error(`[IAS]: No story found with ID ${storyId}`);
13296
- this.initStoriesWithinRange(index);
13297
- return this.setActiveStoryByIndex(index);
13298
- }
13299
- async navigateStoryWithAnimation(index, action = "lastSlideClick") {
13300
- if (!this.animatedNavigationController ||
13301
- this.animatedNavigationController.animating ||
13302
- this._targetTransitionIndex !== -1)
13303
- return;
13304
- index = this.limitIndex(index);
13305
- this._targetTransitionIndex = index;
13306
- this.currentStoryDisplayStrategy.handleNextStoryByIndex(index);
13307
- this.initStoriesWithinRange(index);
13308
- await this.animatedNavigationController.transitionByIndex(index, this.currentIndex);
13309
- await this.handleTransitionEnd(index, action);
13310
- }
13311
- handleStoryReaderReachEnd(action) {
13312
- var _b;
13313
- if (action !== CloseStoryReaderAction.CloseByTimer) {
13314
- this.storyReader.close(CloseStoryReaderAction.CloseByLastSlideClick);
13315
- }
13316
- else if ((_b = this.animatedNavigationController) === null || _b === void 0 ? void 0 : _b.options.closeOnLastSlideByTimer) {
13317
- this.storyReader.close(CloseStoryReaderAction.CloseByTimer);
13318
- }
13319
- }
13320
- async handleTransitionEnd(index, navigationAction) {
13321
- if (this.activeStory) {
13322
- const event = new CloseStoryEvent(this.activeStory, {
13323
- action: navigationAction
13324
- });
13325
- this.storyManager.emit(event.name, event.toJSON());
13326
- }
13327
- await this.setActiveStoryByIndex(index);
13328
- this._targetTransitionIndex = -1;
13329
- }
13330
- async setActiveStoryByIndex(index) {
13331
- const prevIndex = this._currentIndex;
13332
- const prevStory = this._activeStory;
13333
- const newActiveStory = this.storyReader.stories[index];
13334
- if (!newActiveStory)
13335
- return;
13336
- await this.updateActiveStory(index, prevStory, newActiveStory);
13337
- this.statistics.emitTransitionEvents(prevIndex, index, prevStory, newActiveStory, this.activeStoryDuration);
13338
- this.handleActiveStoryError(this._activeStory);
13339
- newActiveStory.markAsOpened();
13340
- return newActiveStory;
13341
- }
13342
- async updateActiveStory(index, prevStory, activeStory) {
13343
- this._currentIndex = index;
13344
- this.runNextStory(prevStory, activeStory);
13345
- this._activeStoryStartTime = Date.now();
13346
- this._activeStory = activeStory;
13347
- return activeStory;
13348
- }
13349
- async runNextStory(prevStory, story) {
13350
- try {
13351
- await (prevStory === null || prevStory === void 0 ? void 0 : prevStory.stop());
13352
- await this.preloadActiveStory(story);
13353
- await story.init();
13354
- await story.start();
13355
- }
13356
- catch (error) {
13357
- console.error(error);
13358
- }
13359
- }
13360
- async initStoriesWithinRange(currentIndex) {
13361
- const stories = this.storyReader.stories;
13362
- const start = Math.max(currentIndex - STORY_INIT_RANGE, 0);
13363
- const end = Math.min(currentIndex + STORY_INIT_RANGE, stories.length - 1);
13364
- const storiesToInit = [];
13365
- for (let i = start; i <= end; i++) {
13366
- if (i !== currentIndex)
13367
- storiesToInit.push(stories[i]);
13368
- }
13369
- await this.preloadSiblingStories(storiesToInit);
13370
- return Promise.allSettled(storiesToInit.map(story => story.init()));
13371
- }
13372
- handleActiveStoryError(story) {
13373
- if (!(story === null || story === void 0 ? void 0 : story.error))
13374
- return;
13375
- const event = new ShowStoryFailed({
13376
- id: story.id,
13377
- title: story.title,
13378
- name: story.error.name,
13379
- message: story.error.message
13380
- });
13381
- this.storyManager.emit(event.name, event.toJSON());
13382
- }
13383
- limitIndex(index) {
13384
- return Math.max(0, Math.min(this.storyReader.stories.length - 1, index));
13385
- }
13386
- async preloadActiveStory(story) {
13387
- const cacheConfig = this.storyManager.config.cache;
13388
- if (!cacheConfig)
13389
- return;
13390
- if (cacheConfig.prefetch) {
13391
- await story.preloadSlides(0, story.slidesCount, ACTIVE_STORY_PRELOAD_PRIORITY);
13392
- }
13393
- else {
13394
- await story.preloadActiveSlide(ACTIVE_STORY_PRELOAD_PRIORITY);
13395
- }
13396
- }
13397
- async preloadSiblingStories(stories) {
13398
- const cacheConfig = this.storyManager.config.cache;
13399
- if (!cacheConfig)
13400
- return;
13401
- if (cacheConfig.prefetch) {
13402
- await Promise.all(stories.map(story => story.preloadSlides(0, 2, NON_ACTIVE_STORY_PRELOAD_PRIORITY)));
13403
- }
13404
- else {
13405
- await Promise.all(stories.map(story => story.preloadActiveSlide(NON_ACTIVE_STORY_PRELOAD_PRIORITY)));
13406
- }
13407
- }
13408
- },
13409
- _StoryReaderNavigationController__activeStory_accessor_storage = new WeakMap(),
13410
- _StoryReaderNavigationController__currentIndex_accessor_storage = new WeakMap(),
13411
- _StoryReaderNavigationController__targetTransitionIndex_accessor_storage = new WeakMap(),
13412
- (() => {
13413
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
13414
- __activeStory_decorators = [external_mobx_namespaceObject.observable];
13415
- __currentIndex_decorators = [external_mobx_namespaceObject.observable];
13416
- __targetTransitionIndex_decorators = [external_mobx_namespaceObject.observable];
13417
- _get_reachStart_decorators = [external_mobx_namespaceObject.computed];
13418
- _get_reachEnd_decorators = [external_mobx_namespaceObject.computed];
13419
- _get_targetTransitionStory_decorators = [external_mobx_namespaceObject.computed];
13420
- _nextStory_decorators = [external_mobx_namespaceObject.action];
13421
- _prevStory_decorators = [external_mobx_namespaceObject.action];
13422
- _nextStoryWithAnimation_decorators = [external_mobx_namespaceObject.action];
13423
- _prevStoryWithAnimation_decorators = [external_mobx_namespaceObject.action];
13424
- _navigateStoryWithAnimation_decorators = [external_mobx_namespaceObject.action];
13425
- _handleTransitionEnd_decorators = [external_mobx_namespaceObject.action];
13426
- storyReaderNavigationController_esDecorate(_a, null, __activeStory_decorators, { kind: "accessor", name: "_activeStory", static: false, private: false, access: { has: obj => "_activeStory" in obj, get: obj => obj._activeStory, set: (obj, value) => { obj._activeStory = value; } }, metadata: _metadata }, __activeStory_initializers, __activeStory_extraInitializers);
13427
- storyReaderNavigationController_esDecorate(_a, null, __currentIndex_decorators, { kind: "accessor", name: "_currentIndex", static: false, private: false, access: { has: obj => "_currentIndex" in obj, get: obj => obj._currentIndex, set: (obj, value) => { obj._currentIndex = value; } }, metadata: _metadata }, __currentIndex_initializers, __currentIndex_extraInitializers);
13428
- storyReaderNavigationController_esDecorate(_a, null, __targetTransitionIndex_decorators, { kind: "accessor", name: "_targetTransitionIndex", static: false, private: false, access: { has: obj => "_targetTransitionIndex" in obj, get: obj => obj._targetTransitionIndex, set: (obj, value) => { obj._targetTransitionIndex = value; } }, metadata: _metadata }, __targetTransitionIndex_initializers, __targetTransitionIndex_extraInitializers);
13429
- storyReaderNavigationController_esDecorate(_a, null, _get_reachStart_decorators, { kind: "getter", name: "reachStart", static: false, private: false, access: { has: obj => "reachStart" in obj, get: obj => obj.reachStart }, metadata: _metadata }, null, _instanceExtraInitializers);
13430
- storyReaderNavigationController_esDecorate(_a, null, _get_reachEnd_decorators, { kind: "getter", name: "reachEnd", static: false, private: false, access: { has: obj => "reachEnd" in obj, get: obj => obj.reachEnd }, metadata: _metadata }, null, _instanceExtraInitializers);
13431
- storyReaderNavigationController_esDecorate(_a, null, _get_targetTransitionStory_decorators, { kind: "getter", name: "targetTransitionStory", static: false, private: false, access: { has: obj => "targetTransitionStory" in obj, get: obj => obj.targetTransitionStory }, metadata: _metadata }, null, _instanceExtraInitializers);
13432
- storyReaderNavigationController_esDecorate(_a, null, _nextStory_decorators, { kind: "method", name: "nextStory", static: false, private: false, access: { has: obj => "nextStory" in obj, get: obj => obj.nextStory }, metadata: _metadata }, null, _instanceExtraInitializers);
13433
- storyReaderNavigationController_esDecorate(_a, null, _prevStory_decorators, { kind: "method", name: "prevStory", static: false, private: false, access: { has: obj => "prevStory" in obj, get: obj => obj.prevStory }, metadata: _metadata }, null, _instanceExtraInitializers);
13434
- storyReaderNavigationController_esDecorate(_a, null, _nextStoryWithAnimation_decorators, { kind: "method", name: "nextStoryWithAnimation", static: false, private: false, access: { has: obj => "nextStoryWithAnimation" in obj, get: obj => obj.nextStoryWithAnimation }, metadata: _metadata }, null, _instanceExtraInitializers);
13435
- storyReaderNavigationController_esDecorate(_a, null, _prevStoryWithAnimation_decorators, { kind: "method", name: "prevStoryWithAnimation", static: false, private: false, access: { has: obj => "prevStoryWithAnimation" in obj, get: obj => obj.prevStoryWithAnimation }, metadata: _metadata }, null, _instanceExtraInitializers);
13436
- storyReaderNavigationController_esDecorate(_a, null, _navigateStoryWithAnimation_decorators, { kind: "method", name: "navigateStoryWithAnimation", static: false, private: false, access: { has: obj => "navigateStoryWithAnimation" in obj, get: obj => obj.navigateStoryWithAnimation }, metadata: _metadata }, null, _instanceExtraInitializers);
13437
- storyReaderNavigationController_esDecorate(_a, null, _handleTransitionEnd_decorators, { kind: "method", name: "handleTransitionEnd", static: false, private: false, access: { has: obj => "handleTransitionEnd" in obj, get: obj => obj.handleTransitionEnd }, metadata: _metadata }, null, _instanceExtraInitializers);
13438
- if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
13439
- })(),
13440
- _a;
13441
- })();
13442
-
13443
-
13444
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/showOnboardingStoriesStrategy.ts
13445
-
13446
- class ShowOnboardingStoriesStrategy {
13447
- constructor(showMultipleStoriesStrategy, storyManager) {
13448
- Object.defineProperty(this, "showMultipleStoriesStrategy", {
13449
- enumerable: true,
13450
- configurable: true,
13451
- writable: true,
13452
- value: showMultipleStoriesStrategy
13453
- });
13454
- Object.defineProperty(this, "storyManager", {
13455
- enumerable: true,
13456
- configurable: true,
13457
- writable: true,
13458
- value: storyManager
13459
- });
13460
- Object.defineProperty(this, "_feed", {
13461
- enumerable: true,
13462
- configurable: true,
13463
- writable: true,
13464
- value: null
13465
- });
13466
- }
13467
- get feed() {
13468
- return this._feed;
13469
- }
13470
- async show(payload) {
13471
- var _a, _b;
13472
- const storyFeedStore = this.storyManager.rootStore.onboardingFeedStore;
13473
- this.throwIfAborted(payload.signal);
13474
- const onboardingFeed = await storyFeedStore.fetchOnboardingFeed({
13475
- feedSlug: payload.feedSlug,
13476
- tags: (_a = payload.customTags) !== null && _a !== void 0 ? _a : [],
13477
- limit: (_b = payload.limit) !== null && _b !== void 0 ? _b : undefined
12938
+ }
12939
+ get feed() {
12940
+ return this._feed;
12941
+ }
12942
+ async show(payload) {
12943
+ var _a, _b;
12944
+ const storyFeedStore = this.storyManager.rootStore.onboardingFeedStore;
12945
+ this.throwIfAborted(payload.signal);
12946
+ const onboardingFeed = await storyFeedStore.fetchOnboardingFeed({
12947
+ feedSlug: payload.feedSlug,
12948
+ tags: (_a = payload.customTags) !== null && _a !== void 0 ? _a : [],
12949
+ limit: (_b = payload.limit) !== null && _b !== void 0 ? _b : undefined
13478
12950
  });
13479
12951
  this.throwIfAborted(payload.signal);
13480
12952
  this._feed = onboardingFeed;
@@ -13753,27 +13225,255 @@ class StoryDisplayStrategyFactory {
13753
13225
  enumerable: true,
13754
13226
  configurable: true,
13755
13227
  writable: true,
13756
- value: storyReaderViewModel
13228
+ value: storyReaderViewModel
13229
+ });
13230
+ }
13231
+ createShowStory() {
13232
+ return new ShowStoryStrategy(this.storyManager, this.storyReaderViewModel);
13233
+ }
13234
+ createShowStoryOnce() {
13235
+ return new ShowStoryOnceStrategy(this.storyManager, this.storyReaderViewModel);
13236
+ }
13237
+ createShowStoryFromSharePage() {
13238
+ return new ShowStoryFromSharePageStrategy(new ShowStoryStrategy(this.storyManager, this.storyReaderViewModel));
13239
+ }
13240
+ createShowOnboardingStories() {
13241
+ return new ShowOnboardingStoriesStrategy(new ShowMultipleStoriesStrategy(this.storyManager, this.storyReaderViewModel), this.storyManager);
13242
+ }
13243
+ createShowMultipleStories() {
13244
+ return new ShowMultipleStoriesStrategy(this.storyManager, this.storyReaderViewModel);
13245
+ }
13246
+ }
13247
+
13248
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/index.ts
13249
+
13250
+
13251
+
13252
+
13253
+
13254
+
13255
+
13256
+
13257
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/baseStoryReaderEvent.ts
13258
+
13259
+
13260
+ class BaseStoryReaderEvent {
13261
+ constructor(story, payload = {}) {
13262
+ var _a, _b, _c, _d;
13263
+ Object.defineProperty(this, "story", {
13264
+ enumerable: true,
13265
+ configurable: true,
13266
+ writable: true,
13267
+ value: story
13268
+ });
13269
+ Object.defineProperty(this, "payload", {
13270
+ enumerable: true,
13271
+ configurable: true,
13272
+ writable: true,
13273
+ value: payload
13274
+ });
13275
+ Object.defineProperty(this, "title", {
13276
+ enumerable: true,
13277
+ configurable: true,
13278
+ writable: true,
13279
+ value: null
13280
+ });
13281
+ Object.defineProperty(this, "tags", {
13282
+ enumerable: true,
13283
+ configurable: true,
13284
+ writable: true,
13285
+ value: []
13286
+ });
13287
+ Object.defineProperty(this, "slidesCount", {
13288
+ enumerable: true,
13289
+ configurable: true,
13290
+ writable: true,
13291
+ value: null
13292
+ });
13293
+ Object.defineProperty(this, "feedSlug", {
13294
+ enumerable: true,
13295
+ configurable: true,
13296
+ writable: true,
13297
+ value: null
13298
+ });
13299
+ Object.defineProperty(this, "filter", {
13300
+ enumerable: true,
13301
+ configurable: true,
13302
+ writable: true,
13303
+ value: null
13304
+ });
13305
+ Object.defineProperty(this, "actionSource", {
13306
+ enumerable: true,
13307
+ configurable: true,
13308
+ writable: true,
13309
+ value: StoryActionSource.list
13310
+ });
13311
+ Object.defineProperty(this, "ugcPayload", {
13312
+ enumerable: true,
13313
+ configurable: true,
13314
+ writable: true,
13315
+ value: null
13316
+ });
13317
+ Object.defineProperty(this, "slideEventPayload", {
13318
+ enumerable: true,
13319
+ configurable: true,
13320
+ writable: true,
13321
+ value: null
13322
+ });
13323
+ const feed = (_a = this.story.displayStrategy) === null || _a === void 0 ? void 0 : _a.feed;
13324
+ const feedType = feed === null || feed === void 0 ? void 0 : feed.type;
13325
+ const feedSlug = (_b = feed === null || feed === void 0 ? void 0 : feed.slug) !== null && _b !== void 0 ? _b : null;
13326
+ const filter = feed instanceof UgcStoryFeed ? feed.filter : null;
13327
+ this.title = this.story.statTitle;
13328
+ this.slidesCount = this.story.slidesCount;
13329
+ this.ugcPayload = feedType === StoryFeedType.UGC ? this.story.ugcPayload : null;
13330
+ this.feedSlug = feedType === StoryFeedType.DEFAULT ? feedSlug : null;
13331
+ this.filter = filter;
13332
+ this.actionSource = feedType != null ? this.getStorySourceByFeedType(feedType) : StoryActionSource.direct;
13333
+ this.slideEventPayload = (_d = (_c = story.activeSlide.eventPayload) === null || _c === void 0 ? void 0 : _c.payload) !== null && _d !== void 0 ? _d : null;
13334
+ }
13335
+ toJSON() {
13336
+ return Object.assign({ id: this.story.id, index: this.story.activeSlideIndex, title: this.title, tags: this.tags, slidesCount: this.slidesCount, feed: this.feedSlug, filter: this.filter, source: this.actionSource, ugcPayload: this.ugcPayload, payload: this.slideEventPayload }, this.payload);
13337
+ }
13338
+ getStorySourceByFeedType(feedType) {
13339
+ switch (feedType) {
13340
+ case StoryFeedType.DEFAULT:
13341
+ return StoryActionSource.list;
13342
+ case StoryFeedType.UGC:
13343
+ return StoryActionSource.list;
13344
+ case StoryFeedType.FAVORITE:
13345
+ return StoryActionSource.favorite;
13346
+ case StoryFeedType.ONBOARDING:
13347
+ return StoryActionSource.onboarding;
13348
+ default:
13349
+ return StoryActionSource.list;
13350
+ }
13351
+ }
13352
+ }
13353
+
13354
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/closeStoryEvent.ts
13355
+
13356
+ class CloseStoryEvent extends BaseStoryReaderEvent {
13357
+ get name() {
13358
+ return "closeStory";
13359
+ }
13360
+ toJSON() {
13361
+ return Object.assign(Object.assign({}, super.toJSON()), { action: this.payload.action });
13362
+ }
13363
+ }
13364
+
13365
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/closeStoryReaderEvent.ts
13366
+
13367
+ class CloseStoryReaderEvent extends BaseStoryReaderEvent {
13368
+ get name() {
13369
+ return "closeStoryReader";
13370
+ }
13371
+ toJSON() {
13372
+ return Object.assign(Object.assign({}, super.toJSON()), { action: this.payload.action });
13373
+ }
13374
+ }
13375
+
13376
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/dislikeStoryEvent.ts
13377
+
13378
+ class DislikeStoryEvent extends BaseStoryReaderEvent {
13379
+ get name() {
13380
+ return "dislikeStory";
13381
+ }
13382
+ toJSON() {
13383
+ return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.value });
13384
+ }
13385
+ }
13386
+
13387
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/favoriteStoryEvent.ts
13388
+
13389
+ class FavoriteStoryEvent extends BaseStoryReaderEvent {
13390
+ get name() {
13391
+ return "favoriteStory";
13392
+ }
13393
+ toJSON() {
13394
+ return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.value });
13395
+ }
13396
+ }
13397
+
13398
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/likeStoryEvent.ts
13399
+
13400
+ class LikeStoryEvent extends BaseStoryReaderEvent {
13401
+ get name() {
13402
+ return "likeStory";
13403
+ }
13404
+ toJSON() {
13405
+ return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.value });
13406
+ }
13407
+ }
13408
+
13409
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/shareStoryEvent.ts
13410
+
13411
+ class ShareStoryEvent extends BaseStoryReaderEvent {
13412
+ get name() {
13413
+ return "shareStory";
13414
+ }
13415
+ }
13416
+
13417
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/shareStoryWithPathEvent.ts
13418
+
13419
+ class ShareStoryWithPathEvent extends BaseStoryReaderEvent {
13420
+ get name() {
13421
+ return "shareStoryWithPath";
13422
+ }
13423
+ toJSON() {
13424
+ return Object.assign(Object.assign({}, super.toJSON()), { value: this.payload.url });
13425
+ }
13426
+ }
13427
+
13428
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/showSlideEvent.ts
13429
+
13430
+ class ShowSlideEvent extends BaseStoryReaderEvent {
13431
+ get name() {
13432
+ return "showSlide";
13433
+ }
13434
+ }
13435
+
13436
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/showStoryEvent.ts
13437
+
13438
+ class ShowStoryEvent extends BaseStoryReaderEvent {
13439
+ get name() {
13440
+ return "showStory";
13441
+ }
13442
+ toJSON() {
13443
+ const data = super.toJSON();
13444
+ data.payload = null;
13445
+ return data;
13446
+ }
13447
+ }
13448
+
13449
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/showStoryFailed.ts
13450
+ class ShowStoryFailed {
13451
+ constructor(payload) {
13452
+ Object.defineProperty(this, "payload", {
13453
+ enumerable: true,
13454
+ configurable: true,
13455
+ writable: true,
13456
+ value: payload
13757
13457
  });
13758
13458
  }
13759
- createShowStory() {
13760
- return new ShowStoryStrategy(this.storyManager, this.storyReaderViewModel);
13761
- }
13762
- createShowStoryOnce() {
13763
- return new ShowStoryOnceStrategy(this.storyManager, this.storyReaderViewModel);
13764
- }
13765
- createShowStoryFromSharePage() {
13766
- return new ShowStoryFromSharePageStrategy(new ShowStoryStrategy(this.storyManager, this.storyReaderViewModel));
13767
- }
13768
- createShowOnboardingStories() {
13769
- return new ShowOnboardingStoriesStrategy(new ShowMultipleStoriesStrategy(this.storyManager, this.storyReaderViewModel), this.storyManager);
13459
+ get name() {
13460
+ return "showStoryFailed";
13770
13461
  }
13771
- createShowMultipleStories() {
13772
- return new ShowMultipleStoriesStrategy(this.storyManager, this.storyReaderViewModel);
13462
+ toJSON() {
13463
+ return {
13464
+ id: this.payload.id,
13465
+ title: this.payload.title,
13466
+ name: this.payload.name,
13467
+ message: this.payload.message
13468
+ };
13773
13469
  }
13774
13470
  }
13775
13471
 
13776
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/index.ts
13472
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/events/index.ts
13473
+
13474
+
13475
+
13476
+
13777
13477
 
13778
13478
 
13779
13479
 
@@ -14452,7 +14152,6 @@ var storyReaderViewModel_classPrivateFieldSet = (undefined && undefined.__classP
14452
14152
 
14453
14153
 
14454
14154
 
14455
-
14456
14155
  var StoryReaderEvent;
14457
14156
  (function (StoryReaderEvent) {
14458
14157
  StoryReaderEvent["Close"] = "closeStoryReader";
@@ -14468,7 +14167,7 @@ var CloseStoryReaderAction;
14468
14167
  CloseStoryReaderAction["AppClose"] = "app-close";
14469
14168
  })(CloseStoryReaderAction || (CloseStoryReaderAction = {}));
14470
14169
  let StoryReaderViewModel = (() => {
14471
- var _a, _StoryReaderViewModel__muted_accessor_storage, _StoryReaderViewModel__closeGestureInAction_accessor_storage, _StoryReaderViewModel__stories_accessor_storage;
14170
+ var _a, _StoryReaderViewModel__muted_accessor_storage, _StoryReaderViewModel__closeGestureInAction_accessor_storage, _StoryReaderViewModel__stories_accessor_storage, _StoryReaderViewModel__activeStory_accessor_storage, _StoryReaderViewModel__activeStoryIndex_accessor_storage, _StoryReaderViewModel__targetTransitionIndex_accessor_storage;
14472
14171
  let _classSuper = ViewModel;
14473
14172
  let _instanceExtraInitializers = [];
14474
14173
  let __muted_decorators;
@@ -14480,6 +14179,16 @@ let StoryReaderViewModel = (() => {
14480
14179
  let __stories_decorators;
14481
14180
  let __stories_initializers = [];
14482
14181
  let __stories_extraInitializers = [];
14182
+ let __activeStory_decorators;
14183
+ let __activeStory_initializers = [];
14184
+ let __activeStory_extraInitializers = [];
14185
+ let __activeStoryIndex_decorators;
14186
+ let __activeStoryIndex_initializers = [];
14187
+ let __activeStoryIndex_extraInitializers = [];
14188
+ let __targetTransitionIndex_decorators;
14189
+ let __targetTransitionIndex_initializers = [];
14190
+ let __targetTransitionIndex_extraInitializers = [];
14191
+ let _get_targetTransitionStory_decorators;
14483
14192
  let _get_isOpened_decorators;
14484
14193
  let _get_reachStart_decorators;
14485
14194
  let _get_reachEnd_decorators;
@@ -14501,6 +14210,8 @@ let StoryReaderViewModel = (() => {
14501
14210
  let _unmute_decorators;
14502
14211
  let _enableCloseGesture_decorators;
14503
14212
  let _disableCloseGesture_decorators;
14213
+ let _navigateStoryWithAnimation_decorators;
14214
+ let _handleTransitionEnd_decorators;
14504
14215
  return _a = class StoryReaderViewModel extends _classSuper {
14505
14216
  get _muted() { return storyReaderViewModel_classPrivateFieldGet(this, _StoryReaderViewModel__muted_accessor_storage, "f"); }
14506
14217
  set _muted(value) { storyReaderViewModel_classPrivateFieldSet(this, _StoryReaderViewModel__muted_accessor_storage, value, "f"); }
@@ -14508,6 +14219,12 @@ let StoryReaderViewModel = (() => {
14508
14219
  set _closeGestureInAction(value) { storyReaderViewModel_classPrivateFieldSet(this, _StoryReaderViewModel__closeGestureInAction_accessor_storage, value, "f"); }
14509
14220
  get _stories() { return storyReaderViewModel_classPrivateFieldGet(this, _StoryReaderViewModel__stories_accessor_storage, "f"); }
14510
14221
  set _stories(value) { storyReaderViewModel_classPrivateFieldSet(this, _StoryReaderViewModel__stories_accessor_storage, value, "f"); }
14222
+ get _activeStory() { return storyReaderViewModel_classPrivateFieldGet(this, _StoryReaderViewModel__activeStory_accessor_storage, "f"); }
14223
+ set _activeStory(value) { storyReaderViewModel_classPrivateFieldSet(this, _StoryReaderViewModel__activeStory_accessor_storage, value, "f"); }
14224
+ get _activeStoryIndex() { return storyReaderViewModel_classPrivateFieldGet(this, _StoryReaderViewModel__activeStoryIndex_accessor_storage, "f"); }
14225
+ set _activeStoryIndex(value) { storyReaderViewModel_classPrivateFieldSet(this, _StoryReaderViewModel__activeStoryIndex_accessor_storage, value, "f"); }
14226
+ get _targetTransitionIndex() { return storyReaderViewModel_classPrivateFieldGet(this, _StoryReaderViewModel__targetTransitionIndex_accessor_storage, "f"); }
14227
+ set _targetTransitionIndex(value) { storyReaderViewModel_classPrivateFieldSet(this, _StoryReaderViewModel__targetTransitionIndex_accessor_storage, value, "f"); }
14511
14228
  constructor(storyManager, storyReaderStatisticV1Service, storyReaderStatisticV2Service, storyFeedStatisticV1Service) {
14512
14229
  super();
14513
14230
  Object.defineProperty(this, "storyManager", {
@@ -14567,11 +14284,20 @@ let StoryReaderViewModel = (() => {
14567
14284
  writable: true,
14568
14285
  value: new TouchController({ touchStartTimeout: 200 })
14569
14286
  });
14570
- Object.defineProperty(this, "navigationController", {
14287
+ _StoryReaderViewModel__activeStory_accessor_storage.set(this, storyReaderViewModel_runInitializers(this, __activeStory_initializers, null));
14288
+ _StoryReaderViewModel__activeStoryIndex_accessor_storage.set(this, (storyReaderViewModel_runInitializers(this, __activeStory_extraInitializers), storyReaderViewModel_runInitializers(this, __activeStoryIndex_initializers, 0)));
14289
+ _StoryReaderViewModel__targetTransitionIndex_accessor_storage.set(this, (storyReaderViewModel_runInitializers(this, __activeStoryIndex_extraInitializers), storyReaderViewModel_runInitializers(this, __targetTransitionIndex_initializers, -1)));
14290
+ Object.defineProperty(this, "animatedNavigationController", {
14571
14291
  enumerable: true,
14572
14292
  configurable: true,
14573
14293
  writable: true,
14574
- value: void 0
14294
+ value: (storyReaderViewModel_runInitializers(this, __targetTransitionIndex_extraInitializers), null)
14295
+ });
14296
+ Object.defineProperty(this, "_activeStoryStartTime", {
14297
+ enumerable: true,
14298
+ configurable: true,
14299
+ writable: true,
14300
+ value: 0
14575
14301
  });
14576
14302
  Object.defineProperty(this, "useModernLayout", {
14577
14303
  enumerable: true,
@@ -14585,17 +14311,23 @@ let StoryReaderViewModel = (() => {
14585
14311
  writable: true,
14586
14312
  value: null
14587
14313
  });
14314
+ Object.defineProperty(this, "statisticsController", {
14315
+ enumerable: true,
14316
+ configurable: true,
14317
+ writable: true,
14318
+ value: void 0
14319
+ });
14588
14320
  this.handleWindowUnload = this.handleWindowUnload.bind(this);
14589
14321
  this.handleKeydown = this.handleKeydown.bind(this);
14590
14322
  window.addEventListener("beforeunload", this.handleWindowUnload);
14591
14323
  this.storyDisplayStrategyFactory = new StoryDisplayStrategyFactory(storyManager, this);
14592
- this.navigationController = new StoryReaderNavigationController(this.storyManager, this, new StoryReaderStatisticsController(this, this.storyManager, this.storyReaderStatisticV1Service, this.storyFeedStatisticV1Service, this.storyReaderStatisticV2Service));
14593
- }
14594
- get targetTransitionIndex() {
14595
- return this.navigationController.targetTransitionIndex;
14324
+ this.statisticsController = new StoryReaderStatisticsController(this, this.storyManager, this.storyReaderStatisticV1Service, this.storyFeedStatisticV1Service, this.storyReaderStatisticV2Service);
14596
14325
  }
14597
14326
  get targetTransitionStory() {
14598
- return this.navigationController.targetTransitionStory;
14327
+ return this.stories[this._targetTransitionIndex];
14328
+ }
14329
+ get targetTransitionIndex() {
14330
+ return this._targetTransitionIndex;
14599
14331
  }
14600
14332
  get touchController() {
14601
14333
  return this._touchController;
@@ -14617,22 +14349,26 @@ let StoryReaderViewModel = (() => {
14617
14349
  return this._stories;
14618
14350
  }
14619
14351
  get activeStory() {
14620
- return this.navigationController.activeStory;
14352
+ return this._activeStory;
14353
+ }
14354
+ get activeStoryDuration() {
14355
+ return Date.now() - this._activeStoryStartTime;
14621
14356
  }
14622
14357
  get dir() {
14623
14358
  return this.storyManager.config.dir;
14624
14359
  }
14625
14360
  get isOpened() {
14626
- return Boolean(this.navigationController.activeStory);
14361
+ return Boolean(this.activeStory);
14627
14362
  }
14628
14363
  get activeStoryIndex() {
14629
- return this.navigationController.currentIndex;
14364
+ return this._activeStoryIndex;
14630
14365
  }
14631
14366
  get reachStart() {
14632
- return this.navigationController.reachStart || this._stories[0] === this.targetTransitionStory;
14367
+ return this._activeStoryIndex === 0 || this._stories[0] === this.targetTransitionStory;
14633
14368
  }
14634
14369
  get reachEnd() {
14635
- return (this.navigationController.reachEnd || this._stories[this._stories.length - 1] === this.targetTransitionStory);
14370
+ return (this._activeStoryIndex === this.stories.length - 1 ||
14371
+ this._stories[this._stories.length - 1] === this.targetTransitionStory);
14636
14372
  }
14637
14373
  open(payload) {
14638
14374
  var _b, _c;
@@ -14642,8 +14378,7 @@ let StoryReaderViewModel = (() => {
14642
14378
  this.cacheManager = new CacheManager(this.storyManager.config.cache);
14643
14379
  this.windowReferer = payload.windowReferer;
14644
14380
  this.setStories(payload.stories);
14645
- const activeStory = this.navigationController.setActiveStoryById(payload.id);
14646
- this.navigationController.setCurrentStoryDisplayStrategy(this._currentStoryDisplayStrategy);
14381
+ this.setActiveStoryById(payload.id);
14647
14382
  this.storyReaderStatisticV1Service.init({ feedSlug: (_c = (_b = this._currentStoryDisplayStrategy) === null || _b === void 0 ? void 0 : _b.feed) === null || _c === void 0 ? void 0 : _c.slug });
14648
14383
  this._touchController.init(document.body);
14649
14384
  this.setScrollBar(payload.windowReferer);
@@ -14670,7 +14405,7 @@ let StoryReaderViewModel = (() => {
14670
14405
  this.storyReaderStatisticV2Service.sendCloseReaderEvent({
14671
14406
  action,
14672
14407
  totalSlides: activeStory.slidesCount,
14673
- durationMs: this.navigationController.activeStoryDuration,
14408
+ durationMs: this.activeStoryDuration,
14674
14409
  storyId: activeStory.id,
14675
14410
  activeSlideIndex: activeStory.activeSlideIndex,
14676
14411
  feedSlug: (_b = this.feed) === null || _b === void 0 ? void 0 : _b.slug
@@ -14691,7 +14426,7 @@ let StoryReaderViewModel = (() => {
14691
14426
  this.clearStoryViewModels();
14692
14427
  this._touchController.destroy();
14693
14428
  document.removeEventListener("keydown", this.handleKeydown);
14694
- this.navigationController.destroy();
14429
+ this._activeStory = null;
14695
14430
  (_b = this.cacheManager) === null || _b === void 0 ? void 0 : _b.destroy();
14696
14431
  }
14697
14432
  canBeClosed() {
@@ -14739,24 +14474,32 @@ let StoryReaderViewModel = (() => {
14739
14474
  });
14740
14475
  }
14741
14476
  nextStory() {
14742
- return this.navigationController.nextStory();
14477
+ if (this.reachEnd)
14478
+ return;
14479
+ this.setActiveStoryByIndex(this._activeStoryIndex + 1);
14743
14480
  }
14744
14481
  prevStory() {
14745
- return this.navigationController.prevStory();
14482
+ if (this.reachStart)
14483
+ return;
14484
+ this.setActiveStoryByIndex(this._activeStoryIndex - 1);
14746
14485
  }
14747
14486
  nextStoryWithAnimation(action) {
14748
- return this.navigationController.nextStoryWithAnimation(action);
14487
+ if (this.reachEnd)
14488
+ this.handleStoryReaderReachEnd(action);
14489
+ else
14490
+ this.navigateStoryWithAnimation(this._activeStoryIndex + 1, action);
14749
14491
  }
14750
14492
  prevStoryWithAnimation(action) {
14751
- return this.navigationController.prevStoryWithAnimation(action);
14493
+ if (!this.reachStart)
14494
+ this.navigateStoryWithAnimation(this._activeStoryIndex - 1, action);
14752
14495
  }
14753
14496
  toStoryWithAnimationByIndex(index) {
14754
14497
  if (this.activeStoryIndex === index)
14755
14498
  return;
14756
- return this.navigationController.navigateStoryWithAnimation(index, "");
14499
+ return this.navigateStoryWithAnimation(index, "");
14757
14500
  }
14758
14501
  navigateStoryWithAnimationByIndex(index, action) {
14759
- this.navigationController.navigateStoryWithAnimation(index, action);
14502
+ this.navigateStoryWithAnimation(index, action);
14760
14503
  }
14761
14504
  destroy() {
14762
14505
  var _b;
@@ -14773,7 +14516,7 @@ let StoryReaderViewModel = (() => {
14773
14516
  (_b = this.activeStory) === null || _b === void 0 ? void 0 : _b.goodsWidget.close();
14774
14517
  }
14775
14518
  setAnimatedNavigationController(animatedNavigationController) {
14776
- this.navigationController.setAnimatedNavigationController(animatedNavigationController);
14519
+ this.animatedNavigationController = animatedNavigationController;
14777
14520
  }
14778
14521
  mute() {
14779
14522
  this._muted = true;
@@ -14877,16 +14620,82 @@ let StoryReaderViewModel = (() => {
14877
14620
  });
14878
14621
  this.storyReaderStatisticV1Service.sendData();
14879
14622
  }
14623
+ setActiveStoryById(storyId) {
14624
+ const stories = this.stories;
14625
+ const index = stories.findIndex(story => story.id === storyId);
14626
+ if (index === -1)
14627
+ throw new Error(`[IAS]: No story found with ID ${storyId}`);
14628
+ return this.setActiveStoryByIndex(index);
14629
+ }
14630
+ setActiveStoryByIndex(index) {
14631
+ const prevIndex = this._activeStoryIndex;
14632
+ const prevStory = this._activeStory;
14633
+ const newActiveStory = this.stories[index];
14634
+ if (!newActiveStory)
14635
+ return;
14636
+ this.updateActiveStory(index, prevStory, newActiveStory);
14637
+ newActiveStory.once(StoryEvent.Started, () => {
14638
+ this.statisticsController.emitTransitionEvents(prevIndex, index, prevStory, newActiveStory, this.activeStoryDuration);
14639
+ this._activeStoryStartTime = Date.now();
14640
+ });
14641
+ newActiveStory.markAsOpened();
14642
+ return newActiveStory;
14643
+ }
14644
+ updateActiveStory(index, prevStory, activeStory) {
14645
+ this._activeStoryIndex = index;
14646
+ this._activeStory = activeStory;
14647
+ return activeStory;
14648
+ }
14649
+ handleStoryReaderReachEnd(action) {
14650
+ var _b;
14651
+ if (action !== CloseStoryReaderAction.CloseByTimer) {
14652
+ this.close(CloseStoryReaderAction.CloseByLastSlideClick);
14653
+ }
14654
+ else if ((_b = this.animatedNavigationController) === null || _b === void 0 ? void 0 : _b.options.closeOnLastSlideByTimer) {
14655
+ this.close(CloseStoryReaderAction.CloseByTimer);
14656
+ }
14657
+ }
14658
+ async navigateStoryWithAnimation(index, action = "lastSlideClick") {
14659
+ if (!this.animatedNavigationController ||
14660
+ this.animatedNavigationController.animating ||
14661
+ this._targetTransitionIndex !== -1)
14662
+ return;
14663
+ index = this.limitIndex(index);
14664
+ this._targetTransitionIndex = index;
14665
+ this._currentStoryDisplayStrategy.handleNextStoryByIndex(index);
14666
+ await this.animatedNavigationController.transitionByIndex(index, this._activeStoryIndex);
14667
+ await this.handleTransitionEnd(index, action);
14668
+ }
14669
+ limitIndex(index) {
14670
+ return Math.max(0, Math.min(this.stories.length - 1, index));
14671
+ }
14672
+ async handleTransitionEnd(index, navigationAction) {
14673
+ if (this.activeStory) {
14674
+ const event = new CloseStoryEvent(this.activeStory, {
14675
+ action: navigationAction
14676
+ });
14677
+ this.storyManager.emit(event.name, event.toJSON());
14678
+ }
14679
+ await this.setActiveStoryByIndex(index);
14680
+ this._targetTransitionIndex = -1;
14681
+ }
14880
14682
  },
14881
14683
  _StoryReaderViewModel__muted_accessor_storage = new WeakMap(),
14882
14684
  _StoryReaderViewModel__closeGestureInAction_accessor_storage = new WeakMap(),
14883
14685
  _StoryReaderViewModel__stories_accessor_storage = new WeakMap(),
14686
+ _StoryReaderViewModel__activeStory_accessor_storage = new WeakMap(),
14687
+ _StoryReaderViewModel__activeStoryIndex_accessor_storage = new WeakMap(),
14688
+ _StoryReaderViewModel__targetTransitionIndex_accessor_storage = new WeakMap(),
14884
14689
  (() => {
14885
14690
  var _b;
14886
14691
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
14887
14692
  __muted_decorators = [external_mobx_namespaceObject.observable];
14888
14693
  __closeGestureInAction_decorators = [external_mobx_namespaceObject.observable];
14889
14694
  __stories_decorators = [external_mobx_namespaceObject.observable];
14695
+ __activeStory_decorators = [external_mobx_namespaceObject.observable];
14696
+ __activeStoryIndex_decorators = [external_mobx_namespaceObject.observable];
14697
+ __targetTransitionIndex_decorators = [external_mobx_namespaceObject.observable];
14698
+ _get_targetTransitionStory_decorators = [external_mobx_namespaceObject.computed];
14890
14699
  _get_isOpened_decorators = [external_mobx_namespaceObject.computed];
14891
14700
  _get_reachStart_decorators = [external_mobx_namespaceObject.computed];
14892
14701
  _get_reachEnd_decorators = [external_mobx_namespaceObject.computed];
@@ -14908,9 +14717,15 @@ let StoryReaderViewModel = (() => {
14908
14717
  _unmute_decorators = [external_mobx_namespaceObject.action];
14909
14718
  _enableCloseGesture_decorators = [external_mobx_namespaceObject.action];
14910
14719
  _disableCloseGesture_decorators = [external_mobx_namespaceObject.action];
14720
+ _navigateStoryWithAnimation_decorators = [external_mobx_namespaceObject.action];
14721
+ _handleTransitionEnd_decorators = [external_mobx_namespaceObject.action];
14911
14722
  storyReaderViewModel_esDecorate(_a, null, __muted_decorators, { kind: "accessor", name: "_muted", static: false, private: false, access: { has: obj => "_muted" in obj, get: obj => obj._muted, set: (obj, value) => { obj._muted = value; } }, metadata: _metadata }, __muted_initializers, __muted_extraInitializers);
14912
14723
  storyReaderViewModel_esDecorate(_a, null, __closeGestureInAction_decorators, { kind: "accessor", name: "_closeGestureInAction", static: false, private: false, access: { has: obj => "_closeGestureInAction" in obj, get: obj => obj._closeGestureInAction, set: (obj, value) => { obj._closeGestureInAction = value; } }, metadata: _metadata }, __closeGestureInAction_initializers, __closeGestureInAction_extraInitializers);
14913
14724
  storyReaderViewModel_esDecorate(_a, null, __stories_decorators, { kind: "accessor", name: "_stories", static: false, private: false, access: { has: obj => "_stories" in obj, get: obj => obj._stories, set: (obj, value) => { obj._stories = value; } }, metadata: _metadata }, __stories_initializers, __stories_extraInitializers);
14725
+ storyReaderViewModel_esDecorate(_a, null, __activeStory_decorators, { kind: "accessor", name: "_activeStory", static: false, private: false, access: { has: obj => "_activeStory" in obj, get: obj => obj._activeStory, set: (obj, value) => { obj._activeStory = value; } }, metadata: _metadata }, __activeStory_initializers, __activeStory_extraInitializers);
14726
+ storyReaderViewModel_esDecorate(_a, null, __activeStoryIndex_decorators, { kind: "accessor", name: "_activeStoryIndex", static: false, private: false, access: { has: obj => "_activeStoryIndex" in obj, get: obj => obj._activeStoryIndex, set: (obj, value) => { obj._activeStoryIndex = value; } }, metadata: _metadata }, __activeStoryIndex_initializers, __activeStoryIndex_extraInitializers);
14727
+ storyReaderViewModel_esDecorate(_a, null, __targetTransitionIndex_decorators, { kind: "accessor", name: "_targetTransitionIndex", static: false, private: false, access: { has: obj => "_targetTransitionIndex" in obj, get: obj => obj._targetTransitionIndex, set: (obj, value) => { obj._targetTransitionIndex = value; } }, metadata: _metadata }, __targetTransitionIndex_initializers, __targetTransitionIndex_extraInitializers);
14728
+ storyReaderViewModel_esDecorate(_a, null, _get_targetTransitionStory_decorators, { kind: "getter", name: "targetTransitionStory", static: false, private: false, access: { has: obj => "targetTransitionStory" in obj, get: obj => obj.targetTransitionStory }, metadata: _metadata }, null, _instanceExtraInitializers);
14914
14729
  storyReaderViewModel_esDecorate(_a, null, _get_isOpened_decorators, { kind: "getter", name: "isOpened", static: false, private: false, access: { has: obj => "isOpened" in obj, get: obj => obj.isOpened }, metadata: _metadata }, null, _instanceExtraInitializers);
14915
14730
  storyReaderViewModel_esDecorate(_a, null, _get_reachStart_decorators, { kind: "getter", name: "reachStart", static: false, private: false, access: { has: obj => "reachStart" in obj, get: obj => obj.reachStart }, metadata: _metadata }, null, _instanceExtraInitializers);
14916
14731
  storyReaderViewModel_esDecorate(_a, null, _get_reachEnd_decorators, { kind: "getter", name: "reachEnd", static: false, private: false, access: { has: obj => "reachEnd" in obj, get: obj => obj.reachEnd }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -14932,14 +14747,10 @@ let StoryReaderViewModel = (() => {
14932
14747
  storyReaderViewModel_esDecorate(_a, null, _unmute_decorators, { kind: "method", name: "unmute", static: false, private: false, access: { has: obj => "unmute" in obj, get: obj => obj.unmute }, metadata: _metadata }, null, _instanceExtraInitializers);
14933
14748
  storyReaderViewModel_esDecorate(_a, null, _enableCloseGesture_decorators, { kind: "method", name: "enableCloseGesture", static: false, private: false, access: { has: obj => "enableCloseGesture" in obj, get: obj => obj.enableCloseGesture }, metadata: _metadata }, null, _instanceExtraInitializers);
14934
14749
  storyReaderViewModel_esDecorate(_a, null, _disableCloseGesture_decorators, { kind: "method", name: "disableCloseGesture", static: false, private: false, access: { has: obj => "disableCloseGesture" in obj, get: obj => obj.disableCloseGesture }, metadata: _metadata }, null, _instanceExtraInitializers);
14750
+ storyReaderViewModel_esDecorate(_a, null, _navigateStoryWithAnimation_decorators, { kind: "method", name: "navigateStoryWithAnimation", static: false, private: false, access: { has: obj => "navigateStoryWithAnimation" in obj, get: obj => obj.navigateStoryWithAnimation }, metadata: _metadata }, null, _instanceExtraInitializers);
14751
+ storyReaderViewModel_esDecorate(_a, null, _handleTransitionEnd_decorators, { kind: "method", name: "handleTransitionEnd", static: false, private: false, access: { has: obj => "handleTransitionEnd" in obj, get: obj => obj.handleTransitionEnd }, metadata: _metadata }, null, _instanceExtraInitializers);
14935
14752
  if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
14936
14753
  })(),
14937
- Object.defineProperty(_a, "id", {
14938
- enumerable: true,
14939
- configurable: true,
14940
- writable: true,
14941
- value: "StoryReaderViewModel"
14942
- }),
14943
14754
  _a;
14944
14755
  })();
14945
14756
 
@@ -14971,7 +14782,6 @@ class StoryReaderViewModelFactory {
14971
14782
 
14972
14783
 
14973
14784
 
14974
-
14975
14785
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/index.ts
14976
14786
 
14977
14787
 
@@ -17363,7 +17173,7 @@ let IamReaderViewModel = (() => {
17363
17173
  this.throwIfAborted(options.signal);
17364
17174
  const message = await this.iamDisplayService.getMessageById(messageId, options);
17365
17175
  this.throwIfAborted(options.signal);
17366
- await this.open(message);
17176
+ await this.open(message, options.appearance);
17367
17177
  return message;
17368
17178
  }
17369
17179
  async showMessageByEvent(eventName, options = {}) {
@@ -17373,7 +17183,7 @@ let IamReaderViewModel = (() => {
17373
17183
  this.throwIfAborted(options.signal);
17374
17184
  const message = await this.iamDisplayService.getMessageByEvent(eventName, options);
17375
17185
  this.throwIfAborted(options.signal);
17376
- await this.open(message);
17186
+ await this.open(message, options.appearance);
17377
17187
  return message;
17378
17188
  }
17379
17189
  async forceClose() {
@@ -17391,8 +17201,11 @@ let IamReaderViewModel = (() => {
17391
17201
  return;
17392
17202
  this.forceClose();
17393
17203
  }
17394
- async open(message) {
17204
+ async open(message, appearance) {
17395
17205
  message.updatePlaceholders(this.storyManager.rootStore.placeholderStore.placeholders);
17206
+ if ((appearance === null || appearance === void 0 ? void 0 : appearance.zIndex) !== undefined) {
17207
+ message.appearanceOptions.zIndex = appearance.zIndex;
17208
+ }
17396
17209
  this.touchController.init(document.body);
17397
17210
  this.setActiveMessage(message);
17398
17211
  this.visibilityObserver.subscribe();
@@ -21091,7 +20904,7 @@ class UgcEditorStore {
21091
20904
  const session = await this.storyManager.rootStore.sessionStore.open();
21092
20905
  const ugcEditorConfigDto = await this.ugcEditorApi.fetchUgcEditorConfig();
21093
20906
  const storyManagerConfig = this.storyManager.config;
21094
- const sdkVersion = "1.9.4";
20907
+ const sdkVersion = "1.9.6";
21095
20908
  this._config = {
21096
20909
  sessionId: session.id,
21097
20910
  apiKey: storyManagerConfig.apiKey,
@@ -21562,11 +21375,11 @@ class StoryManager extends TypedEventEmitter {
21562
21375
  return deviceDescriptor.deviceId;
21563
21376
  }
21564
21377
  get sdkVersionName() {
21565
- const sdkVersionName = "1.9.4";
21378
+ const sdkVersionName = "1.9.6";
21566
21379
  return sdkVersionName || "0.0.0";
21567
21380
  }
21568
21381
  get sdkVersionCode() {
21569
- const sdkVersionCode = 10904;
21382
+ const sdkVersionCode = 10906;
21570
21383
  return sdkVersionCode ? parseInt(sdkVersionCode) : 0;
21571
21384
  }
21572
21385
  get lang() {
@@ -21630,7 +21443,7 @@ class StoryManager extends TypedEventEmitter {
21630
21443
  this.rootStore.storyManagerConfigStore.setConfig(configDto);
21631
21444
  }
21632
21445
  setUserAgent(userAgent) {
21633
- const sdkVersionCode = 10904;
21446
+ const sdkVersionCode = 10906;
21634
21447
  const buildVersion = sdkVersionCode ? parseInt(sdkVersionCode) : 0;
21635
21448
  // According to RFC5987, HTTP header values can legitimately be supplied using the ISO-8859-1 encoding.
21636
21449
  this._userAgent = `${userAgent} ${convertStrToLatin1(navigator.userAgent)}`;
@@ -23657,11 +23470,11 @@ const StoryReaderRoot = (0,external_mobx_react_lite_namespaceObject.observer)((p
23657
23470
  const getSlideBackdropStyle = () => {
23658
23471
  var _a, _b, _c;
23659
23472
  const imageOptions = [];
23660
- const displayedSlideImage = (_a = props.storyReader.activeStory) === null || _a === void 0 ? void 0 : _a.displayedSlideImage;
23473
+ const cover = (_a = props.storyReader.activeStory) === null || _a === void 0 ? void 0 : _a.cover;
23661
23474
  if (options.slideBackdrop != null && Array.isArray(options.slideBackdrop.linearGradientOverlay))
23662
23475
  imageOptions.push(`linear-gradient(${options.slideBackdrop.linearGradientOverlay.join(", ")})`);
23663
- if (displayedSlideImage != null)
23664
- imageOptions.push(`url(${displayedSlideImage})`);
23476
+ if (cover != null)
23477
+ imageOptions.push(`url(${cover})`);
23665
23478
  return {
23666
23479
  backgroundImage: imageOptions.join(", "),
23667
23480
  opacity: ((_b = options.slideBackdrop) === null || _b === void 0 ? void 0 : _b.opacity) || 0,
@@ -25696,13 +25509,7 @@ class StorySlidesContainer extends HTMLElement {
25696
25509
  writable: true,
25697
25510
  value: null
25698
25511
  });
25699
- Object.defineProperty(this, "story", {
25700
- enumerable: true,
25701
- configurable: true,
25702
- writable: true,
25703
- value: null
25704
- });
25705
- Object.defineProperty(this, "mountPoint", {
25512
+ Object.defineProperty(this, "_mountPoint", {
25706
25513
  enumerable: true,
25707
25514
  configurable: true,
25708
25515
  writable: true,
@@ -25719,22 +25526,22 @@ class StorySlidesContainer extends HTMLElement {
25719
25526
  configurable: true,
25720
25527
  writable: true,
25721
25528
  value: (event) => {
25722
- var _a;
25723
25529
  if (!this.shadowRoot)
25724
25530
  return;
25725
- const isActiveStory = this.getAttribute("is-active-story") === "true";
25726
- if (!isActiveStory)
25727
- return;
25728
- (_a = this.story) === null || _a === void 0 ? void 0 : _a.activeSlide.onClick({
25729
- event,
25730
- currentTarget: this.mountPoint,
25731
- preventNavigation: this.getAttribute("prevent-navigation") === "true"
25732
- });
25531
+ this.dispatchEvent(new CustomEvent("click", {
25532
+ detail: {
25533
+ event,
25534
+ currentTarget: this._mountPoint
25535
+ }
25536
+ }));
25733
25537
  }
25734
25538
  });
25735
25539
  }
25540
+ getMountPoint() {
25541
+ return this._mountPoint;
25542
+ }
25736
25543
  setStyle(cssString) {
25737
- if (!this.mountPoint)
25544
+ if (!this._mountPoint)
25738
25545
  return;
25739
25546
  if (this.styleElement && this.styleElement.parentNode)
25740
25547
  this.styleElement.parentNode.removeChild(this.styleElement);
@@ -25742,30 +25549,20 @@ class StorySlidesContainer extends HTMLElement {
25742
25549
  style.textContent = cssString;
25743
25550
  style.setAttribute("nonce", getNonce());
25744
25551
  this.styleElement = style;
25745
- this.mountPoint.prepend(style);
25746
- }
25747
- attach(story) {
25748
- /** React uses its own virtual DOM and can reuse or move nodes without actually removing them from the DOM. So connectedCallback and disconnectedCallback are not always called.React uses its own virtual DOM and can reuse or move nodes without actually removing them from the DOM. So connectedCallback and disconnectedCallback are not always called. */
25749
- if (!this.mountPoint)
25750
- throw new Error("[IAS]: Mount point was undefined");
25751
- this.story = story;
25752
- this.story.attachRoot(this.mountPoint);
25753
- this.mountPoint.addEventListener("click", this.handleClick);
25754
- }
25755
- detach() {
25756
- var _a, _b;
25757
- /** React uses its own virtual DOM and can reuse or move nodes without actually removing them from the DOM. So connectedCallback and disconnectedCallback are not always called. */
25758
- (_a = this.story) === null || _a === void 0 ? void 0 : _a.detachRoot();
25759
- (_b = this.mountPoint) === null || _b === void 0 ? void 0 : _b.removeEventListener("click", this.handleClick);
25552
+ this._mountPoint.prepend(style);
25760
25553
  }
25761
25554
  connectedCallback() {
25762
25555
  const shadowRoot = this.attachShadow({ mode: "open" });
25763
- this.mountPoint = document.createElement("div");
25764
- this.mountPoint.style.height = "100%";
25765
- this.mountPoint.style.width = "100%";
25766
- shadowRoot.appendChild(this.mountPoint);
25556
+ this._mountPoint = document.createElement("div");
25557
+ this._mountPoint.style.height = "100%";
25558
+ this._mountPoint.style.width = "100%";
25559
+ this._mountPoint.addEventListener("click", this.handleClick);
25560
+ shadowRoot.appendChild(this._mountPoint);
25561
+ }
25562
+ disconnectedCallback() {
25563
+ var _a;
25564
+ (_a = this._mountPoint) === null || _a === void 0 ? void 0 : _a.removeEventListener("click", this.handleClick);
25767
25565
  }
25768
- disconnectedCallback() { }
25769
25566
  }
25770
25567
  customElements.get("story-slides-container") || customElements.define("story-slides-container", StorySlidesContainer);
25771
25568
 
@@ -25786,7 +25583,7 @@ var StorySlidesRenderer_rest = (undefined && undefined.__rest) || function (s, e
25786
25583
 
25787
25584
 
25788
25585
  const StorySlidesRenderer = (0,external_mobx_react_lite_namespaceObject.observer)((0,external_react_namespaceObject.forwardRef)((_a, ref) => {
25789
- var { className, story, preventNavigation, isActiveStory } = _a, props = StorySlidesRenderer_rest(_a, ["className", "story", "preventNavigation", "isActiveStory"]);
25586
+ var { className, story } = _a, props = StorySlidesRenderer_rest(_a, ["className", "story"]);
25790
25587
  const storySlidesRef = (0,external_react_namespaceObject.useRef)(null);
25791
25588
  (0,external_react_namespaceObject.useImperativeHandle)(ref, () => {
25792
25589
  return {
@@ -25794,23 +25591,85 @@ const StorySlidesRenderer = (0,external_mobx_react_lite_namespaceObject.observer
25794
25591
  var _a;
25795
25592
  (_a = storySlidesRef.current) === null || _a === void 0 ? void 0 : _a.setStyle(style);
25796
25593
  },
25797
- attach: (story) => {
25798
- var _a;
25799
- (_a = storySlidesRef.current) === null || _a === void 0 ? void 0 : _a.attach(story);
25800
- },
25801
- detach: () => {
25802
- var _a;
25803
- (_a = storySlidesRef.current) === null || _a === void 0 ? void 0 : _a.detach();
25594
+ getMountPoint: () => {
25595
+ var _a, _b;
25596
+ return (_b = (_a = storySlidesRef.current) === null || _a === void 0 ? void 0 : _a.getMountPoint()) !== null && _b !== void 0 ? _b : null;
25804
25597
  }
25805
25598
  };
25806
25599
  }, [ref, storySlidesRef]);
25600
+ (0,external_react_namespaceObject.useEffect)(() => {
25601
+ if (!storySlidesRef.current)
25602
+ return;
25603
+ const storySlides = storySlidesRef.current;
25604
+ const handleClickEvent = (event) => {
25605
+ props.onClick(event.detail);
25606
+ };
25607
+ storySlides.addEventListener("click", handleClickEvent);
25608
+ return () => {
25609
+ storySlides.removeEventListener("click", handleClickEvent);
25610
+ };
25611
+ }, [props.onClick]);
25807
25612
  const bottomOffset = !props.isDesktopGeometry ? `${story.actionPanel.height}px` : "0px";
25808
25613
  // Bug with attributes in React 19. Explicit cast to string required
25809
25614
  return ((0,jsx_runtime_namespaceObject.jsx)("story-slides-container", { ref: storySlidesRef, style: {
25810
25615
  bottom: bottomOffset
25811
- }, class: className, dir: story.dir, "prevent-navigation": preventNavigation.toString(), "is-active-story": isActiveStory.toString() }));
25616
+ }, class: className, dir: story.dir }));
25812
25617
  }));
25813
25618
 
25619
+ ;// CONCATENATED MODULE: ./src/StoryReader/Story/hooks/useStoryLifecycle.ts
25620
+
25621
+ const useStoryLifecycle = (args) => {
25622
+ (0,external_react_namespaceObject.useEffect)(() => {
25623
+ if (!args.slideRef.current)
25624
+ return;
25625
+ args.story.update({
25626
+ container: args.slideRef.current.getMountPoint(),
25627
+ canBeInited: args.canBeInited,
25628
+ canBeStarted: args.canBeStarted,
25629
+ activeStory: args.activeStory
25630
+ });
25631
+ }, [args.canBeInited, args.canBeStarted, args.slideRef, args.story]);
25632
+ (0,external_react_namespaceObject.useEffect)(() => {
25633
+ return () => {
25634
+ args.story.update({
25635
+ container: null,
25636
+ canBeInited: false,
25637
+ canBeStarted: false,
25638
+ activeStory: null
25639
+ });
25640
+ };
25641
+ }, []);
25642
+ };
25643
+
25644
+ ;// CONCATENATED MODULE: ./src/StoryReader/Story/hooks/useStoryActionPanel.ts
25645
+
25646
+
25647
+
25648
+ const useStoryActionPanel = ({ geometry, story }) => {
25649
+ const { storyReaderOptions, commonOptions } = useIASContainer();
25650
+ const isDesktopGeometry = geometry instanceof DesktopStoryGeometry;
25651
+ (0,external_react_namespaceObject.useLayoutEffect)(() => {
25652
+ const bottomOffset = parseFloat(String(storyReaderOptions.actionPanelBottomOffset));
25653
+ story.actionPanel.setOptions(commonOptions);
25654
+ story.actionPanel.setActionPanelHeight(bottomOffset);
25655
+ }, [story, commonOptions, storyReaderOptions.actionPanelBottomOffset, isDesktopGeometry]);
25656
+ };
25657
+
25658
+ ;// CONCATENATED MODULE: ./src/StoryReader/Story/hooks/useStorySlideStyle.ts
25659
+
25660
+ const useStorySlideStyle = ({ story, slideRef }) => {
25661
+ (0,external_react_namespaceObject.useLayoutEffect)(() => {
25662
+ if (!slideRef.current)
25663
+ return;
25664
+ slideRef.current.setStyle(story.context.style);
25665
+ }, [story.context.style, slideRef]);
25666
+ };
25667
+
25668
+ ;// CONCATENATED MODULE: ./src/StoryReader/Story/hooks/index.ts
25669
+
25670
+
25671
+
25672
+
25814
25673
  ;// CONCATENATED MODULE: ./src/StoryReader/Story/Story.tsx
25815
25674
  var Story_rest = (undefined && undefined.__rest) || function (s, e) {
25816
25675
  var t = {};
@@ -25837,37 +25696,21 @@ var Story_rest = (undefined && undefined.__rest) || function (s, e) {
25837
25696
 
25838
25697
 
25839
25698
 
25699
+
25840
25700
  const Story_Story = (0,external_mobx_react_lite_namespaceObject.observer)((_a) => {
25841
25701
  var { story, geometry, className } = _a, props = Story_rest(_a, ["story", "geometry", "className"]);
25842
- const { storyReaderOptions, commonOptions, goodsWidgetOptions } = useIASContainer();
25843
25702
  const storyRef = (0,external_react_namespaceObject.useRef)(null);
25844
25703
  const slideRef = (0,external_react_namespaceObject.useRef)(null);
25845
- const isActiveStory = story === props.activeStory;
25846
- const isDesktopGeometry = geometry instanceof DesktopStoryGeometry;
25847
- const useModernLayout = storyReaderOptions.layout === StoryReaderLayout.Modern;
25848
- const shouldHideHeader = isDesktopGeometry && useModernLayout
25849
- ? !isActiveStory || story.pauseState.isUIPaused
25850
- : story.pauseState.isUIPaused;
25851
- const shouldHideActionPanel = isDesktopGeometry && ((useModernLayout && !isActiveStory) || story.textInput.isOpened);
25852
- (0,external_react_namespaceObject.useLayoutEffect)(() => {
25853
- const bottomOffset = parseFloat(String(storyReaderOptions.actionPanelBottomOffset));
25854
- story.actionPanel.setOptions(commonOptions);
25855
- story.actionPanel.setActionPanelHeight(bottomOffset);
25856
- }, [story, commonOptions, storyReaderOptions.actionPanelBottomOffset, isDesktopGeometry]);
25857
- (0,external_react_namespaceObject.useLayoutEffect)(() => {
25858
- if (!slideRef.current)
25859
- return;
25860
- slideRef.current.setStyle(story.context.style);
25861
- }, [story.context.style]);
25862
- (0,external_react_namespaceObject.useLayoutEffect)(() => {
25863
- if (!slideRef.current)
25864
- return;
25865
- const storySlides = slideRef.current;
25866
- storySlides.attach(story);
25867
- return () => {
25868
- storySlides.detach();
25869
- };
25870
- }, [story]);
25704
+ const { storyReaderOptions, commonOptions, goodsWidgetOptions } = useIASContainer();
25705
+ useStoryActionPanel({ geometry, story });
25706
+ useStorySlideStyle({ story, slideRef });
25707
+ useStoryLifecycle({
25708
+ story,
25709
+ canBeInited: props.canBeInited,
25710
+ canBeStarted: props.canBeStarted,
25711
+ activeStory: props.activeStory,
25712
+ slideRef
25713
+ });
25871
25714
  const handleReloadStory = async () => {
25872
25715
  const storyError = Boolean(story.error);
25873
25716
  try {
@@ -25880,13 +25723,28 @@ const Story_Story = (0,external_mobx_react_lite_namespaceObject.observer)((_a) =
25880
25723
  console.error(error);
25881
25724
  }
25882
25725
  };
25726
+ const isDesktopGeometry = geometry instanceof DesktopStoryGeometry;
25727
+ const isActiveStory = story === props.activeStory;
25728
+ const useModernLayout = storyReaderOptions.layout === StoryReaderLayout.Modern;
25729
+ const shouldHideHeader = isDesktopGeometry && useModernLayout
25730
+ ? !isActiveStory || story.pauseState.isUIPaused
25731
+ : story.pauseState.isUIPaused;
25732
+ const shouldHideActionPanel = isDesktopGeometry && ((useModernLayout && !isActiveStory) || story.textInput.isOpened);
25883
25733
  return ((0,jsx_runtime_namespaceObject.jsxs)("div", { ref: storyRef, className: (0,external_classnames_namespaceObject["default"])(Story_story_module["story"], className, {
25884
25734
  [Story_story_module["story_mobile"]]: !isDesktopGeometry
25885
25735
  }), onMouseDown: () => {
25886
25736
  story.sharePanel.completeNativeSharing({ result: false });
25887
25737
  }, onTouchStart: () => {
25888
25738
  story.sharePanel.completeNativeSharing({ result: false });
25889
- }, "data-testid": "story", children: [isDesktopGeometry && useModernLayout && story.isSlideRendered && (0,jsx_runtime_namespaceObject.jsx)(StoryBackdrop, { hidden: isActiveStory }), story.canBeShown && story.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(StoryHeader, { hidden: shouldHideHeader, story: story, onClose: props.onClose, isDesktopGeometry: isDesktopGeometry })), (0,jsx_runtime_namespaceObject.jsx)(StorySlidesRenderer, { className: Story_story_module["story-slides"], story: story, ref: slideRef, preventNavigation: useModernLayout && isDesktopGeometry, isActiveStory: isActiveStory, isDesktopGeometry: isDesktopGeometry }), story.actionPanel.needShown && story.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(StoryActionPanel, { dir: story.dir, isDesktopGeometry: isDesktopGeometry, hidden: shouldHideActionPanel, actionPanel: story.actionPanel, commonOptions: commonOptions, storyReaderOptions: storyReaderOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(GoodsWidgetViewer, { story: story, goodsWidgetOptions: goodsWidgetOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(TextInputModal, { story: story, storyRef: storyRef, storyGeometry: geometry })), story.sharePanel.isOpened && ((0,jsx_runtime_namespaceObject.jsx)(SharePanel, { dir: story.dir, className: Story_story_module["share-panel-wrapper"], shareText: story.sharePanel.params.text, shareType: story.sharePanel.params.type, shareLink: story.sharePanel.params.link, onShareCompelete: (result) => story.sharePanel.handleShareComplete(story.sharePanel.params.id, result), sharePanelOptions: storyReaderOptions.sharePanel })), (0,jsx_runtime_namespaceObject.jsx)(Loader, { needShowErrorScreen: story.needShowErrorScreen, needShowLoaderScreen: story.needShowLoaderScreen, onReload: handleReloadStory })] }));
25739
+ }, "data-testid": "story", children: [isDesktopGeometry && useModernLayout && story.isSlideRendered && (0,jsx_runtime_namespaceObject.jsx)(StoryBackdrop, { hidden: isActiveStory }), story.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(StoryHeader, { hidden: shouldHideHeader, story: story, onClose: props.onClose, isDesktopGeometry: isDesktopGeometry })), (0,jsx_runtime_namespaceObject.jsx)(StorySlidesRenderer, { className: Story_story_module["story-slides"], story: story, ref: slideRef, isDesktopGeometry: isDesktopGeometry, onClick: ({ event, currentTarget }) => {
25740
+ if (!isActiveStory)
25741
+ return;
25742
+ story.activeSlide.onClick({
25743
+ event: event,
25744
+ currentTarget,
25745
+ preventNavigation: useModernLayout && isDesktopGeometry
25746
+ });
25747
+ } }), story.actionPanel.needShown && story.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(StoryActionPanel, { dir: story.dir, isDesktopGeometry: isDesktopGeometry, hidden: shouldHideActionPanel, actionPanel: story.actionPanel, commonOptions: commonOptions, storyReaderOptions: storyReaderOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(GoodsWidgetViewer, { story: story, goodsWidgetOptions: goodsWidgetOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(TextInputModal, { story: story, storyRef: storyRef, storyGeometry: geometry })), story.sharePanel.isOpened && ((0,jsx_runtime_namespaceObject.jsx)(SharePanel, { dir: story.dir, className: Story_story_module["share-panel-wrapper"], shareText: story.sharePanel.params.text, shareType: story.sharePanel.params.type, shareLink: story.sharePanel.params.link, onShareCompelete: (result) => story.sharePanel.handleShareComplete(story.sharePanel.params.id, result), sharePanelOptions: storyReaderOptions.sharePanel })), (0,jsx_runtime_namespaceObject.jsx)(Loader, { needShowErrorScreen: story.needShowErrorScreen, needShowLoaderScreen: story.needShowLoaderScreen, onReload: handleReloadStory })] }));
25890
25748
  });
25891
25749
 
25892
25750
  ;// CONCATENATED MODULE: ./src/StoryReader/Story/index.ts
@@ -26218,6 +26076,15 @@ const ModernStoryList = (0,external_mobx_react_lite_namespaceObject.observer)((p
26218
26076
  const borderRadius = parseFloat(String(storyReaderOptions.borderRadius));
26219
26077
  const maxWidth = parseFloat(props.storyGeometry.getWidth()) * STORIES_PER_VIEWPORT;
26220
26078
  const uiDisabled = activeStory.pauseState.isUIPaused || slider.animating;
26079
+ const canBeInited = (index, range = 2) => {
26080
+ const activeIndex = props.storyReader.targetTransitionIndex === -1 ? props.storyReader.activeStoryIndex : props.storyReader.targetTransitionIndex;
26081
+ const start = Math.max(activeIndex - range, 0);
26082
+ const end = Math.min(activeIndex + range, props.storyReader.stories.length - 1);
26083
+ return index >= start && index <= end;
26084
+ };
26085
+ const canBeStarted = (index) => {
26086
+ return props.storyReader.activeStoryIndex === index;
26087
+ };
26221
26088
  return ((0,jsx_runtime_namespaceObject.jsx)("div", { className: (0,external_classnames_namespaceObject["default"])(ModernStoryList_modernStoryList_module["stories-list-container"]), style: {
26222
26089
  "--slide-border-radius": `${borderRadius}px`,
26223
26090
  maxWidth
@@ -26233,7 +26100,8 @@ const ModernStoryList = (0,external_mobx_react_lite_namespaceObject.observer)((p
26233
26100
  if (uiDisabled)
26234
26101
  return;
26235
26102
  props.storyReader.toStoryWithAnimationByIndex(index);
26236
- }, children: [(0,jsx_runtime_namespaceObject.jsx)(Story_Story, { index: index, story: story, slideClickDisabled: uiDisabled, activeStory: activeStory, geometry: props.storyGeometry, onClose: props.onCloseStory }), (props.storyReader.stories.length > 1 || story.slidesCount > 1) && activeStory.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(ModernStoryListControls, { dir: props.storyReader.dir, display: isActiveStory && activeStory.canBeShown, disabled: uiDisabled, isNextDisabled: isNextDisabled, isPrevDisabled: isPrevDisabled, navigationOptions: storyReaderOptions.navigation, onNext: () => {
26103
+ }, children: [(0,jsx_runtime_namespaceObject.jsx)(Story_Story, { index: index, story: story, slideClickDisabled: uiDisabled, activeStory: activeStory, geometry: props.storyGeometry, onClose: props.onCloseStory, canBeInited: canBeInited(index), canBeStarted: canBeStarted(index) }), (props.storyReader.stories.length > 1 || story.slidesCount > 1) &&
26104
+ activeStory.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(ModernStoryListControls, { dir: props.storyReader.dir, display: isActiveStory && activeStory.isSlideRendered, disabled: uiDisabled, isNextDisabled: isNextDisabled, isPrevDisabled: isPrevDisabled, navigationOptions: storyReaderOptions.navigation, onNext: () => {
26237
26105
  props.storyReader.goNext();
26238
26106
  }, onPrev: () => {
26239
26107
  props.storyReader.goPrev();
@@ -27058,13 +26926,22 @@ const MobileStoryList = (0,external_mobx_react_lite_namespaceObject.observer)((p
27058
26926
  : 0;
27059
26927
  const uiPaused = activeStory.pauseState.isUIPaused || slider.api.animating;
27060
26928
  const useModernLayout = storyReaderOptions.layout === StoryReaderLayout.Modern;
26929
+ const canBeInited = (index, range = 2) => {
26930
+ const activeIndex = props.storyReader.targetTransitionIndex === -1 ? props.storyReader.activeStoryIndex : props.storyReader.targetTransitionIndex;
26931
+ const start = Math.max(activeIndex - range, 0);
26932
+ const end = Math.min(activeIndex + range, props.storyReader.stories.length - 1);
26933
+ return index >= start && index <= end;
26934
+ };
26935
+ const canBeStarted = (index) => {
26936
+ return props.storyReader.activeStoryIndex === index;
26937
+ };
27061
26938
  return ((0,jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, { children: [(0,jsx_runtime_namespaceObject.jsx)("div", { className: (0,external_classnames_namespaceObject["default"])(StoryReader_MobileStoryList_storyList_module["stories-list-container"], {
27062
26939
  [StoryReader_MobileStoryList_storyList_module["stories-list-container_swipe-up"]]: props.storyReader.closeGestureInAction,
27063
26940
  [StoryReader_MobileStoryList_storyList_module["stories-list-container_desktop"]]: props.isDesktopGeometry
27064
26941
  }), style: Object.assign({ WebkitPerspective: `${slider.perspective}px`, perspective: `${slider.perspective}px`, width: props.storyGeometry.getWidth(), backgroundColor: !props.isDesktopGeometry &&
27065
26942
  props.safeAreaFrameCalculator.shouldBeShownSafeAreaInsets &&
27066
26943
  "#000", "--slide-border-radius": `${borderRadius}px` }, props.correctionPaddingStyle), children: (0,jsx_runtime_namespaceObject.jsx)("div", { className: StoryReader_MobileStoryList_storyList_module["stories-list"], style: { transform: `translateZ(-${slider.depth}px)` }, children: (0,jsx_runtime_namespaceObject.jsxs)("div", { className: (0,external_classnames_namespaceObject["default"])(StoryReader_MobileStoryList_storyList_module["stories-list__effect-viewer"]), ref: slider.ref, children: [(0,jsx_runtime_namespaceObject.jsx)("div", { className: (0,external_classnames_namespaceObject["default"])(StoryReader_MobileStoryList_storyList_module["stories-list__item"]), children: (0,jsx_runtime_namespaceObject.jsx)(StoryBlank, {}) }), stories.map((story, index) => {
27067
- return ((0,jsx_runtime_namespaceObject.jsx)("div", { className: (0,external_classnames_namespaceObject["default"])(StoryReader_MobileStoryList_storyList_module["stories-list__item"]), children: (0,jsx_runtime_namespaceObject.jsx)(Story_Story, { slideClickDisabled: uiPaused, index: index, story: story, activeStory: activeStory, geometry: props.storyGeometry, onClose: props.onCloseStory }) }, story.id));
26944
+ return ((0,jsx_runtime_namespaceObject.jsx)("div", { className: (0,external_classnames_namespaceObject["default"])(StoryReader_MobileStoryList_storyList_module["stories-list__item"]), children: (0,jsx_runtime_namespaceObject.jsx)(Story_Story, { slideClickDisabled: uiPaused, index: index, story: story, activeStory: activeStory, geometry: props.storyGeometry, onClose: props.onCloseStory, canBeInited: canBeInited(index), canBeStarted: canBeStarted(index) }) }, story.id));
27068
26945
  }), (0,jsx_runtime_namespaceObject.jsx)("div", { className: (0,external_classnames_namespaceObject["default"])(StoryReader_MobileStoryList_storyList_module["stories-list__item"]), children: (0,jsx_runtime_namespaceObject.jsx)(StoryBlank, {}) })] }) }) }), !useModernLayout && ((0,jsx_runtime_namespaceObject.jsx)(MobileStoryListControls, { dir: props.storyReader.dir, disabledByUI: activeStory.pauseState.isUIPaused, disabled: uiPaused, reachEnd: props.storyReader.reachEnd, reachStart: props.storyReader.reachStart, navigationOptions: storyReaderOptions.navigation, width: props.storyGeometry.calculateWidth(), onNext: () => props.storyReader.goNext(), onPrev: () => props.storyReader.goPrev() }))] }));
27069
26946
  });
27070
26947
 
@@ -27125,6 +27002,12 @@ var decorators_js_x = (y) => {
27125
27002
  }
27126
27003
  var decorators_js_y = (x) => (() => (x))
27127
27004
  const decorators_js_namespaceObject = decorators_js_x({ ["property"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.property), ["query"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.query), ["state"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.state) });
27005
+ ;// CONCATENATED MODULE: external "lit/directives/style-map.js"
27006
+ var style_map_js_x = (y) => {
27007
+ var x = {}; __webpack_require__.d(x, y); return x
27008
+ }
27009
+ var style_map_js_y = (x) => (() => (x))
27010
+ const style_map_js_namespaceObject = style_map_js_x({ ["styleMap"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_directives_style_map_js_4fbc7c29__.styleMap) });
27128
27011
  ;// CONCATENATED MODULE: ./src/InAppMessaging/controllers/viewportController.ts
27129
27012
  class ViewportController {
27130
27013
  constructor(host) {
@@ -27188,12 +27071,6 @@ const messageViewsByType = {
27188
27071
 
27189
27072
  const bottomSheetStyles = (0,external_lit_namespaceObject.css) `.bottom-sheet{position:fixed;inset:0;left:0;bottom:0;right:0;z-index:999}.bottom-sheet__backdrop{position:fixed;inset:0;left:0;bottom:0;right:0;z-index:-1;background-color:rgba(0,0,0,var(--backdrop-opacity,.5));opacity:0;transition:opacity 225ms cubic-bezier(.4,0,.2,1);pointer-events:none}.bottom-sheet__backdrop--visible{animation:fade-in .3s forwards}.bottom-sheet__backdrop--hidden{animation:fade-out .3s forwards}.bottom-sheet__box{position:absolute;left:0;right:0;bottom:0;will-change:transform;border-top-left-radius:var(--slide-border-top-left-radius,0);border-top-right-radius:var(--slide-border-top-right-radius,0);background-color:transparent;transition:opacity .3s ease,transform .3s ease;transform:translate3d(0,120%,0);pointer-events:all;overflow:hidden}.bottom-sheet__box-wrapper{position:absolute;inset:0;pointer-events:none}.bottom-sheet__box-wrapper.bottom-sheet__box-wrapper--desktop-mode{position:absolute;bottom:0;left:50%;transform:translate3d(-50%,0,0)}.bottom-sheet__box.bottom-sheet__box--open{opacity:1;transform:translate3d(0,0,0)}.bottom-sheet__backdrop.bottom-sheet__backdrop--open{opacity:1;pointer-events:all}.bottom-sheet__header .grab-handler-area{position:absolute;left:50%;transform:translate3d(-50%,0,0);padding:0 32px 16px;z-index:10000;cursor:grab;user-select:none}.bottom-sheet__header .grab-handler{margin-top:8px;width:32px;height:4px;background-color:#00000080;border-radius:var(--grab-handler-border-radius)}`;
27190
27073
 
27191
- ;// CONCATENATED MODULE: external "lit/directives/style-map.js"
27192
- var style_map_js_x = (y) => {
27193
- var x = {}; __webpack_require__.d(x, y); return x
27194
- }
27195
- var style_map_js_y = (x) => (() => (x))
27196
- const style_map_js_namespaceObject = style_map_js_x({ ["styleMap"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_directives_style_map_js_4fbc7c29__.styleMap) });
27197
27074
  ;// CONCATENATED MODULE: external "lit/directives/class-map.js"
27198
27075
  var class_map_js_x = (y) => {
27199
27076
  var x = {}; __webpack_require__.d(x, y); return x
@@ -27470,6 +27347,7 @@ let BottomSheet = (() => {
27470
27347
  }, 50);
27471
27348
  }
27472
27349
  render() {
27350
+ var _a;
27473
27351
  if (this.isClosed)
27474
27352
  return external_lit_namespaceObject.nothing;
27475
27353
  const bottomSheetBoxStyle = {
@@ -27489,7 +27367,10 @@ let BottomSheet = (() => {
27489
27367
  height: `${this.appearanceOptions.closeButton.height}px`,
27490
27368
  marginTop: `${this.appearanceOptions.closeButton.marginTop}px`
27491
27369
  };
27492
- return (0,external_lit_namespaceObject.html) `<div id="bottom-sheet" class="bottom-sheet"><div id="bottom-sheet__backdrop" style="${(0,style_map_js_namespaceObject.styleMap)({
27370
+ const bottomSheetStyle = {
27371
+ zIndex: (_a = this.appearanceOptions.zIndex) !== null && _a !== void 0 ? _a : 999
27372
+ };
27373
+ return (0,external_lit_namespaceObject.html) `<div id="bottom-sheet" class="bottom-sheet" style="${(0,style_map_js_namespaceObject.styleMap)(bottomSheetStyle)}"><div id="bottom-sheet__backdrop" style="${(0,style_map_js_namespaceObject.styleMap)({
27493
27374
  "--backdrop-opacity": this.appearanceOptions.backdrop.opacity
27494
27375
  })}" @click="${this.close}" class="bottom-sheet__backdrop ${(0,class_map_js_namespaceObject.classMap)({
27495
27376
  "bottom-sheet__backdrop--open": this.isVisible
@@ -27871,6 +27752,7 @@ let Modal_Modal = (() => {
27871
27752
  return "fadeOut";
27872
27753
  }
27873
27754
  render() {
27755
+ var _a;
27874
27756
  const borderRadius = this.fullscreen ? 0 : this.appearanceOptions.borderRadius;
27875
27757
  const modalBoxContentStyle = {
27876
27758
  background: this.appearanceOptions.background,
@@ -27886,7 +27768,10 @@ let Modal_Modal = (() => {
27886
27768
  ? this.getEnterModalAnimationCSSClass(animationType)
27887
27769
  : this.getOutModalAnimationCSSClass(animationType);
27888
27770
  const backdropAnimationClass = this.getBackdropAnimationCSSClass(this.isVisible);
27889
- return (0,external_lit_namespaceObject.html) `<div class="modal"><div id="modal__backdrop" style="${(0,style_map_js_namespaceObject.styleMap)({
27771
+ const modalStyle = {
27772
+ zIndex: (_a = this.appearanceOptions.zIndex) !== null && _a !== void 0 ? _a : 1000
27773
+ };
27774
+ return (0,external_lit_namespaceObject.html) `<div class="modal" style="${(0,style_map_js_namespaceObject.styleMap)(modalStyle)}"><div id="modal__backdrop" style="${(0,style_map_js_namespaceObject.styleMap)({
27890
27775
  "--backdrop-opacity": this.appearanceOptions instanceof IamModalAppearanceOptions
27891
27776
  ? this.appearanceOptions.backdrop.opacity
27892
27777
  : undefined
@@ -28717,6 +28602,7 @@ var InAppMessagingReader_classPrivateFieldSet = (undefined && undefined.__classP
28717
28602
 
28718
28603
 
28719
28604
 
28605
+
28720
28606
  let InAppMessagingReader = (() => {
28721
28607
  var _InAppMessagingReader_options_accessor_storage, _InAppMessagingReader_desktopMode_accessor_storage, _InAppMessagingReader_dir_accessor_storage, _InAppMessagingReader_viewModel_accessor_storage, _InAppMessagingReader_open_accessor_storage;
28722
28608
  let _classDecorators = [safeCustomElement("iam-reader"), mobxObserver];
@@ -28827,7 +28713,7 @@ let InAppMessagingReader = (() => {
28827
28713
  }
28828
28714
  }
28829
28715
  render() {
28830
- var _a, _b;
28716
+ var _a, _b, _c;
28831
28717
  const message = (_a = this.viewModel) === null || _a === void 0 ? void 0 : _a.activeMessage;
28832
28718
  const touchController = (_b = this.viewModel) === null || _b === void 0 ? void 0 : _b.touchController;
28833
28719
  if (!(message === null || message === void 0 ? void 0 : message.context))
@@ -28835,7 +28721,10 @@ let InAppMessagingReader = (() => {
28835
28721
  const type = message.type;
28836
28722
  const messageGeometry = this.createMessageGeometry(type, message.appearanceOptions);
28837
28723
  const slideGeometry = this.createSlideGeometry(messageGeometry);
28838
- return (0,external_lit_namespaceObject.html) `<message-view-factory type="${type}" @closed="${this.handleClosed}" .disableClose="${message.disableClose}" .appearanceOptions="${message.appearanceOptions}" .geometry="${messageGeometry}" .open="${this.open}" .dir="${this.dir}" .desktopMode="${this.desktopMode}" .touchController="${touchController}"><message-slide .message="${message}" .styleContext="${message.context.style}" .geometry="${slideGeometry}"></message-slide><iam-loader .background="${"transparent"}" .needShowErrorScreen="${message.needShowErrorScreen}" .needShowLoaderScreen="${message.needShowLoaderScreen}" @reload="${this.handleReloadMessage}"></iam-loader></message-view-factory>`;
28724
+ const containerStyle = {
28725
+ zIndex: (_c = message.appearanceOptions.zIndex) !== null && _c !== void 0 ? _c : 1000
28726
+ };
28727
+ return (0,external_lit_namespaceObject.html) `<div class="iam-container" style="${(0,style_map_js_namespaceObject.styleMap)(containerStyle)}"><message-view-factory type="${type}" @closed="${this.handleClosed}" .disableClose="${message.disableClose}" .appearanceOptions="${message.appearanceOptions}" .geometry="${messageGeometry}" .open="${this.open}" .dir="${this.dir}" .desktopMode="${this.desktopMode}" .touchController="${touchController}"><message-slide .message="${message}" .styleContext="${message.context.style}" .geometry="${slideGeometry}"></message-slide><iam-loader .background="${"transparent"}" .needShowErrorScreen="${message.needShowErrorScreen}" .needShowLoaderScreen="${message.needShowLoaderScreen}" @reload="${this.handleReloadMessage}"></iam-loader></message-view-factory></div>`;
28839
28728
  }
28840
28729
  };
28841
28730
  _InAppMessagingReader_options_accessor_storage = new WeakMap();
@@ -28980,7 +28869,7 @@ const useStoryManagerConfig = (config) => {
28980
28869
  ;// CONCATENATED MODULE: ./src/IASContainer/hooks/useStoryManagerEvents.ts
28981
28870
 
28982
28871
 
28983
- const useStoryManagerEvents = ({ onClickOnStory, onClickOnButton, onShowStory, onCloseStory, onShowSlide, onLikeStory, onDislikeStory, onFavoriteStory, onShareStory, onShareStoryWithPath, onFeedImpression, onVisibleAreaUpdated, onWidgetEvent, onStartGame, onCloseGame, onFinishGame, onEventGame, onCloseStoryReader, onProductCartUpdated, onProductCartClicked }) => {
28872
+ const useStoryManagerEvents = ({ onClickOnStory, onClickOnButton, onShowStory, onCloseStory, onShowSlide, onLikeStory, onDislikeStory, onFavoriteStory, onShareStory, onShareStoryWithPath, onFeedImpression, onVisibleAreaUpdated, onWidgetEvent, onStartGame, onCloseGame, onEventGame, onCloseStoryReader, onProductCartUpdated, onProductCartClicked }) => {
28984
28873
  (0,external_react_namespaceObject.useEffect)(() => {
28985
28874
  const handlers = [
28986
28875
  { event: "clickOnStory", handler: onClickOnStory },
@@ -28997,7 +28886,6 @@ const useStoryManagerEvents = ({ onClickOnStory, onClickOnButton, onShowStory, o
28997
28886
  { event: "widgetEvent", handler: onWidgetEvent },
28998
28887
  { event: "startGame", handler: onStartGame },
28999
28888
  { event: "closeGame", handler: onCloseGame },
29000
- { event: "finishGame", handler: onFinishGame },
29001
28889
  { event: "eventGame", handler: onEventGame },
29002
28890
  { event: "clickOnButton", handler: onClickOnButton },
29003
28891
  { event: "closeStoryReader", handler: onCloseStoryReader },
@@ -29022,7 +28910,6 @@ const useStoryManagerEvents = ({ onClickOnStory, onClickOnButton, onShowStory, o
29022
28910
  onShowSlide,
29023
28911
  onStartGame,
29024
28912
  onCloseGame,
29025
- onFinishGame,
29026
28913
  onEventGame,
29027
28914
  onLikeStory,
29028
28915
  onDislikeStory,