crmbonus-component-wake 2.1.34 → 2.1.36-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 +979 -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 -15
  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 +72 -26
  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-5d014ac9.entry.js +2 -0
  82. package/dist/crmbonus-component-wake/p-5d014ac9.entry.js.map +1 -0
  83. package/dist/crmbonus-component-wake/p-622d5644.entry.js +2 -0
  84. package/dist/crmbonus-component-wake/p-7e52727e.entry.js +2 -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 +965 -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,965 @@
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
+ try {
187
+ await this.loadSession();
188
+ this.handleLoad();
189
+ await this.loadConfigStore();
190
+ }
191
+ catch (error) {
192
+ this.loading_reprocess = false;
193
+ }
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
+ 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
+ if (this.cartWake.user.id) {
242
+ this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {
243
+ if (customer) {
244
+ this.customer = customer;
245
+ }
246
+ });
247
+ }
248
+ const amount = localStorage.getItem(this.cartWake.id);
249
+ if (amount) {
250
+ this.canCancel = true;
251
+ this.amountCancel = amount;
252
+ }
253
+ await this.buildAndGetProducts(this.cartWake.products);
254
+ }
255
+ catch (error) {
256
+ console.log('info customer');
257
+ }
258
+ }
259
+ async loadSession() {
260
+ this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();
261
+ console.log('[bc:carregou carrinho]');
262
+ this.session = await this.crmBonusService.getToken(this.cartWake.store.name);
263
+ console.log('[bc:carregou session]');
264
+ setTimeout(() => {
265
+ this.loadSession();
266
+ }, 1500000);
267
+ }
268
+ async buildAndGetProducts(productsWake) {
269
+ console.log();
270
+ const key = `bc-products:${this.cartWake.id}`;
271
+ const productsString = JSON.stringify(productsWake);
272
+ localStorage.setItem(key, productsString);
273
+ const products_in_cache = JSON.parse(localStorage.getItem(key));
274
+ const products = [];
275
+ for (const product_cart of productsWake) {
276
+ const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId);
277
+ //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === "Formula")
278
+ if (pro) {
279
+ products.push(Object.assign(Object.assign({}, product_cart), { PrecoPor: pro.PrecoPor, PrecoDe: pro.PrecoDe, Quantidade: pro.Quantidade, Ajustes: pro.Ajustes }));
280
+ }
281
+ else {
282
+ products.push(product_cart);
283
+ }
284
+ }
285
+ this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);
286
+ }
287
+ async sendPin(phone) {
288
+ var _a, _b;
289
+ this.loading = true;
290
+ this.message = "";
291
+ try {
292
+ const _phone = phone.replace(/\D/g, '');
293
+ this.phone = Number(_phone);
294
+ this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
295
+ await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
296
+ this.showModal = true;
297
+ }
298
+ catch (error) {
299
+ 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;
300
+ }
301
+ finally {
302
+ this.loading = false;
303
+ }
304
+ }
305
+ async sendPinName(customerName) {
306
+ var _a, _b;
307
+ this.loading = true;
308
+ this.message = "";
309
+ try {
310
+ this.customer.name = customerName;
311
+ this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
312
+ await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
313
+ this.showModal = true;
314
+ }
315
+ catch (error) {
316
+ 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;
317
+ }
318
+ finally {
319
+ this.loading = false;
320
+ }
321
+ }
322
+ buildProducts() {
323
+ return buildProductsByWake(this.cartWake.products);
324
+ }
325
+ handleCloseModal() {
326
+ this.showModal = false;
327
+ }
328
+ save(amount) {
329
+ localStorage.setItem(this.cartWake.id, amount.toString());
330
+ this.canCancel = true;
331
+ this.amountCancel = amount.toString();
332
+ }
333
+ async cancel() {
334
+ this.message = "";
335
+ this.loading = true;
336
+ try {
337
+ await this.crmBonusService.cancel(this.cartWake.id);
338
+ this.canCancel = false;
339
+ localStorage.removeItem(this.cartWake.id);
340
+ }
341
+ catch (error) {
342
+ this.message = "Não consegui cancelar o bônus, tente novamente!";
343
+ }
344
+ finally {
345
+ this.loading = false;
346
+ }
347
+ }
348
+ async handleSendPin(phone) {
349
+ this.message = "";
350
+ if (!phone) {
351
+ this.message = "Informe seu telefone";
352
+ return;
353
+ }
354
+ this.customer.phone = phone;
355
+ const _phone = phone.replace(/\D/g, '');
356
+ this.phone = Number(_phone);
357
+ if (this.customer.name) {
358
+ return this.sendPin(phone);
359
+ }
360
+ await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);
361
+ this.showModal = true;
362
+ }
363
+ render() {
364
+ if (this.canhidden) {
365
+ return null;
366
+ }
367
+ 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 }))));
368
+ }
369
+ static get assetsDirs() { return ["assets"]; }
370
+ };
371
+ CrmBonus$1.style = CrmBonusStyle0;
372
+
373
+ 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}";
374
+ const CrmButtonStyle0 = crmButtonCss;
375
+
376
+ const Button = class {
377
+ constructor(hostRef) {
378
+ registerInstance(this, hostRef);
379
+ this.txtBtn = undefined;
380
+ this.loading = undefined;
381
+ this.handleClick = undefined;
382
+ }
383
+ render() {
384
+ 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" }))));
385
+ }
386
+ };
387
+ Button.style = CrmButtonStyle0;
388
+
389
+ 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;}";
390
+ const CrmGiftbackFormStyle0 = giftbackFormCss$2;
391
+
392
+ const CrmBonus = class {
393
+ constructor(hostRef) {
394
+ registerInstance(this, hostRef);
395
+ // private phoneInputMask: HTMLPhoneFormElement;
396
+ this.crmBonusService = CrmBonusService.getInstance();
397
+ this.storeName = undefined;
398
+ this.cartId = undefined;
399
+ this.products = undefined;
400
+ this.customer = undefined;
401
+ this.loadProducts = undefined;
402
+ this.loadAll = undefined;
403
+ this.customStyles = undefined;
404
+ this.reservedInfo = undefined;
405
+ this.value = undefined;
406
+ this.loading = false;
407
+ this.message = undefined;
408
+ this.phone = undefined;
409
+ this.pinInfo = undefined;
410
+ this.step = StepFormEnum.STEP_RESERVE;
411
+ this.bonus = undefined;
412
+ this.sucess = "";
413
+ this.error = "";
414
+ this.config = undefined;
415
+ this.hasApplyBonus = false;
416
+ this.loadingAllComponent = false;
417
+ }
418
+ async setStep(step) {
419
+ this.step = step;
420
+ }
421
+ async processBonus(products = [], hasNewProduct = false) {
422
+ await this.loadProducts();
423
+ this.sucess = "";
424
+ if (hasNewProduct) {
425
+ this.products = products;
426
+ }
427
+ const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
428
+ if (_bonus) {
429
+ const bonus = JSON.parse(_bonus);
430
+ this.bonus = bonus;
431
+ this.phone = bonus.phone;
432
+ this.pinInfo = {
433
+ storeId: bonus.storeId,
434
+ userId: bonus.userId
435
+ };
436
+ await this.validateBonus("2018");
437
+ //this.step = StepFormEnum.STEP_RESERVE;
438
+ }
439
+ }
440
+ async handleSendPin(phone) {
441
+ await this.loadAll();
442
+ this.message = "";
443
+ if (!phone) {
444
+ this.message = "Informe seu telefone";
445
+ return;
446
+ }
447
+ this.phone = phone;
448
+ this.sendPin();
449
+ }
450
+ async componentWillLoad() {
451
+ this.sucess = "";
452
+ this.error = "";
453
+ this.config = getInfoCustomization(this.storeName);
454
+ const phoneAgain = this.getPhoneNumberAgain();
455
+ if (phoneAgain) {
456
+ this.step = StepFormEnum.STEP_PHONE;
457
+ return;
458
+ }
459
+ await this.processBonus();
460
+ }
461
+ getPhoneNumberAgain() {
462
+ const consulta_bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
463
+ if (!consulta_bonus)
464
+ return true;
465
+ const bonus = JSON.parse(consulta_bonus);
466
+ return !bonus.hasBonus;
467
+ }
468
+ convertStringToNumber() {
469
+ var _a;
470
+ const _phone = (_a = this.phone) === null || _a === void 0 ? void 0 : _a.replace(/\D/g, '');
471
+ return Number(_phone);
472
+ }
473
+ async sendPin() {
474
+ var _a, _b, _c;
475
+ this.loading = true;
476
+ this.message = "";
477
+ this.sucess = "";
478
+ this.error = "";
479
+ try {
480
+ const _phone = this.convertStringToNumber();
481
+ const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);
482
+ if (!pinInfoCache) {
483
+ this.pinInfo = await this.crmBonusService.sendPin(_phone, (_a = this.customer) === null || _a === void 0 ? void 0 : _a.name, this.storeName);
484
+ }
485
+ if (pinInfoCache) {
486
+ const bonus = JSON.parse(pinInfoCache);
487
+ this.pinInfo = {
488
+ storeId: bonus.storeId,
489
+ userId: bonus.userId
490
+ };
491
+ await this.validateBonus("2018");
492
+ // this.step = StepFormEnum.STEP_RESERVE;
493
+ }
494
+ else {
495
+ this.step = StepFormEnum.STEP_PIN;
496
+ }
497
+ }
498
+ catch (error) {
499
+ 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;
500
+ }
501
+ finally {
502
+ this.loading = false;
503
+ }
504
+ }
505
+ changePhone() {
506
+ this.sucess = "";
507
+ this.error = "";
508
+ this.step = StepFormEnum.STEP_PHONE;
509
+ }
510
+ async validateBonus(pin) {
511
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
512
+ this.loadingAllComponent = true;
513
+ await this.loadProducts();
514
+ const used_or_no = localStorage.getItem(USED_KEY);
515
+ if (used_or_no == "dontUse") {
516
+ this.step = StepFormEnum.STEP_RESERVE;
517
+ return;
518
+ }
519
+ this.loading = true;
520
+ this.sucess = "";
521
+ this.error = "";
522
+ 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);
523
+ 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);
524
+ const cellphone = (_h = (_g = this.reservedInfo) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.cellphone;
525
+ const payload = {
526
+ pin: pin,
527
+ cellphone: cellphone || this.convertStringToNumber(),
528
+ storeId: storeId.toString(),
529
+ userId: userId.toString(),
530
+ checkoutId: this.cartId,
531
+ checkoutProducts: this.products,
532
+ name: (_j = this.customer) === null || _j === void 0 ? void 0 : _j.name,
533
+ storeName: this.storeName
534
+ };
535
+ try {
536
+ this.bonus = await this.crmBonusService.validatePinBonus(payload);
537
+ if (!this.bonus.hasBonus) {
538
+ localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify(Object.assign(Object.assign({}, this.bonus), { phone: this.phone })));
539
+ this.loading = false;
540
+ this.step = StepFormEnum.STEP_NO_BONUS;
541
+ return;
542
+ }
543
+ this.sucess = "Código validado com sucesso!";
544
+ localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify(Object.assign(Object.assign({}, this.bonus), { phone: this.phone })));
545
+ localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));
546
+ localStorage.setItem(USED_KEY, "use");
547
+ localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());
548
+ this.updateMetadata({ storeId: Number(storeId), userId: Number(userId) }, payload.cellphone);
549
+ console.log('RESERVE', this.bonus);
550
+ this.step = StepFormEnum.STEP_RESERVE;
551
+ }
552
+ catch (error) {
553
+ 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;
554
+ const response = (_m = error === null || error === void 0 ? void 0 : error.response) === null || _m === void 0 ? void 0 : _m.data;
555
+ if (_error && _error.includes("Pin")) {
556
+ this.error = "Código inválido!";
557
+ }
558
+ else if ([403, 500].includes(response.statusCode)) {
559
+ this.error = "ocorreu um error, atualize a pagina e tente novamente!";
560
+ }
561
+ else {
562
+ this.error = _error;
563
+ this.step = StepFormEnum.STEP_NO_BONUS;
564
+ }
565
+ }
566
+ finally {
567
+ this.loading = false;
568
+ this.loadingAllComponent = false;
569
+ }
570
+ }
571
+ async updateMetadata(pinInfo, cellphone) {
572
+ try {
573
+ if (this.reservedInfo.isExpired()) {
574
+ console.log('[CRM:updateMetadata]');
575
+ await persisteMetadata(this.storeName, this.cartId, {
576
+ createdAt: Date.now(),
577
+ url: window.location.href,
578
+ storeId: pinInfo.storeId,
579
+ userId: pinInfo.userId,
580
+ cellphone: cellphone,
581
+ });
582
+ localStorage.removeItem("bc:time");
583
+ }
584
+ else {
585
+ await persisteMetadata(this.storeName, this.cartId, {
586
+ url: window.location.href,
587
+ storeId: pinInfo.storeId,
588
+ userId: pinInfo.userId,
589
+ cellphone: cellphone,
590
+ });
591
+ }
592
+ }
593
+ catch (error) {
594
+ console.error('[CRMBONUS:updateMetadata]: ', error);
595
+ }
596
+ }
597
+ handleCancel() {
598
+ // this.step = StepFormEnum.STEP_PHONE;
599
+ this.cancel();
600
+ }
601
+ async cancel() {
602
+ this.message = "";
603
+ this.loading = true;
604
+ try {
605
+ await this.crmBonusService.cancel(this.cartId);
606
+ localStorage.setItem(USED_KEY, "dontUse");
607
+ // this.save(0)
608
+ await this.updateMetadata({ storeId: null, userId: null }, null);
609
+ }
610
+ catch (error) {
611
+ this.message = "Não consegui cancelar o bônus, tente novamente!";
612
+ }
613
+ finally {
614
+ this.loading = false;
615
+ }
616
+ }
617
+ async reserveApply(amount) {
618
+ this.loading = true;
619
+ this.message = "";
620
+ try {
621
+ await this.reserve(amount);
622
+ // this.save(amount);
623
+ }
624
+ catch (error) {
625
+ this.message = "ocorreu um error ao solicitar a aplicação do bonus! tente novamente";
626
+ this.step = StepFormEnum.STEP_NO_BONUS;
627
+ localStorage.removeItem(this.cartId);
628
+ }
629
+ finally {
630
+ this.loading = false;
631
+ }
632
+ }
633
+ // save(amount: number) {
634
+ // localStorage.setItem(this.cartId, amount.toString());
635
+ // }
636
+ async reserve(amount) {
637
+ await this.crmBonusService.reserve({
638
+ redeemedBonus: amount,
639
+ cartId: this.cartId,
640
+ ticket: this.cartId,
641
+ grossValue: Number(this.bonus.totalValue),
642
+ storeName: this.storeName,
643
+ storeId: this.bonus.storeId.toString(),
644
+ userId: this.bonus.userId
645
+ });
646
+ }
647
+ render() {
648
+ 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 &&
649
+ 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 &&
650
+ 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 &&
651
+ 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 &&
652
+ (h("div", { key: '6583e51ae1988bd5c797665e3119eed3aeb7a354', class: "container-message" }, instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
653
+ }
654
+ };
655
+ CrmBonus.style = CrmGiftbackFormStyle0;
656
+
657
+ const infoCircleSvgrepoComSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xMiAxNy43NUMxMi40MTQyIDE3Ljc1IDEyLjc1IDE3LjQxNDIgMTIuNzUgMTdWMTFDMTIuNzUgMTAuNTg1OCAxMi40MTQyIDEwLjI1IDEyIDEwLjI1QzExLjU4NTggMTAuMjUgMTEuMjUgMTAuNTg1OCAxMS4yNSAxMVYxN0MxMS4yNSAxNy40MTQyIDExLjU4NTggMTcuNzUgMTIgMTcuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8cGF0aCBkPSJNMTIgN0MxMi41NTIzIDcgMTMgNy40NDc3MiAxMyA4QzEzIDguNTUyMjggMTIuNTUyMyA5IDEyIDlDMTEuNDQ3NyA5IDExIDguNTUyMjggMTEgOEMxMSA3LjQ0NzcyIDExLjQ0NzcgNyAxMiA3WiIgZmlsbD0iIzFDMjc0QyIvPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjI1IDEyQzEuMjUgNi4wNjI5NCA2LjA2Mjk0IDEuMjUgMTIgMS4yNUMxNy45MzcxIDEuMjUgMjIuNzUgNi4wNjI5NCAyMi43NSAxMkMyMi43NSAxNy45MzcxIDE3LjkzNzEgMjIuNzUgMTIgMjIuNzVDNi4wNjI5NCAyMi43NSAxLjI1IDE3LjkzNzEgMS4yNSAxMlpNMTIgMi43NUM2Ljg5MTM3IDIuNzUgMi43NSA2Ljg5MTM3IDIuNzUgMTJDMi43NSAxNy4xMDg2IDYuODkxMzcgMjEuMjUgMTIgMjEuMjVDMTcuMTA4NiAyMS4yNSAyMS4yNSAxNy4xMDg2IDIxLjI1IDEyQzIxLjI1IDYuODkxMzcgMTcuMTA4NiAyLjc1IDEyIDIuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8L3N2Zz4=';
658
+
659
+ 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}";
660
+ const CrmTooltipStyle0 = crmTooltipCss;
661
+
662
+ const Tooltip = class {
663
+ constructor(hostRef) {
664
+ registerInstance(this, hostRef);
665
+ this.text = undefined;
666
+ this.identity = undefined;
667
+ }
668
+ render() {
669
+ 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)));
670
+ }
671
+ };
672
+ Tooltip.style = CrmTooltipStyle0;
673
+
674
+ 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}";
675
+ const GiftbackInfoStyle0 = giftbackInfoCss;
676
+
677
+ const GiftbackInfo = class {
678
+ constructor(hostRef) {
679
+ registerInstance(this, hostRef);
680
+ this.usedValue = 0;
681
+ this.selectedOption = 'none';
682
+ this.cartId = undefined;
683
+ this.loading = false;
684
+ this.bonus = {
685
+ totalBonus: 0,
686
+ cartId: "",
687
+ minimumPurchase: 0,
688
+ bonusBalance: 0,
689
+ calculatedValue: 0,
690
+ firstValidityDate: "",
691
+ totalValue: 0
692
+ };
693
+ this.reserve = undefined;
694
+ this.cancel = undefined;
695
+ this.config = undefined;
696
+ this.infoBonus = undefined;
697
+ this.storeName = undefined;
698
+ this.sliderPosition = 0;
699
+ this.sliderValuePosition = 0;
700
+ this.loadingTime = false;
701
+ }
702
+ changedBonus() {
703
+ this.updateBonus();
704
+ }
705
+ updateBonus() {
706
+ this.usedValue = this.bonus.bonusBalance;
707
+ this.buildPositionSlider(0, this.bonus.totalBonus);
708
+ }
709
+ componentWillLoad() {
710
+ this.updateBonus();
711
+ this.selectedOption = localStorage.getItem(USED_KEY);
712
+ }
713
+ handleSliderChange(event) {
714
+ const input = event.target;
715
+ this.usedValue = parseFloat(input.value);
716
+ // Calculando a posição do texto com base no valor do slider
717
+ // const percentage = ((this.usedValue - parseInt(input.min)) / (parseInt(input.max) - parseInt(input.min))) * 100;
718
+ // this.sliderPosition = percentage;
719
+ this.buildPositionSlider(parseFloat(input.min), parseFloat(input.max));
720
+ }
721
+ componentDidLoad() {
722
+ var _a;
723
+ if (this.bonus) {
724
+ this._refIinputRange.value = (_a = this.bonus) === null || _a === void 0 ? void 0 : _a.bonusBalance.toString();
725
+ }
726
+ }
727
+ buildPositionSlider(min, max) {
728
+ const percentage_init = max * 0.1;
729
+ // Calculando a posição do texto com base no valor do slider
730
+ const percentage = ((this.usedValue - min) / (max - min)) * 100;
731
+ this.sliderPosition = percentage;
732
+ this.sliderValuePosition = percentage + (this.usedValue <= percentage_init ? 10 : 0);
733
+ }
734
+ async handleOptionChange(option) {
735
+ this.selectedOption = option;
736
+ localStorage.setItem(USED_KEY, option);
737
+ await persisteMetadata(this.storeName, this.cartId, Object.assign(Object.assign({}, this.infoBonus.metadata), { createdAt: null }));
738
+ switch (this.selectedOption) {
739
+ case 'use':
740
+ await this.reserve(this.usedValue);
741
+ break;
742
+ case 'dontUse':
743
+ await this.cancel();
744
+ break;
745
+ }
746
+ }
747
+ showTime() {
748
+ if (!this.infoBonus)
749
+ return false;
750
+ return !this.infoBonus.isExpired();
751
+ // return this.infoBonus.isBonusProcessed
752
+ }
753
+ getTime() {
754
+ var _a, _b;
755
+ const createdAt = new Date((_b = (_a = this.infoBonus) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.createdAt);
756
+ const expiration = new Date(createdAt);
757
+ expiration.setMinutes(expiration.getMinutes() + 6);
758
+ return {
759
+ createdAt,
760
+ expiration
761
+ };
762
+ }
763
+ async downtime() {
764
+ await persisteMetadata(this.storeName, this.bonus.cartId, {
765
+ createdAt: null,
766
+ });
767
+ }
768
+ render() {
769
+ var _a, _b, _c, _d, _e, _f, _g;
770
+ console.log('this.bonus', this.bonus);
771
+ const remainingGiftback = this.bonus.minimumPurchase - this.bonus.totalValue;
772
+ 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" });
773
+ const limit = defineLimit(remainingGiftback);
774
+ 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: {
775
+ left: `calc(${this.sliderValuePosition}% - 20px)`, // Ajuste para centralizar o texto
776
+ } }, "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: {
777
+ background: `linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`,
778
+ } })), 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 :
779
+ _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 :
780
+ _d.giftbackTitle))), this.showTime() &&
781
+ (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."))));
782
+ }
783
+ static get watchers() { return {
784
+ "bonus": ["changedBonus"]
785
+ }; }
786
+ };
787
+ GiftbackInfo.style = GiftbackInfoStyle0;
788
+
789
+ 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}";
790
+ const LoadingContainerStyle0 = loadingContainerCss;
791
+
792
+ const LoadingContainer = class {
793
+ constructor(hostRef) {
794
+ registerInstance(this, hostRef);
795
+ this.loading = true;
796
+ this.text = null;
797
+ }
798
+ render() {
799
+ 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' })));
800
+ }
801
+ };
802
+ LoadingContainer.style = LoadingContainerStyle0;
803
+
804
+ 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)}}";
805
+ const LoadingSpinnerStyle0 = loadingSpinnerCss;
806
+
807
+ const LoadingSpinner = class {
808
+ constructor(hostRef) {
809
+ registerInstance(this, hostRef);
810
+ this.size = '50px';
811
+ this.color = '#0078d7';
812
+ }
813
+ render() {
814
+ return (h("div", { key: 'e1916d264937b0470cd5b1581c87184061b40c3a', class: "spinner", style: { width: this.size, height: this.size, borderColor: `${this.color} transparent transparent transparent` } }));
815
+ }
816
+ };
817
+ LoadingSpinner.style = LoadingSpinnerStyle0;
818
+
819
+ 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;}";
820
+ const PhoneFormStyle0 = giftbackFormCss$1;
821
+
822
+ const PhoneForm = class {
823
+ constructor(hostRef) {
824
+ registerInstance(this, hostRef);
825
+ this.value = undefined;
826
+ this.loading = undefined;
827
+ this.handlerSubmit = undefined;
828
+ this.config = undefined;
829
+ }
830
+ async handlePhone() {
831
+ const phone = await this.phoneInputMask.getPhone();
832
+ await this.handlerSubmit(phone);
833
+ }
834
+ render() {
835
+ var _a;
836
+ 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() })));
837
+ }
838
+ };
839
+ PhoneForm.style = PhoneFormStyle0;
840
+
841
+ 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}";
842
+ const PhoneInputMaskStyle0 = phoneInputMaskCss;
843
+
844
+ const PhoneInputMask = class {
845
+ constructor(hostRef) {
846
+ registerInstance(this, hostRef);
847
+ this.phone = '';
848
+ this.message = "";
849
+ this.initialValue = undefined;
850
+ this.disabled = undefined;
851
+ }
852
+ componentWillLoad() {
853
+ this.phone = this.initialValue;
854
+ }
855
+ formatPhone(value) {
856
+ const cleaned = value.replace(/\D/g, ''); // Remove tudo que não for número
857
+ const match = cleaned.match(/^(\d{0,2})(\d{0,5})(\d{0,4})$/);
858
+ if (!match)
859
+ return value;
860
+ const part1 = match[1] ? `(${match[1]}` : '';
861
+ const part2 = match[2] ? `) ${match[2]}` : '';
862
+ const part3 = match[3] ? ` ${match[3]}` : '';
863
+ return `${part1}${part2}${part3}`;
864
+ }
865
+ handleInput(event) {
866
+ const input = event.target;
867
+ this.phone = this.formatPhone(input.value);
868
+ if (!this.validatePhoneNumber(input.value)) {
869
+ this.message = MESSAGE_ERROR_INVALID_NUMBER;
870
+ }
871
+ else {
872
+ this.message = "";
873
+ }
874
+ console.log('phone', this.phone);
875
+ }
876
+ validatePhoneNumber(phone) {
877
+ if (phone.length < 15) {
878
+ return true;
879
+ }
880
+ const phoneRegex = /^\(\d{2}\) \d{5} \d{4}$/; // Valida formato (99) 99999-9999
881
+ return phoneRegex.test(phone);
882
+ }
883
+ async getPhone() {
884
+ return this.phone;
885
+ }
886
+ render() {
887
+ 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)));
888
+ }
889
+ };
890
+ PhoneInputMask.style = PhoneInputMaskStyle0;
891
+
892
+ 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}";
893
+ const PinFormStyle0 = pinFormCss;
894
+
895
+ 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;}";
896
+ const PinFormStyle1 = giftbackFormCss;
897
+
898
+ const GiftbackPin = class {
899
+ constructor(hostRef) {
900
+ registerInstance(this, hostRef);
901
+ this.validate = undefined;
902
+ this.cancel = undefined;
903
+ this.resend = undefined;
904
+ this.sent = undefined;
905
+ this.loading = false;
906
+ this.phone = undefined;
907
+ this.config = undefined;
908
+ this.pin = ['', '', '', ''];
909
+ this.isVerified = false;
910
+ this.canResend = false;
911
+ }
912
+ componentWillLoad() {
913
+ this.canResend = false;
914
+ }
915
+ handleInput(event, index) {
916
+ const input = event.target;
917
+ const value = input.value.slice(0, 1); // Limitar a um único dígito
918
+ this.pin[index] = value;
919
+ // Focar no próximo campo, se possível
920
+ if (value && index < this.pin.length - 1) {
921
+ const nextInput = input.nextElementSibling;
922
+ nextInput === null || nextInput === void 0 ? void 0 : nextInput.focus();
923
+ }
924
+ this.pin = [...this.pin];
925
+ }
926
+ validatePin() {
927
+ localStorage.removeItem("bc:resend");
928
+ this.validate(this.pin.join(""));
929
+ }
930
+ verifyPin() {
931
+ const pinCode = this.pin.join('');
932
+ if (pinCode === '9999') {
933
+ this.isVerified = true;
934
+ }
935
+ }
936
+ handleTimeout() {
937
+ localStorage.removeItem("bc:resend");
938
+ this.canResend = true;
939
+ }
940
+ async handleResend() {
941
+ await this.resend();
942
+ this.canResend = false;
943
+ this.pin = ['', '', '', ''];
944
+ localStorage.removeItem("bc:resend");
945
+ }
946
+ buildTime() {
947
+ const resendDate = localStorage.getItem("bc:resend");
948
+ if (resendDate) {
949
+ return resendDate;
950
+ }
951
+ const date = new Date();
952
+ date.setSeconds(date.getSeconds() + 30);
953
+ localStorage.setItem("bc:resend", date.toString());
954
+ return date.toString();
955
+ }
956
+ render() {
957
+ var _a;
958
+ 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() })));
959
+ }
960
+ };
961
+ GiftbackPin.style = PinFormStyle0 + PinFormStyle1;
962
+
963
+ 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 };
964
+
965
+ //# sourceMappingURL=countdown-timer_11.entry.js.map