@orion-studios/payload-studio 0.5.0-beta.98 → 0.6.0-beta.1

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 (63) hide show
  1. package/README.md +58 -68
  2. package/dist/admin/client.d.mts +5 -0
  3. package/dist/admin/client.d.ts +5 -0
  4. package/dist/admin/client.js +4491 -736
  5. package/dist/admin/client.mjs +3367 -752
  6. package/dist/admin/index.d.mts +2 -1
  7. package/dist/admin/index.d.ts +2 -1
  8. package/dist/admin/index.js +498 -53
  9. package/dist/admin/index.mjs +2 -1
  10. package/dist/admin-app/client.d.mts +1 -0
  11. package/dist/admin-app/client.d.ts +1 -0
  12. package/dist/admin-app/client.js +285 -109
  13. package/dist/admin-app/client.mjs +59 -871
  14. package/dist/admin-app/index.d.mts +2 -1
  15. package/dist/admin-app/index.d.ts +2 -1
  16. package/dist/admin-app/index.mjs +5 -3
  17. package/dist/admin-app/styles.css +1708 -56
  18. package/dist/admin.css +158 -35
  19. package/dist/blocks/index.js +415 -200
  20. package/dist/blocks/index.mjs +2 -2
  21. package/dist/{chunk-XK3K5GRP.mjs → chunk-JQAHXYAM.mjs} +271 -67
  22. package/dist/chunk-KPIX7OSV.mjs +1051 -0
  23. package/dist/chunk-OQSEJXC4.mjs +166 -0
  24. package/dist/{chunk-XHWQJUX5.mjs → chunk-OTHERBGX.mjs} +3 -3
  25. package/dist/chunk-PF3EBZXF.mjs +326 -0
  26. package/dist/chunk-Q2HGC67S.mjs +904 -0
  27. package/dist/{chunk-XVH5SCBD.mjs → chunk-RKTIFEUY.mjs} +4 -19
  28. package/dist/chunk-W2UOCJDX.mjs +32 -0
  29. package/dist/{chunk-C4J35SPJ.mjs → chunk-XKUTZ7IU.mjs} +257 -452
  30. package/dist/{index-ZbOx4OCF.d.ts → index-52HdVLQq.d.ts} +12 -22
  31. package/dist/index-BMitiKK8.d.ts +435 -0
  32. package/dist/index-Crx_MtPw.d.ts +223 -0
  33. package/dist/index-Cv-6qnrw.d.mts +223 -0
  34. package/dist/{index-ZbOx4OCF.d.mts → index-DEQC3Dwj.d.mts} +12 -22
  35. package/dist/{index-BIwu3qIH.d.mts → index-DWmudwDm.d.mts} +2 -1
  36. package/dist/{index-BIwu3qIH.d.ts → index-DWmudwDm.d.ts} +2 -1
  37. package/dist/index-D_b24Gef.d.mts +435 -0
  38. package/dist/index.d.mts +5 -4
  39. package/dist/index.d.ts +5 -4
  40. package/dist/index.js +1968 -1198
  41. package/dist/index.mjs +10 -8
  42. package/dist/nextjs/index.js +5 -684
  43. package/dist/nextjs/index.mjs +2 -3
  44. package/dist/sitePreviewTypes-BkHCWxNW.d.mts +58 -0
  45. package/dist/sitePreviewTypes-BkHCWxNW.d.ts +58 -0
  46. package/dist/studio/index.d.mts +1 -1
  47. package/dist/studio/index.d.ts +1 -1
  48. package/dist/studio-pages/builder.css +125 -83
  49. package/dist/studio-pages/client.d.mts +58 -1
  50. package/dist/studio-pages/client.d.ts +58 -1
  51. package/dist/studio-pages/client.js +450 -241
  52. package/dist/studio-pages/client.mjs +455 -247
  53. package/dist/studio-pages/index.d.mts +3 -2
  54. package/dist/studio-pages/index.d.ts +3 -2
  55. package/dist/studio-pages/index.js +418 -183
  56. package/dist/studio-pages/index.mjs +15 -6
  57. package/package.json +19 -5
  58. package/dist/chunk-2FO2ROW4.mjs +0 -468
  59. package/dist/chunk-SIL2J5MF.mjs +0 -155
  60. package/dist/index-BFXZue5i.d.ts +0 -178
  61. package/dist/index-CoYRBbf6.d.mts +0 -178
  62. package/dist/index-R7hA134j.d.mts +0 -140
  63. package/dist/index-vjrjy0P4.d.ts +0 -140
@@ -0,0 +1,166 @@
1
+ // src/blocks/blocks/sectionStyleFields.ts
2
+ var sectionStyleDefaults = {
3
+ contentBackgroundColor: "#ffffff",
4
+ contentBackgroundMode: "none",
5
+ contentGradientAngle: "135",
6
+ contentGradientFrom: "#ffffff",
7
+ contentGradientPreset: "none",
8
+ contentGradientTo: "#f4f6f8",
9
+ contentWidth: "inherit",
10
+ sectionPaddingX: "inherit",
11
+ sectionBackgroundColor: "#ffffff",
12
+ sectionBackgroundMode: "none",
13
+ sectionGradientAngle: "135",
14
+ sectionGradientFrom: "#334b63",
15
+ sectionGradientPreset: "slate",
16
+ sectionGradientTo: "#496582",
17
+ sectionPaddingY: "md",
18
+ sectionWidth: "content"
19
+ };
20
+ var hideFromCMS = (field) => ({
21
+ ...field,
22
+ admin: {
23
+ ...field.admin || {},
24
+ hidden: true
25
+ }
26
+ });
27
+ var sectionStyleFields = () => {
28
+ const fields = [
29
+ {
30
+ name: "sectionWidth",
31
+ type: "select",
32
+ defaultValue: sectionStyleDefaults.sectionWidth,
33
+ options: [
34
+ { label: "Content", value: "content" },
35
+ { label: "Wide", value: "wide" },
36
+ { label: "Full", value: "full" }
37
+ ]
38
+ },
39
+ {
40
+ name: "contentWidth",
41
+ type: "select",
42
+ defaultValue: sectionStyleDefaults.contentWidth,
43
+ options: [
44
+ { label: "Inherit", value: "inherit" },
45
+ { label: "Narrow", value: "narrow" },
46
+ { label: "Content", value: "content" },
47
+ { label: "Wide", value: "wide" },
48
+ { label: "Full", value: "full" }
49
+ ]
50
+ },
51
+ {
52
+ name: "sectionPaddingY",
53
+ type: "select",
54
+ defaultValue: sectionStyleDefaults.sectionPaddingY,
55
+ options: [
56
+ { label: "None", value: "none" },
57
+ { label: "Small", value: "sm" },
58
+ { label: "Medium", value: "md" },
59
+ { label: "Large", value: "lg" }
60
+ ]
61
+ },
62
+ {
63
+ name: "sectionPaddingX",
64
+ type: "select",
65
+ defaultValue: sectionStyleDefaults.sectionPaddingX,
66
+ options: [
67
+ { label: "Inherit", value: "inherit" },
68
+ { label: "None", value: "none" },
69
+ { label: "Small", value: "sm" },
70
+ { label: "Medium", value: "md" },
71
+ { label: "Large", value: "lg" }
72
+ ]
73
+ },
74
+ {
75
+ name: "sectionBackgroundMode",
76
+ type: "select",
77
+ defaultValue: sectionStyleDefaults.sectionBackgroundMode,
78
+ options: [
79
+ { label: "None", value: "none" },
80
+ { label: "Color", value: "color" },
81
+ { label: "Gradient", value: "gradient" }
82
+ ]
83
+ },
84
+ {
85
+ name: "sectionBackgroundColor",
86
+ type: "text",
87
+ defaultValue: sectionStyleDefaults.sectionBackgroundColor
88
+ },
89
+ {
90
+ name: "sectionGradientPreset",
91
+ type: "select",
92
+ defaultValue: sectionStyleDefaults.sectionGradientPreset,
93
+ options: [
94
+ { label: "None", value: "none" },
95
+ { label: "Brand", value: "brand" },
96
+ { label: "Forest", value: "forest" },
97
+ { label: "Moss", value: "moss" },
98
+ { label: "Cream", value: "cream" },
99
+ { label: "Slate", value: "slate" }
100
+ ]
101
+ },
102
+ {
103
+ name: "sectionGradientFrom",
104
+ type: "text",
105
+ defaultValue: sectionStyleDefaults.sectionGradientFrom
106
+ },
107
+ {
108
+ name: "sectionGradientTo",
109
+ type: "text",
110
+ defaultValue: sectionStyleDefaults.sectionGradientTo
111
+ },
112
+ {
113
+ name: "sectionGradientAngle",
114
+ type: "text",
115
+ defaultValue: sectionStyleDefaults.sectionGradientAngle
116
+ },
117
+ {
118
+ name: "contentBackgroundMode",
119
+ type: "select",
120
+ defaultValue: sectionStyleDefaults.contentBackgroundMode,
121
+ options: [
122
+ { label: "None", value: "none" },
123
+ { label: "Color", value: "color" },
124
+ { label: "Gradient", value: "gradient" }
125
+ ]
126
+ },
127
+ {
128
+ name: "contentBackgroundColor",
129
+ type: "text",
130
+ defaultValue: sectionStyleDefaults.contentBackgroundColor
131
+ },
132
+ {
133
+ name: "contentGradientPreset",
134
+ type: "select",
135
+ defaultValue: sectionStyleDefaults.contentGradientPreset,
136
+ options: [
137
+ { label: "None", value: "none" },
138
+ { label: "Cloud", value: "cloud" },
139
+ { label: "Sand", value: "sand" },
140
+ { label: "Mint", value: "mint" },
141
+ { label: "Night", value: "night" }
142
+ ]
143
+ },
144
+ {
145
+ name: "contentGradientFrom",
146
+ type: "text",
147
+ defaultValue: sectionStyleDefaults.contentGradientFrom
148
+ },
149
+ {
150
+ name: "contentGradientTo",
151
+ type: "text",
152
+ defaultValue: sectionStyleDefaults.contentGradientTo
153
+ },
154
+ {
155
+ name: "contentGradientAngle",
156
+ type: "text",
157
+ defaultValue: sectionStyleDefaults.contentGradientAngle
158
+ }
159
+ ];
160
+ return fields.map(hideFromCMS);
161
+ };
162
+
163
+ export {
164
+ sectionStyleDefaults,
165
+ sectionStyleFields
166
+ };
@@ -3,12 +3,12 @@ import {
3
3
  SOCIAL_MEDIA_PLATFORMS,
4
4
  SOCIAL_MEDIA_PLATFORM_LABELS
5
5
  } from "./chunk-ZTXJG4K5.mjs";
6
+ import {
7
+ studioDocumentToLayout
8
+ } from "./chunk-PF3EBZXF.mjs";
6
9
  import {
7
10
  assertStudioDocumentV1
8
11
  } from "./chunk-ADIIWIYL.mjs";
9
- import {
10
- studioDocumentToLayout
11
- } from "./chunk-C4J35SPJ.mjs";
12
12
  import {
13
13
  __export
14
14
  } from "./chunk-6BWS3CLP.mjs";
@@ -0,0 +1,326 @@
1
+ // src/studio-pages/builder/settings-v2/types.ts
2
+ var defaultBuilderBlockSettingsV2 = {
3
+ advanced: {
4
+ customClassName: "",
5
+ editCopyInPanel: false,
6
+ hideOnMobile: false
7
+ },
8
+ appearance: {
9
+ contentBackgroundColor: "#ffffff",
10
+ contentBackgroundMode: "none",
11
+ contentGradientAngle: "135",
12
+ contentGradientFrom: "#ffffff",
13
+ contentGradientPreset: "none",
14
+ contentGradientTo: "#f4f6f8",
15
+ sectionBackgroundColor: "#ffffff",
16
+ sectionBackgroundMode: "none",
17
+ sectionGradientAngle: "135",
18
+ sectionGradientFrom: "#334b63",
19
+ sectionGradientPreset: "slate",
20
+ sectionGradientTo: "#496582"
21
+ },
22
+ layout: {
23
+ contentWidth: "inherit",
24
+ linkHorizontalPadding: true,
25
+ linkVerticalPadding: true,
26
+ paddingBottomPt: null,
27
+ paddingLeftPt: null,
28
+ paddingRightPt: null,
29
+ paddingTopPt: null,
30
+ sectionPaddingX: "inherit",
31
+ sectionPaddingY: "md"
32
+ },
33
+ media: {
34
+ cornerStyle: "rounded",
35
+ fit: "cover",
36
+ height: null,
37
+ position: "center",
38
+ positionX: null,
39
+ positionY: null
40
+ },
41
+ typography: {
42
+ bodyAlign: "left",
43
+ headingAlign: "left",
44
+ letterSpacingPreset: "normal",
45
+ lineHeightPreset: "normal",
46
+ maxTextWidth: "auto"
47
+ },
48
+ version: 2
49
+ };
50
+ var defaultBuilderItemSettingsV2 = {
51
+ layout: {
52
+ contentWidth: "inherit",
53
+ linkHorizontalPadding: true,
54
+ linkVerticalPadding: true,
55
+ paddingBottomPt: null,
56
+ paddingLeftPt: null,
57
+ paddingRightPt: null,
58
+ paddingTopPt: null,
59
+ sectionPaddingX: "inherit",
60
+ sectionPaddingY: "md"
61
+ },
62
+ media: {
63
+ cornerStyle: "rounded",
64
+ fit: "cover",
65
+ height: null,
66
+ position: "center",
67
+ positionX: null,
68
+ positionY: null
69
+ },
70
+ typography: {
71
+ bodyAlign: "left",
72
+ headingAlign: "left",
73
+ letterSpacingPreset: "normal",
74
+ lineHeightPreset: "normal",
75
+ maxTextWidth: "auto"
76
+ },
77
+ version: 2
78
+ };
79
+ var defaultBuilderThemeTokens = {
80
+ colors: {
81
+ accent: "#334b63",
82
+ bodyText: "#425163",
83
+ headingText: "#182332",
84
+ surface: "#ffffff"
85
+ },
86
+ radii: {
87
+ card: 16,
88
+ panel: 14
89
+ },
90
+ spacing: {
91
+ sectionGap: "md",
92
+ sectionPadding: "md"
93
+ },
94
+ typography: {
95
+ bodySize: "md",
96
+ headingSize: "md"
97
+ }
98
+ };
99
+
100
+ // src/studio-pages/builder/adapters/settingsV2.ts
101
+ var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
102
+ var parsePercent = (value) => {
103
+ if (typeof value === "number" && Number.isFinite(value)) {
104
+ return Math.max(0, Math.min(100, value));
105
+ }
106
+ if (typeof value === "string" && value.trim().length > 0) {
107
+ const parsed = Number(value);
108
+ if (Number.isFinite(parsed)) {
109
+ return Math.max(0, Math.min(100, parsed));
110
+ }
111
+ }
112
+ return null;
113
+ };
114
+ var parsePixel = (value) => {
115
+ if (typeof value === "number" && Number.isFinite(value)) {
116
+ return value;
117
+ }
118
+ if (typeof value === "string" && value.trim().length > 0) {
119
+ const parsed = Number(value);
120
+ if (Number.isFinite(parsed)) {
121
+ return parsed;
122
+ }
123
+ }
124
+ return null;
125
+ };
126
+ var mergeSettings = (defaults, input) => {
127
+ if (!isRecord(input)) {
128
+ return structuredClone(defaults);
129
+ }
130
+ const next = structuredClone(defaults);
131
+ for (const [key, value] of Object.entries(input)) {
132
+ if (isRecord(value) && isRecord(next[key])) {
133
+ next[key] = mergeSettings(next[key], value);
134
+ continue;
135
+ }
136
+ if (typeof value !== "undefined") {
137
+ next[key] = value;
138
+ }
139
+ }
140
+ return next;
141
+ };
142
+ var legacyBlockToV2Settings = (block) => {
143
+ const current = structuredClone(defaultBuilderBlockSettingsV2);
144
+ current.layout.contentWidth = block.contentWidth === "narrow" || block.contentWidth === "content" || block.contentWidth === "wide" || block.contentWidth === "full" || block.contentWidth === "inherit" ? block.contentWidth : current.layout.contentWidth;
145
+ current.layout.sectionPaddingX = block.sectionPaddingX === "none" || block.sectionPaddingX === "sm" || block.sectionPaddingX === "md" || block.sectionPaddingX === "lg" || block.sectionPaddingX === "inherit" ? block.sectionPaddingX : current.layout.sectionPaddingX;
146
+ current.layout.sectionPaddingY = block.sectionPaddingY === "none" || block.sectionPaddingY === "sm" || block.sectionPaddingY === "lg" ? block.sectionPaddingY : current.layout.sectionPaddingY;
147
+ current.appearance.sectionBackgroundMode = block.sectionBackgroundMode === "none" || block.sectionBackgroundMode === "color" || block.sectionBackgroundMode === "gradient" ? block.sectionBackgroundMode : current.appearance.sectionBackgroundMode;
148
+ current.appearance.sectionBackgroundColor = typeof block.sectionBackgroundColor === "string" ? block.sectionBackgroundColor : current.appearance.sectionBackgroundColor;
149
+ current.appearance.sectionGradientPreset = typeof block.sectionGradientPreset === "string" ? block.sectionGradientPreset : current.appearance.sectionGradientPreset;
150
+ current.appearance.sectionGradientFrom = typeof block.sectionGradientFrom === "string" ? block.sectionGradientFrom : current.appearance.sectionGradientFrom;
151
+ current.appearance.sectionGradientTo = typeof block.sectionGradientTo === "string" ? block.sectionGradientTo : current.appearance.sectionGradientTo;
152
+ current.appearance.sectionGradientAngle = typeof block.sectionGradientAngle === "string" ? block.sectionGradientAngle : current.appearance.sectionGradientAngle;
153
+ current.appearance.contentBackgroundMode = block.contentBackgroundMode === "none" || block.contentBackgroundMode === "color" || block.contentBackgroundMode === "gradient" ? block.contentBackgroundMode : current.appearance.contentBackgroundMode;
154
+ current.appearance.contentBackgroundColor = typeof block.contentBackgroundColor === "string" ? block.contentBackgroundColor : current.appearance.contentBackgroundColor;
155
+ current.appearance.contentGradientPreset = typeof block.contentGradientPreset === "string" ? block.contentGradientPreset : current.appearance.contentGradientPreset;
156
+ current.appearance.contentGradientFrom = typeof block.contentGradientFrom === "string" ? block.contentGradientFrom : current.appearance.contentGradientFrom;
157
+ current.appearance.contentGradientTo = typeof block.contentGradientTo === "string" ? block.contentGradientTo : current.appearance.contentGradientTo;
158
+ current.appearance.contentGradientAngle = typeof block.contentGradientAngle === "string" ? block.contentGradientAngle : current.appearance.contentGradientAngle;
159
+ if (block.backgroundImageFit === "cover" || block.backgroundImageFit === "contain") {
160
+ current.media.fit = block.backgroundImageFit;
161
+ }
162
+ if (block.imageFit === "cover" || block.imageFit === "contain") {
163
+ current.media.fit = block.imageFit;
164
+ }
165
+ if (block.backgroundImageCornerStyle === "rounded" || block.backgroundImageCornerStyle === "square") {
166
+ current.media.cornerStyle = block.backgroundImageCornerStyle;
167
+ }
168
+ if (block.imageCornerStyle === "rounded" || block.imageCornerStyle === "square") {
169
+ current.media.cornerStyle = block.imageCornerStyle;
170
+ }
171
+ if (block.backgroundImagePosition === "top" || block.backgroundImagePosition === "bottom" || block.backgroundImagePosition === "left" || block.backgroundImagePosition === "right" || block.backgroundImagePosition === "center") {
172
+ current.media.position = block.backgroundImagePosition;
173
+ }
174
+ if (block.imagePosition === "top" || block.imagePosition === "bottom" || block.imagePosition === "left" || block.imagePosition === "right" || block.imagePosition === "center") {
175
+ current.media.position = block.imagePosition;
176
+ }
177
+ current.media.positionX = parsePercent(block.imagePositionX ?? block.backgroundImagePositionX);
178
+ current.media.positionY = parsePercent(block.imagePositionY ?? block.backgroundImagePositionY);
179
+ current.media.height = parsePixel(block.imageHeight);
180
+ current.typography.headingAlign = block.textHeadingAlign === "left" || block.textHeadingAlign === "center" || block.textHeadingAlign === "right" || block.textHeadingAlign === "justify" ? block.textHeadingAlign : current.typography.headingAlign;
181
+ current.typography.bodyAlign = block.textBodyAlign === "left" || block.textBodyAlign === "center" || block.textBodyAlign === "right" || block.textBodyAlign === "justify" ? block.textBodyAlign : current.typography.bodyAlign;
182
+ current.typography.maxTextWidth = block.textMaxWidth === "auto" || block.textMaxWidth === "sm" || block.textMaxWidth === "md" || block.textMaxWidth === "lg" || block.textMaxWidth === "full" ? block.textMaxWidth : current.typography.maxTextWidth;
183
+ current.typography.lineHeightPreset = block.textLineHeightPreset === "tight" || block.textLineHeightPreset === "normal" || block.textLineHeightPreset === "relaxed" ? block.textLineHeightPreset : current.typography.lineHeightPreset;
184
+ current.typography.letterSpacingPreset = block.textLetterSpacingPreset === "tight" || block.textLetterSpacingPreset === "normal" || block.textLetterSpacingPreset === "relaxed" ? block.textLetterSpacingPreset : current.typography.letterSpacingPreset;
185
+ current.advanced.editCopyInPanel = Boolean(block.editCopyInPanel ?? current.advanced.editCopyInPanel);
186
+ current.advanced.customClassName = typeof block.customClassName === "string" ? block.customClassName : current.advanced.customClassName;
187
+ current.advanced.hideOnMobile = Boolean(block.hideOnMobile ?? current.advanced.hideOnMobile);
188
+ return mergeSettings(current, block.settings);
189
+ };
190
+ var v2SettingsToLegacyBlock = (blockWithSettings) => {
191
+ const settings = legacyBlockToV2Settings(blockWithSettings);
192
+ const next = {
193
+ ...blockWithSettings,
194
+ settings
195
+ };
196
+ const blockType = typeof next.blockType === "string" ? next.blockType : "";
197
+ next.contentWidth = settings.layout.contentWidth;
198
+ next.sectionPaddingX = settings.layout.sectionPaddingX;
199
+ next.sectionPaddingY = settings.layout.sectionPaddingY;
200
+ next.sectionBackgroundMode = settings.appearance.sectionBackgroundMode;
201
+ next.sectionBackgroundColor = settings.appearance.sectionBackgroundColor;
202
+ next.sectionGradientPreset = settings.appearance.sectionGradientPreset;
203
+ next.sectionGradientFrom = settings.appearance.sectionGradientFrom;
204
+ next.sectionGradientTo = settings.appearance.sectionGradientTo;
205
+ next.sectionGradientAngle = settings.appearance.sectionGradientAngle;
206
+ next.contentBackgroundMode = settings.appearance.contentBackgroundMode;
207
+ next.contentBackgroundColor = settings.appearance.contentBackgroundColor;
208
+ next.contentGradientPreset = settings.appearance.contentGradientPreset;
209
+ next.contentGradientFrom = settings.appearance.contentGradientFrom;
210
+ next.contentGradientTo = settings.appearance.contentGradientTo;
211
+ next.contentGradientAngle = settings.appearance.contentGradientAngle;
212
+ next.textHeadingAlign = settings.typography.headingAlign;
213
+ next.textBodyAlign = settings.typography.bodyAlign;
214
+ next.textMaxWidth = settings.typography.maxTextWidth;
215
+ next.textLineHeightPreset = settings.typography.lineHeightPreset;
216
+ next.textLetterSpacingPreset = settings.typography.letterSpacingPreset;
217
+ next.editCopyInPanel = settings.advanced.editCopyInPanel;
218
+ next.customClassName = settings.advanced.customClassName;
219
+ next.hideOnMobile = settings.advanced.hideOnMobile;
220
+ delete next.backgroundImagePositionX;
221
+ delete next.backgroundImagePositionY;
222
+ delete next.imageHeight;
223
+ delete next.imagePositionX;
224
+ delete next.imagePositionY;
225
+ if (blockType === "hero") {
226
+ next.backgroundImageFit = settings.media.fit;
227
+ next.backgroundImageCornerStyle = settings.media.cornerStyle;
228
+ next.backgroundImagePosition = settings.media.position;
229
+ } else if (blockType === "media") {
230
+ next.imageFit = settings.media.fit;
231
+ next.imageCornerStyle = settings.media.cornerStyle;
232
+ next.imagePosition = settings.media.position;
233
+ }
234
+ if (Array.isArray(next.items)) {
235
+ next.items = next.items.map((rawItem) => isRecord(rawItem) ? v2SettingsToLegacyItem(rawItem) : rawItem);
236
+ }
237
+ return next;
238
+ };
239
+ var legacyItemToV2Settings = (item) => {
240
+ const current = structuredClone(defaultBuilderItemSettingsV2);
241
+ if (item.imageFit === "cover" || item.imageFit === "contain") {
242
+ current.media.fit = item.imageFit;
243
+ }
244
+ if (item.imageCornerStyle === "rounded" || item.imageCornerStyle === "square") {
245
+ current.media.cornerStyle = item.imageCornerStyle;
246
+ }
247
+ if (item.imagePosition === "top" || item.imagePosition === "bottom" || item.imagePosition === "left" || item.imagePosition === "right" || item.imagePosition === "center") {
248
+ current.media.position = item.imagePosition;
249
+ }
250
+ current.media.positionX = parsePercent(item.imagePositionX);
251
+ current.media.positionY = parsePercent(item.imagePositionY);
252
+ current.media.height = parsePixel(item.imageHeight);
253
+ return mergeSettings(current, item.settings);
254
+ };
255
+ var v2SettingsToLegacyItem = (itemWithSettings) => {
256
+ const settings = legacyItemToV2Settings(itemWithSettings);
257
+ return {
258
+ ...itemWithSettings,
259
+ imageCornerStyle: settings.media.cornerStyle,
260
+ imageFit: settings.media.fit,
261
+ imageHeight: settings.media.height,
262
+ imagePosition: settings.media.position,
263
+ imagePositionX: settings.media.positionX,
264
+ imagePositionY: settings.media.positionY,
265
+ settings
266
+ };
267
+ };
268
+ var migrateBlockToSettingsV2 = (block) => {
269
+ const withLegacyMirrors = v2SettingsToLegacyBlock(block);
270
+ if (!Array.isArray(withLegacyMirrors.items)) {
271
+ return withLegacyMirrors;
272
+ }
273
+ return {
274
+ ...withLegacyMirrors,
275
+ items: withLegacyMirrors.items.map((rawItem) => isRecord(rawItem) ? v2SettingsToLegacyItem(rawItem) : rawItem)
276
+ };
277
+ };
278
+
279
+ // src/studio-pages/document.ts
280
+ var ensureNodeID = (value, index) => {
281
+ if (typeof value === "string" && value.trim().length > 0) {
282
+ return value.trim();
283
+ }
284
+ return `node-${index + 1}`;
285
+ };
286
+ var layoutToStudioDocument = (layout, title, metadata) => {
287
+ const nodes = layout.filter((block) => typeof block.blockType === "string").map((rawBlock, index) => {
288
+ const block = migrateBlockToSettingsV2(rawBlock);
289
+ const blockType = String(block.blockType);
290
+ const { id, blockType: _ignoredBlockType, ...data } = block;
291
+ return {
292
+ id: ensureNodeID(id, index),
293
+ type: blockType,
294
+ data
295
+ };
296
+ });
297
+ return {
298
+ metadata,
299
+ schemaVersion: 1,
300
+ title,
301
+ nodes,
302
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
303
+ };
304
+ };
305
+ var studioDocumentToLayout = (document) => document.nodes.map(
306
+ (node) => migrateBlockToSettingsV2({
307
+ id: node.id,
308
+ blockType: node.type,
309
+ ...node.data
310
+ })
311
+ );
312
+ var createDefaultStudioDocument = (title) => ({
313
+ metadata: {},
314
+ schemaVersion: 1,
315
+ title,
316
+ nodes: [],
317
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
318
+ });
319
+
320
+ export {
321
+ defaultBuilderThemeTokens,
322
+ migrateBlockToSettingsV2,
323
+ layoutToStudioDocument,
324
+ studioDocumentToLayout,
325
+ createDefaultStudioDocument
326
+ };