@tma.js/bridge 2.2.5 → 2.3.2

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,21 +1,21 @@
1
1
  import * as T from "valibot";
2
- import { looseObject as d, nullish as v, boolean as I, number as $, string as E, optional as z, unknown as me, parse as L, is as Y, function as we, any as de } from "valibot";
3
- import { throwifyFpFn as A, getStorageValue as ge, setStorageValue as X, createLogger as be, throwifyAnyEither as C, createCbCollector as Z, BetterTaskEither as ee } from "@tma.js/toolkit";
2
+ import { looseObject as d, nullish as v, boolean as z, number as V, string as E, optional as B, unknown as we, parse as L, is as O, function as de, any as G } from "valibot";
3
+ import { throwifyFpFn as A, getStorageValue as be, setStorageValue as Z, createLogger as ge, throwifyAnyEither as C, createCbCollector as ee, BetterTaskEither as te } from "@tma.js/toolkit";
4
4
  import { createLogger as vt, deepSnakeToCamelObjKeys as Et } from "@tma.js/toolkit";
5
- import { BetterPromise as te, TimeoutError as he } from "better-promises";
5
+ import { BetterPromise as re, TimeoutError as he } from "better-promises";
6
6
  import { CancelledError as xt, TimeoutError as kt } from "better-promises";
7
- import { function as f, either as c, option as j, taskEither as m, json as ye } from "fp-ts";
7
+ import { function as l, either as c, option as R, taskEither as f, json as ye } from "fp-ts";
8
8
  import { errorClassWithData as ve, errorClass as x } from "error-kid";
9
- import { parseLaunchParamsQueryFp as re, themeParams as Ee, pipeJsonToSchema as ne, miniAppsMessage as oe, serializeLaunchParamsQuery as Pe, parseLaunchParamsQuery as xe } from "@tma.js/transformers";
10
- import { signal as b, computed as ae } from "@tma.js/signals";
9
+ import { parseLaunchParamsQueryFp as ne, themeParams as Ee, pipeJsonToSchema as oe, miniAppsMessage as ae, serializeLaunchParamsQuery as Pe, parseLaunchParamsQuery as xe } from "@tma.js/transformers";
10
+ import { signal as g, computed as se } from "@tma.js/signals";
11
11
  import ke from "mitt";
12
- function se(e) {
12
+ function ie(e) {
13
13
  return typeof e == "object" && !!e && !Array.isArray(e) && T.is(
14
14
  T.looseObject({ TelegramWebviewProxy: T.looseObject({ postEvent: T.function() }) }),
15
15
  { TelegramWebviewProxy: e.TelegramWebviewProxy }
16
16
  );
17
17
  }
18
- function ie() {
18
+ function pe() {
19
19
  try {
20
20
  return window.self !== window.top;
21
21
  } catch {
@@ -60,40 +60,40 @@ class Ce extends (/* @__PURE__ */ x({
60
60
  ]
61
61
  })) {
62
62
  }
63
- class pe extends (/* @__PURE__ */ x({ name: "UnknownEnvError" })) {
63
+ class ce extends (/* @__PURE__ */ x({ name: "UnknownEnvError" })) {
64
64
  }
65
65
  class Me extends (/* @__PURE__ */ x({
66
66
  name: "InvokeCustomMethodError",
67
67
  super: (t) => [`Server returned error: ${t}`]
68
68
  })) {
69
69
  }
70
- const V = "launchParams";
71
- function B(e) {
70
+ const D = "launchParams";
71
+ function J(e) {
72
72
  return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
73
73
  }
74
74
  function We() {
75
- return f.pipe(
75
+ return l.pipe(
76
76
  M(),
77
- c.chainW(re)
77
+ c.chainW(ne)
78
78
  );
79
79
  }
80
80
  const rt = A(We);
81
- function qe() {
82
- return f.pipe(
81
+ function je() {
82
+ return l.pipe(
83
83
  M(),
84
84
  c.map((e) => {
85
85
  const t = new URLSearchParams(e).get("tgWebAppData");
86
- return t ? j.some(t) : j.none;
86
+ return t ? R.some(t) : R.none;
87
87
  })
88
88
  );
89
89
  }
90
90
  function nt() {
91
- return f.pipe(
92
- qe(),
91
+ return l.pipe(
92
+ je(),
93
93
  c.fold((e) => {
94
94
  throw e;
95
95
  }, (e) => e),
96
- j.match(() => {
96
+ R.match(() => {
97
97
  }, (e) => e)
98
98
  );
99
99
  }
@@ -103,43 +103,43 @@ function M() {
103
103
  // Try to retrieve launch parameters from the current location. This method
104
104
  // can return nothing in case, location was changed, and then the page was
105
105
  // reloaded.
106
- [() => B(window.location.href), "window.location.href"],
106
+ [() => J(window.location.href), "window.location.href"],
107
107
  // Then, try using the lower level API - window.performance.
108
108
  [() => {
109
109
  const n = performance.getEntriesByType("navigation")[0];
110
- return n && B(n.name);
110
+ return n && J(n.name);
111
111
  }, "performance navigation entries"],
112
112
  // Finally, try using the session storage.
113
- [() => ge(V), "local storage"]
113
+ [() => be(D), "local storage"]
114
114
  ]) {
115
115
  const n = t();
116
116
  if (!n) {
117
117
  e.push({ source: r, error: new Error("Source is empty") });
118
118
  continue;
119
119
  }
120
- const a = f.pipe(
121
- re(n),
120
+ const a = l.pipe(
121
+ ne(n),
122
122
  c.foldW((o) => o, () => !0)
123
123
  );
124
124
  if (typeof a != "boolean") {
125
125
  e.push({ source: r, error: a });
126
126
  continue;
127
127
  }
128
- return X(V, n), c.right(n);
128
+ return Z(D, n), c.right(n);
129
129
  }
130
130
  return c.left(new Ae(e));
131
131
  }
132
132
  const ot = A(M);
133
- function Fe(e, t) {
133
+ function qe(e, t) {
134
134
  const r = /* @__PURE__ */ new Map(), n = ke(), a = (o, s, p = !1) => {
135
135
  const _ = r.get(o) || /* @__PURE__ */ new Map();
136
136
  r.set(o, _);
137
137
  const i = _.get(s) || [];
138
138
  _.set(s, i);
139
- const u = i.findIndex((l) => l[1] === p);
139
+ const u = i.findIndex((m) => m[1] === p);
140
140
  if (u >= 0 && (n.off(o, i[u][0]), i.splice(u, 1), !i.length && (_.delete(s), !_.size))) {
141
- const l = r.size;
142
- r.delete(o), l && !r.size && t();
141
+ const m = r.size;
142
+ r.delete(o), m && !r.size && t();
143
143
  }
144
144
  };
145
145
  return {
@@ -153,8 +153,8 @@ function Fe(e, t) {
153
153
  n.on(o, i);
154
154
  const u = r.get(o) || /* @__PURE__ */ new Map();
155
155
  r.set(o, u);
156
- const l = u.get(s) || [];
157
- return u.set(s, l), l.push([i, p || !1]), _;
156
+ const m = u.get(s) || [];
157
+ return u.set(s, m), m.push([i, p || !1]), _;
158
158
  },
159
159
  off: a,
160
160
  // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -165,7 +165,7 @@ function Fe(e, t) {
165
165
  }
166
166
  };
167
167
  }
168
- function q(e, t) {
168
+ function j(e, t) {
169
169
  window.dispatchEvent(new MessageEvent("message", {
170
170
  data: JSON.stringify({ eventType: e, eventData: t }),
171
171
  // We specify this kind of source here in order to allow the package's "on" function to
@@ -174,29 +174,29 @@ function q(e, t) {
174
174
  source: window.parent
175
175
  }));
176
176
  }
177
- const S = b(!1), O = b("https://web.telegram.org"), Le = (e) => {
178
- g().log("Event received:", e);
179
- }, ce = ae(S);
177
+ const S = g(!1), U = g("https://web.telegram.org"), Fe = (e) => {
178
+ b().log("Event received:", e);
179
+ }, _e = se(S);
180
180
  function at(e) {
181
- e !== S() && (S.set(e), (e ? R : Oe)("*", Le));
181
+ e !== S() && (S.set(e), (e ? I : Oe)("*", Fe));
182
182
  }
183
- const _e = ae(O);
183
+ const ue = se(U);
184
184
  function st(e) {
185
- O.set(e), g().log("New target origin set", e);
185
+ U.set(e), b().log("New target origin set", e);
186
186
  }
187
- const P = b((...e) => {
187
+ const P = g((...e) => {
188
188
  window.parent.postMessage(...e);
189
- }), g = b(be("Bridge", {
189
+ }), b = g(ge("Bridge", {
190
190
  bgColor: "#9147ff",
191
191
  textColor: "white",
192
- shouldLog: ce
192
+ shouldLog: _e
193
193
  }));
194
194
  function it() {
195
- Ue(), [P, O, _e, S, ce, g].forEach((e) => {
195
+ Ue(), [P, U, ue, S, _e, b].forEach((e) => {
196
196
  e.unsubAll(), "reset" in e && e.reset();
197
197
  });
198
198
  }
199
- function F(e, t, r) {
199
+ function q(e, t, r) {
200
200
  const n = [r], a = e[t];
201
201
  typeof a == "function" && n.push(a);
202
202
  const o = (...p) => {
@@ -212,28 +212,28 @@ function F(e, t, r) {
212
212
  return;
213
213
  }
214
214
  if (p === 2) {
215
- D(e, t, n[1]);
215
+ Q(e, t, n[1]);
216
216
  return;
217
217
  }
218
- n.unshift(1), D(e, t, o);
218
+ n.unshift(1), Q(e, t, o);
219
219
  }
220
220
  });
221
- ue(
221
+ me(
222
222
  e,
223
223
  t,
224
224
  () => s,
225
225
  (p) => n.push(p)
226
226
  );
227
227
  }
228
- function G(e, t) {
228
+ function N(e, t) {
229
229
  const r = e[t];
230
- ue(e, t, () => r, (n) => {
230
+ me(e, t, () => r, (n) => {
231
231
  Object.entries(n).forEach(([a, o]) => {
232
232
  r[a] = o;
233
233
  });
234
234
  });
235
235
  }
236
- function ue(e, t, r, n) {
236
+ function me(e, t, r, n) {
237
237
  Object.defineProperty(e, t, {
238
238
  enumerable: !0,
239
239
  configurable: !0,
@@ -241,7 +241,7 @@ function ue(e, t, r, n) {
241
241
  set: n
242
242
  });
243
243
  }
244
- function D(e, t, r) {
244
+ function Q(e, t, r) {
245
245
  Object.defineProperty(e, t, {
246
246
  enumerable: !0,
247
247
  configurable: !0,
@@ -249,15 +249,15 @@ function D(e, t, r) {
249
249
  value: r
250
250
  });
251
251
  }
252
- const je = {
252
+ const Le = {
253
253
  clipboard_text_received: d({
254
254
  req_id: E(),
255
255
  data: v(E())
256
256
  }),
257
257
  custom_method_invoked: d({
258
258
  req_id: E(),
259
- result: z(me()),
260
- error: z(E())
259
+ result: B(we()),
260
+ error: B(E())
261
261
  }),
262
262
  popup_closed: v(
263
263
  d({ button_id: v(E(), () => {
@@ -266,10 +266,10 @@ const je = {
266
266
  ),
267
267
  viewport_changed: v(
268
268
  d({
269
- height: $(),
270
- width: v($(), () => window.innerWidth),
271
- is_state_stable: I(),
272
- is_expanded: I()
269
+ height: V(),
270
+ width: v(V(), () => window.innerWidth),
271
+ is_state_stable: z(),
272
+ is_expanded: z()
273
273
  }),
274
274
  // TODO: At the moment, macOS has a bug with the invalid event payload - it is always equal to
275
275
  // null. Leaving this default value until the bug is fixed.
@@ -283,21 +283,21 @@ const je = {
283
283
  theme_params: Ee()
284
284
  })
285
285
  };
286
- function J(e) {
286
+ function H(e) {
287
287
  if (e.source !== window.parent)
288
288
  return;
289
289
  let t;
290
290
  try {
291
- t = L(ne(oe()), e.data);
291
+ t = L(oe(ae()), e.data);
292
292
  } catch {
293
293
  return;
294
294
  }
295
- const { eventType: r, eventData: n } = t, a = je[r];
295
+ const { eventType: r, eventData: n } = t, a = Le[r];
296
296
  let o;
297
297
  try {
298
298
  o = a ? L(a, n) : n;
299
299
  } catch (s) {
300
- return g().forceError(
300
+ return b().forceError(
301
301
  [
302
302
  `An error occurred processing the "${r}" event from the Telegram application.`,
303
303
  "Please, file an issue here:",
@@ -311,14 +311,14 @@ function J(e) {
311
311
  Re(r, o);
312
312
  }
313
313
  const {
314
- on: R,
314
+ on: I,
315
315
  off: Oe,
316
316
  emit: Re,
317
317
  clear: Ue
318
- } = Fe(
318
+ } = qe(
319
319
  () => {
320
320
  const e = window;
321
- !e.TelegramGameProxy && (e.TelegramGameProxy = {}), F(e.TelegramGameProxy, "receiveEvent", q), G(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), F(e.Telegram.WebView, "receiveEvent", q), G(e.Telegram, "WebView"), F(e, "TelegramGameProxy_receiveEvent", q), window.addEventListener("message", J);
321
+ !e.TelegramGameProxy && (e.TelegramGameProxy = {}), q(e.TelegramGameProxy, "receiveEvent", j), N(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), q(e.Telegram.WebView, "receiveEvent", j), N(e.Telegram, "WebView"), q(e, "TelegramGameProxy_receiveEvent", j), window.addEventListener("message", H);
322
322
  },
323
323
  () => {
324
324
  [
@@ -333,11 +333,11 @@ const {
333
333
  return;
334
334
  const [n, a] = r;
335
335
  "unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
336
- }), window.removeEventListener("message", J);
336
+ }), window.removeEventListener("message", H);
337
337
  }
338
338
  ), Ie = (...e) => P()(...e);
339
339
  function $e(e, t) {
340
- f.pipe(
340
+ l.pipe(
341
341
  k(
342
342
  // @ts-expect-error It's ok, TS can't determine a specific override.
343
343
  e,
@@ -349,30 +349,30 @@ function $e(e, t) {
349
349
  );
350
350
  }
351
351
  function k(e, t) {
352
- g().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
352
+ b().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
353
353
  const r = window, n = JSON.stringify({ eventType: e, eventData: t });
354
- return ie() ? (Ie(n, _e()), c.right(void 0)) : se(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : Y(d({ external: d({ notify: we() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new pe());
354
+ return pe() ? (Ie(n, ue()), c.right(void 0)) : ie(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : O(d({ external: d({ notify: de() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new ce());
355
355
  }
356
- function U(e, t, r = {}) {
356
+ function $(e, t, r = {}) {
357
357
  const {
358
358
  // If no capture function was passed, we capture the first compatible event.
359
359
  capture: n = () => !0,
360
360
  postEvent: a = k
361
- } = r, o = b(), [s, p] = Z();
361
+ } = r, o = g(), [s, p] = ee();
362
362
  (Array.isArray(t) ? t : [t]).forEach((i) => {
363
363
  s(
364
- R(i, (u) => {
365
- const l = Array.isArray(t);
366
- n(l ? { event: i, payload: u } : u) && o.set([
367
- l ? { event: i, payload: u } : u
364
+ I(i, (u) => {
365
+ const m = Array.isArray(t);
366
+ n(m ? { event: i, payload: u } : u) && o.set([
367
+ m ? { event: i, payload: u } : u
368
368
  ]);
369
369
  })
370
370
  );
371
371
  });
372
372
  const _ = (i) => (p(), i);
373
- return f.pipe(
373
+ return l.pipe(
374
374
  async () => a(e, r.params),
375
- m.chainW(() => ee((i, u, l) => {
375
+ f.chainW(() => te((i, u, m) => {
376
376
  const w = o();
377
377
  if (w)
378
378
  return i(w[0]);
@@ -381,16 +381,16 @@ function U(e, t, r = {}) {
381
381
  }, W = () => {
382
382
  o.unsub(h);
383
383
  };
384
- o.sub(h), l.on("finalized", W);
384
+ o.sub(h), m.on("finalized", W);
385
385
  }, r)),
386
- m.mapBoth(_, _)
386
+ f.mapBoth(_, _)
387
387
  );
388
388
  }
389
389
  function pt(e, t, r) {
390
390
  const { postEvent: n } = r || {};
391
391
  return C(
392
392
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
393
- U(e, t, {
393
+ $(e, t, {
394
394
  ...r,
395
395
  postEvent: n ? (...a) => {
396
396
  try {
@@ -408,19 +408,19 @@ function ct(e, t) {
408
408
  e,
409
409
  t
410
410
  );
411
- return typeof r == "function" ? te.fn(() => C(r)) : r;
411
+ return typeof r == "function" ? re.fn(() => C(r)) : r;
412
412
  }
413
413
  function ze(e, t) {
414
- const r = se(window);
414
+ const r = ie(window);
415
415
  if (!e)
416
- return r || f.pipe(M(), c.match(() => !1, () => !0));
416
+ return r || l.pipe(M(), c.match(() => !1, () => !0));
417
417
  if (r)
418
- return m.right(!0);
418
+ return f.right(!0);
419
419
  const { timeout: n = 100 } = t || {};
420
- return f.pipe(
421
- U("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
422
- m.match(
423
- (a) => he.is(a) || pe.is(a) ? c.right(!1) : c.left(a),
420
+ return l.pipe(
421
+ $("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
422
+ f.match(
423
+ (a) => he.is(a) || ce.is(a) ? c.right(!1) : c.left(a),
424
424
  () => c.right(!0)
425
425
  )
426
426
  );
@@ -438,9 +438,9 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
438
438
  } catch (s) {
439
439
  throw new Ce(o, s);
440
440
  }
441
- X("launchParams", o);
441
+ Z("launchParams", o);
442
442
  }
443
- if (ie()) {
443
+ if (pe()) {
444
444
  if (!t)
445
445
  return;
446
446
  r && P.reset();
@@ -450,7 +450,7 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
450
450
  o(...s);
451
451
  };
452
452
  try {
453
- const i = L(ne(oe()), p);
453
+ const i = L(oe(ae()), p);
454
454
  t({ name: i.eventType, params: i.eventData }, _);
455
455
  } catch {
456
456
  _();
@@ -471,12 +471,12 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
471
471
  params: s ? JSON.parse(s) : void 0
472
472
  }, p) : p();
473
473
  }
474
- }, g().log("Environment was mocked by the mockTelegramEnv function");
474
+ }, b().log("Environment was mocked by the mockTelegramEnv function");
475
475
  }
476
476
  function Ve(e) {
477
477
  return ({ req_id: t }) => t === e;
478
478
  }
479
- const N = {
479
+ const K = {
480
480
  "6.0": [
481
481
  "iframe_ready",
482
482
  "iframe_will_reload",
@@ -562,16 +562,20 @@ const N = {
562
562
  "web_app_secure_storage_restore_key",
563
563
  "web_app_secure_storage_save_key"
564
564
  ],
565
- 9.1: ["web_app_hide_keyboard"]
565
+ 9.1: ["web_app_hide_keyboard"],
566
+ 9.5: [
567
+ { method: "web_app_setup_main_button", param: "icon_custom_emoji_id" },
568
+ { method: "web_app_setup_secondary_button", param: "icon_custom_emoji_id" }
569
+ ]
566
570
  };
567
- function Q(e, t) {
568
- return Object.keys(N).find((n) => N[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
571
+ function Y(e, t) {
572
+ return Object.keys(K).find((n) => K[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
569
573
  }
570
- function H(e) {
574
+ function X(e) {
571
575
  return e.split(".").map(Number);
572
576
  }
573
577
  function Be(e, t) {
574
- const r = H(e), n = H(t), a = Math.max(r.length, n.length);
578
+ const r = X(e), n = X(t), a = Math.max(r.length, n.length);
575
579
  for (let o = 0; o < a; o += 1) {
576
580
  const s = r[o] || 0, p = n[o] || 0;
577
581
  if (s !== p)
@@ -579,11 +583,11 @@ function Be(e, t) {
579
583
  }
580
584
  return 0;
581
585
  }
582
- function K(e, t, r) {
583
- const n = r ? Q(
586
+ function F(e, t, r) {
587
+ const n = r ? Y(
584
588
  e,
585
589
  t
586
- ) : Q(e);
590
+ ) : Y(e);
587
591
  return n ? Be(n, r || t) <= 0 : !1;
588
592
  }
589
593
  function ut(e, t = "strict") {
@@ -591,25 +595,25 @@ function ut(e, t = "strict") {
591
595
  const { method: a, version: o } = n, s = "param" in n ? new Se(a, n.param, o) : new Te(a, o);
592
596
  if (t === "strict")
593
597
  throw s;
594
- return g().forceWarn(s.message);
598
+ return b().forceWarn(s.message);
595
599
  };
596
- return (n, a) => K(n, e) ? n === "web_app_set_header_color" && Y(d({ color: de() }), a) && !K(n, "color", e) ? r({ version: e, method: n, param: "color" }) : $e(n, a) : r({ version: e, method: n });
600
+ return (n, a) => F(n, e) ? n === "web_app_set_header_color" && O(d({ color: G() }), a) && !F(n, "color", e) ? r({ version: e, method: n, param: "color" }) : (n === "web_app_setup_main_button" || n === "web_app_setup_secondary_button") && O(d({ icon_custom_emoji_id: G() }), a) && !F(n, "icon_custom_emoji_id", e) ? r({ version: e, method: n, param: "icon_custom_emoji_id" }) : $e(n, a) : r({ version: e, method: n });
597
601
  }
598
602
  function Ge(e, t, r, n) {
599
- return f.pipe(
600
- U("web_app_invoke_custom_method", "custom_method_invoked", {
603
+ return l.pipe(
604
+ $("web_app_invoke_custom_method", "custom_method_invoked", {
601
605
  ...n || {},
602
606
  params: { method: e, params: t, req_id: r },
603
607
  capture: Ve(r)
604
608
  }),
605
- m.chain(({ result: a, error: o }) => o ? m.left(new Me(o)) : m.right(a))
609
+ f.chain(({ result: a, error: o }) => o ? f.left(new Me(o)) : f.right(a))
606
610
  );
607
611
  }
608
- function lt(e, t, r, n) {
609
- return te.fn(() => f.pipe(
612
+ function mt(e, t, r, n) {
613
+ return re.fn(() => l.pipe(
610
614
  // @ts-expect-error TypeScript is unable to determine required override.
611
615
  Ge(e, t, r, n),
612
- m.match(
616
+ f.match(
613
617
  (a) => {
614
618
  throw a;
615
619
  },
@@ -622,18 +626,18 @@ function De(e, t, r = {}) {
622
626
  // If no capture function was passed, we capture the first compatible event.
623
627
  capture: n = () => !0,
624
628
  postEvent: a = k
625
- } = r, o = b(), [s, p] = Z();
629
+ } = r, o = g(), [s, p] = ee();
626
630
  (Array.isArray(t) ? t : [t]).forEach((i) => {
627
631
  s(
628
- R(i, (u) => {
632
+ I(i, (u) => {
629
633
  (Array.isArray(t) ? n({ event: i, payload: u }) : n(u)) && o.set([u]);
630
634
  })
631
635
  );
632
636
  });
633
637
  const _ = (i) => (p(), i);
634
- return f.pipe(
638
+ return l.pipe(
635
639
  async () => a(e, r.params),
636
- m.chainW(() => ee((i, u, l) => {
640
+ f.chainW(() => te((i, u, m) => {
637
641
  const w = o();
638
642
  if (w)
639
643
  return i(w[0]);
@@ -642,12 +646,12 @@ function De(e, t, r = {}) {
642
646
  }, W = () => {
643
647
  o.unsub(h);
644
648
  };
645
- o.sub(h), l.on("finalized", W);
649
+ o.sub(h), m.on("finalized", W);
646
650
  }, r)),
647
- m.mapBoth(_, _)
651
+ f.mapBoth(_, _)
648
652
  );
649
653
  }
650
- function ft(e, t, r) {
654
+ function lt(e, t, r) {
651
655
  const { postEvent: n } = r || {};
652
656
  return C(
653
657
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
@@ -663,7 +667,7 @@ function ft(e, t, r) {
663
667
  })
664
668
  );
665
669
  }
666
- function mt() {
670
+ function ft() {
667
671
  Object.hasOwn || (Object.hasOwn = function(e, t) {
668
672
  return Object.prototype.hasOwnProperty.call(e, t);
669
673
  });
@@ -679,14 +683,14 @@ const wt = A(le);
679
683
  function fe(e) {
680
684
  return btoa(
681
685
  encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
682
- ).replace(/\+/g, "-").replace(/\//g, "_");
686
+ ).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
683
687
  }
684
688
  function Je(e) {
685
689
  const t = fe(typeof e == "string" ? e : JSON.stringify(e));
686
690
  return t.length > 512 ? c.left(new Error("Value is too long for start parameter")) : c.right(t);
687
691
  }
688
692
  const dt = A(Je);
689
- function gt(e, t) {
693
+ function bt(e, t) {
690
694
  return C(
691
695
  Ne(
692
696
  e,
@@ -696,12 +700,12 @@ function gt(e, t) {
696
700
  );
697
701
  }
698
702
  function Ne(e, t) {
699
- return f.pipe(
703
+ return l.pipe(
700
704
  le(e),
701
705
  c.chain((r) => t ? typeof t == "function" ? t(r) : ye.parse(r) : c.right(r))
702
706
  );
703
707
  }
704
- function bt(e) {
708
+ function gt(e) {
705
709
  return fe(e).length <= 512;
706
710
  }
707
711
  export {
@@ -712,53 +716,53 @@ export {
712
716
  Se as MethodParameterUnsupportedError,
713
717
  Te as MethodUnsupportedError,
714
718
  kt as TimeoutError,
715
- pe as UnknownEnvError,
716
- mt as applyPolyfills,
719
+ ce as UnknownEnvError,
720
+ ft as applyPolyfills,
717
721
  Ve as captureSameReq,
718
722
  Be as compareVersions,
719
723
  vt as createLogger,
720
724
  ut as createPostEvent,
721
725
  dt as createStartParam,
722
726
  Je as createStartParamFp,
723
- ce as debug,
727
+ _e as debug,
724
728
  wt as decodeBase64Url,
725
729
  le as decodeBase64UrlFp,
726
- gt as decodeStartParam,
730
+ bt as decodeStartParam,
727
731
  Ne as decodeStartParamFp,
728
732
  Et as deepSnakeToCamelObjKeys,
729
- q as emitEvent,
733
+ j as emitEvent,
730
734
  fe as encodeBase64Url,
731
- Q as getReleaseVersion,
732
- se as hasWebviewProxy,
733
- lt as invokeCustomMethod,
735
+ Y as getReleaseVersion,
736
+ ie as hasWebviewProxy,
737
+ mt as invokeCustomMethod,
734
738
  Ge as invokeCustomMethodFp,
735
- ie as isIframe,
736
- bt as isSafeToCreateStartParam,
739
+ pe as isIframe,
740
+ gt as isSafeToCreateStartParam,
737
741
  ct as isTMA,
738
742
  ze as isTMAFp,
739
- g as logger,
743
+ b as logger,
740
744
  _t as mockTelegramEnv,
741
745
  Oe as off,
742
746
  Ue as offAll,
743
- R as on,
747
+ I as on,
744
748
  $e as postEvent,
745
749
  k as postEventFp,
746
750
  Ie as postMessage,
747
751
  P as postMessageImpl,
748
- ft as request,
752
+ lt as request,
749
753
  pt as request2,
750
- U as request2Fp,
754
+ $ as request2Fp,
751
755
  De as requestFp,
752
756
  it as resetGlobals,
753
757
  rt as retrieveLaunchParams,
754
758
  We as retrieveLaunchParamsFp,
755
759
  nt as retrieveRawInitData,
756
- qe as retrieveRawInitDataFp,
760
+ je as retrieveRawInitDataFp,
757
761
  ot as retrieveRawLaunchParams,
758
762
  M as retrieveRawLaunchParamsFp,
759
763
  at as setDebug,
760
764
  st as setTargetOrigin,
761
- K as supports,
762
- _e as targetOrigin
765
+ F as supports,
766
+ ue as targetOrigin
763
767
  };
764
768
  //# sourceMappingURL=index.js.map