@inappstory/react-sdk 1.8.0 → 1.9.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -904,7 +904,7 @@ ___CSS_LOADER_EXPORT___.locals = {
904
904
 
905
905
  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
906
  // Module
907
- ___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":""}]);
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":""}]);
908
908
  // Exports
909
909
  ___CSS_LOADER_EXPORT___.locals = {
910
910
  "loader": "loader--O0iuj",
@@ -3070,6 +3070,21 @@ const ua = browser.parse();
3070
3070
  */
3071
3071
  const isDesktopMode_isDesktopMode = ua.getPlatformType() !== "mobile";
3072
3072
 
3073
+ ;// CONCATENATED MODULE: ../core/src/helpers/safeJson.ts
3074
+ function safeJson(input) {
3075
+ if (typeof input !== "string")
3076
+ return null;
3077
+ if (!input.trim())
3078
+ return null;
3079
+ try {
3080
+ const parsed = JSON.parse(input);
3081
+ return (parsed !== null && parsed !== void 0 ? parsed : null);
3082
+ }
3083
+ catch (_a) {
3084
+ return null;
3085
+ }
3086
+ }
3087
+
3073
3088
  ;// CONCATENATED MODULE: ../core/src/helpers/index.ts
3074
3089
 
3075
3090
 
@@ -3088,6 +3103,7 @@ const isDesktopMode_isDesktopMode = ua.getPlatformType() !== "mobile";
3088
3103
 
3089
3104
 
3090
3105
 
3106
+
3091
3107
  ;// CONCATENATED MODULE: ../core/src/api/deviceDescriptor.ts
3092
3108
 
3093
3109
 
@@ -3950,7 +3966,7 @@ let IamMessageSlide = (() => {
3950
3966
 
3951
3967
 
3952
3968
  const openFields = "session,server_timestamp,user_key,share,preview_aspect_ratio,placeholders,image_placeholders,is_allow_ugc,is_allow_statistic_v2";
3953
- const openFeatures = "animation,data,deeplink,placeholder,resetTimers,gameReader,sendApi,swipeUpItems,imgPlaceholder,vod,closeStoryApi,slideTimerEndApi";
3969
+ const openFeatures = "animation,data,deeplink,placeholder,resetTimers,gameReader,sendApi,swipeUpItems,imgPlaceholder,vod,closeStoryApi,slideTimerEndApi,multislideIam";
3954
3970
  class SessionApi {
3955
3971
  async open(payload) {
3956
3972
  const data = await this.getOpenSessionPayload(payload);
@@ -6351,6 +6367,12 @@ class TouchController extends (events_default()) {
6351
6367
  writable: true,
6352
6368
  value: null
6353
6369
  });
6370
+ Object.defineProperty(this, "$grabHandler", {
6371
+ enumerable: true,
6372
+ configurable: true,
6373
+ writable: true,
6374
+ value: null
6375
+ });
6354
6376
  Object.defineProperty(this, "startPoint", {
6355
6377
  enumerable: true,
6356
6378
  configurable: true,
@@ -6437,6 +6459,9 @@ class TouchController extends (events_default()) {
6437
6459
  get verticalSwipeGesture() {
6438
6460
  return this._verticalSwipeGesture;
6439
6461
  }
6462
+ forceEnable() {
6463
+ this.enabled = true;
6464
+ }
6440
6465
  enable() {
6441
6466
  if (isDesktopMode_isDesktopMode)
6442
6467
  return;
@@ -6458,22 +6483,58 @@ class TouchController extends (events_default()) {
6458
6483
  this._horizontalSwipeGestureDisabled = false;
6459
6484
  }
6460
6485
  destroy() {
6461
- if (!this.$el)
6486
+ if (!this.$el || !this.$grabHandler)
6462
6487
  return;
6463
6488
  this.reset();
6464
6489
  this.clearTouchStartTimeout();
6465
- this.$el.removeEventListener("touchstart", this.handleTouchStart);
6466
- this.$el.removeEventListener("touchmove", this.handleTouchMove);
6467
- this.$el.removeEventListener("touchend", this.handleTouchEnd);
6490
+ if (isDesktopMode_isDesktopMode) {
6491
+ this.$grabHandler.removeEventListener("mousedown", this.handleTouchStart);
6492
+ this.$el.removeEventListener("mousemove", this.handleTouchMove);
6493
+ window.removeEventListener("mouseup", this.handleTouchEnd);
6494
+ }
6495
+ else {
6496
+ this.$grabHandler.removeEventListener("touchstart", this.handleTouchStart);
6497
+ this.$el.removeEventListener("touchmove", this.handleTouchMove);
6498
+ window.removeEventListener("touchend", this.handleTouchEnd);
6499
+ }
6468
6500
  this.$el = null;
6501
+ this.$grabHandler = null;
6469
6502
  }
6470
- init(element) {
6503
+ init(element, grabHandler) {
6471
6504
  if (this.$el)
6472
6505
  return; // throw new Error("[TouchController]: you already init touch controller");
6473
6506
  this.$el = element;
6474
- this.$el.addEventListener("touchstart", this.handleTouchStart, { passive: true });
6475
- this.$el.addEventListener("touchmove", this.handleTouchMove, { passive: true });
6476
- this.$el.addEventListener("touchend", this.handleTouchEnd);
6507
+ this.$grabHandler = grabHandler !== null && grabHandler !== void 0 ? grabHandler : this.$el;
6508
+ if (isDesktopMode_isDesktopMode) {
6509
+ this.$grabHandler.addEventListener("mousedown", this.handleTouchStart, { passive: true });
6510
+ this.$el.addEventListener("mousemove", this.handleTouchMove, { passive: true });
6511
+ window.addEventListener("mouseup", this.handleTouchEnd);
6512
+ }
6513
+ else {
6514
+ this.$grabHandler.addEventListener("touchstart", this.handleTouchStart, { passive: true });
6515
+ this.$el.addEventListener("touchmove", this.handleTouchMove, { passive: true });
6516
+ window.addEventListener("touchend", this.handleTouchEnd);
6517
+ }
6518
+ }
6519
+ resetGrabHandler() {
6520
+ if (this.$el)
6521
+ this.updateGrabHandler(this.$el);
6522
+ }
6523
+ setGrabHandler(grabHandler) {
6524
+ if (grabHandler)
6525
+ this.updateGrabHandler(grabHandler);
6526
+ }
6527
+ updateGrabHandler(grabHandler) {
6528
+ var _a, _b;
6529
+ if (isDesktopMode_isDesktopMode) {
6530
+ (_a = this.$grabHandler) === null || _a === void 0 ? void 0 : _a.removeEventListener("mousedown", this.handleTouchStart);
6531
+ grabHandler.addEventListener("mousedown", this.handleTouchStart);
6532
+ }
6533
+ else {
6534
+ (_b = this.$grabHandler) === null || _b === void 0 ? void 0 : _b.removeEventListener("touchstart", this.handleTouchStart);
6535
+ grabHandler.addEventListener("touchstart", this.handleTouchStart);
6536
+ }
6537
+ this.$grabHandler = grabHandler;
6477
6538
  }
6478
6539
  handleTouchStart(event) {
6479
6540
  if (!this.enabled || this.touched)
@@ -6528,7 +6589,7 @@ class TouchController extends (events_default()) {
6528
6589
  }, this.options.touchStartTimeout);
6529
6590
  }
6530
6591
  getPointByEvent(event) {
6531
- if (event instanceof TouchEvent) {
6592
+ if ("changedTouches" in event) {
6532
6593
  const touch = event.changedTouches[0];
6533
6594
  return new Point(touch.pageX, touch.pageY);
6534
6595
  }
@@ -10309,870 +10370,1022 @@ var isObject_js_x = (y) => {
10309
10370
  }
10310
10371
  var isObject_js_y = (x) => (() => (x))
10311
10372
  const isObject_js_namespaceObject = isObject_js_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_lodash_isObject_js_84bb7d23__["default"]) });
10312
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/gameInstanceLocalDataHandlers/gameInstanceStorage.ts
10373
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/api/gameCenterApi.ts
10313
10374
 
10314
10375
 
10315
- class GameInstanceStorage {
10316
- constructor(userKey, gameInstanceId, instanceUserData) {
10376
+ class GameCenterApi {
10377
+ async openGame({ gameInstanceId, gameOptions }) {
10378
+ const params = {
10379
+ expand: "config",
10380
+ fields: "splashScreen,splashLandscapeScreen,splashLottieScreen,screenOptions,config,resources,url,downloadUrl,instanceUserData,canTryReloadCount,loggerLevel,lottie"
10381
+ };
10382
+ const body = {};
10383
+ if (gameOptions && (0,isObject_js_namespaceObject["default"])(gameOptions) && gameOptions.demoMode != null)
10384
+ body.demoMode = Boolean(gameOptions.demoMode);
10385
+ const response = await api.post(`game/${gameInstanceId}/launch`, body, { params });
10386
+ return response.data;
10387
+ }
10388
+ }
10389
+
10390
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/api/index.ts
10391
+
10392
+
10393
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameClientConfig.ts
10394
+
10395
+
10396
+
10397
+ var GamePlaceholderType;
10398
+ (function (GamePlaceholderType) {
10399
+ GamePlaceholderType["TEXT"] = "text";
10400
+ GamePlaceholderType["IMAGE"] = "image";
10401
+ })(GamePlaceholderType || (GamePlaceholderType = {}));
10402
+ class GameClientConfig {
10403
+ constructor(storyManager) {
10404
+ var _a;
10405
+ Object.defineProperty(this, "storyManager", {
10406
+ enumerable: true,
10407
+ configurable: true,
10408
+ writable: true,
10409
+ value: storyManager
10410
+ });
10411
+ Object.defineProperty(this, "sessionId", {
10412
+ enumerable: true,
10413
+ configurable: true,
10414
+ writable: true,
10415
+ value: void 0
10416
+ });
10417
+ Object.defineProperty(this, "lang", {
10418
+ enumerable: true,
10419
+ configurable: true,
10420
+ writable: true,
10421
+ value: void 0
10422
+ });
10423
+ Object.defineProperty(this, "apiKey", {
10424
+ enumerable: true,
10425
+ configurable: true,
10426
+ writable: true,
10427
+ value: void 0
10428
+ });
10317
10429
  Object.defineProperty(this, "userKey", {
10318
10430
  enumerable: true,
10319
10431
  configurable: true,
10320
10432
  writable: true,
10321
- value: userKey
10433
+ value: void 0
10322
10434
  });
10323
- Object.defineProperty(this, "gameInstanceId", {
10435
+ Object.defineProperty(this, "appPackageId", {
10324
10436
  enumerable: true,
10325
10437
  configurable: true,
10326
10438
  writable: true,
10327
- value: gameInstanceId
10439
+ value: void 0
10328
10440
  });
10329
- Object.defineProperty(this, "instanceUserData", {
10441
+ Object.defineProperty(this, "deviceId", {
10330
10442
  enumerable: true,
10331
10443
  configurable: true,
10332
10444
  writable: true,
10333
- value: instanceUserData
10445
+ value: void 0
10334
10446
  });
10447
+ Object.defineProperty(this, "userId", {
10448
+ enumerable: true,
10449
+ configurable: true,
10450
+ writable: true,
10451
+ value: void 0
10452
+ });
10453
+ Object.defineProperty(this, "sdkVersion", {
10454
+ enumerable: true,
10455
+ configurable: true,
10456
+ writable: true,
10457
+ value: void 0
10458
+ });
10459
+ Object.defineProperty(this, "apiBaseUrl", {
10460
+ enumerable: true,
10461
+ configurable: true,
10462
+ writable: true,
10463
+ value: void 0
10464
+ });
10465
+ Object.defineProperty(this, "userAgent", {
10466
+ enumerable: true,
10467
+ configurable: true,
10468
+ writable: true,
10469
+ value: void 0
10470
+ });
10471
+ Object.defineProperty(this, "placeholders", {
10472
+ enumerable: true,
10473
+ configurable: true,
10474
+ writable: true,
10475
+ value: void 0
10476
+ });
10477
+ const storyManagerConfig = this.storyManager.config;
10478
+ const sdkVersion = "1.9.0-rc.0";
10479
+ const placeholders = this.storyManager.rootStore.placeholderStore.placeholders;
10480
+ const session = this.storyManager.rootStore.sessionStore.session;
10481
+ this.sessionId = session.id;
10482
+ this.userKey = session.userKey;
10483
+ this.apiKey = storyManagerConfig.apiKey;
10484
+ this.sdkVersion = sdkVersion;
10485
+ this.apiBaseUrl = domains.apiUrl;
10486
+ this.userAgent = storyManager.userAgent;
10487
+ this.appPackageId = storyManagerConfig.appPackageId;
10488
+ this.deviceId = deviceDescriptor.deviceId;
10489
+ this.userId = (_a = storyManagerConfig.userId) !== null && _a !== void 0 ? _a : "";
10490
+ this.lang = storyManagerConfig.lang.toString();
10491
+ this.placeholders = placeholders.map(placeholder => this.mapPlaceholder(placeholder));
10335
10492
  }
10336
- set(data) {
10337
- // without deepmerge with localInstance
10338
- // let the game fully control the data (delete keys from Data, for instance)
10339
- window.localStorage.setItem(this.key, JSON.stringify(data));
10493
+ mapPlaceholder(placeholder) {
10494
+ return {
10495
+ type: this.mapPlaceholderType(placeholder.type),
10496
+ name: placeholder.key,
10497
+ value: placeholder.value
10498
+ };
10340
10499
  }
10341
- get() {
10342
- var _a;
10343
- let localData = {};
10344
- const remoteData = (0,isObject_js_namespaceObject["default"])(this.instanceUserData) ? this.instanceUserData : {};
10345
- try {
10346
- const data = JSON.parse((_a = window.localStorage.getItem(this.key)) !== null && _a !== void 0 ? _a : "{}");
10347
- if ((0,isObject_js_namespaceObject["default"])(data)) {
10348
- localData = data;
10349
- }
10350
- }
10351
- catch (error) {
10352
- console.error(error);
10500
+ mapPlaceholderType(placeholderType) {
10501
+ switch (placeholderType) {
10502
+ case PlaceholderType.TEXT:
10503
+ return GamePlaceholderType.TEXT;
10504
+ case PlaceholderType.IMAGE:
10505
+ return GamePlaceholderType.IMAGE;
10353
10506
  }
10354
- // remoteData - with higher priority
10355
- return (0,external_deepmerge_namespaceObject["default"])(localData, remoteData);
10356
10507
  }
10357
- get key() {
10358
- return `game_instance_data_${this.userKey}_${this.gameInstanceId}`;
10508
+ toJSON() {
10509
+ return {
10510
+ sessionId: this.sessionId,
10511
+ lang: this.lang,
10512
+ apiKey: this.apiKey,
10513
+ userKey: this.userKey,
10514
+ appPackageId: this.appPackageId,
10515
+ deviceId: this.deviceId,
10516
+ userId: this.userId,
10517
+ sdkVersion: this.sdkVersion,
10518
+ apiBaseUrl: this.apiBaseUrl,
10519
+ userAgent: this.userAgent,
10520
+ placeholders: this.placeholders
10521
+ };
10359
10522
  }
10360
10523
  }
10361
10524
 
10362
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/gameInstanceLocalDataHandlers/gameInstanceGetLocalDataHandler.ts
10363
-
10364
- class GameInstanceGetLocalDataHandler {
10365
- constructor(gameSession, game) {
10366
- Object.defineProperty(this, "gameSession", {
10525
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameConfig.ts
10526
+ class GameConfig {
10527
+ constructor(configDto) {
10528
+ Object.defineProperty(this, "rawData", {
10367
10529
  enumerable: true,
10368
10530
  configurable: true,
10369
10531
  writable: true,
10370
- value: gameSession
10532
+ value: void 0
10371
10533
  });
10372
- Object.defineProperty(this, "game", {
10534
+ Object.defineProperty(this, "gameInstanceId", {
10373
10535
  enumerable: true,
10374
10536
  configurable: true,
10375
10537
  writable: true,
10376
- value: game
10538
+ value: void 0
10377
10539
  });
10540
+ this.gameInstanceId = configDto.gameInstanceId;
10541
+ this.rawData = configDto;
10378
10542
  }
10379
- handle(payload) {
10380
- const { id, callback } = JSON.parse(payload);
10381
- const gameInstanceStorage = new GameInstanceStorage(this.game.clientConfig.userKey, this.game.config.gameInstanceId, this.game.instanceUserData);
10382
- const gameInstanceData = gameInstanceStorage.get();
10383
- this.gameSession.sendMessage("cb", {
10384
- cb: callback,
10385
- arguments: JSON.stringify([id, JSON.stringify(gameInstanceData)])
10386
- });
10543
+ toJSON() {
10544
+ return this.rawData;
10387
10545
  }
10388
10546
  }
10389
10547
 
10390
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/gameInstanceLocalDataHandlers/gameInstanceSetLocalDataHandler.ts
10391
-
10392
-
10393
- class GameInstanceSetLocalDataHandler {
10394
- constructor(storyManager, game) {
10395
- Object.defineProperty(this, "storyManager", {
10548
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameResource.ts
10549
+ class GameResource {
10550
+ constructor(resourceDto) {
10551
+ Object.defineProperty(this, "url", {
10396
10552
  enumerable: true,
10397
10553
  configurable: true,
10398
10554
  writable: true,
10399
- value: storyManager
10555
+ value: void 0
10400
10556
  });
10401
- Object.defineProperty(this, "game", {
10557
+ Object.defineProperty(this, "size", {
10402
10558
  enumerable: true,
10403
10559
  configurable: true,
10404
10560
  writable: true,
10405
- value: game
10561
+ value: void 0
10406
10562
  });
10407
- }
10408
- async handle(rawData) {
10409
- try {
10410
- const payload = JSON.parse(rawData);
10411
- const gameInstanceStorage = new GameInstanceStorage(this.game.clientConfig.userKey, this.game.config.gameInstanceId, this.game.instanceUserData);
10412
- gameInstanceStorage.set(payload.data);
10413
- if (this.storyManager.isStatisticsDisabled || !payload.sendToServer)
10414
- return;
10415
- await api.post(`game/${payload.gameInstanceId}/instance-user-data`, { data: payload.data });
10416
- }
10417
- catch (error) {
10418
- console.error(error);
10419
- }
10420
- }
10421
- }
10422
-
10423
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/gameInstanceLocalDataHandlers/index.ts
10424
-
10425
-
10426
-
10427
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/shareActionHandler/utils/dataUrlToFile.util.ts
10428
- const dataUrlToFile = async ({ file, name, type }) => {
10429
- // type - image/png etc
10430
- const res = await fetch(`data:${type};base64,${file}`);
10431
- const blob = await res.blob();
10432
- return new File([blob], name, { type, lastModified: new Date().getTime() });
10433
- };
10434
-
10435
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/shareActionHandler/shareActionHandler.ts
10436
-
10437
- var shareActionHandler_ShareType;
10438
- (function (ShareType) {
10439
- ShareType["Social"] = "social";
10440
- ShareType["SlideScreenshot"] = "slide-screenshot";
10441
- })(shareActionHandler_ShareType || (shareActionHandler_ShareType = {}));
10442
- class ShareActionHandler {
10443
- constructor(gameSession, shareNotifier, desktopMode) {
10444
- Object.defineProperty(this, "gameSession", {
10563
+ Object.defineProperty(this, "key", {
10445
10564
  enumerable: true,
10446
10565
  configurable: true,
10447
10566
  writable: true,
10448
- value: gameSession
10567
+ value: void 0
10449
10568
  });
10450
- Object.defineProperty(this, "shareNotifier", {
10569
+ Object.defineProperty(this, "sha1", {
10451
10570
  enumerable: true,
10452
10571
  configurable: true,
10453
10572
  writable: true,
10454
- value: shareNotifier
10573
+ value: void 0
10455
10574
  });
10456
- Object.defineProperty(this, "desktopMode", {
10575
+ this.url = resourceDto.url;
10576
+ this.size = resourceDto.size;
10577
+ this.key = resourceDto.key;
10578
+ this.sha1 = resourceDto.sha1;
10579
+ }
10580
+ }
10581
+
10582
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameScreenOptions.ts
10583
+ class GameScreenOptions {
10584
+ constructor(options) {
10585
+ Object.defineProperty(this, "fullScreen", {
10457
10586
  enumerable: true,
10458
10587
  configurable: true,
10459
10588
  writable: true,
10460
- value: desktopMode
10589
+ value: void 0
10461
10590
  });
10462
- }
10463
- async handle(shareId, configDto) {
10464
- var _a, _b;
10465
- const config = this.getFilteredConfigDto(configDto);
10466
- let sharePath = (_b = (_a = config === null || config === void 0 ? void 0 : config.url) !== null && _a !== void 0 ? _a : config.text) !== null && _b !== void 0 ? _b : "";
10467
- try {
10468
- const files = await this.getShareFiles(configDto);
10469
- config.files = files.length > 0 ? files : undefined;
10470
- if (!((config.files && config.files.length > 0) || config.url)) {
10471
- this.shareNotifier.notifyShareCompleted({ shareId, isSuccess: false });
10472
- return;
10473
- }
10474
- if (this.desktopMode) {
10475
- this.openSharePanel({ shareConfig: config, sharePath, shareId });
10476
- return;
10477
- }
10478
- await this.startNativeSharing(shareId, config);
10479
- }
10480
- catch (err) {
10481
- this.openSharePanel({ shareConfig: config, sharePath, shareId });
10482
- }
10483
- }
10484
- async getShareFiles(config) {
10485
- const { files } = config;
10486
- if (!Array.isArray(files) || files.length === 0)
10487
- return [];
10488
- try {
10489
- const filePromises = files.map(file => dataUrlToFile(file));
10490
- return await Promise.all(filePromises);
10491
- }
10492
- catch (error) {
10493
- console.warn("[IAS]: Error converting data URLs to files:", error);
10494
- return [];
10495
- }
10496
- }
10497
- async startNativeSharing(shareId, config) {
10498
- try {
10499
- const shareFn = this.getNavigatorShareFunction();
10500
- await shareFn(config);
10501
- this.shareNotifier.notifyShareCompleted({ shareId, isSuccess: true });
10502
- }
10503
- catch (err) {
10504
- if (err instanceof DOMException && err.name === "AbortError")
10505
- return;
10506
- console.error(`[IAS]: Native sharing error: ${err.message}`);
10507
- throw err;
10508
- }
10509
- finally {
10510
- this.shareNotifier.notifyShareCompleted({ shareId, isSuccess: false });
10511
- }
10512
- }
10513
- getNavigatorShareFunction() {
10514
- var _a, _b;
10515
- let shareFn = (_a = navigator.share) === null || _a === void 0 ? void 0 : _a.bind(navigator);
10516
- if (!shareFn && ((_b = window.parent) === null || _b === void 0 ? void 0 : _b.navigator.share))
10517
- shareFn = window.parent.navigator.share.bind(window.parent.navigator);
10518
- return shareFn;
10519
- }
10520
- getFilteredConfigDto(configDto) {
10521
- const newConfig = {};
10522
- for (const [key, value] of Object.entries(configDto !== null && configDto !== void 0 ? configDto : {})) {
10523
- if (value === null)
10524
- continue;
10525
- newConfig[key] = value;
10526
- }
10527
- return newConfig;
10528
- }
10529
- openSharePanel({ shareConfig, sharePath, shareId }) {
10530
- let shareType = shareActionHandler_ShareType.Social;
10531
- let shareLink = sharePath;
10532
- if (shareConfig.files && shareConfig.files.length > 0) {
10533
- shareType = shareActionHandler_ShareType.SlideScreenshot;
10534
- shareLink = URL.createObjectURL(shareConfig.files[0]);
10535
- }
10536
- this.shareNotifier.notifyOpenSharePanel({
10537
- shareId,
10538
- shareType,
10539
- shareLink
10591
+ Object.defineProperty(this, "widescreen", {
10592
+ enumerable: true,
10593
+ configurable: true,
10594
+ writable: true,
10595
+ value: void 0
10596
+ });
10597
+ Object.defineProperty(this, "orientation", {
10598
+ enumerable: true,
10599
+ configurable: true,
10600
+ writable: true,
10601
+ value: void 0
10540
10602
  });
10603
+ this.fullScreen = options.fullScreen;
10604
+ this.widescreen = options.widescreen;
10605
+ this.orientation = options.orientation;
10541
10606
  }
10542
10607
  }
10543
10608
 
10544
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/shareActionHandler/index.ts
10545
-
10546
-
10547
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/storyLocalDataHandlers/narrativeDataStorage.ts
10548
- class NarrativeDataStorage {
10549
- constructor(storyId) {
10550
- Object.defineProperty(this, "storyId", {
10609
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSplashLandscapeScreen.ts
10610
+ class GameSplashLandscapeScreen {
10611
+ constructor(splashLandscapeScreenDto) {
10612
+ Object.defineProperty(this, "url", {
10551
10613
  enumerable: true,
10552
10614
  configurable: true,
10553
10615
  writable: true,
10554
- value: storyId
10616
+ value: void 0
10555
10617
  });
10556
- }
10557
- set(data) {
10558
- sessionStorage.setItem(this.key, JSON.stringify(data));
10559
- }
10560
- get() {
10561
- var _a;
10562
- const storedData = (_a = sessionStorage.getItem(this.key)) !== null && _a !== void 0 ? _a : "{}";
10563
- if (window.__activeNarrativeId)
10564
- return JSON.parse(storedData);
10565
- return {};
10566
- }
10567
- get key() {
10568
- return `narrative_${this.storyId}_data`;
10618
+ Object.defineProperty(this, "size", {
10619
+ enumerable: true,
10620
+ configurable: true,
10621
+ writable: true,
10622
+ value: void 0
10623
+ });
10624
+ Object.defineProperty(this, "sha1", {
10625
+ enumerable: true,
10626
+ configurable: true,
10627
+ writable: true,
10628
+ value: void 0
10629
+ });
10630
+ this.url = splashLandscapeScreenDto.url;
10631
+ this.size = splashLandscapeScreenDto.size;
10632
+ this.sha1 = splashLandscapeScreenDto.sha1;
10569
10633
  }
10570
10634
  }
10571
10635
 
10572
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/storyLocalDataHandlers/storyGetLocalDataHandler.ts
10573
-
10574
-
10575
- class StoryGetLocalDataHandler {
10576
- constructor(gameSession) {
10577
- Object.defineProperty(this, "gameSession", {
10636
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSplashLottieScreen.ts
10637
+ class GameSplashLottieScreen {
10638
+ constructor(splashLottieScreenDto) {
10639
+ Object.defineProperty(this, "url", {
10578
10640
  enumerable: true,
10579
10641
  configurable: true,
10580
10642
  writable: true,
10581
- value: gameSession
10643
+ value: void 0
10582
10644
  });
10583
- }
10584
- handle(payload) {
10585
- const parsedPayload = JSON.parse(payload);
10586
- if (!(0,isObject_js_namespaceObject["default"])(parsedPayload))
10587
- return;
10588
- const { id, storyId, callback } = parsedPayload;
10589
- const narrativeDataStorage = new NarrativeDataStorage(storyId);
10590
- let narrativeData = narrativeDataStorage.get();
10591
- this.gameSession.sendMessage("cb", {
10592
- cb: callback,
10593
- arguments: JSON.stringify([id, JSON.stringify(narrativeData)])
10645
+ Object.defineProperty(this, "size", {
10646
+ enumerable: true,
10647
+ configurable: true,
10648
+ writable: true,
10649
+ value: void 0
10650
+ });
10651
+ Object.defineProperty(this, "sha1", {
10652
+ enumerable: true,
10653
+ configurable: true,
10654
+ writable: true,
10655
+ value: void 0
10656
+ });
10657
+ Object.defineProperty(this, "durationMinimalMs", {
10658
+ enumerable: true,
10659
+ configurable: true,
10660
+ writable: true,
10661
+ value: void 0
10594
10662
  });
10663
+ this.url = splashLottieScreenDto.url;
10664
+ this.size = splashLottieScreenDto.size;
10665
+ this.sha1 = splashLottieScreenDto.sha1;
10666
+ this.durationMinimalMs = splashLottieScreenDto.durationMinimalMs;
10595
10667
  }
10596
10668
  }
10597
10669
 
10598
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/storyLocalDataHandlers/storySetLocalDataHandler.ts
10599
-
10600
-
10601
-
10602
- class StorySetLocalDataHandler {
10603
- constructor(storyManager) {
10604
- Object.defineProperty(this, "storyManager", {
10670
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSplashScreen.ts
10671
+ class GameSplashScreen {
10672
+ constructor(splashScreenDto) {
10673
+ Object.defineProperty(this, "url", {
10605
10674
  enumerable: true,
10606
10675
  configurable: true,
10607
10676
  writable: true,
10608
- value: storyManager
10677
+ value: void 0
10609
10678
  });
10610
- }
10611
- async handle(rawData) {
10612
- try {
10613
- const payload = JSON.parse(rawData);
10614
- if (!(0,isObject_js_namespaceObject["default"])(payload))
10615
- return;
10616
- const narrativeDataStorage = new NarrativeDataStorage(payload.storyId);
10617
- narrativeDataStorage.set(payload.data);
10618
- if (this.storyManager.isStatisticsDisabled || !payload.sendToServer)
10619
- return;
10620
- await api.request({
10621
- url: "story-data/" + payload.storyId,
10622
- method: "put",
10623
- data: { data: payload.data }
10624
- });
10625
- }
10626
- catch (error) {
10627
- console.error(error);
10628
- }
10679
+ Object.defineProperty(this, "size", {
10680
+ enumerable: true,
10681
+ configurable: true,
10682
+ writable: true,
10683
+ value: void 0
10684
+ });
10685
+ Object.defineProperty(this, "sha1", {
10686
+ enumerable: true,
10687
+ configurable: true,
10688
+ writable: true,
10689
+ value: void 0
10690
+ });
10691
+ this.url = splashScreenDto.url;
10692
+ this.size = splashScreenDto.size;
10693
+ this.sha1 = splashScreenDto.sha1;
10629
10694
  }
10630
10695
  }
10631
10696
 
10632
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/storyLocalDataHandlers/index.ts
10633
-
10634
-
10635
-
10636
-
10637
- ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/index.ts
10638
-
10639
-
10640
-
10697
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/game.ts
10641
10698
 
10642
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/api/gameCenterApi.ts
10643
10699
 
10644
10700
 
10645
- class GameCenterApi {
10646
- async openGame({ gameInstanceId, gameOptions }) {
10647
- const params = {
10648
- expand: "config",
10649
- fields: "splashScreen,splashLandscapeScreen,splashLottieScreen,screenOptions,config,resources,url,downloadUrl,instanceUserData,canTryReloadCount,loggerLevel,lottie"
10650
- };
10651
- const body = {};
10652
- if (gameOptions && (0,isObject_js_namespaceObject["default"])(gameOptions) && gameOptions.demoMode != null)
10653
- body.demoMode = Boolean(gameOptions.demoMode);
10654
- const response = await api.post(`game/${gameInstanceId}/launch`, body, { params });
10655
- return response.data;
10656
- }
10657
- }
10658
10701
 
10659
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/api/index.ts
10660
10702
 
10661
10703
 
10662
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameClientConfig.ts
10663
10704
 
10664
10705
 
10665
10706
 
10666
- var GamePlaceholderType;
10667
- (function (GamePlaceholderType) {
10668
- GamePlaceholderType["TEXT"] = "text";
10669
- GamePlaceholderType["IMAGE"] = "image";
10670
- })(GamePlaceholderType || (GamePlaceholderType = {}));
10671
- class GameClientConfig {
10672
- constructor(storyManager) {
10673
- var _a;
10707
+ class Game {
10708
+ constructor(id, storyManager, gameDto) {
10709
+ var _a, _b;
10710
+ Object.defineProperty(this, "id", {
10711
+ enumerable: true,
10712
+ configurable: true,
10713
+ writable: true,
10714
+ value: id
10715
+ });
10674
10716
  Object.defineProperty(this, "storyManager", {
10675
10717
  enumerable: true,
10676
10718
  configurable: true,
10677
10719
  writable: true,
10678
10720
  value: storyManager
10679
10721
  });
10680
- Object.defineProperty(this, "sessionId", {
10722
+ Object.defineProperty(this, "splashScreen", {
10681
10723
  enumerable: true,
10682
10724
  configurable: true,
10683
10725
  writable: true,
10684
10726
  value: void 0
10685
10727
  });
10686
- Object.defineProperty(this, "lang", {
10728
+ Object.defineProperty(this, "splashLandscapeScreen", {
10687
10729
  enumerable: true,
10688
10730
  configurable: true,
10689
10731
  writable: true,
10690
10732
  value: void 0
10691
10733
  });
10692
- Object.defineProperty(this, "apiKey", {
10734
+ Object.defineProperty(this, "splashLottieScreen", {
10693
10735
  enumerable: true,
10694
10736
  configurable: true,
10695
10737
  writable: true,
10696
10738
  value: void 0
10697
10739
  });
10698
- Object.defineProperty(this, "userKey", {
10740
+ Object.defineProperty(this, "screenOptions", {
10699
10741
  enumerable: true,
10700
10742
  configurable: true,
10701
10743
  writable: true,
10702
10744
  value: void 0
10703
10745
  });
10704
- Object.defineProperty(this, "appPackageId", {
10746
+ Object.defineProperty(this, "config", {
10705
10747
  enumerable: true,
10706
10748
  configurable: true,
10707
10749
  writable: true,
10708
10750
  value: void 0
10709
10751
  });
10710
- Object.defineProperty(this, "deviceId", {
10752
+ Object.defineProperty(this, "resources", {
10711
10753
  enumerable: true,
10712
10754
  configurable: true,
10713
10755
  writable: true,
10714
10756
  value: void 0
10715
10757
  });
10716
- Object.defineProperty(this, "userId", {
10758
+ Object.defineProperty(this, "url", {
10717
10759
  enumerable: true,
10718
10760
  configurable: true,
10719
10761
  writable: true,
10720
10762
  value: void 0
10721
10763
  });
10722
- Object.defineProperty(this, "sdkVersion", {
10764
+ Object.defineProperty(this, "downloadUrl", {
10723
10765
  enumerable: true,
10724
10766
  configurable: true,
10725
10767
  writable: true,
10726
10768
  value: void 0
10727
10769
  });
10728
- Object.defineProperty(this, "apiBaseUrl", {
10770
+ Object.defineProperty(this, "instanceUserData", {
10729
10771
  enumerable: true,
10730
10772
  configurable: true,
10731
10773
  writable: true,
10732
10774
  value: void 0
10733
10775
  });
10734
- Object.defineProperty(this, "userAgent", {
10776
+ Object.defineProperty(this, "clientConfig", {
10735
10777
  enumerable: true,
10736
10778
  configurable: true,
10737
10779
  writable: true,
10738
10780
  value: void 0
10739
10781
  });
10740
- Object.defineProperty(this, "placeholders", {
10782
+ Object.defineProperty(this, "canTryReloadCount", {
10741
10783
  enumerable: true,
10742
10784
  configurable: true,
10743
10785
  writable: true,
10744
10786
  value: void 0
10745
10787
  });
10746
- const storyManagerConfig = this.storyManager.config;
10747
- const sdkVersion = "1.8.0";
10748
- const placeholders = this.storyManager.rootStore.placeholderStore.placeholders;
10749
- const session = this.storyManager.rootStore.sessionStore.session;
10750
- this.sessionId = session.id;
10751
- this.userKey = session.userKey;
10752
- this.apiKey = storyManagerConfig.apiKey;
10753
- this.sdkVersion = sdkVersion;
10754
- this.apiBaseUrl = domains.apiUrl;
10755
- this.userAgent = storyManager.userAgent;
10756
- this.appPackageId = storyManagerConfig.appPackageId;
10757
- this.deviceId = deviceDescriptor.deviceId;
10758
- this.userId = (_a = storyManagerConfig.userId) !== null && _a !== void 0 ? _a : "";
10759
- this.lang = storyManagerConfig.lang.toString();
10760
- this.placeholders = placeholders.map(placeholder => this.mapPlaceholder(placeholder));
10761
- }
10762
- mapPlaceholder(placeholder) {
10763
- return {
10764
- type: this.mapPlaceholderType(placeholder.type),
10765
- name: placeholder.key,
10766
- value: placeholder.value
10767
- };
10768
- }
10769
- mapPlaceholderType(placeholderType) {
10770
- switch (placeholderType) {
10771
- case PlaceholderType.TEXT:
10772
- return GamePlaceholderType.TEXT;
10773
- case PlaceholderType.IMAGE:
10774
- return GamePlaceholderType.IMAGE;
10775
- }
10776
- }
10777
- toJSON() {
10778
- return {
10779
- sessionId: this.sessionId,
10780
- lang: this.lang,
10781
- apiKey: this.apiKey,
10782
- userKey: this.userKey,
10783
- appPackageId: this.appPackageId,
10784
- deviceId: this.deviceId,
10785
- userId: this.userId,
10786
- sdkVersion: this.sdkVersion,
10787
- apiBaseUrl: this.apiBaseUrl,
10788
- userAgent: this.userAgent,
10789
- placeholders: this.placeholders
10790
- };
10791
- }
10792
- }
10793
-
10794
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameConfig.ts
10795
- class GameConfig {
10796
- constructor(configDto) {
10797
- Object.defineProperty(this, "rawData", {
10788
+ Object.defineProperty(this, "loggerLevel", {
10798
10789
  enumerable: true,
10799
10790
  configurable: true,
10800
10791
  writable: true,
10801
10792
  value: void 0
10802
10793
  });
10803
- Object.defineProperty(this, "gameInstanceId", {
10794
+ Object.defineProperty(this, "lottie", {
10804
10795
  enumerable: true,
10805
10796
  configurable: true,
10806
10797
  writable: true,
10807
10798
  value: void 0
10808
10799
  });
10809
- this.gameInstanceId = configDto.gameInstanceId;
10810
- this.rawData = configDto;
10800
+ this.splashScreen = gameDto.splashScreen ? new GameSplashScreen(gameDto.splashScreen) : undefined;
10801
+ this.splashLandscapeScreen = gameDto.splashLandscapeScreen
10802
+ ? new GameSplashLandscapeScreen(gameDto.splashLandscapeScreen)
10803
+ : undefined;
10804
+ this.splashLottieScreen = gameDto.splashLottieScreen
10805
+ ? new GameSplashLottieScreen(gameDto.splashLottieScreen)
10806
+ : undefined;
10807
+ this.screenOptions = new GameScreenOptions(gameDto.screenOptions);
10808
+ this.config = new GameConfig(gameDto.config);
10809
+ this.resources = (_b = (_a = gameDto.resources) === null || _a === void 0 ? void 0 : _a.map(resourceDto => new GameResource(resourceDto))) !== null && _b !== void 0 ? _b : [];
10810
+ this.url = gameDto.url;
10811
+ this.downloadUrl = gameDto.downloadUrl;
10812
+ this.instanceUserData = gameDto.instanceUserData;
10813
+ this.clientConfig = new GameClientConfig(storyManager);
10814
+ this.canTryReloadCount = gameDto.canTryReloadCount;
10815
+ this.loggerLevel = gameDto.loggerLevel;
10816
+ this.lottie = gameDto.lottie
10817
+ ? {
10818
+ src: gameDto.lottie.src
10819
+ }
10820
+ : undefined;
10811
10821
  }
10812
- toJSON() {
10813
- return this.rawData;
10822
+ toInitDto(payload) {
10823
+ return (0,external_deepmerge_namespaceObject["default"])(this.config.toJSON(), {
10824
+ clientConfig: Object.assign({ fullScreen: false, screenOrientation: this.screenOptions.orientation, variables: this.storyManager.config.options, safeAreaInsets: payload.safeAreaInsets, widescreen: payload.isWidescreen, dir: payload.dir, nonce: getNonce(), sdkFeatures: {
10825
+ gameShouldForegroundCallback: true,
10826
+ writeToClipboard: true
10827
+ } }, this.clientConfig.toJSON())
10828
+ });
10814
10829
  }
10815
10830
  }
10816
10831
 
10817
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameResource.ts
10818
- class GameResource {
10819
- constructor(resourceDto) {
10820
- Object.defineProperty(this, "url", {
10832
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSession.ts
10833
+
10834
+
10835
+ class GameLoadFailedError extends Error {
10836
+ constructor(reason, canTryReload) {
10837
+ super(reason);
10838
+ Object.defineProperty(this, "canTryReload", {
10821
10839
  enumerable: true,
10822
10840
  configurable: true,
10823
10841
  writable: true,
10824
- value: void 0
10842
+ value: canTryReload
10825
10843
  });
10826
- Object.defineProperty(this, "size", {
10844
+ }
10845
+ }
10846
+ class GameForegroundTimeoutError extends Error {
10847
+ constructor() {
10848
+ super("[IAS]: game foreground timeout exceeded 60 seconds");
10849
+ }
10850
+ }
10851
+ class GameSession extends events.EventEmitter {
10852
+ constructor(iframe, origin) {
10853
+ super();
10854
+ Object.defineProperty(this, "iframe", {
10827
10855
  enumerable: true,
10828
10856
  configurable: true,
10829
10857
  writable: true,
10830
- value: void 0
10858
+ value: iframe
10831
10859
  });
10832
- Object.defineProperty(this, "key", {
10860
+ Object.defineProperty(this, "origin", {
10833
10861
  enumerable: true,
10834
10862
  configurable: true,
10835
10863
  writable: true,
10836
- value: void 0
10864
+ value: origin
10837
10865
  });
10838
- Object.defineProperty(this, "sha1", {
10839
- enumerable: true,
10840
- configurable: true,
10841
- writable: true,
10842
- value: void 0
10866
+ this.messageListener = this.messageListener.bind(this);
10867
+ window.addEventListener("message", this.messageListener, false);
10868
+ }
10869
+ open(gameConfig) {
10870
+ return new Promise((resolve, reject) => {
10871
+ this.once("gameLoadFailed" /* GameSessionEvent.GameLoadFailed */, (reason, canTryReload) => {
10872
+ reject(new GameLoadFailedError(reason, canTryReload));
10873
+ });
10874
+ this.once("gameLoaded" /* GameSessionEvent.GameLoaded */, () => resolve());
10875
+ this.sendMessage("cb", { cb: "initGame", arguments: JSON.stringify([gameConfig]) });
10843
10876
  });
10844
- this.url = resourceDto.url;
10845
- this.size = resourceDto.size;
10846
- this.key = resourceDto.key;
10847
- this.sha1 = resourceDto.sha1;
10848
10877
  }
10849
- }
10850
-
10851
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameScreenOptions.ts
10852
- class GameScreenOptions {
10853
- constructor(options) {
10854
- Object.defineProperty(this, "fullScreen", {
10855
- enumerable: true,
10856
- configurable: true,
10857
- writable: true,
10858
- value: void 0
10878
+ waitForeground(timeoutMs = 60000) {
10879
+ return new Promise((resolve, reject) => {
10880
+ let timeoutId = null;
10881
+ const onForeground = (serialized) => {
10882
+ var _a;
10883
+ cleanup();
10884
+ const payload = (_a = safeJson(serialized)) !== null && _a !== void 0 ? _a : {};
10885
+ resolve(typeof payload === "object" ? payload : {});
10886
+ };
10887
+ const onTimeout = () => {
10888
+ cleanup();
10889
+ reject(new GameForegroundTimeoutError());
10890
+ };
10891
+ const cleanup = () => {
10892
+ if (timeoutId) {
10893
+ clearTimeout(timeoutId);
10894
+ timeoutId = null;
10895
+ }
10896
+ this.off("gameShouldForegroundCallback" /* GameSessionEvent.GameShouldForegroundCallback */, onForeground);
10897
+ };
10898
+ this.once("gameShouldForegroundCallback" /* GameSessionEvent.GameShouldForegroundCallback */, onForeground);
10899
+ timeoutId = setTimeout(onTimeout, timeoutMs);
10859
10900
  });
10860
- Object.defineProperty(this, "widescreen", {
10861
- enumerable: true,
10862
- configurable: true,
10863
- writable: true,
10864
- value: void 0
10901
+ }
10902
+ close() {
10903
+ window.removeEventListener("message", this.messageListener, false);
10904
+ this.removeAllListeners();
10905
+ }
10906
+ sendMessage(event, data) {
10907
+ var _a;
10908
+ (_a = this.iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage([event, data], this.origin);
10909
+ }
10910
+ pauseGameUI() {
10911
+ this.sendMessage("cb", { cb: "pauseUI", arguments: JSON.stringify([]) });
10912
+ }
10913
+ resumeGameUI() {
10914
+ this.sendMessage("cb", { cb: "resumeUI", arguments: JSON.stringify([]) });
10915
+ }
10916
+ shareComplete(shareId, isSuccess) {
10917
+ this.sendMessage("shareComplete", { id: shareId, isSuccess });
10918
+ }
10919
+ closeGameReader() {
10920
+ this.sendMessage("closeGameReader");
10921
+ }
10922
+ sendGameCenterEventByApiRequest(eventName, payload) {
10923
+ this.sendMessage("cb", {
10924
+ cb: eventName,
10925
+ plainData: payload
10865
10926
  });
10866
- Object.defineProperty(this, "orientation", {
10867
- enumerable: true,
10868
- configurable: true,
10869
- writable: true,
10870
- value: void 0
10927
+ }
10928
+ notifyGameCanBeStarted() {
10929
+ this.sendMessage("gameShouldForeground");
10930
+ }
10931
+ messageListener(event) {
10932
+ if (event.origin !== this.origin)
10933
+ return;
10934
+ try {
10935
+ if (!Array.isArray(event.data))
10936
+ throw new Error(`[IAS]: Invalid MessageEvent data format ${event.data}`);
10937
+ const [gameEvent, ...restData] = event.data;
10938
+ this.emit(gameEvent, ...restData);
10939
+ }
10940
+ catch (err) {
10941
+ console.error(err);
10942
+ }
10943
+ }
10944
+ }
10945
+
10946
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/index.ts
10947
+
10948
+
10949
+
10950
+
10951
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/factories/gameSessionFactory.ts
10952
+
10953
+ class GameSessionFactory {
10954
+ create(iframe, origin) {
10955
+ return new GameSession(iframe, origin);
10956
+ }
10957
+ }
10958
+
10959
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/factories/index.ts
10960
+
10961
+
10962
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/apiModule.ts
10963
+
10964
+
10965
+ class GameApiModule {
10966
+ attach(session, game) {
10967
+ session.on("sendApiRequest" /* GameSessionEvent.SendApiRequest */, async (raw) => {
10968
+ let id, data, cb;
10969
+ try {
10970
+ const payload = safeJson(raw);
10971
+ (id = payload.id), (data = payload.data), (cb = payload.cb);
10972
+ await api.request({
10973
+ url: payload.url,
10974
+ method: payload.method,
10975
+ params: payload.params,
10976
+ data: payload.data,
10977
+ headers: payload.headers
10978
+ }).catch(console.error);
10979
+ session.sendGameCenterEventByApiRequest(cb, JSON.stringify({
10980
+ requestId: id,
10981
+ data: JSON.stringify(data.data),
10982
+ status: data.status,
10983
+ headers: data.headers
10984
+ }));
10985
+ }
10986
+ catch (error) {
10987
+ if (error instanceof SyntaxError)
10988
+ return;
10989
+ if (!cb)
10990
+ return;
10991
+ session.sendGameCenterEventByApiRequest(cb, JSON.stringify({
10992
+ requestId: id,
10993
+ data: JSON.stringify(error),
10994
+ status: 400,
10995
+ headers: [{}]
10996
+ }));
10997
+ }
10871
10998
  });
10872
- this.fullScreen = options.fullScreen;
10873
- this.widescreen = options.widescreen;
10874
- this.orientation = options.orientation;
10875
10999
  }
10876
11000
  }
10877
11001
 
10878
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSplashLandscapeScreen.ts
10879
- class GameSplashLandscapeScreen {
10880
- constructor(splashLandscapeScreenDto) {
10881
- Object.defineProperty(this, "url", {
10882
- enumerable: true,
10883
- configurable: true,
10884
- writable: true,
10885
- value: void 0
11002
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/clipboardModule.ts
11003
+
11004
+
11005
+ class GameClipboardModule {
11006
+ attach(session, game) {
11007
+ session.on("writeToClipboard" /* GameSessionEvent.WriteToClipboard */, payload => {
11008
+ var _a;
11009
+ try {
11010
+ const { textValue } = (_a = safeJson(payload)) !== null && _a !== void 0 ? _a : { textValue: "" };
11011
+ new Clipboard().copy(textValue);
11012
+ }
11013
+ catch (error) {
11014
+ console.error(`[IAS]: `, error.message);
11015
+ }
10886
11016
  });
10887
- Object.defineProperty(this, "size", {
11017
+ }
11018
+ }
11019
+
11020
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/gameEventModule.ts
11021
+ class GameEventModule {
11022
+ constructor(storyManager) {
11023
+ Object.defineProperty(this, "storyManager", {
10888
11024
  enumerable: true,
10889
11025
  configurable: true,
10890
11026
  writable: true,
10891
- value: void 0
11027
+ value: storyManager
10892
11028
  });
10893
- Object.defineProperty(this, "sha1", {
10894
- enumerable: true,
10895
- configurable: true,
10896
- writable: true,
10897
- value: void 0
11029
+ }
11030
+ attach(session, game) {
11031
+ session.on("event" /* GameSessionEvent.Event */, (name, payload) => {
11032
+ // @deprecated Use `eventGame` instead
11033
+ this.storyManager.emit("gameEvent", { name, payload });
11034
+ this.storyManager.emit("eventGame", { name, payload });
10898
11035
  });
10899
- this.url = splashLandscapeScreenDto.url;
10900
- this.size = splashLandscapeScreenDto.size;
10901
- this.sha1 = splashLandscapeScreenDto.sha1;
10902
11036
  }
10903
11037
  }
10904
11038
 
10905
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSplashLottieScreen.ts
10906
- class GameSplashLottieScreen {
10907
- constructor(splashLottieScreenDto) {
10908
- Object.defineProperty(this, "url", {
11039
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/navigationModule.ts
11040
+
11041
+
11042
+ class GameNavigationModule {
11043
+ constructor(storyManager) {
11044
+ Object.defineProperty(this, "storyManager", {
10909
11045
  enumerable: true,
10910
11046
  configurable: true,
10911
11047
  writable: true,
10912
- value: void 0
11048
+ value: storyManager
10913
11049
  });
10914
- Object.defineProperty(this, "size", {
10915
- enumerable: true,
10916
- configurable: true,
10917
- writable: true,
10918
- value: void 0
11050
+ }
11051
+ attach(session, game) {
11052
+ session.on("openUrl" /* GameSessionEvent.OpenUrl */, payload => {
11053
+ var _a;
11054
+ const { url } = (_a = safeJson(payload)) !== null && _a !== void 0 ? _a : { url: "" };
11055
+ const event = {
11056
+ src: StoryManagerLinkEventSource.GameReader,
11057
+ data: { id: game.id, url, gameInstanceId: game.id }
11058
+ };
11059
+ this.storyManager.storyLinkClickHandler(event);
11060
+ // @deprecated
11061
+ this.storyManager.emit("clickOnButton", event);
10919
11062
  });
10920
- Object.defineProperty(this, "sha1", {
11063
+ }
11064
+ }
11065
+
11066
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/shareModule/utils/dataUrlToFile.util.ts
11067
+ const dataUrlToFile = async ({ file, name, type }) => {
11068
+ // type - image/png etc
11069
+ const res = await fetch(`data:${type};base64,${file}`);
11070
+ const blob = await res.blob();
11071
+ return new File([blob], name, { type, lastModified: new Date().getTime() });
11072
+ };
11073
+
11074
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/shareModule/shareModule.ts
11075
+
11076
+
11077
+ var shareModule_ShareType;
11078
+ (function (ShareType) {
11079
+ ShareType["Social"] = "social";
11080
+ ShareType["SlideScreenshot"] = "slide-screenshot";
11081
+ })(shareModule_ShareType || (shareModule_ShareType = {}));
11082
+ class GameShareModule {
11083
+ constructor(shareNotifier) {
11084
+ Object.defineProperty(this, "shareNotifier", {
10921
11085
  enumerable: true,
10922
11086
  configurable: true,
10923
11087
  writable: true,
10924
- value: void 0
11088
+ value: shareNotifier
10925
11089
  });
10926
- Object.defineProperty(this, "durationMinimalMs", {
11090
+ Object.defineProperty(this, "handleShare", {
10927
11091
  enumerable: true,
10928
11092
  configurable: true,
10929
11093
  writable: true,
10930
- value: void 0
11094
+ value: async (shareId, configDto) => {
11095
+ var _a, _b;
11096
+ const config = this.getFilteredConfigDto(configDto);
11097
+ let sharePath = (_b = (_a = config === null || config === void 0 ? void 0 : config.url) !== null && _a !== void 0 ? _a : config.text) !== null && _b !== void 0 ? _b : "";
11098
+ try {
11099
+ const files = await this.getShareFiles(configDto);
11100
+ config.files = files.length > 0 ? files : undefined;
11101
+ if (!((config.files && config.files.length > 0) || config.url)) {
11102
+ this.shareNotifier.notifyShareCompleted({ shareId, isSuccess: false });
11103
+ return;
11104
+ }
11105
+ if (isDesktopMode_isDesktopMode) {
11106
+ this.openSharePanel({ shareConfig: config, sharePath, shareId });
11107
+ return;
11108
+ }
11109
+ await this.startNativeSharing(shareId, config);
11110
+ }
11111
+ catch (err) {
11112
+ this.openSharePanel({ shareConfig: config, sharePath, shareId });
11113
+ }
11114
+ }
11115
+ });
11116
+ }
11117
+ attach(session, game) {
11118
+ session.on("share" /* GameSessionEvent.Share */, this.handleShare);
11119
+ }
11120
+ async getShareFiles(config) {
11121
+ const { files } = config;
11122
+ if (!Array.isArray(files) || files.length === 0)
11123
+ return [];
11124
+ try {
11125
+ const filePromises = files.map(file => dataUrlToFile(file));
11126
+ return await Promise.all(filePromises);
11127
+ }
11128
+ catch (error) {
11129
+ console.warn("[IAS]: Error converting data URLs to files:", error);
11130
+ return [];
11131
+ }
11132
+ }
11133
+ async startNativeSharing(shareId, config) {
11134
+ try {
11135
+ const shareFn = this.getNavigatorShareFunction();
11136
+ await shareFn(config);
11137
+ this.shareNotifier.notifyShareCompleted({ shareId, isSuccess: true });
11138
+ }
11139
+ catch (err) {
11140
+ if (err instanceof DOMException && err.name === "AbortError")
11141
+ return;
11142
+ console.error(`[IAS]: Native sharing error: ${err.message}`);
11143
+ throw err;
11144
+ }
11145
+ finally {
11146
+ this.shareNotifier.notifyShareCompleted({ shareId, isSuccess: false });
11147
+ }
11148
+ }
11149
+ getNavigatorShareFunction() {
11150
+ var _a, _b;
11151
+ let shareFn = (_a = navigator.share) === null || _a === void 0 ? void 0 : _a.bind(navigator);
11152
+ if (!shareFn && ((_b = window.parent) === null || _b === void 0 ? void 0 : _b.navigator.share))
11153
+ shareFn = window.parent.navigator.share.bind(window.parent.navigator);
11154
+ return shareFn;
11155
+ }
11156
+ getFilteredConfigDto(configDto) {
11157
+ const newConfig = {};
11158
+ for (const [key, value] of Object.entries(configDto !== null && configDto !== void 0 ? configDto : {})) {
11159
+ if (value === null)
11160
+ continue;
11161
+ newConfig[key] = value;
11162
+ }
11163
+ return newConfig;
11164
+ }
11165
+ openSharePanel({ shareConfig, sharePath, shareId }) {
11166
+ let shareType = shareModule_ShareType.Social;
11167
+ let shareLink = sharePath;
11168
+ if (shareConfig.files && shareConfig.files.length > 0) {
11169
+ shareType = shareModule_ShareType.SlideScreenshot;
11170
+ shareLink = URL.createObjectURL(shareConfig.files[0]);
11171
+ }
11172
+ this.shareNotifier.notifyOpenSharePanel({
11173
+ shareId,
11174
+ shareType,
11175
+ shareLink
10931
11176
  });
10932
- this.url = splashLottieScreenDto.url;
10933
- this.size = splashLottieScreenDto.size;
10934
- this.sha1 = splashLottieScreenDto.sha1;
10935
- this.durationMinimalMs = splashLottieScreenDto.durationMinimalMs;
10936
11177
  }
10937
11178
  }
10938
11179
 
10939
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSplashScreen.ts
10940
- class GameSplashScreen {
10941
- constructor(splashScreenDto) {
10942
- Object.defineProperty(this, "url", {
11180
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/shareModule/index.ts
11181
+
11182
+
11183
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/gameLocalDataModule/gameInstanceStorage.ts
11184
+
11185
+
11186
+ class GameInstanceStorage {
11187
+ constructor(userKey, gameInstanceId, instanceUserData) {
11188
+ Object.defineProperty(this, "userKey", {
10943
11189
  enumerable: true,
10944
11190
  configurable: true,
10945
11191
  writable: true,
10946
- value: void 0
11192
+ value: userKey
10947
11193
  });
10948
- Object.defineProperty(this, "size", {
11194
+ Object.defineProperty(this, "gameInstanceId", {
10949
11195
  enumerable: true,
10950
11196
  configurable: true,
10951
11197
  writable: true,
10952
- value: void 0
11198
+ value: gameInstanceId
10953
11199
  });
10954
- Object.defineProperty(this, "sha1", {
11200
+ Object.defineProperty(this, "instanceUserData", {
10955
11201
  enumerable: true,
10956
11202
  configurable: true,
10957
11203
  writable: true,
10958
- value: void 0
11204
+ value: instanceUserData
10959
11205
  });
10960
- this.url = splashScreenDto.url;
10961
- this.size = splashScreenDto.size;
10962
- this.sha1 = splashScreenDto.sha1;
11206
+ }
11207
+ set(data) {
11208
+ // without deepmerge with localInstance
11209
+ // let the game fully control the data (delete keys from Data, for instance)
11210
+ window.localStorage.setItem(this.key, JSON.stringify(data));
11211
+ }
11212
+ get() {
11213
+ var _a;
11214
+ let localData = {};
11215
+ const remoteData = (0,isObject_js_namespaceObject["default"])(this.instanceUserData) ? this.instanceUserData : {};
11216
+ try {
11217
+ const data = JSON.parse((_a = window.localStorage.getItem(this.key)) !== null && _a !== void 0 ? _a : "{}");
11218
+ if ((0,isObject_js_namespaceObject["default"])(data)) {
11219
+ localData = data;
11220
+ }
11221
+ }
11222
+ catch (error) {
11223
+ console.error(error);
11224
+ }
11225
+ // remoteData - with higher priority
11226
+ return (0,external_deepmerge_namespaceObject["default"])(localData, remoteData);
11227
+ }
11228
+ get key() {
11229
+ return `game_instance_data_${this.userKey}_${this.gameInstanceId}`;
10963
11230
  }
10964
11231
  }
10965
11232
 
10966
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/game.ts
10967
-
10968
-
10969
-
10970
-
10971
-
11233
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/gameLocalDataModule/gameLocalDataModule.ts
10972
11234
 
10973
11235
 
10974
-
10975
-
10976
- class Game {
10977
- constructor(storyManager, gameDto) {
10978
- var _a, _b;
11236
+ class GameLocalDataModule {
11237
+ constructor(storyManager) {
10979
11238
  Object.defineProperty(this, "storyManager", {
10980
11239
  enumerable: true,
10981
11240
  configurable: true,
10982
11241
  writable: true,
10983
11242
  value: storyManager
10984
11243
  });
10985
- Object.defineProperty(this, "splashScreen", {
10986
- enumerable: true,
10987
- configurable: true,
10988
- writable: true,
10989
- value: void 0
10990
- });
10991
- Object.defineProperty(this, "splashLandscapeScreen", {
10992
- enumerable: true,
10993
- configurable: true,
10994
- writable: true,
10995
- value: void 0
10996
- });
10997
- Object.defineProperty(this, "splashLottieScreen", {
10998
- enumerable: true,
10999
- configurable: true,
11000
- writable: true,
11001
- value: void 0
11002
- });
11003
- Object.defineProperty(this, "screenOptions", {
11004
- enumerable: true,
11005
- configurable: true,
11006
- writable: true,
11007
- value: void 0
11008
- });
11009
- Object.defineProperty(this, "config", {
11010
- enumerable: true,
11011
- configurable: true,
11012
- writable: true,
11013
- value: void 0
11014
- });
11015
- Object.defineProperty(this, "resources", {
11016
- enumerable: true,
11017
- configurable: true,
11018
- writable: true,
11019
- value: void 0
11020
- });
11021
- Object.defineProperty(this, "url", {
11022
- enumerable: true,
11023
- configurable: true,
11024
- writable: true,
11025
- value: void 0
11026
- });
11027
- Object.defineProperty(this, "downloadUrl", {
11244
+ Object.defineProperty(this, "handleSetLocalData", {
11028
11245
  enumerable: true,
11029
11246
  configurable: true,
11030
11247
  writable: true,
11031
- value: void 0
11248
+ value: async (session, game, rawData) => {
11249
+ try {
11250
+ const payload = JSON.parse(rawData);
11251
+ const gameInstanceStorage = new GameInstanceStorage(game.clientConfig.userKey, game.config.gameInstanceId, game.instanceUserData);
11252
+ gameInstanceStorage.set(payload.data);
11253
+ if (this.storyManager.isStatisticsDisabled || !payload.sendToServer)
11254
+ return;
11255
+ await api.post(`game/${payload.gameInstanceId}/instance-user-data`, { data: payload.data });
11256
+ }
11257
+ catch (error) {
11258
+ console.error(error);
11259
+ }
11260
+ }
11032
11261
  });
11033
- Object.defineProperty(this, "instanceUserData", {
11262
+ Object.defineProperty(this, "handleGetLocalData", {
11034
11263
  enumerable: true,
11035
11264
  configurable: true,
11036
11265
  writable: true,
11037
- value: void 0
11266
+ value: (session, game, payload) => {
11267
+ const { id, callback } = JSON.parse(payload);
11268
+ const gameInstanceStorage = new GameInstanceStorage(game.clientConfig.userKey, game.config.gameInstanceId, game.instanceUserData);
11269
+ const gameInstanceData = gameInstanceStorage.get();
11270
+ session.sendMessage("cb", {
11271
+ cb: callback,
11272
+ arguments: JSON.stringify([id, JSON.stringify(gameInstanceData)])
11273
+ });
11274
+ }
11038
11275
  });
11039
- Object.defineProperty(this, "clientConfig", {
11276
+ }
11277
+ attach(session, game) {
11278
+ session.on("gameInstanceSetLocalData" /* GameSessionEvent.GameInstanceSetLocalData */, (rawData) => this.handleSetLocalData(session, game, rawData));
11279
+ session.on("gameInstanceGetLocalData" /* GameSessionEvent.GameInstanceGetLocalData */, (payload) => this.handleGetLocalData(session, game, payload));
11280
+ }
11281
+ }
11282
+
11283
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/gameLocalDataModule/index.ts
11284
+
11285
+
11286
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/storyLocalDataModule/narrativeDataStorage.ts
11287
+ class NarrativeDataStorage {
11288
+ constructor(storyId) {
11289
+ Object.defineProperty(this, "storyId", {
11040
11290
  enumerable: true,
11041
11291
  configurable: true,
11042
11292
  writable: true,
11043
- value: void 0
11293
+ value: storyId
11044
11294
  });
11045
- Object.defineProperty(this, "canTryReloadCount", {
11295
+ }
11296
+ set(data) {
11297
+ sessionStorage.setItem(this.key, JSON.stringify(data));
11298
+ }
11299
+ get() {
11300
+ var _a;
11301
+ const storedData = (_a = sessionStorage.getItem(this.key)) !== null && _a !== void 0 ? _a : "{}";
11302
+ if (window.__activeNarrativeId)
11303
+ return JSON.parse(storedData);
11304
+ return {};
11305
+ }
11306
+ get key() {
11307
+ return `narrative_${this.storyId}_data`;
11308
+ }
11309
+ }
11310
+
11311
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/storyLocalDataModule/storyLocalDataModule.ts
11312
+
11313
+
11314
+
11315
+ class GameStoryLocalDataModule {
11316
+ constructor(storyManager) {
11317
+ Object.defineProperty(this, "storyManager", {
11046
11318
  enumerable: true,
11047
11319
  configurable: true,
11048
11320
  writable: true,
11049
- value: void 0
11321
+ value: storyManager
11050
11322
  });
11051
- Object.defineProperty(this, "loggerLevel", {
11323
+ Object.defineProperty(this, "session", {
11052
11324
  enumerable: true,
11053
11325
  configurable: true,
11054
11326
  writable: true,
11055
11327
  value: void 0
11056
11328
  });
11057
- Object.defineProperty(this, "lottie", {
11329
+ Object.defineProperty(this, "handleSetLocalData", {
11058
11330
  enumerable: true,
11059
11331
  configurable: true,
11060
11332
  writable: true,
11061
- value: void 0
11062
- });
11063
- this.splashScreen = gameDto.splashScreen ? new GameSplashScreen(gameDto.splashScreen) : undefined;
11064
- this.splashLandscapeScreen = gameDto.splashLandscapeScreen
11065
- ? new GameSplashLandscapeScreen(gameDto.splashLandscapeScreen)
11066
- : undefined;
11067
- this.splashLottieScreen = gameDto.splashLottieScreen
11068
- ? new GameSplashLottieScreen(gameDto.splashLottieScreen)
11069
- : undefined;
11070
- this.screenOptions = new GameScreenOptions(gameDto.screenOptions);
11071
- this.config = new GameConfig(gameDto.config);
11072
- this.resources = (_b = (_a = gameDto.resources) === null || _a === void 0 ? void 0 : _a.map(resourceDto => new GameResource(resourceDto))) !== null && _b !== void 0 ? _b : [];
11073
- this.url = gameDto.url;
11074
- this.downloadUrl = gameDto.downloadUrl;
11075
- this.instanceUserData = gameDto.instanceUserData;
11076
- this.clientConfig = new GameClientConfig(storyManager);
11077
- this.canTryReloadCount = gameDto.canTryReloadCount;
11078
- this.loggerLevel = gameDto.loggerLevel;
11079
- this.lottie = gameDto.lottie
11080
- ? {
11081
- src: gameDto.lottie.src
11333
+ value: async (rawData) => {
11334
+ try {
11335
+ const payload = JSON.parse(rawData);
11336
+ if (!isObject_default()(payload))
11337
+ return;
11338
+ const narrativeDataStorage = new NarrativeDataStorage(payload.storyId);
11339
+ narrativeDataStorage.set(payload.data);
11340
+ if (this.storyManager.isStatisticsDisabled || !payload.sendToServer)
11341
+ return;
11342
+ await api.request({
11343
+ url: "story-data/" + payload.storyId,
11344
+ method: "put",
11345
+ data: { data: payload.data }
11346
+ });
11347
+ }
11348
+ catch (error) {
11349
+ console.error(error);
11350
+ }
11082
11351
  }
11083
- : undefined;
11084
- }
11085
- toInitDto(payload) {
11086
- return (0,external_deepmerge_namespaceObject["default"])(this.config.toJSON(), {
11087
- clientConfig: Object.assign({ fullScreen: false, screenOrientation: this.screenOptions.orientation, variables: this.storyManager.config.options, safeAreaInsets: payload.safeAreaInsets, widescreen: payload.isWidescreen, dir: payload.dir, nonce: getNonce(), sdkFeatures: {
11088
- gameShouldForegroundCallback: true,
11089
- writeToClipboard: true
11090
- } }, this.clientConfig.toJSON())
11091
- });
11092
- }
11093
- }
11094
-
11095
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/gameSession.ts
11096
-
11097
- class GameSession extends events.EventEmitter {
11098
- constructor(iframe, origin) {
11099
- super();
11100
- Object.defineProperty(this, "iframe", {
11101
- enumerable: true,
11102
- configurable: true,
11103
- writable: true,
11104
- value: iframe
11105
11352
  });
11106
- Object.defineProperty(this, "origin", {
11353
+ Object.defineProperty(this, "handleGetLocalData", {
11107
11354
  enumerable: true,
11108
- configurable: true,
11109
- writable: true,
11110
- value: origin
11111
- });
11112
- this.messageListener = this.messageListener.bind(this);
11113
- window.addEventListener("message", this.messageListener, false);
11114
- }
11115
- destroy() {
11116
- window.removeEventListener("message", this.messageListener, false);
11117
- this.removeAllListeners();
11118
- }
11119
- sendMessage(event, data) {
11120
- var _a;
11121
- (_a = this.iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage([event, data], this.origin);
11122
- }
11123
- pauseGameUI() {
11124
- this.sendMessage("cb", { cb: "pauseUI", arguments: JSON.stringify([]) });
11125
- }
11126
- resumeGameUI() {
11127
- this.sendMessage("cb", { cb: "resumeUI", arguments: JSON.stringify([]) });
11128
- }
11129
- shareComplete(shareId, isSuccess) {
11130
- this.sendMessage("shareComplete", { id: shareId, isSuccess });
11131
- }
11132
- closeGameReader() {
11133
- this.sendMessage("closeGameReader");
11134
- }
11135
- initGame(gameConfig) {
11136
- this.sendMessage("cb", { cb: "initGame", arguments: JSON.stringify([gameConfig]) });
11137
- }
11138
- sendGameCenterEventByApiRequest(eventName, payload) {
11139
- this.sendMessage("cb", {
11140
- cb: eventName,
11141
- plainData: payload
11355
+ configurable: true,
11356
+ writable: true,
11357
+ value: (payload) => {
11358
+ const parsedPayload = JSON.parse(payload);
11359
+ if (!isObject_default()(parsedPayload))
11360
+ return;
11361
+ const { id, storyId, callback } = parsedPayload;
11362
+ const narrativeDataStorage = new NarrativeDataStorage(storyId);
11363
+ let narrativeData = narrativeDataStorage.get();
11364
+ this.session.sendMessage("cb", {
11365
+ cb: callback,
11366
+ arguments: JSON.stringify([id, JSON.stringify(narrativeData)])
11367
+ });
11368
+ }
11142
11369
  });
11143
11370
  }
11144
- notifyGameCanBeStarted() {
11145
- this.sendMessage("gameShouldForeground");
11146
- }
11147
- messageListener(event) {
11148
- if (event.origin !== this.origin)
11149
- return;
11150
- try {
11151
- if (!Array.isArray(event.data))
11152
- throw new Error(`[IAS]: Invalid MessageEvent data format ${event.data}`);
11153
- const [gameEvent, ...restData] = event.data;
11154
- this.emit(gameEvent, ...restData);
11155
- }
11156
- catch (err) {
11157
- console.error(err);
11158
- }
11371
+ attach(session, game) {
11372
+ this.session = session;
11373
+ session.on("storySetLocalData" /* GameSessionEvent.StorySetLocalData */, this.handleSetLocalData);
11374
+ session.on("storyGetLocalData" /* GameSessionEvent.StoryGetLocalData */, this.handleGetLocalData);
11159
11375
  }
11160
11376
  }
11161
11377
 
11162
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/models/index.ts
11378
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/storyLocalDataModule/index.ts
11379
+
11380
+
11381
+ ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/modules/index.ts
11382
+
11163
11383
 
11164
11384
 
11165
11385
 
11166
11386
 
11167
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/factories/gameSessionFactory.ts
11168
11387
 
11169
- class GameSessionFactory {
11170
- create(iframe, origin) {
11171
- return new GameSession(iframe, origin);
11172
- }
11173
- }
11174
11388
 
11175
- ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/factories/index.ts
11176
11389
 
11177
11390
 
11178
11391
  ;// CONCATENATED MODULE: ../core/src/domain/gameCenter/index.ts
@@ -11181,6 +11394,7 @@ class GameSessionFactory {
11181
11394
 
11182
11395
 
11183
11396
 
11397
+
11184
11398
  ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameReaderViewModel.ts
11185
11399
  var gameReaderViewModel_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
11186
11400
  var useValue = arguments.length > 2;
@@ -11231,18 +11445,18 @@ var gameReaderViewModel_classPrivateFieldSet = (undefined && undefined.__classPr
11231
11445
 
11232
11446
 
11233
11447
 
11234
-
11235
-
11236
-
11237
-
11238
-
11239
11448
  var GameReaderEvent;
11240
11449
  (function (GameReaderEvent) {
11241
11450
  GameReaderEvent["Close"] = "close";
11242
11451
  GameReaderEvent["OpenSharePanel"] = "openSharePanel";
11243
11452
  })(GameReaderEvent || (GameReaderEvent = {}));
11453
+ class NoOpenedGameError extends Error {
11454
+ constructor() {
11455
+ super(`[IAS]: You must open the game first`);
11456
+ }
11457
+ }
11244
11458
  let GameReaderViewModel = (() => {
11245
- var _a, _GameReaderViewModel__isOpened_accessor_storage, _GameReaderViewModel__isGameInited_accessor_storage, _GameReaderViewModel__isGameLoading_accessor_storage, _GameReaderViewModel__gameInstanceId_accessor_storage, _GameReaderViewModel__game_accessor_storage, _GameReaderViewModel__gameError_accessor_storage, _GameReaderViewModel__closeBtnVisible_accessor_storage, _GameReaderViewModel__gameShouldBeShown_accessor_storage;
11459
+ var _a, _GameReaderViewModel__isOpened_accessor_storage, _GameReaderViewModel__isGameInited_accessor_storage, _GameReaderViewModel__isGameLoading_accessor_storage, _GameReaderViewModel__game_accessor_storage, _GameReaderViewModel__gameInstanceId_accessor_storage, _GameReaderViewModel__gameError_accessor_storage, _GameReaderViewModel__closeBtnVisible_accessor_storage, _GameReaderViewModel__gameShouldBeShown_accessor_storage;
11246
11460
  let _classSuper = ViewModel;
11247
11461
  let _instanceExtraInitializers = [];
11248
11462
  let __isOpened_decorators;
@@ -11254,12 +11468,12 @@ let GameReaderViewModel = (() => {
11254
11468
  let __isGameLoading_decorators;
11255
11469
  let __isGameLoading_initializers = [];
11256
11470
  let __isGameLoading_extraInitializers = [];
11257
- let __gameInstanceId_decorators;
11258
- let __gameInstanceId_initializers = [];
11259
- let __gameInstanceId_extraInitializers = [];
11260
11471
  let __game_decorators;
11261
11472
  let __game_initializers = [];
11262
11473
  let __game_extraInitializers = [];
11474
+ let __gameInstanceId_decorators;
11475
+ let __gameInstanceId_initializers = [];
11476
+ let __gameInstanceId_extraInitializers = [];
11263
11477
  let __gameError_decorators;
11264
11478
  let __gameError_initializers = [];
11265
11479
  let __gameError_extraInitializers = [];
@@ -11269,15 +11483,14 @@ let GameReaderViewModel = (() => {
11269
11483
  let __gameShouldBeShown_decorators;
11270
11484
  let __gameShouldBeShown_initializers = [];
11271
11485
  let __gameShouldBeShown_extraInitializers = [];
11272
- let _get_dir_decorators;
11273
11486
  let _openGame_decorators;
11487
+ let _initGame_decorators;
11274
11488
  let _closeGame_decorators;
11275
- let _reload_decorators;
11276
- let _handleGameShouldBeShown_decorators;
11277
- let _handleGameLoaded_decorators;
11278
- let _handleGameComplete_decorators;
11279
- let _handleReloadGameReader_decorators;
11280
- let _handleGameLoadFailed_decorators;
11489
+ let _reloadGame_decorators;
11490
+ let _waitForeground_decorators;
11491
+ let _restartGame_decorators;
11492
+ let _showError_decorators;
11493
+ let _finishGame_decorators;
11281
11494
  return _a = class GameReaderViewModel extends _classSuper {
11282
11495
  get _isOpened() { return gameReaderViewModel_classPrivateFieldGet(this, _GameReaderViewModel__isOpened_accessor_storage, "f"); }
11283
11496
  set _isOpened(value) { gameReaderViewModel_classPrivateFieldSet(this, _GameReaderViewModel__isOpened_accessor_storage, value, "f"); }
@@ -11285,10 +11498,10 @@ let GameReaderViewModel = (() => {
11285
11498
  set _isGameInited(value) { gameReaderViewModel_classPrivateFieldSet(this, _GameReaderViewModel__isGameInited_accessor_storage, value, "f"); }
11286
11499
  get _isGameLoading() { return gameReaderViewModel_classPrivateFieldGet(this, _GameReaderViewModel__isGameLoading_accessor_storage, "f"); }
11287
11500
  set _isGameLoading(value) { gameReaderViewModel_classPrivateFieldSet(this, _GameReaderViewModel__isGameLoading_accessor_storage, value, "f"); }
11288
- get _gameInstanceId() { return gameReaderViewModel_classPrivateFieldGet(this, _GameReaderViewModel__gameInstanceId_accessor_storage, "f"); }
11289
- set _gameInstanceId(value) { gameReaderViewModel_classPrivateFieldSet(this, _GameReaderViewModel__gameInstanceId_accessor_storage, value, "f"); }
11290
11501
  get _game() { return gameReaderViewModel_classPrivateFieldGet(this, _GameReaderViewModel__game_accessor_storage, "f"); }
11291
11502
  set _game(value) { gameReaderViewModel_classPrivateFieldSet(this, _GameReaderViewModel__game_accessor_storage, value, "f"); }
11503
+ get _gameInstanceId() { return gameReaderViewModel_classPrivateFieldGet(this, _GameReaderViewModel__gameInstanceId_accessor_storage, "f"); }
11504
+ set _gameInstanceId(value) { gameReaderViewModel_classPrivateFieldSet(this, _GameReaderViewModel__gameInstanceId_accessor_storage, value, "f"); }
11292
11505
  get _gameError() { return gameReaderViewModel_classPrivateFieldGet(this, _GameReaderViewModel__gameError_accessor_storage, "f"); }
11293
11506
  set _gameError(value) { gameReaderViewModel_classPrivateFieldSet(this, _GameReaderViewModel__gameError_accessor_storage, value, "f"); }
11294
11507
  get _closeBtnVisible() { return gameReaderViewModel_classPrivateFieldGet(this, _GameReaderViewModel__closeBtnVisible_accessor_storage, "f"); }
@@ -11324,12 +11537,12 @@ let GameReaderViewModel = (() => {
11324
11537
  _GameReaderViewModel__isOpened_accessor_storage.set(this, gameReaderViewModel_runInitializers(this, __isOpened_initializers, false));
11325
11538
  _GameReaderViewModel__isGameInited_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __isOpened_extraInitializers), gameReaderViewModel_runInitializers(this, __isGameInited_initializers, false)));
11326
11539
  _GameReaderViewModel__isGameLoading_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __isGameInited_extraInitializers), gameReaderViewModel_runInitializers(this, __isGameLoading_initializers, false)));
11327
- _GameReaderViewModel__gameInstanceId_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __isGameLoading_extraInitializers), gameReaderViewModel_runInitializers(this, __gameInstanceId_initializers, null)));
11328
- _GameReaderViewModel__game_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __gameInstanceId_extraInitializers), gameReaderViewModel_runInitializers(this, __game_initializers, null)));
11329
- _GameReaderViewModel__gameError_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __game_extraInitializers), gameReaderViewModel_runInitializers(this, __gameError_initializers, null)));
11540
+ _GameReaderViewModel__game_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __isGameLoading_extraInitializers), gameReaderViewModel_runInitializers(this, __game_initializers, null)));
11541
+ _GameReaderViewModel__gameInstanceId_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __game_extraInitializers), gameReaderViewModel_runInitializers(this, __gameInstanceId_initializers, null)));
11542
+ _GameReaderViewModel__gameError_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __gameInstanceId_extraInitializers), gameReaderViewModel_runInitializers(this, __gameError_initializers, null)));
11330
11543
  _GameReaderViewModel__closeBtnVisible_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __gameError_extraInitializers), gameReaderViewModel_runInitializers(this, __closeBtnVisible_initializers, false)));
11331
11544
  _GameReaderViewModel__gameShouldBeShown_accessor_storage.set(this, (gameReaderViewModel_runInitializers(this, __closeBtnVisible_extraInitializers), gameReaderViewModel_runInitializers(this, __gameShouldBeShown_initializers, false)));
11332
- Object.defineProperty(this, "initGameRetryAttempts", {
11545
+ Object.defineProperty(this, "retryAttempts", {
11333
11546
  enumerable: true,
11334
11547
  configurable: true,
11335
11548
  writable: true,
@@ -11353,19 +11566,33 @@ let GameReaderViewModel = (() => {
11353
11566
  writable: true,
11354
11567
  value: null
11355
11568
  });
11356
- this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
11357
- document.addEventListener("visibilitychange", this.handleVisibilityChange);
11358
- }
11359
- notifyShareCompleted({ shareId, isSuccess }) {
11360
- var _b;
11361
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.shareComplete(shareId, isSuccess);
11362
- }
11363
- notifyOpenSharePanel({ shareId, shareType, shareLink }) {
11364
- this.emit(GameReaderEvent.OpenSharePanel, {
11365
- shareId,
11366
- shareType,
11367
- shareLink
11569
+ Object.defineProperty(this, "modules", {
11570
+ enumerable: true,
11571
+ configurable: true,
11572
+ writable: true,
11573
+ value: void 0
11574
+ });
11575
+ Object.defineProperty(this, "handleVisibilityChange", {
11576
+ enumerable: true,
11577
+ configurable: true,
11578
+ writable: true,
11579
+ value: () => {
11580
+ if (document.visibilityState === "hidden")
11581
+ this.pauseGameUI();
11582
+ else if (document.visibilityState === "visible")
11583
+ this.resumeGameUI();
11584
+ }
11368
11585
  });
11586
+ document.addEventListener("visibilitychange", this.handleVisibilityChange);
11587
+ this.modules = [
11588
+ new GameApiModule(),
11589
+ new GameClipboardModule(),
11590
+ new GameEventModule(this.storyManager),
11591
+ new GameNavigationModule(this.storyManager),
11592
+ new GameStoryLocalDataModule(this.storyManager),
11593
+ new GameLocalDataModule(this.storyManager),
11594
+ new GameShareModule(this)
11595
+ ];
11369
11596
  }
11370
11597
  get closeBtnVisible() {
11371
11598
  return this._closeBtnVisible;
@@ -11382,9 +11609,6 @@ let GameReaderViewModel = (() => {
11382
11609
  get game() {
11383
11610
  return this._game;
11384
11611
  }
11385
- get gameInstanceId() {
11386
- return this._gameInstanceId;
11387
- }
11388
11612
  get isOpened() {
11389
11613
  return this._isOpened;
11390
11614
  }
@@ -11394,78 +11618,33 @@ let GameReaderViewModel = (() => {
11394
11618
  get dir() {
11395
11619
  return this.storyManager.config.dir;
11396
11620
  }
11397
- async openGame(gameInstanceId, openGameOptions = {}) {
11398
- const config = await this.storyManager.waitForConfig();
11399
- if (config.anonymous) {
11400
- console.warn("[IAS]: You can't open game in anonymous access mode");
11401
- return;
11402
- }
11403
- gameInstanceId = gameInstanceId.toString();
11404
- if (gameInstanceId === this._gameInstanceId) {
11405
- console.warn(`[IAS]: Prevented reopening of game with ID ${gameInstanceId}`);
11621
+ async openGame(gameInstanceId, options = {}) {
11622
+ gameInstanceId = String(gameInstanceId);
11623
+ if (this.preventReopen(gameInstanceId))
11406
11624
  return;
11407
- }
11408
- if (this.isOpened)
11409
- throw new Error(`Close the launched game with ID "${this.gameInstanceId}"`);
11410
- this._gameInstanceId = gameInstanceId;
11625
+ await this.ensureCanOpen();
11411
11626
  this._isOpened = true;
11412
- this.openGameOptions = openGameOptions;
11627
+ this._gameInstanceId = gameInstanceId;
11413
11628
  this._gameShouldBeShown = false;
11629
+ this.openGameOptions = options;
11414
11630
  await this.launchGameById(gameInstanceId);
11415
11631
  this.scrollbarHelper.enable();
11416
11632
  }
11417
- async closeGame() {
11418
- var _b;
11419
- if (!this._isOpened)
11633
+ preventReopen(id) {
11634
+ if (id !== this._gameInstanceId)
11420
11635
  return false;
11421
- if (this._isGameInited)
11422
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.closeGameReader();
11423
- else
11424
- this.handleGameComplete({});
11636
+ console.warn(`[IAS]: Prevented reopening of game with ID ${id}`);
11425
11637
  return true;
11426
11638
  }
11427
- async reload() {
11428
- this._game = null;
11429
- if (!this.gameInstanceId)
11430
- throw new Error(`[IAS]: You must open the game first`);
11431
- await this.launchGameById(this.gameInstanceId);
11432
- }
11433
- setSafeAreaInsets(value) {
11434
- this.safeAreaInsets = value;
11435
- }
11436
- setGameCenterIframe(iframe, { isWidescreen }) {
11437
- var _b;
11438
- if (!this._game)
11439
- throw new Error("GameCenter iframe setup error");
11440
- if (this._isGameInited)
11441
- return;
11442
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.destroy();
11443
- const gameOrigin = new URL(this._game.url).origin;
11444
- this.gameSession = this.gameSessionFactory.create(iframe, gameOrigin);
11445
- this.initGameCenter({
11446
- isWidescreen,
11447
- gameSession: this.gameSession,
11448
- game: this._game
11449
- });
11450
- }
11451
- pauseGameUI() {
11452
- var _b;
11453
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.pauseGameUI();
11454
- }
11455
- resumeGameUI() {
11456
- var _b;
11457
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.resumeGameUI();
11458
- }
11459
- notifyGameCanBeStarted() {
11460
- var _b;
11461
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.notifyGameCanBeStarted();
11462
- }
11463
- destroy() {
11639
+ async ensureCanOpen() {
11464
11640
  var _b;
11465
- this.scrollbarHelper.disable();
11466
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.destroy();
11467
- document.removeEventListener("visibilitychange", this.handleVisibilityChange);
11468
- this.completeGame();
11641
+ const config = await this.storyManager.waitForConfig();
11642
+ if (config.anonymous) {
11643
+ console.warn("[IAS]: You can't open game in anonymous access mode");
11644
+ throw new Error("Anonymous mode is not allowed");
11645
+ }
11646
+ if (this.isOpened)
11647
+ throw new Error(`Close the launched game with ID "${(_b = this.game) === null || _b === void 0 ? void 0 : _b.id}"`);
11469
11648
  }
11470
11649
  async launchGameById(gameInstanceId) {
11471
11650
  try {
@@ -11476,175 +11655,112 @@ let GameReaderViewModel = (() => {
11476
11655
  gameInstanceId,
11477
11656
  gameOptions: this.openGameOptions
11478
11657
  });
11479
- this._game = new Game(this.storyManager, gameDto);
11658
+ this._game = new Game(gameInstanceId, this.storyManager, gameDto);
11480
11659
  }
11481
11660
  catch (error) {
11482
- this._gameError = error;
11661
+ this.showError(error.message);
11483
11662
  }
11484
11663
  }
11485
- initGameCenter({ isWidescreen, gameSession, game }) {
11486
- this.handleGameCenterEvents(game, gameSession);
11487
- const gameInitDto = game.toInitDto({
11488
- safeAreaInsets: this.safeAreaInsets,
11489
- dir: this.dir,
11490
- isWidescreen
11491
- });
11492
- gameSession.initGame(gameInitDto);
11493
- }
11494
- handleGameCenterEvents(game, gameSession) {
11495
- gameSession
11496
- .on("gameLoaded" /* GameSessionEvent.GameLoaded */, this.handleGameLoaded.bind(this))
11497
- .on("gameComplete" /* GameSessionEvent.GameComplete */, this.handleGameComplete.bind(this))
11498
- .on("sendApiRequest" /* GameSessionEvent.SendApiRequest */, this.handleSendApiRequest.bind(this))
11499
- .on("openUrl" /* GameSessionEvent.OpenUrl */, this.handleOpenUrl.bind(this))
11500
- .on("event" /* GameSessionEvent.Event */, this.handleGameEvent.bind(this))
11501
- .on("reloadGameReader" /* GameSessionEvent.ReloadGameReader */, this.handleReloadGameReader.bind(this))
11502
- .on("gameLoadFailed" /* GameSessionEvent.GameLoadFailed */, this.handleGameLoadFailed.bind(this))
11503
- .on("gameShouldForegroundCallback" /* GameSessionEvent.GameShouldForegroundCallback */, this.handleGameShouldBeShown.bind(this))
11504
- .on("writeToClipboard" /* GameSessionEvent.WriteToClipboard */, this.handleWriteToClipboard.bind(this));
11505
- const handlers = {
11506
- ["share" /* GameSessionEvent.Share */]: new ShareActionHandler(gameSession, this, isDesktopMode_isDesktopMode),
11507
- ["storySetLocalData" /* GameSessionEvent.StorySetLocalData */]: new StorySetLocalDataHandler(this.storyManager),
11508
- ["storyGetLocalData" /* GameSessionEvent.StoryGetLocalData */]: new StoryGetLocalDataHandler(gameSession),
11509
- ["gameInstanceGetLocalData" /* GameSessionEvent.GameInstanceGetLocalData */]: new GameInstanceGetLocalDataHandler(gameSession, game),
11510
- ["gameInstanceSetLocalData" /* GameSessionEvent.GameInstanceSetLocalData */]: new GameInstanceSetLocalDataHandler(this.storyManager, game)
11511
- };
11512
- for (const [eventName, handler] of Object.entries(handlers))
11513
- gameSession.on(eventName, (...args) => handler.handle(...args));
11514
- }
11515
- handleGameShouldBeShown(serializedPayload) {
11516
- this._gameShouldBeShown = true;
11517
- const parsedPayload = JSON.parse(serializedPayload);
11518
- if (!(0,isObject_js_namespaceObject["default"])(parsedPayload))
11664
+ async initGame(iframe, params) {
11665
+ if (!this._game)
11666
+ throw new NoOpenedGameError();
11667
+ if (this._isGameInited)
11519
11668
  return;
11520
- this._closeBtnVisible = Boolean(parsedPayload.showClose);
11521
- }
11522
- handleGameLoaded() {
11523
11669
  try {
11524
- this.initGame();
11525
- this.startGame();
11670
+ this.closeSession();
11671
+ const session = await this.createAndOpenSession({
11672
+ iframe,
11673
+ game: this._game,
11674
+ params: Object.assign(Object.assign({}, params), { dir: this.dir, safeAreaInsets: this.safeAreaInsets })
11675
+ });
11676
+ this.subscribeToGameSession(session);
11677
+ this.gameSession = session;
11678
+ this._isGameInited = true;
11679
+ this._isGameLoading = false;
11680
+ await this.waitForeground(session);
11526
11681
  }
11527
11682
  catch (error) {
11528
- console.error(error);
11683
+ this.handleGameLoadError(error);
11529
11684
  }
11530
11685
  }
11531
- initGame() {
11532
- this._isGameInited = true;
11533
- this._isGameLoading = false;
11534
- }
11535
- completeGame() {
11536
- this._isGameInited = false;
11537
- this._isOpened = false;
11538
- this._game = null;
11539
- this._gameInstanceId = null;
11686
+ async createAndOpenSession({ iframe, game, params }) {
11687
+ const gameOrigin = new URL(game.url).origin;
11688
+ const session = this.gameSessionFactory.create(iframe, gameOrigin);
11689
+ const dto = game.toInitDto(params);
11690
+ await session.open(dto);
11691
+ this.useGameModules(session, game);
11692
+ this.storyManager.emit("startGame", { id: game.id });
11693
+ return session;
11540
11694
  }
11541
- startGame() {
11542
- this.storyManager.emit("startGame", {
11543
- id: this.gameInstanceId
11544
- });
11695
+ useGameModules(session, game) {
11696
+ for (const module of this.modules)
11697
+ module.attach(session, game);
11545
11698
  }
11546
- handleVisibilityChange() {
11547
- if (document.visibilityState === "hidden")
11548
- this.pauseGameUI();
11549
- else if (document.visibilityState === "visible")
11550
- this.resumeGameUI();
11699
+ async closeGame() {
11700
+ var _b;
11701
+ if (!this._isOpened || !this._game)
11702
+ return false;
11703
+ if (this._isGameInited)
11704
+ (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.closeGameReader();
11705
+ else
11706
+ this.finishGame({ result: {} });
11707
+ return true;
11551
11708
  }
11552
- handleGameComplete(result, arg1, arg2, openStory, gameInstance) {
11553
- this.resetGameState(result);
11554
- this.processGameResult(gameInstance, openStory);
11709
+ async reloadGame() {
11710
+ this._game = null;
11711
+ if (!this._gameInstanceId)
11712
+ throw new NoOpenedGameError();
11713
+ await this.launchGameById(this._gameInstanceId);
11555
11714
  }
11556
- resetGameState(result) {
11557
- var _b;
11558
- const gameId = this.gameInstanceId;
11559
- if (!gameId)
11560
- throw new Error(`[IAS]: No game instance ID on game complete`);
11561
- this.scrollbarHelper.disable();
11562
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.destroy();
11563
- this.completeGame();
11564
- this.emitGameCompleteEventByStoryManager(gameId, result);
11715
+ setSafeAreaInsets(value) {
11716
+ this.safeAreaInsets = value;
11565
11717
  }
11566
- processGameResult(gameInstance, openStory) {
11567
- if (gameInstance === null || gameInstance === void 0 ? void 0 : gameInstance.id) {
11568
- this.openGame(gameInstance.id, {});
11569
- return;
11718
+ handleGameLoadError(error) {
11719
+ if (error instanceof GameLoadFailedError && error.canTryReload && this.canRestartGame()) {
11720
+ this.restartGame();
11721
+ this.retryAttempts++;
11570
11722
  }
11571
- if (openStory === null || openStory === void 0 ? void 0 : openStory.id) {
11572
- this.storyManager.showStory(openStory.id);
11723
+ else if (error instanceof Error) {
11724
+ this.showError(error.message);
11573
11725
  }
11574
- this.emit(GameReaderEvent.Close);
11575
11726
  }
11576
- emitGameCompleteEventByStoryManager(gameInstanceId, gameCompleteData) {
11577
- if ((0,isEmpty_js_namespaceObject["default"])(gameCompleteData))
11578
- this.storyManager.emit("closeGame", { id: gameInstanceId });
11579
- else
11580
- this.storyManager.emit("finishGame", {
11581
- id: gameInstanceId,
11582
- result: gameCompleteData
11583
- });
11727
+ subscribeToGameSession(session) {
11728
+ session.on("gameComplete" /* GameSessionEvent.GameComplete */, (result, arg1, arg2, openStory, gameInstance) => {
11729
+ this.finishGame({ result, openStory, gameInstance });
11730
+ });
11731
+ session.on("reloadGameReader" /* GameSessionEvent.ReloadGameReader */, () => {
11732
+ this.restartGame();
11733
+ });
11584
11734
  }
11585
- async handleSendApiRequest(jsonPayload) {
11586
- let id, data, cb;
11587
- try {
11588
- const payload = JSON.parse(jsonPayload);
11589
- (id = payload.id), (data = payload.data), (cb = payload.cb);
11590
- await api.request({
11591
- url: payload.url,
11592
- method: payload.method,
11593
- params: payload.params,
11594
- data: payload.data,
11595
- headers: payload.headers
11596
- }).catch(console.error);
11597
- this.sendGameCenterEventByApiRequest(cb, JSON.stringify({
11598
- requestId: id,
11599
- data: JSON.stringify(data.data),
11600
- status: data.status,
11601
- headers: data.headers
11602
- }));
11603
- }
11604
- catch (error) {
11605
- if (error instanceof SyntaxError)
11606
- return;
11607
- if (!cb)
11608
- return;
11609
- this.sendGameCenterEventByApiRequest(cb, JSON.stringify({
11610
- requestId: id,
11611
- data: JSON.stringify(error),
11612
- status: 400,
11613
- headers: [{}]
11614
- }));
11615
- }
11735
+ pauseGameUI() {
11736
+ var _b;
11737
+ (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.pauseGameUI();
11616
11738
  }
11617
- handleWriteToClipboard(payload) {
11618
- try {
11619
- const { type, textValue } = JSON.parse(payload);
11620
- new Clipboard().copy(textValue);
11621
- }
11622
- catch (error) {
11623
- console.error(`[IAS]: `, error.message);
11624
- }
11739
+ resumeGameUI() {
11740
+ var _b;
11741
+ (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.resumeGameUI();
11625
11742
  }
11626
- sendGameCenterEventByApiRequest(eventName, payload) {
11743
+ notifyGameCanBeStarted() {
11627
11744
  var _b;
11628
- (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.sendGameCenterEventByApiRequest(eventName, payload);
11629
- }
11630
- handleOpenUrl(payload) {
11631
- if (!this.gameInstanceId)
11632
- throw new Error("The game instance ID is undefined");
11633
- const { url } = JSON.parse(payload);
11634
- const event = {
11635
- src: StoryManagerLinkEventSource.GameReader,
11636
- data: { id: this.gameInstanceId, url, gameInstanceId: this.gameInstanceId }
11637
- };
11638
- this.storyManager.storyLinkClickHandler(event);
11639
- // @deprecated
11640
- this.storyManager.emit("clickOnButton", event);
11745
+ (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.notifyGameCanBeStarted();
11746
+ }
11747
+ notifyShareCompleted({ shareId, isSuccess }) {
11748
+ var _b;
11749
+ (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.shareComplete(shareId, isSuccess);
11750
+ }
11751
+ notifyOpenSharePanel({ shareId, shareType, shareLink }) {
11752
+ this.emit(GameReaderEvent.OpenSharePanel, {
11753
+ shareId,
11754
+ shareType,
11755
+ shareLink
11756
+ });
11641
11757
  }
11642
- handleGameEvent(name, payload) {
11643
- // @deprecated Use `eventGame` instead
11644
- this.storyManager.emit("gameEvent", { name, payload });
11645
- this.storyManager.emit("eventGame", { name, payload });
11758
+ async waitForeground(session) {
11759
+ const payload = await session.waitForeground();
11760
+ this._gameShouldBeShown = true;
11761
+ this._closeBtnVisible = Boolean(payload.showClose);
11646
11762
  }
11647
- handleReloadGameReader() {
11763
+ restartGame() {
11648
11764
  const game = this._game;
11649
11765
  this._game = null;
11650
11766
  this._isGameInited = false;
@@ -11654,21 +11770,79 @@ let GameReaderViewModel = (() => {
11654
11770
  this._game = game;
11655
11771
  }));
11656
11772
  }
11657
- handleGameLoadFailed(reason, canTryReload) {
11658
- if (this._game && canTryReload && this.initGameRetryAttempts < this._game.canTryReloadCount) {
11659
- this.initGameRetryAttempts++;
11660
- this.handleReloadGameReader();
11773
+ canRestartGame() {
11774
+ return this._game && this.retryAttempts < this._game.canTryReloadCount;
11775
+ }
11776
+ showError(reason) {
11777
+ this._gameError = new Error(reason);
11778
+ console.error(reason);
11779
+ }
11780
+ destroy() {
11781
+ document.removeEventListener("visibilitychange", this.handleVisibilityChange);
11782
+ this.resetScrollbar();
11783
+ this.closeSession();
11784
+ this.resetFlags();
11785
+ this.resetGameData();
11786
+ }
11787
+ finishGame({ result, openStory, gameInstance }) {
11788
+ const gameId = this.ensureGameIsOpen();
11789
+ this.resetScrollbar();
11790
+ this.closeSession();
11791
+ this.resetFlags();
11792
+ this.resetGameData();
11793
+ this.resetCounters();
11794
+ this.emitGameCompletion(gameId, result);
11795
+ this.navigateAfterGame({ gameInstance, openStory });
11796
+ }
11797
+ resetScrollbar() {
11798
+ this.scrollbarHelper.disable();
11799
+ }
11800
+ closeSession() {
11801
+ var _b;
11802
+ (_b = this.gameSession) === null || _b === void 0 ? void 0 : _b.close();
11803
+ }
11804
+ resetFlags() {
11805
+ this._isGameInited = false;
11806
+ this._isOpened = false;
11807
+ this._isGameLoading = false;
11808
+ }
11809
+ resetGameData() {
11810
+ this._game = null;
11811
+ this._gameInstanceId = null;
11812
+ this.retryAttempts = 0;
11813
+ }
11814
+ resetCounters() {
11815
+ this.retryAttempts = 0;
11816
+ }
11817
+ ensureGameIsOpen() {
11818
+ var _b;
11819
+ const gameId = (_b = this.game) === null || _b === void 0 ? void 0 : _b.id;
11820
+ if (!gameId)
11821
+ throw new NoOpenedGameError();
11822
+ return gameId;
11823
+ }
11824
+ emitGameCompletion(gameId, result) {
11825
+ const event = (0,isEmpty_js_namespaceObject["default"])(result) ? "closeGame" : "finishGame";
11826
+ const payload = (0,isEmpty_js_namespaceObject["default"])(result) ? { id: gameId } : { id: gameId, result };
11827
+ this.storyManager.emit(event, payload);
11828
+ }
11829
+ navigateAfterGame(params) {
11830
+ var _b, _c;
11831
+ if ((_b = params.gameInstance) === null || _b === void 0 ? void 0 : _b.id) {
11832
+ this.openGame(params.gameInstance.id, {});
11833
+ return;
11661
11834
  }
11662
- else {
11663
- this._gameError = new Error(reason);
11835
+ if ((_c = params.openStory) === null || _c === void 0 ? void 0 : _c.id) {
11836
+ this.storyManager.showStory(params.openStory.id);
11664
11837
  }
11838
+ this.emit(GameReaderEvent.Close);
11665
11839
  }
11666
11840
  },
11667
11841
  _GameReaderViewModel__isOpened_accessor_storage = new WeakMap(),
11668
11842
  _GameReaderViewModel__isGameInited_accessor_storage = new WeakMap(),
11669
11843
  _GameReaderViewModel__isGameLoading_accessor_storage = new WeakMap(),
11670
- _GameReaderViewModel__gameInstanceId_accessor_storage = new WeakMap(),
11671
11844
  _GameReaderViewModel__game_accessor_storage = new WeakMap(),
11845
+ _GameReaderViewModel__gameInstanceId_accessor_storage = new WeakMap(),
11672
11846
  _GameReaderViewModel__gameError_accessor_storage = new WeakMap(),
11673
11847
  _GameReaderViewModel__closeBtnVisible_accessor_storage = new WeakMap(),
11674
11848
  _GameReaderViewModel__gameShouldBeShown_accessor_storage = new WeakMap(),
@@ -11678,45 +11852,37 @@ let GameReaderViewModel = (() => {
11678
11852
  __isOpened_decorators = [external_mobx_namespaceObject.observable];
11679
11853
  __isGameInited_decorators = [external_mobx_namespaceObject.observable];
11680
11854
  __isGameLoading_decorators = [external_mobx_namespaceObject.observable];
11681
- __gameInstanceId_decorators = [external_mobx_namespaceObject.observable];
11682
11855
  __game_decorators = [external_mobx_namespaceObject.observable];
11856
+ __gameInstanceId_decorators = [external_mobx_namespaceObject.observable];
11683
11857
  __gameError_decorators = [external_mobx_namespaceObject.observable];
11684
11858
  __closeBtnVisible_decorators = [external_mobx_namespaceObject.observable];
11685
11859
  __gameShouldBeShown_decorators = [external_mobx_namespaceObject.observable];
11686
- _get_dir_decorators = [external_mobx_namespaceObject.computed];
11687
11860
  _openGame_decorators = [external_mobx_namespaceObject.action];
11861
+ _initGame_decorators = [external_mobx_namespaceObject.action];
11688
11862
  _closeGame_decorators = [external_mobx_namespaceObject.action];
11689
- _reload_decorators = [external_mobx_namespaceObject.action];
11690
- _handleGameShouldBeShown_decorators = [external_mobx_namespaceObject.action];
11691
- _handleGameLoaded_decorators = [external_mobx_namespaceObject.action];
11692
- _handleGameComplete_decorators = [external_mobx_namespaceObject.action];
11693
- _handleReloadGameReader_decorators = [external_mobx_namespaceObject.action];
11694
- _handleGameLoadFailed_decorators = [external_mobx_namespaceObject.action];
11863
+ _reloadGame_decorators = [external_mobx_namespaceObject.action];
11864
+ _waitForeground_decorators = [external_mobx_namespaceObject.action];
11865
+ _restartGame_decorators = [external_mobx_namespaceObject.action];
11866
+ _showError_decorators = [external_mobx_namespaceObject.action];
11867
+ _finishGame_decorators = [external_mobx_namespaceObject.action];
11695
11868
  gameReaderViewModel_esDecorate(_a, null, __isOpened_decorators, { kind: "accessor", name: "_isOpened", static: false, private: false, access: { has: obj => "_isOpened" in obj, get: obj => obj._isOpened, set: (obj, value) => { obj._isOpened = value; } }, metadata: _metadata }, __isOpened_initializers, __isOpened_extraInitializers);
11696
11869
  gameReaderViewModel_esDecorate(_a, null, __isGameInited_decorators, { kind: "accessor", name: "_isGameInited", static: false, private: false, access: { has: obj => "_isGameInited" in obj, get: obj => obj._isGameInited, set: (obj, value) => { obj._isGameInited = value; } }, metadata: _metadata }, __isGameInited_initializers, __isGameInited_extraInitializers);
11697
11870
  gameReaderViewModel_esDecorate(_a, null, __isGameLoading_decorators, { kind: "accessor", name: "_isGameLoading", static: false, private: false, access: { has: obj => "_isGameLoading" in obj, get: obj => obj._isGameLoading, set: (obj, value) => { obj._isGameLoading = value; } }, metadata: _metadata }, __isGameLoading_initializers, __isGameLoading_extraInitializers);
11698
- gameReaderViewModel_esDecorate(_a, null, __gameInstanceId_decorators, { kind: "accessor", name: "_gameInstanceId", static: false, private: false, access: { has: obj => "_gameInstanceId" in obj, get: obj => obj._gameInstanceId, set: (obj, value) => { obj._gameInstanceId = value; } }, metadata: _metadata }, __gameInstanceId_initializers, __gameInstanceId_extraInitializers);
11699
11871
  gameReaderViewModel_esDecorate(_a, null, __game_decorators, { kind: "accessor", name: "_game", static: false, private: false, access: { has: obj => "_game" in obj, get: obj => obj._game, set: (obj, value) => { obj._game = value; } }, metadata: _metadata }, __game_initializers, __game_extraInitializers);
11872
+ gameReaderViewModel_esDecorate(_a, null, __gameInstanceId_decorators, { kind: "accessor", name: "_gameInstanceId", static: false, private: false, access: { has: obj => "_gameInstanceId" in obj, get: obj => obj._gameInstanceId, set: (obj, value) => { obj._gameInstanceId = value; } }, metadata: _metadata }, __gameInstanceId_initializers, __gameInstanceId_extraInitializers);
11700
11873
  gameReaderViewModel_esDecorate(_a, null, __gameError_decorators, { kind: "accessor", name: "_gameError", static: false, private: false, access: { has: obj => "_gameError" in obj, get: obj => obj._gameError, set: (obj, value) => { obj._gameError = value; } }, metadata: _metadata }, __gameError_initializers, __gameError_extraInitializers);
11701
11874
  gameReaderViewModel_esDecorate(_a, null, __closeBtnVisible_decorators, { kind: "accessor", name: "_closeBtnVisible", static: false, private: false, access: { has: obj => "_closeBtnVisible" in obj, get: obj => obj._closeBtnVisible, set: (obj, value) => { obj._closeBtnVisible = value; } }, metadata: _metadata }, __closeBtnVisible_initializers, __closeBtnVisible_extraInitializers);
11702
11875
  gameReaderViewModel_esDecorate(_a, null, __gameShouldBeShown_decorators, { kind: "accessor", name: "_gameShouldBeShown", static: false, private: false, access: { has: obj => "_gameShouldBeShown" in obj, get: obj => obj._gameShouldBeShown, set: (obj, value) => { obj._gameShouldBeShown = value; } }, metadata: _metadata }, __gameShouldBeShown_initializers, __gameShouldBeShown_extraInitializers);
11703
- gameReaderViewModel_esDecorate(_a, null, _get_dir_decorators, { kind: "getter", name: "dir", static: false, private: false, access: { has: obj => "dir" in obj, get: obj => obj.dir }, metadata: _metadata }, null, _instanceExtraInitializers);
11704
11876
  gameReaderViewModel_esDecorate(_a, null, _openGame_decorators, { kind: "method", name: "openGame", static: false, private: false, access: { has: obj => "openGame" in obj, get: obj => obj.openGame }, metadata: _metadata }, null, _instanceExtraInitializers);
11877
+ gameReaderViewModel_esDecorate(_a, null, _initGame_decorators, { kind: "method", name: "initGame", static: false, private: false, access: { has: obj => "initGame" in obj, get: obj => obj.initGame }, metadata: _metadata }, null, _instanceExtraInitializers);
11705
11878
  gameReaderViewModel_esDecorate(_a, null, _closeGame_decorators, { kind: "method", name: "closeGame", static: false, private: false, access: { has: obj => "closeGame" in obj, get: obj => obj.closeGame }, metadata: _metadata }, null, _instanceExtraInitializers);
11706
- gameReaderViewModel_esDecorate(_a, null, _reload_decorators, { kind: "method", name: "reload", static: false, private: false, access: { has: obj => "reload" in obj, get: obj => obj.reload }, metadata: _metadata }, null, _instanceExtraInitializers);
11707
- gameReaderViewModel_esDecorate(_a, null, _handleGameShouldBeShown_decorators, { kind: "method", name: "handleGameShouldBeShown", static: false, private: false, access: { has: obj => "handleGameShouldBeShown" in obj, get: obj => obj.handleGameShouldBeShown }, metadata: _metadata }, null, _instanceExtraInitializers);
11708
- gameReaderViewModel_esDecorate(_a, null, _handleGameLoaded_decorators, { kind: "method", name: "handleGameLoaded", static: false, private: false, access: { has: obj => "handleGameLoaded" in obj, get: obj => obj.handleGameLoaded }, metadata: _metadata }, null, _instanceExtraInitializers);
11709
- gameReaderViewModel_esDecorate(_a, null, _handleGameComplete_decorators, { kind: "method", name: "handleGameComplete", static: false, private: false, access: { has: obj => "handleGameComplete" in obj, get: obj => obj.handleGameComplete }, metadata: _metadata }, null, _instanceExtraInitializers);
11710
- gameReaderViewModel_esDecorate(_a, null, _handleReloadGameReader_decorators, { kind: "method", name: "handleReloadGameReader", static: false, private: false, access: { has: obj => "handleReloadGameReader" in obj, get: obj => obj.handleReloadGameReader }, metadata: _metadata }, null, _instanceExtraInitializers);
11711
- gameReaderViewModel_esDecorate(_a, null, _handleGameLoadFailed_decorators, { kind: "method", name: "handleGameLoadFailed", static: false, private: false, access: { has: obj => "handleGameLoadFailed" in obj, get: obj => obj.handleGameLoadFailed }, metadata: _metadata }, null, _instanceExtraInitializers);
11879
+ gameReaderViewModel_esDecorate(_a, null, _reloadGame_decorators, { kind: "method", name: "reloadGame", static: false, private: false, access: { has: obj => "reloadGame" in obj, get: obj => obj.reloadGame }, metadata: _metadata }, null, _instanceExtraInitializers);
11880
+ gameReaderViewModel_esDecorate(_a, null, _waitForeground_decorators, { kind: "method", name: "waitForeground", static: false, private: false, access: { has: obj => "waitForeground" in obj, get: obj => obj.waitForeground }, metadata: _metadata }, null, _instanceExtraInitializers);
11881
+ gameReaderViewModel_esDecorate(_a, null, _restartGame_decorators, { kind: "method", name: "restartGame", static: false, private: false, access: { has: obj => "restartGame" in obj, get: obj => obj.restartGame }, metadata: _metadata }, null, _instanceExtraInitializers);
11882
+ gameReaderViewModel_esDecorate(_a, null, _showError_decorators, { kind: "method", name: "showError", static: false, private: false, access: { has: obj => "showError" in obj, get: obj => obj.showError }, metadata: _metadata }, null, _instanceExtraInitializers);
11883
+ gameReaderViewModel_esDecorate(_a, null, _finishGame_decorators, { kind: "method", name: "finishGame", static: false, private: false, access: { has: obj => "finishGame" in obj, get: obj => obj.finishGame }, metadata: _metadata }, null, _instanceExtraInitializers);
11712
11884
  if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
11713
11885
  })(),
11714
- Object.defineProperty(_a, "id", {
11715
- enumerable: true,
11716
- configurable: true,
11717
- writable: true,
11718
- value: "GameReaderViewModel"
11719
- }),
11720
11886
  _a;
11721
11887
  })();
11722
11888
 
@@ -16463,7 +16629,7 @@ class IamStatisticCloseEvent extends IamStatisticEvent {
16463
16629
  return "close";
16464
16630
  }
16465
16631
  toQueryParams() {
16466
- return Object.assign(Object.assign({}, super.toQueryParams()), { d: this.payload.duration });
16632
+ return Object.assign(Object.assign({}, super.toQueryParams()), { d: this.payload.duration, sa: JSON.stringify(this.payload.slideAnalytics.map(({ slideIndex, duration }) => ({ si: slideIndex, d: duration }))) });
16467
16633
  }
16468
16634
  }
16469
16635
 
@@ -17535,7 +17701,8 @@ class IamReaderVisibilityObserver {
17535
17701
  iterationId: activeMessage.iterationId,
17536
17702
  slidesTotal: activeMessage.slides.length,
17537
17703
  slideIndex: activeMessage.activeSlideIndex,
17538
- duration: activeMessage.timeSinceLastShow
17704
+ duration: activeMessage.timeSinceLastShow,
17705
+ slideAnalytics: activeMessage.slidesAnalytics
17539
17706
  });
17540
17707
  }
17541
17708
  else {
@@ -17795,7 +17962,8 @@ let IamReaderViewModel = (() => {
17795
17962
  iterationId: activeMessage.iterationId,
17796
17963
  slidesTotal: activeMessage.slides.length,
17797
17964
  slideIndex: activeMessage.activeSlideIndex,
17798
- duration: activeMessage.timeSinceLastShow
17965
+ duration: activeMessage.timeSinceLastShow,
17966
+ slideAnalytics: activeMessage.slidesAnalytics
17799
17967
  });
17800
17968
  }
17801
17969
  createIamMessageViewModel(message) {
@@ -17990,12 +18158,23 @@ class IamSlideApiHandlers {
17990
18158
  });
17991
18159
  }
17992
18160
  onEvent(name, event) {
17993
- switch (name) {
17994
- case "showSlide":
17995
- if (this.iamMessage instanceof IamMultiSlideMessageViewModel) {
17996
- this.iamMessage.onShowSlide(event.index);
17997
- }
17998
- break;
18161
+ try {
18162
+ switch (name) {
18163
+ case "showSlide":
18164
+ if (this.iamMessage instanceof IamMultiSlideMessageViewModel) {
18165
+ this.iamMessage.onShowSlide(event.index);
18166
+ }
18167
+ case "slideLeft":
18168
+ {
18169
+ if (this.iamMessage instanceof IamMultiSlideMessageViewModel) {
18170
+ this.iamMessage.onSlideLeft(event.index);
18171
+ }
18172
+ }
18173
+ break;
18174
+ }
18175
+ }
18176
+ catch (error) {
18177
+ console.error(error);
17999
18178
  }
18000
18179
  }
18001
18180
  onCardLoadingStateChange(state) {
@@ -18388,6 +18567,9 @@ let IamMessageViewModel = (() => {
18388
18567
  get disableClose() {
18389
18568
  return this.iamMessage.disableClose;
18390
18569
  }
18570
+ get slidesAnalytics() {
18571
+ return [{ slideIndex: this.activeSlideIndex, duration: this.timeSinceLastShow }];
18572
+ }
18391
18573
  open() {
18392
18574
  this._isOnceOpened = true;
18393
18575
  const iterationId = this.iamMessage.trackOpen();
@@ -18643,6 +18825,12 @@ let IamMultiSlideMessageViewModel = (() => {
18643
18825
  writable: true,
18644
18826
  value: false
18645
18827
  });
18828
+ Object.defineProperty(this, "slidesMetrics", {
18829
+ enumerable: true,
18830
+ configurable: true,
18831
+ writable: true,
18832
+ value: new Map()
18833
+ });
18646
18834
  Object.defineProperty(this, "touchController", {
18647
18835
  enumerable: true,
18648
18836
  configurable: true,
@@ -18715,6 +18903,15 @@ let IamMultiSlideMessageViewModel = (() => {
18715
18903
  get disableClose() {
18716
18904
  return this.iamMessage.disableClose;
18717
18905
  }
18906
+ get slidesAnalytics() {
18907
+ return Array.from(this.slidesMetrics.values()).map(metrics => {
18908
+ var _b;
18909
+ return ({
18910
+ slideIndex: metrics.slideIndex,
18911
+ duration: (_b = metrics.leftTime) !== null && _b !== void 0 ? _b : Date.now() - metrics.showTime
18912
+ });
18913
+ });
18914
+ }
18718
18915
  open() {
18719
18916
  this._isOnceOpened = true;
18720
18917
  const iterationId = this.iamMessage.trackOpen();
@@ -18796,6 +18993,18 @@ let IamMultiSlideMessageViewModel = (() => {
18796
18993
  }
18797
18994
  onShowSlide(index) {
18798
18995
  this._activeSlideIndex = index;
18996
+ this.slidesMetrics.set(index, {
18997
+ slideIndex: index,
18998
+ showTime: Date.now(),
18999
+ leftTime: null
19000
+ });
19001
+ }
19002
+ onSlideLeft(index) {
19003
+ const slideMetrics = this.slidesMetrics.get(index);
19004
+ if (!slideMetrics)
19005
+ throw new Error(`[IAS]: Not found slide <${index}> time metrics`);
19006
+ slideMetrics.leftTime = Date.now();
19007
+ this.slidesMetrics.set(index, slideMetrics);
18799
19008
  }
18800
19009
  async restart() {
18801
19010
  await this.init();
@@ -21514,7 +21723,7 @@ class UgcEditorStore {
21514
21723
  const session = await this.storyManager.rootStore.sessionStore.open();
21515
21724
  const ugcEditorConfigDto = await this.ugcEditorApi.fetchUgcEditorConfig();
21516
21725
  const storyManagerConfig = this.storyManager.config;
21517
- const sdkVersion = "1.8.0";
21726
+ const sdkVersion = "1.9.0-rc.0";
21518
21727
  this._config = {
21519
21728
  sessionId: session.id,
21520
21729
  apiKey: storyManagerConfig.apiKey,
@@ -21945,11 +22154,11 @@ class StoryManager extends TypedEventEmitter {
21945
22154
  return this._userAgent;
21946
22155
  }
21947
22156
  get sdkVersionName() {
21948
- const sdkVersionName = "1.8.0";
22157
+ const sdkVersionName = "1.9.0-rc.0";
21949
22158
  return sdkVersionName || "0.0.0";
21950
22159
  }
21951
22160
  get sdkVersionCode() {
21952
- const sdkVersionCode = 10800;
22161
+ const sdkVersionCode = 10900;
21953
22162
  return sdkVersionCode ? parseInt(sdkVersionCode) : 0;
21954
22163
  }
21955
22164
  get lang() {
@@ -22006,7 +22215,7 @@ class StoryManager extends TypedEventEmitter {
22006
22215
  this.rootStore.storyManagerConfigStore.setConfig(configDto);
22007
22216
  }
22008
22217
  setUserAgent(userAgent) {
22009
- const sdkVersionCode = 10800;
22218
+ const sdkVersionCode = 10900;
22010
22219
  const buildVersion = sdkVersionCode ? parseInt(sdkVersionCode) : 0;
22011
22220
  // According to RFC5987, HTTP header values can legitimately be supplied using the ISO-8859-1 encoding.
22012
22221
  this._userAgent = `${userAgent} ${convertStrToLatin1(navigator.userAgent)}`;
@@ -23659,7 +23868,7 @@ const GameReader = (0,external_mobx_react_lite_namespaceObject.observer)(({ game
23659
23868
  });
23660
23869
  const handleIframeLoaded = (el) => {
23661
23870
  gameReaderIframeRef.current = el.target;
23662
- gameReader.setGameCenterIframe(gameReaderIframeRef.current, { isWidescreen });
23871
+ gameReader.initGame(gameReaderIframeRef.current, { isWidescreen }).catch(console.error);
23663
23872
  };
23664
23873
  const handleOrientationChange = ({ isWrong }) => {
23665
23874
  if (!gameReader.isGameInited)
@@ -23670,7 +23879,7 @@ const GameReader = (0,external_mobx_react_lite_namespaceObject.observer)(({ game
23670
23879
  gameReader.resumeGameUI();
23671
23880
  };
23672
23881
  const retryLoadingGame = () => {
23673
- gameReader.reload().catch(console.error);
23882
+ gameReader.reloadGame().catch(console.error);
23674
23883
  };
23675
23884
  const closeGame = () => {
23676
23885
  gameReader.closeGame();
@@ -26023,12 +26232,14 @@ class StorySlidesContainer extends HTMLElement {
26023
26232
  this.mountPoint.prepend(style);
26024
26233
  }
26025
26234
  init(story) {
26026
- /** 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. */
26027
- if (!this.mountPoint)
26028
- throw new Error("[IAS]: Mount point was undefined");
26029
- this.story = story;
26030
- this.story.attachRoot(this.mountPoint);
26031
- this.mountPoint.addEventListener("click", this.handleClick);
26235
+ requestAnimationFrame(() => {
26236
+ /** 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. */
26237
+ if (!this.mountPoint)
26238
+ throw new Error("[IAS]: Mount point was undefined");
26239
+ this.story = story;
26240
+ this.story.attachRoot(this.mountPoint);
26241
+ this.mountPoint.addEventListener("click", this.handleClick);
26242
+ });
26032
26243
  }
26033
26244
  destroy() {
26034
26245
  var _a, _b;
@@ -27447,7 +27658,7 @@ const messageViewsByType = {
27447
27658
 
27448
27659
  ;// CONCATENATED MODULE: ./src/InAppMessaging/components/BottomSheet/BottomSheet.styles.ts
27449
27660
 
27450
- 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 .close-strip-btn{margin-top:8px;width:32px;height:4px;background-color:#00000080;border-radius:var(--close-strip-btn-border-radius);position:absolute;z-index:10000;left:50%;transform:translate3d(-50%,0,0)}`;
27661
+ 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)}`;
27451
27662
 
27452
27663
  ;// CONCATENATED MODULE: external "lit/directives/style-map.js"
27453
27664
  var style_map_js_x = (y) => {
@@ -27486,13 +27697,14 @@ class BottomSheetSwipeController {
27486
27697
  }
27487
27698
  hostConnected() { }
27488
27699
  hostDisconnected() {
27489
- var _a, _b;
27700
+ var _a, _b, _c;
27490
27701
  (_a = this.touchController) === null || _a === void 0 ? void 0 : _a.off(TouchControllerEvent.TouchMoveVertical, this.handleTouchMoveVertical);
27491
27702
  (_b = this.touchController) === null || _b === void 0 ? void 0 : _b.off(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
27703
+ (_c = this.touchController) === null || _c === void 0 ? void 0 : _c.disable();
27492
27704
  }
27493
27705
  setTouchController(touchController) {
27494
27706
  this.touchController = touchController;
27495
- this.touchController.enable();
27707
+ this.touchController.forceEnable();
27496
27708
  this.touchController.on(TouchControllerEvent.TouchMoveVertical, this.handleTouchMoveVertical);
27497
27709
  this.touchController.on(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
27498
27710
  }
@@ -27506,7 +27718,7 @@ class BottomSheetSwipeController {
27506
27718
  return;
27507
27719
  this.enableBoxTransition();
27508
27720
  const translateY = this.getTranslateYByDeltaY(dy);
27509
- if (translateY > CLOSE_THRESHOLD) {
27721
+ if (translateY > CLOSE_THRESHOLD && !this.host.disableClose) {
27510
27722
  this.touchController.disable();
27511
27723
  this.translateBoxOnY(CLOSE_TRANSFORM_Y);
27512
27724
  this.host.close();
@@ -27594,7 +27806,7 @@ var BottomSheet_classPrivateFieldSet = (undefined && undefined.__classPrivateFie
27594
27806
 
27595
27807
 
27596
27808
  let BottomSheet = (() => {
27597
- var _BottomSheet_open_accessor_storage, _BottomSheet_disableClose_accessor_storage, _BottomSheet_geometry_accessor_storage, _BottomSheet_appearanceOptions_accessor_storage, _BottomSheet_touchController_accessor_storage, _BottomSheet_desktopMode_accessor_storage, _BottomSheet_isVisible_accessor_storage, _BottomSheet_isClosed_accessor_storage, _BottomSheet_backdropRef_accessor_storage, _BottomSheet_bottomSheetBoxRef_accessor_storage, _BottomSheet_bottomSheetRef_accessor_storage;
27809
+ var _BottomSheet_open_accessor_storage, _BottomSheet_disableClose_accessor_storage, _BottomSheet_geometry_accessor_storage, _BottomSheet_appearanceOptions_accessor_storage, _BottomSheet_touchController_accessor_storage, _BottomSheet_desktopMode_accessor_storage, _BottomSheet_isVisible_accessor_storage, _BottomSheet_isClosed_accessor_storage, _BottomSheet_backdropRef_accessor_storage, _BottomSheet_bottomSheetBoxRef_accessor_storage, _BottomSheet_bottomSheetRef_accessor_storage, _BottomSheet_grabHandlerAreaRef_accessor_storage;
27598
27810
  let _classDecorators = [safeCustomElement("iam-bottom-sheet")];
27599
27811
  let _classDescriptor;
27600
27812
  let _classExtraInitializers = [];
@@ -27633,6 +27845,9 @@ let BottomSheet = (() => {
27633
27845
  let _bottomSheetRef_decorators;
27634
27846
  let _bottomSheetRef_initializers = [];
27635
27847
  let _bottomSheetRef_extraInitializers = [];
27848
+ let _grabHandlerAreaRef_decorators;
27849
+ let _grabHandlerAreaRef_initializers = [];
27850
+ let _grabHandlerAreaRef_extraInitializers = [];
27636
27851
  var BottomSheet = _classThis = class extends _classSuper {
27637
27852
  get open() { return BottomSheet_classPrivateFieldGet(this, _BottomSheet_open_accessor_storage, "f"); }
27638
27853
  set open(value) { BottomSheet_classPrivateFieldSet(this, _BottomSheet_open_accessor_storage, value, "f"); }
@@ -27656,6 +27871,8 @@ let BottomSheet = (() => {
27656
27871
  set bottomSheetBoxRef(value) { BottomSheet_classPrivateFieldSet(this, _BottomSheet_bottomSheetBoxRef_accessor_storage, value, "f"); }
27657
27872
  get bottomSheetRef() { return BottomSheet_classPrivateFieldGet(this, _BottomSheet_bottomSheetRef_accessor_storage, "f"); }
27658
27873
  set bottomSheetRef(value) { BottomSheet_classPrivateFieldSet(this, _BottomSheet_bottomSheetRef_accessor_storage, value, "f"); }
27874
+ get grabHandlerAreaRef() { return BottomSheet_classPrivateFieldGet(this, _BottomSheet_grabHandlerAreaRef_accessor_storage, "f"); }
27875
+ set grabHandlerAreaRef(value) { BottomSheet_classPrivateFieldSet(this, _BottomSheet_grabHandlerAreaRef_accessor_storage, value, "f"); }
27659
27876
  constructor() {
27660
27877
  super();
27661
27878
  _BottomSheet_open_accessor_storage.set(this, BottomSheet_runInitializers(this, _open_initializers, false));
@@ -27669,11 +27886,12 @@ let BottomSheet = (() => {
27669
27886
  _BottomSheet_backdropRef_accessor_storage.set(this, (BottomSheet_runInitializers(this, _isClosed_extraInitializers), BottomSheet_runInitializers(this, _backdropRef_initializers, null)));
27670
27887
  _BottomSheet_bottomSheetBoxRef_accessor_storage.set(this, (BottomSheet_runInitializers(this, _backdropRef_extraInitializers), BottomSheet_runInitializers(this, _bottomSheetBoxRef_initializers, null)));
27671
27888
  _BottomSheet_bottomSheetRef_accessor_storage.set(this, (BottomSheet_runInitializers(this, _bottomSheetBoxRef_extraInitializers), BottomSheet_runInitializers(this, _bottomSheetRef_initializers, null)));
27889
+ _BottomSheet_grabHandlerAreaRef_accessor_storage.set(this, (BottomSheet_runInitializers(this, _bottomSheetRef_extraInitializers), BottomSheet_runInitializers(this, _grabHandlerAreaRef_initializers, null)));
27672
27890
  Object.defineProperty(this, "bottomSheetSwipeController", {
27673
27891
  enumerable: true,
27674
27892
  configurable: true,
27675
27893
  writable: true,
27676
- value: (BottomSheet_runInitializers(this, _bottomSheetRef_extraInitializers), new BottomSheetSwipeController(this))
27894
+ value: (BottomSheet_runInitializers(this, _grabHandlerAreaRef_extraInitializers), new BottomSheetSwipeController(this))
27677
27895
  });
27678
27896
  this.handleTransitionEnd = this.handleTransitionEnd.bind(this);
27679
27897
  }
@@ -27697,10 +27915,18 @@ let BottomSheet = (() => {
27697
27915
  }
27698
27916
  connectedCallback() {
27699
27917
  super.connectedCallback();
27700
- this.bottomSheetSwipeController.setTouchController(this.touchController);
27918
+ setTimeout(() => {
27919
+ const grabHandler = this.grabHandlerAreaRef;
27920
+ const canGrab = grabHandler && !this.disableClose;
27921
+ if (isDesktopMode_isDesktopMode && canGrab)
27922
+ this.touchController.setGrabHandler(grabHandler);
27923
+ if (!isDesktopMode_isDesktopMode || canGrab)
27924
+ this.bottomSheetSwipeController.setTouchController(this.touchController);
27925
+ });
27701
27926
  }
27702
27927
  disconnectedCallback() {
27703
27928
  super.disconnectedCallback();
27929
+ this.touchController.resetGrabHandler();
27704
27930
  }
27705
27931
  close() {
27706
27932
  if (this.disableClose)
@@ -27724,12 +27950,12 @@ let BottomSheet = (() => {
27724
27950
  width: this.geometry.getWidth() + "px",
27725
27951
  "--slide-border-top-left-radius": `${this.appearanceOptions.borderRadius}px`,
27726
27952
  "--slide-border-top-right-radius": `${this.appearanceOptions.borderRadius}px`,
27727
- "--close-strip-btn-border-radius": `${this.appearanceOptions.closeButton.width / 2}px`
27953
+ "--grab-handler-border-radius": `${this.appearanceOptions.closeButton.width / 2}px`
27728
27954
  };
27729
27955
  const bottomSheetBoxWrapperStyle = {
27730
27956
  width: this.geometry.getWidth() + "px"
27731
27957
  };
27732
- const closeStripButtonStyle = {
27958
+ const grabHandlerStyle = {
27733
27959
  backgroundColor: this.appearanceOptions.closeButton.backgroundColor,
27734
27960
  width: `${this.appearanceOptions.closeButton.width}px`,
27735
27961
  height: `${this.appearanceOptions.closeButton.height}px`,
@@ -27743,7 +27969,7 @@ let BottomSheet = (() => {
27743
27969
  "bottom-sheet__box-wrapper--desktop-mode": this.desktopMode
27744
27970
  })}" style="${(0,style_map_js_namespaceObject.styleMap)(bottomSheetBoxWrapperStyle)}"><div style="${(0,style_map_js_namespaceObject.styleMap)(bottomSheetBoxStyle)}" id="bottom-sheet__box" class="bottom-sheet__box ${(0,class_map_js_namespaceObject.classMap)({
27745
27971
  "bottom-sheet__box--open": this.isVisible
27746
- })}"><div class="bottom-sheet__header">${this.disableClose ? external_lit_namespaceObject.nothing : (0,external_lit_namespaceObject.html) `<div class="close-strip-btn" style="${(0,style_map_js_namespaceObject.styleMap)(closeStripButtonStyle)}"></div>`}</div><slot></slot></div></div></div>`;
27972
+ })}"><div class="bottom-sheet__header">${this.disableClose ? external_lit_namespaceObject.nothing : (0,external_lit_namespaceObject.html) `<div id="grab-handler-area" class="grab-handler-area"><div class="grab-handler" style="${(0,style_map_js_namespaceObject.styleMap)(grabHandlerStyle)}"></div></div>`}</div><slot></slot></div></div></div>`;
27747
27973
  }
27748
27974
  };
27749
27975
  _BottomSheet_open_accessor_storage = new WeakMap();
@@ -27757,6 +27983,7 @@ let BottomSheet = (() => {
27757
27983
  _BottomSheet_backdropRef_accessor_storage = new WeakMap();
27758
27984
  _BottomSheet_bottomSheetBoxRef_accessor_storage = new WeakMap();
27759
27985
  _BottomSheet_bottomSheetRef_accessor_storage = new WeakMap();
27986
+ _BottomSheet_grabHandlerAreaRef_accessor_storage = new WeakMap();
27760
27987
  __setFunctionName(_classThis, "BottomSheet");
27761
27988
  (() => {
27762
27989
  var _a;
@@ -27772,6 +27999,7 @@ let BottomSheet = (() => {
27772
27999
  _backdropRef_decorators = [(0,decorators_js_namespaceObject.query)("#bottom-sheet__backdrop")];
27773
28000
  _bottomSheetBoxRef_decorators = [(0,decorators_js_namespaceObject.query)("#bottom-sheet__box")];
27774
28001
  _bottomSheetRef_decorators = [(0,decorators_js_namespaceObject.query)("#bottom-sheet")];
28002
+ _grabHandlerAreaRef_decorators = [(0,decorators_js_namespaceObject.query)("#grab-handler-area")];
27775
28003
  BottomSheet_esDecorate(_classThis, null, _open_decorators, { kind: "accessor", name: "open", static: false, private: false, access: { has: obj => "open" in obj, get: obj => obj.open, set: (obj, value) => { obj.open = value; } }, metadata: _metadata }, _open_initializers, _open_extraInitializers);
27776
28004
  BottomSheet_esDecorate(_classThis, null, _disableClose_decorators, { kind: "accessor", name: "disableClose", static: false, private: false, access: { has: obj => "disableClose" in obj, get: obj => obj.disableClose, set: (obj, value) => { obj.disableClose = value; } }, metadata: _metadata }, _disableClose_initializers, _disableClose_extraInitializers);
27777
28005
  BottomSheet_esDecorate(_classThis, null, _geometry_decorators, { kind: "accessor", name: "geometry", static: false, private: false, access: { has: obj => "geometry" in obj, get: obj => obj.geometry, set: (obj, value) => { obj.geometry = value; } }, metadata: _metadata }, _geometry_initializers, _geometry_extraInitializers);
@@ -27783,6 +28011,7 @@ let BottomSheet = (() => {
27783
28011
  BottomSheet_esDecorate(_classThis, null, _backdropRef_decorators, { kind: "accessor", name: "backdropRef", static: false, private: false, access: { has: obj => "backdropRef" in obj, get: obj => obj.backdropRef, set: (obj, value) => { obj.backdropRef = value; } }, metadata: _metadata }, _backdropRef_initializers, _backdropRef_extraInitializers);
27784
28012
  BottomSheet_esDecorate(_classThis, null, _bottomSheetBoxRef_decorators, { kind: "accessor", name: "bottomSheetBoxRef", static: false, private: false, access: { has: obj => "bottomSheetBoxRef" in obj, get: obj => obj.bottomSheetBoxRef, set: (obj, value) => { obj.bottomSheetBoxRef = value; } }, metadata: _metadata }, _bottomSheetBoxRef_initializers, _bottomSheetBoxRef_extraInitializers);
27785
28013
  BottomSheet_esDecorate(_classThis, null, _bottomSheetRef_decorators, { kind: "accessor", name: "bottomSheetRef", static: false, private: false, access: { has: obj => "bottomSheetRef" in obj, get: obj => obj.bottomSheetRef, set: (obj, value) => { obj.bottomSheetRef = value; } }, metadata: _metadata }, _bottomSheetRef_initializers, _bottomSheetRef_extraInitializers);
28014
+ BottomSheet_esDecorate(_classThis, null, _grabHandlerAreaRef_decorators, { kind: "accessor", name: "grabHandlerAreaRef", static: false, private: false, access: { has: obj => "grabHandlerAreaRef" in obj, get: obj => obj.grabHandlerAreaRef, set: (obj, value) => { obj.grabHandlerAreaRef = value; } }, metadata: _metadata }, _grabHandlerAreaRef_initializers, _grabHandlerAreaRef_extraInitializers);
27786
28015
  BottomSheet_esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
27787
28016
  BottomSheet = _classThis = _classDescriptor.value;
27788
28017
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
@@ -28891,7 +29120,7 @@ let Loader_Loader = (() => {
28891
29120
  enumerable: true,
28892
29121
  configurable: true,
28893
29122
  writable: true,
28894
- value: (0,external_lit_namespaceObject.css) `.loader{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,#000)}.loader__refresh-btn{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__spinner{flex-shrink:0;display:inline-block;width:32px;height:32px;border-radius:50%;border:solid 2px var(--loaderBackgroundColor,#fff);border-color:var(--loaderBackgroundAccentColor,transparent) var(--loaderBackgroundColor,#fff) var(--loaderBackgroundColor,#fff) var(--loaderBackgroundColor,#fff);animation:loading-spinner .6s infinite linear}@keyframes loading-spinner{from{transform:rotate(0)}to{transform:rotate(359deg)}}`
29123
+ value: (0,external_lit_namespaceObject.css) `.loader{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,#000);pointer-events:none}.loader__refresh-btn{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__spinner{flex-shrink:0;display:inline-block;width:32px;height:32px;border-radius:50%;border:solid 2px var(--loaderBackgroundColor,#fff);border-color:var(--loaderBackgroundAccentColor,transparent) var(--loaderBackgroundColor,#fff) var(--loaderBackgroundColor,#fff) var(--loaderBackgroundColor,#fff);animation:loading-spinner .6s infinite linear}@keyframes loading-spinner{from{transform:rotate(0)}to{transform:rotate(359deg)}}`
28895
29124
  });
28896
29125
  (() => {
28897
29126
  Loader_runInitializers(_classThis, _classExtraInitializers);
@@ -29078,7 +29307,7 @@ let InAppMessagingReader = (() => {
29078
29307
  const type = message.type;
29079
29308
  const messageGeometry = this.createMessageGeometry(type, message.appearanceOptions);
29080
29309
  const slideGeometry = this.createSlideGeometry(messageGeometry);
29081
- 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 .needShowErrorScreen="${message.needShowErrorScreen}" .needShowLoaderScreen="${message.needShowLoaderScreen}" @reload="${this.handleReloadMessage}"></iam-loader></message-view-factory>`;
29310
+ 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>`;
29082
29311
  }
29083
29312
  };
29084
29313
  _InAppMessagingReader_options_accessor_storage = new WeakMap();