@lucrex/storefront-blocks 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,2608 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/server.ts
21
+ var server_exports = {};
22
+ __export(server_exports, {
23
+ BlockList: () => BlockList,
24
+ Breakpoints: () => Breakpoints,
25
+ FunnelTemplateIds: () => FunnelTemplateIds,
26
+ OnlineStorePageTypes: () => OnlineStorePageTypes,
27
+ OnlineStoreTemplateIds: () => OnlineStoreTemplateIds,
28
+ PageContent: () => PageContent,
29
+ PageDataProvider: () => PageDataProvider,
30
+ PageDocumentError: () => PageDocumentError,
31
+ StyleProperties: () => StyleProperties,
32
+ blockSelector: () => blockSelector,
33
+ blocks: () => blocks,
34
+ checkoutData: () => checkoutData,
35
+ countBlocks: () => countBlocks,
36
+ funnelTemplate: () => funnelTemplate,
37
+ moneyFormatter: () => moneyFormatter,
38
+ onlineStorePages: () => onlineStorePages,
39
+ onlineStoreTemplate: () => onlineStoreTemplate,
40
+ pageCss: () => pageCss,
41
+ pageFontStylesheets: () => pageFontStylesheets,
42
+ pageJsonSchema: () => pageJsonSchema,
43
+ pagePreloadImages: () => pagePreloadImages,
44
+ parsePageDocument: () => parsePageDocument,
45
+ processCss: () => processCss,
46
+ renderPage: () => renderPage,
47
+ storeData: () => storeData,
48
+ useCheckoutData: () => useCheckoutData,
49
+ usePageData: () => usePageData,
50
+ useStoreData: () => useStoreData,
51
+ walkBlocks: () => walkBlocks
52
+ });
53
+ module.exports = __toCommonJS(server_exports);
54
+ var import_react6 = require("react");
55
+ var import_server = require("react-dom/server");
56
+ var import_lightningcss = require("lightningcss");
57
+
58
+ // src/document.ts
59
+ var PageDocumentError = class extends Error {
60
+ constructor(issues) {
61
+ super(
62
+ `Invalid page document: ${issues.map((issue) => `${issue.path || "document"}: ${issue.message}`).join("; ")}`
63
+ );
64
+ this.issues = issues;
65
+ this.name = "PageDocumentError";
66
+ }
67
+ };
68
+
69
+ // src/page.ts
70
+ var import_react5 = require("react");
71
+
72
+ // src/blocks/layout.tsx
73
+ var import_react = require("react");
74
+ var import_zod3 = require("zod");
75
+
76
+ // src/block.ts
77
+ var import_zod2 = require("zod");
78
+
79
+ // src/style.ts
80
+ var import_zod = require("zod");
81
+ var StyleProperties = [
82
+ "display",
83
+ "position",
84
+ "top",
85
+ "right",
86
+ "bottom",
87
+ "left",
88
+ "zIndex",
89
+ "width",
90
+ "minWidth",
91
+ "maxWidth",
92
+ "height",
93
+ "minHeight",
94
+ "maxHeight",
95
+ "margin",
96
+ "marginTop",
97
+ "marginRight",
98
+ "marginBottom",
99
+ "marginLeft",
100
+ "padding",
101
+ "paddingTop",
102
+ "paddingRight",
103
+ "paddingBottom",
104
+ "paddingLeft",
105
+ "flexDirection",
106
+ "flexWrap",
107
+ "alignItems",
108
+ "justifyContent",
109
+ "gap",
110
+ "gridTemplateColumns",
111
+ "color",
112
+ "background",
113
+ "backgroundColor",
114
+ "backgroundImage",
115
+ "backgroundSize",
116
+ "backgroundPosition",
117
+ "fontFamily",
118
+ "fontSize",
119
+ "fontWeight",
120
+ "fontStyle",
121
+ "lineHeight",
122
+ "letterSpacing",
123
+ "textAlign",
124
+ "textTransform",
125
+ "textDecoration",
126
+ "border",
127
+ "borderTop",
128
+ "borderBottom",
129
+ "borderColor",
130
+ "borderRadius",
131
+ "boxShadow",
132
+ "opacity",
133
+ "overflow",
134
+ "objectFit",
135
+ "aspectRatio",
136
+ "transition",
137
+ "transform"
138
+ ];
139
+ var Breakpoints = {
140
+ tablet: "(max-width: 1023px)",
141
+ mobile: "(max-width: 767px)"
142
+ };
143
+ var StyleValueSchema = import_zod.z.string().max(500).regex(/^[^;{}<]*$/, "A style value cannot contain ; { } or <").refine((value) => !/(expression\s*\(|javascript:|@import)/i.test(value), {
144
+ message: "A style value cannot contain expression(), javascript: or @import"
145
+ }).refine((value) => !findUrls(value).some((url) => !isAllowedUrl(url)), {
146
+ message: "A style url() must be https:// or a data: image"
147
+ });
148
+ var DeclarationsSchema = import_zod.z.object(
149
+ Object.fromEntries(
150
+ StyleProperties.map((property) => [property, StyleValueSchema.optional()])
151
+ )
152
+ );
153
+ var BlockStyleSchema = DeclarationsSchema.extend({
154
+ tablet: DeclarationsSchema.optional(),
155
+ mobile: DeclarationsSchema.optional()
156
+ });
157
+ var CssSchema = import_zod.z.string().max(2e4).refine((value) => !value.includes("<"), { message: "CSS cannot contain <" }).refine((value) => !/(@import|expression\s*\(|javascript:|behavior\s*:)/i.test(value), {
158
+ message: "CSS cannot contain @import, expression(), javascript: or behavior"
159
+ }).refine((value) => !findUrls(value).some((url) => !isAllowedUrl(url)), {
160
+ message: "CSS url() must be https:// or a data: image"
161
+ });
162
+ function styleToCss(selector, style) {
163
+ if (!style) return "";
164
+ const { tablet, mobile, ...base } = style;
165
+ return [
166
+ rule(selector, base),
167
+ media(Breakpoints.tablet, rule(selector, tablet)),
168
+ media(Breakpoints.mobile, rule(selector, mobile))
169
+ ].filter(Boolean).join("\n");
170
+ }
171
+ function rule(selector, declarations) {
172
+ const body = Object.entries(declarations != null ? declarations : {}).filter(([, value]) => typeof value === "string" && value.trim() !== "").map(([property, value]) => `${kebab(property)}: ${value};`).join(" ");
173
+ return body ? `${selector} { ${body} }` : "";
174
+ }
175
+ function media(query, body) {
176
+ return body ? `@media ${query} { ${body} }` : "";
177
+ }
178
+ function kebab(property) {
179
+ return property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
180
+ }
181
+ function findUrls(value) {
182
+ return [...value.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi)].map((match) => match[2].trim());
183
+ }
184
+ function isAllowedUrl(url) {
185
+ return /^https:\/\//i.test(url) || /^data:image\//i.test(url);
186
+ }
187
+
188
+ // src/block.ts
189
+ var BlockIdSchema = import_zod2.z.string().min(1).max(100).regex(/^[A-Za-z0-9_-]+$/, "A block id can only contain letters, digits, _ and -");
190
+ var ClassNameSchema = import_zod2.z.string().max(200).regex(/^[A-Za-z0-9_\- ]*$/, "A class name can only contain letters, digits, _, - and spaces");
191
+ var BlockNodeSchema = import_zod2.z.object({
192
+ type: import_zod2.z.string().min(1),
193
+ props: import_zod2.z.looseObject({ id: BlockIdSchema })
194
+ });
195
+ var BaseBlockPropsSchema = import_zod2.z.object({
196
+ id: BlockIdSchema,
197
+ className: ClassNameSchema.optional(),
198
+ style: BlockStyleSchema.optional(),
199
+ css: CssSchema.optional()
200
+ });
201
+ function defineBlock(definition) {
202
+ var _a;
203
+ const slots = (_a = definition.slots) != null ? _a : [];
204
+ return {
205
+ ...definition,
206
+ slots,
207
+ defaultProps: {
208
+ ...definition.schema.parse({}),
209
+ ...Object.fromEntries(slots.map((slot) => [slot, []]))
210
+ }
211
+ };
212
+ }
213
+ function blockRoot(props, ...classNames) {
214
+ const className = [...classNames, props.className].filter(Boolean).join(" ");
215
+ return { "data-block": props.id, className: className || void 0 };
216
+ }
217
+
218
+ // src/blocks/layout.tsx
219
+ var import_jsx_runtime = require("react/jsx-runtime");
220
+ var AnchorIdSchema = import_zod3.z.string().max(60).regex(/^[A-Za-z0-9_-]*$/, "An anchor id can only contain letters, digits, _ and -");
221
+ var Section = defineBlock({
222
+ type: "Section",
223
+ label: "Section",
224
+ description: "A full-width page section that holds other blocks. Give it an anchorId so buttons can link to it with #anchorId.",
225
+ category: "layout",
226
+ schema: import_zod3.z.object({
227
+ tag: import_zod3.z.enum(["section", "div", "header", "footer", "aside", "nav"]).default("section"),
228
+ anchorId: AnchorIdSchema.default("")
229
+ }),
230
+ slots: ["content"],
231
+ fields: {
232
+ tag: {
233
+ type: "select",
234
+ label: "HTML tag",
235
+ options: ["section", "div", "header", "footer", "aside", "nav"].map((tag) => ({
236
+ label: tag,
237
+ value: tag
238
+ }))
239
+ },
240
+ anchorId: { type: "text", label: "Anchor id" }
241
+ },
242
+ render: (props) => (0, import_react.createElement)(
243
+ props.tag,
244
+ { ...blockRoot(props), id: props.anchorId || void 0 },
245
+ props.slots.content
246
+ )
247
+ });
248
+ var Stack = defineBlock({
249
+ type: "Stack",
250
+ label: "Stack",
251
+ description: "A plain container that groups blocks. Use style (display, flexDirection, gap) to lay them out.",
252
+ category: "layout",
253
+ schema: import_zod3.z.object({}),
254
+ slots: ["content"],
255
+ fields: {},
256
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockRoot(props), children: props.slots.content })
257
+ });
258
+ var Columns = defineBlock({
259
+ type: "Columns",
260
+ label: "Columns",
261
+ description: "Puts up to four columns side by side on desktop and stacks them on mobile. Fill column1 to columnN, where N is count.",
262
+ category: "layout",
263
+ schema: import_zod3.z.object({
264
+ count: import_zod3.z.union([import_zod3.z.literal(2), import_zod3.z.literal(3), import_zod3.z.literal(4)]).default(2),
265
+ stackOnMobile: import_zod3.z.boolean().default(true)
266
+ }),
267
+ slots: ["column1", "column2", "column3", "column4"],
268
+ fields: {
269
+ count: {
270
+ type: "select",
271
+ label: "Columns",
272
+ options: [2, 3, 4].map((count) => ({ label: String(count), value: count }))
273
+ },
274
+ stackOnMobile: {
275
+ type: "radio",
276
+ label: "Stack on mobile",
277
+ options: [
278
+ { label: "Yes", value: true },
279
+ { label: "No", value: false }
280
+ ]
281
+ }
282
+ },
283
+ render: (props) => {
284
+ const columns = [
285
+ props.slots.column1,
286
+ props.slots.column2,
287
+ props.slots.column3,
288
+ props.slots.column4
289
+ ];
290
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
291
+ "div",
292
+ {
293
+ ...blockRoot(
294
+ props,
295
+ "lx-columns",
296
+ `lx-columns--${props.count}`,
297
+ props.stackOnMobile && "lx-columns--stack"
298
+ ),
299
+ children: columns.slice(0, props.count).map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "lx-columns__column", children: column }, index))
300
+ }
301
+ );
302
+ },
303
+ baseCss: `
304
+ .lx-columns { display: grid; gap: 24px; }
305
+ .lx-columns--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
306
+ .lx-columns--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
307
+ .lx-columns--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
308
+ @media (max-width: 767px) { .lx-columns--stack { grid-template-columns: minmax(0, 1fr); } }
309
+ `
310
+ });
311
+
312
+ // src/blocks/content.tsx
313
+ var import_react2 = require("react");
314
+ var import_zod4 = require("zod");
315
+ var import_jsx_runtime2 = require("react/jsx-runtime");
316
+ var LinkSchema = import_zod4.z.string().max(2e3).regex(
317
+ /^(https?:\/\/|\/|#|tel:|mailto:)/,
318
+ "A link must start with https://, http://, /, #, tel: or mailto:"
319
+ );
320
+ var ImageSourceSchema = import_zod4.z.string().max(2e3).regex(/^(https:\/\/|\/|$)/, "An image must be an https:// or / url");
321
+ var Heading = defineBlock({
322
+ type: "Heading",
323
+ label: "Heading",
324
+ description: "A title. Use level h1 once per page.",
325
+ category: "content",
326
+ schema: import_zod4.z.object({
327
+ text: import_zod4.z.string().max(500).default("Heading"),
328
+ level: import_zod4.z.enum(["h1", "h2", "h3", "h4", "h5", "h6"]).default("h2")
329
+ }),
330
+ fields: {
331
+ text: { type: "text", label: "Text" },
332
+ level: {
333
+ type: "select",
334
+ label: "Level",
335
+ options: ["h1", "h2", "h3", "h4", "h5", "h6"].map((level) => ({
336
+ label: level.toUpperCase(),
337
+ value: level
338
+ }))
339
+ }
340
+ },
341
+ render: (props) => (0, import_react2.createElement)(props.level, blockRoot(props, "lx-heading"), props.text),
342
+ baseCss: `.lx-heading { margin: 0; }`
343
+ });
344
+ var Text = defineBlock({
345
+ type: "Text",
346
+ label: "Text",
347
+ description: "A paragraph. Line breaks in text are kept.",
348
+ category: "content",
349
+ schema: import_zod4.z.object({
350
+ text: import_zod4.z.string().max(1e4).default("Text")
351
+ }),
352
+ fields: {
353
+ text: { type: "textarea", label: "Text" }
354
+ },
355
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { ...blockRoot(props, "lx-text"), children: props.text }),
356
+ baseCss: `.lx-text { margin: 0; white-space: pre-line; }`
357
+ });
358
+ var Image = defineBlock({
359
+ type: "Image",
360
+ label: "Image",
361
+ description: "An image, optionally wrapped in a link. Set loading to eager for the first image a visitor sees.",
362
+ category: "content",
363
+ schema: import_zod4.z.object({
364
+ src: ImageSourceSchema.default(""),
365
+ alt: import_zod4.z.string().max(300).default(""),
366
+ href: LinkSchema.or(import_zod4.z.literal("")).default(""),
367
+ loading: import_zod4.z.enum(["lazy", "eager"]).default("lazy")
368
+ }),
369
+ fields: {
370
+ src: { type: "text", label: "Image url" },
371
+ alt: { type: "text", label: "Alternative text" },
372
+ href: { type: "text", label: "Link" },
373
+ loading: {
374
+ type: "radio",
375
+ label: "Loading",
376
+ options: [
377
+ { label: "Lazy", value: "lazy" },
378
+ { label: "Eager", value: "eager" }
379
+ ]
380
+ }
381
+ },
382
+ preload: (props) => props.loading === "eager" && props.src ? [props.src] : [],
383
+ render: (props) => {
384
+ if (!props.src) return null;
385
+ const image = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
386
+ "img",
387
+ {
388
+ ...props.href ? {} : blockRoot(props, "lx-image"),
389
+ src: props.src,
390
+ alt: props.alt,
391
+ loading: props.loading === "lazy" ? "lazy" : void 0,
392
+ fetchPriority: props.loading === "eager" ? "high" : void 0,
393
+ decoding: "async"
394
+ }
395
+ );
396
+ return props.href ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { ...blockRoot(props, "lx-image"), href: props.href, children: image }) : image;
397
+ },
398
+ baseCss: `.lx-image { display: block; max-width: 100%; }`
399
+ });
400
+ var Button = defineBlock({
401
+ type: "Button",
402
+ label: "Button",
403
+ description: "A call-to-action link styled as a button. Link to #order to scroll to the order form.",
404
+ category: "content",
405
+ schema: import_zod4.z.object({
406
+ label: import_zod4.z.string().max(200).default("Order now"),
407
+ href: LinkSchema.default("#order"),
408
+ newTab: import_zod4.z.boolean().default(false)
409
+ }),
410
+ fields: {
411
+ label: { type: "text", label: "Label" },
412
+ href: { type: "text", label: "Link" },
413
+ newTab: {
414
+ type: "radio",
415
+ label: "Open in a new tab",
416
+ options: [
417
+ { label: "Yes", value: true },
418
+ { label: "No", value: false }
419
+ ]
420
+ }
421
+ },
422
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
423
+ "a",
424
+ {
425
+ ...blockRoot(props, "lx-button"),
426
+ href: props.href,
427
+ target: props.newTab ? "_blank" : void 0,
428
+ rel: props.newTab ? "noopener noreferrer" : void 0,
429
+ children: props.label
430
+ }
431
+ ),
432
+ baseCss: `
433
+ .lx-button {
434
+ display: inline-flex;
435
+ align-items: center;
436
+ justify-content: center;
437
+ padding: 14px 24px;
438
+ border-radius: 12px;
439
+ background: var(--cs-accent);
440
+ color: var(--cs-accent-ink);
441
+ font-weight: 700;
442
+ text-decoration: none;
443
+ }
444
+ `
445
+ });
446
+ var Spacer = defineBlock({
447
+ type: "Spacer",
448
+ label: "Spacer",
449
+ description: "Empty vertical space. Set its height with style.height.",
450
+ category: "content",
451
+ schema: import_zod4.z.object({}),
452
+ fields: {},
453
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...blockRoot(props, "lx-spacer"), "aria-hidden": "true" }),
454
+ baseCss: `.lx-spacer { height: 32px; }`
455
+ });
456
+
457
+ // src/blocks/product.tsx
458
+ var import_react4 = require("react");
459
+ var import_zod5 = require("zod");
460
+
461
+ // src/context.tsx
462
+ var import_react3 = require("react");
463
+ var import_jsx_runtime3 = require("react/jsx-runtime");
464
+ var PageDataContext = (0, import_react3.createContext)(null);
465
+ function PageDataProvider({ data, children }) {
466
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PageDataContext.Provider, { value: data, children });
467
+ }
468
+ function usePageData() {
469
+ const data = (0, import_react3.useContext)(PageDataContext);
470
+ if (!data) {
471
+ throw new Error("Blocks must be rendered inside a PageDataProvider");
472
+ }
473
+ return data;
474
+ }
475
+ function checkoutData(data) {
476
+ if (!data.funnel || !data.product || !data.landingPage || !data.geo || !data.api) {
477
+ throw new Error("This block needs the product and checkout data of a product page");
478
+ }
479
+ return data;
480
+ }
481
+ function useCheckoutData() {
482
+ return checkoutData(usePageData());
483
+ }
484
+ function storeData(data) {
485
+ if (!data.store) {
486
+ throw new Error("This block needs the data of an online store page");
487
+ }
488
+ return data.store;
489
+ }
490
+ function useStoreData() {
491
+ return storeData(usePageData());
492
+ }
493
+
494
+ // src/blocks/product.tsx
495
+ var import_jsx_runtime4 = require("react/jsx-runtime");
496
+ function galleryImages(data) {
497
+ return data.landingPage.leadImages.length ? data.landingPage.leadImages : data.product.images;
498
+ }
499
+ var ProductTitle = defineBlock({
500
+ type: "ProductTitle",
501
+ label: "Product name",
502
+ description: "The product name, read from the product.",
503
+ category: "product",
504
+ schema: import_zod5.z.object({
505
+ level: import_zod5.z.enum(["h1", "h2", "h3"]).default("h1")
506
+ }),
507
+ fields: {
508
+ level: {
509
+ type: "select",
510
+ label: "Level",
511
+ options: ["h1", "h2", "h3"].map((level) => ({
512
+ label: level.toUpperCase(),
513
+ value: level
514
+ }))
515
+ }
516
+ },
517
+ render: function ProductTitle2(props) {
518
+ const data = useCheckoutData();
519
+ return (0, import_react4.createElement)(
520
+ props.level,
521
+ { ...blockRoot(props, "cs-title"), "data-funnel": "product-name" },
522
+ data.product.name
523
+ );
524
+ }
525
+ });
526
+ var ProductPrice = defineBlock({
527
+ type: "ProductPrice",
528
+ label: "Price",
529
+ description: "The live price and the compare-at price. The storefront script fills them from the selected offer or variant.",
530
+ category: "product",
531
+ schema: import_zod5.z.object({}),
532
+ fields: {},
533
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ...blockRoot(props, "cs-price"), "data-funnel": "price", children: [
534
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "cs-price__current", "data-display-price": "" }),
535
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "cs-price__compare", "data-compare-price": "" })
536
+ ] })
537
+ });
538
+ var ProductTagline = defineBlock({
539
+ type: "ProductTagline",
540
+ label: "Tagline",
541
+ description: "The product tagline. Renders nothing when the product has none.",
542
+ category: "product",
543
+ schema: import_zod5.z.object({}),
544
+ fields: {},
545
+ render: function ProductTagline2(props) {
546
+ const { product: product2 } = useCheckoutData();
547
+ if (!product2.tagline) return null;
548
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { ...blockRoot(props, "cs-tagline"), "data-funnel": "tagline", children: product2.tagline });
549
+ }
550
+ });
551
+ var ProductGallery = defineBlock({
552
+ type: "ProductGallery",
553
+ label: "Gallery",
554
+ description: "The main product image with clickable thumbnails. Uses the landing page lead images, or the product images when there are none.",
555
+ category: "product",
556
+ schema: import_zod5.z.object({}),
557
+ fields: {},
558
+ preload: (_props, data) => galleryImages(checkoutData(data)).slice(0, 1),
559
+ render: function ProductGallery2(props) {
560
+ const data = useCheckoutData();
561
+ const images = galleryImages(data);
562
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ...blockRoot(props, "cs-gallery"), "data-funnel": "lead-images", children: images.length ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
563
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
564
+ "img",
565
+ {
566
+ className: "cs-gallery__main",
567
+ "data-gallery-main": "",
568
+ src: images[0],
569
+ alt: data.product.name,
570
+ fetchPriority: "high",
571
+ decoding: "async"
572
+ }
573
+ ),
574
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "cs-gallery__thumbs", children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
575
+ "img",
576
+ {
577
+ src: image,
578
+ alt: data.product.name,
579
+ "data-gallery-thumb": "",
580
+ className: index === 0 ? "is-active" : void 0,
581
+ loading: index === 0 ? void 0 : "lazy",
582
+ decoding: "async"
583
+ },
584
+ index
585
+ )) })
586
+ ] }) : null });
587
+ }
588
+ });
589
+ var LandingImages = defineBlock({
590
+ type: "LandingImages",
591
+ label: "Landing images",
592
+ description: "The landing page images stacked one under the other. Set eagerFirstImage when they are the first thing a visitor sees.",
593
+ category: "product",
594
+ schema: import_zod5.z.object({
595
+ eagerFirstImage: import_zod5.z.boolean().default(false)
596
+ }),
597
+ fields: {
598
+ eagerFirstImage: {
599
+ type: "radio",
600
+ label: "Load the first image first",
601
+ options: [
602
+ { label: "Yes", value: true },
603
+ { label: "No", value: false }
604
+ ]
605
+ }
606
+ },
607
+ preload: (props, data) => props.eagerFirstImage ? checkoutData(data).landingPage.images.slice(0, 1) : [],
608
+ render: function LandingImages2(props) {
609
+ const data = useCheckoutData();
610
+ const images = data.landingPage.images;
611
+ if (!images.length) return null;
612
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
613
+ "section",
614
+ {
615
+ ...blockRoot(props, "cs-landing-images", "cs-landing-images--flush"),
616
+ "data-funnel": "description",
617
+ children: images.map(
618
+ (image, index) => props.eagerFirstImage && index === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
619
+ "img",
620
+ {
621
+ src: image,
622
+ alt: data.product.name,
623
+ fetchPriority: "high",
624
+ decoding: "async"
625
+ },
626
+ index
627
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
628
+ "img",
629
+ {
630
+ src: image,
631
+ alt: data.product.name,
632
+ loading: "lazy",
633
+ decoding: "async"
634
+ },
635
+ index
636
+ )
637
+ )
638
+ }
639
+ );
640
+ }
641
+ });
642
+ var ProductDescription = defineBlock({
643
+ type: "ProductDescription",
644
+ label: "Description",
645
+ description: "The product description text. With onlyWithoutLandingImages it shows only when the landing page has no images.",
646
+ category: "product",
647
+ schema: import_zod5.z.object({
648
+ onlyWithoutLandingImages: import_zod5.z.boolean().default(true)
649
+ }),
650
+ fields: {
651
+ onlyWithoutLandingImages: {
652
+ type: "radio",
653
+ label: "Only without landing images",
654
+ options: [
655
+ { label: "Yes", value: true },
656
+ { label: "No", value: false }
657
+ ]
658
+ }
659
+ },
660
+ render: function ProductDescription2(props) {
661
+ const data = useCheckoutData();
662
+ if (!data.product.description) return null;
663
+ if (props.onlyWithoutLandingImages && data.landingPage.images.length) return null;
664
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("section", { ...blockRoot(props, "cs-card", "cs-desc"), "data-funnel": "description", children: data.product.description });
665
+ }
666
+ });
667
+ var ProductFaq = defineBlock({
668
+ type: "ProductFaq",
669
+ label: "FAQ",
670
+ description: "The product questions and answers. Renders nothing when there are none.",
671
+ category: "product",
672
+ schema: import_zod5.z.object({}),
673
+ fields: {},
674
+ render: function ProductFaq2(props) {
675
+ const { product: product2 } = useCheckoutData();
676
+ if (!product2.faq.length) return null;
677
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("section", { ...blockRoot(props, "cs-card", "cs-faq"), "data-funnel": "faq", children: product2.faq.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { children: [
678
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("summary", { children: item.question }),
679
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: item.answer })
680
+ ] }, index)) });
681
+ }
682
+ });
683
+
684
+ // src/blocks/checkout.tsx
685
+ var import_zod6 = require("zod");
686
+ var import_jsx_runtime5 = require("react/jsx-runtime");
687
+ function offerUnitCount(products2) {
688
+ return products2.reduce((sum, item) => sum + (item.quantity || 0), 0);
689
+ }
690
+ function offerUnitNumber(products2, productIndex, unitIndex) {
691
+ var _a;
692
+ let start = 0;
693
+ for (let i = 0; i < productIndex; i += 1) {
694
+ start += ((_a = products2[i]) == null ? void 0 : _a.quantity) || 0;
695
+ }
696
+ return start + unitIndex + 1;
697
+ }
698
+ function placeLabel(place) {
699
+ return place.name !== place.nameAr ? `${place.name} - ${place.nameAr}` : place.name;
700
+ }
701
+ function VariantSelects({ definitions: definitions2 }) {
702
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: definitions2.map((definition) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "cs-offer__field", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("select", { "data-variant-def": definition.name, "aria-label": definition.name, children: definition.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value, children: value }, value)) }) }, definition.name)) });
703
+ }
704
+ function VariantChips({ definitions: definitions2 }) {
705
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: definitions2.map((definition) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
706
+ "div",
707
+ {
708
+ className: "cs-variants",
709
+ "data-variant-def": definition.name,
710
+ children: [
711
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", children: definition.name }),
712
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-chips", children: definition.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
713
+ "button",
714
+ {
715
+ type: "button",
716
+ className: "cs-chip",
717
+ "data-variant-value": value,
718
+ children: value
719
+ },
720
+ value
721
+ )) })
722
+ ]
723
+ },
724
+ definition.name
725
+ )) });
726
+ }
727
+ function OfferUnitVariants({ data, offer }) {
728
+ const { product: product2 } = data;
729
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-offer__variants", "data-offer-variants": "", children: offer.products.map(
730
+ (item, productIndex) => Array.from({ length: item.quantity }, (_unused, unit) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
731
+ "div",
732
+ {
733
+ className: "cs-offer__unit",
734
+ "data-offer-unit": "",
735
+ "data-product-id": item.trackingId,
736
+ "data-unit-index": unit,
737
+ children: [
738
+ offerUnitCount(offer.products) > 1 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-offer__unit-label", children: `#${offerUnitNumber(offer.products, productIndex, unit)}` }) : null,
739
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-offer__fields", children: product2.isBundle ? product2.bundleProducts.filter(
740
+ (bundleProduct) => bundleProduct.trackingId === item.trackingId
741
+ ).map((bundleProduct) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
742
+ VariantSelects,
743
+ {
744
+ definitions: bundleProduct.variantDefinitions
745
+ },
746
+ bundleProduct.trackingId
747
+ )) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VariantSelects, { definitions: product2.variantDefinitions }) })
748
+ ]
749
+ },
750
+ `${item.trackingId}-${productIndex}-${unit}`
751
+ ))
752
+ ) });
753
+ }
754
+ function Catalog({ data }) {
755
+ const { product: product2, offers } = data;
756
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
757
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "cs-offers", "data-funnel": "offers", hidden: !offers.length, children: [
758
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", "data-i18n": "offers" }),
759
+ offers.map((offer, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
760
+ "div",
761
+ {
762
+ className: [
763
+ "cs-offer",
764
+ index === 0 && "is-active",
765
+ offer.notes && "has-note"
766
+ ].filter(Boolean).join(" "),
767
+ "data-offer-id": offer.trackingId,
768
+ children: [
769
+ offer.notes ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-offer__sticker", children: offer.notes }) : null,
770
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "cs-offer__pick", "data-offer-pick": "", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-offer__head", children: [
771
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-offer__copy", children: [
772
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-offer__name", children: offer.name }),
773
+ offer.freeShipping ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-offer__ship", "data-i18n": "freeShipping" }) : null
774
+ ] }),
775
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-offer__price", children: [
776
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
777
+ "span",
778
+ {
779
+ className: "cs-price__compare",
780
+ "data-offer-compare": "",
781
+ hidden: true
782
+ }
783
+ ),
784
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
785
+ "span",
786
+ {
787
+ className: "cs-offer__price-value",
788
+ "data-price": offer.price
789
+ }
790
+ )
791
+ ] })
792
+ ] }) }),
793
+ product2.isBundle || product2.variantDefinitions.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OfferUnitVariants, { data, offer }) : null
794
+ ]
795
+ },
796
+ offer.trackingId
797
+ ))
798
+ ] }),
799
+ offers.length ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
800
+ product2.isBundle ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("section", { "data-funnel": "bundle-products", children: product2.bundleProducts.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
801
+ "div",
802
+ {
803
+ className: "cs-bundle",
804
+ "data-bundle-product": item.trackingId,
805
+ children: [
806
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", children: item.name }),
807
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VariantChips, { definitions: item.variantDefinitions })
808
+ ]
809
+ },
810
+ item.trackingId
811
+ )) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("section", { "data-funnel": "variants", hidden: !product2.variantDefinitions.length, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VariantChips, { definitions: product2.variantDefinitions }) }),
812
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "cs-qty", "data-funnel": "qty", children: [
813
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", "data-qty": "-1", children: "-" }),
814
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-qty__value", "data-qty-value": "", children: "1" }),
815
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", "data-qty": "1", children: "+" })
816
+ ] })
817
+ ] })
818
+ ] });
819
+ }
820
+ function Totals() {
821
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals", "data-funnel": "totals", children: [
822
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", "data-i18n": "orderSummary" }),
823
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals__row", children: [
824
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-i18n": "productsPrice" }),
825
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { "data-total": "products" })
826
+ ] }),
827
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals__row", children: [
828
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-i18n": "shippingPrice" }),
829
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { "data-total": "shipping" })
830
+ ] }),
831
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals__row cs-totals__row--total", children: [
832
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-i18n": "total" }),
833
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { "data-total": "grand" })
834
+ ] })
835
+ ] });
836
+ }
837
+ function fieldAutocomplete(type) {
838
+ if (type === "phone") return "tel";
839
+ if (type === "name") return "name";
840
+ if (type === "address") return "street-address";
841
+ return "on";
842
+ }
843
+ function FormField({ data, type }) {
844
+ if (type === "state") {
845
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("select", { name: "state", "data-field": "state", children: [
846
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "" }),
847
+ data.geo.states.map((state) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
848
+ "option",
849
+ {
850
+ value: state.id,
851
+ "data-code": state.code,
852
+ "data-name": state.name,
853
+ "data-name-ar": state.nameAr,
854
+ children: placeLabel(state)
855
+ },
856
+ state.id
857
+ ))
858
+ ] });
859
+ }
860
+ if (type === "city") {
861
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("select", { name: "city", "data-field": "city", children: [
862
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "" }),
863
+ (data.lazyCities ? [] : data.geo.cities).map((city) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
864
+ "option",
865
+ {
866
+ value: city.id,
867
+ "data-code": city.code,
868
+ "data-state": city.stateId,
869
+ "data-name": city.name,
870
+ "data-name-ar": city.nameAr,
871
+ children: placeLabel(city)
872
+ },
873
+ city.id
874
+ ))
875
+ ] });
876
+ }
877
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
878
+ "input",
879
+ {
880
+ type: type === "phone" ? "tel" : "text",
881
+ name: type,
882
+ "data-field": type,
883
+ autoComplete: fieldAutocomplete(type)
884
+ }
885
+ );
886
+ }
887
+ var PrivacyLink = "https://policies.google.com/privacy";
888
+ var TermsLink = "https://policies.google.com/terms";
889
+ function RecaptchaNotice({ language }) {
890
+ const link = (href, label) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href, target: "_blank", rel: "noopener noreferrer", children: label });
891
+ if (language === "ar") {
892
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "cs-recaptcha", children: [
893
+ "\u0647\u0630\u0627 \u0627\u0644\u0645\u0648\u0642\u0639 \u0645\u062D\u0645\u064A \u0628\u0648\u0627\u0633\u0637\u0629 reCAPTCHA \u0648\u062A\u0633\u0631\u064A ",
894
+ link(PrivacyLink, "\u0633\u064A\u0627\u0633\u0629 \u0627\u0644\u062E\u0635\u0648\u0635\u064A\u0629"),
895
+ " \u0648",
896
+ " ",
897
+ link(TermsLink, "\u0634\u0631\u0648\u0637 \u0627\u0644\u062E\u062F\u0645\u0629"),
898
+ " \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0640 Google."
899
+ ] });
900
+ }
901
+ if (language === "fr") {
902
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "cs-recaptcha", children: [
903
+ "Ce site est prot\xE9g\xE9 par reCAPTCHA et les",
904
+ " ",
905
+ link(PrivacyLink, "r\xE8gles de confidentialit\xE9"),
906
+ " et",
907
+ " ",
908
+ link(TermsLink, "conditions d'utilisation"),
909
+ " de Google s'appliquent."
910
+ ] });
911
+ }
912
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "cs-recaptcha", children: [
913
+ "This site is protected by reCAPTCHA and the Google ",
914
+ link(PrivacyLink, "Privacy Policy"),
915
+ " ",
916
+ "and ",
917
+ link(TermsLink, "Terms of Service"),
918
+ " apply."
919
+ ] });
920
+ }
921
+ function OrderFormView(props) {
922
+ var _a;
923
+ const data = useCheckoutData();
924
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { ...blockRoot(props, "cs-form"), "data-funnel": "form", children: [
925
+ props.includeCatalog ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Catalog, { data }) : null,
926
+ data.funnel.form.fields.filter((field) => field.enabled).map((field) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
927
+ "div",
928
+ {
929
+ className: "cs-field",
930
+ "data-funnel-field": field.type,
931
+ "data-required": String(field.required),
932
+ children: [
933
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { "data-i18n": field.type }),
934
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormField, { data, type: field.type }),
935
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-field__error", "data-error": "" })
936
+ ]
937
+ },
938
+ field.type
939
+ )),
940
+ ((_a = data.deliveryPrices) == null ? void 0 : _a.stopdeskEnabled) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-ship", "data-funnel": "shipping-method", children: [
941
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
942
+ "button",
943
+ {
944
+ type: "button",
945
+ className: "cs-chip is-active",
946
+ "data-ship": "home",
947
+ "data-i18n": "homeDelivery"
948
+ }
949
+ ),
950
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
951
+ "button",
952
+ {
953
+ type: "button",
954
+ className: "cs-chip",
955
+ "data-ship": "stopdesk",
956
+ "data-i18n": "stopDesk"
957
+ }
958
+ )
959
+ ] }) : null,
960
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Totals, {}),
961
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "submit", className: "cs-submit", "data-i18n": "orderNow" }),
962
+ data.api.recaptchaSiteKey ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RecaptchaNotice, { language: data.funnel.language }) : null
963
+ ] });
964
+ }
965
+ var ProductCatalog = defineBlock({
966
+ type: "ProductCatalog",
967
+ label: "Offers and variants",
968
+ description: "The offer picker, or the variant chips and quantity when the product has no offers. Use it only when the order form does not include the catalog.",
969
+ category: "checkout",
970
+ schema: import_zod6.z.object({}),
971
+ fields: {},
972
+ render: function ProductCatalog2(props) {
973
+ const data = useCheckoutData();
974
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ...blockRoot(props), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Catalog, { data }) });
975
+ }
976
+ });
977
+ var OrderForm = defineBlock({
978
+ type: "OrderForm",
979
+ label: "Order form",
980
+ description: "The checkout form: customer fields, shipping method, totals and the order button. Every funnel page needs exactly one. Set includeCatalog to show the offers and variants inside the form.",
981
+ category: "checkout",
982
+ schema: import_zod6.z.object({
983
+ includeCatalog: import_zod6.z.boolean().default(true)
984
+ }),
985
+ fields: {
986
+ includeCatalog: {
987
+ type: "radio",
988
+ label: "Show offers and variants in the form",
989
+ options: [
990
+ { label: "Yes", value: true },
991
+ { label: "No", value: false }
992
+ ]
993
+ }
994
+ },
995
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OrderFormView, { ...props })
996
+ });
997
+
998
+ // src/blocks/store.tsx
999
+ var import_zod7 = require("zod");
1000
+
1001
+ // src/money.ts
1002
+ function moneyFormatter({
1003
+ language,
1004
+ iso2,
1005
+ currency
1006
+ }) {
1007
+ const options = {
1008
+ style: "currency",
1009
+ currency,
1010
+ currencyDisplay: "symbol",
1011
+ minimumFractionDigits: 0,
1012
+ maximumFractionDigits: 2
1013
+ };
1014
+ const country = iso2.toUpperCase();
1015
+ const part = (locale2) => {
1016
+ var _a, _b;
1017
+ return (_b = (_a = new Intl.NumberFormat(locale2, options).formatToParts(0).find((p) => p.type === "currency")) == null ? void 0 : _a.value) != null ? _b : "";
1018
+ };
1019
+ const isCode = (symbol2) => symbol2.replace(/\./g, "").toUpperCase() === currency.toUpperCase();
1020
+ const locale = `${language}-${country}`;
1021
+ const formatter = new Intl.NumberFormat(locale, options);
1022
+ const symbol = [locale, `fr-${country}`, `ar-${country}`].map(part).find((item) => !isCode(item));
1023
+ return (value) => formatter.formatToParts(value).map((item) => item.type === "currency" ? symbol != null ? symbol : item.value : item.value).join("");
1024
+ }
1025
+
1026
+ // src/blocks/store.tsx
1027
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1028
+ var LabelKeys = [
1029
+ "bestSellers",
1030
+ "newArrivals",
1031
+ "shopByCategory",
1032
+ "youMayAlsoLike",
1033
+ "categories",
1034
+ "allProducts",
1035
+ "cod"
1036
+ ];
1037
+ var LabelKeySchema = import_zod7.z.enum(LabelKeys);
1038
+ var labelOptions = LabelKeys.map((key) => ({ label: key, value: key }));
1039
+ var TextSchema = import_zod7.z.string().max(300);
1040
+ function heading(store, text, label) {
1041
+ return text || store.labels[label];
1042
+ }
1043
+ var MenuIcon = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1044
+ "svg",
1045
+ {
1046
+ viewBox: "0 0 24 24",
1047
+ width: "22",
1048
+ height: "22",
1049
+ fill: "none",
1050
+ stroke: "currentColor",
1051
+ strokeWidth: "1.8",
1052
+ strokeLinecap: "round",
1053
+ "aria-hidden": "true",
1054
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M3 6h18M3 12h18M3 18h18" })
1055
+ }
1056
+ );
1057
+ var SearchIcon = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1058
+ "svg",
1059
+ {
1060
+ viewBox: "0 0 24 24",
1061
+ width: "22",
1062
+ height: "22",
1063
+ fill: "none",
1064
+ stroke: "currentColor",
1065
+ strokeWidth: "1.8",
1066
+ strokeLinecap: "round",
1067
+ "aria-hidden": "true",
1068
+ children: [
1069
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
1070
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "m20 20-3.5-3.5" })
1071
+ ]
1072
+ }
1073
+ );
1074
+ function ProductCard({
1075
+ item,
1076
+ position,
1077
+ list,
1078
+ money
1079
+ }) {
1080
+ var _a;
1081
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1082
+ "a",
1083
+ {
1084
+ className: "card",
1085
+ href: item.url,
1086
+ "data-product-card": "",
1087
+ "data-category": (_a = item.categoryId) != null ? _a : "",
1088
+ "data-price": item.fromPrice,
1089
+ "data-name": item.product.name,
1090
+ "data-position": position,
1091
+ "data-track": "product",
1092
+ "data-product-id": item.product.trackingId,
1093
+ "data-list": list,
1094
+ children: [
1095
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "card__media", children: [
1096
+ item.cardImage ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1097
+ "img",
1098
+ {
1099
+ className: "card__image",
1100
+ src: item.cardImage,
1101
+ alt: item.product.name,
1102
+ loading: "lazy",
1103
+ decoding: "async"
1104
+ }
1105
+ ) : null,
1106
+ item.cardHoverImage ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1107
+ "img",
1108
+ {
1109
+ className: "card__hover",
1110
+ src: item.cardHoverImage,
1111
+ alt: "",
1112
+ loading: "lazy",
1113
+ decoding: "async"
1114
+ }
1115
+ ) : null,
1116
+ item.discountPercent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "card__badge", children: `-${item.discountPercent}%` }) : null
1117
+ ] }),
1118
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "card__body", children: [
1119
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "card__name", children: item.product.name }),
1120
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "card__price", children: [
1121
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: money(item.fromPrice) }),
1122
+ item.compareAtPrice ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("s", { children: money(item.compareAtPrice) }) : null
1123
+ ] })
1124
+ ] })
1125
+ ]
1126
+ }
1127
+ );
1128
+ }
1129
+ function SectionHead({ title, viewAll }) {
1130
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "section-head", children: [
1131
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: title }),
1132
+ viewAll ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: viewAll }) : null
1133
+ ] });
1134
+ }
1135
+ var CategoryItemStyles = ["card", "pill", "tag", "chip", "link", "room"];
1136
+ function CategoryItem({
1137
+ entry,
1138
+ itemStyle
1139
+ }) {
1140
+ const track = { "data-track": "category", "data-category-id": entry.trackingId };
1141
+ if (itemStyle === "card") {
1142
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "category", href: entry.url, ...track, children: [
1143
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "category__media", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: entry.imageUrl, alt: entry.name, loading: "lazy", decoding: "async" }) }),
1144
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "category__name", children: entry.name })
1145
+ ] });
1146
+ }
1147
+ if (itemStyle === "chip") {
1148
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "chip-link", href: entry.url, ...track, children: [
1149
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: entry.imageUrl, alt: "", loading: "lazy", decoding: "async" }),
1150
+ entry.name
1151
+ ] });
1152
+ }
1153
+ if (itemStyle === "room") {
1154
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "room", href: entry.url, ...track, children: [
1155
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: entry.imageUrl, alt: entry.name, loading: "lazy", decoding: "async" }),
1156
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: entry.name })
1157
+ ] });
1158
+ }
1159
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: itemStyle === "link" ? void 0 : itemStyle, href: entry.url, ...track, children: entry.name });
1160
+ }
1161
+ function trimmed(value, characters) {
1162
+ return (value != null ? value : "").split("").filter((character) => !characters.includes(character)).join("");
1163
+ }
1164
+ var AnnouncementBar = defineBlock({
1165
+ type: "AnnouncementBar",
1166
+ label: "Announcement bar",
1167
+ description: "The thin bar above the header with the announcement text from the store settings. Renders nothing when the announcement is off.",
1168
+ category: "store",
1169
+ schema: import_zod7.z.object({}),
1170
+ fields: {},
1171
+ render: function AnnouncementBar2(props) {
1172
+ const { onlineStore } = useStoreData();
1173
+ if (!onlineStore.announcementBarEnabled || !onlineStore.announcementBarText) return null;
1174
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "announcement"), children: onlineStore.announcementBarText });
1175
+ }
1176
+ });
1177
+ var StoreHeader = defineBlock({
1178
+ type: "StoreHeader",
1179
+ label: "Header",
1180
+ description: "The store navbar: menu button, logo, links to home, all products, the first categories and contact, the search link, and the mobile menu.",
1181
+ category: "store",
1182
+ schema: import_zod7.z.object({
1183
+ navCategories: import_zod7.z.number().int().min(0).max(12).default(4)
1184
+ }),
1185
+ fields: {
1186
+ navCategories: { type: "number", label: "Categories in the navbar" }
1187
+ },
1188
+ render: function StoreHeader2(props) {
1189
+ const { labels: t, onlineStore, categories: categories2 } = useStoreData();
1190
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "head"), children: [
1191
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "head__bar", children: [
1192
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1193
+ "button",
1194
+ {
1195
+ className: "head__icon head__menu",
1196
+ type: "button",
1197
+ "data-store": "menu-toggle",
1198
+ "aria-label": t.menu,
1199
+ "aria-expanded": "false",
1200
+ children: MenuIcon
1201
+ }
1202
+ ),
1203
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "logo", href: "/", children: onlineStore.logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: onlineStore.logoUrl, alt: onlineStore.name }) : onlineStore.name }),
1204
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { className: "head__nav", "aria-label": t.menu, children: [
1205
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/", children: t.home }),
1206
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: t.allProducts }),
1207
+ categories2.slice(0, props.navCategories).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: entry.url, children: entry.name }, entry.trackingId)),
1208
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/contact", children: t.contact })
1209
+ ] }),
1210
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "head__icon head__search", href: "/products", "aria-label": t.search, children: SearchIcon })
1211
+ ] }),
1212
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { className: "menu", "data-store": "menu", hidden: true, "aria-label": t.menu, children: [
1213
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/", children: t.home }),
1214
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: t.allProducts }),
1215
+ categories2.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: entry.url, children: entry.name }, entry.trackingId)),
1216
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/about", children: t.about }),
1217
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/contact", children: t.contact })
1218
+ ] })
1219
+ ] });
1220
+ }
1221
+ });
1222
+ var StoreFooter = defineBlock({
1223
+ type: "StoreFooter",
1224
+ label: "Footer",
1225
+ description: "The store footer: name and tagline, shop links with the first categories, help and policy links, social links, and the copyright line.",
1226
+ category: "store",
1227
+ schema: import_zod7.z.object({
1228
+ footerCategories: import_zod7.z.number().int().min(0).max(12).default(5)
1229
+ }),
1230
+ fields: {
1231
+ footerCategories: { type: "number", label: "Categories in the footer" }
1232
+ },
1233
+ render: function StoreFooter2(props) {
1234
+ const { labels: t, onlineStore, categories: categories2 } = useStoreData();
1235
+ const { contact: contact2 } = onlineStore;
1236
+ const social = { rel: "noopener noreferrer", target: "_blank" };
1237
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("footer", { ...blockRoot(props, "foot"), children: [
1238
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "foot__inner", children: [
1239
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "foot__brand", children: [
1240
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "logo", href: "/", children: onlineStore.name }),
1241
+ onlineStore.tagline ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: onlineStore.tagline }) : null
1242
+ ] }),
1243
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1244
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h4", { children: t.shop }),
1245
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: t.allProducts }),
1246
+ categories2.slice(0, props.footerCategories).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: entry.url, children: entry.name }, entry.trackingId))
1247
+ ] }),
1248
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1249
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h4", { children: t.help }),
1250
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/about", children: t.about }),
1251
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/contact", children: t.contact }),
1252
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/privacy-policy", children: t.privacyPolicy }),
1253
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/refund-policy", children: t.refundPolicy }),
1254
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/terms-of-service", children: t.termsOfService })
1255
+ ] }),
1256
+ contact2.facebook || contact2.instagram || contact2.tiktok ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1257
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h4", { children: t.followUs }),
1258
+ contact2.facebook ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: contact2.facebook, ...social, children: "Facebook" }) : null,
1259
+ contact2.instagram ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: contact2.instagram, ...social, children: "Instagram" }) : null,
1260
+ contact2.tiktok ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: contact2.tiktok, ...social, children: "TikTok" }) : null
1261
+ ] }) : null
1262
+ ] }),
1263
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "foot__legal", children: `\xA9 ${onlineStore.name}. ${t.rights}` })
1264
+ ] });
1265
+ }
1266
+ });
1267
+ var StoreHeroTitle = defineBlock({
1268
+ type: "StoreHeroTitle",
1269
+ label: "Hero title",
1270
+ description: "The home page headline. Uses text when set, otherwise the hero title from the store settings, otherwise a default for the store language.",
1271
+ category: "store",
1272
+ schema: import_zod7.z.object({ text: TextSchema.default("") }),
1273
+ fields: { text: { type: "text", label: "Text" } },
1274
+ render: function StoreHeroTitle2(props) {
1275
+ const { labels: t, onlineStore } = useStoreData();
1276
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { ...blockRoot(props, "hero__title"), children: props.text || onlineStore.hero.title || t.heroTitle });
1277
+ }
1278
+ });
1279
+ var StoreHeroSubtitle = defineBlock({
1280
+ type: "StoreHeroSubtitle",
1281
+ label: "Hero subtitle",
1282
+ description: "The line under the home page headline. Uses text when set, otherwise the hero subtitle from the store settings, otherwise a default.",
1283
+ category: "store",
1284
+ schema: import_zod7.z.object({ text: TextSchema.default("") }),
1285
+ fields: { text: { type: "textarea", label: "Text" } },
1286
+ render: function StoreHeroSubtitle2(props) {
1287
+ const { labels: t, onlineStore } = useStoreData();
1288
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { ...blockRoot(props, "hero__subtitle"), children: props.text || onlineStore.hero.subtitle || t.heroSubtitle });
1289
+ }
1290
+ });
1291
+ var StoreHeroButton = defineBlock({
1292
+ type: "StoreHeroButton",
1293
+ label: "Hero button",
1294
+ description: "The home page call to action. Links to all products. Uses label when set, otherwise the hero button label from the store settings.",
1295
+ category: "store",
1296
+ schema: import_zod7.z.object({
1297
+ label: TextSchema.default(""),
1298
+ href: import_zod7.z.string().max(500).regex(/^(https?:\/\/|\/|#)/, "A link must start with https://, / or #").default("/products")
1299
+ }),
1300
+ fields: {
1301
+ label: { type: "text", label: "Label" },
1302
+ href: { type: "text", label: "Link" }
1303
+ },
1304
+ render: function StoreHeroButton2(props) {
1305
+ const { labels: t, onlineStore } = useStoreData();
1306
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { ...blockRoot(props, "btn"), href: props.href, children: props.label || onlineStore.hero.ctaLabel || t.shopNow });
1307
+ }
1308
+ });
1309
+ var StoreHeroImage = defineBlock({
1310
+ type: "StoreHeroImage",
1311
+ label: "Hero image",
1312
+ description: "The hero image from the store settings, loaded first. Set frameClassName to wrap it in a div. Renders nothing when the store has no hero image.",
1313
+ category: "store",
1314
+ schema: import_zod7.z.object({ frameClassName: ClassNameSchema.default("") }),
1315
+ fields: { frameClassName: { type: "text", label: "Frame class" } },
1316
+ preload: (_props, data) => {
1317
+ const imageUrl = storeData(data).onlineStore.hero.imageUrl;
1318
+ return imageUrl ? [imageUrl] : [];
1319
+ },
1320
+ render: function StoreHeroImage2(props) {
1321
+ const { onlineStore } = useStoreData();
1322
+ if (!onlineStore.hero.imageUrl) return null;
1323
+ const image = (attributes) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1324
+ "img",
1325
+ {
1326
+ ...attributes,
1327
+ src: onlineStore.hero.imageUrl,
1328
+ alt: onlineStore.name,
1329
+ fetchPriority: "high",
1330
+ decoding: "async"
1331
+ }
1332
+ );
1333
+ if (props.frameClassName) {
1334
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, props.frameClassName), children: image({}) });
1335
+ }
1336
+ return image(blockRoot(props));
1337
+ }
1338
+ });
1339
+ var StoreCategories = defineBlock({
1340
+ type: "StoreCategories",
1341
+ label: "Categories",
1342
+ description: "The store categories as links. layout nav renders a nav list, layout section renders a titled section. Renders nothing when the store has no categories.",
1343
+ category: "store",
1344
+ schema: import_zod7.z.object({
1345
+ layout: import_zod7.z.enum(["nav", "section"]).default("section"),
1346
+ listClassName: ClassNameSchema.default("categories"),
1347
+ itemStyle: import_zod7.z.enum(CategoryItemStyles).default("card"),
1348
+ title: TextSchema.default(""),
1349
+ titleLabel: LabelKeySchema.default("shopByCategory")
1350
+ }),
1351
+ fields: {
1352
+ layout: {
1353
+ type: "radio",
1354
+ label: "Layout",
1355
+ options: [
1356
+ { label: "List", value: "nav" },
1357
+ { label: "Titled section", value: "section" }
1358
+ ]
1359
+ },
1360
+ listClassName: { type: "text", label: "List class" },
1361
+ itemStyle: {
1362
+ type: "select",
1363
+ label: "Item style",
1364
+ options: CategoryItemStyles.map((style) => ({ label: style, value: style }))
1365
+ },
1366
+ title: { type: "text", label: "Title" },
1367
+ titleLabel: { type: "select", label: "Default title", options: labelOptions }
1368
+ },
1369
+ render: function StoreCategories2(props) {
1370
+ const store = useStoreData();
1371
+ if (!store.categories.length) return null;
1372
+ const items = store.categories.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CategoryItem, { entry, itemStyle: props.itemStyle }, entry.trackingId));
1373
+ if (props.layout === "nav") {
1374
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1375
+ "nav",
1376
+ {
1377
+ ...blockRoot(props, props.listClassName),
1378
+ "aria-label": store.labels.categories,
1379
+ children: items
1380
+ }
1381
+ );
1382
+ }
1383
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { ...blockRoot(props, "section"), children: [
1384
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SectionHead, { title: heading(store, props.title, props.titleLabel), viewAll: null }),
1385
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: props.listClassName, children: items })
1386
+ ] });
1387
+ }
1388
+ });
1389
+ var StoreProductGrid = defineBlock({
1390
+ type: "StoreProductGrid",
1391
+ label: "Product grid",
1392
+ description: "A titled section of product cards. source home shows the featured products first, related shows products from the same category on a product page.",
1393
+ category: "store",
1394
+ schema: import_zod7.z.object({
1395
+ source: import_zod7.z.enum(["home", "related"]).default("home"),
1396
+ gridClassName: ClassNameSchema.default(""),
1397
+ title: TextSchema.default(""),
1398
+ titleLabel: LabelKeySchema.default("bestSellers"),
1399
+ viewAll: import_zod7.z.boolean().default(true),
1400
+ hideWhenEmpty: import_zod7.z.boolean().default(true)
1401
+ }),
1402
+ fields: {
1403
+ source: {
1404
+ type: "radio",
1405
+ label: "Products",
1406
+ options: [
1407
+ { label: "Home products", value: "home" },
1408
+ { label: "Related products", value: "related" }
1409
+ ]
1410
+ },
1411
+ gridClassName: { type: "text", label: "Grid class" },
1412
+ title: { type: "text", label: "Title" },
1413
+ titleLabel: { type: "select", label: "Default title", options: labelOptions },
1414
+ viewAll: {
1415
+ type: "radio",
1416
+ label: "View all link",
1417
+ options: [
1418
+ { label: "Yes", value: true },
1419
+ { label: "No", value: false }
1420
+ ]
1421
+ },
1422
+ hideWhenEmpty: {
1423
+ type: "radio",
1424
+ label: "Hide when empty",
1425
+ options: [
1426
+ { label: "Yes", value: true },
1427
+ { label: "No", value: false }
1428
+ ]
1429
+ }
1430
+ },
1431
+ render: function StoreProductGrid2(props) {
1432
+ var _a, _b;
1433
+ const store = useStoreData();
1434
+ const products2 = props.source === "related" ? (_b = (_a = store.productPage) == null ? void 0 : _a.related) != null ? _b : [] : store.homeProducts;
1435
+ if (props.hideWhenEmpty && !products2.length) return null;
1436
+ const money = moneyFormatter(store.money);
1437
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { ...blockRoot(props, "section"), children: [
1438
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1439
+ SectionHead,
1440
+ {
1441
+ title: heading(store, props.title, props.titleLabel),
1442
+ viewAll: props.viewAll ? store.labels.viewAll : null
1443
+ }
1444
+ ),
1445
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `grid ${props.gridClassName}`, children: products2.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1446
+ ProductCard,
1447
+ {
1448
+ item,
1449
+ position: index,
1450
+ list: props.source,
1451
+ money
1452
+ },
1453
+ item.url
1454
+ )) })
1455
+ ] });
1456
+ }
1457
+ });
1458
+ var TrustItems = [
1459
+ ["cod", "codText"],
1460
+ ["fastDelivery", "fastDeliveryText"],
1461
+ ["confirmed", "confirmedText"],
1462
+ ["easyReturns", "easyReturnsText"]
1463
+ ];
1464
+ var StoreTrust = defineBlock({
1465
+ type: "StoreTrust",
1466
+ label: "Trust badges",
1467
+ description: "Cash on delivery, fast delivery, phone confirmation and easy returns, in the store language. variant bento shows them as tiles.",
1468
+ category: "store",
1469
+ schema: import_zod7.z.object({ variant: import_zod7.z.enum(["list", "bento"]).default("list") }),
1470
+ fields: {
1471
+ variant: {
1472
+ type: "radio",
1473
+ label: "Style",
1474
+ options: [
1475
+ { label: "List", value: "list" },
1476
+ { label: "Tiles", value: "bento" }
1477
+ ]
1478
+ }
1479
+ },
1480
+ render: function StoreTrust2(props) {
1481
+ const { labels: t } = useStoreData();
1482
+ if (props.variant === "bento") {
1483
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "bento"), style: { marginBlockStart: "8px" }, children: TrustItems.map(([title, text]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "bento__tile", children: [
1484
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: t[title] }),
1485
+ t[text]
1486
+ ] }, title)) });
1487
+ }
1488
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "trust"), children: TrustItems.map(([title, text]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "trust__item", children: [
1489
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: t[title] }),
1490
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t[text] })
1491
+ ] }, title)) });
1492
+ }
1493
+ });
1494
+ var StoreTagline = defineBlock({
1495
+ type: "StoreTagline",
1496
+ label: "Tagline",
1497
+ description: "The store tagline from the settings, as a quote section. Renders nothing when the store has no tagline.",
1498
+ category: "store",
1499
+ schema: import_zod7.z.object({}),
1500
+ fields: {},
1501
+ render: function StoreTagline2(props) {
1502
+ const { onlineStore } = useStoreData();
1503
+ if (!onlineStore.tagline) return null;
1504
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: onlineStore.tagline }) });
1505
+ }
1506
+ });
1507
+ var StoreTicker = defineBlock({
1508
+ type: "StoreTicker",
1509
+ label: "Ticker",
1510
+ description: "A scrolling strip that repeats the given labels.",
1511
+ category: "store",
1512
+ schema: import_zod7.z.object({
1513
+ labels: import_zod7.z.array(LabelKeySchema).max(4).default(["newArrivals", "cod"]),
1514
+ repeat: import_zod7.z.number().int().min(1).max(20).default(8)
1515
+ }),
1516
+ fields: {
1517
+ repeat: { type: "number", label: "Repeat" }
1518
+ },
1519
+ render: function StoreTicker2(props) {
1520
+ const { labels: t } = useStoreData();
1521
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "ticker"), "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ticker__track", children: Array.from(
1522
+ { length: props.repeat },
1523
+ (_, index) => props.labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t[label] }, `${index}-${label}`))
1524
+ ) }) });
1525
+ }
1526
+ });
1527
+ var StoreSearch = defineBlock({
1528
+ type: "StoreSearch",
1529
+ label: "Search box",
1530
+ description: "A search field that opens all products filtered by the query.",
1531
+ category: "store",
1532
+ schema: import_zod7.z.object({}),
1533
+ fields: {},
1534
+ render: function StoreSearch2(props) {
1535
+ const { labels: t } = useStoreData();
1536
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("form", { ...blockRoot(props, "home-search"), action: "/products", role: "search", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "search", name: "q", placeholder: t.search, "aria-label": t.search }) });
1537
+ }
1538
+ });
1539
+ var Ornament = defineBlock({
1540
+ type: "Ornament",
1541
+ label: "Ornament",
1542
+ description: "An empty decorative element, drawn by its class and css.",
1543
+ category: "store",
1544
+ schema: import_zod7.z.object({}),
1545
+ fields: {},
1546
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {}) })
1547
+ });
1548
+ var StorePageHeading = defineBlock({
1549
+ type: "StorePageHeading",
1550
+ label: "Page heading",
1551
+ description: "The page title. source listing shows the category or all products with the product count, contact shows the contact title and intro, article shows the page title.",
1552
+ category: "store",
1553
+ schema: import_zod7.z.object({
1554
+ source: import_zod7.z.enum(["listing", "contact", "article"]).default("listing"),
1555
+ title: TextSchema.default(""),
1556
+ text: TextSchema.default("")
1557
+ }),
1558
+ fields: {
1559
+ source: {
1560
+ type: "select",
1561
+ label: "Page",
1562
+ options: [
1563
+ { label: "Listing", value: "listing" },
1564
+ { label: "Contact", value: "contact" },
1565
+ { label: "Article", value: "article" }
1566
+ ]
1567
+ },
1568
+ title: { type: "text", label: "Title" },
1569
+ text: { type: "textarea", label: "Text" }
1570
+ },
1571
+ render: function StorePageHeading2(props) {
1572
+ var _a, _b;
1573
+ const store = useStoreData();
1574
+ const t = store.labels;
1575
+ if (props.source === "listing") {
1576
+ const listing2 = store.listing;
1577
+ const title = props.title || ((listing2 == null ? void 0 : listing2.category) ? listing2.category.name : t.allProducts);
1578
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "page-head"), children: [
1579
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: title }),
1580
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || `${(_a = listing2 == null ? void 0 : listing2.products.length) != null ? _a : 0} ${t.productsCount}` })
1581
+ ] });
1582
+ }
1583
+ if (props.source === "contact") {
1584
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "page-head"), children: [
1585
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || t.contact }),
1586
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || t.contactIntro })
1587
+ ] });
1588
+ }
1589
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "page-head"), children: [
1590
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || ((_b = store.article) == null ? void 0 : _b.title) }),
1591
+ props.text ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text }) : null
1592
+ ] });
1593
+ }
1594
+ });
1595
+ var ListingToolbar = defineBlock({
1596
+ type: "ListingToolbar",
1597
+ label: "Listing toolbar",
1598
+ description: "Category filters (on all products only), the search field and the sort menu of a product listing.",
1599
+ category: "store",
1600
+ schema: import_zod7.z.object({}),
1601
+ fields: {},
1602
+ render: function ListingToolbar2(props) {
1603
+ const { labels: t, categories: categories2, listing: listing2 } = useStoreData();
1604
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "toolbar"), children: [
1605
+ !(listing2 == null ? void 0 : listing2.category) && categories2.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "toolbar__filters", children: [
1606
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "chip is-active", "data-filter-category": "", children: t.all }),
1607
+ categories2.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1608
+ "button",
1609
+ {
1610
+ type: "button",
1611
+ className: "chip",
1612
+ "data-filter-category": entry.trackingId,
1613
+ children: entry.name
1614
+ },
1615
+ entry.trackingId
1616
+ ))
1617
+ ] }) : null,
1618
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1619
+ "input",
1620
+ {
1621
+ className: "search-input",
1622
+ type: "search",
1623
+ "data-store": "search",
1624
+ placeholder: t.search,
1625
+ "aria-label": t.search
1626
+ }
1627
+ ),
1628
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("select", { "data-store": "sort", "aria-label": t.sortBy, children: [
1629
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "position", children: t.sortFeatured }),
1630
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "price-asc", children: t.sortPriceAsc }),
1631
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "price-desc", children: t.sortPriceDesc })
1632
+ ] })
1633
+ ] });
1634
+ }
1635
+ });
1636
+ var ListingGrid = defineBlock({
1637
+ type: "ListingGrid",
1638
+ label: "Listing products",
1639
+ description: "The product cards of a listing page, filtered and sorted in the browser.",
1640
+ category: "store",
1641
+ schema: import_zod7.z.object({}),
1642
+ fields: {},
1643
+ render: function ListingGrid2(props) {
1644
+ var _a, _b;
1645
+ const store = useStoreData();
1646
+ const money = moneyFormatter(store.money);
1647
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "grid"), "data-store": "listing", children: ((_b = (_a = store.listing) == null ? void 0 : _a.products) != null ? _b : []).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1648
+ ProductCard,
1649
+ {
1650
+ item,
1651
+ position: index,
1652
+ list: "listing",
1653
+ money
1654
+ },
1655
+ item.url
1656
+ )) });
1657
+ }
1658
+ });
1659
+ var ListingEmpty = defineBlock({
1660
+ type: "ListingEmpty",
1661
+ label: "No results",
1662
+ description: "The message shown when the listing filters match no product.",
1663
+ category: "store",
1664
+ schema: import_zod7.z.object({ text: TextSchema.default("") }),
1665
+ fields: { text: { type: "text", label: "Text" } },
1666
+ render: function ListingEmpty2(props) {
1667
+ const { labels: t } = useStoreData();
1668
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { ...blockRoot(props, "empty"), "data-store": "empty", hidden: true, children: props.text || t.noProducts });
1669
+ }
1670
+ });
1671
+ var ListingLoadMore = defineBlock({
1672
+ type: "ListingLoadMore",
1673
+ label: "Load more",
1674
+ description: "The button that shows the next products of a long listing.",
1675
+ category: "store",
1676
+ schema: import_zod7.z.object({ label: TextSchema.default("") }),
1677
+ fields: { label: { type: "text", label: "Label" } },
1678
+ render: function ListingLoadMore2(props) {
1679
+ const { labels: t } = useStoreData();
1680
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "more"), "data-store": "load-more", hidden: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "btn btn--ghost", children: props.label || t.loadMore }) });
1681
+ }
1682
+ });
1683
+ var StoreProductGallery = defineBlock({
1684
+ type: "StoreProductGallery",
1685
+ label: "Product gallery",
1686
+ description: "The product page images with thumbnails. The first image loads first.",
1687
+ category: "store",
1688
+ schema: import_zod7.z.object({}),
1689
+ fields: {},
1690
+ preload: (_props, data) => {
1691
+ var _a, _b;
1692
+ return ((_b = (_a = storeData(data).productPage) == null ? void 0 : _a.gallery) != null ? _b : []).slice(0, 1);
1693
+ },
1694
+ render: function StoreProductGallery2(props) {
1695
+ var _a, _b;
1696
+ const store = useStoreData();
1697
+ const { product: product2 } = useCheckoutData();
1698
+ const gallery = (_b = (_a = store.productPage) == null ? void 0 : _a.gallery) != null ? _b : [];
1699
+ const name = product2.name;
1700
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { ...blockRoot(props, "pdp__media"), "data-funnel": "lead-images", children: [
1701
+ gallery.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1702
+ "img",
1703
+ {
1704
+ className: "pdp__main",
1705
+ "data-gallery-main": "",
1706
+ src: gallery[0],
1707
+ alt: name,
1708
+ fetchPriority: "high",
1709
+ decoding: "async"
1710
+ }
1711
+ ) : null,
1712
+ gallery.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "pdp__thumbs", children: gallery.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1713
+ "img",
1714
+ {
1715
+ src: image,
1716
+ alt: name,
1717
+ "data-gallery-thumb": "",
1718
+ className: index === 0 ? "is-active" : void 0,
1719
+ loading: index === 0 ? void 0 : "lazy",
1720
+ decoding: "async"
1721
+ },
1722
+ `${index}-${image}`
1723
+ )) }) : null
1724
+ ] });
1725
+ }
1726
+ });
1727
+ var StoreBreadcrumbs = defineBlock({
1728
+ type: "StoreBreadcrumbs",
1729
+ label: "Breadcrumbs",
1730
+ description: "Home and the product category above the product name.",
1731
+ category: "store",
1732
+ schema: import_zod7.z.object({}),
1733
+ fields: {},
1734
+ render: function StoreBreadcrumbs2(props) {
1735
+ const { labels: t, productPage } = useStoreData();
1736
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { ...blockRoot(props, "crumbs"), "aria-label": t.menu, children: [
1737
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/", children: t.home }),
1738
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "/" }),
1739
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: (productPage == null ? void 0 : productPage.categoryName) || t.allProducts })
1740
+ ] });
1741
+ }
1742
+ });
1743
+ var StoreProductTitle = defineBlock({
1744
+ type: "StoreProductTitle",
1745
+ label: "Product name",
1746
+ description: "The product name on a store product page.",
1747
+ category: "store",
1748
+ schema: import_zod7.z.object({}),
1749
+ fields: {},
1750
+ render: function StoreProductTitle2(props) {
1751
+ const { product: product2 } = useCheckoutData();
1752
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { ...blockRoot(props, "pdp__title"), "data-funnel": "product-name", children: product2.name });
1753
+ }
1754
+ });
1755
+ var StoreProductPrice = defineBlock({
1756
+ type: "StoreProductPrice",
1757
+ label: "Product price",
1758
+ description: "The product price on a store product page. The checkout replaces it with the price of the chosen offer.",
1759
+ category: "store",
1760
+ schema: import_zod7.z.object({}),
1761
+ fields: {},
1762
+ render: function StoreProductPrice2(props) {
1763
+ var _a, _b;
1764
+ const store = useStoreData();
1765
+ const money = moneyFormatter(store.money);
1766
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "cs-price"), "data-funnel": "price", children: [
1767
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cs-price__current", "data-display-price": "", children: money((_b = (_a = store.productPage) == null ? void 0 : _a.price) != null ? _b : 0) }),
1768
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cs-price__compare", "data-compare-price": "" })
1769
+ ] });
1770
+ }
1771
+ });
1772
+ var StoreProductDescription = defineBlock({
1773
+ type: "StoreProductDescription",
1774
+ label: "Product description",
1775
+ description: "The landing page images of the product, or its text description when it has no images. Renders nothing when it has neither.",
1776
+ category: "store",
1777
+ schema: import_zod7.z.object({}),
1778
+ fields: {},
1779
+ render: function StoreProductDescription2(props) {
1780
+ const { product: product2, landingPage } = useCheckoutData();
1781
+ if (landingPage.images.length) {
1782
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "pdp-images"), "data-funnel": "description", children: landingPage.images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1783
+ "img",
1784
+ {
1785
+ src: image,
1786
+ alt: product2.name,
1787
+ loading: "lazy",
1788
+ decoding: "async"
1789
+ },
1790
+ `${index}-${image}`
1791
+ )) });
1792
+ }
1793
+ if (!product2.description) return null;
1794
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "pdp-text"), "data-funnel": "description", children: product2.description });
1795
+ }
1796
+ });
1797
+ var StoreProductFaq = defineBlock({
1798
+ type: "StoreProductFaq",
1799
+ label: "Product FAQ",
1800
+ description: "The product questions and answers. Renders nothing when there are none.",
1801
+ category: "store",
1802
+ schema: import_zod7.z.object({}),
1803
+ fields: {},
1804
+ render: function StoreProductFaq2(props) {
1805
+ const { product: product2 } = useCheckoutData();
1806
+ if (!product2.faq.length) return null;
1807
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "pdp-faq"), "data-funnel": "faq", children: product2.faq.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("details", { children: [
1808
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("summary", { children: entry.question }),
1809
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: entry.answer })
1810
+ ] }, index)) });
1811
+ }
1812
+ });
1813
+ var ContactDetails = defineBlock({
1814
+ type: "ContactDetails",
1815
+ label: "Contact details",
1816
+ description: "WhatsApp, phone, email and address from the store settings, each when set.",
1817
+ category: "store",
1818
+ schema: import_zod7.z.object({}),
1819
+ fields: {},
1820
+ render: function ContactDetails2(props) {
1821
+ const { labels: t, onlineStore } = useStoreData();
1822
+ const { contact: contact2 } = onlineStore;
1823
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "contact__info"), children: [
1824
+ contact2.whatsapp ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1825
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.whatsapp }),
1826
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1827
+ "a",
1828
+ {
1829
+ dir: "ltr",
1830
+ href: `https://wa.me/${trimmed(contact2.whatsapp, ["+", " "])}`,
1831
+ rel: "noopener noreferrer",
1832
+ target: "_blank",
1833
+ "data-track": "contact",
1834
+ "data-channel": "whatsapp",
1835
+ children: contact2.whatsapp
1836
+ }
1837
+ )
1838
+ ] }) : null,
1839
+ contact2.phone ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1840
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.phone }),
1841
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1842
+ "a",
1843
+ {
1844
+ dir: "ltr",
1845
+ href: `tel:${trimmed(contact2.phone, [" "])}`,
1846
+ "data-track": "contact",
1847
+ "data-channel": "phone",
1848
+ children: contact2.phone
1849
+ }
1850
+ )
1851
+ ] }) : null,
1852
+ contact2.email ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1853
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.email }),
1854
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1855
+ "a",
1856
+ {
1857
+ href: `mailto:${contact2.email}`,
1858
+ "data-track": "contact",
1859
+ "data-channel": "email",
1860
+ children: contact2.email
1861
+ }
1862
+ )
1863
+ ] }) : null,
1864
+ contact2.address ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1865
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.address }),
1866
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: contact2.address })
1867
+ ] }) : null
1868
+ ] });
1869
+ }
1870
+ });
1871
+ var ContactFields = [
1872
+ { name: "name", label: "yourName", type: "text", autoComplete: "name" },
1873
+ { name: "phone", label: "yourPhone", type: "tel", autoComplete: "tel" },
1874
+ { name: "email", label: "yourEmail", type: "email", autoComplete: "email" }
1875
+ ];
1876
+ var ContactForm = defineBlock({
1877
+ type: "ContactForm",
1878
+ label: "Contact form",
1879
+ description: "The contact form (name, phone, optional email, message) with its success message. Messages reach the merchant inbox.",
1880
+ category: "store",
1881
+ schema: import_zod7.z.object({}),
1882
+ fields: {},
1883
+ render: function ContactForm2(props) {
1884
+ const { labels: t } = useStoreData();
1885
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props), children: [
1886
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { className: "form", "data-store": "contact-form", noValidate: true, children: [
1887
+ ContactFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "field", "data-contact-wrap": "", children: [
1888
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: `contact-${field.name}`, children: t[field.label] }),
1889
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1890
+ "input",
1891
+ {
1892
+ id: `contact-${field.name}`,
1893
+ name: field.name,
1894
+ type: field.type === "text" ? void 0 : field.type,
1895
+ autoComplete: field.autoComplete,
1896
+ "data-contact-field": field.name
1897
+ }
1898
+ ),
1899
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "field__error", "data-error": "" })
1900
+ ] }, field.name)),
1901
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "field", "data-contact-wrap": "", children: [
1902
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: "contact-message", children: t.yourMessage }),
1903
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1904
+ "textarea",
1905
+ {
1906
+ id: "contact-message",
1907
+ name: "message",
1908
+ "data-contact-field": "message"
1909
+ }
1910
+ ),
1911
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "field__error", "data-error": "" })
1912
+ ] }),
1913
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "form__error", "data-store": "contact-error", hidden: true }),
1914
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "btn", type: "submit", children: t.send })
1915
+ ] }),
1916
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "notice", "data-store": "contact-success", hidden: true, children: [
1917
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: t.messageSent }),
1918
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.messageSentText })
1919
+ ] })
1920
+ ] });
1921
+ }
1922
+ });
1923
+ var OrderRows = [
1924
+ ["offer", "offer", false],
1925
+ ["customer", "customer", false],
1926
+ ["phone", "phone", true],
1927
+ ["delivery", "state", false],
1928
+ ["city", "city", false],
1929
+ ["deliveryAddress", "address", false]
1930
+ ];
1931
+ var StoreThankYou = defineBlock({
1932
+ type: "StoreThankYou",
1933
+ label: "Thank you",
1934
+ description: "The thank-you message and the order summary the checkout fills in from the browser, with a link back to the products.",
1935
+ category: "store",
1936
+ schema: import_zod7.z.object({
1937
+ title: TextSchema.default(""),
1938
+ text: TextSchema.default("")
1939
+ }),
1940
+ fields: {
1941
+ title: { type: "text", label: "Title" },
1942
+ text: { type: "textarea", label: "Text" }
1943
+ },
1944
+ render: function StoreThankYou2(props) {
1945
+ const { labels: t } = useStoreData();
1946
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "wrap"), "data-store": "thank-you", children: [
1947
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "center", children: [
1948
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || t.thankYouTitle }),
1949
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || t.thankYouText })
1950
+ ] }),
1951
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "order", "data-store": "order-details", hidden: true, children: [
1952
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: t.orderDetails }),
1953
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__product", children: [
1954
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { "data-order-image": "", alt: "", hidden: true }),
1955
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { "data-order": "product" })
1956
+ ] }),
1957
+ OrderRows.map(([label, field, ltr]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row", "data-order-row": "", children: [
1958
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t[label] }),
1959
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": field, dir: ltr ? "ltr" : void 0 })
1960
+ ] }, field)),
1961
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row", children: [
1962
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.productsPrice }),
1963
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": "products" })
1964
+ ] }),
1965
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row", children: [
1966
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.delivery }),
1967
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": "shipping" })
1968
+ ] }),
1969
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row order__row--total", children: [
1970
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.total }),
1971
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": "total" })
1972
+ ] })
1973
+ ] }),
1974
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "btn", href: "/products", children: t.keepShopping }) })
1975
+ ] });
1976
+ }
1977
+ });
1978
+ var StoreNotFound = defineBlock({
1979
+ type: "StoreNotFound",
1980
+ label: "Not found",
1981
+ description: "The message of the 404 page with a link back home.",
1982
+ category: "store",
1983
+ schema: import_zod7.z.object({
1984
+ title: TextSchema.default(""),
1985
+ text: TextSchema.default("")
1986
+ }),
1987
+ fields: {
1988
+ title: { type: "text", label: "Title" },
1989
+ text: { type: "textarea", label: "Text" }
1990
+ },
1991
+ render: function StoreNotFound2(props) {
1992
+ const { labels: t } = useStoreData();
1993
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "center"), children: [
1994
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || t.notFoundTitle }),
1995
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || t.notFoundText }),
1996
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "btn", href: "/", children: t.backHome })
1997
+ ] });
1998
+ }
1999
+ });
2000
+ var StoreArticle = defineBlock({
2001
+ type: "StoreArticle",
2002
+ label: "Page text",
2003
+ description: "The text of an about or policy page, written in the store settings. Headings and lists come from the settings text.",
2004
+ category: "store",
2005
+ schema: import_zod7.z.object({}),
2006
+ fields: {},
2007
+ render: function StoreArticle2(props) {
2008
+ var _a;
2009
+ const { article: article2 } = useStoreData();
2010
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2011
+ "article",
2012
+ {
2013
+ ...blockRoot(props, "article"),
2014
+ dangerouslySetInnerHTML: { __html: (_a = article2 == null ? void 0 : article2.html) != null ? _a : "" }
2015
+ }
2016
+ );
2017
+ }
2018
+ });
2019
+
2020
+ // src/blocks/index.ts
2021
+ var definitions = [
2022
+ Section,
2023
+ Stack,
2024
+ Columns,
2025
+ Heading,
2026
+ Text,
2027
+ Image,
2028
+ Button,
2029
+ Spacer,
2030
+ ProductTitle,
2031
+ ProductPrice,
2032
+ ProductTagline,
2033
+ ProductGallery,
2034
+ LandingImages,
2035
+ ProductDescription,
2036
+ ProductFaq,
2037
+ ProductCatalog,
2038
+ OrderForm,
2039
+ AnnouncementBar,
2040
+ StoreHeader,
2041
+ StoreFooter,
2042
+ StoreHeroTitle,
2043
+ StoreHeroSubtitle,
2044
+ StoreHeroButton,
2045
+ StoreHeroImage,
2046
+ StoreCategories,
2047
+ StoreProductGrid,
2048
+ StoreTrust,
2049
+ StoreTagline,
2050
+ StoreTicker,
2051
+ StoreSearch,
2052
+ Ornament,
2053
+ StorePageHeading,
2054
+ ListingToolbar,
2055
+ ListingGrid,
2056
+ ListingEmpty,
2057
+ ListingLoadMore,
2058
+ StoreProductGallery,
2059
+ StoreBreadcrumbs,
2060
+ StoreProductTitle,
2061
+ StoreProductPrice,
2062
+ StoreProductDescription,
2063
+ StoreProductFaq,
2064
+ ContactDetails,
2065
+ ContactForm,
2066
+ StoreThankYou,
2067
+ StoreNotFound,
2068
+ StoreArticle
2069
+ ];
2070
+ var blocks = Object.fromEntries(
2071
+ definitions.map((definition) => [definition.type, definition])
2072
+ );
2073
+
2074
+ // src/validate.ts
2075
+ var import_zod8 = require("zod");
2076
+ var FontSchema = import_zod8.z.object({
2077
+ family: import_zod8.z.string().min(1).max(60).regex(/^[A-Za-z0-9 ]+$/, "A font family can only contain letters, digits and spaces"),
2078
+ weights: import_zod8.z.array(import_zod8.z.number().int().min(100).max(900)).max(9).default([400, 700])
2079
+ });
2080
+ var PageRootPropsSchema = import_zod8.z.object({
2081
+ css: CssSchema.optional(),
2082
+ fonts: import_zod8.z.array(FontSchema).max(4).optional()
2083
+ });
2084
+ var DocumentShapeSchema = import_zod8.z.object({
2085
+ root: import_zod8.z.object({ props: import_zod8.z.unknown() }).default({ props: {} }),
2086
+ content: import_zod8.z.array(import_zod8.z.unknown())
2087
+ });
2088
+ function blockPropsSchema(definition) {
2089
+ return BaseBlockPropsSchema.extend(definition.schema.shape).extend(
2090
+ Object.fromEntries(
2091
+ definition.slots.map((slot) => [slot, import_zod8.z.array(BlockNodeSchema).default([])])
2092
+ )
2093
+ );
2094
+ }
2095
+ function parsePageDocument(input) {
2096
+ var _a;
2097
+ const issues = [];
2098
+ const shape = DocumentShapeSchema.safeParse(input);
2099
+ if (!shape.success) {
2100
+ throw new PageDocumentError(toIssues(shape.error, ""));
2101
+ }
2102
+ const root = PageRootPropsSchema.safeParse((_a = shape.data.root.props) != null ? _a : {});
2103
+ if (!root.success) {
2104
+ issues.push(...toIssues(root.error, "root.props"));
2105
+ }
2106
+ const ids = /* @__PURE__ */ new Set();
2107
+ const content = parseNodes(shape.data.content, "content", ids, issues);
2108
+ if (issues.length) {
2109
+ throw new PageDocumentError(issues);
2110
+ }
2111
+ return { root: { props: root.data }, content };
2112
+ }
2113
+ function parseNodes(nodes, path, ids, issues) {
2114
+ const parsed = [];
2115
+ nodes.forEach((raw, index) => {
2116
+ const nodePath = `${path}[${index}]`;
2117
+ const node = BlockNodeSchema.safeParse(raw);
2118
+ if (!node.success) {
2119
+ issues.push(...toIssues(node.error, nodePath));
2120
+ return;
2121
+ }
2122
+ const definition = blocks[node.data.type];
2123
+ if (!definition) {
2124
+ issues.push({
2125
+ path: `${nodePath}.type`,
2126
+ message: `Unknown block type ${node.data.type}`
2127
+ });
2128
+ return;
2129
+ }
2130
+ if (ids.has(node.data.props.id)) {
2131
+ issues.push({
2132
+ path: `${nodePath}.props.id`,
2133
+ message: `The block id ${node.data.props.id} is used more than once`
2134
+ });
2135
+ }
2136
+ ids.add(node.data.props.id);
2137
+ const props = blockPropsSchema(definition).safeParse(node.data.props);
2138
+ if (!props.success) {
2139
+ issues.push(...toIssues(props.error, `${nodePath}.props`));
2140
+ return;
2141
+ }
2142
+ const values = props.data;
2143
+ for (const slot of definition.slots) {
2144
+ values[slot] = parseNodes(
2145
+ values[slot],
2146
+ `${nodePath}.props.${slot}`,
2147
+ ids,
2148
+ issues
2149
+ );
2150
+ }
2151
+ parsed.push({ type: definition.type, props: values });
2152
+ });
2153
+ return parsed;
2154
+ }
2155
+ function toIssues(error, prefix) {
2156
+ return error.issues.map((issue) => ({
2157
+ path: [prefix, ...issue.path.map(String)].filter(Boolean).join("."),
2158
+ message: issue.message
2159
+ }));
2160
+ }
2161
+ function walkBlocks(nodes, visit) {
2162
+ var _a, _b, _c;
2163
+ for (const node of nodes) {
2164
+ visit(node);
2165
+ for (const slot of (_b = (_a = blocks[node.type]) == null ? void 0 : _a.slots) != null ? _b : []) {
2166
+ walkBlocks((_c = node.props[slot]) != null ? _c : [], visit);
2167
+ }
2168
+ }
2169
+ }
2170
+ function countBlocks(document, type) {
2171
+ let count = 0;
2172
+ walkBlocks(document.content, (node) => {
2173
+ if (node.type === type) count += 1;
2174
+ });
2175
+ return count;
2176
+ }
2177
+
2178
+ // src/page.ts
2179
+ function BlockList({ nodes }) {
2180
+ return (0, import_react5.createElement)(
2181
+ import_react5.Fragment,
2182
+ null,
2183
+ nodes.map((node) => (0, import_react5.createElement)(BlockView, { key: node.props.id, node }))
2184
+ );
2185
+ }
2186
+ function BlockView({ node }) {
2187
+ const definition = blocks[node.type];
2188
+ if (!definition) return null;
2189
+ const slots = Object.fromEntries(
2190
+ definition.slots.map((slot) => {
2191
+ var _a;
2192
+ return [
2193
+ slot,
2194
+ (0, import_react5.createElement)(BlockList, { nodes: (_a = node.props[slot]) != null ? _a : [] })
2195
+ ];
2196
+ })
2197
+ );
2198
+ return (0, import_react5.createElement)(definition.render, { ...definition.defaultProps, ...node.props, slots });
2199
+ }
2200
+ function PageContent({
2201
+ document,
2202
+ data
2203
+ }) {
2204
+ return (0, import_react5.createElement)(PageDataProvider, {
2205
+ data,
2206
+ children: (0, import_react5.createElement)(BlockList, { nodes: document.content })
2207
+ });
2208
+ }
2209
+ function blockSelector(id) {
2210
+ return `[data-block="${id}"]`;
2211
+ }
2212
+ function pageCss(document) {
2213
+ var _a;
2214
+ const base = /* @__PURE__ */ new Set();
2215
+ const scoped = [];
2216
+ walkBlocks(document.content, (node) => {
2217
+ const definition = blocks[node.type];
2218
+ if (definition == null ? void 0 : definition.baseCss) base.add(definition.baseCss);
2219
+ const selector = blockSelector(node.props.id);
2220
+ scoped.push(styleToCss(selector, node.props.style));
2221
+ if (typeof node.props.css === "string" && node.props.css.trim()) {
2222
+ scoped.push(`${selector} { ${node.props.css} }`);
2223
+ }
2224
+ });
2225
+ return [...base, (_a = document.root.props.css) != null ? _a : "", ...scoped].filter(Boolean).join("\n");
2226
+ }
2227
+ function pagePreloadImages(document, data) {
2228
+ const images = [];
2229
+ walkBlocks(document.content, (node) => {
2230
+ const definition = blocks[node.type];
2231
+ if (definition == null ? void 0 : definition.preload) {
2232
+ images.push(...definition.preload({ ...definition.defaultProps, ...node.props }, data));
2233
+ }
2234
+ });
2235
+ return [...new Set(images)];
2236
+ }
2237
+ function pageFontStylesheets(document) {
2238
+ var _a;
2239
+ return ((_a = document.root.props.fonts) != null ? _a : []).map((font) => {
2240
+ var _a2;
2241
+ const family = encodeURIComponent(font.family).replace(/%20/g, "+");
2242
+ const weights = [...new Set((_a2 = font.weights) != null ? _a2 : [400, 700])].sort((a, b) => a - b).join(";");
2243
+ return `https://fonts.googleapis.com/css2?family=${family}:wght@${weights}&display=swap`;
2244
+ });
2245
+ }
2246
+
2247
+ // src/json-schema.ts
2248
+ var import_zod9 = require("zod");
2249
+ function pageJsonSchema() {
2250
+ return {
2251
+ format: "A page is { root: { props }, content: Block[] }. A block is { type, props: { id, ...props } }. Ids are unique on the page. Slot props hold Block[]. Every block accepts style (CSS properties in camelCase, with tablet and mobile overrides) and css (CSS scoped to the block, nesting allowed, & is the block).",
2252
+ root: import_zod9.z.toJSONSchema(PageRootPropsSchema, { io: "input" }),
2253
+ blocks: Object.values(blocks).map((definition) => ({
2254
+ type: definition.type,
2255
+ label: definition.label,
2256
+ description: definition.description,
2257
+ category: definition.category,
2258
+ slots: definition.slots,
2259
+ props: import_zod9.z.toJSONSchema(blockPropsSchema(definition), { io: "input" })
2260
+ }))
2261
+ };
2262
+ }
2263
+
2264
+ // src/templates/funnels.ts
2265
+ var FunnelTemplateIds = ["classic-product", "classic-landing"];
2266
+ function block(type, id, props = {}) {
2267
+ return { type, props: { id, ...props } };
2268
+ }
2269
+ function page(content) {
2270
+ return { root: { props: {} }, content };
2271
+ }
2272
+ function classicProduct() {
2273
+ return page([
2274
+ block("Section", "hero", {
2275
+ tag: "section",
2276
+ className: "cs-hero",
2277
+ content: [
2278
+ block("ProductGallery", "gallery"),
2279
+ block("Stack", "buy-box", {
2280
+ content: [
2281
+ block("ProductTitle", "product-name", { level: "h1" }),
2282
+ block("ProductPrice", "price"),
2283
+ block("ProductTagline", "tagline"),
2284
+ block("ProductCatalog", "catalog"),
2285
+ block("OrderForm", "order-form", { includeCatalog: false })
2286
+ ]
2287
+ })
2288
+ ]
2289
+ }),
2290
+ block("LandingImages", "landing-images", { eagerFirstImage: false }),
2291
+ block("ProductDescription", "description", { onlyWithoutLandingImages: true }),
2292
+ block("ProductFaq", "faq")
2293
+ ]);
2294
+ }
2295
+ function classicLanding(options) {
2296
+ const formOnTop = options.formPosition === "top";
2297
+ const order = block("Section", "order", {
2298
+ tag: "section",
2299
+ className: "cs-card",
2300
+ anchorId: "order",
2301
+ content: [
2302
+ block("ProductTitle", "product-name", { level: "h1" }),
2303
+ block("ProductPrice", "price"),
2304
+ block("OrderForm", "order-form", { includeCatalog: true })
2305
+ ]
2306
+ });
2307
+ const images = block("LandingImages", "landing-images", { eagerFirstImage: !formOnTop });
2308
+ const description = block("ProductDescription", "description", {
2309
+ onlyWithoutLandingImages: true
2310
+ });
2311
+ return page(formOnTop ? [order, images, description] : [images, order, description]);
2312
+ }
2313
+ function funnelTemplate(templateId, options) {
2314
+ if (templateId === "classic-product") return classicProduct();
2315
+ if (templateId === "classic-landing") return classicLanding(options);
2316
+ throw new Error(`Unknown funnel template ${templateId}`);
2317
+ }
2318
+
2319
+ // src/templates/online-stores.ts
2320
+ var OnlineStoreTemplateIds = [
2321
+ "maison",
2322
+ "atelier",
2323
+ "noor",
2324
+ "block",
2325
+ "glow",
2326
+ "oud",
2327
+ "circuit",
2328
+ "hearth",
2329
+ "pebble",
2330
+ "souq"
2331
+ ];
2332
+ var OnlineStorePageTypes = [
2333
+ "header",
2334
+ "footer",
2335
+ "home",
2336
+ "all-products",
2337
+ "category",
2338
+ "product",
2339
+ "thank-you",
2340
+ "contact",
2341
+ "about",
2342
+ "privacy-policy",
2343
+ "refund-policy",
2344
+ "terms-of-service",
2345
+ "not-found"
2346
+ ];
2347
+ function block2(type, id, props = {}) {
2348
+ return { type, props: { id, ...props } };
2349
+ }
2350
+ function page2(content) {
2351
+ return { root: { props: {} }, content };
2352
+ }
2353
+ function stack(id, className, content) {
2354
+ return block2("Stack", id, { className, content });
2355
+ }
2356
+ function section(id, className, content) {
2357
+ return block2("Section", id, { tag: "section", className, content });
2358
+ }
2359
+ function heroText() {
2360
+ return [
2361
+ block2("StoreHeroTitle", "hero-title"),
2362
+ block2("StoreHeroSubtitle", "hero-subtitle"),
2363
+ block2("StoreHeroButton", "hero-button")
2364
+ ];
2365
+ }
2366
+ function heroImage(className = "") {
2367
+ return block2("StoreHeroImage", "hero-image", className ? { className } : {});
2368
+ }
2369
+ function categories(props = {}) {
2370
+ return block2("StoreCategories", "categories", props);
2371
+ }
2372
+ function categoryNav(listClassName, itemStyle) {
2373
+ return categories({ layout: "nav", listClassName, itemStyle });
2374
+ }
2375
+ function products(titleLabel, gridClassName = "") {
2376
+ return block2("StoreProductGrid", "products", {
2377
+ source: "home",
2378
+ titleLabel,
2379
+ gridClassName,
2380
+ hideWhenEmpty: false
2381
+ });
2382
+ }
2383
+ function trust() {
2384
+ return block2("StoreTrust", "trust");
2385
+ }
2386
+ var homes = {
2387
+ maison: () => [
2388
+ section("hero", "hero", [
2389
+ heroImage("hero__image"),
2390
+ stack("hero-text", "hero__text", heroText())
2391
+ ]),
2392
+ stack("main", "wrap", [
2393
+ categories(),
2394
+ block2("StoreTagline", "story", { className: "story" }),
2395
+ products("bestSellers"),
2396
+ trust()
2397
+ ])
2398
+ ],
2399
+ atelier: () => [
2400
+ section("hero", "split", [
2401
+ stack("hero-text", "split__text", heroText()),
2402
+ stack("hero-media", "split__media", [heroImage()])
2403
+ ]),
2404
+ stack("main", "wrap", [
2405
+ categoryNav("pills", "pill"),
2406
+ products("newArrivals", "editorial"),
2407
+ block2("StoreTagline", "quote", { className: "quote" }),
2408
+ trust()
2409
+ ])
2410
+ ],
2411
+ noor: () => [
2412
+ section("hero", "arch-hero", [
2413
+ stack("hero-media", "arch", [heroImage()]),
2414
+ stack("hero-text", "arch-hero__text", heroText())
2415
+ ]),
2416
+ stack("main", "wrap", [categories(), products("newArrivals"), trust()])
2417
+ ],
2418
+ block: () => [
2419
+ block2("StoreTicker", "ticker", { labels: ["newArrivals", "cod"], repeat: 8 }),
2420
+ section("hero", "poster", [heroImage(), stack("hero-text", "poster__text", heroText())]),
2421
+ categoryNav("tags", "tag"),
2422
+ products("newArrivals", "wall"),
2423
+ trust()
2424
+ ],
2425
+ glow: () => [
2426
+ section("hero", "glow-hero", [
2427
+ heroImage(),
2428
+ stack("hero-text", "glow-hero__text", heroText())
2429
+ ]),
2430
+ stack("main", "wrap", [categoryNav("chips", "chip"), products("bestSellers"), trust()])
2431
+ ],
2432
+ oud: () => [
2433
+ section("hero", "oud-hero", [
2434
+ block2("StoreHeroImage", "hero-image", { frameClassName: "oud-hero__frame" }),
2435
+ ...heroText()
2436
+ ]),
2437
+ block2("Ornament", "rule", { className: "oud-rule" }),
2438
+ stack("main", "wrap", [categories(), products("bestSellers"), trust()])
2439
+ ],
2440
+ circuit: () => [
2441
+ section("hero", "stage", [
2442
+ stack("hero-text", "stage__text", heroText()),
2443
+ stack("hero-media", "stage__media", [heroImage()])
2444
+ ]),
2445
+ block2("StoreTrust", "trust", { variant: "bento" }),
2446
+ stack("main", "wrap", [categoryNav("chip-row", "link"), products("bestSellers")])
2447
+ ],
2448
+ hearth: () => [
2449
+ section("hero", "room-hero", [
2450
+ heroImage(),
2451
+ stack("hero-text", "room-hero__card", heroText())
2452
+ ]),
2453
+ stack("main", "wrap", [
2454
+ categories({ listClassName: "rooms", itemStyle: "room" }),
2455
+ products("bestSellers"),
2456
+ trust()
2457
+ ])
2458
+ ],
2459
+ pebble: () => [
2460
+ section("hero", "play-hero", [
2461
+ stack("hero-text", "play-hero__text", heroText()),
2462
+ stack("hero-media", "play-hero__media", [heroImage()])
2463
+ ]),
2464
+ stack("main", "wrap", [categories(), products("bestSellers"), trust()])
2465
+ ],
2466
+ souq: () => [
2467
+ stack("main", "wrap", [
2468
+ block2("StoreSearch", "search"),
2469
+ categoryNav("rail", "card"),
2470
+ section("promo", "promo", [
2471
+ heroImage("promo__image"),
2472
+ stack("promo-text", "promo__text", heroText())
2473
+ ]),
2474
+ products("bestSellers"),
2475
+ trust()
2476
+ ])
2477
+ ]
2478
+ };
2479
+ function listing() {
2480
+ return page2([
2481
+ stack("main", "wrap", [
2482
+ block2("StorePageHeading", "heading", { source: "listing" }),
2483
+ block2("ListingToolbar", "toolbar"),
2484
+ block2("ListingGrid", "products"),
2485
+ block2("ListingEmpty", "empty"),
2486
+ block2("ListingLoadMore", "load-more")
2487
+ ])
2488
+ ]);
2489
+ }
2490
+ function product() {
2491
+ return page2([
2492
+ stack("main", "wrap", [
2493
+ stack("product", "pdp", [
2494
+ block2("StoreProductGallery", "gallery"),
2495
+ section("buy-box", "pdp__info", [
2496
+ block2("StoreBreadcrumbs", "breadcrumbs"),
2497
+ block2("StoreProductTitle", "product-name"),
2498
+ block2("StoreProductPrice", "price"),
2499
+ block2("ProductTagline", "tagline"),
2500
+ block2("ProductCatalog", "catalog"),
2501
+ block2("OrderForm", "order-form", { includeCatalog: false })
2502
+ ])
2503
+ ]),
2504
+ block2("StoreProductDescription", "description"),
2505
+ block2("StoreProductFaq", "faq"),
2506
+ block2("StoreProductGrid", "related", {
2507
+ source: "related",
2508
+ titleLabel: "youMayAlsoLike"
2509
+ })
2510
+ ])
2511
+ ]);
2512
+ }
2513
+ function contact() {
2514
+ return page2([
2515
+ stack("main", "wrap", [
2516
+ block2("StorePageHeading", "heading", { source: "contact" }),
2517
+ stack("contact", "contact", [
2518
+ block2("ContactDetails", "details"),
2519
+ block2("ContactForm", "form")
2520
+ ])
2521
+ ])
2522
+ ]);
2523
+ }
2524
+ function article() {
2525
+ return page2([
2526
+ stack("main", "wrap", [
2527
+ block2("StorePageHeading", "heading", { source: "article" }),
2528
+ block2("StoreArticle", "text")
2529
+ ])
2530
+ ]);
2531
+ }
2532
+ function onlineStoreTemplate(templateId, pageType) {
2533
+ if (!OnlineStoreTemplateIds.includes(templateId)) {
2534
+ throw new Error(`Unknown online store template: ${templateId}`);
2535
+ }
2536
+ switch (pageType) {
2537
+ case "header":
2538
+ return page2([block2("AnnouncementBar", "announcement"), block2("StoreHeader", "header")]);
2539
+ case "footer":
2540
+ return page2([block2("StoreFooter", "footer")]);
2541
+ case "home":
2542
+ return page2(homes[templateId]());
2543
+ case "all-products":
2544
+ case "category":
2545
+ return listing();
2546
+ case "product":
2547
+ return product();
2548
+ case "thank-you":
2549
+ return page2([block2("StoreThankYou", "thank-you")]);
2550
+ case "contact":
2551
+ return contact();
2552
+ case "about":
2553
+ case "privacy-policy":
2554
+ case "refund-policy":
2555
+ case "terms-of-service":
2556
+ return article();
2557
+ case "not-found":
2558
+ return page2([stack("main", "wrap", [block2("StoreNotFound", "not-found")])]);
2559
+ default:
2560
+ throw new Error(`Unknown online store page type: ${pageType}`);
2561
+ }
2562
+ }
2563
+ function onlineStorePages(templateId) {
2564
+ return OnlineStorePageTypes.map((pageType) => ({
2565
+ pageType,
2566
+ document: onlineStoreTemplate(templateId, pageType)
2567
+ }));
2568
+ }
2569
+
2570
+ // src/server.ts
2571
+ var Targets = {
2572
+ chrome: 80 << 16,
2573
+ android: 80 << 16,
2574
+ firefox: 78 << 16,
2575
+ safari: 13 << 16,
2576
+ ios_saf: 13 << 16,
2577
+ samsung: 12 << 16
2578
+ };
2579
+ function processCss(css) {
2580
+ if (!css.trim()) return "";
2581
+ try {
2582
+ const { code } = (0, import_lightningcss.transform)({
2583
+ filename: "page.css",
2584
+ code: Buffer.from(css),
2585
+ minify: true,
2586
+ targets: Targets
2587
+ });
2588
+ return code.toString().replace(/<\/(style)/gi, "<\\/$1");
2589
+ } catch (error) {
2590
+ throw new PageDocumentError([
2591
+ { path: "css", message: error instanceof Error ? error.message : String(error) }
2592
+ ]);
2593
+ }
2594
+ }
2595
+ function withoutHoistedPreloads(html) {
2596
+ return html.replace(/^(?:<link rel="preload"[^>]*\/>)+/, "");
2597
+ }
2598
+ function renderPage(input, data) {
2599
+ const document = parsePageDocument(input);
2600
+ return {
2601
+ html: withoutHoistedPreloads(
2602
+ (0, import_server.renderToStaticMarkup)((0, import_react6.createElement)(PageContent, { document, data }))
2603
+ ),
2604
+ css: processCss(pageCss(document)),
2605
+ fontStylesheets: pageFontStylesheets(document),
2606
+ preloadImages: pagePreloadImages(document, data)
2607
+ };
2608
+ }