@tma.js/sdk 0.12.6 → 0.12.8

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.
Files changed (33) hide show
  1. package/README.md +3 -3
  2. package/dist/dts/components/BackButton/BackButton.d.ts +1 -1
  3. package/dist/dts/components/ClosingBehaviour/ClosingBehaviour.d.ts +3 -3
  4. package/dist/dts/components/InitData/InitData.d.ts +11 -12
  5. package/dist/dts/components/MainButton/MainButton.d.ts +3 -3
  6. package/dist/dts/components/ThemeParams/ThemeParams.d.ts +1 -1
  7. package/dist/dts/components/Viewport/Viewport.d.ts +14 -14
  8. package/dist/dts/components/WebApp/WebApp.d.ts +13 -13
  9. package/dist/dts/env.d.ts +1 -1
  10. package/dist/dts/init/creators/createViewport.d.ts +1 -1
  11. package/dist/dts/init/creators/createWebApp.d.ts +1 -1
  12. package/dist/dts/init/types.d.ts +1 -1
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.iife.js +1 -1
  16. package/dist/index.iife.js.map +1 -1
  17. package/dist/index.mjs +144 -153
  18. package/dist/index.mjs.map +1 -1
  19. package/package.json +9 -9
  20. package/src/components/BackButton/BackButton.ts +6 -8
  21. package/src/components/ClosingBehaviour/ClosingBehaviour.ts +3 -3
  22. package/src/components/InitData/InitData.ts +11 -12
  23. package/src/components/MainButton/MainButton.ts +8 -9
  24. package/src/components/Viewport/Viewport.ts +14 -14
  25. package/src/components/WebApp/WebApp.ts +12 -12
  26. package/src/env.ts +1 -1
  27. package/src/errors/MethodNotSupportedError.ts +1 -1
  28. package/src/errors/ParameterNotSupportedError.ts +1 -1
  29. package/src/init/creators/createViewport.ts +1 -1
  30. package/src/init/creators/createWebApp.ts +1 -1
  31. package/src/init/css.ts +1 -1
  32. package/src/init/init.ts +1 -1
  33. package/src/init/types.ts +1 -1
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var it = Object.defineProperty;
2
2
  var at = (s, t, e) => t in s ? it(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
3
  var i = (s, t, e) => (at(s, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { parse as U, retrieveFromStorage as F, saveToStorage as ct } from "@tma.js/launch-params";
4
+ import { parse as W, retrieveFromStorage as F, saveToStorage as ct } from "@tma.js/launch-params";
5
5
  import { EventEmitter as w } from "@tma.js/event-emitter";
6
6
  import { supports as C, postEvent as g, on as x, off as K, request as _, detectSupportParams as ht, setDebug as ut, setTargetOrigin as pt, isIframe as lt } from "@tma.js/bridge";
7
7
  import { array as dt, string as j, json as gt } from "@tma.js/parsing";
@@ -13,8 +13,8 @@ function v(s, t) {
13
13
  }
14
14
  function mt(s, t) {
15
15
  return (e) => {
16
- const [o, r] = t[e];
17
- return C(o, r, s);
16
+ const [o, n] = t[e];
17
+ return C(o, n, s);
18
18
  };
19
19
  }
20
20
  class f {
@@ -32,8 +32,8 @@ class f {
32
32
  if (typeof t == "string")
33
33
  o = this.internalSet(t, e);
34
34
  else
35
- for (const r in t)
36
- this.internalSet(r, t[r]) && (o = !0);
35
+ for (const n in t)
36
+ this.internalSet(n, t[n]) && (o = !0);
37
37
  o && this.emit("changed");
38
38
  }
39
39
  get(t) {
@@ -49,11 +49,7 @@ class Ct {
49
49
  * @param event - event name.
50
50
  * @param listener - event listener.
51
51
  */
52
- i(this, "on", (t, e) => {
53
- if (t === "click")
54
- return x("back_button_pressed", e);
55
- this.ee.on(t, e);
56
- });
52
+ i(this, "on", (t, e) => t === "click" ? x("back_button_pressed", e) : this.ee.on(t, e));
57
53
  /**
58
54
  * Removes event listener.
59
55
  * @param event - event name.
@@ -114,28 +110,28 @@ class vt {
114
110
  }
115
111
  /**
116
112
  * Returns true, if the confirmation dialog enabled while the user is trying
117
- * to close the Web App.
113
+ * to close the Mini App.
118
114
  */
119
115
  get isConfirmationNeeded() {
120
116
  return this.state.get("isConfirmationNeeded");
121
117
  }
122
118
  /**
123
119
  * Disables the confirmation dialog while the user is trying to close the
124
- * Web App.
120
+ * Mini App.
125
121
  */
126
122
  disableConfirmation() {
127
123
  this.isConfirmationNeeded = !1;
128
124
  }
129
125
  /**
130
126
  * Enables the confirmation dialog while the user is trying to close the
131
- * Web App.
127
+ * Mini App.
132
128
  */
133
129
  enableConfirmation() {
134
130
  this.isConfirmationNeeded = !0;
135
131
  }
136
132
  }
137
133
  const yt = dt().of(j());
138
- function z(s, t) {
134
+ function M(s, t) {
139
135
  return s.reduce((e, o) => (e[o] = t, e), {});
140
136
  }
141
137
  class Et {
@@ -158,15 +154,15 @@ class Et {
158
154
  * @param options - execution options.
159
155
  */
160
156
  async invokeCustomMethod(t, e, o = {}) {
161
- const { result: r, error: n } = await _(
157
+ const { result: n, error: r } = await _(
162
158
  "web_app_invoke_custom_method",
163
159
  { method: t, params: e, req_id: this.createRequestId() },
164
160
  "custom_method_invoked",
165
161
  { ...o, postEvent: this.postEvent }
166
162
  );
167
- if (n)
168
- throw new Error(typeof n == "string" ? n : `Unknown error: ${JSON.stringify(n)}`);
169
- return r;
163
+ if (r)
164
+ throw new Error(typeof r == "string" ? r : `Unknown error: ${JSON.stringify(r)}`);
165
+ return n;
170
166
  }
171
167
  /**
172
168
  * Deletes specified keys from the CloudStorage.
@@ -192,12 +188,12 @@ class Et {
192
188
  */
193
189
  async getValues(t, e) {
194
190
  if (t.length === 0)
195
- return z(t, "");
191
+ return M(t, "");
196
192
  const o = gt(
197
- z(t, j())
193
+ M(t, j())
198
194
  // fixme
199
- ), r = await this.invokeCustomMethod("getStorageValues", { keys: t }, e);
200
- return o.parse(r);
195
+ ), n = await this.invokeCustomMethod("getStorageValues", { keys: t }, e);
196
+ return o.parse(n);
201
197
  }
202
198
  /**
203
199
  * Saves specified value by key.
@@ -256,8 +252,8 @@ class xt {
256
252
  constructor(t, e, o = {}) {
257
253
  i(this, "state");
258
254
  const {
259
- chat: r = null,
260
- canSendAfter: n = null,
255
+ chat: n = null,
256
+ canSendAfter: r = null,
261
257
  chatType: a = null,
262
258
  chatInstance: c = null,
263
259
  user: u = null,
@@ -267,8 +263,8 @@ class xt {
267
263
  } = o;
268
264
  this.state = new f({
269
265
  authDate: t,
270
- canSendAfter: n === null ? null : new Date(t.getTime() + n * 1e3),
271
- chat: r,
266
+ canSendAfter: r === null ? null : new Date(t.getTime() + r * 1e3),
267
+ chat: n,
272
268
  chatType: a,
273
269
  chatInstance: c,
274
270
  user: u,
@@ -285,17 +281,16 @@ class xt {
285
281
  return this.state.get("authDate");
286
282
  }
287
283
  /**
288
- * Date after which a message can be sent via the answerWebAppQuery
289
- * method.
290
- * @see https://core.telegram.org/bots/api#answerwebappquery
284
+ * Date after which a message can be sent via the
285
+ * [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.
291
286
  */
292
287
  get canSendAfter() {
293
288
  return this.state.get("canSendAfter");
294
289
  }
295
290
  /**
296
- * An object containing data about the chat where the bot was
297
- * launched via the attachment menu. Returned for supergroups, channels and
298
- * group chats – only for Web Apps launched via the attachment menu.
291
+ * An object containing data about the chat where the bot was launched via the attachment
292
+ * menu. Returned for supergroups, channels and group chats – only for Mini Apps launched via
293
+ * the attachment menu.
299
294
  */
300
295
  get chat() {
301
296
  return this.state.get("chat");
@@ -307,8 +302,8 @@ class xt {
307
302
  return this.state.get("chatType");
308
303
  }
309
304
  /**
310
- * A global identifier indicating the chat from which Mini App was
311
- * opened. Returned only for applications opened by direct link.
305
+ * A global identifier indicating the chat from which Mini App was opened. Returned only for
306
+ * applications opened by direct link.
312
307
  */
313
308
  get chatInstance() {
314
309
  return this.state.get("chatInstance");
@@ -322,7 +317,7 @@ class xt {
322
317
  return this.state.get("hash");
323
318
  }
324
319
  /**
325
- * A unique identifier for the Web App session, required for sending
320
+ * A unique identifier for the Mini App session, required for sending
326
321
  * messages via the `answerWebAppQuery` method.
327
322
  * @see https://core.telegram.org/bots/api#answerwebappquery
328
323
  */
@@ -332,7 +327,7 @@ class xt {
332
327
  /**
333
328
  * An object containing data about the chat partner of the current
334
329
  * user in the chat where the bot was launched via the attachment menu.
335
- * Returned only for private chats and only for Web Apps launched
330
+ * Returned only for private chats and only for Mini Apps launched
336
331
  * via the attachment menu.
337
332
  */
338
333
  get receiver() {
@@ -340,7 +335,7 @@ class xt {
340
335
  }
341
336
  /**
342
337
  * The value of the `startattach` parameter, passed via link. Only
343
- * returned for Web Apps when launched from the attachment menu via link.
338
+ * returned for Mini Apps when launched from the attachment menu via link.
344
339
  */
345
340
  get startParam() {
346
341
  return this.state.get("startParam");
@@ -353,7 +348,7 @@ class xt {
353
348
  }
354
349
  }
355
350
  class Vt {
356
- constructor(t, e, o, r, n, a, c = g) {
351
+ constructor(t, e, o, n, r, a, c = g) {
357
352
  i(this, "ee", new w());
358
353
  i(this, "state");
359
354
  /**
@@ -364,11 +359,7 @@ class Vt {
364
359
  * @param event - event name.
365
360
  * @param listener - event listener.
366
361
  */
367
- i(this, "on", (t, e) => {
368
- if (t === "click")
369
- return x("main_button_pressed", e);
370
- this.ee.on(t, e);
371
- });
362
+ i(this, "on", (t, e) => t === "click" ? x("main_button_pressed", e) : this.ee.on(t, e));
372
363
  /**
373
364
  * Removes event listener.
374
365
  * @param event - event name.
@@ -383,8 +374,8 @@ class Vt {
383
374
  backgroundColor: t,
384
375
  isEnabled: e,
385
376
  isVisible: o,
386
- isProgressVisible: r,
387
- text: n,
377
+ isProgressVisible: n,
378
+ text: r,
388
379
  textColor: a
389
380
  }, this.ee);
390
381
  }
@@ -471,8 +462,8 @@ class Vt {
471
462
  return this.isProgressVisible = !1, this;
472
463
  }
473
464
  /**
474
- * Shows the button. Note that opening the Web App from the attachment
475
- * menu hides the main button until the user interacts with the Web App
465
+ * Shows the button. Note that opening the Mini App from the attachment
466
+ * menu hides the main button until the user interacts with the Mini App
476
467
  * interface.
477
468
  *
478
469
  * Returns current button instance for chaining.
@@ -523,27 +514,27 @@ class Vt {
523
514
  }
524
515
  function St(s) {
525
516
  const t = s.message.trim(), e = (s.title || "").trim(), o = s.buttons || [];
526
- let r;
517
+ let n;
527
518
  if (e.length > 64)
528
519
  throw new Error(`Title has incorrect size: ${e.length}`);
529
520
  if (t.length === 0 || t.length > 256)
530
521
  throw new Error(`Message has incorrect size: ${t.length}`);
531
522
  if (o.length > 3)
532
523
  throw new Error(`Buttons have incorrect size: ${o.length}`);
533
- return o.length === 0 ? r = [{ type: "close", id: "" }] : r = o.map((n) => {
534
- const { id: a = "" } = n;
524
+ return o.length === 0 ? n = [{ type: "close", id: "" }] : n = o.map((r) => {
525
+ const { id: a = "" } = r;
535
526
  if (a.length > 64)
536
527
  throw new Error(`Button ID has incorrect size: ${a}`);
537
- if (n.type === void 0 || n.type === "default" || n.type === "destructive") {
538
- const c = n.text.trim();
528
+ if (r.type === void 0 || r.type === "default" || r.type === "destructive") {
529
+ const c = r.text.trim();
539
530
  if (c.length === 0 || c.length > 64) {
540
- const u = n.type || "default";
541
- throw new Error(`Button text with type "${u}" has incorrect size: ${n.text.length}`);
531
+ const u = r.type || "default";
532
+ throw new Error(`Button text with type "${u}" has incorrect size: ${r.text.length}`);
542
533
  }
543
- return { ...n, text: c, id: a };
534
+ return { ...r, text: c, id: a };
544
535
  }
545
- return { ...n, id: a };
546
- }), { title: e, message: t, buttons: r };
536
+ return { ...r, id: a };
537
+ }), { title: e, message: t, buttons: n };
547
538
  }
548
539
  class Pt {
549
540
  constructor(t, e = g) {
@@ -658,13 +649,13 @@ class qt {
658
649
  }
659
650
  }
660
651
  }
661
- function M(s) {
652
+ function z(s) {
662
653
  const {
663
654
  backgroundColor: t = null,
664
655
  buttonTextColor: e = null,
665
656
  buttonColor: o = null,
666
- hintColor: r = null,
667
- linkColor: n = null,
657
+ hintColor: n = null,
658
+ linkColor: r = null,
668
659
  textColor: a = null,
669
660
  secondaryBackgroundColor: c = null
670
661
  } = s;
@@ -672,8 +663,8 @@ function M(s) {
672
663
  backgroundColor: t,
673
664
  buttonTextColor: e,
674
665
  buttonColor: o,
675
- hintColor: r,
676
- linkColor: n,
666
+ hintColor: n,
667
+ linkColor: r,
677
668
  textColor: a,
678
669
  secondaryBackgroundColor: c
679
670
  };
@@ -690,7 +681,7 @@ class P {
690
681
  * Removes event listener.
691
682
  */
692
683
  i(this, "off", this.ee.off.bind(this.ee));
693
- this.state = new f(M(t), this.ee);
684
+ this.state = new f(z(t), this.ee);
694
685
  }
695
686
  /**
696
687
  * Requests fresh information about current theme.
@@ -699,11 +690,11 @@ class P {
699
690
  * @param options - method options.
700
691
  */
701
692
  static async request(t = {}) {
702
- const { timeout: e = 1e3, ...o } = t, r = await _("web_app_request_theme", "theme_changed", {
693
+ const { timeout: e = 1e3, ...o } = t, n = await _("web_app_request_theme", "theme_changed", {
703
694
  ...o,
704
695
  timeout: e
705
696
  });
706
- return N(r.theme_params);
697
+ return N(n.theme_params);
707
698
  }
708
699
  /**
709
700
  * Synchronizes specified instance of ThemeParams with the actual value in the native
@@ -712,7 +703,7 @@ class P {
712
703
  */
713
704
  static sync(t) {
714
705
  x("theme_changed", (e) => {
715
- t.state.set(M(N(e.theme_params)));
706
+ t.state.set(z(N(e.theme_params)));
716
707
  });
717
708
  }
718
709
  /**
@@ -778,7 +769,7 @@ function E(s) {
778
769
  return s < 0 ? 0 : s;
779
770
  }
780
771
  class k {
781
- constructor(t, e, o, r, n = g) {
772
+ constructor(t, e, o, n, r = g) {
782
773
  i(this, "ee", new w());
783
774
  i(this, "state");
784
775
  /**
@@ -789,9 +780,9 @@ class k {
789
780
  * Removes event listener.
790
781
  */
791
782
  i(this, "off", this.ee.off.bind(this.ee));
792
- this.postEvent = n, this.state = new f({
783
+ this.postEvent = r, this.state = new f({
793
784
  height: E(t),
794
- isExpanded: r,
785
+ isExpanded: n,
795
786
  stableHeight: E(o),
796
787
  width: E(e)
797
788
  }, this.ee);
@@ -805,14 +796,14 @@ class k {
805
796
  */
806
797
  static async request(t = {}) {
807
798
  const { timeout: e = 1e3, ...o } = t, {
808
- is_expanded: r,
809
- is_state_stable: n,
799
+ is_expanded: n,
800
+ is_state_stable: r,
810
801
  ...a
811
802
  } = await _("web_app_request_viewport", "viewport_changed", {
812
803
  ...o,
813
804
  timeout: e
814
805
  });
815
- return { ...a, isExpanded: r, isStateStable: n };
806
+ return { ...a, isExpanded: n, isStateStable: r };
816
807
  }
817
808
  /**
818
809
  * Synchronizes specified instance of Viewport with the actual value in the native
@@ -823,34 +814,34 @@ class k {
823
814
  x("viewport_changed", (e) => {
824
815
  const {
825
816
  height: o,
826
- width: r,
827
- is_expanded: n,
817
+ width: n,
818
+ is_expanded: r,
828
819
  is_state_stable: a
829
820
  } = e, c = E(o);
830
821
  t.state.set({
831
822
  height: c,
832
- isExpanded: n,
833
- width: E(r),
823
+ isExpanded: r,
824
+ width: E(n),
834
825
  stableHeight: a ? c : void 0
835
826
  });
836
827
  });
837
828
  }
838
829
  /**
839
830
  * Returns initialized instance of Viewport which is synchronized with
840
- * its actual state in Web Apps.
831
+ * its actual state in Mini Apps.
841
832
  * @param options - method options.
842
833
  */
843
834
  static async synced(t = {}) {
844
- const { height: e, isExpanded: o, width: r } = await this.request(t), n = new k(e, r, e, o, t.postEvent);
845
- return this.sync(n), n;
835
+ const { height: e, isExpanded: o, width: n } = await this.request(t), r = new k(e, n, e, o, t.postEvent);
836
+ return this.sync(r), r;
846
837
  }
847
838
  /**
848
- * The current height of the visible area of the Web App.
839
+ * The current height of the visible area of the Mini App.
849
840
  *
850
- * The application can display just the top part of the Web App, with its
841
+ * The application can display just the top part of the Mini App, with its
851
842
  * lower part remaining outside the screen area. From this position, the
852
- * user can "pull" the Web App to its maximum height, while the bot can do
853
- * the same by calling `expand` method. As the position of the Web App
843
+ * user can "pull" the Mini App to its maximum height, while the bot can do
844
+ * the same by calling `expand` method. As the position of the Mini App
854
845
  * changes, the current height value of the visible area will be updated
855
846
  * in real time.
856
847
  *
@@ -868,18 +859,18 @@ class k {
868
859
  return this.state.get("height");
869
860
  }
870
861
  /**
871
- * The height of the visible area of the Web App in its last stable state.
862
+ * The height of the visible area of the Mini App in its last stable state.
872
863
  *
873
- * The application can display just the top part of the Web App, with its
864
+ * The application can display just the top part of the Mini App, with its
874
865
  * lower part remaining outside the screen area. From this position,
875
- * the user can "pull" the Web App to its maximum height, while the bot can
866
+ * the user can "pull" the Mini App to its maximum height, while the bot can
876
867
  * do the same by calling `expand` method.
877
868
  *
878
869
  * Unlike the value of `height`, the value of `stableHeight`
879
- * does not change as the position of the Web App changes with user
870
+ * does not change as the position of the Mini App changes with user
880
871
  * gestures or during animations. The value of `stableHeight`
881
872
  * will be updated after all gestures and animations are completed and
882
- * the Web App reaches its final size.
873
+ * the Mini App reaches its final size.
883
874
  *
884
875
  * @see init
885
876
  * @see expand
@@ -889,8 +880,8 @@ class k {
889
880
  return this.state.get("stableHeight");
890
881
  }
891
882
  /**
892
- * Returns true if the Web App is expanded to the maximum available height.
893
- * Otherwise, if the Web App occupies part of the screen and can be expanded
883
+ * Returns true if the Mini App is expanded to the maximum available height.
884
+ * Otherwise, if the Mini App occupies part of the screen and can be expanded
894
885
  * to the full height using `expand` method.
895
886
  * @see expand
896
887
  */
@@ -904,8 +895,8 @@ class k {
904
895
  return this.state.get("width");
905
896
  }
906
897
  /**
907
- * A method that expands the Web App to the maximum available height. To
908
- * find out if the Web App is expanded to the maximum height, refer to the
898
+ * A method that expands the Mini App to the maximum available height. To
899
+ * find out if the Mini App is expanded to the maximum height, refer to the
909
900
  * value of the `isExpanded`.
910
901
  * @see isExpanded
911
902
  */
@@ -929,7 +920,7 @@ function T(s) {
929
920
  return t.href;
930
921
  }
931
922
  class Ot {
932
- constructor(t, e, o, r, n, a = g) {
923
+ constructor(t, e, o, n, r, a = g) {
933
924
  i(this, "ee", new w());
934
925
  i(this, "state");
935
926
  /**
@@ -948,7 +939,7 @@ class Ot {
948
939
  * Checks if specified method parameter is supported by current component.
949
940
  */
950
941
  i(this, "supportsParam");
951
- this.currentVersion = o, this.currentPlatform = r, this.createRequestId = n, this.postEvent = a, this.state = new f({
942
+ this.currentVersion = o, this.currentPlatform = n, this.createRequestId = r, this.postEvent = a, this.state = new f({
952
943
  backgroundColor: e,
953
944
  headerColor: t
954
945
  }, this.ee), this.supports = v(o, {
@@ -977,7 +968,7 @@ class Ot {
977
968
  return J(this.backgroundColor) ? "dark" : "light";
978
969
  }
979
970
  /**
980
- * Closes the Web App.
971
+ * Closes the Mini App.
981
972
  */
982
973
  close() {
983
974
  this.postEvent("web_app_close");
@@ -990,17 +981,17 @@ class Ot {
990
981
  }
991
982
  /**
992
983
  * Returns true if passed version is more than or equal to current
993
- * Web App version.
984
+ * Mini App version.
994
985
  * @param version - compared version.
995
986
  */
996
987
  isVersionAtLeast(t) {
997
988
  return _t(t, this.version) >= 0;
998
989
  }
999
990
  /**
1000
- * Opens a link in an external browser. The Web App will not be closed.
991
+ * Opens a link in an external browser. The Mini App will not be closed.
1001
992
  *
1002
993
  * Note that this method can be called only in response to the user
1003
- * interaction with the Web App interface (e.g. click inside the Web App
994
+ * interaction with the Mini App interface (e.g. click inside the Mini App
1004
995
  * or on the main button).
1005
996
  * @param url - URL to be opened.
1006
997
  * @param tryInstantView
@@ -1017,20 +1008,20 @@ class Ot {
1017
1008
  });
1018
1009
  }
1019
1010
  /**
1020
- * Opens a Telegram link inside Telegram app. The Web App will be closed.
1011
+ * Opens a Telegram link inside Telegram app. The Mini App will be closed.
1021
1012
  * It expects passing link in full format, with hostname "t.me".
1022
1013
  * @param url - URL to be opened.
1023
1014
  * @throws {Error} URL has not allowed hostname.
1024
1015
  */
1025
1016
  openTelegramLink(t) {
1026
- const { hostname: e, pathname: o, search: r } = new URL(T(t));
1017
+ const { hostname: e, pathname: o, search: n } = new URL(T(t));
1027
1018
  if (e !== "t.me")
1028
1019
  throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
1029
1020
  if (!C("web_app_open_tg_link", this.version)) {
1030
1021
  window.location.href = t;
1031
1022
  return;
1032
1023
  }
1033
- return this.postEvent("web_app_open_tg_link", { path_full: o + r });
1024
+ return this.postEvent("web_app_open_tg_link", { path_full: o + n });
1034
1025
  }
1035
1026
  /**
1036
1027
  * Opens an invoice using its url. It expects passing link in full format,
@@ -1041,27 +1032,27 @@ class Ot {
1041
1032
  const { hostname: e, pathname: o } = new URL(T(t));
1042
1033
  if (e !== "t.me")
1043
1034
  throw new Error(`Incorrect hostname: ${e}`);
1044
- const r = o.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1045
- if (r === null)
1035
+ const n = o.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1036
+ if (n === null)
1046
1037
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/slug" or "/$slug"');
1047
- const [, , n] = r;
1048
- return (await _("web_app_open_invoice", { slug: n }, "invoice_closed", {
1038
+ const [, , r] = n;
1039
+ return (await _("web_app_open_invoice", { slug: r }, "invoice_closed", {
1049
1040
  postEvent: this.postEvent,
1050
- capture: ({ slug: c }) => n === c
1041
+ capture: ({ slug: c }) => r === c
1051
1042
  })).status;
1052
1043
  }
1053
1044
  /**
1054
- * Returns current Web App platform.
1045
+ * Returns current Mini App platform.
1055
1046
  */
1056
1047
  get platform() {
1057
1048
  return this.currentPlatform;
1058
1049
  }
1059
1050
  /**
1060
- * Informs the Telegram app that the Web App is ready to be displayed.
1051
+ * Informs the Telegram app that the Mini App is ready to be displayed.
1061
1052
  *
1062
1053
  * It is recommended to call this method as early as possible, as soon as
1063
1054
  * all essential interface elements loaded. Once this method called,
1064
- * the loading placeholder is hidden and the Web App shown.
1055
+ * the loading placeholder is hidden and the Mini App shown.
1065
1056
  *
1066
1057
  * If the method not called, the placeholder will be hidden only when
1067
1058
  * the page fully loaded.
@@ -1105,10 +1096,10 @@ class Ot {
1105
1096
  /**
1106
1097
  * A method used to send data to the bot. When this method called, a
1107
1098
  * service message sent to the bot containing the data of the
1108
- * length up to 4096 bytes, and the Web App closed. See the field
1099
+ * length up to 4096 bytes, and the Mini App closed. See the field
1109
1100
  * `web_app_data` in the class Message.
1110
1101
  *
1111
- * This method is only available for Web Apps launched via a Keyboard button.
1102
+ * This method is only available for Mini Apps launched via a Keyboard button.
1112
1103
  * @param data - data to send to bot.
1113
1104
  * @throws {Error} data has incorrect size.
1114
1105
  */
@@ -1141,7 +1132,7 @@ class Ot {
1141
1132
  this.postEvent("web_app_set_background_color", { color: t }), this.state.set("backgroundColor", t);
1142
1133
  }
1143
1134
  /**
1144
- * Current Web App version. This property is used by other components to check if
1135
+ * Current Mini App version. This property is used by other components to check if
1145
1136
  * some functionality is available on current device.
1146
1137
  */
1147
1138
  get version() {
@@ -1150,12 +1141,12 @@ class Ot {
1150
1141
  }
1151
1142
  class I extends Error {
1152
1143
  constructor(t, e) {
1153
- super(`Method "${t}" is not supported in the Web Apps version ${e}.`), Object.setPrototypeOf(this, I.prototype);
1144
+ super(`Method "${t}" is not supported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, I.prototype);
1154
1145
  }
1155
1146
  }
1156
1147
  class $ extends Error {
1157
1148
  constructor(t, e, o) {
1158
- super(`Parameter "${e}" in method "${t}" is not supported in the Web Apps version ${o}.`), Object.setPrototypeOf(this, $.prototype);
1149
+ super(`Parameter "${e}" in method "${t}" is not supported in the Mini Apps version ${o}.`), Object.setPrototypeOf(this, $.prototype);
1159
1150
  }
1160
1151
  }
1161
1152
  function G(s, t) {
@@ -1164,7 +1155,7 @@ function G(s, t) {
1164
1155
  function b(s, t) {
1165
1156
  t !== null && G(s, t);
1166
1157
  }
1167
- function W(s, t) {
1158
+ function U(s, t) {
1168
1159
  G(s, `${t}px`);
1169
1160
  }
1170
1161
  function Bt(s) {
@@ -1172,16 +1163,16 @@ function Bt(s) {
1172
1163
  backgroundColor: t,
1173
1164
  buttonTextColor: e,
1174
1165
  secondaryBackgroundColor: o,
1175
- hintColor: r,
1176
- buttonColor: n,
1166
+ hintColor: n,
1167
+ buttonColor: r,
1177
1168
  linkColor: a,
1178
1169
  textColor: c
1179
1170
  } = s;
1180
- b("--tg-theme-bg-color", t), b("--tg-theme-button-color", n), b("--tg-theme-button-text-color", e), b("--tg-theme-hint-color", r), b("--tg-theme-link-color", a), b("--tg-theme-secondary-bg-color", o), b("--tg-theme-text-color", c);
1171
+ b("--tg-theme-bg-color", t), b("--tg-theme-button-color", r), b("--tg-theme-button-text-color", e), b("--tg-theme-hint-color", n), b("--tg-theme-link-color", a), b("--tg-theme-secondary-bg-color", o), b("--tg-theme-text-color", c);
1181
1172
  }
1182
1173
  function Tt(s, t) {
1183
- const { backgroundColor: e, secondaryBackgroundColor: o } = t, { backgroundColor: r, headerColor: n } = s;
1184
- b("--tg-bg-color", r), b("--tg-header-color", n === "bg_color" ? e : o);
1174
+ const { backgroundColor: e, secondaryBackgroundColor: o } = t, { backgroundColor: n, headerColor: r } = s;
1175
+ b("--tg-bg-color", n), b("--tg-header-color", r === "bg_color" ? e : o);
1185
1176
  }
1186
1177
  function It(s) {
1187
1178
  const t = () => Bt(s);
@@ -1193,9 +1184,9 @@ function $t(s, t) {
1193
1184
  }
1194
1185
  function At(s) {
1195
1186
  const t = () => {
1196
- W("--tg-viewport-height", s.height);
1187
+ U("--tg-viewport-height", s.height);
1197
1188
  }, e = () => {
1198
- W("--tg-viewport-stable-height", s.stableHeight);
1189
+ U("--tg-viewport-stable-height", s.stableHeight);
1199
1190
  };
1200
1191
  s.on("heightChanged", t), s.on("stableHeightChanged", e), t(), e();
1201
1192
  }
@@ -1213,10 +1204,10 @@ function S(s) {
1213
1204
  return t ? JSON.parse(t) : null;
1214
1205
  }
1215
1206
  function Rt(s, t, e) {
1216
- const { isVisible: o = !1 } = s ? S("back-button") || {} : {}, r = new Ct(o, t, e);
1217
- return r.on("isVisibleChanged", () => {
1218
- V("back-button", { isVisible: r.isVisible });
1219
- }), r;
1207
+ const { isVisible: o = !1 } = s ? S("back-button") || {} : {}, n = new Ct(o, t, e);
1208
+ return n.on("isVisibleChanged", () => {
1209
+ V("back-button", { isVisible: n.isVisible });
1210
+ }), n;
1220
1211
  }
1221
1212
  function Dt(s, t) {
1222
1213
  const { isConfirmationNeeded: e = !1 } = s ? S("closing-behavior") || {} : {}, o = new vt(e, t);
@@ -1226,15 +1217,15 @@ function Dt(s, t) {
1226
1217
  }
1227
1218
  function Lt(s, t, e, o) {
1228
1219
  const {
1229
- backgroundColor: r = t,
1230
- isEnabled: n = !1,
1220
+ backgroundColor: n = t,
1221
+ isEnabled: r = !1,
1231
1222
  isVisible: a = !1,
1232
1223
  isProgressVisible: c = !1,
1233
1224
  textColor: u = e,
1234
1225
  text: p = ""
1235
1226
  } = s ? S("main-button") || {} : {}, h = new Vt(
1236
- r,
1237
1227
  n,
1228
+ r,
1238
1229
  a,
1239
1230
  c,
1240
1231
  p,
@@ -1254,28 +1245,28 @@ function Nt(s, t) {
1254
1245
  return s ? (e, o) => {
1255
1246
  if (!C(e, t))
1256
1247
  throw new I(e, t);
1257
- return ft(o) && ht(e, o).forEach((r) => {
1258
- if (!C(e, r, t))
1259
- throw new $(e, r, t);
1248
+ return ft(o) && ht(e, o).forEach((n) => {
1249
+ if (!C(e, n, t))
1250
+ throw new $(e, n, t);
1260
1251
  }), g(e, o);
1261
1252
  } : g;
1262
1253
  }
1263
- function zt() {
1254
+ function Mt() {
1264
1255
  let s = 0;
1265
1256
  return () => (s += 1, s.toString());
1266
1257
  }
1267
- function Mt(s) {
1258
+ function zt(s) {
1268
1259
  const t = new P(s);
1269
1260
  return P.sync(t), t;
1270
1261
  }
1271
- async function Wt(s, t, e) {
1262
+ async function Ut(s, t, e) {
1272
1263
  const {
1273
1264
  height: o = window.innerHeight,
1274
- stableHeight: r = window.innerHeight,
1275
- width: n = window.innerWidth,
1265
+ stableHeight: n = window.innerHeight,
1266
+ width: r = window.innerWidth,
1276
1267
  isExpanded: a = !1
1277
1268
  } = s ? S("viewport") || {} : {}, u = t === "macos" || t === "web" ? (() => {
1278
- const h = new k(o, n, r, a, e);
1269
+ const h = new k(o, r, n, a, e);
1279
1270
  return k.sync(h), h;
1280
1271
  })() : await k.synced({ postEvent: e }), p = () => V("viewport", {
1281
1272
  height: u.height,
@@ -1285,7 +1276,7 @@ async function Wt(s, t, e) {
1285
1276
  });
1286
1277
  return u.on("heightChanged", p), u.on("isExpandedChanged", p), u.on("stableHeightChanged", p), u.on("widthChanged", p), u;
1287
1278
  }
1288
- function Ut(s, t, e, o, r, n) {
1279
+ function Wt(s, t, e, o, n, r) {
1289
1280
  const {
1290
1281
  backgroundColor: a = t,
1291
1282
  headerColor: c = "bg_color"
@@ -1294,8 +1285,8 @@ function Ut(s, t, e, o, r, n) {
1294
1285
  a,
1295
1286
  e,
1296
1287
  o,
1297
- r,
1298
- n
1288
+ n,
1289
+ r
1299
1290
  ), p = () => V("web-app", {
1300
1291
  backgroundColor: u.backgroundColor,
1301
1292
  headerColor: u.headerColor
@@ -1305,7 +1296,7 @@ function Ut(s, t, e, o, r, n) {
1305
1296
  function Z() {
1306
1297
  let s;
1307
1298
  try {
1308
- return U(window.location.hash.slice(1));
1299
+ return W(window.location.hash.slice(1));
1309
1300
  } catch (e) {
1310
1301
  s = e;
1311
1302
  }
@@ -1326,13 +1317,13 @@ async function jt(s = {}) {
1326
1317
  checkCompat: t = !0,
1327
1318
  cssVars: e = !1,
1328
1319
  acceptScrollbarStyle: o = !0,
1329
- acceptCustomStyles: r = o,
1330
- targetOrigin: n,
1320
+ acceptCustomStyles: n = o,
1321
+ targetOrigin: r,
1331
1322
  debug: a = !1,
1332
1323
  launchParams: c
1333
1324
  } = s;
1334
- a && ut(a), typeof n == "string" && pt(n);
1335
- const u = F(), p = c instanceof URLSearchParams || typeof c == "string" ? U(c) : Z();
1325
+ a && ut(a), typeof r == "string" && pt(r);
1326
+ const u = F(), p = c instanceof URLSearchParams || typeof c == "string" ? W(c) : Z();
1336
1327
  ct(p);
1337
1328
  const h = Ft() || Kt(u, p), {
1338
1329
  initData: l,
@@ -1344,7 +1335,7 @@ async function jt(s = {}) {
1344
1335
  backgroundColor: Y = "#ffffff",
1345
1336
  buttonColor: tt = "#000000",
1346
1337
  buttonTextColor: et = "#ffffff"
1347
- } = H, R = zt(), d = Nt(t, m), q = Mt(H), D = Ut(
1338
+ } = H, R = Mt(), d = Nt(t, m), q = zt(H), D = Wt(
1348
1339
  h,
1349
1340
  Y,
1350
1341
  m,
@@ -1354,11 +1345,11 @@ async function jt(s = {}) {
1354
1345
  ), {
1355
1346
  themeParams: st,
1356
1347
  viewport: ot,
1357
- webApp: rt
1348
+ webApp: nt
1358
1349
  } = Ht(e);
1359
- rt && $t(D, q), st && It(q);
1360
- const L = await Wt(h, A, d);
1361
- if (ot && At(L), r && lt()) {
1350
+ nt && $t(D, q), st && It(q);
1351
+ const L = await Ut(h, A, d);
1352
+ if (ot && At(L), n && lt()) {
1362
1353
  const y = document.createElement("style");
1363
1354
  y.id = "telegram-custom-styles", document.head.appendChild(y), x("set_custom_style", (B) => {
1364
1355
  y.innerHTML = B;
@@ -1378,8 +1369,8 @@ async function jt(s = {}) {
1378
1369
  webApp: D
1379
1370
  };
1380
1371
  if (l !== void 0) {
1381
- const { authDate: y, hash: B, ...nt } = l;
1382
- O.initData = new xt(y, B, nt), O.initDataRaw = X;
1372
+ const { authDate: y, hash: B, ...rt } = l;
1373
+ O.initData = new xt(y, B, rt), O.initDataRaw = X;
1383
1374
  }
1384
1375
  return O;
1385
1376
  }