@salla.sa/twilight-components 1.0.48 → 1.0.49
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/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-button_7.cjs.entry.js +1 -1
- package/dist/cjs/{salla-search-4aa9e827.js → salla-search-a7147639.js} +21 -10
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-login/salla-login.js +33 -19
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button_7.entry.js +1 -1
- package/dist/esm/{salla-search-9ddf927f.js → salla-search-813732a1.js} +21 -10
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/{p-3a0a7e8a.entry.js → p-4b774cf9.entry.js} +1 -1
- package/dist/twilight-components/p-b8ed7363.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-login/salla-login.d.ts +0 -3
- package/dist/types/components.d.ts +6 -6
- package/package.json +1 -1
- package/dist/twilight-components/p-01128f6b.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[
|
|
17
|
+
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-0b5b5867.js');
|
|
6
6
|
const Helper = require('./Helper-98cc9f18.js');
|
|
7
|
-
const sallaSearch = require('./salla-search-
|
|
7
|
+
const sallaSearch = require('./salla-search-a7147639.js');
|
|
8
8
|
|
|
9
9
|
const sallaButtonCss = "";
|
|
10
10
|
|
|
@@ -8,6 +8,18 @@ const sallaLoginCss = "";
|
|
|
8
8
|
const SallaLogin = class {
|
|
9
9
|
constructor(hostRef) {
|
|
10
10
|
index.registerInstance(this, hostRef);
|
|
11
|
+
/**
|
|
12
|
+
* Does the merchant allow to login using email
|
|
13
|
+
*/
|
|
14
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', true);
|
|
15
|
+
/**
|
|
16
|
+
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
17
|
+
*/
|
|
18
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
19
|
+
/**
|
|
20
|
+
* Does the merchant require registration with email & mobile
|
|
21
|
+
*/
|
|
22
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', false);
|
|
11
23
|
this.regType = 'phone';
|
|
12
24
|
//TODO:: any salla-button, text should updated by this.btn?.setText(newText)
|
|
13
25
|
this.title = salla.lang.get('blocks.header.login');
|
|
@@ -102,6 +114,11 @@ const SallaLogin = class {
|
|
|
102
114
|
//
|
|
103
115
|
});
|
|
104
116
|
salla.event.on('login::show', () => this.show());
|
|
117
|
+
salla.event.on('twilight::initiated', () => {
|
|
118
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', !!this.isEmailAllowed);
|
|
119
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', !!this.isMobileAllowed);
|
|
120
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', !!this.isEmailRequired);
|
|
121
|
+
});
|
|
105
122
|
}
|
|
106
123
|
/**
|
|
107
124
|
* @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
|
|
@@ -127,9 +144,6 @@ const SallaLogin = class {
|
|
|
127
144
|
* Show login component
|
|
128
145
|
*/
|
|
129
146
|
async show() {
|
|
130
|
-
this.isEmailAllowed = this.isEmailAllowed !== undefined ? this.isEmailAllowed : salla.config.get('store.settings.auth.email_allowed', true);
|
|
131
|
-
this.isMobileAllowed = this.isMobileAllowed !== undefined ? this.isMobileAllowed : salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
132
|
-
this.isEmailRequired = this.isEmailRequired !== undefined ? this.isEmailRequired : salla.config.get('store.settings.auth.is_email_required', false);
|
|
133
147
|
if (this.isEmailAllowed && this.isMobileAllowed) {
|
|
134
148
|
this.showTab(this.homeTab);
|
|
135
149
|
}
|
|
@@ -144,13 +158,10 @@ const SallaLogin = class {
|
|
|
144
158
|
showTab(tab, evt) {
|
|
145
159
|
var _a, _b;
|
|
146
160
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
147
|
-
[this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab]
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
setTimeout(() => {
|
|
152
|
-
this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px');
|
|
153
|
-
});
|
|
161
|
+
let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
|
|
162
|
+
tabs.map(el => Helper.Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
|
|
163
|
+
setTimeout(() => tabs.map(el => Helper.Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab)), 200);
|
|
164
|
+
setTimeout(() => this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
|
|
154
165
|
if ([this.mobileTab, this.emailTab].includes(tab)) {
|
|
155
166
|
this.regType = tab === this.mobileTab ? 'phone' : 'email';
|
|
156
167
|
}
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[
|
|
18
|
+
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -13,6 +13,18 @@ import Helper from "../../Helpers/Helper";
|
|
|
13
13
|
*/
|
|
14
14
|
export class SallaLogin {
|
|
15
15
|
constructor() {
|
|
16
|
+
/**
|
|
17
|
+
* Does the merchant allow to login using email
|
|
18
|
+
*/
|
|
19
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', true);
|
|
20
|
+
/**
|
|
21
|
+
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
22
|
+
*/
|
|
23
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
24
|
+
/**
|
|
25
|
+
* Does the merchant require registration with email & mobile
|
|
26
|
+
*/
|
|
27
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', false);
|
|
16
28
|
this.regType = 'phone';
|
|
17
29
|
//TODO:: any salla-button, text should updated by this.btn?.setText(newText)
|
|
18
30
|
this.title = salla.lang.get('blocks.header.login');
|
|
@@ -107,6 +119,11 @@ export class SallaLogin {
|
|
|
107
119
|
//
|
|
108
120
|
});
|
|
109
121
|
salla.event.on('login::show', () => this.show());
|
|
122
|
+
salla.event.on('twilight::initiated', () => {
|
|
123
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', !!this.isEmailAllowed);
|
|
124
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', !!this.isMobileAllowed);
|
|
125
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', !!this.isEmailRequired);
|
|
126
|
+
});
|
|
110
127
|
}
|
|
111
128
|
/**
|
|
112
129
|
* @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
|
|
@@ -132,9 +149,6 @@ export class SallaLogin {
|
|
|
132
149
|
* Show login component
|
|
133
150
|
*/
|
|
134
151
|
async show() {
|
|
135
|
-
this.isEmailAllowed = this.isEmailAllowed !== undefined ? this.isEmailAllowed : salla.config.get('store.settings.auth.email_allowed', true);
|
|
136
|
-
this.isMobileAllowed = this.isMobileAllowed !== undefined ? this.isMobileAllowed : salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
137
|
-
this.isEmailRequired = this.isEmailRequired !== undefined ? this.isEmailRequired : salla.config.get('store.settings.auth.is_email_required', false);
|
|
138
152
|
if (this.isEmailAllowed && this.isMobileAllowed) {
|
|
139
153
|
this.showTab(this.homeTab);
|
|
140
154
|
}
|
|
@@ -149,13 +163,10 @@ export class SallaLogin {
|
|
|
149
163
|
showTab(tab, evt) {
|
|
150
164
|
var _a, _b;
|
|
151
165
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
152
|
-
[this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab]
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
setTimeout(() => {
|
|
157
|
-
this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px');
|
|
158
|
-
});
|
|
166
|
+
let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
|
|
167
|
+
tabs.map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
|
|
168
|
+
setTimeout(() => tabs.map(el => Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab)), 200);
|
|
169
|
+
setTimeout(() => this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
|
|
159
170
|
if ([this.mobileTab, this.emailTab].includes(tab)) {
|
|
160
171
|
this.regType = tab === this.mobileTab ? 'phone' : 'email';
|
|
161
172
|
}
|
|
@@ -248,7 +259,7 @@ export class SallaLogin {
|
|
|
248
259
|
static get properties() { return {
|
|
249
260
|
"isEmailAllowed": {
|
|
250
261
|
"type": "boolean",
|
|
251
|
-
"mutable":
|
|
262
|
+
"mutable": true,
|
|
252
263
|
"complexType": {
|
|
253
264
|
"original": "boolean",
|
|
254
265
|
"resolved": "boolean",
|
|
@@ -258,14 +269,15 @@ export class SallaLogin {
|
|
|
258
269
|
"optional": false,
|
|
259
270
|
"docs": {
|
|
260
271
|
"tags": [],
|
|
261
|
-
"text": "Does the merchant allow to login using email
|
|
272
|
+
"text": "Does the merchant allow to login using email"
|
|
262
273
|
},
|
|
263
274
|
"attribute": "is-email-allowed",
|
|
264
|
-
"reflect": false
|
|
275
|
+
"reflect": false,
|
|
276
|
+
"defaultValue": "salla.config.get('store.settings.auth.email_allowed', true)"
|
|
265
277
|
},
|
|
266
278
|
"isMobileAllowed": {
|
|
267
279
|
"type": "boolean",
|
|
268
|
-
"mutable":
|
|
280
|
+
"mutable": true,
|
|
269
281
|
"complexType": {
|
|
270
282
|
"original": "boolean",
|
|
271
283
|
"resolved": "boolean",
|
|
@@ -275,14 +287,15 @@ export class SallaLogin {
|
|
|
275
287
|
"optional": false,
|
|
276
288
|
"docs": {
|
|
277
289
|
"tags": [],
|
|
278
|
-
"text": "Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false
|
|
290
|
+
"text": "Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`"
|
|
279
291
|
},
|
|
280
292
|
"attribute": "is-mobile-allowed",
|
|
281
|
-
"reflect": false
|
|
293
|
+
"reflect": false,
|
|
294
|
+
"defaultValue": "salla.config.get('store.settings.auth.mobile_allowed', true)"
|
|
282
295
|
},
|
|
283
296
|
"isEmailRequired": {
|
|
284
297
|
"type": "boolean",
|
|
285
|
-
"mutable":
|
|
298
|
+
"mutable": true,
|
|
286
299
|
"complexType": {
|
|
287
300
|
"original": "boolean",
|
|
288
301
|
"resolved": "boolean",
|
|
@@ -292,10 +305,11 @@ export class SallaLogin {
|
|
|
292
305
|
"optional": false,
|
|
293
306
|
"docs": {
|
|
294
307
|
"tags": [],
|
|
295
|
-
"text": "Does the merchant require registration with email & mobile
|
|
308
|
+
"text": "Does the merchant require registration with email & mobile"
|
|
296
309
|
},
|
|
297
310
|
"attribute": "is-email-required",
|
|
298
|
-
"reflect": false
|
|
311
|
+
"reflect": false,
|
|
312
|
+
"defaultValue": "salla.config.get('store.settings.auth.is_email_required', false)"
|
|
299
313
|
}
|
|
300
314
|
}; }
|
|
301
315
|
static get states() { return {
|
package/dist/esm/index.js
CHANGED
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[
|
|
13
|
+
return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-8b97d225.js';
|
|
2
2
|
import { H as Helper } from './Helper-7162a06c.js';
|
|
3
|
-
export { S as salla_login, a as salla_search } from './salla-search-
|
|
3
|
+
export { S as salla_login, a as salla_search } from './salla-search-813732a1.js';
|
|
4
4
|
|
|
5
5
|
const sallaButtonCss = "";
|
|
6
6
|
|
|
@@ -6,6 +6,18 @@ const sallaLoginCss = "";
|
|
|
6
6
|
const SallaLogin = class {
|
|
7
7
|
constructor(hostRef) {
|
|
8
8
|
registerInstance(this, hostRef);
|
|
9
|
+
/**
|
|
10
|
+
* Does the merchant allow to login using email
|
|
11
|
+
*/
|
|
12
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', true);
|
|
13
|
+
/**
|
|
14
|
+
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
15
|
+
*/
|
|
16
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
17
|
+
/**
|
|
18
|
+
* Does the merchant require registration with email & mobile
|
|
19
|
+
*/
|
|
20
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', false);
|
|
9
21
|
this.regType = 'phone';
|
|
10
22
|
//TODO:: any salla-button, text should updated by this.btn?.setText(newText)
|
|
11
23
|
this.title = salla.lang.get('blocks.header.login');
|
|
@@ -100,6 +112,11 @@ const SallaLogin = class {
|
|
|
100
112
|
//
|
|
101
113
|
});
|
|
102
114
|
salla.event.on('login::show', () => this.show());
|
|
115
|
+
salla.event.on('twilight::initiated', () => {
|
|
116
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', !!this.isEmailAllowed);
|
|
117
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', !!this.isMobileAllowed);
|
|
118
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', !!this.isEmailRequired);
|
|
119
|
+
});
|
|
103
120
|
}
|
|
104
121
|
/**
|
|
105
122
|
* @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
|
|
@@ -125,9 +142,6 @@ const SallaLogin = class {
|
|
|
125
142
|
* Show login component
|
|
126
143
|
*/
|
|
127
144
|
async show() {
|
|
128
|
-
this.isEmailAllowed = this.isEmailAllowed !== undefined ? this.isEmailAllowed : salla.config.get('store.settings.auth.email_allowed', true);
|
|
129
|
-
this.isMobileAllowed = this.isMobileAllowed !== undefined ? this.isMobileAllowed : salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
130
|
-
this.isEmailRequired = this.isEmailRequired !== undefined ? this.isEmailRequired : salla.config.get('store.settings.auth.is_email_required', false);
|
|
131
145
|
if (this.isEmailAllowed && this.isMobileAllowed) {
|
|
132
146
|
this.showTab(this.homeTab);
|
|
133
147
|
}
|
|
@@ -142,13 +156,10 @@ const SallaLogin = class {
|
|
|
142
156
|
showTab(tab, evt) {
|
|
143
157
|
var _a, _b;
|
|
144
158
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
145
|
-
[this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab]
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
setTimeout(() => {
|
|
150
|
-
this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px');
|
|
151
|
-
});
|
|
159
|
+
let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
|
|
160
|
+
tabs.map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
|
|
161
|
+
setTimeout(() => tabs.map(el => Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab)), 200);
|
|
162
|
+
setTimeout(() => this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
|
|
152
163
|
if ([this.mobileTab, this.emailTab].includes(tab)) {
|
|
153
164
|
this.regType = tab === this.mobileTab ? 'phone' : 'email';
|
|
154
165
|
}
|
|
@@ -13,5 +13,5 @@ const patchBrowser = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
patchBrowser().then(options => {
|
|
16
|
-
return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[
|
|
16
|
+
return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
17
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{S as SallaLogin,a as SallaSearch}from"./p-
|
|
1
|
+
export{S as SallaLogin,a as SallaSearch}from"./p-b8ed7363.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,h as t,H as s,g as e,c as n}from"./p-cb1c59a2.js";import{H as r}from"./p-ed1c00c5.js";export{S as salla_login,a as salla_search}from"./p-01128f6b.js";const o=class{constructor(t){i(this,t),this.btnStyle="primary",this.loading=!1,this.disabled=!1,this.loaderPosition="after",this.wide=!1,this.hostAttributes={};for(let i=0;i<this.host.attributes.length;i++)this.hostAttributes[this.host.attributes[i].name]=this.host.attributes[i].value;this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-btn btn--has-loading s-button-"+this.btnStyle+(this.wide?" s-button-wide ":"")+" s-button-btn-loader-"+this.loaderPosition+("after"==this.loaderPosition?" s-button-loader-after":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,delete this.hostAttributes["data-on-click"],this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),"center"==this.loaderPosition&&this.text.classList.remove("s-button-hide"),this.host}async setText(i){return this.text.innerHTML=i,this.host}async disable(){this.host.setAttribute("disabled","")}async enable(){this.host.removeAttribute("disabled")}handleVisible(i,t){this.btn.classList.remove("btn-"+t),this.btn.classList.add("btn-"+i)}handleLoading(i){r.toggleElement(this.btn,"btn--is-loading","btn--no-loading",(()=>i))}render(){return t(s,{class:"s-button-wrap"},t("button",Object.assign({ref:i=>this.btn=i,disabled:this.disabled},this.hostAttributes),t("span",{class:{"s-button-text":!0,"s-button-hide":"center"==this.loaderPosition&&this.loading},ref:i=>this.text=i},t("slot",null)),this.loading?t("span",{class:{"s-button-loader":!0,"s-button-loader-start":"start"===this.loaderPosition,"s-button-loader-end":"end"===this.loaderPosition,"s-button-loader-center":"center"===this.loaderPosition}}):""))}get host(){return e(this)}static get watchers(){return{btnStyle:["handleVisible"],loading:["handleLoading"]}}};o.style="";const l=class{constructor(t){var s,a;i(this,t),this.languages=[],this.currencies=[],this.isLoading=!0,this.language=salla.config.get("user.language_code"),this.currency=salla.config.get("user.currency_code"),r.setHost(this.host),salla.event.on("localization::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{var i;this.languagesTitle=salla.lang.get("common.titles.language"),this.currenciesTitle=salla.lang.get("common.titles.currency"),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("common.elements.ok"))})),this.languageSlot=(null===(s=r.getElement('[slot="language"]'))||void 0===s?void 0:s.innerHTML)||'<label class="s-localization-label" for="lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>',this.currencySlot=(null===(a=r.getElement('[slot="currency"]'))||void 0===a?void 0:a.innerHTML)||'<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>'}async show(){return this.modal.show().then((()=>this.getLanguages())).then((()=>this.getCurrencies())).then((()=>this.isLoading=!1))}async hide(){return this.modal.hide()}async getLanguages(){return this.language=this.language||salla.config.get("user.language_code"),this.languages.length>1?null:await salla.config.languages().then((i=>this.languages=i))}async getCurrencies(){return this.currency=this.currency||salla.config.get("user.currency_code"),this.currencies.length>1?null:await salla.config.currencies().then((i=>this.currencies=i))}onChangeCurrency(i){this.currency=i.target.value}onChangeLanguage(i){this.language=i.target.value}async submit(){let i;this.btn.load().then((()=>{if(this.currency){if(this.currency!==salla.config.get("user.currency_code","SAR"))return i=window.location.href,salla.currency.api.change(this.currency)}else salla.log("There is no currency!")})).then((()=>this.language===salla.config.get("user.language_code","ar")||(i=salla.helpers.addParamToUrl("lang",this.language)))).then((()=>this.btn.stop())).then((()=>this.hide())).then((()=>i&&(window.location.href=i)))}render(){return t("salla-modal",{isLoading:this.isLoading,id:"salla-localization",class:"s-hidden",ref:i=>this.modal=i,width:"xs"},this.isLoading?"":t("div",{class:"s-localization-inner"},this.languages.length>1?t("div",{class:"s-localization-section"},t("label",{class:"s-localization-title"},this.languagesTitle),t("div",{class:"s-localization-section-inner"},this.languages.length<6?this.languages.map((i=>t("div",{class:"s-localization-item"},t("input",{class:"s-localization-input",type:"radio",checked:this.language==i.iso_code,onChange:()=>this.language=i.iso_code,name:"language",id:"lang-"+i.code.toLowerCase(),value:i.code}),t("div",{id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,i.name).replace(/\{code\}/g,i.code).replace(/\{country_code\}/g,i.country_code)})))):t("select",{class:"s-localization-select",name:"currency",onChange:i=>this.onChangeLanguage(i)},this.languages.map((i=>t("option",{value:i.code,selected:this.language==i.code},i.name)))))):"",this.currencies.length>1?t("div",{class:"s-localization-section"},t("label",{class:"s-localization-title"},this.currenciesTitle),t("div",{class:"s-localization-section-inner"},this.currencies.length<6?this.currencies.map((i=>t("div",{class:"s-localization-item"},t("input",{class:"s-localization-input",type:"radio",name:"currency",checked:this.currency==i.code,onChange:()=>this.currency=i.code,id:"currency-"+i.code,value:i.code}),t("div",{id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,i.name).replace(/\{code\}/g,i.code).replace(/\{country_code\}/g,i.country_code)})))):t("select",{class:"s-localization-select",name:"currency",onChange:i=>this.onChangeCurrency(i)},this.currencies.map((i=>t("option",{value:i.code,selected:this.currency==i.code},i.name)))))):"",t("salla-button",{wide:!0,ref:i=>this.btn=i,onClick:()=>this.submit()},salla.lang.get("common.elements.ok"))))}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((i=>i.replaceWith(i.firstChild))),this.host.querySelectorAll("#language-slot").forEach((i=>i.replaceWith(i.firstChild)))}get host(){return e(this)}};l.style="";const h=class{constructor(t){i(this,t),this.modalOpened=n(this,"modalOpened",7),this.modalClosed=n(this,"modalClosed",7),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.icon="",this.iconStyle="",this.imageIcon="",r.setHost(this.host),salla.event.on("modal::open",(i=>i.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(i=>i.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title")}handleVisible(i){if(!i)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(i){return this.title=i,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(i){const t=this.host.querySelector(".s-modal-body");r.toggleElement(t,"s-modal-entering","s-modal-leaving",(()=>i)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>i)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>i)),i||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":"error"!=this.iconStyle&&"success"!=this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}iconClasses(){return{[this.icon]:!0,"sicon-alert-engine":!this.icon&&"error"==this.iconStyle&&!this.imageIcon,"sicon-check-circle2":!this.icon&&"success"==this.iconStyle&&!this.imageIcon}}render(){return this.host.id=this.host.id||"salla-modal",t(s,{class:"salla-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:i=>this.overlay=i,onClick:()=>this.closeModal()}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},""),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},this.isLoading?t("div",{class:"s-modal-loader-wrap"},t("span",{class:"s-modal-loader"})):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.title||this.subTitle?t("div",{class:"s-modal-header-inner"},this.iconStyle||this.icon?t("div",{class:this.iconBlockClasses()},t("i",{class:this.iconClasses()})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};h.style="";var u,c=(function(i){var t;t=function(i){return function(){for(var t=[["Afghanistan (افغانستان)","af","93"],["Albania (Shqipëri)","al","355"],["Algeria (الجزائر)","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua and Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia (Հայաստան)","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria (Österreich)","at","43"],["Azerbaijan (Azərbaycan)","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain (البحرين)","bh","973"],["Bangladesh (বাংলাদেশ)","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus (Беларусь)","by","375"],["Belgium (België)","be","32"],["Belize","bz","501"],["Benin (Bénin)","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan (འབྲུག)","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina (Босна и Херцеговина)","ba","387"],["Botswana","bw","267"],["Brazil (Brasil)","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria (България)","bg","359"],["Burkina Faso","bf","226"],["Burundi (Uburundi)","bi","257"],["Cambodia (កម្ពុជា)","kh","855"],["Cameroon (Cameroun)","cm","237"],["Canada","ca","1",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde (Kabu Verdi)","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic (République centrafricaine)","cf","236"],["Chad (Tchad)","td","235"],["Chile","cl","56"],["China (中国)","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros (جزر القمر)","km","269"],["Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)","cd","243"],["Congo (Republic) (Congo-Brazzaville)","cg","242"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["Côte d’Ivoire","ci","225"],["Croatia (Hrvatska)","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599",0],["Cyprus (Κύπρος)","cy","357"],["Czech Republic (Česká republika)","cz","420"],["Denmark (Danmark)","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic (República Dominicana)","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt (مصر)","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea (Guinea Ecuatorial)","gq","240"],["Eritrea","er","291"],["Estonia (Eesti)","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands (Islas Malvinas)","fk","500"],["Faroe Islands (Føroyar)","fo","298"],["Fiji","fj","679"],["Finland (Suomi)","fi","358",0],["France","fr","33"],["French Guiana (Guyane française)","gf","594"],["French Polynesia (Polynésie française)","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia (საქართველო)","ge","995"],["Germany (Deutschland)","de","49"],["Ghana (Gaana)","gh","233"],["Gibraltar","gi","350"],["Greece (Ελλάδα)","gr","30"],["Greenland (Kalaallit Nunaat)","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea (Guinée)","gn","224"],["Guinea-Bissau (Guiné Bissau)","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong (香港)","hk","852"],["Hungary (Magyarország)","hu","36"],["Iceland (Ísland)","is","354"],["India (भारत)","in","91"],["Indonesia","id","62"],["Iran (ایران)","ir","98"],["Iraq (العراق)","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel (ישראל)","il","972"],["Italy (Italia)","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan (日本)","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan (الأردن)","jo","962"],["Kazakhstan (Казахстан)","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait (الكويت)","kw","965"],["Kyrgyzstan (Кыргызстан)","kg","996"],["Laos (ລາວ)","la","856"],["Latvia (Latvija)","lv","371"],["Lebanon (لبنان)","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya (ليبيا)","ly","218"],["Liechtenstein","li","423"],["Lithuania (Lietuva)","lt","370"],["Luxembourg","lu","352"],["Macau (澳門)","mo","853"],["North Macedonia (Македонија)","mk","389"],["Madagascar (Madagasikara)","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania (موريتانيا)","mr","222"],["Mauritius (Moris)","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico (México)","mx","52"],["Micronesia","fm","691"],["Moldova (Republica Moldova)","md","373"],["Monaco","mc","377"],["Mongolia (Монгол)","mn","976"],["Montenegro (Crna Gora)","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco (المغرب)","ma","212",0],["Mozambique (Moçambique)","mz","258"],["Myanmar (Burma) (မြန်မာ)","mm","95"],["Namibia (Namibië)","na","264"],["Nauru","nr","674"],["Nepal (नेपाल)","np","977"],["Netherlands (Nederland)","nl","31"],["New Caledonia (Nouvelle-Calédonie)","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger (Nijar)","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea (조선 민주주의 인민 공화국)","kp","850"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway (Norge)","no","47",0],["Oman (عُمان)","om","968"],["Pakistan (پاکستان)","pk","92"],["Palau","pw","680"],["Palestine (فلسطين)","ps","970"],["Panama (Panamá)","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru (Perú)","pe","51"],["Philippines","ph","63"],["Poland (Polska)","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar (قطر)","qa","974"],["Réunion (La Réunion)","re","262",0],["Romania (România)","ro","40"],["Russia (Россия)","ru","7",0],["Rwanda","rw","250"],["Saint Barthélemy","bl","590",1],["Saint Helena","sh","290"],["Saint Kitts and Nevis","kn","1",18,["869"]],["Saint Lucia","lc","1",19,["758"]],["Saint Martin (Saint-Martin (partie française))","mf","590",2],["Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)","pm","508"],["Saint Vincent and the Grenadines","vc","1",20,["784"]],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé and Príncipe (São Tomé e Príncipe)","st","239"],["Saudi Arabia (المملكة العربية السعودية)","sa","966"],["Senegal (Sénégal)","sn","221"],["Serbia (Србија)","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia (Slovensko)","sk","421"],["Slovenia (Slovenija)","si","386"],["Solomon Islands","sb","677"],["Somalia (Soomaaliya)","so","252"],["South Africa","za","27"],["South Korea (대한민국)","kr","82"],["South Sudan (جنوب السودان)","ss","211"],["Spain (España)","es","34"],["Sri Lanka (ශ්රී ලංකාව)","lk","94"],["Sudan (السودان)","sd","249"],["Suriname","sr","597"],["Svalbard and Jan Mayen","sj","47",1,["79"]],["Sweden (Sverige)","se","46"],["Switzerland (Schweiz)","ch","41"],["Syria (سوريا)","sy","963"],["Taiwan (台灣)","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand (ไทย)","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad and Tobago","tt","1",22,["868"]],["Tunisia (تونس)","tn","216"],["Turkey (Türkiye)","tr","90"],["Turkmenistan","tm","993"],["Turks and Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["U.S. Virgin Islands","vi","1",24,["340"]],["Uganda","ug","256"],["Ukraine (Україна)","ua","380"],["United Arab Emirates (الإمارات العربية المتحدة)","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["Uzbekistan (Oʻzbekiston)","uz","998"],["Vanuatu","vu","678"],["Vatican City (Città del Vaticano)","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam (Việt Nam)","vn","84"],["Wallis and Futuna (Wallis-et-Futuna)","wf","681"],["Western Sahara (الصحراء الغربية)","eh","212",1,["5288","5289"]],["Yemen (اليمن)","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["Åland Islands","ax","358",1,["18"]]],s=0;s<t.length;s++){var a=t[s];t[s]={name:a[0],iso2:a[1],dialCode:a[2],priority:a[3]||0,areaCodes:a[4]||null}}function e(i,t){for(var s=0;s<t.length;s++){var a=t[s];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(i,a.key,a)}}var n={getInstance:function(i){var t=i.getAttribute("data-intl-tel-input-id");return window.intlTelInputGlobals.instances[t]},instances:{},documentReady:function(){return"complete"===document.readyState}};"object"==typeof window&&(window.intlTelInputGlobals=n);var r=0,o={allowDropdown:!0,autoHideDialCode:!0,autoPlaceholder:"polite",customContainer:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],formatOnDisplay:!0,geoIpLookup:null,hiddenInput:"",initialCountry:"",localizedCountries:null,nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:["us","gb"],separateDialCode:!1,utilsScript:""},l=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],h=function(i,t){for(var s=Object.keys(i),a=0;a<s.length;a++)t(s[a],i[s[a]])},u=function(i){h(window.intlTelInputGlobals.instances,(function(t){window.intlTelInputGlobals.instances[t][i]()}))},c=function(){function s(i,t){var a=this;!function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),this.id=r++,this.telInput=i,this.activeItem=null,this.highlightedItem=null;var e=t||{};this.options={},h(o,(function(i,t){a.options[i]=e.hasOwnProperty(i)?e[i]:t})),this.hadInitialPlaceholder=Boolean(i.getAttribute("placeholder"))}var a,n;return a=s,(n=[{key:"_init",value:function(){var i=this;if(this.options.nationalMode&&(this.options.autoHideDialCode=!1),this.options.separateDialCode&&(this.options.autoHideDialCode=this.options.nationalMode=!1),this.isMobile=/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),this.isMobile&&(document.body.classList.add("iti-mobile"),this.options.dropdownContainer||(this.options.dropdownContainer=document.body)),"undefined"!=typeof Promise){var t=new Promise((function(t,s){i.resolveAutoCountryPromise=t,i.rejectAutoCountryPromise=s})),s=new Promise((function(t,s){i.resolveUtilsScriptPromise=t,i.rejectUtilsScriptPromise=s}));this.promise=Promise.all([t,s])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processCountryCodes(),this._processPreferredCountries(),this.options.localizedCountries&&this._translateCountriesByLocale(),(this.options.onlyCountries.length||this.options.localizedCountries)&&this.countries.sort(this._countryNameSort)}},{key:"_addCountryCode",value:function(t,s,a){s.length>this.countryCodeMaxLen&&(this.countryCodeMaxLen=s.length),this.countryCodes.hasOwnProperty(s)||(this.countryCodes[s]=[]);for(var e=0;e<this.countryCodes[s].length;e++)if(this.countryCodes[s][e]===t)return;this.countryCodes[s][a!==i?a:this.countryCodes[s].length]=t}},{key:"_processAllCountries",value:function(){if(this.options.onlyCountries.length){var i=this.options.onlyCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(t){return i.indexOf(t.iso2)>-1}))}else if(this.options.excludeCountries.length){var s=this.options.excludeCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(i){return-1===s.indexOf(i.iso2)}))}else this.countries=t}},{key:"_translateCountriesByLocale",value:function(){for(var i=0;i<this.countries.length;i++){var t=this.countries[i].iso2.toLowerCase();this.options.localizedCountries.hasOwnProperty(t)&&(this.countries[i].name=this.options.localizedCountries[t])}}},{key:"_countryNameSort",value:function(i,t){return i.name.localeCompare(t.name)}},{key:"_processCountryCodes",value:function(){this.countryCodeMaxLen=0,this.dialCodes={},this.countryCodes={};for(var i=0;i<this.countries.length;i++){var t=this.countries[i];this.dialCodes[t.dialCode]||(this.dialCodes[t.dialCode]=!0),this._addCountryCode(t.iso2,t.dialCode,t.priority)}for(var s=0;s<this.countries.length;s++){var a=this.countries[s];if(a.areaCodes)for(var e=this.countryCodes[a.dialCode][0],n=0;n<a.areaCodes.length;n++){for(var r=a.areaCodes[n],o=1;o<r.length;o++){var l=a.dialCode+r.substr(0,o);this._addCountryCode(e,l),this._addCountryCode(a.iso2,l)}this._addCountryCode(a.iso2,a.dialCode+r)}}}},{key:"_processPreferredCountries",value:function(){this.preferredCountries=[];for(var i=0;i<this.options.preferredCountries.length;i++){var t=this.options.preferredCountries[i].toLowerCase(),s=this._getCountryData(t,!1,!0);s&&this.preferredCountries.push(s)}}},{key:"_createEl",value:function(i,t,s){var a=document.createElement(i);return t&&h(t,(function(i,t){return a.setAttribute(i,t)})),s&&s.appendChild(a),a}},{key:"_generateMarkup",value:function(){this.telInput.hasAttribute("autocomplete")||this.telInput.form&&this.telInput.form.hasAttribute("autocomplete")||this.telInput.setAttribute("autocomplete","off");var i="iti";this.options.allowDropdown&&(i+=" iti--allow-dropdown"),this.options.separateDialCode&&(i+=" iti--separate-dial-code"),this.options.customContainer&&(i+=" ",i+=this.options.customContainer);var t=this._createEl("div",{class:i});if(this.telInput.parentNode.insertBefore(t,this.telInput),this.flagsContainer=this._createEl("div",{class:"iti__flag-container"},t),t.appendChild(this.telInput),this.selectedFlag=this._createEl("div",{class:"iti__selected-flag",role:"combobox","aria-controls":"iti-".concat(this.id,"__country-listbox"),"aria-owns":"iti-".concat(this.id,"__country-listbox"),"aria-expanded":"false"},this.flagsContainer),this.selectedFlagInner=this._createEl("div",{class:"iti__flag"},this.selectedFlag),this.options.separateDialCode&&(this.selectedDialCode=this._createEl("div",{class:"iti__selected-dial-code"},this.selectedFlag)),this.options.allowDropdown&&(this.selectedFlag.setAttribute("tabindex","0"),this.dropdownArrow=this._createEl("div",{class:"iti__arrow"},this.selectedFlag),this.countryList=this._createEl("ul",{class:"iti__country-list iti__hide",id:"iti-".concat(this.id,"__country-listbox"),role:"listbox","aria-label":"List of countries"}),this.preferredCountries.length&&(this._appendListItems(this.preferredCountries,"iti__preferred",!0),this._createEl("li",{class:"iti__divider",role:"separator","aria-disabled":"true"},this.countryList)),this._appendListItems(this.countries,"iti__standard"),this.options.dropdownContainer?(this.dropdown=this._createEl("div",{class:"iti iti--container"}),this.dropdown.appendChild(this.countryList)):this.flagsContainer.appendChild(this.countryList)),this.options.hiddenInput){var s=this.options.hiddenInput,a=this.telInput.getAttribute("name");if(a){var e=a.lastIndexOf("[");-1!==e&&(s="".concat(a.substr(0,e),"[").concat(s,"]"))}this.hiddenInput=this._createEl("input",{type:"hidden",name:s}),t.appendChild(this.hiddenInput)}}},{key:"_appendListItems",value:function(i,t,s){for(var a="",e=0;e<i.length;e++){var n=i[e],r=s?"-preferred":"";a+="<li class='iti__country ".concat(t,"' tabIndex='-1' id='iti-").concat(this.id,"__item-").concat(n.iso2).concat(r,"' role='option' data-dial-code='").concat(n.dialCode,"' data-country-code='").concat(n.iso2,"' aria-selected='false'>"),a+="<div class='iti__flag-box'><div class='iti__flag iti__".concat(n.iso2,"'></div></div>"),a+="<span class='iti__country-name'>".concat(n.name,"</span>"),a+="<span class='iti__dial-code'>+".concat(n.dialCode,"</span>"),a+="</li>"}this.countryList.insertAdjacentHTML("beforeend",a)}},{key:"_setInitialState",value:function(){var i=this.telInput.getAttribute("value"),t=this.telInput.value,s=!i||"+"!==i.charAt(0)||t&&"+"===t.charAt(0)?t:i,a=this._getDialCode(s),e=this._isRegionlessNanp(s),n=this.options,r=n.initialCountry,o=n.nationalMode,l=n.autoHideDialCode,h=n.separateDialCode;a&&!e?this._updateFlagFromNumber(s):"auto"!==r&&(r?this._setFlag(r.toLowerCase()):a&&e?this._setFlag("us"):(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,s||this._setFlag(this.defaultCountry)),s||o||l||h||(this.telInput.value="+".concat(this.selectedCountryData.dialCode))),s&&this._updateValFromNumber(s)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoHideDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var i=this;this._handleHiddenInputSubmit=function(){i.hiddenInput.value=i.getNumber()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_getClosestLabel",value:function(){for(var i=this.telInput;i&&"LABEL"!==i.tagName;)i=i.parentNode;return i}},{key:"_initDropdownListeners",value:function(){var i=this;this._handleLabelClick=function(t){i.countryList.classList.contains("iti__hide")?i.telInput.focus():t.preventDefault()};var t=this._getClosestLabel();t&&t.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){!i.countryList.classList.contains("iti__hide")||i.telInput.disabled||i.telInput.readOnly||i._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(t){i.countryList.classList.contains("iti__hide")&&-1!==["ArrowUp","Up","ArrowDown","Down"," ","Enter"].indexOf(t.key)&&(t.preventDefault(),t.stopPropagation(),i._showDropdown()),"Tab"===t.key&&i._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var i=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",(function(){window.intlTelInputGlobals.loadUtils(i.options.utilsScript)})):this.resolveUtilsScriptPromise(),"auto"===this.options.initialCountry?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.options.geoIpLookup&&this.options.geoIpLookup((function(i){window.intlTelInputGlobals.autoCountry=i.toLowerCase(),setTimeout((function(){return u("handleAutoCountry")}))}),(function(){return u("rejectAutoCountryPromise")})))}},{key:"_initKeyListeners",value:function(){var i=this;this._handleKeyupEvent=function(){i._updateFlagFromNumber(i.telInput.value)&&i._triggerCountryChange()},this.telInput.addEventListener("keyup",this._handleKeyupEvent),this._handleClipboardEvent=function(){setTimeout(i._handleKeyupEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_cap",value:function(i){var t=this.telInput.getAttribute("maxlength");return t&&i.length>t?i.substr(0,t):i}},{key:"_initBlurListeners",value:function(){var i=this;this._handleSubmitOrBlurEvent=function(){i._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if("+"===this.telInput.value.charAt(0)){var i=this._getNumeric(this.telInput.value);i&&this.selectedCountryData.dialCode!==i||(this.telInput.value="")}}},{key:"_getNumeric",value:function(i){return i.replace(/\D/g,"")}},{key:"_trigger",value:function(i){var t=document.createEvent("Event");t.initEvent(i,!0,!0),this.telInput.dispatchEvent(t)}},{key:"_showDropdown",value:function(){this.countryList.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0)),this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(i,t,s){s&&!i.classList.contains(t)?i.classList.add(t):!s&&i.classList.contains(t)&&i.classList.remove(t)}},{key:"_setDropdownPosition",value:function(){var i=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.isMobile){var t=this.telInput.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,a=t.top+s,e=this.countryList.offsetHeight,n=a+this.telInput.offsetHeight+e<s+window.innerHeight,r=a-e>s;this._toggleClass(this.countryList,"iti__country-list--dropup",!n&&r),this.options.dropdownContainer&&(this.dropdown.style.top="".concat(a+(!n&&r?0:this.telInput.offsetHeight),"px"),this.dropdown.style.left="".concat(t.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return i._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll))}}},{key:"_getClosestListItem",value:function(i){for(var t=i;t&&t!==this.countryList&&!t.classList.contains("iti__country");)t=t.parentNode;return t===this.countryList?null:t}},{key:"_bindDropdownListeners",value:function(){var i=this;this._handleMouseoverCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._highlightListItem(s,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._selectListItem(s)},this.countryList.addEventListener("click",this._handleClickCountryList);var t=!0;this._handleClickOffToClose=function(){t||i._closeDropdown(),t=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var s="",a=null;this._handleKeydownOnDropdown=function(t){t.preventDefault(),"ArrowUp"===t.key||"Up"===t.key||"ArrowDown"===t.key||"Down"===t.key?i._handleUpDownKey(t.key):"Enter"===t.key?i._handleEnterKey():"Escape"===t.key?i._closeDropdown():/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(t.key)&&(a&&clearTimeout(a),s+=t.key.toLowerCase(),i._searchForCountry(s),a=setTimeout((function(){s=""}),1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown)}},{key:"_handleUpDownKey",value:function(i){var t="ArrowUp"===i||"Up"===i?this.highlightedItem.previousElementSibling:this.highlightedItem.nextElementSibling;t&&(t.classList.contains("iti__divider")&&(t="ArrowUp"===i||"Up"===i?t.previousElementSibling:t.nextElementSibling),this._highlightListItem(t,!0))}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(i){for(var t=0;t<this.countries.length;t++)if(this._startsWith(this.countries[t].name,i)){var s=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(this.countries[t].iso2));this._highlightListItem(s,!1),this._scrollTo(s,!0);break}}},{key:"_startsWith",value:function(i,t){return i.substr(0,t.length).toLowerCase()===t}},{key:"_updateValFromNumber",value:function(i){var t=i;if(this.options.formatOnDisplay&&window.intlTelInputUtils&&this.selectedCountryData){var s=!this.options.separateDialCode&&(this.options.nationalMode||"+"!==t.charAt(0)),a=intlTelInputUtils.numberFormat;t=intlTelInputUtils.formatNumber(t,this.selectedCountryData.iso2,s?a.NATIONAL:a.INTERNATIONAL)}t=this._beforeSetNumber(t),this.telInput.value=t}},{key:"_updateFlagFromNumber",value:function(i){var t=i,s=this.selectedCountryData.dialCode;t&&this.options.nationalMode&&"1"===s&&"+"!==t.charAt(0)&&("1"!==t.charAt(0)&&(t="1".concat(t)),t="+".concat(t)),this.options.separateDialCode&&s&&"+"!==t.charAt(0)&&(t="+".concat(s).concat(t));var a=this._getDialCode(t,!0),e=this._getNumeric(t),n=null;if(a){var r=this.countryCodes[this._getNumeric(a)],o=-1!==r.indexOf(this.selectedCountryData.iso2)&&e.length<=a.length-1;if(!("1"===s&&this._isRegionlessNanp(e)||o))for(var l=0;l<r.length;l++)if(r[l]){n=r[l];break}}else"+"===t.charAt(0)&&e.length?n="":t&&"+"!==t||(n=this.defaultCountry);return null!==n&&this._setFlag(n)}},{key:"_isRegionlessNanp",value:function(i){var t=this._getNumeric(i);if("1"===t.charAt(0)){var s=t.substr(1,3);return-1!==l.indexOf(s)}return!1}},{key:"_highlightListItem",value:function(i,t){var s=this.highlightedItem;s&&s.classList.remove("iti__highlight"),this.highlightedItem=i,this.highlightedItem.classList.add("iti__highlight"),t&&this.highlightedItem.focus()}},{key:"_getCountryData",value:function(i,s,a){for(var e=s?t:this.countries,n=0;n<e.length;n++)if(e[n].iso2===i)return e[n];if(a)return null;throw new Error("No country data for '".concat(i,"'"))}},{key:"_setFlag",value:function(i){var t=this.selectedCountryData.iso2?this.selectedCountryData:{};this.selectedCountryData=i?this._getCountryData(i,!1,!1):{},this.selectedCountryData.iso2&&(this.defaultCountry=this.selectedCountryData.iso2),this.selectedFlagInner.setAttribute("class","iti__flag iti__".concat(i));var s=i?"".concat(this.selectedCountryData.name,": +").concat(this.selectedCountryData.dialCode):"Unknown";if(this.selectedFlag.setAttribute("title",s),this.options.separateDialCode){var a=this.selectedCountryData.dialCode?"+".concat(this.selectedCountryData.dialCode):"";this.selectedDialCode.innerHTML=a;var e=this.selectedFlag.offsetWidth||this._getHiddenSelectedFlagWidth();this.telInput.style.paddingLeft="".concat(e+6,"px")}if(this._updatePlaceholder(),this.options.allowDropdown){var n=this.activeItem;if(n&&(n.classList.remove("iti__active"),n.setAttribute("aria-selected","false")),i){var r=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i,"-preferred"))||this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i));r.setAttribute("aria-selected","true"),r.classList.add("iti__active"),this.activeItem=r,this.selectedFlag.setAttribute("aria-activedescendant",r.getAttribute("id"))}}return t.iso2!==i}},{key:"_getHiddenSelectedFlagWidth",value:function(){var i=this.telInput.parentNode.cloneNode();i.style.visibility="hidden",document.body.appendChild(i);var t=this.flagsContainer.cloneNode();i.appendChild(t);var s=this.selectedFlag.cloneNode(!0);t.appendChild(s);var a=s.offsetWidth;return i.parentNode.removeChild(i),a}},{key:"_updatePlaceholder",value:function(){if(window.intlTelInputUtils&&("aggressive"===this.options.autoPlaceholder||!this.hadInitialPlaceholder&&"polite"===this.options.autoPlaceholder)){var i=intlTelInputUtils.numberType[this.options.placeholderNumberType],t=this.selectedCountryData.iso2?intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2,this.options.nationalMode,i):"";t=this._beforeSetNumber(t),"function"==typeof this.options.customPlaceholder&&(t=this.options.customPlaceholder(t,this.selectedCountryData)),this.telInput.setAttribute("placeholder",t)}}},{key:"_selectListItem",value:function(i){var t=this._setFlag(i.getAttribute("data-country-code"));this._closeDropdown(),this._updateDialCode(i.getAttribute("data-dial-code"),!0),this.telInput.focus();var s=this.telInput.value.length;this.telInput.setSelectionRange(s,s),t&&this._triggerCountryChange()}},{key:"_closeDropdown",value:function(){this.countryList.classList.add("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","false"),this.dropdownArrow.classList.remove("iti__arrow--up"),document.removeEventListener("keydown",this._handleKeydownOnDropdown),document.documentElement.removeEventListener("click",this._handleClickOffToClose),this.countryList.removeEventListener("mouseover",this._handleMouseoverCountryList),this.countryList.removeEventListener("click",this._handleClickCountryList),this.options.dropdownContainer&&(this.isMobile||window.removeEventListener("scroll",this._handleWindowScroll),this.dropdown.parentNode&&this.dropdown.parentNode.removeChild(this.dropdown)),this._trigger("close:countrydropdown")}},{key:"_scrollTo",value:function(i,t){var s=this.countryList,a=window.pageYOffset||document.documentElement.scrollTop,e=s.offsetHeight,n=s.getBoundingClientRect().top+a,r=n+e,o=i.offsetHeight,l=i.getBoundingClientRect().top+a,h=l+o,u=l-n+s.scrollTop,c=e/2-o/2;l<n?(t&&(u-=c),s.scrollTop=u):h>r&&(t&&(u+=c),s.scrollTop=u-(e-o))}},{key:"_updateDialCode",value:function(i,t){var s,a=this.telInput.value,e="+".concat(i);if("+"===a.charAt(0)){var n=this._getDialCode(a);s=n?a.replace(n,e):e}else{if(this.options.nationalMode||this.options.separateDialCode)return;if(a)s=e+a;else{if(!t&&this.options.autoHideDialCode)return;s=e}}this.telInput.value=s}},{key:"_getDialCode",value:function(i,t){var s="";if("+"===i.charAt(0))for(var a="",e=0;e<i.length;e++){var n=i.charAt(e);if(!isNaN(parseInt(n,10))){if(a+=n,t)this.countryCodes[a]&&(s=i.substr(0,e+1));else if(this.dialCodes[a]){s=i.substr(0,e+1);break}if(a.length===this.countryCodeMaxLen)break}}return s}},{key:"_getFullNumber",value:function(){var i=this.telInput.value.trim(),t=this.selectedCountryData.dialCode,s=this._getNumeric(i);return(this.options.separateDialCode&&"+"!==i.charAt(0)&&t&&s?"+".concat(t):"")+i}},{key:"_beforeSetNumber",value:function(i){var t=i;if(this.options.separateDialCode){var s=this._getDialCode(t);s&&(s="+".concat(this.selectedCountryData.dialCode),t=t.substr(" "===t[s.length]||"-"===t[s.length]?s.length+1:s.length))}return this._cap(t)}},{key:"_triggerCountryChange",value:function(){this._trigger("countrychange")}},{key:"handleAutoCountry",value:function(){"auto"===this.options.initialCountry&&(this.defaultCountry=window.intlTelInputGlobals.autoCountry,this.telInput.value||this.setCountry(this.defaultCountry),this.resolveAutoCountryPromise())}},{key:"handleUtils",value:function(){window.intlTelInputUtils&&(this.telInput.value&&this._updateValFromNumber(this.telInput.value),this._updatePlaceholder()),this.resolveUtilsScriptPromise()}},{key:"destroy",value:function(){var i=this.telInput.form;if(this.options.allowDropdown){this._closeDropdown(),this.selectedFlag.removeEventListener("click",this._handleClickSelectedFlag),this.flagsContainer.removeEventListener("keydown",this._handleFlagsContainerKeydown);var t=this._getClosestLabel();t&&t.removeEventListener("click",this._handleLabelClick)}this.hiddenInput&&i&&i.removeEventListener("submit",this._handleHiddenInputSubmit),this.options.autoHideDialCode&&(i&&i.removeEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.removeEventListener("blur",this._handleSubmitOrBlurEvent)),this.telInput.removeEventListener("keyup",this._handleKeyupEvent),this.telInput.removeEventListener("cut",this._handleClipboardEvent),this.telInput.removeEventListener("paste",this._handleClipboardEvent),this.telInput.removeAttribute("data-intl-tel-input-id");var s=this.telInput.parentNode;s.parentNode.insertBefore(this.telInput,s),s.parentNode.removeChild(s),delete window.intlTelInputGlobals.instances[this.id]}},{key:"getExtension",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getExtension(this._getFullNumber(),this.selectedCountryData.iso2):""}},{key:"getNumber",value:function(i){if(window.intlTelInputUtils){var t=this.selectedCountryData.iso2;return intlTelInputUtils.formatNumber(this._getFullNumber(),t,i)}return""}},{key:"getNumberType",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getNumberType(this._getFullNumber(),this.selectedCountryData.iso2):-99}},{key:"getSelectedCountryData",value:function(){return this.selectedCountryData}},{key:"getValidationError",value:function(){if(window.intlTelInputUtils){var i=this.selectedCountryData.iso2;return intlTelInputUtils.getValidationError(this._getFullNumber(),i)}return-99}},{key:"isValidNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isValidNumber(i,this.options.nationalMode?this.selectedCountryData.iso2:""):null}},{key:"setCountry",value:function(i){var t=i.toLowerCase();this.selectedFlagInner.classList.contains("iti__".concat(t))||(this._setFlag(t),this._updateDialCode(this.selectedCountryData.dialCode,!1),this._triggerCountryChange())}},{key:"setNumber",value:function(i){var t=this._updateFlagFromNumber(i);this._updateValFromNumber(i),t&&this._triggerCountryChange()}},{key:"setPlaceholderNumberType",value:function(i){this.options.placeholderNumberType=i,this._updatePlaceholder()}}])&&e(a.prototype,n),s}();n.getCountryData=function(){return t};var d=function(i,t,s){var a=document.createElement("script");a.onload=function(){u("handleUtils"),t&&t()},a.onerror=function(){u("rejectUtilsScriptPromise"),s&&s()},a.className="iti-load-utils",a.async=!0,a.src=i,document.body.appendChild(a)};return n.loadUtils=function(i){if(!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript){if(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,"undefined"!=typeof Promise)return new Promise((function(t,s){return d(i,t,s)}));d(i)}return null},n.defaults=o,n.version="17.0.15",function(i,t){var s=new c(i,t);return s._init(),i.setAttribute("data-intl-tel-input-id",s.id),window.intlTelInputGlobals.instances[s.id]=s,s}}()},i.exports?i.exports=t():window.intlTelInput=t()}(u={path:undefined,exports:{},require:function(){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}}),u.exports);const d=class{constructor(t){i(this,t),this.enterClicked=n(this,"enterClicked",7),this.countryCode=salla.config.get("user.country_code","SA"),this.countryKey="+966",this.countryCodeLabel=salla.lang.get("common.country_code"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.tooShort=salla.lang.get("common.errors.too_short",{attribute:this.mobileLabel}),this.tooLong=salla.lang.get("common.errors.too_long",{attribute:this.mobileLabel}),this.invalidCountryCode=salla.lang.get("common.errors.invalid_value",{attribute:this.countryCodeLabel}),this.invalidNumber=salla.lang.get("common.errors.invalid_value",{attribute:this.mobileLabel}),this.errorMap=[this.invalidNumber,this.invalidCountryCode,this.tooShort,this.tooLong,this.invalidNumber],r.setHost(this.host),salla.event.on("languages::translations.loaded",(()=>{this.mobileLabel=salla.lang.get("common.elements.mobile"),this.countryCodeLabel=salla.lang.get("common.country_code"),this.invalidNumber=salla.lang.get("common.errors.invalid_value",{attribute:this.mobileLabel}),this.invalidCountryCode=salla.lang.get("common.errors.invalid_value",{attribute:this.countryCodeLabel}),this.tooShort=salla.lang.get("common.errors.too_short",{attribute:this.mobileLabel}),this.tooLong=salla.lang.get("common.errors.too_long",{attribute:this.mobileLabel}),this.mobileRequired=salla.lang.get("common.errors.field_required",{attribute:this.mobileLabel}),this.errorMap=[this.invalidNumber,this.invalidCountryCode,this.tooShort,this.tooLong,this.invalidNumber]}))}async getValues(){return{mobile:this.mobile=this.phoneInput.value,countryCode:this.countryCode=this.countryCodeInput.value,countryKey:this.countryKey=this.countryKeyInput.value}}async isValid(){if(this.reset(),this.iti.isValidNumber())return!0;if(!this.phoneInput.value.trim())return this.phoneInput.classList.add("s-has-error"),void(this.errorMsg.innerText=this.mobileRequired||"");this.phoneInput.classList.add("s-has-error");let i=this.iti.getValidationError();return this.errorMsg.innerText=this.errorMap[i]||"",!1}initTelInput(){salla.helpers.digitsOnly(this.phoneInput),this.iti=c(this.phoneInput,{initialCountry:this.countryCode||"sa",preferredCountries:["sa","ae","kw","bh","qa","iq","om","ye","eg","jo","sy","ps","sd","lb","dz","tn","ma","ly"],formatOnDisplay:!1,separateDialCode:!0,autoPlaceholder:"aggressive",utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.min.js"}),this.phoneInput.addEventListener("countrychange",(()=>{let i=this.iti.getSelectedCountryData();this.host.querySelectorAll(".country_code").forEach((t=>t.value=i.iso2.toUpperCase())),this.host.querySelectorAll(".country_key").forEach((t=>{t.value=("+"+i.dialCode).replace("++","+")}))})),this.phoneInput.addEventListener("blur",(()=>this.isValid())),this.phoneInput.addEventListener("input",(i=>{salla.helpers.digitsOnly(i.target),this.reset()}))}reset(){this.phoneInput.classList.remove("s-has-error"),this.errorMsg.innerHTML=""}render(){return t(s,{id:"s-tel-input"},t("input",{type:"tel",name:"mobile",value:this.mobile,ref:i=>this.phoneInput=i,class:"s-tel-input-control tel-input s-ltr"}),t("span",{class:"s-tel-input-error-msg",ref:i=>this.errorMsg=i}),t("input",{type:"hidden",name:"country_code",value:this.countryCode,ref:i=>this.countryCodeInput=i,class:"country_code"}),t("input",{type:"hidden",name:"country_key",value:this.countryKey,ref:i=>this.countryKeyInput=i,class:"country_key"}))}componentDidLoad(){this.initTelInput()}get host(){return e(this)}};d.style="";const m=class{constructor(t){i(this,t),this.verified=n(this,"verified",7),this.initiated=!1,this.by="sms",this.autoReload=!0,r.setHost(this.host),this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(i=>{this.url="profile/verify-mobile",this.show(i)})),salla.event.on("languages::translations.loaded",(()=>{var i;this.title=salla.lang.get("pages.profile.verify_title"),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("pages.profile.verify"))}))}async getCode(){return this.code.value}async show(i){var t;this.data=i,this.resendTimer(),this.otpInputs=this.host.querySelectorAll(".s-verify-modal-input"),this.initiated||(r.on("input",".s-verify-modal-input",(i=>salla.helpers.digitsOnly(i.target))),r.onKeyUp(".s-verify-modal-input",(i=>{var t,s,a,e;let n=i.keyCode||i.charCode;i.target.value?(null===(t=i.target.nextElementSibling)||void 0===t||t.focus(),null===(s=i.target.nextElementSibling)||void 0===s||s.select()):[8,46].includes(n)&&(null===(a=i.target.previousElementSibling)||void 0===a||a.focus(),null===(e=i.target.previousElementSibling)||void 0===e||e.select()),this.toggleOTPSubmit()})),r.on("paste",".s-verify-modal-input",(i=>{let t=i.clipboardData.getData("text").toArabicDigits().replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((i,s)=>i.value=t[s]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.initiated=!0),this.reset(),!this.withoutModal&&(null===(t=this.modal)||void 0===t||t.setTitle(this.title)),this.modal.show()}toggleOTPSubmit(){let i=[];if(this.otpInputs.forEach((t=>t.value&&i.push(t.value))),this.code.value=i.join(""),4===i.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}reset(){this.otpInputs.forEach((i=>i.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){r.showElement(this.resendMessage).hideElement(this.resend);let i=30,t=setInterval((()=>{-1===i?(clearTimeout(t),r.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${i>=10?i:"0"+i} : 00`,i--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((i=>i.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){let i=Object.assign({code:this.code.value},this.data);return this.btn.load().then((()=>this.btn.disable())).then((()=>this.url?salla.api.auth.request(this.url,i):salla.api.auth.verify("sms"==this.by?"mobile":this.by,i))).then((i=>this.verified.emit(i))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return this.withoutModal?this.myBody():t("salla-modal",{icon:"sicon-android-phone",width:"xs",id:"s-verify-modal",ref:i=>this.modal=i,title:this.title},this.myBody())}myBody(){return t(s,{id:"s-verify-modal"},t("div",{class:"s-verify-modal-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:i=>this.code=i}),t("div",{class:"s-verify-modal-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-modal-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-modal-footer"},t("salla-button",{class:"s-verify-modal-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:i=>this.btn=i},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-modal-resend-message",ref:i=>this.resendMessage=i},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-modal-timer",ref:i=>this.timer=i})),t("a",{href:"#",class:"s-verify-modal-resend",onClick:()=>this.resendCode(),ref:i=>this.resend=i},salla.lang.get("blocks.comments.submit"))),t("slot",{name:"after-footer"}))}get host(){return e(this)}};m.style="salla-verify-modal{display:block}";export{o as salla_button,l as salla_localization,h as salla_modal,d as salla_tel_input,m as salla_verify_modal}
|
|
1
|
+
import{r as i,h as t,H as s,g as e,c as n}from"./p-cb1c59a2.js";import{H as r}from"./p-ed1c00c5.js";export{S as salla_login,a as salla_search}from"./p-b8ed7363.js";const o=class{constructor(t){i(this,t),this.btnStyle="primary",this.loading=!1,this.disabled=!1,this.loaderPosition="after",this.wide=!1,this.hostAttributes={};for(let i=0;i<this.host.attributes.length;i++)this.hostAttributes[this.host.attributes[i].name]=this.host.attributes[i].value;this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-btn btn--has-loading s-button-"+this.btnStyle+(this.wide?" s-button-wide ":"")+" s-button-btn-loader-"+this.loaderPosition+("after"==this.loaderPosition?" s-button-loader-after":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,delete this.hostAttributes["data-on-click"],this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),"center"==this.loaderPosition&&this.text.classList.remove("s-button-hide"),this.host}async setText(i){return this.text.innerHTML=i,this.host}async disable(){this.host.setAttribute("disabled","")}async enable(){this.host.removeAttribute("disabled")}handleVisible(i,t){this.btn.classList.remove("btn-"+t),this.btn.classList.add("btn-"+i)}handleLoading(i){r.toggleElement(this.btn,"btn--is-loading","btn--no-loading",(()=>i))}render(){return t(s,{class:"s-button-wrap"},t("button",Object.assign({ref:i=>this.btn=i,disabled:this.disabled},this.hostAttributes),t("span",{class:{"s-button-text":!0,"s-button-hide":"center"==this.loaderPosition&&this.loading},ref:i=>this.text=i},t("slot",null)),this.loading?t("span",{class:{"s-button-loader":!0,"s-button-loader-start":"start"===this.loaderPosition,"s-button-loader-end":"end"===this.loaderPosition,"s-button-loader-center":"center"===this.loaderPosition}}):""))}get host(){return e(this)}static get watchers(){return{btnStyle:["handleVisible"],loading:["handleLoading"]}}};o.style="";const l=class{constructor(t){var s,a;i(this,t),this.languages=[],this.currencies=[],this.isLoading=!0,this.language=salla.config.get("user.language_code"),this.currency=salla.config.get("user.currency_code"),r.setHost(this.host),salla.event.on("localization::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{var i;this.languagesTitle=salla.lang.get("common.titles.language"),this.currenciesTitle=salla.lang.get("common.titles.currency"),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("common.elements.ok"))})),this.languageSlot=(null===(s=r.getElement('[slot="language"]'))||void 0===s?void 0:s.innerHTML)||'<label class="s-localization-label" for="lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>',this.currencySlot=(null===(a=r.getElement('[slot="currency"]'))||void 0===a?void 0:a.innerHTML)||'<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>'}async show(){return this.modal.show().then((()=>this.getLanguages())).then((()=>this.getCurrencies())).then((()=>this.isLoading=!1))}async hide(){return this.modal.hide()}async getLanguages(){return this.language=this.language||salla.config.get("user.language_code"),this.languages.length>1?null:await salla.config.languages().then((i=>this.languages=i))}async getCurrencies(){return this.currency=this.currency||salla.config.get("user.currency_code"),this.currencies.length>1?null:await salla.config.currencies().then((i=>this.currencies=i))}onChangeCurrency(i){this.currency=i.target.value}onChangeLanguage(i){this.language=i.target.value}async submit(){let i;this.btn.load().then((()=>{if(this.currency){if(this.currency!==salla.config.get("user.currency_code","SAR"))return i=window.location.href,salla.currency.api.change(this.currency)}else salla.log("There is no currency!")})).then((()=>this.language===salla.config.get("user.language_code","ar")||(i=salla.helpers.addParamToUrl("lang",this.language)))).then((()=>this.btn.stop())).then((()=>this.hide())).then((()=>i&&(window.location.href=i)))}render(){return t("salla-modal",{isLoading:this.isLoading,id:"salla-localization",class:"s-hidden",ref:i=>this.modal=i,width:"xs"},this.isLoading?"":t("div",{class:"s-localization-inner"},this.languages.length>1?t("div",{class:"s-localization-section"},t("label",{class:"s-localization-title"},this.languagesTitle),t("div",{class:"s-localization-section-inner"},this.languages.length<6?this.languages.map((i=>t("div",{class:"s-localization-item"},t("input",{class:"s-localization-input",type:"radio",checked:this.language==i.iso_code,onChange:()=>this.language=i.iso_code,name:"language",id:"lang-"+i.code.toLowerCase(),value:i.code}),t("div",{id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,i.name).replace(/\{code\}/g,i.code).replace(/\{country_code\}/g,i.country_code)})))):t("select",{class:"s-localization-select",name:"currency",onChange:i=>this.onChangeLanguage(i)},this.languages.map((i=>t("option",{value:i.code,selected:this.language==i.code},i.name)))))):"",this.currencies.length>1?t("div",{class:"s-localization-section"},t("label",{class:"s-localization-title"},this.currenciesTitle),t("div",{class:"s-localization-section-inner"},this.currencies.length<6?this.currencies.map((i=>t("div",{class:"s-localization-item"},t("input",{class:"s-localization-input",type:"radio",name:"currency",checked:this.currency==i.code,onChange:()=>this.currency=i.code,id:"currency-"+i.code,value:i.code}),t("div",{id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,i.name).replace(/\{code\}/g,i.code).replace(/\{country_code\}/g,i.country_code)})))):t("select",{class:"s-localization-select",name:"currency",onChange:i=>this.onChangeCurrency(i)},this.currencies.map((i=>t("option",{value:i.code,selected:this.currency==i.code},i.name)))))):"",t("salla-button",{wide:!0,ref:i=>this.btn=i,onClick:()=>this.submit()},salla.lang.get("common.elements.ok"))))}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((i=>i.replaceWith(i.firstChild))),this.host.querySelectorAll("#language-slot").forEach((i=>i.replaceWith(i.firstChild)))}get host(){return e(this)}};l.style="";const h=class{constructor(t){i(this,t),this.modalOpened=n(this,"modalOpened",7),this.modalClosed=n(this,"modalClosed",7),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.icon="",this.iconStyle="",this.imageIcon="",r.setHost(this.host),salla.event.on("modal::open",(i=>i.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(i=>i.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title")}handleVisible(i){if(!i)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(i){return this.title=i,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(i){const t=this.host.querySelector(".s-modal-body");r.toggleElement(t,"s-modal-entering","s-modal-leaving",(()=>i)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>i)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>i)),i||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":"error"!=this.iconStyle&&"success"!=this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}iconClasses(){return{[this.icon]:!0,"sicon-alert-engine":!this.icon&&"error"==this.iconStyle&&!this.imageIcon,"sicon-check-circle2":!this.icon&&"success"==this.iconStyle&&!this.imageIcon}}render(){return this.host.id=this.host.id||"salla-modal",t(s,{class:"salla-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:i=>this.overlay=i,onClick:()=>this.closeModal()}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},""),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},this.isLoading?t("div",{class:"s-modal-loader-wrap"},t("span",{class:"s-modal-loader"})):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.title||this.subTitle?t("div",{class:"s-modal-header-inner"},this.iconStyle||this.icon?t("div",{class:this.iconBlockClasses()},t("i",{class:this.iconClasses()})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};h.style="";var u,c=(function(i){var t;t=function(i){return function(){for(var t=[["Afghanistan (افغانستان)","af","93"],["Albania (Shqipëri)","al","355"],["Algeria (الجزائر)","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua and Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia (Հայաստան)","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria (Österreich)","at","43"],["Azerbaijan (Azərbaycan)","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain (البحرين)","bh","973"],["Bangladesh (বাংলাদেশ)","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus (Беларусь)","by","375"],["Belgium (België)","be","32"],["Belize","bz","501"],["Benin (Bénin)","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan (འབྲུག)","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina (Босна и Херцеговина)","ba","387"],["Botswana","bw","267"],["Brazil (Brasil)","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria (България)","bg","359"],["Burkina Faso","bf","226"],["Burundi (Uburundi)","bi","257"],["Cambodia (កម្ពុជា)","kh","855"],["Cameroon (Cameroun)","cm","237"],["Canada","ca","1",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde (Kabu Verdi)","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic (République centrafricaine)","cf","236"],["Chad (Tchad)","td","235"],["Chile","cl","56"],["China (中国)","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros (جزر القمر)","km","269"],["Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)","cd","243"],["Congo (Republic) (Congo-Brazzaville)","cg","242"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["Côte d’Ivoire","ci","225"],["Croatia (Hrvatska)","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599",0],["Cyprus (Κύπρος)","cy","357"],["Czech Republic (Česká republika)","cz","420"],["Denmark (Danmark)","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic (República Dominicana)","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt (مصر)","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea (Guinea Ecuatorial)","gq","240"],["Eritrea","er","291"],["Estonia (Eesti)","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands (Islas Malvinas)","fk","500"],["Faroe Islands (Føroyar)","fo","298"],["Fiji","fj","679"],["Finland (Suomi)","fi","358",0],["France","fr","33"],["French Guiana (Guyane française)","gf","594"],["French Polynesia (Polynésie française)","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia (საქართველო)","ge","995"],["Germany (Deutschland)","de","49"],["Ghana (Gaana)","gh","233"],["Gibraltar","gi","350"],["Greece (Ελλάδα)","gr","30"],["Greenland (Kalaallit Nunaat)","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea (Guinée)","gn","224"],["Guinea-Bissau (Guiné Bissau)","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong (香港)","hk","852"],["Hungary (Magyarország)","hu","36"],["Iceland (Ísland)","is","354"],["India (भारत)","in","91"],["Indonesia","id","62"],["Iran (ایران)","ir","98"],["Iraq (العراق)","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel (ישראל)","il","972"],["Italy (Italia)","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan (日本)","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan (الأردن)","jo","962"],["Kazakhstan (Казахстан)","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait (الكويت)","kw","965"],["Kyrgyzstan (Кыргызстан)","kg","996"],["Laos (ລາວ)","la","856"],["Latvia (Latvija)","lv","371"],["Lebanon (لبنان)","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya (ليبيا)","ly","218"],["Liechtenstein","li","423"],["Lithuania (Lietuva)","lt","370"],["Luxembourg","lu","352"],["Macau (澳門)","mo","853"],["North Macedonia (Македонија)","mk","389"],["Madagascar (Madagasikara)","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania (موريتانيا)","mr","222"],["Mauritius (Moris)","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico (México)","mx","52"],["Micronesia","fm","691"],["Moldova (Republica Moldova)","md","373"],["Monaco","mc","377"],["Mongolia (Монгол)","mn","976"],["Montenegro (Crna Gora)","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco (المغرب)","ma","212",0],["Mozambique (Moçambique)","mz","258"],["Myanmar (Burma) (မြန်မာ)","mm","95"],["Namibia (Namibië)","na","264"],["Nauru","nr","674"],["Nepal (नेपाल)","np","977"],["Netherlands (Nederland)","nl","31"],["New Caledonia (Nouvelle-Calédonie)","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger (Nijar)","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea (조선 민주주의 인민 공화국)","kp","850"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway (Norge)","no","47",0],["Oman (عُمان)","om","968"],["Pakistan (پاکستان)","pk","92"],["Palau","pw","680"],["Palestine (فلسطين)","ps","970"],["Panama (Panamá)","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru (Perú)","pe","51"],["Philippines","ph","63"],["Poland (Polska)","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar (قطر)","qa","974"],["Réunion (La Réunion)","re","262",0],["Romania (România)","ro","40"],["Russia (Россия)","ru","7",0],["Rwanda","rw","250"],["Saint Barthélemy","bl","590",1],["Saint Helena","sh","290"],["Saint Kitts and Nevis","kn","1",18,["869"]],["Saint Lucia","lc","1",19,["758"]],["Saint Martin (Saint-Martin (partie française))","mf","590",2],["Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)","pm","508"],["Saint Vincent and the Grenadines","vc","1",20,["784"]],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé and Príncipe (São Tomé e Príncipe)","st","239"],["Saudi Arabia (المملكة العربية السعودية)","sa","966"],["Senegal (Sénégal)","sn","221"],["Serbia (Србија)","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia (Slovensko)","sk","421"],["Slovenia (Slovenija)","si","386"],["Solomon Islands","sb","677"],["Somalia (Soomaaliya)","so","252"],["South Africa","za","27"],["South Korea (대한민국)","kr","82"],["South Sudan (جنوب السودان)","ss","211"],["Spain (España)","es","34"],["Sri Lanka (ශ්රී ලංකාව)","lk","94"],["Sudan (السودان)","sd","249"],["Suriname","sr","597"],["Svalbard and Jan Mayen","sj","47",1,["79"]],["Sweden (Sverige)","se","46"],["Switzerland (Schweiz)","ch","41"],["Syria (سوريا)","sy","963"],["Taiwan (台灣)","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand (ไทย)","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad and Tobago","tt","1",22,["868"]],["Tunisia (تونس)","tn","216"],["Turkey (Türkiye)","tr","90"],["Turkmenistan","tm","993"],["Turks and Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["U.S. Virgin Islands","vi","1",24,["340"]],["Uganda","ug","256"],["Ukraine (Україна)","ua","380"],["United Arab Emirates (الإمارات العربية المتحدة)","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["Uzbekistan (Oʻzbekiston)","uz","998"],["Vanuatu","vu","678"],["Vatican City (Città del Vaticano)","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam (Việt Nam)","vn","84"],["Wallis and Futuna (Wallis-et-Futuna)","wf","681"],["Western Sahara (الصحراء الغربية)","eh","212",1,["5288","5289"]],["Yemen (اليمن)","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["Åland Islands","ax","358",1,["18"]]],s=0;s<t.length;s++){var a=t[s];t[s]={name:a[0],iso2:a[1],dialCode:a[2],priority:a[3]||0,areaCodes:a[4]||null}}function e(i,t){for(var s=0;s<t.length;s++){var a=t[s];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(i,a.key,a)}}var n={getInstance:function(i){var t=i.getAttribute("data-intl-tel-input-id");return window.intlTelInputGlobals.instances[t]},instances:{},documentReady:function(){return"complete"===document.readyState}};"object"==typeof window&&(window.intlTelInputGlobals=n);var r=0,o={allowDropdown:!0,autoHideDialCode:!0,autoPlaceholder:"polite",customContainer:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],formatOnDisplay:!0,geoIpLookup:null,hiddenInput:"",initialCountry:"",localizedCountries:null,nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:["us","gb"],separateDialCode:!1,utilsScript:""},l=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],h=function(i,t){for(var s=Object.keys(i),a=0;a<s.length;a++)t(s[a],i[s[a]])},u=function(i){h(window.intlTelInputGlobals.instances,(function(t){window.intlTelInputGlobals.instances[t][i]()}))},c=function(){function s(i,t){var a=this;!function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),this.id=r++,this.telInput=i,this.activeItem=null,this.highlightedItem=null;var e=t||{};this.options={},h(o,(function(i,t){a.options[i]=e.hasOwnProperty(i)?e[i]:t})),this.hadInitialPlaceholder=Boolean(i.getAttribute("placeholder"))}var a,n;return a=s,(n=[{key:"_init",value:function(){var i=this;if(this.options.nationalMode&&(this.options.autoHideDialCode=!1),this.options.separateDialCode&&(this.options.autoHideDialCode=this.options.nationalMode=!1),this.isMobile=/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),this.isMobile&&(document.body.classList.add("iti-mobile"),this.options.dropdownContainer||(this.options.dropdownContainer=document.body)),"undefined"!=typeof Promise){var t=new Promise((function(t,s){i.resolveAutoCountryPromise=t,i.rejectAutoCountryPromise=s})),s=new Promise((function(t,s){i.resolveUtilsScriptPromise=t,i.rejectUtilsScriptPromise=s}));this.promise=Promise.all([t,s])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processCountryCodes(),this._processPreferredCountries(),this.options.localizedCountries&&this._translateCountriesByLocale(),(this.options.onlyCountries.length||this.options.localizedCountries)&&this.countries.sort(this._countryNameSort)}},{key:"_addCountryCode",value:function(t,s,a){s.length>this.countryCodeMaxLen&&(this.countryCodeMaxLen=s.length),this.countryCodes.hasOwnProperty(s)||(this.countryCodes[s]=[]);for(var e=0;e<this.countryCodes[s].length;e++)if(this.countryCodes[s][e]===t)return;this.countryCodes[s][a!==i?a:this.countryCodes[s].length]=t}},{key:"_processAllCountries",value:function(){if(this.options.onlyCountries.length){var i=this.options.onlyCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(t){return i.indexOf(t.iso2)>-1}))}else if(this.options.excludeCountries.length){var s=this.options.excludeCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(i){return-1===s.indexOf(i.iso2)}))}else this.countries=t}},{key:"_translateCountriesByLocale",value:function(){for(var i=0;i<this.countries.length;i++){var t=this.countries[i].iso2.toLowerCase();this.options.localizedCountries.hasOwnProperty(t)&&(this.countries[i].name=this.options.localizedCountries[t])}}},{key:"_countryNameSort",value:function(i,t){return i.name.localeCompare(t.name)}},{key:"_processCountryCodes",value:function(){this.countryCodeMaxLen=0,this.dialCodes={},this.countryCodes={};for(var i=0;i<this.countries.length;i++){var t=this.countries[i];this.dialCodes[t.dialCode]||(this.dialCodes[t.dialCode]=!0),this._addCountryCode(t.iso2,t.dialCode,t.priority)}for(var s=0;s<this.countries.length;s++){var a=this.countries[s];if(a.areaCodes)for(var e=this.countryCodes[a.dialCode][0],n=0;n<a.areaCodes.length;n++){for(var r=a.areaCodes[n],o=1;o<r.length;o++){var l=a.dialCode+r.substr(0,o);this._addCountryCode(e,l),this._addCountryCode(a.iso2,l)}this._addCountryCode(a.iso2,a.dialCode+r)}}}},{key:"_processPreferredCountries",value:function(){this.preferredCountries=[];for(var i=0;i<this.options.preferredCountries.length;i++){var t=this.options.preferredCountries[i].toLowerCase(),s=this._getCountryData(t,!1,!0);s&&this.preferredCountries.push(s)}}},{key:"_createEl",value:function(i,t,s){var a=document.createElement(i);return t&&h(t,(function(i,t){return a.setAttribute(i,t)})),s&&s.appendChild(a),a}},{key:"_generateMarkup",value:function(){this.telInput.hasAttribute("autocomplete")||this.telInput.form&&this.telInput.form.hasAttribute("autocomplete")||this.telInput.setAttribute("autocomplete","off");var i="iti";this.options.allowDropdown&&(i+=" iti--allow-dropdown"),this.options.separateDialCode&&(i+=" iti--separate-dial-code"),this.options.customContainer&&(i+=" ",i+=this.options.customContainer);var t=this._createEl("div",{class:i});if(this.telInput.parentNode.insertBefore(t,this.telInput),this.flagsContainer=this._createEl("div",{class:"iti__flag-container"},t),t.appendChild(this.telInput),this.selectedFlag=this._createEl("div",{class:"iti__selected-flag",role:"combobox","aria-controls":"iti-".concat(this.id,"__country-listbox"),"aria-owns":"iti-".concat(this.id,"__country-listbox"),"aria-expanded":"false"},this.flagsContainer),this.selectedFlagInner=this._createEl("div",{class:"iti__flag"},this.selectedFlag),this.options.separateDialCode&&(this.selectedDialCode=this._createEl("div",{class:"iti__selected-dial-code"},this.selectedFlag)),this.options.allowDropdown&&(this.selectedFlag.setAttribute("tabindex","0"),this.dropdownArrow=this._createEl("div",{class:"iti__arrow"},this.selectedFlag),this.countryList=this._createEl("ul",{class:"iti__country-list iti__hide",id:"iti-".concat(this.id,"__country-listbox"),role:"listbox","aria-label":"List of countries"}),this.preferredCountries.length&&(this._appendListItems(this.preferredCountries,"iti__preferred",!0),this._createEl("li",{class:"iti__divider",role:"separator","aria-disabled":"true"},this.countryList)),this._appendListItems(this.countries,"iti__standard"),this.options.dropdownContainer?(this.dropdown=this._createEl("div",{class:"iti iti--container"}),this.dropdown.appendChild(this.countryList)):this.flagsContainer.appendChild(this.countryList)),this.options.hiddenInput){var s=this.options.hiddenInput,a=this.telInput.getAttribute("name");if(a){var e=a.lastIndexOf("[");-1!==e&&(s="".concat(a.substr(0,e),"[").concat(s,"]"))}this.hiddenInput=this._createEl("input",{type:"hidden",name:s}),t.appendChild(this.hiddenInput)}}},{key:"_appendListItems",value:function(i,t,s){for(var a="",e=0;e<i.length;e++){var n=i[e],r=s?"-preferred":"";a+="<li class='iti__country ".concat(t,"' tabIndex='-1' id='iti-").concat(this.id,"__item-").concat(n.iso2).concat(r,"' role='option' data-dial-code='").concat(n.dialCode,"' data-country-code='").concat(n.iso2,"' aria-selected='false'>"),a+="<div class='iti__flag-box'><div class='iti__flag iti__".concat(n.iso2,"'></div></div>"),a+="<span class='iti__country-name'>".concat(n.name,"</span>"),a+="<span class='iti__dial-code'>+".concat(n.dialCode,"</span>"),a+="</li>"}this.countryList.insertAdjacentHTML("beforeend",a)}},{key:"_setInitialState",value:function(){var i=this.telInput.getAttribute("value"),t=this.telInput.value,s=!i||"+"!==i.charAt(0)||t&&"+"===t.charAt(0)?t:i,a=this._getDialCode(s),e=this._isRegionlessNanp(s),n=this.options,r=n.initialCountry,o=n.nationalMode,l=n.autoHideDialCode,h=n.separateDialCode;a&&!e?this._updateFlagFromNumber(s):"auto"!==r&&(r?this._setFlag(r.toLowerCase()):a&&e?this._setFlag("us"):(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,s||this._setFlag(this.defaultCountry)),s||o||l||h||(this.telInput.value="+".concat(this.selectedCountryData.dialCode))),s&&this._updateValFromNumber(s)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoHideDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var i=this;this._handleHiddenInputSubmit=function(){i.hiddenInput.value=i.getNumber()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_getClosestLabel",value:function(){for(var i=this.telInput;i&&"LABEL"!==i.tagName;)i=i.parentNode;return i}},{key:"_initDropdownListeners",value:function(){var i=this;this._handleLabelClick=function(t){i.countryList.classList.contains("iti__hide")?i.telInput.focus():t.preventDefault()};var t=this._getClosestLabel();t&&t.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){!i.countryList.classList.contains("iti__hide")||i.telInput.disabled||i.telInput.readOnly||i._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(t){i.countryList.classList.contains("iti__hide")&&-1!==["ArrowUp","Up","ArrowDown","Down"," ","Enter"].indexOf(t.key)&&(t.preventDefault(),t.stopPropagation(),i._showDropdown()),"Tab"===t.key&&i._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var i=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",(function(){window.intlTelInputGlobals.loadUtils(i.options.utilsScript)})):this.resolveUtilsScriptPromise(),"auto"===this.options.initialCountry?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.options.geoIpLookup&&this.options.geoIpLookup((function(i){window.intlTelInputGlobals.autoCountry=i.toLowerCase(),setTimeout((function(){return u("handleAutoCountry")}))}),(function(){return u("rejectAutoCountryPromise")})))}},{key:"_initKeyListeners",value:function(){var i=this;this._handleKeyupEvent=function(){i._updateFlagFromNumber(i.telInput.value)&&i._triggerCountryChange()},this.telInput.addEventListener("keyup",this._handleKeyupEvent),this._handleClipboardEvent=function(){setTimeout(i._handleKeyupEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_cap",value:function(i){var t=this.telInput.getAttribute("maxlength");return t&&i.length>t?i.substr(0,t):i}},{key:"_initBlurListeners",value:function(){var i=this;this._handleSubmitOrBlurEvent=function(){i._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if("+"===this.telInput.value.charAt(0)){var i=this._getNumeric(this.telInput.value);i&&this.selectedCountryData.dialCode!==i||(this.telInput.value="")}}},{key:"_getNumeric",value:function(i){return i.replace(/\D/g,"")}},{key:"_trigger",value:function(i){var t=document.createEvent("Event");t.initEvent(i,!0,!0),this.telInput.dispatchEvent(t)}},{key:"_showDropdown",value:function(){this.countryList.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0)),this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(i,t,s){s&&!i.classList.contains(t)?i.classList.add(t):!s&&i.classList.contains(t)&&i.classList.remove(t)}},{key:"_setDropdownPosition",value:function(){var i=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.isMobile){var t=this.telInput.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,a=t.top+s,e=this.countryList.offsetHeight,n=a+this.telInput.offsetHeight+e<s+window.innerHeight,r=a-e>s;this._toggleClass(this.countryList,"iti__country-list--dropup",!n&&r),this.options.dropdownContainer&&(this.dropdown.style.top="".concat(a+(!n&&r?0:this.telInput.offsetHeight),"px"),this.dropdown.style.left="".concat(t.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return i._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll))}}},{key:"_getClosestListItem",value:function(i){for(var t=i;t&&t!==this.countryList&&!t.classList.contains("iti__country");)t=t.parentNode;return t===this.countryList?null:t}},{key:"_bindDropdownListeners",value:function(){var i=this;this._handleMouseoverCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._highlightListItem(s,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._selectListItem(s)},this.countryList.addEventListener("click",this._handleClickCountryList);var t=!0;this._handleClickOffToClose=function(){t||i._closeDropdown(),t=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var s="",a=null;this._handleKeydownOnDropdown=function(t){t.preventDefault(),"ArrowUp"===t.key||"Up"===t.key||"ArrowDown"===t.key||"Down"===t.key?i._handleUpDownKey(t.key):"Enter"===t.key?i._handleEnterKey():"Escape"===t.key?i._closeDropdown():/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(t.key)&&(a&&clearTimeout(a),s+=t.key.toLowerCase(),i._searchForCountry(s),a=setTimeout((function(){s=""}),1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown)}},{key:"_handleUpDownKey",value:function(i){var t="ArrowUp"===i||"Up"===i?this.highlightedItem.previousElementSibling:this.highlightedItem.nextElementSibling;t&&(t.classList.contains("iti__divider")&&(t="ArrowUp"===i||"Up"===i?t.previousElementSibling:t.nextElementSibling),this._highlightListItem(t,!0))}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(i){for(var t=0;t<this.countries.length;t++)if(this._startsWith(this.countries[t].name,i)){var s=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(this.countries[t].iso2));this._highlightListItem(s,!1),this._scrollTo(s,!0);break}}},{key:"_startsWith",value:function(i,t){return i.substr(0,t.length).toLowerCase()===t}},{key:"_updateValFromNumber",value:function(i){var t=i;if(this.options.formatOnDisplay&&window.intlTelInputUtils&&this.selectedCountryData){var s=!this.options.separateDialCode&&(this.options.nationalMode||"+"!==t.charAt(0)),a=intlTelInputUtils.numberFormat;t=intlTelInputUtils.formatNumber(t,this.selectedCountryData.iso2,s?a.NATIONAL:a.INTERNATIONAL)}t=this._beforeSetNumber(t),this.telInput.value=t}},{key:"_updateFlagFromNumber",value:function(i){var t=i,s=this.selectedCountryData.dialCode;t&&this.options.nationalMode&&"1"===s&&"+"!==t.charAt(0)&&("1"!==t.charAt(0)&&(t="1".concat(t)),t="+".concat(t)),this.options.separateDialCode&&s&&"+"!==t.charAt(0)&&(t="+".concat(s).concat(t));var a=this._getDialCode(t,!0),e=this._getNumeric(t),n=null;if(a){var r=this.countryCodes[this._getNumeric(a)],o=-1!==r.indexOf(this.selectedCountryData.iso2)&&e.length<=a.length-1;if(!("1"===s&&this._isRegionlessNanp(e)||o))for(var l=0;l<r.length;l++)if(r[l]){n=r[l];break}}else"+"===t.charAt(0)&&e.length?n="":t&&"+"!==t||(n=this.defaultCountry);return null!==n&&this._setFlag(n)}},{key:"_isRegionlessNanp",value:function(i){var t=this._getNumeric(i);if("1"===t.charAt(0)){var s=t.substr(1,3);return-1!==l.indexOf(s)}return!1}},{key:"_highlightListItem",value:function(i,t){var s=this.highlightedItem;s&&s.classList.remove("iti__highlight"),this.highlightedItem=i,this.highlightedItem.classList.add("iti__highlight"),t&&this.highlightedItem.focus()}},{key:"_getCountryData",value:function(i,s,a){for(var e=s?t:this.countries,n=0;n<e.length;n++)if(e[n].iso2===i)return e[n];if(a)return null;throw new Error("No country data for '".concat(i,"'"))}},{key:"_setFlag",value:function(i){var t=this.selectedCountryData.iso2?this.selectedCountryData:{};this.selectedCountryData=i?this._getCountryData(i,!1,!1):{},this.selectedCountryData.iso2&&(this.defaultCountry=this.selectedCountryData.iso2),this.selectedFlagInner.setAttribute("class","iti__flag iti__".concat(i));var s=i?"".concat(this.selectedCountryData.name,": +").concat(this.selectedCountryData.dialCode):"Unknown";if(this.selectedFlag.setAttribute("title",s),this.options.separateDialCode){var a=this.selectedCountryData.dialCode?"+".concat(this.selectedCountryData.dialCode):"";this.selectedDialCode.innerHTML=a;var e=this.selectedFlag.offsetWidth||this._getHiddenSelectedFlagWidth();this.telInput.style.paddingLeft="".concat(e+6,"px")}if(this._updatePlaceholder(),this.options.allowDropdown){var n=this.activeItem;if(n&&(n.classList.remove("iti__active"),n.setAttribute("aria-selected","false")),i){var r=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i,"-preferred"))||this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i));r.setAttribute("aria-selected","true"),r.classList.add("iti__active"),this.activeItem=r,this.selectedFlag.setAttribute("aria-activedescendant",r.getAttribute("id"))}}return t.iso2!==i}},{key:"_getHiddenSelectedFlagWidth",value:function(){var i=this.telInput.parentNode.cloneNode();i.style.visibility="hidden",document.body.appendChild(i);var t=this.flagsContainer.cloneNode();i.appendChild(t);var s=this.selectedFlag.cloneNode(!0);t.appendChild(s);var a=s.offsetWidth;return i.parentNode.removeChild(i),a}},{key:"_updatePlaceholder",value:function(){if(window.intlTelInputUtils&&("aggressive"===this.options.autoPlaceholder||!this.hadInitialPlaceholder&&"polite"===this.options.autoPlaceholder)){var i=intlTelInputUtils.numberType[this.options.placeholderNumberType],t=this.selectedCountryData.iso2?intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2,this.options.nationalMode,i):"";t=this._beforeSetNumber(t),"function"==typeof this.options.customPlaceholder&&(t=this.options.customPlaceholder(t,this.selectedCountryData)),this.telInput.setAttribute("placeholder",t)}}},{key:"_selectListItem",value:function(i){var t=this._setFlag(i.getAttribute("data-country-code"));this._closeDropdown(),this._updateDialCode(i.getAttribute("data-dial-code"),!0),this.telInput.focus();var s=this.telInput.value.length;this.telInput.setSelectionRange(s,s),t&&this._triggerCountryChange()}},{key:"_closeDropdown",value:function(){this.countryList.classList.add("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","false"),this.dropdownArrow.classList.remove("iti__arrow--up"),document.removeEventListener("keydown",this._handleKeydownOnDropdown),document.documentElement.removeEventListener("click",this._handleClickOffToClose),this.countryList.removeEventListener("mouseover",this._handleMouseoverCountryList),this.countryList.removeEventListener("click",this._handleClickCountryList),this.options.dropdownContainer&&(this.isMobile||window.removeEventListener("scroll",this._handleWindowScroll),this.dropdown.parentNode&&this.dropdown.parentNode.removeChild(this.dropdown)),this._trigger("close:countrydropdown")}},{key:"_scrollTo",value:function(i,t){var s=this.countryList,a=window.pageYOffset||document.documentElement.scrollTop,e=s.offsetHeight,n=s.getBoundingClientRect().top+a,r=n+e,o=i.offsetHeight,l=i.getBoundingClientRect().top+a,h=l+o,u=l-n+s.scrollTop,c=e/2-o/2;l<n?(t&&(u-=c),s.scrollTop=u):h>r&&(t&&(u+=c),s.scrollTop=u-(e-o))}},{key:"_updateDialCode",value:function(i,t){var s,a=this.telInput.value,e="+".concat(i);if("+"===a.charAt(0)){var n=this._getDialCode(a);s=n?a.replace(n,e):e}else{if(this.options.nationalMode||this.options.separateDialCode)return;if(a)s=e+a;else{if(!t&&this.options.autoHideDialCode)return;s=e}}this.telInput.value=s}},{key:"_getDialCode",value:function(i,t){var s="";if("+"===i.charAt(0))for(var a="",e=0;e<i.length;e++){var n=i.charAt(e);if(!isNaN(parseInt(n,10))){if(a+=n,t)this.countryCodes[a]&&(s=i.substr(0,e+1));else if(this.dialCodes[a]){s=i.substr(0,e+1);break}if(a.length===this.countryCodeMaxLen)break}}return s}},{key:"_getFullNumber",value:function(){var i=this.telInput.value.trim(),t=this.selectedCountryData.dialCode,s=this._getNumeric(i);return(this.options.separateDialCode&&"+"!==i.charAt(0)&&t&&s?"+".concat(t):"")+i}},{key:"_beforeSetNumber",value:function(i){var t=i;if(this.options.separateDialCode){var s=this._getDialCode(t);s&&(s="+".concat(this.selectedCountryData.dialCode),t=t.substr(" "===t[s.length]||"-"===t[s.length]?s.length+1:s.length))}return this._cap(t)}},{key:"_triggerCountryChange",value:function(){this._trigger("countrychange")}},{key:"handleAutoCountry",value:function(){"auto"===this.options.initialCountry&&(this.defaultCountry=window.intlTelInputGlobals.autoCountry,this.telInput.value||this.setCountry(this.defaultCountry),this.resolveAutoCountryPromise())}},{key:"handleUtils",value:function(){window.intlTelInputUtils&&(this.telInput.value&&this._updateValFromNumber(this.telInput.value),this._updatePlaceholder()),this.resolveUtilsScriptPromise()}},{key:"destroy",value:function(){var i=this.telInput.form;if(this.options.allowDropdown){this._closeDropdown(),this.selectedFlag.removeEventListener("click",this._handleClickSelectedFlag),this.flagsContainer.removeEventListener("keydown",this._handleFlagsContainerKeydown);var t=this._getClosestLabel();t&&t.removeEventListener("click",this._handleLabelClick)}this.hiddenInput&&i&&i.removeEventListener("submit",this._handleHiddenInputSubmit),this.options.autoHideDialCode&&(i&&i.removeEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.removeEventListener("blur",this._handleSubmitOrBlurEvent)),this.telInput.removeEventListener("keyup",this._handleKeyupEvent),this.telInput.removeEventListener("cut",this._handleClipboardEvent),this.telInput.removeEventListener("paste",this._handleClipboardEvent),this.telInput.removeAttribute("data-intl-tel-input-id");var s=this.telInput.parentNode;s.parentNode.insertBefore(this.telInput,s),s.parentNode.removeChild(s),delete window.intlTelInputGlobals.instances[this.id]}},{key:"getExtension",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getExtension(this._getFullNumber(),this.selectedCountryData.iso2):""}},{key:"getNumber",value:function(i){if(window.intlTelInputUtils){var t=this.selectedCountryData.iso2;return intlTelInputUtils.formatNumber(this._getFullNumber(),t,i)}return""}},{key:"getNumberType",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getNumberType(this._getFullNumber(),this.selectedCountryData.iso2):-99}},{key:"getSelectedCountryData",value:function(){return this.selectedCountryData}},{key:"getValidationError",value:function(){if(window.intlTelInputUtils){var i=this.selectedCountryData.iso2;return intlTelInputUtils.getValidationError(this._getFullNumber(),i)}return-99}},{key:"isValidNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isValidNumber(i,this.options.nationalMode?this.selectedCountryData.iso2:""):null}},{key:"setCountry",value:function(i){var t=i.toLowerCase();this.selectedFlagInner.classList.contains("iti__".concat(t))||(this._setFlag(t),this._updateDialCode(this.selectedCountryData.dialCode,!1),this._triggerCountryChange())}},{key:"setNumber",value:function(i){var t=this._updateFlagFromNumber(i);this._updateValFromNumber(i),t&&this._triggerCountryChange()}},{key:"setPlaceholderNumberType",value:function(i){this.options.placeholderNumberType=i,this._updatePlaceholder()}}])&&e(a.prototype,n),s}();n.getCountryData=function(){return t};var d=function(i,t,s){var a=document.createElement("script");a.onload=function(){u("handleUtils"),t&&t()},a.onerror=function(){u("rejectUtilsScriptPromise"),s&&s()},a.className="iti-load-utils",a.async=!0,a.src=i,document.body.appendChild(a)};return n.loadUtils=function(i){if(!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript){if(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,"undefined"!=typeof Promise)return new Promise((function(t,s){return d(i,t,s)}));d(i)}return null},n.defaults=o,n.version="17.0.15",function(i,t){var s=new c(i,t);return s._init(),i.setAttribute("data-intl-tel-input-id",s.id),window.intlTelInputGlobals.instances[s.id]=s,s}}()},i.exports?i.exports=t():window.intlTelInput=t()}(u={path:undefined,exports:{},require:function(){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}}),u.exports);const d=class{constructor(t){i(this,t),this.enterClicked=n(this,"enterClicked",7),this.countryCode=salla.config.get("user.country_code","SA"),this.countryKey="+966",this.countryCodeLabel=salla.lang.get("common.country_code"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.tooShort=salla.lang.get("common.errors.too_short",{attribute:this.mobileLabel}),this.tooLong=salla.lang.get("common.errors.too_long",{attribute:this.mobileLabel}),this.invalidCountryCode=salla.lang.get("common.errors.invalid_value",{attribute:this.countryCodeLabel}),this.invalidNumber=salla.lang.get("common.errors.invalid_value",{attribute:this.mobileLabel}),this.errorMap=[this.invalidNumber,this.invalidCountryCode,this.tooShort,this.tooLong,this.invalidNumber],r.setHost(this.host),salla.event.on("languages::translations.loaded",(()=>{this.mobileLabel=salla.lang.get("common.elements.mobile"),this.countryCodeLabel=salla.lang.get("common.country_code"),this.invalidNumber=salla.lang.get("common.errors.invalid_value",{attribute:this.mobileLabel}),this.invalidCountryCode=salla.lang.get("common.errors.invalid_value",{attribute:this.countryCodeLabel}),this.tooShort=salla.lang.get("common.errors.too_short",{attribute:this.mobileLabel}),this.tooLong=salla.lang.get("common.errors.too_long",{attribute:this.mobileLabel}),this.mobileRequired=salla.lang.get("common.errors.field_required",{attribute:this.mobileLabel}),this.errorMap=[this.invalidNumber,this.invalidCountryCode,this.tooShort,this.tooLong,this.invalidNumber]}))}async getValues(){return{mobile:this.mobile=this.phoneInput.value,countryCode:this.countryCode=this.countryCodeInput.value,countryKey:this.countryKey=this.countryKeyInput.value}}async isValid(){if(this.reset(),this.iti.isValidNumber())return!0;if(!this.phoneInput.value.trim())return this.phoneInput.classList.add("s-has-error"),void(this.errorMsg.innerText=this.mobileRequired||"");this.phoneInput.classList.add("s-has-error");let i=this.iti.getValidationError();return this.errorMsg.innerText=this.errorMap[i]||"",!1}initTelInput(){salla.helpers.digitsOnly(this.phoneInput),this.iti=c(this.phoneInput,{initialCountry:this.countryCode||"sa",preferredCountries:["sa","ae","kw","bh","qa","iq","om","ye","eg","jo","sy","ps","sd","lb","dz","tn","ma","ly"],formatOnDisplay:!1,separateDialCode:!0,autoPlaceholder:"aggressive",utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.min.js"}),this.phoneInput.addEventListener("countrychange",(()=>{let i=this.iti.getSelectedCountryData();this.host.querySelectorAll(".country_code").forEach((t=>t.value=i.iso2.toUpperCase())),this.host.querySelectorAll(".country_key").forEach((t=>{t.value=("+"+i.dialCode).replace("++","+")}))})),this.phoneInput.addEventListener("blur",(()=>this.isValid())),this.phoneInput.addEventListener("input",(i=>{salla.helpers.digitsOnly(i.target),this.reset()}))}reset(){this.phoneInput.classList.remove("s-has-error"),this.errorMsg.innerHTML=""}render(){return t(s,{id:"s-tel-input"},t("input",{type:"tel",name:"mobile",value:this.mobile,ref:i=>this.phoneInput=i,class:"s-tel-input-control tel-input s-ltr"}),t("span",{class:"s-tel-input-error-msg",ref:i=>this.errorMsg=i}),t("input",{type:"hidden",name:"country_code",value:this.countryCode,ref:i=>this.countryCodeInput=i,class:"country_code"}),t("input",{type:"hidden",name:"country_key",value:this.countryKey,ref:i=>this.countryKeyInput=i,class:"country_key"}))}componentDidLoad(){this.initTelInput()}get host(){return e(this)}};d.style="";const m=class{constructor(t){i(this,t),this.verified=n(this,"verified",7),this.initiated=!1,this.by="sms",this.autoReload=!0,r.setHost(this.host),this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(i=>{this.url="profile/verify-mobile",this.show(i)})),salla.event.on("languages::translations.loaded",(()=>{var i;this.title=salla.lang.get("pages.profile.verify_title"),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("pages.profile.verify"))}))}async getCode(){return this.code.value}async show(i){var t;this.data=i,this.resendTimer(),this.otpInputs=this.host.querySelectorAll(".s-verify-modal-input"),this.initiated||(r.on("input",".s-verify-modal-input",(i=>salla.helpers.digitsOnly(i.target))),r.onKeyUp(".s-verify-modal-input",(i=>{var t,s,a,e;let n=i.keyCode||i.charCode;i.target.value?(null===(t=i.target.nextElementSibling)||void 0===t||t.focus(),null===(s=i.target.nextElementSibling)||void 0===s||s.select()):[8,46].includes(n)&&(null===(a=i.target.previousElementSibling)||void 0===a||a.focus(),null===(e=i.target.previousElementSibling)||void 0===e||e.select()),this.toggleOTPSubmit()})),r.on("paste",".s-verify-modal-input",(i=>{let t=i.clipboardData.getData("text").toArabicDigits().replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((i,s)=>i.value=t[s]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.initiated=!0),this.reset(),!this.withoutModal&&(null===(t=this.modal)||void 0===t||t.setTitle(this.title)),this.modal.show()}toggleOTPSubmit(){let i=[];if(this.otpInputs.forEach((t=>t.value&&i.push(t.value))),this.code.value=i.join(""),4===i.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}reset(){this.otpInputs.forEach((i=>i.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){r.showElement(this.resendMessage).hideElement(this.resend);let i=30,t=setInterval((()=>{-1===i?(clearTimeout(t),r.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${i>=10?i:"0"+i} : 00`,i--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((i=>i.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){let i=Object.assign({code:this.code.value},this.data);return this.btn.load().then((()=>this.btn.disable())).then((()=>this.url?salla.api.auth.request(this.url,i):salla.api.auth.verify("sms"==this.by?"mobile":this.by,i))).then((i=>this.verified.emit(i))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return this.withoutModal?this.myBody():t("salla-modal",{icon:"sicon-android-phone",width:"xs",id:"s-verify-modal",ref:i=>this.modal=i,title:this.title},this.myBody())}myBody(){return t(s,{id:"s-verify-modal"},t("div",{class:"s-verify-modal-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:i=>this.code=i}),t("div",{class:"s-verify-modal-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-modal-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-modal-footer"},t("salla-button",{class:"s-verify-modal-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:i=>this.btn=i},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-modal-resend-message",ref:i=>this.resendMessage=i},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-modal-timer",ref:i=>this.timer=i})),t("a",{href:"#",class:"s-verify-modal-resend",onClick:()=>this.resendCode(),ref:i=>this.resend=i},salla.lang.get("blocks.comments.submit"))),t("slot",{name:"after-footer"}))}get host(){return e(this)}};m.style="salla-verify-modal{display:block}";export{o as salla_button,l as salla_localization,h as salla_modal,d as salla_tel_input,m as salla_verify_modal}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,h as i,g as t}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";const l=class{constructor(i){s(this,i),this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!0),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!0),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!1),this.regType="phone",this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),this.typing=(s,i)=>{const t=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==t?void 0:t.classList.contains("s-login-error-message"))&&(t.innerText=""),"Enter"==s.key&&i()},this.loginBySMS=async()=>{const{mobile:s,countryCode:i}=await this.loginTelInput.getValues();await this.loginTelInput.isValid()&&this.smsBtn.load().then((()=>this.smsBtn.disable())).then((()=>salla.auth.api.login({type:"mobile",phone:s,country_code:i}))).then((()=>this.smsBtn.stop()&&this.smsBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>(this.verifyTab.by="sms")&&(this.verifyTab.url="auth/mobile/verify"))).then((()=>this.verifyTab.show({phone:s,country_code:i})))},this.loginByEmail=()=>{e.isValidEmail(this.loginEmail.value)?this.emailBtn.load().then((()=>this.emailBtn.disable())).then((()=>salla.auth.api.login({type:"email",email:this.loginEmail.value}))).then((()=>this.emailBtn.stop()&&this.emailBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.by="email")).then((()=>this.verifyTab.show({email:this.loginEmail.value}))):this.validateField(this.loginEmail,this.emailErrorMsg)},this.newUser=async()=>{var s;const{mobile:i,countryCode:t,countryKey:e}=await this.regTelInput.getValues(),l=this.regEmail.value||(null===(s=this.loginEmail)||void 0===s?void 0:s.value);await this.newUserValidation(),await this.regBtn.load(),await this.regBtn.disable();let a={first_name:this.firstName.value,last_name:this.lastName.value,phone:i||this.loginTelInput.mobile,country_code:t,country_key:e,verified_by:this.regType};l&&(a=Object.assign(Object.assign({},a),{email:l})),this.verifyTab.getCode().then((s=>salla.auth.api.register(Object.assign(Object.assign({},a),{code:s})))).then((()=>window.location.reload())).catch((()=>this.regBtn.stop()&&this.regBtn.enable()))},this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.event.on("languages::translations.loaded",(()=>{var s,i,t,e;this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.smsBtn)||void 0===i||i.setText(salla.lang.get("blocks.header.enter")),null===(t=this.emailBtn)||void 0===t||t.setText(salla.lang.get("blocks.header.enter")),null===(e=this.regBtn)||void 0===e||e.setText(salla.lang.get("blocks.header.register"))})),salla.auth.event.onVerificationFailed((()=>{})),salla.event.on("login::show",(()=>this.show())),salla.event.on("twilight::initiated",(()=>{this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!!this.isEmailAllowed),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!!this.isMobileAllowed),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!!this.isEmailRequired)}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}async show(){return this.isEmailAllowed&&this.isMobileAllowed?this.showTab(this.homeTab):this.isEmailAllowed?this.showTab(this.emailTab):this.isMobileAllowed&&this.showTab(this.mobileTab),this.modal.show()}showTab(s,i){var t,l;null==i||i.preventDefault();let a=[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab];a.map((i=>e.toggleElement(i,"visible","s-hidden",(()=>i==s)))),setTimeout((()=>a.map((i=>e.toggleElement(i,"s-login-active","s-login-unactive",(()=>i==s))))),200),setTimeout((()=>this.host.querySelector(".s-login-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px"))),[this.mobileTab,this.emailTab].includes(s)&&(this.regType=s===this.mobileTab?"phone":"email");let o=s==this.registrationTab;return o&&(null===(t=this.firstName)||void 0===t||t.focus()),null===(l=this.modal)||void 0===l||l.setTitle(o?salla.lang.get("common.titles.registration"):this.title),o||e.toggleElement(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElement(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}async newUserValidation(){const s="phone"==this.regType,i=this.regEmail.value||"email"==this.regType&&this.loginEmail.value,t=e.isValidEmail(i),l=this.firstName.value.length>0,a=this.lastName.value.length>0,o=await this.regTelInput.isValid()||s&&await this.loginTelInput.isValid();if(!((i&&t||!i&&!this.isEmailRequired)&&o&&l&&a))throw!t&&this.validateField(this.regEmail,this.emailErrorMsg),!l&&this.validateField(this.firstName,this.firstNameErrorMsg),!a&&this.validateField(this.lastName,this.lastNameErrorMsg),"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i("salla-modal",{id:"salla-login",icon:"sicon-user",title:this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-wrapper"},this.isEmailAllowed&&this.isMobileAllowed?i("div",{class:"s-login-tab",ref:s=>this.homeTab=s},i("p",{class:"s-login-sub-title"},this.loginTypeTitle),i("slot",{name:"before-login-type"}),i("a",{href:"#",class:"s-login-main-btn",onClick:s=>this.showTab(this.mobileTab,s)},i("i",{class:"s-login-main-btn-icon sicon-phone"}),i("span",{class:"s-login-main-btn-text"},this.smsLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"})),i("a",{href:"#",class:"s-login-main-btn",onClick:s=>this.showTab(this.emailTab,s)},i("i",{class:"s-login-main-btn-icon sicon-mail"}),i("span",{class:"s-login-main-btn-text"},this.emailLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"})),i("slot",{name:"after-login-type"})):"",this.isMobileAllowed?i("div",{class:"s-login-tab",ref:s=>this.mobileTab=s},i("slot",{name:"before-login-mobile"}),i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.loginTelInput=s,onKeyDown:s=>this.typing(s,this.loginBySMS)}),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.loginBySMS(),ref:s=>this.smsBtn=s},salla.lang.get("blocks.header.enter")),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.emailTab),class:"s-login-link"},this.byEmailText):"",i("slot",{name:"after-login-mobile"})):"",this.isEmailAllowed?i("div",{class:"s-login-tab",ref:s=>this.emailTab=s},i("slot",{name:"before-login-email"}),i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.loginEmail=s,onKeyDown:s=>this.typing(s,this.loginByEmail),placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"}),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.loginByEmail(),ref:s=>this.emailBtn=s},salla.lang.get("blocks.header.enter")),this.isMobileAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.mobileTab),class:"s-login-link"},this.bySMSText):"",i("slot",{name:"after-login-email"})):"",i("salla-verify-modal",{withoutModal:!0,ref:s=>this.verifyTab=s,autoReload:!1},i("a",{onClick:()=>this.showTab("phone"==this.regType?this.mobileTab:this.emailTab),class:"s-verify-modal-back sicon-arrow-right",slot:"after-footer",href:"#"})),i("div",{ref:s=>this.registrationTab=s},i("slot",{name:"before-registration"}),i("label",{class:"s-login-label"},this.firstNameLabel),i("input",{type:"text",class:"s-login-input",ref:s=>this.firstName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.first_name")}),i("span",{class:"s-login-error-message"}),i("label",{class:"s-login-label"},this.lastNameLabel),i("input",{type:"text",class:"s-login-input",ref:s=>this.lastName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.last_name")}),i("span",{class:"s-login-error-message"}),i("div",{ref:s=>this.regMobileBlock=s,class:"mb-1.5"},i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.regTelInput=s,onKeyDown:s=>this.typing(s,this.newUser)})),i("div",{ref:s=>this.regEmailBlock=s,class:"mb-1.5"},i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"})),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.newUser(),ref:s=>this.regBtn=s},salla.lang.get("blocks.header.register")),i("slot",{name:"after-registration"}))))}get host(){return t(this)}};l.style="";const a=class{constructor(i){var t;s(this,i),e.setHost(this.host),this.productSlot=(null===(t=e.getElement('[slot="product"]'))||void 0===t?void 0:t.innerHTML)||this.getDefaultProductSlot(),salla.event.on("search::show",(()=>this.modal.show())),salla.event.on("languages::translations.loaded",(()=>{this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options")}))}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=void 0,this.afterSearching()}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(e.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(e.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s)).catch((s=>"Query Same As Previous!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){var i;this.noResults.style.display=s||(null===(i=this.results)||void 0===i?void 0:i.data.length)>0?"none":"block",e.toggleElement(this.container,"s-search-container-open","no-results",(()=>{var s;return null===(s=this.results)||void 0===s?void 0:s.data.length})).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery=""}render(){var s;return i("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},i("div",{class:"s-search-container",ref:s=>this.container=s},i("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),i("span",{class:"s-search-icon"},i("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),i("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>i("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price).replace(/\{image\}/g,s.image_url)}))),i("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText))))}componentDidLoad(){this.afterSearching()}get host(){return t(this)}};a.style="#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";export{l as S,a}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as l}from"./p-cb1c59a2.js";(()=>{const l=import.meta.url,o={};return""!==l&&(o.resourcesUrl=new URL(".",l).href),e(o)})().then((e=>l([["p-
|
|
1
|
+
import{p as e,b as l}from"./p-cb1c59a2.js";(()=>{const l=import.meta.url,o={};return""!==l&&(o.resourcesUrl=new URL(".",l).href),e(o)})().then((e=>l([["p-4b774cf9",[[4,"salla-login",{isEmailAllowed:[1028,"is-email-allowed"],isMobileAllowed:[1028,"is-mobile-allowed"],isEmailRequired:[1028,"is-email-required"],title:[32],loginTypeTitle:[32],loginText:[32],smsLabel:[32],mobileLabel:[32],emailLabel:[32],enterText:[32],bySMSText:[32],byEmailText:[32],emailErrorMsg:[32],firstNameLabel:[32],lastNameLabel:[32],firstNameErrorMsg:[32],lastNameErrorMsg:[32],show:[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{language:[1537],currency:[1537],languages:[32],currencies:[32],languagesTitle:[32],currenciesTitle:[32],isLoading:[32],show:[64],hide:[64],submit:[64]}],[0,"salla-search",{results:[32],placeholder:[32],noResultsText:[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify-modal",{withoutModal:[4,"without-modal"],url:[513],by:[1],autoReload:[4,"auto-reload"],title:[32],getCode:[64],show:[64]}],[0,"salla-tel-input",{mobile:[1025],countryCode:[1025,"country-code"],countryKey:[1025,"country-key"],mobileRequired:[32],countryCodeLabel:[32],mobileLabel:[32],tooShort:[32],tooLong:[32],invalidCountryCode:[32],invalidNumber:[32],errorMap:[32],getValues:[64],isValid:[64]}],[4,"salla-button",{btnStyle:[513,"btn-style"],loading:[516],disabled:[516],loaderPosition:[1,"loader-position"],wide:[4],load:[64],stop:[64],setText:[64],disable:[64],enable:[64]}],[4,"salla-modal",{isClosable:[1028,"is-closable"],width:[513],position:[513],visible:[516],isLoading:[1540,"is-loading"],subTitleFirst:[4,"sub-title-first"],noPadding:[4,"no-padding"],subTitle:[1,"sub-title"],icon:[1],iconStyle:[1,"icon-style"],imageIcon:[1,"image-icon"],title:[32],show:[64],hide:[64],setTitle:[64],loading:[64],stopLoading:[64]}]]],["p-c0a7b5a2",[[4,"salla-product-availability",{channels:[1],productId:[2,"product-id"],isSubscribed:[1028,"is-subscribed"],subTitle:[32],mobileLabel:[32],emailLabel:[32],emailPlaceholder:[32],subscribedMessage:[32],title_:[32],emailErrorMsg:[32],isVisitorSubscribed:[32]}]]],["p-e6c67b55",[[4,"salla-branches",{position:[1],displayAs:[1,"display-as"],browseProductsFrom:[1,"browse-products-from"],branches:[16],current:[1026],open:[32],selected:[32],isOpenedBefore:[32],show:[64],hide:[64]}]]],["p-152b7287",[[0,"salla-offer",{offer:[32],offer_name:[32],offer_message:[32],offer_expires_in:[32],remember_my_choice:[32],show:[64],showOffer:[64]}]]],["p-b584e892",[[0,"salla-rating",{orderId:[2,"order-id"],order:[32],show:[64],hide:[64]}]]],["p-f89bc866",[[4,"salla-infinite-scroll",{nextPage:[1,"next-page"],nextPageAutoload:[1028,"next-page-autoload"],container:[1],item:[1],loadMore:[32],noMore:[32],failedToLoad:[32]}]]]],e)));
|
|
@@ -14,17 +14,14 @@ export declare class SallaLogin {
|
|
|
14
14
|
host: HTMLElement;
|
|
15
15
|
/**
|
|
16
16
|
* Does the merchant allow to login using email
|
|
17
|
-
* Default: salla.config.get('store.settings.auth.email_allowed', true)
|
|
18
17
|
*/
|
|
19
18
|
isEmailAllowed: boolean;
|
|
20
19
|
/**
|
|
21
20
|
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
22
|
-
* Default: salla.config.get('store.settings.auth.mobile_allowed', true)
|
|
23
21
|
*/
|
|
24
22
|
isMobileAllowed: boolean;
|
|
25
23
|
/**
|
|
26
24
|
* Does the merchant require registration with email & mobile
|
|
27
|
-
* Default: salla.config.get('store.settings.auth.is_email_required', false)
|
|
28
25
|
*/
|
|
29
26
|
isEmailRequired: boolean;
|
|
30
27
|
private modal;
|
|
@@ -91,15 +91,15 @@ export namespace Components {
|
|
|
91
91
|
}
|
|
92
92
|
interface SallaLogin {
|
|
93
93
|
/**
|
|
94
|
-
* Does the merchant allow to login using email
|
|
94
|
+
* Does the merchant allow to login using email
|
|
95
95
|
*/
|
|
96
96
|
"isEmailAllowed": boolean;
|
|
97
97
|
/**
|
|
98
|
-
* Does the merchant require registration with email & mobile
|
|
98
|
+
* Does the merchant require registration with email & mobile
|
|
99
99
|
*/
|
|
100
100
|
"isEmailRequired": boolean;
|
|
101
101
|
/**
|
|
102
|
-
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
102
|
+
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
103
103
|
*/
|
|
104
104
|
"isMobileAllowed": boolean;
|
|
105
105
|
/**
|
|
@@ -393,15 +393,15 @@ declare namespace LocalJSX {
|
|
|
393
393
|
}
|
|
394
394
|
interface SallaLogin {
|
|
395
395
|
/**
|
|
396
|
-
* Does the merchant allow to login using email
|
|
396
|
+
* Does the merchant allow to login using email
|
|
397
397
|
*/
|
|
398
398
|
"isEmailAllowed"?: boolean;
|
|
399
399
|
/**
|
|
400
|
-
* Does the merchant require registration with email & mobile
|
|
400
|
+
* Does the merchant require registration with email & mobile
|
|
401
401
|
*/
|
|
402
402
|
"isEmailRequired"?: boolean;
|
|
403
403
|
/**
|
|
404
|
-
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
404
|
+
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
405
405
|
*/
|
|
406
406
|
"isMobileAllowed"?: boolean;
|
|
407
407
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,h as i,g as t}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";const l=class{constructor(i){s(this,i),this.regType="phone",this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),this.typing=(s,i)=>{const t=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==t?void 0:t.classList.contains("s-login-error-message"))&&(t.innerText=""),"Enter"==s.key&&i()},this.loginBySMS=async()=>{const{mobile:s,countryCode:i}=await this.loginTelInput.getValues();await this.loginTelInput.isValid()&&this.smsBtn.load().then((()=>this.smsBtn.disable())).then((()=>salla.auth.api.login({type:"mobile",phone:s,country_code:i}))).then((()=>this.smsBtn.stop()&&this.smsBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>(this.verifyTab.by="sms")&&(this.verifyTab.url="auth/mobile/verify"))).then((()=>this.verifyTab.show({phone:s,country_code:i})))},this.loginByEmail=()=>{e.isValidEmail(this.loginEmail.value)?this.emailBtn.load().then((()=>this.emailBtn.disable())).then((()=>salla.auth.api.login({type:"email",email:this.loginEmail.value}))).then((()=>this.emailBtn.stop()&&this.emailBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.by="email")).then((()=>this.verifyTab.show({email:this.loginEmail.value}))):this.validateField(this.loginEmail,this.emailErrorMsg)},this.newUser=async()=>{var s;const{mobile:i,countryCode:t,countryKey:e}=await this.regTelInput.getValues(),l=this.regEmail.value||(null===(s=this.loginEmail)||void 0===s?void 0:s.value);await this.newUserValidation(),await this.regBtn.load(),await this.regBtn.disable();let a={first_name:this.firstName.value,last_name:this.lastName.value,phone:i||this.loginTelInput.mobile,country_code:t,country_key:e,verified_by:this.regType};l&&(a=Object.assign(Object.assign({},a),{email:l})),this.verifyTab.getCode().then((s=>salla.auth.api.register(Object.assign(Object.assign({},a),{code:s})))).then((()=>window.location.reload())).catch((()=>this.regBtn.stop()&&this.regBtn.enable()))},this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.event.on("languages::translations.loaded",(()=>{var s,i,t,e;this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.smsBtn)||void 0===i||i.setText(salla.lang.get("blocks.header.enter")),null===(t=this.emailBtn)||void 0===t||t.setText(salla.lang.get("blocks.header.enter")),null===(e=this.regBtn)||void 0===e||e.setText(salla.lang.get("blocks.header.register"))})),salla.auth.event.onVerificationFailed((()=>{})),salla.event.on("login::show",(()=>this.show()))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}async show(){return this.isEmailAllowed=void 0!==this.isEmailAllowed?this.isEmailAllowed:salla.config.get("store.settings.auth.email_allowed",!0),this.isMobileAllowed=void 0!==this.isMobileAllowed?this.isMobileAllowed:salla.config.get("store.settings.auth.mobile_allowed",!0),this.isEmailRequired=void 0!==this.isEmailRequired?this.isEmailRequired:salla.config.get("store.settings.auth.is_email_required",!1),this.isEmailAllowed&&this.isMobileAllowed?this.showTab(this.homeTab):this.isEmailAllowed?this.showTab(this.emailTab):this.isMobileAllowed&&this.showTab(this.mobileTab),this.modal.show()}showTab(s,i){var t,l;null==i||i.preventDefault(),[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab].map((i=>e.toggleElement(i,"visible","s-hidden",(()=>i==s)))),setTimeout((()=>{[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab].map((i=>e.toggleElement(i,"s-login-active","s-login-unactive",(()=>i==s))))}),200),setTimeout((()=>{this.host.querySelector(".s-login-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px")})),[this.mobileTab,this.emailTab].includes(s)&&(this.regType=s===this.mobileTab?"phone":"email");let a=s==this.registrationTab;return a&&(null===(t=this.firstName)||void 0===t||t.focus()),null===(l=this.modal)||void 0===l||l.setTitle(a?salla.lang.get("common.titles.registration"):this.title),a||e.toggleElement(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElement(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}async newUserValidation(){const s="phone"==this.regType,i=this.regEmail.value||"email"==this.regType&&this.loginEmail.value,t=e.isValidEmail(i),l=this.firstName.value.length>0,a=this.lastName.value.length>0,o=await this.regTelInput.isValid()||s&&await this.loginTelInput.isValid();if(!((i&&t||!i&&!this.isEmailRequired)&&o&&l&&a))throw!t&&this.validateField(this.regEmail,this.emailErrorMsg),!l&&this.validateField(this.firstName,this.firstNameErrorMsg),!a&&this.validateField(this.lastName,this.lastNameErrorMsg),"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i("salla-modal",{id:"salla-login",icon:"sicon-user",title:this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-wrapper"},this.isEmailAllowed&&this.isMobileAllowed?i("div",{class:"s-login-tab",ref:s=>this.homeTab=s},i("p",{class:"s-login-sub-title"},this.loginTypeTitle),i("slot",{name:"before-login-type"}),i("a",{href:"#",class:"s-login-main-btn",onClick:s=>this.showTab(this.mobileTab,s)},i("i",{class:"s-login-main-btn-icon sicon-phone"}),i("span",{class:"s-login-main-btn-text"},this.smsLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"})),i("a",{href:"#",class:"s-login-main-btn",onClick:s=>this.showTab(this.emailTab,s)},i("i",{class:"s-login-main-btn-icon sicon-mail"}),i("span",{class:"s-login-main-btn-text"},this.emailLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"})),i("slot",{name:"after-login-type"})):"",this.isMobileAllowed?i("div",{class:"s-login-tab",ref:s=>this.mobileTab=s},i("slot",{name:"before-login-mobile"}),i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.loginTelInput=s,onKeyDown:s=>this.typing(s,this.loginBySMS)}),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.loginBySMS(),ref:s=>this.smsBtn=s},salla.lang.get("blocks.header.enter")),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.emailTab),class:"s-login-link"},this.byEmailText):"",i("slot",{name:"after-login-mobile"})):"",this.isEmailAllowed?i("div",{class:"s-login-tab",ref:s=>this.emailTab=s},i("slot",{name:"before-login-email"}),i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.loginEmail=s,onKeyDown:s=>this.typing(s,this.loginByEmail),placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"}),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.loginByEmail(),ref:s=>this.emailBtn=s},salla.lang.get("blocks.header.enter")),this.isMobileAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.mobileTab),class:"s-login-link"},this.bySMSText):"",i("slot",{name:"after-login-email"})):"",i("salla-verify-modal",{withoutModal:!0,ref:s=>this.verifyTab=s,autoReload:!1},i("a",{onClick:()=>this.showTab("phone"==this.regType?this.mobileTab:this.emailTab),class:"s-verify-modal-back sicon-arrow-right",slot:"after-footer",href:"#"})),i("div",{ref:s=>this.registrationTab=s},i("slot",{name:"before-registration"}),i("label",{class:"s-login-label"},this.firstNameLabel),i("input",{type:"text",class:"s-login-input",ref:s=>this.firstName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.first_name")}),i("span",{class:"s-login-error-message"}),i("label",{class:"s-login-label"},this.lastNameLabel),i("input",{type:"text",class:"s-login-input",ref:s=>this.lastName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.last_name")}),i("span",{class:"s-login-error-message"}),i("div",{ref:s=>this.regMobileBlock=s,class:"mb-1.5"},i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.regTelInput=s,onKeyDown:s=>this.typing(s,this.newUser)})),i("div",{ref:s=>this.regEmailBlock=s,class:"mb-1.5"},i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"})),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.newUser(),ref:s=>this.regBtn=s},salla.lang.get("blocks.header.register")),i("slot",{name:"after-registration"}))))}get host(){return t(this)}};l.style="";const a=class{constructor(i){var t;s(this,i),e.setHost(this.host),this.productSlot=(null===(t=e.getElement('[slot="product"]'))||void 0===t?void 0:t.innerHTML)||this.getDefaultProductSlot(),salla.event.on("search::show",(()=>this.modal.show())),salla.event.on("languages::translations.loaded",(()=>{this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options")}))}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=void 0,this.afterSearching()}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(e.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(e.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s)).catch((s=>"Query Same As Previous!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){var i;this.noResults.style.display=s||(null===(i=this.results)||void 0===i?void 0:i.data.length)>0?"none":"block",e.toggleElement(this.container,"s-search-container-open","no-results",(()=>{var s;return null===(s=this.results)||void 0===s?void 0:s.data.length})).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery=""}render(){var s;return i("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},i("div",{class:"s-search-container",ref:s=>this.container=s},i("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),i("span",{class:"s-search-icon"},i("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),i("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>i("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price).replace(/\{image\}/g,s.image_url)}))),i("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText))))}componentDidLoad(){this.afterSearching()}get host(){return t(this)}};a.style="#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";export{l as S,a}
|