@etsoo/appscript 1.4.77 → 1.4.78

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.
@@ -42,22 +42,16 @@ class PublicApi extends BaseApi_1.BaseApi {
42
42
  }
43
43
  currencies(names) {
44
44
  if (typeof names === 'boolean' && names) {
45
- return Currency_1.Currencies.map((name) => {
46
- var _a;
47
- return ({
48
- id: name,
49
- label: (_a = this.app.get(`currency${name}`)) !== null && _a !== void 0 ? _a : name
50
- });
51
- });
45
+ return Currency_1.Currencies.map((name) => ({
46
+ id: name,
47
+ label: this.app.get(`currency${name}`) ?? name
48
+ }));
52
49
  }
53
50
  if (Array.isArray(names)) {
54
- return names.map((name) => {
55
- var _a;
56
- return ({
57
- id: name,
58
- label: (_a = this.app.get(`currency${name}`)) !== null && _a !== void 0 ? _a : name
59
- });
60
- });
51
+ return names.map((name) => ({
52
+ id: name,
53
+ label: this.app.get(`currency${name}`) ?? name
54
+ }));
61
55
  }
62
56
  return this.api.get('Public/GetCurrencies', undefined, {
63
57
  defaultValue: [],
@@ -72,7 +66,7 @@ class PublicApi extends BaseApi_1.BaseApi {
72
66
  * @returns Result
73
67
  */
74
68
  async exchangeAmount(amount, sourceCurrency, targetCurrency) {
75
- targetCurrency !== null && targetCurrency !== void 0 ? targetCurrency : (targetCurrency = this.app.defaultRegion.currency);
69
+ targetCurrency ?? (targetCurrency = this.app.defaultRegion.currency);
76
70
  const [sourceRate, targetRate] = await Promise.all([
77
71
  this.exchangeRate(sourceCurrency, {
78
72
  showLoading: false
@@ -115,7 +109,7 @@ class PublicApi extends BaseApi_1.BaseApi {
115
109
  * @returns Result
116
110
  */
117
111
  exchangeRateHistory(currencies, months, payload) {
118
- payload !== null && payload !== void 0 ? payload : (payload = { defaultValue: [] });
112
+ payload ?? (payload = { defaultValue: [] });
119
113
  return this.api.post('Public/ExchangeRateHistory', { currencies, months }, payload);
120
114
  }
121
115
  /**
@@ -132,9 +126,8 @@ class PublicApi extends BaseApi_1.BaseApi {
132
126
  * @returns Label
133
127
  */
134
128
  getCurrencyLabel(currency) {
135
- var _a;
136
129
  const c = `currency${currency}`;
137
- return (_a = this.app.get(c)) !== null && _a !== void 0 ? _a : c;
130
+ return this.app.get(c) ?? c;
138
131
  }
139
132
  /**
140
133
  * Get product unit's label
@@ -144,9 +137,8 @@ class PublicApi extends BaseApi_1.BaseApi {
144
137
  * @returns Label
145
138
  */
146
139
  getUnitLabel(unit, isJoined) {
147
- var _a;
148
140
  const key = ProductUnit_1.ProductUnit[unit];
149
- const label = (_a = this.app.get(unitPrefix + key)) !== null && _a !== void 0 ? _a : key;
141
+ const label = this.app.get(unitPrefix + key) ?? key;
150
142
  const join = this.getUnitJoin(isJoined);
151
143
  if (join) {
152
144
  return join.format(label);
@@ -154,9 +146,8 @@ class PublicApi extends BaseApi_1.BaseApi {
154
146
  return label;
155
147
  }
156
148
  getUnitJoin(isJoined) {
157
- var _a;
158
149
  return typeof isJoined === 'string'
159
- ? (_a = this.app.get(isJoined)) !== null && _a !== void 0 ? _a : isJoined
150
+ ? this.app.get(isJoined) ?? isJoined
160
151
  : isJoined
161
152
  ? this.app.get('unitJoin')
162
153
  : undefined;
@@ -177,9 +168,8 @@ class PublicApi extends BaseApi_1.BaseApi {
177
168
  * @returns Result
178
169
  */
179
170
  parsePin(input, payload) {
180
- var _a;
181
171
  const rq = typeof input === 'string' ? { pin: input } : input;
182
- (_a = rq.language) !== null && _a !== void 0 ? _a : (rq.language = this.app.culture);
172
+ rq.language ?? (rq.language = this.app.culture);
183
173
  return this.api.post('Public/ParsePin', rq, payload);
184
174
  }
185
175
  /**
@@ -201,7 +191,7 @@ class PublicApi extends BaseApi_1.BaseApi {
201
191
  * @returns Units
202
192
  */
203
193
  repeatOptions(options, isJoined = true) {
204
- options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(RepeatOption_1.RepeatOption));
194
+ options ?? (options = shared_1.DataTypes.getEnumKeys(RepeatOption_1.RepeatOption));
205
195
  return this.units(options, isJoined);
206
196
  }
207
197
  /**
@@ -220,7 +210,7 @@ class PublicApi extends BaseApi_1.BaseApi {
220
210
  * @returns Units
221
211
  */
222
212
  units(options, isJoined) {
223
- options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(ProductUnit_1.ProductUnit));
213
+ options ?? (options = shared_1.DataTypes.getEnumKeys(ProductUnit_1.ProductUnit));
224
214
  return options.map((key) => {
225
215
  const id = shared_1.DataTypes.getEnumByKey(ProductUnit_1.ProductUnit, key);
226
216
  return {
@@ -116,7 +116,6 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
116
116
  get isReady(): boolean;
117
117
  private set isReady(value);
118
118
  private _isTryingLogin;
119
- private CJ;
120
119
  /**
121
120
  * Last called with token refresh
122
121
  */
@@ -8,6 +8,8 @@ import { EntityStatus } from '../business/EntityStatus';
8
8
  import { ActionResultError } from '../result/ActionResultError';
9
9
  import { appFields } from './IApp';
10
10
  import { UserRole } from './UserRole';
11
+ let CJ;
12
+ const loadCrypto = () => import('crypto-js');
11
13
  /**
12
14
  * Core application
13
15
  */
@@ -98,7 +100,6 @@ export class CoreApp {
98
100
  * @param name Application name
99
101
  */
100
102
  constructor(settings, api, notifier, storage, name) {
101
- var _a;
102
103
  /**
103
104
  * Pending actions
104
105
  */
@@ -106,7 +107,6 @@ export class CoreApp {
106
107
  this._authorized = false;
107
108
  this._isReady = false;
108
109
  this._isTryingLogin = false;
109
- this.CJ = null;
110
110
  /**
111
111
  * Last called with token refresh
112
112
  */
@@ -123,7 +123,7 @@ export class CoreApp {
123
123
  * Passphrase for encryption
124
124
  */
125
125
  this.passphrase = '';
126
- if (((_a = settings === null || settings === void 0 ? void 0 : settings.regions) === null || _a === void 0 ? void 0 : _a.length) === 0) {
126
+ if (settings?.regions?.length === 0) {
127
127
  throw new Error('No regions defined');
128
128
  }
129
129
  this.settings = settings;
@@ -143,11 +143,8 @@ export class CoreApp {
143
143
  this.setApi(api);
144
144
  const { currentCulture, currentRegion } = settings;
145
145
  // Load resources
146
- Promise.all([
147
- import('crypto-js'),
148
- this.changeCulture(currentCulture)
149
- ]).then(([cj, _resources]) => {
150
- (this.CJ = cj), this.changeRegion(currentRegion);
146
+ Promise.all([loadCrypto(), this.changeCulture(currentCulture)]).then(([cj, _resources]) => {
147
+ (CJ = cj), this.changeRegion(currentRegion);
151
148
  this.setup();
152
149
  });
153
150
  }
@@ -330,7 +327,7 @@ export class CoreApp {
330
327
  * @param action Custom action
331
328
  */
332
329
  setupLogging(action) {
333
- action !== null && action !== void 0 ? action : (action = (data) => {
330
+ action ?? (action = (data) => {
334
331
  this.api.post('Auth/LogFrontendError', data, {
335
332
  onError: (error) => {
336
333
  // Use 'debug' to avoid infinite loop
@@ -376,7 +373,6 @@ export class CoreApp {
376
373
  * @returns Result
377
374
  */
378
375
  async initCall(callback, resetKeys) {
379
- var _a;
380
376
  // Reset keys
381
377
  if (resetKeys) {
382
378
  this.clearDeviceId();
@@ -418,7 +414,7 @@ export class CoreApp {
418
414
  if (result.title === 'timeDifferenceInvalid' &&
419
415
  seconds != null &&
420
416
  validSeconds != null) {
421
- const title = (_a = this.get('timeDifferenceInvalid')) === null || _a === void 0 ? void 0 : _a.format(seconds.toString(), validSeconds.toString());
417
+ const title = this.get('timeDifferenceInvalid')?.format(seconds.toString(), validSeconds.toString());
422
418
  this.notifier.alert(title);
423
419
  }
424
420
  else {
@@ -518,7 +514,6 @@ export class CoreApp {
518
514
  * @param refreshToken Refresh token
519
515
  */
520
516
  authorize(token, refreshToken) {
521
- var _a;
522
517
  // State, when token is null, means logout
523
518
  this.authorized = token != null;
524
519
  // Token
@@ -539,7 +534,7 @@ export class CoreApp {
539
534
  this.refreshCountdownClear();
540
535
  }
541
536
  // Host notice
542
- (_a = BridgeUtils.host) === null || _a === void 0 ? void 0 : _a.userAuthorization(this.authorized);
537
+ BridgeUtils.host?.userAuthorization(this.authorized);
543
538
  }
544
539
  /**
545
540
  * Change country or region
@@ -647,12 +642,12 @@ export class CoreApp {
647
642
  const iterations = parseInt(messageEncrypted.substring(0, 2), 10);
648
643
  if (isNaN(iterations))
649
644
  return undefined;
650
- const { PBKDF2, algo, enc, AES, pad, mode } = this.CJ;
645
+ const { PBKDF2, algo, enc, AES, pad, mode } = CJ;
651
646
  try {
652
647
  const salt = enc.Hex.parse(messageEncrypted.substring(2, 34));
653
648
  const iv = enc.Hex.parse(messageEncrypted.substring(34, 66));
654
649
  const encrypted = messageEncrypted.substring(66);
655
- const key = PBKDF2(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, salt, {
650
+ const key = PBKDF2(passphrase ?? this.passphrase, salt, {
656
651
  keySize: 8, // 256 / 32
657
652
  hasher: algo.SHA256,
658
653
  iterations: 1000 * iterations
@@ -695,7 +690,7 @@ export class CoreApp {
695
690
  return undefined;
696
691
  }
697
692
  const message = messageEncrypted.substring(pos + 1);
698
- passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
693
+ passphrase = this.encryptionEnhance(passphrase ?? this.passphrase, timestamp);
699
694
  return this.decrypt(message, passphrase);
700
695
  }
701
696
  catch (e) {
@@ -733,8 +728,7 @@ export class CoreApp {
733
728
  }
734
729
  // Detect IP callbacks
735
730
  detectIPCallbacks() {
736
- var _a;
737
- (_a = this.ipDetectCallbacks) === null || _a === void 0 ? void 0 : _a.forEach((f) => f());
731
+ this.ipDetectCallbacks?.forEach((f) => f());
738
732
  }
739
733
  /**
740
734
  * Download file
@@ -774,11 +768,11 @@ export class CoreApp {
774
768
  */
775
769
  encrypt(message, passphrase, iterations) {
776
770
  // Default 1 * 1000
777
- iterations !== null && iterations !== void 0 ? iterations : (iterations = 1);
778
- const { lib, PBKDF2, algo, enc, AES, pad, mode } = this.CJ;
771
+ iterations ?? (iterations = 1);
772
+ const { lib, PBKDF2, algo, enc, AES, pad, mode } = CJ;
779
773
  const bits = 16; // 128 / 8
780
774
  const salt = lib.WordArray.random(bits);
781
- const key = PBKDF2(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, salt, {
775
+ const key = PBKDF2(passphrase ?? this.passphrase, salt, {
782
776
  keySize: 8, // 256 / 32
783
777
  hasher: algo.SHA256,
784
778
  iterations: 1000 * iterations
@@ -804,7 +798,7 @@ export class CoreApp {
804
798
  encryptEnhanced(message, passphrase, iterations) {
805
799
  // Timestamp
806
800
  const timestamp = Utils.numberToChars(new Date().getTime());
807
- passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
801
+ passphrase = this.encryptionEnhance(passphrase ?? this.passphrase, timestamp);
808
802
  const result = this.encrypt(message, passphrase, iterations);
809
803
  return timestamp + '!' + result;
810
804
  }
@@ -839,7 +833,7 @@ export class CoreApp {
839
833
  */
840
834
  formatDate(input, options, timeZone) {
841
835
  const { currentCulture, timeZone: defaultTimeZone } = this.settings;
842
- timeZone !== null && timeZone !== void 0 ? timeZone : (timeZone = defaultTimeZone);
836
+ timeZone ?? (timeZone = defaultTimeZone);
843
837
  return DateUtils.format(input, currentCulture.name, options, timeZone);
844
838
  }
845
839
  /**
@@ -888,11 +882,11 @@ export class CoreApp {
888
882
  if (typeof result === 'object' &&
889
883
  !(result instanceof ApiDataError) &&
890
884
  this.checkDeviceResult(result)) {
891
- initCallCallback !== null && initCallCallback !== void 0 ? initCallCallback : (initCallCallback = (result) => {
892
- var _a;
885
+ initCallCallback ?? (initCallCallback = (result) => {
893
886
  if (!result)
894
887
  return;
895
- this.notifier.alert((_a = this.get('environmentChanged')) !== null && _a !== void 0 ? _a : 'Environment changed', () => {
888
+ this.notifier.alert(this.get('environmentChanged') ??
889
+ 'Environment changed', () => {
896
890
  // Reload the page
897
891
  history.go(0);
898
892
  });
@@ -916,9 +910,9 @@ export class CoreApp {
916
910
  */
917
911
  formatFullName(familyName, givenName) {
918
912
  if (!familyName)
919
- return givenName !== null && givenName !== void 0 ? givenName : '';
913
+ return givenName ?? '';
920
914
  if (!givenName)
921
- return familyName !== null && familyName !== void 0 ? familyName : '';
915
+ return familyName ?? '';
922
916
  const wf = givenName + ' ' + familyName;
923
917
  if (wf.containChinese() || wf.containJapanese() || wf.containKorean()) {
924
918
  return familyName + givenName;
@@ -946,7 +940,6 @@ export class CoreApp {
946
940
  * @param forceToLocal Force to local labels
947
941
  */
948
942
  formatResult(result, forceToLocal) {
949
- var _a;
950
943
  const title = result.title;
951
944
  if (title && /^\w+$/.test(title)) {
952
945
  const key = title.formatInitial(false);
@@ -964,7 +957,7 @@ export class CoreApp {
964
957
  result.title = this.get(key);
965
958
  }
966
959
  // When title contains {0}, replace with the field label
967
- if (result.field && ((_a = result.title) === null || _a === void 0 ? void 0 : _a.includes('{0}'))) {
960
+ if (result.field && result.title?.includes('{0}')) {
968
961
  const fieldLabel = this.get(result.field.formatInitial(false));
969
962
  if (fieldLabel)
970
963
  result.title = result.title.format(fieldLabel);
@@ -993,7 +986,7 @@ export class CoreApp {
993
986
  */
994
987
  getLabels(...keys) {
995
988
  const init = {};
996
- return keys.reduce((a, v) => { var _a; return ({ ...a, [v]: (_a = this.get(v)) !== null && _a !== void 0 ? _a : '' }); }, init);
989
+ return keys.reduce((a, v) => ({ ...a, [v]: this.get(v) ?? '' }), init);
997
990
  }
998
991
  /**
999
992
  * Get bool items
@@ -1031,18 +1024,16 @@ export class CoreApp {
1031
1024
  * @returns List
1032
1025
  */
1033
1026
  getEnumList(em, prefix, filter) {
1034
- var _a;
1035
1027
  const list = [];
1036
1028
  const getKey = typeof prefix === 'function'
1037
1029
  ? prefix
1038
1030
  : (key) => prefix + key;
1039
1031
  if (Array.isArray(filter)) {
1040
1032
  filter.forEach((id) => {
1041
- var _a;
1042
1033
  if (typeof id !== 'number')
1043
1034
  return;
1044
1035
  const key = DataTypes.getEnumKey(em, id);
1045
- const label = (_a = this.get(getKey(key))) !== null && _a !== void 0 ? _a : key;
1036
+ const label = this.get(getKey(key)) ?? key;
1046
1037
  list.push({ id, label });
1047
1038
  });
1048
1039
  }
@@ -1058,7 +1049,7 @@ export class CoreApp {
1058
1049
  }
1059
1050
  if (typeof id !== 'number')
1060
1051
  continue;
1061
- const label = (_a = this.get(getKey(key))) !== null && _a !== void 0 ? _a : key;
1052
+ const label = this.get(getKey(key)) ?? key;
1062
1053
  list.push({ id, label });
1063
1054
  }
1064
1055
  }
@@ -1072,7 +1063,6 @@ export class CoreApp {
1072
1063
  * @returns List
1073
1064
  */
1074
1065
  getEnumStrList(em, prefix, filter) {
1075
- var _a;
1076
1066
  const list = [];
1077
1067
  const getKey = typeof prefix === 'function'
1078
1068
  ? prefix
@@ -1086,7 +1076,7 @@ export class CoreApp {
1086
1076
  continue;
1087
1077
  id = fid;
1088
1078
  }
1089
- var label = (_a = this.get(getKey(key))) !== null && _a !== void 0 ? _a : key;
1079
+ var label = this.get(getKey(key)) ?? key;
1090
1080
  list.push({ id: id.toString(), label });
1091
1081
  }
1092
1082
  return list;
@@ -1097,8 +1087,7 @@ export class CoreApp {
1097
1087
  * @returns Label
1098
1088
  */
1099
1089
  getRegionLabel(id) {
1100
- var _a;
1101
- return (_a = this.get('region' + id)) !== null && _a !== void 0 ? _a : id;
1090
+ return this.get('region' + id) ?? id;
1102
1091
  }
1103
1092
  /**
1104
1093
  * Get all regions
@@ -1132,11 +1121,10 @@ export class CoreApp {
1132
1121
  * @param status Status value
1133
1122
  */
1134
1123
  getStatusLabel(status) {
1135
- var _a;
1136
1124
  if (status == null)
1137
1125
  return '';
1138
1126
  const key = EntityStatus[status];
1139
- return (_a = this.get('status' + key)) !== null && _a !== void 0 ? _a : key;
1127
+ return this.get('status' + key) ?? key;
1140
1128
  }
1141
1129
  /**
1142
1130
  * Get refresh token from response headers
@@ -1152,9 +1140,8 @@ export class CoreApp {
1152
1140
  * @returns Time zone
1153
1141
  */
1154
1142
  getTimeZone() {
1155
- var _a, _b;
1156
1143
  // settings.timeZone = Utils.getTimeZone()
1157
- return (_a = this.settings.timeZone) !== null && _a !== void 0 ? _a : (_b = this.ipData) === null || _b === void 0 ? void 0 : _b.timezone;
1144
+ return this.settings.timeZone ?? this.ipData?.timezone;
1158
1145
  }
1159
1146
  /**
1160
1147
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
@@ -1163,7 +1150,7 @@ export class CoreApp {
1163
1150
  * @param passphrase Secret passphrase
1164
1151
  */
1165
1152
  hash(message, passphrase) {
1166
- const { SHA3, enc, HmacSHA512 } = this.CJ;
1153
+ const { SHA3, enc, HmacSHA512 } = CJ;
1167
1154
  if (passphrase == null)
1168
1155
  return SHA3(message, { outputLength: 512 }).toString(enc.Base64);
1169
1156
  else
@@ -1176,7 +1163,7 @@ export class CoreApp {
1176
1163
  * @param passphrase Secret passphrase
1177
1164
  */
1178
1165
  hashHex(message, passphrase) {
1179
- const { SHA3, enc, HmacSHA512 } = this.CJ;
1166
+ const { SHA3, enc, HmacSHA512 } = CJ;
1180
1167
  if (passphrase == null)
1181
1168
  return SHA3(message, { outputLength: 512 }).toString(enc.Hex);
1182
1169
  else
@@ -1188,8 +1175,7 @@ export class CoreApp {
1188
1175
  * @returns Result
1189
1176
  */
1190
1177
  hasPermission(roles) {
1191
- var _a;
1192
- const userRole = (_a = this.userData) === null || _a === void 0 ? void 0 : _a.role;
1178
+ const userRole = this.userData?.role;
1193
1179
  if (userRole == null)
1194
1180
  return false;
1195
1181
  if (Array.isArray(roles)) {
@@ -1231,7 +1217,7 @@ export class CoreApp {
1231
1217
  globalThis.history.go(to);
1232
1218
  }
1233
1219
  else {
1234
- const { state, replace = false } = options !== null && options !== void 0 ? options : {};
1220
+ const { state, replace = false } = options ?? {};
1235
1221
  if (replace) {
1236
1222
  if (state)
1237
1223
  globalThis.history.replaceState(state, '', to);
@@ -1250,8 +1236,7 @@ export class CoreApp {
1250
1236
  * Callback where exit a page
1251
1237
  */
1252
1238
  pageExit() {
1253
- var _a;
1254
- (_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.dismiss();
1239
+ this.lastWarning?.dismiss();
1255
1240
  }
1256
1241
  /**
1257
1242
  * Refresh countdown
@@ -1330,7 +1315,7 @@ export class CoreApp {
1330
1315
  * @param removeUrl Remove current URL for reuse
1331
1316
  */
1332
1317
  toLoginPage(tryLogin, removeUrl) {
1333
- const url = `/?tryLogin=${tryLogin !== null && tryLogin !== void 0 ? tryLogin : false}` +
1318
+ const url = `/?tryLogin=${tryLogin ?? false}` +
1334
1319
  (removeUrl ? '' : '&url=' + encodeURIComponent(location.href));
1335
1320
  this.navigate(url);
1336
1321
  }
@@ -1384,12 +1369,11 @@ export class CoreApp {
1384
1369
  * @param align Align, default as TopRight
1385
1370
  */
1386
1371
  warning(message, align) {
1387
- var _a, _b;
1388
1372
  // Same message is open
1389
- if (((_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.open) && ((_b = this.lastWarning) === null || _b === void 0 ? void 0 : _b.content) === message)
1373
+ if (this.lastWarning?.open && this.lastWarning?.content === message)
1390
1374
  return;
1391
1375
  this.lastWarning = this.notifier.message(NotificationMessageType.Warning, message, undefined, {
1392
- align: align !== null && align !== void 0 ? align : NotificationAlign.TopRight
1376
+ align: align ?? NotificationAlign.TopRight
1393
1377
  });
1394
1378
  }
1395
1379
  }
@@ -51,7 +51,6 @@ export class FlutterHost {
51
51
  this.cacheCommand('exit');
52
52
  }
53
53
  async getLabels(...keys) {
54
- var _a;
55
54
  // Try 500 miliseconds
56
55
  let count = 5;
57
56
  while (this.host.callHandler == null) {
@@ -63,14 +62,11 @@ export class FlutterHost {
63
62
  const init = {};
64
63
  if (this.host.callHandler == null)
65
64
  return init;
66
- const result = (_a = (await this.host.callHandler('getLabels'))) !== null && _a !== void 0 ? _a : {};
67
- return keys.reduce((a, v) => {
68
- var _a;
69
- return ({
70
- ...a,
71
- [v]: (_a = result[v]) !== null && _a !== void 0 ? _a : ''
72
- });
73
- }, init);
65
+ const result = (await this.host.callHandler('getLabels')) ?? {};
66
+ return keys.reduce((a, v) => ({
67
+ ...a,
68
+ [v]: result[v] ?? ''
69
+ }), init);
74
70
  }
75
71
  getStartUrl() {
76
72
  return this.startUrl;
@@ -41,9 +41,8 @@ export var BusinessUtils;
41
41
  * @param data Data to format
42
42
  */
43
43
  function formatCultues(cultures, data) {
44
- var _a;
45
44
  // Add the lost cultures
46
- const allCultures = (_a = data.cultures) !== null && _a !== void 0 ? _a : [];
45
+ const allCultures = data.cultures ?? [];
47
46
  cultures.forEach((culture) => {
48
47
  if (!allCultures.some((a) => a.id === culture.id)) {
49
48
  allCultures.push({ id: culture.id, title: '' });
@@ -39,9 +39,9 @@ export class ShoppingCart {
39
39
  * @returns Result
40
40
  */
41
41
  static getCartData(storage, id) {
42
- var _a;
43
42
  try {
44
- return ((_a = storage.getPersistedObject(id)) !== null && _a !== void 0 ? _a : storage.getObject(id));
43
+ return (storage.getPersistedObject(id) ??
44
+ storage.getObject(id));
45
45
  }
46
46
  catch (error) {
47
47
  console.warn(`ShoppingCart getCartData ${id} error`, error);
@@ -174,11 +174,11 @@ export class ShoppingCart {
174
174
  }
175
175
  }
176
176
  getCartData() {
177
- var _a;
178
- return ((_a = this.storage.getPersistedObject(this.identifier)) !== null && _a !== void 0 ? _a : this.storage.getObject(this.identifier));
177
+ return (this.storage.getPersistedObject(this.identifier) ??
178
+ this.storage.getObject(this.identifier));
179
179
  }
180
180
  setCartData(state) {
181
- const { owner, items = [], promotions = [], formData, cache } = state !== null && state !== void 0 ? state : {};
181
+ const { owner, items = [], promotions = [], formData, cache } = state ?? {};
182
182
  this.owner = owner;
183
183
  this.items = items;
184
184
  this.promotions = promotions;
@@ -369,7 +369,6 @@ export class ShoppingCart {
369
369
  * @returns Updated or not
370
370
  */
371
371
  updateAssetItem(id, assetQty, itemCreator) {
372
- var _a;
373
372
  if (assetQty == null || assetQty <= 0)
374
373
  assetQty = 1;
375
374
  const index = this.items.findIndex((item) => item.id === id);
@@ -396,7 +395,7 @@ export class ShoppingCart {
396
395
  // Update
397
396
  const item = this.items[index];
398
397
  // Price may be cached first
399
- const price = (_a = this.prices[id]) !== null && _a !== void 0 ? _a : item.price;
398
+ const price = this.prices[id] ?? item.price;
400
399
  const qty = item.qty;
401
400
  const newItem = {
402
401
  ...item,
@@ -419,7 +418,6 @@ export class ShoppingCart {
419
418
  * @returns Updated or not
420
419
  */
421
420
  updateItem(id, qty, itemCreator) {
422
- var _a;
423
421
  const index = this.items.findIndex((item) => item.id === id);
424
422
  if (qty == null) {
425
423
  // Remove the item
@@ -449,7 +447,7 @@ export class ShoppingCart {
449
447
  // Update
450
448
  const item = this.items[index];
451
449
  // Price may be cached first
452
- const price = (_a = this.prices[id]) !== null && _a !== void 0 ? _a : item.price;
450
+ const price = this.prices[id] ?? item.price;
453
451
  const newItem = {
454
452
  ...item,
455
453
  qty,