@gataca/qr 0.0.7

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.
Files changed (119) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/gat-icon-alert-0ad19b26.js +14 -0
  3. package/dist/cjs/gataca-autoqr.cjs.entry.js +105 -0
  4. package/dist/cjs/gataca-qr_2.cjs.entry.js +294 -0
  5. package/dist/cjs/gataca-qrws.cjs.entry.js +252 -0
  6. package/dist/cjs/gataca-ssibutton_2.cjs.entry.js +309 -0
  7. package/dist/cjs/gatacaqr.cjs.js +19 -0
  8. package/dist/cjs/index-93d47a75.js +1469 -0
  9. package/dist/cjs/index.cjs.js +16 -0
  10. package/dist/cjs/loader.cjs.js +21 -0
  11. package/dist/cjs/qr-code-styling-412bbc7a.js +28 -0
  12. package/dist/cjs/utils-ef28b844.js +27 -0
  13. package/dist/collection/assets/icons/gat-icon-alert.svg +5 -0
  14. package/dist/collection/assets/icons/gat-icon-check.svg +5 -0
  15. package/dist/collection/assets/icons/gat-icon-refresh.svg +4 -0
  16. package/dist/collection/assets/images/logo_gataca.svg +7 -0
  17. package/dist/collection/collection-manifest.json +17 -0
  18. package/dist/collection/components/gataca-autoqr/gataca-autoqr.css +116 -0
  19. package/dist/collection/components/gataca-autoqr/gataca-autoqr.js +323 -0
  20. package/dist/collection/components/gataca-qr/components/qr/QR.js +5 -0
  21. package/dist/collection/components/gataca-qr/components/readQR/ReadQR.js +11 -0
  22. package/dist/collection/components/gataca-qr/components/readQR/components/AnimatedLoader.js +4 -0
  23. package/dist/collection/components/gataca-qr/components/retryButton/RetryButton.js +13 -0
  24. package/dist/collection/components/gataca-qr/components/success/Success.js +8 -0
  25. package/dist/collection/components/gataca-qr/gataca-qr.css +399 -0
  26. package/dist/collection/components/gataca-qr/gataca-qr.js +965 -0
  27. package/dist/collection/components/gataca-qrdisplay/gataca-qrdisplay.js +154 -0
  28. package/dist/collection/components/gataca-qrws/components/qr/QR.js +5 -0
  29. package/dist/collection/components/gataca-qrws/components/readQR/ReadQR.js +11 -0
  30. package/dist/collection/components/gataca-qrws/components/readQR/components/AnimatedLoader.js +4 -0
  31. package/dist/collection/components/gataca-qrws/components/retryButton/RetryButton.js +13 -0
  32. package/dist/collection/components/gataca-qrws/components/success/Success.js +8 -0
  33. package/dist/collection/components/gataca-qrws/gataca-qrws.css +400 -0
  34. package/dist/collection/components/gataca-qrws/gataca-qrws.js +974 -0
  35. package/dist/collection/components/gataca-ssibutton/gataca-ssibutton.css +116 -0
  36. package/dist/collection/components/gataca-ssibutton/gataca-ssibutton.js +933 -0
  37. package/dist/collection/components/gataca-ssibuttonws/gataca-ssibuttonws.css +116 -0
  38. package/dist/collection/components/gataca-ssibuttonws/gataca-ssibuttonws.js +410 -0
  39. package/dist/collection/index.js +2 -0
  40. package/dist/collection/utils/index.js +1 -0
  41. package/dist/collection/utils/utils.js +22 -0
  42. package/dist/components/gat-icon-alert.js +30 -0
  43. package/dist/components/gataca-autoqr.d.ts +11 -0
  44. package/dist/components/gataca-autoqr.js +161 -0
  45. package/dist/components/gataca-qr.d.ts +11 -0
  46. package/dist/components/gataca-qr.js +6 -0
  47. package/dist/components/gataca-qr2.js +309 -0
  48. package/dist/components/gataca-qrdisplay.d.ts +11 -0
  49. package/dist/components/gataca-qrdisplay.js +6 -0
  50. package/dist/components/gataca-qrdisplay2.js +93 -0
  51. package/dist/components/gataca-qrws.d.ts +11 -0
  52. package/dist/components/gataca-qrws.js +6 -0
  53. package/dist/components/gataca-qrws2.js +310 -0
  54. package/dist/components/gataca-ssibutton.d.ts +11 -0
  55. package/dist/components/gataca-ssibutton.js +6 -0
  56. package/dist/components/gataca-ssibutton2.js +318 -0
  57. package/dist/components/gataca-ssibuttonws.d.ts +11 -0
  58. package/dist/components/gataca-ssibuttonws.js +6 -0
  59. package/dist/components/gataca-ssibuttonws2.js +102 -0
  60. package/dist/components/index.d.ts +27 -0
  61. package/dist/components/index.js +8 -0
  62. package/dist/esm/gat-icon-alert-7b06ef3a.js +9 -0
  63. package/dist/esm/gataca-autoqr.entry.js +101 -0
  64. package/dist/esm/gataca-qr_2.entry.js +289 -0
  65. package/dist/esm/gataca-qrws.entry.js +248 -0
  66. package/dist/esm/gataca-ssibutton_2.entry.js +304 -0
  67. package/dist/esm/gatacaqr.js +17 -0
  68. package/dist/esm/index-2be54f32.js +1443 -0
  69. package/dist/esm/index.js +1 -0
  70. package/dist/esm/loader.js +17 -0
  71. package/dist/esm/polyfills/core-js.js +11 -0
  72. package/dist/esm/polyfills/css-shim.js +1 -0
  73. package/dist/esm/polyfills/dom.js +79 -0
  74. package/dist/esm/polyfills/es5-html-element.js +1 -0
  75. package/dist/esm/polyfills/index.js +34 -0
  76. package/dist/esm/polyfills/system.js +6 -0
  77. package/dist/esm/qr-code-styling-0eeb38d5.js +26 -0
  78. package/dist/esm/utils-63e7a33b.js +24 -0
  79. package/dist/gatacaqr/gatacaqr.esm.js +1 -0
  80. package/dist/gatacaqr/index.esm.js +1 -0
  81. package/dist/gatacaqr/p-0381ab9a.entry.js +1 -0
  82. package/dist/gatacaqr/p-0be4566d.js +1 -0
  83. package/dist/gatacaqr/p-16298cb4.entry.js +1 -0
  84. package/dist/gatacaqr/p-2cd7b062.js +1 -0
  85. package/dist/gatacaqr/p-5ae5f952.js +2 -0
  86. package/dist/gatacaqr/p-68f20267.entry.js +1 -0
  87. package/dist/gatacaqr/p-9e9af27e.entry.js +1 -0
  88. package/dist/gatacaqr/p-ea783014.js +1 -0
  89. package/dist/index.cjs.js +1 -0
  90. package/dist/index.js +1 -0
  91. package/dist/types/components/gataca-autoqr/gataca-autoqr.d.ts +85 -0
  92. package/dist/types/components/gataca-qr/components/qr/QR.d.ts +9 -0
  93. package/dist/types/components/gataca-qr/components/readQR/ReadQR.d.ts +13 -0
  94. package/dist/types/components/gataca-qr/components/readQR/components/AnimatedLoader.d.ts +2 -0
  95. package/dist/types/components/gataca-qr/components/retryButton/RetryButton.d.ts +13 -0
  96. package/dist/types/components/gataca-qr/components/success/Success.d.ts +7 -0
  97. package/dist/types/components/gataca-qr/gataca-qr.d.ts +246 -0
  98. package/dist/types/components/gataca-qrdisplay/gataca-qrdisplay.d.ts +35 -0
  99. package/dist/types/components/gataca-qrws/components/qr/QR.d.ts +9 -0
  100. package/dist/types/components/gataca-qrws/components/readQR/ReadQR.d.ts +13 -0
  101. package/dist/types/components/gataca-qrws/components/readQR/components/AnimatedLoader.d.ts +2 -0
  102. package/dist/types/components/gataca-qrws/components/retryButton/RetryButton.d.ts +13 -0
  103. package/dist/types/components/gataca-qrws/components/success/Success.d.ts +7 -0
  104. package/dist/types/components/gataca-qrws/gataca-qrws.d.ts +239 -0
  105. package/dist/types/components/gataca-ssibutton/gataca-ssibutton.d.ts +218 -0
  106. package/dist/types/components/gataca-ssibuttonws/gataca-ssibuttonws.d.ts +110 -0
  107. package/dist/types/components.d.ts +1326 -0
  108. package/dist/types/index.d.ts +2 -0
  109. package/dist/types/stencil-public-runtime.d.ts +1581 -0
  110. package/dist/types/utils/index.d.ts +1 -0
  111. package/dist/types/utils/utils.d.ts +57 -0
  112. package/loader/cdn.js +3 -0
  113. package/loader/index.cjs.js +3 -0
  114. package/loader/index.d.ts +12 -0
  115. package/loader/index.es2017.js +3 -0
  116. package/loader/index.js +4 -0
  117. package/loader/package.json +11 -0
  118. package/package.json +45 -0
  119. package/readme.md +69 -0
@@ -0,0 +1,289 @@
1
+ import { r as registerInstance, h, c as createEvent } from './index-2be54f32.js';
2
+ import { l as logoGatacaSvg, g as gatIconCheckSvg, a as gatIconRefreshSvg, b as gatIconAlertSvg } from './gat-icon-alert-7b06ef3a.js';
3
+ import { Q as QRCodeStyling } from './qr-code-styling-0eeb38d5.js';
4
+ import { R as RESULT_STATUS, c as checkMobile, b as base64UrlEncode } from './utils-63e7a33b.js';
5
+
6
+ const GatacaQRDisplay = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.qrData = undefined;
10
+ this.size = 256;
11
+ this.logoSize = 0;
12
+ this.logoSrc = undefined;
13
+ this.qrColor = "#1E1E20";
14
+ this.rounded = true;
15
+ }
16
+ componentDidLoad() {
17
+ const qrCode = new QRCodeStyling({
18
+ data: this.qrData,
19
+ width: this.size,
20
+ height: this.size,
21
+ image: this.logoSize > 0 ? this.logoSrc || logoGatacaSvg : undefined,
22
+ margin: 10,
23
+ type: "svg",
24
+ dotsOptions: {
25
+ color: this.qrColor,
26
+ type: this.rounded ? "dots" : "square",
27
+ },
28
+ cornersSquareOptions: {
29
+ type: this.rounded ? "extra-rounded" : "square",
30
+ },
31
+ cornersDotOptions: {
32
+ type: this.rounded ? "dot" : "square",
33
+ },
34
+ imageOptions: {
35
+ margin: 2,
36
+ imageSize: this.logoSize,
37
+ },
38
+ });
39
+ qrCode.append(this.qr);
40
+ }
41
+ render() {
42
+ return (h("div", { ref: (el) => {
43
+ this.qr = el;
44
+ } }));
45
+ }
46
+ };
47
+
48
+ const Success = (props) => {
49
+ const { modalHeight, successLoginLabel } = props;
50
+ return (h("div", { class: "success", style: {
51
+ height: modalHeight ? (modalHeight === null || modalHeight === void 0 ? void 0 : modalHeight.toString()) + "px" : "300px",
52
+ } },
53
+ h("img", { src: gatIconCheckSvg, height: 52, width: 52 }),
54
+ h("p", { class: "successMsg" }, successLoginLabel)));
55
+ };
56
+
57
+ const RetryButton = (props) => {
58
+ var _a;
59
+ const { errorMessage, modalWidth, clickInsideBoxLabel, refreshQrLabel, scanQrLabel, waitingStartSessionLabel, display, renderRetryQR, } = props;
60
+ return (h("div", { class: "reload", style: {
61
+ width: (modalWidth - 48).toString() + "px",
62
+ height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + "px" : "",
63
+ } },
64
+ h("div", { id: "notify", onClick: () => display() },
65
+ h("img", { src: gatIconRefreshSvg, height: 24, width: 24 }),
66
+ h("p", { class: "notify-text" },
67
+ clickInsideBoxLabel,
68
+ " "),
69
+ errorMessage ? (h("p", { class: "notify-text bold" }, refreshQrLabel)) : (h("p", { class: "notify-text bold" }, scanQrLabel)),
70
+ errorMessage && (h("div", { class: "alert", style: {
71
+ width: (modalWidth - 48).toString() + "px",
72
+ } },
73
+ h("img", { src: gatIconAlertSvg, height: 24, width: 24 }),
74
+ h("p", null, errorMessage)))),
75
+ h("div", { id: "qrwait" }, renderRetryQR(waitingStartSessionLabel))));
76
+ };
77
+
78
+ const AnimatedLoader = () => {
79
+ return (h("div", { class: "containerLoader" },
80
+ h("div", { class: "loader" },
81
+ h("div", { class: "loader__item loader__item__1" }),
82
+ h("div", { class: "loader__item loader__item__2" }),
83
+ h("div", { class: "loader__item loader__item__3" }),
84
+ h("div", { class: "loader__item loader__item__4" }),
85
+ h("div", { class: "loader__item loader__item__5" }),
86
+ h("div", { class: "loader__item loader__item__6" }),
87
+ h("div", { class: "loader__item loader__item__7" }),
88
+ h("div", { class: "loader__item loader__item__8" }))));
89
+ };
90
+
91
+ const ReadQR = (props) => {
92
+ var _a;
93
+ const { modalWidth, readQrMessages, renderQR, url, sizeQR } = props;
94
+ return (h("div", { class: "blured", style: {
95
+ width: (modalWidth - 48).toString() + "px",
96
+ height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + "px" : "",
97
+ } },
98
+ h("div", { id: "notify" },
99
+ h(AnimatedLoader, null),
100
+ h("p", { class: "notify-text" }, readQrMessages === null || readQrMessages === void 0 ? void 0 :
101
+ readQrMessages.title,
102
+ " "),
103
+ h("p", { class: "notify-text bold" }, readQrMessages === null || readQrMessages === void 0 ? void 0 : readQrMessages.description)),
104
+ h("div", { id: "qrwait" }, renderQR(url, false, sizeQR))));
105
+ };
106
+
107
+ const QR = (props) => {
108
+ const { value, useLogo, logoSrc, size } = props;
109
+ return (h("gataca-qrdisplay", { qrData: value, rounded: true, size: size, "logo-size": useLogo ? 0.33 : 0, "logo-src": logoSrc }));
110
+ };
111
+
112
+ const gatacaQrCss = "@import url(\"https://fonts.googleapis.com/css2?family=Ubuntu:wght@100;300;400;500;600;700&display=swap\"); @import url(\"https://fonts.googleapis.com/css2?family=Poppins:wght@100;300;400;500;600;700&display=swap\"); @import url(\"https://fonts.googleapis.com/css2?family=Work+Sans:wght@300;400&display=swap\"); html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:\"\";content:none}table{border-collapse:collapse;border-spacing:0}.img-fluid{height:auto;max-width:50%}img{margin-left:auto;margin-right:auto}.brandSection{padding-top:5px;display:flex;align-items:center}.brandSection .gatacaImgSmall{height:13px;width:13px;margin:0;margin-right:10px}.popUpContainer .large-modal{width:300px;min-height:350px}.popUpContainer .modal-window{position:relative;border-radius:6px;overflow:hidden;color:rgba(24, 27, 94, 0.8);box-shadow:0px 3px 10px rgba(48, 48, 48, 0.1);display:flex;flex-direction:column;justify-content:space-between;align-items:center;display:flex;z-index:1001;padding:1px;background-color:white;border-radius:12px;-webkit-transition:opacity 0.5s, visibility 0s 0.5s;transition:opacity 0.5s, visibility 0s 0.5s;visibility:hidden;opacity:0}.popUpContainer .modal-window__content{width:100%;height:100%;text-align:left}.popUpContainer .modal-window__content .hidenText{display:none}.popUpContainer .modal-window .modalText{font-family:\"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:20px;font-style:normal;font-weight:700;line-height:24px;margin-top:10px;letter-spacing:1px}.popUpContainer .modal-window .qrTitleContainer{padding:14px 24px;padding-bottom:0px}.popUpContainer .modal-window .qrTitle{font-size:20px;font-weight:600;line-height:23.5px}.popUpContainer .modal-window .qrDescription{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:16px;color:#707074}.popUpContainer .modal-window .bold{font-weight:700}.popUpContainer .modal-window .qrBrand{margin-top:4px;font-size:14px;font-weight:400;line-height:16.5px;display:flex;align-items:center}.popUpContainer .modal-window .qrBrand img{margin-left:5px;height:12px}.popUpContainer .modal-window .qr-section{width:252px;height:252px}.popUpContainer .noBoxShadow{box-shadow:none}.popUpContainer .is-visible{opacity:1;visibility:visible}.is-transparent{opacity:0}.success{display:flex;height:300px;flex-direction:column;justify-content:center;align-items:center;padding:0px}.success>img{padding-bottom:12px}.success>.successMsg{line-height:23.5px;color:var(--neutral-1000, #1e1e20);text-align:center;font-family:\"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:20px;font-style:normal;font-weight:700;line-height:24px}.reload,.blured{height:252px;width:252px;border:1px dashed #a1a1a1;border-radius:12px;position:relative;top:24px;margin:0 24px 24px;display:flex;overflow:hidden;justify-content:center;align-items:center}#qrwait{display:flex;justify-content:center}#qrwait,#notify{width:100%;height:100%;top:0;left:0;border-radius:20px}#notify{z-index:10;position:absolute;justify-self:center;justify-items:center;justify-content:center;align-items:center;align-content:center;display:flex;flex-direction:column;box-sizing:border-box;padding:20px;background:rgba(255, 255, 255, 0.95)}#notify>img{padding-bottom:12px}.alert{display:flex;flex-direction:row;justify-content:start;width:252px;position:absolute;bottom:0px;border:1px solid #ee888c;background:#ffdedf;border-radius:11px;box-sizing:border-box;padding:12px;align-items:center;gap:12px}.alert>img{margin:0}.alert>p{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;margin-top:0;line-height:16px;color:#1e1e20}.notify-text{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:16px;color:#707074;text-align:center}.containerLoader{display:flex;justify-content:center;align-items:center;width:30px;height:30px;margin-bottom:12px}.loader{position:relative;margin-left:0 !important}.loader__item{position:absolute;width:9.68px;height:4px;background:transparent;border-radius:2px}.loader__item__1{transform:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-webkit-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-moz-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-o-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);animation:blink 0.8333333333s linear 0.1041666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.1041666667s infinite;-moz-animation:blink 0.8333333333s linear 0.1041666667s infinite;-o-animation:blink 0.8333333333s linear 0.1041666667s infinite}.loader__item__2{transform:translate(-4.84px, 8.5px) rotate(90deg);-webkit-animation:translate(-4.84px, 8.5px) rotate(90deg);-moz-animation:translate(-4.84px, 8.5px) rotate(90deg);-o-animation:translate(-4.84px, 8.5px) rotate(90deg);animation:blink 0.8333333333s linear 0.2083333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.2083333333s infinite;-moz-animation:blink 0.8333333333s linear 0.2083333333s infinite;-o-animation:blink 0.8333333333s linear 0.2083333333s infinite}.loader__item__3{transform:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-webkit-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-moz-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-o-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);animation:blink 0.8333333333s linear 0.3125s infinite;-webkit-animation:blink 0.8333333333s linear 0.3125s infinite;-moz-animation:blink 0.8333333333s linear 0.3125s infinite;-o-animation:blink 0.8333333333s linear 0.3125s infinite}.loader__item__4{transform:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-webkit-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-moz-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-o-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);animation:blink 0.8333333333s linear 0.4166666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.4166666667s infinite;-moz-animation:blink 0.8333333333s linear 0.4166666667s infinite;-o-animation:blink 0.8333333333s linear 0.4166666667s infinite}.loader__item__5{transform:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-webkit-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-moz-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-o-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);animation:blink 0.8333333333s linear 0.5208333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.5208333333s infinite;-moz-animation:blink 0.8333333333s linear 0.5208333333s infinite;-o-animation:blink 0.8333333333s linear 0.5208333333s infinite}.loader__item__6{transform:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-webkit-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-moz-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-o-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);animation:blink 0.8333333333s linear 0.625s infinite;-webkit-animation:blink 0.8333333333s linear 0.625s infinite;-moz-animation:blink 0.8333333333s linear 0.625s infinite;-o-animation:blink 0.8333333333s linear 0.625s infinite}.loader__item__7{transform:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-webkit-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-moz-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-o-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);animation:blink 0.8333333333s linear 0.7291666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.7291666667s infinite;-moz-animation:blink 0.8333333333s linear 0.7291666667s infinite;-o-animation:blink 0.8333333333s linear 0.7291666667s infinite}.loader__item__8{transform:translate(5.6631628524px, -1.99913122px) rotate(360deg);-webkit-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);-moz-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);-o-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);animation:blink 0.8333333333s linear 0.8333333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.8333333333s infinite;-moz-animation:blink 0.8333333333s linear 0.8333333333s infinite;-o-animation:blink 0.8333333333s linear 0.8333333333s infinite}.loader__item__8{max-width:8.5px}@keyframes blink{0%{background:#4745B7}100%{background:#CCCBF8}}@keyframes rotate{0%{transform:rotate(0deg)}100%{background:rotate(360deg)}}";
113
+
114
+ const DEEP_LINK_PREFIX = "https://api.gataca.io/qr/redirect.html";
115
+ //Default values
116
+ const DEFAULT_SESSION_TIMEOUT = 300; //5mins as in connect
117
+ const DEFAULT_POLLING_FREQ = 3;
118
+ const GatacaQR = class {
119
+ constructor(hostRef) { registerInstance(this, hostRef); this.gatacaLoginCompleted = createEvent(this, "gatacaLoginCompleted", 7); this.gatacaLoginFailed = createEvent(this, "gatacaLoginFailed", 7); this.checkStatus = undefined; this.createSession = undefined; this.successCallback = undefined; this.errorCallback = undefined; this.qrRole = undefined; this.callbackServer = undefined; this.autostart = true; this.autorefresh = false; this.v = "3"; this.qrModalTitle = "Quick Access"; this.modalTitleColor = "#4745B7"; this.qrModalDescription = "Sign up or sign in by scanning the QR Code with the Gataca Wallet"; this.hideModalTexts = false; this.hideModalBoxShadow = false; this.hideBrandTitle = false; this.logoSize = 0; this.logoSrc = logoGatacaSvg; this.qrSize = 300; this.modalWidth = 300; this.modalHeight = undefined; this.qrCodeExpiredLabel = "QR Code expired"; this.credentialsNotValidatedLabel = "User credentials not validated"; this.clickInsideBoxLabel = "Click inside the box to"; this.refreshQrLabel = "Refresh QR Code"; this.scanQrLabel = "Scan QR Code"; this.userNotScanInTimeErrorLabel = "User did not scan the QR in the allowed time"; this.credsNotValidatedErrorLabel = "Provided user credentials couldn't be validated"; this.failedLoginErrorLabel = "No successful login"; this.successLoginLabel = "Successful Connection!"; this.byBrandLabel = "by Gataca"; this.waitingStartSessionLabel = "waiting to start a session"; this.readQrTitle = "Processing..."; this.readQrDescription = "Please wait a moment"; this.hideQrModalDescription = false; this.sessionTimeout = DEFAULT_SESSION_TIMEOUT; this.pollingFrequency = DEFAULT_POLLING_FREQ; this.dynamicLink = true; this.sessionId = undefined; this.authenticationRequest = undefined; this.sessionData = undefined; this.result = RESULT_STATUS.NOT_STARTED; }
120
+ disconnectedCallback() {
121
+ this.stop();
122
+ }
123
+ async componentDidLoad() {
124
+ if (this.autostart) {
125
+ await this.display();
126
+ }
127
+ }
128
+ /**
129
+ * Force manually the display of a QR
130
+ */
131
+ async display() {
132
+ await this.getSessionId();
133
+ this.result = RESULT_STATUS.ONGOING;
134
+ this.poll()
135
+ .then((data) => {
136
+ this.result = RESULT_STATUS.SUCCESS;
137
+ this.sessionData = data;
138
+ this.gatacaLoginCompleted.emit(data);
139
+ this.successCallback(data);
140
+ })
141
+ .catch((err) => {
142
+ this.clean();
143
+ let expired = err === RESULT_STATUS.EXPIRED;
144
+ if (expired && this.autorefresh) {
145
+ this.display();
146
+ }
147
+ else {
148
+ if (err !== RESULT_STATUS.NOT_STARTED) {
149
+ let error = expired
150
+ ? new Error(this.userNotScanInTimeErrorLabel)
151
+ : new Error(this.credsNotValidatedErrorLabel);
152
+ this.result = err;
153
+ this.gatacaLoginFailed.emit(error);
154
+ this.errorCallback(error);
155
+ }
156
+ }
157
+ });
158
+ if (checkMobile() && this.dynamicLink) {
159
+ window.location.href = this.getLink();
160
+ }
161
+ }
162
+ /**
163
+ * Stop manually an ongoing session
164
+ */
165
+ async stop() {
166
+ this.clean();
167
+ if (this.result === RESULT_STATUS.ONGOING || RESULT_STATUS.READ) {
168
+ this.result = RESULT_STATUS.NOT_STARTED;
169
+ }
170
+ }
171
+ clean() {
172
+ this.sessionData = undefined;
173
+ this.sessionId = undefined;
174
+ }
175
+ /**
176
+ * Retrieve manually the session data on a successful login
177
+ */
178
+ async getSessionData() {
179
+ return this.sessionData
180
+ ? Promise.resolve(this.sessionData)
181
+ : Promise.reject(new Error(this.failedLoginErrorLabel));
182
+ }
183
+ async getSessionId() {
184
+ if (this.sessionId) {
185
+ return this.sessionId;
186
+ }
187
+ let { sessionId, authenticationRequest } = await this.createSession();
188
+ this.sessionId = sessionId;
189
+ this.authenticationRequest = authenticationRequest;
190
+ return this.sessionId;
191
+ }
192
+ getLink() {
193
+ if (this.v === "2") {
194
+ return this.authenticationRequest;
195
+ }
196
+ const authRequestEncoded = "?dl=" + base64UrlEncode(this.authenticationRequest);
197
+ return DEEP_LINK_PREFIX + authRequestEncoded;
198
+ }
199
+ async poll() {
200
+ let endTime = new Date().getTime() +
201
+ (this.sessionTimeout || DEFAULT_SESSION_TIMEOUT) * 1000;
202
+ let interval = (this.pollingFrequency || DEFAULT_POLLING_FREQ) * 1000;
203
+ let checkFunc = async (component) => {
204
+ if (component.result === RESULT_STATUS.NOT_STARTED) {
205
+ return { result: RESULT_STATUS.NOT_STARTED };
206
+ }
207
+ let id = await component.getSessionId();
208
+ return component.checkStatus(id);
209
+ };
210
+ let component = this;
211
+ let checkCondition = async function (resolve, reject) {
212
+ // If the condition is met, we're done!
213
+ let { result, data } = await checkFunc(component);
214
+ switch (result) {
215
+ case RESULT_STATUS.SUCCESS:
216
+ resolve(data);
217
+ break;
218
+ case RESULT_STATUS.READ:
219
+ component.result = RESULT_STATUS.READ;
220
+ case RESULT_STATUS.ONGOING:
221
+ if (component.sessionTimeout > 0 && new Date().getTime() < endTime) {
222
+ setTimeout(checkCondition, interval, resolve, reject);
223
+ }
224
+ else {
225
+ reject(RESULT_STATUS.EXPIRED);
226
+ }
227
+ break;
228
+ default:
229
+ reject(result);
230
+ break;
231
+ }
232
+ };
233
+ return new Promise(checkCondition);
234
+ }
235
+ renderQRSection() {
236
+ switch (this.result) {
237
+ case RESULT_STATUS.NOT_STARTED:
238
+ return this.renderRetryButton();
239
+ case RESULT_STATUS.ONGOING:
240
+ return this.renderQR(this.getLink(), true);
241
+ case RESULT_STATUS.EXPIRED:
242
+ return this.renderRetryButton(this.qrCodeExpiredLabel);
243
+ case RESULT_STATUS.FAILED:
244
+ return this.renderRetryButton(this.credentialsNotValidatedLabel);
245
+ case RESULT_STATUS.SUCCESS:
246
+ return this.renderSuccess();
247
+ case RESULT_STATUS.READ:
248
+ return this.renderReadQR({
249
+ title: this === null || this === void 0 ? void 0 : this.readQrTitle,
250
+ description: this === null || this === void 0 ? void 0 : this.readQrDescription,
251
+ });
252
+ }
253
+ }
254
+ renderSuccess() {
255
+ return (h(Success, { modalHeight: this === null || this === void 0 ? void 0 : this.modalHeight, successLoginLabel: this === null || this === void 0 ? void 0 : this.successLoginLabel }));
256
+ }
257
+ renderRetryButton(errorMessage) {
258
+ return (h(RetryButton, { errorMessage: errorMessage, modalWidth: this === null || this === void 0 ? void 0 : this.modalWidth, clickInsideBoxLabel: this === null || this === void 0 ? void 0 : this.clickInsideBoxLabel, refreshQrLabel: this === null || this === void 0 ? void 0 : this.refreshQrLabel, scanQrLabel: this === null || this === void 0 ? void 0 : this.scanQrLabel, waitingStartSessionLabel: this === null || this === void 0 ? void 0 : this.waitingStartSessionLabel, display: this.display.bind(this), renderRetryQR: this.renderRetryQR.bind(this) }));
259
+ }
260
+ renderReadQR(readQrMessages) {
261
+ return (h(ReadQR, { modalWidth: this === null || this === void 0 ? void 0 : this.modalWidth, readQrMessages: readQrMessages, url: this.getLink(), sizeQR: (this === null || this === void 0 ? void 0 : this.qrSize) ? (this === null || this === void 0 ? void 0 : this.qrSize) - 50 : undefined, renderQR: this.renderQR }));
262
+ }
263
+ renderQR(value, useLogo) {
264
+ return (h(QR, { value: value, useLogo: useLogo, size: (this === null || this === void 0 ? void 0 : this.qrSize) || undefined, logoSrc: this === null || this === void 0 ? void 0 : this.logoSrc }));
265
+ }
266
+ renderRetryQR(value, useLogo) {
267
+ return (h(QR, { value: value, useLogo: useLogo, size: (this === null || this === void 0 ? void 0 : this.qrSize) ? (this === null || this === void 0 ? void 0 : this.qrSize) - 50 : undefined, logoSrc: this === null || this === void 0 ? void 0 : this.logoSrc }));
268
+ }
269
+ render() {
270
+ var _a, _b;
271
+ return (h("div", { class: "popUpContainer" }, h("div", { class: `is-visible modal-window ${this.hideModalTexts ? "" : "large-modal"} ${this.hideModalBoxShadow ? "noBoxShadow" : ""}`, style: {
272
+ width: (this.modalWidth - 2).toString() + "px",
273
+ height: this.modalHeight
274
+ ? ((_a = (this.modalHeight - 2)) === null || _a === void 0 ? void 0 : _a.toString()) + "px"
275
+ : "",
276
+ }, onClick: (event) => {
277
+ event.stopPropagation();
278
+ } }, h("div", { class: "modal-window__content" }, h("div", { class: `qrTitleContainer ${this.hideModalTexts ? "hidenText" : ""}` }, h("p", { class: "qrTitle modalText", style: { color: this.modalTitleColor || "#1e1e20" } }, this.qrModalTitle), !this.hideBrandTitle && (h("p", { class: "qrBrand modalText" }, this.byBrandLabel, " ", h("span", null, h("img", { src: logoGatacaSvg })))), this.result !== RESULT_STATUS.SUCCESS &&
279
+ !this.hideQrModalDescription && (h("p", { class: "qrDescription modalText" }, this.qrModalDescription))), h("div", { class: "qrSection", style: {
280
+ width: this.modalWidth.toString() + "px",
281
+ height: this.modalWidth
282
+ ? ((_b = this.modalWidth) === null || _b === void 0 ? void 0 : _b.toString()) + "px"
283
+ : "",
284
+ } }, this.renderQRSection())))));
285
+ }
286
+ };
287
+ GatacaQR.style = gatacaQrCss;
288
+
289
+ export { GatacaQR as gataca_qr, GatacaQRDisplay as gataca_qrdisplay };
@@ -0,0 +1,248 @@
1
+ import { h, r as registerInstance, c as createEvent } from './index-2be54f32.js';
2
+ import { g as gatIconCheckSvg, a as gatIconRefreshSvg, b as gatIconAlertSvg, l as logoGatacaSvg } from './gat-icon-alert-7b06ef3a.js';
3
+ import './qr-code-styling-0eeb38d5.js';
4
+ import { R as RESULT_STATUS, c as checkMobile, b as base64UrlEncode } from './utils-63e7a33b.js';
5
+
6
+ const Success = (props) => {
7
+ const { modalHeight, successLoginLabel } = props;
8
+ return (h("div", { class: "success", style: {
9
+ height: modalHeight ? (modalHeight === null || modalHeight === void 0 ? void 0 : modalHeight.toString()) + "px" : "300px",
10
+ } },
11
+ h("img", { src: gatIconCheckSvg, height: 52, width: 52 }),
12
+ h("p", { class: "successMsg" }, successLoginLabel)));
13
+ };
14
+
15
+ const RetryButton = (props) => {
16
+ var _a;
17
+ const { errorMessage, modalWidth, clickInsideBoxLabel, refreshQrLabel, scanQrLabel, waitingStartSessionLabel, display, renderRetryQR, } = props;
18
+ return (h("div", { class: "reload", style: {
19
+ width: (modalWidth - 48).toString() + "px",
20
+ height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + "px" : "",
21
+ } },
22
+ h("div", { id: "notify", onClick: () => display() },
23
+ h("img", { src: gatIconRefreshSvg, height: 24, width: 24 }),
24
+ h("p", { class: "notify-text" },
25
+ clickInsideBoxLabel,
26
+ " "),
27
+ errorMessage ? (h("p", { class: "notify-text bold" }, refreshQrLabel)) : (h("p", { class: "notify-text bold" }, scanQrLabel)),
28
+ errorMessage && (h("div", { class: "alert", style: {
29
+ width: (modalWidth - 48).toString() + "px",
30
+ } },
31
+ h("img", { src: gatIconAlertSvg, height: 24, width: 24 }),
32
+ h("p", null, errorMessage)))),
33
+ h("div", { id: "qrwait" }, renderRetryQR(waitingStartSessionLabel))));
34
+ };
35
+
36
+ const QR = (props) => {
37
+ const { value, useLogo, logoSrc, size } = props;
38
+ return (h("gataca-qrdisplay", { qrData: value, rounded: true, size: size, "logo-size": useLogo ? 0.33 : 0, "logo-src": logoSrc }));
39
+ };
40
+
41
+ const AnimatedLoader = () => {
42
+ return (h("div", { class: "containerLoader" },
43
+ h("div", { class: "loader" },
44
+ h("div", { class: "loader__item loader__item__1" }),
45
+ h("div", { class: "loader__item loader__item__2" }),
46
+ h("div", { class: "loader__item loader__item__3" }),
47
+ h("div", { class: "loader__item loader__item__4" }),
48
+ h("div", { class: "loader__item loader__item__5" }),
49
+ h("div", { class: "loader__item loader__item__6" }),
50
+ h("div", { class: "loader__item loader__item__7" }),
51
+ h("div", { class: "loader__item loader__item__8" }))));
52
+ };
53
+
54
+ const ReadQR = (props) => {
55
+ var _a;
56
+ const { modalWidth, readQrMessages, renderQR, url, sizeQR } = props;
57
+ return (h("div", { class: "blured", style: {
58
+ width: (modalWidth - 48).toString() + "px",
59
+ height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + "px" : "",
60
+ } },
61
+ h("div", { id: "notify" },
62
+ h(AnimatedLoader, null),
63
+ h("p", { class: "notify-text" }, readQrMessages === null || readQrMessages === void 0 ? void 0 :
64
+ readQrMessages.title,
65
+ " "),
66
+ h("p", { class: "notify-text bold" }, readQrMessages === null || readQrMessages === void 0 ? void 0 : readQrMessages.description)),
67
+ h("div", { id: "qrwait" }, renderQR(url, false, sizeQR))));
68
+ };
69
+
70
+ const gatacaQrwsCss = "@import url(\"https://fonts.googleapis.com/css2?family=Ubuntu:wght@100;300;400;500;600;700&display=swap\"); @import url(\"https://fonts.googleapis.com/css2?family=Poppins:wght@100;300;400;500;600;700&display=swap\"); @import url(\"https://fonts.googleapis.com/css2?family=Work+Sans:wght@300;400&display=swap\"); html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:\"\";content:none}table{border-collapse:collapse;border-spacing:0}.img-fluid{height:auto;max-width:50%}img{margin-left:auto;margin-right:auto}.brandSection{padding-top:5px;display:flex;align-items:center}.brandSection .gatacaImgSmall{height:13px;width:13px;margin:0;margin-right:10px}.popUpContainer .large-modal{width:300px;min-height:350px}.popUpContainer .modal-window{position:relative;border-radius:6px;overflow:hidden;color:rgba(24, 27, 94, 0.8);box-shadow:0px 3px 10px rgba(48, 48, 48, 0.1);display:flex;flex-direction:column;justify-content:space-between;align-items:center;display:flex;z-index:1001;padding:1px;background-color:white;border-radius:12px;-webkit-transition:opacity 0.5s, visibility 0s 0.5s;transition:opacity 0.5s, visibility 0s 0.5s;visibility:hidden;opacity:0}.popUpContainer .modal-window__content{width:100%;height:100%;text-align:left}.popUpContainer .modal-window__content .hidenText{display:none}.popUpContainer .modal-window .modalText{font-family:\"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:20px;font-style:normal;font-weight:700;line-height:24px;margin-top:10px;letter-spacing:1px}.popUpContainer .modal-window .qrTitleContainer{padding:14px 24px;padding-bottom:0px}.popUpContainer .modal-window .qrTitle{font-size:20px;font-weight:600;line-height:23.5px}.popUpContainer .modal-window .qrDescription{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:16px;color:#707074}.popUpContainer .modal-window .bold{font-weight:700}.popUpContainer .modal-window .qrBrand{margin-top:4px;font-size:14px;font-weight:400;line-height:16.5px;display:flex;align-items:center}.popUpContainer .modal-window .qrBrand img{margin-left:5px;height:12px}.popUpContainer .modal-window .qr-section{width:252px;height:252px}.popUpContainer .noBoxShadow{box-shadow:none}.popUpContainer .is-visible{opacity:1;visibility:visible}.is-transparent{opacity:0}.success{display:flex;height:300px;flex-direction:column;justify-content:center;align-items:center;padding:0px}.success>img{padding-bottom:12px}.success>.successMsg{line-height:23.5px;color:var(--neutral-1000, #1e1e20);text-align:center;font-family:\"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:20px;font-style:normal;font-weight:700;line-height:24px}.reload,.blured{height:252px;width:252px;border:1px dashed #a1a1a1;border-radius:12px;position:relative;top:24px;margin:0 24px 24px;display:flex;overflow:hidden;justify-content:center;align-items:center}#qrwait{display:flex;justify-content:center}#qrwait,#notify{width:100%;height:100%;top:0;left:0;border-radius:20px}#notify{z-index:10;position:absolute;justify-self:center;justify-items:center;justify-content:center;align-items:center;align-content:center;display:flex;flex-direction:column;box-sizing:border-box;padding:20px;background:rgba(255, 255, 255, 0.95)}#notify>img{padding-bottom:12px}.alert{display:flex;flex-direction:row;justify-content:start;width:252px;position:absolute;bottom:0px;border:1px solid #ee888c;background:#ffdedf;border-radius:11px;box-sizing:border-box;padding:12px;align-items:center;gap:12px}.alert>img{margin:0}.alert>p{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;margin-top:0;line-height:16px;color:#1e1e20}.notify-text{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:16px;color:#707074;text-align:center}.containerLoader{display:flex;justify-content:center;align-items:center;width:30px;height:30px;margin-bottom:12px}.loader{position:relative;margin-left:0 !important}.loader__item{position:absolute;width:9.68px;height:4px;background:transparent;border-radius:2px}.loader__item__1{transform:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-webkit-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-moz-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-o-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);animation:blink 0.8333333333s linear 0.1041666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.1041666667s infinite;-moz-animation:blink 0.8333333333s linear 0.1041666667s infinite;-o-animation:blink 0.8333333333s linear 0.1041666667s infinite}.loader__item__2{transform:translate(-4.84px, 8.5px) rotate(90deg);-webkit-animation:translate(-4.84px, 8.5px) rotate(90deg);-moz-animation:translate(-4.84px, 8.5px) rotate(90deg);-o-animation:translate(-4.84px, 8.5px) rotate(90deg);animation:blink 0.8333333333s linear 0.2083333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.2083333333s infinite;-moz-animation:blink 0.8333333333s linear 0.2083333333s infinite;-o-animation:blink 0.8333333333s linear 0.2083333333s infinite}.loader__item__3{transform:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-webkit-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-moz-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-o-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);animation:blink 0.8333333333s linear 0.3125s infinite;-webkit-animation:blink 0.8333333333s linear 0.3125s infinite;-moz-animation:blink 0.8333333333s linear 0.3125s infinite;-o-animation:blink 0.8333333333s linear 0.3125s infinite}.loader__item__4{transform:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-webkit-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-moz-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-o-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);animation:blink 0.8333333333s linear 0.4166666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.4166666667s infinite;-moz-animation:blink 0.8333333333s linear 0.4166666667s infinite;-o-animation:blink 0.8333333333s linear 0.4166666667s infinite}.loader__item__5{transform:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-webkit-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-moz-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-o-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);animation:blink 0.8333333333s linear 0.5208333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.5208333333s infinite;-moz-animation:blink 0.8333333333s linear 0.5208333333s infinite;-o-animation:blink 0.8333333333s linear 0.5208333333s infinite}.loader__item__6{transform:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-webkit-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-moz-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-o-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);animation:blink 0.8333333333s linear 0.625s infinite;-webkit-animation:blink 0.8333333333s linear 0.625s infinite;-moz-animation:blink 0.8333333333s linear 0.625s infinite;-o-animation:blink 0.8333333333s linear 0.625s infinite}.loader__item__7{transform:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-webkit-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-moz-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-o-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);animation:blink 0.8333333333s linear 0.7291666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.7291666667s infinite;-moz-animation:blink 0.8333333333s linear 0.7291666667s infinite;-o-animation:blink 0.8333333333s linear 0.7291666667s infinite}.loader__item__8{transform:translate(5.6631628524px, -1.99913122px) rotate(360deg);-webkit-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);-moz-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);-o-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);animation:blink 0.8333333333s linear 0.8333333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.8333333333s infinite;-moz-animation:blink 0.8333333333s linear 0.8333333333s infinite;-o-animation:blink 0.8333333333s linear 0.8333333333s infinite}.loader__item__8{max-width:8.5px}@keyframes blink{0%{background:#4745B7}100%{background:#CCCBF8}}@keyframes rotate{0%{transform:rotate(0deg)}100%{background:rotate(360deg)}}";
71
+
72
+ const DEEP_LINK_PREFIX = "https://api.gataca.io/qr/redirect.html";
73
+ const DEFAULT_SESSION_TIMEOUT = 300;
74
+ const QR_ROLE_CONNECT = "connect";
75
+ const GatacaQRWS = class {
76
+ constructor(hostRef) { registerInstance(this, hostRef); this.gatacaLoginCompleted = createEvent(this, "gatacaLoginCompleted", 7); this.gatacaLoginFailed = createEvent(this, "gatacaLoginFailed", 7); this.successCallback = undefined; this.errorCallback = undefined; this.qrRole = undefined; this.callbackServer = undefined; this.socketEndpoint = undefined; this.sessionTimeout = DEFAULT_SESSION_TIMEOUT; this.wsOnOpen = undefined; this.wsOnMessage = undefined; this.autostart = true; this.autorefresh = false; this.v = "3"; this.qrModalTitle = "Quick Access"; this.modalTitleColor = "#4745B7"; this.qrModalDescription = "Sign up or sign in by scanning the QR Code with the Gataca Wallet"; this.hideModalTexts = false; this.hideModalBoxShadow = false; this.hideBrandTitle = false; this.logoSize = 0; this.logoSrc = logoGatacaSvg; this.qrSize = 300; this.modalWidth = 300; this.modalHeight = undefined; this.qrCodeExpiredLabel = "QR Code expired"; this.credentialsNotValidatedLabel = "User credentials not validated"; this.clickInsideBoxLabel = "Click inside the box to"; this.refreshQrLabel = "Refresh QR Code"; this.scanQrLabel = "Scan QR Code"; this.userNotScanInTimeErrorLabel = "User did not scan the QR in the allowed time"; this.credsNotValidatedErrorLabel = "Provided user credentials couldn't be validated"; this.failedLoginErrorLabel = "No successful login"; this.successLoginLabel = "Successful Connection!"; this.byBrandLabel = "by Gataca"; this.waitingStartSessionLabel = "waiting to start a session"; this.readQrTitle = "Processing..."; this.readQrDescription = "Please wait a moment"; this.hideQrModalDescription = false; this.dynamicLink = true; this.sessionId = undefined; this.authenticationRequest = undefined; this.sessionData = undefined; this.result = RESULT_STATUS.NOT_STARTED; }
77
+ disconnectedCallback() {
78
+ this.stop();
79
+ }
80
+ async componentDidLoad() {
81
+ if (this.autostart) {
82
+ await this.display();
83
+ }
84
+ }
85
+ /**
86
+ * Force manually the display of a QR
87
+ */
88
+ async display() {
89
+ let socket = new WebSocket(this.socketEndpoint);
90
+ setTimeout(() => {
91
+ this.socket.close(1000, "");
92
+ }, 1000 * this.sessionTimeout);
93
+ this.socket = socket;
94
+ socket.onopen = () => {
95
+ if (this.wsOnOpen)
96
+ this.wsOnOpen(this.socket);
97
+ };
98
+ socket.onmessage = (msg) => {
99
+ if (this.wsOnMessage) {
100
+ this.wsOnMessage(this.socket, msg);
101
+ }
102
+ else {
103
+ let wsresp = JSON.parse(msg.data);
104
+ if (!!wsresp.sessionId) {
105
+ this.handleWSResponse(wsresp);
106
+ }
107
+ }
108
+ };
109
+ socket.onerror = () => {
110
+ let error = new Error("Error connecting with server");
111
+ this.result = RESULT_STATUS.FAILED;
112
+ this.gatacaLoginFailed.emit(error);
113
+ this.errorCallback(error);
114
+ socket.close(1000, "");
115
+ };
116
+ socket.onclose = () => {
117
+ if (this.result === RESULT_STATUS.ONGOING || RESULT_STATUS.READ) {
118
+ this.result = RESULT_STATUS.EXPIRED;
119
+ }
120
+ if (this.result === RESULT_STATUS.EXPIRED) {
121
+ if (this.autorefresh) {
122
+ this.display();
123
+ }
124
+ else {
125
+ let error = new Error("User did not scan the QR in the alloted time");
126
+ this.gatacaLoginFailed.emit(error);
127
+ this.errorCallback(error);
128
+ }
129
+ }
130
+ };
131
+ if (checkMobile() && this.dynamicLink) {
132
+ window.location.href = this.getLink();
133
+ }
134
+ }
135
+ sessionMsgReceived(event) {
136
+ let wsresp = event.detail;
137
+ this.handleWSResponse(wsresp);
138
+ }
139
+ handleWSResponse(wsresp) {
140
+ this.result = wsresp.result;
141
+ switch (wsresp.result) {
142
+ case RESULT_STATUS.ONGOING:
143
+ case RESULT_STATUS.READ:
144
+ this.sessionId = wsresp.sessionId;
145
+ this.authenticationRequest = wsresp.authenticationRequest;
146
+ break;
147
+ case RESULT_STATUS.SUCCESS:
148
+ this.sessionData = wsresp.authenticatedUserData;
149
+ this.gatacaLoginCompleted.emit(wsresp.authenticatedUserData);
150
+ this.successCallback(wsresp.authenticatedUserData);
151
+ this.socket.close(1000, "");
152
+ break;
153
+ case RESULT_STATUS.FAILED:
154
+ this.socket.close();
155
+ let error = new Error("Provided user credentials couldn't be validated");
156
+ this.gatacaLoginFailed.emit(error);
157
+ this.errorCallback(error);
158
+ break;
159
+ case RESULT_STATUS.EXPIRED:
160
+ this.socket.close();
161
+ if (this.autorefresh) {
162
+ this.display();
163
+ }
164
+ else {
165
+ let error = new Error("User did not scan the QR in the alloted time");
166
+ this.gatacaLoginFailed.emit(error);
167
+ this.errorCallback(error);
168
+ }
169
+ }
170
+ }
171
+ /**
172
+ * Stop manually an ongoing session
173
+ */
174
+ async stop() {
175
+ this.sessionData = undefined;
176
+ this.sessionId = undefined;
177
+ this.socket.close(1000, "Client stopped the connection");
178
+ }
179
+ /**
180
+ * Retrieve manually the session data on a successful login
181
+ */
182
+ async getSessionData() {
183
+ return this.sessionData
184
+ ? Promise.resolve(this.sessionData)
185
+ : Promise.reject(new Error("No successful login"));
186
+ }
187
+ getLink() {
188
+ if (this.v === "2" && this.qrRole == QR_ROLE_CONNECT) {
189
+ return this.authenticationRequest;
190
+ }
191
+ const authRequestEncoded = "?dl=" + base64UrlEncode(this.authenticationRequest);
192
+ return DEEP_LINK_PREFIX + authRequestEncoded;
193
+ }
194
+ renderQRSection() {
195
+ switch (this.result) {
196
+ case RESULT_STATUS.NOT_STARTED:
197
+ return this.renderRetryButton();
198
+ case RESULT_STATUS.ONGOING:
199
+ return this.renderQR(this.getLink(), true);
200
+ case RESULT_STATUS.EXPIRED:
201
+ return this.renderRetryButton(this.qrCodeExpiredLabel);
202
+ case RESULT_STATUS.FAILED:
203
+ return this.renderRetryButton(this.credentialsNotValidatedLabel);
204
+ case RESULT_STATUS.SUCCESS:
205
+ return this.renderSuccess();
206
+ case RESULT_STATUS.READ:
207
+ return this.renderReadQR({
208
+ title: this === null || this === void 0 ? void 0 : this.readQrTitle,
209
+ description: this === null || this === void 0 ? void 0 : this.readQrDescription,
210
+ });
211
+ }
212
+ }
213
+ renderSuccess() {
214
+ return (h(Success, { modalHeight: this === null || this === void 0 ? void 0 : this.modalHeight, successLoginLabel: this === null || this === void 0 ? void 0 : this.successLoginLabel }));
215
+ }
216
+ renderRetryButton(errorMessage) {
217
+ return (h(RetryButton, { errorMessage: errorMessage, modalWidth: this === null || this === void 0 ? void 0 : this.modalWidth, clickInsideBoxLabel: this === null || this === void 0 ? void 0 : this.clickInsideBoxLabel, refreshQrLabel: this === null || this === void 0 ? void 0 : this.refreshQrLabel, scanQrLabel: this === null || this === void 0 ? void 0 : this.scanQrLabel, waitingStartSessionLabel: this === null || this === void 0 ? void 0 : this.waitingStartSessionLabel, display: this.display.bind(this), renderRetryQR: this.renderRetryQR.bind(this) }));
218
+ }
219
+ renderReadQR(readQrMessages) {
220
+ return (h(ReadQR, { modalWidth: this === null || this === void 0 ? void 0 : this.modalWidth, readQrMessages: readQrMessages, url: this.getLink(), sizeQR: (this === null || this === void 0 ? void 0 : this.qrSize) ? (this === null || this === void 0 ? void 0 : this.qrSize) - 50 : undefined, renderQR: this.renderQR.bind(this) }));
221
+ }
222
+ renderQR(value, useLogo) {
223
+ return (h(QR, { value: value, useLogo: useLogo, size: (this === null || this === void 0 ? void 0 : this.qrSize) || undefined, logoSrc: this === null || this === void 0 ? void 0 : this.logoSrc }));
224
+ }
225
+ renderRetryQR(value, useLogo) {
226
+ return (h(QR, { value: value, useLogo: useLogo, size: (this === null || this === void 0 ? void 0 : this.qrSize) ? (this === null || this === void 0 ? void 0 : this.qrSize) - 50 : undefined, logoSrc: this === null || this === void 0 ? void 0 : this.logoSrc }));
227
+ }
228
+ render() {
229
+ var _a, _b;
230
+ return (h("div", { class: "popUpContainer" }, h("div", { class: `is-visible modal-window ${this.hideModalTexts ? "" : "large-modal"} ${this.hideModalBoxShadow ? "noBoxShadow" : ""}`, style: {
231
+ width: (this.modalWidth - 2).toString() + "px",
232
+ height: this.modalHeight
233
+ ? ((_a = (this.modalHeight - 2)) === null || _a === void 0 ? void 0 : _a.toString()) + "px"
234
+ : "",
235
+ }, onClick: (event) => {
236
+ event.stopPropagation();
237
+ } }, h("div", { class: "modal-window__content" }, h("div", { class: `qrTitleContainer ${this.hideModalTexts ? "hidenText" : ""}` }, h("p", { class: "qrTitle modalText", style: { color: this.modalTitleColor || "#1e1e20" } }, this.qrModalTitle), !this.hideBrandTitle && (h("p", { class: "qrBrand modalText" }, this.byBrandLabel, " ", h("span", null, h("img", { src: logoGatacaSvg })))), this.result !== RESULT_STATUS.SUCCESS &&
238
+ !this.hideQrModalDescription && (h("p", { class: "qrDescription modalText" }, this.qrModalDescription))), h("div", { class: "qrSection", style: {
239
+ width: this.modalWidth.toString() + "px",
240
+ height: this.modalWidth
241
+ ? ((_b = this.modalWidth) === null || _b === void 0 ? void 0 : _b.toString()) + "px"
242
+ : "",
243
+ } }, this.renderQRSection())))));
244
+ }
245
+ };
246
+ GatacaQRWS.style = gatacaQrwsCss;
247
+
248
+ export { GatacaQRWS as gataca_qrws };