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