@cleartrip/ct-platform-utils 3.0.0-beta.8 → 3.1.0

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.
@@ -1,745 +1,2 @@
1
- 'use strict';
2
-
3
- var tslib = require('tslib');
4
- var ctPlatformConstants = require('@cleartrip/ct-platform-constants');
5
- var ctPlatformTypes = require('@cleartrip/ct-platform-types');
6
-
7
- var urlJoin = function () {
8
- var parts = [];
9
- for (var _i = 0; _i < arguments.length; _i++) {
10
- parts[_i] = arguments[_i];
11
- }
12
- var trimmedParts = parts.map(function (part) { return part.trim().replace(/^[/]+/, ''); });
13
- var joinedParts = trimmedParts.join('/');
14
- joinedParts = joinedParts.replace(/\/\?/g, '?');
15
- return joinedParts;
16
- };
17
- var getApiDomain = function () {
18
- var domain = typeof window !== 'undefined' ? window.location.hostname : '';
19
- console.log('API_BASE domain', domain);
20
- switch (domain) {
21
- case 'localhost':
22
- case '0.0.0.0':
23
- return 'https://qa2new.cleartrip.com';
24
- case 'www.cleartrip.com':
25
- return 'https://www.cleartrip.com';
26
- case 'qa2.cleartrip.com':
27
- return 'https://qa2.cleartrip.com';
28
- case 'qa2new.cleartrip.com':
29
- return 'https://qa2new.cleartrip.com';
30
- default:
31
- return 'https://www.cleartrip.com';
32
- }
33
- };
34
- var getNestedValue = function (data, path) {
35
- var reducerFunction = function (prev, current) {
36
- return prev && prev[current] ? prev[current] : null;
37
- };
38
- return path.reduce(reducerFunction, data);
39
- };
40
- var path = function (p, o) {
41
- return p.reduce(function (prev, curr) {
42
- return prev && prev[curr] ? prev[curr] : null;
43
- }, o);
44
- };
45
- var MULTI_SPACE = /\s\s+/g;
46
- var isEmpty = function (obj) {
47
- if (obj instanceof Date) {
48
- return false;
49
- }
50
- if (obj == null) {
51
- return true;
52
- }
53
- var isNumber = function (value) {
54
- return Object.prototype.toString.call(value) === '[object Number]';
55
- };
56
- var isNaN = function (value) { return isNumber(value) && value.toString() === 'NaN'; };
57
- if (isNumber(obj)) {
58
- return isNaN(obj);
59
- }
60
- if (obj.length > 0) {
61
- return false;
62
- }
63
- if (obj.length === 0) {
64
- return true;
65
- }
66
- if (typeof obj !== 'object') {
67
- return true;
68
- }
69
- var keys = Object.keys(obj);
70
- for (var i = 0, key = keys[i]; i < keys.length; i += 1) {
71
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
72
- return false;
73
- }
74
- }
75
- return true;
76
- };
77
- var isHTMLInputElement = function (ref) {
78
- return (typeof ref === 'object' &&
79
- ref !== null &&
80
- 'value' in ref &&
81
- ref instanceof HTMLInputElement);
82
- };
83
- var isNumeric = function (value) {
84
- return /^[0-9]*$/.test(value);
85
- };
86
- var getCurrentUrl = typeof window !== 'undefined' ? window.location.href : '';
87
- var getQueryParam = function (queryParam) {
88
- var urlParams = new URLSearchParams(window.location.search);
89
- return urlParams.get(queryParam);
90
- };
91
- var getCurrentPathName = function () {
92
- return typeof window !== 'undefined'
93
- ? (window.location.pathname + window.location.search).slice(1)
94
- : '';
95
- };
96
- var getHeightFromImgUrl = function (url) {
97
- if (!url) {
98
- return;
99
- }
100
- var regex = /h_(\d+)[,\/]/;
101
- var match = url.match(regex);
102
- if (match && match[1]) {
103
- return parseInt(match[1], 10);
104
- }
105
- return;
106
- };
107
- var getWidthFromImgUrl = function (url) {
108
- if (!url) {
109
- return;
110
- }
111
- var regex = /w_(\d+)[,\/]/;
112
- var match = url.match(regex);
113
- if (match && match[1]) {
114
- return parseInt(match[1], 10);
115
- }
116
- return;
117
- };
118
- var isServer = function () {
119
- return typeof window === 'undefined' || !window;
120
- };
121
- function getCookie(name, customCookie) {
122
- var _cookie = customCookie || getNestedValue(document, ['cookie']);
123
- if (_cookie) {
124
- var nameEQ = name + '=';
125
- var ca = _cookie.split(';');
126
- for (var i = 0; i < ca.length; i++) {
127
- var c = ca[i];
128
- while (c.charAt(0) == ' ')
129
- c = c.substring(1, c.length);
130
- if (c.indexOf(nameEQ) == 0)
131
- return c.substring(nameEQ.length, c.length);
132
- }
133
- return '';
134
- }
135
- else {
136
- return '';
137
- }
138
- }
139
- var getDimensionFromImageUrl = function (url) {
140
- if (url === void 0) { url = ''; }
141
- var height = getHeightFromImgUrl(url) || 0;
142
- var width = getWidthFromImgUrl(url) || 0;
143
- return {
144
- height: "".concat(height, "px"),
145
- width: "".concat(width, "px"),
146
- heightInNumber: height,
147
- widthInNumber: width,
148
- };
149
- };
150
- var replacePlaceHolder = function (text, data, replaceWithTag, replaceClass) {
151
- if (replaceWithTag === void 0) { replaceWithTag = false; }
152
- if (replaceClass === void 0) { replaceClass = ""; }
153
- if (!isEmpty(text) && !isEmpty(data)) {
154
- var placeholders_1 = text.match(/[^{\}]+(?=})/g);
155
- text = text.replace(/[{}]/g, "");
156
- if (!isEmpty(placeholders_1)) {
157
- placeholders_1.forEach(function (item, index) {
158
- if (replaceWithTag) {
159
- text = text.replace(placeholders_1[index], "<span class=".concat(replaceClass, ">").concat(data[placeholders_1[index]], "</span>"));
160
- }
161
- else {
162
- text = text.replace(placeholders_1[index], data[placeholders_1[index]]);
163
- }
164
- });
165
- }
166
- }
167
- return text;
168
- };
169
-
170
- var getDevicePlatform = function () {
171
- var _a;
172
- var userAgent = (_a = getNestedValue(window, [
173
- 'navigator',
174
- 'userAgent',
175
- ])) === null || _a === void 0 ? void 0 : _a.toLowerCase();
176
- var safariBrowser = /safari/.test(userAgent);
177
- var appleDevice = /iphone|ipod|ipad/.test(userAgent);
178
- if ((getNestedValue(window, ['androidData', 'app-agent']) &&
179
- getNestedValue(window, ['androidData', 'js-version'])) ||
180
- typeof getNestedValue(window, ['MobileApp', 'getAppSpecificData']) ===
181
- 'function') {
182
- return ctPlatformConstants.Platform.ANDROID;
183
- }
184
- else if ((getNestedValue(window, ['iosData', 'app-agent']) &&
185
- getNestedValue(window, ['iosData', 'js-version'])) ||
186
- (appleDevice && !safariBrowser)) {
187
- return ctPlatformConstants.Platform.IOS;
188
- }
189
- return ctPlatformConstants.Platform.PWA;
190
- };
191
- var getAppAgent = function () {
192
- var _a, _b;
193
- var platform = getDevicePlatform();
194
- if (platform === ctPlatformConstants.Platform.IOS) {
195
- return (_a = getNestedValue(window, ['iosData', 'app-agent'])) !== null && _a !== void 0 ? _a : ctPlatformConstants.AppAgent.IOS;
196
- }
197
- else if (platform === ctPlatformConstants.Platform.ANDROID) {
198
- return ((_b = getNestedValue(window, ['androidData', 'app-agent'])) !== null && _b !== void 0 ? _b : ctPlatformConstants.AppAgent.ANDROID);
199
- }
200
- return ctPlatformConstants.AppAgent.PWA;
201
- };
202
- var getJSVersion = function () {
203
- var jsVersion = '';
204
- if (isIOSApp()) {
205
- jsVersion = getNestedValue(window, ['iosData', 'js-version']);
206
- }
207
- else if (isAndroidApp()) {
208
- jsVersion = getNestedValue(window, ['androidData', 'js-version']);
209
- }
210
- if (jsVersion) {
211
- jsVersion = jsVersion.toString().split('.')[0];
212
- }
213
- return jsVersion;
214
- };
215
- var isPwa = function () {
216
- return getDevicePlatform() !== ctPlatformConstants.Platform.ANDROID &&
217
- getDevicePlatform() !== ctPlatformConstants.Platform.IOS;
218
- };
219
- var isAndroidApp = function () {
220
- return getDevicePlatform() === ctPlatformConstants.Platform.ANDROID;
221
- };
222
- var isJSVersionUpdated = function (compareVersion) {
223
- return parseInt(getJSVersion()) >= compareVersion;
224
- };
225
- var isIOSApp = function () { return getDevicePlatform() === ctPlatformConstants.Platform.IOS; };
226
-
227
- var API_BASE = getApiDomain();
228
- var getRequestUrl = function (path, params) {
229
- var url = ctPlatformConstants.API_ROUTES[path];
230
- if (!url || !url.trim().length) {
231
- return;
232
- }
233
- url = urlJoin(API_BASE, url);
234
- if (params === null || params === void 0 ? void 0 : params.pathParams) {
235
- for (var _i = 0, _a = Object.entries(params.pathParams); _i < _a.length; _i++) {
236
- var _b = _a[_i], key = _b[0], value = _b[1];
237
- url = url.replace(":".concat(key), value);
238
- }
239
- }
240
- if (params === null || params === void 0 ? void 0 : params.queryParams) {
241
- url += "?".concat(new URLSearchParams(params.queryParams).toString());
242
- }
243
- return url;
244
- };
245
- var createAPIRequest = function (path, method, payload, headers, params, useCustomErrorHandler) {
246
- if (method === void 0) { method = ctPlatformConstants.RequestMethods.GET; }
247
- if (headers === void 0) { headers = {}; }
248
- if (params === void 0) { params = {}; }
249
- if (useCustomErrorHandler === void 0) { useCustomErrorHandler = false; }
250
- return tslib.__awaiter(void 0, void 0, void 0, function () {
251
- var url, API_AUTHORITY, requestOptions, responseData, response, error, message, contentType;
252
- return tslib.__generator(this, function (_a) {
253
- switch (_a.label) {
254
- case 0:
255
- url = getRequestUrl(path, params);
256
- if (!url || !url.trim().length) {
257
- return [2, Promise.reject('URL parameter missing')];
258
- }
259
- API_AUTHORITY = getApiDomain();
260
- requestOptions = {
261
- method: method,
262
- headers: tslib.__assign({ Caller: API_BASE, Origin: API_BASE, Referer: API_BASE, Authority: API_AUTHORITY, x_ct_sourcetype: 'MOBILE', 'app-agent': getAppAgent(), 'Content-Type': 'application/json' }, headers),
263
- };
264
- if (payload) {
265
- requestOptions.body = JSON.stringify(payload);
266
- }
267
- return [4, fetch(url, requestOptions)];
268
- case 1:
269
- response = _a.sent();
270
- error = {
271
- name: 'API_FAILURE',
272
- status: response.status,
273
- message: 'UNKNOWN_ERROR',
274
- statusText: response.statusText,
275
- };
276
- if (!!(response === null || response === void 0 ? void 0 : response.ok)) return [3, 3];
277
- if (useCustomErrorHandler) {
278
- return [2, Promise.reject(error)];
279
- }
280
- return [4, response.json()];
281
- case 2:
282
- message = (_a.sent()).message;
283
- error.message = message;
284
- throw error;
285
- case 3:
286
- contentType = response.headers.get('content-type');
287
- if (!(contentType === null || contentType === void 0 ? void 0 : contentType.includes('application/json'))) return [3, 5];
288
- return [4, response.json()];
289
- case 4:
290
- responseData = _a.sent();
291
- return [3, 9];
292
- case 5:
293
- if (!(contentType === null || contentType === void 0 ? void 0 : contentType.includes('text'))) return [3, 7];
294
- return [4, response.text()];
295
- case 6:
296
- responseData = _a.sent();
297
- return [3, 9];
298
- case 7:
299
- if (!(response.status !== 204)) return [3, 9];
300
- return [4, response.blob()];
301
- case 8:
302
- responseData = _a.sent();
303
- _a.label = 9;
304
- case 9: return [2, {
305
- data: responseData,
306
- status: response.status,
307
- }];
308
- }
309
- });
310
- });
311
- };
312
- var createGetRequest = function (path, headers, params, useCustomErrorHandler) {
313
- if (headers === void 0) { headers = {}; }
314
- if (params === void 0) { params = {}; }
315
- if (useCustomErrorHandler === void 0) { useCustomErrorHandler = false; }
316
- return tslib.__awaiter(void 0, void 0, void 0, function () {
317
- return tslib.__generator(this, function (_a) {
318
- return [2, createAPIRequest(path, ctPlatformConstants.RequestMethods.GET, null, tslib.__assign({ expires: '0', accept: 'application/json', 'cache-control': 'no-cache' }, headers), params, useCustomErrorHandler)];
319
- });
320
- });
321
- };
322
- var createPostOrPutRequest = function (path, method, payload, headers, params, useCustomErrorHandler) {
323
- if (method === void 0) { method = ctPlatformConstants.RequestMethods.POST; }
324
- if (payload === void 0) { payload = {}; }
325
- if (headers === void 0) { headers = {}; }
326
- if (params === void 0) { params = {}; }
327
- if (useCustomErrorHandler === void 0) { useCustomErrorHandler = false; }
328
- return tslib.__awaiter(void 0, void 0, void 0, function () {
329
- return tslib.__generator(this, function (_a) {
330
- return [2, createAPIRequest(path, method, payload, tslib.__assign({ expires: '0', accept: 'application/json', 'cache-control': 'no-cache' }, headers), params, useCustomErrorHandler)];
331
- });
332
- });
333
- };
334
-
335
- var showMobileNumberHint = function () {
336
- var _a;
337
- if (typeof ((_a = window.MobileApp) === null || _a === void 0 ? void 0 : _a.onRequestMobileNumber) === 'function') {
338
- window.MobileApp.onRequestMobileNumber();
339
- var promiseResolver_1;
340
- var mobileNoPromise = new Promise(function (resolve) {
341
- promiseResolver_1 = resolve;
342
- });
343
- window.sendSelectedMobileNumber = function (mobileNum) {
344
- return promiseResolver_1(getAutoDetectedMobile(mobileNum));
345
- };
346
- return mobileNoPromise;
347
- }
348
- return Promise.resolve('');
349
- };
350
- var getAutoDetectedMobile = function (mobileNumber) {
351
- var formattedMobileNo = '';
352
- var matches = mobileNumber.match(ctPlatformConstants.MOBILE_CONSTANTS.REGEX);
353
- if (matches) {
354
- formattedMobileNo = matches[0].replace(/\D/g, '');
355
- }
356
- return formattedMobileNo;
357
- };
358
- var autoReadOtp = function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
359
- return tslib.__generator(this, function (_a) {
360
- return [2, isAndroidApp() ? readOtpAndroid() : readOtpPWA()];
361
- });
362
- }); };
363
- var updateNativeIOSOnSignIn = function () {
364
- var _a, _b, _c;
365
- (_c = (_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.PWA_IS_SIGNIN) === null || _c === void 0 ? void 0 : _c.postMessage({
366
- isSignIn: true,
367
- });
368
- };
369
- var updateNativeAndroidOnSignIn = function () {
370
- var _a;
371
- (_a = window.MobileApp) === null || _a === void 0 ? void 0 : _a.onPWALoginStatus(JSON.stringify({
372
- isSignIn: true,
373
- }));
374
- };
375
- var triggerOTPListener = function () {
376
- var _a;
377
- if (isAndroidApp()) {
378
- (_a = window.MobileApp) === null || _a === void 0 ? void 0 : _a.onPageStart('OTP_SCREEN');
379
- }
380
- };
381
- var readOtpPWA = function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
382
- var abortController;
383
- var _a;
384
- return tslib.__generator(this, function (_b) {
385
- if (!((_a = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a === void 0 ? void 0 : _a.get) || !('OTPCredential' in window)) {
386
- return [2, Promise.reject('NOT_SUPPORTED')];
387
- }
388
- abortController = new AbortController();
389
- setTimeout(function () {
390
- abortController.abort();
391
- }, 60000);
392
- return [2, navigator.credentials
393
- .get({
394
- otp: { transport: ['sms'] },
395
- signal: abortController.signal,
396
- })
397
- .then(function (content) { return content === null || content === void 0 ? void 0 : content.code; })];
398
- });
399
- }); };
400
- var readOtpAndroid = function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
401
- var promiseResolver, otpPromise;
402
- return tslib.__generator(this, function (_a) {
403
- otpPromise = new Promise(function (resolve) {
404
- promiseResolver = resolve;
405
- });
406
- window.sendOtpValue = function (otp) {
407
- promiseResolver(otp);
408
- };
409
- return [2, otpPromise];
410
- });
411
- }); };
412
-
413
- var sendLoginOtp = function (mobile, personalizationHeaders) { return tslib.__awaiter(void 0, void 0, void 0, function () {
414
- var response;
415
- return tslib.__generator(this, function (_a) {
416
- switch (_a.label) {
417
- case 0: return [4, createPostOrPutRequest('SEND_OTP', ctPlatformConstants.RequestMethods.POST, {
418
- value: mobile,
419
- type: 'MOBILE',
420
- action: 'SIGNIN',
421
- countryCode: ctPlatformConstants.MOBILE_CONSTANTS.COUNTRY_CODE,
422
- }, {
423
- 'ab-otp': 'b',
424
- dvid_data: personalizationHeaders,
425
- })];
426
- case 1:
427
- response = _a.sent();
428
- return [2, response === null || response === void 0 ? void 0 : response.data];
429
- }
430
- });
431
- }); };
432
- var validateOtp = function (mobile, otp) { return tslib.__awaiter(void 0, void 0, void 0, function () {
433
- var response, data;
434
- return tslib.__generator(this, function (_a) {
435
- switch (_a.label) {
436
- case 0: return [4, createPostOrPutRequest('VALIDATE_OTP', ctPlatformConstants.RequestMethods.POST, {
437
- otp: otp,
438
- value: mobile,
439
- type: 'MOBILE',
440
- action: 'SIGNIN',
441
- countryCode: '+91',
442
- }, { 'ab-otp': 'b' })];
443
- case 1:
444
- response = _a.sent();
445
- data = response === null || response === void 0 ? void 0 : response.data;
446
- return [2, tslib.__assign(tslib.__assign({}, response), { signup: (data === null || data === void 0 ? void 0 : data.action) === ctPlatformTypes.ValidateOTPAction.SIGNUP, action: data === null || data === void 0 ? void 0 : data.action, status: response === null || response === void 0 ? void 0 : response.status })];
447
- }
448
- });
449
- }); };
450
- var handleFKSSO = function (fallbackUri, signupPageUri, currentPageUri) { return tslib.__awaiter(void 0, void 0, void 0, function () {
451
- var redirectionInfo;
452
- return tslib.__generator(this, function (_a) {
453
- switch (_a.label) {
454
- case 0:
455
- if (isIOSApp()) {
456
- return [2, Promise.reject()];
457
- }
458
- return [4, sendFKSSORedirectionInfo(fallbackUri, signupPageUri, currentPageUri)];
459
- case 1:
460
- redirectionInfo = _a.sent();
461
- if (isAndroidApp()) {
462
- return [2, handleFKSSOAndroid(redirectionInfo)];
463
- }
464
- else {
465
- return [2, handleFKSSOWeb(redirectionInfo)];
466
- }
467
- }
468
- });
469
- }); };
470
- var isValidMobileNumber = function (text) {
471
- return (text === null || text === void 0 ? void 0 : text.length) === ctPlatformConstants.MOBILE_CONSTANTS.LENGTH && /^\d{10}$/.test(text);
472
- };
473
- var updateNativeOnLogin = function () {
474
- if (isIOSApp()) {
475
- updateNativeIOSOnSignIn();
476
- }
477
- else if (isAndroidApp()) {
478
- updateNativeAndroidOnSignIn();
479
- }
480
- };
481
- var isFKSSOEnabled = function () {
482
- return isPwa() || (!isIOSApp() && isJSVersionUpdated(5));
483
- };
484
- var sendFKSSORedirectionInfo = function (fallbackUri, signupPageUri, currentPageUri) { return tslib.__awaiter(void 0, void 0, void 0, function () {
485
- var WEBSITE_BASE, response;
486
- return tslib.__generator(this, function (_a) {
487
- switch (_a.label) {
488
- case 0:
489
- WEBSITE_BASE = getApiDomain();
490
- return [4, createPostOrPutRequest('FK_REDIRECTION_INFO', ctPlatformConstants.RequestMethods.POST, {
491
- provider: 'flipkart',
492
- fallbackUri: urlJoin(WEBSITE_BASE, fallbackUri || getCurrentPathName()),
493
- signupPageUri: urlJoin(WEBSITE_BASE, signupPageUri || 'personal-details'),
494
- currentPageUri: urlJoin(WEBSITE_BASE, currentPageUri),
495
- })];
496
- case 1:
497
- response = _a.sent();
498
- return [2, response === null || response === void 0 ? void 0 : response.data];
499
- }
500
- });
501
- }); };
502
- var handleFKSSOWeb = function (redirectionInfo) {
503
- var _a;
504
- var params = (_a = redirectionInfo === null || redirectionInfo === void 0 ? void 0 : redirectionInfo.params) !== null && _a !== void 0 ? _a : {};
505
- var redirectUri = redirectionInfo === null || redirectionInfo === void 0 ? void 0 : redirectionInfo.redirectUri;
506
- if (redirectUri) {
507
- redirectUri += '?';
508
- for (var key in params) {
509
- redirectUri += key + '=' + params[key] + '&';
510
- }
511
- return Promise.resolve(redirectUri);
512
- }
513
- return Promise.reject();
514
- };
515
- var handleFKSSOAndroid = function (redirectionInfo) {
516
- var _a, _b;
517
- var params = redirectionInfo === null || redirectionInfo === void 0 ? void 0 : redirectionInfo.params;
518
- if (isEmpty(params) ||
519
- typeof ((_a = window.MobileApp) === null || _a === void 0 ? void 0 : _a.onNavigationChange) !== 'function') {
520
- return Promise.reject();
521
- }
522
- else {
523
- var FK_REDIRECT_DL = urlJoin(getApiDomain(), 'dl/oauth2');
524
- (_b = window.MobileApp) === null || _b === void 0 ? void 0 : _b.onNavigationChange(JSON.stringify({
525
- type: 'FkSSO',
526
- miscData: tslib.__assign(tslib.__assign({}, params), { redirectURI: FK_REDIRECT_DL }),
527
- }));
528
- return Promise.resolve();
529
- }
530
- };
531
- function getUserAuthValues(customCookie) {
532
- try {
533
- var _a = decodeURIComponent(getCookie('userid', customCookie) || '').split('|'), email = _a[0], profileName = _a[1], gender = _a[2], photo = _a[3], userId = _a[4];
534
- return {
535
- email: email,
536
- profileName: profileName,
537
- gender: gender,
538
- photo: photo,
539
- userId: userId,
540
- };
541
- }
542
- catch (error) {
543
- return {};
544
- }
545
- }
546
- var isUserSignedIn = function (customCookie) {
547
- var userObject = getUserAuthValues(customCookie) || {};
548
- var usermiscVal = decodeURIComponent(getCookie('usermisc', customCookie) || '').split('|');
549
- var signedIn = usermiscVal.includes('SIGNED_IN') &&
550
- userObject.userId &&
551
- userObject.userId.length > 0
552
- ? true
553
- : false;
554
- return signedIn;
555
- };
556
-
557
- var getUserInsights = function (userId) { return tslib.__awaiter(void 0, void 0, void 0, function () {
558
- var response;
559
- return tslib.__generator(this, function (_a) {
560
- switch (_a.label) {
561
- case 0:
562
- _a.trys.push([0, 2, , 3]);
563
- return [4, createGetRequest('USER_INSIGHTS', {}, {
564
- pathParams: {
565
- userId: userId,
566
- },
567
- })];
568
- case 1:
569
- response = _a.sent();
570
- return [2, response === null || response === void 0 ? void 0 : response.data];
571
- case 2:
572
- _a.sent();
573
- return [2, Promise.resolve(null)];
574
- case 3: return [2];
575
- }
576
- });
577
- }); };
578
- var getUserInsightsData = function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
579
- var userId, stringifiedData, userInsights;
580
- var _a, _b;
581
- return tslib.__generator(this, function (_c) {
582
- switch (_c.label) {
583
- case 0:
584
- _c.trys.push([0, 2, , 3]);
585
- userId = getUserAuthValues().userId;
586
- if (!userId) {
587
- return [2, null];
588
- }
589
- stringifiedData = (_a = window === null || window === void 0 ? void 0 : window.sessionStorage) === null || _a === void 0 ? void 0 : _a.getItem('martech_user_attributes');
590
- if (typeof stringifiedData === 'string') {
591
- return [2, JSON.parse(stringifiedData)];
592
- }
593
- return [4, getUserInsights(userId)];
594
- case 1:
595
- userInsights = _c.sent();
596
- if (isEmpty(userInsights === null || userInsights === void 0 ? void 0 : userInsights.data)) {
597
- return [2, null];
598
- }
599
- (_b = window === null || window === void 0 ? void 0 : window.sessionStorage) === null || _b === void 0 ? void 0 : _b.setItem('martech_user_attributes', JSON.stringify(userInsights === null || userInsights === void 0 ? void 0 : userInsights.data));
600
- return [2, userInsights === null || userInsights === void 0 ? void 0 : userInsights.data];
601
- case 2:
602
- _c.sent();
603
- return [2, null];
604
- case 3: return [2];
605
- }
606
- });
607
- }); };
608
-
609
- var stringifyPayload = function (payload) {
610
- var keys = Object.keys(payload);
611
- keys.forEach(function (key) {
612
- if (key === 'a_fare_price' ||
613
- key === 'a_ct_discount' ||
614
- key === 'supercoin_balance' ||
615
- key === 'supercoin_earned' ||
616
- key === 'supercoin_burnt' ||
617
- key === 'wallet_balance_used' ||
618
- key === 'convenience_fee')
619
- payload[key] = Number(payload[key]);
620
- else
621
- payload[key] = '' + payload[key];
622
- });
623
- return payload;
624
- };
625
- var ravenSDKTrigger = function (eventName, ravenPayload) {
626
- var _a;
627
- if (window && window['ravenWebManager']) {
628
- var commonPayload = {
629
- platform: (_a = getDevicePlatform()) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
630
- login_status: isUserSignedIn() ? 'yes' : 'no',
631
- domain: window.location.host,
632
- };
633
- var newRavenPayload = stringifyPayload(ravenPayload);
634
- var RavenWebManager = window['ravenWebManager'];
635
- RavenWebManager === null || RavenWebManager === void 0 ? void 0 : RavenWebManager.triggerRaven(eventName, tslib.__assign(tslib.__assign({}, commonPayload), newRavenPayload));
636
- }
637
- };
638
- var isAirHomePage = function () {
639
- if (window && typeof window !== 'undefined') {
640
- var pathname = getNestedValue(window, ['location', 'pathname']);
641
- if (pathname === '/' || pathname === '/flights') {
642
- return true;
643
- }
644
- }
645
- return false;
646
- };
647
- var getRavenEventProps = function () {
648
- if (window && typeof window !== 'undefined') {
649
- var queryParams = new URLSearchParams(getNestedValue(window, ['location', 'search']));
650
- var pathUrl = window.location.pathname;
651
- var redirectionPath = decodeURIComponent(queryParams.get('service'));
652
- var loginForm = isAirHomePage() ? 'skippable_login' : 'account_login';
653
- var vertical = 'air';
654
- var pageName = pathUrl.includes('flights/itinerary') ||
655
- redirectionPath.includes('flights/itinerary')
656
- ? 'a_itinerary'
657
- : 'a_home';
658
- if (redirectionPath.includes('my-account')) {
659
- vertical = 'uar';
660
- pageName = 'account';
661
- }
662
- if (redirectionPath.includes('hotels')) {
663
- vertical = 'hotel';
664
- pageName = redirectionPath.includes('hotels/itinerary')
665
- ? 'h_itinerary'
666
- : 'h_home';
667
- }
668
- if (redirectionPath.includes('bus')) {
669
- vertical = 'bus';
670
- pageName = redirectionPath.includes('bus/itinerary')
671
- ? 'b_itinerary'
672
- : 'b_home';
673
- }
674
- return { loginForm: loginForm, vertical: vertical, pageName: pageName };
675
- }
676
- return {};
677
- };
678
- var sendEventWithUserInsights = function (eventName, ravenPayload) { return tslib.__awaiter(void 0, void 0, void 0, function () {
679
- var userInsights, updatedPayload, loyaltyData;
680
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
681
- return tslib.__generator(this, function (_q) {
682
- switch (_q.label) {
683
- case 0: return [4, getUserInsightsData()];
684
- case 1:
685
- userInsights = _q.sent();
686
- updatedPayload = tslib.__assign(tslib.__assign({}, ravenPayload), { fk_loyalty_status: '', ct_lifetime_booking: '', myntra_loyalty_status: '', ct_postmerger_booking: '', ct_last_1year_booking: '' });
687
- if (!isEmpty(userInsights)) {
688
- loyaltyData = ((_a = userInsights === null || userInsights === void 0 ? void 0 : userInsights.loyaltyStatus) !== null && _a !== void 0 ? _a : []).reduce(function (prev, curr) {
689
- return tslib.__assign(tslib.__assign({}, prev), curr);
690
- }, {});
691
- updatedPayload = tslib.__assign(tslib.__assign({}, updatedPayload), { fk_loyalty_status: (_c = (_b = loyaltyData === null || loyaltyData === void 0 ? void 0 : loyaltyData.fk) === null || _b === void 0 ? void 0 : _b.program) !== null && _c !== void 0 ? _c : '', myntra_loyalty_status: (_e = (_d = loyaltyData === null || loyaltyData === void 0 ? void 0 : loyaltyData.myntra) === null || _d === void 0 ? void 0 : _d.program) !== null && _e !== void 0 ? _e : '', ct_postmerger_booking: (_h = (_g = (_f = userInsights === null || userInsights === void 0 ? void 0 : userInsights.bookingStatus) === null || _f === void 0 ? void 0 : _f.postmergerBooking) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : '', ct_last_1year_booking: (_l = (_k = (_j = userInsights === null || userInsights === void 0 ? void 0 : userInsights.bookingStatus) === null || _j === void 0 ? void 0 : _j.lastOneYearBooking) === null || _k === void 0 ? void 0 : _k.toString()) !== null && _l !== void 0 ? _l : '', ct_lifetime_booking: (_p = (_o = (_m = userInsights === null || userInsights === void 0 ? void 0 : userInsights.bookingStatus) === null || _m === void 0 ? void 0 : _m.lifetimeBooking) === null || _o === void 0 ? void 0 : _o.toString()) !== null && _p !== void 0 ? _p : '' });
692
- }
693
- ravenSDKTrigger(eventName, updatedPayload);
694
- return [2];
695
- }
696
- });
697
- }); };
698
-
699
- exports.MULTI_SPACE = MULTI_SPACE;
700
- exports.autoReadOtp = autoReadOtp;
701
- exports.createAPIRequest = createAPIRequest;
702
- exports.createGetRequest = createGetRequest;
703
- exports.createPostOrPutRequest = createPostOrPutRequest;
704
- exports.getApiDomain = getApiDomain;
705
- exports.getAppAgent = getAppAgent;
706
- exports.getAutoDetectedMobile = getAutoDetectedMobile;
707
- exports.getCookie = getCookie;
708
- exports.getCurrentPathName = getCurrentPathName;
709
- exports.getCurrentUrl = getCurrentUrl;
710
- exports.getDevicePlatform = getDevicePlatform;
711
- exports.getDimensionFromImageUrl = getDimensionFromImageUrl;
712
- exports.getHeightFromImgUrl = getHeightFromImgUrl;
713
- exports.getJSVersion = getJSVersion;
714
- exports.getNestedValue = getNestedValue;
715
- exports.getQueryParam = getQueryParam;
716
- exports.getRavenEventProps = getRavenEventProps;
717
- exports.getUserAuthValues = getUserAuthValues;
718
- exports.getWidthFromImgUrl = getWidthFromImgUrl;
719
- exports.handleFKSSO = handleFKSSO;
720
- exports.isAirHomePage = isAirHomePage;
721
- exports.isAndroidApp = isAndroidApp;
722
- exports.isEmpty = isEmpty;
723
- exports.isFKSSOEnabled = isFKSSOEnabled;
724
- exports.isHTMLInputElement = isHTMLInputElement;
725
- exports.isIOSApp = isIOSApp;
726
- exports.isJSVersionUpdated = isJSVersionUpdated;
727
- exports.isNumeric = isNumeric;
728
- exports.isPwa = isPwa;
729
- exports.isServer = isServer;
730
- exports.isUserSignedIn = isUserSignedIn;
731
- exports.isValidMobileNumber = isValidMobileNumber;
732
- exports.path = path;
733
- exports.ravenSDKTrigger = ravenSDKTrigger;
734
- exports.replacePlaceHolder = replacePlaceHolder;
735
- exports.sendEventWithUserInsights = sendEventWithUserInsights;
736
- exports.sendLoginOtp = sendLoginOtp;
737
- exports.showMobileNumberHint = showMobileNumberHint;
738
- exports.stringifyPayload = stringifyPayload;
739
- exports.triggerOTPListener = triggerOTPListener;
740
- exports.updateNativeAndroidOnSignIn = updateNativeAndroidOnSignIn;
741
- exports.updateNativeIOSOnSignIn = updateNativeIOSOnSignIn;
742
- exports.updateNativeOnLogin = updateNativeOnLogin;
743
- exports.urlJoin = urlJoin;
744
- exports.validateOtp = validateOtp;
1
+ "use strict";var t=require("tslib"),e=require("@cleartrip/ct-platform-constants"),n=require("@cleartrip/ct-platform-types"),r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t.map((function(t){return t.trim().replace(/^[/]+/,"")})).join("/");return n=n.replace(/\/\?/g,"?")},o=function(){var t="undefined"!=typeof window?window.location.hostname:"";switch(console.log("API_BASE domain",t),t){case"localhost":case"0.0.0.0":case"qa2new.cleartrip.com":return"https://qa2new.cleartrip.com";case"www.cleartrip.com":default:return"https://www.cleartrip.com";case"qa2.cleartrip.com":return"https://qa2.cleartrip.com"}},i=function(t,e){return e.reduce((function(t,e){return t&&t[e]?t[e]:null}),t)},a=function(t){if(t instanceof Date)return!1;if(null==t)return!0;var e,n=function(t){return"[object Number]"===Object.prototype.toString.call(t)};if(n(t))return n(e=t)&&"NaN"===e.toString();if(t.length>0)return!1;if(0===t.length)return!0;if("object"!=typeof t)return!0;for(var r=Object.keys(t),o=0,i=r[o];o<r.length;o+=1)if(Object.prototype.hasOwnProperty.call(t,i))return!1;return!0},s="undefined"!=typeof window?window.location.href:"",u=function(){return"undefined"!=typeof window?(window.location.pathname+window.location.search).slice(1):""},l=function(t){if(t){var e=t.match(/h_(\d+)[,\/]/);return e&&e[1]?parseInt(e[1],10):void 0}},c=function(t){if(t){var e=t.match(/w_(\d+)[,\/]/);return e&&e[1]?parseInt(e[1],10):void 0}};function d(t,e){var n=e||i(document,["cookie"]);if(n){for(var r=t+"=",o=n.split(";"),a=0;a<o.length;a++){for(var s=o[a];" "==s.charAt(0);)s=s.substring(1,s.length);if(0==s.indexOf(r))return s.substring(r.length,s.length)}return""}return""}var v=function(){var t,n=null===(t=i(window,["navigator","userAgent"]))||void 0===t?void 0:t.toLowerCase(),r=/safari/.test(n),o=/iphone|ipod|ipad/.test(n);return i(window,["androidData","app-agent"])&&i(window,["androidData","js-version"])||"function"==typeof i(window,["MobileApp","getAppSpecificData"])?e.Platform.ANDROID:i(window,["iosData","app-agent"])&&i(window,["iosData","js-version"])||o&&!r?e.Platform.IOS:e.Platform.PWA},p=function(){var t,n,r=v();return r===e.Platform.IOS?null!==(t=i(window,["iosData","app-agent"]))&&void 0!==t?t:e.AppAgent.IOS:r===e.Platform.ANDROID?null!==(n=i(window,["androidData","app-agent"]))&&void 0!==n?n:e.AppAgent.ANDROID:e.AppAgent.PWA},f=function(){var t="";return m()?t=i(window,["iosData","js-version"]):_()&&(t=i(window,["androidData","js-version"])),t&&(t=t.toString().split(".")[0]),t},g=function(){return v()!==e.Platform.ANDROID&&v()!==e.Platform.IOS},_=function(){return v()===e.Platform.ANDROID},w=function(t){return parseInt(f())>=t},m=function(){return v()===e.Platform.IOS},h=o(),b=function(n,i,a,s,u,l){return void 0===i&&(i=e.RequestMethods.GET),void 0===s&&(s={}),void 0===u&&(u={}),void 0===l&&(l=!1),t.__awaiter(void 0,void 0,void 0,(function(){var c,d,v,f,g,_,w,m;return t.__generator(this,(function(b){switch(b.label){case 0:return c=function(t,n){var o=e.API_ROUTES[t];if(o&&o.trim().length){if(o=r(h,o),null==n?void 0:n.pathParams)for(var i=0,a=Object.entries(n.pathParams);i<a.length;i++){var s=a[i],u=s[0],l=s[1];o=o.replace(":".concat(u),l)}return(null==n?void 0:n.queryParams)&&(o+="?".concat(new URLSearchParams(n.queryParams).toString())),o}}(n,u),c&&c.trim().length?(d=o(),v={method:i,headers:t.__assign({Caller:h,Origin:h,Referer:h,Authority:d,x_ct_sourcetype:"MOBILE","app-agent":p(),"Content-Type":"application/json"},s)},a&&(v.body=JSON.stringify(a)),[4,fetch(c,v)]):[2,Promise.reject("URL parameter missing")];case 1:return g=b.sent(),_={name:"API_FAILURE",status:g.status,message:"UNKNOWN_ERROR",statusText:g.statusText},(null==g?void 0:g.ok)?[3,3]:l?[2,Promise.reject(_)]:[4,g.json()];case 2:throw w=b.sent().message,_.message=w,_;case 3:return(null==(m=g.headers.get("content-type"))?void 0:m.includes("application/json"))?[4,g.json()]:[3,5];case 4:return f=b.sent(),[3,9];case 5:return(null==m?void 0:m.includes("text"))?[4,g.text()]:[3,7];case 6:return f=b.sent(),[3,9];case 7:return 204===g.status?[3,9]:[4,g.blob()];case 8:f=b.sent(),b.label=9;case 9:return[2,{data:f,status:g.status}]}}))}))},S=function(n,r,o,i){return void 0===r&&(r={}),void 0===o&&(o={}),void 0===i&&(i=!1),t.__awaiter(void 0,void 0,void 0,(function(){return t.__generator(this,(function(a){return[2,b(n,e.RequestMethods.GET,null,t.__assign({expires:"0",accept:"application/json","cache-control":"no-cache"},r),o,i)]}))}))},I=function(n,r,o,i,a,s){return void 0===r&&(r=e.RequestMethods.POST),void 0===o&&(o={}),void 0===i&&(i={}),void 0===a&&(a={}),void 0===s&&(s=!1),t.__awaiter(void 0,void 0,void 0,(function(){return t.__generator(this,(function(e){return[2,b(n,r,o,t.__assign({expires:"0",accept:"application/json","cache-control":"no-cache"},i),a,s)]}))}))},y=function(t){var n="",r=t.match(e.MOBILE_CONSTANTS.REGEX);return r&&(n=r[0].replace(/\D/g,"")),n},O=function(){var t,e,n;null===(n=null===(e=null===(t=window.webkit)||void 0===t?void 0:t.messageHandlers)||void 0===e?void 0:e.PWA_IS_SIGNIN)||void 0===n||n.postMessage({isSignIn:!0})},P=function(){var t;null===(t=window.MobileApp)||void 0===t||t.onPWALoginStatus(JSON.stringify({isSignIn:!0}))},N=function(){return t.__awaiter(void 0,void 0,void 0,(function(){var e,n;return t.__generator(this,(function(t){return(null===(n=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===n?void 0:n.get)&&"OTPCredential"in window?(e=new AbortController,setTimeout((function(){e.abort()}),6e4),[2,navigator.credentials.get({otp:{transport:["sms"]},signal:e.signal}).then((function(t){return null==t?void 0:t.code}))]):[2,Promise.reject("NOT_SUPPORTED")]}))}))},x=function(){return t.__awaiter(void 0,void 0,void 0,(function(){var e,n;return t.__generator(this,(function(t){return n=new Promise((function(t){e=t})),window.sendOtpValue=function(t){e(t)},[2,n]}))}))},A=function(n,i,a){return t.__awaiter(void 0,void 0,void 0,(function(){var s,l;return t.__generator(this,(function(t){switch(t.label){case 0:return s=o(),[4,I("FK_REDIRECTION_INFO",e.RequestMethods.POST,{provider:"flipkart",fallbackUri:r(s,n||u()),signupPageUri:r(s,i||"personal-details"),currentPageUri:r(s,a)})];case 1:return[2,null==(l=t.sent())?void 0:l.data]}}))}))},R=function(t){var e,n=null!==(e=null==t?void 0:t.params)&&void 0!==e?e:{},r=null==t?void 0:t.redirectUri;if(r){for(var o in r+="?",n)r+=o+"="+n[o]+"&";return Promise.resolve(r)}return Promise.reject()},T=function(e){var n,i,s=null==e?void 0:e.params;if(a(s)||"function"!=typeof(null===(n=window.MobileApp)||void 0===n?void 0:n.onNavigationChange))return Promise.reject();var u=r(o(),"dl/oauth2");return null===(i=window.MobileApp)||void 0===i||i.onNavigationChange(JSON.stringify({type:"FkSSO",miscData:t.__assign(t.__assign({},s),{redirectURI:u})})),Promise.resolve()};function D(t){try{var e=decodeURIComponent(d("userid",t)||"").split("|");return{email:e[0],profileName:e[1],gender:e[2],photo:e[3],userId:e[4]}}catch(t){return{}}}var E=function(t){var e=D(t)||{};return!!(decodeURIComponent(d("usermisc",t)||"").split("|").includes("SIGNED_IN")&&e.userId&&e.userId.length>0)},M=function(e){return t.__awaiter(void 0,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,S("USER_INSIGHTS",{},{pathParams:{userId:e}})];case 1:return[2,null==(n=t.sent())?void 0:n.data];case 2:return t.sent(),[2,Promise.resolve(null)];case 3:return[2]}}))}))},U=function(e){return t.__awaiter(void 0,void 0,void 0,(function(){var n,r,o,i,s;return t.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),(n=null!=e?e:D().userId)?"string"==typeof(r=null===(i=null===window||void 0===window?void 0:window.sessionStorage)||void 0===i?void 0:i.getItem("martech_user_attributes"))?[2,JSON.parse(r)]:[4,M(n)]:[2,null];case 1:return o=t.sent(),a(null==o?void 0:o.data)?[2,null]:(null===(s=null===window||void 0===window?void 0:window.sessionStorage)||void 0===s||s.setItem("martech_user_attributes",JSON.stringify(null==o?void 0:o.data)),[2,null==o?void 0:o.data]);case 2:return t.sent(),[2,null];case 3:return[2]}}))}))},j=function(t){return Object.keys(t).forEach((function(e){t[e]="a_fare_price"===e||"a_ct_discount"===e||"supercoin_balance"===e||"supercoin_earned"===e||"supercoin_burnt"===e||"wallet_balance_used"===e||"convenience_fee"===e?Number(t[e]):""+t[e]})),t},k=function(e,n){var r;if(window&&window.ravenWebManager){var o={platform:null===(r=v())||void 0===r?void 0:r.toLowerCase(),login_status:E()?"yes":"no",domain:window.location.host},i=j(n),a=window.ravenWebManager;null==a||a.triggerRaven(e,t.__assign(t.__assign({},o),i))}},C=function(){if(window&&"undefined"!=typeof window){var t=i(window,["location","pathname"]);if("/"===t||"/flights"===t)return!0}return!1};exports.MULTI_SPACE=/\s\s+/g,exports.autoReadOtp=function(){return t.__awaiter(void 0,void 0,void 0,(function(){return t.__generator(this,(function(t){return[2,_()?x():N()]}))}))},exports.createAPIRequest=b,exports.createGetRequest=S,exports.createPostOrPutRequest=I,exports.getApiDomain=o,exports.getAppAgent=p,exports.getAutoDetectedMobile=y,exports.getCookie=d,exports.getCurrentPathName=u,exports.getCurrentUrl=s,exports.getDevicePlatform=v,exports.getDimensionFromImageUrl=function(t){void 0===t&&(t="");var e=l(t)||0,n=c(t)||0;return{height:"".concat(e,"px"),width:"".concat(n,"px"),heightInNumber:e,widthInNumber:n}},exports.getHeightFromImgUrl=l,exports.getJSVersion=f,exports.getNestedValue=i,exports.getQueryParam=function(t){return new URLSearchParams(window.location.search).get(t)},exports.getRavenEventProps=function(){if(window&&"undefined"!=typeof window){var t=new URLSearchParams(i(window,["location","search"])),e=window.location.pathname,n=decodeURIComponent(t.get("service")),r=C()?"skippable_login":"account_login",o="air",a=e.includes("flights/itinerary")||n.includes("flights/itinerary")?"a_itinerary":"a_home";return n.includes("my-account")&&(o="uar",a="account"),n.includes("hotels")&&(o="hotel",a=n.includes("hotels/itinerary")?"h_itinerary":"h_home"),n.includes("bus")&&(o="bus",a=n.includes("bus/itinerary")?"b_itinerary":"b_home"),{loginForm:r,vertical:o,pageName:a}}return{}},exports.getUserAuthValues=D,exports.getWidthFromImgUrl=c,exports.handleFKSSO=function(e,n,r){return t.__awaiter(void 0,void 0,void 0,(function(){var o;return t.__generator(this,(function(t){switch(t.label){case 0:return m()?[2,Promise.reject()]:[4,A(e,n,r)];case 1:return o=t.sent(),_()?[2,T(o)]:[2,R(o)]}}))}))},exports.isAirHomePage=C,exports.isAndroidApp=_,exports.isEmpty=a,exports.isFKSSOEnabled=function(){return g()||!m()&&w(5)},exports.isHTMLInputElement=function(t){return"object"==typeof t&&null!==t&&"value"in t&&t instanceof HTMLInputElement},exports.isIOSApp=m,exports.isJSVersionUpdated=w,exports.isNumeric=function(t){return/^[0-9]*$/.test(t)},exports.isPwa=g,exports.isServer=function(){return"undefined"==typeof window||!window},exports.isUserSignedIn=E,exports.isValidMobileNumber=function(t){return(null==t?void 0:t.length)===e.MOBILE_CONSTANTS.LENGTH&&/^\d{10}$/.test(t)},exports.path=function(t,e){return t.reduce((function(t,e){return t&&t[e]?t[e]:null}),e)},exports.ravenSDKTrigger=k,exports.sendEventWithUserInsights=function(e,n,r){return t.__awaiter(void 0,void 0,void 0,(function(){var o,i,s,u,l,c,d,v,p,f,g,_,w,m,h,b,S;return t.__generator(this,(function(I){switch(I.label){case 0:return[4,U(r)];case 1:return o=I.sent(),i=t.__assign(t.__assign({},n),{fk_loyalty_status:"",ct_lifetime_booking:"",myntra_loyalty_status:"",ct_postmerger_booking:"",ct_last_1year_booking:""}),a(o)||(s=(null!==(u=null==o?void 0:o.loyaltyStatus)&&void 0!==u?u:[]).reduce((function(e,n){return t.__assign(t.__assign({},e),n)}),{}),i=t.__assign(t.__assign({},i),{fk_loyalty_status:null!==(c=null===(l=null==s?void 0:s.fk)||void 0===l?void 0:l.program)&&void 0!==c?c:"",myntra_loyalty_status:null!==(v=null===(d=null==s?void 0:s.myntra)||void 0===d?void 0:d.program)&&void 0!==v?v:"",ct_postmerger_booking:null!==(g=null===(f=null===(p=null==o?void 0:o.bookingStatus)||void 0===p?void 0:p.postmergerBooking)||void 0===f?void 0:f.toString())&&void 0!==g?g:"",ct_last_1year_booking:null!==(m=null===(w=null===(_=null==o?void 0:o.bookingStatus)||void 0===_?void 0:_.lastOneYearBooking)||void 0===w?void 0:w.toString())&&void 0!==m?m:"",ct_lifetime_booking:null!==(S=null===(b=null===(h=null==o?void 0:o.bookingStatus)||void 0===h?void 0:h.lifetimeBooking)||void 0===b?void 0:b.toString())&&void 0!==S?S:""})),k(e,i),[2]}}))}))},exports.sendLoginOtp=function(n,r){return t.__awaiter(void 0,void 0,void 0,(function(){var o;return t.__generator(this,(function(t){switch(t.label){case 0:return[4,I("SEND_OTP",e.RequestMethods.POST,{value:n,type:"MOBILE",action:"SIGNIN",countryCode:e.MOBILE_CONSTANTS.COUNTRY_CODE},{"ab-otp":"b",dvid_data:r})];case 1:return[2,null==(o=t.sent())?void 0:o.data]}}))}))},exports.showMobileNumberHint=function(){var t;if("function"==typeof(null===(t=window.MobileApp)||void 0===t?void 0:t.onRequestMobileNumber)){var e;window.MobileApp.onRequestMobileNumber();var n=new Promise((function(t){e=t}));return window.sendSelectedMobileNumber=function(t){return e(y(t))},n}return Promise.resolve("")},exports.stringifyPayload=j,exports.triggerOTPListener=function(){var t;_()&&(null===(t=window.MobileApp)||void 0===t||t.onPageStart("OTP_SCREEN"))},exports.updateNativeAndroidOnSignIn=P,exports.updateNativeIOSOnSignIn=O,exports.updateNativeOnLogin=function(){m()?O():_()&&P()},exports.urlJoin=r,exports.validateOtp=function(r,o){return t.__awaiter(void 0,void 0,void 0,(function(){var i,a;return t.__generator(this,(function(s){switch(s.label){case 0:return[4,I("VALIDATE_OTP",e.RequestMethods.POST,{otp:o,value:r,type:"MOBILE",action:"SIGNIN",countryCode:"+91"},{"ab-otp":"b"})];case 1:return i=s.sent(),a=null==i?void 0:i.data,[2,t.__assign(t.__assign({},i),{signup:(null==a?void 0:a.action)===n.ValidateOTPAction.SIGNUP,action:null==a?void 0:a.action,status:null==i?void 0:i.status})]}}))}))};
745
2
  //# sourceMappingURL=ct-platform-utils.cjs.js.map