cloudcommerce 0.23.0 → 0.23.2

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 (113) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
  3. package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
  4. package/ecomplus-stores/barra-doce/functions/ssr/src/main/Home.astro +18 -10
  5. package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
  6. package/ecomplus-stores/barra-doce/package.json +2 -3
  7. package/ecomplus-stores/iluminim/functions/many/package.json +3 -3
  8. package/ecomplus-stores/iluminim/functions/ssr/package.json +6 -6
  9. package/ecomplus-stores/iluminim/functions/with-apps/package.json +3 -3
  10. package/ecomplus-stores/iluminim/package.json +2 -3
  11. package/package.json +4 -4
  12. package/packages/api/package.json +1 -1
  13. package/packages/api/types/carts.d.ts +8 -0
  14. package/packages/api/types/orders.d.ts +8 -0
  15. package/packages/apps/affilate-program/package.json +1 -1
  16. package/packages/apps/correios/package.json +1 -1
  17. package/packages/apps/custom-payment/package.json +1 -1
  18. package/packages/apps/custom-shipping/package.json +1 -1
  19. package/packages/apps/datafrete/package.json +1 -1
  20. package/packages/apps/discounts/package.json +1 -1
  21. package/packages/apps/emails/package.json +1 -1
  22. package/packages/apps/fb-conversions/package.json +1 -1
  23. package/packages/apps/flash-courier/package.json +1 -1
  24. package/packages/apps/frenet/package.json +1 -1
  25. package/packages/apps/galaxpay/package.json +1 -1
  26. package/packages/apps/google-analytics/package.json +1 -1
  27. package/packages/apps/jadlog/package.json +1 -1
  28. package/packages/apps/loyalty-points/package.json +1 -1
  29. package/packages/apps/melhor-envio/package.json +1 -1
  30. package/packages/apps/mercadopago/package.json +1 -1
  31. package/packages/apps/pagarme/package.json +1 -1
  32. package/packages/apps/paghiper/package.json +1 -1
  33. package/packages/apps/pix/package.json +1 -1
  34. package/packages/apps/tiny-erp/package.json +1 -1
  35. package/packages/apps/webhooks/package.json +1 -1
  36. package/packages/cli/package.json +1 -1
  37. package/packages/config/package.json +1 -1
  38. package/packages/emails/package.json +1 -1
  39. package/packages/eslint/package.json +3 -3
  40. package/packages/events/package.json +1 -1
  41. package/packages/feeds/package.json +1 -1
  42. package/packages/firebase/package.json +1 -1
  43. package/packages/i18n/lib/en_us/i19minus.txt +1 -0
  44. package/packages/i18n/lib/en_us/i19plus.txt +1 -0
  45. package/packages/i18n/lib/en_us.d.ts +2 -0
  46. package/packages/i18n/lib/en_us.js +2 -0
  47. package/packages/i18n/lib/en_us.js.map +1 -1
  48. package/packages/i18n/lib/pt_br/i19minus.txt +1 -0
  49. package/packages/i18n/lib/pt_br/i19plus.txt +1 -0
  50. package/packages/i18n/lib/pt_br.d.ts +2 -0
  51. package/packages/i18n/lib/pt_br.js +2 -0
  52. package/packages/i18n/lib/pt_br.js.map +1 -1
  53. package/packages/i18n/package.json +1 -1
  54. package/packages/i18n/src/en_us.ts +2 -0
  55. package/packages/i18n/src/pt_br.ts +2 -0
  56. package/packages/modules/package.json +1 -1
  57. package/packages/passport/package.json +1 -1
  58. package/packages/ssr/cloudflare/README.md +3 -0
  59. package/packages/ssr/cloudflare/swr-worker.js +110 -0
  60. package/packages/ssr/lib/firebase/serve-storefront.js +13 -0
  61. package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
  62. package/packages/ssr/package.json +6 -4
  63. package/packages/ssr/src/cloudflare/swr-worker.ts +128 -0
  64. package/packages/ssr/src/cloudflare/tsconfig.json +9 -0
  65. package/packages/ssr/src/firebase/serve-storefront.ts +14 -0
  66. package/packages/ssr/tsconfig.json +2 -1
  67. package/packages/storefront/config/storefront.tailwind.cjs +1 -0
  68. package/packages/storefront/dist/client/_astro/Carousel.63d511ab.js +1 -0
  69. package/packages/storefront/dist/client/_astro/{HeroSlider.794b113c.js → HeroSlider.8d2ea532.js} +1 -1
  70. package/packages/storefront/dist/client/_astro/{PitchBar.a0503ba1.js → PitchBar.c2a2ad79.js} +1 -1
  71. package/packages/storefront/dist/client/_astro/Prices.8572765c.js +1 -0
  72. package/packages/storefront/dist/client/_astro/ProductShelf.4a105932.js +1 -0
  73. package/packages/storefront/dist/client/_astro/ShopHeader.2400b065.js +4 -0
  74. package/packages/storefront/dist/client/_astro/{_...slug_.caa8cb90.css → _...slug_.07c1fa58.css} +1 -1
  75. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.48e557ba.js +1 -0
  76. package/packages/storefront/dist/client/_astro/client.9dbf6b61.js +1 -0
  77. package/packages/storefront/dist/client/_astro/{img.abbe849f.js → img.7def76a1.js} +1 -1
  78. package/packages/storefront/dist/client/_astro/index.c0c35ead.js +1 -0
  79. package/packages/storefront/dist/client/sw.js +1 -1
  80. package/packages/storefront/dist/server/chunks/{_...e1758019.mjs → _...c5a36021.mjs} +3 -3
  81. package/packages/storefront/dist/server/chunks/{account@_@astro.f568e384.mjs → account@_@astro.3e90f29a.mjs} +3 -3
  82. package/packages/storefront/dist/server/chunks/{astro.b875de26.mjs → astro.6adaff02.mjs} +296 -1146
  83. package/packages/storefront/dist/server/chunks/{endpoint@_@js.32b9ab50.mjs → endpoint@_@js.b79eed3b.mjs} +3 -3
  84. package/packages/storefront/dist/server/chunks/{fallback@_@astro.4d902266.mjs → fallback@_@astro.9f73db0f.mjs} +3 -3
  85. package/packages/storefront/dist/server/chunks/{index@_@astro.a80337aa.mjs → index@_@astro.0221a7bd.mjs} +3 -3
  86. package/packages/storefront/dist/server/chunks/{index@_@astro.2072e1c3.mjs → index@_@astro.66b84ac2.mjs} +3 -3
  87. package/packages/storefront/dist/server/chunks/pages/{_...slug_.astro.7c69d6fe.mjs → _...slug_.astro.501582b9.mjs} +779 -119
  88. package/packages/storefront/dist/server/chunks/pages/{account.astro.4b8c2471.mjs → account.astro.53400a42.mjs} +1 -1
  89. package/packages/storefront/dist/server/chunks/pages/{endpoint.js.64061d33.mjs → endpoint.js.4c130895.mjs} +1 -1
  90. package/packages/storefront/dist/server/chunks/pages/{fallback.astro.f225bb85.mjs → fallback.astro.8d1c6076.mjs} +2 -2
  91. package/packages/storefront/dist/server/chunks/pages/{index.astro.a972914a.mjs → index.astro.f1104ab2.mjs} +15 -338
  92. package/packages/storefront/dist/server/entry.mjs +31 -23
  93. package/packages/storefront/dist/server/renderers.mjs +2 -2
  94. package/packages/storefront/package.json +10 -10
  95. package/packages/storefront/src/lib/components/Carousel.vue +0 -3
  96. package/packages/storefront/src/lib/components/CheckoutLink.vue +23 -0
  97. package/packages/storefront/src/lib/components/Drawer.vue +1 -1
  98. package/packages/storefront/src/lib/components/QuantitySelector.vue +107 -0
  99. package/packages/storefront/src/lib/components/QuantitySelectorControl.vue +35 -0
  100. package/packages/storefront/src/lib/composables/use-cart-item.ts +20 -14
  101. package/packages/storefront/src/lib/composables/use-sticky-header.ts +18 -2
  102. package/packages/storefront/src/lib/state/customer-session.ts +2 -2
  103. package/packages/storefront/src/lib/state/modules-info.ts +1 -1
  104. package/packages/storefront/src/lib/state/shopping-cart/parse-product.ts +23 -21
  105. package/packages/storefront/src/lib/state/shopping-cart.ts +13 -4
  106. package/packages/types/package.json +1 -1
  107. package/packages/storefront/dist/client/_astro/Carousel.6824b5e2.js +0 -1
  108. package/packages/storefront/dist/client/_astro/ProductShelf.7fca4465.js +0 -1
  109. package/packages/storefront/dist/client/_astro/ShopHeader.fe08e043.js +0 -4
  110. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.4cb7dd76.js +0 -1
  111. package/packages/storefront/dist/client/_astro/api.4984c5be.js +0 -1
  112. package/packages/storefront/dist/client/_astro/client.0fb6b44e.js +0 -1
  113. package/packages/storefront/dist/client/_astro/index.c723d38d.js +0 -1
@@ -0,0 +1,110 @@
1
+ // Compiled version at https://github.com/ecomplus/cloud-commerce/blob/main/packages/ssr/cloudflare/swr-worker.js
2
+ // Inspired by https://gist.github.com/wilsonpage/a4568d776ee6de188999afe6e2d2ee69
3
+ const HEADER_CACHE_CONTROL = 'Cache-Control';
4
+ const HEADER_SSR_TOOK = 'X-Load-Took';
5
+ const HEADER_STALE_AT = 'X-Edge-Stale-At';
6
+ const HEADER_STYLE_LINK = 'X-Style-Link';
7
+ const resolveCacheControl = (response) => {
8
+ const cacheControl = response.headers.get(HEADER_CACHE_CONTROL);
9
+ if (!cacheControl || !response.headers.get(HEADER_SSR_TOOK)) {
10
+ return { cacheControl };
11
+ }
12
+ const parts = cacheControl.replace(/ +/g, '').split(',');
13
+ const { 'max-age': maxAge, 's-maxage': sMaxAge, 'stale-while-revalidate': staleMaxAge } = parts.reduce((result, part) => {
14
+ const [key, value] = part.split('=');
15
+ result[key] = Number(value) || 0;
16
+ return result;
17
+ }, {});
18
+ const cdnMaxAge = typeof sMaxAge === 'number' ? sMaxAge : maxAge;
19
+ if (!cdnMaxAge || cdnMaxAge <= 1 || !staleMaxAge || staleMaxAge <= cdnMaxAge) {
20
+ return { cacheControl };
21
+ }
22
+ const staleAt = Date.now() + (cdnMaxAge * 1000);
23
+ return {
24
+ cacheControl: `public, max-age=${maxAge}, must-revalidate`
25
+ + `, s-maxage=${staleMaxAge}`,
26
+ staleAt,
27
+ };
28
+ };
29
+ const addHeaders = (response, headers) => {
30
+ const res = new Response(response.clone().body, {
31
+ status: response.status,
32
+ headers: response.headers,
33
+ });
34
+ Object.keys(headers).forEach((key) => {
35
+ res.headers.delete(key);
36
+ const value = headers[key];
37
+ if (value) {
38
+ res.headers.append(key, value);
39
+ }
40
+ });
41
+ return res;
42
+ };
43
+ const toCacheRes = (response, cacheControl, staleAt) => {
44
+ if (cacheControl === undefined) {
45
+ const parsedCacheControl = resolveCacheControl(response);
46
+ cacheControl = parsedCacheControl.cacheControl;
47
+ staleAt = parsedCacheControl.staleAt;
48
+ }
49
+ return addHeaders(response, {
50
+ [HEADER_CACHE_CONTROL]: cacheControl,
51
+ [HEADER_STALE_AT]: `${(staleAt || 0)}`,
52
+ 'set-cookie': null,
53
+ 'cf-cache-status': null,
54
+ vary: null,
55
+ });
56
+ };
57
+ const swr = async (event) => {
58
+ if (event.request.method !== 'GET') {
59
+ return fetch(event.request);
60
+ }
61
+ const { pathname } = new URL(event.request.url);
62
+ if (pathname === '/_image'
63
+ || pathname.startsWith('/~')
64
+ || pathname.startsWith('/api/')
65
+ || pathname.startsWith('/_feeds/')) {
66
+ return fetch(event.request);
67
+ }
68
+ const [uri] = event.request.url.split('?', 2);
69
+ const request = new Request(`${uri}?t=${Date.now()}`, event.request);
70
+ const cacheKey = new Request(`${uri}?v=29`, {
71
+ method: event.request.method,
72
+ });
73
+ const cachedRes = await caches.default.match(cacheKey);
74
+ let edgeState = 'miss';
75
+ if (cachedRes) {
76
+ const cachedStaleAt = Number(cachedRes.headers.get(HEADER_STALE_AT));
77
+ if (!(cachedStaleAt > 0)) {
78
+ edgeState = 'bypass';
79
+ } else if (Date.now() > cachedStaleAt) {
80
+ edgeState = 'stale';
81
+ event.waitUntil((async () => {
82
+ const newCacheRes = toCacheRes(await fetch(request));
83
+ return caches.default.put(cacheKey, newCacheRes);
84
+ })());
85
+ } else {
86
+ edgeState = 'fresh';
87
+ }
88
+ }
89
+ const response = cachedRes || await fetch(request);
90
+ const { cacheControl, staleAt } = resolveCacheControl(response);
91
+ if (!cachedRes && response.ok) {
92
+ const newCacheRes = toCacheRes(response, cacheControl, staleAt);
93
+ event.waitUntil(caches.default.put(cacheKey, newCacheRes));
94
+ }
95
+ const headers = {
96
+ [HEADER_CACHE_CONTROL]: cacheControl,
97
+ 'x-edge-state': edgeState,
98
+ };
99
+ const styleLink = response.headers.get(HEADER_STYLE_LINK);
100
+ if (styleLink) {
101
+ // https://developers.cloudflare.com/workers/examples/103-early-hints/
102
+ headers.link = `</${styleLink}>; rel=preload; as=style`;
103
+ headers[HEADER_STYLE_LINK] = null;
104
+ }
105
+ return addHeaders(response, headers);
106
+ };
107
+ // eslint-disable-next-line no-restricted-globals
108
+ addEventListener('fetch', (event) => {
109
+ event.respondWith(swr(event));
110
+ });
@@ -176,6 +176,19 @@ export default async (req, res) => {
176
176
  });
177
177
  }
178
178
  })();
179
+ /*
180
+ Check Response methods used by Astro Node.js integration:
181
+ https://github.com/withastro/astro/blob/main/packages/integrations/node/src/nodeMiddleware.ts
182
+ */
183
+ const _writeHead = res.writeHead;
184
+ /* eslint-disable prefer-rest-params */
185
+ // @ts-ignore
186
+ res.writeHead = function writeHead(status, headers) {
187
+ if (status === 200 && headers && cssFilename) {
188
+ headers['X-Style-Link'] = cssFilename;
189
+ }
190
+ _writeHead.apply(res, [status, headers]);
191
+ };
179
192
  /*
180
193
  https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
181
194
  import { handler as renderStorefront } from '../dist/server/entry.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"serve-storefront.js","sourceRoot":"","sources":["../../src/firebase/serve-storefront.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAW/C,MAAM,EACJ,mBAAmB,EACnB,eAAe,EACf,iBAAiB,GAClB,GAAG,OAAO,CAAC,GAAG,CAAC;AAEhB,MAAM,OAAO,GAAG,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AACrD,IAAI,cAAsB,CAAC;AAE3B,MAAM,WAAW,GAAiB,EAAE,CAAC;AAErC,IAAI,WAA+B,CAAC;AACpC,MAAM,qBAAqB,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACpD,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,6BAA6B,CAAC,EAAE,OAAO,CAAC;SAChE,IAAI,CAAC,CAAC,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1C,MAA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"module",
4
- "version": "0.23.0",
4
+ "version": "0.23.2",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -20,23 +20,25 @@
20
20
  },
21
21
  "homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/ssr#readme",
22
22
  "scripts": {
23
- "build": "bash ../../scripts/build-lib.sh"
23
+ "build": "bash ../../scripts/build-lib.sh",
24
+ "build:workers": "npx tsc -p src/cloudflare --outDir cloudflare && npx eslint --ext .js cloudflare --fix"
24
25
  },
25
26
  "dependencies": {
26
- "@astrojs/node": "5.3.0",
27
+ "@astrojs/node": "5.3.2",
27
28
  "@cloudcommerce/api": "workspace:*",
28
29
  "@cloudcommerce/firebase": "workspace:*",
29
30
  "@cloudcommerce/i18n": "workspace:*",
30
31
  "@ecomplus/utils": "1.5.0-rc.5",
31
32
  "@headlessui/vue": "^1.7.15",
32
33
  "@vueuse/core": "10.3.0",
33
- "astro": "2.9.6",
34
+ "astro": "2.10.1",
34
35
  "firebase-admin": "^11.10.1",
35
36
  "firebase-functions": "^4.4.1",
36
37
  "vue": "^3.3.4"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@cloudcommerce/types": "workspace:*",
41
+ "@cloudflare/workers-types": "^4.20230801.0",
40
42
  "@firebase/app-types": "^0.9.0"
41
43
  }
42
44
  }
@@ -0,0 +1,128 @@
1
+ // Compiled version at https://github.com/ecomplus/cloud-commerce/blob/main/packages/ssr/cloudflare/swr-worker.js
2
+ // Inspired by https://gist.github.com/wilsonpage/a4568d776ee6de188999afe6e2d2ee69
3
+
4
+ const HEADER_CACHE_CONTROL = 'Cache-Control';
5
+ const HEADER_SSR_TOOK = 'X-Load-Took';
6
+ const HEADER_STALE_AT = 'X-Edge-Stale-At';
7
+ const HEADER_STYLE_LINK = 'X-Style-Link';
8
+
9
+ interface ParsedCacheControl {
10
+ 'max-age'?: number;
11
+ 's-maxage'?: number;
12
+ 'stale-while-revalidate'?: number;
13
+ }
14
+
15
+ const resolveCacheControl = (response: Response) => {
16
+ const cacheControl = response.headers.get(HEADER_CACHE_CONTROL);
17
+ if (!cacheControl || !response.headers.get(HEADER_SSR_TOOK)) {
18
+ return { cacheControl };
19
+ }
20
+ const parts = cacheControl.replace(/ +/g, '').split(',');
21
+ const {
22
+ 'max-age': maxAge,
23
+ 's-maxage': sMaxAge,
24
+ 'stale-while-revalidate': staleMaxAge,
25
+ } = parts.reduce((result, part) => {
26
+ const [key, value] = part.split('=');
27
+ result[key as 'max-age'] = Number(value) || 0;
28
+ return result;
29
+ }, {} as ParsedCacheControl);
30
+ const cdnMaxAge = typeof sMaxAge === 'number' ? sMaxAge : maxAge;
31
+ if (!cdnMaxAge || cdnMaxAge <= 1 || !staleMaxAge || staleMaxAge <= cdnMaxAge) {
32
+ return { cacheControl };
33
+ }
34
+ const staleAt = Date.now() + (cdnMaxAge * 1000);
35
+ return {
36
+ cacheControl: `public, max-age=${maxAge}, must-revalidate`
37
+ + `, s-maxage=${staleMaxAge}`,
38
+ staleAt,
39
+ };
40
+ };
41
+
42
+ const addHeaders = (response: Response, headers: Record<string, string | null>) => {
43
+ const res = new Response(response.clone().body, {
44
+ status: response.status,
45
+ headers: response.headers,
46
+ });
47
+ Object.keys(headers).forEach((key) => {
48
+ res.headers.delete(key);
49
+ const value = headers[key];
50
+ if (value) {
51
+ res.headers.append(key, value);
52
+ }
53
+ });
54
+ return res;
55
+ };
56
+
57
+ const toCacheRes = (response: Response, cacheControl?: string | null, staleAt?: number) => {
58
+ if (cacheControl === undefined) {
59
+ const parsedCacheControl = resolveCacheControl(response);
60
+ cacheControl = parsedCacheControl.cacheControl;
61
+ staleAt = parsedCacheControl.staleAt;
62
+ }
63
+ return addHeaders(response, {
64
+ [HEADER_CACHE_CONTROL]: cacheControl,
65
+ [HEADER_STALE_AT]: `${(staleAt || 0)}`,
66
+ 'set-cookie': null,
67
+ 'cf-cache-status': null,
68
+ vary: null,
69
+ });
70
+ };
71
+
72
+ const swr = async (event: FetchEvent) => {
73
+ if (event.request.method !== 'GET') {
74
+ return fetch(event.request);
75
+ }
76
+ const { pathname } = new URL(event.request.url);
77
+ if (
78
+ pathname === '/_image'
79
+ || pathname.startsWith('/~')
80
+ || pathname.startsWith('/api/')
81
+ || pathname.startsWith('/_feeds/')
82
+ ) {
83
+ return fetch(event.request);
84
+ }
85
+ const [uri] = event.request.url.split('?', 2);
86
+ const request = new Request(`${uri}?t=${Date.now()}`, event.request);
87
+ const cacheKey = new Request(`${uri}?v=29`, {
88
+ method: event.request.method,
89
+ });
90
+ const cachedRes = await caches.default.match(cacheKey);
91
+ let edgeState = 'miss';
92
+ if (cachedRes) {
93
+ const cachedStaleAt = Number(cachedRes.headers.get(HEADER_STALE_AT));
94
+ if (!(cachedStaleAt > 0)) {
95
+ edgeState = 'bypass';
96
+ } else if (Date.now() > cachedStaleAt) {
97
+ edgeState = 'stale';
98
+ event.waitUntil((async () => {
99
+ const newCacheRes = toCacheRes(await fetch(request));
100
+ return caches.default.put(cacheKey, newCacheRes);
101
+ })());
102
+ } else {
103
+ edgeState = 'fresh';
104
+ }
105
+ }
106
+ const response = cachedRes || await fetch(request);
107
+ const { cacheControl, staleAt } = resolveCacheControl(response);
108
+ if (!cachedRes && response.ok) {
109
+ const newCacheRes = toCacheRes(response, cacheControl, staleAt);
110
+ event.waitUntil(caches.default.put(cacheKey, newCacheRes));
111
+ }
112
+ const headers: Record<string, string | null> = {
113
+ [HEADER_CACHE_CONTROL]: cacheControl,
114
+ 'x-edge-state': edgeState,
115
+ };
116
+ const styleLink = response.headers.get(HEADER_STYLE_LINK);
117
+ if (styleLink) {
118
+ // https://developers.cloudflare.com/workers/examples/103-early-hints/
119
+ headers.link = `</${styleLink}>; rel=preload; as=style`;
120
+ headers[HEADER_STYLE_LINK] = null;
121
+ }
122
+ return addHeaders(response, headers);
123
+ };
124
+
125
+ // eslint-disable-next-line no-restricted-globals
126
+ addEventListener('fetch', (event) => {
127
+ event.respondWith(swr(event));
128
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "lib": ["esnext"],
6
+ "types": ["@cloudflare/workers-types"],
7
+ "strict": true,
8
+ }
9
+ }
@@ -1,3 +1,4 @@
1
+ import type { OutgoingHttpHeaders } from 'node:http';
1
2
  import type { Request, Response } from 'firebase-functions';
2
3
  import { join as joinPath } from 'node:path';
3
4
  import { readFile } from 'node:fs/promises';
@@ -200,6 +201,19 @@ export default async (req: Request, res: Response) => {
200
201
  });
201
202
  }
202
203
  })();
204
+ /*
205
+ Check Response methods used by Astro Node.js integration:
206
+ https://github.com/withastro/astro/blob/main/packages/integrations/node/src/nodeMiddleware.ts
207
+ */
208
+ const _writeHead = res.writeHead;
209
+ /* eslint-disable prefer-rest-params */
210
+ // @ts-ignore
211
+ res.writeHead = function writeHead(status: number, headers: OutgoingHttpHeaders) {
212
+ if (status === 200 && headers && cssFilename) {
213
+ headers['X-Style-Link'] = cssFilename;
214
+ }
215
+ _writeHead.apply(res, [status, headers]);
216
+ };
203
217
 
204
218
  /*
205
219
  https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
@@ -1,3 +1,4 @@
1
1
  {
2
- "extends": "../../tsconfig.json"
2
+ "extends": "../../tsconfig.json",
3
+ "exclude": ["src/cloudflare/**/*"],
3
4
  }
@@ -16,6 +16,7 @@ let defaultThemeOptions = {
16
16
  'facebook',
17
17
  'twitter',
18
18
  'instagram',
19
+ 'threads',
19
20
  'linkedin',
20
21
  'youtube',
21
22
  'google',
@@ -0,0 +1 @@
1
+ import{a as G,e as J,c as Q}from"./index.c0c35ead.js";import{_ as K,d as U,B as X,o as B,a as q,u as v,b as Y,n as $,j as c,k as h,t as D,c as F,l as Z,E as ee,R as te,C as ae,g as oe,w as P,h as le,e as M,H as se,I as re}from"./_plugin-vue_export-helper.48e557ba.js";const ne=U({__name:"CarouselControl",props:{isPrev:{type:Boolean,default:!1}},setup(r,{expose:u}){u();const{changeSlide:l}=X(L),t={changeSlide:l};return Object.defineProperty(t,"__isScriptSetup",{enumerable:!1,value:!0}),t}}),ue=["aria-label","data-carousel-control"];function ie(r,u,l,t,n,o){return B(),q("button",{type:"button","aria-label":l.isPrev?"Anterior":"Próximo",onClick:u[0]||(u[0]=m=>t.changeSlide(l.isPrev?-1:1)),class:$(["group absolute top-0 z-1",l.isPrev?"left-0":"right-0"]),"data-carousel-control":l.isPrev?"previous":"next"},[v(r.$slots,"default",{},()=>[Y("i",{class:$(["m-0",l.isPrev?"i-chevron-left group-active:-translate-x-1":"i-chevron-right group-active:translate-x-1"])},null,2)])],10,ue)}const ce=K(ne,[["render",ie]]),L=Symbol("carousel"),de=U({__name:"Carousel",props:{as:{default:"ul"},modelValue:{default:1},autoplay:{}},emits:["update:modelValue"],setup(r,{expose:u,emit:l}){u();const t=r,n=c(0);h(D(t,"modelValue"),e=>{n.value=e-1},{immediate:!0}),h(n,(e,a)=>{e!==a&&l("update:modelValue",e+1)});const o=c(null),{x:m,isScrolling:T,arrivedState:_}=G(o),W=F(()=>_.left),I=F(()=>_.right),s=c([]),g=c(0),p=c(0),k=c(0),R=()=>{o.value&&(g.value=o.value.scrollWidth,p.value=o.value.offsetWidth)},V=()=>{if(!o.value)return;let e=[...o.value.children];e.length===1&&e[0].tagName.endsWith("SLOT")&&(e=[...e[0].children]),s.value=e.map(a=>({offsetLeft:a.offsetLeft,width:a.offsetWidth}))},z=e=>{let a=n.value+e;if(a>=s.value.length)return 0;a<0&&(a=s.value.length+a);const{offsetLeft:y,width:d}=s.value[a]||{};return d?y:0},x=()=>{const e=s.value.findIndex(a=>Math.abs(a.offsetLeft-m.value)<=5);e>-1&&(n.value=e||0)},E=()=>{const e=g.value-p.value;k.value=s.value.findIndex(({offsetLeft:a})=>a>=e-5)};let i;const f=()=>{t.autoplay&&(clearTimeout(i),i=setTimeout(()=>{C(1)},t.autoplay))},C=(e,a=!0)=>{if(s.value.length<2)return;if(a&&(e===1||e===-1)){let d=0,A=0;for(let S=n.value;S<s.value.length;S++){const{width:H}=s.value[S]||{};if(H&&(d+=1,A+=H,A>=p.value))break}d&&(e=e>0?d:-d)}const y=z(e);o.value?.scrollTo({left:y,behavior:"smooth"}),f()};h(T,e=>{e?clearTimeout(i):(x(),f())});const O=c(null),N=J(O);h(N,e=>{e?clearTimeout(i):f()});const w=()=>{o.value&&(R(),V(),x(),E())},b=Q(()=>{o.value&&(o.value.scrollLeft=0,w())},400);Z(()=>{w(),ee(()=>{o.value&&[...o.value.children].forEach(e=>{e.setAttribute("tabindex","0")})}),f(),window.addEventListener("resize",b)}),te(()=>{window.removeEventListener("resize",b),clearTimeout(i)}),ae(L,{autoplay:D(t,"autoplay"),changeSlide:C,isBoundLeft:W,isBoundRight:I});const j={carouselKey:L,props:t,emit:l,currentIndex:n,wrapper:o,currentPos:m,isScrolling:T,arrivedState:_,isBoundLeft:W,isBoundRight:I,slidesWidth:s,wrapperScrollWidth:g,wrapperVisibleWidth:p,indexCount:k,calcWrapperWidth:R,calcSlidesWidth:V,calcNextOffsetLeft:z,calcCurrentIndex:x,calcIndexCount:E,get autoplayTimer(){return i},set autoplayTimer(e){i=e},restartAutoplay:f,changeSlide:C,carousel:O,isHovered:N,calcOnInit:w,onResize:b,CarouselControl:ce};return Object.defineProperty(j,"__isScriptSetup",{enumerable:!1,value:!0}),j}}),fe={ref:"carousel",class:"relative","data-carousel":""};function ve(r,u,l,t,n,o){return B(),q("div",fe,[(B(),oe(le(l.as),{ref:"wrapper",class:"flex overflow-x-scroll overflow-y-hidden list-none m-0 p-0 snap-x snap-mandatory scroll-smooth [&>*]:snap-start [&>*]:outline-none",style:{"scrollbar-width":"none","-webkit-overflow-scrolling":"touch","-ms-overflow-style":"none"},"data-carousel-wrapper":""},{default:P(()=>[v(r.$slots,"default")]),_:3},512)),v(r.$slots,"controls",se(re({changeSlide:t.changeSlide,isBoundLeft:t.isBoundLeft,isBoundRight:t.isBoundRight,currentPage:t.currentIndex+1,pageCount:t.indexCount+1})),()=>[M(t.CarouselControl,{"is-prev":""},{default:P(()=>[v(r.$slots,"previous")]),_:3}),M(t.CarouselControl,null,{default:P(()=>[v(r.$slots,"next")]),_:3})])],512)}const me=K(de,[["render",ve]]);export{me as C,ce as a};
@@ -1 +1 @@
1
- import{c,_ as w,d as y,o as s,a as o,g as f,w as l,u as k,n as b,h as p,y as v,x,i as u,e as d,f as T,v as C,b as m,F as S,r as B,K as H}from"./_plugin-vue_export-helper.4cb7dd76.js";import{C as j,a as L}from"./Carousel.6824b5e2.js";import{p as g}from"./index.c723d38d.js";import"./session-utm.744b0db3.js";const N=a=>{const r=c(()=>a.title?g(a.title).value:""),t=c(()=>a.subtitle?g(a.subtitle).value:""),e=c(()=>a.buttonText?g(a.buttonText).value:""),i=c(()=>!!(r.value||t.value||e.value));return{parsedTitle:r,parsedSubtitle:t,parsedButtonText:e,hasHeader:i}},P=y({__name:"Banner",props:{img:{},alt:{},mobileImg:{},href:{},title:{},subtitle:{},buttonLink:{},buttonText:{},headingTag:{default:"h3"}},setup(a,{expose:r}){r();const t=a,{hasHeader:e,parsedTitle:i,parsedSubtitle:_,parsedButtonText:h}=N(t),n={props:t,hasHeader:e,parsedTitle:i,parsedSubtitle:_,parsedButtonText:h};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),V={key:0,class:"p-12 xl:ps-32 mb-3 sm:mb-0"},D={key:1,class:"text-lg mt-4 md:mt-6"};function z(a,r,t,e,i,_){return s(),o("div",{class:b(["mx-auto overflow-x-hidden",e.hasHeader?"grid grid-cols-1 sm:grid-cols-2 items-center":null])},[(s(),f(p(t.href?"a-link":"span"),{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:l(()=>[k(a.$slots,"picture")]),_:3},8,["href","class"])),e.hasHeader?(s(),o("div",V,[e.parsedTitle?(s(),f(p(t.headingTag),{key:0,class:"ui-title mt-1"},{default:l(()=>[v(x(e.parsedTitle),1)]),_:1})):u("",!0),e.parsedSubtitle?(s(),o("p",D,x(e.parsedSubtitle),1)):u("",!0),e.parsedButtonText?(s(),f(p(t.buttonLink?"a-link":"span"),{key:2,href:t.buttonLink,class:"ui-btn-lg ui-btn-contrast min-w-[150px] mt-7 md:mt-10"},{default:l(()=>[v(x(e.parsedButtonText),1)]),_:1},8,["href"])):u("",!0)])):u("",!0)],2)}const F=w(P,[["render",z]]),O=y({__name:"HeroSlider",props:{autoplay:{},slides:{}},setup(a,{expose:r}){r();const t={Carousel:j,CarouselControl:L,Banner:F};return Object.defineProperty(t,"__isScriptSetup",{enumerable:!1,value:!0}),t}}),E={class:"relative mx-auto"},I={class:"absolute z-10 bottom-5 flex justify-end items-center w-screen right-5 xl:right-auto xl:max-w-screen-xl xl:left-1/2 xl:-ms-[640px]"},K={class:"relative w-20 h-10 rounded-full bg-white/50 text-primary shadow-sm ring-1 ring-black/5"},q=m("i",{class:"i-arrow-left"},null,-1),A=m("i",{class:"i-arrow-right"},null,-1);function G(a,r,t,e,i,_){return s(),o("section",E,[d(e.Carousel,{autoplay:t.autoplay,class:"secondary [&>*]:items-center"},{controls:l(()=>[T(m("div",I,[m("div",K,[d(e.CarouselControl,{class:"w-10 h-10 rounded-full hover:bg-primary/10","is-prev":""},{default:l(()=>[q]),_:1}),d(e.CarouselControl,{class:"w-10 h-10 rounded-full hover:bg-primary/10"},{default:l(()=>[A]),_:1})])],512),[[C,t.slides.length>1]])]),default:l(()=>[(s(!0),o(S,null,B(t.slides,(h,n)=>(s(),o("li",{key:n,class:"shrink-0 basis-full"},[d(e.Banner,H({...h,headingTag:n===0?"h2":"h3"},{class:"w-screen max-w-screen-2xl"}),{picture:l(()=>[k(a.$slots,`picture-${n}`)]),_:2},1040)]))),128))]),_:3},8,["autoplay"])])}const U=w(O,[["render",G]]);export{U as default};
1
+ import{c,_ as w,d as y,o as s,a as o,g as f,w as l,u as k,n as b,h as p,y as v,x,i as u,e as d,f as T,v as C,b as m,F as S,r as B,L as H}from"./_plugin-vue_export-helper.48e557ba.js";import{C as L,a as j}from"./Carousel.63d511ab.js";import{p as g}from"./index.c0c35ead.js";import"./session-utm.744b0db3.js";const N=a=>{const r=c(()=>a.title?g(a.title).value:""),t=c(()=>a.subtitle?g(a.subtitle).value:""),e=c(()=>a.buttonText?g(a.buttonText).value:""),i=c(()=>!!(r.value||t.value||e.value));return{parsedTitle:r,parsedSubtitle:t,parsedButtonText:e,hasHeader:i}},P=y({__name:"Banner",props:{img:{},alt:{},mobileImg:{},href:{},title:{},subtitle:{},buttonLink:{},buttonText:{},headingTag:{default:"h3"}},setup(a,{expose:r}){r();const t=a,{hasHeader:e,parsedTitle:i,parsedSubtitle:_,parsedButtonText:h}=N(t),n={props:t,hasHeader:e,parsedTitle:i,parsedSubtitle:_,parsedButtonText:h};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),V={key:0,class:"p-12 xl:ps-32 mb-3 sm:mb-0"},D={key:1,class:"text-lg mt-4 md:mt-6"};function z(a,r,t,e,i,_){return s(),o("div",{class:b(["mx-auto overflow-x-hidden",e.hasHeader?"grid grid-cols-1 sm:grid-cols-2 items-center":null])},[(s(),f(p(t.href?"a-link":"span"),{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:l(()=>[k(a.$slots,"picture")]),_:3},8,["href","class"])),e.hasHeader?(s(),o("div",V,[e.parsedTitle?(s(),f(p(t.headingTag),{key:0,class:"ui-title mt-1"},{default:l(()=>[v(x(e.parsedTitle),1)]),_:1})):u("",!0),e.parsedSubtitle?(s(),o("p",D,x(e.parsedSubtitle),1)):u("",!0),e.parsedButtonText?(s(),f(p(t.buttonLink?"a-link":"span"),{key:2,href:t.buttonLink,class:"ui-btn-lg ui-btn-contrast min-w-[150px] mt-7 md:mt-10"},{default:l(()=>[v(x(e.parsedButtonText),1)]),_:1},8,["href"])):u("",!0)])):u("",!0)],2)}const F=w(P,[["render",z]]),O=y({__name:"HeroSlider",props:{autoplay:{},slides:{}},setup(a,{expose:r}){r();const t={Carousel:L,CarouselControl:j,Banner:F};return Object.defineProperty(t,"__isScriptSetup",{enumerable:!1,value:!0}),t}}),E={class:"relative mx-auto"},I={class:"absolute z-10 bottom-5 flex justify-end items-center w-screen right-5 xl:right-auto xl:max-w-screen-xl xl:left-1/2 xl:-ms-[640px]"},q={class:"relative w-20 h-10 rounded-full bg-white/50 text-primary shadow-sm ring-1 ring-black/5"},A=m("i",{class:"i-arrow-left"},null,-1),G=m("i",{class:"i-arrow-right"},null,-1);function J(a,r,t,e,i,_){return s(),o("section",E,[d(e.Carousel,{autoplay:t.autoplay,class:"secondary [&>*]:items-center"},{controls:l(()=>[T(m("div",I,[m("div",q,[d(e.CarouselControl,{class:"w-10 h-10 rounded-full hover:bg-primary/10","is-prev":""},{default:l(()=>[A]),_:1}),d(e.CarouselControl,{class:"w-10 h-10 rounded-full hover:bg-primary/10"},{default:l(()=>[G]),_:1})])],512),[[C,t.slides.length>1]])]),default:l(()=>[(s(!0),o(S,null,B(t.slides,(h,n)=>(s(),o("li",{key:n,class:"shrink-0 basis-full"},[d(e.Banner,H({...h,headingTag:n===0?"h2":"h3"},{class:"w-screen max-w-screen-2xl"}),{picture:l(()=>[k(a.$slots,`picture-${n}`)]),_:2},1040)]))),128))]),_:3},8,["autoplay"])])}const U=w(O,[["render",J]]);export{U as default};
@@ -1 +1 @@
1
- import{s as _,c as u,_ as f,d as m,a as l,b as h,e as d,w as p,o,f as v,v as C,F as g,r as b,g as w,h as x,n as y,i as S}from"./_plugin-vue_export-helper.4cb7dd76.js";import{p as k}from"./index.c723d38d.js";import{C as B,a as P}from"./Carousel.6824b5e2.js";import"./session-utm.744b0db3.js";function V(t,s){{const a=btoa(JSON.stringify({filename:t}));window.parent.postMessage(JSON.parse(JSON.stringify({type:"open",filename:t,id:a})),window.location.origin),window.addEventListener("message",e=>{e.data.id===a&&s(e.data.data)})}}const L=t=>{const s=_(null);return window.$isCmsPreview&&V(t,a=>{s.value=a}),{liveContent:s}},N=t=>{const s={slides:[]};return t.header?.pitch_bar&&(s.slides=t.header.pitch_bar),s},O=t=>{const{liveContent:s}=L("layout"),a=u(()=>(s.value?N(s.value).slides:t.slides).map(({html:n})=>k(n).value.replace(/<\/?p>/g,"").replace(/&lt;(\/?d-md)&gt;/g,"<$1>"))),e=u(()=>a.value.filter(r=>r).length);return{parsedContents:a,countValidSlides:e}},J=m({__name:"PitchBar",props:{slides:{}},setup(t,{expose:s}){s();const a=t,{parsedContents:e,countValidSlides:r}=O(a),n={props:a,parsedContents:e,countValidSlides:r,Carousel:B,CarouselControl:P};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),M={class:"bg-base-100 relative z-20"},z={class:"container md:w-2/3 mx-auto px-3 py-1"},D=["innerHTML"],E={class:"text-xl leading-none text-base-400"};function F(t,s,a,e,r,n){return o(),l("div",M,[h("div",z,[d(e.Carousel,{autoplay:e.countValidSlides>1?7e3:void 0},{controls:p(()=>[v(h("div",E,[d(e.CarouselControl,{class:"pr-2 bg-base-100 hover:text-base-700","is-prev":""}),d(e.CarouselControl,{class:"pl-2 bg-base-100 hover:text-base-700"})],512),[[C,e.countValidSlides>1]])]),default:p(()=>[(o(!0),l(g,null,b(a.slides,(i,c)=>(o(),l("li",{key:c,class:"shrink-0 basis-full h-full text-center"},[(o(),w(x(i.href?"ALink":"span"),{href:i.href,target:i.target,class:y(["inline-block px-8",i.href?"hover:underline":null])},{default:p(()=>[e.parsedContents[c]?(o(),l("span",{key:0,innerHTML:e.parsedContents[c],class:"prose text-sm text-base-800"},null,8,D)):S("",!0)]),_:2},1032,["href","target","class"]))]))),128))]),_:1},8,["autoplay"])])])}const R=f(J,[["render",F]]);export{R as default};
1
+ import{s as _,c as u,_ as f,d as m,a as l,b as h,e as d,w as p,o,f as v,v as C,F as g,r as b,g as w,h as x,n as y,i as S}from"./_plugin-vue_export-helper.48e557ba.js";import{p as k}from"./index.c0c35ead.js";import{C as B,a as P}from"./Carousel.63d511ab.js";import"./session-utm.744b0db3.js";function V(t,s){{const a=btoa(JSON.stringify({filename:t}));window.parent.postMessage(JSON.parse(JSON.stringify({type:"open",filename:t,id:a})),window.location.origin),window.addEventListener("message",e=>{e.data.id===a&&s(e.data.data)})}}const L=t=>{const s=_(null);return window.$isCmsPreview&&V(t,a=>{s.value=a}),{liveContent:s}},N=t=>{const s={slides:[]};return t.header?.pitch_bar&&(s.slides=t.header.pitch_bar),s},O=t=>{const{liveContent:s}=L("layout"),a=u(()=>(s.value?N(s.value).slides:t.slides).map(({html:n})=>k(n).value.replace(/<\/?p>/g,"").replace(/&lt;(\/?d-md)&gt;/g,"<$1>"))),e=u(()=>a.value.filter(r=>r).length);return{parsedContents:a,countValidSlides:e}},J=m({__name:"PitchBar",props:{slides:{}},setup(t,{expose:s}){s();const a=t,{parsedContents:e,countValidSlides:r}=O(a),n={props:a,parsedContents:e,countValidSlides:r,Carousel:B,CarouselControl:P};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),M={class:"bg-base-100 relative z-20"},z={class:"container md:w-2/3 mx-auto px-3 py-1"},D=["innerHTML"],E={class:"text-xl leading-none text-base-400"};function F(t,s,a,e,r,n){return o(),l("div",M,[h("div",z,[d(e.Carousel,{autoplay:e.countValidSlides>1?7e3:void 0},{controls:p(()=>[v(h("div",E,[d(e.CarouselControl,{class:"pr-2 bg-base-100 hover:text-base-700","is-prev":""}),d(e.CarouselControl,{class:"pl-2 bg-base-100 hover:text-base-700"})],512),[[C,e.countValidSlides>1]])]),default:p(()=>[(o(!0),l(g,null,b(a.slides,(i,c)=>(o(),l("li",{key:c,class:"shrink-0 basis-full h-full text-center"},[(o(),w(x(i.href?"ALink":"span"),{href:i.href,target:i.target,class:y(["inline-block px-8",i.href?"hover:underline":null])},{default:p(()=>[e.parsedContents[c]?(o(),l("span",{key:0,innerHTML:e.parsedContents[c],class:"prose text-sm text-base-800"},null,8,D)):S("",!0)]),_:2},1032,["href","target","class"]))]))),128))]),_:1},8,["autoplay"])])])}const R=f(J,[["render",F]]);export{R as default};
@@ -0,0 +1 @@
1
+ import{P as J,Q as L,k as K,N as x,c,O as w,_ as U,d as Q,m as G,o as _,a as h,x as d,i as p,b as O,y as V,n as M,e as q,w as B}from"./_plugin-vue_export-helper.48e557ba.js";import{i as H}from"./img.7def76a1.js";import{h as Y,j as F,k as X,l as Z}from"./index.c0c35ead.js";const tt=(t,e=J.get("lang"))=>e&&t.i18n&&t.i18n[e]?t.i18n[e]:t.name||t.title||H(t.i18n,e)||"",Mt=tt,et=()=>{let t=Math.floor(Math.random()*1e6).toString()+Date.now();for(;t.length<24;)t+="0";return t},at=et,st=(t,e,a=globalThis.localStorage)=>{if(!a)return L(e);let s;const i=a.getItem(t);if(i)try{s=JSON.parse(i)}catch{s=null,a.removeItem(t)}const n=L(s||e);return K(n,()=>{a.setItem(t,JSON.stringify(n))}),n},nt=(t,{flags:e})=>!t.flags&&!e?!0:!t.flags||!e||t.flags.length!==e.length?!1:t.flags.every(a=>e.includes(a)),it=(t,e)=>{if(typeof e.product_id!="string"||typeof e.quantity!="number"||!(e.quantity>=0)||typeof e.price!="number"||!(e.price>=0))return null;const{items:a}=t;if(!e.kit_product)for(let i=0;i<a.length;i++){const n=a[i];if(!n.kit_product&&n.product_id===e.product_id&&n.variation_id===e.variation_id&&(!n.customizations||!n.customizations.length)&&nt(n,e))return n.quantity+=e.quantity,e.price&&(n.price=e.price),e.final_price&&(n.final_price=e.final_price),n}const s={...e};if((!e._id||e._id===e.variation_id||a.find(({_id:i})=>i===e._id))&&(s._id=at()),e.customizations){const i=[];e.customizations.forEach((n,r)=>{i[r]={...n}}),s.customizations=i}return a.push(s),s},rt=(t,e,a)=>{(typeof a!="number"||Number.isNaN(a))&&(a=t.min_quantity||1);const s=t.min_quantity||0,i=e&&t.variations?t.variations.find(({_id:r})=>r===e):void 0,n={product_id:t._id,variation_id:e,sku:i?.sku||t.sku,name:i?.name||t.name,slug:t.slug,production_time:i?.production_time||t.production_time,currency_id:t.currency_id,currency_symbol:t.currency_symbol,base_price:i?.base_price||t.base_price,max_quantity:t.quantity,quantity:s>0?Math.max(s,a):a,price:x(t)};return i?.picture_id&&t.pictures&&(n.picture=t.pictures.find(r=>r._id===i.picture_id)),!n.picture&&t.pictures&&([n.picture]=t.pictures),n},ot="ecomShoppingCart",ct={items:[]},D=st(ot,ct),R=c(()=>D.items.map(t=>{let e=t.kit_product?.price&&t.kit_product.pack_quantity?t.kit_product.price/t.kit_product.pack_quantity:t.price;Array.isArray(t.customizations)&&t.customizations.forEach(i=>{if(i.add_to_price){const{type:n,addition:r}=i.add_to_price;e+=n==="fixed"?r:t.price*(r/100)}}),t.final_price=e;const a=t.min_quantity||1,s=t.max_quantity;return typeof t.quantity!="number"||Number.isNaN(t.quantity)||t.quantity<a?t.quantity=a:s&&t.quantity>s&&(t.quantity=s),t})),z=c(()=>R.value.reduce((t,e)=>t+e.quantity*(e.final_price||e.price),0)),zt=c(()=>R.value.reduce((t,e)=>t+e.quantity,0)),A=c({get(){return{...D,subtotal:z.value}},set(t){Object.assign(D,t,{subtotal:z.value})}}),lt=t=>{const e=A.value;it(e,t)&&(A.value.items=e.items)},It=t=>{for(let e=0;e<A.value.items.length;e++)if(A.value.items[e]._id===t){A.value.items.splice(e,1);break}},$t=(t,e,a)=>lt(rt(t,e,a));globalThis.__apiCache||(globalThis.__apiCache={});const N=typeof process=="object"&&process?.env||globalThis;class I extends Error{constructor(e,a,s,i=!1){a?(super(a.statusText),this.data=a.data,this.statusCode=a.status):super(s||"Request error"),this.config=e,this.response=a,this.isTimeout=i}}const ut={middleware(t){const e={...t.headers};if(!t.isNoAuth)if(t.accessToken)e.Authorization=`Bearer ${t.accessToken}`;else{const n=t.authenticationId||N.ECOM_AUTHENTICATION_ID,r=t.apiKey||N.ECOM_API_KEY;if(n&&r){const l=`${n}:${r}`,f=typeof Buffer=="function"?Buffer.from(l).toString("base64"):btoa(l);e.Authorization=`Basic ${f}`}}let a=t.baseUrl||N.API_BASE_URL||"https://ecomplus.io/v2";const{endpoint:s,params:i}=t;if(s!=="login"&&s!=="authenticate"&&s!=="ask-auth-callback"&&s!=="check-username"){const n=t.storeId||N.ECOM_STORE_ID;if(!n)throw new Error("`storeId` must be set in config or `ECOM_STORE_ID` env var");a+=`/:${n}`;const r=t.lang||N.ECOM_LANG;r&&(a+=`,lang:${r}`)}if(a+=`/${s}`,typeof i=="string")a+=`?${i}`;else{const n=i||{};if(["fields","sort"].forEach(r=>{const l=t[r];l&&!n[r]&&(n[r]=l.join(","))}),["limit","offset","count","buckets","concise","verbose"].forEach(r=>{const l=t[r];l&&!n[r]&&(n[r]=l)}),Object.keys(n).length){const r=new URLSearchParams;Object.keys(n).forEach(l=>{const f=n[l];Array.isArray(f)?f.forEach(g=>{r.append(l,g)}):f!==void 0&&r.append(l,f)}),a+=`?${r.toString()}`}}return{url:a,headers:e}}},y=async(t,e=0)=>{const a=globalThis.$apiMergeConfig?{...globalThis.$apiMergeConfig,...t}:t,{url:s,headers:i}=ut.middleware(a),{method:n="get",timeout:r=2e4,maxRetries:l=3,cacheMaxAge:f=6e5}=a,g=n==="get"&&a.canCache;let k;if(g){k=`${s}${JSON.stringify(i)}`;const v=globalThis.__apiCache[k];if(v&&Date.now()-v.timestamp<=f)return{...v.res,config:a}}const T=a.body||a.data;let b;T&&(b=JSON.stringify(T),i["Content-Type"]="application/json",i["Content-Length"]=b.length.toString());const C=new AbortController;let E=!1;const j=setTimeout(()=>{C.abort(),E=!0},r);let u;try{u=await(a.fetch||fetch)(s,{method:n,headers:i,body:b,signal:C.signal})}catch(v){throw new I(a,u,v.message,E)}if(clearTimeout(j),u){if(u.ok){const o={...u,data:await u.json()};return g&&k&&(globalThis.__apiCache[k]={timestamp:Date.now(),res:o}),{...o,config:a}}const{status:v}=u;if(l<e&&(v===429||v>=500)){const o=u.headers.get("retry-after");return new Promise((m,P)=>{setTimeout(()=>{y(t,e+1).then(m).catch(P)},o&&parseInt(o,10)||5e3)})}}try{u.data=await u?.json()}catch{}throw new I(a,u)},dt=(t,e)=>y({...e,endpoint:t}),mt=(t,e,a)=>y({...a,method:"post",endpoint:t,body:e}),_t=(t,e,a)=>y({...a,method:"put",endpoint:t,body:e}),ht=(t,e,a)=>y({...a,method:"patch",endpoint:t,body:e}),W=(t,e)=>y({...e,method:"delete",endpoint:t});y.get=dt;y.post=mt;y.put=_t;y.patch=ht;y.del=W;y.delete=W;const $=(t,e)=>{const{type:a,value:s}=e;let i;return s?(a==="percentage"?i=t*((100-s)/100):i=t-s,i>0?i:0):t},ft=t=>{const e=c(()=>t.product||{price:t.price||0,base_price:t.basePrice}),a=c(()=>{const{variations:o}=e.value;if(o){const m=x(e.value);for(let P=0;P<o.length;P++)if(x({...e.value,...o[P]})>m)return!0}return!1}),s=c(()=>{const o=x(e.value),m=Y.value;return m&&(!m.min_amount||o>m.min_amount)?$(o,m):o}),i=c(()=>{if(w(e.value))return e.value.base_price;const o=x(e.value);return o>s.value?o:0}),n=c(()=>t.installmentsOption||F.value||{max_number:1}),r=c(()=>{if(n.value.max_number<=1)return 1;const o=n.value.min_installment||5,m=Math.floor(s.value/o);return Math.min(m,n.value.max_number)}),l=c(()=>n.value.monthly_interest||0),f=c(()=>{if(r.value>=2){if(!l.value)return s.value/r.value;const o=l.value/100;return s.value*o/(1-(1+o)**-r.value)}return 0}),g=c(()=>{const o=t.discountOption||X.value;return o&&(!o.min_amount||o.min_amount<=s.value)&&(!t.isAmountTotal||o.apply_at==="total")?o:{}}),k=c(()=>{const{label:o}=g.value;return o?o.includes(" ")?o:`via ${o}`:""}),T=c(()=>$(s.value,g.value)),b=c(()=>{if(t.loyaltyPointsProgram)return t.loyaltyPointsProgram;const o=Z.value;if(o){const m=Object.keys(o);for(let P=0;P<m.length;P++){const S=o[m[P]];if(S?.earn_percentage&&S.earn_percentage>0)return S}}return{ratio:0}}),C=c(()=>b.value.min_subtotal_to_earn||0),E=c(()=>b.value.name||""),j=c(()=>b.value.earn_percentage||0),u=c(()=>j.value*b.value.ratio),v=c(()=>u.value>=1?s.value*(u.value/100):0);return{hasVariedPrices:a,salePrice:s,comparePrice:i,installmentsObject:n,installmentsNumber:r,monthlyInterest:l,installmentValue:f,discountObject:g,discountLabel:k,priceWithDiscount:T,pointsProgramObject:b,pointsMinPrice:C,pointsProgramName:E,earnPointsPercentage:j,cashbackPercentage:u,cashbackValue:v}},pt=Q({__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(t,{expose:e}){e();const a=t,{hasVariedPrices:s,salePrice:i,comparePrice:n,cashbackPercentage:r,cashbackValue:l,installmentsNumber:f,monthlyInterest:g,installmentValue:k,priceWithDiscount:T,discountLabel:b}=ft(a),C={props:a,hasVariedPrices:s,salePrice:i,comparePrice:n,cashbackPercentage:r,cashbackValue:l,installmentsNumber:f,monthlyInterest:g,installmentValue:k,priceWithDiscount:T,discountLabel:b};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),yt={key:0,class:"text-base-500 mr-1 text-[87%]"},bt={key:0},vt={key:1},gt={key:0},Pt={key:0,class:"relative z-10"},kt=["data-tooltip"],Ot=O("i",{class:"i-arrow-uturn-left mr-1"},null,-1),Ct={class:"font-medium"},Tt=O("small",null," cashback",-1),Nt={key:0},xt={key:0},At={key:1},Et={key:2},jt={key:0},St={key:0},qt={key:1};function Bt(t,e,a,s,i,n){const r=G("Fade");return _(),h("div",{class:M(["text-base-600 [&>div]:[font-size:90%] [&_small]:lowercase [&_small]:[font-size:92%]",a.isBig?"text-lg":null]),"data-prices":""},[s.comparePrice?(_(),h("span",yt,[a.isLiteral?(_(),h("small",bt,d("De "))):p("",!0),O("s",null,d(t.$money(s.comparePrice)),1),a.isLiteral?(_(),h("small",vt,d(" Por"))):p("",!0)])):p("",!0),O("strong",{class:M(["inline-block text-base-800",a.isBig?"text-5xl block":null])},[s.hasVariedPrices?(_(),h("small",gt,d("A partir de "))):p("",!0),V(" "+d(t.$money(s.salePrice)),1)],2),q(r,{slide:"down"},{default:B(()=>[s.cashbackValue&&a.hasCashback?(_(),h("div",Pt,[O("span",{"data-tooltip":"Receba $1 de volta".replace("$1",t.$percentage(s.cashbackPercentage))},[Ot,O("span",Ct,d(t.$money(s.cashbackValue)),1),Tt],8,kt)])):p("",!0)]),_:1}),q(r,{slide:"down"},{default:B(()=>[s.installmentValue&&a.hasPriceOptions?(_(),h("div",Nt,[a.isLiteral?(_(),h("small",xt,d("Até "))):p("",!0),V(" "+d(s.installmentsNumber)+"x ",1),a.isLiteral?(_(),h("small",At,d(" De "))):p("",!0),O("span",null,d(t.$money(s.installmentValue)),1),!s.monthlyInterest&&a.isLiteral?(_(),h("small",Et,d("Sem juros"))):p("",!0)])):p("",!0)]),_:1}),q(r,{slide:"down"},{default:B(()=>[s.priceWithDiscount<s.salePrice&&a.hasPriceOptions?(_(),h("div",jt,[s.discountLabel?p("",!0):(_(),h("small",St,d("A partir de "))),O("span",null,d(t.$money(s.priceWithDiscount)),1),s.discountLabel?(_(),h("small",qt,d(` ${s.discountLabel}`),1)):p("",!0)])):p("",!0)]),_:1})],2)}const Rt=U(pt,[["render",Bt]]);export{Rt as P,y as a,$t as b,Mt as g,rt as p,It as r,A as s,zt as t,st as u};
@@ -0,0 +1 @@
1
+ import{j as _,M as j,N as L,c as p,O as Q,_ as V,d as q,m as B,o as s,a as d,g as S,w as C,b as m,F as E,e as b,i as I,y as x,x as y,h as O,n as T,q as M,f as F,v as H,r as z}from"./_plugin-vue_export-helper.48e557ba.js";import{a as A,g as D,b as R,P as G}from"./Prices.8572765c.js";import{C as J,a as K}from"./Carousel.63d511ab.js";import{e as U,g as W}from"./index.c0c35ead.js";import{g as X}from"./img.7def76a1.js";import"./session-utm.744b0db3.js";const Y=e=>e&&e.min_quantity||1,Z=Y,$=e=>!e.hasOwnProperty("quantity")||e.quantity>=Z(e),N=$,tt=e=>{const a=_(e.title||""),i=_(e.titleLink||""),t=_(!1);let u=null;const r=_(null),l=j(e.products||[]);return e.products||(t.value=!0,u=(async()=>{let c=e.searchQuery||"",h;if(e.collectionId){try{const{data:o}=await A.get(`collections/${e.collectionId}`);h=o}catch(o){console.error(o),r.value=o}const n=h?.products;Array.isArray(n)&&n.length&&(c+=`&_id=${n.slice(0,60).join(",")}`),!a.value&&a.value!==null&&h?.name&&(a.value=h?.name)}const v=e.limit||24;let f=`offset=${e.page?(e.page-1)*v:0}&limit=${v}`;e.sort&&(f+=`&sort=${e.sort}`),f+=c;try{const{data:n}=await A.get(`search/v1?${f}`);if(e.isShuffle){let o=n.result.filter(w=>w.available&&N(w)).length,g,k;for(;o;)k=Math.floor(Math.random()*o--),g=n.result[o],n.result[o]=n.result[k],n.result[k]=g}n.result.forEach(o=>l.push(o))}catch(n){console.error(n),r.value=n}t.value=!1})()),{title:a,titleLink:i,isFetching:t,fetching:u,fetchError:r,products:l}},et=e=>{const a=_(!1);let i=null;const t=_(null),{productId:u}=e,r=j({...e.product,_id:e.product?._id||u,price:L(e.product||{})});!e.product&&u&&(a.value=!0,i=(async()=>{try{const{data:o}=await A.get(`products/${u}`);Object.assign(r,o)}catch(o){console.error(o),t.value=o}a.value=!1})());const l=p(()=>D(r)),c=p(()=>{const{slug:o}=r;return typeof o=="string"?`/${o}`:null}),h=p(()=>{const{pictures:o}=r,g=[];return o&&o.forEach(k=>{const w=X(k);w&&g.push(w)}),g}),v=p(()=>N(r)),P=p(()=>v.value&&r.available&&r.visible),f=p(()=>{if(Q(r)){const o=r.base_price;return Math.round((o-L(r))*100/o)}return 0}),n=p(()=>r.has_variations?!0:!!r.variations?.length);return{isFetching:a,fetching:i,fetchError:t,product:r,title:l,link:c,images:h,isInStock:v,isActive:P,discountPercentage:f,hasVariations:n}},ot=q({__name:"ProductCard",props:{product:{},productId:{},headingTag:{default:"h3"}},setup(e,{expose:a}){a();const i=e,{product:t,title:u,link:r,images:l,isInStock:c,isActive:h,discountPercentage:v,hasVariations:P}=et(i),f=_(null),n=U(f),o=_(!1);W(n,()=>{o.value=!0});const g={props:i,product:t,title:u,link:r,images:l,isInStock:c,isActive:h,discountPercentage:v,hasVariations:P,card:f,isHovered:n,wasHoveredOnce:o,get addProductToCart(){return R},Prices:G};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),rt=["data-sku"],nt={class:"aspect-square p-2 motion-safe:group-hover:scale-110 transition-transform"},at={class:"relative w-full h-full bg-white rounded overflow-hidden group-hover:rounded-none"},st={key:1,class:"w-full h-full bg-gradient-to-br from-base-50/20 to-base-100"},it={key:0,class:"uno-bm03rg"},lt={class:"relative flex flex-col grow justify-between p-4 group-hover:backdrop-blur-md bg-white/40 z-10"},ct={class:"pt-2"},ut={key:0},dt={key:1,class:"ui-badge bg-warning-100 text-warning-700"},ht=m("span",{class:"inline-block h-4 w-4 leading-none text-base text-center bg-on-primary text-primary opacity-80 rounded-full mr-1"}," + ",-1);function ft(e,a,i,t,u,r){const l=B("AImg");return s(),d("article",{ref:"card","data-sku":t.product.sku,class:"relative h-full max-w-[350px] mx-auto py-3 group"},[(s(),S(O(t.link?"ALink":"span"),{href:t.link,class:"flex flex-col h-full rounded overflow-hidden group-hover:shadow group-hover:ring-1 ring-black/5"},{default:C(()=>[m("div",nt,[m("div",at,[t.images?.length?(s(),d(E,{key:0},[b(l,{picture:t.images[0],alt:t.title,class:"absolute top-0 left-0 block w-full h-full object-cover"},null,8,["picture","alt"]),t.images[1]&&t.wasHoveredOnce?(s(),S(l,{key:0,picture:t.images[1],alt:t.title,class:"absolute top-0 left-0 block w-full h-full object-cover opacity-0 group-hover:opacity-100 transition-opacity motion-safe:duration-300 text-transparent z-10"},null,8,["picture","alt"])):I("",!0)],64)):(s(),d("div",st))])]),t.discountPercentage?(s(),d("span",it,[x(" -"),m("strong",null,y(t.discountPercentage),1),x("% ")])):I("",!0),m("div",lt,[(s(),S(O(i.headingTag),{class:T(["ui-link no-underline line-clamp-2",[t.isActive?"text-base-700":"text-base-500",t.link?"group-hover:underline group-hover:text-primary":null]])},{default:C(()=>[x(y(t.title),1)]),_:1},8,["class"])),m("div",ct,[t.isActive?(s(),d("div",ut,[b(t.Prices,{product:t.product},null,8,["product"])])):(s(),d("span",dt,y(t.isInStock?"Inativo":"Sem estoque"),1))]),t.isActive&&!t.hasVariations?(s(),d("button",{key:0,class:"uno-3suct9 ui-btn-sm ui-btn-primary",onClick:a[0]||(a[0]=M(c=>t.addProductToCart(t.product),["prevent"]))},[ht,x(" "+y("Adicionar ao carrinho"))])):I("",!0)])]),_:1},8,["href"]))],8,rt)}const gt=V(ot,[["render",ft]]),mt=q({__name:"ProductShelf",props:{collectionId:{},searchQuery:{},sort:{},title:{},titleLink:{},isShuffle:{type:Boolean},limit:{},page:{},products:{}},async setup(e,{expose:a}){a();const i=e,{title:t,titleLink:u,fetching:r,products:l}=tt(i),c={props:i,title:t,titleLink:u,fetching:r,products:l,Carousel:J,CarouselControl:K,ProductCard:gt};return Object.defineProperty(c,"__isScriptSetup",{enumerable:!1,value:!0}),c}}),_t={class:"ui-section"},vt={key:0,class:"max-w-prose mx-auto text-center mb-2"},pt={class:"ui-text-brand text-3xl"},bt={key:1,class:"text-base-700"},yt={class:"text-3xl lg:text-2xl leading-none text-primary lg:opacity-0 group-hover/shelf:opacity-90 transition-opacity"};function kt(e,a,i,t,u,r){const l=B("ALink");return s(),d("section",_t,[t.title?(s(),d("div",vt,[m("h2",pt,[t.titleLink?(s(),S(l,{key:0,href:t.titleLink,class:"ui-link"},{default:C(()=>[x(y(t.title),1)]),_:1},8,["href"])):(s(),d("span",bt,y(t.title),1))])])):I("",!0),b(t.Carousel,{class:"group/shelf"},{controls:C(()=>[F(m("div",yt,[b(t.CarouselControl,{class:"!top-1/2 !-left-4 w-12 h-12 bg-transparent lg:bg-white/80 lg:hover:bg-primary-300/60 rounded-full lg:shadow-sm lg:ring-1 ring-black/5","is-prev":""}),b(t.CarouselControl,{class:"!top-1/2 !-right-4 w-12 h-12 bg-transparent lg:bg-white/80 lg:hover:bg-primary-300/60 rounded-full lg:shadow-sm lg:ring-1 ring-black/5"})],512),[[H,t.products.length>2]])]),default:C(()=>[(s(!0),d(E,null,z(t.products,c=>(s(),d("li",{key:c._id,class:"basis-1/2 md:basis-1/3 lg:basis-1/4 shrink-0"},[b(t.ProductCard,{product:c},null,8,["product"])]))),128))]),_:1})])}const At=V(mt,[["render",kt]]);export{At as default};