@thorprovider/blocks 0.1.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.
Files changed (184) hide show
  1. package/.turbo/turbo-build.log +24 -0
  2. package/.turbo/turbo-test.log +10 -0
  3. package/.turbo/turbo-type-check.log +0 -0
  4. package/AGENTS.md +1 -0
  5. package/README.md +161 -0
  6. package/components.json +33 -0
  7. package/dist/.tsbuildinfo +1 -0
  8. package/dist/contracts.d.mts +563 -0
  9. package/dist/contracts.d.ts +563 -0
  10. package/dist/contracts.js +207 -0
  11. package/dist/contracts.js.map +1 -0
  12. package/dist/contracts.mjs +168 -0
  13. package/dist/contracts.mjs.map +1 -0
  14. package/dist/index.d.mts +2408 -0
  15. package/dist/index.d.ts +2408 -0
  16. package/dist/index.js +16422 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/index.mjs +16352 -0
  19. package/dist/index.mjs.map +1 -0
  20. package/docs/standards/data-contracts.md +70 -0
  21. package/docs/standards/theming.md +85 -0
  22. package/package.json +62 -0
  23. package/src/blocks/application/app-shells/app-shell-1-sidebar.tsx +198 -0
  24. package/src/blocks/application/app-shells/app-shell-1.tsx +196 -0
  25. package/src/blocks/application/login-forms/login-page-1.tsx +246 -0
  26. package/src/blocks/application/login-forms/login-page-2.tsx +207 -0
  27. package/src/blocks/application/password-recovery/forgot-password-page-1-brand-mark.tsx +38 -0
  28. package/src/blocks/application/password-recovery/forgot-password-page-1.tsx +320 -0
  29. package/src/blocks/application/signup-forms/signup-page-1.tsx +231 -0
  30. package/src/blocks/application/verification/verify-1.tsx +307 -0
  31. package/src/blocks/application/verification/verify-confetti.tsx +192 -0
  32. package/src/blocks/e-commerce/category-filters/category-filter-1.tsx +260 -0
  33. package/src/blocks/e-commerce/category-filters/category-filter-2-filter-panel.tsx +179 -0
  34. package/src/blocks/e-commerce/category-filters/category-filter-2.tsx +341 -0
  35. package/src/blocks/e-commerce/category-filters/category-filter-4-chip-rail.tsx +57 -0
  36. package/src/blocks/e-commerce/category-filters/category-filter-4-drawer.tsx +124 -0
  37. package/src/blocks/e-commerce/category-filters/category-filter-4-fields.tsx +170 -0
  38. package/src/blocks/e-commerce/category-filters/category-filter-4-sidebar.tsx +52 -0
  39. package/src/blocks/e-commerce/category-filters/category-filter-4-sort-sheet.tsx +57 -0
  40. package/src/blocks/e-commerce/category-filters/category-filter-4-state.ts +68 -0
  41. package/src/blocks/e-commerce/category-filters/category-filter-4.tsx +298 -0
  42. package/src/blocks/e-commerce/checkout-forms/card-formatting.test.ts +47 -0
  43. package/src/blocks/e-commerce/checkout-forms/card-formatting.ts +9 -0
  44. package/src/blocks/e-commerce/checkout-forms/checkbox-check.tsx +74 -0
  45. package/src/blocks/e-commerce/checkout-forms/checkout-confirmation-fulfilment-progress.tsx +189 -0
  46. package/src/blocks/e-commerce/checkout-forms/checkout-confirmation.tsx +283 -0
  47. package/src/blocks/e-commerce/checkout-forms/checkout-field-feedback.tsx +29 -0
  48. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-contact-step.tsx +96 -0
  49. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-country-field.tsx +51 -0
  50. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-order-summary.tsx +139 -0
  51. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-payment-step.tsx +184 -0
  52. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-progress.tsx +36 -0
  53. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-shipping-step.tsx +107 -0
  54. package/src/blocks/e-commerce/checkout-forms/checkout-form-1.tsx +235 -0
  55. package/src/blocks/e-commerce/checkout-forms/checkout-form-2-order-summary.tsx +130 -0
  56. package/src/blocks/e-commerce/checkout-forms/checkout-form-2-payment-card.tsx +175 -0
  57. package/src/blocks/e-commerce/checkout-forms/checkout-form-2-shipping-card.tsx +190 -0
  58. package/src/blocks/e-commerce/checkout-forms/checkout-form-2.tsx +312 -0
  59. package/src/blocks/e-commerce/checkout-forms/checkout-form-3-information-step.tsx +91 -0
  60. package/src/blocks/e-commerce/checkout-forms/checkout-form-3-order-summary.tsx +110 -0
  61. package/src/blocks/e-commerce/checkout-forms/checkout-form-3-payment-step.tsx +137 -0
  62. package/src/blocks/e-commerce/checkout-forms/checkout-form-3-progress.tsx +68 -0
  63. package/src/blocks/e-commerce/checkout-forms/checkout-form-3-review-step.tsx +79 -0
  64. package/src/blocks/e-commerce/checkout-forms/checkout-form-3-shipping-step.tsx +172 -0
  65. package/src/blocks/e-commerce/checkout-forms/checkout-form-3.tsx +392 -0
  66. package/src/blocks/e-commerce/checkout-forms/checkout-form-types.ts +7 -0
  67. package/src/blocks/e-commerce/navigation/category-icon.test.tsx +54 -0
  68. package/src/blocks/e-commerce/navigation/category-icon.tsx +94 -0
  69. package/src/blocks/e-commerce/navigation/mega-menu.test.tsx +139 -0
  70. package/src/blocks/e-commerce/navigation/mega-menu.tsx +271 -0
  71. package/src/blocks/e-commerce/navigation/mobile-category-drawer.test.tsx +152 -0
  72. package/src/blocks/e-commerce/navigation/mobile-category-drawer.tsx +276 -0
  73. package/src/blocks/e-commerce/order-history/order-history-1.tsx +159 -0
  74. package/src/blocks/e-commerce/order-history/order-history-2.tsx +222 -0
  75. package/src/blocks/e-commerce/product-categories/avatar-group.tsx +86 -0
  76. package/src/blocks/e-commerce/product-categories/product-category-1.tsx +126 -0
  77. package/src/blocks/e-commerce/product-categories/product-category-2.tsx +100 -0
  78. package/src/blocks/e-commerce/product-categories/product-category-4.tsx +129 -0
  79. package/src/blocks/e-commerce/product-categories/product-category-5.tsx +218 -0
  80. package/src/blocks/e-commerce/product-list/product-card-1.tsx +131 -0
  81. package/src/blocks/e-commerce/product-list/product-card-2.tsx +71 -0
  82. package/src/blocks/e-commerce/product-list/product-card-3-reaction-toggle.tsx +166 -0
  83. package/src/blocks/e-commerce/product-list/product-card-3.tsx +215 -0
  84. package/src/blocks/e-commerce/product-list/product-card-5-checkbox-check.tsx +98 -0
  85. package/src/blocks/e-commerce/product-list/product-card-5-reaction-toggle.tsx +171 -0
  86. package/src/blocks/e-commerce/product-list/product-card-5.tsx +367 -0
  87. package/src/blocks/e-commerce/product-overview/product-overview-1.tsx +201 -0
  88. package/src/blocks/e-commerce/product-overview/product-overview-2.tsx +272 -0
  89. package/src/blocks/e-commerce/product-overview/product-overview-5-gallery.tsx +59 -0
  90. package/src/blocks/e-commerce/product-overview/product-overview-5-lightbox-tab.tsx +104 -0
  91. package/src/blocks/e-commerce/product-overview/product-overview-5-reviews-tab.tsx +82 -0
  92. package/src/blocks/e-commerce/product-overview/product-overview-5-tabs.tsx +69 -0
  93. package/src/blocks/e-commerce/product-overview/product-overview-5.tsx +274 -0
  94. package/src/blocks/e-commerce/product-overview/product-quick-view-card.tsx +135 -0
  95. package/src/blocks/e-commerce/product-overview/product-quick-view-dialog.tsx +393 -0
  96. package/src/blocks/e-commerce/product-overview/product-quick-view.tsx +136 -0
  97. package/src/blocks/e-commerce/reviews/review-rating-1-review-form.tsx +133 -0
  98. package/src/blocks/e-commerce/reviews/review-rating-1.tsx +178 -0
  99. package/src/blocks/e-commerce/reviews/review-rating-2.tsx +246 -0
  100. package/src/blocks/e-commerce/shopping-carts/shopping-cart-1-spinning-counter.tsx +142 -0
  101. package/src/blocks/e-commerce/shopping-carts/shopping-cart-1.tsx +291 -0
  102. package/src/blocks/e-commerce/shopping-carts/shopping-cart-2-item-row.tsx +110 -0
  103. package/src/blocks/e-commerce/shopping-carts/shopping-cart-2-recommendations.tsx +51 -0
  104. package/src/blocks/e-commerce/shopping-carts/shopping-cart-2-spinning-counter.tsx +146 -0
  105. package/src/blocks/e-commerce/shopping-carts/shopping-cart-2.tsx +295 -0
  106. package/src/blocks/e-commerce/shopping-carts/shopping-cart-3-spinning-counter.tsx +142 -0
  107. package/src/blocks/e-commerce/shopping-carts/shopping-cart-3.tsx +342 -0
  108. package/src/blocks/e-commerce/shopping-carts/shopping-cart-4-spinning-counter.tsx +146 -0
  109. package/src/blocks/e-commerce/shopping-carts/shopping-cart-4.tsx +391 -0
  110. package/src/blocks/e-commerce/store-containers/store-container-1.tsx +29 -0
  111. package/src/blocks/e-commerce/storefront-hero/storefront-hero-1.tsx +244 -0
  112. package/src/blocks/e-commerce/storefront-hero/storefront-hero-2.tsx +283 -0
  113. package/src/blocks/e-commerce/storefront-hero/storefront-hero-5.tsx +318 -0
  114. package/src/blocks/e-commerce/storefront-hero/storefront-hero-6.tsx +205 -0
  115. package/src/blocks/marketing/banners/avatar-group.tsx +69 -0
  116. package/src/blocks/marketing/banners/banner-1.tsx +188 -0
  117. package/src/blocks/marketing/cta/cta-section-1.tsx +112 -0
  118. package/src/blocks/marketing/faq/faq-block-1.tsx +45 -0
  119. package/src/blocks/marketing/features/feature-1.tsx +97 -0
  120. package/src/blocks/marketing/features/feature-2.tsx +82 -0
  121. package/src/blocks/marketing/footers/footer-section-1.tsx +141 -0
  122. package/src/blocks/marketing/footers/footer-section-3.tsx +192 -0
  123. package/src/blocks/marketing/footers/footer-section-4.tsx +355 -0
  124. package/src/blocks/marketing/hero-sections/avatar-group.tsx +86 -0
  125. package/src/blocks/marketing/hero-sections/hero-section-1.tsx +135 -0
  126. package/src/blocks/marketing/logo-clouds/logo-cloud-1-logo-icon.tsx +52 -0
  127. package/src/blocks/marketing/logo-clouds/logo-cloud-1.tsx +56 -0
  128. package/src/blocks/marketing/navbars/navbar-1.tsx +267 -0
  129. package/src/blocks/marketing/navbars/navbar-2.tsx +351 -0
  130. package/src/blocks/marketing/navbars/navbar-3.tsx +303 -0
  131. package/src/blocks/marketing/navbars/navbar-4-account-menu.tsx +118 -0
  132. package/src/blocks/marketing/navbars/navbar-4-cart-sheet.tsx +248 -0
  133. package/src/blocks/marketing/navbars/navbar-4-like-button.tsx +177 -0
  134. package/src/blocks/marketing/navbars/navbar-4-mobile-nav.tsx +104 -0
  135. package/src/blocks/marketing/navbars/navbar-4-product-grid.tsx +219 -0
  136. package/src/blocks/marketing/navbars/navbar-4-search-bar.tsx +52 -0
  137. package/src/blocks/marketing/navbars/navbar-4.tsx +411 -0
  138. package/src/blocks/marketing/pricing/pricing-section-1.tsx +94 -0
  139. package/src/blocks/marketing/statistics/statistic-1.tsx +93 -0
  140. package/src/blocks/marketing/testimonials/testimonial-1.tsx +141 -0
  141. package/src/blocks/marketing/testimonials/testimonial-2.tsx +108 -0
  142. package/src/blocks/shared/reaction-toggle.tsx +145 -0
  143. package/src/hooks/use-mobile.ts +19 -0
  144. package/src/index.ts +200 -0
  145. package/src/lib/contracts.test.ts +32 -0
  146. package/src/lib/contracts.ts +235 -0
  147. package/src/lib/types/menu.ts +43 -0
  148. package/src/lib/types.ts +4 -0
  149. package/src/lib/utils.ts +10 -0
  150. package/src/ui/accordion.tsx +65 -0
  151. package/src/ui/avatar.tsx +108 -0
  152. package/src/ui/badge.tsx +47 -0
  153. package/src/ui/breadcrumb.tsx +108 -0
  154. package/src/ui/button-group.tsx +83 -0
  155. package/src/ui/button.tsx +63 -0
  156. package/src/ui/card.tsx +91 -0
  157. package/src/ui/carousel.tsx +241 -0
  158. package/src/ui/dialog.tsx +158 -0
  159. package/src/ui/drawer.tsx +134 -0
  160. package/src/ui/dropdown-menu.tsx +256 -0
  161. package/src/ui/empty.tsx +103 -0
  162. package/src/ui/field.tsx +248 -0
  163. package/src/ui/input-group.tsx +170 -0
  164. package/src/ui/input-otp.tsx +76 -0
  165. package/src/ui/input.tsx +20 -0
  166. package/src/ui/label.tsx +23 -0
  167. package/src/ui/navigation-menu.tsx +167 -0
  168. package/src/ui/pagination.tsx +127 -0
  169. package/src/ui/progress.tsx +30 -0
  170. package/src/ui/radio-group.tsx +44 -0
  171. package/src/ui/select.tsx +189 -0
  172. package/src/ui/separator.tsx +27 -0
  173. package/src/ui/sheet.tsx +142 -0
  174. package/src/ui/sidebar.tsx +726 -0
  175. package/src/ui/skeleton.tsx +13 -0
  176. package/src/ui/table.tsx +115 -0
  177. package/src/ui/tabs.tsx +90 -0
  178. package/src/ui/textarea.tsx +17 -0
  179. package/src/ui/toggle-group.tsx +83 -0
  180. package/src/ui/toggle.tsx +46 -0
  181. package/src/ui/tooltip.tsx +56 -0
  182. package/tsconfig.json +20 -0
  183. package/tsup.config.ts +16 -0
  184. package/vitest.config.ts +9 -0
@@ -0,0 +1,207 @@
1
+ 'use client';
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/lib/contracts.ts
22
+ var contracts_exports = {};
23
+ __export(contracts_exports, {
24
+ PRODUCT_IMAGE_FALLBACK: () => PRODUCT_IMAGE_FALLBACK,
25
+ accountMenuItemSchema: () => accountMenuItemSchema,
26
+ buttonPropsSchema: () => buttonPropsSchema,
27
+ cardProductSchema: () => cardProductSchema,
28
+ cartItemSchema: () => cartItemSchema,
29
+ navCartItemSchema: () => navCartItemSchema,
30
+ navbar4PropsSchema: () => navbar4PropsSchema,
31
+ paymentMethodSchema: () => paymentMethodSchema,
32
+ productCard1PropsSchema: () => productCard1PropsSchema,
33
+ promotionSchema: () => promotionSchema,
34
+ recentlyViewedItemSchema: () => recentlyViewedItemSchema,
35
+ shoppingCart4PropsSchema: () => shoppingCart4PropsSchema,
36
+ storeCategorySchema: () => storeCategorySchema,
37
+ storeContainer1PropsSchema: () => storeContainer1PropsSchema,
38
+ storeUserSchema: () => storeUserSchema,
39
+ utilityLinkSchema: () => utilityLinkSchema
40
+ });
41
+ module.exports = __toCommonJS(contracts_exports);
42
+ var import_zod = require("zod");
43
+ var PRODUCT_IMAGE_FALLBACK = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(
44
+ `<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><rect width='100%' height='100%' fill='#e2e8f0'/><g fill='none' stroke='#94a3b8' stroke-width='12' stroke-linecap='round'><path d='M150 300h300M300 150v300'/><path d='M220 230h50M220 300h50M220 370h50'/><path d='M330 230h50M330 300h50M330 370h50'/></g></svg>`
45
+ );
46
+ var cardProductSchema = import_zod.z.object({
47
+ id: import_zod.z.union([import_zod.z.string(), import_zod.z.number()]),
48
+ title: import_zod.z.string(),
49
+ price: import_zod.z.number(),
50
+ originalPrice: import_zod.z.number().optional(),
51
+ image: import_zod.z.string(),
52
+ badge: import_zod.z.string().optional()
53
+ });
54
+ var cartItemSchema = import_zod.z.object({
55
+ id: import_zod.z.string(),
56
+ name: import_zod.z.string(),
57
+ price: import_zod.z.number(),
58
+ quantity: import_zod.z.number().int().min(0),
59
+ image: import_zod.z.string(),
60
+ variant: import_zod.z.string().optional()
61
+ });
62
+ var recentlyViewedItemSchema = import_zod.z.object({
63
+ id: import_zod.z.string(),
64
+ name: import_zod.z.string(),
65
+ price: import_zod.z.number(),
66
+ image: import_zod.z.string()
67
+ });
68
+ var promotionSchema = import_zod.z.object({
69
+ threshold: import_zod.z.number(),
70
+ reward: import_zod.z.string(),
71
+ icon: import_zod.z.string().default("gift")
72
+ });
73
+ var storeCategoryBase = {
74
+ label: import_zod.z.string(),
75
+ href: import_zod.z.string(),
76
+ emphasis: import_zod.z.boolean().optional()
77
+ };
78
+ var storeCategorySchema = import_zod.z.lazy(
79
+ () => import_zod.z.object({
80
+ ...storeCategoryBase,
81
+ children: import_zod.z.array(storeCategorySchema).optional()
82
+ })
83
+ );
84
+ var utilityLinkSchema = import_zod.z.object({
85
+ label: import_zod.z.string(),
86
+ href: import_zod.z.string()
87
+ });
88
+ var navCartItemSchema = import_zod.z.object({
89
+ id: import_zod.z.string(),
90
+ name: import_zod.z.string(),
91
+ variant: import_zod.z.string(),
92
+ price: import_zod.z.number(),
93
+ qty: import_zod.z.number().int().min(0),
94
+ image: import_zod.z.string()
95
+ });
96
+ var storeUserSchema = import_zod.z.object({
97
+ name: import_zod.z.string(),
98
+ email: import_zod.z.string(),
99
+ avatar: import_zod.z.string(),
100
+ initials: import_zod.z.string()
101
+ });
102
+ var accountMenuItemSchema = import_zod.z.object({
103
+ label: import_zod.z.string(),
104
+ href: import_zod.z.string(),
105
+ description: import_zod.z.string().optional(),
106
+ icon: import_zod.z.enum(["orders", "wishlist", "addresses", "settings"]).optional()
107
+ });
108
+ var paymentMethodSchema = import_zod.z.object({
109
+ id: import_zod.z.string(),
110
+ name: import_zod.z.string(),
111
+ type: import_zod.z.enum([
112
+ "card",
113
+ "wallet",
114
+ "bank_transfer",
115
+ "buy_now_pay_later",
116
+ "cash_on_delivery",
117
+ "crypto",
118
+ "other"
119
+ ]),
120
+ isEnabled: import_zod.z.boolean(),
121
+ requiresSetup: import_zod.z.boolean(),
122
+ description: import_zod.z.string().optional(),
123
+ metadata: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
124
+ features: import_zod.z.object({
125
+ saveForLater: import_zod.z.boolean().optional(),
126
+ requires3DS: import_zod.z.boolean().optional(),
127
+ supportsRefunds: import_zod.z.boolean().optional(),
128
+ minAmount: import_zod.z.number().optional(),
129
+ maxAmount: import_zod.z.number().optional(),
130
+ supportedCurrencies: import_zod.z.array(import_zod.z.string()).optional(),
131
+ requiresVerification: import_zod.z.boolean().optional()
132
+ }).optional(),
133
+ logo: import_zod.z.string().optional()
134
+ });
135
+ var buttonPropsSchema = import_zod.z.object({
136
+ variant: import_zod.z.enum(["default", "destructive", "outline", "secondary", "ghost", "link"]).optional(),
137
+ size: import_zod.z.enum(["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"]).optional(),
138
+ disabled: import_zod.z.boolean().optional(),
139
+ className: import_zod.z.string().optional()
140
+ });
141
+ var storeContainer1PropsSchema = import_zod.z.object({
142
+ size: import_zod.z.enum(["default", "narrow", "wide", "full"]).optional(),
143
+ className: import_zod.z.string().optional()
144
+ });
145
+ var productCard1PropsSchema = import_zod.z.object({
146
+ products: import_zod.z.array(cardProductSchema),
147
+ heading: import_zod.z.string().optional(),
148
+ maxItems: import_zod.z.number().int().positive().optional()
149
+ });
150
+ var shoppingCart4PropsSchema = import_zod.z.object({
151
+ items: import_zod.z.array(cartItemSchema),
152
+ promotions: import_zod.z.array(promotionSchema).default([]),
153
+ recentlyViewed: import_zod.z.array(recentlyViewedItemSchema).optional(),
154
+ taxRate: import_zod.z.number().optional(),
155
+ titleLabel: import_zod.z.string().optional(),
156
+ subtotalLabel: import_zod.z.string().optional(),
157
+ taxLabel: import_zod.z.string().optional(),
158
+ shippingLabel: import_zod.z.string().optional(),
159
+ shippingFreeLabel: import_zod.z.string().optional(),
160
+ totalLabel: import_zod.z.string().optional(),
161
+ awayFromLabel: import_zod.z.string().optional(),
162
+ activatedLabel: import_zod.z.string().optional(),
163
+ itemsLabel: import_zod.z.string().optional(),
164
+ expressCheckoutLabel: import_zod.z.string().optional(),
165
+ expressLabel: import_zod.z.string().optional(),
166
+ standardLabel: import_zod.z.string().optional(),
167
+ estimatedDeliveryLabel: import_zod.z.string().optional(),
168
+ secureCheckoutLabel: import_zod.z.string().optional(),
169
+ recentlyViewedLabel: import_zod.z.string().optional(),
170
+ collapseLabel: import_zod.z.string().optional(),
171
+ expandLabel: import_zod.z.string().optional(),
172
+ checkoutLabel: import_zod.z.string().optional(),
173
+ quickCheckoutLabel: import_zod.z.string().optional(),
174
+ checkoutNowLabel: import_zod.z.string().optional()
175
+ });
176
+ var navbar4PropsSchema = import_zod.z.object({
177
+ storeCategories: import_zod.z.array(storeCategorySchema),
178
+ shippingNote: import_zod.z.string(),
179
+ utilityLinks: import_zod.z.array(utilityLinkSchema),
180
+ logoText: import_zod.z.string(),
181
+ logoHref: import_zod.z.string().optional(),
182
+ accountHref: import_zod.z.string().optional(),
183
+ searchQuery: import_zod.z.string().optional(),
184
+ items: import_zod.z.array(navCartItemSchema).optional(),
185
+ user: storeUserSchema.optional(),
186
+ accountMenuItems: import_zod.z.array(accountMenuItemSchema).optional()
187
+ });
188
+ // Annotate the CommonJS export names for ESM import in node:
189
+ 0 && (module.exports = {
190
+ PRODUCT_IMAGE_FALLBACK,
191
+ accountMenuItemSchema,
192
+ buttonPropsSchema,
193
+ cardProductSchema,
194
+ cartItemSchema,
195
+ navCartItemSchema,
196
+ navbar4PropsSchema,
197
+ paymentMethodSchema,
198
+ productCard1PropsSchema,
199
+ promotionSchema,
200
+ recentlyViewedItemSchema,
201
+ shoppingCart4PropsSchema,
202
+ storeCategorySchema,
203
+ storeContainer1PropsSchema,
204
+ storeUserSchema,
205
+ utilityLinkSchema
206
+ });
207
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/contracts.ts"],"sourcesContent":["import { z } from 'zod'\nimport type { Money, PaymentMethod, ProductPreview } from '@thorprovider/types'\n\n/**\n * Serialization contracts for spec-driven storefronts.\n *\n * These Zod schemas are the *serializable subset* of what a spec may write for\n * a block. The component keeps its rich React interface; the catalog/registry\n * is the adapter that maps these props to real component props and binds\n * callbacks (see storefronts-on-blocks design D3). `z.infer` is the typed\n * boundary between spec and catalog — a prop outside the schema is a compile\n * error, not a runtime surprise.\n *\n * Data shapes are projections of the @thorprovider/types canon so that\n * @thorprovider/adapters output validates without conflict:\n * - Prices are plain numbers here while the canon `Money` is a decimal string\n * ({ amount: \"45.00\", currencyCode }). The projection happens at the\n * loader boundary.\n * - Blocks use `title` while the canon `ProductPreview` uses `name`. Reconcile\n * via the canonical aliases below or the catalog/loader adapter.\n */\nexport type CanonMoney = Money\nexport type CanonProduct = ProductPreview\n\n/**\n * Fallback data-URI for required image fields when the data source has no\n * image. Image fields are non-optional `z.string()` in these contracts, so the\n * boundary must never emit `\"\"` (React warns about `src=\"\"`); it must emit a\n * real, renderable value. Hosts may override with their own branded fallback\n * (e.g. electrostore's `CATEGORY_IMAGE_FALLBACK`), but blocks ship a neutral\n * one so direct consumers are safe by default.\n */\nexport const PRODUCT_IMAGE_FALLBACK =\n 'data:image/svg+xml;charset=utf-8,' +\n encodeURIComponent(\n `<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><rect width='100%' height='100%' fill='#e2e8f0'/><g fill='none' stroke='#94a3b8' stroke-width='12' stroke-linecap='round'><path d='M150 300h300M300 150v300'/><path d='M220 230h50M220 300h50M220 370h50'/><path d='M330 230h50M330 300h50M330 370h50'/></g></svg>`,\n )\n\n// ---------------------------------------------------------------------------\n// Data contracts\n// ---------------------------------------------------------------------------\n\nexport const cardProductSchema = z.object({\n id: z.union([z.string(), z.number()]),\n title: z.string(),\n price: z.number(),\n originalPrice: z.number().optional(),\n image: z.string(),\n badge: z.string().optional(),\n})\nexport type CardProduct = z.infer<typeof cardProductSchema>\n\nexport const cartItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n price: z.number(),\n quantity: z.number().int().min(0),\n image: z.string(),\n variant: z.string().optional(),\n})\nexport type CartItem = z.infer<typeof cartItemSchema>\n\nexport const recentlyViewedItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n price: z.number(),\n image: z.string(),\n})\nexport type RecentlyViewedItem = z.infer<typeof recentlyViewedItemSchema>\n\nexport const promotionSchema = z.object({\n threshold: z.number(),\n reward: z.string(),\n icon: z.string().default('gift'),\n})\nexport type Promotion = z.infer<typeof promotionSchema>\n\nconst storeCategoryBase = {\n label: z.string(),\n href: z.string(),\n emphasis: z.boolean().optional(),\n}\n\nexport const storeCategorySchema: z.ZodType<StoreCategory> = z.lazy(() =>\n z.object({\n ...storeCategoryBase,\n children: z.array(storeCategorySchema).optional(),\n }),\n)\nexport type StoreCategory = {\n label: string\n href: string\n children?: StoreCategory[]\n emphasis?: boolean\n}\n\nexport const utilityLinkSchema = z.object({\n label: z.string(),\n href: z.string(),\n})\nexport type UtilityLink = z.infer<typeof utilityLinkSchema>\n\nexport const navCartItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n variant: z.string(),\n price: z.number(),\n qty: z.number().int().min(0),\n image: z.string(),\n})\nexport type NavCartItem = z.infer<typeof navCartItemSchema>\n\nexport const storeUserSchema = z.object({\n name: z.string(),\n email: z.string(),\n avatar: z.string(),\n initials: z.string(),\n})\nexport type StoreUser = z.infer<typeof storeUserSchema>\n\nexport const accountMenuItemSchema = z.object({\n label: z.string(),\n href: z.string(),\n description: z.string().optional(),\n icon: z.enum(['orders', 'wishlist', 'addresses', 'settings']).optional(),\n})\nexport type AccountMenuItem = z.infer<typeof accountMenuItemSchema>\n\n/**\n * Serialization contract for a payment method offered at checkout.\n *\n * A projection of `@thorprovider/types` `PaymentMethod` — the storefront-facing\n * shape produced by the adapters transform. Checkout blocks render the method\n * list from this data instead of hardcoding providers.\n */\nexport const paymentMethodSchema: z.ZodType<PaymentMethod> = z.object({\n id: z.string(),\n name: z.string(),\n type: z.enum([\n 'card',\n 'wallet',\n 'bank_transfer',\n 'buy_now_pay_later',\n 'cash_on_delivery',\n 'crypto',\n 'other',\n ]),\n isEnabled: z.boolean(),\n requiresSetup: z.boolean(),\n description: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n features: z\n .object({\n saveForLater: z.boolean().optional(),\n requires3DS: z.boolean().optional(),\n supportsRefunds: z.boolean().optional(),\n minAmount: z.number().optional(),\n maxAmount: z.number().optional(),\n supportedCurrencies: z.array(z.string()).optional(),\n requiresVerification: z.boolean().optional(),\n })\n .optional(),\n logo: z.string().optional(),\n})\n\n// ---------------------------------------------------------------------------\n// Block prop schemas\n// ---------------------------------------------------------------------------\n\nexport const buttonPropsSchema = z.object({\n variant: z\n .enum(['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'])\n .optional(),\n size: z\n .enum(['default', 'xs', 'sm', 'lg', 'icon', 'icon-xs', 'icon-sm', 'icon-lg'])\n .optional(),\n disabled: z.boolean().optional(),\n className: z.string().optional(),\n})\nexport type ButtonSpecProps = z.infer<typeof buttonPropsSchema>\n\nexport const storeContainer1PropsSchema = z.object({\n size: z.enum(['default', 'narrow', 'wide', 'full']).optional(),\n className: z.string().optional(),\n})\nexport type StoreContainer1SpecProps = z.infer<typeof storeContainer1PropsSchema>\n\nexport const productCard1PropsSchema = z.object({\n products: z.array(cardProductSchema),\n heading: z.string().optional(),\n maxItems: z.number().int().positive().optional(),\n})\nexport type ProductCard1SpecProps = z.infer<typeof productCard1PropsSchema>\n\nexport const shoppingCart4PropsSchema = z.object({\n items: z.array(cartItemSchema),\n promotions: z.array(promotionSchema).default([]),\n recentlyViewed: z.array(recentlyViewedItemSchema).optional(),\n taxRate: z.number().optional(),\n titleLabel: z.string().optional(),\n subtotalLabel: z.string().optional(),\n taxLabel: z.string().optional(),\n shippingLabel: z.string().optional(),\n shippingFreeLabel: z.string().optional(),\n totalLabel: z.string().optional(),\n awayFromLabel: z.string().optional(),\n activatedLabel: z.string().optional(),\n itemsLabel: z.string().optional(),\n expressCheckoutLabel: z.string().optional(),\n expressLabel: z.string().optional(),\n standardLabel: z.string().optional(),\n estimatedDeliveryLabel: z.string().optional(),\n secureCheckoutLabel: z.string().optional(),\n recentlyViewedLabel: z.string().optional(),\n collapseLabel: z.string().optional(),\n expandLabel: z.string().optional(),\n checkoutLabel: z.string().optional(),\n quickCheckoutLabel: z.string().optional(),\n checkoutNowLabel: z.string().optional(),\n})\nexport type ShoppingCart4SpecProps = z.infer<typeof shoppingCart4PropsSchema>\n\nexport const navbar4PropsSchema = z.object({\n storeCategories: z.array(storeCategorySchema),\n shippingNote: z.string(),\n utilityLinks: z.array(utilityLinkSchema),\n logoText: z.string(),\n logoHref: z.string().optional(),\n accountHref: z.string().optional(),\n searchQuery: z.string().optional(),\n items: z.array(navCartItemSchema).optional(),\n user: storeUserSchema.optional(),\n accountMenuItems: z.array(accountMenuItemSchema).optional(),\n})\nexport type Navbar4SpecProps = z.infer<typeof navbar4PropsSchema>"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAgCX,IAAM,yBACX,sCACA;AAAA,EACE;AACF;AAMK,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,IAAI,aAAE,MAAM,CAAC,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,CAAC;AAAA,EACpC,OAAO,aAAE,OAAO;AAAA,EAChB,OAAO,aAAE,OAAO;AAAA,EAChB,eAAe,aAAE,OAAO,EAAE,SAAS;AAAA,EACnC,OAAO,aAAE,OAAO;AAAA,EAChB,OAAO,aAAE,OAAO,EAAE,SAAS;AAC7B,CAAC;AAGM,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,IAAI,aAAE,OAAO;AAAA,EACb,MAAM,aAAE,OAAO;AAAA,EACf,OAAO,aAAE,OAAO;AAAA,EAChB,UAAU,aAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,EAChC,OAAO,aAAE,OAAO;AAAA,EAChB,SAAS,aAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAGM,IAAM,2BAA2B,aAAE,OAAO;AAAA,EAC/C,IAAI,aAAE,OAAO;AAAA,EACb,MAAM,aAAE,OAAO;AAAA,EACf,OAAO,aAAE,OAAO;AAAA,EAChB,OAAO,aAAE,OAAO;AAClB,CAAC;AAGM,IAAM,kBAAkB,aAAE,OAAO;AAAA,EACtC,WAAW,aAAE,OAAO;AAAA,EACpB,QAAQ,aAAE,OAAO;AAAA,EACjB,MAAM,aAAE,OAAO,EAAE,QAAQ,MAAM;AACjC,CAAC;AAGD,IAAM,oBAAoB;AAAA,EACxB,OAAO,a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C,cAAc,aAAE,OAAO;AAAA,EACvB,cAAc,aAAE,MAAM,iBAAiB;AAAA,EACvC,UAAU,aAAE,OAAO;AAAA,EACnB,UAAU,aAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACjC,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACjC,OAAO,aAAE,MAAM,iBAAiB,EAAE,SAAS;AAAA,EAC3C,MAAM,gBAAgB,SAAS;AAAA,EAC/B,kBAAkB,aAAE,MAAM,qBAAqB,EAAE,SAAS;AAC5D,CAAC;","names":[]}
@@ -0,0 +1,168 @@
1
+ 'use client';
2
+
3
+ // src/lib/contracts.ts
4
+ import { z } from "zod";
5
+ var PRODUCT_IMAGE_FALLBACK = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(
6
+ `<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><rect width='100%' height='100%' fill='#e2e8f0'/><g fill='none' stroke='#94a3b8' stroke-width='12' stroke-linecap='round'><path d='M150 300h300M300 150v300'/><path d='M220 230h50M220 300h50M220 370h50'/><path d='M330 230h50M330 300h50M330 370h50'/></g></svg>`
7
+ );
8
+ var cardProductSchema = z.object({
9
+ id: z.union([z.string(), z.number()]),
10
+ title: z.string(),
11
+ price: z.number(),
12
+ originalPrice: z.number().optional(),
13
+ image: z.string(),
14
+ badge: z.string().optional()
15
+ });
16
+ var cartItemSchema = z.object({
17
+ id: z.string(),
18
+ name: z.string(),
19
+ price: z.number(),
20
+ quantity: z.number().int().min(0),
21
+ image: z.string(),
22
+ variant: z.string().optional()
23
+ });
24
+ var recentlyViewedItemSchema = z.object({
25
+ id: z.string(),
26
+ name: z.string(),
27
+ price: z.number(),
28
+ image: z.string()
29
+ });
30
+ var promotionSchema = z.object({
31
+ threshold: z.number(),
32
+ reward: z.string(),
33
+ icon: z.string().default("gift")
34
+ });
35
+ var storeCategoryBase = {
36
+ label: z.string(),
37
+ href: z.string(),
38
+ emphasis: z.boolean().optional()
39
+ };
40
+ var storeCategorySchema = z.lazy(
41
+ () => z.object({
42
+ ...storeCategoryBase,
43
+ children: z.array(storeCategorySchema).optional()
44
+ })
45
+ );
46
+ var utilityLinkSchema = z.object({
47
+ label: z.string(),
48
+ href: z.string()
49
+ });
50
+ var navCartItemSchema = z.object({
51
+ id: z.string(),
52
+ name: z.string(),
53
+ variant: z.string(),
54
+ price: z.number(),
55
+ qty: z.number().int().min(0),
56
+ image: z.string()
57
+ });
58
+ var storeUserSchema = z.object({
59
+ name: z.string(),
60
+ email: z.string(),
61
+ avatar: z.string(),
62
+ initials: z.string()
63
+ });
64
+ var accountMenuItemSchema = z.object({
65
+ label: z.string(),
66
+ href: z.string(),
67
+ description: z.string().optional(),
68
+ icon: z.enum(["orders", "wishlist", "addresses", "settings"]).optional()
69
+ });
70
+ var paymentMethodSchema = z.object({
71
+ id: z.string(),
72
+ name: z.string(),
73
+ type: z.enum([
74
+ "card",
75
+ "wallet",
76
+ "bank_transfer",
77
+ "buy_now_pay_later",
78
+ "cash_on_delivery",
79
+ "crypto",
80
+ "other"
81
+ ]),
82
+ isEnabled: z.boolean(),
83
+ requiresSetup: z.boolean(),
84
+ description: z.string().optional(),
85
+ metadata: z.record(z.string(), z.unknown()).optional(),
86
+ features: z.object({
87
+ saveForLater: z.boolean().optional(),
88
+ requires3DS: z.boolean().optional(),
89
+ supportsRefunds: z.boolean().optional(),
90
+ minAmount: z.number().optional(),
91
+ maxAmount: z.number().optional(),
92
+ supportedCurrencies: z.array(z.string()).optional(),
93
+ requiresVerification: z.boolean().optional()
94
+ }).optional(),
95
+ logo: z.string().optional()
96
+ });
97
+ var buttonPropsSchema = z.object({
98
+ variant: z.enum(["default", "destructive", "outline", "secondary", "ghost", "link"]).optional(),
99
+ size: z.enum(["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"]).optional(),
100
+ disabled: z.boolean().optional(),
101
+ className: z.string().optional()
102
+ });
103
+ var storeContainer1PropsSchema = z.object({
104
+ size: z.enum(["default", "narrow", "wide", "full"]).optional(),
105
+ className: z.string().optional()
106
+ });
107
+ var productCard1PropsSchema = z.object({
108
+ products: z.array(cardProductSchema),
109
+ heading: z.string().optional(),
110
+ maxItems: z.number().int().positive().optional()
111
+ });
112
+ var shoppingCart4PropsSchema = z.object({
113
+ items: z.array(cartItemSchema),
114
+ promotions: z.array(promotionSchema).default([]),
115
+ recentlyViewed: z.array(recentlyViewedItemSchema).optional(),
116
+ taxRate: z.number().optional(),
117
+ titleLabel: z.string().optional(),
118
+ subtotalLabel: z.string().optional(),
119
+ taxLabel: z.string().optional(),
120
+ shippingLabel: z.string().optional(),
121
+ shippingFreeLabel: z.string().optional(),
122
+ totalLabel: z.string().optional(),
123
+ awayFromLabel: z.string().optional(),
124
+ activatedLabel: z.string().optional(),
125
+ itemsLabel: z.string().optional(),
126
+ expressCheckoutLabel: z.string().optional(),
127
+ expressLabel: z.string().optional(),
128
+ standardLabel: z.string().optional(),
129
+ estimatedDeliveryLabel: z.string().optional(),
130
+ secureCheckoutLabel: z.string().optional(),
131
+ recentlyViewedLabel: z.string().optional(),
132
+ collapseLabel: z.string().optional(),
133
+ expandLabel: z.string().optional(),
134
+ checkoutLabel: z.string().optional(),
135
+ quickCheckoutLabel: z.string().optional(),
136
+ checkoutNowLabel: z.string().optional()
137
+ });
138
+ var navbar4PropsSchema = z.object({
139
+ storeCategories: z.array(storeCategorySchema),
140
+ shippingNote: z.string(),
141
+ utilityLinks: z.array(utilityLinkSchema),
142
+ logoText: z.string(),
143
+ logoHref: z.string().optional(),
144
+ accountHref: z.string().optional(),
145
+ searchQuery: z.string().optional(),
146
+ items: z.array(navCartItemSchema).optional(),
147
+ user: storeUserSchema.optional(),
148
+ accountMenuItems: z.array(accountMenuItemSchema).optional()
149
+ });
150
+ export {
151
+ PRODUCT_IMAGE_FALLBACK,
152
+ accountMenuItemSchema,
153
+ buttonPropsSchema,
154
+ cardProductSchema,
155
+ cartItemSchema,
156
+ navCartItemSchema,
157
+ navbar4PropsSchema,
158
+ paymentMethodSchema,
159
+ productCard1PropsSchema,
160
+ promotionSchema,
161
+ recentlyViewedItemSchema,
162
+ shoppingCart4PropsSchema,
163
+ storeCategorySchema,
164
+ storeContainer1PropsSchema,
165
+ storeUserSchema,
166
+ utilityLinkSchema
167
+ };
168
+ //# sourceMappingURL=contracts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/contracts.ts"],"sourcesContent":["import { z } from 'zod'\nimport type { Money, PaymentMethod, ProductPreview } from '@thorprovider/types'\n\n/**\n * Serialization contracts for spec-driven storefronts.\n *\n * These Zod schemas are the *serializable subset* of what a spec may write for\n * a block. The component keeps its rich React interface; the catalog/registry\n * is the adapter that maps these props to real component props and binds\n * callbacks (see storefronts-on-blocks design D3). `z.infer` is the typed\n * boundary between spec and catalog — a prop outside the schema is a compile\n * error, not a runtime surprise.\n *\n * Data shapes are projections of the @thorprovider/types canon so that\n * @thorprovider/adapters output validates without conflict:\n * - Prices are plain numbers here while the canon `Money` is a decimal string\n * ({ amount: \"45.00\", currencyCode }). The projection happens at the\n * loader boundary.\n * - Blocks use `title` while the canon `ProductPreview` uses `name`. Reconcile\n * via the canonical aliases below or the catalog/loader adapter.\n */\nexport type CanonMoney = Money\nexport type CanonProduct = ProductPreview\n\n/**\n * Fallback data-URI for required image fields when the data source has no\n * image. Image fields are non-optional `z.string()` in these contracts, so the\n * boundary must never emit `\"\"` (React warns about `src=\"\"`); it must emit a\n * real, renderable value. Hosts may override with their own branded fallback\n * (e.g. electrostore's `CATEGORY_IMAGE_FALLBACK`), but blocks ship a neutral\n * one so direct consumers are safe by default.\n */\nexport const PRODUCT_IMAGE_FALLBACK =\n 'data:image/svg+xml;charset=utf-8,' +\n encodeURIComponent(\n `<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><rect width='100%' height='100%' fill='#e2e8f0'/><g fill='none' stroke='#94a3b8' stroke-width='12' stroke-linecap='round'><path d='M150 300h300M300 150v300'/><path d='M220 230h50M220 300h50M220 370h50'/><path d='M330 230h50M330 300h50M330 370h50'/></g></svg>`,\n )\n\n// ---------------------------------------------------------------------------\n// Data contracts\n// ---------------------------------------------------------------------------\n\nexport const cardProductSchema = z.object({\n id: z.union([z.string(), z.number()]),\n title: z.string(),\n price: z.number(),\n originalPrice: z.number().optional(),\n image: z.string(),\n badge: z.string().optional(),\n})\nexport type CardProduct = z.infer<typeof cardProductSchema>\n\nexport const cartItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n price: z.number(),\n quantity: z.number().int().min(0),\n image: z.string(),\n variant: z.string().optional(),\n})\nexport type CartItem = z.infer<typeof cartItemSchema>\n\nexport const recentlyViewedItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n price: z.number(),\n image: z.string(),\n})\nexport type RecentlyViewedItem = z.infer<typeof recentlyViewedItemSchema>\n\nexport const promotionSchema = z.object({\n threshold: z.number(),\n reward: z.string(),\n icon: z.string().default('gift'),\n})\nexport type Promotion = z.infer<typeof promotionSchema>\n\nconst storeCategoryBase = {\n label: z.string(),\n href: z.string(),\n emphasis: z.boolean().optional(),\n}\n\nexport const storeCategorySchema: z.ZodType<StoreCategory> = z.lazy(() =>\n z.object({\n ...storeCategoryBase,\n children: z.array(storeCategorySchema).optional(),\n }),\n)\nexport type StoreCategory = {\n label: string\n href: string\n children?: StoreCategory[]\n emphasis?: boolean\n}\n\nexport const utilityLinkSchema = z.object({\n label: z.string(),\n href: z.string(),\n})\nexport type UtilityLink = z.infer<typeof utilityLinkSchema>\n\nexport const navCartItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n variant: z.string(),\n price: z.number(),\n qty: z.number().int().min(0),\n image: z.string(),\n})\nexport type NavCartItem = z.infer<typeof navCartItemSchema>\n\nexport const storeUserSchema = z.object({\n name: z.string(),\n email: z.string(),\n avatar: z.string(),\n initials: z.string(),\n})\nexport type StoreUser = z.infer<typeof storeUserSchema>\n\nexport const accountMenuItemSchema = z.object({\n label: z.string(),\n href: z.string(),\n description: z.string().optional(),\n icon: z.enum(['orders', 'wishlist', 'addresses', 'settings']).optional(),\n})\nexport type AccountMenuItem = z.infer<typeof accountMenuItemSchema>\n\n/**\n * Serialization contract for a payment method offered at checkout.\n *\n * A projection of `@thorprovider/types` `PaymentMethod` — the storefront-facing\n * shape produced by the adapters transform. Checkout blocks render the method\n * list from this data instead of hardcoding providers.\n */\nexport const paymentMethodSchema: z.ZodType<PaymentMethod> = z.object({\n id: z.string(),\n name: z.string(),\n type: z.enum([\n 'card',\n 'wallet',\n 'bank_transfer',\n 'buy_now_pay_later',\n 'cash_on_delivery',\n 'crypto',\n 'other',\n ]),\n isEnabled: z.boolean(),\n requiresSetup: z.boolean(),\n description: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n features: z\n .object({\n saveForLater: z.boolean().optional(),\n requires3DS: z.boolean().optional(),\n supportsRefunds: z.boolean().optional(),\n minAmount: z.number().optional(),\n maxAmount: z.number().optional(),\n supportedCurrencies: z.array(z.string()).optional(),\n requiresVerification: z.boolean().optional(),\n })\n .optional(),\n logo: z.string().optional(),\n})\n\n// ---------------------------------------------------------------------------\n// Block prop schemas\n// ---------------------------------------------------------------------------\n\nexport const buttonPropsSchema = z.object({\n variant: z\n .enum(['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'])\n .optional(),\n size: z\n .enum(['default', 'xs', 'sm', 'lg', 'icon', 'icon-xs', 'icon-sm', 'icon-lg'])\n .optional(),\n disabled: z.boolean().optional(),\n className: z.string().optional(),\n})\nexport type ButtonSpecProps = z.infer<typeof buttonPropsSchema>\n\nexport const storeContainer1PropsSchema = z.object({\n size: z.enum(['default', 'narrow', 'wide', 'full']).optional(),\n className: z.string().optional(),\n})\nexport type StoreContainer1SpecProps = z.infer<typeof storeContainer1PropsSchema>\n\nexport const productCard1PropsSchema = z.object({\n products: z.array(cardProductSchema),\n heading: z.string().optional(),\n maxItems: z.number().int().positive().optional(),\n})\nexport type ProductCard1SpecProps = z.infer<typeof productCard1PropsSchema>\n\nexport const shoppingCart4PropsSchema = z.object({\n items: z.array(cartItemSchema),\n promotions: z.array(promotionSchema).default([]),\n recentlyViewed: z.array(recentlyViewedItemSchema).optional(),\n taxRate: z.number().optional(),\n titleLabel: z.string().optional(),\n subtotalLabel: z.string().optional(),\n taxLabel: z.string().optional(),\n shippingLabel: z.string().optional(),\n shippingFreeLabel: z.string().optional(),\n totalLabel: z.string().optional(),\n awayFromLabel: z.string().optional(),\n activatedLabel: z.string().optional(),\n itemsLabel: z.string().optional(),\n expressCheckoutLabel: z.string().optional(),\n expressLabel: z.string().optional(),\n standardLabel: z.string().optional(),\n estimatedDeliveryLabel: z.string().optional(),\n secureCheckoutLabel: z.string().optional(),\n recentlyViewedLabel: z.string().optional(),\n collapseLabel: z.string().optional(),\n expandLabel: z.string().optional(),\n checkoutLabel: z.string().optional(),\n quickCheckoutLabel: z.string().optional(),\n checkoutNowLabel: z.string().optional(),\n})\nexport type ShoppingCart4SpecProps = z.infer<typeof shoppingCart4PropsSchema>\n\nexport const navbar4PropsSchema = z.object({\n storeCategories: z.array(storeCategorySchema),\n shippingNote: z.string(),\n utilityLinks: z.array(utilityLinkSchema),\n logoText: z.string(),\n logoHref: z.string().optional(),\n accountHref: z.string().optional(),\n searchQuery: z.string().optional(),\n items: z.array(navCartItemSchema).optional(),\n user: storeUserSchema.optional(),\n accountMenuItems: z.array(accountMenuItemSchema).optional(),\n})\nexport type Navbar4SpecProps = z.infer<typeof navbar4PropsSchema>"],"mappings":";;;AAAA,SAAS,SAAS;AAgCX,IAAM,yBACX,sCACA;AAAA,EACE;AACF;AAMK,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,OAAO,EAAE,OAAO;AAAA,EAChB,OAAO,EAAE,OAAO;AAAA,EAChB,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,EACnC,OAAO,EAAE,OAAO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