@caartzee/theme-sdk 0.0.0-stage → 1.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.
Files changed (179) hide show
  1. package/README.md +222 -2
  2. package/dist/bin/caartzee-theme.js +9223 -0
  3. package/dist/lib/index.js +11614 -0
  4. package/dist/types/src/auth/credentials-store.d.ts +18 -0
  5. package/dist/types/src/auth/index.d.ts +2 -0
  6. package/dist/types/src/auth/oauth-client.d.ts +39 -0
  7. package/dist/types/src/blocks/block-contract.d.ts +242 -0
  8. package/dist/types/src/candy/compatibility-matrix.d.ts +10 -0
  9. package/dist/types/src/candy/context-builder.d.ts +31 -0
  10. package/dist/types/src/candy/engine.d.ts +69 -0
  11. package/dist/types/src/candy/filters.d.ts +32 -0
  12. package/dist/types/src/candy/ide-support.d.ts +20 -0
  13. package/dist/types/src/candy/index.d.ts +9 -0
  14. package/dist/types/src/candy/schema-parser.d.ts +13 -0
  15. package/dist/types/src/candy/security.d.ts +54 -0
  16. package/dist/types/src/candy/tags.d.ts +11 -0
  17. package/dist/types/src/candy/types.d.ts +185 -0
  18. package/dist/types/src/cli/caartzee-cli.d.ts +9 -0
  19. package/dist/types/src/cli/candy-mcp.d.ts +2 -0
  20. package/dist/types/src/cli/candy-tool-server.d.ts +39 -0
  21. package/dist/types/src/cli/index.d.ts +1 -0
  22. package/dist/types/src/cli/mcp/component-tools.d.ts +2 -0
  23. package/dist/types/src/cli/mcp/docs-tools.d.ts +89 -0
  24. package/dist/types/src/cli/mcp/editor-tools.d.ts +22 -0
  25. package/dist/types/src/cli/mcp/resources-and-prompts.d.ts +2 -0
  26. package/dist/types/src/cli/mcp/testing-tools.d.ts +54 -0
  27. package/dist/types/src/cli/sdk-client.d.ts +12 -0
  28. package/dist/types/src/contracts/category-selection.d.ts +15 -0
  29. package/dist/types/src/contracts/commerce.d.ts +282 -0
  30. package/dist/types/src/contracts/footer-builder.d.ts +125 -0
  31. package/dist/types/src/contracts/hooks.d.ts +37 -0
  32. package/dist/types/src/contracts/manifest.d.ts +3127 -0
  33. package/dist/types/src/contracts/navigation.d.ts +39 -0
  34. package/dist/types/src/contracts/order-tracking.d.ts +40 -0
  35. package/dist/types/src/contracts/page.d.ts +262 -0
  36. package/dist/types/src/contracts/storefront-content.d.ts +60 -0
  37. package/dist/types/src/contracts/style-document.d.ts +2 -0
  38. package/dist/types/src/contracts/styles.d.ts +2002 -0
  39. package/dist/types/src/contracts/theme.d.ts +35 -0
  40. package/dist/types/src/dev-server/catalog-preview.d.ts +25 -0
  41. package/dist/types/src/dev-server/dev-server.d.ts +25 -0
  42. package/dist/types/src/dev-server/index.d.ts +1 -0
  43. package/dist/types/src/dev-server/local-commerce-runtime.d.ts +76 -0
  44. package/dist/types/src/dev-server/local-editor-server.d.ts +22 -0
  45. package/dist/types/src/dev-server/theme-preview.d.ts +8 -0
  46. package/dist/types/src/index.d.ts +27 -0
  47. package/dist/types/src/mock/index.d.ts +10 -0
  48. package/dist/types/src/mock/mock-categories.d.ts +2 -0
  49. package/dist/types/src/mock/mock-commerce.d.ts +55 -0
  50. package/dist/types/src/mock/mock-customer.d.ts +47 -0
  51. package/dist/types/src/mock/mock-hooks.d.ts +2 -0
  52. package/dist/types/src/mock/mock-products.d.ts +3 -0
  53. package/dist/types/src/rendering/commerce-pages.d.ts +16 -0
  54. package/dist/types/src/rendering/raw-html.d.ts +12 -0
  55. package/dist/types/src/rendering/section-wrapper.d.ts +30 -0
  56. package/dist/types/src/scaffold/candy-starter-assets.d.ts +2 -0
  57. package/dist/types/src/scaffold/commerce-generator.d.ts +3 -0
  58. package/dist/types/src/scaffold/index.d.ts +2 -0
  59. package/dist/types/src/scaffold/template-generator.d.ts +21 -0
  60. package/dist/types/src/sections/section-contract.d.ts +350 -0
  61. package/dist/types/src/settings/global-settings.d.ts +25 -0
  62. package/dist/types/src/templates/json-template.d.ts +991 -0
  63. package/dist/types/src/validation/package-validator.d.ts +53 -0
  64. package/dist/types/src/validation/rich-text.d.ts +24 -0
  65. package/package.json +29 -3
  66. package/templates/commerce/README.md +165 -0
  67. package/templates/commerce/assets/theme.css +1 -0
  68. package/templates/commerce/manifest.json +1 -0
  69. package/templates/commerce/src/blocks/index.ts +184 -0
  70. package/templates/commerce/src/config/settings-defaults.ts +25 -0
  71. package/templates/commerce/src/config/settings-schema.ts +102 -0
  72. package/templates/commerce/src/index.ts +90 -0
  73. package/templates/commerce/src/layouts/default.ts +275 -0
  74. package/templates/commerce/src/manifest.ts +976 -0
  75. package/templates/commerce/src/pages/account/components.ts +369 -0
  76. package/templates/commerce/src/pages/account/tabs.ts +792 -0
  77. package/templates/commerce/src/pages/account.ts +55 -0
  78. package/templates/commerce/src/pages/campaign.ts +423 -0
  79. package/templates/commerce/src/pages/cart.ts +261 -0
  80. package/templates/commerce/src/pages/category-detail.ts +124 -0
  81. package/templates/commerce/src/pages/category-list.ts +87 -0
  82. package/templates/commerce/src/pages/checkout.ts +712 -0
  83. package/templates/commerce/src/pages/commerce.ts +45 -0
  84. package/templates/commerce/src/pages/home.ts +160 -0
  85. package/templates/commerce/src/pages/index.ts +99 -0
  86. package/templates/commerce/src/pages/login.ts +204 -0
  87. package/templates/commerce/src/pages/order-success.ts +80 -0
  88. package/templates/commerce/src/pages/product-detail.ts +489 -0
  89. package/templates/commerce/src/pages/product-list.ts +125 -0
  90. package/templates/commerce/src/pages/search.ts +88 -0
  91. package/templates/commerce/src/pages/signup.ts +253 -0
  92. package/templates/commerce/src/pages/status.ts +7 -0
  93. package/templates/commerce/src/pages/theme-layout.ts +491 -0
  94. package/templates/commerce/src/pages/track-order.ts +196 -0
  95. package/templates/commerce/src/pages/wishlist.ts +83 -0
  96. package/templates/commerce/src/sections/about-story.ts +117 -0
  97. package/templates/commerce/src/sections/announcement-bar.ts +101 -0
  98. package/templates/commerce/src/sections/banner-grid.ts +319 -0
  99. package/templates/commerce/src/sections/campaign-banners.ts +158 -0
  100. package/templates/commerce/src/sections/category-slider.ts +144 -0
  101. package/templates/commerce/src/sections/content-builder.ts +123 -0
  102. package/templates/commerce/src/sections/content-controls.ts +45 -0
  103. package/templates/commerce/src/sections/custom-form.ts +59 -0
  104. package/templates/commerce/src/sections/faq-accordion.ts +123 -0
  105. package/templates/commerce/src/sections/footer.ts +728 -0
  106. package/templates/commerce/src/sections/header.ts +439 -0
  107. package/templates/commerce/src/sections/hero-slider.ts +492 -0
  108. package/templates/commerce/src/sections/hero.ts +137 -0
  109. package/templates/commerce/src/sections/index.ts +102 -0
  110. package/templates/commerce/src/sections/mobile-slider.ts +102 -0
  111. package/templates/commerce/src/sections/newsletter.ts +43 -0
  112. package/templates/commerce/src/sections/product-grid.ts +191 -0
  113. package/templates/commerce/src/sections/raw-html.ts +1 -0
  114. package/templates/commerce/src/sections/rich-text.ts +26 -0
  115. package/templates/commerce/src/sections/services-features.ts +211 -0
  116. package/templates/commerce/src/sections/testimonials.ts +194 -0
  117. package/templates/commerce/src/snippets/product-card.ts +178 -0
  118. package/templates/commerce/src/snippets/product-price.ts +46 -0
  119. package/templates/commerce/src/snippets/responsive-image.ts +29 -0
  120. package/templates/commerce/src/styles.ts +477 -0
  121. package/templates/commerce/src/templates/404.json +26 -0
  122. package/templates/commerce/src/templates/account.json +17 -0
  123. package/templates/commerce/src/templates/cart.json +17 -0
  124. package/templates/commerce/src/templates/category.json +16 -0
  125. package/templates/commerce/src/templates/checkout.json +15 -0
  126. package/templates/commerce/src/templates/collection.json +16 -0
  127. package/templates/commerce/src/templates/index.json +180 -0
  128. package/templates/commerce/src/templates/login.json +17 -0
  129. package/templates/commerce/src/templates/order-success.json +17 -0
  130. package/templates/commerce/src/templates/page.json +17 -0
  131. package/templates/commerce/src/templates/product.json +17 -0
  132. package/templates/commerce/src/templates/search.json +18 -0
  133. package/templates/commerce/src/templates/signup.json +17 -0
  134. package/templates/commerce/src/templates/track-order.json +17 -0
  135. package/templates/commerce/src/templates/wishlist.json +17 -0
  136. package/templates/commerce/src/templates.ts +510 -0
  137. package/templates/commerce/src/tokens.ts +22 -0
  138. package/templates/theme-candy-boilerplate/.editorconfig +14 -0
  139. package/templates/theme-candy-boilerplate/.gitattributes +1 -0
  140. package/templates/theme-candy-boilerplate/.vscode/extensions.json +7 -0
  141. package/templates/theme-candy-boilerplate/.vscode/settings.json +17 -0
  142. package/templates/theme-candy-boilerplate/assets/theme.css +78 -0
  143. package/templates/theme-candy-boilerplate/assets/theme.js +7 -0
  144. package/templates/theme-candy-boilerplate/candy.config.json +40 -0
  145. package/templates/theme-candy-boilerplate/index.ts +39 -0
  146. package/templates/theme-candy-boilerplate/layout/theme.candy +25 -0
  147. package/templates/theme-candy-boilerplate/locales/en.default.json +37 -0
  148. package/templates/theme-candy-boilerplate/manifest.json +123 -0
  149. package/templates/theme-candy-boilerplate/package.json +16 -0
  150. package/templates/theme-candy-boilerplate/schemas/settings_schema.json +36 -0
  151. package/templates/theme-candy-boilerplate/sections/featured-products.candy +89 -0
  152. package/templates/theme-candy-boilerplate/sections/footer.candy +50 -0
  153. package/templates/theme-candy-boilerplate/sections/header.candy +116 -0
  154. package/templates/theme-candy-boilerplate/sections/hero-banner.candy +135 -0
  155. package/templates/theme-candy-boilerplate/sections/image-with-text.candy +85 -0
  156. package/templates/theme-candy-boilerplate/snippets/price.candy +19 -0
  157. package/templates/theme-candy-boilerplate/snippets/product-card.candy +43 -0
  158. package/templates/theme-candy-boilerplate/templates/404.candy +12 -0
  159. package/templates/theme-candy-boilerplate/templates/cart.candy +51 -0
  160. package/templates/theme-candy-boilerplate/templates/collection.candy +51 -0
  161. package/templates/theme-candy-boilerplate/templates/index.candy +7 -0
  162. package/templates/theme-candy-boilerplate/templates/page.candy +10 -0
  163. package/templates/theme-candy-boilerplate/templates/product.candy +59 -0
  164. package/templates/theme-candy-boilerplate/templates/search.candy +40 -0
  165. package/templates/vscode-candy/LICENSE +21 -0
  166. package/templates/vscode-candy/README.md +22 -0
  167. package/templates/vscode-candy/extension.js +689 -0
  168. package/templates/vscode-candy/icons/candy-dark.svg +23 -0
  169. package/templates/vscode-candy/icons/candy-light.svg +23 -0
  170. package/templates/vscode-candy/icons/candy-logo.png +0 -0
  171. package/templates/vscode-candy/icons/candy-sweet-dark.svg +23 -0
  172. package/templates/vscode-candy/icons/candy-sweet-light.svg +23 -0
  173. package/templates/vscode-candy/language-configuration.json +47 -0
  174. package/templates/vscode-candy/package.json +118 -0
  175. package/templates/vscode-candy/schemas/candy-config.schema.json +56 -0
  176. package/templates/vscode-candy/schemas/candy-settings.schema.json +70 -0
  177. package/templates/vscode-candy/snippets/candy.code-snippets +270 -0
  178. package/templates/vscode-candy/syntaxes/candy.tmLanguage.json +296 -0
  179. package/templates/vscode-candy/vim/ftdetect/candy.vim +5 -0
@@ -0,0 +1,728 @@
1
+ import {
2
+ createDefaultGlobalFooterConfig,
3
+ escapeHtml,
4
+ resolveNavItems,
5
+ sanitizeNavUrl,
6
+ type GlobalFooterConfig,
7
+ type SectionRenderContext,
8
+ } from '@caartzee/theme-sdk';
9
+
10
+ interface ResolvedFooterBrand {
11
+ logoImage: string;
12
+ logoWidth: number;
13
+ logoText: string;
14
+ tagline: string;
15
+ copyright: string;
16
+ replaceThemeSlug: (val: string) => string;
17
+ }
18
+
19
+ function resolveFooterBrand(
20
+ settings: Record<string, any>,
21
+ globalSettings: Record<string, any>,
22
+ fallbackCopyright?: string,
23
+ ): ResolvedFooterBrand {
24
+ const logoImage =
25
+ (typeof settings.logoImage === 'string' && settings.logoImage.trim()) ||
26
+ (typeof settings.logoUrl === 'string' && settings.logoUrl.trim()) ||
27
+ (typeof globalSettings.logoUrl === 'string' && globalSettings.logoUrl.trim()) ||
28
+ (typeof globalSettings.siteLogo === 'string' && globalSettings.siteLogo.trim()) ||
29
+ (typeof globalSettings.whiteLogo === 'string' && globalSettings.whiteLogo.trim()) ||
30
+ '';
31
+
32
+ const logoWidth = Math.max(40, Math.min(320, Number(settings.logoWidth || 140)));
33
+
34
+ const logoText =
35
+ (typeof settings.logoText === 'string' && settings.logoText.trim()) ||
36
+ (typeof globalSettings.storeName === 'string' && globalSettings.storeName.trim()) ||
37
+ (typeof globalSettings.siteTitle === 'string' && globalSettings.siteTitle.trim()) ||
38
+ 'My Store';
39
+
40
+ const tagline =
41
+ (typeof settings.tagline === 'string' && settings.tagline.trim()) ||
42
+ (typeof globalSettings.storeDescription === 'string' && globalSettings.storeDescription.trim()) ||
43
+ '';
44
+
45
+ const replaceThemeSlug = (val: string): string =>
46
+ val.replace(/\bstarter-theme\b/gi, logoText);
47
+
48
+ const rawCopyright =
49
+ (typeof settings.copyrightText === 'string' && settings.copyrightText.trim()) ||
50
+ (typeof settings.copyright === 'string' && settings.copyright.trim()) ||
51
+ (fallbackCopyright ? replaceThemeSlug(fallbackCopyright) : '') ||
52
+ (typeof globalSettings.footerCopyrightText === 'string' && globalSettings.footerCopyrightText.trim()) ||
53
+ '© {year} {store}. All Rights Reserved.';
54
+
55
+ const copyright = rawCopyright
56
+ .replace(/\{copy\}/gi, '©')
57
+ .replace(/\{year\}/gi, String(new Date().getFullYear()))
58
+ .replace(/\{store\}/gi, logoText);
59
+
60
+ return { logoImage, logoWidth, logoText, tagline, copyright, replaceThemeSlug };
61
+ }
62
+
63
+ function renderNewsletterTopStrip(
64
+ settings: Record<string, any>,
65
+ headingColor: string,
66
+ textColor: string,
67
+ accentColor: string,
68
+ dividerColor: string,
69
+ ): string {
70
+ const showNewsletter =
71
+ settings.showNewsletter !== false &&
72
+ settings.enableNewsletter !== false &&
73
+ settings.showTopNewsletter !== false;
74
+ if (!showNewsletter) {
75
+ return '';
76
+ }
77
+
78
+ const heading =
79
+ (typeof settings.newsletterTitle === 'string' && settings.newsletterTitle.trim()) ||
80
+ (typeof settings.newsletterHeading === 'string' && settings.newsletterHeading.trim()) ||
81
+ 'Subscribe to our Newsletter';
82
+
83
+ const subtitle =
84
+ (typeof settings.newsletterDescription === 'string' && settings.newsletterDescription.trim()) ||
85
+ (typeof settings.newsletterSubtitle === 'string' && settings.newsletterSubtitle.trim()) ||
86
+ 'Get the latest updates, exclusive deals, and new arrivals delivered right to your inbox.';
87
+
88
+ const placeholder =
89
+ (typeof settings.newsletterPlaceholder === 'string' && settings.newsletterPlaceholder.trim()) ||
90
+ 'Enter your email address';
91
+
92
+ const buttonText =
93
+ (typeof settings.newsletterButtonText === 'string' && settings.newsletterButtonText.trim()) ||
94
+ 'Subscribe';
95
+
96
+ return `
97
+ <div class="footer-newsletter-strip" data-element="newsletter-strip" style="border-bottom: 1px solid ${dividerColor}; padding-bottom: 28px; margin-bottom: 32px;">
98
+ <div style="display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px;">
99
+ <div style="max-width: 480px;">
100
+ <h3 style="font-size: 18px; font-weight: 700; color: ${headingColor}; margin: 0 0 6px 0; font-family: inherit; letter-spacing: -0.01em;">
101
+ ${escapeHtml(heading)}
102
+ </h3>
103
+ <p style="font-size: 13px; color: ${textColor}; margin: 0; line-height: 1.5;">
104
+ ${escapeHtml(subtitle)}
105
+ </p>
106
+ </div>
107
+ <form action="/_api/newsletter" method="POST" class="js-newsletter-form" data-v2-action="newsletter" style="display: flex; flex-wrap: wrap; gap: 8px; width: 100%; max-width: 460px; margin: 0;">
108
+ <input
109
+ type="email"
110
+ name="email"
111
+ required
112
+ placeholder="${escapeHtml(placeholder)}"
113
+ style="flex: 1; min-width: 220px; padding: 10px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06); color: #ffffff; font-size: 13px; outline: none; transition: border-color 0.15s ease;"
114
+ />
115
+ <button
116
+ type="submit"
117
+ style="padding: 10px 22px; border-radius: 8px; border: none; background: ${accentColor}; color: #14100e; font-weight: 700; font-size: 13px; cursor: pointer; transition: opacity 0.15s ease;"
118
+ >
119
+ ${escapeHtml(buttonText)}
120
+ </button>
121
+ <div data-v2-feedback style="width: 100%; font-size: 12px; margin-top: 4px; min-height: 16px; color: ${accentColor}; font-weight: 500;"></div>
122
+ </form>
123
+ </div>
124
+ </div>
125
+ `;
126
+ }
127
+
128
+ /**
129
+ * Helper to extract normalized social media platform URLs from various setting formats:
130
+ * - Flat keys: facebookUrl, facebook, instagramUrl, etc.
131
+ * - Nested objects: socialLinks: { facebook: '...', instagram: '...' }
132
+ * - Widget Builder platforms array: platforms: [{ platform: 'facebook', url: '...', enabled: true }]
133
+ */
134
+ export function extractSocialUrls(settings: Record<string, any>): Record<string, string> {
135
+ const result: Record<string, string> = {};
136
+
137
+ const platforms = [
138
+ 'facebook',
139
+ 'instagram',
140
+ 'youtube',
141
+ 'twitter',
142
+ 'x',
143
+ 'linkedin',
144
+ 'tiktok',
145
+ 'pinterest',
146
+ 'whatsapp',
147
+ ];
148
+ for (const p of platforms) {
149
+ const val = settings[`${p}Url`] || settings[p];
150
+ if (typeof val === 'string' && val.trim()) {
151
+ result[p === 'x' ? 'twitter' : p] = val.trim();
152
+ }
153
+ }
154
+
155
+ const nested = (settings.socialLinks || settings.social || {}) as Record<string, any>;
156
+ if (typeof nested === 'object' && !Array.isArray(nested)) {
157
+ for (const [k, v] of Object.entries(nested)) {
158
+ const plat = k.toLowerCase().trim();
159
+ const val =
160
+ typeof v === 'string'
161
+ ? v.trim()
162
+ : v && typeof v === 'object' && (v as any).enabled !== false && typeof (v as any).url === 'string'
163
+ ? (v as any).url.trim()
164
+ : '';
165
+ if (val && !result[plat === 'x' ? 'twitter' : plat]) {
166
+ result[plat === 'x' ? 'twitter' : plat] = val;
167
+ }
168
+ }
169
+ }
170
+
171
+ if (Array.isArray(settings.platforms)) {
172
+ for (const item of settings.platforms) {
173
+ if (!item) continue;
174
+ if (typeof item === 'object') {
175
+ if (item.enabled === false) continue;
176
+ const plat = String(item.platform || item.name || item.id || '').toLowerCase().trim();
177
+ const url =
178
+ typeof item.url === 'string'
179
+ ? item.url.trim()
180
+ : typeof item.link === 'string'
181
+ ? item.link.trim()
182
+ : '';
183
+ if (url) {
184
+ result[plat === 'x' ? 'twitter' : plat] = url;
185
+ }
186
+ }
187
+ }
188
+ }
189
+
190
+ return result;
191
+ }
192
+
193
+ /**
194
+ * Starter Footer Section (footer-links / starter-footer)
195
+ *
196
+ * Supports store logo auto-inheritance, custom colors, tagline, contact details,
197
+ * social links, payment badges, navigation links, and customizable copyright notice.
198
+ */
199
+ export function renderStarterFooter(ctx: SectionRenderContext): string {
200
+ const settings = (ctx.section.settings || {}) as Record<string, any>;
201
+ const globalSettings = (ctx.globalSettings || {}) as Record<string, any>;
202
+
203
+ // If a footer-links section carries a Widget Builder footerConfig, delegate seamlessly
204
+ if (settings.footerConfig) {
205
+ return renderFooterBuilder(ctx);
206
+ }
207
+
208
+ const navigation = resolveNavItems(ctx.section, []);
209
+ const { logoImage, logoWidth, logoText, tagline, copyright } = resolveFooterBrand(
210
+ settings,
211
+ globalSettings,
212
+ );
213
+ const showMonogram =
214
+ settings.showMonogram !== undefined ? Boolean(settings.showMonogram) : !logoImage;
215
+
216
+ const bgColor = (typeof settings.backgroundColor === 'string' && settings.backgroundColor.trim()) || '#0e0c0b';
217
+ const headingColor = (typeof settings.headingColor === 'string' && settings.headingColor.trim()) || '#ffffff';
218
+ const textColor = (typeof settings.textColor === 'string' && settings.textColor.trim()) || '#a8a29e';
219
+ const linkColor = (typeof settings.linkColor === 'string' && settings.linkColor.trim()) || '#d6d3d1';
220
+ const accentColor = (typeof settings.accentColor === 'string' && settings.accentColor.trim()) || '#e5b95c';
221
+ const showPaymentIcons = settings.showPaymentIcons !== false;
222
+
223
+ const customerCareLinks: Array<{ label: string; url: string }> = Array.isArray(settings.customerCareLinks)
224
+ ? (settings.customerCareLinks as any[]).filter((l) => l && l.label)
225
+ : [];
226
+ const legalLinks: Array<{ label: string; url: string }> = Array.isArray(settings.legalLinks)
227
+ ? (settings.legalLinks as any[]).filter((l) => l && l.label)
228
+ : [];
229
+
230
+ const address = typeof settings.address === 'string' ? settings.address.trim() : '';
231
+ const email = typeof settings.email === 'string' ? settings.email.trim() : '';
232
+ const phone = typeof settings.phone === 'string' ? settings.phone.trim() : '';
233
+ const hours = typeof settings.hours === 'string' ? settings.hours.trim() : '';
234
+ const hasContactInfo = Boolean(address || email || phone || hours);
235
+
236
+ const socialMap = extractSocialUrls(settings);
237
+ const socialLinks = {
238
+ facebook: socialMap.facebook || '',
239
+ instagram: socialMap.instagram || '',
240
+ youtube: socialMap.youtube || '',
241
+ twitter: socialMap.twitter || '',
242
+ linkedin: socialMap.linkedin || '',
243
+ tiktok: socialMap.tiktok || '',
244
+ whatsapp: socialMap.whatsapp || '',
245
+ };
246
+ const hasSocial = Boolean(
247
+ socialLinks.facebook ||
248
+ socialLinks.instagram ||
249
+ socialLinks.youtube ||
250
+ socialLinks.twitter ||
251
+ socialLinks.linkedin ||
252
+ socialLinks.tiktok ||
253
+ socialLinks.whatsapp
254
+ );
255
+
256
+ const newsletterStripHtml = renderNewsletterTopStrip(
257
+ settings,
258
+ headingColor,
259
+ textColor,
260
+ accentColor,
261
+ 'rgba(255,255,255,0.1)',
262
+ );
263
+
264
+ return `
265
+ <footer class="sf-footer sf-starter-footer border-t border-white/10 pt-14 pb-8 mt-auto select-none" id="${escapeHtml(ctx.section.id)}" data-section-id="${escapeHtml(ctx.section.id)}" data-section-type="${escapeHtml(ctx.section.type || 'footer-links')}" data-region="footer" style="background-color: ${escapeHtml(bgColor)}; color: ${escapeHtml(textColor)};">
266
+ <div class="max-w-[1360px] mx-auto px-4 sm:px-6 lg:px-8">
267
+ ${newsletterStripHtml}
268
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-8 lg:gap-10 pb-12">
269
+
270
+ <!-- Brand Column -->
271
+ <div class="lg:col-span-3">
272
+ <a href="/" class="inline-flex items-center gap-2.5 mb-3.5 no-underline">
273
+ ${logoImage ? `
274
+ <img src="${escapeHtml(logoImage)}" alt="${escapeHtml(logoText)}" style="max-width: ${logoWidth}px; max-height: 44px; width: auto; height: auto; object-fit: contain;" class="shrink-0" />
275
+ ` : showMonogram ? `
276
+ <span class="w-7 h-7 rounded-lg bg-gradient-to-br from-[#f2cf7e] to-[#c79131] text-[#14100e] inline-flex items-center justify-center shrink-0" aria-hidden="true">
277
+ <svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
278
+ <path d="M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z" />
279
+ <line x1="3" y1="6" x2="21" y2="6" />
280
+ <path d="M16 10a4 4 0 0 1-8 0" />
281
+ </svg>
282
+ </span>
283
+ ` : ''}
284
+ <span class="text-xl font-bold tracking-tight font-heading" style="color: ${escapeHtml(headingColor)};">
285
+ ${escapeHtml(logoText)}
286
+ </span>
287
+ </a>
288
+ ${tagline ? `
289
+ <p class="text-xs leading-relaxed max-w-xs mb-5" style="color: ${escapeHtml(textColor)};">
290
+ ${escapeHtml(tagline)}
291
+ </p>
292
+ ` : ''}
293
+ ${hasSocial ? `
294
+ <div class="flex items-center gap-2.5">
295
+ ${socialLinks.facebook ? `<a href="${sanitizeNavUrl(socialLinks.facebook, '#')}" aria-label="Facebook" class="w-8 h-8 rounded-full bg-white/10 hover:opacity-85 flex items-center justify-center transition-opacity" style="color: ${escapeHtml(linkColor)};"><svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"/></svg></a>` : ''}
296
+ ${socialLinks.instagram ? `<a href="${sanitizeNavUrl(socialLinks.instagram, '#')}" aria-label="Instagram" class="w-8 h-8 rounded-full bg-white/10 hover:opacity-85 flex items-center justify-center transition-opacity" style="color: ${escapeHtml(linkColor)};"><svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="5"/><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"/><line x1="17.5" y1="6.5" x2="17.51" y2="6.5"/></svg></a>` : ''}
297
+ ${socialLinks.youtube ? `<a href="${sanitizeNavUrl(socialLinks.youtube, '#')}" aria-label="YouTube" class="w-8 h-8 rounded-full bg-white/10 hover:opacity-85 flex items-center justify-center transition-opacity" style="color: ${escapeHtml(linkColor)};"><svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z"/></svg></a>` : ''}
298
+ ${socialLinks.twitter ? `<a href="${sanitizeNavUrl(socialLinks.twitter, '#')}" aria-label="X" class="w-8 h-8 rounded-full bg-white/10 hover:opacity-85 flex items-center justify-center transition-opacity" style="color: ${escapeHtml(linkColor)};"><svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231z"/></svg></a>` : ''}
299
+ </div>
300
+ ` : ''}
301
+ </div>
302
+
303
+ ${navigation.length ? `
304
+ <nav class="lg:col-span-2" aria-label="Quick Links">
305
+ <h4 class="text-xs font-bold mb-3.5" style="color: ${escapeHtml(headingColor)};">Quick Links</h4>
306
+ <ul class="space-y-2.5 text-xs">
307
+ ${navigation.map((link) => `<li><a href="${escapeHtml(link.url)}" class="hover:opacity-80 transition-opacity" style="color: ${escapeHtml(linkColor)};">${escapeHtml(link.label)}</a></li>`).join('')}
308
+ </ul>
309
+ </nav>
310
+ ` : ''}
311
+
312
+ ${customerCareLinks.length ? `
313
+ <nav class="lg:col-span-2" aria-label="Customer Care">
314
+ <h4 class="text-xs font-bold mb-3.5" style="color: ${escapeHtml(headingColor)};">Customer Care</h4>
315
+ <ul class="space-y-2.5 text-xs">
316
+ ${customerCareLinks.map((link) => `<li><a href="${sanitizeNavUrl(link.url, '#')}" class="hover:opacity-80 transition-opacity" style="color: ${escapeHtml(linkColor)};">${escapeHtml(link.label)}</a></li>`).join('')}
317
+ </ul>
318
+ </nav>
319
+ ` : ''}
320
+
321
+ ${hasContactInfo ? `
322
+ <div class="lg:col-span-3">
323
+ <h4 class="text-xs font-bold mb-3.5" style="color: ${escapeHtml(headingColor)};">Get in Touch</h4>
324
+ <div class="space-y-2.5 text-xs" style="color: ${escapeHtml(textColor)};">
325
+ ${address ? `<p class="flex items-start gap-2"><svg class="w-3.5 h-3.5 shrink-0 mt-0.5" style="color: ${escapeHtml(accentColor)};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg><span>${escapeHtml(address)}</span></p>` : ''}
326
+ ${email ? `<p class="flex items-center gap-2"><svg class="w-3.5 h-3.5 shrink-0" style="color: ${escapeHtml(accentColor)};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg><a href="mailto:${escapeHtml(email)}" class="hover:opacity-80" style="color: ${escapeHtml(linkColor)};">${escapeHtml(email)}</a></p>` : ''}
327
+ ${phone ? `<p class="flex items-center gap-2"><svg class="w-3.5 h-3.5 shrink-0" style="color: ${escapeHtml(accentColor)};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z"/></svg><a href="tel:${escapeHtml(phone)}" class="hover:opacity-80" style="color: ${escapeHtml(linkColor)};">${escapeHtml(phone)}</a></p>` : ''}
328
+ ${hours ? `<p class="flex items-center gap-2"><svg class="w-3.5 h-3.5 shrink-0" style="color: ${escapeHtml(accentColor)};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg><span>${escapeHtml(hours)}</span></p>` : ''}
329
+ </div>
330
+ </div>
331
+ ` : ''}
332
+
333
+ ${showPaymentIcons ? `
334
+ <!-- Secure Payments Column -->
335
+ <div class="lg:col-span-2">
336
+ <h4 class="text-xs font-bold mb-3.5" style="color: ${escapeHtml(headingColor)};">Secure Payments</h4>
337
+ <div class="flex flex-wrap items-center gap-2">
338
+ <span class="inline-flex items-center justify-center h-6 px-2.5 rounded bg-white text-slate-900 text-[10px] font-extrabold">VISA</span>
339
+ <span class="inline-flex items-center justify-center h-6 px-2.5 rounded bg-white text-slate-900 text-[10px] font-extrabold">MC</span>
340
+ <span class="inline-flex items-center justify-center h-6 px-2.5 rounded bg-white text-slate-900 text-[10px] font-extrabold">UPI</span>
341
+ <span class="inline-flex items-center justify-center h-6 px-2.5 rounded bg-white text-slate-900 text-[10px] font-extrabold">Paytm</span>
342
+ </div>
343
+ </div>
344
+ ` : ''}
345
+
346
+ </div>
347
+
348
+ <!-- Bottom Copyright & Legal Row -->
349
+ <div class="pt-6 border-t border-white/10 flex flex-col sm:flex-row items-center justify-between gap-4 text-xs" style="color: ${escapeHtml(textColor)};">
350
+ <div class="sf-footer-copyright" data-footer-copyright="true">
351
+ ${escapeHtml(copyright)}
352
+ </div>
353
+
354
+ ${legalLinks.length > 0 ? `
355
+ <div class="flex items-center gap-3">
356
+ ${legalLinks.map((l, idx) => `${idx > 0 ? '<span class="opacity-35">|</span>' : ''}<a href="${sanitizeNavUrl(l.url, '#')}" class="hover:opacity-80 transition-opacity" style="color: ${escapeHtml(linkColor)};">${escapeHtml(l.label)}</a>`).join('')}
357
+ </div>
358
+ ` : ''}
359
+ </div>
360
+
361
+ </div>
362
+ </footer>
363
+ `;
364
+ }
365
+
366
+ /**
367
+ * Global Widget-Builder Footer Renderer (footer-builder)
368
+ *
369
+ * Renders multi-row/multi-column Widget Builder layouts while honoring store logo,
370
+ * brand name, and Theme Editor customization overrides.
371
+ */
372
+ export function renderFooterBuilder(context: any): string {
373
+ const section = context?.section || {};
374
+ const settings = (section.settings || {}) as Record<string, any>;
375
+
376
+ if (settings.enabled === false) {
377
+ return '';
378
+ }
379
+
380
+ let config: GlobalFooterConfig;
381
+ if (settings.footerConfig) {
382
+ try {
383
+ config =
384
+ typeof settings.footerConfig === 'string'
385
+ ? JSON.parse(settings.footerConfig)
386
+ : settings.footerConfig;
387
+ } catch {
388
+ config = createDefaultGlobalFooterConfig();
389
+ }
390
+ } else {
391
+ config = createDefaultGlobalFooterConfig();
392
+ }
393
+
394
+ const globalSettings = (context?.globalSettings || {}) as Record<string, any>;
395
+ const bottomBar = config.bottomBar;
396
+ const {
397
+ logoImage: resolvedLogoUrl,
398
+ logoWidth: resolvedLogoWidth,
399
+ logoText: resolvedStoreName,
400
+ tagline: brandTagline,
401
+ copyright: copyText,
402
+ replaceThemeSlug,
403
+ } = resolveFooterBrand(settings, globalSettings, bottomBar?.copyrightText);
404
+
405
+ const styling = config.styling || {};
406
+ const bgColor = settings.backgroundColor || styling.backgroundColor || '#0e0c0b';
407
+ const textColor = settings.textColor || styling.textColor || '#a8a29e';
408
+ const headingColor = settings.headingColor || styling.headingColor || '#ffffff';
409
+ const linkColor = settings.linkColor || styling.linkColor || '#d6d3d1';
410
+ const paddingTop = styling.paddingTop !== undefined ? `${styling.paddingTop}px` : '56px';
411
+ const paddingBottom = styling.paddingBottom !== undefined ? `${styling.paddingBottom}px` : '40px';
412
+ const borderTop =
413
+ styling.borderTopWidth && styling.borderTopWidth > 0
414
+ ? `${styling.borderTopWidth}px solid ${styling.borderTopColor || '#1f1a17'}`
415
+ : 'none';
416
+
417
+ const hasExplicitLogoComponent = (config.rows || []).some((row) =>
418
+ (row.columns || []).some((col) =>
419
+ (col.components || []).some((c) => c.type === 'logo' || (c.type as string) === 'brand-logo'),
420
+ ),
421
+ );
422
+
423
+ const rowsHtml = (config.rows || [])
424
+ .map((row) => {
425
+ const colsHtml = (row.columns || [])
426
+ .map((col) => {
427
+ const widthNum = Number(col.width) || 3;
428
+ const flexBasis = widthNum > 12 ? `${widthNum}%` : `${Math.round((widthNum / 12) * 100)}%`;
429
+
430
+ const compsHtml = (col.components || [])
431
+ .map((comp) => {
432
+ const compSettings = comp.settings || {};
433
+
434
+ switch (comp.type as string) {
435
+ case 'link-list':
436
+ case 'category-links':
437
+ case 'customer-care-links': {
438
+ const heading = compSettings.title || compSettings.heading
439
+ ? `<h4 style="font-size: 13px; font-weight: 700; color: ${headingColor}; margin-bottom: 14px;">${escapeHtml(compSettings.title || compSettings.heading)}</h4>`
440
+ : '';
441
+ const desc = compSettings.description
442
+ ? `<p style="margin: 0 0 12px 0; font-size: 13px; line-height: 1.6; color: ${textColor};">${escapeHtml(replaceThemeSlug(String(compSettings.description)))}</p>`
443
+ : '';
444
+ const items = (compSettings.links || compSettings.items || [])
445
+ .map(
446
+ (item: any) =>
447
+ `<li style="margin-bottom: 9px;"><a href="${sanitizeNavUrl(item.url, '#')}" target="${escapeHtml(item.target || '_self')}" style="color: ${linkColor}; text-decoration: none; font-size: 13px; transition: color 0.15s ease;">${escapeHtml(item.label || '')}</a></li>`,
448
+ )
449
+ .join('');
450
+ return `
451
+ <div class="footer-comp footer-comp-${comp.type} footer-widget" id="${escapeHtml(comp.id)}">
452
+ ${heading}
453
+ ${desc}
454
+ <ul style="list-style: none; padding: 0; margin: 0;">${items}</ul>
455
+ </div>
456
+ `;
457
+ }
458
+ case 'logo':
459
+ case 'brand-logo': {
460
+ const compLogoText = compSettings.brandName || compSettings.logoText || resolvedStoreName;
461
+ const compLogoImg = compSettings.logoUrl || compSettings.logoImage || resolvedLogoUrl;
462
+ const showIcon = compSettings.showBrandIcon !== false && !compLogoImg;
463
+ const desc = compSettings.description
464
+ ? `<p style="margin-top: 12px; font-size: 12.5px; line-height: 1.65; color: ${textColor}; max-width: 260px;">${escapeHtml(replaceThemeSlug(String(compSettings.description)))}</p>`
465
+ : '';
466
+ const imgHtml = compLogoImg
467
+ ? `<img src="${escapeHtml(compLogoImg)}" alt="${escapeHtml(compLogoText)}" style="max-width: ${resolvedLogoWidth}px; max-height: 44px; width: auto; height: auto; object-fit: contain; flex-shrink: 0;" />`
468
+ : '';
469
+ const badgeHtml = showIcon
470
+ ? `<span style="width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #f2cf7e, #c79131); color: #14100e; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;">
471
+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z"/><line x1="3" y1="6" x2="21" y2="6"/><path d="M16 10a4 4 0 0 1-8 0"/></svg>
472
+ </span>`
473
+ : '';
474
+ return `
475
+ <div class="footer-comp footer-comp-logo" id="${escapeHtml(comp.id)}">
476
+ <a href="/" style="display: inline-flex; align-items: center; gap: 10px; text-decoration: none;">
477
+ ${imgHtml || badgeHtml}
478
+ <span style="font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: ${headingColor};">${escapeHtml(compLogoText)}</span>
479
+ </a>
480
+ ${desc}
481
+ </div>
482
+ `;
483
+ }
484
+ case 'menu':
485
+ case 'navigation-menu': {
486
+ const headingText = compSettings.title || compSettings.heading;
487
+ const heading = headingText
488
+ ? `<h4 style="font-size: 13px; font-weight: 700; color: ${headingColor}; margin-bottom: 14px;">${escapeHtml(headingText)}</h4>`
489
+ : '';
490
+ const rawItems =
491
+ compSettings.resolvedMenuItems ||
492
+ compSettings.menuItems ||
493
+ compSettings.links ||
494
+ compSettings.items ||
495
+ [];
496
+ const isHorizontal = compSettings.displayStyle === 'horizontal';
497
+ const listStyle = isHorizontal
498
+ ? 'list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;'
499
+ : 'list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px;';
500
+ const itemStyle = isHorizontal
501
+ ? 'display: inline-block; margin: 0;'
502
+ : 'margin-bottom: 0;';
503
+ const items = (Array.isArray(rawItems) ? rawItems : [])
504
+ .map(
505
+ (item: any) =>
506
+ `<li style="${itemStyle}"><a href="${sanitizeNavUrl(item.url || item.purl, '#')}" target="${escapeHtml(item.target || item.antarget || '_self')}" style="color: ${linkColor}; text-decoration: none; font-size: 13px;">${escapeHtml(item.label || item.menulabel || item.title || '')}</a></li>`,
507
+ )
508
+ .join('');
509
+ return `
510
+ <div class="footer-comp footer-comp-menu footer-widget" id="${escapeHtml(comp.id)}">
511
+ ${heading}
512
+ <ul style="${listStyle}">${items}</ul>
513
+ </div>
514
+ `;
515
+ }
516
+ case 'contact':
517
+ case 'contact-info': {
518
+ const heading = compSettings.title || compSettings.heading
519
+ ? `<h4 style="font-size: 13px; font-weight: 700; color: ${headingColor}; margin-bottom: 14px;">${escapeHtml(compSettings.title || compSettings.heading)}</h4>`
520
+ : '';
521
+ const iconColor = '#e5b95c';
522
+ const rowCss = 'display: flex; align-items: flex-start; gap: 8px; margin: 0 0 10px 0; font-size: 12.5px; line-height: 1.5;';
523
+ const address = compSettings.address
524
+ ? `<p style="${rowCss} color: ${textColor};"><svg width="14" height="14" style="flex-shrink:0;margin-top:2px;color:${iconColor};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg><span>${escapeHtml(compSettings.address)}</span></p>`
525
+ : '';
526
+ const email = compSettings.email
527
+ ? `<p style="${rowCss}"><svg width="14" height="14" style="flex-shrink:0;margin-top:2px;color:${iconColor};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg><a href="mailto:${escapeHtml(compSettings.email)}" style="color: ${linkColor}; text-decoration: none;">${escapeHtml(compSettings.email)}</a></p>`
528
+ : '';
529
+ const phone = compSettings.phone
530
+ ? `<p style="${rowCss}"><svg width="14" height="14" style="flex-shrink:0;margin-top:2px;color:${iconColor};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z"/></svg><a href="tel:${escapeHtml(compSettings.phone)}" style="color: ${linkColor}; text-decoration: none;">${escapeHtml(compSettings.phone)}</a></p>`
531
+ : '';
532
+ const hours = compSettings.businessHours
533
+ ? `<p style="${rowCss} color: ${textColor}; margin-bottom: 0;"><svg width="14" height="14" style="flex-shrink:0;margin-top:2px;color:${iconColor};" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg><span>${escapeHtml(compSettings.businessHours)}</span></p>`
534
+ : '';
535
+ return `
536
+ <div class="footer-comp footer-comp-contact" id="${escapeHtml(comp.id)}">
537
+ ${heading}
538
+ ${address}
539
+ ${email}
540
+ ${phone}
541
+ ${hours}
542
+ </div>
543
+ `;
544
+ }
545
+ case 'social':
546
+ case 'social-links': {
547
+ const heading = compSettings.title || compSettings.heading
548
+ ? `<h4 style="font-size: 13px; font-weight: 700; color: ${headingColor}; margin-bottom: 12px;">${escapeHtml(compSettings.title || compSettings.heading)}</h4>`
549
+ : '';
550
+
551
+ const sUrls = extractSocialUrls(compSettings);
552
+ const fb = sUrls.facebook;
553
+ const ig = sUrls.instagram;
554
+ const yt = sUrls.youtube;
555
+ const tw = sUrls.twitter;
556
+ const li = sUrls.linkedin;
557
+ const tt = sUrls.tiktok;
558
+ const pin = sUrls.pinterest;
559
+ const wa = sUrls.whatsapp;
560
+
561
+ const btnStyle = `width: 32px; height: 32px; border-radius: 9999px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); color: ${escapeHtml(linkColor || '#d6d3d1')}; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; transition: opacity 0.2s ease, transform 0.2s ease;`;
562
+ const links = [
563
+ fb ? `<a href="${sanitizeNavUrl(fb, '#')}" style="${btnStyle}" aria-label="Facebook" target="_blank" rel="noopener noreferrer"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"/></svg></a>` : '',
564
+ ig ? `<a href="${sanitizeNavUrl(ig, '#')}" style="${btnStyle}" aria-label="Instagram" target="_blank" rel="noopener noreferrer"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"/><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"/><line x1="17.5" y1="6.5" x2="17.51" y2="6.5"/></svg></a>` : '',
565
+ yt ? `<a href="${sanitizeNavUrl(yt, '#')}" style="${btnStyle}" aria-label="YouTube" target="_blank" rel="noopener noreferrer"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z"/><polygon points="9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02" fill="#0e0c0b"/></svg></a>` : '',
566
+ tw ? `<a href="${sanitizeNavUrl(tw, '#')}" style="${btnStyle}" aria-label="X" target="_blank" rel="noopener noreferrer"><svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg></a>` : '',
567
+ li ? `<a href="${sanitizeNavUrl(li, '#')}" style="${btnStyle}" aria-label="LinkedIn" target="_blank" rel="noopener noreferrer"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z"/><rect x="2" y="9" width="4" height="12"/><circle cx="4" cy="4" r="2"/></svg></a>` : '',
568
+ tt ? `<a href="${sanitizeNavUrl(tt, '#')}" style="${btnStyle}" aria-label="TikTok" target="_blank" rel="noopener noreferrer"><svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 0 1-5.2 1.74 2.89 2.89 0 0 1 2.31-4.64c.298-.002.595.042.88.13V9.4a6.33 6.33 0 0 0-1-.08A6.34 6.34 0 0 0 3 15.66a6.34 6.34 0 0 0 10.82 4.49 6.26 6.26 0 0 0 1.86-4.49V8.65a8.28 8.28 0 0 0 5.24 1.85V7.05a4.85 4.85 0 0 1-1.33-.36z"/></svg></a>` : '',
569
+ pin ? `<a href="${sanitizeNavUrl(pin, '#')}" style="${btnStyle}" aria-label="Pinterest" target="_blank" rel="noopener noreferrer"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0a12 12 0 0 0-4.37 23.18c-.07-.94-.13-2.39.03-3.42l1.12-4.75s-.28-.56-.28-1.39c0-1.3.75-2.27 1.69-2.27.8 0 1.18.6 1.18 1.32 0 .8-.51 2-0.78 3.12-.22.93.46 1.69 1.38 1.69 1.66 0 2.94-1.75 2.94-4.28 0-2.24-1.61-3.8-3.91-3.8-2.66 0-4.22 2-4.22 4.06 0 .8.31 1.67.7 2.14a.28.28 0 0 1 .06.27c-.07.28-.22.9-.25 1.03-.04.17-.14.21-.32.13-1.2-.56-1.95-2.31-1.95-3.72 0-3.03 2.2-5.81 6.35-5.81 3.33 0 5.92 2.38 5.92 5.55 0 3.31-2.09 5.98-4.99 5.98-.97 0-1.89-.51-2.2-.11l-.6 2.29c-.22.84-.81 1.9-1.21 2.54A12 12 0 1 0 12 0z"/></svg></a>` : '',
570
+ wa ? `<a href="${sanitizeNavUrl(wa, '#')}" style="${btnStyle}" aria-label="WhatsApp" target="_blank" rel="noopener noreferrer"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12.031 6.172c-3.181 0-5.767 2.586-5.768 5.766-.001 1.298.38 2.27 1.019 3.287l-.711 2.598 2.669-.699c.969.587 1.77.8 2.791.801h.005c3.18 0 5.767-2.586 5.768-5.766 0-1.542-.601-2.991-1.691-4.082s-2.542-1.705-4.082-1.705zm3.433 8.169c-.146.411-.848.791-1.189.845-.33.052-.756.079-1.219-.071-.295-.095-.678-.225-1.183-.443-2.102-.913-3.486-3.047-3.591-3.187-.105-.14-1.026-1.365-1.026-2.604 0-1.238.649-1.848.88-2.099.231-.251.503-.314.67-.314.168 0 .335.002.482.009.155.008.363-.059.568.433.21.503.714 1.743.777 1.87.063.126.105.273.021.44-.084.168-.126.273-.251.419-.126.147-.264.328-.377.44-.126.126-.258.263-.111.515.147.251.652 1.077 1.398 1.742.96.856 1.769 1.121 2.021 1.247.252.126.4-.021.546-.147.147-.126.63-.733.797-.985.168-.252.336-.21.567-.126.231.084 1.468.692 1.72.818.252.126.42.189.482.293.063.105.063.609-.083 1.02z"/></svg></a>` : '',
571
+ ].filter(Boolean).join('');
572
+
573
+ return `
574
+ <div class="footer-comp footer-comp-social" id="${escapeHtml(comp.id)}" style="margin-top: 16px;">
575
+ ${heading}
576
+ <div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">${links}</div>
577
+ </div>
578
+ `;
579
+ }
580
+ case 'newsletter': {
581
+ const heading = compSettings.heading
582
+ ? `<h4 style="font-size: 13px; font-weight: 700; color: ${headingColor}; margin-bottom: 12px;">${escapeHtml(compSettings.heading)}</h4>`
583
+ : '';
584
+ const desc = compSettings.description
585
+ ? `<p style="font-size: 13px; line-height: 1.5; color: ${textColor}; margin-bottom: 14px;">${escapeHtml(compSettings.description)}</p>`
586
+ : '';
587
+ const placeholder = compSettings.placeholder || 'Enter your email';
588
+ const btnText = compSettings.buttonText || 'Subscribe';
589
+ return `
590
+ <div class="footer-comp footer-comp-newsletter" id="${escapeHtml(comp.id)}">
591
+ ${heading}
592
+ ${desc}
593
+ <form action="/_api/newsletter" method="POST" class="js-newsletter-form" style="display: flex; gap: 6px;">
594
+ <input type="email" name="email" required placeholder="${escapeHtml(placeholder)}" style="flex: 1; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06); color: #fff; font-size: 13px;" />
595
+ <button type="submit" style="padding: 8px 16px; border-radius: 8px; border: none; background: #e5b95c; color: #14100e; font-weight: 700; font-size: 13px; cursor: pointer;">${escapeHtml(btnText)}</button>
596
+ </form>
597
+ </div>
598
+ `;
599
+ }
600
+ case 'payment-methods': {
601
+ const heading = compSettings.heading
602
+ ? `<h4 style="font-size: 13px; font-weight: 700; color: ${headingColor}; margin-bottom: 14px;">${escapeHtml(compSettings.heading)}</h4>`
603
+ : '';
604
+ const methods = Array.isArray(compSettings.methods) && compSettings.methods.length > 0
605
+ ? compSettings.methods
606
+ : ['VISA', 'Mastercard', 'UPI', 'Paytm'];
607
+ const badgeStyle = 'display: inline-flex; align-items: center; justify-content: center; height: 26px; padding: 0 9px; background: #ffffff; border-radius: 5px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.02em; color: #111827;';
608
+ return `
609
+ <div class="footer-comp footer-comp-payments" id="${escapeHtml(comp.id)}">
610
+ ${heading}
611
+ <div style="display: flex; gap: 6px; flex-wrap: wrap; align-items: center;">
612
+ ${methods.map((m: string) => `<span style="${badgeStyle}">${escapeHtml(m)}</span>`).join('')}
613
+ </div>
614
+ </div>
615
+ `;
616
+ }
617
+ case 'custom-text': {
618
+ const heading = compSettings.heading
619
+ ? `<h4 style="font-size: 13px; font-weight: 700; color: ${headingColor}; margin-bottom: 12px;">${escapeHtml(compSettings.heading)}</h4>`
620
+ : '';
621
+ const content = compSettings.content || '';
622
+ return `
623
+ <div class="footer-comp footer-comp-custom-text" id="${escapeHtml(comp.id)}">
624
+ ${heading}
625
+ <div style="font-size: 13px; line-height: 1.6; color: ${textColor};">${escapeHtml(content)}</div>
626
+ </div>
627
+ `;
628
+ }
629
+ default:
630
+ return '';
631
+ }
632
+ })
633
+ .join('');
634
+
635
+ return `
636
+ <div class="footer-col" id="${escapeHtml(col.id)}" style="flex: 1 1 ${flexBasis}; min-width: 170px; box-sizing: border-box; padding: 0 14px 24px 14px;">
637
+ ${compsHtml}
638
+ </div>
639
+ `;
640
+ })
641
+ .join('');
642
+
643
+ return `
644
+ <div class="footer-row" id="${escapeHtml(row.id)}" style="display: flex; flex-wrap: wrap; margin: 0 -14px;">
645
+ ${colsHtml}
646
+ </div>
647
+ `;
648
+ })
649
+ .join('');
650
+
651
+ const legalLinks: Array<{ label: string; url: string }> = Array.isArray(settings.legalLinks)
652
+ ? settings.legalLinks
653
+ : (Array.isArray((bottomBar as any)?.legalLinks) ? (bottomBar as any).legalLinks : []);
654
+
655
+ let bottomBarHtml = '';
656
+ const showBottomBar = bottomBar ? bottomBar.enabled !== false : true;
657
+ if (showBottomBar) {
658
+ const bottomBg = bottomBar?.backgroundColor || '#090706';
659
+ const bottomText = bottomBar?.textColor || textColor || '#78716c';
660
+ const showPayments =
661
+ settings.showPaymentIcons !== undefined
662
+ ? Boolean(settings.showPaymentIcons)
663
+ : Boolean(bottomBar?.showPaymentIcons);
664
+
665
+ bottomBarHtml = `
666
+ <div class="footer-bottom-bar" style="background-color: ${bottomBg}; padding: 16px 0; border-top: 1px solid ${styling.dividerColor || 'rgba(255,255,255,0.08)'};">
667
+ <div style="max-width: 1360px; margin: 0 auto; padding: 0 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 12px; color: ${bottomText};">
668
+ <div data-footer-copyright="true">${escapeHtml(copyText)}</div>
669
+ <div style="display: flex; gap: 12px; align-items: center;">
670
+ ${legalLinks.length > 0
671
+ ? legalLinks
672
+ .map(
673
+ (l, idx) =>
674
+ `${idx > 0 ? '<span style="opacity: 0.35;">|</span>' : ''}<a href="${sanitizeNavUrl(l.url, '#')}" style="color: ${bottomText}; text-decoration: none;">${escapeHtml(l.label)}</a>`,
675
+ )
676
+ .join('')
677
+ : showPayments
678
+ ? `<div style="display: flex; gap: 6px;">
679
+ <span style="font-size: 10px; padding: 2px 6px; background: #fff; color: #111827; font-weight: 700; border-radius: 3px;">VISA</span>
680
+ <span style="font-size: 10px; padding: 2px 6px; background: #fff; color: #111827; font-weight: 700; border-radius: 3px;">MC</span>
681
+ <span style="font-size: 10px; padding: 2px 6px; background: #fff; color: #111827; font-weight: 700; border-radius: 3px;">UPI</span>
682
+ </div>`
683
+ : ''}
684
+ </div>
685
+ </div>
686
+ </div>
687
+ `;
688
+ }
689
+
690
+ const showBrandStrip = settings.showLogo !== false && !hasExplicitLogoComponent && (resolvedLogoUrl || resolvedStoreName);
691
+ const brandHeaderHtml = showBrandStrip
692
+ ? `
693
+ <div class="footer-brand-strip" style="display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 28px; margin-bottom: 28px; border-bottom: 1px solid ${styling.dividerColor || 'rgba(255,255,255,0.08)'};">
694
+ <a href="/" style="display: inline-flex; align-items: center; gap: 12px; text-decoration: none;">
695
+ ${resolvedLogoUrl ? `<img src="${escapeHtml(resolvedLogoUrl)}" alt="${escapeHtml(resolvedStoreName)}" style="max-width: ${resolvedLogoWidth}px; max-height: 44px; width: auto; height: auto; object-fit: contain;" />` : ''}
696
+ <span style="font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: ${headingColor};">${escapeHtml(resolvedStoreName)}</span>
697
+ </a>
698
+ ${brandTagline ? `<p style="margin: 0; font-size: 13px; color: ${textColor}; max-width: 460px;">${escapeHtml(brandTagline)}</p>` : ''}
699
+ </div>
700
+ `
701
+ : '';
702
+
703
+ const hasNewsletterInGrid = (config.rows || []).some((row) =>
704
+ (row.columns || []).some((col) =>
705
+ (col.components || []).some((c) => c.type === 'newsletter'),
706
+ ),
707
+ );
708
+ const newsletterStripHtml = hasNewsletterInGrid
709
+ ? ''
710
+ : renderNewsletterTopStrip(
711
+ settings,
712
+ headingColor,
713
+ textColor,
714
+ settings.accentColor || styling.linkHoverColor || '#e5b95c',
715
+ styling.dividerColor || 'rgba(255,255,255,0.08)',
716
+ );
717
+
718
+ return `
719
+ <footer id="${escapeHtml(section.id || 'sec_global_footer')}" class="theme-footer-builder" data-section-id="${escapeHtml(section.id || 'sec_global_footer')}" data-section-type="footer-builder" data-region="footer" style="background-color: ${bgColor}; color: ${textColor}; border-top: ${borderTop};">
720
+ <div style="max-width: 1360px; margin: 0 auto; padding: ${paddingTop} 24px ${paddingBottom} 24px;">
721
+ ${newsletterStripHtml}
722
+ ${brandHeaderHtml}
723
+ ${rowsHtml}
724
+ </div>
725
+ ${bottomBarHtml}
726
+ </footer>
727
+ `.trim();
728
+ }