@cleartrip/ct-platform-login-module 0.1.42-b5

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.
@@ -0,0 +1,557 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var react = require('react');
6
+ var ctPlatformDrawer = require('@cleartrip/ct-platform-drawer');
7
+ var ctDesignTheme = require('@cleartrip/ct-design-theme');
8
+ var ctDesignComponents = require('@cleartrip/ct-design-components');
9
+ var ctPlatformConstants = require('@cleartrip/ct-platform-constants');
10
+ var ctPlatformUtils = require('@cleartrip/ct-platform-utils');
11
+ var ctDesignIcons = require('@cleartrip/ct-design-icons');
12
+ var classNames = require('classnames');
13
+ var ctPlatformAssets = require('@cleartrip/ct-platform-assets');
14
+ var react$1 = require('swiper/react');
15
+
16
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
17
+
18
+ var classNames__default = /*#__PURE__*/_interopDefault(classNames);
19
+
20
+ function styleInject(css, ref) {
21
+ if (ref === void 0) ref = {};
22
+ var insertAt = ref.insertAt;
23
+ if (!css || typeof document === 'undefined') {
24
+ return;
25
+ }
26
+ var head = document.head || document.getElementsByTagName('head')[0];
27
+ var style = document.createElement('style');
28
+ style.type = 'text/css';
29
+ if (insertAt === 'top') {
30
+ if (head.firstChild) {
31
+ head.insertBefore(style, head.firstChild);
32
+ } else {
33
+ head.appendChild(style);
34
+ }
35
+ } else {
36
+ head.appendChild(style);
37
+ }
38
+ if (style.styleSheet) {
39
+ style.styleSheet.cssText = css;
40
+ } else {
41
+ style.appendChild(document.createTextNode(css));
42
+ }
43
+ }
44
+
45
+ var css_248z$1 = ".index-module_mobileinput_footertext__jPQ-g a{color:#0f6bff;text-decoration:none}.index-module_mobileinput-seperator__7Ewok{position:relative}.index-module_mobileinput_seperatortext__-KDOp{background:#fff;left:0;margin:0 auto;position:absolute;right:0;text-align:center;top:-10px;width:40px}.index-module_slider_carousel_wrapper__0SuGB{border-top-left-radius:16px;border-top-right-radius:16px;width:100dvw}.index-module_login_form__tpSDz{background-color:#fff;padding-left:16px;padding-right:16px}.index-module_nonUtilsSelector_toast__lvWmB{bottom:12px!important;margin-bottom:12px;margin:0 auto!important;padding:12px 16px!important;width:calc(100% - 48px)!important;z-index:2000}.index-module_login_otp_error__o3y2L{padding-top:4px}.index-module_login_otp_input__L-3P8{font-size:24px!important;font-style:normal;font-weight:600!important;height:56px!important;line-height:28px;padding:auto;text-align:center;width:56px!important}.index-module_footer_text__nkeJv{color:grey!important;font-size:12px!important}.index-module_swiper-custom-pagination__Ma1gV{--swiper-pagination-color:#fff;--swiper-pagination-bullet-inactive-color:#999;--swiper-pagination-bullet-inactive-opacity:1}.index-module_otp_box_wrapper__sM2Ba{margin-right:8px}.index-module_otp_container__1CE4N{display:flex;flex-direction:column;margin-top:24px}.index-module_swiper__r5-8U{height:100%;width:100%}.index-module_swiper__r5-8U .index-module_swiper-slide__Zchn0{height:auto}.index-module_swiper-slide__Zchn0 img{display:block;height:100%;object-fit:fill;width:100%}";
46
+ var styles = {"mobileinput_footertext":"index-module_mobileinput_footertext__jPQ-g","mobileinput-seperator":"index-module_mobileinput-seperator__7Ewok","mobileinput_seperatortext":"index-module_mobileinput_seperatortext__-KDOp","slider_carousel_wrapper":"index-module_slider_carousel_wrapper__0SuGB","login_form":"index-module_login_form__tpSDz","nonUtilsSelector_toast":"index-module_nonUtilsSelector_toast__lvWmB","login_otp_error":"index-module_login_otp_error__o3y2L","login_otp_input":"index-module_login_otp_input__L-3P8","footer_text":"index-module_footer_text__nkeJv","swiper-custom-pagination":"index-module_swiper-custom-pagination__Ma1gV","otp_box_wrapper":"index-module_otp_box_wrapper__sM2Ba","otp_container":"index-module_otp_container__1CE4N","swiper":"index-module_swiper__r5-8U","swiper-slide":"index-module_swiper-slide__Zchn0"};
47
+ styleInject(css_248z$1);
48
+
49
+ var AutoDetectState;
50
+ (function (AutoDetectState) {
51
+ AutoDetectState[AutoDetectState["DETECTING"] = 0] = "DETECTING";
52
+ AutoDetectState[AutoDetectState["FAILED"] = 1] = "FAILED";
53
+ AutoDetectState[AutoDetectState["DETECTED"] = 2] = "DETECTED";
54
+ })(AutoDetectState || (AutoDetectState = {}));
55
+ var OtpInput = function (_a) {
56
+ var mobileNumber = _a.mobileNumber, errorCallout = _a.errorCallout, ravenPayload = _a.ravenPayload, otpInputHeight = _a.otpInputHeight, skipProfileFlow = _a.skipProfileFlow, otpResendDisabled = _a.otpResendDisabled, getOTP = _a.getOTP, setCtaDisabled = _a.setCtaDisabled, setErrorCallout = _a.setErrorCallout, setMobileNumber = _a.setMobileNumber, setShowMobilePage = _a.setShowMobilePage, handleLoginSuccess = _a.handleLoginSuccess, handleLoginFailure = _a.handleLoginFailure;
57
+ var inputRefs = react.useRef(Array(4).fill(null));
58
+ var _b = react.useState(AutoDetectState.DETECTING), autoDetecting = _b[0], setAutoDetecting = _b[1];
59
+ var _c = react.useState(ctPlatformConstants.LOGIN_CONSTANTS.OTP_COUNTDOWN), countdown = _c[0], setCountdown = _c[1];
60
+ var _d = react.useState(''), otp = _d[0], setOtp = _d[1];
61
+ var _f = react.useState(true), countdownEnabled = _f[0], setCountdownEnabled = _f[1];
62
+ var _g = react.useState(false), verifiedOtp = _g[0], setVerifiedOtp = _g[1];
63
+ var _h = react.useState(''), otpErrorMessage = _h[0], setOtpErrorMessage = _h[1];
64
+ var _j = react.useState(true), enableAutoDetect = _j[0], setEnableAutoDetect = _j[1];
65
+ var lastOtpRequest = react.useRef();
66
+ var lastOtpRequestTimeStamp = react.useRef();
67
+ var loginMethod = 'CT';
68
+ react.useEffect(function () {
69
+ autoDetect();
70
+ var eventProps = ctPlatformUtils.getRavenEventProps();
71
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_otp_screen_opened', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
72
+ }, []);
73
+ react.useEffect(function () {
74
+ if (ctPlatformUtils.isIOSApp()) {
75
+ setEnableAutoDetect(false);
76
+ }
77
+ }, []);
78
+ react.useEffect(function () {
79
+ autoDetect();
80
+ }, []);
81
+ react.useEffect(function () {
82
+ if (countdown === 0) {
83
+ setCountdownEnabled(false);
84
+ }
85
+ }, [countdown]);
86
+ react.useEffect(function () {
87
+ var interval;
88
+ if (countdownEnabled && countdown > 0) {
89
+ interval = setInterval(function () {
90
+ setCountdown(function (prevCountdown) { return prevCountdown - 1; });
91
+ }, 1000);
92
+ }
93
+ return function () {
94
+ clearInterval(interval);
95
+ };
96
+ }, [countdownEnabled, countdown]);
97
+ var autoDetect = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
98
+ var otp_1, _e_1;
99
+ return tslib.__generator(this, function (_a) {
100
+ switch (_a.label) {
101
+ case 0:
102
+ _a.trys.push([0, 2, , 3]);
103
+ return [4, ctPlatformUtils.autoReadOtp()];
104
+ case 1:
105
+ otp_1 = _a.sent();
106
+ setOtp(otp_1);
107
+ setAutoDetecting(AutoDetectState.DETECTED);
108
+ if ((otp_1 === null || otp_1 === void 0 ? void 0 : otp_1.length) === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH &&
109
+ handleOtpComplete) {
110
+ handleOtpComplete(otp_1, true);
111
+ }
112
+ return [3, 3];
113
+ case 2:
114
+ _e_1 = _a.sent();
115
+ if (_e_1 === 'NOT_SUPPORTED') {
116
+ setEnableAutoDetect(false);
117
+ }
118
+ return [3, 3];
119
+ case 3: return [2];
120
+ }
121
+ });
122
+ }); }, [enableAutoDetect]);
123
+ var handleOtpValidationError = react.useCallback(function (e) {
124
+ var eventProps = ctPlatformUtils.getRavenEventProps();
125
+ ctPlatformUtils.ravenSDKTrigger('u_login_error', tslib.__assign({ action_name: 'otp_incorrect', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
126
+ var message = e === null || e === void 0 ? void 0 : e.message;
127
+ if (message !== 'OTP_VALIDATE_LIMIT_EXCEEDED') {
128
+ setOtp('');
129
+ }
130
+ inputRefs.current[0].focus();
131
+ inputRefs.current[0].click();
132
+ var messageValue = ctPlatformConstants.LOGIN_CONSTANTS[message];
133
+ var toastMessage = typeof messageValue === 'string'
134
+ ? messageValue
135
+ : ctPlatformConstants.LOGIN_CONSTANTS.INVALID_OTP;
136
+ setOtpErrorMessage(toastMessage);
137
+ }, [inputRefs]);
138
+ var handleOtpComplete = react.useCallback(function (otp, autodetected) { return tslib.__awaiter(void 0, void 0, void 0, function () {
139
+ var eventProps, response, status_1, action, e_1;
140
+ return tslib.__generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ _a.trys.push([0, 2, , 3]);
144
+ eventProps = ctPlatformUtils.getRavenEventProps();
145
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'otp_entered', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: !autodetected ? 'manual_entry' : 'autodetected', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
146
+ if (otp === lastOtpRequest.current &&
147
+ lastOtpRequestTimeStamp.current &&
148
+ lastOtpRequestTimeStamp.current - Date.now() <= 100) {
149
+ return [2];
150
+ }
151
+ lastOtpRequest.current = otp;
152
+ lastOtpRequestTimeStamp.current = Date.now();
153
+ return [4, ctPlatformUtils.validateOtp(mobileNumber, otp)];
154
+ case 1:
155
+ response = _a.sent();
156
+ status_1 = response.status, action = response.action;
157
+ if (Number(status_1) === 200 && !ctPlatformUtils.isEmpty(action)) {
158
+ setVerifiedOtp(true);
159
+ setOtpErrorMessage('');
160
+ ctPlatformUtils.updateNativeOnLogin();
161
+ if (action === 'SIGNUP') {
162
+ if (!skipProfileFlow) {
163
+ window.location.href =
164
+ ctPlatformConstants.NAVIGATION_ROUTES.PERSONAL_DETAILS +
165
+ '?onboardingFlow=true';
166
+ }
167
+ handleLoginSuccess(loginMethod, true);
168
+ }
169
+ else {
170
+ handleLoginSuccess(loginMethod);
171
+ }
172
+ }
173
+ else {
174
+ handleLoginFailure(loginMethod);
175
+ }
176
+ return [3, 3];
177
+ case 2:
178
+ e_1 = _a.sent();
179
+ handleLoginFailure(loginMethod);
180
+ handleOtpValidationError(e_1);
181
+ return [3, 3];
182
+ case 3: return [2];
183
+ }
184
+ });
185
+ }); }, [
186
+ lastOtpRequest,
187
+ lastOtpRequestTimeStamp,
188
+ setVerifiedOtp,
189
+ setAutoDetecting,
190
+ setOtpErrorMessage,
191
+ handleOtpValidationError,
192
+ ]);
193
+ var handleOnPaste = function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
194
+ var clipboardData, pastedArr, pastedString;
195
+ var _a, _b;
196
+ return tslib.__generator(this, function (_c) {
197
+ switch (_c.label) {
198
+ case 0: return [4, navigator.clipboard.readText()];
199
+ case 1:
200
+ clipboardData = _c.sent();
201
+ if (clipboardData && ctPlatformUtils.isNumeric(clipboardData)) {
202
+ pastedArr = clipboardData
203
+ .slice(0, ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH)
204
+ .split('');
205
+ (_a = inputRefs.current[ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH - 1]) === null || _a === void 0 ? void 0 : _a.focus();
206
+ (_b = inputRefs.current[ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH - 1]) === null || _b === void 0 ? void 0 : _b.click();
207
+ pastedString = pastedArr.join('');
208
+ setOtp(pastedString);
209
+ if (pastedString.length === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH) {
210
+ handleOtpComplete(pastedString, false);
211
+ }
212
+ }
213
+ return [2];
214
+ }
215
+ });
216
+ }); };
217
+ var handleInput = react.useCallback(function (event, index) {
218
+ var _a, _b;
219
+ setErrorCallout('');
220
+ var value = event.target.value;
221
+ if (value !== '' && index < inputRefs.current.length - 1) {
222
+ (_a = inputRefs.current[index + 1]) === null || _a === void 0 ? void 0 : _a.focus();
223
+ (_b = inputRefs.current[index + 1]) === null || _b === void 0 ? void 0 : _b.click();
224
+ }
225
+ var inputValues = inputRefs.current.map(function (ref) {
226
+ if (ctPlatformUtils.isHTMLInputElement(ref)) {
227
+ return ref.value;
228
+ }
229
+ return '';
230
+ });
231
+ var otpValue = inputValues.join('').slice(0, 4);
232
+ setOtp(otpValue);
233
+ if (otpValue.length === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH) {
234
+ handleOtpComplete(otpValue, false);
235
+ }
236
+ }, [setOtp, handleOtpComplete]);
237
+ var handleKeyDown = react.useCallback(function (e, index) {
238
+ var _a, _b, _c;
239
+ if (e.key === 'Backspace' &&
240
+ index > 0 &&
241
+ ((_a = inputRefs.current[index]) === null || _a === void 0 ? void 0 : _a.value) === '') {
242
+ e.preventDefault();
243
+ (_b = inputRefs.current[index - 1]) === null || _b === void 0 ? void 0 : _b.focus();
244
+ (_c = inputRefs.current[index - 1]) === null || _c === void 0 ? void 0 : _c.click();
245
+ }
246
+ }, [inputRefs]);
247
+ var onResendOtpClick = react.useCallback(function () {
248
+ setCountdown(ctPlatformConstants.LOGIN_CONSTANTS.OTP_COUNTDOWN);
249
+ setCountdownEnabled(true);
250
+ getOTP(mobileNumber);
251
+ var eventProps = ctPlatformUtils.getRavenEventProps();
252
+ ctPlatformUtils.ravenSDKTrigger('u_login_error', tslib.__assign({ action_name: 'resend_otp_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
253
+ }, [setCountdown, setCountdownEnabled]);
254
+ var onEditCLick = react.useCallback(function () {
255
+ setCtaDisabled(true);
256
+ setShowMobilePage(true);
257
+ setMobileNumber('');
258
+ }, [setShowMobilePage]);
259
+ return (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-column bg-neutral-100', style: { height: otpInputHeight } }, { children: [errorCallout && (jsxRuntime.jsx(ctDesignComponents.AlertCallout, { variant: 'error', textNode: errorCallout, prefixIconNode: jsxRuntime.jsx(ctDesignIcons.InfoIcon, { fill: 'red' }), style: {
260
+ color: '#ffff',
261
+ backgroundColor: '#db201e',
262
+ }, className: 'fs-12' })), jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-bottom' }, { children: [jsxRuntime.jsxs(ctDesignComponents.Typography, tslib.__assign({ variant: 'HM1', color: 'heading' }, { children: [ctPlatformConstants.LOGIN_CONSTANTS.OTP_TEXT, " ", jsxRuntime.jsx("br", {}), mobileNumber] })), jsxRuntime.jsx("div", tslib.__assign({ className: 'pl-2', onClick: onEditCLick }, { children: jsxRuntime.jsx(ctDesignIcons.Edit, {}) }))] })), jsxRuntime.jsxs("div", tslib.__assign({ className: styles.otp_container }, { children: [jsxRuntime.jsx("div", tslib.__assign({ className: 'flex' }, { children: tslib.__spreadArray([], Array(ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH), true).map(function (_, i) { return (jsxRuntime.jsx("div", tslib.__assign({ className: styles.otp_box_wrapper }, { children: jsxRuntime.jsx(ctDesignComponents.FieldV2, { prompt: {
263
+ hasError: !!otpErrorMessage,
264
+ }, type: 'number', placeholder: '', value: otp[i], max: 1, inputMode: 'numeric', className: styles.login_otp_input, variant: 'md', ref: function (ref) {
265
+ if (ref) {
266
+ inputRefs.current[i] = ref;
267
+ }
268
+ }, onKeyDown: function (e) { return handleKeyDown(e, i); }, onChange: function (e) { return handleInput(e, i); }, onPaste: handleOnPaste, autoFocus: i === 0 }) }), i)); }) })), !!otpErrorMessage && (jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'P1', color: 'warning', className: styles.login_otp_error }, { children: otpErrorMessage })))] })), jsxRuntime.jsx(ctDesignComponents.Spacer, { className: 'pt-2' }), autoDetecting === AutoDetectState.DETECTING &&
269
+ !verifiedOtp &&
270
+ enableAutoDetect &&
271
+ countdown >
272
+ ctPlatformConstants.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN && (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle' }, { children: [jsxRuntime.jsx(ctDesignComponents.Spinner, { width: '20px', height: '20px', borderColor: '#11a670', className: 'bg-neutral-900 bc-black' }), jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'B3', className: 'fs-12 fw-500 ml-1 c-neutral-700' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.AUTO_DETECTING_TEXT }))] }))), autoDetecting === AutoDetectState.DETECTING &&
273
+ countdown <= ctPlatformConstants.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN &&
274
+ enableAutoDetect &&
275
+ !verifiedOtp && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex' }, { children: [jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'B3', className: 'fs-12 fw-500 c-neutral-700 ' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.OTP_RESEND_TEXT })), jsxRuntime.jsx(ctDesignComponents.Spacer, { className: 'ml-1' }), otpResendDisabled ? (jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ className: 'color-neutral-200 fw-500', variant: 'B3' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.RESEND_CTA }))) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [countdown === 0 && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ isClickable: true, variant: 'B3', onClick: onResendOtpClick, color: 'link', className: '\n fs-12 fw-500 c-pointer' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.RESEND_CTA })) })), countdown > 0 && (jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ color: 'disabled', variant: 'B3' }, { children: ' Resend (' + countdown + 's)' })))] }))] })) })), !otpErrorMessage && verifiedOtp && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle' }, { children: [jsxRuntime.jsx(ctDesignIcons.CheckCircle, {}), jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'P1', color: 'success', className: 'fs-12' }, { children: autoDetecting === AutoDetectState.DETECTED
276
+ ? ctPlatformConstants.LOGIN_CONSTANTS.AUTO_DETECTED_TEXT
277
+ : ctPlatformConstants.LOGIN_CONSTANTS.VERIFIED_MESSAGE }))] })) })), jsxRuntime.jsx(ctDesignComponents.Spacer, { className: 'mt-24' })] })));
278
+ };
279
+
280
+ var css_248z = ".index-module_loader__63LeU{align-items:center;background-color:hsla(0,0%,100%,.95);bottom:0;display:flex;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:0}.index-module_loader__63LeU.index-module_With-full-opacity__ZSY-U{background-color:#fff}.index-module_loader__content__Q6kJl{max-width:280px;text-align:center}.index-module_loader__spinner__6B3AR{animation:index-module_loader-rotate__efcf3 .8s linear infinite;border:2px solid rgba(51,102,204,.3);border-radius:50%;border-top-color:#36c;display:inline-block;height:30px;margin-bottom:10px;position:relative;width:30px}.index-module_loader__heading__7YZ3N{color:#000;font-size:18px;font-weight:600;margin-bottom:5px}.index-module_loader__text__1QcLi{color:rgba(0,0,0,.8);font-size:16px;line-height:1.5}";
281
+ var Styles = {"loader":"index-module_loader__63LeU","With-full-opacity":"index-module_With-full-opacity__ZSY-U","loader__content":"index-module_loader__content__Q6kJl","loader__spinner":"index-module_loader__spinner__6B3AR","loader-rotate":"index-module_loader-rotate__efcf3","loader__heading":"index-module_loader__heading__7YZ3N","loader__text":"index-module_loader__text__1QcLi"};
282
+ styleInject(css_248z);
283
+
284
+ var Loader = function (_a) {
285
+ var title = _a.title, message = _a.message, className = _a.className;
286
+ return (jsxRuntime.jsx("div", tslib.__assign({ className: "".concat(Styles['utilswrapper'], " utilswrapper") }, { children: jsxRuntime.jsx("div", tslib.__assign({ className: classNames__default.default(Styles['loader'], className) }, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: Styles['loader__content'] }, { children: [jsxRuntime.jsx("div", { className: Styles['loader__spinner'] }), jsxRuntime.jsx("h5", tslib.__assign({ className: Styles['loader__heading'] }, { children: title })), jsxRuntime.jsx("p", tslib.__assign({ className: Styles['loader__text'] }, { children: message }))] })) })) })));
287
+ };
288
+
289
+ var MobileInput = function (_a) {
290
+ var sendingOtp = _a.sendingOtp, ctaDisabled = _a.ctaDisabled, getOTP = _a.getOTP, setErrorCallout = _a.setErrorCallout, errorCallout = _a.errorCallout, mobileNumber = _a.mobileNumber, setMobileInputHeight = _a.setMobileInputHeight, setMobileNumber = _a.setMobileNumber, fallbackUri = _a.fallbackUri, skipProfileFlow = _a.skipProfileFlow, currentPageUri = _a.currentPageUri, ravenPayload = _a.ravenPayload;
291
+ var fkSSOEnabled = react.useState(ctPlatformUtils.isFKSSOEnabled)[0];
292
+ var _b = react.useState(false), fkButtonLoading = _b[0], setFkButtonLoading = _b[1];
293
+ var inputRef = react.useRef(null);
294
+ var mobileViewRef = react.useRef(null);
295
+ react.useEffect(function () {
296
+ if (mobileViewRef.current) {
297
+ var height = mobileViewRef.current.clientHeight;
298
+ setMobileInputHeight(height);
299
+ }
300
+ }, [mobileViewRef.current]);
301
+ react.useEffect(function () {
302
+ var timeout;
303
+ if (inputRef.current) {
304
+ timeout = setTimeout(function () {
305
+ var _a;
306
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
307
+ }, 100);
308
+ }
309
+ return function () {
310
+ clearTimeout(timeout);
311
+ };
312
+ }, []);
313
+ react.useEffect(function () {
314
+ if (ctPlatformUtils.isAndroidApp()) {
315
+ autoDetectMobileNumber();
316
+ }
317
+ }, []);
318
+ var handleFKSSOClick = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
319
+ var eventProps, redirectUrl;
320
+ return tslib.__generator(this, function (_a) {
321
+ switch (_a.label) {
322
+ case 0:
323
+ _a.trys.push([0, 2, , 3]);
324
+ eventProps = ctPlatformUtils.getRavenEventProps();
325
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_with_flipkart_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'fk_sso', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
326
+ setFkButtonLoading(true);
327
+ return [4, ctPlatformUtils.handleFKSSO(fallbackUri, skipProfileFlow
328
+ ? currentPageUri
329
+ : ctPlatformConstants.NAVIGATION_ROUTES.PERSONAL_DETAILS +
330
+ '?onboardingFlow=true', currentPageUri)];
331
+ case 1:
332
+ redirectUrl = _a.sent();
333
+ window.location.href = redirectUrl;
334
+ return [3, 3];
335
+ case 2:
336
+ _a.sent();
337
+ setFkButtonLoading(false);
338
+ return [3, 3];
339
+ case 3: return [2];
340
+ }
341
+ });
342
+ }); }, []);
343
+ var handleInputChange = react.useCallback(function (event, autoDetected) {
344
+ if (autoDetected === void 0) { autoDetected = false; }
345
+ setErrorCallout('');
346
+ var value = event.target.value || '';
347
+ value = value.replace(ctPlatformUtils.MULTI_SPACE, ' ').trimStart();
348
+ setMobileNumber(value);
349
+ var validMobileNo = ctPlatformUtils.isValidMobileNumber(event.target.value);
350
+ if (validMobileNo) {
351
+ getOTP(value);
352
+ var eventProps = ctPlatformUtils.getRavenEventProps();
353
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'get_otp_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'auto_click', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
354
+ if (!autoDetected) {
355
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'phone_number_entered', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'manual_entry', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
356
+ }
357
+ else {
358
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'phone_number_autodetected', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'autodetected', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
359
+ }
360
+ }
361
+ }, [setMobileNumber]);
362
+ var autoDetectMobileNumber = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
363
+ var autoDetectedNumber, simulatedEvent;
364
+ return tslib.__generator(this, function (_a) {
365
+ switch (_a.label) {
366
+ case 0: return [4, ctPlatformUtils.showMobileNumberHint()];
367
+ case 1:
368
+ autoDetectedNumber = _a.sent();
369
+ simulatedEvent = {
370
+ target: {
371
+ value: autoDetectedNumber,
372
+ },
373
+ };
374
+ if (autoDetectedNumber) {
375
+ handleInputChange(simulatedEvent, true);
376
+ }
377
+ return [2];
378
+ }
379
+ });
380
+ }); }, [handleInputChange]);
381
+ var handlePrivacyPolicyClick = react.useCallback(function () {
382
+ var eventProps = ctPlatformUtils.getRavenEventProps();
383
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'policy_click', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
384
+ window.location.href = ctPlatformConstants.NAVIGATION_ROUTES.PRIVACY_POLICY;
385
+ }, []);
386
+ var handleTermsOfUseClick = react.useCallback(function () {
387
+ var eventProps = ctPlatformUtils.getRavenEventProps();
388
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'tnc_click', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
389
+ window.location.href = ctPlatformConstants.NAVIGATION_ROUTES.TERMS;
390
+ }, []);
391
+ return (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-column', ref: mobileViewRef }, { children: [errorCallout && (jsxRuntime.jsx(ctDesignComponents.AlertCallout, { variant: 'error', textNode: errorCallout, prefixIconNode: jsxRuntime.jsx(ctDesignIcons.InfoIcon, { fill: 'red' }), style: {
392
+ color: '#ffff',
393
+ backgroundColor: '#db201e',
394
+ }, className: 'fs-12' })), jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'HM1', color: 'heading', className: 'mb-4 fs-24' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.LOGIN_TO_CT })), jsxRuntime.jsx(ctDesignComponents.PhoneField, { onChange: handleInputChange, value: mobileNumber, placeholder: '', inputMode: 'numeric', ref: inputRef, min: 0, max: 10, autoFocus: true, countryCode: ctPlatformConstants.LOGIN_CONSTANTS.COUNTRY_CODE }), jsxRuntime.jsx(ctDesignComponents.Button, tslib.__assign({ color: 'primary', size: 'medium', minWidth: '160px', disabled: ctaDisabled, loading: sendingOtp, className: 'my-6', onClick: function () { return getOTP(mobileNumber); } }, { children: ctPlatformConstants.LOGIN_CONSTANTS.GET_OTP })), fkSSOEnabled && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", tslib.__assign({ className: 'my-6 p-relative' }, { children: [jsxRuntime.jsx(ctDesignComponents.Divider, {}), jsxRuntime.jsx("span", tslib.__assign({ className: "".concat(styles.mobileinput_seperatortext) }, { children: "or" }))] })), jsxRuntime.jsx(ctDesignComponents.Button, tslib.__assign({ variant: 'outline', size: 'medium', className: 'my-6', loading: fkButtonLoading, onClick: handleFKSSOClick, showLeftIcon: !fkButtonLoading, LeftIcon: jsxRuntime.jsx("img", { src: ctPlatformAssets.FlipkartLogo }) }, { children: ctPlatformConstants.LOGIN_CONSTANTS.FK_LOGIN_CTA }))] })), jsxRuntime.jsxs("div", tslib.__assign({ className: 'pt-8 pb-6' }, { children: [jsxRuntime.jsx(ctDesignComponents.Divider, {}), jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle \n flex-center flex-wrap pt-2' }, { children: [jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'P1', className: styles.footer_text }, { children: ctPlatformConstants.LOGIN_CONSTANTS.FOOTER_TEXT })), jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'P1', color: 'link', className: 'pl-1 fs-12', isClickable: true, onClick: handlePrivacyPolicyClick }, { children: ctPlatformConstants.LOGIN_CONSTANTS.PRIVACY_CTA })), jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ className: 'px-1 fs-12 c-neutral-700', variant: 'P1' }, { children: '& ' })), jsxRuntime.jsx(ctDesignComponents.Typography, tslib.__assign({ variant: 'P1', color: 'link', isClickable: true, onClick: handleTermsOfUseClick, className: 'fs-12' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.TNC_CTA }))] }))] }))] })));
395
+ };
396
+
397
+ const imagePlaceHolderURI =
398
+ // eslint-disable-next-line max-len
399
+ 'data:image/png;base64,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';
400
+ const ImageUrls = [{
401
+ src: 'https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel1.png',
402
+ placeholder: imagePlaceHolderURI
403
+ }, {
404
+ src: 'https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel2.png',
405
+ placeholder: imagePlaceHolderURI
406
+ }, {
407
+ src: 'https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel3.png',
408
+ placeholder: imagePlaceHolderURI
409
+ }];
410
+
411
+ var ImageWithPlaceholder = function (_a) {
412
+ var src = _a.src, placeholderSrc = _a.placeholderSrc, onLoad = _a.onLoad, props = tslib.__rest(_a, ["src", "placeholderSrc", "onLoad"]);
413
+ var _b = react.useState(placeholderSrc || src), imgSrc = _b[0], setImgSrc = _b[1];
414
+ var onLoadRef = react.useRef(onLoad);
415
+ react.useEffect(function () {
416
+ onLoadRef.current = onLoad;
417
+ }, [onLoad]);
418
+ react.useEffect(function () {
419
+ var img = new Image();
420
+ img.onload = function () {
421
+ setImgSrc(src);
422
+ if (onLoadRef.current) {
423
+ onLoadRef.current();
424
+ }
425
+ };
426
+ img.src = src;
427
+ }, [src]);
428
+ return jsxRuntime.jsx("img", tslib.__assign({ src: imgSrc }, props));
429
+ };
430
+
431
+ var CarouselWrapper = function () {
432
+ return (jsxRuntime.jsx("div", tslib.__assign({ className: " o-hidden p-relative ".concat(styles.slider_carousel_wrapper) }, { children: jsxRuntime.jsx(react$1.Swiper, tslib.__assign({ autoplay: true, slidesPerView: 1, navigation: false, loop: true, pagination: { clickable: true }, className: "".concat(styles['swiper'], " ").concat(styles['swiper-custom-pagination']), lazy: {
433
+ loadPrevNextAmount: 1,
434
+ } }, { children: ImageUrls.map(function (item, index) {
435
+ return (jsxRuntime.jsx(react$1.SwiperSlide, tslib.__assign({ className: styles['swiper-slide'] }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: index < 1 ? (jsxRuntime.jsx(ImageWithPlaceholder, { src: item.src, placeholderSrc: item.placeholder, alt: "Slide ".concat(index + 1), rel: 'preload', fetchPriority: 'high' })) : (jsxRuntime.jsx(ImageWithPlaceholder, { src: item.src, placeholderSrc: item.placeholder, alt: "Slide ".concat(index + 1), loading: 'lazy', className: 'lazy' })) }) }), index));
436
+ }) })) })));
437
+ };
438
+
439
+ var LoginModule = function (_a) {
440
+ var fallbackUri = _a.fallbackUri, isDrawerOpen = _a.isDrawerOpen, skipProfileFlow = _a.skipProfileFlow, handleLoginClose = _a.handleLoginClose, onAuthSuccess = _a.onAuthSuccess, onAuthFailure = _a.onAuthFailure, _b = _a.ravenPayload, ravenPayload = _b === void 0 ? {} : _b;
441
+ var _c = react.useState(true), showMobilePage = _c[0], setShowMobilePage = _c[1];
442
+ var _d = react.useState(true), ctaDisabled = _d[0], setCtaDisabled = _d[1];
443
+ var _e = react.useState(false), sendingOtp = _e[0], setSendingOtp = _e[1];
444
+ var _f = react.useState(isDrawerOpen), showLoginForm = _f[0], setShowLoginForm = _f[1];
445
+ var _g = react.useState(''), mobileNumber = _g[0], setMobileNumber = _g[1];
446
+ var _h = react.useState(0), mobileInputHeight = _h[0], setMobileInputHeight = _h[1];
447
+ var _j = react.useState(false), otpResendDisabled = _j[0], setOtpResendDisabled = _j[1];
448
+ var _k = react.useState(''), errorCallout = _k[0], setErrorCallout = _k[1];
449
+ var _l = react.useState(false), showSuccess = _l[0], setShowSuccess = _l[1];
450
+ var _m = react.useState(false), showSigninLoader = _m[0], setShowSigninLoader = _m[1];
451
+ var showSigninLoaderScreen = function () {
452
+ setShowSigninLoader(true);
453
+ };
454
+ react.useEffect(function () {
455
+ if (window) {
456
+ window['showSigninLoaderScreen'] = showSigninLoaderScreen;
457
+ }
458
+ var queryValue = ctPlatformUtils.getQueryParam('fkSSOstatus');
459
+ var loginMethod = 'FK';
460
+ if (queryValue === 'signin') {
461
+ if (ctPlatformUtils.isAndroidApp()) {
462
+ ctPlatformUtils.updateNativeAndroidOnSignIn();
463
+ }
464
+ handleLoginSuccess(loginMethod);
465
+ }
466
+ if (queryValue === 'signup') {
467
+ if (ctPlatformUtils.isAndroidApp()) {
468
+ ctPlatformUtils.updateNativeAndroidOnSignIn();
469
+ }
470
+ handleLoginSuccess(loginMethod, true);
471
+ }
472
+ if (queryValue === 'failure') {
473
+ handleLoginFailure(loginMethod);
474
+ }
475
+ }, []);
476
+ var getOTP = react.useCallback(function (mobileNumber) { return tslib.__awaiter(void 0, void 0, void 0, function () {
477
+ var res, status_1, err_1, message, errorMessage;
478
+ return tslib.__generator(this, function (_a) {
479
+ switch (_a.label) {
480
+ case 0:
481
+ _a.trys.push([0, 2, , 3]);
482
+ setCtaDisabled(false);
483
+ setSendingOtp(true);
484
+ ctPlatformUtils.triggerOTPListener();
485
+ return [4, ctPlatformUtils.sendLoginOtp(mobileNumber)];
486
+ case 1:
487
+ res = _a.sent();
488
+ status_1 = (res || {}).status;
489
+ if (status_1 === 'SUCCESS') {
490
+ setShowMobilePage(false);
491
+ setSendingOtp(false);
492
+ }
493
+ return [3, 3];
494
+ case 2:
495
+ err_1 = _a.sent();
496
+ console.error(err_1);
497
+ message = (err_1 || {}).message;
498
+ setSendingOtp(false);
499
+ errorMessage = message && ctPlatformConstants.LOGIN_CONSTANTS[message];
500
+ if (errorMessage) {
501
+ setErrorCallout(String(errorMessage));
502
+ }
503
+ else {
504
+ setErrorCallout(String(ctPlatformConstants.LOGIN_CONSTANTS.GENERIC_ERROR_MESSAGE));
505
+ }
506
+ if (message === 'OTP_SEND_LIMIT_EXCEEDED') {
507
+ setOtpResendDisabled(true);
508
+ }
509
+ return [3, 3];
510
+ case 3: return [2];
511
+ }
512
+ });
513
+ }); }, [showMobilePage, setShowMobilePage]);
514
+ var handleLoginSuccess = react.useCallback(function (loginMethod, action) {
515
+ var eventProps = ctPlatformUtils.getRavenEventProps();
516
+ ctPlatformUtils.ravenSDKTrigger('u_login_success', tslib.__assign({ action_name: 'login_successful', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', login_new: action ? 'sign_up' : 'sign_in', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
517
+ onAuthSuccess(loginMethod, action);
518
+ if (action && !skipProfileFlow) ;
519
+ else {
520
+ handleDrawerClose();
521
+ setShowSuccess(true);
522
+ }
523
+ }, []);
524
+ var handleLoginFailure = react.useCallback(function (loginMethod) {
525
+ onAuthFailure(loginMethod);
526
+ }, []);
527
+ var handleDrawerClose = function (evt) {
528
+ evt === null || evt === void 0 ? void 0 : evt.stopPropagation();
529
+ setShowLoginForm(false);
530
+ setMobileNumber('');
531
+ setCtaDisabled(true);
532
+ var eventProps = ctPlatformUtils.getRavenEventProps();
533
+ ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_prompt_dismissed', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
534
+ if (handleLoginClose && typeof handleLoginClose === 'function') {
535
+ handleLoginClose();
536
+ }
537
+ };
538
+ react.useEffect(function () {
539
+ if (isDrawerOpen) {
540
+ setShowMobilePage(true);
541
+ setShowLoginForm(true);
542
+ var eventProps = ctPlatformUtils.getRavenEventProps();
543
+ ctPlatformUtils.ravenSDKTrigger('u_login_popup', tslib.__assign({ action_name: 'login_prompt_opened', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
544
+ }
545
+ else {
546
+ setShowLoginForm(false);
547
+ }
548
+ }, [isDrawerOpen]);
549
+ return (jsxRuntime.jsx(ctDesignTheme.ThemeProvider, { children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(ctPlatformDrawer.Drawer, tslib.__assign({ direction: 'bottom', isOpen: showLoginForm, showClose: true, overlay: true, handleClose: handleDrawerClose, onClose: function () { } }, { children: jsxRuntime.jsx("div", tslib.__assign({ className: "".concat(styles['utilswrapper'], " utilswrapper") }, { children: jsxRuntime.jsxs("div", tslib.__assign({ style: {
550
+ maxHeight: 'calc(100dvh - 60px)',
551
+ overflowY: 'auto',
552
+ borderRadius: '16px 16px 0 0',
553
+ } }, { children: [jsxRuntime.jsx(CarouselWrapper, {}), jsxRuntime.jsxs("div", tslib.__assign({ className: styles['login_form'] }, { children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(ctDesignComponents.Spacer, { className: 'pt-6' }) }), showMobilePage ? (jsxRuntime.jsx(MobileInput, { device: 'PWA', ctaDisabled: ctaDisabled, sendingOtp: sendingOtp, getOTP: getOTP, mobileNumber: mobileNumber, setMobileNumber: setMobileNumber, setMobileInputHeight: setMobileInputHeight, fallbackUri: fallbackUri, skipProfileFlow: skipProfileFlow, currentPageUri: ctPlatformUtils.getCurrentPathName, setErrorCallout: setErrorCallout, errorCallout: errorCallout, ravenPayload: ravenPayload })) : (jsxRuntime.jsx(OtpInput, { mobileNumber: mobileNumber, getOTP: getOTP, setCtaDisabled: setCtaDisabled, setShowMobilePage: setShowMobilePage, handleLoginSuccess: handleLoginSuccess, handleLoginFailure: handleLoginFailure, otpInputHeight: mobileInputHeight, setMobileNumber: setMobileNumber, setErrorCallout: setErrorCallout, errorCallout: errorCallout, otpResendDisabled: otpResendDisabled, ravenPayload: ravenPayload, skipProfileFlow: skipProfileFlow }))] }))] })) })) })), showSuccess && (jsxRuntime.jsx(ctDesignComponents.Toast, { text: 'Logged in successfully!', show: showSuccess, className: "".concat(styles.nonUtilsSelector_toast), closeTimeout: 2000 })), showSigninLoader && (jsxRuntime.jsx(Loader, { title: 'Please wait', message: 'Signing in...', className: 'z-2 bg-white' }))] }) }));
554
+ };
555
+
556
+ exports.LoginModule = LoginModule;
557
+ //# sourceMappingURL=ct-platform-login-module.cjs.js.map