aesirx-analytics 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,815 @@
1
+ import {
2
+ BROWSER_WALLET,
3
+ Connect_default,
4
+ Ethereum_default,
5
+ LoadingStatus,
6
+ TermsComponent,
7
+ WALLET_CONNECT,
8
+ agreeConsents,
9
+ arrow_default,
10
+ bg_default,
11
+ getConsents,
12
+ getMember,
13
+ getNonce,
14
+ getSignature,
15
+ getWalletNonce,
16
+ getWeb3ID,
17
+ no_default,
18
+ privacy_default,
19
+ revokeConsents,
20
+ useConsentStatus_default,
21
+ verifySignature,
22
+ yes_default
23
+ } from "./chunk-AJMXPNA2.js";
24
+ import {
25
+ AnalyticsContext,
26
+ useTranslation
27
+ } from "./chunk-FKCTTU52.js";
28
+
29
+ // src/Components/ConsentCustom.tsx
30
+ import React, { useContext, useEffect, useState } from "react";
31
+ import { Button, Form } from "react-bootstrap";
32
+ import { ToastContainer, toast } from "react-toastify";
33
+
34
+ // src/Assets/checkbox.svg
35
+ var checkbox_default = 'data:image/svg+xml,<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<circle cx="11.5" cy="11.5" r="10.5" stroke="%23DEDEDE" stroke-width="2"/>%0A</svg>%0A';
36
+
37
+ // src/Assets/checkbox_active.svg
38
+ var checkbox_active_default = 'data:image/svg+xml,<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<circle cx="11.5" cy="11.5" r="11.5" fill="%231C9678"/>%0A<path fill-rule="evenodd" clip-rule="evenodd" d="M15.6685 9.15506C15.8752 9.36181 15.8752 9.69701 15.6685 9.90376L10.7273 14.8449C10.5205 15.0517 10.1853 15.0517 9.97859 14.8449L7.15506 12.0214C6.94831 11.8147 6.94831 11.4795 7.15506 11.2727C7.36181 11.066 7.69701 11.066 7.90376 11.2727L10.3529 13.7219L14.9198 9.15506C15.1265 8.94831 15.4617 8.94831 15.6685 9.15506Z" fill="white" stroke="white" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round"/>%0A</svg>%0A';
39
+
40
+ // src/Components/ConsentCustom.tsx
41
+ import ContentLoader from "react-content-loader";
42
+ import { SSOButton } from "aesirx-sso";
43
+ import {
44
+ MAINNET,
45
+ WithWalletConnector,
46
+ useConnection,
47
+ useConnect,
48
+ stringMessage,
49
+ useGrpcClient,
50
+ TESTNET
51
+ } from "@concordium/react-components";
52
+ import { OsTypes, isDesktop, isMobile, osName } from "react-device-detect";
53
+ import { useAccount, useSignMessage } from "wagmi";
54
+ var ConsentComponentCustom = ({ endpoint, aesirXEndpoint, networkEnv }) => {
55
+ return /* @__PURE__ */ React.createElement(WithWalletConnector, { network: networkEnv === "testnet" ? TESTNET : MAINNET }, (props) => /* @__PURE__ */ React.createElement("div", { className: "aesirxconsent" }, /* @__PURE__ */ React.createElement(Ethereum_default, null, /* @__PURE__ */ React.createElement(
56
+ ConsentComponentCustomApp,
57
+ {
58
+ ...props,
59
+ endpoint,
60
+ aesirXEndpoint
61
+ }
62
+ ))));
63
+ };
64
+ var ConsentComponentCustomApp = (props) => {
65
+ const {
66
+ endpoint,
67
+ aesirXEndpoint,
68
+ activeConnectorType,
69
+ activeConnector,
70
+ activeConnectorError,
71
+ connectedAccounts,
72
+ genesisHashes,
73
+ setActiveConnectorType,
74
+ network
75
+ } = props;
76
+ const { setConnection } = useConnection(connectedAccounts, genesisHashes);
77
+ const { isConnecting } = useConnect(activeConnector, setConnection);
78
+ const handleOnConnect = async (connectorType, network2 = "concordium") => {
79
+ if (network2 === "concordium") {
80
+ setActiveConnectorType(connectorType);
81
+ }
82
+ setLoading("done");
83
+ };
84
+ const [
85
+ uuid,
86
+ level,
87
+ connection,
88
+ account,
89
+ show,
90
+ setShow,
91
+ web3ID,
92
+ setWeb3ID,
93
+ handleLevel,
94
+ showRevoke,
95
+ handleRevoke
96
+ ] = useConsentStatus_default(endpoint, props);
97
+ const [consents, setConsents] = useState([1, 2]);
98
+ const [loading, setLoading] = useState("done");
99
+ const [loadingCheckAccount, setLoadingCheckAccount] = useState(false);
100
+ const [showExpandConsent, setShowExpandConsent] = useState(true);
101
+ const [showExpandRevoke, setShowExpandRevoke] = useState(false);
102
+ const [showBackdrop, setShowBackdrop] = useState(true);
103
+ const [consentTier4, setConsentTier4] = useState({});
104
+ const [upgradeLayout, setUpgradeLayout] = useState(false);
105
+ const [upgradeShowDetail, setUpgradeShowDetail] = useState(false);
106
+ const [upgradeLevel, setUpgradeLevel] = useState(0);
107
+ const analyticsContext = useContext(AnalyticsContext);
108
+ const { t } = useTranslation();
109
+ const gRPCClient = useGrpcClient(network);
110
+ const { address, connector } = useAccount();
111
+ const { signMessage } = useSignMessage({
112
+ async onSuccess(data, variables) {
113
+ const signature = Buffer.from(
114
+ typeof data === "object" && data !== null ? JSON.stringify(data) : data,
115
+ "utf-8"
116
+ ).toString("base64");
117
+ const jwt = sessionStorage.getItem("aesirx-analytics-jwt");
118
+ if (variables?.message.indexOf("Revoke consent") > -1) {
119
+ const levelRevoke = sessionStorage.getItem("aesirx-analytics-revoke");
120
+ const consentList = await getConsents(endpoint, uuid);
121
+ consentList.forEach(async (consent) => {
122
+ !consent?.expiration && await revokeConsents(
123
+ endpoint,
124
+ levelRevoke,
125
+ consent?.consent_uuid,
126
+ address,
127
+ signature,
128
+ web3ID,
129
+ jwt,
130
+ "metamask"
131
+ );
132
+ });
133
+ setLoading("done");
134
+ handleRevoke(false);
135
+ setShowExpandConsent(false);
136
+ setShow(true);
137
+ setShowBackdrop(false);
138
+ sessionStorage.removeItem("aesirx-analytics-allow");
139
+ } else if (variables?.message.indexOf("Login with nonce") > -1) {
140
+ const res = await verifySignature(aesirXEndpoint, "metamask", address, data);
141
+ sessionStorage.setItem("aesirx-analytics-jwt", res?.jwt);
142
+ setLoadingCheckAccount(false);
143
+ const nonce = await getNonce(
144
+ endpoint,
145
+ address,
146
+ "Give consent Tier 4:{nonce} {domain} {time}",
147
+ "metamask"
148
+ );
149
+ signMessage({ message: `${nonce}` });
150
+ } else {
151
+ setLoading("saving");
152
+ await agreeConsents(
153
+ endpoint,
154
+ level,
155
+ uuid,
156
+ consents,
157
+ address,
158
+ signature,
159
+ web3ID,
160
+ jwt,
161
+ "metamask"
162
+ );
163
+ sessionStorage.setItem("aesirx-analytics-uuid", uuid);
164
+ sessionStorage.setItem("aesirx-analytics-allow", "1");
165
+ sessionStorage.setItem("aesirx-analytics-consent-type", "metamask");
166
+ setShow(false);
167
+ setLoading("done");
168
+ handleRevoke(true, level);
169
+ setShowBackdrop(false);
170
+ }
171
+ },
172
+ async onError(error) {
173
+ setLoading("done");
174
+ toast.error(error.message);
175
+ }
176
+ });
177
+ const handleChange = async ({ target: { value } }) => {
178
+ if (consents.indexOf(parseInt(value)) === -1) {
179
+ setConsents([...consents, ...[parseInt(value)]]);
180
+ } else {
181
+ setConsents(consents.filter((consent) => consent !== parseInt(value)));
182
+ }
183
+ };
184
+ const handleAgree = async () => {
185
+ try {
186
+ let flag = true;
187
+ let jwt = "";
188
+ if (level > 2) {
189
+ if (level === 4) {
190
+ try {
191
+ setLoadingCheckAccount(true);
192
+ const nonceLogin = await getWalletNonce(
193
+ aesirXEndpoint,
194
+ account ? "concordium" : "metamask",
195
+ account ?? address
196
+ );
197
+ if (nonceLogin) {
198
+ try {
199
+ if (account) {
200
+ const signature = await connection.signMessage(
201
+ account,
202
+ stringMessage(`${nonceLogin}`)
203
+ );
204
+ const convertedSignature = typeof signature === "object" && signature !== null ? signature : JSON.parse(signature);
205
+ if (signature) {
206
+ const data = await verifySignature(
207
+ aesirXEndpoint,
208
+ "concordium",
209
+ account,
210
+ convertedSignature
211
+ );
212
+ sessionStorage.setItem("aesirx-analytics-jwt", data?.jwt);
213
+ jwt = data?.jwt;
214
+ setLoadingCheckAccount(false);
215
+ }
216
+ } else {
217
+ signMessage({ message: `${nonceLogin}` });
218
+ }
219
+ } catch (error) {
220
+ setLoadingCheckAccount(false);
221
+ toast(error.message);
222
+ }
223
+ }
224
+ } catch (error) {
225
+ SSOClick(".loginSSO");
226
+ setLoadingCheckAccount(false);
227
+ return;
228
+ }
229
+ }
230
+ if (account) {
231
+ const signature = await getSignature(
232
+ endpoint,
233
+ account,
234
+ connection,
235
+ level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}"
236
+ );
237
+ setLoading("saving");
238
+ await agreeConsents(endpoint, level, uuid, consents, account, signature, web3ID, jwt);
239
+ sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
240
+ } else if (connector) {
241
+ if (level === 3) {
242
+ const nonce = await getNonce(
243
+ endpoint,
244
+ address,
245
+ level === 3 ? "Give consent:{nonce} {domain} {time}" : "Give consent Tier 4:{nonce} {domain} {time}",
246
+ "metamask"
247
+ );
248
+ signMessage({ message: `${nonce}` });
249
+ }
250
+ } else {
251
+ setLoading("connect");
252
+ flag = false;
253
+ }
254
+ } else {
255
+ setLoading("saving");
256
+ const consentList = await getConsents(endpoint, analyticsContext.visitor_uuid);
257
+ consents.forEach(async (consent) => {
258
+ const existConsent = consentList.find((item) => item?.consent === consent);
259
+ if (!existConsent) {
260
+ await agreeConsents(endpoint, 1, uuid, consent);
261
+ } else if (!!existConsent?.consent_uuid && existConsent?.expiration && new Date(existConsent.expiration) < /* @__PURE__ */ new Date()) {
262
+ await agreeConsents(endpoint, 1, uuid, consent);
263
+ }
264
+ });
265
+ }
266
+ if (flag && (account || level < 3)) {
267
+ sessionStorage.setItem("aesirx-analytics-uuid", uuid);
268
+ sessionStorage.setItem("aesirx-analytics-allow", "1");
269
+ setShow(false);
270
+ setLoading("done");
271
+ handleRevoke(true, level);
272
+ setShowBackdrop(false);
273
+ }
274
+ } catch (error) {
275
+ console.log(error);
276
+ handleNotAllow();
277
+ setLoading("done");
278
+ toast.error(error?.response?.data?.error ?? error.message);
279
+ }
280
+ };
281
+ useEffect(() => {
282
+ const init = async () => {
283
+ if (Object.keys(consentTier4)?.length && (account || address)) {
284
+ await consentTier4Init(consentTier4);
285
+ setConsentTier4({});
286
+ }
287
+ };
288
+ init();
289
+ }, [consentTier4, account, address]);
290
+ const consentTier4Init = async (response) => {
291
+ let hasWeb3ID = true;
292
+ if (response?.loginType === "concordium") {
293
+ const web3ID2 = await getWeb3ID(account, gRPCClient, network?.name);
294
+ if (web3ID2) {
295
+ setWeb3ID(web3ID2);
296
+ } else {
297
+ hasWeb3ID = false;
298
+ }
299
+ } else {
300
+ const memberData = await getMember(aesirXEndpoint, response?.access_token);
301
+ hasWeb3ID = memberData?.web3id ? true : false;
302
+ }
303
+ if (hasWeb3ID) {
304
+ if (response?.loginType === "concordium") {
305
+ sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
306
+ const signature = await getSignature(
307
+ endpoint,
308
+ account,
309
+ connection,
310
+ "Give consent Tier 4:{nonce} {domain} {time}"
311
+ );
312
+ await agreeConsents(
313
+ endpoint,
314
+ level,
315
+ uuid,
316
+ consents,
317
+ account,
318
+ signature,
319
+ null,
320
+ response?.jwt
321
+ );
322
+ setShow(false);
323
+ handleRevoke(true, level);
324
+ setLoading("done");
325
+ } else if (response?.loginType === "metamask") {
326
+ sessionStorage.setItem("aesirx-analytics-consent-type", "metamask");
327
+ const nonce = await getNonce(
328
+ endpoint,
329
+ address,
330
+ "Give consent Tier 4:{nonce} {domain} {time}",
331
+ "metamask"
332
+ );
333
+ signMessage({ message: `${nonce}` });
334
+ }
335
+ } else {
336
+ handleLevel(3);
337
+ toast("You haven't minted any WEB3 ID yet. Try to mint at https://dapp.shield.aesirx.io");
338
+ setLoading("done");
339
+ }
340
+ };
341
+ const onGetData = async (response) => {
342
+ try {
343
+ setLoading("saving");
344
+ const levelRevoke = sessionStorage.getItem("aesirx-analytics-revoke");
345
+ sessionStorage.setItem("aesirx-analytics-jwt", response?.jwt);
346
+ if (levelRevoke && levelRevoke !== "0") {
347
+ sessionStorage.setItem(
348
+ "aesirx-analytics-consent-type",
349
+ response?.loginType === "concordium" ? "concordium" : "metamask"
350
+ );
351
+ handleRevokeBtn();
352
+ } else {
353
+ if (level === 4) {
354
+ if (response?.loginType === "concordium" && isDesktop) {
355
+ setActiveConnectorType(BROWSER_WALLET);
356
+ }
357
+ setConsentTier4(response);
358
+ } else {
359
+ await agreeConsents(endpoint, level, uuid, consents, null, null, null, response?.jwt);
360
+ setShow(false);
361
+ handleRevoke(true, level);
362
+ setLoading("done");
363
+ }
364
+ }
365
+ } catch (error) {
366
+ console.log(error);
367
+ setShow(false);
368
+ setLoading("done");
369
+ toast.error(error?.response?.data?.error ?? error.message);
370
+ }
371
+ };
372
+ const handleNotAllow = () => {
373
+ sessionStorage.setItem("aesirx-analytics-uuid", uuid);
374
+ sessionStorage.setItem("aesirx-analytics-rejected", "true");
375
+ setShowExpandConsent(false);
376
+ setShowBackdrop(false);
377
+ };
378
+ const handleRevokeBtn = async () => {
379
+ const levelRevoke = sessionStorage.getItem("aesirx-analytics-revoke");
380
+ const consentType = sessionStorage.getItem("aesirx-analytics-consent-type");
381
+ const jwt = sessionStorage.getItem("aesirx-analytics-jwt");
382
+ try {
383
+ let flag = true;
384
+ if (levelRevoke !== "1") {
385
+ if (parseInt(levelRevoke) > 2) {
386
+ if (!jwt && (parseInt(levelRevoke) === 2 || parseInt(levelRevoke) === 4)) {
387
+ SSOClick(".revokeLogin");
388
+ return;
389
+ }
390
+ if (account && consentType !== "metamask") {
391
+ setLoading("sign");
392
+ const signature = await getSignature(
393
+ endpoint,
394
+ account,
395
+ connection,
396
+ "Revoke consent:{nonce} {domain} {time}"
397
+ );
398
+ setLoading("saving");
399
+ const consentList = await getConsents(endpoint, uuid);
400
+ consentList.forEach(async (consent) => {
401
+ !consent?.expiration && await revokeConsents(
402
+ endpoint,
403
+ levelRevoke,
404
+ consent?.consent_uuid,
405
+ account,
406
+ signature,
407
+ web3ID,
408
+ jwt
409
+ );
410
+ });
411
+ setLoading("done");
412
+ handleRevoke(false);
413
+ } else if (connector) {
414
+ setLoading("sign");
415
+ setLoading("saving");
416
+ const nonce = await getNonce(
417
+ endpoint,
418
+ address,
419
+ "Revoke consent:{nonce} {domain} {time}",
420
+ "metamask"
421
+ );
422
+ signMessage({ message: `${nonce}` });
423
+ } else {
424
+ setLoading("connect");
425
+ flag = false;
426
+ }
427
+ } else {
428
+ setLoading("saving");
429
+ const consentList = await getConsents(endpoint, uuid);
430
+ consentList.forEach(async (consent) => {
431
+ !consent?.expiration && await revokeConsents(
432
+ endpoint,
433
+ levelRevoke,
434
+ consent?.consent_uuid,
435
+ null,
436
+ null,
437
+ null,
438
+ jwt
439
+ );
440
+ });
441
+ setLoading("done");
442
+ handleRevoke(false);
443
+ }
444
+ if (flag && (account && consentType !== "metamask" || level < 3)) {
445
+ setShowExpandConsent(false);
446
+ setShow(true);
447
+ setShowBackdrop(false);
448
+ sessionStorage.removeItem("aesirx-analytics-allow");
449
+ }
450
+ } else {
451
+ handleRevoke(false);
452
+ setShowExpandConsent(false);
453
+ setShow(true);
454
+ setShowBackdrop(false);
455
+ sessionStorage.removeItem("aesirx-analytics-allow");
456
+ }
457
+ } catch (error) {
458
+ console.log(error);
459
+ setLoading("done");
460
+ toast.error(error?.response?.data?.error ?? error.message);
461
+ }
462
+ };
463
+ const SSOClick = (selector) => {
464
+ const element = document.querySelector(selector);
465
+ element.click();
466
+ };
467
+ useEffect(() => {
468
+ if (activeConnectorError) {
469
+ toast.error(activeConnectorError);
470
+ }
471
+ }, [activeConnectorError]);
472
+ useEffect(() => {
473
+ if (sessionStorage.getItem("aesirx-analytics-rejected") === "true") {
474
+ setShowBackdrop(false);
475
+ setShowExpandConsent(false);
476
+ }
477
+ if (sessionStorage.getItem("aesirx-analytics-revoke") && sessionStorage.getItem("aesirx-analytics-revoke") !== "0") {
478
+ window.funcAfterConsent && window.funcAfterConsent();
479
+ }
480
+ }, []);
481
+ console.log("level", uuid, level, web3ID, account, loading);
482
+ const ConsentLevelUprade = ({
483
+ level: level2,
484
+ tier,
485
+ levelname,
486
+ term_custom,
487
+ content_custom,
488
+ isUpgrade = false
489
+ }) => {
490
+ return /* @__PURE__ */ React.createElement(
491
+ "div",
492
+ {
493
+ className: `consent_level mt-2 ${isUpgrade ? `cursor-pointer ${upgradeLevel === level2 ? "active" : ""}` : ""} `,
494
+ onClick: () => {
495
+ setUpgradeLevel(level2);
496
+ }
497
+ },
498
+ /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center justify-content-between flex-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center" }, /* @__PURE__ */ React.createElement("div", { className: `status-tier tier-${level2} rounded-circle` }), /* @__PURE__ */ React.createElement("div", { className: "status-tier-text fw-semibold fs-14 text-primary" }, tier, " - ", levelname)), !isUpgrade ? /* @__PURE__ */ React.createElement("div", { className: "fw-semibold fs-14 text-primary" }, term_custom) : /* @__PURE__ */ React.createElement(React.Fragment, null, upgradeShowDetail ? /* @__PURE__ */ React.createElement("div", { className: "fw-semibold fs-14 text-primary" }, term_custom) : /* @__PURE__ */ React.createElement(React.Fragment, null))),
499
+ !isUpgrade ? /* @__PURE__ */ React.createElement("div", { className: `${isUpgrade ? "consent_upgrade_content" : ""} mt-2` }, content_custom) : /* @__PURE__ */ React.createElement(React.Fragment, null, upgradeShowDetail ? /* @__PURE__ */ React.createElement("div", { className: "mt-2" }, content_custom) : /* @__PURE__ */ React.createElement(React.Fragment, null)),
500
+ isUpgrade ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "checkbox_img" }, /* @__PURE__ */ React.createElement(
501
+ "img",
502
+ {
503
+ width: "23px",
504
+ height: "23px",
505
+ src: upgradeLevel === level2 ? checkbox_active_default : checkbox_default
506
+ }
507
+ ))) : /* @__PURE__ */ React.createElement(React.Fragment, null)
508
+ );
509
+ };
510
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(ToastContainer, null), /* @__PURE__ */ React.createElement("div", { className: `offcanvas-backdrop fade ${showBackdrop && show ? "show" : "d-none"}` }), /* @__PURE__ */ React.createElement(
511
+ "div",
512
+ {
513
+ tabIndex: -1,
514
+ className: `toast-container position-fixed m-md-3 ${showExpandRevoke ? "top-50 start-50 translate-middle" : "bottom-0 end-0"}`
515
+ },
516
+ /* @__PURE__ */ React.createElement(
517
+ "div",
518
+ {
519
+ className: `toast revoke-toast ${showRevoke || sessionStorage.getItem("aesirx-analytics-revoke") && sessionStorage.getItem("aesirx-analytics-revoke") !== "0" ? "show" : ""} ${showExpandRevoke ? "" : "minimize"}`
520
+ },
521
+ /* @__PURE__ */ React.createElement(LoadingStatus, { loading }),
522
+ /* @__PURE__ */ React.createElement("div", { className: "toast-body p-0 shadow mx-3 mx-md-0" }, /* @__PURE__ */ React.createElement("div", { className: "revoke-wrapper minimize-shield-wrapper position-relative" }, !showExpandRevoke && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
523
+ "img",
524
+ {
525
+ className: "cover-img position-absolute h-100 w-100 object-fit-cover",
526
+ src: bg_default
527
+ }
528
+ ), /* @__PURE__ */ React.createElement(
529
+ "div",
530
+ {
531
+ className: "minimize-shield",
532
+ onClick: () => {
533
+ if (osName !== OsTypes?.IOS && isMobile && !connection && sessionStorage.getItem("aesirx-analytics-revoke") && parseInt(sessionStorage.getItem("aesirx-analytics-revoke")) > 2) {
534
+ setActiveConnectorType(WALLET_CONNECT);
535
+ }
536
+ setShowExpandRevoke(true);
537
+ }
538
+ },
539
+ /* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
540
+ t("txt_shield_of_privacy")
541
+ )), showExpandRevoke && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
542
+ "div",
543
+ {
544
+ className: "minimize-revoke",
545
+ onClick: () => {
546
+ setShowExpandRevoke(false);
547
+ }
548
+ },
549
+ /* @__PURE__ */ React.createElement("img", { src: no_default })
550
+ ), /* @__PURE__ */ React.createElement("div", { className: "p-3 bg-white text" }, t("txt_you_can_revoke"), " ", /* @__PURE__ */ React.createElement("br", null), t("txt_visit"), " ", /* @__PURE__ */ React.createElement(
551
+ "a",
552
+ {
553
+ href: "https://nft.shield.aesirx.io",
554
+ className: "text-success text-decoration-underline",
555
+ target: "_blank",
556
+ rel: "noreferrer"
557
+ },
558
+ t("txt_link")
559
+ ), " ", t("txt_for_more_information")), /* @__PURE__ */ React.createElement("div", { className: "rounded-bottom position-relative overflow-hidden text-white" }, /* @__PURE__ */ React.createElement(
560
+ "img",
561
+ {
562
+ className: "cover-img position-absolute h-100 w-100 object-fit-cover",
563
+ src: bg_default
564
+ }
565
+ ), /* @__PURE__ */ React.createElement("div", { className: "position-relative p-3" }, /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center justify-content-between flex-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "me-2" }, /* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }), " ", t("txt_shield_of_privacy")), /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center" }, /* @__PURE__ */ React.createElement(
566
+ "a",
567
+ {
568
+ className: "text-success text-decoration-underline manage-consent fs-14",
569
+ href: "https://dapp.shield.aesirx.io/revoke-consent",
570
+ target: "_blank",
571
+ rel: "noreferrer"
572
+ },
573
+ t("txt_manage_consent")
574
+ ), loading === "done" ? /* @__PURE__ */ React.createElement(
575
+ Button,
576
+ {
577
+ variant: "success",
578
+ onClick: handleRevokeBtn,
579
+ className: "text-white d-flex align-items-center revoke-btn fs-14"
580
+ },
581
+ t("txt_revoke_consent")
582
+ ) : /* @__PURE__ */ React.createElement(React.Fragment, null), (sessionStorage.getItem("aesirx-analytics-revoke") === "4" || sessionStorage.getItem("aesirx-analytics-revoke") === "2") && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
583
+ SSOButton,
584
+ {
585
+ className: "d-none revokeLogin",
586
+ text: /* @__PURE__ */ React.createElement(React.Fragment, null, "Login Revoke"),
587
+ ssoState: "noscopes",
588
+ onGetData
589
+ }
590
+ )))))))))
591
+ )
592
+ ), /* @__PURE__ */ React.createElement(
593
+ "div",
594
+ {
595
+ tabIndex: -1,
596
+ className: `toast-container position-fixed m-md-3 ${showExpandConsent ? "top-50 start-50 translate-middle" : "bottom-0 end-0"}`
597
+ },
598
+ /* @__PURE__ */ React.createElement(
599
+ "div",
600
+ {
601
+ className: `toast custom ${show ? "show" : ""} ${showExpandConsent ? "" : "minimize"}`
602
+ },
603
+ /* @__PURE__ */ React.createElement(LoadingStatus, { loading }),
604
+ /* @__PURE__ */ React.createElement("div", { className: "toast-body p-0 shadow mx-3 mx-md-0" }, !showExpandConsent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "minimize-shield-wrapper position-relative" }, /* @__PURE__ */ React.createElement(
605
+ "img",
606
+ {
607
+ className: "cover-img position-absolute h-100 w-100 object-fit-cover",
608
+ src: bg_default
609
+ }
610
+ ), /* @__PURE__ */ React.createElement(
611
+ "div",
612
+ {
613
+ className: "minimize-shield",
614
+ onClick: () => {
615
+ setShowExpandConsent(true);
616
+ sessionStorage.removeItem("aesirx-analytics-rejected");
617
+ }
618
+ },
619
+ /* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "Shield of Privacy" }),
620
+ t("txt_shield_of_privacy")
621
+ ))) : /* @__PURE__ */ React.createElement("div", { className: "bg-white" }, level ? /* @__PURE__ */ React.createElement(React.Fragment, null, upgradeLayout ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "bg-white rounded p-3 w-100" }, loading === "done" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", { className: "mb-3" }, t("txt_upgrade_consent_text")), /* @__PURE__ */ React.createElement("p", { className: "fw-semibold text-dark" }, t("txt_your_current_level")), /* @__PURE__ */ React.createElement(
622
+ ConsentLevelUprade,
623
+ {
624
+ level,
625
+ tier: t(`txt_tier_${level}_tier`),
626
+ levelname: t(`txt_tier_${level}_levelname`),
627
+ term_custom: t(`txt_tier_${level}_term_custom`),
628
+ content_custom: t(`txt_tier_${level}_content_custom`)
629
+ }
630
+ ), /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center justify-content-between w-100 mt-3 flex-wrap" }, /* @__PURE__ */ React.createElement("p", { className: "fw-semibold text-dark w-100 w-lg-auto mb-0" }, t("txt_upgrade_consent_to")), /* @__PURE__ */ React.createElement(
631
+ "div",
632
+ {
633
+ className: "ms-auto read-more-btn fs-7 text-primary cursor-pointer",
634
+ onClick: () => {
635
+ setUpgradeShowDetail(!upgradeShowDetail ? true : false);
636
+ }
637
+ },
638
+ !upgradeShowDetail ? t("txt_show_details") : t("txt_hide_details"),
639
+ " ",
640
+ /* @__PURE__ */ React.createElement(
641
+ "img",
642
+ {
643
+ src: arrow_default,
644
+ className: `ms-1 ${upgradeShowDetail ? "revert" : ""}`
645
+ }
646
+ )
647
+ )), /* @__PURE__ */ React.createElement(Form, null, level !== 1 && /* @__PURE__ */ React.createElement(
648
+ ConsentLevelUprade,
649
+ {
650
+ level: 1,
651
+ tier: t(`txt_tier_1_tier`),
652
+ levelname: t(`txt_tier_1_levelname`),
653
+ term_custom: t(`txt_tier_1_term_custom`),
654
+ content_custom: t(`txt_tier_1_content_custom`),
655
+ isUpgrade: true
656
+ }
657
+ ), level !== 2 && /* @__PURE__ */ React.createElement(
658
+ ConsentLevelUprade,
659
+ {
660
+ level: 2,
661
+ tier: t(`txt_tier_2_tier`),
662
+ levelname: t(`txt_tier_2_levelname`),
663
+ term_custom: t(`txt_tier_2_term_custom`),
664
+ content_custom: t(`txt_tier_2_content_custom`),
665
+ isUpgrade: true
666
+ }
667
+ ), level !== 3 && /* @__PURE__ */ React.createElement(
668
+ ConsentLevelUprade,
669
+ {
670
+ level: 3,
671
+ tier: t(`txt_tier_3_tier`),
672
+ levelname: t(`txt_tier_3_levelname`),
673
+ term_custom: t(`txt_tier_3_term_custom`),
674
+ content_custom: t(`txt_tier_3_content_custom`),
675
+ isUpgrade: true
676
+ }
677
+ ), level !== 4 && /* @__PURE__ */ React.createElement(
678
+ ConsentLevelUprade,
679
+ {
680
+ level: 4,
681
+ tier: t(`txt_tier_4_tier`),
682
+ levelname: t(`txt_tier_4_levelname`),
683
+ term_custom: t(`txt_tier_4_term_custom`),
684
+ content_custom: t(`txt_tier_4_content_custom`),
685
+ isUpgrade: true
686
+ }
687
+ )), /* @__PURE__ */ React.createElement("div", { className: "d-flex w-100 flex-wrap flex-lg-nowrap justify-content-end mt-4" }, /* @__PURE__ */ React.createElement(
688
+ Button,
689
+ {
690
+ variant: "outline-success",
691
+ onClick: () => {
692
+ setUpgradeLayout(false);
693
+ },
694
+ className: "d-flex align-items-center justify-content-center fs-14 w-100 w-lg-30 me-3 mb-2 mb-lg-0 rounded-pill py-3 text-dark"
695
+ },
696
+ t("txt_cancel")
697
+ ), /* @__PURE__ */ React.createElement(
698
+ Button,
699
+ {
700
+ variant: "success",
701
+ onClick: () => {
702
+ if (upgradeLevel) {
703
+ handleLevel(upgradeLevel);
704
+ setUpgradeLayout(false);
705
+ } else {
706
+ toast("Please choose upgrade level");
707
+ }
708
+ },
709
+ className: "d-flex align-items-center justify-content-center fs-14 w-100 w-lg-30 me-3 rounded-pill py-3 text-white"
710
+ },
711
+ t("txt_change_consent")
712
+ ))) : /* @__PURE__ */ React.createElement(React.Fragment, null))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TermsComponent, { level, handleLevel, isCustom: true }, /* @__PURE__ */ React.createElement(Form, { className: "mb-0 w-100" }, /* @__PURE__ */ React.createElement(
713
+ Form.Check,
714
+ {
715
+ checked: consents.includes(1),
716
+ type: "switch",
717
+ label: "Personal data share consent.",
718
+ value: 1,
719
+ onChange: handleChange,
720
+ className: "d-none"
721
+ }
722
+ ), /* @__PURE__ */ React.createElement(
723
+ Form.Check,
724
+ {
725
+ checked: consents.includes(2),
726
+ type: "switch",
727
+ label: "Personal data cross site share consent.",
728
+ value: 2,
729
+ onChange: handleChange,
730
+ className: "d-none"
731
+ }
732
+ ), /* @__PURE__ */ React.createElement("div", { className: "d-flex w-100 flex-wrap flex-lg-nowrap" }, loading === "done" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
733
+ Button,
734
+ {
735
+ variant: "outline-success",
736
+ onClick: () => {
737
+ setUpgradeLayout(true);
738
+ },
739
+ className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-3 text-dark"
740
+ },
741
+ t("txt_change_consent")
742
+ ), " ", /* @__PURE__ */ React.createElement(
743
+ Button,
744
+ {
745
+ variant: "outline-success",
746
+ onClick: handleNotAllow,
747
+ className: "d-flex align-items-center justify-content-center fs-14 w-100 me-3 mb-2 mb-lg-0 rounded-pill py-3 text-dark"
748
+ },
749
+ t("txt_reject_consent")
750
+ ), /* @__PURE__ */ React.createElement(
751
+ "div",
752
+ {
753
+ className: `ssoBtnWrapper w-100 me-3 bg-success rounded-pill ${level === 2 || level === 4 && !account && !address ? "" : "d-none"}`
754
+ },
755
+ /* @__PURE__ */ React.createElement(
756
+ SSOButton,
757
+ {
758
+ className: "btn btn-success text-white d-flex align-items-center justify-content-center loginSSO rounded-pill py-3 w-100",
759
+ text: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }), t("txt_yes_i_consent")),
760
+ ssoState: "noscopes",
761
+ onGetData,
762
+ ...level === 2 ? { noCreateAccount: true } : {}
763
+ }
764
+ )
765
+ ), level === 2 || level === 4 && !account && !address ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement(
766
+ Button,
767
+ {
768
+ variant: "success",
769
+ onClick: handleAgree,
770
+ className: "w-100 me-3 text-white d-flex align-items-center justify-content-center fs-14 rounded-pill py-3"
771
+ },
772
+ loadingCheckAccount ? /* @__PURE__ */ React.createElement(
773
+ "span",
774
+ {
775
+ className: "spinner-border spinner-border-sm me-1",
776
+ role: "status",
777
+ "aria-hidden": "true"
778
+ }
779
+ ) : /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1" }),
780
+ t("txt_yes_i_consent")
781
+ )) : /* @__PURE__ */ React.createElement(React.Fragment, null)))))) : /* @__PURE__ */ React.createElement("div", { className: "p-4" }, /* @__PURE__ */ React.createElement(
782
+ ContentLoader,
783
+ {
784
+ speed: 2,
785
+ width: 340,
786
+ height: 84,
787
+ viewBox: "0 0 340 84",
788
+ backgroundColor: "#f3f3f3",
789
+ foregroundColor: "#ecebeb"
790
+ },
791
+ /* @__PURE__ */ React.createElement("rect", { x: "0", y: "0", rx: "3", ry: "3", width: "67", height: "11" }),
792
+ /* @__PURE__ */ React.createElement("rect", { x: "76", y: "0", rx: "3", ry: "3", width: "140", height: "11" }),
793
+ /* @__PURE__ */ React.createElement("rect", { x: "127", y: "48", rx: "3", ry: "3", width: "53", height: "11" }),
794
+ /* @__PURE__ */ React.createElement("rect", { x: "187", y: "48", rx: "3", ry: "3", width: "72", height: "11" }),
795
+ /* @__PURE__ */ React.createElement("rect", { x: "18", y: "48", rx: "3", ry: "3", width: "100", height: "11" }),
796
+ /* @__PURE__ */ React.createElement("rect", { x: "0", y: "71", rx: "3", ry: "3", width: "37", height: "11" }),
797
+ /* @__PURE__ */ React.createElement("rect", { x: "18", y: "23", rx: "3", ry: "3", width: "140", height: "11" }),
798
+ /* @__PURE__ */ React.createElement("rect", { x: "166", y: "23", rx: "3", ry: "3", width: "173", height: "11" })
799
+ ))))
800
+ )
801
+ ), !account && loading === "connect" && /* @__PURE__ */ React.createElement(
802
+ Connect_default,
803
+ {
804
+ isConnecting,
805
+ handleOnConnect,
806
+ activeConnectorError,
807
+ activeConnectorType,
808
+ activeConnector
809
+ }
810
+ ));
811
+ };
812
+ var ConsentCustom_default = ConsentComponentCustom;
813
+ export {
814
+ ConsentCustom_default as default
815
+ };