@tma.js/bridge 2.2.4 → 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,17 +1,18 @@
1
- import { is as O, looseObject as m, function as Y, nullish as v, boolean as I, number as $, string as E, optional as z, unknown as me, parse as F, any as we } from "valibot";
2
- import { throwifyFpFn as T, getStorageValue as de, setStorageValue as X, createLogger as ge, throwifyAnyEither as A, createCbCollector as Z, BetterTaskEither as ee } from "@tma.js/toolkit";
3
- import { createLogger as yt, deepSnakeToCamelObjKeys as vt } from "@tma.js/toolkit";
4
- import { BetterPromise as te, TimeoutError as be } from "better-promises";
5
- import { CancelledError as Pt, TimeoutError as kt } from "better-promises";
6
- import { function as f, either as c, option as L, taskEither as w, json as he } from "fp-ts";
7
- import { errorClassWithData as ye, errorClass as k } from "error-kid";
8
- import { parseLaunchParamsQueryFp as re, themeParams as ve, pipeJsonToSchema as ne, miniAppsMessage as oe, serializeLaunchParamsQuery as Ee, parseLaunchParamsQuery as Pe } from "@tma.js/transformers";
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";
4
+ import { createLogger as vt, deepSnakeToCamelObjKeys as Et } from "@tma.js/toolkit";
5
+ import { BetterPromise as te, TimeoutError as he } from "better-promises";
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";
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";
9
10
  import { signal as b, computed as ae } from "@tma.js/signals";
10
11
  import ke from "mitt";
11
12
  function se(e) {
12
- return O(
13
- m({ TelegramWebviewProxy: m({ postEvent: Y() }) }),
14
- e
13
+ return typeof e == "object" && !!e && !Array.isArray(e) && T.is(
14
+ T.looseObject({ TelegramWebviewProxy: T.looseObject({ postEvent: T.function() }) }),
15
+ { TelegramWebviewProxy: e.TelegramWebviewProxy }
15
16
  );
16
17
  }
17
18
  function ie() {
@@ -21,21 +22,21 @@ function ie() {
21
22
  return !0;
22
23
  }
23
24
  }
24
- class xe extends (/* @__PURE__ */ k({
25
+ class Te extends (/* @__PURE__ */ x({
25
26
  name: "MethodUnsupportedError",
26
27
  super: (t, r) => [
27
28
  `Method "${t}" is unsupported in Mini Apps version ${r}`
28
29
  ]
29
30
  })) {
30
31
  }
31
- class Se extends (/* @__PURE__ */ k({
32
+ class Se extends (/* @__PURE__ */ x({
32
33
  name: "MethodParameterUnsupportedError",
33
34
  super: (t, r, n) => [
34
35
  `Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
35
36
  ]
36
37
  })) {
37
38
  }
38
- class Te extends (/* @__PURE__ */ ye({
39
+ class Ae extends (/* @__PURE__ */ ve({
39
40
  name: "LaunchParamsRetrieveError",
40
41
  data: (t) => ({ errors: t }),
41
42
  super: (t) => [
@@ -51,7 +52,7 @@ class Te extends (/* @__PURE__ */ ye({
51
52
  ]
52
53
  })) {
53
54
  }
54
- class Ae extends (/* @__PURE__ */ k({
55
+ class Ce extends (/* @__PURE__ */ x({
55
56
  name: "InvalidLaunchParamsError",
56
57
  super: (t, r) => [
57
58
  `Invalid value for launch params: ${t}`,
@@ -59,9 +60,9 @@ class Ae extends (/* @__PURE__ */ k({
59
60
  ]
60
61
  })) {
61
62
  }
62
- class pe extends (/* @__PURE__ */ k({ name: "UnknownEnvError" })) {
63
+ class pe extends (/* @__PURE__ */ x({ name: "UnknownEnvError" })) {
63
64
  }
64
- class Ce extends (/* @__PURE__ */ k({
65
+ class Me extends (/* @__PURE__ */ x({
65
66
  name: "InvokeCustomMethodError",
66
67
  super: (t) => [`Server returned error: ${t}`]
67
68
  })) {
@@ -70,33 +71,33 @@ const V = "launchParams";
70
71
  function B(e) {
71
72
  return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
72
73
  }
73
- function Me() {
74
+ function We() {
74
75
  return f.pipe(
75
- C(),
76
+ M(),
76
77
  c.chainW(re)
77
78
  );
78
79
  }
79
- const tt = T(Me);
80
+ const rt = A(We);
80
81
  function qe() {
81
82
  return f.pipe(
82
- C(),
83
+ M(),
83
84
  c.map((e) => {
84
85
  const t = new URLSearchParams(e).get("tgWebAppData");
85
- return t ? L.some(t) : L.none;
86
+ return t ? j.some(t) : j.none;
86
87
  })
87
88
  );
88
89
  }
89
- function rt() {
90
+ function nt() {
90
91
  return f.pipe(
91
92
  qe(),
92
93
  c.fold((e) => {
93
94
  throw e;
94
95
  }, (e) => e),
95
- L.match(() => {
96
+ j.match(() => {
96
97
  }, (e) => e)
97
98
  );
98
99
  }
99
- function C() {
100
+ function M() {
100
101
  const e = [];
101
102
  for (const [t, r] of [
102
103
  // Try to retrieve launch parameters from the current location. This method
@@ -109,7 +110,7 @@ function C() {
109
110
  return n && B(n.name);
110
111
  }, "performance navigation entries"],
111
112
  // Finally, try using the session storage.
112
- [() => de(V), "local storage"]
113
+ [() => ge(V), "local storage"]
113
114
  ]) {
114
115
  const n = t();
115
116
  if (!n) {
@@ -126,10 +127,10 @@ function C() {
126
127
  }
127
128
  return X(V, n), c.right(n);
128
129
  }
129
- return c.left(new Te(e));
130
+ return c.left(new Ae(e));
130
131
  }
131
- const nt = T(C);
132
- function We(e, t) {
132
+ const ot = A(M);
133
+ function Fe(e, t) {
133
134
  const r = /* @__PURE__ */ new Map(), n = ke(), a = (o, s, p = !1) => {
134
135
  const _ = r.get(o) || /* @__PURE__ */ new Map();
135
136
  r.set(o, _);
@@ -146,8 +147,8 @@ function We(e, t) {
146
147
  !r.size && e();
147
148
  const _ = () => {
148
149
  a(o, s, p);
149
- }, i = (...d) => {
150
- p && _(), o === "*" ? s({ name: d[0], payload: d[1] }) : s(...d);
150
+ }, i = (...w) => {
151
+ p && _(), o === "*" ? s({ name: w[0], payload: w[1] }) : s(...w);
151
152
  };
152
153
  n.on(o, i);
153
154
  const u = r.get(o) || /* @__PURE__ */ new Map();
@@ -173,29 +174,29 @@ function q(e, t) {
173
174
  source: window.parent
174
175
  }));
175
176
  }
176
- const S = b(!1), R = b("https://web.telegram.org"), Fe = (e) => {
177
+ const S = b(!1), O = b("https://web.telegram.org"), Le = (e) => {
177
178
  g().log("Event received:", e);
178
179
  }, ce = ae(S);
179
- function ot(e) {
180
- e !== S() && (S.set(e), (e ? j : Oe)("*", Fe));
181
- }
182
- const _e = ae(R);
183
180
  function at(e) {
184
- R.set(e), g().log("New target origin set", e);
181
+ e !== S() && (S.set(e), (e ? R : Oe)("*", Le));
182
+ }
183
+ const _e = ae(O);
184
+ function st(e) {
185
+ O.set(e), g().log("New target origin set", e);
185
186
  }
186
187
  const P = b((...e) => {
187
188
  window.parent.postMessage(...e);
188
- }), g = b(ge("Bridge", {
189
+ }), g = b(be("Bridge", {
189
190
  bgColor: "#9147ff",
190
191
  textColor: "white",
191
192
  shouldLog: ce
192
193
  }));
193
- function st() {
194
- je(), [P, R, _e, S, ce, g].forEach((e) => {
194
+ function it() {
195
+ Ue(), [P, O, _e, S, ce, g].forEach((e) => {
195
196
  e.unsubAll(), "reset" in e && e.reset();
196
197
  });
197
198
  }
198
- function W(e, t, r) {
199
+ function F(e, t, r) {
199
200
  const n = [r], a = e[t];
200
201
  typeof a == "function" && n.push(a);
201
202
  const o = (...p) => {
@@ -248,23 +249,23 @@ function D(e, t, r) {
248
249
  value: r
249
250
  });
250
251
  }
251
- const Le = {
252
- clipboard_text_received: m({
252
+ const je = {
253
+ clipboard_text_received: d({
253
254
  req_id: E(),
254
255
  data: v(E())
255
256
  }),
256
- custom_method_invoked: m({
257
+ custom_method_invoked: d({
257
258
  req_id: E(),
258
259
  result: z(me()),
259
260
  error: z(E())
260
261
  }),
261
262
  popup_closed: v(
262
- m({ button_id: v(E(), () => {
263
+ d({ button_id: v(E(), () => {
263
264
  }) }),
264
265
  {}
265
266
  ),
266
267
  viewport_changed: v(
267
- m({
268
+ d({
268
269
  height: $(),
269
270
  width: v($(), () => window.innerWidth),
270
271
  is_state_stable: I(),
@@ -278,8 +279,8 @@ const Le = {
278
279
  is_expanded: !0
279
280
  })
280
281
  ),
281
- theme_changed: m({
282
- theme_params: ve()
282
+ theme_changed: d({
283
+ theme_params: Ee()
283
284
  })
284
285
  };
285
286
  function J(e) {
@@ -287,14 +288,14 @@ function J(e) {
287
288
  return;
288
289
  let t;
289
290
  try {
290
- t = F(ne(oe()), e.data);
291
+ t = L(ne(oe()), e.data);
291
292
  } catch {
292
293
  return;
293
294
  }
294
- const { eventType: r, eventData: n } = t, a = Le[r];
295
+ const { eventType: r, eventData: n } = t, a = je[r];
295
296
  let o;
296
297
  try {
297
- o = a ? F(a, n) : n;
298
+ o = a ? L(a, n) : n;
298
299
  } catch (s) {
299
300
  return g().forceError(
300
301
  [
@@ -310,14 +311,14 @@ function J(e) {
310
311
  Re(r, o);
311
312
  }
312
313
  const {
313
- on: j,
314
+ on: R,
314
315
  off: Oe,
315
316
  emit: Re,
316
- clear: je
317
- } = We(
317
+ clear: Ue
318
+ } = Fe(
318
319
  () => {
319
320
  const e = window;
320
- !e.TelegramGameProxy && (e.TelegramGameProxy = {}), W(e.TelegramGameProxy, "receiveEvent", q), G(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), W(e.Telegram.WebView, "receiveEvent", q), G(e.Telegram, "WebView"), W(e, "TelegramGameProxy_receiveEvent", q), window.addEventListener("message", J);
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
322
  },
322
323
  () => {
323
324
  [
@@ -334,10 +335,10 @@ const {
334
335
  "unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
335
336
  }), window.removeEventListener("message", J);
336
337
  }
337
- ), Ue = (...e) => P()(...e);
338
- function Ie(e, t) {
338
+ ), Ie = (...e) => P()(...e);
339
+ function $e(e, t) {
339
340
  f.pipe(
340
- x(
341
+ k(
341
342
  // @ts-expect-error It's ok, TS can't determine a specific override.
342
343
  e,
343
344
  t
@@ -347,20 +348,20 @@ function Ie(e, t) {
347
348
  })
348
349
  );
349
350
  }
350
- function x(e, t) {
351
+ function k(e, t) {
351
352
  g().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
352
353
  const r = window, n = JSON.stringify({ eventType: e, eventData: t });
353
- return ie() ? (Ue(n, _e()), c.right(void 0)) : se(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : O(m({ external: m({ notify: Y() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new pe());
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
355
  }
355
356
  function U(e, t, r = {}) {
356
357
  const {
357
358
  // If no capture function was passed, we capture the first compatible event.
358
359
  capture: n = () => !0,
359
- postEvent: a = x
360
+ postEvent: a = k
360
361
  } = r, o = b(), [s, p] = Z();
361
362
  (Array.isArray(t) ? t : [t]).forEach((i) => {
362
363
  s(
363
- j(i, (u) => {
364
+ R(i, (u) => {
364
365
  const l = Array.isArray(t);
365
366
  n(l ? { event: i, payload: u } : u) && o.set([
366
367
  l ? { event: i, payload: u } : u
@@ -371,23 +372,23 @@ function U(e, t, r = {}) {
371
372
  const _ = (i) => (p(), i);
372
373
  return f.pipe(
373
374
  async () => a(e, r.params),
374
- w.chainW(() => ee((i, u, l) => {
375
- const d = o();
376
- if (d)
377
- return i(d[0]);
375
+ m.chainW(() => ee((i, u, l) => {
376
+ const w = o();
377
+ if (w)
378
+ return i(w[0]);
378
379
  const h = (y) => {
379
380
  y && i(y[0]);
380
- }, M = () => {
381
+ }, W = () => {
381
382
  o.unsub(h);
382
383
  };
383
- o.sub(h), l.on("finalized", M);
384
+ o.sub(h), l.on("finalized", W);
384
385
  }, r)),
385
- w.mapBoth(_, _)
386
+ m.mapBoth(_, _)
386
387
  );
387
388
  }
388
- function it(e, t, r) {
389
+ function pt(e, t, r) {
389
390
  const { postEvent: n } = r || {};
390
- return A(
391
+ return C(
391
392
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
392
393
  U(e, t, {
393
394
  ...r,
@@ -397,45 +398,45 @@ function it(e, t, r) {
397
398
  } catch (o) {
398
399
  return c.left(o);
399
400
  }
400
- } : x
401
+ } : k
401
402
  })
402
403
  );
403
404
  }
404
- function pt(e, t) {
405
- const r = $e(
405
+ function ct(e, t) {
406
+ const r = ze(
406
407
  // @ts-expect-error TS doesn't get what override we are going to use.
407
408
  e,
408
409
  t
409
410
  );
410
- return typeof r == "function" ? te.fn(() => A(r)) : r;
411
+ return typeof r == "function" ? te.fn(() => C(r)) : r;
411
412
  }
412
- function $e(e, t) {
413
+ function ze(e, t) {
413
414
  const r = se(window);
414
415
  if (!e)
415
- return r || f.pipe(C(), c.match(() => !1, () => !0));
416
+ return r || f.pipe(M(), c.match(() => !1, () => !0));
416
417
  if (r)
417
- return w.right(!0);
418
+ return m.right(!0);
418
419
  const { timeout: n = 100 } = t || {};
419
420
  return f.pipe(
420
421
  U("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
421
- w.match(
422
- (a) => be.is(a) || pe.is(a) ? c.right(!1) : c.left(a),
422
+ m.match(
423
+ (a) => he.is(a) || pe.is(a) ? c.right(!1) : c.left(a),
423
424
  () => c.right(!0)
424
425
  )
425
426
  );
426
427
  }
427
- function ct({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
428
+ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
428
429
  if (e) {
429
430
  const o = typeof e == "string" || e instanceof URLSearchParams ? e.toString() : (
430
431
  // Here we have to trick serializeLaunchParamsQuery into thinking, it serializes a valid
431
432
  // value. We are doing it because we are working with tgWebAppData presented as a
432
433
  // string, not an object as serializeLaunchParamsQuery requires.
433
- Ee({ ...e, tgWebAppData: void 0 }) + (e.tgWebAppData ? `&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}` : "")
434
+ Pe({ ...e, tgWebAppData: void 0 }) + (e.tgWebAppData ? `&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}` : "")
434
435
  );
435
436
  try {
436
- Pe(o);
437
+ xe(o);
437
438
  } catch (s) {
438
- throw new Ae(o, s);
439
+ throw new Ce(o, s);
439
440
  }
440
441
  X("launchParams", o);
441
442
  }
@@ -449,7 +450,7 @@ function ct({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
449
450
  o(...s);
450
451
  };
451
452
  try {
452
- const i = F(ne(oe()), p);
453
+ const i = L(ne(oe()), p);
453
454
  t({ name: i.eventType, params: i.eventData }, _);
454
455
  } catch {
455
456
  _();
@@ -472,7 +473,7 @@ function ct({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
472
473
  }
473
474
  }, g().log("Environment was mocked by the mockTelegramEnv function");
474
475
  }
475
- function ze(e) {
476
+ function Ve(e) {
476
477
  return ({ req_id: t }) => t === e;
477
478
  }
478
479
  const N = {
@@ -569,7 +570,7 @@ function Q(e, t) {
569
570
  function H(e) {
570
571
  return e.split(".").map(Number);
571
572
  }
572
- function Ve(e, t) {
573
+ function Be(e, t) {
573
574
  const r = H(e), n = H(t), a = Math.max(r.length, n.length);
574
575
  for (let o = 0; o < a; o += 1) {
575
576
  const s = r[o] || 0, p = n[o] || 0;
@@ -583,32 +584,32 @@ function K(e, t, r) {
583
584
  e,
584
585
  t
585
586
  ) : Q(e);
586
- return n ? Ve(n, r || t) <= 0 : !1;
587
+ return n ? Be(n, r || t) <= 0 : !1;
587
588
  }
588
- function _t(e, t = "strict") {
589
+ function ut(e, t = "strict") {
589
590
  const r = typeof t == "function" ? t : (n) => {
590
- const { method: a, version: o } = n, s = "param" in n ? new Se(a, n.param, o) : new xe(a, o);
591
+ const { method: a, version: o } = n, s = "param" in n ? new Se(a, n.param, o) : new Te(a, o);
591
592
  if (t === "strict")
592
593
  throw s;
593
594
  return g().forceWarn(s.message);
594
595
  };
595
- return (n, a) => K(n, e) ? n === "web_app_set_header_color" && O(m({ color: we() }), a) && !K(n, "color", e) ? r({ version: e, method: n, param: "color" }) : Ie(n, a) : r({ version: e, method: n });
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 });
596
597
  }
597
- function Be(e, t, r, n) {
598
+ function Ge(e, t, r, n) {
598
599
  return f.pipe(
599
600
  U("web_app_invoke_custom_method", "custom_method_invoked", {
600
601
  ...n || {},
601
602
  params: { method: e, params: t, req_id: r },
602
- capture: ze(r)
603
+ capture: Ve(r)
603
604
  }),
604
- w.chain(({ result: a, error: o }) => o ? w.left(new Ce(o)) : w.right(a))
605
+ m.chain(({ result: a, error: o }) => o ? m.left(new Me(o)) : m.right(a))
605
606
  );
606
607
  }
607
- function ut(e, t, r, n) {
608
+ function lt(e, t, r, n) {
608
609
  return te.fn(() => f.pipe(
609
610
  // @ts-expect-error TypeScript is unable to determine required override.
610
- Be(e, t, r, n),
611
- w.match(
611
+ Ge(e, t, r, n),
612
+ m.match(
612
613
  (a) => {
613
614
  throw a;
614
615
  },
@@ -616,15 +617,15 @@ function ut(e, t, r, n) {
616
617
  )
617
618
  )());
618
619
  }
619
- function Ge(e, t, r = {}) {
620
+ function De(e, t, r = {}) {
620
621
  const {
621
622
  // If no capture function was passed, we capture the first compatible event.
622
623
  capture: n = () => !0,
623
- postEvent: a = x
624
+ postEvent: a = k
624
625
  } = r, o = b(), [s, p] = Z();
625
626
  (Array.isArray(t) ? t : [t]).forEach((i) => {
626
627
  s(
627
- j(i, (u) => {
628
+ R(i, (u) => {
628
629
  (Array.isArray(t) ? n({ event: i, payload: u }) : n(u)) && o.set([u]);
629
630
  })
630
631
  );
@@ -632,25 +633,25 @@ function Ge(e, t, r = {}) {
632
633
  const _ = (i) => (p(), i);
633
634
  return f.pipe(
634
635
  async () => a(e, r.params),
635
- w.chainW(() => ee((i, u, l) => {
636
- const d = o();
637
- if (d)
638
- return i(d[0]);
636
+ m.chainW(() => ee((i, u, l) => {
637
+ const w = o();
638
+ if (w)
639
+ return i(w[0]);
639
640
  const h = (y) => {
640
641
  y && i(y[0]);
641
- }, M = () => {
642
+ }, W = () => {
642
643
  o.unsub(h);
643
644
  };
644
- o.sub(h), l.on("finalized", M);
645
+ o.sub(h), l.on("finalized", W);
645
646
  }, r)),
646
- w.mapBoth(_, _)
647
+ m.mapBoth(_, _)
647
648
  );
648
649
  }
649
- function lt(e, t, r) {
650
+ function ft(e, t, r) {
650
651
  const { postEvent: n } = r || {};
651
- return A(
652
+ return C(
652
653
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
653
- Ge(e, t, {
654
+ De(e, t, {
654
655
  ...r,
655
656
  postEvent: n ? (...a) => {
656
657
  try {
@@ -658,11 +659,11 @@ function lt(e, t, r) {
658
659
  } catch (o) {
659
660
  return c.left(o);
660
661
  }
661
- } : x
662
+ } : k
662
663
  })
663
664
  );
664
665
  }
665
- function ft() {
666
+ function mt() {
666
667
  Object.hasOwn || (Object.hasOwn = function(e, t) {
667
668
  return Object.prototype.hasOwnProperty.call(e, t);
668
669
  });
@@ -674,89 +675,89 @@ function le(e) {
674
675
  ).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
675
676
  ), (t) => t);
676
677
  }
677
- const mt = T(le);
678
+ const wt = A(le);
678
679
  function fe(e) {
679
680
  return btoa(
680
681
  encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
681
682
  ).replace(/\+/g, "-").replace(/\//g, "_");
682
683
  }
683
- function De(e) {
684
+ function Je(e) {
684
685
  const t = fe(typeof e == "string" ? e : JSON.stringify(e));
685
686
  return t.length > 512 ? c.left(new Error("Value is too long for start parameter")) : c.right(t);
686
687
  }
687
- const wt = T(De);
688
- function dt(e, t) {
689
- return A(
690
- Je(
688
+ const dt = A(Je);
689
+ function gt(e, t) {
690
+ return C(
691
+ Ne(
691
692
  e,
692
693
  // @ts-expect-error TypeScript is unable to detect a correct override.
693
694
  typeof t == "function" ? (r) => c.tryCatch(() => t(r), (n) => n) : t
694
695
  )
695
696
  );
696
697
  }
697
- function Je(e, t) {
698
+ function Ne(e, t) {
698
699
  return f.pipe(
699
700
  le(e),
700
- c.chain((r) => t ? typeof t == "function" ? t(r) : he.parse(r) : c.right(r))
701
+ c.chain((r) => t ? typeof t == "function" ? t(r) : ye.parse(r) : c.right(r))
701
702
  );
702
703
  }
703
- function gt(e) {
704
+ function bt(e) {
704
705
  return fe(e).length <= 512;
705
706
  }
706
707
  export {
707
- Pt as CancelledError,
708
- Ae as InvalidLaunchParamsError,
709
- Ce as InvokeCustomMethodFailedError,
710
- Te as LaunchParamsRetrieveError,
708
+ xt as CancelledError,
709
+ Ce as InvalidLaunchParamsError,
710
+ Me as InvokeCustomMethodFailedError,
711
+ Ae as LaunchParamsRetrieveError,
711
712
  Se as MethodParameterUnsupportedError,
712
- xe as MethodUnsupportedError,
713
+ Te as MethodUnsupportedError,
713
714
  kt as TimeoutError,
714
715
  pe as UnknownEnvError,
715
- ft as applyPolyfills,
716
- ze as captureSameReq,
717
- Ve as compareVersions,
718
- yt as createLogger,
719
- _t as createPostEvent,
720
- wt as createStartParam,
721
- De as createStartParamFp,
716
+ mt as applyPolyfills,
717
+ Ve as captureSameReq,
718
+ Be as compareVersions,
719
+ vt as createLogger,
720
+ ut as createPostEvent,
721
+ dt as createStartParam,
722
+ Je as createStartParamFp,
722
723
  ce as debug,
723
- mt as decodeBase64Url,
724
+ wt as decodeBase64Url,
724
725
  le as decodeBase64UrlFp,
725
- dt as decodeStartParam,
726
- Je as decodeStartParamFp,
727
- vt as deepSnakeToCamelObjKeys,
726
+ gt as decodeStartParam,
727
+ Ne as decodeStartParamFp,
728
+ Et as deepSnakeToCamelObjKeys,
728
729
  q as emitEvent,
729
730
  fe as encodeBase64Url,
730
731
  Q as getReleaseVersion,
731
732
  se as hasWebviewProxy,
732
- ut as invokeCustomMethod,
733
- Be as invokeCustomMethodFp,
733
+ lt as invokeCustomMethod,
734
+ Ge as invokeCustomMethodFp,
734
735
  ie as isIframe,
735
- gt as isSafeToCreateStartParam,
736
- pt as isTMA,
737
- $e as isTMAFp,
736
+ bt as isSafeToCreateStartParam,
737
+ ct as isTMA,
738
+ ze as isTMAFp,
738
739
  g as logger,
739
- ct as mockTelegramEnv,
740
+ _t as mockTelegramEnv,
740
741
  Oe as off,
741
- je as offAll,
742
- j as on,
743
- Ie as postEvent,
744
- x as postEventFp,
745
- Ue as postMessage,
742
+ Ue as offAll,
743
+ R as on,
744
+ $e as postEvent,
745
+ k as postEventFp,
746
+ Ie as postMessage,
746
747
  P as postMessageImpl,
747
- lt as request,
748
- it as request2,
748
+ ft as request,
749
+ pt as request2,
749
750
  U as request2Fp,
750
- Ge as requestFp,
751
- st as resetGlobals,
752
- tt as retrieveLaunchParams,
753
- Me as retrieveLaunchParamsFp,
754
- rt as retrieveRawInitData,
751
+ De as requestFp,
752
+ it as resetGlobals,
753
+ rt as retrieveLaunchParams,
754
+ We as retrieveLaunchParamsFp,
755
+ nt as retrieveRawInitData,
755
756
  qe as retrieveRawInitDataFp,
756
- nt as retrieveRawLaunchParams,
757
- C as retrieveRawLaunchParamsFp,
758
- ot as setDebug,
759
- at as setTargetOrigin,
757
+ ot as retrieveRawLaunchParams,
758
+ M as retrieveRawLaunchParamsFp,
759
+ at as setDebug,
760
+ st as setTargetOrigin,
760
761
  K as supports,
761
762
  _e as targetOrigin
762
763
  };