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