@tma.js/sdk 1.4.4 → 1.4.7

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 (298) hide show
  1. package/README.md +2 -2
  2. package/dist/dts/bridge/env/index.d.ts +0 -1
  3. package/dist/dts/bridge/events/events.d.ts +16 -16
  4. package/dist/dts/bridge/methods/methods.d.ts +27 -27
  5. package/dist/dts/bridge/methods/popup.d.ts +1 -1
  6. package/dist/dts/index.d.ts +3 -3
  7. package/dist/dts/init-data/types.d.ts +3 -3
  8. package/dist/dts/launch-params/index.d.ts +1 -4
  9. package/dist/dts/launch-params/retrieveFromLocation.d.ts +2 -2
  10. package/dist/dts/launch-params/retrieveFromPerformance.d.ts +3 -4
  11. package/dist/dts/launch-params/retrieveFromUrl.d.ts +3 -2
  12. package/dist/dts/launch-params/retrieveLaunchData.d.ts +1 -0
  13. package/dist/dts/launch-params/retrieveLaunchParams.d.ts +6 -0
  14. package/dist/dts/launch-params/storage.d.ts +3 -5
  15. package/dist/dts/launch-params/types.d.ts +1 -1
  16. package/dist/dts/{launch-params → misc}/getFirstNavigationEntry.d.ts +1 -1
  17. package/dist/dts/misc/index.d.ts +3 -0
  18. package/dist/dts/{bridge/env → misc}/isIframe.d.ts +1 -1
  19. package/dist/dts/misc/isPageReload.d.ts +5 -0
  20. package/dist/dts/theme-params/types.d.ts +1 -1
  21. package/dist/index.cjs +1 -2
  22. package/dist/index.iife.js +1 -2
  23. package/dist/index.mjs +841 -866
  24. package/package.json +2 -3
  25. package/dist/dts/launch-params/computeLaunchData.d.ts +0 -6
  26. package/dist/dts/launch-params/computePageReload.d.ts +0 -6
  27. package/dist/dts/launch-params/retrieveCurrent.d.ts +0 -5
  28. package/dist/index.cjs.map +0 -1
  29. package/dist/index.iife.js.map +0 -1
  30. package/dist/index.mjs.map +0 -1
  31. package/src/__tests__/globals.ts +0 -39
  32. package/src/back-button/BackButton.ts +0 -90
  33. package/src/back-button/__tests__/BackButton.ts +0 -129
  34. package/src/back-button/index.ts +0 -2
  35. package/src/back-button/types.ts +0 -14
  36. package/src/bridge/__tests__/parseMessage.ts +0 -23
  37. package/src/bridge/__tests__/request.ts +0 -236
  38. package/src/bridge/env/__tests__/hasExternalNotify.ts +0 -15
  39. package/src/bridge/env/__tests__/hasWebviewProxy.ts +0 -15
  40. package/src/bridge/env/__tests__/isIframe.ts +0 -30
  41. package/src/bridge/env/hasExternalNotify.ts +0 -19
  42. package/src/bridge/env/hasWebviewProxy.ts +0 -19
  43. package/src/bridge/env/index.ts +0 -3
  44. package/src/bridge/env/isIframe.ts +0 -11
  45. package/src/bridge/errors/MethodUnsupportedError.ts +0 -13
  46. package/src/bridge/errors/ParameterUnsupportedError.ts +0 -13
  47. package/src/bridge/errors/index.ts +0 -2
  48. package/src/bridge/events/__tests__/createEmitter.ts +0 -143
  49. package/src/bridge/events/__tests__/off.ts +0 -34
  50. package/src/bridge/events/__tests__/on.ts +0 -49
  51. package/src/bridge/events/__tests__/onTelegramEvent.ts +0 -49
  52. package/src/bridge/events/__tests__/once.ts +0 -64
  53. package/src/bridge/events/__tests__/singletonEmitter.ts +0 -22
  54. package/src/bridge/events/__tests__/subscribe.ts +0 -49
  55. package/src/bridge/events/__tests__/unsubscribe.ts +0 -34
  56. package/src/bridge/events/createEmitter.ts +0 -108
  57. package/src/bridge/events/events.ts +0 -170
  58. package/src/bridge/events/index.ts +0 -9
  59. package/src/bridge/events/off.ts +0 -14
  60. package/src/bridge/events/on.ts +0 -19
  61. package/src/bridge/events/onTelegramEvent.ts +0 -81
  62. package/src/bridge/events/once.ts +0 -18
  63. package/src/bridge/events/parsers/__tests__/clipboardTextReceived.ts +0 -21
  64. package/src/bridge/events/parsers/__tests__/invoiceClosed.ts +0 -12
  65. package/src/bridge/events/parsers/__tests__/popupClosed.ts +0 -10
  66. package/src/bridge/events/parsers/__tests__/qrTextReceived.ts +0 -9
  67. package/src/bridge/events/parsers/__tests__/theme-changed.ts +0 -42
  68. package/src/bridge/events/parsers/__tests__/viewportChanged.ts +0 -49
  69. package/src/bridge/events/parsers/clipboardTextReceived.ts +0 -26
  70. package/src/bridge/events/parsers/customMethodInvoked.ts +0 -25
  71. package/src/bridge/events/parsers/index.ts +0 -9
  72. package/src/bridge/events/parsers/invoiceClosed.ts +0 -26
  73. package/src/bridge/events/parsers/phoneRequested.ts +0 -14
  74. package/src/bridge/events/parsers/popupClosed.ts +0 -19
  75. package/src/bridge/events/parsers/qrTextReceived.ts +0 -14
  76. package/src/bridge/events/parsers/theme-changed.ts +0 -58
  77. package/src/bridge/events/parsers/viewportChanged.ts +0 -33
  78. package/src/bridge/events/parsers/writeAccessRequested.ts +0 -14
  79. package/src/bridge/events/singletonEmitter.ts +0 -19
  80. package/src/bridge/events/subscribe.ts +0 -15
  81. package/src/bridge/events/unsubscribe.ts +0 -10
  82. package/src/bridge/index.ts +0 -7
  83. package/src/bridge/invokeCustomMethod.ts +0 -56
  84. package/src/bridge/methods/__tests__/createPostEvent.ts +0 -37
  85. package/src/bridge/methods/__tests__/postEvent.ts +0 -137
  86. package/src/bridge/methods/createPostEvent.ts +0 -40
  87. package/src/bridge/methods/custom-methods.ts +0 -68
  88. package/src/bridge/methods/haptic.ts +0 -52
  89. package/src/bridge/methods/index.ts +0 -6
  90. package/src/bridge/methods/methods.ts +0 -370
  91. package/src/bridge/methods/popup.ts +0 -53
  92. package/src/bridge/methods/postEvent.ts +0 -101
  93. package/src/bridge/parseMessage.ts +0 -28
  94. package/src/bridge/request.ts +0 -176
  95. package/src/classnames/__tests__/classNames.ts +0 -20
  96. package/src/classnames/__tests__/mergeClassNames.ts +0 -21
  97. package/src/classnames/classNames.ts +0 -34
  98. package/src/classnames/index.ts +0 -2
  99. package/src/classnames/mergeClassNames.ts +0 -60
  100. package/src/closing-behavior/ClosingBehavior.ts +0 -64
  101. package/src/closing-behavior/__tests__/ClosingBehavior.ts +0 -86
  102. package/src/closing-behavior/index.ts +0 -2
  103. package/src/closing-behavior/types.ts +0 -12
  104. package/src/cloud-storage/CloudStorage.ts +0 -138
  105. package/src/cloud-storage/index.ts +0 -1
  106. package/src/colors/__tests__/isColorDark.ts +0 -12
  107. package/src/colors/__tests__/isRGB.ts +0 -13
  108. package/src/colors/__tests__/isRGBShort.ts +0 -13
  109. package/src/colors/__tests__/toRGB.ts +0 -23
  110. package/src/colors/index.ts +0 -5
  111. package/src/colors/isColorDark.ts +0 -22
  112. package/src/colors/isRGB.ts +0 -9
  113. package/src/colors/isRGBShort.ts +0 -9
  114. package/src/colors/toRGB.ts +0 -49
  115. package/src/colors/types.ts +0 -9
  116. package/src/css/__tests__/bindMiniAppCSSVars.ts +0 -175
  117. package/src/css/__tests__/bindThemeCSSVars.ts +0 -52
  118. package/src/css/__tests__/bindViewportCSSVars.ts +0 -55
  119. package/src/css/__tests__/setCSSVar.ts +0 -14
  120. package/src/css/bindMiniAppCSSVars.ts +0 -51
  121. package/src/css/bindThemeCSSVars.ts +0 -31
  122. package/src/css/bindViewportCSSVars.ts +0 -36
  123. package/src/css/index.ts +0 -4
  124. package/src/css/setCSSVar.ts +0 -8
  125. package/src/event-emitter/EventEmitter.ts +0 -146
  126. package/src/event-emitter/__tests__/EventEmitter.ts +0 -145
  127. package/src/event-emitter/index.ts +0 -2
  128. package/src/event-emitter/types.ts +0 -60
  129. package/src/globals.ts +0 -38
  130. package/src/haptic-feedback/HapticFeedback.ts +0 -70
  131. package/src/haptic-feedback/__tests__/HapticFeedback.ts +0 -68
  132. package/src/haptic-feedback/index.ts +0 -1
  133. package/src/index.ts +0 -185
  134. package/src/init/catchCustomStyles.ts +0 -17
  135. package/src/init/creators/__tests__/createViewport.ts +0 -96
  136. package/src/init/creators/createBackButton.ts +0 -25
  137. package/src/init/creators/createClosingBehavior.ts +0 -24
  138. package/src/init/creators/createMainButton.ts +0 -51
  139. package/src/init/creators/createMiniApp.ts +0 -48
  140. package/src/init/creators/createRequestIdGenerator.ts +0 -13
  141. package/src/init/creators/createSettingsButton.ts +0 -25
  142. package/src/init/creators/createThemeParams.ts +0 -11
  143. package/src/init/creators/createViewport.ts +0 -94
  144. package/src/init/creators/index.ts +0 -8
  145. package/src/init/css/index.ts +0 -1
  146. package/src/init/css/processCSSVarsOption.ts +0 -55
  147. package/src/init/index.ts +0 -2
  148. package/src/init/init.ts +0 -134
  149. package/src/init/types.ts +0 -94
  150. package/src/init-data/InitData.ts +0 -96
  151. package/src/init-data/__tests__/InitData.ts +0 -98
  152. package/src/init-data/__tests__/chatParser.ts +0 -102
  153. package/src/init-data/__tests__/initDataParser.ts +0 -136
  154. package/src/init-data/__tests__/parseInitData.ts +0 -136
  155. package/src/init-data/__tests__/userParser.ts +0 -96
  156. package/src/init-data/chatParser.ts +0 -19
  157. package/src/init-data/index.ts +0 -6
  158. package/src/init-data/initDataParser.ts +0 -41
  159. package/src/init-data/parseInitData.ts +0 -10
  160. package/src/init-data/types.ts +0 -164
  161. package/src/init-data/userParser.ts +0 -45
  162. package/src/invoice/Invoice.ts +0 -123
  163. package/src/invoice/index.ts +0 -2
  164. package/src/invoice/types.ts +0 -11
  165. package/src/launch-params/__tests__/retrieveFromUrl.ts +0 -19
  166. package/src/launch-params/computeLaunchData.ts +0 -81
  167. package/src/launch-params/computePageReload.ts +0 -13
  168. package/src/launch-params/getFirstNavigationEntry.ts +0 -10
  169. package/src/launch-params/index.ts +0 -13
  170. package/src/launch-params/launchParamsParser.ts +0 -45
  171. package/src/launch-params/parseLaunchParams.ts +0 -10
  172. package/src/launch-params/retrieveCurrent.ts +0 -27
  173. package/src/launch-params/retrieveFromLocation.ts +0 -10
  174. package/src/launch-params/retrieveFromPerformance.ts +0 -18
  175. package/src/launch-params/retrieveFromUrl.ts +0 -19
  176. package/src/launch-params/retrieveLaunchData.ts +0 -30
  177. package/src/launch-params/serializeLaunchParams.ts +0 -37
  178. package/src/launch-params/storage.ts +0 -33
  179. package/src/launch-params/types.ts +0 -62
  180. package/src/logger/Logger.ts +0 -72
  181. package/src/logger/__tests__/Logger.ts +0 -107
  182. package/src/logger/index.ts +0 -1
  183. package/src/main-button/MainButton.ts +0 -239
  184. package/src/main-button/__tests__/MainButton.ts +0 -346
  185. package/src/main-button/index.ts +0 -2
  186. package/src/main-button/types.ts +0 -26
  187. package/src/mini-app/MiniApp.ts +0 -348
  188. package/src/mini-app/__tests__/MiniApp.ts +0 -140
  189. package/src/mini-app/contactParser.ts +0 -29
  190. package/src/mini-app/index.ts +0 -2
  191. package/src/mini-app/types.ts +0 -38
  192. package/src/misc/__tests__/isRecord.ts +0 -21
  193. package/src/misc/index.ts +0 -2
  194. package/src/misc/isRecord.ts +0 -7
  195. package/src/misc/isTMA.ts +0 -13
  196. package/src/navigation/HashNavigator/HashNavigator.ts +0 -220
  197. package/src/navigation/HashNavigator/__tests__/HashNavigator.ts +0 -144
  198. package/src/navigation/HashNavigator/__tests__/drop.ts +0 -42
  199. package/src/navigation/HashNavigator/__tests__/go.ts +0 -9
  200. package/src/navigation/HashNavigator/drop.ts +0 -36
  201. package/src/navigation/HashNavigator/go.ts +0 -28
  202. package/src/navigation/HashNavigator/index.ts +0 -2
  203. package/src/navigation/HashNavigator/types.ts +0 -41
  204. package/src/navigation/Navigator/Navigator.ts +0 -282
  205. package/src/navigation/Navigator/index.ts +0 -2
  206. package/src/navigation/Navigator/types.ts +0 -55
  207. package/src/navigation/ensurePrefix.ts +0 -9
  208. package/src/navigation/getHash.ts +0 -17
  209. package/src/navigation/index.ts +0 -4
  210. package/src/parsing/ArrayValueParser.ts +0 -79
  211. package/src/parsing/ParseError.ts +0 -27
  212. package/src/parsing/ParseSchemaFieldError.ts +0 -21
  213. package/src/parsing/ValueParser.ts +0 -71
  214. package/src/parsing/__tests__/ArrayValueParser.ts +0 -18
  215. package/src/parsing/__tests__/toRecord.ts +0 -10
  216. package/src/parsing/createValueParserGenerator.ts +0 -16
  217. package/src/parsing/index.ts +0 -10
  218. package/src/parsing/parseBySchema.ts +0 -65
  219. package/src/parsing/parsers/__tests__/array.ts +0 -39
  220. package/src/parsing/parsers/__tests__/boolean.ts +0 -31
  221. package/src/parsing/parsers/__tests__/date.ts +0 -25
  222. package/src/parsing/parsers/__tests__/json.ts +0 -80
  223. package/src/parsing/parsers/__tests__/number.ts +0 -23
  224. package/src/parsing/parsers/__tests__/rgb.ts +0 -22
  225. package/src/parsing/parsers/__tests__/searchParams.ts +0 -105
  226. package/src/parsing/parsers/__tests__/string.ts +0 -25
  227. package/src/parsing/parsers/array.ts +0 -9
  228. package/src/parsing/parsers/boolean.ts +0 -22
  229. package/src/parsing/parsers/date.ts +0 -11
  230. package/src/parsing/parsers/index.ts +0 -8
  231. package/src/parsing/parsers/json.ts +0 -17
  232. package/src/parsing/parsers/number.ts +0 -21
  233. package/src/parsing/parsers/rgb.ts +0 -10
  234. package/src/parsing/parsers/searchParams.ts +0 -24
  235. package/src/parsing/parsers/string.ts +0 -12
  236. package/src/parsing/toRecord.ts +0 -27
  237. package/src/parsing/types.ts +0 -32
  238. package/src/parsing/unexpectedTypeError.ts +0 -6
  239. package/src/popup/Popup.ts +0 -91
  240. package/src/popup/__tests__/Popup.ts +0 -130
  241. package/src/popup/__tests__/preparePopupParams.ts +0 -85
  242. package/src/popup/index.ts +0 -2
  243. package/src/popup/preparePopupParams.ts +0 -59
  244. package/src/popup/types.ts +0 -69
  245. package/src/qr-scanner/QRScanner.ts +0 -95
  246. package/src/qr-scanner/index.ts +0 -2
  247. package/src/qr-scanner/types.ts +0 -11
  248. package/src/settings-button/SettingsButton.ts +0 -85
  249. package/src/settings-button/index.ts +0 -2
  250. package/src/settings-button/types.ts +0 -15
  251. package/src/state/State.ts +0 -67
  252. package/src/state/index.ts +0 -2
  253. package/src/state/types.ts +0 -31
  254. package/src/storage.ts +0 -69
  255. package/src/supports/__tests__/supports.ts +0 -123
  256. package/src/supports/createSupportsFunc.ts +0 -18
  257. package/src/supports/createSupportsParamFunc.ts +0 -27
  258. package/src/supports/index.ts +0 -4
  259. package/src/supports/supports.ts +0 -84
  260. package/src/supports/types.ts +0 -1
  261. package/src/theme-params/ThemeParams.ts +0 -131
  262. package/src/theme-params/__tests__/keys.ts +0 -19
  263. package/src/theme-params/__tests__/parseThemeParams.ts +0 -29
  264. package/src/theme-params/__tests__/serializeThemeParams.ts +0 -29
  265. package/src/theme-params/__tests__/themeParamsParser.ts +0 -29
  266. package/src/theme-params/index.ts +0 -6
  267. package/src/theme-params/keys.ts +0 -24
  268. package/src/theme-params/parseThemeParams.ts +0 -10
  269. package/src/theme-params/requestThemeParams.ts +0 -13
  270. package/src/theme-params/serializeThemeParams.ts +0 -20
  271. package/src/theme-params/themeParamsParser.ts +0 -22
  272. package/src/theme-params/types.ts +0 -33
  273. package/src/timeout/TimeoutError.ts +0 -6
  274. package/src/timeout/__tests__/isTimeoutError.ts +0 -9
  275. package/src/timeout/__tests__/withTimeout.ts +0 -28
  276. package/src/timeout/index.ts +0 -4
  277. package/src/timeout/isTimeoutError.ts +0 -9
  278. package/src/timeout/sleep.ts +0 -10
  279. package/src/timeout/withTimeout.ts +0 -24
  280. package/src/types/index.ts +0 -4
  281. package/src/types/methods.ts +0 -18
  282. package/src/types/platform.ts +0 -14
  283. package/src/types/request-id.ts +0 -10
  284. package/src/types/utils.ts +0 -50
  285. package/src/utils/Utils.ts +0 -107
  286. package/src/utils/index.ts +0 -1
  287. package/src/version/__tests__/compareVersions.ts +0 -19
  288. package/src/version/compareVersions.ts +0 -28
  289. package/src/version/index.ts +0 -2
  290. package/src/version/types.ts +0 -4
  291. package/src/viewport/Viewport.ts +0 -171
  292. package/src/viewport/__tests__/isStableViewportPlatform.ts +0 -15
  293. package/src/viewport/__tests__/utils.ts +0 -12
  294. package/src/viewport/index.ts +0 -4
  295. package/src/viewport/isStableViewportPlatform.ts +0 -10
  296. package/src/viewport/requestViewport.ts +0 -23
  297. package/src/viewport/types.ts +0 -23
  298. package/src/viewport/utils.ts +0 -7
package/dist/index.mjs CHANGED
@@ -1,81 +1,88 @@
1
- var Rt = Object.defineProperty;
2
- var It = (r, t, e) => t in r ? Rt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var o = (r, t, e) => (It(r, typeof t != "symbol" ? t + "" : t, e), e);
4
- function R(r) {
5
- return typeof r == "object" && r !== null && !Array.isArray(r);
1
+ var Re = Object.defineProperty;
2
+ var Ie = (r, e, t) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var o = (r, e, t) => (Ie(r, typeof e != "symbol" ? e + "" : e, t), t);
4
+ function ue() {
5
+ return performance.getEntriesByType("navigation")[0];
6
6
  }
7
- function ht() {
8
- return performance.getEntriesByType("navigation")[0] || null;
7
+ function pe() {
8
+ try {
9
+ return window.self !== window.top;
10
+ } catch {
11
+ return !0;
12
+ }
9
13
  }
10
- function Lt() {
11
- const r = ht();
12
- return r ? r.type === "reload" : null;
14
+ function le() {
15
+ var r;
16
+ return ((r = ue()) == null ? void 0 : r.type) === "reload";
17
+ }
18
+ function R(r) {
19
+ return typeof r == "object" && r !== null && !Array.isArray(r);
13
20
  }
14
21
  function L() {
15
22
  return new TypeError("Value has unexpected type");
16
23
  }
17
24
  class F extends Error {
18
- constructor(e, { cause: s, type: n } = {}) {
25
+ constructor(t, { cause: s, type: n } = {}) {
19
26
  super(`Unable to parse value${n ? ` as ${n}` : ""}`, { cause: s });
20
27
  /**
21
28
  * Parser name.
22
29
  */
23
30
  o(this, "type");
24
- this.value = e, Object.setPrototypeOf(this, F.prototype), this.type = n;
31
+ this.value = t, Object.setPrototypeOf(this, F.prototype), this.type = n;
25
32
  }
26
33
  }
27
34
  class z {
28
- constructor(t, e, s) {
29
- this.parser = t, this.isOptional = e, this.type = s;
35
+ constructor(e, t, s) {
36
+ this.parser = e, this.isOptional = t, this.type = s;
30
37
  }
31
- parse(t) {
32
- if (!(this.isOptional && t === void 0))
38
+ parse(e) {
39
+ if (!(this.isOptional && e === void 0))
33
40
  try {
34
- return this.parser(t);
35
- } catch (e) {
36
- throw new F(t, { type: this.type, cause: e });
41
+ return this.parser(e);
42
+ } catch (t) {
43
+ throw new F(e, { type: this.type, cause: t });
37
44
  }
38
45
  }
39
46
  optional() {
40
47
  return this.isOptional = !0, this;
41
48
  }
42
49
  }
43
- function $t(r) {
50
+ function Le(r) {
44
51
  if (Array.isArray(r))
45
52
  return r;
46
53
  if (typeof r == "string")
47
54
  try {
48
- const t = JSON.parse(r);
49
- if (Array.isArray(t))
50
- return t;
55
+ const e = JSON.parse(r);
56
+ if (Array.isArray(e))
57
+ return e;
51
58
  } catch {
52
59
  }
53
60
  throw L();
54
61
  }
55
- class Tt extends z {
56
- constructor(e, s, n) {
57
- super($t, s, n);
62
+ class Te extends z {
63
+ constructor(t, s, n) {
64
+ super(Le, s, n);
58
65
  o(this, "itemParser");
59
- this.itemParser = typeof e == "function" ? e : e.parse.bind(e);
66
+ this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
60
67
  }
61
- parse(e) {
62
- const s = super.parse(e);
68
+ parse(t) {
69
+ const s = super.parse(t);
63
70
  return s === void 0 ? s : s.map(this.itemParser);
64
71
  }
65
- of(e) {
66
- return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
72
+ of(t) {
73
+ return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
67
74
  }
68
75
  }
69
- function $(r, t) {
70
- return () => new z(r, !1, t);
76
+ function T(r, e) {
77
+ return () => new z(r, !1, e);
71
78
  }
72
79
  class j extends Error {
73
- constructor(t, { cause: e, type: s } = {}) {
74
- super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, j.prototype);
80
+ constructor(e, { cause: t, type: s } = {}) {
81
+ super(`Unable to parse field "${e}"${s ? ` as ${s}` : ""}`, { cause: t }), Object.setPrototypeOf(this, j.prototype);
75
82
  }
76
83
  }
77
- function pt(r, t) {
78
- const e = {};
84
+ function de(r, e) {
85
+ const t = {};
79
86
  for (const s in r) {
80
87
  const n = r[s];
81
88
  if (!n)
@@ -84,121 +91,121 @@ function pt(r, t) {
84
91
  if (typeof n == "function" || "parse" in n)
85
92
  i = s, a = typeof n == "function" ? n : n.parse.bind(n);
86
93
  else {
87
- const { type: h } = n;
88
- i = n.from || s, a = typeof h == "function" ? h : h.parse.bind(h);
94
+ const { type: p } = n;
95
+ i = n.from || s, a = typeof p == "function" ? p : p.parse.bind(p);
89
96
  }
90
97
  let c;
91
- const p = t(i);
98
+ const u = e(i);
92
99
  try {
93
- c = a(p);
94
- } catch (h) {
95
- throw h instanceof F ? new j(i, {
96
- type: h.type,
97
- cause: h
98
- }) : new j(i, { cause: h });
100
+ c = a(u);
101
+ } catch (p) {
102
+ throw p instanceof F ? new j(i, {
103
+ type: p.type,
104
+ cause: p
105
+ }) : new j(i, { cause: p });
99
106
  }
100
- c !== void 0 && (e[s] = c);
107
+ c !== void 0 && (t[s] = c);
101
108
  }
102
- return e;
109
+ return t;
103
110
  }
104
- function Bt(r) {
105
- return new Tt((t) => t, !1, r);
111
+ function $e(r) {
112
+ return new Te((e) => e, !1, r);
106
113
  }
107
- const k = $((r) => {
114
+ const k = T((r) => {
108
115
  if (typeof r == "boolean")
109
116
  return r;
110
- const t = String(r);
111
- if (t === "1" || t === "true")
117
+ const e = String(r);
118
+ if (e === "1" || e === "true")
112
119
  return !0;
113
- if (t === "0" || t === "false")
120
+ if (e === "0" || e === "false")
114
121
  return !1;
115
122
  throw L();
116
- }, "boolean"), q = $((r) => {
123
+ }, "boolean"), A = T((r) => {
117
124
  if (typeof r == "number")
118
125
  return r;
119
126
  if (typeof r == "string") {
120
- const t = Number(r);
121
- if (!Number.isNaN(t))
122
- return t;
127
+ const e = Number(r);
128
+ if (!Number.isNaN(e))
129
+ return e;
123
130
  }
124
131
  throw L();
125
- }, "number"), lt = $((r) => r instanceof Date ? r : new Date(q().parse(r) * 1e3), "Date");
132
+ }, "number"), fe = T((r) => r instanceof Date ? r : new Date(A().parse(r) * 1e3), "Date");
126
133
  function Y(r) {
127
- let t = r;
128
- if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
134
+ let e = r;
135
+ if (typeof e == "string" && (e = JSON.parse(e)), typeof e != "object" || e === null || Array.isArray(e))
129
136
  throw L();
130
- return t;
137
+ return e;
131
138
  }
132
- function f(r, t) {
133
- return new z((e) => {
134
- const s = Y(e);
135
- return pt(r, (n) => s[n]);
136
- }, !1, t);
139
+ function f(r, e) {
140
+ return new z((t) => {
141
+ const s = Y(t);
142
+ return de(r, (n) => s[n]);
143
+ }, !1, e);
137
144
  }
138
145
  function X(r) {
139
146
  return /^#[\da-f]{6}$/i.test(r);
140
147
  }
141
- function Dt(r) {
148
+ function Be(r) {
142
149
  return /^#[\da-f]{3}$/i.test(r);
143
150
  }
144
- function dt(r) {
145
- const t = r.replace(/\s/g, "").toLowerCase();
146
- if (X(t))
147
- return t;
148
- if (Dt(t)) {
151
+ function ge(r) {
152
+ const e = r.replace(/\s/g, "").toLowerCase();
153
+ if (X(e))
154
+ return e;
155
+ if (Be(e)) {
149
156
  let s = "#";
150
157
  for (let n = 0; n < 3; n += 1)
151
- s += t[1 + n].repeat(2);
158
+ s += e[1 + n].repeat(2);
152
159
  return s;
153
160
  }
154
- const e = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
155
- if (e === null)
161
+ const t = e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
162
+ if (t === null)
156
163
  throw new Error(`Value "${r}" does not satisfy any of known RGB formats.`);
157
- return e.slice(1).reduce((s, n) => {
164
+ return t.slice(1).reduce((s, n) => {
158
165
  const i = parseInt(n, 10).toString(16);
159
166
  return s + (i.length === 1 ? "0" : "") + i;
160
167
  }, "#");
161
168
  }
162
- function ft(r) {
163
- const t = dt(r);
169
+ function we(r) {
170
+ const e = ge(r);
164
171
  return Math.sqrt(
165
172
  [0.299, 0.587, 0.114].reduce((s, n, i) => {
166
- const a = parseInt(t.slice(1 + i * 2, 1 + (i + 1) * 2), 16);
173
+ const a = parseInt(e.slice(1 + i * 2, 1 + (i + 1) * 2), 16);
167
174
  return s + a * a * n;
168
175
  }, 0)
169
176
  ) < 120;
170
177
  }
171
- const u = $((r) => {
178
+ const h = T((r) => {
172
179
  if (typeof r == "string" || typeof r == "number")
173
180
  return r.toString();
174
181
  throw L();
175
- }, "string"), gt = $((r) => dt(u().parse(r)), "rgb");
176
- function tt(r, t) {
177
- return new z((e) => {
178
- if (typeof e != "string" && !(e instanceof URLSearchParams))
182
+ }, "string"), _e = T((r) => ge(h().parse(r)), "rgb");
183
+ function ee(r, e) {
184
+ return new z((t) => {
185
+ if (typeof t != "string" && !(t instanceof URLSearchParams))
179
186
  throw L();
180
- const s = typeof e == "string" ? new URLSearchParams(e) : e;
181
- return pt(r, (n) => {
187
+ const s = typeof t == "string" ? new URLSearchParams(t) : t;
188
+ return de(r, (n) => {
182
189
  const i = s.get(n);
183
190
  return i === null ? void 0 : i;
184
191
  });
185
- }, !1, t);
192
+ }, !1, e);
186
193
  }
187
- function Wt() {
194
+ function De() {
188
195
  return f({
189
- id: q(),
190
- type: u(),
191
- title: u(),
196
+ id: A(),
197
+ type: h(),
198
+ title: h(),
192
199
  photoUrl: {
193
- type: u().optional(),
200
+ type: h().optional(),
194
201
  from: "photo_url"
195
202
  },
196
- username: u().optional()
203
+ username: h().optional()
197
204
  }, "Chat");
198
205
  }
199
- class Nt {
200
- constructor(t) {
201
- this.initData = t;
206
+ class We {
207
+ constructor(e) {
208
+ this.initData = e;
202
209
  }
203
210
  /**
204
211
  * @see InitDataParsed.authDate
@@ -217,8 +224,8 @@ class Nt {
217
224
  * the [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.
218
225
  */
219
226
  get canSendAfterDate() {
220
- const { canSendAfter: t } = this;
221
- return t === void 0 ? void 0 : new Date(this.authDate.getTime() + t * 1e3);
227
+ const { canSendAfter: e } = this;
228
+ return e === void 0 ? void 0 : new Date(this.authDate.getTime() + e * 1e3);
222
229
  }
223
230
  /**
224
231
  * @see InitDataParsed.chat
@@ -269,7 +276,7 @@ class Nt {
269
276
  return this.initData.user;
270
277
  }
271
278
  }
272
- function st() {
279
+ function ne() {
273
280
  return f({
274
281
  addedToAttachmentMenu: {
275
282
  type: k().optional(),
@@ -280,10 +287,10 @@ function st() {
280
287
  from: "allows_write_to_pm"
281
288
  },
282
289
  firstName: {
283
- type: u(),
290
+ type: h(),
284
291
  from: "first_name"
285
292
  },
286
- id: q(),
293
+ id: A(),
287
294
  isBot: {
288
295
  type: k().optional(),
289
296
  from: "is_bot"
@@ -293,77 +300,77 @@ function st() {
293
300
  from: "is_premium"
294
301
  },
295
302
  languageCode: {
296
- type: u().optional(),
303
+ type: h().optional(),
297
304
  from: "language_code"
298
305
  },
299
306
  lastName: {
300
- type: u().optional(),
307
+ type: h().optional(),
301
308
  from: "last_name"
302
309
  },
303
310
  photoUrl: {
304
- type: u().optional(),
311
+ type: h().optional(),
305
312
  from: "photo_url"
306
313
  },
307
- username: u().optional()
314
+ username: h().optional()
308
315
  }, "User");
309
316
  }
310
- function wt() {
311
- return tt({
317
+ function be() {
318
+ return ee({
312
319
  authDate: {
313
- type: lt(),
320
+ type: fe(),
314
321
  from: "auth_date"
315
322
  },
316
323
  canSendAfter: {
317
- type: q().optional(),
324
+ type: A().optional(),
318
325
  from: "can_send_after"
319
326
  },
320
- chat: Wt().optional(),
327
+ chat: De().optional(),
321
328
  chatInstance: {
322
- type: u().optional(),
329
+ type: h().optional(),
323
330
  from: "chat_instance"
324
331
  },
325
332
  chatType: {
326
- type: u().optional(),
333
+ type: h().optional(),
327
334
  from: "chat_type"
328
335
  },
329
- hash: u(),
336
+ hash: h(),
330
337
  queryId: {
331
- type: u().optional(),
338
+ type: h().optional(),
332
339
  from: "query_id"
333
340
  },
334
- receiver: st().optional(),
341
+ receiver: ne().optional(),
335
342
  startParam: {
336
- type: u().optional(),
343
+ type: h().optional(),
337
344
  from: "start_param"
338
345
  },
339
- user: st().optional()
346
+ user: ne().optional()
340
347
  }, "InitData");
341
348
  }
342
- function tr(r) {
343
- return wt().parse(r);
349
+ function Zt(r) {
350
+ return be().parse(r);
344
351
  }
345
- function Ot(r) {
346
- return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
352
+ function Oe(r) {
353
+ return r.replace(/(^|_)bg/, (e, t) => `${t}background`).replace(/_([a-z])/g, (e, t) => t.toUpperCase());
347
354
  }
348
- function Ht(r) {
349
- return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
355
+ function He(r) {
356
+ return r.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`).replace(/(^|_)background/, (e, t) => `${t}bg`);
350
357
  }
351
- const _t = $(
358
+ const me = T(
352
359
  (r) => {
353
- const t = gt().optional();
354
- return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Ot(s)] = t.parse(n), e), {});
360
+ const e = _e().optional();
361
+ return Object.entries(Y(r)).reduce((t, [s, n]) => (t[Oe(s)] = e.parse(n), t), {});
355
362
  },
356
363
  "ThemeParams"
357
364
  );
358
- function bt(r) {
359
- return _t().parse(r);
365
+ function ye(r) {
366
+ return me().parse(r);
360
367
  }
361
- function er(r = {}) {
362
- return m("web_app_request_theme", "theme_changed", r).then(bt);
368
+ function Kt(r = {}) {
369
+ return m("web_app_request_theme", "theme_changed", r).then(ye);
363
370
  }
364
- function Ut(r) {
371
+ function Ne(r) {
365
372
  return JSON.stringify(
366
- Object.entries(r).reduce((t, [e, s]) => (s && (t[Ht(e)] = s), t), {})
373
+ Object.entries(r).reduce((e, [t, s]) => (s && (e[He(t)] = s), e), {})
367
374
  );
368
375
  }
369
376
  class w {
@@ -377,15 +384,15 @@ class w {
377
384
  * @param listener - event listener.
378
385
  * @param once - should listener called only once.
379
386
  */
380
- addListener(t, e, s) {
381
- let n = this.listeners.get(t);
382
- return n || (n = [], this.listeners.set(t, n)), n.push([e, s]), () => this.off(t, e);
387
+ addListener(e, t, s) {
388
+ let n = this.listeners.get(e);
389
+ return n || (n = [], this.listeners.set(e, n)), n.push([t, s]), () => this.off(e, t);
383
390
  }
384
- emit(t, ...e) {
385
- this.subscribeListeners.forEach((n) => n(t, ...e));
386
- const s = this.listeners.get(t);
391
+ emit(e, ...t) {
392
+ this.subscribeListeners.forEach((n) => n(e, ...t));
393
+ const s = this.listeners.get(e);
387
394
  s && s.forEach(([n, i], a) => {
388
- n(...e), i && s.splice(a, 1);
395
+ n(...t), i && s.splice(a, 1);
389
396
  });
390
397
  }
391
398
  /**
@@ -394,8 +401,8 @@ class w {
394
401
  * @param listener - event listener.
395
402
  * @returns Function to remove event listener.
396
403
  */
397
- on(t, e) {
398
- return this.addListener(t, e, !1);
404
+ on(e, t) {
405
+ return this.addListener(e, t, !1);
399
406
  }
400
407
  /**
401
408
  * Adds event listener following the logic, described in `on` method, but calls specified
@@ -405,8 +412,8 @@ class w {
405
412
  * @returns Function to remove event listener.
406
413
  * @see on
407
414
  */
408
- once(t, e) {
409
- return this.addListener(t, e, !0);
415
+ once(e, t) {
416
+ return this.addListener(e, t, !0);
410
417
  }
411
418
  /**
412
419
  * Removes event listener. In case, specified listener was bound several times, it removes
@@ -414,11 +421,11 @@ class w {
414
421
  * @param event - event name.
415
422
  * @param listener - event listener.
416
423
  */
417
- off(t, e) {
418
- const s = this.listeners.get(t);
424
+ off(e, t) {
425
+ const s = this.listeners.get(e);
419
426
  if (s) {
420
427
  for (let n = 0; n < s.length; n += 1)
421
- if (e === s[n][0]) {
428
+ if (t === s[n][0]) {
422
429
  s.splice(n, 1);
423
430
  return;
424
431
  }
@@ -431,8 +438,8 @@ class w {
431
438
  * @see on
432
439
  * @see once
433
440
  */
434
- subscribe(t) {
435
- return this.subscribeListeners.push(t), () => this.unsubscribe(t);
441
+ subscribe(e) {
442
+ return this.subscribeListeners.push(e), () => this.unsubscribe(e);
436
443
  }
437
444
  /**
438
445
  * Removes global event listener. In case, specified listener was bound several times, it removes
@@ -440,20 +447,20 @@ class w {
440
447
  * @param listener - events listener.
441
448
  * @returns Function to remove event listener.
442
449
  */
443
- unsubscribe(t) {
444
- for (let e = 0; e < this.subscribeListeners.length; e += 1)
445
- if (this.subscribeListeners[e] === t) {
446
- this.subscribeListeners.splice(e, 1);
450
+ unsubscribe(e) {
451
+ for (let t = 0; t < this.subscribeListeners.length; t += 1)
452
+ if (this.subscribeListeners[t] === e) {
453
+ this.subscribeListeners.splice(t, 1);
447
454
  return;
448
455
  }
449
456
  }
450
457
  }
451
458
  class b {
452
- constructor(t, e) {
453
- this.state = t, this.ee = e;
459
+ constructor(e, t) {
460
+ this.state = e, this.ee = t;
454
461
  }
455
- internalSet(t, e) {
456
- return this.state[t] === e || e === void 0 ? !1 : (this.state[t] = e, this.ee.emit(`change:${t}`, e), !0);
462
+ internalSet(e, t) {
463
+ return this.state[e] === t || t === void 0 ? !1 : (this.state[e] = t, this.ee.emit(`change:${e}`, t), !0);
457
464
  }
458
465
  /**
459
466
  * Returns copy of current state.
@@ -461,25 +468,25 @@ class b {
461
468
  clone() {
462
469
  return { ...this.state };
463
470
  }
464
- set(t, e) {
471
+ set(e, t) {
465
472
  let s = !1;
466
- if (typeof t == "string")
467
- s = this.internalSet(t, e);
473
+ if (typeof e == "string")
474
+ s = this.internalSet(e, t);
468
475
  else
469
- for (const n in t)
470
- this.internalSet(n, t[n]) && (s = !0);
476
+ for (const n in e)
477
+ this.internalSet(n, e[n]) && (s = !0);
471
478
  s && this.ee.emit("change");
472
479
  }
473
480
  /**
474
481
  * Returns value by specified key.
475
482
  * @param key - state key.
476
483
  */
477
- get(t) {
478
- return this.state[t];
484
+ get(e) {
485
+ return this.state[e];
479
486
  }
480
487
  }
481
- class Mt {
482
- constructor(t) {
488
+ class Ue {
489
+ constructor(e) {
483
490
  o(this, "ee", new w());
484
491
  o(this, "state");
485
492
  /**
@@ -490,7 +497,7 @@ class Mt {
490
497
  * Removes event listener.
491
498
  */
492
499
  o(this, "off", this.ee.off.bind(this.ee));
493
- this.state = new b(t, this.ee);
500
+ this.state = new b(e, this.ee);
494
501
  }
495
502
  /**
496
503
  * @since v6.10
@@ -514,8 +521,8 @@ class Mt {
514
521
  * Retrieves palette color value by its name.
515
522
  * @param key - palette key name.
516
523
  */
517
- get(t) {
518
- return this.state.get(t);
524
+ get(e) {
525
+ return this.state.get(e);
519
526
  }
520
527
  /**
521
528
  * Returns the copy of the internal state of the current component instance.
@@ -537,7 +544,7 @@ class Mt {
537
544
  * value is calculated according to theme background color.
538
545
  */
539
546
  get isDark() {
540
- return !this.backgroundColor || ft(this.backgroundColor);
547
+ return !this.backgroundColor || we(this.backgroundColor);
541
548
  }
542
549
  get linkColor() {
543
550
  return this.get("linkColor");
@@ -562,8 +569,8 @@ class Mt {
562
569
  * @returns Function to stop listening.
563
570
  */
564
571
  listen() {
565
- return y("theme_changed", (t) => {
566
- this.state.set(bt(t.theme_params));
572
+ return y("theme_changed", (e) => {
573
+ this.state.set(ye(e.theme_params));
567
574
  });
568
575
  }
569
576
  /**
@@ -576,22 +583,22 @@ class Mt {
576
583
  return this.get("textColor");
577
584
  }
578
585
  }
579
- function mt() {
580
- return tt({
586
+ function Me() {
587
+ return ee({
581
588
  botInline: {
582
589
  type: k().optional(),
583
590
  from: "tgWebAppBotInline"
584
591
  },
585
592
  initData: {
586
- type: wt().optional(),
593
+ type: be().optional(),
587
594
  from: "tgWebAppData"
588
595
  },
589
596
  initDataRaw: {
590
- type: u().optional(),
597
+ type: h().optional(),
591
598
  from: "tgWebAppData"
592
599
  },
593
600
  platform: {
594
- type: u(),
601
+ type: h(),
595
602
  from: "tgWebAppPlatform"
596
603
  },
597
604
  showSettings: {
@@ -599,142 +606,45 @@ function mt() {
599
606
  from: "tgWebAppShowSettings"
600
607
  },
601
608
  startParam: {
602
- type: u().optional(),
609
+ type: h().optional(),
603
610
  from: "tgWebAppStartParam"
604
611
  },
605
612
  themeParams: {
606
- type: _t(),
613
+ type: me(),
607
614
  from: "tgWebAppThemeParams"
608
615
  },
609
616
  version: {
610
- type: u(),
617
+ type: h(),
611
618
  from: "tgWebAppVersion"
612
619
  }
613
620
  }, "LaunchParams");
614
621
  }
615
- function Gt(r) {
616
- return mt().parse(r);
622
+ function Ee(r) {
623
+ return Me().parse(r);
617
624
  }
618
- function yt(r) {
619
- const t = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
620
- return Gt(t);
625
+ function Ce(r) {
626
+ const e = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
627
+ return Ee(e);
621
628
  }
622
- function jt() {
623
- return yt(window.location.href);
629
+ function Ge() {
630
+ return Ce(window.location.href);
624
631
  }
625
- function Ft() {
626
- const r = ht();
632
+ function je() {
633
+ const r = ue();
627
634
  if (!r)
628
635
  throw new Error("Unable to get first navigation entry.");
629
- return yt(r.name);
630
- }
631
- function zt() {
632
- try {
633
- return Ft();
634
- } catch {
635
- }
636
- try {
637
- return jt();
638
- } catch {
639
- }
640
- return null;
641
- }
642
- function Jt(r) {
643
- const {
644
- initDataRaw: t,
645
- themeParams: e,
646
- platform: s,
647
- version: n,
648
- showSettings: i,
649
- botInline: a
650
- } = r, c = new URLSearchParams();
651
- return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform", s), c.set("tgWebAppThemeParams", Ut(e)), c.set("tgWebAppVersion", n), typeof i == "boolean" && c.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && c.set("tgWebAppBotInline", a ? "1" : "0"), c.toString();
652
- }
653
- const Et = "telegram-mini-apps-launch-params";
654
- function Qt() {
655
- const r = sessionStorage.getItem(Et);
656
- return r ? mt().parse(r) : null;
657
- }
658
- function Zt(r) {
659
- sessionStorage.setItem(Et, Jt(r));
660
- }
661
- function Kt() {
662
- try {
663
- return window.self !== window.top;
664
- } catch {
665
- return !0;
666
- }
667
- }
668
- function Yt() {
669
- const r = Qt(), t = zt(), e = Lt();
670
- if (r) {
671
- if (t)
672
- return {
673
- launchParams: t,
674
- isPageReload: Kt() ? e || r.initDataRaw === t.initDataRaw : !0
675
- };
676
- if (e)
677
- return {
678
- launchParams: r,
679
- isPageReload: e
680
- };
681
- throw new Error("Unable to retrieve current launch parameters, which must exist.");
682
- }
683
- if (t)
684
- return {
685
- launchParams: t,
686
- isPageReload: !1
687
- };
688
- throw new Error("Unable to retrieve any launch parameters.");
636
+ return Ce(r.name);
689
637
  }
690
- const nt = "tmajsLaunchData";
691
- function Ct() {
692
- const r = window[nt];
693
- if (r)
694
- return r;
695
- const t = Yt();
696
- return window[nt] = t, Zt(t.launchParams), t;
697
- }
698
- function rr() {
699
- try {
700
- return Ct(), !0;
701
- } catch {
702
- return !1;
703
- }
704
- }
705
- function Xt(r) {
706
- return "external" in r && R(r.external) && "notify" in r.external && typeof r.external.notify == "function";
707
- }
708
- function te(r) {
709
- return "TelegramWebviewProxy" in r && R(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
710
- }
711
- function vt() {
712
- try {
713
- return window.self !== window.top;
714
- } catch {
715
- return !0;
716
- }
717
- }
718
- class et extends Error {
719
- constructor(t, e) {
720
- super(`Method "${t}" is unsupported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, et.prototype);
721
- }
722
- }
723
- class rt extends Error {
724
- constructor(t, e, s) {
725
- super(`Parameter "${e}" in method "${t}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, rt.prototype);
726
- }
727
- }
728
- class Pt {
729
- constructor(t, e) {
730
- this.prefix = t, this.enabled = e;
638
+ class ve {
639
+ constructor(e, t) {
640
+ this.prefix = e, this.enabled = t;
731
641
  }
732
642
  /**
733
643
  * Prints message into a console in case, logger is currently enabled.
734
644
  * @param level - log level.
735
645
  * @param args - arguments.
736
646
  */
737
- print(t, ...e) {
647
+ print(e, ...t) {
738
648
  if (!this.enabled)
739
649
  return;
740
650
  const s = /* @__PURE__ */ new Date(), n = Intl.DateTimeFormat("en-GB", {
@@ -744,7 +654,7 @@ class Pt {
744
654
  fractionalSecondDigits: 3,
745
655
  timeZone: "UTC"
746
656
  }).format(s);
747
- console[t](`[${n}]`, this.prefix, ...e);
657
+ console[e](`[${n}]`, this.prefix, ...t);
748
658
  }
749
659
  /**
750
660
  * Disables the logger.
@@ -756,8 +666,8 @@ class Pt {
756
666
  * Prints error message into a console.
757
667
  * @param args
758
668
  */
759
- error(...t) {
760
- this.print("error", ...t);
669
+ error(...e) {
670
+ this.print("error", ...e);
761
671
  }
762
672
  /**
763
673
  * Enables the logger.
@@ -769,47 +679,114 @@ class Pt {
769
679
  * Prints log message into a console.
770
680
  * @param args
771
681
  */
772
- log(...t) {
773
- this.print("log", ...t);
682
+ log(...e) {
683
+ this.print("log", ...e);
774
684
  }
775
685
  /**
776
686
  * Prints warning message into a console.
777
687
  * @param args
778
688
  */
779
- warn(...t) {
780
- this.print("warn", ...t);
689
+ warn(...e) {
690
+ this.print("warn", ...e);
781
691
  }
782
692
  }
783
- let kt = "https://web.telegram.org";
784
- const V = new Pt("[SDK]", !1);
785
- function sr(r) {
693
+ let Pe = "https://web.telegram.org";
694
+ const q = new ve("[SDK]", !1);
695
+ function Yt(r) {
786
696
  if (r) {
787
- V.enable();
697
+ q.enable();
788
698
  return;
789
699
  }
790
- V.disable();
700
+ q.disable();
791
701
  }
792
- function nr(r) {
793
- kt = r;
702
+ function Xt(r) {
703
+ Pe = r;
704
+ }
705
+ function Fe() {
706
+ return Pe;
707
+ }
708
+ function ze(r) {
709
+ const {
710
+ initDataRaw: e,
711
+ themeParams: t,
712
+ platform: s,
713
+ version: n,
714
+ showSettings: i,
715
+ startParam: a,
716
+ botInline: c
717
+ } = r, u = new URLSearchParams();
718
+ return e && u.set("tgWebAppData", e), u.set("tgWebAppPlatform", s), u.set("tgWebAppThemeParams", Ne(t)), u.set("tgWebAppVersion", n), a && u.set("tgWebAppStartParam", n), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof c == "boolean" && u.set("tgWebAppBotInline", c ? "1" : "0"), u.toString();
719
+ }
720
+ const ke = "telegram-mini-apps-launch-params";
721
+ function Je() {
722
+ return Ee(sessionStorage.getItem(ke) || "");
723
+ }
724
+ function Qe(r) {
725
+ sessionStorage.setItem(ke, ze(r));
726
+ }
727
+ function te() {
728
+ const r = [];
729
+ for (const e of [
730
+ // Try to retrieve launch parameters from the current location. This method can return
731
+ // nothing in case, location was changed and then page was reloaded.
732
+ Ge,
733
+ // Then, try using the lower level API - window.performance.
734
+ je,
735
+ // Finally, try to extract launch parameters from the session storage.
736
+ Je
737
+ ])
738
+ try {
739
+ const t = e();
740
+ return Qe(t), t;
741
+ } catch (t) {
742
+ r.push(t);
743
+ }
744
+ throw q.error("Unable to extract launch parameters. Received errors:", r), new Error("Unable to retrieve launch parameters from any known source.");
745
+ }
746
+ function er() {
747
+ return {
748
+ launchParams: te(),
749
+ isPageReload: le()
750
+ };
751
+ }
752
+ function tr() {
753
+ try {
754
+ return te(), !0;
755
+ } catch {
756
+ return !1;
757
+ }
794
758
  }
795
- function ee() {
796
- return kt;
759
+ function Ze(r) {
760
+ return "external" in r && R(r.external) && "notify" in r.external && typeof r.external.notify == "function";
761
+ }
762
+ function Ke(r) {
763
+ return "TelegramWebviewProxy" in r && R(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
764
+ }
765
+ class re extends Error {
766
+ constructor(e, t) {
767
+ super(`Method "${e}" is unsupported in the Mini Apps version ${t}.`), Object.setPrototypeOf(this, re.prototype);
768
+ }
797
769
  }
798
- const re = f({
799
- eventType: u(),
770
+ class se extends Error {
771
+ constructor(e, t, s) {
772
+ super(`Parameter "${t}" in method "${e}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, se.prototype);
773
+ }
774
+ }
775
+ const Ye = f({
776
+ eventType: h(),
800
777
  eventData: (r) => r
801
778
  });
802
- function se(r) {
803
- return re.parse(r);
779
+ function Xe(r) {
780
+ return Ye.parse(r);
804
781
  }
805
- function ne(r, t) {
782
+ function et(r, e) {
806
783
  window.dispatchEvent(new MessageEvent("message", {
807
- data: JSON.stringify({ eventType: r, eventData: t }),
784
+ data: JSON.stringify({ eventType: r, eventData: e }),
808
785
  // We specify window.parent to imitate the case, it sent us this event.
809
786
  source: window.parent
810
787
  }));
811
788
  }
812
- function ie() {
789
+ function tt() {
813
790
  const r = window;
814
791
  "TelegramGameProxy_receiveEvent" in r || [
815
792
  ["TelegramGameProxy_receiveEvent"],
@@ -818,168 +795,168 @@ function ie() {
818
795
  // Desktop.
819
796
  ["Telegram", "WebView", "receiveEvent"]
820
797
  // Android and iOS.
821
- ].forEach((t) => {
822
- let e = r;
823
- t.forEach((s, n, i) => {
798
+ ].forEach((e) => {
799
+ let t = r;
800
+ e.forEach((s, n, i) => {
824
801
  if (n === i.length - 1) {
825
- e[s] = ne;
802
+ t[s] = et;
826
803
  return;
827
804
  }
828
- s in e || (e[s] = {}), e = e[s];
805
+ s in t || (t[s] = {}), t = t[s];
829
806
  });
830
807
  });
831
808
  }
832
- function oe(r) {
833
- ie(), window.addEventListener("message", (t) => {
834
- if (t.source === window.parent)
809
+ function rt(r) {
810
+ tt(), window.addEventListener("message", (e) => {
811
+ if (e.source === window.parent)
835
812
  try {
836
- const { eventType: e, eventData: s } = se(t.data);
837
- r(e, s);
813
+ const { eventType: t, eventData: s } = Xe(e.data);
814
+ r(t, s);
838
815
  } catch {
839
816
  }
840
817
  });
841
818
  }
842
- function ae() {
819
+ function st() {
843
820
  return f({
844
- req_id: u(),
845
- data: (r) => r === null ? r : u().optional().parse(r)
821
+ req_id: h(),
822
+ data: (r) => r === null ? r : h().optional().parse(r)
846
823
  });
847
824
  }
848
- function ce() {
825
+ function nt() {
849
826
  return f({
850
- req_id: u(),
827
+ req_id: h(),
851
828
  result: (r) => r,
852
- error: u().optional()
829
+ error: h().optional()
853
830
  });
854
831
  }
855
- function ue() {
832
+ function it() {
856
833
  return f({
857
- slug: u(),
858
- status: u()
834
+ slug: h(),
835
+ status: h()
859
836
  });
860
837
  }
861
- function he() {
862
- return f({ status: u() });
838
+ function ot() {
839
+ return f({ status: h() });
863
840
  }
864
- function pe() {
841
+ function at() {
865
842
  return f({
866
- button_id: (r) => r == null ? void 0 : u().parse(r)
843
+ button_id: (r) => r == null ? void 0 : h().parse(r)
867
844
  });
868
845
  }
869
- function le() {
846
+ function ct() {
870
847
  return f({
871
- data: u().optional()
848
+ data: h().optional()
872
849
  });
873
850
  }
874
- function de() {
851
+ function ht() {
875
852
  return f({
876
853
  theme_params: (r) => {
877
- const t = gt().optional();
878
- return Object.entries(Y(r)).reduce((e, [s, n]) => (e[s] = t.parse(n), e), {});
854
+ const e = _e().optional();
855
+ return Object.entries(Y(r)).reduce((t, [s, n]) => (t[s] = e.parse(n), t), {});
879
856
  }
880
857
  });
881
858
  }
882
- function fe() {
859
+ function ut() {
883
860
  return f({
884
- height: q(),
885
- width: (r) => r == null ? window.innerWidth : q().parse(r),
861
+ height: A(),
862
+ width: (r) => r == null ? window.innerWidth : A().parse(r),
886
863
  is_state_stable: k(),
887
864
  is_expanded: k()
888
865
  });
889
866
  }
890
- function ge() {
891
- return f({ status: u() });
867
+ function pt() {
868
+ return f({ status: h() });
892
869
  }
893
- function we() {
894
- const r = new w(), t = (e, ...s) => {
895
- V.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
870
+ function lt() {
871
+ const r = new w(), e = (t, ...s) => {
872
+ q.log("Emitting processed event:", t, ...s), r.emit(t, ...s);
896
873
  };
897
874
  return window.addEventListener("resize", () => {
898
- t("viewport_changed", {
875
+ e("viewport_changed", {
899
876
  width: window.innerWidth,
900
877
  height: window.innerHeight,
901
878
  is_state_stable: !0,
902
879
  is_expanded: !0
903
880
  });
904
- }), oe((e, s) => {
905
- V.log("Received raw event:", e, s);
881
+ }), rt((t, s) => {
882
+ q.log("Received raw event:", t, s);
906
883
  try {
907
- switch (e) {
884
+ switch (t) {
908
885
  case "viewport_changed":
909
- return t(e, fe().parse(s));
886
+ return e(t, ut().parse(s));
910
887
  case "theme_changed":
911
- return t(e, de().parse(s));
888
+ return e(t, ht().parse(s));
912
889
  case "popup_closed":
913
890
  return (
914
891
  // Sent on desktop.
915
- s == null ? t(e, {}) : t(e, pe().parse(s))
892
+ s == null ? e(t, {}) : e(t, at().parse(s))
916
893
  );
917
894
  case "set_custom_style":
918
- return t(e, u().parse(s));
895
+ return e(t, h().parse(s));
919
896
  case "qr_text_received":
920
- return t(e, le().parse(s));
897
+ return e(t, ct().parse(s));
921
898
  case "clipboard_text_received":
922
- return t(e, ae().parse(s));
899
+ return e(t, st().parse(s));
923
900
  case "invoice_closed":
924
- return t(e, ue().parse(s));
901
+ return e(t, it().parse(s));
925
902
  case "phone_requested":
926
- return t("phone_requested", he().parse(s));
903
+ return e("phone_requested", ot().parse(s));
927
904
  case "custom_method_invoked":
928
- return t("custom_method_invoked", ce().parse(s));
905
+ return e("custom_method_invoked", nt().parse(s));
929
906
  case "write_access_requested":
930
- return t("write_access_requested", ge().parse(s));
907
+ return e("write_access_requested", pt().parse(s));
931
908
  case "main_button_pressed":
932
909
  case "back_button_pressed":
933
910
  case "settings_button_pressed":
934
911
  case "scan_qr_popup_closed":
935
912
  case "reload_iframe":
936
- return t(e);
913
+ return e(t);
937
914
  default:
938
- return t(e, s);
915
+ return e(t, s);
939
916
  }
940
917
  } catch (n) {
941
- V.error("Error processing event:", n);
918
+ q.error("Error processing event:", n);
942
919
  }
943
920
  }), r;
944
921
  }
945
922
  const Q = "telegram-mini-apps-cached-emitter";
946
923
  function U() {
947
924
  const r = window;
948
- return r[Q] === void 0 && (r[Q] = we()), r[Q];
925
+ return r[Q] === void 0 && (r[Q] = lt()), r[Q];
949
926
  }
950
- function T(r, t) {
951
- U().off(r, t);
927
+ function $(r, e) {
928
+ U().off(r, e);
952
929
  }
953
- function y(r, t) {
954
- return U().on(r, t), () => T(r, t);
930
+ function y(r, e) {
931
+ return U().on(r, e), () => $(r, e);
955
932
  }
956
- function ir(r, t) {
957
- return U().once(r, t), () => T(r, t);
933
+ function rr(r, e) {
934
+ return U().once(r, e), () => $(r, e);
958
935
  }
959
- function _e(r) {
936
+ function dt(r) {
960
937
  U().unsubscribe(r);
961
938
  }
962
- function or(r) {
963
- return U().subscribe(r), () => _e(r);
939
+ function sr(r) {
940
+ return U().subscribe(r), () => dt(r);
964
941
  }
965
- function be(r, t) {
966
- const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
942
+ function ft(r, e) {
943
+ const t = r.split("."), s = e.split("."), n = Math.max(t.length, s.length);
967
944
  for (let i = 0; i < n; i += 1) {
968
- const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
945
+ const a = parseInt(t[i] || "0", 10), c = parseInt(s[i] || "0", 10);
969
946
  if (a !== c)
970
947
  return a > c ? 1 : -1;
971
948
  }
972
949
  return 0;
973
950
  }
974
- function P(r, t) {
975
- return be(r, t) <= 0;
951
+ function P(r, e) {
952
+ return ft(r, e) <= 0;
976
953
  }
977
- function I(r, t, e) {
978
- if (typeof e == "string") {
979
- if (r === "web_app_open_link" && t === "try_instant_view")
980
- return P("6.4", e);
981
- if (r === "web_app_set_header_color" && t === "color")
982
- return P("6.9", e);
954
+ function I(r, e, t) {
955
+ if (typeof t == "string") {
956
+ if (r === "web_app_open_link" && e === "try_instant_view")
957
+ return P("6.4", t);
958
+ if (r === "web_app_set_header_color" && e === "color")
959
+ return P("6.9", t);
983
960
  }
984
961
  switch (r) {
985
962
  case "web_app_open_tg_link":
@@ -988,50 +965,50 @@ function I(r, t, e) {
988
965
  case "web_app_set_background_color":
989
966
  case "web_app_set_header_color":
990
967
  case "web_app_trigger_haptic_feedback":
991
- return P("6.1", t);
968
+ return P("6.1", e);
992
969
  case "web_app_open_popup":
993
- return P("6.2", t);
970
+ return P("6.2", e);
994
971
  case "web_app_close_scan_qr_popup":
995
972
  case "web_app_open_scan_qr_popup":
996
973
  case "web_app_read_text_from_clipboard":
997
- return P("6.4", t);
974
+ return P("6.4", e);
998
975
  case "web_app_switch_inline_query":
999
- return P("6.7", t);
976
+ return P("6.7", e);
1000
977
  case "web_app_invoke_custom_method":
1001
978
  case "web_app_request_write_access":
1002
979
  case "web_app_request_phone":
1003
- return P("6.9", t);
980
+ return P("6.9", e);
1004
981
  case "web_app_setup_settings_button":
1005
- return P("6.10", t);
982
+ return P("6.10", e);
1006
983
  default:
1007
984
  return !0;
1008
985
  }
1009
986
  }
1010
- function E(r, t) {
1011
- return (e) => I(t[e], r);
987
+ function E(r, e) {
988
+ return (t) => I(e[t], r);
1012
989
  }
1013
- function St(r, t) {
1014
- return (e) => {
1015
- const [s, n] = t[e];
990
+ function Se(r, e) {
991
+ return (t) => {
992
+ const [s, n] = e[t];
1016
993
  return I(s, n, r);
1017
994
  };
1018
995
  }
1019
- function d(r, t, e) {
996
+ function d(r, e, t) {
1020
997
  let s = {}, n;
1021
- t === void 0 && e === void 0 ? s = {} : t !== void 0 && e !== void 0 ? (s = e, n = t) : t !== void 0 && ("targetOrigin" in t ? s = t : n = t);
1022
- const { targetOrigin: i = ee() } = s;
1023
- if (V.log(`Calling method "${r}"`, n), vt()) {
998
+ e === void 0 && t === void 0 ? s = {} : e !== void 0 && t !== void 0 ? (s = t, n = e) : e !== void 0 && ("targetOrigin" in e ? s = e : n = e);
999
+ const { targetOrigin: i = Fe() } = s;
1000
+ if (q.log(`Calling method "${r}"`, n), pe()) {
1024
1001
  window.parent.postMessage(JSON.stringify({
1025
1002
  eventType: r,
1026
1003
  eventData: n
1027
1004
  }), i);
1028
1005
  return;
1029
1006
  }
1030
- if (Xt(window)) {
1007
+ if (Ze(window)) {
1031
1008
  window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
1032
1009
  return;
1033
1010
  }
1034
- if (te(window)) {
1011
+ if (Ke(window)) {
1035
1012
  window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
1036
1013
  return;
1037
1014
  }
@@ -1039,64 +1016,64 @@ function d(r, t, e) {
1039
1016
  "Unable to determine current environment and possible way to send event."
1040
1017
  );
1041
1018
  }
1042
- function me(r) {
1043
- return (t, e) => {
1044
- if (!I(t, r))
1045
- throw new et(t, r);
1046
- if (R(e)) {
1019
+ function gt(r) {
1020
+ return (e, t) => {
1021
+ if (!I(e, r))
1022
+ throw new re(e, r);
1023
+ if (R(t)) {
1047
1024
  let s;
1048
- if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !I(t, s, r))
1049
- throw new rt(t, s, r);
1025
+ if (e === "web_app_open_link" && "try_instant_view" in t ? s = "try_instant_view" : e === "web_app_set_header_color" && "color" in t && (s = "color"), s && !I(e, s, r))
1026
+ throw new se(e, s, r);
1050
1027
  }
1051
- return d(t, e);
1028
+ return d(e, t);
1052
1029
  };
1053
1030
  }
1054
1031
  class J extends Error {
1055
- constructor(t) {
1056
- super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, J.prototype);
1032
+ constructor(e) {
1033
+ super(`Async call timeout exceeded. Timeout: ${e}`), Object.setPrototypeOf(this, J.prototype);
1057
1034
  }
1058
1035
  }
1059
- function ar(r) {
1036
+ function nr(r) {
1060
1037
  return r instanceof J;
1061
1038
  }
1062
- function ye(r) {
1063
- return new Promise((t) => {
1064
- setTimeout(t, r);
1039
+ function wt(r) {
1040
+ return new Promise((e) => {
1041
+ setTimeout(e, r);
1065
1042
  });
1066
1043
  }
1067
- function Ee(r) {
1068
- return new Promise((t, e) => {
1069
- setTimeout(e, r, new J(r));
1044
+ function _t(r) {
1045
+ return new Promise((e, t) => {
1046
+ setTimeout(t, r, new J(r));
1070
1047
  });
1071
1048
  }
1072
- function xt(r, t) {
1049
+ function xe(r, e) {
1073
1050
  return Promise.race([
1074
1051
  r(),
1075
- Ee(t)
1052
+ _t(e)
1076
1053
  ]);
1077
1054
  }
1078
- function m(r, t, e, s) {
1055
+ function m(r, e, t, s) {
1079
1056
  let n, i, a, c;
1080
- typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), R(i) && typeof i.req_id == "string" && (c = i.req_id);
1081
- const { postEvent: p = d, timeout: h } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((A, l) => {
1057
+ typeof e == "string" || Array.isArray(e) ? (a = Array.isArray(e) ? e : [e], n = t) : (i = e, a = Array.isArray(t) ? t : [t], n = s), R(i) && typeof i.req_id == "string" && (c = i.req_id);
1058
+ const { postEvent: u = d, timeout: p } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((V, l) => {
1082
1059
  const C = a.map((v) => y(v, (M) => {
1083
- c && (!R(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
1060
+ c && (!R(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), V(M));
1084
1061
  })), x = () => C.forEach((v) => v());
1085
1062
  try {
1086
- p(r, i);
1063
+ u(r, i);
1087
1064
  } catch (v) {
1088
1065
  x(), l(v);
1089
1066
  }
1090
1067
  });
1091
- return typeof h == "number" ? xt(_, h) : _();
1068
+ return typeof p == "number" ? xe(_, p) : _();
1092
1069
  }
1093
- async function O(r, t, e, s = {}) {
1070
+ async function H(r, e, t, s = {}) {
1094
1071
  const { result: n, error: i } = await m(
1095
1072
  "web_app_invoke_custom_method",
1096
1073
  {
1097
1074
  method: r,
1098
- params: t,
1099
- req_id: e
1075
+ params: e,
1076
+ req_id: t
1100
1077
  },
1101
1078
  "custom_method_invoked",
1102
1079
  s
@@ -1105,8 +1082,8 @@ async function O(r, t, e, s = {}) {
1105
1082
  throw new Error(i);
1106
1083
  return n;
1107
1084
  }
1108
- class Ce {
1109
- constructor(t, e, s = d) {
1085
+ class bt {
1086
+ constructor(e, t, s = d) {
1110
1087
  o(this, "ee", new w());
1111
1088
  o(this, "state");
1112
1089
  /**
@@ -1114,24 +1091,24 @@ class Ce {
1114
1091
  * @param event - event name.
1115
1092
  * @param listener - event listener.
1116
1093
  */
1117
- o(this, "on", (t, e) => t === "click" ? y("back_button_pressed", e) : this.ee.on(t, e));
1094
+ o(this, "on", (e, t) => e === "click" ? y("back_button_pressed", t) : this.ee.on(e, t));
1118
1095
  /**
1119
1096
  * Removes event listener.
1120
1097
  * @param event - event name.
1121
1098
  * @param listener - event listener.
1122
1099
  */
1123
- o(this, "off", (t, e) => t === "click" ? T("back_button_pressed", e) : this.ee.off(t, e));
1100
+ o(this, "off", (e, t) => e === "click" ? $("back_button_pressed", t) : this.ee.off(e, t));
1124
1101
  /**
1125
1102
  * Checks if specified method is supported by current component.
1126
1103
  */
1127
1104
  o(this, "supports");
1128
- this.postEvent = s, this.state = new b({ isVisible: t }, this.ee), this.supports = E(e, {
1105
+ this.postEvent = s, this.state = new b({ isVisible: e }, this.ee), this.supports = E(t, {
1129
1106
  show: "web_app_setup_back_button",
1130
1107
  hide: "web_app_setup_back_button"
1131
1108
  });
1132
1109
  }
1133
- set isVisible(t) {
1134
- this.state.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
1110
+ set isVisible(e) {
1111
+ this.state.set("isVisible", e), this.postEvent("web_app_setup_back_button", { is_visible: e });
1135
1112
  }
1136
1113
  /**
1137
1114
  * True if BackButton is currently visible.
@@ -1152,23 +1129,23 @@ class Ce {
1152
1129
  this.isVisible = !0;
1153
1130
  }
1154
1131
  }
1155
- function it(r, t) {
1156
- return r + (r.length > 0 && t.length > 0 ? ` ${t}` : t);
1132
+ function ie(r, e) {
1133
+ return r + (r.length > 0 && e.length > 0 ? ` ${e}` : e);
1157
1134
  }
1158
- function ve(...r) {
1159
- return r.reduce((t, e) => {
1135
+ function mt(...r) {
1136
+ return r.reduce((e, t) => {
1160
1137
  let s = "";
1161
- return typeof e == "string" ? s = e : typeof e == "object" && e !== null && (s = Object.entries(e).reduce((n, [i, a]) => a ? it(n, i) : n, "")), it(t, s);
1138
+ return typeof t == "string" ? s = t : typeof t == "object" && t !== null && (s = Object.entries(t).reduce((n, [i, a]) => a ? ie(n, i) : n, "")), ie(e, s);
1162
1139
  }, "");
1163
1140
  }
1164
- function cr(...r) {
1165
- return r.reduce((t, e) => (R(e) && Object.entries(e).forEach(([s, n]) => {
1166
- const i = ve(t[s], n);
1167
- i.length > 0 && (t[s] = i);
1168
- }), t), {});
1141
+ function ir(...r) {
1142
+ return r.reduce((e, t) => (R(t) && Object.entries(t).forEach(([s, n]) => {
1143
+ const i = mt(e[s], n);
1144
+ i.length > 0 && (e[s] = i);
1145
+ }), e), {});
1169
1146
  }
1170
- class Pe {
1171
- constructor(t, e = d) {
1147
+ class yt {
1148
+ constructor(e, t = d) {
1172
1149
  o(this, "ee", new w());
1173
1150
  o(this, "state");
1174
1151
  /**
@@ -1179,10 +1156,10 @@ class Pe {
1179
1156
  * Removes event listener.
1180
1157
  */
1181
1158
  o(this, "off", this.ee.off.bind(this.ee));
1182
- this.postEvent = e, this.state = new b({ isConfirmationNeeded: t }, this.ee);
1159
+ this.postEvent = t, this.state = new b({ isConfirmationNeeded: e }, this.ee);
1183
1160
  }
1184
- set isConfirmationNeeded(t) {
1185
- this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
1161
+ set isConfirmationNeeded(e) {
1162
+ this.state.set("isConfirmationNeeded", e), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: e });
1186
1163
  }
1187
1164
  /**
1188
1165
  * Returns true, if the confirmation dialog enabled while the user is trying
@@ -1206,16 +1183,16 @@ class Pe {
1206
1183
  this.isConfirmationNeeded = !0;
1207
1184
  }
1208
1185
  }
1209
- function ot(r, t) {
1210
- return r.reduce((e, s) => (e[s] = t, e), {});
1186
+ function oe(r, e) {
1187
+ return r.reduce((t, s) => (t[s] = e, t), {});
1211
1188
  }
1212
- class ke {
1213
- constructor(t, e, s = d) {
1189
+ class Et {
1190
+ constructor(e, t, s = d) {
1214
1191
  /**
1215
1192
  * Checks if specified method is supported by current component.
1216
1193
  */
1217
1194
  o(this, "supports");
1218
- this.createRequestId = e, this.postEvent = s, this.supports = E(t, {
1195
+ this.createRequestId = t, this.postEvent = s, this.supports = E(e, {
1219
1196
  delete: "web_app_invoke_custom_method",
1220
1197
  get: "web_app_invoke_custom_method",
1221
1198
  getKeys: "web_app_invoke_custom_method",
@@ -1227,41 +1204,41 @@ class ke {
1227
1204
  * @param keyOrKeys - key or keys to delete.
1228
1205
  * @param options - request execution options.
1229
1206
  */
1230
- async delete(t, e = {}) {
1231
- const s = Array.isArray(t) ? t : [t];
1232
- s.length !== 0 && await O(
1207
+ async delete(e, t = {}) {
1208
+ const s = Array.isArray(e) ? e : [e];
1209
+ s.length !== 0 && await H(
1233
1210
  "deleteStorageValues",
1234
1211
  { keys: s },
1235
1212
  this.createRequestId(),
1236
- { ...e, postEvent: this.postEvent }
1213
+ { ...t, postEvent: this.postEvent }
1237
1214
  );
1238
1215
  }
1239
1216
  /**
1240
1217
  * Returns list of all keys presented in the cloud storage.
1241
1218
  * @param options - request execution options.
1242
1219
  */
1243
- async getKeys(t = {}) {
1244
- const e = await O(
1220
+ async getKeys(e = {}) {
1221
+ const t = await H(
1245
1222
  "getStorageKeys",
1246
1223
  {},
1247
1224
  this.createRequestId(),
1248
- { ...t, postEvent: this.postEvent }
1225
+ { ...e, postEvent: this.postEvent }
1249
1226
  );
1250
- return Bt().of(u()).parse(e);
1227
+ return $e().of(h()).parse(t);
1251
1228
  }
1252
- async get(t, e = {}) {
1253
- const s = Array.isArray(t) ? t : [t];
1229
+ async get(e, t = {}) {
1230
+ const s = Array.isArray(e) ? e : [e];
1254
1231
  if (s.length === 0)
1255
- return ot(s, "");
1232
+ return oe(s, "");
1256
1233
  const n = f(
1257
- ot(s, u())
1258
- ), i = await O(
1234
+ oe(s, h())
1235
+ ), i = await H(
1259
1236
  "getStorageValues",
1260
1237
  { keys: s },
1261
1238
  this.createRequestId(),
1262
- { ...e, postEvent: this.postEvent }
1239
+ { ...t, postEvent: this.postEvent }
1263
1240
  ).then((a) => n.parse(a));
1264
- return Array.isArray(t) ? i : i[t];
1241
+ return Array.isArray(e) ? i : i[e];
1265
1242
  }
1266
1243
  /**
1267
1244
  * Saves specified value by key.
@@ -1269,26 +1246,26 @@ class ke {
1269
1246
  * @param value - storage value.
1270
1247
  * @param options - request execution options.
1271
1248
  */
1272
- async set(t, e, s = {}) {
1273
- await O(
1249
+ async set(e, t, s = {}) {
1250
+ await H(
1274
1251
  "saveStorageValue",
1275
- { key: t, value: e },
1252
+ { key: e, value: t },
1276
1253
  this.createRequestId(),
1277
1254
  { ...s, postEvent: this.postEvent }
1278
1255
  );
1279
1256
  }
1280
1257
  }
1281
- function S(r, t) {
1282
- document.documentElement.style.setProperty(r, t);
1258
+ function S(r, e) {
1259
+ document.documentElement.style.setProperty(r, e);
1283
1260
  }
1284
- function Se(r, t) {
1285
- const e = () => {
1261
+ function Ct(r, e) {
1262
+ const t = () => {
1286
1263
  S("--tg-background-color", r.backgroundColor);
1287
1264
  }, s = () => {
1288
1265
  const {
1289
1266
  backgroundColor: n,
1290
1267
  secondaryBackgroundColor: i
1291
- } = t;
1268
+ } = e;
1292
1269
  if (X(r.headerColor)) {
1293
1270
  S("--tg-header-color", r.headerColor);
1294
1271
  return;
@@ -1299,31 +1276,31 @@ function Se(r, t) {
1299
1276
  }
1300
1277
  r.headerColor === "secondary_bg_color" && i && S("--tg-header-color", i);
1301
1278
  };
1302
- t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
1279
+ e.on("change", s), r.on("change:backgroundColor", t), r.on("change:headerColor", s), t(), s();
1303
1280
  }
1304
- function xe(r) {
1305
- const t = () => {
1306
- const e = r.getState();
1307
- Object.entries(e).forEach(([s, n]) => {
1281
+ function vt(r) {
1282
+ const e = () => {
1283
+ const t = r.getState();
1284
+ Object.entries(t).forEach(([s, n]) => {
1308
1285
  if (n) {
1309
1286
  const i = s.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`);
1310
1287
  S(`--tg-theme-${i}`, n);
1311
1288
  }
1312
1289
  });
1313
1290
  };
1314
- r.on("change", t), t();
1291
+ r.on("change", e), e();
1315
1292
  }
1316
- function at(r) {
1317
- const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-stable-height", `${r.stableHeight}px`);
1318
- r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
1293
+ function ae(r) {
1294
+ const e = () => S("--tg-viewport-height", `${r.height}px`), t = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-stable-height", `${r.stableHeight}px`);
1295
+ r.on("change:height", e), r.on("change:width", t), r.on("change:stableHeight", s), e(), t(), s();
1319
1296
  }
1320
- class qe {
1321
- constructor(t, e = d) {
1297
+ class Pt {
1298
+ constructor(e, t = d) {
1322
1299
  /**
1323
1300
  * Checks if specified method is supported by current component.
1324
1301
  */
1325
1302
  o(this, "supports");
1326
- this.postEvent = e, this.supports = E(t, {
1303
+ this.postEvent = t, this.supports = E(e, {
1327
1304
  impactOccurred: "web_app_trigger_haptic_feedback",
1328
1305
  notificationOccurred: "web_app_trigger_haptic_feedback",
1329
1306
  selectionChanged: "web_app_trigger_haptic_feedback"
@@ -1334,10 +1311,10 @@ class qe {
1334
1311
  * appropriate haptics based on style value passed.
1335
1312
  * @param style - impact style.
1336
1313
  */
1337
- impactOccurred(t) {
1314
+ impactOccurred(e) {
1338
1315
  this.postEvent("web_app_trigger_haptic_feedback", {
1339
1316
  type: "impact",
1340
- impact_style: t
1317
+ impact_style: e
1341
1318
  });
1342
1319
  }
1343
1320
  /**
@@ -1346,10 +1323,10 @@ class qe {
1346
1323
  * type value passed.
1347
1324
  * @param type - notification type.
1348
1325
  */
1349
- notificationOccurred(t) {
1326
+ notificationOccurred(e) {
1350
1327
  this.postEvent("web_app_trigger_haptic_feedback", {
1351
1328
  type: "notification",
1352
- notification_type: t
1329
+ notification_type: e
1353
1330
  });
1354
1331
  }
1355
1332
  /**
@@ -1363,36 +1340,36 @@ class qe {
1363
1340
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1364
1341
  }
1365
1342
  }
1366
- function Ae() {
1343
+ function kt() {
1367
1344
  const r = document.createElement("style");
1368
- r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (t) => {
1369
- r.innerHTML = t;
1345
+ r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (e) => {
1346
+ r.innerHTML = e;
1370
1347
  });
1371
1348
  }
1372
- function qt(r) {
1349
+ function qe(r) {
1373
1350
  return `telegram-mini-apps-${r}`;
1374
1351
  }
1375
- function B(r, t) {
1376
- sessionStorage.setItem(qt(r), JSON.stringify(t));
1352
+ function B(r, e) {
1353
+ sessionStorage.setItem(qe(r), JSON.stringify(e));
1377
1354
  }
1378
1355
  function D(r) {
1379
- const t = sessionStorage.getItem(qt(r));
1380
- return t ? JSON.parse(t) : null;
1356
+ const e = sessionStorage.getItem(qe(r));
1357
+ return e ? JSON.parse(e) : null;
1381
1358
  }
1382
- function Ve(r, t, e) {
1383
- const { isVisible: s = !1 } = r ? D("back-button") || {} : {}, n = new Ce(s, t, e);
1359
+ function St(r, e, t) {
1360
+ const { isVisible: s = !1 } = r ? D("back-button") || {} : {}, n = new bt(s, e, t);
1384
1361
  return n.on("change", () => {
1385
1362
  B("back-button", { isVisible: n.isVisible });
1386
1363
  }), n;
1387
1364
  }
1388
- function Re(r, t) {
1389
- const { isConfirmationNeeded: e = !1 } = r ? D("closing-behavior") || {} : {}, s = new Pe(e, t);
1365
+ function xt(r, e) {
1366
+ const { isConfirmationNeeded: t = !1 } = r ? D("closing-behavior") || {} : {}, s = new yt(t, e);
1390
1367
  return s.on("change", () => B("closing-behavior", {
1391
1368
  isConfirmationNeeded: s.isConfirmationNeeded
1392
1369
  })), s;
1393
1370
  }
1394
- class Ie {
1395
- constructor(t) {
1371
+ class qt {
1372
+ constructor(e) {
1396
1373
  o(this, "ee", new w());
1397
1374
  o(this, "state");
1398
1375
  o(this, "postEvent");
@@ -1401,32 +1378,32 @@ class Ie {
1401
1378
  * @param event - event name.
1402
1379
  * @param listener - event listener.
1403
1380
  */
1404
- o(this, "on", (t, e) => (
1381
+ o(this, "on", (e, t) => (
1405
1382
  // FIXME: Event 'main_button_pressed' is still being received on Android
1406
1383
  // even if the main button is disabled.
1407
1384
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/3
1408
- t === "click" ? y("main_button_pressed", e) : this.ee.on(t, e)
1385
+ e === "click" ? y("main_button_pressed", t) : this.ee.on(e, t)
1409
1386
  ));
1410
1387
  /**
1411
1388
  * Removes event listener.
1412
1389
  * @param event - event name.
1413
1390
  * @param listener - event listener.
1414
1391
  */
1415
- o(this, "off", (t, e) => t === "click" ? T("main_button_pressed", e) : this.ee.off(t, e));
1392
+ o(this, "off", (e, t) => e === "click" ? $("main_button_pressed", t) : this.ee.off(e, t));
1416
1393
  const {
1417
- postEvent: e = d,
1394
+ postEvent: t = d,
1418
1395
  text: s,
1419
1396
  textColor: n,
1420
1397
  backgroundColor: i,
1421
1398
  isEnabled: a,
1422
1399
  isVisible: c,
1423
- isLoaderVisible: p
1424
- } = t;
1425
- this.postEvent = e, this.state = new b({
1400
+ isLoaderVisible: u
1401
+ } = e;
1402
+ this.postEvent = t, this.state = new b({
1426
1403
  backgroundColor: i,
1427
1404
  isEnabled: a,
1428
1405
  isVisible: c,
1429
- isLoaderVisible: p,
1406
+ isLoaderVisible: u,
1430
1407
  text: s,
1431
1408
  textColor: n
1432
1409
  }, this.ee);
@@ -1444,8 +1421,8 @@ class Ie {
1444
1421
  text_color: this.textColor
1445
1422
  });
1446
1423
  }
1447
- set isEnabled(t) {
1448
- this.setParams({ isEnabled: t });
1424
+ set isEnabled(e) {
1425
+ this.setParams({ isEnabled: e });
1449
1426
  }
1450
1427
  /**
1451
1428
  * True if the Main Button is currently enabled.
@@ -1453,8 +1430,8 @@ class Ie {
1453
1430
  get isEnabled() {
1454
1431
  return this.state.get("isEnabled");
1455
1432
  }
1456
- set isLoaderVisible(t) {
1457
- this.setParams({ isLoaderVisible: t });
1433
+ set isLoaderVisible(e) {
1434
+ this.setParams({ isLoaderVisible: e });
1458
1435
  }
1459
1436
  /**
1460
1437
  * True if the Main Button loader is currently visible.
@@ -1462,8 +1439,8 @@ class Ie {
1462
1439
  get isLoaderVisible() {
1463
1440
  return this.state.get("isLoaderVisible");
1464
1441
  }
1465
- set isVisible(t) {
1466
- this.setParams({ isVisible: t });
1442
+ set isVisible(e) {
1443
+ this.setParams({ isVisible: e });
1467
1444
  }
1468
1445
  /**
1469
1446
  * True if the Main Button is currently visible.
@@ -1531,47 +1508,47 @@ class Ie {
1531
1508
  * Sets new Main Button text. Minimal length for text is 1 symbol, and maximum is 64 symbols.
1532
1509
  * @param text - new text.
1533
1510
  */
1534
- setText(t) {
1535
- return this.setParams({ text: t });
1511
+ setText(e) {
1512
+ return this.setParams({ text: e });
1536
1513
  }
1537
1514
  /**
1538
1515
  * Sets new Main Button text color.
1539
1516
  * @param textColor - new text color.
1540
1517
  */
1541
- setTextColor(t) {
1542
- return this.setParams({ textColor: t });
1518
+ setTextColor(e) {
1519
+ return this.setParams({ textColor: e });
1543
1520
  }
1544
1521
  /**
1545
1522
  * Updates current Main Button color.
1546
1523
  * @param backgroundColor - color to set.
1547
1524
  */
1548
- setBackgroundColor(t) {
1549
- return this.setParams({ backgroundColor: t });
1525
+ setBackgroundColor(e) {
1526
+ return this.setParams({ backgroundColor: e });
1550
1527
  }
1551
1528
  /**
1552
1529
  * Allows setting multiple Main Button parameters.
1553
1530
  * @param params - Main Button parameters.
1554
1531
  */
1555
- setParams(t) {
1556
- return this.state.set(t), this.commit(), this;
1532
+ setParams(e) {
1533
+ return this.state.set(e), this.commit(), this;
1557
1534
  }
1558
1535
  }
1559
- function Le(r, t, e, s) {
1536
+ function At(r, e, t, s) {
1560
1537
  const {
1561
- backgroundColor: n = t,
1538
+ backgroundColor: n = e,
1562
1539
  isEnabled: i = !1,
1563
1540
  isVisible: a = !1,
1564
1541
  isLoaderVisible: c = !1,
1565
- textColor: p = e,
1566
- text: h = ""
1567
- } = r ? D("main-button") || {} : {}, g = new Ie({
1542
+ textColor: u = t,
1543
+ text: p = ""
1544
+ } = r ? D("main-button") || {} : {}, g = new qt({
1568
1545
  backgroundColor: n,
1569
1546
  isEnabled: i,
1570
1547
  isLoaderVisible: c,
1571
1548
  isVisible: a,
1572
1549
  postEvent: s,
1573
- text: h,
1574
- textColor: p
1550
+ text: p,
1551
+ textColor: u
1575
1552
  }), _ = () => B("main-button", {
1576
1553
  backgroundColor: g.backgroundColor,
1577
1554
  isEnabled: g.isEnabled,
@@ -1582,33 +1559,33 @@ function Le(r, t, e, s) {
1582
1559
  });
1583
1560
  return g.on("change", _), g;
1584
1561
  }
1585
- const $e = tt({
1562
+ const Vt = ee({
1586
1563
  contact: f({
1587
1564
  userId: {
1588
- type: q(),
1565
+ type: A(),
1589
1566
  from: "user_id"
1590
1567
  },
1591
1568
  phoneNumber: {
1592
- type: u(),
1569
+ type: h(),
1593
1570
  from: "phone_number"
1594
1571
  },
1595
1572
  firstName: {
1596
- type: u(),
1573
+ type: h(),
1597
1574
  from: "first_name"
1598
1575
  },
1599
1576
  lastName: {
1600
- type: u().optional(),
1577
+ type: h().optional(),
1601
1578
  from: "last_name"
1602
1579
  }
1603
1580
  }),
1604
1581
  authDate: {
1605
- type: lt(),
1582
+ type: fe(),
1606
1583
  from: "auth_date"
1607
1584
  },
1608
- hash: u()
1585
+ hash: h()
1609
1586
  });
1610
- class Te {
1611
- constructor(t) {
1587
+ class Rt {
1588
+ constructor(e) {
1612
1589
  o(this, "ee", new w());
1613
1590
  o(this, "state");
1614
1591
  o(this, "botInline");
@@ -1633,20 +1610,20 @@ class Te {
1633
1610
  */
1634
1611
  o(this, "supportsParam");
1635
1612
  const {
1636
- postEvent: e = d,
1613
+ postEvent: t = d,
1637
1614
  headerColor: s,
1638
1615
  backgroundColor: n,
1639
1616
  version: i,
1640
1617
  botInline: a,
1641
1618
  createRequestId: c
1642
- } = t, p = E(i, {
1619
+ } = e, u = E(i, {
1643
1620
  requestPhoneAccess: "web_app_request_phone",
1644
1621
  requestWriteAccess: "web_app_request_write_access",
1645
1622
  switchInlineQuery: "web_app_switch_inline_query",
1646
1623
  setHeaderColor: "web_app_set_header_color",
1647
1624
  setBackgroundColor: "web_app_set_background_color"
1648
1625
  });
1649
- this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (h) => !(!p(h) || h === "switchInlineQuery" && !a), this.state = new b({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = St(i, {
1626
+ this.postEvent = t, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new b({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = Se(i, {
1650
1627
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1651
1628
  });
1652
1629
  }
@@ -1654,7 +1631,7 @@ class Te {
1654
1631
  * Attempts to get requested contact.
1655
1632
  */
1656
1633
  async getRequestedContact() {
1657
- return O(
1634
+ return H(
1658
1635
  "getRequestedContact",
1659
1636
  {},
1660
1637
  this.createRequestId(),
@@ -1662,7 +1639,7 @@ class Te {
1662
1639
  postEvent: this.postEvent,
1663
1640
  timeout: 1e4
1664
1641
  }
1665
- ).then((t) => $e.parse(t));
1642
+ ).then((e) => Vt.parse(e));
1666
1643
  }
1667
1644
  /**
1668
1645
  * The Mini App background color.
@@ -1692,7 +1669,7 @@ class Te {
1692
1669
  * True if current Mini App background color recognized as dark.
1693
1670
  */
1694
1671
  get isDark() {
1695
- return ft(this.backgroundColor);
1672
+ return we(this.backgroundColor);
1696
1673
  }
1697
1674
  /**
1698
1675
  * True if phone access is currently being requested.
@@ -1724,25 +1701,25 @@ class Te {
1724
1701
  * failed.
1725
1702
  * @param options - additional options.
1726
1703
  */
1727
- async requestContact({ timeout: t = 5e3 } = {}) {
1704
+ async requestContact({ timeout: e = 5e3 } = {}) {
1728
1705
  try {
1729
1706
  return await this.getRequestedContact();
1730
1707
  } catch {
1731
1708
  }
1732
1709
  if (await this.requestPhoneAccess() !== "sent")
1733
1710
  throw new Error("Access denied.");
1734
- const s = Date.now() + t;
1711
+ const s = Date.now() + e;
1735
1712
  let n = 50;
1736
- return xt(async () => {
1713
+ return xe(async () => {
1737
1714
  for (; Date.now() < s; ) {
1738
1715
  try {
1739
1716
  return await this.getRequestedContact();
1740
1717
  } catch {
1741
1718
  }
1742
- await ye(n), n += 50;
1719
+ await wt(n), n += 50;
1743
1720
  }
1744
1721
  throw new Error("Unable to retrieve requested contact.");
1745
- }, t);
1722
+ }, e);
1746
1723
  }
1747
1724
  /**
1748
1725
  * Requests current user phone access. Method returns promise, which resolves
@@ -1753,13 +1730,13 @@ class Te {
1753
1730
  * @param options - additional options.
1754
1731
  * @see requestContact
1755
1732
  */
1756
- requestPhoneAccess(t = {}) {
1733
+ requestPhoneAccess(e = {}) {
1757
1734
  if (this.requestingPhoneAccess)
1758
1735
  throw new Error("Phone access is already being requested.");
1759
1736
  return this.requestingPhoneAccess = !0, m("web_app_request_phone", "phone_requested", {
1760
- ...t,
1737
+ ...e,
1761
1738
  postEvent: this.postEvent
1762
- }).then((e) => e.status).finally(() => {
1739
+ }).then((t) => t.status).finally(() => {
1763
1740
  this.requestingPhoneAccess = !1;
1764
1741
  });
1765
1742
  }
@@ -1767,13 +1744,13 @@ class Te {
1767
1744
  * Requests write message access to current user.
1768
1745
  * @param options - additional options.
1769
1746
  */
1770
- requestWriteAccess(t = {}) {
1747
+ requestWriteAccess(e = {}) {
1771
1748
  if (this.requestingWriteAccess)
1772
1749
  throw new Error("Write access is already being requested.");
1773
1750
  return this.requestingWriteAccess = !0, m("web_app_request_write_access", "write_access_requested", {
1774
- ...t,
1751
+ ...e,
1775
1752
  postEvent: this.postEvent
1776
- }).then((e) => e.status).finally(() => {
1753
+ }).then((t) => t.status).finally(() => {
1777
1754
  this.requestingWriteAccess = !1;
1778
1755
  });
1779
1756
  }
@@ -1786,25 +1763,25 @@ class Te {
1786
1763
  * @param data - data to send to bot.
1787
1764
  * @throws {Error} data has incorrect size.
1788
1765
  */
1789
- sendData(t) {
1790
- const { size: e } = new Blob([t]);
1791
- if (e === 0 || e > 4096)
1792
- throw new Error(`Passed data has incorrect size: ${e}`);
1793
- this.postEvent("web_app_data_send", { data: t });
1766
+ sendData(e) {
1767
+ const { size: t } = new Blob([e]);
1768
+ if (t === 0 || t > 4096)
1769
+ throw new Error(`Passed data has incorrect size: ${t}`);
1770
+ this.postEvent("web_app_data_send", { data: e });
1794
1771
  }
1795
1772
  /**
1796
1773
  * Updates current Mini App header color.
1797
1774
  * @param color - color key or RGB color.
1798
1775
  */
1799
- setHeaderColor(t) {
1800
- this.postEvent("web_app_set_header_color", X(t) ? { color: t } : { color_key: t }), this.state.set("headerColor", t);
1776
+ setHeaderColor(e) {
1777
+ this.postEvent("web_app_set_header_color", X(e) ? { color: e } : { color_key: e }), this.state.set("headerColor", e);
1801
1778
  }
1802
1779
  /**
1803
1780
  * Updates current Mini App background color.
1804
1781
  * @param color - RGB color.
1805
1782
  */
1806
- setBackgroundColor(t) {
1807
- this.postEvent("web_app_set_background_color", { color: t }), this.state.set("backgroundColor", t);
1783
+ setBackgroundColor(e) {
1784
+ this.postEvent("web_app_set_background_color", { color: e }), this.state.set("backgroundColor", e);
1808
1785
  }
1809
1786
  /**
1810
1787
  * Inserts the bot's username and the specified inline query in the current chat's input field.
@@ -1816,38 +1793,38 @@ class Te {
1816
1793
  * @param chatTypes - List of chat types which could be chosen to send the message. Could be
1817
1794
  * empty list.
1818
1795
  */
1819
- switchInlineQuery(t, e = []) {
1796
+ switchInlineQuery(e, t = []) {
1820
1797
  if (!this.supports("switchInlineQuery") && !this.isBotInline)
1821
1798
  throw new Error("Method is unsupported because Mini App should be launched in inline mode.");
1822
1799
  this.postEvent("web_app_switch_inline_query", {
1823
- query: t,
1824
- chat_types: e
1800
+ query: e,
1801
+ chat_types: t
1825
1802
  });
1826
1803
  }
1827
1804
  }
1828
- function Be(r, t, e, s, n, i) {
1805
+ function It(r, e, t, s, n, i) {
1829
1806
  const {
1830
- backgroundColor: a = t,
1807
+ backgroundColor: a = e,
1831
1808
  headerColor: c = "bg_color"
1832
- } = r ? D("mini-app") || {} : {}, p = new Te({
1809
+ } = r ? D("mini-app") || {} : {}, u = new Rt({
1833
1810
  headerColor: c,
1834
1811
  backgroundColor: a,
1835
- version: e,
1812
+ version: t,
1836
1813
  botInline: s,
1837
1814
  createRequestId: n,
1838
1815
  postEvent: i
1839
- }), h = () => B("mini-app", {
1840
- backgroundColor: p.backgroundColor,
1841
- headerColor: p.headerColor
1816
+ }), p = () => B("mini-app", {
1817
+ backgroundColor: u.backgroundColor,
1818
+ headerColor: u.headerColor
1842
1819
  });
1843
- return p.on("change", h), p;
1820
+ return u.on("change", p), u;
1844
1821
  }
1845
- function De() {
1822
+ function Lt() {
1846
1823
  let r = 0;
1847
1824
  return () => (r += 1, r.toString());
1848
1825
  }
1849
- class We {
1850
- constructor(t, e, s = d) {
1826
+ class Tt {
1827
+ constructor(e, t, s = d) {
1851
1828
  o(this, "ee", new w());
1852
1829
  o(this, "state");
1853
1830
  /**
@@ -1855,24 +1832,24 @@ class We {
1855
1832
  * @param event - event name.
1856
1833
  * @param listener - event listener.
1857
1834
  */
1858
- o(this, "on", (t, e) => t === "click" ? y("settings_button_pressed", e) : this.ee.on(t, e));
1835
+ o(this, "on", (e, t) => e === "click" ? y("settings_button_pressed", t) : this.ee.on(e, t));
1859
1836
  /**
1860
1837
  * Removes event listener.
1861
1838
  * @param event - event name.
1862
1839
  * @param listener - event listener.
1863
1840
  */
1864
- o(this, "off", (t, e) => t === "click" ? T("settings_button_pressed", e) : this.ee.off(t, e));
1841
+ o(this, "off", (e, t) => e === "click" ? $("settings_button_pressed", t) : this.ee.off(e, t));
1865
1842
  /**
1866
1843
  * Checks if specified method is supported by current component.
1867
1844
  */
1868
1845
  o(this, "supports");
1869
- this.postEvent = s, this.state = new b({ isVisible: t }, this.ee), this.supports = E(e, {
1846
+ this.postEvent = s, this.state = new b({ isVisible: e }, this.ee), this.supports = E(t, {
1870
1847
  show: "web_app_setup_settings_button",
1871
1848
  hide: "web_app_setup_settings_button"
1872
1849
  });
1873
1850
  }
1874
- set isVisible(t) {
1875
- this.state.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
1851
+ set isVisible(e) {
1852
+ this.state.set("isVisible", e), this.postEvent("web_app_setup_settings_button", { is_visible: e });
1876
1853
  }
1877
1854
  /**
1878
1855
  * True if SettingsButton is currently visible.
@@ -1893,33 +1870,33 @@ class We {
1893
1870
  this.isVisible = !0;
1894
1871
  }
1895
1872
  }
1896
- function Ne(r, t, e) {
1897
- const { isVisible: s = !1 } = r ? D("settings-button") || {} : {}, n = new We(s, t, e);
1873
+ function $t(r, e, t) {
1874
+ const { isVisible: s = !1 } = r ? D("settings-button") || {} : {}, n = new Tt(s, e, t);
1898
1875
  return n.on("change", () => {
1899
1876
  B("settings-button", { isVisible: n.isVisible });
1900
1877
  }), n;
1901
1878
  }
1902
- function Oe(r) {
1903
- const t = new Mt(r);
1904
- return t.listen(), t;
1879
+ function Bt(r) {
1880
+ const e = new Ue(r);
1881
+ return e.listen(), e;
1905
1882
  }
1906
- function He(r) {
1883
+ function Dt(r) {
1907
1884
  return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
1908
1885
  }
1909
- async function At(r) {
1910
- const t = await m("web_app_request_viewport", "viewport_changed", r);
1886
+ async function Ae(r) {
1887
+ const e = await m("web_app_request_viewport", "viewport_changed", r);
1911
1888
  return {
1912
- height: t.height,
1913
- width: t.width,
1914
- isExpanded: t.is_expanded,
1915
- isStateStable: t.is_state_stable
1889
+ height: e.height,
1890
+ width: e.width,
1891
+ isExpanded: e.is_expanded,
1892
+ isStateStable: e.is_state_stable
1916
1893
  };
1917
1894
  }
1918
1895
  function W(r) {
1919
1896
  return r < 0 ? 0 : r;
1920
1897
  }
1921
- class Ue {
1922
- constructor(t) {
1898
+ class Wt {
1899
+ constructor(e) {
1923
1900
  o(this, "ee", new w());
1924
1901
  o(this, "state");
1925
1902
  o(this, "postEvent");
@@ -1932,14 +1909,14 @@ class Ue {
1932
1909
  */
1933
1910
  o(this, "off", this.ee.off.bind(this.ee));
1934
1911
  const {
1935
- height: e,
1912
+ height: t,
1936
1913
  isExpanded: s,
1937
1914
  width: n,
1938
1915
  stableHeight: i,
1939
1916
  postEvent: a = d
1940
- } = t;
1917
+ } = e;
1941
1918
  this.postEvent = a, this.state = new b({
1942
- height: W(e),
1919
+ height: W(t),
1943
1920
  isExpanded: s,
1944
1921
  stableHeight: W(i),
1945
1922
  width: W(n)
@@ -1950,13 +1927,13 @@ class Ue {
1950
1927
  * instance.
1951
1928
  * @param options - options to request fresh data.
1952
1929
  */
1953
- sync(t) {
1954
- return At(t).then(({ height: e, isExpanded: s, width: n, isStateStable: i }) => {
1930
+ sync(e) {
1931
+ return Ae(e).then(({ height: t, isExpanded: s, width: n, isStateStable: i }) => {
1955
1932
  this.state.set({
1956
- height: e,
1933
+ height: t,
1957
1934
  width: n,
1958
1935
  isExpanded: s,
1959
- stableHeight: i ? e : this.state.get("stableHeight")
1936
+ stableHeight: i ? t : this.state.get("stableHeight")
1960
1937
  });
1961
1938
  });
1962
1939
  }
@@ -2001,14 +1978,14 @@ class Ue {
2001
1978
  * @returns Function to stop listening.
2002
1979
  */
2003
1980
  listen() {
2004
- return y("viewport_changed", (t) => {
1981
+ return y("viewport_changed", (e) => {
2005
1982
  const {
2006
- height: e,
1983
+ height: t,
2007
1984
  width: s,
2008
1985
  is_expanded: n,
2009
1986
  is_state_stable: i
2010
- } = t, a = {
2011
- height: W(e),
1987
+ } = e, a = {
1988
+ height: W(t),
2012
1989
  isExpanded: n,
2013
1990
  width: W(s)
2014
1991
  };
@@ -2048,32 +2025,32 @@ class Ue {
2048
2025
  }
2049
2026
  }
2050
2027
  function G(r) {
2051
- const t = new Ue(r);
2052
- return t.on("change", () => B("viewport", {
2053
- height: t.height,
2054
- isExpanded: t.isExpanded,
2055
- stableHeight: t.stableHeight,
2056
- width: t.width
2057
- })), t.listen(), t;
2058
- }
2059
- function Me(r, t, e, s) {
2028
+ const e = new Wt(r);
2029
+ return e.on("change", () => B("viewport", {
2030
+ height: e.height,
2031
+ isExpanded: e.isExpanded,
2032
+ stableHeight: e.stableHeight,
2033
+ width: e.width
2034
+ })), e.listen(), e;
2035
+ }
2036
+ function Ot(r, e, t, s) {
2060
2037
  const n = r ? D("viewport") : null;
2061
2038
  if (n)
2062
- return G({ ...n, postEvent: e });
2063
- if (He(t))
2039
+ return G({ ...n, postEvent: t });
2040
+ if (Dt(e))
2064
2041
  return G({
2065
2042
  height: window.innerHeight,
2066
2043
  isExpanded: !0,
2067
- postEvent: e,
2044
+ postEvent: t,
2068
2045
  stableHeight: window.innerHeight,
2069
2046
  width: window.innerWidth
2070
2047
  });
2071
2048
  if (s)
2072
- return At({
2073
- postEvent: e,
2049
+ return Ae({
2050
+ postEvent: t,
2074
2051
  timeout: 5e3
2075
- }).then(({ height: a, isStateStable: c, ...p }) => G({
2076
- ...p,
2052
+ }).then(({ height: a, isStateStable: c, ...u }) => G({
2053
+ ...u,
2077
2054
  height: a,
2078
2055
  stableHeight: c ? a : 0
2079
2056
  }));
@@ -2081,35 +2058,35 @@ function Me(r, t, e, s) {
2081
2058
  width: 0,
2082
2059
  height: 0,
2083
2060
  isExpanded: !1,
2084
- postEvent: e,
2061
+ postEvent: t,
2085
2062
  stableHeight: 0
2086
2063
  });
2087
- return i.sync({ postEvent: e, timeout: 5e3 }).catch((a) => {
2064
+ return i.sync({ postEvent: t, timeout: 5e3 }).catch((a) => {
2088
2065
  console.error("Unable to actualize viewport state", a);
2089
2066
  }), i;
2090
2067
  }
2091
- function Ge(r) {
2068
+ function Ht(r) {
2092
2069
  return typeof r == "object" ? r : r ? {
2093
2070
  themeParams: !0,
2094
2071
  viewport: !0,
2095
2072
  miniApp: !0
2096
2073
  } : {};
2097
2074
  }
2098
- function ct(r, t, e, s) {
2099
- const n = Ge(r);
2100
- n.miniApp && Se(t, e), n.themeParams && xe(e), n.viewport && (s instanceof Promise ? s.then(at) : at(s));
2075
+ function ce(r, e, t, s) {
2076
+ const n = Ht(r);
2077
+ n.miniApp && Ct(e, t), n.themeParams && vt(t), n.viewport && (s instanceof Promise ? s.then(ae) : ae(s));
2101
2078
  }
2102
- function je(r) {
2103
- const { hostname: t, pathname: e } = new URL(r, window.location.href);
2104
- if (t !== "t.me")
2105
- throw new Error(`Incorrect hostname: ${t}`);
2106
- const s = e.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
2079
+ function Nt(r) {
2080
+ const { hostname: e, pathname: t } = new URL(r, window.location.href);
2081
+ if (e !== "t.me")
2082
+ throw new Error(`Incorrect hostname: ${e}`);
2083
+ const s = t.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
2107
2084
  if (s === null)
2108
2085
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
2109
2086
  return s[2];
2110
2087
  }
2111
- class Fe {
2112
- constructor(t, e = d) {
2088
+ class Ut {
2089
+ constructor(e, t = d) {
2113
2090
  o(this, "ee", new w());
2114
2091
  o(this, "state");
2115
2092
  /**
@@ -2124,10 +2101,10 @@ class Fe {
2124
2101
  * Checks if specified method is supported by current component.
2125
2102
  */
2126
2103
  o(this, "supports");
2127
- this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_invoice" });
2104
+ this.postEvent = t, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(e, { open: "web_app_open_invoice" });
2128
2105
  }
2129
- set isOpened(t) {
2130
- this.state.set("isOpened", t);
2106
+ set isOpened(e) {
2107
+ this.state.set("isOpened", e);
2131
2108
  }
2132
2109
  /**
2133
2110
  * True if invoice is currently opened.
@@ -2135,10 +2112,10 @@ class Fe {
2135
2112
  get isOpened() {
2136
2113
  return this.state.get("isOpened");
2137
2114
  }
2138
- async open(t, e) {
2115
+ async open(e, t) {
2139
2116
  if (this.isOpened)
2140
2117
  throw new Error("Invoice is already opened");
2141
- const s = e ? je(t) : t;
2118
+ const s = t ? Nt(e) : e;
2142
2119
  this.isOpened = !0;
2143
2120
  try {
2144
2121
  return (await m(
@@ -2157,13 +2134,13 @@ class Fe {
2157
2134
  }
2158
2135
  }
2159
2136
  }
2160
- function ze(r) {
2161
- const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
2137
+ function Mt(r) {
2138
+ const e = r.message.trim(), t = (r.title || "").trim(), s = r.buttons || [];
2162
2139
  let n;
2163
- if (e.length > 64)
2164
- throw new Error(`Title has incorrect size: ${e.length}`);
2165
- if (t.length === 0 || t.length > 256)
2166
- throw new Error(`Message has incorrect size: ${t.length}`);
2140
+ if (t.length > 64)
2141
+ throw new Error(`Title has incorrect size: ${t.length}`);
2142
+ if (e.length === 0 || e.length > 256)
2143
+ throw new Error(`Message has incorrect size: ${e.length}`);
2167
2144
  if (s.length > 3)
2168
2145
  throw new Error(`Buttons have incorrect size: ${s.length}`);
2169
2146
  return s.length === 0 ? n = [{ type: "close", id: "" }] : n = s.map((i) => {
@@ -2173,16 +2150,16 @@ function ze(r) {
2173
2150
  if (i.type === void 0 || i.type === "default" || i.type === "destructive") {
2174
2151
  const c = i.text.trim();
2175
2152
  if (c.length === 0 || c.length > 64) {
2176
- const p = i.type || "default";
2177
- throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
2153
+ const u = i.type || "default";
2154
+ throw new Error(`Button text with type "${u}" has incorrect size: ${i.text.length}`);
2178
2155
  }
2179
2156
  return { ...i, text: c, id: a };
2180
2157
  }
2181
2158
  return { ...i, id: a };
2182
- }), { title: e, message: t, buttons: n };
2159
+ }), { title: t, message: e, buttons: n };
2183
2160
  }
2184
- class Je {
2185
- constructor(t, e = d) {
2161
+ class Gt {
2162
+ constructor(e, t = d) {
2186
2163
  o(this, "ee", new w());
2187
2164
  o(this, "state");
2188
2165
  /**
@@ -2197,10 +2174,10 @@ class Je {
2197
2174
  * Checks if specified method is supported by current component.
2198
2175
  */
2199
2176
  o(this, "supports");
2200
- this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_popup" });
2177
+ this.postEvent = t, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(e, { open: "web_app_open_popup" });
2201
2178
  }
2202
- set isOpened(t) {
2203
- this.state.set("isOpened", t);
2179
+ set isOpened(e) {
2180
+ this.state.set("isOpened", e);
2204
2181
  }
2205
2182
  /**
2206
2183
  * True if popup is currently opened.
@@ -2221,21 +2198,21 @@ class Je {
2221
2198
  * @param options - popup parameters.
2222
2199
  * @throws {Error} Popup is already opened.
2223
2200
  */
2224
- open(t) {
2201
+ open(e) {
2225
2202
  if (this.isOpened)
2226
2203
  throw new Error("Popup is already opened.");
2227
2204
  return this.isOpened = !0, m(
2228
2205
  "web_app_open_popup",
2229
- ze(t),
2206
+ Mt(e),
2230
2207
  "popup_closed",
2231
2208
  { postEvent: this.postEvent }
2232
- ).then(({ button_id: e = null }) => e).finally(() => {
2209
+ ).then(({ button_id: t = null }) => t).finally(() => {
2233
2210
  this.isOpened = !1;
2234
2211
  });
2235
2212
  }
2236
2213
  }
2237
- class Qe {
2238
- constructor(t, e = d) {
2214
+ class jt {
2215
+ constructor(e, t = d) {
2239
2216
  o(this, "ee", new w());
2240
2217
  o(this, "state");
2241
2218
  /**
@@ -2250,7 +2227,7 @@ class Qe {
2250
2227
  * Checks if specified method is supported by current component.
2251
2228
  */
2252
2229
  o(this, "supports");
2253
- this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, {
2230
+ this.postEvent = t, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(e, {
2254
2231
  close: "web_app_close_scan_qr_popup",
2255
2232
  open: "web_app_open_scan_qr_popup"
2256
2233
  });
@@ -2261,8 +2238,8 @@ class Qe {
2261
2238
  close() {
2262
2239
  this.postEvent("web_app_close_scan_qr_popup"), this.isOpened = !1;
2263
2240
  }
2264
- set isOpened(t) {
2265
- this.state.set("isOpened", t);
2241
+ set isOpened(e) {
2242
+ this.state.set("isOpened", e);
2266
2243
  }
2267
2244
  /**
2268
2245
  * Returns true in case, QR scanner is currently opened.
@@ -2276,25 +2253,25 @@ class Qe {
2276
2253
  * case, scanner was closed.
2277
2254
  * @param text - title to display.
2278
2255
  */
2279
- async open(t) {
2256
+ async open(e) {
2280
2257
  if (this.isOpened)
2281
2258
  throw new Error("QR scanner is already opened.");
2282
2259
  this.isOpened = !0;
2283
2260
  try {
2284
- const e = await m(
2261
+ const t = await m(
2285
2262
  "web_app_open_scan_qr_popup",
2286
- { text: t },
2263
+ { text: e },
2287
2264
  ["qr_text_received", "scan_qr_popup_closed"],
2288
2265
  { postEvent: this.postEvent }
2289
2266
  );
2290
- return typeof e == "object" && typeof e.data == "string" ? e.data : null;
2267
+ return typeof t == "object" && typeof t.data == "string" ? t.data : null;
2291
2268
  } finally {
2292
2269
  this.isOpened = !1;
2293
2270
  }
2294
2271
  }
2295
2272
  }
2296
- class Ze {
2297
- constructor(t, e, s = d) {
2273
+ class Ft {
2274
+ constructor(e, t, s = d) {
2298
2275
  /**
2299
2276
  * Checks if specified method is supported by current component.
2300
2277
  */
@@ -2303,9 +2280,9 @@ class Ze {
2303
2280
  * Checks if specified method parameter is supported by current component.
2304
2281
  */
2305
2282
  o(this, "supportsParam");
2306
- this.version = t, this.createRequestId = e, this.postEvent = s, this.supports = E(t, {
2283
+ this.version = e, this.createRequestId = t, this.postEvent = s, this.supports = E(e, {
2307
2284
  readTextFromClipboard: "web_app_read_text_from_clipboard"
2308
- }), this.supportsParam = St(t, {
2285
+ }), this.supportsParam = Se(e, {
2309
2286
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2310
2287
  });
2311
2288
  }
@@ -2318,15 +2295,15 @@ class Ze {
2318
2295
  * @param url - URL to be opened.
2319
2296
  * @param tryInstantView
2320
2297
  */
2321
- openLink(t, e) {
2322
- const s = new URL(t, window.location.href).toString();
2298
+ openLink(e, t) {
2299
+ const s = new URL(e, window.location.href).toString();
2323
2300
  if (!I("web_app_open_link", this.version)) {
2324
2301
  window.open(s, "_blank");
2325
2302
  return;
2326
2303
  }
2327
2304
  this.postEvent("web_app_open_link", {
2328
2305
  url: s,
2329
- ...typeof e == "boolean" ? { try_instant_view: e } : {}
2306
+ ...typeof t == "boolean" ? { try_instant_view: t } : {}
2330
2307
  });
2331
2308
  }
2332
2309
  /**
@@ -2335,16 +2312,16 @@ class Ze {
2335
2312
  * @param url - URL to be opened.
2336
2313
  * @throws {Error} URL has not allowed hostname.
2337
2314
  */
2338
- openTelegramLink(t) {
2315
+ openTelegramLink(e) {
2339
2316
  const {
2340
- hostname: e,
2317
+ hostname: t,
2341
2318
  pathname: s,
2342
2319
  search: n
2343
- } = new URL(t, window.location.href);
2344
- if (e !== "t.me")
2345
- throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
2320
+ } = new URL(e, window.location.href);
2321
+ if (t !== "t.me")
2322
+ throw new Error(`URL has not allowed hostname: ${t}. Only "t.me" is allowed`);
2346
2323
  if (!I("web_app_open_tg_link", this.version)) {
2347
- window.location.href = t;
2324
+ window.location.href = e;
2348
2325
  return;
2349
2326
  }
2350
2327
  this.postEvent("web_app_open_tg_link", { path_full: s + n });
@@ -2361,147 +2338,144 @@ class Ze {
2361
2338
  { req_id: this.createRequestId() },
2362
2339
  "clipboard_text_received",
2363
2340
  { postEvent: this.postEvent }
2364
- ).then(({ data: t = null }) => t);
2341
+ ).then(({ data: e = null }) => e);
2365
2342
  }
2366
2343
  }
2367
- function ur(r = {}) {
2344
+ function or(r = {}) {
2368
2345
  const {
2369
- async: t = !1,
2370
- complete: e = t,
2346
+ async: e = !1,
2347
+ complete: t = e,
2371
2348
  cssVars: s = !1,
2372
2349
  acceptCustomStyles: n = !1
2373
2350
  } = r;
2374
2351
  try {
2375
2352
  const {
2376
- launchParams: {
2377
- initData: i,
2378
- initDataRaw: a,
2379
- version: c,
2380
- platform: p,
2381
- themeParams: h,
2382
- botInline: g = !1
2383
- },
2384
- isPageReload: _
2385
- } = Ct(), A = De(), l = me(c);
2386
- vt() && (n && Ae(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
2353
+ initData: i,
2354
+ initDataRaw: a,
2355
+ version: c,
2356
+ platform: u,
2357
+ themeParams: p,
2358
+ botInline: g = !1
2359
+ } = te(), _ = le(), V = Lt(), l = gt(c);
2360
+ pe() && (n && kt(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
2387
2361
  const C = {
2388
- backButton: Ve(_, c, l),
2389
- closingBehavior: Re(_, l),
2390
- cloudStorage: new ke(c, A, l),
2391
- createRequestId: A,
2392
- hapticFeedback: new qe(c, l),
2393
- invoice: new Fe(c, l),
2394
- mainButton: Le(
2362
+ backButton: St(_, c, l),
2363
+ closingBehavior: xt(_, l),
2364
+ cloudStorage: new Et(c, V, l),
2365
+ createRequestId: V,
2366
+ hapticFeedback: new Pt(c, l),
2367
+ invoice: new Ut(c, l),
2368
+ mainButton: At(
2395
2369
  _,
2396
- h.buttonColor || "#000000",
2397
- h.buttonTextColor || "#ffffff",
2370
+ p.buttonColor || "#000000",
2371
+ p.buttonTextColor || "#ffffff",
2398
2372
  l
2399
2373
  ),
2400
- miniApp: Be(
2374
+ miniApp: It(
2401
2375
  _,
2402
- h.backgroundColor || "#ffffff",
2376
+ p.backgroundColor || "#ffffff",
2403
2377
  c,
2404
2378
  g,
2405
- A,
2379
+ V,
2406
2380
  l
2407
2381
  ),
2408
- popup: new Je(c, l),
2382
+ popup: new Gt(c, l),
2409
2383
  postEvent: l,
2410
- qrScanner: new Qe(c, l),
2411
- settingsButton: Ne(_, c, l),
2412
- themeParams: Oe(h),
2413
- utils: new Ze(c, A, l),
2384
+ qrScanner: new jt(c, l),
2385
+ settingsButton: $t(_, c, l),
2386
+ themeParams: Bt(p),
2387
+ utils: new Ft(c, V, l),
2414
2388
  ...i ? {
2415
- initData: new Nt(i),
2389
+ initData: new We(i),
2416
2390
  initDataRaw: a
2417
2391
  } : {}
2418
- }, x = Me(_, p, l, e);
2419
- return x instanceof Promise || e ? Promise.resolve(x).then((v) => (ct(
2392
+ }, x = Ot(_, u, l, t);
2393
+ return x instanceof Promise || t ? Promise.resolve(x).then((v) => (ce(
2420
2394
  s,
2421
2395
  C.miniApp,
2422
2396
  C.themeParams,
2423
2397
  v
2424
- ), { ...C, viewport: v })) : (ct(
2398
+ ), { ...C, viewport: v })) : (ce(
2425
2399
  s,
2426
2400
  C.miniApp,
2427
2401
  C.themeParams,
2428
2402
  x
2429
2403
  ), { ...C, viewport: x });
2430
2404
  } catch (i) {
2431
- if (e)
2405
+ if (t)
2432
2406
  return Promise.reject(i);
2433
2407
  throw i;
2434
2408
  }
2435
2409
  }
2436
- function N(r, t) {
2437
- return r.startsWith(t) ? r : `${t}${r}`;
2410
+ function O(r, e) {
2411
+ return r.startsWith(e) ? r : `${e}${r}`;
2438
2412
  }
2439
- function hr(r) {
2440
- const t = r.match(/#(.+)/);
2441
- return t ? t[1] : null;
2413
+ function ar(r) {
2414
+ const e = r.match(/#(.+)/);
2415
+ return e ? e[1] : null;
2442
2416
  }
2443
- async function H(r) {
2417
+ async function N(r) {
2444
2418
  return r === 0 ? !0 : Promise.race([
2445
- new Promise((t) => {
2446
- window.addEventListener("popstate", function e() {
2447
- window.removeEventListener("popstate", e), t(!0);
2419
+ new Promise((e) => {
2420
+ window.addEventListener("popstate", function t() {
2421
+ window.removeEventListener("popstate", t), e(!0);
2448
2422
  }), window.history.go(r);
2449
2423
  }),
2450
2424
  // Usually, it takes about 1ms to emit this event, but we use some buffer.
2451
- new Promise((t) => {
2452
- setTimeout(t, 50, !1);
2425
+ new Promise((e) => {
2426
+ setTimeout(e, 50, !1);
2453
2427
  })
2454
2428
  ]);
2455
2429
  }
2456
- async function Ke() {
2457
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await H(1 - window.history.length)))
2430
+ async function zt() {
2431
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
2458
2432
  return;
2459
- let t = await H(-1);
2460
- for (; t; )
2461
- t = await H(-1);
2433
+ let e = await N(-1);
2434
+ for (; e; )
2435
+ e = await N(-1);
2462
2436
  }
2463
- class Ye {
2464
- constructor(t, e, {
2437
+ class Jt {
2438
+ constructor(e, t, {
2465
2439
  debug: s = !1,
2466
2440
  loggerPrefix: n = "Navigator"
2467
2441
  }) {
2468
2442
  o(this, "logger");
2469
2443
  o(this, "entries");
2470
- if (this.entriesCursor = e, t.length === 0)
2444
+ if (this.entriesCursor = t, e.length === 0)
2471
2445
  throw new Error("Entries list should not be empty.");
2472
- if (e >= t.length)
2446
+ if (t >= e.length)
2473
2447
  throw new Error("Cursor should be less than entries count.");
2474
- this.entries = t.map(({ pathname: i = "", search: a, hash: c }) => {
2448
+ this.entries = e.map(({ pathname: i = "", search: a, hash: c }) => {
2475
2449
  if (!i.startsWith("/") && i.length > 0)
2476
2450
  throw new Error('Pathname should start with "/"');
2477
2451
  return {
2478
- pathname: N(i, "/"),
2479
- search: a ? N(a, "?") : "",
2480
- hash: c ? N(c, "#") : ""
2452
+ pathname: O(i, "/"),
2453
+ search: a ? O(a, "?") : "",
2454
+ hash: c ? O(c, "#") : ""
2481
2455
  };
2482
- }), this.logger = new Pt(`[${n}]`, s);
2456
+ }), this.logger = new ve(`[${n}]`, s);
2483
2457
  }
2484
2458
  /**
2485
2459
  * Converts entry to the navigation entry.
2486
2460
  * @param entry - entry data
2487
2461
  */
2488
- formatEntry(t) {
2489
- let e;
2490
- if (typeof t == "string")
2491
- e = t;
2462
+ formatEntry(e) {
2463
+ let t;
2464
+ if (typeof e == "string")
2465
+ t = e;
2492
2466
  else {
2493
2467
  const {
2494
2468
  pathname: a = "",
2495
2469
  search: c,
2496
- hash: p
2497
- } = t;
2498
- e = a + (c ? N(c, "?") : "") + (p ? N(p, "#") : "");
2470
+ hash: u
2471
+ } = e;
2472
+ t = a + (c ? O(c, "?") : "") + (u ? O(u, "#") : "");
2499
2473
  }
2500
2474
  const {
2501
2475
  pathname: s,
2502
2476
  search: n,
2503
2477
  hash: i
2504
- } = new URL(e, `https://localhost${this.path}`);
2478
+ } = new URL(t, `https://localhost${this.path}`);
2505
2479
  return {
2506
2480
  pathname: s,
2507
2481
  search: n,
@@ -2548,23 +2522,23 @@ class Ye {
2548
2522
  * Moves entries cursor by specified delta.
2549
2523
  * @param delta - cursor delta.
2550
2524
  */
2551
- go(t) {
2552
- this.logger.log(`called go(${t})`);
2553
- const e = Math.min(
2525
+ go(e) {
2526
+ this.logger.log(`called go(${e})`);
2527
+ const t = Math.min(
2554
2528
  this.entries.length - 1,
2555
- Math.max(this.entriesCursor + t, 0)
2529
+ Math.max(this.entriesCursor + e, 0)
2556
2530
  );
2557
- if (this.entriesCursor === e)
2531
+ if (this.entriesCursor === t)
2558
2532
  return this.performGo({
2559
2533
  updated: !1,
2560
- delta: t
2534
+ delta: e
2561
2535
  });
2562
2536
  const s = this.entry;
2563
- this.entriesCursor = e;
2537
+ this.entriesCursor = t;
2564
2538
  const n = this.entry;
2565
2539
  return this.logger.log("State changed", { before: s, after: n }), this.performGo({
2566
2540
  updated: !0,
2567
- delta: t,
2541
+ delta: e,
2568
2542
  before: s,
2569
2543
  after: n
2570
2544
  });
@@ -2573,7 +2547,7 @@ class Ye {
2573
2547
  * Returns copy of navigator entries.
2574
2548
  */
2575
2549
  getEntries() {
2576
- return this.entries.map((t) => ({ ...t }));
2550
+ return this.entries.map((e) => ({ ...e }));
2577
2551
  }
2578
2552
  /**
2579
2553
  * Current hash.
@@ -2604,10 +2578,10 @@ class Ye {
2604
2578
  * push("#my-hash"); // "/home" -> "/home#my-hash"
2605
2579
  * push("johny#my-hash"); // "/home/root" -> "/home/johny#my-hash"
2606
2580
  */
2607
- push(t) {
2581
+ push(e) {
2608
2582
  this.entriesCursor !== this.entries.length - 1 && this.entries.splice(this.entriesCursor + 1);
2609
- const e = this.formatEntry(t), s = this.entry;
2610
- this.entriesCursor += 1, this.entries[this.entriesCursor] = e;
2583
+ const t = this.formatEntry(e), s = this.entry;
2584
+ this.entriesCursor += 1, this.entries[this.entriesCursor] = t;
2611
2585
  const n = this.entry;
2612
2586
  return this.logger.log("State changed", { before: s, after: n }), this.performPush({
2613
2587
  before: s,
@@ -2634,15 +2608,15 @@ class Ye {
2634
2608
  * @see push
2635
2609
  * @returns True if changes were done.
2636
2610
  */
2637
- replace(t) {
2638
- const e = this.formatEntry(t);
2639
- if (this.search === e.search && this.pathname === e.pathname && this.hash === e.hash)
2611
+ replace(e) {
2612
+ const t = this.formatEntry(e);
2613
+ if (this.search === t.search && this.pathname === t.pathname && this.hash === t.hash)
2640
2614
  return this.performReplace({
2641
2615
  updated: !1,
2642
- entry: e
2616
+ entry: t
2643
2617
  });
2644
2618
  const s = this.entry;
2645
- this.entries[this.entriesCursor] = e;
2619
+ this.entries[this.entriesCursor] = t;
2646
2620
  const n = this.entry;
2647
2621
  return this.logger.log("State changed", { before: s, after: n }), this.performReplace({
2648
2622
  updated: !0,
@@ -2659,10 +2633,10 @@ class Ye {
2659
2633
  return this.entry.search;
2660
2634
  }
2661
2635
  }
2662
- const ut = 0, Z = 1, K = 2;
2663
- class Vt extends Ye {
2664
- constructor(e, s, n = {}) {
2665
- super(e, s, {
2636
+ const he = 0, Z = 1, K = 2;
2637
+ class Ve extends Jt {
2638
+ constructor(t, s, n = {}) {
2639
+ super(t, s, {
2666
2640
  ...n,
2667
2641
  loggerPrefix: "HashNavigator"
2668
2642
  });
@@ -2672,16 +2646,16 @@ class Vt extends Ye {
2672
2646
  * Handles window "popstate" event.
2673
2647
  * @param state - event state.
2674
2648
  */
2675
- o(this, "onPopState", async ({ state: e }) => {
2676
- if (this.logger.log('"popstate" event received. State:', e), e === null)
2649
+ o(this, "onPopState", async ({ state: t }) => {
2650
+ if (this.logger.log('"popstate" event received. State:', t), t === null)
2677
2651
  return this.push(window.location.hash.slice(1));
2678
- if (e === ut) {
2652
+ if (t === he) {
2679
2653
  this.logger.log("Void reached. Moving history forward"), window.history.forward();
2680
2654
  return;
2681
2655
  }
2682
- if (e === Z)
2656
+ if (t === Z)
2683
2657
  return this.back();
2684
- if (e === K)
2658
+ if (t === K)
2685
2659
  return this.forward();
2686
2660
  });
2687
2661
  o(this, "back", () => super.back());
@@ -2698,7 +2672,7 @@ class Vt extends Ye {
2698
2672
  * Creates navigator from current window location hash.
2699
2673
  * @param options - options passed to constructor.
2700
2674
  */
2701
- static fromLocation(e) {
2675
+ static fromLocation(t) {
2702
2676
  const {
2703
2677
  search: s,
2704
2678
  pathname: n,
@@ -2707,29 +2681,29 @@ class Vt extends Ye {
2707
2681
  window.location.hash.slice(1),
2708
2682
  window.location.href
2709
2683
  );
2710
- return new Vt([{ search: s, pathname: n, hash: i }], 0, e);
2684
+ return new Ve([{ search: s, pathname: n, hash: i }], 0, t);
2711
2685
  }
2712
- async performGo(e) {
2713
- e.updated && (this.attached && await this.syncHistory(), this.emitChanged(e.before, e.after));
2686
+ async performGo(t) {
2687
+ t.updated && (this.attached && await this.syncHistory(), this.emitChanged(t.before, t.after));
2714
2688
  }
2715
- async performPush({ before: e, after: s }) {
2716
- this.attached && await this.syncHistory(), this.emitChanged(e, s);
2689
+ async performPush({ before: t, after: s }) {
2690
+ this.attached && await this.syncHistory(), this.emitChanged(t, s);
2717
2691
  }
2718
- async performReplace(e) {
2719
- e.updated && (this.attached && window.history.replaceState(null, "", `#${this.path}`), this.emitChanged(e.before, e.after));
2692
+ async performReplace(t) {
2693
+ t.updated && (this.attached && window.history.replaceState(null, "", `#${this.path}`), this.emitChanged(t.before, t.after));
2720
2694
  }
2721
2695
  /**
2722
2696
  * Synchronizes current navigator state with browser history.
2723
2697
  */
2724
2698
  async syncHistory() {
2725
2699
  window.removeEventListener("popstate", this.onPopState);
2726
- const e = `#${this.path}`;
2727
- await Ke(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e), window.history.pushState(K, ""), await H(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(K, ""), await H(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ut, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2700
+ const t = `#${this.path}`;
2701
+ await zt(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", t), window.history.pushState(K, ""), await N(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", t)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, t), window.history.pushState(K, ""), await N(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(he, ""), window.history.pushState(null, "", t)), window.addEventListener("popstate", this.onPopState);
2728
2702
  }
2729
- emitChanged(e, s) {
2703
+ emitChanged(t, s) {
2730
2704
  this.ee.emit("change", {
2731
2705
  navigator: this,
2732
- from: e,
2706
+ from: t,
2733
2707
  to: s
2734
2708
  });
2735
2709
  }
@@ -2744,83 +2718,84 @@ class Vt extends Ye {
2744
2718
  * Detaches current navigator from the browser history.
2745
2719
  */
2746
2720
  detach() {
2747
- this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), T("back_button_pressed", this.back));
2721
+ this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), $("back_button_pressed", this.back));
2748
2722
  }
2749
2723
  }
2750
2724
  export {
2751
- Ce as BackButton,
2752
- Pe as ClosingBehavior,
2753
- ke as CloudStorage,
2754
- qe as HapticFeedback,
2755
- Vt as HashNavigator,
2756
- Nt as InitData,
2757
- Fe as Invoice,
2758
- Ie as MainButton,
2759
- et as MethodUnsupportedError,
2760
- Te as MiniApp,
2761
- Ye as Navigator,
2762
- rt as ParameterUnsupportedError,
2725
+ bt as BackButton,
2726
+ yt as ClosingBehavior,
2727
+ Et as CloudStorage,
2728
+ Pt as HapticFeedback,
2729
+ Ve as HashNavigator,
2730
+ We as InitData,
2731
+ Ut as Invoice,
2732
+ qt as MainButton,
2733
+ re as MethodUnsupportedError,
2734
+ Rt as MiniApp,
2735
+ Jt as Navigator,
2736
+ se as ParameterUnsupportedError,
2763
2737
  F as ParseError,
2764
2738
  j as ParseSchemaFieldError,
2765
- Je as Popup,
2766
- Qe as QRScanner,
2767
- We as SettingsButton,
2768
- Mt as ThemeParams,
2739
+ Gt as Popup,
2740
+ jt as QRScanner,
2741
+ Tt as SettingsButton,
2742
+ Ue as ThemeParams,
2769
2743
  J as TimeoutError,
2770
- Ze as Utils,
2771
- Ue as Viewport,
2772
- Bt as array,
2773
- Se as bindMiniAppCSSVars,
2774
- xe as bindThemeCSSVars,
2775
- at as bindViewportCSSVars,
2744
+ Ft as Utils,
2745
+ Wt as Viewport,
2746
+ $e as array,
2747
+ Ct as bindMiniAppCSSVars,
2748
+ vt as bindThemeCSSVars,
2749
+ ae as bindViewportCSSVars,
2776
2750
  k as boolean,
2777
- Wt as chatParser,
2778
- ve as classNames,
2779
- be as compareVersions,
2780
- me as createPostEvent,
2781
- lt as date,
2782
- hr as getHash,
2783
- ur as init,
2784
- wt as initDataParser,
2785
- O as invokeCustomMethod,
2786
- ft as isColorDark,
2787
- vt as isIframe,
2751
+ De as chatParser,
2752
+ mt as classNames,
2753
+ ft as compareVersions,
2754
+ gt as createPostEvent,
2755
+ fe as date,
2756
+ ar as getHash,
2757
+ or as init,
2758
+ be as initDataParser,
2759
+ H as invokeCustomMethod,
2760
+ we as isColorDark,
2761
+ pe as isIframe,
2762
+ le as isPageReload,
2788
2763
  X as isRGB,
2789
- Dt as isRGBShort,
2764
+ Be as isRGBShort,
2790
2765
  R as isRecord,
2791
- He as isStableViewportPlatform,
2792
- rr as isTMA,
2793
- ar as isTimeoutError,
2766
+ Dt as isStableViewportPlatform,
2767
+ tr as isTMA,
2768
+ nr as isTimeoutError,
2794
2769
  f as json,
2795
- mt as launchParamsParser,
2796
- cr as mergeClassNames,
2797
- q as number,
2798
- T as off,
2770
+ Me as launchParamsParser,
2771
+ ir as mergeClassNames,
2772
+ A as number,
2773
+ $ as off,
2799
2774
  y as on,
2800
- ir as once,
2801
- tr as parseInitData,
2802
- Gt as parseLaunchParams,
2803
- se as parseMessage,
2804
- bt as parseThemeParams,
2775
+ rr as once,
2776
+ Zt as parseInitData,
2777
+ Ee as parseLaunchParams,
2778
+ Xe as parseMessage,
2779
+ ye as parseThemeParams,
2805
2780
  d as postEvent,
2806
2781
  m as request,
2807
- er as requestThemeParams,
2808
- At as requestViewport,
2809
- Ct as retrieveLaunchData,
2810
- gt as rgb,
2811
- tt as searchParams,
2812
- Jt as serializeLaunchParams,
2813
- Ut as serializeThemeParams,
2782
+ Kt as requestThemeParams,
2783
+ Ae as requestViewport,
2784
+ er as retrieveLaunchData,
2785
+ te as retrieveLaunchParams,
2786
+ _e as rgb,
2787
+ ee as searchParams,
2788
+ ze as serializeLaunchParams,
2789
+ Ne as serializeThemeParams,
2814
2790
  S as setCSSVar,
2815
- sr as setDebug,
2816
- nr as setTargetOrigin,
2817
- u as string,
2818
- or as subscribe,
2791
+ Yt as setDebug,
2792
+ Xt as setTargetOrigin,
2793
+ h as string,
2794
+ sr as subscribe,
2819
2795
  I as supports,
2820
- _t as themeParamsParser,
2821
- dt as toRGB,
2822
- _e as unsubscribe,
2823
- st as userParser,
2824
- xt as withTimeout
2796
+ me as themeParamsParser,
2797
+ ge as toRGB,
2798
+ dt as unsubscribe,
2799
+ ne as userParser,
2800
+ xe as withTimeout
2825
2801
  };
2826
- //# sourceMappingURL=index.mjs.map