authscape 1.0.708 → 1.0.712

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/index.js CHANGED
@@ -42,66 +42,56 @@ function AuthScapeApp(_ref) {
42
42
  _ref$enforceLoggedIn = _ref.enforceLoggedIn,
43
43
  enforceLoggedIn = _ref$enforceLoggedIn === void 0 ? false : _ref$enforceLoggedIn,
44
44
  _ref$enableAuth = _ref.enableAuth,
45
- enableAuth = _ref$enableAuth === void 0 ? true : _ref$enableAuth,
46
- _ref$enableConsentDia = _ref.enableConsentDialog,
47
- enableConsentDialog = _ref$enableConsentDia === void 0 ? false : _ref$enableConsentDia;
45
+ enableAuth = _ref$enableAuth === void 0 ? true : _ref$enableAuth;
48
46
  var _useState = (0, _react.useState)(false),
49
47
  _useState2 = _slicedToArray(_useState, 2),
50
48
  frontEndLoadedState = _useState2[0],
51
49
  setFrontEndLoadedState = _useState2[1];
52
50
  var _useState3 = (0, _react.useState)(false),
53
51
  _useState4 = _slicedToArray(_useState3, 2),
54
- concentState = _useState4[0],
55
- setConcentState = _useState4[1];
56
- var _useState5 = (0, _react.useState)(false),
52
+ isLoadingShow = _useState4[0],
53
+ setIsLoadingShow = _useState4[1];
54
+ var _useState5 = (0, _react.useState)(null),
57
55
  _useState6 = _slicedToArray(_useState5, 2),
58
- isLoadingShow = _useState6[0],
59
- setIsLoadingShow = _useState6[1];
60
- var _useState7 = (0, _react.useState)(null),
61
- _useState8 = _slicedToArray(_useState7, 2),
62
- signedInUserState = _useState8[0],
63
- setSignedInUserState = _useState8[1];
56
+ signedInUserState = _useState6[0],
57
+ setSignedInUserState = _useState6[1];
64
58
  var loadingAuth = (0, _react.useRef)(false);
65
- var frontEndLoaded = (0, _react.useRef)(false);
66
59
  var signedInUser = (0, _react.useRef)(null);
67
60
  var queryCodeUsed = (0, _react.useRef)(null);
68
61
  var ga4React = (0, _react.useRef)(null);
69
62
  var searchParams = (0, _navigation.useSearchParams)();
70
- var queryRef = searchParams.get('ref');
71
- var queryCode = searchParams.get('code');
63
+ var queryCode = searchParams.get("code");
72
64
  var pathname = (0, _navigation.usePathname)();
73
- var handleConsentAccepted = function handleConsentAccepted(prefs) {
74
- console.log("Consent accepted:", prefs);
75
- setConcentState(prefs);
76
- };
77
- var handleConsentRejected = function handleConsentRejected() {
78
- console.log("Consent rejected");
79
- setConcentState(null);
80
- // disable analytics scripts, etc.
81
- };
65
+
66
+ // ---------- PKCE Sign-in ----------
82
67
  var signInValidator = /*#__PURE__*/function () {
83
68
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
84
69
  var codeVerifier, headers, queryString, response, domainHost, redirectUri;
85
70
  return _regeneratorRuntime().wrap(function _callee$(_context) {
86
71
  while (1) switch (_context.prev = _context.next) {
87
72
  case 0:
88
- if (!(queryCodeUsed.current != queryCode)) {
89
- _context.next = 4;
73
+ if (!(queryCodeUsed.current === queryCode)) {
74
+ _context.next = 2;
90
75
  break;
91
76
  }
77
+ return _context.abrupt("return");
78
+ case 2:
92
79
  queryCodeUsed.current = queryCode;
93
- _context.next = 5;
94
- break;
95
- case 4:
80
+ if (!(typeof window === "undefined")) {
81
+ _context.next = 5;
82
+ break;
83
+ }
96
84
  return _context.abrupt("return");
97
85
  case 5:
98
86
  codeVerifier = window.localStorage.getItem("verifier");
99
- if (!(queryCode != null && codeVerifier != null)) {
100
- _context.next = 28;
87
+ if (!(!queryCode || !codeVerifier)) {
88
+ _context.next = 8;
101
89
  break;
102
90
  }
91
+ return _context.abrupt("return");
92
+ case 8:
103
93
  headers = {
104
- 'Content-Type': 'application/x-www-form-urlencoded'
94
+ "Content-Type": "application/x-www-form-urlencoded"
105
95
  };
106
96
  queryString = _queryString["default"].stringify({
107
97
  code: queryCode,
@@ -111,417 +101,195 @@ function AuthScapeApp(_ref) {
111
101
  client_secret: process.env.client_secret,
112
102
  code_verifier: codeVerifier
113
103
  });
114
- _context.prev = 9;
115
- _context.next = 12;
116
- return _axios["default"].post(process.env.authorityUri + '/connect/token', queryString, {
104
+ _context.prev = 10;
105
+ _context.next = 13;
106
+ return _axios["default"].post(process.env.authorityUri + "/connect/token", queryString, {
117
107
  headers: headers
118
108
  });
119
- case 12:
109
+ case 13:
120
110
  response = _context.sent;
121
- domainHost = window.location.hostname.split('.').slice(-2).join('.');
111
+ domainHost = window.location.hostname.split(".").slice(-2).join(".");
122
112
  window.localStorage.removeItem("verifier");
123
- _context.next = 17;
124
- return setCookie('access_token', response.data.access_token, {
113
+ _context.next = 18;
114
+ return setCookie("access_token", response.data.access_token, {
125
115
  maxAge: 60 * 60 * 24 * 365,
126
- // 1 year,
127
- path: '/',
116
+ path: "/",
128
117
  domain: domainHost,
129
118
  secure: true
130
119
  });
131
- case 17:
132
- _context.next = 19;
133
- return setCookie('expires_in', response.data.expires_in, {
120
+ case 18:
121
+ _context.next = 20;
122
+ return setCookie("expires_in", response.data.expires_in, {
134
123
  maxAge: 60 * 60 * 24 * 365,
135
- // 1 year,
136
- path: '/',
124
+ path: "/",
137
125
  domain: domainHost,
138
126
  secure: true
139
127
  });
140
- case 19:
141
- _context.next = 21;
142
- return setCookie('refresh_token', response.data.refresh_token, {
128
+ case 20:
129
+ _context.next = 22;
130
+ return setCookie("refresh_token", response.data.refresh_token, {
143
131
  maxAge: 60 * 60 * 24 * 365,
144
- // 1 year,
145
- path: '/',
132
+ path: "/",
146
133
  domain: domainHost,
147
134
  secure: true
148
135
  });
149
- case 21:
150
- // await setCookie(null, "access_token", response.data.access_token,
151
- // {
152
- // maxAge: 2147483647,
153
- // path: '/',
154
- // domain: domainHost,
155
- // secure: true
156
- // });
157
- // await setCookie(null, "expires_in", response.data.expires_in,
158
- // {
159
- // maxAge: 2147483647,
160
- // path: '/',
161
- // domain: domainHost,
162
- // secure: true
163
- // });
164
- // await setCookie(null, "refresh_token", response.data.refresh_token,
165
- // {
166
- // maxAge: 2147483647,
167
- // path: '/',
168
- // domain: domainHost,
169
- // secure: true
170
- // });
136
+ case 22:
171
137
  redirectUri = localStorage.getItem("redirectUri");
172
138
  localStorage.clear();
173
- if (redirectUri != null) {
174
- window.location.href = redirectUri;
175
- } else {
176
- window.location.href = "/";
177
- }
178
- _context.next = 28;
139
+ window.location.href = redirectUri || "/";
140
+ _context.next = 30;
179
141
  break;
180
- case 26:
181
- _context.prev = 26;
182
- _context.t0 = _context["catch"](9);
183
- case 28:
142
+ case 27:
143
+ _context.prev = 27;
144
+ _context.t0 = _context["catch"](10);
145
+ console.error("PKCE sign-in failed", _context.t0);
146
+ case 30:
184
147
  case "end":
185
148
  return _context.stop();
186
149
  }
187
- }, _callee, null, [[9, 26]]);
150
+ }, _callee, null, [[10, 27]]);
188
151
  }));
189
152
  return function signInValidator(_x) {
190
153
  return _ref2.apply(this, arguments);
191
154
  };
192
155
  }();
156
+
157
+ // ---------- GA + Clarity ----------
193
158
  function initGA(_x2) {
194
159
  return _initGA.apply(this, arguments);
195
160
  }
196
161
  function _initGA() {
197
- _initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(G) {
198
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
199
- while (1) switch (_context3.prev = _context3.next) {
162
+ _initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(G) {
163
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
164
+ while (1) switch (_context2.prev = _context2.next) {
200
165
  case 0:
201
- if (!(!_ga4React["default"].isInitialized() && G && process.browser)) {
202
- _context3.next = 10;
166
+ if (!(typeof window !== "undefined" && !_ga4React["default"].isInitialized() && G)) {
167
+ _context2.next = 10;
203
168
  break;
204
169
  }
205
170
  ga4React.current = new _ga4React["default"](G, {
206
171
  debug_mode: !process.env.production
207
172
  });
208
- _context3.prev = 2;
209
- _context3.next = 5;
173
+ _context2.prev = 2;
174
+ _context2.next = 5;
210
175
  return ga4React.current.initialize();
211
176
  case 5:
212
- _context3.next = 10;
177
+ _context2.next = 10;
213
178
  break;
214
179
  case 7:
215
- _context3.prev = 7;
216
- _context3.t0 = _context3["catch"](2);
217
- console.error(_context3.t0);
180
+ _context2.prev = 7;
181
+ _context2.t0 = _context2["catch"](2);
182
+ console.error(_context2.t0);
218
183
  case 10:
219
184
  case "end":
220
- return _context3.stop();
185
+ return _context2.stop();
221
186
  }
222
- }, _callee3, null, [[2, 7]]);
187
+ }, _callee2, null, [[2, 7]]);
223
188
  }));
224
189
  return _initGA.apply(this, arguments);
225
190
  }
226
191
  var logEvent = function logEvent(category, action, label) {
227
- if (ga4React != null && ga4React.current != null && ga4React != "") {
192
+ if (ga4React.current) {
228
193
  ga4React.current.event(action, label, category);
229
194
  }
230
- if (process.env.enableDatabaseAnalytics == "true") {
231
- var userId = null;
232
- var locationId = null;
233
- var companyId = null;
234
- var host = window.location.protocol + "//" + window.location.host;
235
- if (signedInUser.current != null) {
236
- userId = signedInUser.current.id;
237
- locationId = signedInUser.current.locationId;
238
- companyId = signedInUser.current.companyId;
239
- }
240
- apiService().post("/Analytics/Event", {
241
- userId: userId,
242
- locationId: locationId,
243
- companyId: companyId,
244
- uri: window.location.pathname,
245
- category: category,
246
- action: action,
247
- label: label,
248
- host: host
249
- });
250
- }
251
195
  };
252
196
  var databaseDrivenPageView = function databaseDrivenPageView(pathName) {
253
- if (process.env.enableDatabaseAnalytics == "true") {
254
- var userId = null;
255
- var locationId = null;
256
- var companyId = null;
257
- var host = window.location.protocol + "//" + window.location.host;
258
- if (signedInUser.current != null) {
259
- userId = signedInUser.current.id;
260
- locationId = signedInUser.current.locationId;
261
- companyId = signedInUser.current.companyId;
262
- }
263
- if (pathName == "/signin-oidc") {
264
- return;
265
- }
266
- apiService().post("/Analytics/PageView", {
267
- userId: userId,
268
- locationId: locationId,
269
- companyId: companyId,
270
- uri: pathName,
271
- host: host
272
- });
273
- }
197
+ var _signedInUser$current, _signedInUser$current2, _signedInUser$current3;
198
+ if (process.env.enableDatabaseAnalytics !== "true") return;
199
+ if (typeof window === "undefined") return;
200
+ if (pathName === "/signin-oidc") return;
201
+ var host = window.location.protocol + "//" + window.location.host;
202
+ apiService().post("/Analytics/PageView", {
203
+ userId: (_signedInUser$current = signedInUser.current) === null || _signedInUser$current === void 0 ? void 0 : _signedInUser$current.id,
204
+ locationId: (_signedInUser$current2 = signedInUser.current) === null || _signedInUser$current2 === void 0 ? void 0 : _signedInUser$current2.locationId,
205
+ companyId: (_signedInUser$current3 = signedInUser.current) === null || _signedInUser$current3 === void 0 ? void 0 : _signedInUser$current3.companyId,
206
+ uri: pathName,
207
+ host: host
208
+ });
274
209
  };
210
+
211
+ // ---------- Auth Init ----------
275
212
  (0, _react.useEffect)(function () {
276
- var enableAnalytics = false;
277
- var stored = localStorage.getItem("gdpr-consent");
278
- if (stored) {
279
- var prefs = JSON.parse(stored);
280
- if (prefs.analytics) {
281
- enableAnalytics = true;
282
- }
283
- }
284
- if (frontEndLoadedState && !enableConsentDialog || frontEndLoadedState && enableConsentDialog && enableAnalytics) {
285
- console.log("Analytics are working now!");
286
- if (pageProps.googleAnalytics4Code != null) {
287
- initGA(pageProps.googleAnalytics4Code);
288
- } else if (process.env.googleAnalytics4 != "") {
289
- initGA(process.env.googleAnalytics4);
290
- }
291
- if (pageProps.microsoftClarityCode != null) {
292
- _reactMicrosoftClarity.clarity.init(pageProps.microsoftClarityCode);
293
- if (signedInUser.current != null && _reactMicrosoftClarity.clarity.hasStarted()) {
294
- _reactMicrosoftClarity.clarity.identify('USER_ID', {
295
- userProperty: signedInUser.current.id.toString()
296
- });
297
- }
298
- } else if (process.env.microsoftClarityTrackingCode != "")
299
- // if there isn't a private label tracking code use the one built in the app
300
- {
301
- _reactMicrosoftClarity.clarity.init(process.env.microsoftClarityTrackingCode);
302
- if (signedInUser.current != null && _reactMicrosoftClarity.clarity.hasStarted()) {
303
- _reactMicrosoftClarity.clarity.identify('USER_ID', {
304
- userProperty: signedInUser.current.id.toString()
305
- });
306
- }
307
- }
308
- databaseDrivenPageView(window.location.pathname);
309
- _router["default"].events.on('routeChangeComplete', function () {
310
- if (ga4React != null && ga4React != "") {
311
- try {
312
- ga4React.current.pageview(window.location.pathname);
313
- } catch (exp) {}
314
- }
315
- databaseDrivenPageView(window.location.pathname);
316
- });
317
- if (pageProps.hubspotTrackingCode != null && pageProps.hubspotTrackingCode != "") {
318
- var script = document.createElement("script");
319
- script.src = pageProps.hubspotTrackingCode;
320
- script.async = true;
321
- script.defer = true;
322
- script.id = "hs-script-loader";
323
- document.body.appendChild(script);
213
+ if (queryCode) {
214
+ signInValidator(queryCode);
215
+ } else if (!loadingAuth.current) {
216
+ loadingAuth.current = true;
217
+ if (enableAuth) {
218
+ apiService().GetCurrentUser().then(function (usr) {
219
+ signedInUser.current = usr;
220
+ setSignedInUserState(usr);
221
+ setFrontEndLoadedState(true);
222
+ });
223
+ } else {
224
+ setFrontEndLoadedState(true);
324
225
  }
325
- } else {
326
- console.log("No Analytics for you!");
327
- }
328
- }, [frontEndLoadedState, concentState]);
329
- var validateUserSignedIn = /*#__PURE__*/function () {
330
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
331
- var usr;
332
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
333
- while (1) switch (_context2.prev = _context2.next) {
334
- case 0:
335
- loadingAuth.current = true;
336
- if (!enableAuth) {
337
- _context2.next = 6;
338
- break;
339
- }
340
- _context2.next = 4;
341
- return apiService().GetCurrentUser();
342
- case 4:
343
- usr = _context2.sent;
344
- if (usr != null) {
345
- signedInUser.current = usr;
346
- }
347
- case 6:
348
- setFrontEndLoadedState(true);
349
- frontEndLoaded.current = true;
350
- setSignedInUserState(signedInUser.current);
351
- case 9:
352
- case "end":
353
- return _context2.stop();
354
- }
355
- }, _callee2);
356
- }));
357
- return function validateUserSignedIn() {
358
- return _ref3.apply(this, arguments);
359
- };
360
- }();
361
- if (queryCode != null) {
362
- signInValidator(queryCode);
363
- } else {
364
- if (!loadingAuth.current) {
365
- validateUserSignedIn();
366
226
  }
367
- }
227
+ }, [queryCode, enableAuth]);
228
+
229
+ // ---------- Analytics Init ----------
230
+ (0, _react.useEffect)(function () {
231
+ if (!frontEndLoadedState || typeof window === "undefined") return;
232
+ if (pageProps.googleAnalytics4Code) {
233
+ initGA(pageProps.googleAnalytics4Code);
234
+ } else if (process.env.googleAnalytics4) {
235
+ initGA(process.env.googleAnalytics4);
236
+ }
237
+ if (pageProps.microsoftClarityCode) {
238
+ _reactMicrosoftClarity.clarity.init(pageProps.microsoftClarityCode);
239
+ } else if (process.env.microsoftClarityTrackingCode) {
240
+ _reactMicrosoftClarity.clarity.init(process.env.microsoftClarityTrackingCode);
241
+ }
242
+ databaseDrivenPageView(window.location.pathname);
243
+ _router["default"].events.on("routeChangeComplete", function (url) {
244
+ var _ga4React$current;
245
+ (_ga4React$current = ga4React.current) === null || _ga4React$current === void 0 || _ga4React$current.pageview(url);
246
+ databaseDrivenPageView(url);
247
+ });
248
+ }, [frontEndLoadedState]);
249
+
250
+ // ---------- Enforce Login ----------
368
251
  (0, _react.useEffect)(function () {
369
- if (signedInUserState == null && enforceLoggedIn && pathname != "/signin-oidc" && frontEndLoadedState == true) {
252
+ if (enforceLoggedIn && pathname !== "/signin-oidc" && frontEndLoadedState && !signedInUserState) {
370
253
  (0, _authscape.authService)().login();
371
254
  }
372
- }, [signedInUserState, enforceLoggedIn, frontEndLoadedState]);
373
- var setIsLoading = function setIsLoading(isLoading) {
374
- setIsLoadingShow(isLoading);
375
- };
376
- var logPurchase = function logPurchase(transactionId, amount, tax, items) {
377
- if (ga4React != null && ga4React != "") {
378
- ga4React.current.gtag("event", "purchase", {
379
- transaction_id: transactionId,
380
- value: amount,
381
- tax: tax,
382
- currency: "USD",
383
- items: items
384
- });
385
- }
386
- };
387
- var setToastMessage = function setToastMessage(message) {
388
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
389
- if (options != null) {
390
- (0, _reactToastify.toast)(message, options);
391
- } else {
392
- (0, _reactToastify.toast)(message);
393
- }
394
- };
395
- var setInfoToastMessage = function setInfoToastMessage(message) {
396
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
397
- if (options != null) {
398
- _reactToastify.toast.info(message, options);
399
- } else {
400
- _reactToastify.toast.info(message);
401
- }
402
- };
403
- var setSuccessToastMessage = function setSuccessToastMessage(message) {
404
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
405
- if (options != null) {
406
- _reactToastify.toast.success(message, options);
407
- } else {
408
- _reactToastify.toast.success(message);
409
- }
410
- };
411
- var setWarnToastMessage = function setWarnToastMessage(message) {
412
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
413
- if (options != null) {
414
- _reactToastify.toast.warn(message, options);
415
- } else {
416
- _reactToastify.toast.warn(message);
417
- }
418
- };
419
- var setErrorToastMessage = function setErrorToastMessage(message) {
420
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
421
- if (options != null) {
422
- _reactToastify.toast.error(message, options);
423
- } else {
424
- _reactToastify.toast.error(message);
425
- }
426
- };
255
+ }, [signedInUserState, enforceLoggedIn, frontEndLoadedState, pathname]);
427
256
  var GetSignedInUser = function GetSignedInUser() {
428
- if (signedInUser != null) {
429
- var _signedInUser = signedInUser.current;
430
- if (_signedInUser != null) {
431
- _signedInUser.hasRole = function (name) {
432
- if (_signedInUser.roles != null) {
433
- if (_signedInUser.roles.find(function (r) {
434
- return r.name === name;
435
- }) != null) {
436
- return true;
437
- } else {
438
- return false;
439
- }
440
- }
441
- };
442
- _signedInUser.hasRoleId = function (id) {
443
- if (_signedInUser.roles != null) {
444
- if (_signedInUser.roles.find(function (r) {
445
- return r.id === id;
446
- }) != null) {
447
- return true;
448
- } else {
449
- return false;
450
- }
451
- }
452
- };
453
- _signedInUser.hasPermission = function (name) {
454
- if (_signedInUser.permissions != null) {
455
- if (_signedInUser.permissions.find(function (r) {
456
- return r === name;
457
- }) != null) {
458
- return true;
459
- } else {
460
- return false;
461
- }
462
- }
463
- };
464
- }
465
- return _signedInUser;
466
- } else {
467
- return null;
468
- }
257
+ return signedInUser.current;
469
258
  };
470
259
  var useStore = (0, _zustand.create)(function (set) {
471
260
  return store;
472
261
  });
473
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
474
- name: "viewport",
475
- content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
476
- })), enableConsentDialog && /*#__PURE__*/_react["default"].createElement(GDPRConsentDialog, {
477
- onAccept: handleConsentAccepted,
478
- onReject: handleConsentRejected,
479
- enableAnalytics: true,
480
- enableMarketing: false
481
- // additionalPrivacyFeatures={[
482
- // {id: "danceParty", title: "Dance Party", description: "Hello world this is about the feature", checked: true },
483
- // {id: "frog", title: "Able to see Frogs", description: "Frogs will appear on your screen", checked: true }
484
- // ]}
485
- }), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
486
- theme: muiTheme
487
- }, frontEndLoadedState != null && frontEndLoadedState && pathname != "/signin-oidc" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, layout != null && layout({
262
+
263
+ // ---------- Render ----------
264
+ var pageContent = layout ? layout({
488
265
  children: /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
489
266
  currentUser: GetSignedInUser(),
490
267
  loadedUser: frontEndLoadedState,
491
- setIsLoading: setIsLoading,
268
+ setIsLoading: setIsLoadingShow,
492
269
  logEvent: logEvent,
493
- logPurchase: logPurchase,
494
270
  store: useStore,
495
- setToastMessage: setToastMessage,
496
- setInfoToastMessage: setInfoToastMessage,
497
- setSuccessToastMessage: setSuccessToastMessage,
498
- setWarnToastMessage: setWarnToastMessage,
499
- setErrorToastMessage: setErrorToastMessage
271
+ toast: _reactToastify.toast
500
272
  })),
501
273
  currentUser: GetSignedInUser(),
274
+ setIsLoading: setIsLoadingShow,
502
275
  logEvent: logEvent,
503
- setIsLoading: setIsLoading,
504
276
  toast: _reactToastify.toast,
505
277
  store: useStore,
506
- setToastMessage: setToastMessage,
507
- pageProps: pageProps,
508
- setInfoToastMessage: setInfoToastMessage,
509
- setSuccessToastMessage: setSuccessToastMessage,
510
- setWarnToastMessage: setWarnToastMessage,
511
- setErrorToastMessage: setErrorToastMessage
512
- }), layout == null && /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
278
+ pageProps: pageProps
279
+ }) : /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
513
280
  currentUser: GetSignedInUser(),
514
281
  loadedUser: frontEndLoadedState,
515
- setIsLoading: setIsLoading,
282
+ setIsLoading: setIsLoadingShow,
516
283
  logEvent: logEvent,
517
- logPurchase: logPurchase,
518
284
  store: useStore,
519
- setToastMessage: setToastMessage,
520
- setInfoToastMessage: setInfoToastMessage,
521
- setSuccessToastMessage: setSuccessToastMessage,
522
- setWarnToastMessage: setWarnToastMessage,
523
- setErrorToastMessage: setErrorToastMessage
524
- }))), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null)), loadingLayout && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, loadingLayout(isLoadingShow)));
285
+ toast: _reactToastify.toast
286
+ }));
287
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
288
+ name: "viewport",
289
+ content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
290
+ })), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
291
+ theme: muiTheme
292
+ }, pageContent, /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null)), loadingLayout && loadingLayout(isLoadingShow));
525
293
  }
526
294
  "use strict";
527
295
 
@@ -2366,214 +2134,6 @@ var FileUploader = exports.FileUploader = function FileUploader(_ref) {
2366
2134
  };
2367
2135
  "use strict";
2368
2136
 
2369
- Object.defineProperty(exports, "__esModule", {
2370
- value: true
2371
- });
2372
- exports.GDPRConsentDialog = void 0;
2373
- var _react = _interopRequireWildcard(require("react"));
2374
- var _material = require("@mui/material");
2375
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
2376
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
2377
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2378
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2379
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2380
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
2381
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2382
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
2383
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2384
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2385
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2386
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2387
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2388
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2389
- var GDPRConsentDialog = exports.GDPRConsentDialog = function GDPRConsentDialog(_ref) {
2390
- var onAccept = _ref.onAccept,
2391
- onReject = _ref.onReject,
2392
- _ref$enableAnalytics = _ref.enableAnalytics,
2393
- enableAnalytics = _ref$enableAnalytics === void 0 ? true : _ref$enableAnalytics,
2394
- _ref$enableMarketing = _ref.enableMarketing,
2395
- enableMarketing = _ref$enableMarketing === void 0 ? true : _ref$enableMarketing,
2396
- _ref$additionalPrivac = _ref.additionalPrivacyFeatures,
2397
- additionalPrivacyFeatures = _ref$additionalPrivac === void 0 ? [] : _ref$additionalPrivac;
2398
- var initialPreferences = _objectSpread({
2399
- necessary: true,
2400
- analytics: enableAnalytics,
2401
- marketing: enableMarketing
2402
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2403
- var _item$checked;
2404
- return [item.id, (_item$checked = item.checked) !== null && _item$checked !== void 0 ? _item$checked : false];
2405
- })));
2406
- var _useState = (0, _react.useState)(false),
2407
- _useState2 = _slicedToArray(_useState, 2),
2408
- open = _useState2[0],
2409
- setOpen = _useState2[1];
2410
- var _useState3 = (0, _react.useState)(false),
2411
- _useState4 = _slicedToArray(_useState3, 2),
2412
- customize = _useState4[0],
2413
- setCustomize = _useState4[1];
2414
- var _useState5 = (0, _react.useState)(initialPreferences),
2415
- _useState6 = _slicedToArray(_useState5, 2),
2416
- preferences = _useState6[0],
2417
- setPreferences = _useState6[1];
2418
- (0, _react.useEffect)(function () {
2419
- var savedConsent = localStorage.getItem("gdpr-consent");
2420
- if (!savedConsent) {
2421
- setOpen(true);
2422
- }
2423
- }, []);
2424
- var saveConsentAndClose = function saveConsentAndClose(prefs) {
2425
- localStorage.setItem("gdpr-consent", JSON.stringify(prefs));
2426
- if (onAccept) onAccept(prefs);
2427
- setOpen(false);
2428
- };
2429
- var handleAcceptAll = function handleAcceptAll() {
2430
- var allPrefs = _objectSpread({
2431
- necessary: true,
2432
- analytics: enableAnalytics,
2433
- marketing: enableMarketing
2434
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2435
- return [item.id, true];
2436
- })));
2437
- saveConsentAndClose(allPrefs);
2438
- };
2439
- var handleRejectAll = function handleRejectAll() {
2440
- var rejectedPrefs = _objectSpread({
2441
- necessary: true,
2442
- analytics: false,
2443
- marketing: false
2444
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2445
- return [item.id, false];
2446
- })));
2447
- localStorage.setItem("gdpr-consent", JSON.stringify(rejectedPrefs));
2448
- if (onReject) onReject();
2449
- setOpen(false);
2450
- };
2451
- var handleAcceptSelected = function handleAcceptSelected() {
2452
- saveConsentAndClose(preferences);
2453
- };
2454
- var handleCheckboxChange = function handleCheckboxChange(key) {
2455
- return function (event) {
2456
- setPreferences(function (prev) {
2457
- return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, event.target.checked));
2458
- });
2459
- };
2460
- };
2461
- if (!open) return null;
2462
- return /*#__PURE__*/_react["default"].createElement(_material.Paper, {
2463
- elevation: 4,
2464
- sx: {
2465
- position: "fixed",
2466
- bottom: 0,
2467
- left: 0,
2468
- right: 0,
2469
- p: 2,
2470
- zIndex: 1300,
2471
- backgroundColor: "#fff",
2472
- borderTop: "1px solid #ccc"
2473
- }
2474
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2475
- display: "flex",
2476
- flexDirection: "column",
2477
- alignItems: "flex-start",
2478
- gap: 2
2479
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, null, /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2480
- variant: "subtitle1",
2481
- fontWeight: "bold"
2482
- }, "We value your privacy"), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2483
- variant: "body2"
2484
- }, "We use cookies to enhance your experience, for analytics and marketing. You can accept all, reject all, or customize your preferences.")), /*#__PURE__*/_react["default"].createElement(_material.Collapse, {
2485
- "in": customize
2486
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2487
- mb: 2
2488
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2489
- mb: 1
2490
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2491
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2492
- checked: true,
2493
- disabled: true
2494
- }),
2495
- label: "Necessary (always required)"
2496
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2497
- variant: "caption",
2498
- color: "textSecondary",
2499
- sx: {
2500
- ml: 4
2501
- }
2502
- }, "Required to enable core site functionality such as security, authentication, and accessibility.")), enableAnalytics && /*#__PURE__*/_react["default"].createElement(_material.Box, {
2503
- mb: 1
2504
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2505
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2506
- checked: preferences.analytics,
2507
- onChange: handleCheckboxChange("analytics")
2508
- }),
2509
- label: "Analytics"
2510
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2511
- variant: "caption",
2512
- color: "textSecondary",
2513
- sx: {
2514
- ml: 4
2515
- }
2516
- }, "Helps us understand how you use our site so we can improve it. For example, tracking page visits or feature usage.")), enableMarketing && /*#__PURE__*/_react["default"].createElement(_material.Box, {
2517
- mb: 1
2518
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2519
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2520
- checked: preferences.marketing,
2521
- onChange: handleCheckboxChange("marketing")
2522
- }),
2523
- label: "Marketing"
2524
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2525
- variant: "caption",
2526
- color: "textSecondary",
2527
- sx: {
2528
- ml: 4
2529
- }
2530
- }, "Allows us to show personalized ads and promotions based on your behavior and interactions.")), additionalPrivacyFeatures.map(function (feature) {
2531
- return /*#__PURE__*/_react["default"].createElement(_material.Box, {
2532
- key: feature.id,
2533
- mb: 1
2534
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2535
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2536
- checked: preferences[feature.id] || false,
2537
- onChange: handleCheckboxChange(feature.id)
2538
- }),
2539
- label: feature.title
2540
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2541
- variant: "caption",
2542
- color: "textSecondary",
2543
- sx: {
2544
- ml: 4
2545
- }
2546
- }, feature.description));
2547
- }))), /*#__PURE__*/_react["default"].createElement(_material.Box, {
2548
- display: "flex",
2549
- gap: 1,
2550
- flexWrap: "wrap"
2551
- }, !customize ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Button, {
2552
- variant: "contained",
2553
- color: "primary",
2554
- onClick: handleAcceptAll
2555
- }, "Accept All"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2556
- variant: "outlined",
2557
- color: "error",
2558
- onClick: handleRejectAll
2559
- }, "Reject All"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2560
- variant: "text",
2561
- onClick: function onClick() {
2562
- return setCustomize(true);
2563
- }
2564
- }, "Customize Preferences")) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Button, {
2565
- variant: "contained",
2566
- color: "primary",
2567
- onClick: handleAcceptSelected
2568
- }, "Save Preferences"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2569
- variant: "text",
2570
- onClick: function onClick() {
2571
- return setCustomize(false);
2572
- }
2573
- }, "Cancel")))));
2574
- };
2575
- "use strict";
2576
-
2577
2137
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2578
2138
  Object.defineProperty(exports, "__esModule", {
2579
2139
  value: true