cloudcommerce 0.34.0 → 0.35.1

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 (191) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/action.yml +11 -3
  3. package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
  4. package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
  5. package/ecomplus-stores/barra-doce/functions/ssr/src/pages/[...slug].astro +1 -1
  6. package/ecomplus-stores/barra-doce/functions/ssr/src/pages/app/account.astro +1 -1
  7. package/ecomplus-stores/barra-doce/functions/ssr/src/pages/app/index.astro +1 -1
  8. package/ecomplus-stores/barra-doce/functions/ssr/src/pages/index.astro +1 -1
  9. package/ecomplus-stores/barra-doce/functions/ssr/src/pages/~fallback.astro +1 -1
  10. package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
  11. package/ecomplus-stores/barra-doce/package.json +2 -2
  12. package/package.json +6 -6
  13. package/packages/api/lib/api.js +1 -1
  14. package/packages/api/lib/api.js.map +1 -1
  15. package/packages/api/package.json +1 -1
  16. package/packages/api/src/api.ts +1 -1
  17. package/packages/apps/affilate-program/package.json +2 -2
  18. package/packages/apps/correios/package.json +2 -2
  19. package/packages/apps/custom-payment/package.json +1 -1
  20. package/packages/apps/custom-shipping/package.json +1 -1
  21. package/packages/apps/datafrete/package.json +2 -2
  22. package/packages/apps/discounts/package.json +1 -1
  23. package/packages/apps/emails/package.json +2 -2
  24. package/packages/apps/fb-conversions/package.json +2 -2
  25. package/packages/apps/flash-courier/package.json +1 -1
  26. package/packages/apps/frenet/package.json +2 -2
  27. package/packages/apps/galaxpay/package.json +2 -2
  28. package/packages/apps/google-analytics/lib/google-analytics-events.js +4 -4
  29. package/packages/apps/google-analytics/lib/google-analytics-events.js.map +1 -1
  30. package/packages/apps/google-analytics/package.json +2 -2
  31. package/packages/apps/google-analytics/src/google-analytics-events.ts +4 -4
  32. package/packages/apps/jadlog/package.json +1 -1
  33. package/packages/apps/loyalty-points/package.json +1 -1
  34. package/packages/apps/mandae/package.json +1 -1
  35. package/packages/apps/melhor-envio/package.json +2 -2
  36. package/packages/apps/mercadopago/package.json +2 -2
  37. package/packages/apps/pagarme/package.json +2 -2
  38. package/packages/apps/pagarme-v5/package.json +2 -2
  39. package/packages/apps/paghiper/package.json +2 -2
  40. package/packages/apps/pix/package.json +2 -2
  41. package/packages/apps/tiny-erp/package.json +2 -2
  42. package/packages/apps/webhooks/package.json +2 -2
  43. package/packages/cli/package.json +4 -1
  44. package/packages/config/package.json +1 -1
  45. package/packages/emails/package.json +1 -1
  46. package/packages/eslint/package.json +1 -1
  47. package/packages/events/package.json +2 -2
  48. package/packages/feeds/package.json +1 -1
  49. package/packages/firebase/package.json +2 -2
  50. package/packages/i18n/package.json +1 -1
  51. package/packages/modules/package.json +2 -2
  52. package/packages/passport/package.json +2 -2
  53. package/packages/ssr/lib/analytics/send-to-ga4.js +44 -0
  54. package/packages/ssr/lib/analytics/send-to-ga4.js.map +1 -0
  55. package/packages/ssr/lib/analytics/send-to-meta.js +44 -0
  56. package/packages/ssr/lib/analytics/send-to-meta.js.map +1 -0
  57. package/packages/ssr/lib/analytics/send-to-tiktok.js +44 -0
  58. package/packages/ssr/lib/analytics/send-to-tiktok.js.map +1 -0
  59. package/packages/ssr/lib/analytics-events.js +52 -24
  60. package/packages/ssr/lib/analytics-events.js.map +1 -1
  61. package/packages/ssr/lib/firebase/serve-storefront.js +16 -3
  62. package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
  63. package/packages/ssr/package.json +6 -5
  64. package/packages/ssr/src/analytics/send-to-ga4.ts +56 -0
  65. package/packages/ssr/src/analytics/send-to-meta.ts +50 -0
  66. package/packages/ssr/src/analytics/send-to-tiktok.ts +49 -0
  67. package/packages/ssr/src/analytics-events.ts +57 -27
  68. package/packages/ssr/src/firebase/serve-storefront.ts +17 -3
  69. package/packages/storefront/dist/client/_astro/AccountPage.700be123.js +1 -0
  70. package/packages/storefront/dist/client/_astro/{CartSidebar.8151e4ee.js → CartSidebar.430b55df.js} +1 -1
  71. package/packages/storefront/dist/client/_astro/HeroSlider.bd684ed8.js +1 -0
  72. package/packages/storefront/dist/client/_astro/PitchBar.06e0f831.js +1 -0
  73. package/packages/storefront/dist/client/_astro/{Prices.311303d8.js → Prices.0e829c31.js} +1 -1
  74. package/packages/storefront/dist/client/_astro/ProductDetails.06da998d.js +1 -0
  75. package/packages/storefront/dist/client/_astro/ProductShelf.3f4f38b5.js +1 -0
  76. package/packages/storefront/dist/client/_astro/ProductShelf.bf82838b.js +1 -0
  77. package/packages/storefront/dist/client/_astro/QuantitySelector.ebf60845.js +1 -0
  78. package/packages/storefront/dist/client/_astro/SearchModal.b6aa5ef7.js +1 -0
  79. package/packages/storefront/dist/client/_astro/ShopHeader.2d6e361a.js +4 -0
  80. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.f75743ee.js +1 -0
  81. package/packages/storefront/dist/client/_astro/_slug_.e7cac999.css +1 -0
  82. package/packages/storefront/dist/client/_astro/client.41b42098.js +1 -0
  83. package/packages/storefront/dist/client/_astro/customer-session.5ab9ab1a.js +1 -0
  84. package/packages/storefront/dist/client/_astro/ecom-utils.5cbfb95e.js +1 -0
  85. package/packages/storefront/dist/client/_astro/{format-money.8962a5ab.js → format-money.9cf6b04d.js} +1 -1
  86. package/packages/storefront/dist/client/_astro/{hoisted.57d8d9d0.js → hoisted.085a62c9.js} +1 -1
  87. package/packages/storefront/dist/client/_astro/hoisted.799e5593.js +1 -0
  88. package/packages/storefront/dist/client/_astro/{i18n.78f362d9.js → i18n.29216eeb.js} +1 -1
  89. package/packages/storefront/dist/client/_astro/{img.bfbd75a8.js → img.4f23a3dd.js} +1 -1
  90. package/packages/storefront/dist/client/_astro/index.570b84fe.js +1 -0
  91. package/packages/storefront/dist/client/_astro/index.8ac1db99.js +1 -0
  92. package/packages/storefront/dist/client/_astro/{modules-info.3c447a07.js → modules-info.55780599.js} +1 -1
  93. package/packages/storefront/dist/client/_astro/name.01410784.js +1 -0
  94. package/packages/storefront/dist/client/_astro/shopping-cart.d9f601dd.js +1 -0
  95. package/packages/storefront/dist/client/_astro/{use-analytics.d0c184ef.js → use-analytics.cc95e346.js} +1 -1
  96. package/packages/storefront/dist/client/_astro/{use-product-card.e0990572.js → use-product-card.437911bb.js} +1 -1
  97. package/packages/storefront/dist/server/chunks/{CartSidebar_03b51b57.mjs → CartSidebar_eab28771.mjs} +1 -1
  98. package/packages/storefront/dist/server/chunks/SearchModal_f66549d4.mjs +147 -0
  99. package/packages/storefront/dist/server/chunks/{_.._4def02ff.mjs → _.._5a781fb3.mjs} +1 -1
  100. package/packages/storefront/dist/server/chunks/{account_2ee873cf.mjs → account_519edb70.mjs} +1 -1
  101. package/packages/storefront/dist/server/chunks/astro/{assets-service_66a9c838.mjs → assets-service_a9d9ab5f.mjs} +58 -10
  102. package/packages/storefront/dist/server/chunks/{astro_8447f017.mjs → astro_d98f7186.mjs} +7 -1
  103. package/packages/storefront/dist/server/chunks/{index_5dcbbe32.mjs → index_10e14f85.mjs} +1 -1
  104. package/packages/storefront/dist/server/chunks/{index_37bacd45.mjs → index_5e3ed8a0.mjs} +1 -1
  105. package/packages/storefront/dist/server/chunks/{node_b3ae36f1.mjs → node_1119b0d1.mjs} +1 -1
  106. package/packages/storefront/dist/server/chunks/pages/{__80fd1c60.mjs → __93ade2dd.mjs} +485 -224
  107. package/packages/storefront/dist/server/chunks/pages/account_e5d410a7.mjs +28 -0
  108. package/packages/storefront/dist/server/chunks/pages/{index_8e1d063c.mjs → index_7e25afc1.mjs} +29 -8
  109. package/packages/storefront/dist/server/chunks/pages/node_bd378ac0.mjs +93 -0
  110. package/packages/storefront/dist/server/chunks/pages/{~fallback_6ff698cd.mjs → ~fallback_73578d2f.mjs} +16 -6
  111. package/packages/storefront/dist/server/chunks/{~fallback_7c4b84d5.mjs → ~fallback_41122b9b.mjs} +1 -1
  112. package/packages/storefront/dist/server/entry.mjs +8 -8
  113. package/packages/storefront/dist/server/{manifest_2019b8a9.mjs → manifest_6bc0c00d.mjs} +2 -2
  114. package/packages/storefront/dist/server/renderers.mjs +5 -3
  115. package/packages/storefront/package.json +8 -8
  116. package/packages/storefront/src/lib/assets/forms.css +35 -30
  117. package/packages/storefront/src/lib/components/Carousel.vue +3 -1
  118. package/packages/storefront/src/lib/components/CarouselControl.vue +1 -1
  119. package/packages/storefront/src/lib/components/Drawer.vue +45 -7
  120. package/packages/storefront/src/lib/components/globals/Fade.vue +1 -1
  121. package/packages/storefront/src/lib/composables/use-product-shelf.ts +1 -1
  122. package/packages/storefront/src/lib/scripts/vbeta-app.ts +25 -15
  123. package/packages/storefront/src/lib/ssr-context.ts +11 -8
  124. package/packages/storefront/src/lib/state/search-engine.ts +101 -0
  125. package/packages/storefront/src/lib/state/shopping-cart.ts +52 -65
  126. package/packages/storefront/src/lib/state/use-analytics.ts +2 -1
  127. package/packages/storefront/src/lib/state/use-storage.ts +5 -2
  128. package/packages/test-base/package.json +1 -1
  129. package/packages/types/package.json +1 -1
  130. package/packages/ssr/lib/analytics-providers/google-analytics.js +0 -48
  131. package/packages/ssr/lib/analytics-providers/google-analytics.js.map +0 -1
  132. package/packages/ssr/lib/analytics-providers/meta-conversions-api.js +0 -44
  133. package/packages/ssr/lib/analytics-providers/meta-conversions-api.js.map +0 -1
  134. package/packages/ssr/src/analytics-providers/google-analytics.ts +0 -67
  135. package/packages/ssr/src/analytics-providers/meta-conversions-api.ts +0 -57
  136. package/packages/storefront/dist/client/_astro/AccountPage.6ead88b1.js +0 -1
  137. package/packages/storefront/dist/client/_astro/HeroSlider.46474cda.js +0 -1
  138. package/packages/storefront/dist/client/_astro/PitchBar.fbca6881.js +0 -1
  139. package/packages/storefront/dist/client/_astro/ProductDetails.d66f9f7e.js +0 -1
  140. package/packages/storefront/dist/client/_astro/ProductShelf.9536b4c1.js +0 -1
  141. package/packages/storefront/dist/client/_astro/QuantitySelector.e74e368a.js +0 -1
  142. package/packages/storefront/dist/client/_astro/SearchModal.83b73e0b.js +0 -1
  143. package/packages/storefront/dist/client/_astro/ShopHeader.06f4d486.js +0 -4
  144. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.dd1a60ce.js +0 -1
  145. package/packages/storefront/dist/client/_astro/_slug_.52cde7a0.css +0 -1
  146. package/packages/storefront/dist/client/_astro/client.7c1b0374.js +0 -1
  147. package/packages/storefront/dist/client/_astro/customer-session.2d173cc1.js +0 -1
  148. package/packages/storefront/dist/client/_astro/ecom-icon_12falx.png +0 -0
  149. package/packages/storefront/dist/client/_astro/ecom-icon_15pqnO.png +0 -0
  150. package/packages/storefront/dist/client/_astro/ecom-icon_t3guw.png +0 -0
  151. package/packages/storefront/dist/client/_astro/ecom-utils.c385a436.js +0 -1
  152. package/packages/storefront/dist/client/_astro/headphone_T2Jjc.avif +0 -0
  153. package/packages/storefront/dist/client/_astro/headphone_Z1CG18r.webp +0 -0
  154. package/packages/storefront/dist/client/_astro/hoisted.f16496bc.js +0 -1
  155. package/packages/storefront/dist/client/_astro/index.e02b88b7.js +0 -1
  156. package/packages/storefront/dist/client/_astro/index.e20e07e3.js +0 -1
  157. package/packages/storefront/dist/client/_astro/logo_1UBsBq.webp +0 -0
  158. package/packages/storefront/dist/client/_astro/logo_Z1K5PE9.png +0 -0
  159. package/packages/storefront/dist/client/_astro/logo_Z1KIIl1.avif +0 -0
  160. package/packages/storefront/dist/client/_astro/name.3cd31c8b.js +0 -1
  161. package/packages/storefront/dist/client/_astro/passion_LHbe9.webp +0 -0
  162. package/packages/storefront/dist/client/_astro/passion_Z23MeUb.avif +0 -0
  163. package/packages/storefront/dist/client/_astro/rect8589_1TtOHY.png +0 -0
  164. package/packages/storefront/dist/client/_astro/rect8589_1f5opX.webp +0 -0
  165. package/packages/storefront/dist/client/_astro/rect8589_IUskt.webp +0 -0
  166. package/packages/storefront/dist/client/_astro/rect8589_Uxfdf.png +0 -0
  167. package/packages/storefront/dist/client/_astro/rect8589_Z15uApA.png +0 -0
  168. package/packages/storefront/dist/client/_astro/rect8589_Z1Ap1Im.avif +0 -0
  169. package/packages/storefront/dist/client/_astro/rect8589_Z1JT1HB.webp +0 -0
  170. package/packages/storefront/dist/client/_astro/rect8589_ZY9mtN.avif +0 -0
  171. package/packages/storefront/dist/client/_astro/rect8589_tMFW0.avif +0 -0
  172. package/packages/storefront/dist/client/_astro/rect859_1TgQXS.avif +0 -0
  173. package/packages/storefront/dist/client/_astro/rect859_2Nm1z.avif +0 -0
  174. package/packages/storefront/dist/client/_astro/rect859_DIqwR.png +0 -0
  175. package/packages/storefront/dist/client/_astro/rect859_Z1IKDb2.png +0 -0
  176. package/packages/storefront/dist/client/_astro/rect859_Z29FI4V.webp +0 -0
  177. package/packages/storefront/dist/client/_astro/rect859_Z2kFHGk.avif +0 -0
  178. package/packages/storefront/dist/client/_astro/rect859_ZkpPFI.webp +0 -0
  179. package/packages/storefront/dist/client/_astro/rect859_jXzBi.png +0 -0
  180. package/packages/storefront/dist/client/_astro/rect859_x1l16.webp +0 -0
  181. package/packages/storefront/dist/client/_astro/rect89_1TSfW7.avif +0 -0
  182. package/packages/storefront/dist/client/_astro/rect89_Z1re32x.webp +0 -0
  183. package/packages/storefront/dist/client/_astro/shopping-cart.6b03b120.js +0 -1
  184. package/packages/storefront/dist/client/~fallback.html +0 -74
  185. package/packages/storefront/dist/client/~index.html +0 -120
  186. package/packages/storefront/dist/server/chunks/SearchModal_2afca4fe.mjs +0 -18
  187. package/packages/storefront/dist/server/chunks/pages/account_bfd9a66a.mjs +0 -21
  188. package/packages/storefront/dist/server/chunks/pages/node_530334cf.mjs +0 -160
  189. package/packages/storefront/dist/server/images.dist.csv +0 -30
  190. package/packages/storefront/dist/server/images.src.csv +0 -11
  191. package/packages/storefront/dist/server/static-builds.csv +0 -66
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "0.34.0",
4
+ "version": "0.35.1",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -34,14 +34,15 @@
34
34
  "astro": "3.6.0",
35
35
  "astro-capo": "^0.0.1",
36
36
  "axios": "^1.6.2",
37
- "firebase-admin": "^11.11.0",
37
+ "firebase-admin": "^11.11.1",
38
38
  "firebase-functions": "^4.5.0",
39
39
  "mitt": "^3.0.1",
40
- "vue": "^3.3.8"
40
+ "vue": "^3.3.9"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@cloudcommerce/types": "workspace:*",
44
- "@cloudflare/workers-types": "^4.20231025.0",
45
- "@firebase/app-types": "^0.9.0"
44
+ "@cloudflare/workers-types": "^4.20231121.0",
45
+ "@firebase/app-types": "^0.9.0",
46
+ "typescript": "~5.2.2"
46
47
  }
47
48
  }
@@ -0,0 +1,56 @@
1
+ import type { AnalyticsEvent } from '../analytics-events';
2
+ import axios from 'axios';
3
+
4
+ const ga4Axios = axios.create({
5
+ baseURL: 'https://www.google-analytics.com',
6
+ headers: {
7
+ 'Content-Type': 'application/json',
8
+ },
9
+ });
10
+ const endpoint = '/mp/collect'
11
+ + `?api_secret=${process.env.GA_API_SECRET}`
12
+ + `&measurement_id=${process.env.GA_MEASUREMENT_ID}`;
13
+
14
+ const sendToGa4 = async (
15
+ events: AnalyticsEvent[],
16
+ clientId: string,
17
+ sessionId: string,
18
+ utm: {
19
+ source?: string,
20
+ medium?: string,
21
+ campaign?: string,
22
+ term?: string,
23
+ content?: string
24
+ } = {},
25
+ ) => {
26
+ if (process.env.GA_API_SECRET && process.env.GA_MEASUREMENT_ID) {
27
+ const data = {
28
+ client_id: clientId,
29
+ events: [] as AnalyticsEvent[],
30
+ };
31
+ for (let i = 0; i < events.length; i++) {
32
+ const event = events[i];
33
+ if (event.name === 'page_view') {
34
+ event.name = 'campaign_details';
35
+ event.params = {
36
+ source: utm.source,
37
+ medium: utm.medium,
38
+ campaign: utm.campaign,
39
+ term: utm.term,
40
+ content: utm.content,
41
+ session_id: sessionId,
42
+ };
43
+ } else if (event.params) {
44
+ Object.assign(event.params, { session_id: sessionId });
45
+ }
46
+ data.events.push(event);
47
+ if (data.events.length === 25 || i === events.length - 1) {
48
+ // eslint-disable-next-line no-await-in-loop
49
+ await ga4Axios.post(endpoint, data);
50
+ data.events = [];
51
+ }
52
+ }
53
+ }
54
+ };
55
+
56
+ export default sendToGa4;
@@ -0,0 +1,50 @@
1
+ import type { AnalyticsEvent } from '../analytics-events';
2
+ import axios from 'axios';
3
+
4
+ // https://developers.facebook.com/docs/meta-pixel/reference#standard-events
5
+ const version = 'v18.0';
6
+ const metaAxios = axios.create({
7
+ baseURL: `https://graph.facebook.com/${version}`,
8
+ headers: {
9
+ 'Content-Type': 'application/json',
10
+ },
11
+ });
12
+ const endpoint = `/${process.env.FB_PIXEL_ID}/events`
13
+ + `?access_token=${process.env.FB_GRAPH_TOKEN}`;
14
+
15
+ const sendToMeta = async (
16
+ events: AnalyticsEvent[],
17
+ pageLocation: string,
18
+ userData: { [x: string]: string | undefined },
19
+ pageTitle?: string,
20
+ ) => {
21
+ if (process.env.FB_PIXEL_ID && process.env.FB_GRAPH_TOKEN) {
22
+ let data: Array<Record<string, any>> = [];
23
+ for (let i = 0; i < events.length; i++) {
24
+ const event = events[i];
25
+ if (event.name === 'PageView') {
26
+ event.name = 'Lead';
27
+ if (pageTitle) {
28
+ event.params = {
29
+ content_name: pageTitle,
30
+ };
31
+ }
32
+ }
33
+ data.push({
34
+ event_name: event.name,
35
+ event_time: Date.now(),
36
+ event_source_url: pageLocation,
37
+ action_source: 'website',
38
+ user_data: userData,
39
+ custom_data: event.params,
40
+ });
41
+ if (data.length === 999 || i === events.length - 1) {
42
+ // eslint-disable-next-line no-await-in-loop
43
+ await metaAxios.post(endpoint, { data });
44
+ data = [];
45
+ }
46
+ }
47
+ }
48
+ };
49
+
50
+ export default sendToMeta;
@@ -0,0 +1,49 @@
1
+ import type { AnalyticsEvent } from '../analytics-events';
2
+ import axios from 'axios';
3
+
4
+ // https://business-api.tiktok.com/portal/docs?id=1741601162187777
5
+ // https://business-api.tiktok.com/portal/docs?rid=oyn7lhbo6ar&id=1771100799076354
6
+ const version = 'v1.3';
7
+ const ttkAxios = axios.create({
8
+ baseURL: `https://business-api.tiktok.com/open_api/${version}/event/track`,
9
+ headers: {
10
+ 'Content-Type': 'application/json',
11
+ 'Access-Token': process.env.TIKTOK_ACCESS_TOKEN,
12
+ },
13
+ });
14
+
15
+ const sendToTiktok = async (
16
+ events: AnalyticsEvent[],
17
+ pageLocation: string,
18
+ user: { [x: string]: string | undefined },
19
+ ) => {
20
+ if (process.env.TIKTOK_ACCESS_TOKEN && process.env.TIKTOK_PIXEL_ID) {
21
+ let data: Array<Record<string, any>> = [];
22
+ for (let i = 0; i < events.length; i++) {
23
+ const event = events[i];
24
+ if (event.name === 'PageView') {
25
+ event.name = 'Contact';
26
+ }
27
+ data.push({
28
+ event: event.name,
29
+ event_time: Date.now(),
30
+ user,
31
+ page: {
32
+ url: pageLocation,
33
+ },
34
+ properties: event.params,
35
+ });
36
+ if (data.length === 999 || i === events.length - 1) {
37
+ // eslint-disable-next-line no-await-in-loop
38
+ await ttkAxios.post('/', {
39
+ event_source: 'web',
40
+ event_source_id: process.env.TIKTOK_PIXEL_ID,
41
+ data,
42
+ });
43
+ data = [];
44
+ }
45
+ }
46
+ }
47
+ };
48
+
49
+ export default sendToTiktok;
@@ -1,7 +1,9 @@
1
- import type { AxiosResponse } from 'axios';
2
1
  import { EventEmitter } from 'node:events';
3
- import ga4Events from './analytics-providers/google-analytics';
4
- import metaEvents from './analytics-providers/meta-conversions-api';
2
+ import { warn, error } from 'firebase-functions/logger';
3
+ import { getFirestore, Timestamp, FieldValue } from 'firebase-admin/firestore';
4
+ import sendToGa4 from './analytics/send-to-ga4';
5
+ import sendToMeta from './analytics/send-to-meta';
6
+ import sendToTiktok from './analytics/send-to-tiktok';
5
7
 
6
8
  const analyticsEmitter = new EventEmitter();
7
9
 
@@ -12,7 +14,7 @@ export type AnalyticsEvent = {
12
14
 
13
15
  export type GroupedAnalyticsEvents = Array<AnalyticsEvent & { type: string }>;
14
16
 
15
- const sendAnalyticsEvents = (
17
+ const sendAnalyticsEvents = async (
16
18
  { url, events }: { url: string, events: GroupedAnalyticsEvents },
17
19
  payload: Record<string, any> = {},
18
20
  ) => {
@@ -24,38 +26,66 @@ const sendAnalyticsEvents = (
24
26
  }
25
27
  (eventsByType[type] as AnalyticsEvent[]).push({ name, params });
26
28
  });
27
-
28
- const sendingEvents: Promise<AxiosResponse<any, any>>[] = [];
29
- if (eventsByType.gtag) {
29
+ const sendingEvents: Promise<any>[] = [];
30
+ const storingEvents: Promise<any>[] = [];
31
+ const {
32
+ gtag: gaEvents,
33
+ fbq: metaEvents,
34
+ ttq: tiktokEvents,
35
+ } = eventsByType;
36
+ if (gaEvents) {
37
+ const pageView = gaEvents.find(({ name }) => {
38
+ return name === 'page_view';
39
+ });
40
+ const productView = gaEvents.find(({ name, params }) => {
41
+ return name === 'view_item' && params?.item_list_id === 'product-page';
42
+ });
43
+ if (pageView || productView) {
44
+ const db = getFirestore();
45
+ if (pageView && url) {
46
+ const storing = db.collection('ssrPageViews')
47
+ .add({ url, at: Timestamp.now() });
48
+ storingEvents.push(storing);
49
+ }
50
+ const productId = productView?.params?.object_id;
51
+ if (productId) {
52
+ const storing = db.doc(`ssrProductViews/${productId}`)
53
+ .set({ countUnsaved: FieldValue.increment(1) }, { merge: true });
54
+ storingEvents.push(storing);
55
+ }
56
+ }
30
57
  const sessionId = payload.g_session_id || payload.session_id;
31
58
  const clientId = payload.g_client_id || payload.client_id;
32
- const listGA4Events = ga4Events(eventsByType.gtag, clientId, sessionId, payload.utm);
33
- if (listGA4Events) {
34
- sendingEvents.push(...listGA4Events);
35
- }
59
+ sendingEvents.push(sendToGa4(gaEvents, clientId, sessionId, payload.utm));
36
60
  }
37
- if (eventsByType.fbq) {
61
+ if (metaEvents) {
38
62
  const userData = {
39
- client_ip_address: payload.id,
63
+ client_ip_address: payload.ip,
40
64
  client_user_agent: payload.user_agent,
41
65
  fbc: payload.fbclid,
42
66
  fbp: payload.fbp,
43
67
  };
44
- const listMetaEvents = metaEvents(eventsByType.fbq, payload.page_location, userData);
45
- if (listMetaEvents) {
46
- sendingEvents.push(...listMetaEvents);
47
- }
68
+ sendingEvents.push(sendToMeta(metaEvents, url, userData, payload.page_title));
69
+ }
70
+ if (tiktokEvents) {
71
+ const userData = {
72
+ ip: payload.ip,
73
+ user_agent: payload.user_agent,
74
+ ttclid: payload.ttclid,
75
+ };
76
+ sendingEvents.push(sendToTiktok(tiktokEvents, url, userData));
48
77
  }
49
- /* @TODO:
50
- - Get credentials from env vars, e.g. `process.env.GA_MEASUREMENT_ID`;
51
- - May receive multiple events in a unique request, and dispatch multiple
52
- events in one POST if possible;
53
- - Consider Google Click ID (`?gclid=`), Facebook Click ID (`?fbclid=`)
54
- and maybe TikTok one from payload;
55
- - Send the events in parallel for all APIs with `Promise.all(sendingEvents)`;
56
- - No CORS!
57
- */
58
- Promise.all(sendingEvents);
78
+ await Promise.all([
79
+ Promise.allSettled(sendingEvents).then((results) => {
80
+ for (let i = 0; i < results.length; i++) {
81
+ const { status } = results[i];
82
+ if (status === 'rejected') {
83
+ warn((results[i] as PromiseRejectedResult).reason);
84
+ }
85
+ }
86
+ }),
87
+ Promise.all(storingEvents).catch(error),
88
+ ]);
59
89
  };
60
90
 
61
91
  export default sendAnalyticsEvents;
@@ -18,7 +18,8 @@ declare global {
18
18
 
19
19
  const { STOREFRONT_BASE_DIR } = process.env;
20
20
  const baseDir = STOREFRONT_BASE_DIR || process.cwd();
21
- const { assetsPrefix } = config.get().settingsContent;
21
+ const { settingsContent } = config.get();
22
+ const { assetsPrefix } = settingsContent;
22
23
  let imagesManifest: string;
23
24
  type BuiltImage = { filename: string, width: number, height: number };
24
25
  const builtImages: BuiltImage[] = [];
@@ -153,6 +154,17 @@ export default async (req: Request, res: Response) => {
153
154
  }
154
155
  }
155
156
 
157
+ if (req.path === '/_logo' || req.path === '/_icon') {
158
+ const field = req.path.slice(2) as 'logo' | 'icon';
159
+ res.set('Cache-Control', 'max-age=300');
160
+ if (settingsContent[field]) {
161
+ res.redirect(302, settingsContent[field]);
162
+ } else {
163
+ res.sendStatus(404);
164
+ }
165
+ return;
166
+ }
167
+
156
168
  if (req.path === '/_image') {
157
169
  const { href } = req.query;
158
170
  if (typeof href === 'string' && href.length > 3) {
@@ -183,7 +195,9 @@ export default async (req: Request, res: Response) => {
183
195
  && filename === _builtImage.filename.replace(filenameRegExp, '');
184
196
  });
185
197
  if (builtImage) {
186
- return res.redirect(301, `/_astro/${builtImage.filename}`);
198
+ return res
199
+ .set('Cache-Control', 'max-age=60')
200
+ .redirect(301, `/_astro/${builtImage.filename}`);
187
201
  }
188
202
  return res.redirect(302, href);
189
203
  })();
@@ -220,7 +234,7 @@ export default async (req: Request, res: Response) => {
220
234
  res.send('Event(s) must be sent via the `{ events }` array in the request body');
221
235
  return;
222
236
  }
223
- sendAnalyticsEvents({ url, events }, { ...req.body, ip: req.ip });
237
+ await sendAnalyticsEvents({ url, events }, { ...req.body, ip: req.ip });
224
238
  res.sendStatus(204);
225
239
  return;
226
240
  }
@@ -0,0 +1 @@
1
+ import{e as M,f as _,E as T,b as V,i as A}from"./customer-session.5ab9ab1a.js";import{_ as P,a as I,v as R,w as k}from"./_plugin-vue_export-helper.f75743ee.js";import{u as j}from"./index.570b84fe.js";import{g as B,b as O,c as q}from"./index-61e5ac61.bdc8d0cd.js";import{b as D}from"./index.8ac1db99.js";import{a as f,w as h,d as C,c as z,L as F,M as l,N as c,Y as N,O as i,V as S,T as r,U as b,X as L,W as E,P as x,Q as U,a1 as W,a2 as Y,R as G,S as K}from"./ecom-utils.5cbfb95e.js";import"./sf-utils.b04e1813.js";const Q=m=>{M();const s=m?.canUseUrlParams!==!1?j("history"):{},e=s.sign_up!==void 0&&s.sign_up!=="0",a=s.password!==void 0&&s.password!=="0",u=f(e),n=f(!e&&!a);h(u,p=>{p?(n.value=!0,s.sign_up="1"):s.sign_up="0"}),h(n,p=>{s.password=p?"0":"1"});const o=f(""),d=f(!1),g=D(async p=>{d.value=!0;const v=Date.now(),y=B();if(_.value){window.localStorage.setItem(T,_.value);try{if(n.value){const w=new URL(p||window.location.toString());w.searchParams.append("email",_.value),await O(y,_.value,{url:w.toString(),handleCodeInApp:!0})}else await q(y,_.value,o.value)}catch(w){console.warn(w.code),console.error(w)}setTimeout(()=>{d.value=!1},Math.min(2e3-(Date.now()-v),1))}},2e3);return{isLinkSignIn:n,isSignUp:u,email:_,password:o,isSubmitting:d,submitLogin:g}},X=C({__name:"LoginForm",props:{loginLinkActionUrl:{}},setup(m,{expose:t}){t();const{isLinkSignIn:s,isSignUp:e,email:a,password:u,isSubmitting:n,submitLogin:o}=Q(),d=f(!1),g=f(0),p=z(()=>g.value>9);h(n,()=>{!n.value&&s.value&&(d.value=!0,g.value+=1)}),h([a,e],()=>{d.value=!1}),h(p,()=>{s.value=!1});const v={isLinkSignIn:s,isSignUp:e,email:a,password:u,isSubmitting:n,submitLogin:o,isEmailSentMsg:d,countEmailsSent:g,isLinkSignInBlocked:p,get customerName(){return V}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),$={class:"text-base-600 mb-4 text-2xl font-light"},H={key:0},J={key:1,class:"lowercase"},Z={key:0,for:"login-form-email"},ee={class:"relative"},se=["disabled"],te={key:0,class:"text-success-800 absolute left-0 top-0 mt-4 font-medium"},ne=i("i",{class:"i-check mr-1"},null,-1);function ie(m,t,s,e,a,u){const n=F("Fade");return l(),c("form",{class:"text-base-800 w-full max-w-sm bg-white p-6 text-base md:p-8",onSubmit:t[4]||(t[4]=k(()=>e.submitLogin(s.loginLinkActionUrl),["prevent"]))},[N(m.$slots,"head"),i("p",$,[S(r("Olá")+" "),e.customerName?(l(),c("span",H,r(e.customerName),1)):(l(),c("span",J,r("Visitante")))]),e.isLinkSignIn?(l(),c("label",Z,r("Enviar link de acesso por e-mail"))):b("",!0),L(i("input",{id:"login-form-email",type:"email",placeholder:"email@mail.com","onUpdate:modelValue":t[0]||(t[0]=o=>e.email=o),class:"mb-0.5 mt-2 w-full",required:""},null,512),[[I,e.email]]),e.isLinkSignIn?b("",!0):L((l(),c("input",{key:1,type:"password",placeholder:"Senha","onUpdate:modelValue":t[1]||(t[1]=o=>e.password=o),class:"mb-0.5 mt-2 w-full lowercase",required:""},null,512)),[[I,e.password]]),i("div",ee,[i("div",{class:E(["transition-opacity",e.isEmailSentMsg&&"opacity-0 invisible"])},[L(i("a",{href:"?password",class:"ui-link text-base-500 text-right text-sm lowercase",onClick:t[2]||(t[2]=k(o=>e.isLinkSignIn=!e.isLinkSignIn,["prevent"]))},r(e.isLinkSignIn?"Entrar com senha":"Esqueci minha senha"),513),[[R,!e.isSignUp&&!e.isLinkSignInBlocked]]),i("button",{type:"submit",disabled:e.isSubmitting,class:E(["ui-btn-lg ui-btn-primary mb-2 mt-5 w-full",e.isSubmitting&&"opacity-50"])},r(e.isSignUp?"Cadastrar":"Acessar minha conta"),11,se)],2),x(n,{speed:"slow"},{default:U(()=>[e.isEmailSentMsg?(l(),c("p",te,[ne,S(" "+r("Te enviamos o e-mail, verifique sua caixa de entrada e spam se necessário."),1)])):b("",!0)]),_:1}),i("a",{href:"?sign_up",class:"ui-btn-lg ui-btn-contrast block w-full text-center",onClick:t[3]||(t[3]=k(o=>e.isSignUp=!e.isSignUp,["prevent"]))},r(e.isSignUp?"Acessar minha conta":"Criar uma conta"),1)])],32)}const ae=P(X,[["render",ie]]),oe=C({__name:"AccountPage",setup(m,{expose:t}){t();let s=null;{const{location:a}=window,u=new URLSearchParams(a.search).get("return_url");if(!u){const n=new URL(a.toString());n.pathname="/app/",n.hash=`#${a.pathname.replace("/app/","/")}`,s=n.toString()}h(A,()=>{A.value&&(a.href=u||s)},{immediate:!0})}const e={get loginLinkActionUrl(){return s},set loginLinkActionUrl(a){s=a},LoginForm:ae};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}}),re={class:"from-secondary-700 to-secondary-950 flex min-h-screen w-full flex-col justify-center bg-gradient-to-br"},le={class:"mx-auto p-4"},ce=i("section",{class:"ui-section text-center"},[i("a",{href:"/",class:"text-base-200 hover:text-white"},[i("i",{class:"i-arrow-right mr-1 rotate-180"}),S(" "+r("Ir para a loja"))])],-1),me={class:"overflow-hidden rounded-md shadow-md ring-4 ring-black/10"},ue={class:"mb-5 text-center"},de={href:"/",class:"inline-block"},pe={key:0,class:"ui-section px-0"},ge={class:"mx-auto flex max-w-sm flex-wrap items-center justify-evenly gap-4 px-3"};function _e(m,t,s,e,a,u){const n=F("ALink");return l(),c("article",re,[i("div",le,[ce,i("section",me,[x(e.LoginForm,W(Y({loginLinkActionUrl:e.loginLinkActionUrl})),{head:U(()=>[i("div",ue,[i("a",de,[N(m.$slots,"logo")])])]),_:3},16)]),m.$settings.serviceLinks?.length?(l(),c("nav",pe,[i("ul",ge,[(l(!0),c(G,null,K(m.$settings.serviceLinks,({title:o,href:d},g)=>(l(),c("li",{key:`s-${g}`},[x(n,{href:d,class:"ui-link text-base-200 hover:text-white"},{default:U(()=>[S(r(o),1)]),_:2},1032,["href"])]))),128))])])):b("",!0)])])}const Le=P(oe,[["render",_e]]);export{Le as default};
@@ -1 +1 @@
1
- import{_ as b,w as x}from"./_plugin-vue_export-helper.dd1a60ce.js";import{f as C}from"./modules-info.3c447a07.js";import{p as I,r as S,s as w,t as V}from"./shopping-cart.6b03b120.js";import{Q as F,C as P}from"./QuantitySelector.e74e368a.js";import{P as v}from"./Prices.311303d8.js";import{c as p,J as y,K as f,f as i,h as m,Q as d,R as k,X as j,M as h,N as t,L as o,O as g,U as L,V as N}from"./ecom-utils.c385a436.js";import{g as z}from"./name.3cd31c8b.js";import{g as A}from"./img.bfbd75a8.js";import"./afetch.f4507208.js";import"./sf-utils.b04e1813.js";import"./format-money.8962a5ab.js";import"./price.04ceb6c4.js";import"./customer-session.2d173cc1.js";import"./index.e20e07e3.js";import"./i18n.78f362d9.js";const q=a=>{const s=p(()=>!a.item&&a.product?I(a.product):null),r=p(()=>a.item||s.value),e=p(()=>z(r.value)),n=p(()=>{const{slug:l}=r.value;return typeof l=="string"?`/${l}`:null}),u=p(()=>{if(r.value.picture)return A(r.value.picture,void 0,a.pictureSize||"small")}),c=p(()=>r.value.final_price||r.value.price);return{cartItem:r,title:e,link:n,image:u,finalPrice:c}},B=y({__name:"CartItem",props:{item:{},product:{},pictureSize:{}},setup(a,{expose:s}){s();const r=a,{cartItem:e,title:n,link:u,image:c,finalPrice:l}=q(r),_={props:r,cartItem:e,title:n,link:u,image:c,finalPrice:l,get removeCartItem(){return S},QuantitySelector:F,Prices:v};return Object.defineProperty(_,"__isScriptSetup",{enumerable:!1,value:!0}),_}}),Q={class:"relative bg-white shadow-sm"},E={class:"text-base-700 group-hover:text-base-900 flex-auto py-2 text-sm group-hover:underline"},M=t("span",{class:"border-3 text-danger-800 border-danger-700/30 flex h-5 w-5 flex-col justify-center rounded-full text-sm leading-none"},[t("i",{class:"i-close mx-auto my-0"})],-1),O=[M],R={class:"border-base-100 flex items-center justify-between border-t-2"},U={class:"border-base-100 border-r-2"};function D(a,s,r,e,n,u){const c=f("AImg"),l=f("ALink");return i(),m("article",Q,[d(l,{href:e.link,class:"group flex items-center gap-5 p-4"},{default:k(()=>[e.image?(i(),j(c,{key:0,picture:e.image,alt:e.title,class:"h-20 w-20 object-cover"},null,8,["picture","alt"])):h("",!0),t("p",E,o(e.title),1)]),_:1},8,["href"]),e.cartItem._id?(i(),m("button",{key:0,onClick:s[0]||(s[0]=x(_=>e.removeCartItem(e.cartItem._id),["stop"])),class:"absolute right-0 top-0 p-2 opacity-70 hover:opacity-100","aria-label":"Remover"},O)):h("",!0),t("div",R,[t("div",U,[d(e.QuantitySelector,{modelValue:e.cartItem.quantity,"onUpdate:modelValue":s[1]||(s[1]=_=>e.cartItem.quantity=_),min:e.cartItem.min_quantity,max:e.cartItem.max_quantity},null,8,["modelValue","min","max"])]),d(e.Prices,{"base-price":e.cartItem.base_price,price:e.finalPrice,"has-cashback":!1,"has-price-options":!1,class:"px-4 py-2.5 text-right text-[95%]"},null,8,["base-price","price"])])])}const J=b(B,[["render",D]]),K=y({__name:"CartSidebar",emits:["close"],setup(a,{expose:s,emit:r}){s();const n={emit:r,get freeShippingFromValue(){return C},get shoppingCart(){return w},get totalItems(){return V},CheckoutLink:P,Prices:v,CartItem:J};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),T={class:"flex h-screen flex-col bg-white"},X={class:"z-10 flex items-center justify-end gap-3 px-6 py-4 shadow ring-1 ring-black/5"},G=t("span",{class:"text-base-600 text-right text-base font-medium"},o("Meu carrinho de compras"),-1),H={class:"min-w-[3rem] text-right"},W={class:"ui-badge-pill-lg"},Y={class:"bg-base-50 grow overflow-y-auto"},Z={key:0,class:"text-center text-sm"},$={key:0,class:"secondary-subtle p-3"},ee=t("strong",{class:"lowercase"},o("Frete grátis"),-1),te={key:1,class:"bg-success-50 text-success-800 p-3"},re=t("i",{class:"text-success-900 i-check mr-1"},null,-1),se={class:"px-4 pb-2 pt-4"},ae={class:"z-10 px-5 pb-3 pt-4 ring-2 ring-black/5"},oe={class:"grid grid-cols-5 items-center gap-3 text-right"},ie=t("div",{class:"col-span-2"},o("Subtotal"),-1),ne=t("i",{class:"i-check mr-2"},null,-1),ce=t("i",{class:"i-arrow-right mr-1 rotate-180"},null,-1);function le(a,s,r,e,n,u){return i(),m("aside",T,[t("header",X,[G,t("span",H,[t("span",W,o(e.totalItems),1)])]),t("article",Y,[e.freeShippingFromValue?(i(),m("div",Z,[e.freeShippingFromValue>e.shoppingCart.subtotal?(i(),m("div",$,[g(o("Adicione $1 para ganhar".replace("$1",a.$money(e.freeShippingFromValue-e.shoppingCart.subtotal)))+" ",1),ee])):(i(),m("div",te,[re,g(" "+o("Frete grátis a partir de")+" "+o(a.$money(e.freeShippingFromValue)),1)]))])):h("",!0),t("ul",se,[(i(!0),m(L,null,N(e.shoppingCart.items,(c,l)=>(i(),m("li",{key:l},[d(e.CartItem,{item:c,class:"mb-3"},null,8,["item"])]))),128))])]),t("footer",ae,[t("div",oe,[ie,d(e.Prices,{price:e.shoppingCart.subtotal,class:"col-span-3 text-lg"},null,8,["price"])]),d(e.CheckoutLink,{to:"checkout",class:"ui-btn-lg ui-btn-primary my-2.5 w-full text-right"},{default:k(()=>[ne,g(" "+o("Finalizar compra"))]),_:1}),t("a",{href:"#",onClick:s[0]||(s[0]=x(c=>e.emit("close"),["prevent"])),class:"ui-link text-base-500 hover:text-base-700 text-sm"},[ce,g(" "+o("Continuar comprando"))])])])}const Se=b(K,[["render",le]]);export{Se as default};
1
+ import{_ as b,w as x}from"./_plugin-vue_export-helper.f75743ee.js";import{f as C}from"./modules-info.55780599.js";import{p as I,r as S,s as w,t as V}from"./shopping-cart.d9f601dd.js";import{Q as P,C as F}from"./QuantitySelector.ebf60845.js";import{P as v}from"./Prices.0e829c31.js";import{c as p,d as y,L as f,M as i,N as m,P as d,Q as k,Z as j,U as h,O as t,T as o,V as g,R as L,S as N}from"./ecom-utils.5cbfb95e.js";import{g as z}from"./name.01410784.js";import{g as A}from"./img.4f23a3dd.js";import"./afetch.f4507208.js";import"./sf-utils.b04e1813.js";import"./format-money.9cf6b04d.js";import"./price.04ceb6c4.js";import"./customer-session.5ab9ab1a.js";import"./index.8ac1db99.js";import"./i18n.29216eeb.js";const q=a=>{const s=p(()=>!a.item&&a.product?I(a.product):null),r=p(()=>a.item||s.value),e=p(()=>z(r.value)),n=p(()=>{const{slug:l}=r.value;return typeof l=="string"?`/${l}`:null}),u=p(()=>{if(r.value.picture)return A(r.value.picture,void 0,a.pictureSize||"small")}),c=p(()=>r.value.final_price||r.value.price);return{cartItem:r,title:e,link:n,image:u,finalPrice:c}},B=y({__name:"CartItem",props:{item:{},product:{},pictureSize:{}},setup(a,{expose:s}){s();const r=a,{cartItem:e,title:n,link:u,image:c,finalPrice:l}=q(r),_={props:r,cartItem:e,title:n,link:u,image:c,finalPrice:l,get removeCartItem(){return S},QuantitySelector:P,Prices:v};return Object.defineProperty(_,"__isScriptSetup",{enumerable:!1,value:!0}),_}}),Q={class:"relative bg-white shadow-sm"},E={class:"text-base-700 group-hover:text-base-900 flex-auto py-2 text-sm group-hover:underline"},M=t("span",{class:"border-3 text-danger-800 border-danger-700/30 flex h-5 w-5 flex-col justify-center rounded-full text-sm leading-none"},[t("i",{class:"i-close mx-auto my-0"})],-1),O=[M],R={class:"border-base-100 flex items-center justify-between border-t-2"},T={class:"border-base-100 border-r-2"};function U(a,s,r,e,n,u){const c=f("AImg"),l=f("ALink");return i(),m("article",Q,[d(l,{href:e.link,class:"group flex items-center gap-5 p-4"},{default:k(()=>[e.image?(i(),j(c,{key:0,picture:e.image,alt:e.title,class:"h-20 w-20 object-cover"},null,8,["picture","alt"])):h("",!0),t("p",E,o(e.title),1)]),_:1},8,["href"]),e.cartItem._id?(i(),m("button",{key:0,onClick:s[0]||(s[0]=x(_=>e.removeCartItem(e.cartItem._id),["stop"])),class:"absolute right-0 top-0 p-2 opacity-70 hover:opacity-100","aria-label":"Remover"},O)):h("",!0),t("div",R,[t("div",T,[d(e.QuantitySelector,{modelValue:e.cartItem.quantity,"onUpdate:modelValue":s[1]||(s[1]=_=>e.cartItem.quantity=_),min:e.cartItem.min_quantity,max:e.cartItem.max_quantity},null,8,["modelValue","min","max"])]),d(e.Prices,{"base-price":e.cartItem.base_price,price:e.finalPrice,"has-cashback":!1,"has-price-options":!1,class:"px-4 py-2.5 text-right text-[95%]"},null,8,["base-price","price"])])])}const D=b(B,[["render",U]]),Z=y({__name:"CartSidebar",emits:["close"],setup(a,{expose:s,emit:r}){s();const n={emit:r,get freeShippingFromValue(){return C},get shoppingCart(){return w},get totalItems(){return V},CheckoutLink:F,Prices:v,CartItem:D};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),G={class:"flex h-screen flex-col bg-white"},H={class:"z-10 flex items-center justify-end gap-3 px-6 py-4 shadow ring-1 ring-black/5"},J=t("span",{class:"text-base-600 text-right text-base font-medium"},o("Meu carrinho de compras"),-1),K={class:"min-w-[3rem] text-right"},W={class:"ui-badge-pill-lg"},X={class:"bg-base-50 grow overflow-y-auto"},Y={key:0,class:"text-center text-sm"},$={key:0,class:"secondary-subtle p-3"},ee=t("strong",{class:"lowercase"},o("Frete grátis"),-1),te={key:1,class:"bg-success-50 text-success-800 p-3"},re=t("i",{class:"text-success-900 i-check mr-1"},null,-1),se={class:"px-4 pb-2 pt-4"},ae={class:"z-10 px-5 pb-3 pt-4 ring-2 ring-black/5"},oe={class:"grid grid-cols-5 items-center gap-3 text-right"},ie=t("div",{class:"col-span-2"},o("Subtotal"),-1),ne=t("i",{class:"i-check mr-2"},null,-1),ce=t("i",{class:"i-arrow-right mr-1 rotate-180"},null,-1);function le(a,s,r,e,n,u){return i(),m("aside",G,[t("header",H,[J,t("span",K,[t("span",W,o(e.totalItems),1)])]),t("article",X,[e.freeShippingFromValue?(i(),m("div",Y,[e.freeShippingFromValue>e.shoppingCart.subtotal?(i(),m("div",$,[g(o("Adicione $1 para ganhar".replace("$1",a.$money(e.freeShippingFromValue-e.shoppingCart.subtotal)))+" ",1),ee])):(i(),m("div",te,[re,g(" "+o("Frete grátis a partir de")+" "+o(a.$money(e.freeShippingFromValue)),1)]))])):h("",!0),t("ul",se,[(i(!0),m(L,null,N(e.shoppingCart.items,(c,l)=>(i(),m("li",{key:l},[d(e.CartItem,{item:c,class:"mb-3"},null,8,["item"])]))),128))])]),t("footer",ae,[t("div",oe,[ie,d(e.Prices,{price:e.shoppingCart.subtotal,class:"col-span-3 text-lg"},null,8,["price"])]),d(e.CheckoutLink,{to:"checkout",class:"ui-btn-lg ui-btn-primary my-2.5 w-full text-right"},{default:k(()=>[ne,g(" "+o("Finalizar compra"))]),_:1}),t("a",{href:"#",onClick:s[0]||(s[0]=x(c=>e.emit("close"),["prevent"])),class:"ui-link text-base-500 hover:text-base-700 text-sm"},[ce,g(" "+o("Continuar comprando"))])])])}const Se=b(Z,[["render",le]]);export{Se as default};
@@ -0,0 +1 @@
1
+ import{_ as w,v as B}from"./_plugin-vue_export-helper.f75743ee.js";import{p as f}from"./modules-info.55780599.js";import{c as d,d as T,L as x,M as r,N as l,P as c,Q as o,Y as S,W as b,Z as v,V as y,T as g,$ as C,U as m,a as H,o as L,X as N,O as _,R as P,S as V,a0 as j}from"./ecom-utils.5cbfb95e.js";import"./afetch.f4507208.js";import"./sf-utils.b04e1813.js";import"./format-money.9cf6b04d.js";import"./price.04ceb6c4.js";const M=s=>{const a=d(()=>s.title?f(s.title).value:""),t=d(()=>s.subtitle?f(s.subtitle).value:""),e=d(()=>s.buttonText?f(s.buttonText).value:""),i=d(()=>!!(a.value||t.value||e.value));return{parsedTitle:a,parsedSubtitle:t,parsedButtonText:e,hasHeader:i}},D=T({__name:"Banner",props:{img:{},alt:{},mobileImg:{},href:{},title:{},subtitle:{},buttonLink:{},buttonText:{},headingTag:{default:"h3"}},setup(s,{expose:a}){a();const t=s,{hasHeader:e,parsedTitle:i,parsedSubtitle:p,parsedButtonText:n}=M(t),u={props:t,hasHeader:e,parsedTitle:i,parsedSubtitle:p,parsedButtonText:n};return Object.defineProperty(u,"__isScriptSetup",{enumerable:!1,value:!0}),u}}),O={key:0,class:"mb-3 p-12 sm:mb-0 xl:ps-32"},z={key:1,class:"mt-4 text-lg md:mt-6"};function A(s,a,t,e,i,p){const n=x("ALink");return r(),l("div",{class:b(["mx-auto overflow-x-hidden",e.hasHeader?"grid grid-cols-1 sm:grid-cols-2 items-center":null])},[c(n,{href:t.href,class:b(e.hasHeader?"sm:order-last [&_img]:max-w-full sm:[&_img]:max-w-none [&_img]:aspect-video sm:[&_img]:aspect-[2.5] [&_img]:object-cover":"[&_img]:max-w-full")},{default:o(()=>[S(s.$slots,"picture")]),_:3},8,["href","class"]),e.hasHeader?(r(),l("div",O,[e.parsedTitle?(r(),v(C(t.headingTag),{key:0,class:"ui-title mt-1"},{default:o(()=>[y(g(e.parsedTitle),1)]),_:1})):m("",!0),e.parsedSubtitle?(r(),l("p",z,g(e.parsedSubtitle),1)):m("",!0),e.parsedButtonText?(r(),v(n,{key:2,href:t.buttonLink,class:"ui-btn-lg ui-btn-contrast mt-7 min-w-[150px] md:mt-10"},{default:o(()=>[y(g(e.parsedButtonText),1)]),_:1},8,["href"])):m("",!0)])):m("",!0)],2)}const E=w(D,[["render",A]]),F=T({__name:"HeroSlider",props:{autoplay:{},slides:{}},setup(s,{expose:a}){a();const t=H(!1);L(()=>{t.value=!0});const e={isMounted:t,Banner:E};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}}),I={class:"relative mx-auto"},Q={class:"absolute bottom-5 right-5 z-10 flex w-screen items-center justify-end xl:left-1/2 xl:right-auto xl:-ms-[640px] xl:max-w-screen-xl"},R=_("i",{class:"i-arrow-right rotate-180"},null,-1),U=_("i",{class:"i-arrow-right"},null,-1);function W(s,a,t,e,i,p){const n=x("CarouselControl"),u=x("Carousel");return r(),l("section",I,[c(u,{autoplay:t.autoplay,class:"secondary [&>*]:items-center"},{controls:o(()=>[N(_("div",Q,[_("div",{class:b(["text-primary relative h-10 w-20 rounded-full bg-white/50 shadow-sm ring-1 ring-black/5 transition-opacity",e.isMounted?"opacity-100":"opacity-20 [&>*]:cursor-wait"])},[c(n,{class:"hover:bg-primary/10 h-10 w-10 rounded-full","is-prev":""},{default:o(()=>[R]),_:1}),c(n,{class:"hover:bg-primary/10 h-10 w-10 rounded-full"},{default:o(()=>[U]),_:1})],2)],512),[[B,t.slides.length>1]])]),default:o(()=>[(r(!0),l(P,null,V(t.slides,(k,h)=>(r(),l("li",{key:h,class:"shrink-0 basis-full"},[c(e.Banner,j({...k,headingTag:h===0?"h2":"h3"},{class:"w-screen max-w-screen-2xl"}),{picture:o(()=>[S(s.$slots,`picture-${h}`)]),_:2},1040)]))),128))]),_:3},8,["autoplay"])])}const $=w(F,[["render",W]]);export{$ as default};
@@ -0,0 +1 @@
1
+ import{_ as C,v as g}from"./_plugin-vue_export-helper.f75743ee.js";import{p as x}from"./modules-info.55780599.js";import{s as b,c as m,d as w,L as p,N as r,O as h,P as i,Q as u,M as l,X as S,R as y,S as B,W as k,U as L}from"./ecom-utils.5cbfb95e.js";import"./afetch.f4507208.js";import"./sf-utils.b04e1813.js";import"./format-money.9cf6b04d.js";import"./price.04ceb6c4.js";function P(t,e){{const s=btoa(JSON.stringify({filename:t}));window.parent.postMessage(JSON.parse(JSON.stringify({type:"open",filename:t,id:s})),window.location.origin),window.addEventListener("message",n=>{n.data.id===s&&e(n.data.data)})}}const N=t=>{const e=b(null);return window.$isCmsPreview&&P(t,s=>{e.value=s}),{liveContent:e}},V=t=>{const e={slides:[]};return t.header?.pitchBar&&(e.slides=t.header.pitchBar),e},O=t=>{const{liveContent:e}=N("layout"),s=m(()=>(e.value?V(e.value).slides:t.slides).map(({html:o})=>x(o).value.replace(/<\/?p>/g,"").replace(/&lt;(\/?d-md)&gt;/g,"<$1>"))),n=m(()=>s.value.filter(a=>a).length);return{parsedContents:s,countValidSlides:n}},M=w({__name:"PitchBar",props:{slides:{}},setup(t,{expose:e}){e();const s=t,{parsedContents:n,countValidSlides:a}=O(s),o={props:s,parsedContents:n,countValidSlides:a};return Object.defineProperty(o,"__isScriptSetup",{enumerable:!1,value:!0}),o}}),J={class:"bg-base-100 relative z-20"},z={class:"container mx-auto px-3 py-1 md:w-2/3"},A=["innerHTML"],E={class:"text-base-400 text-xl leading-none"};function H(t,e,s,n,a,o){const f=p("ALink"),_=p("CarouselControl"),v=p("Carousel");return l(),r("div",J,[h("div",z,[i(v,{autoplay:n.countValidSlides>1?7e3:void 0},{controls:u(()=>[S(h("div",E,[i(_,{class:"bg-base-100 hover:text-base-700 pr-2","is-prev":""}),i(_,{class:"bg-base-100 hover:text-base-700 pl-2"})],512),[[g,n.countValidSlides>1]])]),default:u(()=>[(l(!0),r(y,null,B(s.slides,(c,d)=>(l(),r("li",{key:d,class:"h-full shrink-0 basis-full text-center"},[i(f,{href:c.href,target:c.target,class:k(["inline-block px-8",c.href?"hover:underline":null])},{default:u(()=>[n.parsedContents[d]?(l(),r("span",{key:0,innerHTML:n.parsedContents[d],class:"prose text-base-800 text-sm"},null,8,A)):L("",!0)]),_:2},1032,["href","target","class"])]))),128))]),_:1},8,["autoplay"])])])}const W=C(M,[["render",H]]);export{W as default};
@@ -1 +1 @@
1
- import{a as W,i as A,d as z,l as M}from"./modules-info.3c447a07.js";import{c as s,J as S,K as E,f as o,h as i,L as r,M as c,N as h,O as N,P as C,Q as L,R as B}from"./ecom-utils.c385a436.js";import{g,c as T}from"./price.04ceb6c4.js";import{_ as F}from"./_plugin-vue_export-helper.dd1a60ce.js";const j=(a,l)=>{const{type:n,value:e}=l;let d;return e?(n==="percentage"?d=a*((100-e)/100):d=a-e,d>0?d:0):a},R=a=>{const l=s(()=>a.product||{price:a.price||0,base_price:a.basePrice}),n=s(()=>{const{variations:t}=l.value;if(t){const u=g(l.value);for(let P=0;P<t.length;P++)if(g({...l.value,...t[P]})>u)return!0}return!1}),e=s(()=>{const t=g(l.value),u=W.value;return u&&(!u.min_amount||t>u.min_amount)?j(t,u):t}),d=s(()=>{if(T(l.value))return l.value.base_price;const t=g(l.value);return t>e.value?t:0}),_=s(()=>a.installmentsOption||A.value||{max_number:1}),m=s(()=>{if(_.value.max_number<=1)return 1;const t=_.value.min_installment||5,u=Math.floor(e.value/t);return Math.min(u,_.value.max_number)}),b=s(()=>_.value.monthly_interest||0),k=s(()=>{if(m.value>=2){if(!b.value)return e.value/m.value;const t=b.value/100;return e.value*t/(1-(1+t)**-m.value)}return 0}),f=s(()=>{const t=a.discountOption||z.value;return t&&(!t.min_amount||t.min_amount<=e.value)&&(!a.isAmountTotal||t.apply_at==="total")?t:{}}),O=s(()=>{const{label:t}=f.value;return t?t.includes(" ")?t:`via ${t}`:""}),V=s(()=>j(e.value,f.value)),v=s(()=>{if(a.loyaltyPointsProgram)return a.loyaltyPointsProgram;const t=M.value;if(t){const u=Object.keys(t);for(let P=0;P<u.length;P++){const p=t[u[P]];if(p?.earn_percentage&&p.earn_percentage>0)return p}}return{ratio:0}}),y=s(()=>v.value.min_subtotal_to_earn||0),w=s(()=>v.value.name||""),D=s(()=>v.value.earn_percentage||0),x=s(()=>D.value*v.value.ratio),I=s(()=>x.value>=1?e.value*(x.value/100):0);return{hasVariedPrices:n,salePrice:e,comparePrice:d,installmentsObject:_,installmentsNumber:m,monthlyInterest:b,installmentValue:k,discountObject:f,discountLabel:O,priceWithDiscount:V,pointsProgramObject:v,pointsMinPrice:y,pointsProgramName:w,earnPointsPercentage:D,cashbackPercentage:x,cashbackValue:I}},J=S({__name:"Prices",props:{isBig:{type:Boolean},isLiteral:{type:Boolean},hasCashback:{type:Boolean,default:!0},hasPriceOptions:{type:Boolean,default:!0},product:{},price:{},basePrice:{},isAmountTotal:{type:Boolean},installmentsOption:{},discountOption:{},loyaltyPointsProgram:{}},setup(a,{expose:l}){l();const n=a,{hasVariedPrices:e,salePrice:d,comparePrice:_,cashbackPercentage:m,cashbackValue:b,installmentsNumber:k,monthlyInterest:f,installmentValue:O,priceWithDiscount:V,discountLabel:v}=R(n),y={props:n,hasVariedPrices:e,salePrice:d,comparePrice:_,cashbackPercentage:m,cashbackValue:b,installmentsNumber:k,monthlyInterest:f,installmentValue:O,priceWithDiscount:V,discountLabel:v};return Object.defineProperty(y,"__isScriptSetup",{enumerable:!1,value:!0}),y}}),K={key:0,class:"text-base-500 mr-1 text-[87%]"},Q={key:0},q={key:1},G={key:0},H={key:0,class:"relative z-10"},U=["data-tooltip"],X=h("i",{class:"i-arrow-uturn-left mr-1"},null,-1),Y={class:"font-medium"},Z=h("small",null," cashback",-1),$={key:0},ee={key:0},te={key:1},ae={key:2},ne={key:0},se={key:0},re={key:1};function oe(a,l,n,e,d,_){const m=E("Fade");return o(),i("div",{class:C(["text-base-600 [&>div]:[font-size:90%] [&_small]:lowercase [&_small]:[font-size:92%]",n.isBig?"text-lg":null])},[e.comparePrice?(o(),i("span",K,[n.isLiteral?(o(),i("small",Q,r("De "))):c("",!0),h("s",null,r(a.$money(e.comparePrice)),1),n.isLiteral?(o(),i("small",q,r(" Por"))):c("",!0)])):c("",!0),h("strong",{class:C(["text-base-800",n.isBig?"text-4xl block":"inline-block"])},[e.hasVariedPrices?(o(),i("small",G,r("A partir de "))):c("",!0),N(" "+r(a.$money(e.salePrice)),1)],2),L(m,{slide:"down"},{default:B(()=>[e.cashbackValue&&n.hasCashback?(o(),i("div",H,[h("span",{"data-tooltip":"Receba $1 de volta".replace("$1",a.$percentage(e.cashbackPercentage))},[X,h("span",Y,r(a.$money(e.cashbackValue)),1),Z],8,U)])):c("",!0)]),_:1}),L(m,{slide:"down"},{default:B(()=>[e.installmentValue&&n.hasPriceOptions?(o(),i("div",$,[n.isLiteral?(o(),i("small",ee,r("Até "))):c("",!0),N(" "+r(e.installmentsNumber)+"x ",1),n.isLiteral?(o(),i("small",te,r(" De "))):c("",!0),h("span",null,r(a.$money(e.installmentValue)),1),!e.monthlyInterest&&n.isLiteral?(o(),i("small",ae,r(" Sem juros"))):c("",!0)])):c("",!0)]),_:1}),L(m,{slide:"down"},{default:B(()=>[e.priceWithDiscount<e.salePrice&&n.hasPriceOptions?(o(),i("div",ne,[e.discountLabel?c("",!0):(o(),i("small",se,r("A partir de "))),h("span",null,r(a.$money(e.priceWithDiscount)),1),e.discountLabel?(o(),i("small",re,r(` ${e.discountLabel}`),1)):c("",!0)])):c("",!0)]),_:1})],2)}const me=F(J,[["render",oe]]);export{me as P};
1
+ import{a as I,i as A,d as z,l as M}from"./modules-info.55780599.js";import{c as s,d as S,L as T,M as o,N as i,T as r,U as c,O as h,V as N,W as C,P as L,Q as B}from"./ecom-utils.5cbfb95e.js";import{g,c as E}from"./price.04ceb6c4.js";import{_ as F}from"./_plugin-vue_export-helper.f75743ee.js";const W=(a,l)=>{const{type:n,value:e}=l;let d;return e?(n==="percentage"?d=a*((100-e)/100):d=a-e,d>0?d:0):a},Q=a=>{const l=s(()=>a.product||{price:a.price||0,base_price:a.basePrice}),n=s(()=>{const{variations:t}=l.value;if(t){const u=g(l.value);for(let P=0;P<t.length;P++)if(g({...l.value,...t[P]})>u)return!0}return!1}),e=s(()=>{const t=g(l.value),u=I.value;return u&&(!u.min_amount||t>u.min_amount)?W(t,u):t}),d=s(()=>{if(E(l.value))return l.value.base_price;const t=g(l.value);return t>e.value?t:0}),_=s(()=>a.installmentsOption||A.value||{max_number:1}),m=s(()=>{if(_.value.max_number<=1)return 1;const t=_.value.min_installment||5,u=Math.floor(e.value/t);return Math.min(u,_.value.max_number)}),b=s(()=>_.value.monthly_interest||0),k=s(()=>{if(m.value>=2){if(!b.value)return e.value/m.value;const t=b.value/100;return e.value*t/(1-(1+t)**-m.value)}return 0}),f=s(()=>{const t=a.discountOption||z.value;return t&&(!t.min_amount||t.min_amount<=e.value)&&(!a.isAmountTotal||t.apply_at==="total")?t:{}}),O=s(()=>{const{label:t}=f.value;return t?t.includes(" ")?t:`via ${t}`:""}),V=s(()=>W(e.value,f.value)),v=s(()=>{if(a.loyaltyPointsProgram)return a.loyaltyPointsProgram;const t=M.value;if(t){const u=Object.keys(t);for(let P=0;P<u.length;P++){const p=t[u[P]];if(p?.earn_percentage&&p.earn_percentage>0)return p}}return{ratio:0}}),y=s(()=>v.value.min_subtotal_to_earn||0),j=s(()=>v.value.name||""),D=s(()=>v.value.earn_percentage||0),x=s(()=>D.value*v.value.ratio),w=s(()=>x.value>=1?e.value*(x.value/100):0);return{hasVariedPrices:n,salePrice:e,comparePrice:d,installmentsObject:_,installmentsNumber:m,monthlyInterest:b,installmentValue:k,discountObject:f,discountLabel:O,priceWithDiscount:V,pointsProgramObject:v,pointsMinPrice:y,pointsProgramName:j,earnPointsPercentage:D,cashbackPercentage:x,cashbackValue:w}},R=S({__name:"Prices",props:{isBig:{type:Boolean},isLiteral:{type:Boolean},hasCashback:{type:Boolean,default:!0},hasPriceOptions:{type:Boolean,default:!0},product:{},price:{},basePrice:{},isAmountTotal:{type:Boolean},installmentsOption:{},discountOption:{},loyaltyPointsProgram:{}},setup(a,{expose:l}){l();const n=a,{hasVariedPrices:e,salePrice:d,comparePrice:_,cashbackPercentage:m,cashbackValue:b,installmentsNumber:k,monthlyInterest:f,installmentValue:O,priceWithDiscount:V,discountLabel:v}=Q(n),y={props:n,hasVariedPrices:e,salePrice:d,comparePrice:_,cashbackPercentage:m,cashbackValue:b,installmentsNumber:k,monthlyInterest:f,installmentValue:O,priceWithDiscount:V,discountLabel:v};return Object.defineProperty(y,"__isScriptSetup",{enumerable:!1,value:!0}),y}}),U={key:0,class:"text-base-500 mr-1 text-[87%]"},q={key:0},G={key:1},H={key:0},J={key:0,class:"relative z-10"},K=["data-tooltip"],X=h("i",{class:"i-arrow-uturn-left mr-1"},null,-1),Y={class:"font-medium"},Z=h("small",null," cashback",-1),$={key:0},ee={key:0},te={key:1},ae={key:2},ne={key:0},se={key:0},re={key:1};function oe(a,l,n,e,d,_){const m=T("Fade");return o(),i("div",{class:C(["text-base-600 [&>div]:[font-size:90%] [&_small]:lowercase [&_small]:[font-size:92%]",n.isBig?"text-lg":null])},[e.comparePrice?(o(),i("span",U,[n.isLiteral?(o(),i("small",q,r("De "))):c("",!0),h("s",null,r(a.$money(e.comparePrice)),1),n.isLiteral?(o(),i("small",G,r(" Por"))):c("",!0)])):c("",!0),h("strong",{class:C(["text-base-800",n.isBig?"text-4xl block":"inline-block"])},[e.hasVariedPrices?(o(),i("small",H,r("A partir de "))):c("",!0),N(" "+r(a.$money(e.salePrice)),1)],2),L(m,{slide:"down"},{default:B(()=>[e.cashbackValue&&n.hasCashback?(o(),i("div",J,[h("span",{"data-tooltip":"Receba $1 de volta".replace("$1",a.$percentage(e.cashbackPercentage))},[X,h("span",Y,r(a.$money(e.cashbackValue)),1),Z],8,K)])):c("",!0)]),_:1}),L(m,{slide:"down"},{default:B(()=>[e.installmentValue&&n.hasPriceOptions?(o(),i("div",$,[n.isLiteral?(o(),i("small",ee,r("Até "))):c("",!0),N(" "+r(e.installmentsNumber)+"x ",1),n.isLiteral?(o(),i("small",te,r(" De "))):c("",!0),h("span",null,r(a.$money(e.installmentValue)),1),!e.monthlyInterest&&n.isLiteral?(o(),i("small",ae,r(" Sem juros"))):c("",!0)])):c("",!0)]),_:1}),L(m,{slide:"down"},{default:B(()=>[e.priceWithDiscount<e.salePrice&&n.hasPriceOptions?(o(),i("div",ne,[e.discountLabel?c("",!0):(o(),i("small",se,r("A partir de "))),h("span",null,r(a.$money(e.priceWithDiscount)),1),e.discountLabel?(o(),i("small",re,r(` ${e.discountLabel}`),1)):c("",!0)])):c("",!0)]),_:1})],2)}const me=F(R,[["render",oe]]);export{me as P};
@@ -0,0 +1 @@
1
+ import{_ as D,w as J}from"./_plugin-vue_export-helper.f75743ee.js";import{u as Z}from"./index.570b84fe.js";import{a as H}from"./shopping-cart.d9f601dd.js";import{u as X}from"./use-product-card.437911bb.js";import{C as $,Q as tt}from"./QuantitySelector.ebf60845.js";import{P as et}from"./Prices.0e829c31.js";import{_ as G,d as ot}from"./customer-session.5ab9ab1a.js";import{u as it}from"./sf-utils.b04e1813.js";import{g as rt}from"./img-sizes.41e0efe4.js";import{_ as at,d as N,a as S,L as P,M as u,N as f,Z as I,Q as A,O as v,U as y,R as k,S as z,W as V,P as w,a5 as F,J as M,r as L,w as T,K as Q,c as K,V as B,T as C,a6 as st,o as nt,Y as lt}from"./ecom-utils.5cbfb95e.js";import{g as ct}from"./name.01410784.js";import"./index.8ac1db99.js";import"./price.04ceb6c4.js";import"./use-analytics.cc95e346.js";import"./afetch.f4507208.js";import"./img.4f23a3dd.js";import"./modules-info.55780599.js";import"./format-money.9cf6b04d.js";import"./i18n.29216eeb.js";const q=(r,o,l)=>{if(typeof r!="object"||r===null)return[];let t=[];if(typeof r=="object"&&r!==null)if(Array.isArray(r))r.length&&(r[0].specifications?r.forEach(e=>{t=t.concat(q(e,o,l))}):r[0].text&&(t=r));else{const{specifications:e}=r;if(e)for(const n in e)e[n]&&n===o&&(t=e[o]);if(t&&!t.length&&Array.isArray(l)&&l.length){let n,d;return l&&(d=l.find(a=>a.grid_id===o))&&d.options&&(n=d.options.map(a=>{let s;return a.colors&&a.colors.length?s=a.colors[0]:s=a.option_id,{text:a.text,value:s}})),q(n,o)}}return t},W=q,dt=(r,o,l,t=", ")=>{let e=W(r,o,l);if(e.length){let n=e[0].text;for(let d=1;d<e.length;d++)n+=t+e[d].text;return n}return null},Y=dt,ut=(r,o,l,t)=>{const e=W(r,l,t);for(let n=0;n<e.length;n++)if(e[n].text===o)return e[n].value},mt=ut,ft=(r,o,l,t)=>{let e={};return r&&Array.isArray(r.variations)&&r.variations.forEach(n=>{if(l&&n.quantity<=0)return;let d=n.specifications,a=s=>Y(n,s,t);if(d){if(o){for(let s in o)if(o.hasOwnProperty(s)&&(!d[s]||a(s)!==o[s]))return}for(let s in d)if(d.hasOwnProperty(s)){let m=a(s);if(!e.hasOwnProperty(s))e[s]=[];else if(e[s].indexOf(m)!==-1)continue;e[s].push(m)}}}),e},j=ft,gt=(r,o,l=at.get("lang"))=>{let t;return Array.isArray(o)?t=o.find(e=>e.grid_id===r):console.error("`grids` must be array to get grid title"),t?ct(t,l):r},pt=gt,_t=N({__name:"ImagesGallery",props:{pictures:{}},setup(r,{expose:o}){o();const l=S(0),t=S("");let e;const n=S(!1),a={activeIndex:l,psId:t,get lightbox(){return e},set lightbox(s){e=s},isLoadingLightbox:n,zoom:s=>{if(t.value=`ps-${it()}`,!e&&!n.value){n.value=!0;const m="photoswipe-style";Promise.all([G(()=>import("./photoswipe-lightbox.esm.c157838f.js"),[]),G(()=>import("./photoswipe.esm.92c2d901.js"),[]),!document.getElementById(m)&&G(()=>import("./photoswipe.01431ec7.js"),[])]).then(([{default:i},{default:c},_])=>{if(_){const{default:b}=_,p=document.createElement("style");p.id=m,p.textContent=b,document.head.appendChild(p)}e=new i({gallery:`#${t.value} > div`,children:"a",pswpModule:c,showAnimationDuration:300,hideAnimationDuration:300}),e.init(),e.loadAndOpen(s),n.value=!1})}},get getImgSizes(){return rt}};return Object.defineProperty(a,"__isScriptSetup",{enumerable:!1,value:!0}),a}}),ht={class:"-mx-4 flex w-screen gap-3 sm:mx-0 sm:w-full md:h-[525px] 2xl:gap-5"},vt=["onClick"],bt=v("span",{class:"absolute bottom-0 block h-2 w-full bg-gradient-to-b from-transparent to-white"},null,-1),yt={class:"relative aspect-square h-full grow md:aspect-auto"},xt={key:0,class:"i-arrow-path bg-base-200 absolute left-1/2 top-1/2 -ml-7 -mt-7 h-14 w-14 animate-spin","aria-label":"Carregando"},kt={key:1,class:"mt-2 flex justify-center gap-1.5 md:hidden"},wt=["aria-label","onClick"];function Ct(r,o,l,t,e,n){const d=P("AImg"),a=P("CarouselControl"),s=P("Carousel"),m=P("ALink");return u(),f("div",ht,[l.pictures.length>1?(u(),I(s,{key:0,axis:"y",class:"group hidden w-[300px] shrink-0 md:block"},{controls:A(()=>[v("span",null,[l.pictures.length>6?(u(),I(a,{key:0,class:"hover:bg-primary-300/60 text-primary !bottom-3 !left-1/2 -ml-5 h-10 w-10 rounded-full bg-white/60 text-xl opacity-0 shadow-sm ring-1 ring-black/5 group-hover:opacity-90"})):y("",!0),bt])]),default:A(()=>[(u(!0),f(k,null,z(Math.ceil(l.pictures.length/2),i=>(u(),f("li",{key:i,class:V(["grid h-1/3 w-full grid-cols-2 gap-3 px-1 pb-3",i===1&&"pt-1"])},[(u(!0),f(k,null,z([1,2].map(c=>(i-1)*2+(c-1)),c=>(u(),f(k,{key:`${i}-${c}`},[c<l.pictures.length?(u(),f("button",{key:0,class:"bg-secondary-100 h-full rounded",onClick:_=>t.activeIndex=c},[w(d,{picture:l.pictures[c],class:V(["ring-secondary/10 h-full w-full rounded border-2 object-cover opacity-90 transition-colors",c===t.activeIndex?"border-secondary/50 ring-4 cursor-auto":"border-transparent hover:border-primary hover:ring-4 hover:ring-primary/20"])},null,8,["picture","class"])],8,vt)):y("",!0)],64))),128))],2))),128))]),_:1})):y("",!0),v("div",yt,[w(s,{as:"div",index:t.activeIndex,"onUpdate:index":o[1]||(o[1]=i=>t.activeIndex=i),class:V(["text-base-600 [&_i]:i-arrow-right mx-auto h-full w-full max-w-[525px] [&>*]:h-full [&_i]:mx-2 [&_i]:text-2xl",t.isLoadingLightbox&&"opacity-80"]),id:t.psId},{default:A(()=>[o[0]||(F(-1),o[0]=(u(!0),f(k,null,z(l.pictures,(i,c)=>(u(),I(m,{key:`big-${c}`,href:i.zoom?.size&&i.zoom.url,"data-pswp-width":t.getImgSizes(i.zoom||"").width,"data-pswp-height":t.getImgSizes(i.zoom||"").height,target:"_blank",rel:"noreferrer",class:V(["shrink-0 basis-full",i.zoom?.size&&"cursor-zoom-in"]),onClick:J(()=>i.zoom?.size&&t.zoom(c),["prevent"])},{default:A(()=>[w(d,{picture:i,"preferred-size":"big",class:"h-full w-full rounded object-cover",fetchpriority:c===0?"high":"low",loading:c===0?"eager":"lazy"},null,8,["picture","fetchpriority","loading"])]),_:2},1032,["href","data-pswp-width","data-pswp-height","class","onClick"]))),128)),F(1),o[0])]),_:1},8,["index","class","id"]),t.isLoadingLightbox?(u(),f("i",xt)):y("",!0),l.pictures.length>1?(u(),f("ul",kt,[(u(!0),f(k,null,z(l.pictures.length,i=>(u(),f("li",{key:`d-${i}`},[v("button",{class:V(["bg-base-700 block h-1.5 w-3 rounded-full",t.activeIndex!==i-1&&"opacity-40"]),"aria-label":`Imagem ${i}`,onClick:c=>t.activeIndex=i-1},null,10,wt)]))),128))])):y("",!0)])])}const St=D(_t,[["render",Ct]]),Ot=r=>{let o=M(globalThis.$storefront.data.grids);o||(o=M([]),ot.get("grids").then(({data:{result:i}})=>{i.forEach(c=>o.push(c))}));const l=L({}),t=L({});T(Q(r,"variations"),()=>{Object.assign(t,j(r,void 0,!0));const i=j(r);Object.keys(i).forEach(c=>{t[c]?l[c]=t[c]:delete l[c]})},{immediate:!0});const e=K(()=>Object.keys(l)),n=L({}),d=S(),a=({optionText:i,gridId:c,gridIndex:_})=>{n[c]=i;const b={};for(let g=0;g<=_;g++){const h=e[g];n[h]&&(b[h]=n[h])}const p=j(r,b,!0);for(let g=_+1;g<e.value.length;g++){const h=e[g],O=p[h];t[h]=O,n[h]&&!O.includes(n[h])&&delete n[h]}const x=r.variations.slice(0);for(let g=0;g<x.length;g++){const h=x[g],{specifications:O}=h,R=Object.keys(O);for(let E=0;E<R.length;E++){const U=R[E];if(n[U]!==Y(h,U)){x.splice(g,1),g-=1;break}}}d.value=x[0]?._id||null};return T(Q(r,"variationId"),i=>{if(!i||i===d.value)return;const c=r.variations.find(x=>x._id===i);if(!c){d.value=null;return}const{specifications:_}=c,b=Object.keys(_),p=(x=0)=>{const g=b[x];if(b[x]&&_[g]&&_[g].length===1){const h=_[g][0].text;l[g].find(O=>O===h)&&(a({optionText:h,gridId:g,gridIndex:e.value.indexOf(g)}),p(x+1))}};p()},{immediate:!0}),{grids:o,variationsGrids:l,activeVariationsGrids:t,selectOption:a,selectedOptions:n,variationId:d,getGridTitle:i=>pt(i,o),getColorOptionBg:i=>{const c=i.split(",").map(_=>mt(r.variations,_.trim(),"colors"));return c.length>1?`background:linear-gradient(to right bottom, ${c[0]} 50%, ${c[1]} 50%)`:`background:${c[0]}`}}},Vt=N({__name:"SkuSelector",props:{variations:{},variationId:{}},emits:["update:variationId"],setup(r,{expose:o,emit:l}){o();const t=r,e=l,{variationsGrids:n,activeVariationsGrids:d,selectOption:a,selectedOptions:s,variationId:m,getGridTitle:i,getColorOptionBg:c}=Ot(t);T(m,b=>{e("update:variationId",b)});const _={props:t,emit:e,variationsGrids:n,activeVariationsGrids:d,selectOption:a,selectedOptions:s,variationId:m,getGridTitle:i,getColorOptionBg:c};return Object.defineProperty(_,"__isScriptSetup",{enumerable:!1,value:!0}),_}}),At={class:"text-base-700 text-sm font-medium"},zt={key:0,class:"text-base-800"},Pt={key:0,class:"mt-2 flex gap-2"},It=["onClick"];function Tt(r,o,l,t,e,n){return u(),f("div",null,[(u(!0),f(k,null,z(t.variationsGrids,(d,a)=>(u(),f("div",{key:a},[v("span",At,[B(C(t.getGridTitle(a))+": ",1),t.selectedOptions[a]?(u(),f("strong",zt,C(t.selectedOptions[a]),1)):y("",!0)]),d.length<7?(u(),f("ul",Pt,[(u(!0),f(k,null,z(d,(s,m)=>(u(),f("li",{key:`${a}-${m}`},[v("button",{class:V(["ring-secondary/60 rounded border",[t.selectedOptions[a]===s?"border-secondary ring-2":null,a==="colors"?"h-9 w-9 text-[0]":"px-2 py-1",t.activeVariationsGrids[a].includes(s)?"text-base-800 bg-base-100 border-base-400":"text-base-500 bg-base-200 border-base-300"]]),style:st(a==="colors"?t.getColorOptionBg(s):void 0),onClick:i=>t.selectOption({optionText:s,gridId:a,gridIndex:m})},C(s),15,It)]))),128))])):y("",!0)]))),128))])}const Et=D(Vt,[["render",Tt]]),Gt=N({__name:"ProductDetails",props:{product:{default:()=>globalThis.$storefront.apiContext?.doc}},setup(r,{expose:o}){o();const l=r,{product:t,title:e,isActive:n}=X(l),d=S(t.min_quantity||1),a=Z("history"),s=S(!1),m=S(null);T(m,p=>{p&&(a.var=p,s.value=!1)}),nt(()=>{T(a,({var:p})=>{typeof p=="string"&&p&&(m.value=p)},{immediate:!0})});const i=K(()=>!!(!t.variations?.length||m.value)),c=p=>(i.value?s.value=!1:(p&&p.preventDefault(),s.value=!0),!s.value),b={props:l,product:t,title:e,isActive:n,quantity:d,params:a,hasSkuSelectionAlert:s,variationId:m,isSkuSelected:i,checkVariation:c,addToCart:()=>{c()&&H(t,m.value?m.value:void 0)},CheckoutLink:$,QuantitySelector:tt,Prices:et,ImagesGallery:St,SkuSelector:Et};return Object.defineProperty(b,"__isScriptSetup",{enumerable:!1,value:!0}),b}}),Lt={class:"ui-section relative grid grid-cols-1 items-start gap-5 md:gap-4 lg:grid-cols-4 2xl:gap-6"},jt={class:"w-full lg:col-span-3"},Bt={class:"top-0 py-4 lg:sticky"},qt={class:"ui-text-brand text-base-700 text-xl"},Dt={key:0,class:"mt-5"},Nt={key:0,class:"ui-alert inline-block"},Rt=v("i",{class:"i-arrow-right ml-1 -rotate-90"},null,-1),Ut={class:"mt-5 flex flex-wrap items-center gap-x-4 gap-y-2 overflow-hidden md:flex-nowrap lg:mt-4 lg:flex-wrap"},Ft=v("i",{class:"i-chevron-double-right mr-1"},null,-1),Mt=["onClick","data-tooltip"],Qt={class:"w-full lg:col-span-3"};function Jt(r,o,l,t,e,n){const d=P("Fade");return u(),f("section",Lt,[v("div",jt,[t.product.pictures?.length?(u(),I(t.ImagesGallery,{key:0,pictures:t.product.pictures},null,8,["pictures"])):y("",!0)]),v("div",Bt,[v("h1",qt,C(t.title),1),t.isActive?(u(),f("div",Dt,[w(t.Prices,{product:t.product,"is-big":"","is-literal":""},null,8,["product"]),t.product.variations?(u(),I(t.SkuSelector,{key:0,variations:t.product.variations,"variation-id":t.variationId,"onUpdate:variationId":o[0]||(o[0]=a=>t.variationId=a),class:"my-4"},null,8,["variations","variation-id"])):y("",!0),w(d,{slide:"down"},{default:A(()=>[t.hasSkuSelectionAlert?(u(),f("div",Nt,[B(C("Por favor selecione uma opção em cada campo acima")+" "),Rt])):y("",!0)]),_:1}),v("div",Ut,[w(t.QuantitySelector,{modelValue:t.quantity,"onUpdate:modelValue":o[1]||(o[1]=a=>t.quantity=a),min:t.product.min_quantity,max:t.product.quantity,class:"border-base-100 rounded md:mr-5 lg:mb-2 lg:mr-auto lg:border-2"},null,8,["modelValue","min","max"]),w(t.CheckoutLink,{class:"ui-btn-lg ui-btn-primary grow text-center",to:"checkout","cart-item":{product_id:t.product._id,quantity:t.quantity,variation_id:t.variationId||void 0},"data-tooltip":t.isSkuSelected?null:"Escolha os detalhes do produto para comprar",onClick:t.checkVariation},{default:A(()=>[Ft,B(" "+C("Comprar"))]),_:1},8,["cart-item","data-tooltip"]),v("button",{class:"ui-btn-lg ui-btn-contrast grow",onClick:J(t.addToCart,["prevent"]),"data-tooltip":t.isSkuSelected?null:"Escolha os detalhes do produto para comprar"},C("Adicionar ao carrinho"),8,Mt)])])):y("",!0)]),v("div",Qt,[lt(r.$slots,"description")])])}const me=D(Gt,[["render",Jt]]);export{me as default};
@@ -0,0 +1 @@
1
+ import{_ as N,w as j,v as V}from"./_plugin-vue_export-helper.f75743ee.js";import{a as O,c as R}from"./index.570b84fe.js";import{d as I}from"./customer-session.5ab9ab1a.js";import{c as B,u as D}from"./use-product-card.437911bb.js";import{a as p,J as Q,d as T,L as C,M as s,N as c,P as h,Q as v,O as _,Z as L,U as w,V as x,T as y,$ as z,W as S,X as E,R as H,S as M}from"./ecom-utils.5cbfb95e.js";import{u as q}from"./sf-utils.b04e1813.js";import{a as F}from"./shopping-cart.d9f601dd.js";import{P as J}from"./Prices.0e829c31.js";import{g as U}from"./index.8ac1db99.js";const W=t=>{const a=p(t.title||""),u=p(t.titleLink||""),e=p(!1);let m=null;const d=p(null),l=Q(t.products||[]);return t.products||(e.value=!0,m=(async()=>{let f=t.searchQuery||"",i;if(t.collectionId){try{const{data:r}=await I.get(`collections/${t.collectionId}`);i=r}catch(r){console.error(r),d.value=r}const o=i?.products;Array.isArray(o)&&o.length&&(f+=`&_id=${o.slice(0,60).join(",")}`),!a.value&&a.value!==null&&i?.name&&(a.value=i?.name)}const n=t.limit||24;let g=`offset=${t.page?(t.page-1)*n:0}&limit=${n}`;t.sort&&(g+=`&sort=${t.sort}`),g+=f;try{const{data:o}=await I.get(`search/v1?${g}`);if(t.isShuffle){let r=o.result.filter(A=>A.available&&B(A)).length,b,P;for(;r;)P=Math.floor(Math.random()*r--),b=o.result[r],o.result[r]=o.result[P],o.result[P]=b}o.result.forEach(r=>l.push(r))}catch(o){console.error(o),d.value=o}e.value=!1})()),{title:a,titleLink:u,isFetching:e,fetching:m,fetchError:d,products:l}},X=T({__name:"ProductCard",props:{product:{},productId:{},listName:{},listId:{},headingTag:{default:"h3"}},setup(t,{expose:a}){a();const u=t,{product:e,title:m,link:d,images:l,isInStock:f,isActive:i,discountPercentage:n,hasVariations:k}=D(u),g=p(null),o=O(g),r=p(!1);U(o,()=>{r.value=!0});const b={props:u,product:e,title:m,link:d,images:l,isInStock:f,isActive:i,discountPercentage:n,hasVariations:k,card:g,isHovered:o,wasHoveredOnce:r,get addProductToCart(){return F},Prices:J};return Object.defineProperty(b,"__isScriptSetup",{enumerable:!1,value:!0}),b}}),Z=["data-sku"],G={class:"aspect-square p-2 transition-transform motion-safe:group-hover:scale-110"},K={class:"relative h-full w-full overflow-hidden rounded bg-white group-hover:rounded-none"},Y={key:0,class:"text-xs text-opacity-70"},$={key:1,class:"from-base-50/20 to-base-100 h-full w-full bg-gradient-to-br"},ee={key:0,class:"uno-bm03rg"},te={class:"relative z-10 flex grow flex-col justify-between p-4"},oe={class:"pt-2"},re={key:0},se={key:1,class:"ui-badge bg-warning-100 text-warning-700"},ae=_("span",{class:"bg-on-primary text-primary mr-1 inline-block h-4 w-4 rounded-full text-center text-base leading-none opacity-80"}," + ",-1);function ne(t,a,u,e,m,d){const l=C("AImg"),f=C("ALink");return s(),c("article",{ref:"card","data-sku":e.product.sku,class:"group relative mx-auto h-full max-w-[350px] px-0.5 py-3 hover:z-[1]"},[h(f,{href:e.link,class:"flex h-full flex-col overflow-hidden rounded bg-white ring-black/5 group-hover:shadow group-hover:ring-1"},{default:v(()=>[_("div",G,[_("div",K,[e.images?.length?(s(),c("span",Y,[h(l,{picture:e.images[0],alt:e.title,class:"absolute left-0 top-0 block h-full w-full object-cover"},null,8,["picture","alt"]),e.images[1]&&e.wasHoveredOnce?(s(),L(l,{key:0,picture:e.images[1],alt:e.title,class:"absolute left-0 top-0 z-10 block h-full w-full object-cover text-transparent opacity-0 transition-opacity group-hover:opacity-100 motion-safe:duration-300"},null,8,["picture","alt"])):w("",!0)])):(s(),c("div",$))])]),e.discountPercentage?(s(),c("span",ee,[x(" -"),_("strong",null,y(e.discountPercentage),1),x("% ")])):w("",!0),_("div",te,[(s(),L(z(u.headingTag),{class:S(["ui-link line-clamp-2 no-underline",[e.isActive?"text-base-700":"text-base-500",e.link?"group-hover:text-primary group-hover:underline":null]])},{default:v(()=>[x(y(e.title),1)]),_:1},8,["class"])),_("div",oe,[e.isActive?(s(),c("div",re,[h(e.Prices,{product:e.product},null,8,["product"])])):(s(),c("span",se,y(e.isInStock?"Inativo":"Sem estoque"),1))]),e.isActive&&!e.hasVariations?(s(),c("button",{key:0,class:"uno-3suct9 ui-btn-sm ui-btn-primary",onClick:a[0]||(a[0]=j(i=>e.addProductToCart(e.product),["prevent"]))},[ae,x(" "+y("Adicionar ao carrinho"))])):w("",!0)])]),_:1},8,["href"])],8,Z)}const le=N(X,[["render",ne]]),ie=T({__name:"ProductShelf",props:{collectionId:{},searchQuery:{},sort:{},title:{},titleLink:{},isShuffle:{type:Boolean},limit:{},page:{},products:{}},async setup(t,{expose:a}){a();const u=t,[e,m]=R(),{title:d,titleLink:l,fetching:f,products:i}=W(u),n=d.value||`Shelf ${q()}`,k={props:u,DefineCarouselControl:e,ReuseCarouselControl:m,title:d,titleLink:l,fetching:f,products:i,listName:n,ProductCard:le};return Object.defineProperty(k,"__isScriptSetup",{enumerable:!1,value:!0}),k}}),ce={class:"ui-section"},ue={key:0,class:"mx-auto mb-2 max-w-prose text-center"},de={class:"ui-text-brand text-3xl"};function fe(t,a,u,e,m,d){const l=C("ALink"),f=C("CarouselControl"),i=C("Carousel");return s(),c("section",ce,[e.title?(s(),c("div",ue,[_("h2",de,[h(l,{href:e.titleLink,class:S(e.titleLink?"ui-link":"text-base-700")},{default:v(()=>[x(y(e.title),1)]),_:1},8,["href","class"])])])):w("",!0),h(i,{class:"group/shelf"},{controls:v(()=>[h(e.DefineCarouselControl,null,{default:v(({isPrev:n})=>[E(h(f,{class:S(["uno-nxxji7",n?"!-left-4":"!-right-4"]),"is-prev":n},null,8,["class","is-prev"]),[[V,e.products.length>2]])]),_:1}),h(e.ReuseCarouselControl,{"is-prev":!0}),h(e.ReuseCarouselControl)]),default:v(()=>[(s(!0),c(H,null,M(e.products,n=>(s(),c("li",{key:n._id,class:"shrink-0 basis-1/2 md:basis-1/3 lg:basis-1/4"},[h(e.ProductCard,{product:n,"list-name":e.listName},null,8,["product","list-name"])]))),128))]),_:1})])}const ye=N(ie,[["render",fe]]);export{ye as P};
@@ -0,0 +1 @@
1
+ import{P as j}from"./ProductShelf.3f4f38b5.js";import"./_plugin-vue_export-helper.f75743ee.js";import"./ecom-utils.5cbfb95e.js";import"./index.570b84fe.js";import"./index.8ac1db99.js";import"./customer-session.5ab9ab1a.js";import"./sf-utils.b04e1813.js";import"./use-product-card.437911bb.js";import"./use-analytics.cc95e346.js";import"./shopping-cart.d9f601dd.js";import"./price.04ceb6c4.js";import"./afetch.f4507208.js";import"./name.01410784.js";import"./i18n.29216eeb.js";import"./img.4f23a3dd.js";import"./Prices.0e829c31.js";import"./modules-info.55780599.js";import"./format-money.9cf6b04d.js";export{j as default};
@@ -0,0 +1 @@
1
+ import{_ as v,w as V,a as U}from"./_plugin-vue_export-helper.f75743ee.js";import{d as M,c as y,M as p,N as f,Y as u,a3 as q,R as k,V as B,a as P,a4 as $,O as x,T as N,a1 as I,a2 as g,X as T,P as w,Q as C}from"./ecom-utils.5cbfb95e.js";import{u as j}from"./sf-utils.b04e1813.js";const z=M({__name:"CheckoutLink",props:{to:{default:"cart"},cartUrl:{default:globalThis.$storefront?.settings.cartUrl||"/app/#/cart"},checkoutUrl:{default:globalThis.$storefront?.settings.checkoutUrl||"/app/#/checkout"},cartId:{},cartItem:{}},setup(a,{expose:i}){i();const t=a,e=y(()=>{let n=t.to==="cart"?t.cartUrl:t.checkoutUrl;if(t.cartId)n+=`/${t.cartId}`;else if(t.cartItem){const o={product_id:t.cartItem.product_id},{variation_id:l,quantity:d,sku:c,customizations:m}=t.cartItem;l&&(o.variation_id=l),d&&(o.quantity=String(d)),c&&(o.sku=c),m&&m.forEach(({label:r,option:_,attachment:S},Q)=>{const b=`customizations.${Q}.`;r&&(o[b+"label"]=r),_&&(_._id&&(o[b+"option._id"]=_._id),o[b+"option.text"]=_.text),S&&(o[b+"attachment"]=S)}),n+="?"+new URLSearchParams(o).toString()}return n}),s={props:t,href:e};return Object.defineProperty(s,"__isScriptSetup",{enumerable:!1,value:!0}),s}}),O=["href"];function L(a,i,t,e,s,n){return p(),f("a",{href:e.href},[u(a.$slots,"default")],8,O)}const Z=v(z,[["render",L]]),R=M({__name:"QuantitySelectorControl",props:{isMinus:{type:Boolean}},setup(a,{expose:i}){i();const{value:t,isBoundMin:e,isBoundMax:s}=q(h),n={value:t,isBoundMin:e,isBoundMax:s};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),D=["data-quantity-selector-control","aria-label","disabled"];function E(a,i,t,e,s,n){return p(),f("button",{type:"button",class:"leading-12 enabled:text-primary enabled:hover:bg-primary-100/70 h-12 w-10 text-xl disabled:opacity-40","data-quantity-selector-control":t.isMinus?"minus":"plus","aria-label":t.isMinus?"Menos":"Mais",disabled:t.isMinus?e.isBoundMin:e.isBoundMax,onClick:i[0]||(i[0]=V(o=>e.value+=t.isMinus?-1:1,["prevent"]))},[u(a.$slots,"default",{},()=>[t.isMinus?(p(),f(k,{key:0},[B("−")],64)):(p(),f(k,{key:1},[B("+")],64))])],8,D)}const F=v(R,[["render",E]]),h=Symbol("quantitySelector"),K=M({__name:"QuantitySelector",props:{modelValue:{default:1},min:{default:1},max:{},step:{},disabled:{type:Boolean},readonly:{type:Boolean}},emits:["update:modelValue"],setup(a,{expose:i,emit:t}){i();const e=a,s=t,n=P(null),o=`NInput${j()}`,l=y({get(){return e.modelValue},set(r){r<e.min&&(r=e.min,n.value.value=`${r}`),e.max&&r>e.max&&(r=e.max,n.value.value=`${r}`),s("update:modelValue",r)}}),d=y(()=>e.min>=l.value),c=y(()=>e.max<=l.value);$(h,{value:l,isBoundMin:d,isBoundMax:c});const m={quantitySelectorKey:h,props:e,emit:s,input:n,inputId:o,value:l,isBoundMin:d,isBoundMax:c,QuantitySelectorControl:F};return Object.defineProperty(m,"__isScriptSetup",{enumerable:!1,value:!0}),m}}),X={"data-quantity-selector":""},Y={class:"flex items-center"},A=["min","max","step","disabled","readonly"];function G(a,i,t,e,s,n){return p(),f("div",X,[u(a.$slots,"label",I(g({inputId:e.inputId,value:e.value})),()=>[x("label",{for:e.inputId,class:"sr-only"},N("Quantidade"))]),x("div",Y,[T(x("input",{ref:"input",type:"number",id:e.inputId,"onUpdate:modelValue":i[0]||(i[0]=o=>e.value=o),min:t.min,max:t.max,step:t.step,disabled:t.disabled,readonly:t.readonly,class:"h-12 w-14 border-transparent px-2 text-center text-lg [-moz-appearance:_textfield] [&::-webkit-inner-spin-button]:m-0 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:m-0 [&::-webkit-outer-spin-button]:appearance-none"},null,8,A),[[U,e.value]]),u(a.$slots,"controls",I(g({value:e.value,isBoundMin:e.isBoundMin,isBoundMax:e.isBoundMax})),()=>[w(e.QuantitySelectorControl,{"is-minus":"",class:"order-first"},{default:C(()=>[u(a.$slots,"minus")]),_:3}),w(e.QuantitySelectorControl,{class:"order-last"},{default:C(()=>[u(a.$slots,"plus")]),_:3})])])])}const ee=v(K,[["render",G]]);export{Z as C,ee as Q};
@@ -0,0 +1 @@
1
+ import{u as g,d as _}from"./customer-session.5ab9ab1a.js";import{a as c,J as p,w as m,d as v,K as S,L as b,M as l,N as u,O as y,P as h,Q as w,R as x,S as k,T as N}from"./ecom-utils.5cbfb95e.js";import{u as C}from"./index.8ac1db99.js";import{P as E}from"./ProductShelf.3f4f38b5.js";import{_ as P}from"./_plugin-vue_export-helper.f75743ee.js";import"./sf-utils.b04e1813.js";import"./index.570b84fe.js";import"./use-product-card.437911bb.js";import"./use-analytics.cc95e346.js";import"./shopping-cart.d9f601dd.js";import"./price.04ceb6c4.js";import"./afetch.f4507208.js";import"./name.01410784.js";import"./i18n.29216eeb.js";import"./img.4f23a3dd.js";import"./Prices.0e829c31.js";import"./modules-info.55780599.js";import"./format-money.9cf6b04d.js";const H="ecomSeachHistory",i=g(H,[]),B=async({term:e,params:r,fields:s,url:t="search/v1"})=>{if(e=e.trim(),e.length<2)return{data:{result:[],meta:null}};const a=await _.get(t,{fields:s,params:{...r,term:e}});if(a.data.result.length&&!i.includes(e)){const o=i.findIndex(n=>e.startsWith(n));for(o>-1?i[o]=e:i.unshift(e);i.length>20;)i.pop()}return a};class M{url;fields;term=c("");params=p({});pageSize=c(24);pageNumber=c(1);products=p([]);#e;constructor({fields:r,url:s="search/v1",debounce:t=150}={}){this.fields=r,this.url=s,this.products=p([]),this.#e=C(B,t),m([this.term,this.params],()=>{this.pageNumber.value=1})}async fetch(r){r&&r!==this.term.value&&(this.term.value=r,this.pageNumber.value=1);const s=this.pageSize.value,t=s*(this.pageNumber.value-1),a=await this.#e({term:this.term.value,params:{limit:s,offset:t,...this.params},url:this.url,fields:this.fields});if(a){const{data:o}=a;o.meta&&this.products.splice(0),o.result.forEach(n=>this.products.push(n))}}}const R=v({__name:"SearchModal",props:{term:{}},setup(e,{expose:r}){r();const s=e,t=new M;m(S(s,"term"),o=>t.fetch(o));const a={props:s,searchEngine:t,get searchHistory(){return i},ProductShelf:E};return Object.defineProperty(a,"__isScriptSetup",{enumerable:!1,value:!0}),a}}),z={class:"bg-base-100/80 p-4 backdrop-blur-md lg:rounded"};function D(e,r,s,t,a,o){const n=b("Carousel");return l(),u("article",null,[y("nav",z,[h(n,{class:"gap-2 px-6","wrapper-key":s.term},{default:w(()=>[(l(!0),u(x,null,k(t.searchHistory,(d,f)=>(l(),u("li",{key:f,class:"shrink-0"},N(d),1))),128))]),_:1},8,["wrapper-key"])]),h(t.ProductShelf,{products:t.searchEngine.products,class:"rounded bg-white"},null,8,["products"])])}const $=P(R,[["render",D]]);export{$ as default};