native-fn 1.0.26 → 1.0.28

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 (161) hide show
  1. package/README.md +22 -192
  2. package/dist/index.d.ts +18 -27
  3. package/dist/native.cjs +27 -1400
  4. package/dist/native.min.cjs +1 -0
  5. package/dist/native.min.mjs +1 -0
  6. package/dist/native.mjs +27 -1400
  7. package/dist/native.umd.js +27 -1400
  8. package/dist/native.umd.min.js +1 -0
  9. package/dist/plugin/app/index.cjs +1025 -0
  10. package/dist/plugin/app/index.d.ts +86 -0
  11. package/dist/plugin/app/index.min.cjs +1 -0
  12. package/dist/plugin/app/index.min.mjs +1 -0
  13. package/dist/plugin/app/index.mjs +1023 -0
  14. package/dist/plugin/app/index.umd.js +1031 -0
  15. package/dist/plugin/app/index.umd.min.js +1 -0
  16. package/dist/plugin/app/src/constants/platform.d.ts +35 -0
  17. package/dist/plugin/app/src/constants/user-agent.d.ts +1 -0
  18. package/dist/plugin/app/src/plugin/app/cores/app.d.ts +3 -0
  19. package/dist/plugin/app/src/plugin/app/index.d.ts +5 -0
  20. package/dist/plugin/app/src/plugin/app/types/app.d.ts +54 -0
  21. package/dist/plugin/app/src/plugin/app/types/appModule.d.ts +54 -0
  22. package/dist/plugin/app/src/plugin/app/types/index.d.ts +1 -0
  23. package/dist/plugin/app/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  24. package/dist/plugin/app/src/plugin/platform/cores/platform.d.ts +3 -0
  25. package/dist/plugin/app/src/plugin/platform/index.d.ts +5 -0
  26. package/dist/plugin/app/src/plugin/platform/types/index.d.ts +1 -0
  27. package/dist/{src → plugin/app/src/plugin/platform}/types/platform.d.ts +1 -1
  28. package/dist/plugin/app/src/plugin/platform/types/platformModule.d.ts +13 -0
  29. package/dist/{src → plugin/app/src/plugin/theme}/constants/theme.d.ts +1 -1
  30. package/dist/plugin/app/src/plugin/theme/cores/theme.d.ts +3 -0
  31. package/dist/plugin/app/src/plugin/theme/index.d.ts +5 -0
  32. package/dist/plugin/app/src/plugin/theme/types/color.d.ts +17 -0
  33. package/dist/{src → plugin/app/src/plugin/theme}/types/easing-syntax.d.ts +1 -1
  34. package/dist/plugin/app/src/plugin/theme/types/index.d.ts +3 -0
  35. package/dist/{src → plugin/app/src/plugin/theme}/types/theme.d.ts +4 -4
  36. package/dist/plugin/app/src/plugin/theme/types/themeModule.d.ts +24 -0
  37. package/dist/{src → plugin/app/src/plugin/theme}/utils/parse-color.d.ts +1 -1
  38. package/dist/{src → plugin/app/src/plugin/theme}/utils/parse-easing-function.d.ts +1 -1
  39. package/dist/plugin/app/src/types/index.d.ts +1 -0
  40. package/dist/plugin/app/src/types/native.d.ts +14 -0
  41. package/dist/plugin/app/src/utils/assign.d.ts +1 -0
  42. package/dist/plugin/app/src/utils/create-custom-error.d.ts +1 -0
  43. package/dist/plugin/platform/index.cjs +171 -0
  44. package/dist/plugin/platform/index.d.ts +51 -0
  45. package/dist/plugin/platform/index.min.cjs +1 -0
  46. package/dist/plugin/platform/index.min.mjs +1 -0
  47. package/dist/plugin/platform/index.mjs +169 -0
  48. package/dist/plugin/platform/index.umd.js +177 -0
  49. package/dist/plugin/platform/index.umd.min.js +1 -0
  50. package/dist/plugin/platform/src/constants/platform.d.ts +35 -0
  51. package/dist/plugin/platform/src/constants/user-agent.d.ts +1 -0
  52. package/dist/plugin/platform/src/plugin/app/constants/app.d.ts +13 -0
  53. package/dist/plugin/platform/src/plugin/app/cores/app.d.ts +3 -0
  54. package/dist/plugin/platform/src/plugin/app/errors/url-open-error.d.ts +2 -0
  55. package/dist/plugin/platform/src/plugin/app/index.d.ts +5 -0
  56. package/dist/plugin/platform/src/plugin/app/types/app.d.ts +54 -0
  57. package/dist/plugin/platform/src/plugin/app/types/appModule.d.ts +54 -0
  58. package/dist/plugin/platform/src/plugin/app/types/index.d.ts +1 -0
  59. package/dist/plugin/platform/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  60. package/dist/plugin/platform/src/plugin/app/utils/try-open-url.d.ts +1 -0
  61. package/dist/plugin/platform/src/plugin/platform/cores/platform.d.ts +3 -0
  62. package/dist/plugin/platform/src/plugin/platform/index.d.ts +5 -0
  63. package/dist/plugin/platform/src/plugin/platform/types/index.d.ts +1 -0
  64. package/dist/plugin/platform/src/plugin/platform/types/platform.d.ts +13 -0
  65. package/dist/plugin/platform/src/plugin/platform/types/platformModule.d.ts +13 -0
  66. package/dist/plugin/platform/src/plugin/theme/constants/theme.d.ts +16 -0
  67. package/dist/plugin/platform/src/plugin/theme/cores/theme.d.ts +3 -0
  68. package/dist/plugin/platform/src/plugin/theme/errors/easing-error.d.ts +6 -0
  69. package/dist/plugin/platform/src/plugin/theme/errors/unsupported-color-error.d.ts +2 -0
  70. package/dist/plugin/platform/src/plugin/theme/index.d.ts +5 -0
  71. package/dist/plugin/platform/src/plugin/theme/types/color.d.ts +17 -0
  72. package/dist/plugin/platform/src/plugin/theme/types/easing-syntax.d.ts +16 -0
  73. package/dist/plugin/platform/src/plugin/theme/types/index.d.ts +3 -0
  74. package/dist/plugin/platform/src/plugin/theme/types/theme.d.ts +24 -0
  75. package/dist/plugin/platform/src/plugin/theme/types/themeModule.d.ts +24 -0
  76. package/dist/plugin/platform/src/plugin/theme/utils/parse-color.d.ts +2 -0
  77. package/dist/plugin/platform/src/plugin/theme/utils/parse-easing-function.d.ts +2 -0
  78. package/dist/plugin/platform/src/types/index.d.ts +1 -0
  79. package/dist/plugin/platform/src/types/native.d.ts +14 -0
  80. package/dist/plugin/platform/src/utils/assign.d.ts +1 -0
  81. package/dist/plugin/platform/src/utils/create-custom-error.d.ts +1 -0
  82. package/dist/plugin/theme/index.cjs +810 -0
  83. package/dist/plugin/theme/index.d.ts +75 -0
  84. package/dist/plugin/theme/index.min.cjs +1 -0
  85. package/dist/plugin/theme/index.min.mjs +1 -0
  86. package/dist/plugin/theme/index.mjs +808 -0
  87. package/dist/plugin/theme/index.umd.js +816 -0
  88. package/dist/plugin/theme/index.umd.min.js +1 -0
  89. package/dist/plugin/theme/src/constants/platform.d.ts +35 -0
  90. package/dist/plugin/theme/src/constants/user-agent.d.ts +1 -0
  91. package/dist/plugin/theme/src/plugin/app/constants/app.d.ts +13 -0
  92. package/dist/plugin/theme/src/plugin/app/cores/app.d.ts +3 -0
  93. package/dist/plugin/theme/src/plugin/app/errors/url-open-error.d.ts +2 -0
  94. package/dist/plugin/theme/src/plugin/app/index.d.ts +5 -0
  95. package/dist/plugin/theme/src/plugin/app/types/app.d.ts +54 -0
  96. package/dist/plugin/theme/src/plugin/app/types/appModule.d.ts +54 -0
  97. package/dist/plugin/theme/src/plugin/app/types/index.d.ts +1 -0
  98. package/dist/plugin/theme/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  99. package/dist/plugin/theme/src/plugin/app/utils/try-open-url.d.ts +1 -0
  100. package/dist/plugin/theme/src/plugin/platform/cores/platform.d.ts +3 -0
  101. package/dist/plugin/theme/src/plugin/platform/index.d.ts +5 -0
  102. package/dist/plugin/theme/src/plugin/platform/types/index.d.ts +1 -0
  103. package/dist/plugin/theme/src/plugin/platform/types/platform.d.ts +13 -0
  104. package/dist/plugin/theme/src/plugin/platform/types/platformModule.d.ts +13 -0
  105. package/dist/plugin/theme/src/plugin/theme/constants/theme.d.ts +16 -0
  106. package/dist/plugin/theme/src/plugin/theme/cores/theme.d.ts +3 -0
  107. package/dist/plugin/theme/src/plugin/theme/errors/easing-error.d.ts +6 -0
  108. package/dist/plugin/theme/src/plugin/theme/errors/unsupported-color-error.d.ts +2 -0
  109. package/dist/plugin/theme/src/plugin/theme/index.d.ts +5 -0
  110. package/dist/plugin/theme/src/plugin/theme/types/color.d.ts +17 -0
  111. package/dist/plugin/theme/src/plugin/theme/types/easing-syntax.d.ts +16 -0
  112. package/dist/plugin/theme/src/plugin/theme/types/index.d.ts +3 -0
  113. package/dist/plugin/theme/src/plugin/theme/types/theme.d.ts +24 -0
  114. package/dist/plugin/theme/src/plugin/theme/types/themeModule.d.ts +24 -0
  115. package/dist/plugin/theme/src/plugin/theme/utils/parse-color.d.ts +2 -0
  116. package/dist/plugin/theme/src/plugin/theme/utils/parse-easing-function.d.ts +2 -0
  117. package/dist/plugin/theme/src/types/index.d.ts +1 -0
  118. package/dist/plugin/theme/src/types/native.d.ts +14 -0
  119. package/dist/plugin/theme/src/utils/assign.d.ts +1 -0
  120. package/dist/plugin/theme/src/utils/create-custom-error.d.ts +1 -0
  121. package/dist/src/plugin/app/constants/app.d.ts +13 -0
  122. package/dist/src/plugin/app/cores/app.d.ts +3 -0
  123. package/dist/src/plugin/app/errors/url-open-error.d.ts +2 -0
  124. package/dist/src/plugin/app/index.d.ts +5 -0
  125. package/dist/src/plugin/app/types/app.d.ts +54 -0
  126. package/dist/src/plugin/app/types/appModule.d.ts +54 -0
  127. package/dist/src/plugin/app/types/index.d.ts +1 -0
  128. package/dist/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  129. package/dist/src/plugin/app/utils/try-open-url.d.ts +1 -0
  130. package/dist/src/plugin/platform/cores/platform.d.ts +3 -0
  131. package/dist/src/plugin/platform/index.d.ts +5 -0
  132. package/dist/src/plugin/platform/types/index.d.ts +1 -0
  133. package/dist/src/plugin/platform/types/platform.d.ts +13 -0
  134. package/dist/src/plugin/platform/types/platformModule.d.ts +13 -0
  135. package/dist/src/plugin/theme/constants/theme.d.ts +16 -0
  136. package/dist/src/plugin/theme/cores/theme.d.ts +3 -0
  137. package/dist/src/plugin/theme/errors/easing-error.d.ts +6 -0
  138. package/dist/src/plugin/theme/errors/unsupported-color-error.d.ts +2 -0
  139. package/dist/src/plugin/theme/index.d.ts +5 -0
  140. package/dist/src/plugin/theme/types/color.d.ts +17 -0
  141. package/dist/src/plugin/theme/types/easing-syntax.d.ts +16 -0
  142. package/dist/src/plugin/theme/types/index.d.ts +3 -0
  143. package/dist/src/plugin/theme/types/theme.d.ts +24 -0
  144. package/dist/src/plugin/theme/types/themeModule.d.ts +24 -0
  145. package/dist/src/plugin/theme/utils/parse-color.d.ts +2 -0
  146. package/dist/src/plugin/theme/utils/parse-easing-function.d.ts +2 -0
  147. package/dist/src/types/index.d.ts +1 -5
  148. package/dist/src/types/native.d.ts +14 -0
  149. package/dist/src/utils/assign.d.ts +1 -0
  150. package/package.json +8 -5
  151. package/dist/src/cores/app.d.ts +0 -3
  152. package/dist/src/cores/platform.d.ts +0 -3
  153. package/dist/src/cores/theme.d.ts +0 -3
  154. package/dist/src/types/app.d.ts +0 -44
  155. package/dist/src/types/color.d.ts +0 -17
  156. package/dist/src/utils/freeze-deep.d.ts +0 -1
  157. /package/dist/{src → plugin/app/src/plugin/app}/constants/app.d.ts +0 -0
  158. /package/dist/{src → plugin/app/src/plugin/app}/errors/url-open-error.d.ts +0 -0
  159. /package/dist/{src → plugin/app/src/plugin/app}/utils/try-open-url.d.ts +0 -0
  160. /package/dist/{src → plugin/app/src/plugin/theme}/errors/easing-error.d.ts +0 -0
  161. /package/dist/{src → plugin/app/src/plugin/theme}/errors/unsupported-color-error.d.ts +0 -0
@@ -0,0 +1,1025 @@
1
+ 'use strict';
2
+
3
+ var USER_AGENT = navigator.userAgent;
4
+
5
+ var AppOpenState;
6
+ (function (AppOpenState) {
7
+ AppOpenState[AppOpenState["Scheme"] = 0] = "Scheme";
8
+ AppOpenState[AppOpenState["Universal"] = 1] = "Universal";
9
+ AppOpenState[AppOpenState["Intent"] = 2] = "Intent";
10
+ AppOpenState[AppOpenState["Fallback"] = 3] = "Fallback";
11
+ AppOpenState[AppOpenState["Store"] = 4] = "Store";
12
+ })(AppOpenState || (AppOpenState = {}));
13
+ var Messengers;
14
+ (function (Messengers) {
15
+ Messengers["Telephone"] = "telephone";
16
+ Messengers["Message"] = "message";
17
+ Messengers["Mail"] = "mail";
18
+ })(Messengers || (Messengers = {}));
19
+ var IS_SUPPORT_INTENT = !/firefox|opr/i.test(USER_AGENT);
20
+
21
+ var OS;
22
+ (function (OS) {
23
+ OS["Unknown"] = "Unknown";
24
+ OS["Android"] = "Android";
25
+ OS["iOS"] = "iOS";
26
+ OS["Windows"] = "Windows";
27
+ OS["MacOS"] = "MacOS";
28
+ })(OS || (OS = {}));
29
+ var Devices;
30
+ (function (Devices) {
31
+ Devices["Unknown"] = "Unknown";
32
+ Devices["Mobile"] = "Mobile";
33
+ Devices["Desktop"] = "Desktop";
34
+ })(Devices || (Devices = {}));
35
+ var Engines;
36
+ (function (Engines) {
37
+ Engines["Unknown"] = "Unknown";
38
+ Engines["EdgeHTML"] = "EdgeHTML";
39
+ Engines["ArkWeb"] = "ArkWeb";
40
+ Engines["Blink"] = "Blink";
41
+ Engines["Presto"] = "Presto";
42
+ Engines["WebKit"] = "WebKit";
43
+ Engines["Trident"] = "Trident";
44
+ Engines["NetFront"] = "NetFront";
45
+ Engines["KHTML"] = "KHTML";
46
+ Engines["Tasman"] = "Tasman";
47
+ Engines["Gecko"] = "Gecko";
48
+ })(Engines || (Engines = {}));
49
+ var OS_RESOLVER_MAP = (function () {
50
+ function resolveIOSOrMacVersion(str) {
51
+ if (str === undefined)
52
+ return '';
53
+ return str.replace(/_/g, '.');
54
+ }
55
+ function resolveWindowsVersion(str) {
56
+ if (str === undefined)
57
+ return '';
58
+ var mapped = {
59
+ '4.90': 'ME',
60
+ 'NT3.51': 'NT 3.11',
61
+ 'NT4.0': 'NT 4.0',
62
+ 'NT 5.0': '2000',
63
+ 'NT 5.1': 'XP',
64
+ 'NT 5.2': 'XP',
65
+ 'NT 6.0': 'Vista',
66
+ 'NT 6.1': '7',
67
+ 'NT 6.2': '8',
68
+ 'NT 6.3': '8.1',
69
+ 'NT 6.4': '10',
70
+ 'NT 10.0': '10',
71
+ 'ARM': 'RT'
72
+ }[str];
73
+ if (mapped !== undefined)
74
+ return mapped;
75
+ return str;
76
+ }
77
+ function resolveVersion(str) {
78
+ if (str === undefined)
79
+ return '';
80
+ return str;
81
+ }
82
+ return [
83
+ [/android\w*[-\/.; ]?([\d.]*)/i, OS.Android, Devices.Mobile, resolveVersion],
84
+ [/microsoft windows (vista|xp)/i, OS.Windows, Devices.Desktop, resolveVersion],
85
+ [/windows (?:phone(?: os)?|mobile|iot)[\/ ]?([.\w ]*)/i, OS.Windows, Devices.Desktop, resolveWindowsVersion],
86
+ [/windows nt 6\.2; (arm)/i, OS.Windows, Devices.Desktop, resolveWindowsVersion],
87
+ [/windows[\/ ]([ntce\d. ]+\w)(?!.+xbox)/i, OS.Windows, Devices.Desktop, resolveWindowsVersion],
88
+ [/(?:win(?=[39n])|win 9x )([nt\d.]+)/i, OS.Windows, Devices.Desktop, resolveWindowsVersion],
89
+ [/[adehimnop]{4,7}\b(?:.*os (\w+) like mac|; opera)/i, OS.iOS, Devices.Mobile, resolveIOSOrMacVersion],
90
+ [/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d.]+)/i, OS.iOS, Devices.Mobile, resolveIOSOrMacVersion],
91
+ [/cfnetwork\/.+darwin/i, OS.iOS, Devices.Mobile, resolveVersion],
92
+ [/mac os x ?([\w. ]*)/i, OS.MacOS, Devices.Desktop, resolveIOSOrMacVersion],
93
+ [/(?:macintosh|mac_powerpc\b)(?!.+haiku)/i, OS.MacOS, Devices.Desktop, resolveIOSOrMacVersion],
94
+ ];
95
+ })();
96
+ var ENGINE_RESOLVER_MAP = [
97
+ [/windows.+ edge\/([\w.]+)/i, Engines.EdgeHTML],
98
+ [/arkweb\/([\w.]+)/i, Engines.ArkWeb],
99
+ [/webkit\/537\.36.+chrome\/(?!27)([\w.]+)/i, Engines.Blink],
100
+ [/presto\/([\w.]+)/i, Engines.Presto],
101
+ [/webkit\/([\w.]+)/i, Engines.WebKit],
102
+ [/trident\/([\w.]+)/i, Engines.Trident],
103
+ [/netfront\/([\w.]+)/i, Engines.NetFront],
104
+ [/khtml[\/ ]\(?([\w.]+)/i, Engines.KHTML],
105
+ [/tasman[\/ ]\(?([\w.]+)/i, Engines.Tasman],
106
+ [/rv:([\w.]{1,9})\b.+gecko/i, Engines.Gecko]
107
+ ];
108
+ var OS_NAME = OS.Unknown;
109
+ var OS_VERSION = '';
110
+ var DEVICE_NAME = Devices.Unknown;
111
+ Engines.Unknown;
112
+ for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
113
+ var map = OS_RESOLVER_MAP[i];
114
+ var regexp = map[0];
115
+ var os = map[1];
116
+ var device = map[2];
117
+ var resolver = map[3];
118
+ var matched = USER_AGENT.match(regexp);
119
+ if (matched !== null) {
120
+ OS_NAME = os;
121
+ OS_VERSION = resolver(matched[1]);
122
+ DEVICE_NAME = device;
123
+ break;
124
+ }
125
+ }
126
+ for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
127
+ var map = ENGINE_RESOLVER_MAP[i];
128
+ var regexp = map[0];
129
+ map[1];
130
+ var matched = USER_AGENT.match(regexp);
131
+ if (matched !== null) {
132
+ matched[1];
133
+ break;
134
+ }
135
+ }
136
+ ((function () {
137
+ var canvas = document.createElement('canvas');
138
+ if (typeof canvas.getContext !== 'function')
139
+ return '';
140
+ var context = canvas.getContext('webgl2') || canvas.getContext('experimental-webgl') || canvas.getContext('webgl');
141
+ if (context === null)
142
+ return '';
143
+ if (context instanceof WebGLRenderingContext || 'getParameter' in context && typeof context.getParameter === 'function') {
144
+ var extension = context.getExtension('WEBGL_debug_renderer_info');
145
+ if (extension === null)
146
+ return context.getParameter(context.RENDERER);
147
+ else
148
+ return context.getParameter(extension.UNMASKED_RENDERER_WEBGL);
149
+ }
150
+ else {
151
+ return '';
152
+ }
153
+ }))();
154
+ DEVICE_NAME === Devices.Mobile;
155
+ DEVICE_NAME === Devices.Desktop;
156
+ ((function () {
157
+ if (OS_NAME === OS.iOS)
158
+ return 'standalone' in navigator && navigator.standalone;
159
+ else
160
+ return window.matchMedia('(display-mode: standalone)').matches;
161
+ }))();
162
+
163
+ function capitalize(match) {
164
+ var groups = [];
165
+ for (var _i = 1; _i < arguments.length; _i++) {
166
+ groups[_i - 1] = arguments[_i];
167
+ }
168
+ var result = '';
169
+ for (var i = 0; i < groups.length - 2; i++) {
170
+ var arg = groups[i];
171
+ if (arg !== undefined)
172
+ result = result + arg.charAt(0).toUpperCase() + arg.slice(1);
173
+ }
174
+ return result;
175
+ }
176
+ function preventDefaultPolyfill() {
177
+ this.returnValue = false;
178
+ }
179
+ function stopPropagationPolyfill() {
180
+ this.cancelBubble = true;
181
+ }
182
+ var EventListenerUtils = {
183
+ useStd: typeof document !== 'undefined' && typeof document.addEventListener === 'function',
184
+ add: function (target, eventListenerOptions) {
185
+ if (eventListenerOptions === void 0) { eventListenerOptions = { callback: null, options: false }; }
186
+ var callback = eventListenerOptions.callback;
187
+ if (target === undefined || callback === null)
188
+ return;
189
+ var type = this.withVender(target, eventListenerOptions.type);
190
+ var options = eventListenerOptions.options;
191
+ if (typeof target.addEventListener === 'function') {
192
+ try {
193
+ return target.addEventListener(type, callback, options);
194
+ }
195
+ catch (_) {
196
+ }
197
+ }
198
+ if (typeof target.addListener === 'function') {
199
+ if (typeof target.matches === 'boolean') {
200
+ try {
201
+ return target.addListener(callback);
202
+ }
203
+ catch (_) {
204
+ }
205
+ }
206
+ else {
207
+ try {
208
+ return target.addListener(type, callback);
209
+ }
210
+ catch (_) {
211
+ }
212
+ }
213
+ }
214
+ function wrapper(event) {
215
+ if (event === undefined)
216
+ event = window.event;
217
+ if (event === undefined)
218
+ return;
219
+ event.currentTarget = target;
220
+ if (typeof event.preventDefault !== 'function')
221
+ event.preventDefault = preventDefaultPolyfill;
222
+ if (typeof event.stopPropagation !== 'function')
223
+ event.stopPropagation = stopPropagationPolyfill;
224
+ if (typeof callback === 'function')
225
+ callback.call(target, event);
226
+ else if (callback && typeof callback.handleEvent === 'function')
227
+ callback.handleEvent.call(target, event);
228
+ }
229
+ if (typeof target.attachEvent === 'function') {
230
+ if (callback.__ieWrapper)
231
+ return target.attachEvent('on' + type, callback.__ieWrapper);
232
+ return target.attachEvent('on' + type, callback.__ieWrapper = wrapper);
233
+ }
234
+ },
235
+ remove: function (target, eventListenerOptions) {
236
+ if (eventListenerOptions === void 0) { eventListenerOptions = { callback: null, options: false }; }
237
+ var callback = eventListenerOptions.callback;
238
+ if (target === undefined || callback === null)
239
+ return;
240
+ var type = this.withVender(target, eventListenerOptions.type);
241
+ var options = eventListenerOptions.options;
242
+ if (typeof target.removeEventListener === 'function') {
243
+ try {
244
+ return target.removeEventListener(type, callback, options);
245
+ }
246
+ catch (_) {
247
+ }
248
+ }
249
+ if (typeof target.removeListener === 'function') {
250
+ if (typeof target.matches === 'boolean') {
251
+ try {
252
+ return target.removeListener(callback);
253
+ }
254
+ catch (_) {
255
+ }
256
+ }
257
+ else {
258
+ try {
259
+ return target.removeListener(type, callback);
260
+ }
261
+ catch (_) {
262
+ }
263
+ }
264
+ }
265
+ if (typeof target.detachEvent === 'function') {
266
+ var wrapper = callback.__ieWrapper;
267
+ if (wrapper !== undefined) {
268
+ target.detachEvent('on' + type, wrapper);
269
+ delete callback.__ieWrapper;
270
+ }
271
+ return;
272
+ }
273
+ },
274
+ withVender: function (target, type) {
275
+ if (type === undefined)
276
+ return '';
277
+ var regex = /(animation)(start|iteration|end|cancel)|(transition)(start|run|end|cancel)|(fullscreen)(change|error)|(lost|got)(pointer)(capture)|(pointer)(lock)(change|error)|(pointer)(cancel|down|enter|leave|move|out|over|up)/i;
278
+ var vendors = ['', 'webkit', 'moz', 'ms', 'MS', 'o', 'O'];
279
+ var types;
280
+ if (type === 'wheel')
281
+ types = ['wheel', 'mousewheel', 'DOMMouseScroll'];
282
+ else if (type === 'focus')
283
+ types = ['focus', 'focusin'];
284
+ else if (type === 'blur')
285
+ types = ['blur', 'focusout'];
286
+ else if (regex.test(type))
287
+ types = [type, type.replace(regex, capitalize)];
288
+ else
289
+ types = [type];
290
+ for (var i = 0; i < vendors.length; i++) {
291
+ for (var j = 0; j < types.length; j++) {
292
+ var name_1 = vendors[i] + types[j];
293
+ if (typeof target['on' + name_1] !== 'undefined')
294
+ return name_1;
295
+ }
296
+ }
297
+ return '';
298
+ }
299
+ };
300
+
301
+ function getTopmostWindow() {
302
+ try {
303
+ if (window.top && window.top !== window) {
304
+ void window.top.location.href;
305
+ return window.top;
306
+ }
307
+ }
308
+ catch (_) {
309
+ }
310
+ return window;
311
+ }
312
+ function openURLViaHref(url, index) {
313
+ var top = getTopmostWindow();
314
+ var a = undefined;
315
+ try {
316
+ if (index === 0) {
317
+ top.location.href = url;
318
+ return;
319
+ }
320
+ a = top.document.createElement('a');
321
+ a.href = url;
322
+ a.setAttribute('aria-hidden', 'true');
323
+ a.style.display = 'none';
324
+ top.document.body.appendChild(a);
325
+ var fake = void 0;
326
+ try {
327
+ fake = new MouseEvent('click', {
328
+ bubbles: true,
329
+ cancelable: true,
330
+ view: top
331
+ });
332
+ }
333
+ catch (_) {
334
+ fake = top.document.createEvent('MouseEvents');
335
+ fake.initMouseEvent('click', true, true, top, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
336
+ }
337
+ a.dispatchEvent(fake);
338
+ }
339
+ catch (_) {
340
+ }
341
+ finally {
342
+ if (a !== undefined) {
343
+ try {
344
+ top.document.body.removeChild(a);
345
+ }
346
+ catch (_) {
347
+ }
348
+ }
349
+ }
350
+ }
351
+ function openURLViaIframe(url) {
352
+ var top = getTopmostWindow();
353
+ var iframe = undefined;
354
+ try {
355
+ iframe = document.createElement('iframe');
356
+ iframe.src = url;
357
+ iframe.width = iframe.height = iframe.frameBorder = '0';
358
+ iframe.setAttribute('aria-hidden', 'true');
359
+ iframe.style.display = 'none';
360
+ iframe.style.position = 'absolute';
361
+ iframe.style.top = '-9999px';
362
+ iframe.style.left = '-9999px';
363
+ top.document.body.appendChild(iframe);
364
+ window.setTimeout(function () {
365
+ if (iframe !== undefined) {
366
+ try {
367
+ top.document.body.removeChild(iframe);
368
+ }
369
+ catch (_) {
370
+ }
371
+ }
372
+ }, 500);
373
+ }
374
+ catch (_) {
375
+ }
376
+ }
377
+ function isDocumentHidden() {
378
+ var document = getTopmostWindow().document;
379
+ if (document.visibilityState === 'hidden')
380
+ return true;
381
+ if (document.webkitVisibilityState === 'hidden')
382
+ return true;
383
+ if (document.mozVisibilityState === 'hidden')
384
+ return true;
385
+ if (document.msVisibilityState === 'hidden')
386
+ return true;
387
+ if (document.hidden !== undefined)
388
+ return document.hidden;
389
+ if (document.webkitHidden !== undefined)
390
+ return document.webkitHidden;
391
+ if (document.mozHidden !== undefined)
392
+ return document.mozHidden;
393
+ if (document.msHidden !== undefined)
394
+ return document.msHidden;
395
+ if (typeof document.hasFocus === 'function')
396
+ return !document.hasFocus();
397
+ return true;
398
+ }
399
+ function hasFocus(document) {
400
+ if (typeof document.hasFocus === 'function')
401
+ return document.hasFocus();
402
+ return false;
403
+ }
404
+ function focus(target) {
405
+ try {
406
+ target.focus({ preventScroll: true });
407
+ }
408
+ catch (_) {
409
+ try {
410
+ target.focus();
411
+ }
412
+ catch (_) {
413
+ }
414
+ }
415
+ }
416
+ function restoreFocus() {
417
+ var top = getTopmostWindow();
418
+ var document = top.document;
419
+ focus(top);
420
+ if (hasFocus(document))
421
+ return true;
422
+ if (document.body.tabIndex < 0) {
423
+ document.body.tabIndex = -1;
424
+ }
425
+ focus(document.body);
426
+ if (hasFocus(document))
427
+ return true;
428
+ var input = undefined;
429
+ try {
430
+ input = document.createElement('input');
431
+ input.type = 'text';
432
+ input.readOnly = true;
433
+ input.tabIndex = -1;
434
+ input.setAttribute('aria-hidden', 'true');
435
+ input.style.position = 'fixed';
436
+ input.style.width = input.style.height = '1px';
437
+ input.style.top = input.style.left = '0';
438
+ input.style.opacity = '0';
439
+ input.style.zIndex = '-1';
440
+ document.body.appendChild(input);
441
+ focus(input);
442
+ try {
443
+ input.select();
444
+ }
445
+ catch (_) {
446
+ }
447
+ if (hasFocus(document))
448
+ return true;
449
+ }
450
+ catch (_) {
451
+ }
452
+ finally {
453
+ if (input !== undefined) {
454
+ try {
455
+ input.blur();
456
+ }
457
+ catch (_) {
458
+ }
459
+ try {
460
+ document.body.removeChild(input);
461
+ }
462
+ catch (_) {
463
+ }
464
+ }
465
+ }
466
+ return hasFocus(document);
467
+ }
468
+ function tryOpenUrl(url, index, timeout) {
469
+ var top = getTopmostWindow();
470
+ var document = top.document;
471
+ var eventType = { focus: undefined, blur: undefined, visibilitychange: undefined };
472
+ var eventTarget = { focus: undefined, blur: undefined, visibilitychange: undefined };
473
+ if (OS_NAME === OS.iOS) {
474
+ if (parseInt(OS_VERSION) >= 8) {
475
+ eventTarget = { visibilitychange: document };
476
+ eventType = { visibilitychange: 'visibilitychange' };
477
+ }
478
+ else {
479
+ eventTarget = { focus: top, blur: top };
480
+ eventType = { focus: 'pageshow', blur: 'pagehide' };
481
+ }
482
+ }
483
+ else {
484
+ if (EventListenerUtils.useStd) {
485
+ eventTarget = { focus: top, blur: top, visibilitychange: document };
486
+ eventType = { focus: 'focus', blur: 'blur', visibilitychange: 'visibilitychange' };
487
+ }
488
+ else {
489
+ eventTarget = { focus: document, blur: document, visibilitychange: document };
490
+ eventType = { focus: 'focus', blur: 'blur', visibilitychange: 'visibilitychange' };
491
+ }
492
+ }
493
+ return new Promise(function (resolve, reject) {
494
+ var timeoutId;
495
+ var resolved = false;
496
+ function cleanup() {
497
+ if (timeoutId !== undefined) {
498
+ clearTimeout(timeoutId);
499
+ timeoutId = undefined;
500
+ }
501
+ try {
502
+ EventListenerUtils.remove(eventTarget.blur, { type: eventType.blur, callback: onBlur });
503
+ EventListenerUtils.remove(eventTarget.focus, { type: eventType.focus, callback: onFocus });
504
+ EventListenerUtils.remove(eventTarget.visibilitychange, { type: eventType.visibilitychange, callback: onVisibilityChange });
505
+ }
506
+ catch (_) {
507
+ }
508
+ }
509
+ function done(success) {
510
+ if (resolved)
511
+ return;
512
+ resolved = true;
513
+ try {
514
+ cleanup();
515
+ if (success)
516
+ resolve();
517
+ else
518
+ reject();
519
+ }
520
+ catch (_) {
521
+ resolve();
522
+ }
523
+ }
524
+ function onBlur() {
525
+ if (timeoutId !== undefined) {
526
+ clearTimeout(timeoutId);
527
+ timeoutId = undefined;
528
+ }
529
+ EventListenerUtils.remove(eventTarget.blur, { type: eventType.blur, callback: onBlur });
530
+ EventListenerUtils.add(eventTarget.focus, { type: eventType.focus, callback: onFocus });
531
+ }
532
+ function onFocus() {
533
+ done(true);
534
+ }
535
+ function onVisibilityChange() {
536
+ if (isDocumentHidden())
537
+ done(true);
538
+ }
539
+ timeoutId = window.setTimeout(function () {
540
+ done(false);
541
+ }, timeout);
542
+ EventListenerUtils.add(eventTarget.blur, { type: eventType.blur, callback: onBlur });
543
+ EventListenerUtils.add(eventTarget.visibilitychange, { type: eventType.visibilitychange, callback: onVisibilityChange });
544
+ if (!hasFocus(document))
545
+ restoreFocus();
546
+ try {
547
+ openURLViaHref(url, index);
548
+ openURLViaIframe(url);
549
+ }
550
+ catch (_) {
551
+ done(false);
552
+ }
553
+ });
554
+ }
555
+
556
+ function createCustomError(name, Base) {
557
+ if (Base === void 0) { Base = Error; }
558
+ function CustomError(message) {
559
+ if (!(this instanceof CustomError))
560
+ return new CustomError(message);
561
+ var error = new Base(message || '');
562
+ if (typeof Object.setPrototypeOf === 'function')
563
+ Object.setPrototypeOf(error, CustomError.prototype);
564
+ else
565
+ error.__proto__ = CustomError.prototype;
566
+ error.name = name;
567
+ if (message !== undefined)
568
+ error.message = message;
569
+ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
570
+ try {
571
+ Object.defineProperty(error, Symbol.toStringTag, {
572
+ value: name,
573
+ writable: false,
574
+ enumerable: false,
575
+ configurable: true
576
+ });
577
+ }
578
+ catch (_) {
579
+ }
580
+ }
581
+ if (typeof Error.captureStackTrace === 'function') {
582
+ Error.captureStackTrace(error, CustomError);
583
+ }
584
+ else if (Base.captureStackTrace && typeof Base.captureStackTrace === 'function') {
585
+ Base.captureStackTrace(error, CustomError);
586
+ }
587
+ else {
588
+ try {
589
+ var tempError = new Base();
590
+ if (tempError.stack)
591
+ error.stack = tempError.stack;
592
+ }
593
+ catch (_) {
594
+ }
595
+ }
596
+ return error;
597
+ }
598
+ CustomError.prototype = Object.create(Base.prototype, {
599
+ constructor: {
600
+ value: CustomError,
601
+ writable: true,
602
+ enumerable: false,
603
+ configurable: true
604
+ }
605
+ });
606
+ try {
607
+ Object.defineProperty(CustomError.prototype, 'name', {
608
+ value: name,
609
+ writable: true,
610
+ enumerable: false,
611
+ configurable: true
612
+ });
613
+ }
614
+ catch (_) {
615
+ try {
616
+ CustomError.prototype.name = name;
617
+ }
618
+ catch (_) {
619
+ }
620
+ }
621
+ try {
622
+ Object.defineProperty(CustomError, 'name', {
623
+ value: name,
624
+ writable: false,
625
+ enumerable: false,
626
+ configurable: true
627
+ });
628
+ }
629
+ catch (_) {
630
+ }
631
+ return CustomError;
632
+ }
633
+
634
+ var URLOpenError = createCustomError('URLOpenError');
635
+
636
+ var _a;
637
+ var App = {
638
+ open: open,
639
+ messenger: (_a = {},
640
+ _a[Messengers.Telephone] = openMessengerTelephone,
641
+ _a[Messengers.Message] = openMessengerMessage,
642
+ _a[Messengers.Mail] = openMessengerMail,
643
+ _a),
644
+ };
645
+ function getTrackId(bundle) {
646
+ try {
647
+ var xhr = new XMLHttpRequest();
648
+ xhr.open('GET', 'https://itunes.apple.com/lookup?bundleId=' + bundle, false);
649
+ xhr.send();
650
+ if (xhr.status === 200) {
651
+ try {
652
+ var response = JSON.parse(xhr.response);
653
+ if (response.results === undefined)
654
+ return undefined;
655
+ var results = response.results;
656
+ if (!Array.isArray(results) || results.length === 0)
657
+ return undefined;
658
+ var result = results[0];
659
+ if (result === undefined)
660
+ return undefined;
661
+ return result.trackId;
662
+ }
663
+ catch (_) {
664
+ return undefined;
665
+ }
666
+ }
667
+ return undefined;
668
+ }
669
+ catch (_) {
670
+ return undefined;
671
+ }
672
+ }
673
+ function createIntentURL(scheme, packageName, fallback) {
674
+ var split = scheme.split('://');
675
+ var prefix = split[0];
676
+ var suffix = split[1];
677
+ var intent = 'intent://';
678
+ if (suffix !== undefined)
679
+ intent = intent + suffix;
680
+ intent = intent + '#Intent;'
681
+ + 'scheme=' + prefix + ';'
682
+ + 'action=android.intent.action.VIEW;'
683
+ + 'category=android.intent.category.BROWSABLE;';
684
+ if (packageName !== undefined)
685
+ intent = intent + 'package=' + packageName + ';';
686
+ if (fallback !== undefined && typeof fallback === 'string')
687
+ intent = intent + 'S.browser_fallback_url=' + fallback + ';';
688
+ else if (packageName !== undefined)
689
+ intent = intent + 'S.browser_fallback_url=' + createAppStoreURL(packageName, OS.Android) + ';';
690
+ return intent + 'end';
691
+ }
692
+ function parseIntentURL(intent) {
693
+ var parsed = {};
694
+ var split = intent.split('#Intent;');
695
+ var host = split[0].substring(9);
696
+ var suffix = split[1];
697
+ var parameterString = suffix.substring(0, suffix.length - 4);
698
+ var parameters = parameterString.split(';');
699
+ var extras = {};
700
+ for (var i = 0; i < parameters.length; i++) {
701
+ var part = parameters[i];
702
+ var index = part.indexOf('=');
703
+ if (index !== -1)
704
+ extras[part.substring(0, index)] = part.substring(index + 1);
705
+ }
706
+ if (extras['scheme'] !== undefined)
707
+ parsed.scheme = (extras['scheme'] + '://' + host);
708
+ if (extras['package'] !== undefined)
709
+ parsed.packageName = extras['package'];
710
+ if (extras['S.browser_fallback_url'] !== undefined)
711
+ parsed.fallback = extras['S.browser_fallback_url'];
712
+ return parsed;
713
+ }
714
+ function createAppStoreURL(packageName, os) {
715
+ switch (os) {
716
+ case OS.Android: return 'market://details?id=' + packageName;
717
+ case OS.iOS: return 'itms-apps://itunes.apple.com/app/id' + packageName + '?mt=8';
718
+ case OS.Windows: return 'ms-windows-store://pdp/?ProductId=' + packageName;
719
+ case OS.MacOS: return 'macappstore://itunes.apple.com/app/id' + packageName + '?mt=12';
720
+ default: throw new URLOpenError('Unsupported OS: \"' + USER_AGENT + '\"');
721
+ }
722
+ }
723
+ function createWebStoreURL(packageName, os) {
724
+ switch (os) {
725
+ case OS.Android: return 'https://play.google.com/store/apps/details?id=' + packageName;
726
+ case OS.iOS: return 'https://itunes.apple.com/app/id' + packageName + '?mt=8';
727
+ case OS.Windows: return 'https://apps.microsoft.com/detail/' + packageName;
728
+ case OS.MacOS: return 'https://apps.apple.com/app/id' + packageName + '?mt=12';
729
+ default: throw new URLOpenError('Unsupported OS: \"' + USER_AGENT + '\"');
730
+ }
731
+ }
732
+ function getDefaultTimeoutByOS(os) {
733
+ switch (os) {
734
+ case OS.iOS: return 2000;
735
+ case OS.Android: return 1000;
736
+ default: return 750;
737
+ }
738
+ }
739
+ function open(options) {
740
+ var os = OS_NAME;
741
+ var urls = [];
742
+ var tried = [];
743
+ var timeout;
744
+ function getURLOpenError() {
745
+ var triedUrlString = '';
746
+ for (var i = 0; i < urls.length; i++)
747
+ triedUrlString += '\n' + (i + 1) + ': ' + tried[i];
748
+ if (triedUrlString.length > 0)
749
+ triedUrlString = '\n' + triedUrlString + '\n';
750
+ return new URLOpenError('Failed to open any of the provided URLs: ' + triedUrlString);
751
+ }
752
+ if (os === OS.Android) {
753
+ var option = options[OS.Android];
754
+ if (option === undefined)
755
+ return Promise.reject(getURLOpenError());
756
+ timeout = option.timeout;
757
+ var scheme = urlToString(option.scheme);
758
+ var intent = urlToString(option.intent);
759
+ var packageName = option.packageName;
760
+ var fallback = urlToString(option.fallback);
761
+ var allowWebStore = option.allowWebStore;
762
+ if (intent !== undefined && (scheme === undefined || packageName === undefined || fallback === undefined)) {
763
+ var parsed = parseIntentURL(intent);
764
+ if (parsed.scheme !== undefined && scheme === undefined)
765
+ scheme = parsed.scheme;
766
+ if (parsed.packageName !== undefined && packageName === undefined)
767
+ packageName = parsed.packageName;
768
+ if (parsed.fallback !== undefined && fallback === undefined)
769
+ fallback = parsed.fallback;
770
+ }
771
+ if (scheme !== undefined && intent === undefined)
772
+ intent = createIntentURL(scheme, packageName, fallback);
773
+ if (intent !== undefined && IS_SUPPORT_INTENT)
774
+ urls.push([intent, AppOpenState.Intent]);
775
+ if (scheme !== undefined)
776
+ urls.push([scheme, AppOpenState.Scheme]);
777
+ if (fallback !== undefined)
778
+ urls.push([fallback, AppOpenState.Fallback]);
779
+ if (packageName !== undefined)
780
+ urls.push([createAppStoreURL(packageName, OS.Android), AppOpenState.Store]);
781
+ if (packageName !== undefined && allowWebStore === true)
782
+ urls.push([createWebStoreURL(packageName, OS.Android), AppOpenState.Store]);
783
+ }
784
+ else if (os === OS.iOS) {
785
+ var option = options[OS.iOS];
786
+ if (option === undefined)
787
+ return Promise.reject(getURLOpenError());
788
+ timeout = option.timeout;
789
+ var scheme = urlToString(option.scheme);
790
+ var packageName = option.bundleId;
791
+ var trackId = option.trackId;
792
+ var universal = urlToString(option.universal);
793
+ var fallback = urlToString(option.fallback);
794
+ var allowWebStore = option.allowWebStore;
795
+ if (packageName !== undefined && trackId === undefined)
796
+ trackId = getTrackId(packageName);
797
+ if (universal !== undefined && parseInt(OS_VERSION) >= 9)
798
+ urls.push([universal, AppOpenState.Universal]);
799
+ if (scheme !== undefined)
800
+ urls.push([scheme, AppOpenState.Scheme]);
801
+ if (fallback !== undefined)
802
+ urls.push([fallback, AppOpenState.Fallback]);
803
+ if (trackId !== undefined)
804
+ urls.push([createAppStoreURL(trackId, OS.iOS), AppOpenState.Store]);
805
+ if (trackId !== undefined && allowWebStore === true)
806
+ urls.push([createWebStoreURL(trackId, OS.iOS), AppOpenState.Store]);
807
+ }
808
+ else if (os === OS.Windows) {
809
+ var option = options[OS.Windows];
810
+ if (option === undefined)
811
+ return Promise.reject(getURLOpenError());
812
+ timeout = option.timeout;
813
+ var scheme = urlToString(option.scheme);
814
+ var productId = option.productId;
815
+ var fallback = urlToString(option.fallback);
816
+ var allowWebStore = option.allowWebStore;
817
+ if (scheme !== undefined)
818
+ urls.push([scheme, AppOpenState.Scheme]);
819
+ if (fallback !== undefined)
820
+ urls.push([fallback, AppOpenState.Fallback]);
821
+ if (productId !== undefined)
822
+ urls.push([createAppStoreURL(productId, OS.Windows), AppOpenState.Store]);
823
+ if (productId !== undefined && allowWebStore === true)
824
+ urls.push([createWebStoreURL(productId, OS.Windows), AppOpenState.Store]);
825
+ }
826
+ else if (os === OS.MacOS) {
827
+ var option = options[OS.MacOS];
828
+ if (option === undefined)
829
+ return Promise.reject(getURLOpenError());
830
+ timeout = option.timeout;
831
+ var scheme = urlToString(option.scheme);
832
+ var packageName = option.bundleId;
833
+ var trackId = option.trackId;
834
+ var fallback = urlToString(option.fallback);
835
+ var allowWebStore = option.allowWebStore;
836
+ if (packageName !== undefined && trackId === undefined)
837
+ trackId = getTrackId(packageName);
838
+ if (scheme !== undefined)
839
+ urls.push([scheme, AppOpenState.Scheme]);
840
+ if (fallback !== undefined)
841
+ urls.push([fallback, AppOpenState.Fallback]);
842
+ if (trackId !== undefined)
843
+ urls.push([createAppStoreURL(trackId, OS.MacOS), AppOpenState.Store]);
844
+ if (trackId !== undefined && allowWebStore === true)
845
+ urls.push([createWebStoreURL(trackId, OS.MacOS), AppOpenState.Store]);
846
+ }
847
+ if (timeout === undefined)
848
+ timeout = getDefaultTimeoutByOS(os);
849
+ return new Promise(function (resolve, reject) {
850
+ function openURLSequential(index) {
851
+ if (index === void 0) { index = 0; }
852
+ if (index >= urls.length)
853
+ return reject(getURLOpenError());
854
+ var entry = urls[index];
855
+ var url = entry[0];
856
+ if (typeof url === 'string') {
857
+ tried[index] = url;
858
+ return tryOpenUrl(url, index, timeout)
859
+ .then(function () {
860
+ resolve(entry[1]);
861
+ })
862
+ .catch(function () {
863
+ openURLSequential(index + 1);
864
+ });
865
+ }
866
+ else {
867
+ tried[index] = '[function fallback]';
868
+ url();
869
+ resolve(entry[1]);
870
+ }
871
+ }
872
+ return openURLSequential();
873
+ });
874
+ }
875
+ function isArrayLike(value) {
876
+ if (value == null || typeof value === 'string')
877
+ return false;
878
+ var length = value.length;
879
+ return typeof length === 'number' && length >= 0 && !(length % 1);
880
+ }
881
+ function joining(values, mapfn, separator) {
882
+ if (separator === void 0) { separator = ','; }
883
+ var length = values.length;
884
+ var result = '';
885
+ for (var i = 0; i < length; i++) {
886
+ result = result + mapfn(values[i]);
887
+ if (i !== length - 1)
888
+ result = result + separator;
889
+ }
890
+ return result;
891
+ }
892
+ function encode(value) {
893
+ return encodeURIComponent(value)
894
+ .replace(/[!'()*]/g, function (c) {
895
+ return '%' + c.charCodeAt(0).toString(16);
896
+ });
897
+ }
898
+ function urlToString(value) {
899
+ if (value instanceof URL)
900
+ return value.toString();
901
+ return value;
902
+ }
903
+ function stringifiableToString(value) {
904
+ if (typeof value === 'string')
905
+ return encode(value);
906
+ if (typeof value === 'number' || typeof value === 'boolean')
907
+ return encode(String(value));
908
+ if (value == null)
909
+ return '';
910
+ if (isArrayLike(value))
911
+ return joining(value, function (v) {
912
+ return stringifiableToString(v);
913
+ });
914
+ if (value instanceof HTMLInputElement) {
915
+ var type = value.type;
916
+ if (type === 'checkbox') {
917
+ return encode(value.checked.toString());
918
+ }
919
+ else if (type === 'radio') {
920
+ if (value.checked)
921
+ return encode(value.value);
922
+ else
923
+ return '';
924
+ }
925
+ else if (type === 'file') {
926
+ var files = value.files;
927
+ if (files === null)
928
+ return '';
929
+ return joining(files, function (file) {
930
+ return encode(file.name);
931
+ });
932
+ }
933
+ else {
934
+ return encode(value.value);
935
+ }
936
+ }
937
+ if (value instanceof HTMLSelectElement) {
938
+ if (value.multiple)
939
+ return joining(value.selectedOptions, function (option) {
940
+ return encode(option.value);
941
+ });
942
+ return encode(value.value);
943
+ }
944
+ if (value instanceof HTMLTextAreaElement)
945
+ return encode(value.value);
946
+ if (value instanceof HTMLElement)
947
+ return encode(value.innerText);
948
+ if (value instanceof Node)
949
+ return stringifiableToString(value.textContent);
950
+ return encode(value.toString());
951
+ }
952
+ function normalize(value) {
953
+ if (value instanceof HTMLFormElement)
954
+ return normalize(new FormData(value));
955
+ if (value instanceof FormData) {
956
+ var result_1 = {};
957
+ value.forEach(function (value, key) {
958
+ var name;
959
+ if (value instanceof File)
960
+ name = value.name;
961
+ else
962
+ name = value;
963
+ if (Object.prototype.hasOwnProperty.call(result_1, key)) {
964
+ var prev = result_1[key];
965
+ if (Array.isArray(prev))
966
+ prev.push(name);
967
+ else
968
+ result_1[key] = [prev, name];
969
+ }
970
+ else {
971
+ result_1[key] = name;
972
+ }
973
+ });
974
+ return normalize(result_1);
975
+ }
976
+ var result = {};
977
+ var keys = Object.keys(value);
978
+ for (var i = 0; i < keys.length; i++) {
979
+ var key = keys[i];
980
+ result[key] = stringifiableToString(value[key]);
981
+ }
982
+ if (result.to === undefined)
983
+ result.to = '';
984
+ if (result.cc === undefined)
985
+ result.cc = '';
986
+ if (result.bcc === undefined)
987
+ result.bcc = '';
988
+ if (result.subject === undefined)
989
+ result.subject = '';
990
+ if (result.body === undefined)
991
+ result.body = '';
992
+ return result;
993
+ }
994
+ function openMessenger(options, type) {
995
+ options = normalize(options);
996
+ return tryOpenUrl(type + ':' + options.to
997
+ + '?cc=' + options.cc
998
+ + '&bcc=' + options.bcc
999
+ + '&subject=' + options.subject
1000
+ + '&body=' + options.body, 0, getDefaultTimeoutByOS(OS_NAME));
1001
+ }
1002
+ function openMessengerTelephone(options) {
1003
+ return openMessenger(options, 'tel');
1004
+ }
1005
+ function openMessengerMessage(options) {
1006
+ return openMessenger(options, 'sms');
1007
+ }
1008
+ function openMessengerMail(options) {
1009
+ return openMessenger(options, 'mailto');
1010
+ }
1011
+
1012
+ var AppPlugin = {
1013
+ installed: false,
1014
+ name: 'App',
1015
+ module: App,
1016
+ constants: {
1017
+ AppOpenState: AppOpenState,
1018
+ Messengers: Messengers
1019
+ },
1020
+ errors: {
1021
+ URLOpenError: URLOpenError
1022
+ }
1023
+ };
1024
+
1025
+ module.exports = AppPlugin;