@marvalt/dstyler 0.1.3

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 (69) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +34 -0
  3. package/dist/components/AutoBlock.d.ts +14 -0
  4. package/dist/components/AutoBlock.d.ts.map +1 -0
  5. package/dist/components/AutoSection.d.ts +15 -0
  6. package/dist/components/AutoSection.d.ts.map +1 -0
  7. package/dist/components/StyledPage.d.ts +18 -0
  8. package/dist/components/StyledPage.d.ts.map +1 -0
  9. package/dist/components/index.d.ts +10 -0
  10. package/dist/components/index.d.ts.map +1 -0
  11. package/dist/engine/detectSections.d.ts +23 -0
  12. package/dist/engine/detectSections.d.ts.map +1 -0
  13. package/dist/engine/index.d.ts +10 -0
  14. package/dist/engine/index.d.ts.map +1 -0
  15. package/dist/engine/renderBlock.d.ts +15 -0
  16. package/dist/engine/renderBlock.d.ts.map +1 -0
  17. package/dist/engine/selectTemplate.d.ts +14 -0
  18. package/dist/engine/selectTemplate.d.ts.map +1 -0
  19. package/dist/index.d.ts +288 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.esm.js +931 -0
  22. package/dist/index.esm.js.map +1 -0
  23. package/dist/index.js +947 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/providers/ThemeProvider.d.ts +14 -0
  26. package/dist/providers/ThemeProvider.d.ts.map +1 -0
  27. package/dist/providers/index.d.ts +8 -0
  28. package/dist/providers/index.d.ts.map +1 -0
  29. package/dist/templates/FooterMinimal.d.ts +14 -0
  30. package/dist/templates/FooterMinimal.d.ts.map +1 -0
  31. package/dist/templates/HeroDefault.d.ts +14 -0
  32. package/dist/templates/HeroDefault.d.ts.map +1 -0
  33. package/dist/templates/SectionBase.d.ts +14 -0
  34. package/dist/templates/SectionBase.d.ts.map +1 -0
  35. package/dist/templates/SectionWave.d.ts +16 -0
  36. package/dist/templates/SectionWave.d.ts.map +1 -0
  37. package/dist/templates/blocks/BlockButton.d.ts +10 -0
  38. package/dist/templates/blocks/BlockButton.d.ts.map +1 -0
  39. package/dist/templates/blocks/BlockForm.d.ts +10 -0
  40. package/dist/templates/blocks/BlockForm.d.ts.map +1 -0
  41. package/dist/templates/blocks/BlockImage.d.ts +10 -0
  42. package/dist/templates/blocks/BlockImage.d.ts.map +1 -0
  43. package/dist/templates/blocks/BlockText.d.ts +10 -0
  44. package/dist/templates/blocks/BlockText.d.ts.map +1 -0
  45. package/dist/templates/blocks/index.d.ts +11 -0
  46. package/dist/templates/blocks/index.d.ts.map +1 -0
  47. package/dist/templates/index.d.ts +11 -0
  48. package/dist/templates/index.d.ts.map +1 -0
  49. package/dist/tokens/css-vars.d.ts +12 -0
  50. package/dist/tokens/css-vars.d.ts.map +1 -0
  51. package/dist/tokens/index.d.ts +10 -0
  52. package/dist/tokens/index.d.ts.map +1 -0
  53. package/dist/tokens/tokens.d.ts +9 -0
  54. package/dist/tokens/tokens.d.ts.map +1 -0
  55. package/dist/tokens/wordpress-to-tokens.d.ts +12 -0
  56. package/dist/tokens/wordpress-to-tokens.d.ts.map +1 -0
  57. package/dist/types/block.d.ts +12 -0
  58. package/dist/types/block.d.ts.map +1 -0
  59. package/dist/types/index.d.ts +10 -0
  60. package/dist/types/index.d.ts.map +1 -0
  61. package/dist/types/section.d.ts +22 -0
  62. package/dist/types/section.d.ts.map +1 -0
  63. package/dist/types/theme.d.ts +58 -0
  64. package/dist/types/theme.d.ts.map +1 -0
  65. package/dist/utils/index.d.ts +8 -0
  66. package/dist/utils/index.d.ts.map +1 -0
  67. package/dist/utils/responsive.d.ts +11 -0
  68. package/dist/utils/responsive.d.ts.map +1 -0
  69. package/package.json +68 -0
@@ -0,0 +1,931 @@
1
+ import require$$0, { useEffect } from 'react';
2
+
3
+ var jsxRuntime = {exports: {}};
4
+
5
+ var reactJsxRuntime_production = {};
6
+
7
+ /**
8
+ * @license React
9
+ * react-jsx-runtime.production.js
10
+ *
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+
17
+ var hasRequiredReactJsxRuntime_production;
18
+
19
+ function requireReactJsxRuntime_production () {
20
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
21
+ hasRequiredReactJsxRuntime_production = 1;
22
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
23
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
24
+ function jsxProd(type, config, maybeKey) {
25
+ var key = null;
26
+ void 0 !== maybeKey && (key = "" + maybeKey);
27
+ void 0 !== config.key && (key = "" + config.key);
28
+ if ("key" in config) {
29
+ maybeKey = {};
30
+ for (var propName in config)
31
+ "key" !== propName && (maybeKey[propName] = config[propName]);
32
+ } else maybeKey = config;
33
+ config = maybeKey.ref;
34
+ return {
35
+ $$typeof: REACT_ELEMENT_TYPE,
36
+ type: type,
37
+ key: key,
38
+ ref: void 0 !== config ? config : null,
39
+ props: maybeKey
40
+ };
41
+ }
42
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
43
+ reactJsxRuntime_production.jsx = jsxProd;
44
+ reactJsxRuntime_production.jsxs = jsxProd;
45
+ return reactJsxRuntime_production;
46
+ }
47
+
48
+ var reactJsxRuntime_development = {};
49
+
50
+ /**
51
+ * @license React
52
+ * react-jsx-runtime.development.js
53
+ *
54
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
55
+ *
56
+ * This source code is licensed under the MIT license found in the
57
+ * LICENSE file in the root directory of this source tree.
58
+ */
59
+
60
+ var hasRequiredReactJsxRuntime_development;
61
+
62
+ function requireReactJsxRuntime_development () {
63
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
64
+ hasRequiredReactJsxRuntime_development = 1;
65
+ "production" !== process.env.NODE_ENV &&
66
+ (function () {
67
+ function getComponentNameFromType(type) {
68
+ if (null == type) return null;
69
+ if ("function" === typeof type)
70
+ return type.$$typeof === REACT_CLIENT_REFERENCE
71
+ ? null
72
+ : type.displayName || type.name || null;
73
+ if ("string" === typeof type) return type;
74
+ switch (type) {
75
+ case REACT_FRAGMENT_TYPE:
76
+ return "Fragment";
77
+ case REACT_PROFILER_TYPE:
78
+ return "Profiler";
79
+ case REACT_STRICT_MODE_TYPE:
80
+ return "StrictMode";
81
+ case REACT_SUSPENSE_TYPE:
82
+ return "Suspense";
83
+ case REACT_SUSPENSE_LIST_TYPE:
84
+ return "SuspenseList";
85
+ case REACT_ACTIVITY_TYPE:
86
+ return "Activity";
87
+ }
88
+ if ("object" === typeof type)
89
+ switch (
90
+ ("number" === typeof type.tag &&
91
+ console.error(
92
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
93
+ ),
94
+ type.$$typeof)
95
+ ) {
96
+ case REACT_PORTAL_TYPE:
97
+ return "Portal";
98
+ case REACT_CONTEXT_TYPE:
99
+ return type.displayName || "Context";
100
+ case REACT_CONSUMER_TYPE:
101
+ return (type._context.displayName || "Context") + ".Consumer";
102
+ case REACT_FORWARD_REF_TYPE:
103
+ var innerType = type.render;
104
+ type = type.displayName;
105
+ type ||
106
+ ((type = innerType.displayName || innerType.name || ""),
107
+ (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
108
+ return type;
109
+ case REACT_MEMO_TYPE:
110
+ return (
111
+ (innerType = type.displayName || null),
112
+ null !== innerType
113
+ ? innerType
114
+ : getComponentNameFromType(type.type) || "Memo"
115
+ );
116
+ case REACT_LAZY_TYPE:
117
+ innerType = type._payload;
118
+ type = type._init;
119
+ try {
120
+ return getComponentNameFromType(type(innerType));
121
+ } catch (x) {}
122
+ }
123
+ return null;
124
+ }
125
+ function testStringCoercion(value) {
126
+ return "" + value;
127
+ }
128
+ function checkKeyStringCoercion(value) {
129
+ try {
130
+ testStringCoercion(value);
131
+ var JSCompiler_inline_result = !1;
132
+ } catch (e) {
133
+ JSCompiler_inline_result = true;
134
+ }
135
+ if (JSCompiler_inline_result) {
136
+ JSCompiler_inline_result = console;
137
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
138
+ var JSCompiler_inline_result$jscomp$0 =
139
+ ("function" === typeof Symbol &&
140
+ Symbol.toStringTag &&
141
+ value[Symbol.toStringTag]) ||
142
+ value.constructor.name ||
143
+ "Object";
144
+ JSCompiler_temp_const.call(
145
+ JSCompiler_inline_result,
146
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
147
+ JSCompiler_inline_result$jscomp$0
148
+ );
149
+ return testStringCoercion(value);
150
+ }
151
+ }
152
+ function getTaskName(type) {
153
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
154
+ if (
155
+ "object" === typeof type &&
156
+ null !== type &&
157
+ type.$$typeof === REACT_LAZY_TYPE
158
+ )
159
+ return "<...>";
160
+ try {
161
+ var name = getComponentNameFromType(type);
162
+ return name ? "<" + name + ">" : "<...>";
163
+ } catch (x) {
164
+ return "<...>";
165
+ }
166
+ }
167
+ function getOwner() {
168
+ var dispatcher = ReactSharedInternals.A;
169
+ return null === dispatcher ? null : dispatcher.getOwner();
170
+ }
171
+ function UnknownOwner() {
172
+ return Error("react-stack-top-frame");
173
+ }
174
+ function hasValidKey(config) {
175
+ if (hasOwnProperty.call(config, "key")) {
176
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
177
+ if (getter && getter.isReactWarning) return false;
178
+ }
179
+ return void 0 !== config.key;
180
+ }
181
+ function defineKeyPropWarningGetter(props, displayName) {
182
+ function warnAboutAccessingKey() {
183
+ specialPropKeyWarningShown ||
184
+ ((specialPropKeyWarningShown = true),
185
+ console.error(
186
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
187
+ displayName
188
+ ));
189
+ }
190
+ warnAboutAccessingKey.isReactWarning = true;
191
+ Object.defineProperty(props, "key", {
192
+ get: warnAboutAccessingKey,
193
+ configurable: true
194
+ });
195
+ }
196
+ function elementRefGetterWithDeprecationWarning() {
197
+ var componentName = getComponentNameFromType(this.type);
198
+ didWarnAboutElementRef[componentName] ||
199
+ ((didWarnAboutElementRef[componentName] = true),
200
+ console.error(
201
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
202
+ ));
203
+ componentName = this.props.ref;
204
+ return void 0 !== componentName ? componentName : null;
205
+ }
206
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
207
+ var refProp = props.ref;
208
+ type = {
209
+ $$typeof: REACT_ELEMENT_TYPE,
210
+ type: type,
211
+ key: key,
212
+ props: props,
213
+ _owner: owner
214
+ };
215
+ null !== (void 0 !== refProp ? refProp : null)
216
+ ? Object.defineProperty(type, "ref", {
217
+ enumerable: false,
218
+ get: elementRefGetterWithDeprecationWarning
219
+ })
220
+ : Object.defineProperty(type, "ref", { enumerable: false, value: null });
221
+ type._store = {};
222
+ Object.defineProperty(type._store, "validated", {
223
+ configurable: false,
224
+ enumerable: false,
225
+ writable: true,
226
+ value: 0
227
+ });
228
+ Object.defineProperty(type, "_debugInfo", {
229
+ configurable: false,
230
+ enumerable: false,
231
+ writable: true,
232
+ value: null
233
+ });
234
+ Object.defineProperty(type, "_debugStack", {
235
+ configurable: false,
236
+ enumerable: false,
237
+ writable: true,
238
+ value: debugStack
239
+ });
240
+ Object.defineProperty(type, "_debugTask", {
241
+ configurable: false,
242
+ enumerable: false,
243
+ writable: true,
244
+ value: debugTask
245
+ });
246
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
247
+ return type;
248
+ }
249
+ function jsxDEVImpl(
250
+ type,
251
+ config,
252
+ maybeKey,
253
+ isStaticChildren,
254
+ debugStack,
255
+ debugTask
256
+ ) {
257
+ var children = config.children;
258
+ if (void 0 !== children)
259
+ if (isStaticChildren)
260
+ if (isArrayImpl(children)) {
261
+ for (
262
+ isStaticChildren = 0;
263
+ isStaticChildren < children.length;
264
+ isStaticChildren++
265
+ )
266
+ validateChildKeys(children[isStaticChildren]);
267
+ Object.freeze && Object.freeze(children);
268
+ } else
269
+ console.error(
270
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
271
+ );
272
+ else validateChildKeys(children);
273
+ if (hasOwnProperty.call(config, "key")) {
274
+ children = getComponentNameFromType(type);
275
+ var keys = Object.keys(config).filter(function (k) {
276
+ return "key" !== k;
277
+ });
278
+ isStaticChildren =
279
+ 0 < keys.length
280
+ ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
281
+ : "{key: someKey}";
282
+ didWarnAboutKeySpread[children + isStaticChildren] ||
283
+ ((keys =
284
+ 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
285
+ console.error(
286
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
287
+ isStaticChildren,
288
+ children,
289
+ keys,
290
+ children
291
+ ),
292
+ (didWarnAboutKeySpread[children + isStaticChildren] = true));
293
+ }
294
+ children = null;
295
+ void 0 !== maybeKey &&
296
+ (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
297
+ hasValidKey(config) &&
298
+ (checkKeyStringCoercion(config.key), (children = "" + config.key));
299
+ if ("key" in config) {
300
+ maybeKey = {};
301
+ for (var propName in config)
302
+ "key" !== propName && (maybeKey[propName] = config[propName]);
303
+ } else maybeKey = config;
304
+ children &&
305
+ defineKeyPropWarningGetter(
306
+ maybeKey,
307
+ "function" === typeof type
308
+ ? type.displayName || type.name || "Unknown"
309
+ : type
310
+ );
311
+ return ReactElement(
312
+ type,
313
+ children,
314
+ maybeKey,
315
+ getOwner(),
316
+ debugStack,
317
+ debugTask
318
+ );
319
+ }
320
+ function validateChildKeys(node) {
321
+ isValidElement(node)
322
+ ? node._store && (node._store.validated = 1)
323
+ : "object" === typeof node &&
324
+ null !== node &&
325
+ node.$$typeof === REACT_LAZY_TYPE &&
326
+ ("fulfilled" === node._payload.status
327
+ ? isValidElement(node._payload.value) &&
328
+ node._payload.value._store &&
329
+ (node._payload.value._store.validated = 1)
330
+ : node._store && (node._store.validated = 1));
331
+ }
332
+ function isValidElement(object) {
333
+ return (
334
+ "object" === typeof object &&
335
+ null !== object &&
336
+ object.$$typeof === REACT_ELEMENT_TYPE
337
+ );
338
+ }
339
+ var React = require$$0,
340
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
341
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
342
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
343
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
344
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
345
+ REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
346
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
347
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
348
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
349
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
350
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
351
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
352
+ REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
353
+ REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
354
+ ReactSharedInternals =
355
+ React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
356
+ hasOwnProperty = Object.prototype.hasOwnProperty,
357
+ isArrayImpl = Array.isArray,
358
+ createTask = console.createTask
359
+ ? console.createTask
360
+ : function () {
361
+ return null;
362
+ };
363
+ React = {
364
+ react_stack_bottom_frame: function (callStackForError) {
365
+ return callStackForError();
366
+ }
367
+ };
368
+ var specialPropKeyWarningShown;
369
+ var didWarnAboutElementRef = {};
370
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
371
+ React,
372
+ UnknownOwner
373
+ )();
374
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
375
+ var didWarnAboutKeySpread = {};
376
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
377
+ reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
378
+ var trackActualOwner =
379
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
380
+ return jsxDEVImpl(
381
+ type,
382
+ config,
383
+ maybeKey,
384
+ false,
385
+ trackActualOwner
386
+ ? Error("react-stack-top-frame")
387
+ : unknownOwnerDebugStack,
388
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
389
+ );
390
+ };
391
+ reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
392
+ var trackActualOwner =
393
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
394
+ return jsxDEVImpl(
395
+ type,
396
+ config,
397
+ maybeKey,
398
+ true,
399
+ trackActualOwner
400
+ ? Error("react-stack-top-frame")
401
+ : unknownOwnerDebugStack,
402
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
403
+ );
404
+ };
405
+ })();
406
+ return reactJsxRuntime_development;
407
+ }
408
+
409
+ if (process.env.NODE_ENV === 'production') {
410
+ jsxRuntime.exports = requireReactJsxRuntime_production();
411
+ } else {
412
+ jsxRuntime.exports = requireReactJsxRuntime_development();
413
+ }
414
+
415
+ var jsxRuntimeExports = jsxRuntime.exports;
416
+
417
+ /**
418
+ * @license GPL-3.0-or-later
419
+ *
420
+ * This file is part of the MarVAlt Open SDK.
421
+ * Copyright (c) 2025 Vibune Pty Ltd.
422
+ */
423
+ const defaultTokens = {
424
+ colors: {
425
+ primary: '#1a73e8',
426
+ secondary: '#34a853',
427
+ background: '#ffffff',
428
+ text: '#222222',
429
+ default: '#ffffff',
430
+ alternate: '#f5f5f5',
431
+ highlight: '#e8f0fe',
432
+ },
433
+ spacing: {
434
+ sm: 8,
435
+ md: 16,
436
+ lg: 32,
437
+ xl: 64,
438
+ },
439
+ typography: {
440
+ body: 'Inter, sans-serif',
441
+ heading: 'Inter, sans-serif',
442
+ scale: 1.2,
443
+ },
444
+ };
445
+
446
+ /**
447
+ * @license GPL-3.0-or-later
448
+ *
449
+ * This file is part of the MarVAlt Open SDK.
450
+ * Copyright (c) 2025 Vibune Pty Ltd.
451
+ */
452
+ /**
453
+ * Convert WordPress theme styles to design tokens
454
+ */
455
+ function convertWordPressToTokens(wpStyles) {
456
+ if (!wpStyles) {
457
+ return defaultTokens;
458
+ }
459
+ const tokens = {
460
+ ...defaultTokens,
461
+ colors: {
462
+ ...defaultTokens.colors,
463
+ ...(wpStyles.colors?.primary && { primary: wpStyles.colors.primary }),
464
+ ...(wpStyles.colors?.secondary && { secondary: wpStyles.colors.secondary }),
465
+ ...(wpStyles.colors?.text && { text: wpStyles.colors.text }),
466
+ ...(wpStyles.colors?.background && {
467
+ background: wpStyles.colors.background,
468
+ default: wpStyles.colors.background,
469
+ }),
470
+ },
471
+ typography: {
472
+ ...defaultTokens.typography,
473
+ ...(wpStyles.typography?.heading_font_family && {
474
+ heading: wpStyles.typography.heading_font_family
475
+ }),
476
+ ...(wpStyles.typography?.body_font_family && {
477
+ body: wpStyles.typography.body_font_family
478
+ }),
479
+ },
480
+ };
481
+ // Generate alternate and highlight colors from primary/background
482
+ if (tokens.colors.primary && tokens.colors.background) {
483
+ // Alternate: slightly darker/lighter than background
484
+ tokens.colors.alternate = adjustBrightness(tokens.colors.background, -0.05);
485
+ // Highlight: tinted with primary color
486
+ tokens.colors.highlight = blendColors(tokens.colors.background, tokens.colors.primary, 0.1);
487
+ }
488
+ return tokens;
489
+ }
490
+ /**
491
+ * Adjust brightness of a hex color
492
+ */
493
+ function adjustBrightness(hex, amount) {
494
+ const num = parseInt(hex.replace('#', ''), 16);
495
+ const r = Math.max(0, Math.min(255, ((num >> 16) & 0xff) + (amount * 255)));
496
+ const g = Math.max(0, Math.min(255, ((num >> 8) & 0xff) + (amount * 255)));
497
+ const b = Math.max(0, Math.min(255, (num & 0xff) + (amount * 255)));
498
+ return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')}`;
499
+ }
500
+ /**
501
+ * Blend two colors
502
+ */
503
+ function blendColors(color1, color2, ratio) {
504
+ const c1 = hexToRgb(color1);
505
+ const c2 = hexToRgb(color2);
506
+ if (!c1 || !c2)
507
+ return color1;
508
+ const r = Math.round(c1.r + (c2.r - c1.r) * ratio);
509
+ const g = Math.round(c1.g + (c2.g - c1.g) * ratio);
510
+ const b = Math.round(c1.b + (c2.b - c1.b) * ratio);
511
+ return `rgb(${r}, ${g}, ${b})`;
512
+ }
513
+ function hexToRgb(hex) {
514
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
515
+ return result
516
+ ? {
517
+ r: parseInt(result[1], 16),
518
+ g: parseInt(result[2], 16),
519
+ b: parseInt(result[3], 16),
520
+ }
521
+ : null;
522
+ }
523
+
524
+ /**
525
+ * @license GPL-3.0-or-later
526
+ *
527
+ * This file is part of the MarVAlt Open SDK.
528
+ * Copyright (c) 2025 Vibune Pty Ltd.
529
+ */
530
+ /**
531
+ * Inject CSS variables from design tokens into the document
532
+ */
533
+ function injectCSSVariables(tokens) {
534
+ if (typeof document === 'undefined')
535
+ return;
536
+ const root = document.documentElement;
537
+ // Colors
538
+ root.style.setProperty('--dstyler-color-primary', tokens.colors.primary);
539
+ root.style.setProperty('--dstyler-color-secondary', tokens.colors.secondary);
540
+ root.style.setProperty('--dstyler-color-background', tokens.colors.background);
541
+ root.style.setProperty('--dstyler-color-text', tokens.colors.text);
542
+ root.style.setProperty('--dstyler-color-default', tokens.colors.default);
543
+ root.style.setProperty('--dstyler-color-alternate', tokens.colors.alternate);
544
+ root.style.setProperty('--dstyler-color-highlight', tokens.colors.highlight);
545
+ // Spacing
546
+ root.style.setProperty('--dstyler-spacing-sm', `${tokens.spacing.sm}px`);
547
+ root.style.setProperty('--dstyler-spacing-md', `${tokens.spacing.md}px`);
548
+ root.style.setProperty('--dstyler-spacing-lg', `${tokens.spacing.lg}px`);
549
+ root.style.setProperty('--dstyler-spacing-xl', `${tokens.spacing.xl}px`);
550
+ // Typography
551
+ root.style.setProperty('--dstyler-font-body', tokens.typography.body);
552
+ root.style.setProperty('--dstyler-font-heading', tokens.typography.heading);
553
+ root.style.setProperty('--dstyler-font-scale', tokens.typography.scale.toString());
554
+ }
555
+
556
+ const ThemeProvider = ({ children, wpStyles }) => {
557
+ useEffect(() => {
558
+ const tokens = convertWordPressToTokens(wpStyles);
559
+ injectCSSVariables(tokens);
560
+ }, [wpStyles]);
561
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
562
+ };
563
+
564
+ /**
565
+ * @license GPL-3.0-or-later
566
+ *
567
+ * This file is part of the MarVAlt Open SDK.
568
+ * Copyright (c) 2025 Vibune Pty Ltd.
569
+ */
570
+ /**
571
+ * Select template component based on section properties
572
+ */
573
+ function selectTemplate(section) {
574
+ const block = section.block;
575
+ const attrs = block.attributes || {};
576
+ const className = section.customClass?.toLowerCase() || '';
577
+ // Check for hero/cover blocks
578
+ if (block.name === 'core/cover') {
579
+ return 'HeroDefault';
580
+ }
581
+ // Check for footer (could be detected by block name or class)
582
+ if (className.includes('footer') || block.name === 'core/footer') {
583
+ return 'FooterMinimal';
584
+ }
585
+ // Check for wave style
586
+ if (className.includes('wave') || attrs.style === 'wave') {
587
+ return 'SectionWave';
588
+ }
589
+ // Default section template
590
+ return 'SectionBase';
591
+ }
592
+
593
+ const SectionBase = ({ section, children }) => {
594
+ const style = section.style || 'default';
595
+ const bgColor = `var(--dstyler-color-${style})`;
596
+ const className = [
597
+ 'dstyler-section',
598
+ `dstyler-section-${style}`,
599
+ section.customClass,
600
+ ].filter(Boolean).join(' ');
601
+ return (jsxRuntimeExports.jsx("section", { className: className, id: section.customId, style: {
602
+ backgroundColor: bgColor,
603
+ padding: 'var(--dstyler-spacing-xl) var(--dstyler-spacing-md)',
604
+ }, children: jsxRuntimeExports.jsx("div", { style: {
605
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
606
+ margin: '0 auto',
607
+ }, children: children }) }));
608
+ };
609
+
610
+ const SectionWave = ({ section, children, waveTop = true, waveBottom = true, }) => {
611
+ const style = section.style || 'default';
612
+ const bgColor = `var(--dstyler-color-${style})`;
613
+ const className = [
614
+ 'dstyler-section',
615
+ 'dstyler-section-wave',
616
+ `dstyler-section-${style}`,
617
+ section.customClass,
618
+ ].filter(Boolean).join(' ');
619
+ // Wave SVG
620
+ const waveSvg = (jsxRuntimeExports.jsx("svg", { viewBox: "0 0 1440 120", preserveAspectRatio: "none", style: {
621
+ width: '100%',
622
+ height: '60px',
623
+ display: 'block',
624
+ fill: bgColor,
625
+ }, children: jsxRuntimeExports.jsx("path", { d: "M0,60 C240,0 480,120 720,60 C960,0 1200,120 1440,60 L1440,120 L0,120 Z" }) }));
626
+ return (jsxRuntimeExports.jsxs("section", { className: className, id: section.customId, style: {
627
+ backgroundColor: bgColor,
628
+ position: 'relative',
629
+ }, children: [waveTop && (jsxRuntimeExports.jsx("div", { style: { marginTop: '-1px' }, children: waveSvg })), jsxRuntimeExports.jsx("div", { style: {
630
+ padding: 'var(--dstyler-spacing-xl) var(--dstyler-spacing-md)',
631
+ }, children: jsxRuntimeExports.jsx("div", { style: {
632
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
633
+ margin: '0 auto',
634
+ }, children: children }) }), waveBottom && (jsxRuntimeExports.jsx("div", { style: { marginBottom: '-1px', transform: 'rotate(180deg)' }, children: waveSvg }))] }));
635
+ };
636
+
637
+ const HeroDefault = ({ section, children }) => {
638
+ const style = section.style || 'default';
639
+ const bgColor = `var(--dstyler-color-${style})`;
640
+ const className = [
641
+ 'dstyler-hero',
642
+ 'dstyler-hero-default',
643
+ `dstyler-hero-${style}`,
644
+ section.customClass,
645
+ ].filter(Boolean).join(' ');
646
+ return (jsxRuntimeExports.jsx("section", { className: className, id: section.customId, style: {
647
+ backgroundColor: bgColor,
648
+ padding: 'var(--dstyler-spacing-xl) var(--dstyler-spacing-md)',
649
+ minHeight: '50vh',
650
+ display: 'flex',
651
+ alignItems: 'center',
652
+ justifyContent: 'center',
653
+ }, children: jsxRuntimeExports.jsx("div", { style: {
654
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
655
+ margin: '0 auto',
656
+ textAlign: 'center',
657
+ }, children: children }) }));
658
+ };
659
+
660
+ const FooterMinimal = ({ section, children }) => {
661
+ const style = section.style || 'default';
662
+ const bgColor = `var(--dstyler-color-${style})`;
663
+ const className = [
664
+ 'dstyler-footer',
665
+ 'dstyler-footer-minimal',
666
+ `dstyler-footer-${style}`,
667
+ section.customClass,
668
+ ].filter(Boolean).join(' ');
669
+ return (jsxRuntimeExports.jsx("footer", { className: className, id: section.customId, style: {
670
+ backgroundColor: bgColor,
671
+ padding: 'var(--dstyler-spacing-lg) var(--dstyler-spacing-md)',
672
+ borderTop: '1px solid var(--dstyler-color-alternate)',
673
+ }, children: jsxRuntimeExports.jsx("div", { style: {
674
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
675
+ margin: '0 auto',
676
+ textAlign: 'center',
677
+ fontSize: '0.875rem',
678
+ color: 'var(--dstyler-color-text)',
679
+ }, children: children }) }));
680
+ };
681
+
682
+ /**
683
+ * @license GPL-3.0-or-later
684
+ *
685
+ * This file is part of the MarVAlt Open SDK.
686
+ * Copyright (c) 2025 Vibune Pty Ltd.
687
+ */
688
+ /**
689
+ * Select block renderer based on block type
690
+ */
691
+ function selectBlockRenderer(block) {
692
+ const blockName = block.name;
693
+ // Map WordPress block types to renderers
694
+ switch (blockName) {
695
+ case 'core/paragraph':
696
+ case 'core/heading':
697
+ return 'BlockText';
698
+ case 'core/image':
699
+ case 'core/gallery':
700
+ return 'BlockImage';
701
+ case 'core/button':
702
+ case 'core/buttons':
703
+ return 'BlockButton';
704
+ case 'core/html':
705
+ case 'core/shortcode':
706
+ // Check if it's a form shortcode
707
+ const attrs = block.attributes || {};
708
+ const content = attrs.content || attrs.html || '';
709
+ if (content.includes('[gravityform') || content.includes('[mauticform')) {
710
+ return 'BlockForm';
711
+ }
712
+ return 'BlockText';
713
+ default:
714
+ return 'BlockText'; // Default fallback
715
+ }
716
+ }
717
+
718
+ const BlockText = ({ block, className }) => {
719
+ const attrs = block.attributes || {};
720
+ const content = attrs.content || attrs.text || '';
721
+ const tagName = block.name === 'core/heading'
722
+ ? `h${attrs.level || 2}`
723
+ : 'p';
724
+ const Tag = tagName;
725
+ const style = {
726
+ fontFamily: 'var(--dstyler-font-body)',
727
+ color: 'var(--dstyler-color-text)',
728
+ marginBottom: 'var(--dstyler-spacing-md)',
729
+ };
730
+ if (block.name === 'core/heading') {
731
+ style.fontFamily = 'var(--dstyler-font-heading)';
732
+ style.fontSize = `calc(1rem * var(--dstyler-font-scale) * ${attrs.level || 2})`;
733
+ style.fontWeight = 'bold';
734
+ }
735
+ return (jsxRuntimeExports.jsx(Tag, { className: className, style: style, dangerouslySetInnerHTML: { __html: content } }));
736
+ };
737
+
738
+ const BlockImage = ({ block, className }) => {
739
+ const attrs = block.attributes || {};
740
+ const url = attrs.url || attrs.sourceUrl || '';
741
+ const alt = attrs.alt || attrs.altText || '';
742
+ const width = attrs.width;
743
+ const height = attrs.height;
744
+ if (!url)
745
+ return null;
746
+ const style = {
747
+ maxWidth: '100%',
748
+ height: 'auto',
749
+ marginBottom: 'var(--dstyler-spacing-md)',
750
+ borderRadius: '8px',
751
+ };
752
+ return (jsxRuntimeExports.jsx("img", { src: url, alt: alt, width: width, height: height, className: className, style: style, loading: "lazy" }));
753
+ };
754
+
755
+ const BlockButton = ({ block, className }) => {
756
+ const attrs = block.attributes || {};
757
+ const text = attrs.text || attrs.label || 'Button';
758
+ const url = attrs.url || attrs.linkUrl || '#';
759
+ const isExternal = typeof window !== 'undefined'
760
+ ? url.startsWith('http') && !url.includes(window.location.hostname)
761
+ : url.startsWith('http');
762
+ const style = {
763
+ display: 'inline-block',
764
+ padding: 'var(--dstyler-spacing-md) var(--dstyler-spacing-lg)',
765
+ backgroundColor: 'var(--dstyler-color-primary)',
766
+ color: '#ffffff',
767
+ textDecoration: 'none',
768
+ borderRadius: '4px',
769
+ fontWeight: '500',
770
+ marginBottom: 'var(--dstyler-spacing-md)',
771
+ transition: 'opacity 0.2s',
772
+ };
773
+ return (jsxRuntimeExports.jsx("a", { href: url, target: isExternal ? '_blank' : undefined, rel: isExternal ? 'noopener noreferrer' : undefined, className: className, style: style, onMouseEnter: (e) => {
774
+ e.currentTarget.style.opacity = '0.9';
775
+ }, onMouseLeave: (e) => {
776
+ e.currentTarget.style.opacity = '1';
777
+ }, children: text }));
778
+ };
779
+
780
+ const BlockForm = ({ block, className }) => {
781
+ const attrs = block.attributes || {};
782
+ const content = attrs.content || attrs.html || '';
783
+ // For now, just render the HTML content
784
+ // In the future, this could parse and render using Gravity Forms or Mautic components
785
+ const style = {
786
+ marginBottom: 'var(--dstyler-spacing-lg)',
787
+ };
788
+ return (jsxRuntimeExports.jsx("div", { className: className, style: style, dangerouslySetInnerHTML: { __html: content } }));
789
+ };
790
+
791
+ const AutoBlock = ({ block, registry }) => {
792
+ // If registry is provided, use it for rendering (integrates with wparser)
793
+ if (registry && registry.renderers[block.name]) {
794
+ const Renderer = registry.renderers[block.name];
795
+ return jsxRuntimeExports.jsx(Renderer, { block: block, context: { registry } });
796
+ }
797
+ // Otherwise, use dstyler's block renderers
798
+ const rendererName = selectBlockRenderer(block);
799
+ switch (rendererName) {
800
+ case 'BlockText':
801
+ return jsxRuntimeExports.jsx(BlockText, { block: block });
802
+ case 'BlockImage':
803
+ return jsxRuntimeExports.jsx(BlockImage, { block: block });
804
+ case 'BlockButton':
805
+ return jsxRuntimeExports.jsx(BlockButton, { block: block });
806
+ case 'BlockForm':
807
+ return jsxRuntimeExports.jsx(BlockForm, { block: block });
808
+ default:
809
+ // Fallback: render block name or content
810
+ return (jsxRuntimeExports.jsx("div", { style: { marginBottom: 'var(--dstyler-spacing-md)' }, children: jsxRuntimeExports.jsxs("pre", { style: { fontSize: '0.875rem', color: '#666' }, children: [block.name, ": ", JSON.stringify(block.attributes, null, 2)] }) }));
811
+ }
812
+ };
813
+
814
+ const AutoSection = ({ section, registry }) => {
815
+ const templateName = selectTemplate(section);
816
+ // Render blocks using AutoBlock or registry
817
+ const renderBlocks = () => {
818
+ if (registry) {
819
+ // Use registry for block rendering (integrates with wparser)
820
+ return section.blocks.map((block, index) => (jsxRuntimeExports.jsx(AutoBlock, { block: block, registry: registry }, `${block.name}-${index}`)));
821
+ }
822
+ // Fallback to simple block rendering
823
+ return section.blocks.map((block, index) => (jsxRuntimeExports.jsx(AutoBlock, { block: block }, `${block.name}-${index}`)));
824
+ };
825
+ // Select template component
826
+ switch (templateName) {
827
+ case 'SectionWave': {
828
+ const className = section.customClass?.toLowerCase() || '';
829
+ const waveTop = className.includes('wave-top') || !className.includes('wave-bottom');
830
+ const waveBottom = className.includes('wave-bottom') || !className.includes('wave-top');
831
+ return (jsxRuntimeExports.jsx(SectionWave, { section: section, waveTop: waveTop, waveBottom: waveBottom, children: renderBlocks() }));
832
+ }
833
+ case 'HeroDefault':
834
+ return (jsxRuntimeExports.jsx(HeroDefault, { section: section, children: renderBlocks() }));
835
+ case 'FooterMinimal':
836
+ return (jsxRuntimeExports.jsx(FooterMinimal, { section: section, children: renderBlocks() }));
837
+ default:
838
+ return (jsxRuntimeExports.jsx(SectionBase, { section: section, children: renderBlocks() }));
839
+ }
840
+ };
841
+
842
+ /**
843
+ * @license GPL-3.0-or-later
844
+ *
845
+ * This file is part of the MarVAlt Open SDK.
846
+ * Copyright (c) 2025 Vibune Pty Ltd.
847
+ */
848
+ /**
849
+ * Detect sections from WordPress blocks
850
+ * Sections are defined by core/group blocks (with or without alignment)
851
+ * Sub-sections are core/columns blocks inside groups
852
+ */
853
+ function detectSections(blocks) {
854
+ const sections = [];
855
+ let sectionIndex = 0;
856
+ for (const block of blocks) {
857
+ // core/group blocks are sections
858
+ if (block.name === 'core/group') {
859
+ const attrs = block.attributes || {};
860
+ const className = attrs.className;
861
+ const customId = attrs.id;
862
+ // Extract blocks from innerBlocks
863
+ const innerBlocks = block.innerBlocks || [];
864
+ sections.push({
865
+ id: `section-${sectionIndex}`,
866
+ type: 'section',
867
+ block,
868
+ blocks: innerBlocks,
869
+ index: sectionIndex,
870
+ customClass: className,
871
+ customId,
872
+ });
873
+ sectionIndex++;
874
+ }
875
+ }
876
+ return sections;
877
+ }
878
+ /**
879
+ * Determine section style based on alternating logic and custom classes
880
+ * Rules:
881
+ * - default is always first
882
+ * - after default follows alternate
883
+ * - highlight resets - next section is default
884
+ */
885
+ function determineSectionStyle(section, previousStyle) {
886
+ const className = section.customClass?.toLowerCase() || '';
887
+ // Check for custom class overrides first
888
+ if (className.includes('highlight') || className.includes('highlight-section')) {
889
+ return 'highlight';
890
+ }
891
+ if (className.includes('dark') || className.includes('dark-section')) {
892
+ return 'alternate';
893
+ }
894
+ if (className.includes('default') || className.includes('default-section')) {
895
+ return 'default';
896
+ }
897
+ // Alternating logic
898
+ if (section.index === 0) {
899
+ return 'default';
900
+ }
901
+ if (previousStyle === 'highlight') {
902
+ return 'default';
903
+ }
904
+ if (previousStyle === 'default') {
905
+ return 'alternate';
906
+ }
907
+ if (previousStyle === 'alternate') {
908
+ return 'default';
909
+ }
910
+ return 'default';
911
+ }
912
+
913
+ const StyledPage = ({ page, registry }) => {
914
+ const blocks = page.blocks || [];
915
+ // Detect sections from blocks
916
+ const sections = detectSections(blocks);
917
+ // Apply alternating style logic
918
+ let previousStyle;
919
+ const styledSections = sections.map((section) => {
920
+ const style = determineSectionStyle(section, previousStyle);
921
+ previousStyle = style;
922
+ return {
923
+ ...section,
924
+ style,
925
+ };
926
+ });
927
+ return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: styledSections.map((section) => (jsxRuntimeExports.jsx(AutoSection, { section: section, registry: registry }, section.id))) }));
928
+ };
929
+
930
+ export { AutoBlock, AutoSection, FooterMinimal, HeroDefault, SectionBase, SectionWave, StyledPage, ThemeProvider, convertWordPressToTokens, defaultTokens, detectSections, determineSectionStyle, injectCSSVariables, selectBlockRenderer, selectTemplate };
931
+ //# sourceMappingURL=index.esm.js.map