crmbonus-component-wake 2.1.34 → 2.1.35-homolog

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 (196) hide show
  1. package/dist/cjs/app-modal.cjs.entry.js +1 -1
  2. package/dist/cjs/{cart.helper-701ea6b2.js → cart.helper-abdd9916.js} +3 -3
  3. package/dist/cjs/{cart.helper-701ea6b2.js.map → cart.helper-abdd9916.js.map} +1 -1
  4. package/dist/cjs/container-empty.cjs.entry.js +19 -0
  5. package/dist/cjs/container-empty.cjs.entry.js.map +1 -0
  6. package/dist/cjs/countdown-timer_11.cjs.entry.js +968 -0
  7. package/dist/cjs/countdown-timer_11.cjs.entry.js.map +1 -0
  8. package/dist/cjs/crm-bonus-note.cjs.entry.js +44 -69
  9. package/dist/cjs/crm-bonus-note.cjs.entry.js.map +1 -1
  10. package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
  11. package/dist/cjs/{i18n-1ce6cb94.js → info.config.helper-d4b1291b.js} +14 -1
  12. package/dist/cjs/info.config.helper-d4b1291b.js.map +1 -0
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/pedido-finalizado.cjs.entry.js +2 -2
  15. package/dist/collection/collection-manifest.json +2 -3
  16. package/dist/collection/components/crm-bonus/crm-bonus.js +13 -19
  17. package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
  18. package/dist/collection/components/giftback-form/giftback-form.js +10 -12
  19. package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
  20. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js +5 -5
  21. package/dist/collection/components/giftback-form/subcomponents/phone-form/phone-form.js +1 -1
  22. package/dist/collection/components/giftback-form/subcomponents/pin-form/pin-form.js +1 -1
  23. package/dist/collection/components/loading-container/container-empty.js +9 -0
  24. package/dist/collection/components/loading-container/container-empty.js.map +1 -0
  25. package/dist/collection/components/loading-container/loading-container.css +9 -2
  26. package/dist/collection/components/loading-container/loading-container.js +20 -1
  27. package/dist/collection/components/loading-container/loading-container.js.map +1 -1
  28. package/dist/collection/components/loading-spinner/loading-spinner.js +1 -1
  29. package/dist/collection/components/modal/app-modal.js +1 -1
  30. package/dist/collection/components/note/crm-bonus-note.js +26 -64
  31. package/dist/collection/components/note/crm-bonus-note.js.map +1 -1
  32. package/dist/collection/components/pedido/pedido.js +1 -1
  33. package/dist/collection/components/phone/phone-input-mask.js +1 -1
  34. package/dist/collection/components/tooltip/tooltip.js +1 -1
  35. package/dist/collection/utils/retry.utils.js +13 -0
  36. package/dist/collection/utils/retry.utils.js.map +1 -0
  37. package/dist/components/app-modal.js +1 -1
  38. package/dist/components/{crm-bonus-2.d.ts → container-empty.d.ts} +4 -4
  39. package/dist/components/container-empty.js +33 -0
  40. package/dist/components/container-empty.js.map +1 -0
  41. package/dist/components/crm-bonus-note.js +40 -64
  42. package/dist/components/crm-bonus-note.js.map +1 -1
  43. package/dist/components/crm-bonus.js +67 -32
  44. package/dist/components/crm-bonus.js.map +1 -1
  45. package/dist/components/crm-button.js +1 -1
  46. package/dist/components/crm-giftback-form.js +1 -1
  47. package/dist/components/crm-tooltip.js +1 -1
  48. package/dist/components/giftback-info.js +1 -1
  49. package/dist/components/loading-container.js +1 -1
  50. package/dist/components/loading-spinner.js +1 -1
  51. package/dist/components/{p-8fda6382.js → p-0a7ccd8c.js} +4 -4
  52. package/dist/components/{p-8fda6382.js.map → p-0a7ccd8c.js.map} +1 -1
  53. package/dist/components/{p-c5be72a0.js → p-2cece106.js} +6 -4
  54. package/dist/components/p-2cece106.js.map +1 -0
  55. package/dist/components/{p-f1823a52.js → p-786485b2.js} +2 -2
  56. package/dist/components/{p-f1823a52.js.map → p-786485b2.js.map} +1 -1
  57. package/dist/components/{p-890dc5d5.js → p-8274e2c4.js} +2 -2
  58. package/dist/components/{p-890dc5d5.js.map → p-8274e2c4.js.map} +1 -1
  59. package/dist/components/{p-ce77a841.js → p-9b5c07d8.js} +2 -2
  60. package/dist/components/{p-ce77a841.js.map → p-9b5c07d8.js.map} +1 -1
  61. package/dist/components/{p-e2a6a4cf.js → p-a7d4e578.js} +19 -21
  62. package/dist/components/p-a7d4e578.js.map +1 -0
  63. package/dist/components/{p-417b4f7f.js → p-bea5a5c2.js} +3 -3
  64. package/dist/components/{p-417b4f7f.js.map → p-bea5a5c2.js.map} +1 -1
  65. package/dist/components/{p-bc930dfe.js → p-c250687d.js} +2 -2
  66. package/dist/components/{p-bc930dfe.js.map → p-c250687d.js.map} +1 -1
  67. package/dist/components/{p-488a119c.js → p-d49313cb.js} +8 -8
  68. package/dist/components/{p-488a119c.js.map → p-d49313cb.js.map} +1 -1
  69. package/dist/components/{p-ee1c025b.js → p-e6863cf5.js} +5 -5
  70. package/dist/components/{p-ee1c025b.js.map → p-e6863cf5.js.map} +1 -1
  71. package/dist/components/pedido-finalizado.js +2 -2
  72. package/dist/components/phone-form.js +1 -1
  73. package/dist/components/phone-input-mask.js +1 -1
  74. package/dist/components/pin-form.js +1 -1
  75. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
  76. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
  77. package/dist/crmbonus-component-wake/p-1644deef.entry.js +2 -0
  78. package/dist/crmbonus-component-wake/p-1644deef.entry.js.map +1 -0
  79. package/dist/crmbonus-component-wake/p-4bfd518e.entry.js +2 -0
  80. package/dist/crmbonus-component-wake/p-4bfd518e.entry.js.map +1 -0
  81. package/dist/crmbonus-component-wake/p-622d5644.entry.js +2 -0
  82. package/dist/crmbonus-component-wake/p-7e52727e.entry.js +2 -0
  83. package/dist/crmbonus-component-wake/p-99e8c3f7.entry.js +2 -0
  84. package/dist/crmbonus-component-wake/p-99e8c3f7.entry.js.map +1 -0
  85. package/dist/crmbonus-component-wake/{p-702d5a6f.js → p-b4f52f79.js} +2 -2
  86. package/dist/crmbonus-component-wake/p-b4f52f79.js.map +1 -0
  87. package/dist/crmbonus-component-wake/{p-b5da6ce1.js → p-bea5a5c2.js} +2 -2
  88. package/dist/crmbonus-component-wake/{p-b5da6ce1.js.map → p-bea5a5c2.js.map} +1 -1
  89. package/dist/env.js +2 -2
  90. package/dist/env.js.map +1 -1
  91. package/dist/esm/app-modal.entry.js +1 -1
  92. package/dist/esm/{cart.helper-4f1913ce.js → cart.helper-89391005.js} +4 -4
  93. package/dist/esm/{cart.helper-4f1913ce.js.map → cart.helper-89391005.js.map} +1 -1
  94. package/dist/esm/container-empty.entry.js +15 -0
  95. package/dist/esm/container-empty.entry.js.map +1 -0
  96. package/dist/esm/countdown-timer_11.entry.js +954 -0
  97. package/dist/esm/countdown-timer_11.entry.js.map +1 -0
  98. package/dist/esm/crm-bonus-note.entry.js +40 -65
  99. package/dist/esm/crm-bonus-note.entry.js.map +1 -1
  100. package/dist/esm/crmbonus-component-wake.js +1 -1
  101. package/dist/esm/{i18n-7938fb86.js → info.config.helper-e4b8c478.js} +14 -2
  102. package/dist/esm/info.config.helper-e4b8c478.js.map +1 -0
  103. package/dist/esm/loader.js +1 -1
  104. package/dist/esm/pedido-finalizado.entry.js +2 -2
  105. package/dist/types/Users/Darlison/Projects/Bycoders/crmbonus/crmbonus-component/.stencil/env.d.ts +1 -1
  106. package/dist/types/components/giftback-form/giftback-form.d.ts +0 -1
  107. package/dist/types/components/loading-container/container-empty.d.ts +3 -0
  108. package/dist/types/components/loading-container/loading-container.d.ts +1 -0
  109. package/dist/types/components/note/crm-bonus-note.d.ts +1 -3
  110. package/dist/types/components.d.ts +15 -26
  111. package/dist/types/utils/retry.utils.d.ts +1 -0
  112. package/package.json +1 -1
  113. package/dist/cjs/build.payload.helper-cfd3173e.js +0 -54
  114. package/dist/cjs/build.payload.helper-cfd3173e.js.map +0 -1
  115. package/dist/cjs/countdown-timer_2.cjs.entry.js +0 -74
  116. package/dist/cjs/countdown-timer_2.cjs.entry.js.map +0 -1
  117. package/dist/cjs/crm-bonus-2.cjs.entry.js +0 -33
  118. package/dist/cjs/crm-bonus-2.cjs.entry.js.map +0 -1
  119. package/dist/cjs/crm-bonus-tray.cjs.entry.js +0 -18
  120. package/dist/cjs/crm-bonus-tray.cjs.entry.js.map +0 -1
  121. package/dist/cjs/crm-bonus.cjs.entry.js +0 -284
  122. package/dist/cjs/crm-bonus.cjs.entry.js.map +0 -1
  123. package/dist/cjs/crm-giftback-form.cjs.entry.js +0 -282
  124. package/dist/cjs/crm-giftback-form.cjs.entry.js.map +0 -1
  125. package/dist/cjs/crm-tooltip_5.cjs.entry.js +0 -292
  126. package/dist/cjs/crm-tooltip_5.cjs.entry.js.map +0 -1
  127. package/dist/cjs/i18n-1ce6cb94.js.map +0 -1
  128. package/dist/cjs/info.config.helper-e35e6e20.js +0 -17
  129. package/dist/cjs/info.config.helper-e35e6e20.js.map +0 -1
  130. package/dist/cjs/loading-container.cjs.entry.js +0 -23
  131. package/dist/cjs/loading-container.cjs.entry.js.map +0 -1
  132. package/dist/cjs/loading-spinner.cjs.entry.js +0 -24
  133. package/dist/cjs/loading-spinner.cjs.entry.js.map +0 -1
  134. package/dist/collection/components/crm-bonus/crmbonus.js +0 -38
  135. package/dist/collection/components/crm-bonus/crmbonus.js.map +0 -1
  136. package/dist/collection/tray-ecommerce/crm-bonus-tray.js +0 -8
  137. package/dist/collection/tray-ecommerce/crm-bonus-tray.js.map +0 -1
  138. package/dist/components/crm-bonus-2.js +0 -57
  139. package/dist/components/crm-bonus-2.js.map +0 -1
  140. package/dist/components/crm-bonus-tray.d.ts +0 -11
  141. package/dist/components/crm-bonus-tray.js +0 -32
  142. package/dist/components/crm-bonus-tray.js.map +0 -1
  143. package/dist/components/p-b0ef2c0b.js +0 -52
  144. package/dist/components/p-b0ef2c0b.js.map +0 -1
  145. package/dist/components/p-c5be72a0.js.map +0 -1
  146. package/dist/components/p-e2a6a4cf.js.map +0 -1
  147. package/dist/crmbonus-component-wake/p-17b97fd2.entry.js +0 -2
  148. package/dist/crmbonus-component-wake/p-1b441909.js +0 -2
  149. package/dist/crmbonus-component-wake/p-1b441909.js.map +0 -1
  150. package/dist/crmbonus-component-wake/p-3a4d7622.entry.js +0 -2
  151. package/dist/crmbonus-component-wake/p-3a4d7622.entry.js.map +0 -1
  152. package/dist/crmbonus-component-wake/p-54b8f32b.entry.js +0 -2
  153. package/dist/crmbonus-component-wake/p-54b8f32b.entry.js.map +0 -1
  154. package/dist/crmbonus-component-wake/p-59033825.entry.js +0 -2
  155. package/dist/crmbonus-component-wake/p-59033825.entry.js.map +0 -1
  156. package/dist/crmbonus-component-wake/p-61ea41c9.entry.js +0 -2
  157. package/dist/crmbonus-component-wake/p-6532623f.entry.js +0 -2
  158. package/dist/crmbonus-component-wake/p-6532623f.entry.js.map +0 -1
  159. package/dist/crmbonus-component-wake/p-702d5a6f.js.map +0 -1
  160. package/dist/crmbonus-component-wake/p-87cb8341.entry.js +0 -2
  161. package/dist/crmbonus-component-wake/p-87cb8341.entry.js.map +0 -1
  162. package/dist/crmbonus-component-wake/p-9d926857.entry.js +0 -2
  163. package/dist/crmbonus-component-wake/p-9d926857.entry.js.map +0 -1
  164. package/dist/crmbonus-component-wake/p-b0ef2c0b.js +0 -2
  165. package/dist/crmbonus-component-wake/p-b0ef2c0b.js.map +0 -1
  166. package/dist/crmbonus-component-wake/p-ce2819cc.entry.js +0 -2
  167. package/dist/crmbonus-component-wake/p-ce2819cc.entry.js.map +0 -1
  168. package/dist/crmbonus-component-wake/p-e992d997.entry.js +0 -2
  169. package/dist/crmbonus-component-wake/p-e992d997.entry.js.map +0 -1
  170. package/dist/crmbonus-component-wake/p-eace8d0e.entry.js +0 -2
  171. package/dist/crmbonus-component-wake/p-eace8d0e.entry.js.map +0 -1
  172. package/dist/esm/build.payload.helper-699a48ca.js +0 -52
  173. package/dist/esm/build.payload.helper-699a48ca.js.map +0 -1
  174. package/dist/esm/countdown-timer_2.entry.js +0 -69
  175. package/dist/esm/countdown-timer_2.entry.js.map +0 -1
  176. package/dist/esm/crm-bonus-2.entry.js +0 -29
  177. package/dist/esm/crm-bonus-2.entry.js.map +0 -1
  178. package/dist/esm/crm-bonus-tray.entry.js +0 -14
  179. package/dist/esm/crm-bonus-tray.entry.js.map +0 -1
  180. package/dist/esm/crm-bonus.entry.js +0 -280
  181. package/dist/esm/crm-bonus.entry.js.map +0 -1
  182. package/dist/esm/crm-giftback-form.entry.js +0 -278
  183. package/dist/esm/crm-giftback-form.entry.js.map +0 -1
  184. package/dist/esm/crm-tooltip_5.entry.js +0 -284
  185. package/dist/esm/crm-tooltip_5.entry.js.map +0 -1
  186. package/dist/esm/i18n-7938fb86.js.map +0 -1
  187. package/dist/esm/info.config.helper-7cad7a9c.js +0 -15
  188. package/dist/esm/info.config.helper-7cad7a9c.js.map +0 -1
  189. package/dist/esm/loading-container.entry.js +0 -19
  190. package/dist/esm/loading-container.entry.js.map +0 -1
  191. package/dist/esm/loading-spinner.entry.js +0 -20
  192. package/dist/esm/loading-spinner.entry.js.map +0 -1
  193. package/dist/types/components/crm-bonus/crmbonus.d.ts +0 -8
  194. package/dist/types/tray-ecommerce/crm-bonus-tray.d.ts +0 -3
  195. /package/dist/crmbonus-component-wake/{p-17b97fd2.entry.js.map → p-622d5644.entry.js.map} +0 -0
  196. /package/dist/crmbonus-component-wake/{p-61ea41c9.entry.js.map → p-7e52727e.entry.js.map} +0 -0
@@ -0,0 +1,954 @@
1
+ import { r as registerInstance, h, H as Host } from './index-bdb70d5a.js';
2
+ import { C as CrmBonusService, U as USED_KEY, g as getCart, a as getInfoBonusByCartIdAndStoreName, b as CartWake, c as getKeyReserveByCartId, p as persisteMetadata } from './cart.helper-89391005.js';
3
+ import { d as defaultStyles, S as StepFormEnum, i as instance, g as getInfoCustomization, M as MESSAGE_ERROR_INVALID_NUMBER } from './info.config.helper-e4b8c478.js';
4
+ import { d as defineLimit, a as formatDateToBr } from './utils-dec6df66.js';
5
+
6
+ const CountdownTimer = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.downtime = undefined;
10
+ this.dataCriacao = undefined;
11
+ this.minutos = 6;
12
+ this.segundos = 60;
13
+ this.tempoRestante = undefined;
14
+ }
15
+ componentWillLoad() {
16
+ const tempoTotal = this.minutos * this.segundos * 1000;
17
+ const data = new Date(this.dataCriacao);
18
+ const agora = new Date();
19
+ const tempoPassado = agora.getTime() - data.getTime();
20
+ if (tempoPassado >= tempoTotal) {
21
+ this.tempoRestante = 0;
22
+ this.onTempoEsgotado();
23
+ }
24
+ else {
25
+ this.tempoRestante = tempoTotal - tempoPassado;
26
+ this.startCountdown();
27
+ }
28
+ }
29
+ disconnectedCallback() {
30
+ clearInterval(this.intervalId);
31
+ }
32
+ startCountdown() {
33
+ this.intervalId = setInterval(() => {
34
+ this.tempoRestante -= 1000;
35
+ if (this.tempoRestante <= 0) {
36
+ this.tempoRestante = 0;
37
+ clearInterval(this.intervalId);
38
+ this.onTempoEsgotado();
39
+ }
40
+ }, 1000);
41
+ }
42
+ onTempoEsgotado() {
43
+ console.log('Tempo esgotado! Executando ação...');
44
+ this.downtime();
45
+ }
46
+ render() {
47
+ const minutos = Math.floor(this.tempoRestante / 60000);
48
+ const segundos = Math.floor((this.tempoRestante % 60000) / 1000);
49
+ const tempoFormatado = `${String(minutos).padStart(2, '0')}:${String(segundos).padStart(2, '0')}`;
50
+ return (h("label", { key: 'ed1e0654cba5b152adcadb10cf9dfd6909c07a1f' }, " ", tempoFormatado));
51
+ }
52
+ };
53
+
54
+ var AjustesTipoEnum;
55
+ (function (AjustesTipoEnum) {
56
+ AjustesTipoEnum["P"] = "Promocao";
57
+ AjustesTipoEnum["CC"] = "ContaCorrente";
58
+ AjustesTipoEnum["PP"] = "PromocaoProduto";
59
+ AjustesTipoEnum["F"] = "Formula";
60
+ })(AjustesTipoEnum || (AjustesTipoEnum = {}));
61
+
62
+ function buildProductsByWake(productsWake = []) {
63
+ const products = [];
64
+ for (const pw of productsWake) {
65
+ let discounts = getDiscount(pw.Ajustes);
66
+ // let discounts_formula = getDiscountFormula(pw.Ajustes);
67
+ var value = (pw.PrecoDe * pw.Quantidade);
68
+ var originalValue = (pw.PrecoDe * pw.Quantidade);
69
+ var discounts_value = (discounts * -1);
70
+ const existsPromotionProduct = pw.Ajustes.filter(adj => [AjustesTipoEnum.PP].includes(adj.Tipo));
71
+ const promotion_product = (existsPromotionProduct.length > 0);
72
+ products.push({
73
+ sku: pw.SKU,
74
+ value: value,
75
+ originalValue: originalValue,
76
+ productVariantId: pw.ProdutoVarianteId.toString(),
77
+ quantity: pw.Quantidade,
78
+ discount: value < discounts_value ? value : discounts_value,
79
+ promotion_product
80
+ });
81
+ }
82
+ return products;
83
+ }
84
+ function getDiscount(ajustes = []) {
85
+ let discounts = 0;
86
+ for (const discount of ajustes) {
87
+ if ([AjustesTipoEnum.P, AjustesTipoEnum.CC, AjustesTipoEnum.PP].includes(discount.Tipo)) {
88
+ discounts += discount.Valor;
89
+ }
90
+ }
91
+ return discounts;
92
+ }
93
+ // function getDiscountFormula(ajustes: IAjustes[] = []) {
94
+ // let discounts = 0;
95
+ // for(const discount of ajustes) {
96
+ // if([AjustesTipoEnum.F].includes(discount.Tipo)) {
97
+ // discounts += (discount.Valor * -1);
98
+ // }
99
+ // }
100
+ // return discounts;
101
+ // }
102
+
103
+ const crmBonusCss = ".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";
104
+ const CrmBonusStyle0 = crmBonusCss;
105
+
106
+ const CrmBonus$1 = class {
107
+ constructor(hostRef) {
108
+ registerInstance(this, hostRef);
109
+ this.crmBonusService = CrmBonusService.getInstance();
110
+ this.cart = undefined;
111
+ this.canhidden = false;
112
+ this.showModal = false;
113
+ this.cartWake = undefined;
114
+ this.customer = {
115
+ birthDate: "",
116
+ document: "",
117
+ name: "",
118
+ phone: ""
119
+ };
120
+ this.loading = false;
121
+ this.message = undefined;
122
+ this.phone = undefined;
123
+ this.canCancel = false;
124
+ this.amountCancel = undefined;
125
+ this.sent = undefined;
126
+ this.session = undefined;
127
+ this.loading_reprocess = false;
128
+ this.styles = defaultStyles;
129
+ this.reservedInfo = undefined;
130
+ }
131
+ async resetBonus() {
132
+ console.log('[CRMBONUS] - reset bonus');
133
+ try {
134
+ await this.crmBonusRef.processBonus(this.buildProducts(), true);
135
+ console.log('[BONUS RESETADO]!!!!!');
136
+ }
137
+ catch (err) {
138
+ this.loading = false;
139
+ console.log('[error ao reprocessar bonous]');
140
+ await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);
141
+ }
142
+ finally {
143
+ this.loading = false;
144
+ }
145
+ }
146
+ async setloading() {
147
+ this.loading_reprocess = !this.loading_reprocess;
148
+ }
149
+ async reprocess() {
150
+ console.log("[CRMBONUS] - reprocess");
151
+ this.loading_reprocess = true;
152
+ try {
153
+ const isUse = localStorage.getItem(USED_KEY);
154
+ if (!isUse)
155
+ return;
156
+ this.cartWake = await getCart();
157
+ await this.resetBonus();
158
+ }
159
+ catch (err) {
160
+ console.debug('[watchProducts]', err.message);
161
+ }
162
+ finally {
163
+ this.loading_reprocess = false;
164
+ }
165
+ }
166
+ async componentWillLoad() {
167
+ this.loading_reprocess = true;
168
+ window.addEventListener('productRemovedFromCart', async () => {
169
+ console.log('[CRMBONUS] - productRemovedFromCart');
170
+ await this.reprocess();
171
+ });
172
+ window.addEventListener('productAddedToCart', async () => {
173
+ console.log('[CRMBONUS] - productAddedToCart');
174
+ await this.reprocess();
175
+ });
176
+ document.querySelectorAll('form').forEach((el) => {
177
+ el.addEventListener("submit", async () => {
178
+ console.log("[CRMBONUS] - Formulário está sendo submetido!");
179
+ await this.reprocess();
180
+ });
181
+ });
182
+ await this.observerHandle();
183
+ instance.changeLanguage(instance.language);
184
+ }
185
+ async componentDidLoad() {
186
+ await this.loadSession();
187
+ this.handleLoad();
188
+ await this.loadConfigStore();
189
+ this.loading_reprocess = false;
190
+ }
191
+ async observerHandle() {
192
+ const elements = document.getElementsByTagName('a');
193
+ //@ts-ignore
194
+ for (let el of elements) {
195
+ console.log('[el.href]', el.href);
196
+ if (el.href.includes('Produto/Delete')) {
197
+ el.addEventListener('click', async () => {
198
+ console.log('[CRMBONUS] - Produto removido do carrinho');
199
+ setTimeout(async () => {
200
+ await this.reprocess();
201
+ this.observerHandle();
202
+ }, 2000);
203
+ });
204
+ }
205
+ if (el.href.includes('Produto/Add')) {
206
+ el.addEventListener('click', async () => {
207
+ console.log('[CRMBONUS] - Produto adicionado ao carrinho');
208
+ setTimeout(async () => {
209
+ await this.reprocess();
210
+ this.observerHandle();
211
+ }, 2000);
212
+ });
213
+ }
214
+ }
215
+ }
216
+ async loadConfigStore() {
217
+ const [customization, infoBonus] = await Promise.all([
218
+ this.crmBonusService.getCustomization(this.cartWake.store.name),
219
+ getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)
220
+ ]);
221
+ this.reservedInfo = infoBonus;
222
+ if (customization.keepStoreFrontStyle) {
223
+ this.styles = null;
224
+ }
225
+ }
226
+ async fetchCustomer(userId, storeName) {
227
+ try {
228
+ return await this.crmBonusService.getCustomer(userId, storeName);
229
+ }
230
+ catch (error) {
231
+ console.error('[fetchCustomer] Error fetching customer:', error);
232
+ return null;
233
+ }
234
+ }
235
+ async handleLoad() {
236
+ try {
237
+ const amount = localStorage.getItem(this.cartWake.id);
238
+ if (amount) {
239
+ this.canCancel = true;
240
+ this.amountCancel = amount;
241
+ }
242
+ await this.buildAndGetProducts(this.cartWake.products);
243
+ }
244
+ catch (error) {
245
+ console.log('info customer');
246
+ }
247
+ }
248
+ async loadSession() {
249
+ this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();
250
+ console.log('[bc:carregou carrinho]');
251
+ this.session = await this.crmBonusService.getToken(this.cartWake.store.name);
252
+ console.log('[bc:carregou session]');
253
+ setTimeout(() => {
254
+ this.loadSession();
255
+ }, 1500000);
256
+ }
257
+ async buildAndGetProducts(productsWake) {
258
+ console.log();
259
+ const key = `bc-products:${this.cartWake.id}`;
260
+ const productsString = JSON.stringify(productsWake);
261
+ localStorage.setItem(key, productsString);
262
+ const products_in_cache = JSON.parse(localStorage.getItem(key));
263
+ const products = [];
264
+ for (const product_cart of productsWake) {
265
+ const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId);
266
+ //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === "Formula")
267
+ if (pro) {
268
+ products.push(Object.assign(Object.assign({}, product_cart), { PrecoPor: pro.PrecoPor, PrecoDe: pro.PrecoDe, Quantidade: pro.Quantidade, Ajustes: pro.Ajustes }));
269
+ }
270
+ else {
271
+ products.push(product_cart);
272
+ }
273
+ }
274
+ this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);
275
+ }
276
+ async sendPin(phone) {
277
+ var _a, _b;
278
+ this.loading = true;
279
+ this.message = "";
280
+ try {
281
+ const _phone = phone.replace(/\D/g, '');
282
+ this.phone = Number(_phone);
283
+ this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
284
+ await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
285
+ this.showModal = true;
286
+ }
287
+ catch (error) {
288
+ this.message = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
289
+ }
290
+ finally {
291
+ this.loading = false;
292
+ }
293
+ }
294
+ async sendPinName(customerName) {
295
+ var _a, _b;
296
+ this.loading = true;
297
+ this.message = "";
298
+ try {
299
+ this.customer.name = customerName;
300
+ this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
301
+ await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
302
+ this.showModal = true;
303
+ }
304
+ catch (error) {
305
+ this.message = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
306
+ }
307
+ finally {
308
+ this.loading = false;
309
+ }
310
+ }
311
+ buildProducts() {
312
+ return buildProductsByWake(this.cartWake.products);
313
+ }
314
+ handleCloseModal() {
315
+ this.showModal = false;
316
+ }
317
+ save(amount) {
318
+ localStorage.setItem(this.cartWake.id, amount.toString());
319
+ this.canCancel = true;
320
+ this.amountCancel = amount.toString();
321
+ }
322
+ async cancel() {
323
+ this.message = "";
324
+ this.loading = true;
325
+ try {
326
+ await this.crmBonusService.cancel(this.cartWake.id);
327
+ this.canCancel = false;
328
+ localStorage.removeItem(this.cartWake.id);
329
+ }
330
+ catch (error) {
331
+ this.message = "Não consegui cancelar o bônus, tente novamente!";
332
+ }
333
+ finally {
334
+ this.loading = false;
335
+ }
336
+ }
337
+ async handleSendPin(phone) {
338
+ this.message = "";
339
+ if (!phone) {
340
+ this.message = "Informe seu telefone";
341
+ return;
342
+ }
343
+ this.customer.phone = phone;
344
+ const _phone = phone.replace(/\D/g, '');
345
+ this.phone = Number(_phone);
346
+ if (this.customer.name) {
347
+ return this.sendPin(phone);
348
+ }
349
+ await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);
350
+ this.showModal = true;
351
+ }
352
+ render() {
353
+ if (this.canhidden) {
354
+ return null;
355
+ }
356
+ return (h("loading-container", { loading: this.loading_reprocess, text: 'carregando...' }, !this.loading_reprocess && (h("crm-giftback-form", { customStyles: this.styles, style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts(), loadAll: () => this.handleLoad(), reservedInfo: this.reservedInfo }))));
357
+ }
358
+ static get assetsDirs() { return ["assets"]; }
359
+ };
360
+ CrmBonus$1.style = CrmBonusStyle0;
361
+
362
+ const crmButtonCss = "input,button{margin:0;padding:10px;}.crm-contaner-button{height:auto;width:auto}.crm-button{height:48px;width:100%;border:1px solid #000;padding:14px 20px;background-color:#000;color:#fff;line-height:20px;font-weight:500;cursor:pointer}";
363
+ const CrmButtonStyle0 = crmButtonCss;
364
+
365
+ const Button = class {
366
+ constructor(hostRef) {
367
+ registerInstance(this, hostRef);
368
+ this.txtBtn = undefined;
369
+ this.loading = undefined;
370
+ this.handleClick = undefined;
371
+ }
372
+ render() {
373
+ return (h("div", { key: '785b4975fb6538dbe2cdb7b99d5801abc72c534a', class: "crm-contaner-button" }, h("button", { key: '1e41951aa024e9f3b9b1836e8386bd369d022f76', class: "crm-button", onClick: () => this.handleClick() }, !this.loading ? this.txtBtn : h("loading-spinner", { size: "15px", color: "#fff" }))));
374
+ }
375
+ };
376
+ Button.style = CrmButtonStyle0;
377
+
378
+ const giftbackFormCss$2 = "*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";
379
+ const CrmGiftbackFormStyle0 = giftbackFormCss$2;
380
+
381
+ const CrmBonus = class {
382
+ constructor(hostRef) {
383
+ registerInstance(this, hostRef);
384
+ // private phoneInputMask: HTMLPhoneFormElement;
385
+ this.crmBonusService = CrmBonusService.getInstance();
386
+ this.storeName = undefined;
387
+ this.cartId = undefined;
388
+ this.products = undefined;
389
+ this.customer = undefined;
390
+ this.loadProducts = undefined;
391
+ this.loadAll = undefined;
392
+ this.customStyles = undefined;
393
+ this.reservedInfo = undefined;
394
+ this.value = undefined;
395
+ this.loading = false;
396
+ this.message = undefined;
397
+ this.phone = undefined;
398
+ this.pinInfo = undefined;
399
+ this.step = StepFormEnum.STEP_RESERVE;
400
+ this.bonus = undefined;
401
+ this.sucess = "";
402
+ this.error = "";
403
+ this.config = undefined;
404
+ this.hasApplyBonus = false;
405
+ this.loadingAllComponent = false;
406
+ }
407
+ async setStep(step) {
408
+ this.step = step;
409
+ }
410
+ async processBonus(products = [], hasNewProduct = false) {
411
+ await this.loadProducts();
412
+ this.sucess = "";
413
+ if (hasNewProduct) {
414
+ this.products = products;
415
+ }
416
+ const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
417
+ if (_bonus) {
418
+ const bonus = JSON.parse(_bonus);
419
+ this.bonus = bonus;
420
+ this.phone = bonus.phone;
421
+ this.pinInfo = {
422
+ storeId: bonus.storeId,
423
+ userId: bonus.userId
424
+ };
425
+ await this.validateBonus("2018");
426
+ //this.step = StepFormEnum.STEP_RESERVE;
427
+ }
428
+ }
429
+ async handleSendPin(phone) {
430
+ await this.loadAll();
431
+ this.message = "";
432
+ if (!phone) {
433
+ this.message = "Informe seu telefone";
434
+ return;
435
+ }
436
+ this.phone = phone;
437
+ this.sendPin();
438
+ }
439
+ async componentWillLoad() {
440
+ this.sucess = "";
441
+ this.error = "";
442
+ this.config = getInfoCustomization(this.storeName);
443
+ const phoneAgain = this.getPhoneNumberAgain();
444
+ if (phoneAgain) {
445
+ this.step = StepFormEnum.STEP_PHONE;
446
+ return;
447
+ }
448
+ await this.processBonus();
449
+ }
450
+ getPhoneNumberAgain() {
451
+ const consulta_bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
452
+ if (!consulta_bonus)
453
+ return true;
454
+ const bonus = JSON.parse(consulta_bonus);
455
+ return !bonus.hasBonus;
456
+ }
457
+ convertStringToNumber() {
458
+ var _a;
459
+ const _phone = (_a = this.phone) === null || _a === void 0 ? void 0 : _a.replace(/\D/g, '');
460
+ return Number(_phone);
461
+ }
462
+ async sendPin() {
463
+ var _a, _b, _c;
464
+ this.loading = true;
465
+ this.message = "";
466
+ this.sucess = "";
467
+ this.error = "";
468
+ try {
469
+ const _phone = this.convertStringToNumber();
470
+ const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);
471
+ if (!pinInfoCache) {
472
+ this.pinInfo = await this.crmBonusService.sendPin(_phone, (_a = this.customer) === null || _a === void 0 ? void 0 : _a.name, this.storeName);
473
+ }
474
+ if (pinInfoCache) {
475
+ const bonus = JSON.parse(pinInfoCache);
476
+ this.pinInfo = {
477
+ storeId: bonus.storeId,
478
+ userId: bonus.userId
479
+ };
480
+ await this.validateBonus("2018");
481
+ // this.step = StepFormEnum.STEP_RESERVE;
482
+ }
483
+ else {
484
+ this.step = StepFormEnum.STEP_PIN;
485
+ }
486
+ }
487
+ catch (error) {
488
+ this.message = (_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message;
489
+ }
490
+ finally {
491
+ this.loading = false;
492
+ }
493
+ }
494
+ changePhone() {
495
+ this.sucess = "";
496
+ this.error = "";
497
+ this.step = StepFormEnum.STEP_PHONE;
498
+ }
499
+ async validateBonus(pin) {
500
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
501
+ this.loadingAllComponent = true;
502
+ await this.loadProducts();
503
+ const used_or_no = localStorage.getItem(USED_KEY);
504
+ if (used_or_no == "dontUse") {
505
+ this.step = StepFormEnum.STEP_RESERVE;
506
+ return;
507
+ }
508
+ this.loading = true;
509
+ this.sucess = "";
510
+ this.error = "";
511
+ const storeId = ((_a = this.pinInfo) === null || _a === void 0 ? void 0 : _a.storeId) || ((_c = (_b = this.reservedInfo) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.storeId);
512
+ const userId = ((_d = this.pinInfo) === null || _d === void 0 ? void 0 : _d.userId) || ((_f = (_e = this.reservedInfo) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.userId);
513
+ const cellphone = (_h = (_g = this.reservedInfo) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.cellphone;
514
+ const payload = {
515
+ pin: pin,
516
+ cellphone: cellphone || this.convertStringToNumber(),
517
+ storeId: storeId.toString(),
518
+ userId: userId.toString(),
519
+ checkoutId: this.cartId,
520
+ checkoutProducts: this.products,
521
+ name: (_j = this.customer) === null || _j === void 0 ? void 0 : _j.name,
522
+ storeName: this.storeName
523
+ };
524
+ try {
525
+ this.bonus = await this.crmBonusService.validatePinBonus(payload);
526
+ if (!this.bonus.hasBonus) {
527
+ localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify(Object.assign(Object.assign({}, this.bonus), { phone: this.phone })));
528
+ this.loading = false;
529
+ this.step = StepFormEnum.STEP_NO_BONUS;
530
+ return;
531
+ }
532
+ this.sucess = "Código validado com sucesso!";
533
+ localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify(Object.assign(Object.assign({}, this.bonus), { phone: this.phone })));
534
+ localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));
535
+ localStorage.setItem(USED_KEY, "use");
536
+ localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());
537
+ this.updateMetadata({ storeId: Number(storeId), userId: Number(userId) }, payload.cellphone);
538
+ console.log('RESERVE', this.bonus);
539
+ this.step = StepFormEnum.STEP_RESERVE;
540
+ }
541
+ catch (error) {
542
+ const _error = (_l = (_k = error === null || error === void 0 ? void 0 : error.response) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.response;
543
+ const response = (_m = error === null || error === void 0 ? void 0 : error.response) === null || _m === void 0 ? void 0 : _m.data;
544
+ if (_error && _error.includes("Pin")) {
545
+ this.error = "Código inválido!";
546
+ }
547
+ else if ([403, 500].includes(response.statusCode)) {
548
+ this.error = "ocorreu um error, atualize a pagina e tente novamente!";
549
+ }
550
+ else {
551
+ this.error = _error;
552
+ this.step = StepFormEnum.STEP_NO_BONUS;
553
+ }
554
+ }
555
+ finally {
556
+ this.loading = false;
557
+ this.loadingAllComponent = false;
558
+ }
559
+ }
560
+ async updateMetadata(pinInfo, cellphone) {
561
+ try {
562
+ if (this.reservedInfo.isExpired()) {
563
+ console.log('[CRM:updateMetadata]');
564
+ await persisteMetadata(this.storeName, this.cartId, {
565
+ createdAt: Date.now(),
566
+ url: window.location.href,
567
+ storeId: pinInfo.storeId,
568
+ userId: pinInfo.userId,
569
+ cellphone: cellphone,
570
+ });
571
+ localStorage.removeItem("bc:time");
572
+ }
573
+ else {
574
+ await persisteMetadata(this.storeName, this.cartId, {
575
+ url: window.location.href,
576
+ storeId: pinInfo.storeId,
577
+ userId: pinInfo.userId,
578
+ cellphone: cellphone,
579
+ });
580
+ }
581
+ }
582
+ catch (error) {
583
+ console.error('[CRMBONUS:updateMetadata]: ', error);
584
+ }
585
+ }
586
+ handleCancel() {
587
+ // this.step = StepFormEnum.STEP_PHONE;
588
+ this.cancel();
589
+ }
590
+ async cancel() {
591
+ this.message = "";
592
+ this.loading = true;
593
+ try {
594
+ await this.crmBonusService.cancel(this.cartId);
595
+ localStorage.setItem(USED_KEY, "dontUse");
596
+ // this.save(0)
597
+ await this.updateMetadata({ storeId: null, userId: null }, null);
598
+ }
599
+ catch (error) {
600
+ this.message = "Não consegui cancelar o bônus, tente novamente!";
601
+ }
602
+ finally {
603
+ this.loading = false;
604
+ }
605
+ }
606
+ async reserveApply(amount) {
607
+ this.loading = true;
608
+ this.message = "";
609
+ try {
610
+ await this.reserve(amount);
611
+ // this.save(amount);
612
+ }
613
+ catch (error) {
614
+ this.message = "ocorreu um error ao solicitar a aplicação do bonus! tente novamente";
615
+ this.step = StepFormEnum.STEP_NO_BONUS;
616
+ localStorage.removeItem(this.cartId);
617
+ }
618
+ finally {
619
+ this.loading = false;
620
+ }
621
+ }
622
+ // save(amount: number) {
623
+ // localStorage.setItem(this.cartId, amount.toString());
624
+ // }
625
+ async reserve(amount) {
626
+ await this.crmBonusService.reserve({
627
+ redeemedBonus: amount,
628
+ cartId: this.cartId,
629
+ ticket: this.cartId,
630
+ grossValue: Number(this.bonus.totalValue),
631
+ storeName: this.storeName,
632
+ storeId: this.bonus.storeId.toString(),
633
+ userId: this.bonus.userId
634
+ });
635
+ }
636
+ render() {
637
+ return (h("div", { key: '939a74f8d91ab9c880ffb2486967a7800a6d2ce6', class: "crm-container-form fbits-responsive-carrinho-desconto", style: this.customStyles }, h("label", { key: 'b51c241a72ae22911293ad3dd28190f22982c8cb', class: "crm-title" }, this.config.giftbackTitle), this.error && (h("label", { key: '9ca50e050603ad594b3086c82f2a31e08d8dec12', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_PHONE &&
638
+ h("phone-form", { key: 'ab8cd8263aaf2729f9af29937a40e029bf17193d', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === StepFormEnum.STEP_PIN &&
639
+ h("pin-form", { key: 'da1680e62073ae2a3656fcef4ec85ec8b8d862cf', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && h("p", { key: '72486a002bbcb2cfad2f8ab32fbdda1e8dff143e', class: "crm-message-info" }, this.sucess), this.error && h("p", { key: 'dcddaee2dd0e7b6d50ef0377ae7a721ba5c8256c', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_RESERVE &&
640
+ h("giftback-info", { key: 'b237add0b03aa26f20bdf42264b01ad890670145', storeName: this.storeName, infoBonus: this.reservedInfo, config: this.config, loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: () => this.processBonus(), cartId: this.cartId }), this.step === StepFormEnum.STEP_NO_BONUS &&
641
+ (h("div", { key: '6583e51ae1988bd5c797665e3119eed3aeb7a354', class: "container-message" }, instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
642
+ }
643
+ };
644
+ CrmBonus.style = CrmGiftbackFormStyle0;
645
+
646
+ const infoCircleSvgrepoComSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xMiAxNy43NUMxMi40MTQyIDE3Ljc1IDEyLjc1IDE3LjQxNDIgMTIuNzUgMTdWMTFDMTIuNzUgMTAuNTg1OCAxMi40MTQyIDEwLjI1IDEyIDEwLjI1QzExLjU4NTggMTAuMjUgMTEuMjUgMTAuNTg1OCAxMS4yNSAxMVYxN0MxMS4yNSAxNy40MTQyIDExLjU4NTggMTcuNzUgMTIgMTcuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8cGF0aCBkPSJNMTIgN0MxMi41NTIzIDcgMTMgNy40NDc3MiAxMyA4QzEzIDguNTUyMjggMTIuNTUyMyA5IDEyIDlDMTEuNDQ3NyA5IDExIDguNTUyMjggMTEgOEMxMSA3LjQ0NzcyIDExLjQ0NzcgNyAxMiA3WiIgZmlsbD0iIzFDMjc0QyIvPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjI1IDEyQzEuMjUgNi4wNjI5NCA2LjA2Mjk0IDEuMjUgMTIgMS4yNUMxNy45MzcxIDEuMjUgMjIuNzUgNi4wNjI5NCAyMi43NSAxMkMyMi43NSAxNy45MzcxIDE3LjkzNzEgMjIuNzUgMTIgMjIuNzVDNi4wNjI5NCAyMi43NSAxLjI1IDE3LjkzNzEgMS4yNSAxMlpNMTIgMi43NUM2Ljg5MTM3IDIuNzUgMi43NSA2Ljg5MTM3IDIuNzUgMTJDMi43NSAxNy4xMDg2IDYuODkxMzcgMjEuMjUgMTIgMjEuMjVDMTcuMTA4NiAyMS4yNSAyMS4yNSAxNy4xMDg2IDIxLjI1IDEyQzIxLjI1IDYuODkxMzcgMTcuMTA4NiAyLjc1IDEyIDIuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8L3N2Zz4=';
647
+
648
+ const crmTooltipCss = ".crm-tooltip-container {\r\n display: flex;\r\n\r\n & img {\r\n width: 16px;\r\n margin-left: 3px;\r\n position: relative;\r\n }\r\n}\r\n\r\n.crm-tooltip {\r\n position: relative;\r\n display: inline-block;\r\n}\r\n\r\n.crm-tooltip .tooltiptext {\r\n visibility: hidden;\r\n background-color: black;\r\n color: #fff;\r\n text-align: center;\r\n padding: 8px 12px;\r\n border-radius: 0px;\r\n position: absolute;\r\n z-index: 1;\r\n min-width: 271px;\r\n top: 100%;\r\n left: 50%;\r\n margin-left: -238px;\r\n}\r\n\r\n@container (max-width: 410px) {\r\n .crm-tooltip .tooltiptext {\r\n margin-left: -14px;\r\n }\r\n\r\n .crm-tooltip #crm-role-description {\r\n margin-left: -151px;\r\n }\r\n}\r\n\r\n@container (max-width: 250px) {\r\n .crm-tooltip .tooltiptext {\r\n margin-left: -201px;\r\n }\r\n}\r\n\r\n.crm-tooltip:hover .tooltiptext {\r\n visibility: visible;\r\n}";
649
+ const CrmTooltipStyle0 = crmTooltipCss;
650
+
651
+ const Tooltip = class {
652
+ constructor(hostRef) {
653
+ registerInstance(this, hostRef);
654
+ this.text = undefined;
655
+ this.identity = undefined;
656
+ }
657
+ render() {
658
+ return (h("div", { key: '01d82d0172ca5f0dbb0b8ea278b4a5d438c13dd5', class: "crm-tooltip-container crm-tooltip" }, h("img", { key: '3b632cc38e8ff206402a2bfaadba9f9d2d747095', src: infoCircleSvgrepoComSvg }), h("span", { key: '08310e35ac945bda0e9356ecad8742698016f262', id: this.identity, class: "tooltiptext" }, this.text)));
659
+ }
660
+ };
661
+ Tooltip.style = CrmTooltipStyle0;
662
+
663
+ const giftbackInfoCss = ":host{--text-color:#6D6D5F}.giftback-container{display:flex;flex-direction:column;gap:14px}h3{margin-bottom:8px;color:#333}.container-description{display:flex;align-items:center;gap:5px;margin:0 0 10px 0}.container-description p{font-weight:400;margin:0px}p{color:#000}.value-display h2{color:#6D6D5F;margin:16px 0}input[type='range']{width:100%;margin:12px 0;-webkit-appearance:none;background:#ddd;height:4px;border-radius:4px;outline:none;padding:3px 0px 3px 3px}input[type=\"range\"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;background:rgb(109, 109, 95);border-radius:50%;cursor:pointer}.options{margin:0px 0;display:flex;gap:10px;flex-direction:column}.options label{display:flex;margin:0px 0;color:#333;align-items:center}.options input[type='radio']{margin-right:8px;height:16px;width:16px}.options input[type='radio']{appearance:none;-webkit-appearance:none;margin-right:8px;width:16px;height:16px;border:2px solid #ddd;border-radius:50%;background-color:#fff;cursor:pointer;transition:all 0.3s;padding:0px}.options input[type='radio']:checked{border-color:#000;background-color:#FAFAFA;border:4px solid #000}.info-box{background-color:#f9f9f9;border:1px solid #e0e0e0;border-radius:4px;padding:8px;color:#262626;line-height:20px}.info-icon{cursor:pointer;color:#888}h3{margin-bottom:8px;color:#333}.slider-wrapper{position:relative;margin:21px 0px 0px 0px}.slider{width:100%;-webkit-appearance:none;background:#ddd;height:4px;border-radius:2px;outline:none}.slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--text-color);border-radius:50%;cursor:pointer}.slider-value{position:absolute;top:-30px;font-weight:700;color:var(--text-color);transform:translateX(-50%);white-space:nowrap;}.options-option{display:flex}";
664
+ const GiftbackInfoStyle0 = giftbackInfoCss;
665
+
666
+ const GiftbackInfo = class {
667
+ constructor(hostRef) {
668
+ registerInstance(this, hostRef);
669
+ this.usedValue = 0;
670
+ this.selectedOption = 'none';
671
+ this.cartId = undefined;
672
+ this.loading = false;
673
+ this.bonus = {
674
+ totalBonus: 0,
675
+ cartId: "",
676
+ minimumPurchase: 0,
677
+ bonusBalance: 0,
678
+ calculatedValue: 0,
679
+ firstValidityDate: "",
680
+ totalValue: 0
681
+ };
682
+ this.reserve = undefined;
683
+ this.cancel = undefined;
684
+ this.config = undefined;
685
+ this.infoBonus = undefined;
686
+ this.storeName = undefined;
687
+ this.sliderPosition = 0;
688
+ this.sliderValuePosition = 0;
689
+ this.loadingTime = false;
690
+ }
691
+ changedBonus() {
692
+ this.updateBonus();
693
+ }
694
+ updateBonus() {
695
+ this.usedValue = this.bonus.bonusBalance;
696
+ this.buildPositionSlider(0, this.bonus.totalBonus);
697
+ }
698
+ componentWillLoad() {
699
+ this.updateBonus();
700
+ this.selectedOption = localStorage.getItem(USED_KEY);
701
+ }
702
+ handleSliderChange(event) {
703
+ const input = event.target;
704
+ this.usedValue = parseFloat(input.value);
705
+ // Calculando a posição do texto com base no valor do slider
706
+ // const percentage = ((this.usedValue - parseInt(input.min)) / (parseInt(input.max) - parseInt(input.min))) * 100;
707
+ // this.sliderPosition = percentage;
708
+ this.buildPositionSlider(parseFloat(input.min), parseFloat(input.max));
709
+ }
710
+ componentDidLoad() {
711
+ var _a;
712
+ if (this.bonus) {
713
+ this._refIinputRange.value = (_a = this.bonus) === null || _a === void 0 ? void 0 : _a.bonusBalance.toString();
714
+ }
715
+ }
716
+ buildPositionSlider(min, max) {
717
+ const percentage_init = max * 0.1;
718
+ // Calculando a posição do texto com base no valor do slider
719
+ const percentage = ((this.usedValue - min) / (max - min)) * 100;
720
+ this.sliderPosition = percentage;
721
+ this.sliderValuePosition = percentage + (this.usedValue <= percentage_init ? 10 : 0);
722
+ }
723
+ async handleOptionChange(option) {
724
+ this.selectedOption = option;
725
+ localStorage.setItem(USED_KEY, option);
726
+ await persisteMetadata(this.storeName, this.cartId, Object.assign(Object.assign({}, this.infoBonus.metadata), { createdAt: null }));
727
+ switch (this.selectedOption) {
728
+ case 'use':
729
+ await this.reserve(this.usedValue);
730
+ break;
731
+ case 'dontUse':
732
+ await this.cancel();
733
+ break;
734
+ }
735
+ }
736
+ showTime() {
737
+ if (!this.infoBonus)
738
+ return false;
739
+ return !this.infoBonus.isExpired();
740
+ // return this.infoBonus.isBonusProcessed
741
+ }
742
+ getTime() {
743
+ var _a, _b;
744
+ const createdAt = new Date((_b = (_a = this.infoBonus) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.createdAt);
745
+ const expiration = new Date(createdAt);
746
+ expiration.setMinutes(expiration.getMinutes() + 6);
747
+ return {
748
+ createdAt,
749
+ expiration
750
+ };
751
+ }
752
+ async downtime() {
753
+ await persisteMetadata(this.storeName, this.bonus.cartId, {
754
+ createdAt: null,
755
+ });
756
+ }
757
+ render() {
758
+ var _a, _b, _c, _d, _e, _f, _g;
759
+ console.log('this.bonus', this.bonus);
760
+ const remainingGiftback = this.bonus.minimumPurchase - this.bonus.totalValue;
761
+ const translateDescription = instance.t("giftDescription", { amount: `${(_b = (_a = this.bonus) === null || _a === void 0 ? void 0 : _a.totalBonus) === null || _b === void 0 ? void 0 : _b.toFixed(2).replace(".", ",")}`, custom_name: "Giftback" });
762
+ const limit = defineLimit(remainingGiftback);
763
+ return (h("div", { key: 'baf90a1de29b3275c1c3cfd31f9d004ca3187a84', class: "giftback-container" }, h("div", { key: '57af5fe5b40b3292a275065f577a9444470f8bf0', class: "container-description" }, h("p", { key: 'fff28c85077c36854f37d5f23f2908fa47197dac', innerHTML: translateDescription }), h("crm-tooltip", { key: 'b66b1914dfa5e0806f85a9695840fdd4bd52d21e', identity: "crm-role-description", text: instance.t("labelUseGiftback", { minimumPurchase: this.bonus.minimumPurchase, expírationDate: formatDateToBr(this.bonus.firstValidityDate) }) })), h("div", { key: 'e13afe9428744084443697df22048ac05b41ffd0', class: "slider-wrapper" }, h("div", { key: '1826a50e4e1b474322dbb0020db0154fe9ed5b80', class: "slider-value", style: {
764
+ left: `calc(${this.sliderValuePosition}% - 20px)`, // Ajuste para centralizar o texto
765
+ } }, "R$ ", this.usedValue.toFixed(2).replace(".", ",")), h("input", { key: '73b42919b8e4e0223dc8490a6190697d1975e96d', ref: ref => this._refIinputRange = ref, id: "position_value_id", disabled: true, type: "range", min: "0", max: this.bonus.totalBonus, value: this.usedValue, class: "slider", step: "0.01", onInput: (event) => this.handleSliderChange(event), style: {
766
+ background: `linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`,
767
+ } })), limit.isComplete && (h("p", { key: 'b9b853490c112bf3e98d14c2ceee25d0b7604983' }, instance.t("maxAmount"))), !limit.isComplete && (h("div", { key: '50b23f6c4bde42ca12b077a33f0ffbde25601e3d', class: "container-description" }, h("p", { key: '73bfbcc779b8775aecc63050816909ba9120af3e' }, "Adicione ", h("strong", { key: '6d5a2ea943a1d3eee80b0f4d0cdda159a300bb25' }, "R$ ", remainingGiftback < 0 ? "0,00" : remainingGiftback.toFixed(2).replace(".", ",")), " ao carrinho para atingir o valor m\u00E1ximo!"), h("crm-tooltip", { key: '5a5bbbeb32abd51fbfb84c63d3e7a06f8d459ea0', identity: "crm-max-description", text: instance.t("labelamountPartial") }))), h("div", { key: 'ea3f6aa8f4668b759b912bac36d9780e183a6180', class: "options" }, h("div", { key: '6f7f70930c8cd97f1215301d823f8631d071b472', class: "options-option" }, h("input", { key: '35b4f8380f34becd4dc94c1bcb1572c2b3401db8', disabled: this.showTime(), type: "radio", name: "giftbackOption", value: "use", checked: this.selectedOption === 'use', onChange: () => this.handleOptionChange('use') }), h("p", { key: '228beeb474e10a67811925bee00e5c1d0f5d64b6' }, "Usar o meu ", (_c = this.config) === null || _c === void 0 ? void 0 :
768
+ _c.giftbackTitle)), h("div", { key: '2a9ad1052f869057d5e36c3eba0cf1a24af88e1b', class: "options-option" }, h("input", { key: '3cc3fae293fda510873f9c5f4d906308affca8e1', disabled: this.showTime(), type: "radio", name: "giftbackOption", value: "dontUse", checked: this.selectedOption === 'dontUse', onChange: () => this.handleOptionChange('dontUse') }), h("p", { key: '364f7de414a6f536680f849fe3efdee803d9a596' }, "N\u00E3o usar o meu ", (_d = this.config) === null || _d === void 0 ? void 0 :
769
+ _d.giftbackTitle))), this.showTime() &&
770
+ (h("div", { key: '8fe525904208e2fc13ebd80615bbe7856cc2dc2c', class: "info-box" }, "Ap\u00F3s ", h("countdown-timer", { key: '3913bc9060980620654f03a987f62f628d6ee440', dataCriacao: new Date((_f = (_e = this.infoBonus) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.createdAt).toString(), downtime: () => { window.location.reload(); } }), ", voc\u00EA poder\u00E1 alterar sua escolha de usar ou n\u00E3o o Giftback.")), !((_g = this === null || this === void 0 ? void 0 : this.infoBonus) === null || _g === void 0 ? void 0 : _g.isBonusProcessed) && (h("div", { key: 'aecd80b9920c8b483d38a1c24a6b38ce03d52b64', class: "info-box" }, "O Giftback ser\u00E1 aplicado na pr\u00F3xima etapa."))));
771
+ }
772
+ static get watchers() { return {
773
+ "bonus": ["changedBonus"]
774
+ }; }
775
+ };
776
+ GiftbackInfo.style = GiftbackInfoStyle0;
777
+
778
+ const loadingContainerCss = ".loading-container{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000;flex-direction:column;}.loading-container p{margin:6px 0px;color:white;font-size:large}.loading-spinner{width:40px;height:40px;border:5px solid rgba(255, 255, 255, 0.3);border-top:5px solid white;border-radius:50%;animation:spin 1s linear infinite;}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.relative-xy{position:relative}";
779
+ const LoadingContainerStyle0 = loadingContainerCss;
780
+
781
+ const LoadingContainer = class {
782
+ constructor(hostRef) {
783
+ registerInstance(this, hostRef);
784
+ this.loading = true;
785
+ this.text = null;
786
+ }
787
+ render() {
788
+ return (h("div", { key: '5e323e6b562ee4d770bb2c9f786a23d6b47ce06e', class: "relative-xy" }, this.loading && (h("div", { key: '31183c82285ec32c7de0348885d0fd30e4a82502', class: "loading-container" }, h("div", { key: '1de235c7594a15e822d044364de0700d3c9e1fa4', class: "loading-spinner" }), this.text && h("p", { key: '82daa6b96a1e14d83be2fc22fd879b3a41896d0e' }, this.text))), h("slot", { key: '09c654783fde15f7b34c4a0804fcec07cfa28b30' })));
789
+ }
790
+ };
791
+ LoadingContainer.style = LoadingContainerStyle0;
792
+
793
+ const loadingSpinnerCss = ".spinner{display:inline-block;border:4px solid transparent;border-radius:50%;border-top-color:var(--color, #0078d7);animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
794
+ const LoadingSpinnerStyle0 = loadingSpinnerCss;
795
+
796
+ const LoadingSpinner = class {
797
+ constructor(hostRef) {
798
+ registerInstance(this, hostRef);
799
+ this.size = '50px';
800
+ this.color = '#0078d7';
801
+ }
802
+ render() {
803
+ return (h("div", { key: 'e1916d264937b0470cd5b1581c87184061b40c3a', class: "spinner", style: { width: this.size, height: this.size, borderColor: `${this.color} transparent transparent transparent` } }));
804
+ }
805
+ };
806
+ LoadingSpinner.style = LoadingSpinnerStyle0;
807
+
808
+ const giftbackFormCss$1 = "*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";
809
+ const PhoneFormStyle0 = giftbackFormCss$1;
810
+
811
+ const PhoneForm = class {
812
+ constructor(hostRef) {
813
+ registerInstance(this, hostRef);
814
+ this.value = undefined;
815
+ this.loading = undefined;
816
+ this.handlerSubmit = undefined;
817
+ this.config = undefined;
818
+ }
819
+ async handlePhone() {
820
+ const phone = await this.phoneInputMask.getPhone();
821
+ await this.handlerSubmit(phone);
822
+ }
823
+ render() {
824
+ var _a;
825
+ return (h(Host, { key: 'b27f64d8464d4c6b259d2d5f0113f55a6f809afb', class: "crm-phone-form" }, h("p", { key: '6f279841f43cd7f70f7a1b5340288b9c2d11c551', class: "crm-subtitle" }, "Digite o seu celular para verificar se h\u00E1 desconto dispon\u00EDvel nessa compra:"), h("phone-input-mask", { key: '7e86f63998a4f35d134b8f4e867a5e5c0b9df20a', initialValue: this.value, ref: ref => this.phoneInputMask = ref }), h("crm-button", { key: '462b7cc91f166c8fc588a5c922ba943a6715dca5', txtBtn: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.btnApplyBonusLabel) || "Avançar", loading: this.loading, handleClick: () => this.handlePhone() })));
826
+ }
827
+ };
828
+ PhoneForm.style = PhoneFormStyle0;
829
+
830
+ const phoneInputMaskCss = "*{margin:0;padding:0;box-sizing:border-box}.phone{display:block;width:100%;height:24px;padding:6px 12px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:0px;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, .075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, .075);-webkit-transition:border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s}.phone-input-form{width:100%;height:48px;padding:13px 16px 13px 16px;border:1px solid #CCCCCC;}.crm-erro-msg{color:#E11D48;font-weight:500;margin-top:11px}";
831
+ const PhoneInputMaskStyle0 = phoneInputMaskCss;
832
+
833
+ const PhoneInputMask = class {
834
+ constructor(hostRef) {
835
+ registerInstance(this, hostRef);
836
+ this.phone = '';
837
+ this.message = "";
838
+ this.initialValue = undefined;
839
+ this.disabled = undefined;
840
+ }
841
+ componentWillLoad() {
842
+ this.phone = this.initialValue;
843
+ }
844
+ formatPhone(value) {
845
+ const cleaned = value.replace(/\D/g, ''); // Remove tudo que não for número
846
+ const match = cleaned.match(/^(\d{0,2})(\d{0,5})(\d{0,4})$/);
847
+ if (!match)
848
+ return value;
849
+ const part1 = match[1] ? `(${match[1]}` : '';
850
+ const part2 = match[2] ? `) ${match[2]}` : '';
851
+ const part3 = match[3] ? ` ${match[3]}` : '';
852
+ return `${part1}${part2}${part3}`;
853
+ }
854
+ handleInput(event) {
855
+ const input = event.target;
856
+ this.phone = this.formatPhone(input.value);
857
+ if (!this.validatePhoneNumber(input.value)) {
858
+ this.message = MESSAGE_ERROR_INVALID_NUMBER;
859
+ }
860
+ else {
861
+ this.message = "";
862
+ }
863
+ console.log('phone', this.phone);
864
+ }
865
+ validatePhoneNumber(phone) {
866
+ if (phone.length < 15) {
867
+ return true;
868
+ }
869
+ const phoneRegex = /^\(\d{2}\) \d{5} \d{4}$/; // Valida formato (99) 99999-9999
870
+ return phoneRegex.test(phone);
871
+ }
872
+ async getPhone() {
873
+ return this.phone;
874
+ }
875
+ render() {
876
+ return (h("div", { key: 'bbb0389d0a7ccb8651b8ee20e92dd4cdc94e3617' }, h("input", { key: 'b36cc9e65314cb786c7f94fee6b4992ba30a82e6', disabled: this.disabled, id: "phone", type: "text", class: "phone-input-form", value: this.phone, onInput: (event) => this.handleInput(event), placeholder: "(99) 99999 9999" }), h("p", { key: '81e48cda38cd9a8fc7d753d269425bd4288c57b1', class: "crm-erro-msg" }, this.message)));
877
+ }
878
+ };
879
+ PhoneInputMask.style = PhoneInputMaskStyle0;
880
+
881
+ const pinFormCss = ":host{display:block}.form-container-pin{display:flex;flex-direction:column;align-items:center}.pin-container{display:flex;justify-content:start;gap:10px}.pin-container input{width:100%;height:48px;text-align:center;border:1px solid #ccc;border-radius:5px}button{padding:10px 20px;background-color:#ddd;border:none;border-radius:5px;cursor:pointer}.success{color:green;margin-top:10px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;border-radius:10px;padding:15px;min-height:30px;min-width:120px;cursor:pointer}.button-cancel{top:50%;background-color:#ffffff;color:#1e1c1c;border:1px solid gray;border-radius:10px;padding:10px;min-height:30px;min-width:120px;cursor:pointer}.crm-description{width:100%;display:flex;gap:9px;flex-wrap:wrap}.crm-description a{font-weight:bold;cursor:pointer;text-decoration:underline}.crm-description div{display:flex;gap:5px}";
882
+ const PinFormStyle0 = pinFormCss;
883
+
884
+ const giftbackFormCss = "*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";
885
+ const PinFormStyle1 = giftbackFormCss;
886
+
887
+ const GiftbackPin = class {
888
+ constructor(hostRef) {
889
+ registerInstance(this, hostRef);
890
+ this.validate = undefined;
891
+ this.cancel = undefined;
892
+ this.resend = undefined;
893
+ this.sent = undefined;
894
+ this.loading = false;
895
+ this.phone = undefined;
896
+ this.config = undefined;
897
+ this.pin = ['', '', '', ''];
898
+ this.isVerified = false;
899
+ this.canResend = false;
900
+ }
901
+ componentWillLoad() {
902
+ this.canResend = false;
903
+ }
904
+ handleInput(event, index) {
905
+ const input = event.target;
906
+ const value = input.value.slice(0, 1); // Limitar a um único dígito
907
+ this.pin[index] = value;
908
+ // Focar no próximo campo, se possível
909
+ if (value && index < this.pin.length - 1) {
910
+ const nextInput = input.nextElementSibling;
911
+ nextInput === null || nextInput === void 0 ? void 0 : nextInput.focus();
912
+ }
913
+ this.pin = [...this.pin];
914
+ }
915
+ validatePin() {
916
+ localStorage.removeItem("bc:resend");
917
+ this.validate(this.pin.join(""));
918
+ }
919
+ verifyPin() {
920
+ const pinCode = this.pin.join('');
921
+ if (pinCode === '9999') {
922
+ this.isVerified = true;
923
+ }
924
+ }
925
+ handleTimeout() {
926
+ localStorage.removeItem("bc:resend");
927
+ this.canResend = true;
928
+ }
929
+ async handleResend() {
930
+ await this.resend();
931
+ this.canResend = false;
932
+ this.pin = ['', '', '', ''];
933
+ localStorage.removeItem("bc:resend");
934
+ }
935
+ buildTime() {
936
+ const resendDate = localStorage.getItem("bc:resend");
937
+ if (resendDate) {
938
+ return resendDate;
939
+ }
940
+ const date = new Date();
941
+ date.setSeconds(date.getSeconds() + 30);
942
+ localStorage.setItem("bc:resend", date.toString());
943
+ return date.toString();
944
+ }
945
+ render() {
946
+ var _a;
947
+ return (h("div", { key: '3f60e4c74c925daf656092812f40ae0d1f3b5a99', class: "crm-phone-form" }, h("label", { key: 'd0c023e22ff7eb8978ee6cc0ca4ced8192c53c20', class: "crm-subtitle" }, instance.t('pin-sutitle'), " ", h("strong", { key: '05bb0e2493c99abaa29031a7cc787260266bb417' }, "+55 ", this.phone)), h("div", { key: '24c8eb55625f3b880741086c66decd96ecf40044', class: "pin-container" }, this.pin.map((_, index) => (h("input", { type: "text", maxLength: 1, value: this.pin[index], onInput: (event) => this.handleInput(event, index) })))), h("slot", { key: '02276aa80396d16f779a92a381e75506fa37d56d' }), h("p", { key: '27af068858b3ead8a70b8ec961d367c7beb04d94', class: "crm-description" }, " N\u00E3o recebeu?", !this.canResend && h("label", { key: '8ef93baf6f92142292078e5e4bcc125ff12b80d7' }, " Reenviar em", h("countdown-timer", { key: 'f3a0c60c7a88229e37add445886c44b00c60913f', minutos: 0, segundos: 30, dataCriacao: this.buildTime(), downtime: () => this.handleTimeout() }), " "), this.canResend && (h("div", { key: '2d1b5b028a7085d912acb0d0c696436e8aa75a29' }, h("a", { key: 'ad9aea2c6f167f1270c75b8dbd2ee79879f7567d', onClick: () => this.handleResend() }, "Reenviar"), h("a", { key: 'b0734ab0e472c5cf24fa083c0a712e4f29cf8d79', onClick: () => this.cancel() }, "Trocar n\u00FAmero")))), h("crm-button", { key: '39095211d007c871f48971509c3ff52b0f257c29', txtBtn: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.btnApplyBonusLabel) || "Avançar", loading: this.loading, handleClick: () => this.validatePin() })));
948
+ }
949
+ };
950
+ GiftbackPin.style = PinFormStyle0 + PinFormStyle1;
951
+
952
+ export { CountdownTimer as countdown_timer, CrmBonus$1 as crm_bonus, Button as crm_button, CrmBonus as crm_giftback_form, Tooltip as crm_tooltip, GiftbackInfo as giftback_info, LoadingContainer as loading_container, LoadingSpinner as loading_spinner, PhoneForm as phone_form, PhoneInputMask as phone_input_mask, GiftbackPin as pin_form };
953
+
954
+ //# sourceMappingURL=countdown-timer_11.entry.js.map