@tma.js/sdk-react 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx as Et } from "react/jsx-runtime";
2
- import { createContext as ie, useContext as oe, useState as Pt, useEffect as S, useMemo as Rt, useRef as ft, useCallback as ae } from "react";
3
- var ce = Object.defineProperty, he = (e, t, s) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (he(e, typeof t != "symbol" ? t + "" : t, s), s);
1
+ import { jsx as Rt } from "react/jsx-runtime";
2
+ import { createContext as re, useContext as ie, useState as rt, useEffect as R, useRef as bt, useCallback as oe, useMemo as ae } from "react";
3
+ var ce = Object.defineProperty, he = (e, t, s) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => he(e, typeof t != "symbol" ? t + "" : t, s);
4
4
  function xt(e, t) {
5
5
  let s;
6
6
  const n = () => {
@@ -55,19 +55,19 @@ class ue {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const nt = new ue("SDK", {
58
+ const it = new ue("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
62
  let X = !1;
63
- const mt = ({ name: e, payload: t }) => {
64
- nt.log("Event received:", t ? { name: e, payload: t } : { name: e });
63
+ const vt = ({ name: e, payload: t }) => {
64
+ it.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
66
  function le(e) {
67
- X !== e && (X = e, e ? pe(mt) : Ct(mt));
67
+ X !== e && (X = e, e ? pe(vt) : Ct(vt));
68
68
  }
69
69
  function de(...e) {
70
- X && nt.log(...e);
70
+ X && it.log(...e);
71
71
  }
72
72
  class D {
73
73
  constructor() {
@@ -142,7 +142,7 @@ class D {
142
142
  function tt(e, t, s) {
143
143
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
144
144
  }
145
- function rt(...e) {
145
+ function ot(...e) {
146
146
  let t = !1;
147
147
  const s = [...e];
148
148
  return [
@@ -226,7 +226,7 @@ function Tt(e, t) {
226
226
  }
227
227
  return s;
228
228
  }
229
- function it(e) {
229
+ function at(e) {
230
230
  let t = e;
231
231
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
232
232
  throw T();
@@ -234,11 +234,11 @@ function it(e) {
234
234
  }
235
235
  function w(e, t) {
236
236
  return new G((s) => {
237
- const n = it(s);
237
+ const n = at(s);
238
238
  return Tt(e, (r) => n[r]);
239
239
  }, !1, t);
240
240
  }
241
- const R = A((e) => {
241
+ const x = A((e) => {
242
242
  if (typeof e == "number")
243
243
  return e;
244
244
  if (typeof e == "string") {
@@ -248,7 +248,7 @@ const R = A((e) => {
248
248
  }
249
249
  throw T();
250
250
  }, "number");
251
- function ot(e) {
251
+ function ct(e) {
252
252
  return /^#[\da-f]{6}$/i.test(e);
253
253
  }
254
254
  function Pe(e) {
@@ -256,7 +256,7 @@ function Pe(e) {
256
256
  }
257
257
  function At(e) {
258
258
  const t = e.replace(/\s/g, "").toLowerCase();
259
- if (ot(t))
259
+ if (ct(t))
260
260
  return t;
261
261
  if (Pe(t)) {
262
262
  let n = "#";
@@ -337,12 +337,12 @@ const Ce = {
337
337
  theme_changed: w({
338
338
  theme_params: (e) => {
339
339
  const t = It().optional();
340
- return Object.entries(it(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
340
+ return Object.entries(at(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
341
341
  }
342
342
  }),
343
343
  viewport_changed: w({
344
- height: R(),
345
- width: (e) => e == null ? window.innerWidth : R().parse(e),
344
+ height: x(),
345
+ width: (e) => e == null ? window.innerWidth : x().parse(e),
346
346
  is_state_stable: E(),
347
347
  is_expanded: E()
348
348
  }),
@@ -353,7 +353,7 @@ function Se() {
353
353
  t.subscribe((n) => {
354
354
  e.emit("event", { name: n.event, payload: n.args[0] });
355
355
  }), xe();
356
- const [, s] = rt(
356
+ const [, s] = ot(
357
357
  // Don't forget to remove created handlers.
358
358
  Re,
359
359
  // Add "resize" event listener to make sure, we always have fresh viewport information.
@@ -385,7 +385,7 @@ function Se() {
385
385
  const p = a ? a.parse(o) : o;
386
386
  t.emit(...p ? [i, p] : [i]);
387
387
  } catch (p) {
388
- nt.error(
388
+ it.error(
389
389
  `An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
390
390
  r,
391
391
  p
@@ -444,7 +444,7 @@ function Ie(e, t) {
444
444
  function v(e, t) {
445
445
  return Ie(e, t) <= 0;
446
446
  }
447
- function x(e, t, s) {
447
+ function C(e, t, s) {
448
448
  if (typeof s == "string") {
449
449
  if (e === "web_app_open_link" && t === "try_instant_view")
450
450
  return v("6.4", s);
@@ -501,7 +501,7 @@ function qt(e) {
501
501
  function Ot(e) {
502
502
  return "TelegramWebviewProxy" in e && V(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
503
503
  }
504
- function at() {
504
+ function ht() {
505
505
  try {
506
506
  return window.self !== window.top;
507
507
  } catch {
@@ -519,7 +519,7 @@ function B(e, t, s) {
519
519
  let n = {}, r;
520
520
  t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
521
521
  const { targetOrigin: i = ke() } = n;
522
- if (de("Posting event:", r ? { event: e, data: r } : { event: e }), at()) {
522
+ if (de("Posting event:", r ? { event: e, data: r } : { event: e }), ht()) {
523
523
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
524
524
  return;
525
525
  }
@@ -538,11 +538,11 @@ function B(e, t, s) {
538
538
  }
539
539
  function qe(e) {
540
540
  return (t, s) => {
541
- if (!x(t, e))
541
+ if (!C(t, e))
542
542
  throw m(_e, `Method "${t}" is unsupported in Mini Apps version ${e}`);
543
543
  if (V(s)) {
544
544
  let n;
545
- if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !x(t, n, e))
545
+ if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !C(t, n, e))
546
546
  throw m(
547
547
  we,
548
548
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
@@ -571,7 +571,7 @@ async function g(e) {
571
571
  let t;
572
572
  const s = new Promise((a) => {
573
573
  t = a;
574
- }), { event: n, capture: r, timeout: i } = e, [, o] = rt(
574
+ }), { event: n, capture: r, timeout: i } = e, [, o] = ot(
575
575
  ...(Array.isArray(n) ? n : [n]).map(
576
576
  (a) => y(a, (p) => (!r || r(p)) && t(p))
577
577
  )
@@ -647,20 +647,20 @@ class Oe {
647
647
  return this.state[t];
648
648
  }
649
649
  }
650
- class ct {
650
+ class pt {
651
651
  constructor(t) {
652
652
  c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Oe(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
653
653
  }
654
654
  }
655
655
  function Lt(e, t) {
656
- return (s) => x(t[s], e);
656
+ return (s) => C(t[s], e);
657
657
  }
658
- class ht extends ct {
658
+ class ut extends pt {
659
659
  constructor(t, s, n) {
660
660
  super(t), c(this, "supports"), this.supports = Lt(s, n);
661
661
  }
662
662
  }
663
- class Ne extends ht {
663
+ class Ne extends ut {
664
664
  constructor(t, s, n) {
665
665
  super({ isVisible: t }, s, {
666
666
  show: "web_app_setup_back_button",
@@ -689,8 +689,8 @@ class Ne extends ht {
689
689
  this.isVisible = !0;
690
690
  }
691
691
  }
692
- const $t = A((e) => e instanceof Date ? e : new Date(R().parse(e) * 1e3), "Date");
693
- function pt(e, t) {
692
+ const $t = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
693
+ function lt(e, t) {
694
694
  return new G((s) => {
695
695
  if (typeof s != "string" && !(s instanceof URLSearchParams))
696
696
  throw T();
@@ -702,7 +702,7 @@ function pt(e, t) {
702
702
  }, !1, t);
703
703
  }
704
704
  const De = w({
705
- id: R(),
705
+ id: x(),
706
706
  type: h(),
707
707
  title: h(),
708
708
  photoUrl: {
@@ -710,7 +710,7 @@ const De = w({
710
710
  from: "photo_url"
711
711
  },
712
712
  username: h().optional()
713
- }, "Chat").optional(), bt = w({
713
+ }, "Chat").optional(), yt = w({
714
714
  addedToAttachmentMenu: {
715
715
  type: E().optional(),
716
716
  from: "added_to_attachment_menu"
@@ -723,7 +723,7 @@ const De = w({
723
723
  type: h(),
724
724
  from: "first_name"
725
725
  },
726
- id: R(),
726
+ id: x(),
727
727
  isBot: {
728
728
  type: E().optional(),
729
729
  from: "is_bot"
@@ -747,13 +747,13 @@ const De = w({
747
747
  username: h().optional()
748
748
  }, "User").optional();
749
749
  function Ut() {
750
- return pt({
750
+ return lt({
751
751
  authDate: {
752
752
  type: $t(),
753
753
  from: "auth_date"
754
754
  },
755
755
  canSendAfter: {
756
- type: R().optional(),
756
+ type: x().optional(),
757
757
  from: "can_send_after"
758
758
  },
759
759
  chat: De,
@@ -770,12 +770,12 @@ function Ut() {
770
770
  type: h().optional(),
771
771
  from: "query_id"
772
772
  },
773
- receiver: bt,
773
+ receiver: yt,
774
774
  startParam: {
775
775
  type: h().optional(),
776
776
  from: "start_param"
777
777
  },
778
- user: bt
778
+ user: yt
779
779
  }, "InitData");
780
780
  }
781
781
  function Be(e) {
@@ -787,12 +787,12 @@ function Me(e) {
787
787
  const Ht = A(
788
788
  (e) => {
789
789
  const t = It().optional();
790
- return Object.entries(it(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
790
+ return Object.entries(at(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
791
791
  },
792
792
  "ThemeParams"
793
793
  );
794
- function ut(e) {
795
- return pt({
794
+ function dt(e) {
795
+ return lt({
796
796
  botInline: {
797
797
  type: E().optional(),
798
798
  from: "tgWebAppBotInline"
@@ -828,7 +828,7 @@ function ut(e) {
828
828
  }).parse(e);
829
829
  }
830
830
  function Wt(e) {
831
- return ut(
831
+ return dt(
832
832
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
833
833
  );
834
834
  }
@@ -858,7 +858,7 @@ function Kt(e) {
858
858
  }
859
859
  }
860
860
  function $e() {
861
- return ut(Kt("launchParams") || "");
861
+ return dt(Kt("launchParams") || "");
862
862
  }
863
863
  function Jt(e) {
864
864
  return JSON.stringify(
@@ -882,7 +882,7 @@ function Ue(e) {
882
882
  function Ft(e) {
883
883
  zt("launchParams", Ue(e));
884
884
  }
885
- function Qt() {
885
+ function nt() {
886
886
  for (const e of [
887
887
  // Try to retrieve launch parameters from the current location. This method can return
888
888
  // nothing in case, location was changed and then page was reloaded.
@@ -899,7 +899,7 @@ function Qt() {
899
899
  }
900
900
  throw new Error("Unable to retrieve launch parameters from any known source.");
901
901
  }
902
- function Yt() {
902
+ function Qt() {
903
903
  const e = Gt();
904
904
  return !!(e && e.type === "reload");
905
905
  }
@@ -910,23 +910,23 @@ function He() {
910
910
  const [We] = xt(He);
911
911
  function l(e, t) {
912
912
  return () => {
913
- const s = Qt(), n = {
913
+ const s = nt(), n = {
914
914
  ...s,
915
915
  postEvent: qe(s.version),
916
916
  createRequestId: We()
917
917
  };
918
918
  if (typeof e == "function")
919
919
  return e(n);
920
- const [r, i, o] = rt(), a = t({
920
+ const [r, i, o] = ot(), a = t({
921
921
  ...n,
922
922
  // State should only be passed only in case, current page was reloaded. If we don't add
923
923
  // this check, state restoration will work improperly in the web version of Telegram,
924
924
  // when we are always working in the same "session" (tab).
925
- state: Yt() ? Kt(e) : void 0,
925
+ state: Qt() ? Kt(e) : void 0,
926
926
  addCleanup: r
927
927
  }), p = (u) => (o || r(
928
- u.on("change", (C) => {
929
- zt(e, C);
928
+ u.on("change", (S) => {
929
+ zt(e, S);
930
930
  })
931
931
  ), u);
932
932
  return [
@@ -940,12 +940,12 @@ const Ge = l("backButton", ({
940
940
  version: t,
941
941
  state: s = { isVisible: !1 }
942
942
  }) => new Ne(s.isVisible, t, e));
943
- class L extends ht {
943
+ class L extends ut {
944
944
  constructor() {
945
945
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
946
946
  }
947
947
  }
948
- function Zt(e) {
948
+ function Yt(e) {
949
949
  const t = e.available ? e : {
950
950
  available: !1,
951
951
  device_id: "",
@@ -1041,7 +1041,7 @@ class je extends L {
1041
1041
  event: "biometry_info_received",
1042
1042
  params: { reason: t || "" }
1043
1043
  }).then((n) => {
1044
- const r = Zt(n);
1044
+ const r = Yt(n);
1045
1045
  return this.set(r), r.accessGranted;
1046
1046
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1047
1047
  }
@@ -1074,7 +1074,7 @@ class je extends L {
1074
1074
  }
1075
1075
  }
1076
1076
  async function ze(e) {
1077
- return Zt(
1077
+ return Yt(
1078
1078
  await g({
1079
1079
  ...e || {},
1080
1080
  method: "web_app_biometry_get_info",
@@ -1085,7 +1085,7 @@ async function ze(e) {
1085
1085
  const Ke = l(
1086
1086
  "biometryManager",
1087
1087
  async ({ postEvent: e, version: t, state: s }) => new je({
1088
- ...s || x("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1088
+ ...s || C("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1089
1089
  available: !1,
1090
1090
  accessGranted: !1,
1091
1091
  accessRequested: !1,
@@ -1096,12 +1096,12 @@ const Ke = l(
1096
1096
  postEvent: e
1097
1097
  })
1098
1098
  );
1099
- class lt extends ct {
1099
+ class _t extends pt {
1100
1100
  constructor() {
1101
1101
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1102
1102
  }
1103
1103
  }
1104
- class Je extends lt {
1104
+ class Je extends _t {
1105
1105
  constructor(t, s) {
1106
1106
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1107
1107
  }
@@ -1135,7 +1135,7 @@ const Fe = l(
1135
1135
  state: t = { isConfirmationNeeded: !1 }
1136
1136
  }) => new Je(t.isConfirmationNeeded, e)
1137
1137
  );
1138
- class dt {
1138
+ class wt {
1139
1139
  constructor(t, s) {
1140
1140
  c(this, "supports"), this.supports = Lt(t, s);
1141
1141
  }
@@ -1173,10 +1173,10 @@ class Ye extends G {
1173
1173
  function Ze(e) {
1174
1174
  return new Ye((t) => t, !1, e);
1175
1175
  }
1176
- function vt(e, t) {
1176
+ function Et(e, t) {
1177
1177
  return Object.fromEntries(e.map((s) => [s, t]));
1178
1178
  }
1179
- class Xe extends dt {
1179
+ class Xe extends wt {
1180
1180
  constructor(t, s, n) {
1181
1181
  super(t, {
1182
1182
  delete: "web_app_invoke_custom_method",
@@ -1216,13 +1216,13 @@ class Xe extends dt {
1216
1216
  async get(t, s = {}) {
1217
1217
  const n = Array.isArray(t) ? t : [t];
1218
1218
  if (!n.length)
1219
- return vt(n, "");
1219
+ return Et(n, "");
1220
1220
  const r = await O(
1221
1221
  "getStorageValues",
1222
1222
  { keys: n },
1223
1223
  this.createRequestId(),
1224
1224
  { ...s, postEvent: this.postEvent }
1225
- ), i = w(vt(n, h()), "CloudStorageData").parse(r);
1225
+ ), i = w(Et(n, h()), "CloudStorageData").parse(r);
1226
1226
  return Array.isArray(t) ? i : i[t];
1227
1227
  }
1228
1228
  /**
@@ -1243,7 +1243,7 @@ class Xe extends dt {
1243
1243
  const ts = l(
1244
1244
  ({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
1245
1245
  );
1246
- class es extends dt {
1246
+ class es extends wt {
1247
1247
  constructor(t, s) {
1248
1248
  super(t, {
1249
1249
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1414,7 +1414,7 @@ class is extends L {
1414
1414
  const os = l(
1415
1415
  ({ version: e, postEvent: t }) => new is(!1, e, t)
1416
1416
  );
1417
- class as extends ct {
1417
+ class as extends pt {
1418
1418
  constructor({ postEvent: t, ...s }) {
1419
1419
  super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? y("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1420
1420
  }
@@ -1561,10 +1561,10 @@ const cs = l(
1561
1561
  }) => new as({ ...s, postEvent: e })
1562
1562
  );
1563
1563
  function hs() {
1564
- return pt({
1564
+ return lt({
1565
1565
  contact: w({
1566
1566
  userId: {
1567
- type: R(),
1567
+ type: x(),
1568
1568
  from: "user_id"
1569
1569
  },
1570
1570
  phoneNumber: {
@@ -1587,10 +1587,10 @@ function hs() {
1587
1587
  hash: h()
1588
1588
  }, "RequestedContact");
1589
1589
  }
1590
- function Xt(e, t) {
1590
+ function Zt(e, t) {
1591
1591
  return (s) => {
1592
1592
  const [n, r] = t[s];
1593
- return x(n, r, e);
1593
+ return C(n, r, e);
1594
1594
  };
1595
1595
  }
1596
1596
  function ps(e) {
@@ -1608,7 +1608,7 @@ class us extends L {
1608
1608
  setBackgroundColor: "web_app_set_background_color"
1609
1609
  }), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
1610
1610
  const o = this.supports.bind(this);
1611
- this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
1611
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Zt(n, {
1612
1612
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1613
1613
  });
1614
1614
  }
@@ -1751,7 +1751,7 @@ class us extends L {
1751
1751
  * @param color - color key or RGB color.
1752
1752
  */
1753
1753
  setHeaderColor(t) {
1754
- this.postEvent("web_app_set_header_color", ot(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1754
+ this.postEvent("web_app_set_header_color", ct(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1755
1755
  }
1756
1756
  /**
1757
1757
  * Updates current Mini App background color.
@@ -1905,7 +1905,7 @@ class gs extends L {
1905
1905
  const fs = l(
1906
1906
  ({ version: e, postEvent: t }) => new gs(!1, e, t)
1907
1907
  );
1908
- class ms extends ht {
1908
+ class ms extends ut {
1909
1909
  constructor(t, s, n) {
1910
1910
  super({ isVisible: t }, s, {
1911
1911
  show: "web_app_setup_settings_button",
@@ -1942,10 +1942,10 @@ const bs = l(
1942
1942
  state: s = { isVisible: !1 }
1943
1943
  }) => new ms(s.isVisible, e, t)
1944
1944
  );
1945
- function te(e) {
1945
+ function Xt(e) {
1946
1946
  return Ht().parse(e);
1947
1947
  }
1948
- class vs extends lt {
1948
+ class vs extends _t {
1949
1949
  /**
1950
1950
  * @since v6.10
1951
1951
  */
@@ -2010,7 +2010,7 @@ class vs extends lt {
2010
2010
  */
2011
2011
  listen() {
2012
2012
  return y("theme_changed", (t) => {
2013
- this.set(te(t.theme_params));
2013
+ this.set(Xt(t.theme_params));
2014
2014
  });
2015
2015
  }
2016
2016
  /**
@@ -2035,11 +2035,11 @@ function mn(e = {}) {
2035
2035
  ...e,
2036
2036
  method: "web_app_request_theme",
2037
2037
  event: "theme_changed"
2038
- }).then(te);
2038
+ }).then(Xt);
2039
2039
  }
2040
- class Es extends dt {
2040
+ class Es extends wt {
2041
2041
  constructor(t, s, n) {
2042
- super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Xt(t, {
2042
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Zt(t, {
2043
2043
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2044
2044
  });
2045
2045
  }
@@ -2054,7 +2054,7 @@ class Es extends dt {
2054
2054
  */
2055
2055
  openLink(t, s) {
2056
2056
  const n = new URL(t, window.location.href).toString();
2057
- if (!x("web_app_open_link", this.version)) {
2057
+ if (!C("web_app_open_link", this.version)) {
2058
2058
  window.open(n, "_blank");
2059
2059
  return;
2060
2060
  }
@@ -2073,7 +2073,7 @@ class Es extends dt {
2073
2073
  const { hostname: s, pathname: n, search: r } = new URL(t, "https://t.me");
2074
2074
  if (s !== "t.me")
2075
2075
  throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
2076
- if (!x("web_app_open_tg_link", this.version)) {
2076
+ if (!C("web_app_open_tg_link", this.version)) {
2077
2077
  window.location.href = t;
2078
2078
  return;
2079
2079
  }
@@ -2105,17 +2105,18 @@ class Es extends dt {
2105
2105
  * @param url - URL to share.
2106
2106
  * @param text - text to append after the URL.
2107
2107
  * @see https://core.telegram.org/api/links#share-links
2108
+ * @see https://core.telegram.org/widgets/share#custom-buttons
2108
2109
  */
2109
2110
  shareURL(t, s) {
2110
2111
  this.openTelegramLink(
2111
- "https://t.me/share?" + new URLSearchParams({ url: t, text: s || "" }).toString()
2112
+ "https://t.me/share/url?" + new URLSearchParams({ url: t, text: s || "" }).toString()
2112
2113
  );
2113
2114
  }
2114
2115
  }
2115
2116
  const Ps = l(
2116
2117
  ({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
2117
2118
  );
2118
- async function ee(e = {}) {
2119
+ async function te(e = {}) {
2119
2120
  const {
2120
2121
  is_expanded: t,
2121
2122
  is_state_stable: s,
@@ -2130,7 +2131,7 @@ async function ee(e = {}) {
2130
2131
  function q(e) {
2131
2132
  return e < 0 ? 0 : e;
2132
2133
  }
2133
- class Rs extends lt {
2134
+ class Rs extends _t {
2134
2135
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2135
2136
  super({
2136
2137
  height: q(n),
@@ -2145,7 +2146,7 @@ class Rs extends lt {
2145
2146
  * @param options - options to request fresh data.
2146
2147
  */
2147
2148
  async sync(t) {
2148
- const { isStateStable: s, ...n } = await ee(t);
2149
+ const { isStateStable: s, ...n } = await te(t);
2149
2150
  this.set({
2150
2151
  ...n,
2151
2152
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2246,7 +2247,7 @@ const xs = l(
2246
2247
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2247
2248
  r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2248
2249
  else {
2249
- const u = await ee({ timeout: 1e3, postEvent: s });
2250
+ const u = await te({ timeout: 1e3, postEvent: s });
2250
2251
  r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2251
2252
  }
2252
2253
  const p = new Rs({
@@ -2266,7 +2267,7 @@ function bn(e, t, s) {
2266
2267
  s || (s = (a) => `--tg-${a}-color`);
2267
2268
  const n = s("header"), r = s("bg"), i = () => {
2268
2269
  const { headerColor: a } = e;
2269
- if (ot(a))
2270
+ if (ct(a))
2270
2271
  P(n, a);
2271
2272
  else {
2272
2273
  const { bgColor: p, secondaryBgColor: u } = t;
@@ -2331,7 +2332,7 @@ async function En() {
2331
2332
  }
2332
2333
  }
2333
2334
  function Pn(e) {
2334
- const t = typeof e == "string" ? ut(e) : e;
2335
+ const t = typeof e == "string" ? dt(e) : e;
2335
2336
  Ft(t);
2336
2337
  function s(r) {
2337
2338
  if (typeof r == "string")
@@ -2348,7 +2349,7 @@ function Pn(e) {
2348
2349
  } catch {
2349
2350
  }
2350
2351
  }
2351
- if (at()) {
2352
+ if (ht()) {
2352
2353
  const r = window.parent.postMessage.bind(window.parent);
2353
2354
  window.parent.postMessage = (i) => {
2354
2355
  s(i), r(i);
@@ -2551,16 +2552,16 @@ async function Is() {
2551
2552
  for (; e; )
2552
2553
  e = await N(-1);
2553
2554
  }
2554
- function se(e) {
2555
+ function ee(e) {
2555
2556
  return U(e).pathname;
2556
2557
  }
2557
- const yt = 0, Y = 1, Z = 2;
2558
- class ne {
2558
+ const Pt = 0, Y = 1, Z = 2;
2559
+ class se {
2559
2560
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2560
2561
  c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2561
2562
  if (o === null)
2562
2563
  return this.push(this.parsePath(window.location.href));
2563
- o === yt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2564
+ o === Pt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2564
2565
  }), c(this, "onNavigatorChange", async ({
2565
2566
  to: o,
2566
2567
  from: a,
@@ -2578,7 +2579,7 @@ class ne {
2578
2579
  n
2579
2580
  ), this.navigator.on("change", (o) => {
2580
2581
  this.onNavigatorChange(o);
2581
- }), this.hashMode = r, this.base = se(i || "");
2582
+ }), this.hashMode = r, this.base = ee(i || "");
2582
2583
  }
2583
2584
  /**
2584
2585
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2735,7 +2736,7 @@ class ne {
2735
2736
  async syncHistory() {
2736
2737
  window.removeEventListener("popstate", this.onPopState);
2737
2738
  const { state: t } = this, s = this.renderPath(this);
2738
- await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await N(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await N(-1)) : (window.history.replaceState(yt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2739
+ await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await N(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await N(-1)) : (window.history.replaceState(Pt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2739
2740
  }
2740
2741
  /**
2741
2742
  * Current query parameters.
@@ -2759,7 +2760,7 @@ function ks(e) {
2759
2760
  let n = H(
2760
2761
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2761
2762
  );
2762
- const r = e.base ? se(e.base) : void 0;
2763
+ const r = e.base ? ee(e.base) : void 0;
2763
2764
  if (r) {
2764
2765
  if (!n.startsWith(r))
2765
2766
  throw m(
@@ -2768,19 +2769,19 @@ function ks(e) {
2768
2769
  );
2769
2770
  n = n.slice(r.length);
2770
2771
  }
2771
- return new ne([n], 0, e);
2772
+ return new se([n], 0, e);
2772
2773
  }
2773
2774
  function xn(e) {
2774
2775
  const t = e.match(/#(.+)/);
2775
2776
  return t ? t[1] : null;
2776
2777
  }
2777
2778
  function qs(e, t) {
2778
- if (Yt()) {
2779
+ if (Qt()) {
2779
2780
  const s = sessionStorage.getItem(e);
2780
2781
  if (s)
2781
2782
  try {
2782
2783
  const { index: n, history: r } = JSON.parse(s);
2783
- return new ne(
2784
+ return new se(
2784
2785
  r,
2785
2786
  n,
2786
2787
  t
@@ -2806,29 +2807,29 @@ function d(e, t) {
2806
2807
  ...p,
2807
2808
  [i]: n(o)
2808
2809
  };
2809
- return /* @__PURE__ */ Et(a, { ...u });
2810
+ return /* @__PURE__ */ Rt(a, { ...u });
2810
2811
  };
2811
2812
  };
2812
2813
  }
2813
2814
  return [s(e), s(t)];
2814
2815
  }
2815
- const re = ie(void 0);
2816
+ const ne = re(void 0);
2816
2817
  function Os() {
2817
- const e = oe(re);
2818
+ const e = ie(ne);
2818
2819
  if (!e)
2819
2820
  throw new Error("useSDK was used outside the SDKProvider.");
2820
2821
  return e;
2821
2822
  }
2822
2823
  function _(e) {
2823
2824
  function t(n) {
2824
- const r = Os(), [i, o] = Pt(
2825
+ const r = Os(), [i, o] = rt(
2825
2826
  n ? void 0 : () => {
2826
2827
  if (Ss())
2827
2828
  throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
2828
2829
  return r.use(e);
2829
2830
  }
2830
2831
  );
2831
- return S(() => {
2832
+ return R(() => {
2832
2833
  o(r.use(e));
2833
2834
  }, [r]), i;
2834
2835
  }
@@ -2861,24 +2862,27 @@ const [Ns, Ds] = _(Ge), [Sn, Tn] = d(
2861
2862
  sn,
2862
2863
  nn
2863
2864
  ), [rn, on] = _(ys), [Yn, Zn] = d(rn, on);
2864
- function Xn() {
2865
- return Rt(Qt, []);
2865
+ function Xn(e) {
2866
+ const [t, s] = rt(() => e ? void 0 : nt());
2867
+ return R(() => {
2868
+ e && s(nt());
2869
+ }, []), t;
2866
2870
  }
2867
2871
  const [an, cn] = _(Ps), [tr, er] = d(an, cn), [hn, pn] = _(xs), [sr, nr] = d(hn, pn);
2868
2872
  function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2869
- const n = ft(!0), [r, i] = Pt(/* @__PURE__ */ new Map()), o = ft(r), a = ae(
2873
+ const n = bt(!0), [r, i] = rt(/* @__PURE__ */ new Map()), o = bt(r), a = oe(
2870
2874
  (u) => {
2871
- n.current && i((C) => (u && u(C), new Map(C)));
2875
+ n.current && i((S) => (u && u(S), new Map(S)));
2872
2876
  },
2873
2877
  []
2874
- ), p = Rt(() => ({
2875
- use(u, ...C) {
2876
- const _t = r.get(u);
2877
- if (_t)
2878
- return _t;
2878
+ ), p = ae(() => ({
2879
+ use(u, ...S) {
2880
+ const gt = r.get(u);
2881
+ if (gt)
2882
+ return gt;
2879
2883
  let b, K;
2880
2884
  try {
2881
- b = u(...C);
2885
+ b = u(...S);
2882
2886
  } catch (f) {
2883
2887
  K = f;
2884
2888
  }
@@ -2890,41 +2894,41 @@ function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2890
2894
  let I;
2891
2895
  if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
2892
2896
  return $({ result: b, cleanup: I });
2893
- function wt(f) {
2897
+ function ft(f) {
2894
2898
  if ("on" in f) {
2895
- const k = f.on("change", () => a()), gt = I;
2899
+ const k = f.on("change", () => a()), mt = I;
2896
2900
  I = () => {
2897
- gt && gt(), k();
2901
+ mt && mt(), k();
2898
2902
  };
2899
2903
  }
2900
2904
  return { result: f, cleanup: I };
2901
2905
  }
2902
2906
  return b instanceof Promise ? (b.then(
2903
- (f) => a((k) => k.set(u, wt(f))),
2907
+ (f) => a((k) => k.set(u, ft(f))),
2904
2908
  (f) => a((k) => k.set(u, { error: f }))
2905
- ), $({})) : $(wt(b));
2909
+ ), $({})) : $(ft(b));
2906
2910
  }
2907
2911
  }), [r]);
2908
- return S(() => (n.current = !0, () => {
2912
+ return R(() => (n.current = !0, () => {
2909
2913
  n.current = !1;
2910
- }), []), S(() => {
2911
- if (at())
2914
+ }), []), R(() => {
2915
+ if (ht())
2912
2916
  return Cs(t);
2913
- }, [t]), S(() => {
2917
+ }, [t]), R(() => {
2914
2918
  le(s || !1);
2915
- }, [s]), S(() => {
2919
+ }, [s]), R(() => {
2916
2920
  o.current = r;
2917
- }, [r]), S(() => () => {
2921
+ }, [r]), R(() => () => {
2918
2922
  o.current.forEach((u) => {
2919
2923
  "cleanup" in u && u.cleanup && u.cleanup();
2920
2924
  });
2921
- }, []), /* @__PURE__ */ Et(re.Provider, { value: p, children: e });
2925
+ }, []), /* @__PURE__ */ Rt(ne.Provider, { value: p, children: e });
2922
2926
  }
2923
2927
  export {
2924
2928
  Ne as BackButton,
2925
2929
  As as BasicNavigator,
2926
2930
  je as BiometryManager,
2927
- ne as BrowserNavigator,
2931
+ se as BrowserNavigator,
2928
2932
  Je as ClosingBehavior,
2929
2933
  Xe as CloudStorage,
2930
2934
  Ee as ERR_INVALID_PATH_BASE,
@@ -2966,7 +2970,7 @@ export {
2966
2970
  U as createSafeURL,
2967
2971
  $t as date,
2968
2972
  xn as getHash,
2969
- se as getPathname,
2973
+ ee as getPathname,
2970
2974
  Ge as initBackButton,
2971
2975
  Ke as initBiometryManager,
2972
2976
  Fe as initClosingBehavior,
@@ -2986,9 +2990,9 @@ export {
2986
2990
  Cs as initWeb,
2987
2991
  O as invokeCustomMethod,
2988
2992
  Vt as isColorDark,
2989
- at as isIframe,
2990
- Yt as isPageReload,
2991
- ot as isRGB,
2993
+ ht as isIframe,
2994
+ Qt as isPageReload,
2995
+ ct as isRGB,
2992
2996
  Pe as isRGBShort,
2993
2997
  Ts as isSDKError,
2994
2998
  Rn as isSDKErrorOfType,
@@ -2997,20 +3001,20 @@ export {
2997
3001
  w as json,
2998
3002
  gn as mergeClassNames,
2999
3003
  Pn as mockTelegramEnv,
3000
- R as number,
3004
+ x as number,
3001
3005
  z as off,
3002
3006
  y as on,
3003
3007
  fn as parseInitData,
3004
- ut as parseLaunchParams,
3005
- te as parseThemeParams,
3008
+ dt as parseLaunchParams,
3009
+ Xt as parseThemeParams,
3006
3010
  B as postEvent,
3007
3011
  g as request,
3008
3012
  ze as requestBiometryInfo,
3009
3013
  mn as requestThemeParams,
3010
- ee as requestViewport,
3011
- Qt as retrieveLaunchParams,
3014
+ te as requestViewport,
3015
+ nt as retrieveLaunchParams,
3012
3016
  It as rgb,
3013
- pt as searchParams,
3017
+ lt as searchParams,
3014
3018
  Ue as serializeLaunchParams,
3015
3019
  Jt as serializeThemeParams,
3016
3020
  P as setCSSVar,
@@ -3018,7 +3022,7 @@ export {
3018
3022
  wn as setTargetOrigin,
3019
3023
  h as string,
3020
3024
  pe as subscribe,
3021
- x as supports,
3025
+ C as supports,
3022
3026
  ke as targetOrigin,
3023
3027
  At as toRGB,
3024
3028
  Ct as unsubscribe,