@builder.io/sdk-solid 0.5.9 → 0.6.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 (166) hide show
  1. package/README.md +0 -4
  2. package/dist/index.d.ts +51 -0
  3. package/lib/browser/dev.js +4790 -0
  4. package/lib/browser/dev.jsx +4392 -0
  5. package/lib/browser/index.js +4767 -0
  6. package/lib/browser/index.jsx +4374 -0
  7. package/lib/edge/dev.js +7921 -0
  8. package/lib/edge/dev.jsx +7525 -0
  9. package/lib/edge/index.js +7898 -0
  10. package/lib/edge/index.jsx +7507 -0
  11. package/lib/node/dev.js +4790 -0
  12. package/lib/node/dev.jsx +4392 -0
  13. package/lib/node/index.js +4767 -0
  14. package/lib/node/index.jsx +4374 -0
  15. package/package.json +86 -14
  16. package/CHANGELOG.md +0 -102
  17. package/solid-index.jsx +0 -5
  18. package/src/blocks/BaseText.jsx +0 -11
  19. package/src/blocks/button/button.jsx +0 -41
  20. package/src/blocks/button/component-info.js +0 -34
  21. package/src/blocks/columns/columns.jsx +0 -174
  22. package/src/blocks/columns/component-info.js +0 -218
  23. package/src/blocks/custom-code/component-info.js +0 -24
  24. package/src/blocks/custom-code/custom-code.jsx +0 -62
  25. package/src/blocks/embed/component-info.js +0 -37
  26. package/src/blocks/embed/embed.jsx +0 -50
  27. package/src/blocks/embed/helpers.js +0 -3
  28. package/src/blocks/form/component-info.js +0 -223
  29. package/src/blocks/form/form.jsx +0 -5
  30. package/src/blocks/fragment/component-info.js +0 -8
  31. package/src/blocks/fragment/fragment.jsx +0 -5
  32. package/src/blocks/helpers.js +0 -27
  33. package/src/blocks/image/component-info.js +0 -122
  34. package/src/blocks/image/image.helpers.js +0 -46
  35. package/src/blocks/image/image.jsx +0 -122
  36. package/src/blocks/img/component-info.js +0 -15
  37. package/src/blocks/img/img.jsx +0 -20
  38. package/src/blocks/input/component-info.js +0 -45
  39. package/src/blocks/input/input.jsx +0 -22
  40. package/src/blocks/raw-text/component-info.js +0 -11
  41. package/src/blocks/raw-text/raw-text.jsx +0 -10
  42. package/src/blocks/section/component-info.js +0 -41
  43. package/src/blocks/section/section.jsx +0 -26
  44. package/src/blocks/select/component-info.js +0 -44
  45. package/src/blocks/select/select.jsx +0 -30
  46. package/src/blocks/submit-button/component-info.js +0 -23
  47. package/src/blocks/submit-button/submit-button.jsx +0 -11
  48. package/src/blocks/symbol/component-info.js +0 -35
  49. package/src/blocks/symbol/symbol.helpers.js +0 -60
  50. package/src/blocks/symbol/symbol.jsx +0 -64
  51. package/src/blocks/text/component-info.js +0 -20
  52. package/src/blocks/text/text.jsx +0 -14
  53. package/src/blocks/textarea/component-info.js +0 -38
  54. package/src/blocks/textarea/textarea.jsx +0 -16
  55. package/src/blocks/video/component-info.js +0 -83
  56. package/src/blocks/video/video.jsx +0 -61
  57. package/src/components/block/block.helpers.js +0 -99
  58. package/src/components/block/block.jsx +0 -167
  59. package/src/components/block/components/block-styles.jsx +0 -85
  60. package/src/components/block/components/block-wrapper.jsx +0 -50
  61. package/src/components/block/components/component-ref/component-ref.helpers.js +0 -41
  62. package/src/components/block/components/component-ref/component-ref.jsx +0 -59
  63. package/src/components/block/components/interactive-element.jsx +0 -30
  64. package/src/components/block/components/repeated-block.jsx +0 -20
  65. package/src/components/block/types.js +0 -0
  66. package/src/components/blocks/blocks-wrapper.jsx +0 -66
  67. package/src/components/blocks/blocks.jsx +0 -57
  68. package/src/components/content/components/enable-editor.jsx +0 -347
  69. package/src/components/content/components/styles.helpers.js +0 -56
  70. package/src/components/content/components/styles.jsx +0 -36
  71. package/src/components/content/content.helpers.js +0 -48
  72. package/src/components/content/content.jsx +0 -136
  73. package/src/components/content/content.types.js +0 -0
  74. package/src/components/content/index.js +0 -2
  75. package/src/components/content/wrap-component-ref.js +0 -2
  76. package/src/components/content-variants/content-variants.jsx +0 -115
  77. package/src/components/content-variants/content-variants.types.js +0 -0
  78. package/src/components/content-variants/helpers.js +0 -158
  79. package/src/components/inlined-script.jsx +0 -5
  80. package/src/components/inlined-styles.jsx +0 -5
  81. package/src/constants/builder-registered-components.js +0 -63
  82. package/src/constants/device-sizes.js +0 -48
  83. package/src/constants/sdk-version.js +0 -1
  84. package/src/constants/target.js +0 -4
  85. package/src/context/builder.context.js +0 -16
  86. package/src/context/components.context.js +0 -5
  87. package/src/context/types.js +0 -0
  88. package/src/functions/apply-patch-with-mutation.js +0 -66
  89. package/src/functions/camel-to-kebab-case.js +0 -2
  90. package/src/functions/evaluate/browser-runtime/browser.js +0 -40
  91. package/src/functions/evaluate/browser-runtime/index.js +0 -2
  92. package/src/functions/evaluate/evaluate.js +0 -49
  93. package/src/functions/evaluate/helpers.js +0 -15
  94. package/src/functions/evaluate/index.js +0 -2
  95. package/src/functions/evaluate/node-runtime/index.js +0 -2
  96. package/src/functions/evaluate/non-node-runtime/acorn-interpreter.js +0 -2876
  97. package/src/functions/evaluate/non-node-runtime/index.js +0 -18
  98. package/src/functions/evaluate/non-node-runtime/non-node-runtime.js +0 -91
  99. package/src/functions/event-handler-name.js +0 -5
  100. package/src/functions/extract-text-styles.js +0 -14
  101. package/src/functions/fast-clone.js +0 -2
  102. package/src/functions/fetch-builder-props.js +0 -60
  103. package/src/functions/get-block-actions-handler.js +0 -11
  104. package/src/functions/get-block-actions.js +0 -29
  105. package/src/functions/get-block-component-options.js +0 -27
  106. package/src/functions/get-block-properties.js +0 -63
  107. package/src/functions/get-builder-search-params/index.js +0 -33
  108. package/src/functions/get-content/generate-content-url.js +0 -59
  109. package/src/functions/get-content/index.js +0 -116
  110. package/src/functions/get-content/types.js +0 -0
  111. package/src/functions/get-fetch.js +0 -12
  112. package/src/functions/get-global-this.js +0 -16
  113. package/src/functions/get-processed-block.js +0 -74
  114. package/src/functions/get-react-native-block-styles.js +0 -32
  115. package/src/functions/is-browser.js +0 -4
  116. package/src/functions/is-editing.js +0 -6
  117. package/src/functions/is-iframe.js +0 -5
  118. package/src/functions/is-non-node-server.js +0 -9
  119. package/src/functions/is-previewing.js +0 -12
  120. package/src/functions/on-change.js +0 -24
  121. package/src/functions/register-component.js +0 -60
  122. package/src/functions/register.js +0 -27
  123. package/src/functions/sanitize-react-native-block-styles.js +0 -71
  124. package/src/functions/set-editor-settings.js +0 -13
  125. package/src/functions/set.js +0 -9
  126. package/src/functions/track/helpers.js +0 -48
  127. package/src/functions/track/index.js +0 -131
  128. package/src/functions/track/interaction.js +0 -57
  129. package/src/functions/transform-block-properties.js +0 -4
  130. package/src/functions/transform-block.js +0 -4
  131. package/src/helpers/ab-tests.js +0 -158
  132. package/src/helpers/canTrack.js +0 -3
  133. package/src/helpers/cookie.js +0 -77
  134. package/src/helpers/css.js +0 -30
  135. package/src/helpers/flatten.js +0 -31
  136. package/src/helpers/localStorage.js +0 -32
  137. package/src/helpers/logger.js +0 -8
  138. package/src/helpers/nullable.js +0 -2
  139. package/src/helpers/preview-lru-cache/get.js +0 -4
  140. package/src/helpers/preview-lru-cache/helpers.js +0 -0
  141. package/src/helpers/preview-lru-cache/init.js +0 -2
  142. package/src/helpers/preview-lru-cache/set.js +0 -31
  143. package/src/helpers/preview-lru-cache/types.js +0 -0
  144. package/src/helpers/sessionId.js +0 -55
  145. package/src/helpers/time.js +0 -3
  146. package/src/helpers/url.js +0 -11
  147. package/src/helpers/uuid.js +0 -11
  148. package/src/helpers/visitorId.js +0 -35
  149. package/src/index-helpers/blocks-exports.js +0 -13
  150. package/src/index-helpers/top-of-file.js +0 -2
  151. package/src/index.js +0 -3
  152. package/src/scripts/init-editing.js +0 -109
  153. package/src/server-index.js +0 -11
  154. package/src/types/api-version.js +0 -2
  155. package/src/types/builder-block.js +0 -0
  156. package/src/types/builder-content.js +0 -0
  157. package/src/types/builder-props.js +0 -0
  158. package/src/types/can-track.js +0 -0
  159. package/src/types/components.js +0 -0
  160. package/src/types/deep-partial.js +0 -0
  161. package/src/types/element.js +0 -0
  162. package/src/types/enforced-partials.js +0 -0
  163. package/src/types/input.js +0 -0
  164. package/src/types/targets.js +0 -0
  165. package/src/types/typescript.js +0 -0
  166. package/vite.config.ts +0 -18
@@ -0,0 +1,4392 @@
1
+ // src/blocks/button/button.jsx
2
+ import { Show } from "solid-js";
3
+ import { css } from "solid-styled-components";
4
+ function Button(props) {
5
+ return <Show
6
+ fallback={<button
7
+ class={props.attributes.class + " " + css({
8
+ all: "unset"
9
+ })}
10
+ {...{}}
11
+ {...props.attributes}
12
+ style={props.attributes.style}
13
+ >{props.text}</button>}
14
+ when={props.link}
15
+ ><a
16
+ role="button"
17
+ {...{}}
18
+ {...props.attributes}
19
+ href={props.link}
20
+ target={props.openLinkInNewTab ? "_blank" : void 0}
21
+ >{props.text}</a></Show>;
22
+ }
23
+ var button_default = Button;
24
+
25
+ // src/blocks/columns/columns.jsx
26
+ import { Show as Show7, For as For4, createSignal as createSignal6 } from "solid-js";
27
+ import { css as css3 } from "solid-styled-components";
28
+
29
+ // src/components/blocks/blocks.jsx
30
+ import { useContext, Show as Show6, For as For3 } from "solid-js";
31
+
32
+ // src/components/block/components/block-styles.jsx
33
+ import { Show as Show2, createSignal } from "solid-js";
34
+
35
+ // src/functions/fast-clone.js
36
+ var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
37
+
38
+ // src/constants/device-sizes.js
39
+ var SIZES = {
40
+ small: {
41
+ min: 320,
42
+ default: 321,
43
+ max: 640
44
+ },
45
+ medium: {
46
+ min: 641,
47
+ default: 642,
48
+ max: 991
49
+ },
50
+ large: {
51
+ min: 990,
52
+ default: 991,
53
+ max: 1200
54
+ }
55
+ };
56
+ var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
57
+ var getSizesForBreakpoints = ({
58
+ small,
59
+ medium
60
+ }) => {
61
+ const newSizes = fastClone(SIZES);
62
+ if (!small || !medium) {
63
+ return newSizes;
64
+ }
65
+ const smallMin = Math.floor(small / 2);
66
+ newSizes.small = {
67
+ max: small,
68
+ min: smallMin,
69
+ default: smallMin + 1
70
+ };
71
+ const mediumMin = newSizes.small.max + 1;
72
+ newSizes.medium = {
73
+ max: medium,
74
+ min: mediumMin,
75
+ default: mediumMin + 1
76
+ };
77
+ const largeMin = newSizes.medium.max + 1;
78
+ newSizes.large = {
79
+ max: 2e3,
80
+ min: largeMin,
81
+ default: largeMin + 1
82
+ };
83
+ return newSizes;
84
+ };
85
+
86
+ // src/constants/target.js
87
+ var TARGET = "solid";
88
+
89
+ // src/helpers/logger.js
90
+ var MSG_PREFIX = "[Builder.io]: ";
91
+ var logger = {
92
+ log: (...message) => console.log(MSG_PREFIX, ...message),
93
+ error: (...message) => console.error(MSG_PREFIX, ...message),
94
+ warn: (...message) => console.warn(MSG_PREFIX, ...message),
95
+ debug: (...message) => console.debug(MSG_PREFIX, ...message)
96
+ };
97
+
98
+ // src/functions/is-browser.js
99
+ function isBrowser() {
100
+ return typeof window !== "undefined" && typeof document !== "undefined";
101
+ }
102
+
103
+ // src/functions/is-iframe.js
104
+ function isIframe() {
105
+ return isBrowser() && window.self !== window.top;
106
+ }
107
+
108
+ // src/functions/is-editing.js
109
+ function isEditing() {
110
+ return isIframe() && (TARGET === "reactNative" || window.location.search.indexOf("builder.frameEditing=") !== -1);
111
+ }
112
+
113
+ // src/functions/track/helpers.js
114
+ var getLocation = () => {
115
+ if (TARGET === "reactNative") {
116
+ return null;
117
+ } else if (isBrowser()) {
118
+ const parsedLocation = new URL(location.href);
119
+ if (parsedLocation.pathname === "") {
120
+ parsedLocation.pathname = "/";
121
+ }
122
+ return parsedLocation;
123
+ } else {
124
+ console.warn("Cannot get location for tracking in non-browser environment");
125
+ return null;
126
+ }
127
+ };
128
+ var getUserAgent = () => typeof navigator === "object" && navigator.userAgent || "";
129
+ var getUserAttributes = () => {
130
+ const userAgent = getUserAgent();
131
+ const isMobile = {
132
+ Android() {
133
+ return userAgent.match(/Android/i);
134
+ },
135
+ BlackBerry() {
136
+ return userAgent.match(/BlackBerry/i);
137
+ },
138
+ iOS() {
139
+ return userAgent.match(/iPhone|iPod/i);
140
+ },
141
+ Opera() {
142
+ return userAgent.match(/Opera Mini/i);
143
+ },
144
+ Windows() {
145
+ return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
146
+ },
147
+ any() {
148
+ return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || TARGET === "reactNative";
149
+ }
150
+ };
151
+ const isTablet = userAgent.match(/Tablet|iPad/i);
152
+ const url = getLocation();
153
+ return {
154
+ urlPath: url == null ? void 0 : url.pathname,
155
+ host: (url == null ? void 0 : url.host) || (url == null ? void 0 : url.hostname),
156
+ device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
157
+ };
158
+ };
159
+
160
+ // src/functions/evaluate/helpers.js
161
+ var getFunctionArguments = ({
162
+ builder,
163
+ context,
164
+ event,
165
+ state
166
+ }) => {
167
+ return Object.entries({
168
+ state,
169
+ Builder: builder,
170
+ builder,
171
+ context,
172
+ event
173
+ });
174
+ };
175
+
176
+ // src/functions/evaluate/browser-runtime/browser.js
177
+ var runInBrowser = ({
178
+ code,
179
+ builder,
180
+ context,
181
+ event,
182
+ localState,
183
+ rootSetState,
184
+ rootState
185
+ }) => {
186
+ const functionArgs = getFunctionArguments({
187
+ builder,
188
+ context,
189
+ event,
190
+ state: flattenState(rootState, localState, rootSetState)
191
+ });
192
+ return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
193
+ };
194
+ function flattenState(rootState, localState, rootSetState) {
195
+ if (rootState === localState) {
196
+ throw new Error("rootState === localState");
197
+ }
198
+ return new Proxy(rootState, {
199
+ get: (_, prop) => {
200
+ if (localState && prop in localState) {
201
+ return localState[prop];
202
+ }
203
+ return rootState[prop];
204
+ },
205
+ set: (_, prop, value) => {
206
+ if (localState && prop in localState) {
207
+ throw new Error("Writing to local state is not allowed as it is read-only.");
208
+ }
209
+ rootState[prop] = value;
210
+ rootSetState == null ? void 0 : rootSetState(rootState);
211
+ return true;
212
+ }
213
+ });
214
+ }
215
+
216
+ // src/functions/evaluate/evaluate.js
217
+ function evaluate({
218
+ code,
219
+ context,
220
+ localState,
221
+ rootState,
222
+ rootSetState,
223
+ event,
224
+ isExpression = true
225
+ }) {
226
+ if (code === "") {
227
+ logger.warn("Skipping evaluation of empty code block.");
228
+ return;
229
+ }
230
+ const builder = {
231
+ isEditing: isEditing(),
232
+ isBrowser: isBrowser(),
233
+ isServer: !isBrowser(),
234
+ getUserAttributes: () => getUserAttributes()
235
+ };
236
+ const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
237
+ const useCode = useReturn ? `return (${code});` : code;
238
+ const args = {
239
+ code: useCode,
240
+ builder,
241
+ context,
242
+ event,
243
+ rootSetState,
244
+ rootState,
245
+ localState
246
+ };
247
+ try {
248
+ return runInBrowser(args);
249
+ } catch (e) {
250
+ logger.error("Failed code evaluation: " + e.message, {
251
+ code
252
+ });
253
+ return void 0;
254
+ }
255
+ }
256
+
257
+ // src/functions/set.js
258
+ var set = (obj, _path, value) => {
259
+ if (Object(obj) !== obj) {
260
+ return obj;
261
+ }
262
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
263
+ path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
264
+ return obj;
265
+ };
266
+
267
+ // src/functions/transform-block.js
268
+ function transformBlock(block) {
269
+ return block;
270
+ }
271
+
272
+ // src/functions/get-processed-block.js
273
+ var __defProp = Object.defineProperty;
274
+ var __defProps = Object.defineProperties;
275
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
276
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
277
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
278
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
279
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
280
+ enumerable: true,
281
+ configurable: true,
282
+ writable: true,
283
+ value
284
+ }) : obj[key] = value;
285
+ var __spreadValues = (a, b) => {
286
+ for (var prop in b || (b = {}))
287
+ if (__hasOwnProp.call(b, prop))
288
+ __defNormalProp(a, prop, b[prop]);
289
+ if (__getOwnPropSymbols)
290
+ for (var prop of __getOwnPropSymbols(b)) {
291
+ if (__propIsEnum.call(b, prop))
292
+ __defNormalProp(a, prop, b[prop]);
293
+ }
294
+ return a;
295
+ };
296
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
297
+ var evaluateBindings = ({
298
+ block,
299
+ context,
300
+ localState,
301
+ rootState,
302
+ rootSetState
303
+ }) => {
304
+ if (!block.bindings) {
305
+ return block;
306
+ }
307
+ const copy = fastClone(block);
308
+ const copied = __spreadProps(__spreadValues({}, copy), {
309
+ properties: __spreadValues({}, copy.properties),
310
+ actions: __spreadValues({}, copy.actions)
311
+ });
312
+ for (const binding in block.bindings) {
313
+ const expression = block.bindings[binding];
314
+ const value = evaluate({
315
+ code: expression,
316
+ localState,
317
+ rootState,
318
+ rootSetState,
319
+ context
320
+ });
321
+ set(copied, binding, value);
322
+ }
323
+ return copied;
324
+ };
325
+ function getProcessedBlock({
326
+ block,
327
+ context,
328
+ shouldEvaluateBindings,
329
+ localState,
330
+ rootState,
331
+ rootSetState
332
+ }) {
333
+ const transformedBlock = transformBlock(block);
334
+ if (shouldEvaluateBindings) {
335
+ return evaluateBindings({
336
+ block: transformedBlock,
337
+ localState,
338
+ rootState,
339
+ rootSetState,
340
+ context
341
+ });
342
+ } else {
343
+ return transformedBlock;
344
+ }
345
+ }
346
+
347
+ // src/functions/camel-to-kebab-case.js
348
+ var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
349
+
350
+ // src/helpers/nullable.js
351
+ var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
352
+
353
+ // src/helpers/css.js
354
+ var convertStyleMapToCSSArray = (style) => {
355
+ const cssProps = Object.entries(style).map(([key, value]) => {
356
+ if (typeof value === "string") {
357
+ return `${camelToKebabCase(key)}: ${value};`;
358
+ } else {
359
+ return void 0;
360
+ }
361
+ });
362
+ return cssProps.filter(checkIsDefined);
363
+ };
364
+ var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
365
+ var createCssClass = ({
366
+ mediaQuery,
367
+ className,
368
+ styles
369
+ }) => {
370
+ const cssClass = `.${className} {
371
+ ${convertStyleMapToCSS(styles)}
372
+ }`;
373
+ if (mediaQuery) {
374
+ return `${mediaQuery} {
375
+ ${cssClass}
376
+ }`;
377
+ } else {
378
+ return cssClass;
379
+ }
380
+ };
381
+
382
+ // src/components/inlined-styles.jsx
383
+ function InlinedStyles(props) {
384
+ return <style innerHTML={props.styles} id={props.id} />;
385
+ }
386
+ var Inlined_styles_default = InlinedStyles;
387
+
388
+ // src/components/block/components/block-styles.jsx
389
+ function BlockStyles(props) {
390
+ const [processedBlock, setProcessedBlock] = createSignal(
391
+ getProcessedBlock({
392
+ block: props.block,
393
+ localState: props.context.localState,
394
+ rootState: props.context.rootState,
395
+ rootSetState: props.context.rootSetState,
396
+ context: props.context.context,
397
+ shouldEvaluateBindings: true
398
+ })
399
+ );
400
+ function canShowBlock() {
401
+ if (checkIsDefined(processedBlock().hide)) {
402
+ return !processedBlock().hide;
403
+ }
404
+ if (checkIsDefined(processedBlock().show)) {
405
+ return processedBlock().show;
406
+ }
407
+ return true;
408
+ }
409
+ function css5() {
410
+ const styles = processedBlock().responsiveStyles;
411
+ const content = props.context.content;
412
+ const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
413
+ content?.meta?.breakpoints || {}
414
+ );
415
+ const largeStyles = styles?.large;
416
+ const mediumStyles = styles?.medium;
417
+ const smallStyles = styles?.small;
418
+ const className = processedBlock().id;
419
+ if (!className) {
420
+ return "";
421
+ }
422
+ const largeStylesClass = largeStyles ? createCssClass({
423
+ className,
424
+ styles: largeStyles
425
+ }) : "";
426
+ const mediumStylesClass = mediumStyles ? createCssClass({
427
+ className,
428
+ styles: mediumStyles,
429
+ mediaQuery: getMaxWidthQueryForSize(
430
+ "medium",
431
+ sizesWithUpdatedBreakpoints
432
+ )
433
+ }) : "";
434
+ const smallStylesClass = smallStyles ? createCssClass({
435
+ className,
436
+ styles: smallStyles,
437
+ mediaQuery: getMaxWidthQueryForSize(
438
+ "small",
439
+ sizesWithUpdatedBreakpoints
440
+ )
441
+ }) : "";
442
+ return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
443
+ }
444
+ return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default styles={css5()} /></Show2>;
445
+ }
446
+ var Block_styles_default = BlockStyles;
447
+
448
+ // src/components/block/block.jsx
449
+ import { Show as Show5, For as For2, createSignal as createSignal4 } from "solid-js";
450
+
451
+ // src/functions/get-block-component-options.js
452
+ var __defProp2 = Object.defineProperty;
453
+ var __defProps2 = Object.defineProperties;
454
+ var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
455
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
456
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
457
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
458
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
459
+ enumerable: true,
460
+ configurable: true,
461
+ writable: true,
462
+ value
463
+ }) : obj[key] = value;
464
+ var __spreadValues2 = (a, b) => {
465
+ for (var prop in b || (b = {}))
466
+ if (__hasOwnProp2.call(b, prop))
467
+ __defNormalProp2(a, prop, b[prop]);
468
+ if (__getOwnPropSymbols2)
469
+ for (var prop of __getOwnPropSymbols2(b)) {
470
+ if (__propIsEnum2.call(b, prop))
471
+ __defNormalProp2(a, prop, b[prop]);
472
+ }
473
+ return a;
474
+ };
475
+ var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
476
+ function getBlockComponentOptions(block) {
477
+ var _a;
478
+ return __spreadProps2(__spreadValues2(__spreadValues2({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
479
+ builderBlock: block
480
+ });
481
+ }
482
+
483
+ // src/functions/sanitize-react-native-block-styles.js
484
+ var __defProp3 = Object.defineProperty;
485
+ var __defProps3 = Object.defineProperties;
486
+ var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
487
+ var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
488
+ var __hasOwnProp3 = Object.prototype.hasOwnProperty;
489
+ var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
490
+ var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, {
491
+ enumerable: true,
492
+ configurable: true,
493
+ writable: true,
494
+ value
495
+ }) : obj[key] = value;
496
+ var __spreadValues3 = (a, b) => {
497
+ for (var prop in b || (b = {}))
498
+ if (__hasOwnProp3.call(b, prop))
499
+ __defNormalProp3(a, prop, b[prop]);
500
+ if (__getOwnPropSymbols3)
501
+ for (var prop of __getOwnPropSymbols3(b)) {
502
+ if (__propIsEnum3.call(b, prop))
503
+ __defNormalProp3(a, prop, b[prop]);
504
+ }
505
+ return a;
506
+ };
507
+ var __spreadProps3 = (a, b) => __defProps3(a, __getOwnPropDescs3(b));
508
+ var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
509
+ var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
510
+ var SHOW_WARNINGS = false;
511
+ var normalizeNumber = (value) => {
512
+ if (Number.isNaN(value)) {
513
+ return void 0;
514
+ } else if (value < 0) {
515
+ return 0;
516
+ } else {
517
+ return value;
518
+ }
519
+ };
520
+ var sanitizeReactNativeBlockStyles = (styles) => {
521
+ return Object.keys(styles).reduce((acc, key) => {
522
+ const propertyValue = styles[key];
523
+ if (key === "display" && !displayValues.has(propertyValue)) {
524
+ if (SHOW_WARNINGS) {
525
+ console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
526
+ }
527
+ return acc;
528
+ }
529
+ if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
530
+ if (SHOW_WARNINGS) {
531
+ console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
532
+ }
533
+ return acc;
534
+ }
535
+ if (typeof propertyValue === "string") {
536
+ const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
537
+ if (isPixelUnit) {
538
+ const newValue = parseFloat(propertyValue);
539
+ const normalizedValue = normalizeNumber(newValue);
540
+ if (normalizedValue) {
541
+ return __spreadProps3(__spreadValues3({}, acc), {
542
+ [key]: normalizedValue
543
+ });
544
+ } else {
545
+ return acc;
546
+ }
547
+ } else if (propertyValue === "0") {
548
+ return __spreadProps3(__spreadValues3({}, acc), {
549
+ [key]: 0
550
+ });
551
+ }
552
+ }
553
+ return __spreadProps3(__spreadValues3({}, acc), {
554
+ [key]: propertyValue
555
+ });
556
+ }, {});
557
+ };
558
+
559
+ // src/functions/get-react-native-block-styles.js
560
+ var __defProp4 = Object.defineProperty;
561
+ var __getOwnPropSymbols4 = Object.getOwnPropertySymbols;
562
+ var __hasOwnProp4 = Object.prototype.hasOwnProperty;
563
+ var __propIsEnum4 = Object.prototype.propertyIsEnumerable;
564
+ var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, {
565
+ enumerable: true,
566
+ configurable: true,
567
+ writable: true,
568
+ value
569
+ }) : obj[key] = value;
570
+ var __spreadValues4 = (a, b) => {
571
+ for (var prop in b || (b = {}))
572
+ if (__hasOwnProp4.call(b, prop))
573
+ __defNormalProp4(a, prop, b[prop]);
574
+ if (__getOwnPropSymbols4)
575
+ for (var prop of __getOwnPropSymbols4(b)) {
576
+ if (__propIsEnum4.call(b, prop))
577
+ __defNormalProp4(a, prop, b[prop]);
578
+ }
579
+ return a;
580
+ };
581
+ function getReactNativeBlockStyles({
582
+ block,
583
+ context,
584
+ blockStyles
585
+ }) {
586
+ const responsiveStyles = block.responsiveStyles;
587
+ if (!responsiveStyles) {
588
+ return {};
589
+ }
590
+ const styles = __spreadValues4(__spreadValues4(__spreadValues4(__spreadValues4(__spreadValues4({}, context.inheritedStyles), responsiveStyles.large || {}), responsiveStyles.medium || {}), responsiveStyles.small || {}), blockStyles);
591
+ const newStyles = sanitizeReactNativeBlockStyles(styles);
592
+ return newStyles;
593
+ }
594
+
595
+ // src/functions/transform-block-properties.js
596
+ function transformBlockProperties(properties) {
597
+ return properties;
598
+ }
599
+
600
+ // src/functions/get-block-properties.js
601
+ var __defProp5 = Object.defineProperty;
602
+ var __defProps4 = Object.defineProperties;
603
+ var __getOwnPropDescs4 = Object.getOwnPropertyDescriptors;
604
+ var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
605
+ var __hasOwnProp5 = Object.prototype.hasOwnProperty;
606
+ var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
607
+ var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, {
608
+ enumerable: true,
609
+ configurable: true,
610
+ writable: true,
611
+ value
612
+ }) : obj[key] = value;
613
+ var __spreadValues5 = (a, b) => {
614
+ for (var prop in b || (b = {}))
615
+ if (__hasOwnProp5.call(b, prop))
616
+ __defNormalProp5(a, prop, b[prop]);
617
+ if (__getOwnPropSymbols5)
618
+ for (var prop of __getOwnPropSymbols5(b)) {
619
+ if (__propIsEnum5.call(b, prop))
620
+ __defNormalProp5(a, prop, b[prop]);
621
+ }
622
+ return a;
623
+ };
624
+ var __spreadProps4 = (a, b) => __defProps4(a, __getOwnPropDescs4(b));
625
+ var extractRelevantRootBlockProperties = (block) => {
626
+ return {
627
+ href: block.href
628
+ };
629
+ };
630
+ function getBlockProperties({
631
+ block,
632
+ context
633
+ }) {
634
+ var _a;
635
+ const properties = __spreadProps4(__spreadValues5(__spreadValues5({}, extractRelevantRootBlockProperties(block)), block.properties), {
636
+ "builder-id": block.id,
637
+ style: block.style ? getStyleAttribute(block.style) : void 0,
638
+ class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
639
+ });
640
+ if (TARGET === "reactNative") {
641
+ properties.style = getReactNativeBlockStyles({
642
+ block,
643
+ context,
644
+ blockStyles: properties.style
645
+ });
646
+ }
647
+ return transformBlockProperties(properties);
648
+ }
649
+ function getStyleAttribute(style) {
650
+ switch (TARGET) {
651
+ case "svelte":
652
+ case "vue2":
653
+ case "vue3":
654
+ case "solid":
655
+ return convertStyleMapToCSSArray(style).join(" ");
656
+ case "qwik":
657
+ case "reactNative":
658
+ case "react":
659
+ case "rsc":
660
+ return style;
661
+ }
662
+ }
663
+
664
+ // src/components/block/block.helpers.js
665
+ var __defProp6 = Object.defineProperty;
666
+ var __defProps5 = Object.defineProperties;
667
+ var __getOwnPropDescs5 = Object.getOwnPropertyDescriptors;
668
+ var __getOwnPropSymbols6 = Object.getOwnPropertySymbols;
669
+ var __hasOwnProp6 = Object.prototype.hasOwnProperty;
670
+ var __propIsEnum6 = Object.prototype.propertyIsEnumerable;
671
+ var __defNormalProp6 = (obj, key, value) => key in obj ? __defProp6(obj, key, {
672
+ enumerable: true,
673
+ configurable: true,
674
+ writable: true,
675
+ value
676
+ }) : obj[key] = value;
677
+ var __spreadValues6 = (a, b) => {
678
+ for (var prop in b || (b = {}))
679
+ if (__hasOwnProp6.call(b, prop))
680
+ __defNormalProp6(a, prop, b[prop]);
681
+ if (__getOwnPropSymbols6)
682
+ for (var prop of __getOwnPropSymbols6(b)) {
683
+ if (__propIsEnum6.call(b, prop))
684
+ __defNormalProp6(a, prop, b[prop]);
685
+ }
686
+ return a;
687
+ };
688
+ var __spreadProps5 = (a, b) => __defProps5(a, __getOwnPropDescs5(b));
689
+ var __objRest = (source, exclude) => {
690
+ var target = {};
691
+ for (var prop in source)
692
+ if (__hasOwnProp6.call(source, prop) && exclude.indexOf(prop) < 0)
693
+ target[prop] = source[prop];
694
+ if (source != null && __getOwnPropSymbols6)
695
+ for (var prop of __getOwnPropSymbols6(source)) {
696
+ if (exclude.indexOf(prop) < 0 && __propIsEnum6.call(source, prop))
697
+ target[prop] = source[prop];
698
+ }
699
+ return target;
700
+ };
701
+ var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
702
+ var isEmptyHtmlElement = (tagName) => {
703
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
704
+ };
705
+ var getComponent = ({
706
+ block,
707
+ context,
708
+ registeredComponents
709
+ }) => {
710
+ var _a;
711
+ const componentName = (_a = getProcessedBlock({
712
+ block,
713
+ localState: context.localState,
714
+ rootState: context.rootState,
715
+ rootSetState: context.rootSetState,
716
+ context: context.context,
717
+ shouldEvaluateBindings: false
718
+ }).component) == null ? void 0 : _a.name;
719
+ if (!componentName) {
720
+ return null;
721
+ }
722
+ const ref = registeredComponents[componentName];
723
+ if (!ref) {
724
+ console.warn(`
725
+ Could not find a registered component named "${componentName}".
726
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
727
+ return void 0;
728
+ } else {
729
+ return ref;
730
+ }
731
+ };
732
+ var getRepeatItemData = ({
733
+ block,
734
+ context
735
+ }) => {
736
+ const _a = block, {
737
+ repeat
738
+ } = _a, blockWithoutRepeat = __objRest(_a, ["repeat"]);
739
+ if (!(repeat == null ? void 0 : repeat.collection)) {
740
+ return void 0;
741
+ }
742
+ const itemsArray = evaluate({
743
+ code: repeat.collection,
744
+ localState: context.localState,
745
+ rootState: context.rootState,
746
+ rootSetState: context.rootSetState,
747
+ context: context.context
748
+ });
749
+ if (!Array.isArray(itemsArray)) {
750
+ return void 0;
751
+ }
752
+ const collectionName = repeat.collection.split(".").pop();
753
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
754
+ const repeatArray = itemsArray.map((item, index) => ({
755
+ context: __spreadProps5(__spreadValues6({}, context), {
756
+ localState: __spreadProps5(__spreadValues6({}, context.localState), {
757
+ $index: index,
758
+ $item: item,
759
+ [itemNameToUse]: item,
760
+ [`$${itemNameToUse}Index`]: index
761
+ })
762
+ }),
763
+ block: blockWithoutRepeat
764
+ }));
765
+ return repeatArray;
766
+ };
767
+
768
+ // src/components/block/components/repeated-block.jsx
769
+ import { createSignal as createSignal2 } from "solid-js";
770
+
771
+ // src/context/builder.context.js
772
+ import { createContext } from "solid-js";
773
+ var stdin_default = createContext({
774
+ content: null,
775
+ context: {},
776
+ localState: void 0,
777
+ rootSetState() {
778
+ },
779
+ rootState: {},
780
+ apiKey: null,
781
+ apiVersion: void 0,
782
+ componentInfos: {},
783
+ inheritedStyles: {}
784
+ });
785
+
786
+ // src/components/block/components/repeated-block.jsx
787
+ function RepeatedBlock(props) {
788
+ const [store, setStore] = createSignal2(props.repeatContext);
789
+ return <stdin_default.Provider value={store()}><Block_default
790
+ block={props.block}
791
+ context={store()}
792
+ registeredComponents={props.registeredComponents}
793
+ /></stdin_default.Provider>;
794
+ }
795
+ var Repeated_block_default = RepeatedBlock;
796
+
797
+ // src/components/block/components/component-ref/component-ref.jsx
798
+ import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
799
+ import { Dynamic as Dynamic2 } from "solid-js/web";
800
+
801
+ // src/components/block/components/interactive-element.jsx
802
+ import { Dynamic } from "solid-js/web";
803
+
804
+ // src/functions/event-handler-name.js
805
+ function capitalizeFirstLetter(string) {
806
+ return string.charAt(0).toUpperCase() + string.slice(1);
807
+ }
808
+ var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
809
+
810
+ // src/functions/get-block-actions-handler.js
811
+ var createEventHandler = (value, options) => (event) => evaluate({
812
+ code: value,
813
+ context: options.context,
814
+ localState: options.localState,
815
+ rootState: options.rootState,
816
+ rootSetState: options.rootSetState,
817
+ event,
818
+ isExpression: false
819
+ });
820
+
821
+ // src/functions/get-block-actions.js
822
+ function getBlockActions(options) {
823
+ var _a;
824
+ const obj = {};
825
+ const optionActions = (_a = options.block.actions) != null ? _a : {};
826
+ for (const key in optionActions) {
827
+ if (!optionActions.hasOwnProperty(key)) {
828
+ continue;
829
+ }
830
+ const value = optionActions[key];
831
+ let eventHandlerName = getEventHandlerName(key);
832
+ if (options.stripPrefix) {
833
+ switch (TARGET) {
834
+ case "vue2":
835
+ case "vue3":
836
+ eventHandlerName = eventHandlerName.replace("v-on:", "");
837
+ break;
838
+ case "svelte":
839
+ eventHandlerName = eventHandlerName.replace("on:", "");
840
+ break;
841
+ }
842
+ }
843
+ obj[eventHandlerName] = createEventHandler(value, options);
844
+ }
845
+ return obj;
846
+ }
847
+
848
+ // src/components/block/components/interactive-element.jsx
849
+ function InteractiveElement(props) {
850
+ return <Dynamic
851
+ {...props.wrapperProps}
852
+ attributes={{
853
+ ...getBlockProperties({
854
+ block: props.block,
855
+ context: props.context
856
+ }),
857
+ ...getBlockActions({
858
+ block: props.block,
859
+ rootState: props.context.rootState,
860
+ rootSetState: props.context.rootSetState,
861
+ localState: props.context.localState,
862
+ context: props.context.context
863
+ })
864
+ }}
865
+ component={props.Wrapper}
866
+ >{props.children}</Dynamic>;
867
+ }
868
+ var interactive_element_default = InteractiveElement;
869
+
870
+ // src/components/block/components/component-ref/component-ref.helpers.js
871
+ var __defProp7 = Object.defineProperty;
872
+ var __getOwnPropSymbols7 = Object.getOwnPropertySymbols;
873
+ var __hasOwnProp7 = Object.prototype.hasOwnProperty;
874
+ var __propIsEnum7 = Object.prototype.propertyIsEnumerable;
875
+ var __defNormalProp7 = (obj, key, value) => key in obj ? __defProp7(obj, key, {
876
+ enumerable: true,
877
+ configurable: true,
878
+ writable: true,
879
+ value
880
+ }) : obj[key] = value;
881
+ var __spreadValues7 = (a, b) => {
882
+ for (var prop in b || (b = {}))
883
+ if (__hasOwnProp7.call(b, prop))
884
+ __defNormalProp7(a, prop, b[prop]);
885
+ if (__getOwnPropSymbols7)
886
+ for (var prop of __getOwnPropSymbols7(b)) {
887
+ if (__propIsEnum7.call(b, prop))
888
+ __defNormalProp7(a, prop, b[prop]);
889
+ }
890
+ return a;
891
+ };
892
+ var getWrapperProps = ({
893
+ componentOptions,
894
+ builderBlock,
895
+ context,
896
+ componentRef,
897
+ includeBlockProps,
898
+ isInteractive,
899
+ contextValue
900
+ }) => {
901
+ const interactiveElementProps = {
902
+ Wrapper: componentRef,
903
+ block: builderBlock,
904
+ context,
905
+ wrapperProps: componentOptions
906
+ };
907
+ return isInteractive ? interactiveElementProps : __spreadValues7(__spreadValues7({}, componentOptions), includeBlockProps ? {
908
+ attributes: getBlockProperties({
909
+ block: builderBlock,
910
+ context: contextValue
911
+ })
912
+ } : {});
913
+ };
914
+
915
+ // src/components/block/components/component-ref/component-ref.jsx
916
+ function ComponentRef(props) {
917
+ const [Wrapper, setWrapper] = createSignal3(
918
+ props.isInteractive ? interactive_element_default : props.componentRef
919
+ );
920
+ return <Show3 when={props.componentRef}><Dynamic2
921
+ {...getWrapperProps({
922
+ componentOptions: props.componentOptions,
923
+ builderBlock: props.builderBlock,
924
+ context: props.context,
925
+ componentRef: props.componentRef,
926
+ includeBlockProps: props.includeBlockProps,
927
+ isInteractive: props.isInteractive,
928
+ contextValue: props.context
929
+ })}
930
+ component={Wrapper()}
931
+ >
932
+ <For each={props.blockChildren}>{(child, _index) => {
933
+ const index = _index();
934
+ return <Block_default
935
+ key={"block-" + child.id}
936
+ block={child}
937
+ context={props.context}
938
+ registeredComponents={props.registeredComponents}
939
+ />;
940
+ }}</For>
941
+ <For each={props.blockChildren}>{(child, _index) => {
942
+ const index = _index();
943
+ return <Block_styles_default
944
+ key={"block-style-" + child.id}
945
+ block={child}
946
+ context={props.context}
947
+ />;
948
+ }}</For>
949
+ </Dynamic2></Show3>;
950
+ }
951
+ var Component_ref_default = ComponentRef;
952
+
953
+ // src/components/block/components/block-wrapper.jsx
954
+ import { Show as Show4 } from "solid-js";
955
+ import { Dynamic as Dynamic3 } from "solid-js/web";
956
+ function BlockWrapper(props) {
957
+ return <Show4
958
+ fallback={<Dynamic3
959
+ {...getBlockProperties({
960
+ block: props.block,
961
+ context: props.context
962
+ })}
963
+ {...getBlockActions({
964
+ block: props.block,
965
+ rootState: props.context.rootState,
966
+ rootSetState: props.context.rootSetState,
967
+ localState: props.context.localState,
968
+ context: props.context.context,
969
+ stripPrefix: true
970
+ })}
971
+ component={props.Wrapper}
972
+ />}
973
+ when={props.hasChildren}
974
+ ><Dynamic3
975
+ {...getBlockProperties({
976
+ block: props.block,
977
+ context: props.context
978
+ })}
979
+ {...getBlockActions({
980
+ block: props.block,
981
+ rootState: props.context.rootState,
982
+ rootSetState: props.context.rootSetState,
983
+ localState: props.context.localState,
984
+ context: props.context.context,
985
+ stripPrefix: true
986
+ })}
987
+ component={props.Wrapper}
988
+ >{props.children}</Dynamic3></Show4>;
989
+ }
990
+ var Block_wrapper_default = BlockWrapper;
991
+
992
+ // src/components/block/block.jsx
993
+ function Block(props) {
994
+ const [childrenContext, setChildrenContext] = createSignal4(props.context);
995
+ function blockComponent() {
996
+ return getComponent({
997
+ block: props.block,
998
+ context: props.context,
999
+ registeredComponents: props.registeredComponents
1000
+ });
1001
+ }
1002
+ function repeatItem() {
1003
+ return getRepeatItemData({
1004
+ block: props.block,
1005
+ context: props.context
1006
+ });
1007
+ }
1008
+ function processedBlock() {
1009
+ return repeatItem() ? props.block : getProcessedBlock({
1010
+ block: props.block,
1011
+ localState: props.context.localState,
1012
+ rootState: props.context.rootState,
1013
+ rootSetState: props.context.rootSetState,
1014
+ context: props.context.context,
1015
+ shouldEvaluateBindings: true
1016
+ });
1017
+ }
1018
+ function Tag() {
1019
+ return props.block.tagName || "div";
1020
+ }
1021
+ function canShowBlock() {
1022
+ if ("hide" in processedBlock()) {
1023
+ return !processedBlock().hide;
1024
+ }
1025
+ if ("show" in processedBlock()) {
1026
+ return processedBlock().show;
1027
+ }
1028
+ return true;
1029
+ }
1030
+ function childrenWithoutParentComponent() {
1031
+ const shouldRenderChildrenOutsideRef = !blockComponent()?.component && !repeatItem();
1032
+ return shouldRenderChildrenOutsideRef ? processedBlock().children ?? [] : [];
1033
+ }
1034
+ function componentRefProps() {
1035
+ return {
1036
+ blockChildren: processedBlock().children ?? [],
1037
+ componentRef: blockComponent()?.component,
1038
+ componentOptions: {
1039
+ ...getBlockComponentOptions(processedBlock()),
1040
+ builderContext: props.context,
1041
+ ...blockComponent()?.name === "Symbol" || blockComponent()?.name === "Columns" ? {
1042
+ builderComponents: props.registeredComponents
1043
+ } : {}
1044
+ },
1045
+ context: childrenContext(),
1046
+ registeredComponents: props.registeredComponents,
1047
+ builderBlock: processedBlock(),
1048
+ includeBlockProps: blockComponent()?.noWrap === true,
1049
+ isInteractive: !blockComponent()?.isRSC
1050
+ };
1051
+ }
1052
+ return <Show5 when={canShowBlock()}><Show5
1053
+ fallback={<Component_ref_default {...componentRefProps()} />}
1054
+ when={!blockComponent()?.noWrap}
1055
+ >
1056
+ <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
1057
+ Wrapper={Tag()}
1058
+ block={processedBlock()}
1059
+ context={props.context}
1060
+ hasChildren={false}
1061
+ /></Show5>
1062
+ <Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
1063
+ const index = _index();
1064
+ return <Repeated_block_default
1065
+ key={index}
1066
+ repeatContext={data.context}
1067
+ block={data.block}
1068
+ registeredComponents={props.registeredComponents}
1069
+ />;
1070
+ }}</For2></Show5>
1071
+ <Show5 when={!isEmptyHtmlElement(Tag()) && !repeatItem()}><Block_wrapper_default
1072
+ Wrapper={Tag()}
1073
+ block={processedBlock()}
1074
+ context={props.context}
1075
+ hasChildren={true}
1076
+ >
1077
+ <Component_ref_default {...componentRefProps()} />
1078
+ <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
1079
+ const index = _index();
1080
+ return <Block
1081
+ key={"block-" + child.id}
1082
+ block={child}
1083
+ context={childrenContext()}
1084
+ registeredComponents={props.registeredComponents}
1085
+ />;
1086
+ }}</For2>
1087
+ <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
1088
+ const index = _index();
1089
+ return <Block_styles_default
1090
+ key={"block-style-" + child.id}
1091
+ block={child}
1092
+ context={childrenContext()}
1093
+ />;
1094
+ }}</For2>
1095
+ </Block_wrapper_default></Show5>
1096
+ </Show5></Show5>;
1097
+ }
1098
+ var Block_default = Block;
1099
+
1100
+ // src/components/blocks/blocks-wrapper.jsx
1101
+ import { createSignal as createSignal5 } from "solid-js";
1102
+ import { css as css2 } from "solid-styled-components";
1103
+ function BlocksWrapper(props) {
1104
+ function className() {
1105
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
1106
+ }
1107
+ function onClick() {
1108
+ if (isEditing() && !props.blocks?.length) {
1109
+ window.parent?.postMessage(
1110
+ {
1111
+ type: "builder.clickEmptyBlocks",
1112
+ data: {
1113
+ parentElementId: props.parent,
1114
+ dataPath: props.path
1115
+ }
1116
+ },
1117
+ "*"
1118
+ );
1119
+ }
1120
+ }
1121
+ function onMouseEnter() {
1122
+ if (isEditing() && !props.blocks?.length) {
1123
+ window.parent?.postMessage(
1124
+ {
1125
+ type: "builder.hoverEmptyBlocks",
1126
+ data: {
1127
+ parentElementId: props.parent,
1128
+ dataPath: props.path
1129
+ }
1130
+ },
1131
+ "*"
1132
+ );
1133
+ }
1134
+ }
1135
+ return <div
1136
+ class={className() + " " + css2({
1137
+ display: "flex",
1138
+ flexDirection: "column",
1139
+ alignItems: "stretch"
1140
+ })}
1141
+ builder-path={props.path}
1142
+ builder-parent-id={props.parent}
1143
+ {...{}}
1144
+ style={props.styleProp}
1145
+ onClick={(event) => onClick()}
1146
+ onMouseEnter={(event) => onMouseEnter()}
1147
+ onKeyPress={(event) => onClick()}
1148
+ >{props.children}</div>;
1149
+ }
1150
+ var Blocks_wrapper_default = BlocksWrapper;
1151
+
1152
+ // src/context/components.context.js
1153
+ import { createContext as createContext2 } from "solid-js";
1154
+ var stdin_default2 = createContext2({ registeredComponents: {} });
1155
+
1156
+ // src/components/blocks/blocks.jsx
1157
+ function Blocks(props) {
1158
+ const builderContext = useContext(stdin_default);
1159
+ const componentsContext = useContext(stdin_default2);
1160
+ return <Blocks_wrapper_default
1161
+ blocks={props.blocks}
1162
+ parent={props.parent}
1163
+ path={props.path}
1164
+ styleProp={props.styleProp}
1165
+ >
1166
+ <Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
1167
+ const index = _index();
1168
+ return <Block_default
1169
+ key={"render-block-" + block.id}
1170
+ block={block}
1171
+ context={props.context || builderContext}
1172
+ registeredComponents={props.registeredComponents || componentsContext.registeredComponents}
1173
+ />;
1174
+ }}</For3></Show6>
1175
+ <Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
1176
+ const index = _index();
1177
+ return <Block_styles_default
1178
+ key={"block-style-" + block.id}
1179
+ block={block}
1180
+ context={props.context || builderContext}
1181
+ />;
1182
+ }}</For3></Show6>
1183
+ </Blocks_wrapper_default>;
1184
+ }
1185
+ var Blocks_default = Blocks;
1186
+
1187
+ // src/blocks/columns/columns.jsx
1188
+ function Columns(props) {
1189
+ const [gutterSize, setGutterSize] = createSignal6(
1190
+ typeof props.space === "number" ? props.space || 0 : 20
1191
+ );
1192
+ const [cols, setCols] = createSignal6(props.columns || []);
1193
+ const [stackAt, setStackAt] = createSignal6(props.stackColumnsAt || "tablet");
1194
+ const [flexDir, setFlexDir] = createSignal6(
1195
+ props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column"
1196
+ );
1197
+ function getWidth(index) {
1198
+ return cols()[index]?.width || 100 / cols().length;
1199
+ }
1200
+ function getColumnCssWidth(index) {
1201
+ const subtractWidth = gutterSize() * (cols().length - 1) / cols().length;
1202
+ return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
1203
+ }
1204
+ function getTabletStyle({ stackedStyle, desktopStyle }) {
1205
+ return stackAt() === "tablet" ? stackedStyle : desktopStyle;
1206
+ }
1207
+ function getMobileStyle({ stackedStyle, desktopStyle }) {
1208
+ return stackAt() === "never" ? desktopStyle : stackedStyle;
1209
+ }
1210
+ function columnsCssVars() {
1211
+ return {
1212
+ "--flex-dir": flexDir(),
1213
+ "--flex-dir-tablet": getTabletStyle({
1214
+ stackedStyle: flexDir(),
1215
+ desktopStyle: "row"
1216
+ })
1217
+ };
1218
+ }
1219
+ function columnCssVars(index) {
1220
+ const gutter = index === 0 ? 0 : gutterSize();
1221
+ const width = getColumnCssWidth(index);
1222
+ const gutterPixels = `${gutter}px`;
1223
+ const mobileWidth = "100%";
1224
+ const mobileMarginLeft = 0;
1225
+ const marginLeftKey = "margin-left";
1226
+ return {
1227
+ width,
1228
+ [marginLeftKey]: gutterPixels,
1229
+ "--column-width-mobile": getMobileStyle({
1230
+ stackedStyle: mobileWidth,
1231
+ desktopStyle: width
1232
+ }),
1233
+ "--column-margin-left-mobile": getMobileStyle({
1234
+ stackedStyle: mobileMarginLeft,
1235
+ desktopStyle: gutterPixels
1236
+ }),
1237
+ "--column-width-tablet": getTabletStyle({
1238
+ stackedStyle: mobileWidth,
1239
+ desktopStyle: width
1240
+ }),
1241
+ "--column-margin-left-tablet": getTabletStyle({
1242
+ stackedStyle: mobileMarginLeft,
1243
+ desktopStyle: gutterPixels
1244
+ })
1245
+ };
1246
+ }
1247
+ function getWidthForBreakpointSize(size) {
1248
+ const breakpointSizes = getSizesForBreakpoints(
1249
+ props.builderContext.content?.meta?.breakpoints || {}
1250
+ );
1251
+ return breakpointSizes[size].max;
1252
+ }
1253
+ function columnsStyles() {
1254
+ return `
1255
+ @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
1256
+ .${props.builderBlock.id}-breakpoints {
1257
+ flex-direction: var(--flex-dir-tablet);
1258
+ align-items: stretch;
1259
+ }
1260
+
1261
+ .${props.builderBlock.id}-breakpoints > .builder-column {
1262
+ width: var(--column-width-tablet) !important;
1263
+ margin-left: var(--column-margin-left-tablet) !important;
1264
+ }
1265
+ }
1266
+
1267
+ @media (max-width: ${getWidthForBreakpointSize("small")}px) {
1268
+ .${props.builderBlock.id}-breakpoints {
1269
+ flex-direction: var(--flex-dir);
1270
+ align-items: stretch;
1271
+ }
1272
+
1273
+ .${props.builderBlock.id}-breakpoints > .builder-column {
1274
+ width: var(--column-width-mobile) !important;
1275
+ margin-left: var(--column-margin-left-mobile) !important;
1276
+ }
1277
+ },
1278
+ `;
1279
+ }
1280
+ return <div
1281
+ class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css3({
1282
+ display: "flex",
1283
+ lineHeight: "normal"
1284
+ })}
1285
+ style={columnsCssVars()}
1286
+ {...{}}
1287
+ >
1288
+ <Show7 when={TARGET !== "reactNative"}><Inlined_styles_default styles={columnsStyles()} /></Show7>
1289
+ <For4 each={props.columns}>{(column, _index) => {
1290
+ const index = _index();
1291
+ return <div
1292
+ class={"builder-column " + css3({
1293
+ display: "flex",
1294
+ flexDirection: "column",
1295
+ alignItems: "stretch"
1296
+ })}
1297
+ style={columnCssVars(index)}
1298
+ {...{}}
1299
+ key={index}
1300
+ ><Blocks_default
1301
+ path={`component.options.columns.${index}.blocks`}
1302
+ parent={props.builderBlock.id}
1303
+ styleProp={{
1304
+ flexGrow: "1"
1305
+ }}
1306
+ context={props.builderContext}
1307
+ registeredComponents={props.builderComponents}
1308
+ blocks={column.blocks}
1309
+ /></div>;
1310
+ }}</For4>
1311
+ </div>;
1312
+ }
1313
+ var columns_default = Columns;
1314
+
1315
+ // src/blocks/fragment/fragment.jsx
1316
+ function FragmentComponent(props) {
1317
+ return <span>{props.children}</span>;
1318
+ }
1319
+ var fragment_default = FragmentComponent;
1320
+
1321
+ // src/blocks/image/image.jsx
1322
+ import { Show as Show8, createSignal as createSignal7 } from "solid-js";
1323
+ import { css as css4 } from "solid-styled-components";
1324
+
1325
+ // src/blocks/image/image.helpers.js
1326
+ function removeProtocol(path) {
1327
+ return path.replace(/http(s)?:/, "");
1328
+ }
1329
+ function updateQueryParam(uri = "", key, value) {
1330
+ const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
1331
+ const separator = uri.indexOf("?") !== -1 ? "&" : "?";
1332
+ if (uri.match(re)) {
1333
+ return uri.replace(re, "$1" + key + "=" + encodeURIComponent(value) + "$2");
1334
+ }
1335
+ return uri + separator + key + "=" + encodeURIComponent(value);
1336
+ }
1337
+ function getShopifyImageUrl(src, size) {
1338
+ if (!src || !(src == null ? void 0 : src.match(/cdn\.shopify\.com/)) || !size) {
1339
+ return src;
1340
+ }
1341
+ if (size === "master") {
1342
+ return removeProtocol(src);
1343
+ }
1344
+ const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
1345
+ if (match) {
1346
+ const prefix = src.split(match[0]);
1347
+ const suffix = match[3];
1348
+ const useSize = size.match("x") ? size : `${size}x`;
1349
+ return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
1350
+ }
1351
+ return null;
1352
+ }
1353
+ function getSrcSet(url) {
1354
+ if (!url) {
1355
+ return url;
1356
+ }
1357
+ const sizes = [100, 200, 400, 800, 1200, 1600, 2e3];
1358
+ if (url.match(/builder\.io/)) {
1359
+ let srcUrl = url;
1360
+ const widthInSrc = Number(url.split("?width=")[1]);
1361
+ if (!isNaN(widthInSrc)) {
1362
+ srcUrl = `${srcUrl} ${widthInSrc}w`;
1363
+ }
1364
+ return sizes.filter((size) => size !== widthInSrc).map((size) => `${updateQueryParam(url, "width", size)} ${size}w`).concat([srcUrl]).join(", ");
1365
+ }
1366
+ if (url.match(/cdn\.shopify\.com/)) {
1367
+ return sizes.map((size) => [getShopifyImageUrl(url, `${size}x${size}`), size]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([url]).join(", ");
1368
+ }
1369
+ return url;
1370
+ }
1371
+
1372
+ // src/blocks/image/image.jsx
1373
+ function Image(props) {
1374
+ function srcSetToUse() {
1375
+ const imageToUse = props.image || props.src;
1376
+ const url = imageToUse;
1377
+ if (!url || // We can auto add srcset for cdn.builder.io and shopify
1378
+ // images, otherwise you can supply this prop manually
1379
+ !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))) {
1380
+ return props.srcset;
1381
+ }
1382
+ if (props.srcset && props.image?.includes("builder.io/api/v1/image")) {
1383
+ if (!props.srcset.includes(props.image.split("?")[0])) {
1384
+ console.debug("Removed given srcset");
1385
+ return getSrcSet(url);
1386
+ }
1387
+ } else if (props.image && !props.srcset) {
1388
+ return getSrcSet(url);
1389
+ }
1390
+ return getSrcSet(url);
1391
+ }
1392
+ function webpSrcSet() {
1393
+ if (srcSetToUse()?.match(/builder\.io/) && !props.noWebp) {
1394
+ return srcSetToUse().replace(/\?/g, "?format=webp&");
1395
+ } else {
1396
+ return "";
1397
+ }
1398
+ }
1399
+ function aspectRatioCss() {
1400
+ const aspectRatioStyles = {
1401
+ position: "absolute",
1402
+ height: "100%",
1403
+ width: "100%",
1404
+ left: "0px",
1405
+ top: "0px"
1406
+ };
1407
+ const out = props.aspectRatio ? aspectRatioStyles : void 0;
1408
+ return out;
1409
+ }
1410
+ return <>
1411
+ <picture>
1412
+ <Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
1413
+ <img
1414
+ class={"builder-image" + (props.className ? " " + props.className : "") + " " + css4({
1415
+ opacity: "1",
1416
+ transition: "opacity 0.2s ease-in-out"
1417
+ })}
1418
+ loading="lazy"
1419
+ alt={props.altText}
1420
+ role={props.altText ? "presentation" : void 0}
1421
+ style={{
1422
+ "object-position": props.backgroundPosition || "center",
1423
+ "object-fit": props.backgroundSize || "cover",
1424
+ ...aspectRatioCss()
1425
+ }}
1426
+ src={props.image}
1427
+ srcset={srcSetToUse()}
1428
+ sizes={props.sizes}
1429
+ />
1430
+ </picture>
1431
+ <Show8
1432
+ when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
1433
+ ><div
1434
+ class={"builder-image-sizer " + css4({
1435
+ width: "100%",
1436
+ pointerEvents: "none",
1437
+ fontSize: "0"
1438
+ })}
1439
+ style={{
1440
+ "padding-top": props.aspectRatio * 100 + "%"
1441
+ }}
1442
+ /></Show8>
1443
+ <Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
1444
+ <Show8 when={!props.fitContent && props.children}><div
1445
+ class={css4({
1446
+ display: "flex",
1447
+ flexDirection: "column",
1448
+ alignItems: "stretch",
1449
+ position: "absolute",
1450
+ top: "0",
1451
+ left: "0",
1452
+ width: "100%",
1453
+ height: "100%"
1454
+ })}
1455
+ >{props.children}</div></Show8>
1456
+ </>;
1457
+ }
1458
+ var image_default = Image;
1459
+
1460
+ // src/blocks/section/section.jsx
1461
+ function SectionComponent(props) {
1462
+ return <section
1463
+ {...{}}
1464
+ {...props.attributes}
1465
+ style={{
1466
+ width: "100%",
1467
+ "align-self": "stretch",
1468
+ "flex-grow": 1,
1469
+ "box-sizing": "border-box",
1470
+ "max-width": props.maxWidth || 1200,
1471
+ display: "flex",
1472
+ "flex-direction": "column",
1473
+ "align-items": "stretch",
1474
+ "margin-left": "auto",
1475
+ "margin-right": "auto"
1476
+ }}
1477
+ >{props.children}</section>;
1478
+ }
1479
+ var section_default = SectionComponent;
1480
+
1481
+ // src/blocks/symbol/symbol.jsx
1482
+ import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal15 } from "solid-js";
1483
+
1484
+ // src/components/content-variants/content-variants.jsx
1485
+ import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal14 } from "solid-js";
1486
+
1487
+ // src/components/content-variants/helpers.js
1488
+ var __defProp8 = Object.defineProperty;
1489
+ var __defProps6 = Object.defineProperties;
1490
+ var __getOwnPropDescs6 = Object.getOwnPropertyDescriptors;
1491
+ var __getOwnPropSymbols8 = Object.getOwnPropertySymbols;
1492
+ var __hasOwnProp8 = Object.prototype.hasOwnProperty;
1493
+ var __propIsEnum8 = Object.prototype.propertyIsEnumerable;
1494
+ var __defNormalProp8 = (obj, key, value) => key in obj ? __defProp8(obj, key, {
1495
+ enumerable: true,
1496
+ configurable: true,
1497
+ writable: true,
1498
+ value
1499
+ }) : obj[key] = value;
1500
+ var __spreadValues8 = (a, b) => {
1501
+ for (var prop in b || (b = {}))
1502
+ if (__hasOwnProp8.call(b, prop))
1503
+ __defNormalProp8(a, prop, b[prop]);
1504
+ if (__getOwnPropSymbols8)
1505
+ for (var prop of __getOwnPropSymbols8(b)) {
1506
+ if (__propIsEnum8.call(b, prop))
1507
+ __defNormalProp8(a, prop, b[prop]);
1508
+ }
1509
+ return a;
1510
+ };
1511
+ var __spreadProps6 = (a, b) => __defProps6(a, __getOwnPropDescs6(b));
1512
+ var getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {}).map((variant) => __spreadProps6(__spreadValues8({}, variant), {
1513
+ testVariationId: variant.id,
1514
+ id: content == null ? void 0 : content.id
1515
+ }));
1516
+ var checkShouldRunVariants = ({
1517
+ canTrack,
1518
+ content
1519
+ }) => {
1520
+ const hasVariants = getVariants(content).length > 0;
1521
+ if (TARGET === "reactNative")
1522
+ return false;
1523
+ if (!hasVariants)
1524
+ return false;
1525
+ if (!canTrack)
1526
+ return false;
1527
+ if (TARGET === "vue2" || TARGET === "vue3")
1528
+ return true;
1529
+ if (isBrowser())
1530
+ return false;
1531
+ return true;
1532
+ };
1533
+ function bldrAbTest(contentId, variants, isHydrationTarget2) {
1534
+ var _a;
1535
+ function getAndSetVariantId2() {
1536
+ function setCookie2(name, value, days) {
1537
+ let expires = "";
1538
+ if (days) {
1539
+ const date = /* @__PURE__ */ new Date();
1540
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
1541
+ expires = "; expires=" + date.toUTCString();
1542
+ }
1543
+ document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
1544
+ }
1545
+ function getCookie2(name) {
1546
+ const nameEQ = name + "=";
1547
+ const ca = document.cookie.split(";");
1548
+ for (let i = 0; i < ca.length; i++) {
1549
+ let c = ca[i];
1550
+ while (c.charAt(0) === " ")
1551
+ c = c.substring(1, c.length);
1552
+ if (c.indexOf(nameEQ) === 0)
1553
+ return c.substring(nameEQ.length, c.length);
1554
+ }
1555
+ return null;
1556
+ }
1557
+ const cookieName = `builder.tests.${contentId}`;
1558
+ const variantInCookie = getCookie2(cookieName);
1559
+ const availableIDs = variants.map((vr) => vr.id).concat(contentId);
1560
+ if (variantInCookie && availableIDs.includes(variantInCookie)) {
1561
+ return variantInCookie;
1562
+ }
1563
+ let n = 0;
1564
+ const random = Math.random();
1565
+ for (let i = 0; i < variants.length; i++) {
1566
+ const variant = variants[i];
1567
+ const testRatio = variant.testRatio;
1568
+ n += testRatio;
1569
+ if (random < n) {
1570
+ setCookie2(cookieName, variant.id);
1571
+ return variant.id;
1572
+ }
1573
+ }
1574
+ setCookie2(cookieName, contentId);
1575
+ return contentId;
1576
+ }
1577
+ const winningVariantId = getAndSetVariantId2();
1578
+ const styleEl = (_a = document.currentScript) == null ? void 0 : _a.previousElementSibling;
1579
+ if (isHydrationTarget2) {
1580
+ styleEl.remove();
1581
+ const thisScriptEl = document.currentScript;
1582
+ thisScriptEl == null ? void 0 : thisScriptEl.remove();
1583
+ } else {
1584
+ const newStyleStr = variants.concat({
1585
+ id: contentId
1586
+ }).filter((variant) => variant.id !== winningVariantId).map((value) => {
1587
+ return `.variant-${value.id} { display: none; }
1588
+ `;
1589
+ }).join("");
1590
+ styleEl.innerHTML = newStyleStr;
1591
+ }
1592
+ }
1593
+ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
1594
+ var _a;
1595
+ if (!navigator.cookieEnabled) {
1596
+ return;
1597
+ }
1598
+ function getCookie2(name) {
1599
+ const nameEQ = name + "=";
1600
+ const ca = document.cookie.split(";");
1601
+ for (let i = 0; i < ca.length; i++) {
1602
+ let c = ca[i];
1603
+ while (c.charAt(0) === " ")
1604
+ c = c.substring(1, c.length);
1605
+ if (c.indexOf(nameEQ) === 0)
1606
+ return c.substring(nameEQ.length, c.length);
1607
+ }
1608
+ return null;
1609
+ }
1610
+ const cookieName = `builder.tests.${defaultContentId}`;
1611
+ const variantId = getCookie2(cookieName);
1612
+ const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
1613
+ const variantIsDefaultContent = variantContentId === defaultContentId;
1614
+ if (variantId === variantContentId) {
1615
+ if (variantIsDefaultContent) {
1616
+ return;
1617
+ }
1618
+ parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
1619
+ parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
1620
+ } else {
1621
+ if (variantIsDefaultContent) {
1622
+ if (isHydrationTarget2) {
1623
+ parentDiv == null ? void 0 : parentDiv.remove();
1624
+ } else {
1625
+ parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
1626
+ parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
1627
+ }
1628
+ }
1629
+ return;
1630
+ }
1631
+ return;
1632
+ }
1633
+ var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
1634
+ var isHydrationTarget = getIsHydrationTarget(TARGET);
1635
+ var AB_TEST_FN_NAME = "builderIoAbTest";
1636
+ var CONTENT_FN_NAME = "builderIoRenderContent";
1637
+ var getScriptString = () => {
1638
+ const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
1639
+ const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
1640
+ return `
1641
+ window.${AB_TEST_FN_NAME} = ${fnStr}
1642
+ window.${CONTENT_FN_NAME} = ${fnStr2}
1643
+ `;
1644
+ };
1645
+ var getVariantsScriptString = (variants, contentId) => {
1646
+ return `
1647
+ window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
1648
+ };
1649
+ var getRenderContentScriptString = ({
1650
+ contentId,
1651
+ variationId
1652
+ }) => {
1653
+ return `
1654
+ window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
1655
+ };
1656
+
1657
+ // src/components/content/content.jsx
1658
+ import { Show as Show10, createSignal as createSignal13 } from "solid-js";
1659
+
1660
+ // src/blocks/button/component-info.js
1661
+ var componentInfo = {
1662
+ name: "Core:Button",
1663
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
1664
+ defaultStyles: {
1665
+ appearance: "none",
1666
+ paddingTop: "15px",
1667
+ paddingBottom: "15px",
1668
+ paddingLeft: "25px",
1669
+ paddingRight: "25px",
1670
+ backgroundColor: "#000000",
1671
+ color: "white",
1672
+ borderRadius: "4px",
1673
+ textAlign: "center",
1674
+ cursor: "pointer"
1675
+ },
1676
+ inputs: [{
1677
+ name: "text",
1678
+ type: "text",
1679
+ defaultValue: "Click me!",
1680
+ bubble: true
1681
+ }, {
1682
+ name: "link",
1683
+ type: "url",
1684
+ bubble: true
1685
+ }, {
1686
+ name: "openLinkInNewTab",
1687
+ type: "boolean",
1688
+ defaultValue: false,
1689
+ friendlyName: "Open link in new tab"
1690
+ }],
1691
+ static: true,
1692
+ noWrap: true
1693
+ };
1694
+
1695
+ // src/blocks/columns/component-info.js
1696
+ var componentInfo2 = {
1697
+ name: "Columns",
1698
+ isRSC: true,
1699
+ inputs: [{
1700
+ name: "columns",
1701
+ type: "array",
1702
+ broadcast: true,
1703
+ subFields: [{
1704
+ name: "blocks",
1705
+ type: "array",
1706
+ hideFromUI: true,
1707
+ defaultValue: [{
1708
+ "@type": "@builder.io/sdk:Element",
1709
+ responsiveStyles: {
1710
+ large: {
1711
+ display: "flex",
1712
+ flexDirection: "column",
1713
+ alignItems: "stretch",
1714
+ flexShrink: "0",
1715
+ position: "relative",
1716
+ marginTop: "30px",
1717
+ textAlign: "center",
1718
+ lineHeight: "normal",
1719
+ height: "auto",
1720
+ minHeight: "20px",
1721
+ minWidth: "20px",
1722
+ overflow: "hidden"
1723
+ }
1724
+ },
1725
+ component: {
1726
+ name: "Image",
1727
+ options: {
1728
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1729
+ backgroundPosition: "center",
1730
+ backgroundSize: "cover",
1731
+ aspectRatio: 0.7004048582995948
1732
+ }
1733
+ }
1734
+ }, {
1735
+ "@type": "@builder.io/sdk:Element",
1736
+ responsiveStyles: {
1737
+ large: {
1738
+ display: "flex",
1739
+ flexDirection: "column",
1740
+ alignItems: "stretch",
1741
+ flexShrink: "0",
1742
+ position: "relative",
1743
+ marginTop: "30px",
1744
+ textAlign: "center",
1745
+ lineHeight: "normal",
1746
+ height: "auto"
1747
+ }
1748
+ },
1749
+ component: {
1750
+ name: "Text",
1751
+ options: {
1752
+ text: "<p>Enter some text...</p>"
1753
+ }
1754
+ }
1755
+ }]
1756
+ }, {
1757
+ name: "width",
1758
+ type: "number",
1759
+ hideFromUI: true,
1760
+ helperText: "Width %, e.g. set to 50 to fill half of the space"
1761
+ }, {
1762
+ name: "link",
1763
+ type: "url",
1764
+ helperText: "Optionally set a url that clicking this column will link to"
1765
+ }],
1766
+ defaultValue: [{
1767
+ blocks: [{
1768
+ "@type": "@builder.io/sdk:Element",
1769
+ responsiveStyles: {
1770
+ large: {
1771
+ display: "flex",
1772
+ flexDirection: "column",
1773
+ alignItems: "stretch",
1774
+ flexShrink: "0",
1775
+ position: "relative",
1776
+ marginTop: "30px",
1777
+ textAlign: "center",
1778
+ lineHeight: "normal",
1779
+ height: "auto",
1780
+ minHeight: "20px",
1781
+ minWidth: "20px",
1782
+ overflow: "hidden"
1783
+ }
1784
+ },
1785
+ component: {
1786
+ name: "Image",
1787
+ options: {
1788
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1789
+ backgroundPosition: "center",
1790
+ backgroundSize: "cover",
1791
+ aspectRatio: 0.7004048582995948
1792
+ }
1793
+ }
1794
+ }, {
1795
+ "@type": "@builder.io/sdk:Element",
1796
+ responsiveStyles: {
1797
+ large: {
1798
+ display: "flex",
1799
+ flexDirection: "column",
1800
+ alignItems: "stretch",
1801
+ flexShrink: "0",
1802
+ position: "relative",
1803
+ marginTop: "30px",
1804
+ textAlign: "center",
1805
+ lineHeight: "normal",
1806
+ height: "auto"
1807
+ }
1808
+ },
1809
+ component: {
1810
+ name: "Text",
1811
+ options: {
1812
+ text: "<p>Enter some text...</p>"
1813
+ }
1814
+ }
1815
+ }]
1816
+ }, {
1817
+ blocks: [{
1818
+ "@type": "@builder.io/sdk:Element",
1819
+ responsiveStyles: {
1820
+ large: {
1821
+ display: "flex",
1822
+ flexDirection: "column",
1823
+ alignItems: "stretch",
1824
+ flexShrink: "0",
1825
+ position: "relative",
1826
+ marginTop: "30px",
1827
+ textAlign: "center",
1828
+ lineHeight: "normal",
1829
+ height: "auto",
1830
+ minHeight: "20px",
1831
+ minWidth: "20px",
1832
+ overflow: "hidden"
1833
+ }
1834
+ },
1835
+ component: {
1836
+ name: "Image",
1837
+ options: {
1838
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1839
+ backgroundPosition: "center",
1840
+ backgroundSize: "cover",
1841
+ aspectRatio: 0.7004048582995948
1842
+ }
1843
+ }
1844
+ }, {
1845
+ "@type": "@builder.io/sdk:Element",
1846
+ responsiveStyles: {
1847
+ large: {
1848
+ display: "flex",
1849
+ flexDirection: "column",
1850
+ alignItems: "stretch",
1851
+ flexShrink: "0",
1852
+ position: "relative",
1853
+ marginTop: "30px",
1854
+ textAlign: "center",
1855
+ lineHeight: "normal",
1856
+ height: "auto"
1857
+ }
1858
+ },
1859
+ component: {
1860
+ name: "Text",
1861
+ options: {
1862
+ text: "<p>Enter some text...</p>"
1863
+ }
1864
+ }
1865
+ }]
1866
+ }],
1867
+ onChange: (options) => {
1868
+ function clearWidths() {
1869
+ columns.forEach((col) => {
1870
+ col.delete("width");
1871
+ });
1872
+ }
1873
+ const columns = options.get("columns");
1874
+ if (Array.isArray(columns)) {
1875
+ const containsColumnWithWidth = !!columns.find((col) => col.get("width"));
1876
+ if (containsColumnWithWidth) {
1877
+ const containsColumnWithoutWidth = !!columns.find((col) => !col.get("width"));
1878
+ if (containsColumnWithoutWidth) {
1879
+ clearWidths();
1880
+ } else {
1881
+ const sumWidths = columns.reduce((memo, col) => {
1882
+ return memo + col.get("width");
1883
+ }, 0);
1884
+ const widthsDontAddUp = sumWidths !== 100;
1885
+ if (widthsDontAddUp) {
1886
+ clearWidths();
1887
+ }
1888
+ }
1889
+ }
1890
+ }
1891
+ }
1892
+ }, {
1893
+ name: "space",
1894
+ type: "number",
1895
+ defaultValue: 20,
1896
+ helperText: "Size of gap between columns",
1897
+ advanced: true
1898
+ }, {
1899
+ name: "stackColumnsAt",
1900
+ type: "string",
1901
+ defaultValue: "tablet",
1902
+ helperText: "Convert horizontal columns to vertical at what device size",
1903
+ enum: ["tablet", "mobile", "never"],
1904
+ advanced: true
1905
+ }, {
1906
+ name: "reverseColumnsWhenStacked",
1907
+ type: "boolean",
1908
+ defaultValue: false,
1909
+ helperText: "When stacking columns for mobile devices, reverse the ordering",
1910
+ advanced: true
1911
+ }]
1912
+ };
1913
+
1914
+ // src/blocks/fragment/component-info.js
1915
+ var componentInfo3 = {
1916
+ name: "Fragment",
1917
+ static: true,
1918
+ hidden: true,
1919
+ canHaveChildren: true,
1920
+ noWrap: true
1921
+ };
1922
+
1923
+ // src/blocks/image/component-info.js
1924
+ var componentInfo4 = {
1925
+ name: "Image",
1926
+ static: true,
1927
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
1928
+ defaultStyles: {
1929
+ position: "relative",
1930
+ minHeight: "20px",
1931
+ minWidth: "20px",
1932
+ overflow: "hidden"
1933
+ },
1934
+ canHaveChildren: true,
1935
+ inputs: [{
1936
+ name: "image",
1937
+ type: "file",
1938
+ bubble: true,
1939
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
1940
+ required: true,
1941
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
1942
+ onChange: (options) => {
1943
+ const DEFAULT_ASPECT_RATIO = 0.7041;
1944
+ options.delete("srcset");
1945
+ options.delete("noWebp");
1946
+ function loadImage(url, timeout = 6e4) {
1947
+ return new Promise((resolve, reject) => {
1948
+ const img = document.createElement("img");
1949
+ let loaded = false;
1950
+ img.onload = () => {
1951
+ loaded = true;
1952
+ resolve(img);
1953
+ };
1954
+ img.addEventListener("error", (event) => {
1955
+ console.warn("Image load failed", event.error);
1956
+ reject(event.error);
1957
+ });
1958
+ img.src = url;
1959
+ setTimeout(() => {
1960
+ if (!loaded) {
1961
+ reject(new Error("Image load timed out"));
1962
+ }
1963
+ }, timeout);
1964
+ });
1965
+ }
1966
+ function round2(num) {
1967
+ return Math.round(num * 1e3) / 1e3;
1968
+ }
1969
+ const value = options.get("image");
1970
+ const aspectRatio = options.get("aspectRatio");
1971
+ fetch(value).then((res) => res.blob()).then((blob) => {
1972
+ if (blob.type.includes("svg")) {
1973
+ options.set("noWebp", true);
1974
+ }
1975
+ });
1976
+ if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) {
1977
+ return loadImage(value).then((img) => {
1978
+ const possiblyUpdatedAspectRatio = options.get("aspectRatio");
1979
+ if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
1980
+ if (img.width && img.height) {
1981
+ options.set("aspectRatio", round2(img.height / img.width));
1982
+ options.set("height", img.height);
1983
+ options.set("width", img.width);
1984
+ }
1985
+ }
1986
+ });
1987
+ }
1988
+ }
1989
+ }, {
1990
+ name: "backgroundSize",
1991
+ type: "text",
1992
+ defaultValue: "cover",
1993
+ enum: [{
1994
+ label: "contain",
1995
+ value: "contain",
1996
+ helperText: "The image should never get cropped"
1997
+ }, {
1998
+ label: "cover",
1999
+ value: "cover",
2000
+ helperText: "The image should fill it's box, cropping when needed"
2001
+ }]
2002
+ }, {
2003
+ name: "backgroundPosition",
2004
+ type: "text",
2005
+ defaultValue: "center",
2006
+ enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
2007
+ }, {
2008
+ name: "altText",
2009
+ type: "string",
2010
+ helperText: "Text to display when the user has images off"
2011
+ }, {
2012
+ name: "height",
2013
+ type: "number",
2014
+ hideFromUI: true
2015
+ }, {
2016
+ name: "width",
2017
+ type: "number",
2018
+ hideFromUI: true
2019
+ }, {
2020
+ name: "sizes",
2021
+ type: "string",
2022
+ hideFromUI: true
2023
+ }, {
2024
+ name: "srcset",
2025
+ type: "string",
2026
+ hideFromUI: true
2027
+ }, {
2028
+ name: "lazy",
2029
+ type: "boolean",
2030
+ defaultValue: true,
2031
+ hideFromUI: true
2032
+ }, {
2033
+ name: "fitContent",
2034
+ type: "boolean",
2035
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
2036
+ defaultValue: true
2037
+ }, {
2038
+ name: "aspectRatio",
2039
+ type: "number",
2040
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
2041
+ advanced: true,
2042
+ defaultValue: 0.7041
2043
+ }]
2044
+ };
2045
+
2046
+ // src/blocks/section/component-info.js
2047
+ var componentInfo5 = {
2048
+ name: "Core:Section",
2049
+ static: true,
2050
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
2051
+ inputs: [{
2052
+ name: "maxWidth",
2053
+ type: "number",
2054
+ defaultValue: 1200
2055
+ }, {
2056
+ name: "lazyLoad",
2057
+ type: "boolean",
2058
+ defaultValue: false,
2059
+ advanced: true,
2060
+ description: "Only render this section when in view"
2061
+ }],
2062
+ defaultStyles: {
2063
+ paddingLeft: "20px",
2064
+ paddingRight: "20px",
2065
+ paddingTop: "50px",
2066
+ paddingBottom: "50px",
2067
+ marginTop: "0px",
2068
+ width: "100vw",
2069
+ marginLeft: "calc(50% - 50vw)"
2070
+ },
2071
+ canHaveChildren: true,
2072
+ defaultChildren: [{
2073
+ "@type": "@builder.io/sdk:Element",
2074
+ responsiveStyles: {
2075
+ large: {
2076
+ textAlign: "center"
2077
+ }
2078
+ },
2079
+ component: {
2080
+ name: "Text",
2081
+ options: {
2082
+ text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
2083
+ }
2084
+ }
2085
+ }]
2086
+ };
2087
+
2088
+ // src/blocks/symbol/component-info.js
2089
+ var componentInfo6 = {
2090
+ name: "Symbol",
2091
+ noWrap: true,
2092
+ static: true,
2093
+ isRSC: true,
2094
+ inputs: [{
2095
+ name: "symbol",
2096
+ type: "uiSymbol"
2097
+ }, {
2098
+ name: "dataOnly",
2099
+ helperText: "Make this a data symbol that doesn't display any UI",
2100
+ type: "boolean",
2101
+ defaultValue: false,
2102
+ advanced: true,
2103
+ hideFromUI: true
2104
+ }, {
2105
+ name: "inheritState",
2106
+ helperText: "Inherit the parent component state and data",
2107
+ type: "boolean",
2108
+ defaultValue: false,
2109
+ advanced: true
2110
+ }, {
2111
+ name: "renderToLiquid",
2112
+ helperText: "Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",
2113
+ type: "boolean",
2114
+ defaultValue: false,
2115
+ advanced: true,
2116
+ hideFromUI: true
2117
+ }, {
2118
+ name: "useChildren",
2119
+ hideFromUI: true,
2120
+ type: "boolean"
2121
+ }]
2122
+ };
2123
+
2124
+ // src/blocks/text/component-info.js
2125
+ var componentInfo7 = {
2126
+ name: "Text",
2127
+ static: true,
2128
+ isRSC: true,
2129
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
2130
+ inputs: [{
2131
+ name: "text",
2132
+ type: "html",
2133
+ required: true,
2134
+ autoFocus: true,
2135
+ bubble: true,
2136
+ defaultValue: "Enter some text..."
2137
+ }],
2138
+ defaultStyles: {
2139
+ lineHeight: "normal",
2140
+ height: "auto",
2141
+ textAlign: "center"
2142
+ }
2143
+ };
2144
+
2145
+ // src/blocks/text/text.jsx
2146
+ function Text(props) {
2147
+ return <span
2148
+ class="builder-text"
2149
+ innerHTML={props.text?.toString() || ""}
2150
+ style={{
2151
+ outline: "none"
2152
+ }}
2153
+ />;
2154
+ }
2155
+ var text_default = Text;
2156
+
2157
+ // src/blocks/video/component-info.js
2158
+ var componentInfo8 = {
2159
+ name: "Video",
2160
+ canHaveChildren: true,
2161
+ defaultStyles: {
2162
+ minHeight: "20px",
2163
+ minWidth: "20px"
2164
+ },
2165
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
2166
+ inputs: [{
2167
+ name: "video",
2168
+ type: "file",
2169
+ allowedFileTypes: ["mp4"],
2170
+ bubble: true,
2171
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
2172
+ required: true
2173
+ }, {
2174
+ name: "posterImage",
2175
+ type: "file",
2176
+ allowedFileTypes: ["jpeg", "png"],
2177
+ helperText: "Image to show before the video plays"
2178
+ }, {
2179
+ name: "autoPlay",
2180
+ type: "boolean",
2181
+ defaultValue: true
2182
+ }, {
2183
+ name: "controls",
2184
+ type: "boolean",
2185
+ defaultValue: false
2186
+ }, {
2187
+ name: "muted",
2188
+ type: "boolean",
2189
+ defaultValue: true
2190
+ }, {
2191
+ name: "loop",
2192
+ type: "boolean",
2193
+ defaultValue: true
2194
+ }, {
2195
+ name: "playsInline",
2196
+ type: "boolean",
2197
+ defaultValue: true
2198
+ }, {
2199
+ name: "fit",
2200
+ type: "text",
2201
+ defaultValue: "cover",
2202
+ enum: ["contain", "cover", "fill", "auto"]
2203
+ }, {
2204
+ name: "preload",
2205
+ type: "text",
2206
+ defaultValue: "metadata",
2207
+ enum: ["auto", "metadata", "none"]
2208
+ }, {
2209
+ name: "fitContent",
2210
+ type: "boolean",
2211
+ helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
2212
+ defaultValue: true,
2213
+ advanced: true
2214
+ }, {
2215
+ name: "position",
2216
+ type: "text",
2217
+ defaultValue: "center",
2218
+ enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
2219
+ }, {
2220
+ name: "height",
2221
+ type: "number",
2222
+ advanced: true
2223
+ }, {
2224
+ name: "width",
2225
+ type: "number",
2226
+ advanced: true
2227
+ }, {
2228
+ name: "aspectRatio",
2229
+ type: "number",
2230
+ advanced: true,
2231
+ defaultValue: 0.7004048582995948
2232
+ }, {
2233
+ name: "lazyLoad",
2234
+ type: "boolean",
2235
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
2236
+ defaultValue: true,
2237
+ advanced: true
2238
+ }]
2239
+ };
2240
+
2241
+ // src/blocks/video/video.jsx
2242
+ import { createSignal as createSignal8 } from "solid-js";
2243
+ function Video(props) {
2244
+ function videoProps() {
2245
+ return {
2246
+ ...props.autoPlay === true ? {
2247
+ autoPlay: true
2248
+ } : {},
2249
+ ...props.muted === true ? {
2250
+ muted: true
2251
+ } : {},
2252
+ ...props.controls === true ? {
2253
+ controls: true
2254
+ } : {},
2255
+ ...props.loop === true ? {
2256
+ loop: true
2257
+ } : {},
2258
+ ...props.playsInline === true ? {
2259
+ playsInline: true
2260
+ } : {}
2261
+ };
2262
+ }
2263
+ function spreadProps() {
2264
+ return {
2265
+ ...props.attributes,
2266
+ ...videoProps()
2267
+ };
2268
+ }
2269
+ return <video
2270
+ {...spreadProps()}
2271
+ preload={props.preload || "metadata"}
2272
+ style={{
2273
+ width: "100%",
2274
+ height: "100%",
2275
+ ...props.attributes?.style,
2276
+ "object-fit": props.fit,
2277
+ "object-position": props.position,
2278
+ // Hack to get object fit to work as expected and
2279
+ // not have the video overflow
2280
+ "border-radius": 1
2281
+ }}
2282
+ src={props.video || "no-src"}
2283
+ poster={props.posterImage}
2284
+ />;
2285
+ }
2286
+ var video_default = Video;
2287
+
2288
+ // src/blocks/embed/component-info.js
2289
+ var componentInfo9 = {
2290
+ name: "Embed",
2291
+ static: true,
2292
+ inputs: [{
2293
+ name: "url",
2294
+ type: "url",
2295
+ required: true,
2296
+ defaultValue: "",
2297
+ helperText: "e.g. enter a youtube url, google map, etc",
2298
+ onChange: (options) => {
2299
+ const url = options.get("url");
2300
+ if (url) {
2301
+ options.set("content", "Loading...");
2302
+ const apiKey = "ae0e60e78201a3f2b0de4b";
2303
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2304
+ if (options.get("url") === url) {
2305
+ if (data.html) {
2306
+ options.set("content", data.html);
2307
+ } else {
2308
+ options.set("content", "Invalid url, please try another");
2309
+ }
2310
+ }
2311
+ }).catch((_err) => {
2312
+ options.set("content", "There was an error embedding this URL, please try again or another URL");
2313
+ });
2314
+ } else {
2315
+ options.delete("content");
2316
+ }
2317
+ }
2318
+ }, {
2319
+ name: "content",
2320
+ type: "html",
2321
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
2322
+ hideFromUI: true
2323
+ }]
2324
+ };
2325
+
2326
+ // src/blocks/embed/embed.jsx
2327
+ import { on, createEffect, createSignal as createSignal9 } from "solid-js";
2328
+
2329
+ // src/blocks/embed/helpers.js
2330
+ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
2331
+ var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2332
+
2333
+ // src/blocks/embed/embed.jsx
2334
+ function Embed(props) {
2335
+ const [scriptsInserted, setScriptsInserted] = createSignal9([]);
2336
+ const [scriptsRun, setScriptsRun] = createSignal9([]);
2337
+ const [ranInitFn, setRanInitFn] = createSignal9(false);
2338
+ function findAndRunScripts() {
2339
+ if (!elem || !elem.getElementsByTagName)
2340
+ return;
2341
+ const scripts = elem.getElementsByTagName("script");
2342
+ for (let i = 0; i < scripts.length; i++) {
2343
+ const script = scripts[i];
2344
+ if (script.src && !scriptsInserted().includes(script.src)) {
2345
+ scriptsInserted().push(script.src);
2346
+ const newScript = document.createElement("script");
2347
+ newScript.async = true;
2348
+ newScript.src = script.src;
2349
+ document.head.appendChild(newScript);
2350
+ } else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
2351
+ try {
2352
+ scriptsRun().push(script.innerText);
2353
+ new Function(script.innerText)();
2354
+ } catch (error) {
2355
+ console.warn("`Embed`: Error running script:", error);
2356
+ }
2357
+ }
2358
+ }
2359
+ }
2360
+ let elem;
2361
+ function onUpdateFn_0() {
2362
+ if (elem && !ranInitFn()) {
2363
+ setRanInitFn(true);
2364
+ findAndRunScripts();
2365
+ }
2366
+ }
2367
+ createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2368
+ return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
2369
+ }
2370
+ var embed_default = Embed;
2371
+
2372
+ // src/blocks/img/img.jsx
2373
+ function ImgComponent(props) {
2374
+ return <img
2375
+ style={{
2376
+ "object-fit": props.backgroundSize || "cover",
2377
+ "object-position": props.backgroundPosition || "center"
2378
+ }}
2379
+ key={isEditing() && props.imgSrc || "default-key"}
2380
+ alt={props.altText}
2381
+ src={props.imgSrc || props.image}
2382
+ {...{}}
2383
+ {...props.attributes}
2384
+ />;
2385
+ }
2386
+ var img_default = ImgComponent;
2387
+
2388
+ // src/blocks/img/component-info.js
2389
+ var componentInfo10 = {
2390
+ name: "Raw:Img",
2391
+ hideFromInsertMenu: true,
2392
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
2393
+ inputs: [{
2394
+ name: "image",
2395
+ bubble: true,
2396
+ type: "file",
2397
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
2398
+ required: true
2399
+ }],
2400
+ noWrap: true,
2401
+ static: true
2402
+ };
2403
+
2404
+ // src/blocks/custom-code/custom-code.jsx
2405
+ import { onMount, createSignal as createSignal10 } from "solid-js";
2406
+ function CustomCode(props) {
2407
+ const [scriptsInserted, setScriptsInserted] = createSignal10([]);
2408
+ const [scriptsRun, setScriptsRun] = createSignal10([]);
2409
+ function findAndRunScripts() {
2410
+ if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
2411
+ const scripts = elem.getElementsByTagName("script");
2412
+ for (let i = 0; i < scripts.length; i++) {
2413
+ const script = scripts[i];
2414
+ if (script.src) {
2415
+ if (scriptsInserted().includes(script.src)) {
2416
+ continue;
2417
+ }
2418
+ scriptsInserted().push(script.src);
2419
+ const newScript = document.createElement("script");
2420
+ newScript.async = true;
2421
+ newScript.src = script.src;
2422
+ document.head.appendChild(newScript);
2423
+ } else if (!script.type || [
2424
+ "text/javascript",
2425
+ "application/javascript",
2426
+ "application/ecmascript"
2427
+ ].includes(script.type)) {
2428
+ if (scriptsRun().includes(script.innerText)) {
2429
+ continue;
2430
+ }
2431
+ try {
2432
+ scriptsRun().push(script.innerText);
2433
+ new Function(script.innerText)();
2434
+ } catch (error) {
2435
+ console.warn("`CustomCode`: Error running script:", error);
2436
+ }
2437
+ }
2438
+ }
2439
+ }
2440
+ }
2441
+ let elem;
2442
+ onMount(() => {
2443
+ findAndRunScripts();
2444
+ });
2445
+ return <div
2446
+ class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
2447
+ ref={elem}
2448
+ innerHTML={props.code}
2449
+ />;
2450
+ }
2451
+ var custom_code_default = CustomCode;
2452
+
2453
+ // src/blocks/custom-code/component-info.js
2454
+ var componentInfo11 = {
2455
+ name: "Custom Code",
2456
+ static: true,
2457
+ requiredPermissions: ["editCode"],
2458
+ inputs: [{
2459
+ name: "code",
2460
+ type: "html",
2461
+ required: true,
2462
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
2463
+ code: true
2464
+ }, {
2465
+ name: "replaceNodes",
2466
+ type: "boolean",
2467
+ helperText: "Preserve server rendered dom nodes",
2468
+ advanced: true
2469
+ }, {
2470
+ name: "scriptsClientOnly",
2471
+ type: "boolean",
2472
+ defaultValue: false,
2473
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
2474
+ advanced: true
2475
+ }]
2476
+ };
2477
+
2478
+ // src/constants/builder-registered-components.js
2479
+ var __defProp9 = Object.defineProperty;
2480
+ var __getOwnPropSymbols9 = Object.getOwnPropertySymbols;
2481
+ var __hasOwnProp9 = Object.prototype.hasOwnProperty;
2482
+ var __propIsEnum9 = Object.prototype.propertyIsEnumerable;
2483
+ var __defNormalProp9 = (obj, key, value) => key in obj ? __defProp9(obj, key, {
2484
+ enumerable: true,
2485
+ configurable: true,
2486
+ writable: true,
2487
+ value
2488
+ }) : obj[key] = value;
2489
+ var __spreadValues9 = (a, b) => {
2490
+ for (var prop in b || (b = {}))
2491
+ if (__hasOwnProp9.call(b, prop))
2492
+ __defNormalProp9(a, prop, b[prop]);
2493
+ if (__getOwnPropSymbols9)
2494
+ for (var prop of __getOwnPropSymbols9(b)) {
2495
+ if (__propIsEnum9.call(b, prop))
2496
+ __defNormalProp9(a, prop, b[prop]);
2497
+ }
2498
+ return a;
2499
+ };
2500
+ var getDefaultRegisteredComponents = () => [__spreadValues9({
2501
+ component: button_default
2502
+ }, componentInfo), __spreadValues9({
2503
+ component: columns_default
2504
+ }, componentInfo2), __spreadValues9({
2505
+ component: custom_code_default
2506
+ }, componentInfo11), __spreadValues9({
2507
+ component: embed_default
2508
+ }, componentInfo9), __spreadValues9({
2509
+ component: fragment_default
2510
+ }, componentInfo3), __spreadValues9({
2511
+ component: image_default
2512
+ }, componentInfo4), __spreadValues9({
2513
+ component: img_default
2514
+ }, componentInfo10), __spreadValues9({
2515
+ component: section_default
2516
+ }, componentInfo5), __spreadValues9({
2517
+ component: symbol_default
2518
+ }, componentInfo6), __spreadValues9({
2519
+ component: text_default
2520
+ }, componentInfo7), __spreadValues9({
2521
+ component: video_default
2522
+ }, componentInfo8)];
2523
+
2524
+ // src/functions/register-component.js
2525
+ var __defProp10 = Object.defineProperty;
2526
+ var __defProps7 = Object.defineProperties;
2527
+ var __getOwnPropDescs7 = Object.getOwnPropertyDescriptors;
2528
+ var __getOwnPropSymbols10 = Object.getOwnPropertySymbols;
2529
+ var __hasOwnProp10 = Object.prototype.hasOwnProperty;
2530
+ var __propIsEnum10 = Object.prototype.propertyIsEnumerable;
2531
+ var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp10(obj, key, {
2532
+ enumerable: true,
2533
+ configurable: true,
2534
+ writable: true,
2535
+ value
2536
+ }) : obj[key] = value;
2537
+ var __spreadValues10 = (a, b) => {
2538
+ for (var prop in b || (b = {}))
2539
+ if (__hasOwnProp10.call(b, prop))
2540
+ __defNormalProp10(a, prop, b[prop]);
2541
+ if (__getOwnPropSymbols10)
2542
+ for (var prop of __getOwnPropSymbols10(b)) {
2543
+ if (__propIsEnum10.call(b, prop))
2544
+ __defNormalProp10(a, prop, b[prop]);
2545
+ }
2546
+ return a;
2547
+ };
2548
+ var __spreadProps7 = (a, b) => __defProps7(a, __getOwnPropDescs7(b));
2549
+ var __objRest2 = (source, exclude) => {
2550
+ var target = {};
2551
+ for (var prop in source)
2552
+ if (__hasOwnProp10.call(source, prop) && exclude.indexOf(prop) < 0)
2553
+ target[prop] = source[prop];
2554
+ if (source != null && __getOwnPropSymbols10)
2555
+ for (var prop of __getOwnPropSymbols10(source)) {
2556
+ if (exclude.indexOf(prop) < 0 && __propIsEnum10.call(source, prop))
2557
+ target[prop] = source[prop];
2558
+ }
2559
+ return target;
2560
+ };
2561
+ var components = [];
2562
+ var createRegisterComponentMessage = (info) => ({
2563
+ type: "builder.registerComponent",
2564
+ data: serializeComponentInfo(info)
2565
+ });
2566
+ var serializeFn = (fnValue) => {
2567
+ const fnStr = fnValue.toString().trim();
2568
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
2569
+ return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
2570
+ };
2571
+ var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
2572
+ var serializeComponentInfo = (_a) => {
2573
+ var _b = _a, {
2574
+ inputs
2575
+ } = _b, info = __objRest2(_b, ["inputs"]);
2576
+ return __spreadProps7(__spreadValues10({}, fastClone(info)), {
2577
+ inputs: inputs == null ? void 0 : inputs.map((input) => Object.entries(input).reduce((acc, [key, value]) => __spreadProps7(__spreadValues10({}, acc), {
2578
+ [key]: serializeValue(value)
2579
+ }), {}))
2580
+ });
2581
+ };
2582
+
2583
+ // src/components/content/components/styles.jsx
2584
+ import { createSignal as createSignal11 } from "solid-js";
2585
+
2586
+ // src/components/content/components/styles.helpers.js
2587
+ var getCssFromFont = (font) => {
2588
+ var _a, _b;
2589
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
2590
+ const name = family.split(",")[0];
2591
+ const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
2592
+ let str = "";
2593
+ if (url && family && name) {
2594
+ str += `
2595
+ @font-face {
2596
+ font-family: "${family}";
2597
+ src: local("${name}"), url('${url}') format('woff2');
2598
+ font-display: fallback;
2599
+ font-weight: 400;
2600
+ }
2601
+ `.trim();
2602
+ }
2603
+ if (font.files) {
2604
+ for (const weight in font.files) {
2605
+ const isNumber = String(Number(weight)) === weight;
2606
+ if (!isNumber) {
2607
+ continue;
2608
+ }
2609
+ const weightUrl = font.files[weight];
2610
+ if (weightUrl && weightUrl !== url) {
2611
+ str += `
2612
+ @font-face {
2613
+ font-family: "${family}";
2614
+ src: url('${weightUrl}') format('woff2');
2615
+ font-display: fallback;
2616
+ font-weight: ${weight};
2617
+ }
2618
+ `.trim();
2619
+ }
2620
+ }
2621
+ }
2622
+ return str;
2623
+ };
2624
+ var getFontCss = ({
2625
+ customFonts
2626
+ }) => {
2627
+ var _a;
2628
+ return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
2629
+ };
2630
+ var getCss = ({
2631
+ cssCode,
2632
+ contentId
2633
+ }) => {
2634
+ if (!cssCode) {
2635
+ return "";
2636
+ }
2637
+ if (!contentId) {
2638
+ return cssCode;
2639
+ }
2640
+ return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
2641
+ };
2642
+
2643
+ // src/components/content/components/styles.jsx
2644
+ function ContentStyles(props) {
2645
+ const [injectedStyles, setInjectedStyles] = createSignal11(
2646
+ `
2647
+ ${getCss({
2648
+ cssCode: props.cssCode,
2649
+ contentId: props.contentId
2650
+ })}
2651
+ ${getFontCss({
2652
+ customFonts: props.customFonts
2653
+ })}
2654
+
2655
+ .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
2656
+ margin: 0;
2657
+ }
2658
+ .builder-text > p, .builder-text > .builder-paragraph {
2659
+ color: inherit;
2660
+ line-height: inherit;
2661
+ letter-spacing: inherit;
2662
+ font-weight: inherit;
2663
+ font-size: inherit;
2664
+ text-align: inherit;
2665
+ font-family: inherit;
2666
+ }
2667
+ `.trim()
2668
+ );
2669
+ return <Inlined_styles_default styles={injectedStyles()} />;
2670
+ }
2671
+ var Styles_default = ContentStyles;
2672
+
2673
+ // src/components/content/content.helpers.js
2674
+ var __defProp11 = Object.defineProperty;
2675
+ var __defProps8 = Object.defineProperties;
2676
+ var __getOwnPropDescs8 = Object.getOwnPropertyDescriptors;
2677
+ var __getOwnPropSymbols11 = Object.getOwnPropertySymbols;
2678
+ var __hasOwnProp11 = Object.prototype.hasOwnProperty;
2679
+ var __propIsEnum11 = Object.prototype.propertyIsEnumerable;
2680
+ var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp11(obj, key, {
2681
+ enumerable: true,
2682
+ configurable: true,
2683
+ writable: true,
2684
+ value
2685
+ }) : obj[key] = value;
2686
+ var __spreadValues11 = (a, b) => {
2687
+ for (var prop in b || (b = {}))
2688
+ if (__hasOwnProp11.call(b, prop))
2689
+ __defNormalProp11(a, prop, b[prop]);
2690
+ if (__getOwnPropSymbols11)
2691
+ for (var prop of __getOwnPropSymbols11(b)) {
2692
+ if (__propIsEnum11.call(b, prop))
2693
+ __defNormalProp11(a, prop, b[prop]);
2694
+ }
2695
+ return a;
2696
+ };
2697
+ var __spreadProps8 = (a, b) => __defProps8(a, __getOwnPropDescs8(b));
2698
+ var getContextStateInitialValue = ({
2699
+ content,
2700
+ data,
2701
+ locale
2702
+ }) => {
2703
+ var _a, _b, _c;
2704
+ const defaultValues = {};
2705
+ (_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
2706
+ var _a2;
2707
+ if (input.name && input.defaultValue !== void 0 && ((_a2 = content == null ? void 0 : content.data) == null ? void 0 : _a2.state) && content.data.state[input.name] === void 0) {
2708
+ defaultValues[input.name] = input.defaultValue;
2709
+ }
2710
+ });
2711
+ const stateToUse = __spreadValues11(__spreadValues11(__spreadValues11({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
2712
+ locale
2713
+ } : {});
2714
+ return __spreadValues11(__spreadValues11({}, defaultValues), stateToUse);
2715
+ };
2716
+ var getContentInitialValue = ({
2717
+ content,
2718
+ data
2719
+ }) => {
2720
+ return !content ? void 0 : __spreadProps8(__spreadValues11({}, content), {
2721
+ data: __spreadValues11(__spreadValues11({}, content == null ? void 0 : content.data), data),
2722
+ meta: content == null ? void 0 : content.meta
2723
+ });
2724
+ };
2725
+
2726
+ // src/components/content/components/enable-editor.jsx
2727
+ import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal12 } from "solid-js";
2728
+
2729
+ // src/functions/get-global-this.js
2730
+ function getGlobalThis() {
2731
+ if (typeof globalThis !== "undefined") {
2732
+ return globalThis;
2733
+ }
2734
+ if (typeof window !== "undefined") {
2735
+ return window;
2736
+ }
2737
+ if (typeof global !== "undefined") {
2738
+ return global;
2739
+ }
2740
+ if (typeof self !== "undefined") {
2741
+ return self;
2742
+ }
2743
+ return globalThis;
2744
+ }
2745
+
2746
+ // src/functions/get-fetch.js
2747
+ function getFetch() {
2748
+ const globalFetch = getGlobalThis().fetch;
2749
+ if (typeof globalFetch === "undefined") {
2750
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2751
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
2752
+ throw new Error("Builder SDK could not find a global `fetch` function");
2753
+ }
2754
+ return globalFetch;
2755
+ }
2756
+ var fetch2 = getFetch();
2757
+
2758
+ // src/helpers/url.js
2759
+ var getTopLevelDomain = (host) => {
2760
+ if (host === "localhost" || host === "127.0.0.1") {
2761
+ return host;
2762
+ }
2763
+ const parts = host.split(".");
2764
+ if (parts.length > 2) {
2765
+ return parts.slice(1).join(".");
2766
+ }
2767
+ return host;
2768
+ };
2769
+
2770
+ // src/helpers/cookie.js
2771
+ var __async = (__this, __arguments, generator) => {
2772
+ return new Promise((resolve, reject) => {
2773
+ var fulfilled = (value) => {
2774
+ try {
2775
+ step(generator.next(value));
2776
+ } catch (e) {
2777
+ reject(e);
2778
+ }
2779
+ };
2780
+ var rejected = (value) => {
2781
+ try {
2782
+ step(generator.throw(value));
2783
+ } catch (e) {
2784
+ reject(e);
2785
+ }
2786
+ };
2787
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2788
+ step((generator = generator.apply(__this, __arguments)).next());
2789
+ });
2790
+ };
2791
+ var getCookieSync = ({
2792
+ name,
2793
+ canTrack
2794
+ }) => {
2795
+ var _a;
2796
+ try {
2797
+ if (!canTrack) {
2798
+ return void 0;
2799
+ }
2800
+ return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
2801
+ } catch (err) {
2802
+ logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
2803
+ return void 0;
2804
+ }
2805
+ };
2806
+ var getCookie = (args) => __async(void 0, null, function* () {
2807
+ return getCookieSync(args);
2808
+ });
2809
+ var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
2810
+ var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
2811
+ var createCookieString = ({
2812
+ name,
2813
+ value,
2814
+ expires
2815
+ }) => {
2816
+ const secure = isBrowser() ? location.protocol === "https:" : true;
2817
+ const secureObj = secure ? SECURE_CONFIG : [[]];
2818
+ const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
2819
+ const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
2820
+ const cookie = stringifyCookie(cookieValue);
2821
+ return cookie;
2822
+ };
2823
+ var setCookie = (_0) => __async(void 0, [_0], function* ({
2824
+ name,
2825
+ value,
2826
+ expires,
2827
+ canTrack
2828
+ }) {
2829
+ try {
2830
+ if (!canTrack) {
2831
+ return;
2832
+ }
2833
+ const cookie = createCookieString({
2834
+ name,
2835
+ value,
2836
+ expires
2837
+ });
2838
+ document.cookie = cookie;
2839
+ } catch (err) {
2840
+ logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
2841
+ }
2842
+ });
2843
+
2844
+ // src/helpers/uuid.js
2845
+ function uuidv4() {
2846
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
2847
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
2848
+ return v.toString(16);
2849
+ });
2850
+ }
2851
+ function uuid() {
2852
+ return uuidv4().replace(/-/g, "");
2853
+ }
2854
+
2855
+ // src/helpers/sessionId.js
2856
+ var __async2 = (__this, __arguments, generator) => {
2857
+ return new Promise((resolve, reject) => {
2858
+ var fulfilled = (value) => {
2859
+ try {
2860
+ step(generator.next(value));
2861
+ } catch (e) {
2862
+ reject(e);
2863
+ }
2864
+ };
2865
+ var rejected = (value) => {
2866
+ try {
2867
+ step(generator.throw(value));
2868
+ } catch (e) {
2869
+ reject(e);
2870
+ }
2871
+ };
2872
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2873
+ step((generator = generator.apply(__this, __arguments)).next());
2874
+ });
2875
+ };
2876
+ var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
2877
+ var getSessionId = (_0) => __async2(void 0, [_0], function* ({
2878
+ canTrack
2879
+ }) {
2880
+ if (!canTrack) {
2881
+ return void 0;
2882
+ }
2883
+ const sessionId = yield getCookie({
2884
+ name: SESSION_LOCAL_STORAGE_KEY,
2885
+ canTrack
2886
+ });
2887
+ if (checkIsDefined(sessionId)) {
2888
+ return sessionId;
2889
+ } else {
2890
+ const newSessionId = createSessionId();
2891
+ setSessionId({
2892
+ id: newSessionId,
2893
+ canTrack
2894
+ });
2895
+ return newSessionId;
2896
+ }
2897
+ });
2898
+ var createSessionId = () => uuid();
2899
+ var setSessionId = ({
2900
+ id,
2901
+ canTrack
2902
+ }) => setCookie({
2903
+ name: SESSION_LOCAL_STORAGE_KEY,
2904
+ value: id,
2905
+ canTrack
2906
+ });
2907
+
2908
+ // src/helpers/localStorage.js
2909
+ var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
2910
+ var getLocalStorageItem = ({
2911
+ key,
2912
+ canTrack
2913
+ }) => {
2914
+ var _a;
2915
+ try {
2916
+ if (canTrack) {
2917
+ return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
2918
+ }
2919
+ return void 0;
2920
+ } catch (err) {
2921
+ console.debug("[LocalStorage] GET error: ", err);
2922
+ return void 0;
2923
+ }
2924
+ };
2925
+ var setLocalStorageItem = ({
2926
+ key,
2927
+ canTrack,
2928
+ value
2929
+ }) => {
2930
+ var _a;
2931
+ try {
2932
+ if (canTrack) {
2933
+ (_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
2934
+ }
2935
+ } catch (err) {
2936
+ console.debug("[LocalStorage] SET error: ", err);
2937
+ }
2938
+ };
2939
+
2940
+ // src/helpers/visitorId.js
2941
+ var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
2942
+ var getVisitorId = ({
2943
+ canTrack
2944
+ }) => {
2945
+ if (!canTrack) {
2946
+ return void 0;
2947
+ }
2948
+ const visitorId = getLocalStorageItem({
2949
+ key: VISITOR_LOCAL_STORAGE_KEY,
2950
+ canTrack
2951
+ });
2952
+ if (checkIsDefined(visitorId)) {
2953
+ return visitorId;
2954
+ } else {
2955
+ const newVisitorId = createVisitorId();
2956
+ setVisitorId({
2957
+ id: newVisitorId,
2958
+ canTrack
2959
+ });
2960
+ return newVisitorId;
2961
+ }
2962
+ };
2963
+ var createVisitorId = () => uuid();
2964
+ var setVisitorId = ({
2965
+ id,
2966
+ canTrack
2967
+ }) => setLocalStorageItem({
2968
+ key: VISITOR_LOCAL_STORAGE_KEY,
2969
+ value: id,
2970
+ canTrack
2971
+ });
2972
+
2973
+ // src/functions/track/index.js
2974
+ var __defProp12 = Object.defineProperty;
2975
+ var __defProps9 = Object.defineProperties;
2976
+ var __getOwnPropDescs9 = Object.getOwnPropertyDescriptors;
2977
+ var __getOwnPropSymbols12 = Object.getOwnPropertySymbols;
2978
+ var __hasOwnProp12 = Object.prototype.hasOwnProperty;
2979
+ var __propIsEnum12 = Object.prototype.propertyIsEnumerable;
2980
+ var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp12(obj, key, {
2981
+ enumerable: true,
2982
+ configurable: true,
2983
+ writable: true,
2984
+ value
2985
+ }) : obj[key] = value;
2986
+ var __spreadValues12 = (a, b) => {
2987
+ for (var prop in b || (b = {}))
2988
+ if (__hasOwnProp12.call(b, prop))
2989
+ __defNormalProp12(a, prop, b[prop]);
2990
+ if (__getOwnPropSymbols12)
2991
+ for (var prop of __getOwnPropSymbols12(b)) {
2992
+ if (__propIsEnum12.call(b, prop))
2993
+ __defNormalProp12(a, prop, b[prop]);
2994
+ }
2995
+ return a;
2996
+ };
2997
+ var __spreadProps9 = (a, b) => __defProps9(a, __getOwnPropDescs9(b));
2998
+ var __objRest3 = (source, exclude) => {
2999
+ var target = {};
3000
+ for (var prop in source)
3001
+ if (__hasOwnProp12.call(source, prop) && exclude.indexOf(prop) < 0)
3002
+ target[prop] = source[prop];
3003
+ if (source != null && __getOwnPropSymbols12)
3004
+ for (var prop of __getOwnPropSymbols12(source)) {
3005
+ if (exclude.indexOf(prop) < 0 && __propIsEnum12.call(source, prop))
3006
+ target[prop] = source[prop];
3007
+ }
3008
+ return target;
3009
+ };
3010
+ var __async3 = (__this, __arguments, generator) => {
3011
+ return new Promise((resolve, reject) => {
3012
+ var fulfilled = (value) => {
3013
+ try {
3014
+ step(generator.next(value));
3015
+ } catch (e) {
3016
+ reject(e);
3017
+ }
3018
+ };
3019
+ var rejected = (value) => {
3020
+ try {
3021
+ step(generator.throw(value));
3022
+ } catch (e) {
3023
+ reject(e);
3024
+ }
3025
+ };
3026
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3027
+ step((generator = generator.apply(__this, __arguments)).next());
3028
+ });
3029
+ };
3030
+ var getTrackingEventData = (_0) => __async3(void 0, [_0], function* ({
3031
+ canTrack
3032
+ }) {
3033
+ if (!canTrack) {
3034
+ return {
3035
+ visitorId: void 0,
3036
+ sessionId: void 0
3037
+ };
3038
+ }
3039
+ const sessionId = yield getSessionId({
3040
+ canTrack
3041
+ });
3042
+ const visitorId = getVisitorId({
3043
+ canTrack
3044
+ });
3045
+ return {
3046
+ sessionId,
3047
+ visitorId
3048
+ };
3049
+ });
3050
+ var createEvent = (_a) => __async3(void 0, null, function* () {
3051
+ var _b = _a, {
3052
+ type: eventType,
3053
+ canTrack,
3054
+ apiKey,
3055
+ metadata
3056
+ } = _b, properties = __objRest3(_b, ["type", "canTrack", "apiKey", "metadata"]);
3057
+ return {
3058
+ type: eventType,
3059
+ data: __spreadProps9(__spreadValues12(__spreadProps9(__spreadValues12({}, properties), {
3060
+ metadata: __spreadValues12({
3061
+ url: location.href
3062
+ }, metadata)
3063
+ }), yield getTrackingEventData({
3064
+ canTrack
3065
+ })), {
3066
+ userAttributes: getUserAttributes(),
3067
+ ownerId: apiKey
3068
+ })
3069
+ };
3070
+ });
3071
+ function _track(eventProps) {
3072
+ return __async3(this, null, function* () {
3073
+ if (!eventProps.apiKey) {
3074
+ logger.error("Missing API key for track call. Please provide your API key.");
3075
+ return;
3076
+ }
3077
+ if (!eventProps.canTrack) {
3078
+ return;
3079
+ }
3080
+ if (isEditing()) {
3081
+ return;
3082
+ }
3083
+ if (!(isBrowser() || TARGET === "reactNative")) {
3084
+ return;
3085
+ }
3086
+ return fetch(`https://cdn.builder.io/api/v1/track`, {
3087
+ method: "POST",
3088
+ body: JSON.stringify({
3089
+ events: [yield createEvent(eventProps)]
3090
+ }),
3091
+ headers: {
3092
+ "content-type": "application/json"
3093
+ },
3094
+ mode: "cors"
3095
+ }).catch((err) => {
3096
+ console.error("Failed to track: ", err);
3097
+ });
3098
+ });
3099
+ }
3100
+ var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
3101
+ canTrack: true
3102
+ }));
3103
+
3104
+ // src/constants/sdk-version.js
3105
+ var SDK_VERSION = "0.6.1";
3106
+
3107
+ // src/functions/register.js
3108
+ var registry = {};
3109
+ function register(type, info) {
3110
+ let typeList = registry[type];
3111
+ if (!typeList) {
3112
+ typeList = registry[type] = [];
3113
+ }
3114
+ typeList.push(info);
3115
+ if (isBrowser()) {
3116
+ const message = {
3117
+ type: "builder.register",
3118
+ data: {
3119
+ type,
3120
+ info
3121
+ }
3122
+ };
3123
+ try {
3124
+ parent.postMessage(message, "*");
3125
+ if (parent !== window) {
3126
+ window.postMessage(message, "*");
3127
+ }
3128
+ } catch (err) {
3129
+ console.debug("Could not postmessage", err);
3130
+ }
3131
+ }
3132
+ }
3133
+
3134
+ // src/scripts/init-editing.js
3135
+ var registerInsertMenu = () => {
3136
+ register("insertMenu", {
3137
+ name: "_default",
3138
+ default: true,
3139
+ items: [{
3140
+ name: "Box"
3141
+ }, {
3142
+ name: "Text"
3143
+ }, {
3144
+ name: "Image"
3145
+ }, {
3146
+ name: "Columns"
3147
+ }, ...TARGET === "reactNative" ? [] : [{
3148
+ name: "Core:Section"
3149
+ }, {
3150
+ name: "Core:Button"
3151
+ }, {
3152
+ name: "Embed"
3153
+ }, {
3154
+ name: "Custom Code"
3155
+ }]]
3156
+ });
3157
+ };
3158
+ var isSetupForEditing = false;
3159
+ var setupBrowserForEditing = (options = {}) => {
3160
+ var _a, _b;
3161
+ if (isSetupForEditing) {
3162
+ return;
3163
+ }
3164
+ isSetupForEditing = true;
3165
+ if (isBrowser()) {
3166
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
3167
+ type: "builder.sdkInfo",
3168
+ data: {
3169
+ target: TARGET,
3170
+ version: SDK_VERSION,
3171
+ supportsPatchUpdates: false,
3172
+ supportsAddBlockScoping: true,
3173
+ supportsCustomBreakpoints: true
3174
+ }
3175
+ }, "*");
3176
+ (_b = window.parent) == null ? void 0 : _b.postMessage({
3177
+ type: "builder.updateContent",
3178
+ data: {
3179
+ options
3180
+ }
3181
+ }, "*");
3182
+ window.addEventListener("message", ({
3183
+ data
3184
+ }) => {
3185
+ var _a2, _b2;
3186
+ if (!(data == null ? void 0 : data.type)) {
3187
+ return;
3188
+ }
3189
+ switch (data.type) {
3190
+ case "builder.evaluate": {
3191
+ const text = data.data.text;
3192
+ const args = data.data.arguments || [];
3193
+ const id = data.data.id;
3194
+ const fn = new Function(text);
3195
+ let result;
3196
+ let error = null;
3197
+ try {
3198
+ result = fn.apply(null, args);
3199
+ } catch (err) {
3200
+ error = err;
3201
+ }
3202
+ if (error) {
3203
+ (_a2 = window.parent) == null ? void 0 : _a2.postMessage({
3204
+ type: "builder.evaluateError",
3205
+ data: {
3206
+ id,
3207
+ error: error.message
3208
+ }
3209
+ }, "*");
3210
+ } else {
3211
+ if (result && typeof result.then === "function") {
3212
+ result.then((finalResult) => {
3213
+ var _a3;
3214
+ (_a3 = window.parent) == null ? void 0 : _a3.postMessage({
3215
+ type: "builder.evaluateResult",
3216
+ data: {
3217
+ id,
3218
+ result: finalResult
3219
+ }
3220
+ }, "*");
3221
+ }).catch(console.error);
3222
+ } else {
3223
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
3224
+ type: "builder.evaluateResult",
3225
+ data: {
3226
+ result,
3227
+ id
3228
+ }
3229
+ }, "*");
3230
+ }
3231
+ }
3232
+ break;
3233
+ }
3234
+ }
3235
+ });
3236
+ }
3237
+ };
3238
+
3239
+ // src/functions/track/interaction.js
3240
+ function round(num) {
3241
+ return Math.round(num * 1e3) / 1e3;
3242
+ }
3243
+ var findParentElement = (target, callback, checkElement = true) => {
3244
+ if (!(target instanceof HTMLElement)) {
3245
+ return null;
3246
+ }
3247
+ let parent2 = checkElement ? target : target.parentElement;
3248
+ do {
3249
+ if (!parent2) {
3250
+ return null;
3251
+ }
3252
+ const matches = callback(parent2);
3253
+ if (matches) {
3254
+ return parent2;
3255
+ }
3256
+ } while (parent2 = parent2.parentElement);
3257
+ return null;
3258
+ };
3259
+ var findBuilderParent = (target) => findParentElement(target, (el) => {
3260
+ const id = el.getAttribute("builder-id") || el.id;
3261
+ return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
3262
+ });
3263
+ var computeOffset = ({
3264
+ event,
3265
+ target
3266
+ }) => {
3267
+ const targetRect = target.getBoundingClientRect();
3268
+ const xOffset = event.clientX - targetRect.left;
3269
+ const yOffset = event.clientY - targetRect.top;
3270
+ const xRatio = round(xOffset / targetRect.width);
3271
+ const yRatio = round(yOffset / targetRect.height);
3272
+ return {
3273
+ x: xRatio,
3274
+ y: yRatio
3275
+ };
3276
+ };
3277
+ var getInteractionPropertiesForEvent = (event) => {
3278
+ const target = event.target;
3279
+ const targetBuilderElement = target && findBuilderParent(target);
3280
+ const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
3281
+ return {
3282
+ targetBuilderElement: builderId || void 0,
3283
+ metadata: {
3284
+ targetOffset: target ? computeOffset({
3285
+ event,
3286
+ target
3287
+ }) : void 0,
3288
+ builderTargetOffset: targetBuilderElement ? computeOffset({
3289
+ event,
3290
+ target: targetBuilderElement
3291
+ }) : void 0,
3292
+ builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
3293
+ }
3294
+ };
3295
+ };
3296
+
3297
+ // src/helpers/ab-tests.js
3298
+ var __defProp13 = Object.defineProperty;
3299
+ var __getOwnPropSymbols13 = Object.getOwnPropertySymbols;
3300
+ var __hasOwnProp13 = Object.prototype.hasOwnProperty;
3301
+ var __propIsEnum13 = Object.prototype.propertyIsEnumerable;
3302
+ var __defNormalProp13 = (obj, key, value) => key in obj ? __defProp13(obj, key, {
3303
+ enumerable: true,
3304
+ configurable: true,
3305
+ writable: true,
3306
+ value
3307
+ }) : obj[key] = value;
3308
+ var __spreadValues13 = (a, b) => {
3309
+ for (var prop in b || (b = {}))
3310
+ if (__hasOwnProp13.call(b, prop))
3311
+ __defNormalProp13(a, prop, b[prop]);
3312
+ if (__getOwnPropSymbols13)
3313
+ for (var prop of __getOwnPropSymbols13(b)) {
3314
+ if (__propIsEnum13.call(b, prop))
3315
+ __defNormalProp13(a, prop, b[prop]);
3316
+ }
3317
+ return a;
3318
+ };
3319
+ var __async4 = (__this, __arguments, generator) => {
3320
+ return new Promise((resolve, reject) => {
3321
+ var fulfilled = (value) => {
3322
+ try {
3323
+ step(generator.next(value));
3324
+ } catch (e) {
3325
+ reject(e);
3326
+ }
3327
+ };
3328
+ var rejected = (value) => {
3329
+ try {
3330
+ step(generator.throw(value));
3331
+ } catch (e) {
3332
+ reject(e);
3333
+ }
3334
+ };
3335
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3336
+ step((generator = generator.apply(__this, __arguments)).next());
3337
+ });
3338
+ };
3339
+ var BUILDER_STORE_PREFIX = "builder.tests";
3340
+ var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
3341
+ var getContentVariationCookie = ({
3342
+ contentId
3343
+ }) => getCookie({
3344
+ name: getContentTestKey(contentId),
3345
+ canTrack: true
3346
+ });
3347
+ var getContentVariationCookieSync = ({
3348
+ contentId
3349
+ }) => getCookieSync({
3350
+ name: getContentTestKey(contentId),
3351
+ canTrack: true
3352
+ });
3353
+ var setContentVariationCookie = ({
3354
+ contentId,
3355
+ value
3356
+ }) => setCookie({
3357
+ name: getContentTestKey(contentId),
3358
+ value,
3359
+ canTrack: true
3360
+ });
3361
+ var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
3362
+ var getRandomVariationId = ({
3363
+ id,
3364
+ variations
3365
+ }) => {
3366
+ var _a;
3367
+ let n = 0;
3368
+ const random = Math.random();
3369
+ for (const id2 in variations) {
3370
+ const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
3371
+ n += testRatio;
3372
+ if (random < n) {
3373
+ return id2;
3374
+ }
3375
+ }
3376
+ return id;
3377
+ };
3378
+ var getAndSetVariantId = (args) => {
3379
+ const randomVariationId = getRandomVariationId(args);
3380
+ setContentVariationCookie({
3381
+ contentId: args.id,
3382
+ value: randomVariationId
3383
+ }).catch((err) => {
3384
+ logger.error("could not store A/B test variation: ", err);
3385
+ });
3386
+ return randomVariationId;
3387
+ };
3388
+ var getTestFields = ({
3389
+ item,
3390
+ testGroupId
3391
+ }) => {
3392
+ const variationValue = item.variations[testGroupId];
3393
+ if (testGroupId === item.id || !variationValue) {
3394
+ return {
3395
+ testVariationId: item.id,
3396
+ testVariationName: "Default"
3397
+ };
3398
+ } else {
3399
+ return {
3400
+ data: variationValue.data,
3401
+ testVariationId: variationValue.id,
3402
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
3403
+ };
3404
+ }
3405
+ };
3406
+ var handleABTestingSync = ({
3407
+ item,
3408
+ canTrack
3409
+ }) => {
3410
+ if (TARGET === "reactNative")
3411
+ return item;
3412
+ if (!canTrack) {
3413
+ return item;
3414
+ }
3415
+ if (!item) {
3416
+ return void 0;
3417
+ }
3418
+ if (!checkIsBuilderContentWithVariations(item)) {
3419
+ return item;
3420
+ }
3421
+ const testGroupId = getContentVariationCookieSync({
3422
+ contentId: item.id
3423
+ }) || getAndSetVariantId({
3424
+ variations: item.variations,
3425
+ id: item.id
3426
+ });
3427
+ const variationValue = getTestFields({
3428
+ item,
3429
+ testGroupId
3430
+ });
3431
+ return __spreadValues13(__spreadValues13({}, item), variationValue);
3432
+ };
3433
+ var handleABTesting = (_0) => __async4(void 0, [_0], function* ({
3434
+ item,
3435
+ canTrack
3436
+ }) {
3437
+ if (!canTrack) {
3438
+ return item;
3439
+ }
3440
+ if (!checkIsBuilderContentWithVariations(item)) {
3441
+ return item;
3442
+ }
3443
+ const cookieValue = yield getContentVariationCookie({
3444
+ contentId: item.id
3445
+ });
3446
+ const testGroupId = cookieValue || getAndSetVariantId({
3447
+ variations: item.variations,
3448
+ id: item.id
3449
+ });
3450
+ const variationValue = getTestFields({
3451
+ item,
3452
+ testGroupId
3453
+ });
3454
+ return __spreadValues13(__spreadValues13({}, item), variationValue);
3455
+ });
3456
+
3457
+ // src/helpers/canTrack.js
3458
+ var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
3459
+
3460
+ // src/helpers/preview-lru-cache/get.js
3461
+ function getPreviewContent(_searchParams) {
3462
+ return void 0;
3463
+ }
3464
+
3465
+ // src/helpers/flatten.js
3466
+ var __defProp14 = Object.defineProperty;
3467
+ var __defProps10 = Object.defineProperties;
3468
+ var __getOwnPropDescs10 = Object.getOwnPropertyDescriptors;
3469
+ var __getOwnPropSymbols14 = Object.getOwnPropertySymbols;
3470
+ var __hasOwnProp14 = Object.prototype.hasOwnProperty;
3471
+ var __propIsEnum14 = Object.prototype.propertyIsEnumerable;
3472
+ var __defNormalProp14 = (obj, key, value) => key in obj ? __defProp14(obj, key, {
3473
+ enumerable: true,
3474
+ configurable: true,
3475
+ writable: true,
3476
+ value
3477
+ }) : obj[key] = value;
3478
+ var __spreadValues14 = (a, b) => {
3479
+ for (var prop in b || (b = {}))
3480
+ if (__hasOwnProp14.call(b, prop))
3481
+ __defNormalProp14(a, prop, b[prop]);
3482
+ if (__getOwnPropSymbols14)
3483
+ for (var prop of __getOwnPropSymbols14(b)) {
3484
+ if (__propIsEnum14.call(b, prop))
3485
+ __defNormalProp14(a, prop, b[prop]);
3486
+ }
3487
+ return a;
3488
+ };
3489
+ var __spreadProps10 = (a, b) => __defProps10(a, __getOwnPropDescs10(b));
3490
+ function flatten(object, path = null, separator = ".") {
3491
+ return Object.keys(object).reduce((acc, key) => {
3492
+ const value = object[key];
3493
+ const newPath = [path, key].filter(Boolean).join(separator);
3494
+ const isObject = [typeof value === "object", value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
3495
+ return isObject ? __spreadValues14(__spreadValues14({}, acc), flatten(value, newPath, separator)) : __spreadProps10(__spreadValues14({}, acc), {
3496
+ [newPath]: value
3497
+ });
3498
+ }, {});
3499
+ }
3500
+
3501
+ // src/functions/get-builder-search-params/index.js
3502
+ var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
3503
+ var BUILDER_OPTIONS_PREFIX = "options.";
3504
+ var convertSearchParamsToQueryObject = (searchParams) => {
3505
+ const options = {};
3506
+ searchParams.forEach((value, key) => {
3507
+ options[key] = value;
3508
+ });
3509
+ return options;
3510
+ };
3511
+ var getBuilderSearchParams = (_options) => {
3512
+ if (!_options) {
3513
+ return {};
3514
+ }
3515
+ const options = normalizeSearchParams(_options);
3516
+ const newOptions = {};
3517
+ Object.keys(options).forEach((key) => {
3518
+ if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
3519
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
3520
+ newOptions[trimmedKey] = options[key];
3521
+ }
3522
+ });
3523
+ return newOptions;
3524
+ };
3525
+ var getBuilderSearchParamsFromWindow = () => {
3526
+ if (!isBrowser()) {
3527
+ return {};
3528
+ }
3529
+ const searchParams = new URLSearchParams(window.location.search);
3530
+ return getBuilderSearchParams(searchParams);
3531
+ };
3532
+ var normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
3533
+
3534
+ // src/types/api-version.js
3535
+ var DEFAULT_API_VERSION = "v3";
3536
+
3537
+ // src/functions/get-content/generate-content-url.js
3538
+ var __defProp15 = Object.defineProperty;
3539
+ var __getOwnPropSymbols15 = Object.getOwnPropertySymbols;
3540
+ var __hasOwnProp15 = Object.prototype.hasOwnProperty;
3541
+ var __propIsEnum15 = Object.prototype.propertyIsEnumerable;
3542
+ var __defNormalProp15 = (obj, key, value) => key in obj ? __defProp15(obj, key, {
3543
+ enumerable: true,
3544
+ configurable: true,
3545
+ writable: true,
3546
+ value
3547
+ }) : obj[key] = value;
3548
+ var __spreadValues15 = (a, b) => {
3549
+ for (var prop in b || (b = {}))
3550
+ if (__hasOwnProp15.call(b, prop))
3551
+ __defNormalProp15(a, prop, b[prop]);
3552
+ if (__getOwnPropSymbols15)
3553
+ for (var prop of __getOwnPropSymbols15(b)) {
3554
+ if (__propIsEnum15.call(b, prop))
3555
+ __defNormalProp15(a, prop, b[prop]);
3556
+ }
3557
+ return a;
3558
+ };
3559
+ var generateContentUrl = (options) => {
3560
+ const {
3561
+ limit = 30,
3562
+ userAttributes,
3563
+ query,
3564
+ noTraverse = false,
3565
+ model,
3566
+ apiKey,
3567
+ includeRefs = true,
3568
+ enrich,
3569
+ locale,
3570
+ apiVersion = DEFAULT_API_VERSION
3571
+ } = options;
3572
+ if (!apiKey) {
3573
+ throw new Error("Missing API key");
3574
+ }
3575
+ if (!["v2", "v3"].includes(apiVersion)) {
3576
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
3577
+ }
3578
+ const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
3579
+ const queryOptions = __spreadValues15(__spreadValues15({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
3580
+ const flattened = flatten(queryOptions);
3581
+ for (const key in flattened) {
3582
+ url.searchParams.set(key, String(flattened[key]));
3583
+ }
3584
+ if (userAttributes) {
3585
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
3586
+ }
3587
+ if (query) {
3588
+ const flattened2 = flatten({
3589
+ query
3590
+ });
3591
+ for (const key in flattened2) {
3592
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
3593
+ }
3594
+ }
3595
+ return url;
3596
+ };
3597
+
3598
+ // src/functions/get-content/index.js
3599
+ var __defProp16 = Object.defineProperty;
3600
+ var __defProps11 = Object.defineProperties;
3601
+ var __getOwnPropDescs11 = Object.getOwnPropertyDescriptors;
3602
+ var __getOwnPropSymbols16 = Object.getOwnPropertySymbols;
3603
+ var __hasOwnProp16 = Object.prototype.hasOwnProperty;
3604
+ var __propIsEnum16 = Object.prototype.propertyIsEnumerable;
3605
+ var __defNormalProp16 = (obj, key, value) => key in obj ? __defProp16(obj, key, {
3606
+ enumerable: true,
3607
+ configurable: true,
3608
+ writable: true,
3609
+ value
3610
+ }) : obj[key] = value;
3611
+ var __spreadValues16 = (a, b) => {
3612
+ for (var prop in b || (b = {}))
3613
+ if (__hasOwnProp16.call(b, prop))
3614
+ __defNormalProp16(a, prop, b[prop]);
3615
+ if (__getOwnPropSymbols16)
3616
+ for (var prop of __getOwnPropSymbols16(b)) {
3617
+ if (__propIsEnum16.call(b, prop))
3618
+ __defNormalProp16(a, prop, b[prop]);
3619
+ }
3620
+ return a;
3621
+ };
3622
+ var __spreadProps11 = (a, b) => __defProps11(a, __getOwnPropDescs11(b));
3623
+ var __async5 = (__this, __arguments, generator) => {
3624
+ return new Promise((resolve, reject) => {
3625
+ var fulfilled = (value) => {
3626
+ try {
3627
+ step(generator.next(value));
3628
+ } catch (e) {
3629
+ reject(e);
3630
+ }
3631
+ };
3632
+ var rejected = (value) => {
3633
+ try {
3634
+ step(generator.throw(value));
3635
+ } catch (e) {
3636
+ reject(e);
3637
+ }
3638
+ };
3639
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3640
+ step((generator = generator.apply(__this, __arguments)).next());
3641
+ });
3642
+ };
3643
+ var checkContentHasResults = (content) => "results" in content;
3644
+ function fetchOneEntry(options) {
3645
+ return __async5(this, null, function* () {
3646
+ const allContent = yield fetchEntries(__spreadProps11(__spreadValues16({}, options), {
3647
+ limit: 1
3648
+ }));
3649
+ if (allContent) {
3650
+ return allContent.results[0] || null;
3651
+ }
3652
+ return null;
3653
+ });
3654
+ }
3655
+ var getContent = fetchOneEntry;
3656
+ var _fetchContent = (options) => __async5(void 0, null, function* () {
3657
+ const url = generateContentUrl(options);
3658
+ const res = yield fetch2(url.href);
3659
+ const content = yield res.json();
3660
+ return content;
3661
+ });
3662
+ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2], function* (options, content, url = generateContentUrl(options)) {
3663
+ const canTrack = getDefaultCanTrack(options.canTrack);
3664
+ const isPreviewing2 = url.search.includes(`preview=`);
3665
+ if (TARGET === "rsc" && isPreviewing2) {
3666
+ const newResults = [];
3667
+ for (const item of content.results) {
3668
+ const previewContent = getPreviewContent(url.searchParams);
3669
+ newResults.push(previewContent || item);
3670
+ }
3671
+ content.results = newResults;
3672
+ }
3673
+ if (!canTrack)
3674
+ return content;
3675
+ if (!(isBrowser() || TARGET === "reactNative"))
3676
+ return content;
3677
+ try {
3678
+ const newResults = [];
3679
+ for (const item of content.results) {
3680
+ newResults.push(yield handleABTesting({
3681
+ item,
3682
+ canTrack
3683
+ }));
3684
+ }
3685
+ content.results = newResults;
3686
+ } catch (e) {
3687
+ logger.error("Could not process A/B tests. ", e);
3688
+ }
3689
+ return content;
3690
+ });
3691
+ function fetchEntries(options) {
3692
+ return __async5(this, null, function* () {
3693
+ try {
3694
+ const url = generateContentUrl(options);
3695
+ const content = yield _fetchContent(options);
3696
+ if (!checkContentHasResults(content)) {
3697
+ logger.error("Error fetching data. ", {
3698
+ url,
3699
+ content,
3700
+ options
3701
+ });
3702
+ return null;
3703
+ }
3704
+ return _processContentResult(options, content);
3705
+ } catch (error) {
3706
+ logger.error("Error fetching data. ", error);
3707
+ return null;
3708
+ }
3709
+ });
3710
+ }
3711
+ var getAllContent = fetchEntries;
3712
+
3713
+ // src/functions/is-previewing.js
3714
+ function isPreviewing() {
3715
+ if (!isBrowser()) {
3716
+ return false;
3717
+ }
3718
+ if (isEditing()) {
3719
+ return false;
3720
+ }
3721
+ return Boolean(location.search.indexOf("builder.preview=") !== -1);
3722
+ }
3723
+
3724
+ // src/components/content/components/enable-editor.jsx
3725
+ function EnableEditor(props) {
3726
+ const [canTrackToUse, setCanTrackToUse] = createSignal12(
3727
+ checkIsDefined(props.canTrack) ? props.canTrack : true
3728
+ );
3729
+ const [forceReRenderCount, setForceReRenderCount] = createSignal12(0);
3730
+ const [lastUpdated, setLastUpdated] = createSignal12(0);
3731
+ const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal12(false);
3732
+ const [httpReqsData, setHttpReqsData] = createSignal12({});
3733
+ const [clicked, setClicked] = createSignal12(false);
3734
+ function mergeNewContent(newContent) {
3735
+ const newContentValue = {
3736
+ ...props.builderContextSignal.content,
3737
+ ...newContent,
3738
+ data: {
3739
+ ...props.builderContextSignal.content?.data,
3740
+ ...newContent?.data
3741
+ },
3742
+ meta: {
3743
+ ...props.builderContextSignal.content?.meta,
3744
+ ...newContent?.meta,
3745
+ breakpoints: newContent?.meta?.breakpoints || props.builderContextSignal.content?.meta?.breakpoints
3746
+ }
3747
+ };
3748
+ props.setBuilderContextSignal((PREVIOUS_VALUE) => ({
3749
+ ...PREVIOUS_VALUE,
3750
+ content: newContentValue
3751
+ }));
3752
+ }
3753
+ function processMessage(event) {
3754
+ const { data } = event;
3755
+ if (data) {
3756
+ switch (data.type) {
3757
+ case "builder.configureSdk": {
3758
+ const messageContent = data.data;
3759
+ const { breakpoints, contentId } = messageContent;
3760
+ if (!contentId || contentId !== props.builderContextSignal.content?.id) {
3761
+ return;
3762
+ }
3763
+ if (breakpoints) {
3764
+ mergeNewContent({
3765
+ meta: {
3766
+ breakpoints
3767
+ }
3768
+ });
3769
+ }
3770
+ setForceReRenderCount(forceReRenderCount() + 1);
3771
+ break;
3772
+ }
3773
+ case "builder.contentUpdate": {
3774
+ const messageContent = data.data;
3775
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3776
+ const contentData = messageContent.data;
3777
+ if (key === props.model) {
3778
+ mergeNewContent(contentData);
3779
+ setForceReRenderCount(forceReRenderCount() + 1);
3780
+ }
3781
+ break;
3782
+ }
3783
+ }
3784
+ }
3785
+ }
3786
+ function evaluateJsCode() {
3787
+ const jsCode = props.builderContextSignal.content?.data?.jsCode;
3788
+ if (jsCode) {
3789
+ evaluate({
3790
+ code: jsCode,
3791
+ context: props.context || {},
3792
+ localState: void 0,
3793
+ rootState: props.builderContextSignal.rootState,
3794
+ rootSetState: props.builderContextSignal.rootSetState
3795
+ });
3796
+ }
3797
+ }
3798
+ function onClick(event) {
3799
+ if (props.builderContextSignal.content) {
3800
+ const variationId = props.builderContextSignal.content?.testVariationId;
3801
+ const contentId = props.builderContextSignal.content?.id;
3802
+ _track({
3803
+ type: "click",
3804
+ canTrack: canTrackToUse(),
3805
+ contentId,
3806
+ apiKey: props.apiKey,
3807
+ variationId: variationId !== contentId ? variationId : void 0,
3808
+ ...getInteractionPropertiesForEvent(event),
3809
+ unique: !clicked()
3810
+ });
3811
+ }
3812
+ if (!clicked()) {
3813
+ setClicked(true);
3814
+ }
3815
+ }
3816
+ function evalExpression(expression) {
3817
+ return expression.replace(
3818
+ /{{([^}]+)}}/g,
3819
+ (_match, group) => evaluate({
3820
+ code: group,
3821
+ context: props.context || {},
3822
+ localState: void 0,
3823
+ rootState: props.builderContextSignal.rootState,
3824
+ rootSetState: props.builderContextSignal.rootSetState
3825
+ })
3826
+ );
3827
+ }
3828
+ function handleRequest({ url, key }) {
3829
+ fetch2(url).then((response) => response.json()).then((json) => {
3830
+ const newState = {
3831
+ ...props.builderContextSignal.rootState,
3832
+ [key]: json
3833
+ };
3834
+ props.builderContextSignal.rootSetState?.(newState);
3835
+ httpReqsData()[key] = true;
3836
+ }).catch((err) => {
3837
+ console.error("error fetching dynamic data", url, err);
3838
+ });
3839
+ }
3840
+ function runHttpRequests() {
3841
+ const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
3842
+ Object.entries(requests).forEach(([key, url]) => {
3843
+ if (url && (!httpReqsData()[key] || isEditing())) {
3844
+ const evaluatedUrl = evalExpression(url);
3845
+ handleRequest({
3846
+ url: evaluatedUrl,
3847
+ key
3848
+ });
3849
+ }
3850
+ });
3851
+ }
3852
+ function emitStateUpdate() {
3853
+ if (isEditing()) {
3854
+ window.dispatchEvent(
3855
+ new CustomEvent("builder:component:stateChange", {
3856
+ detail: {
3857
+ state: fastClone(props.builderContextSignal.rootState),
3858
+ ref: {
3859
+ name: props.model
3860
+ }
3861
+ }
3862
+ })
3863
+ );
3864
+ }
3865
+ }
3866
+ let elementRef;
3867
+ onMount2(() => {
3868
+ if (!props.apiKey) {
3869
+ logger.error(
3870
+ "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
3871
+ );
3872
+ }
3873
+ if (isBrowser()) {
3874
+ if (isEditing()) {
3875
+ setForceReRenderCount(forceReRenderCount() + 1);
3876
+ window.addEventListener("message", processMessage);
3877
+ registerInsertMenu();
3878
+ setupBrowserForEditing({
3879
+ ...props.locale ? {
3880
+ locale: props.locale
3881
+ } : {},
3882
+ ...props.includeRefs ? {
3883
+ includeRefs: props.includeRefs
3884
+ } : {},
3885
+ ...props.enrich ? {
3886
+ enrich: props.enrich
3887
+ } : {}
3888
+ });
3889
+ Object.values(props.builderContextSignal.componentInfos).forEach(
3890
+ (registeredComponent) => {
3891
+ const message = createRegisterComponentMessage(registeredComponent);
3892
+ window.parent?.postMessage(message, "*");
3893
+ }
3894
+ );
3895
+ window.addEventListener(
3896
+ "builder:component:stateChangeListenerActivated",
3897
+ emitStateUpdate
3898
+ );
3899
+ }
3900
+ if (props.builderContextSignal.content) {
3901
+ const variationId = props.builderContextSignal.content?.testVariationId;
3902
+ const contentId = props.builderContextSignal.content?.id;
3903
+ _track({
3904
+ type: "impression",
3905
+ canTrack: canTrackToUse(),
3906
+ contentId,
3907
+ apiKey: props.apiKey,
3908
+ variationId: variationId !== contentId ? variationId : void 0
3909
+ });
3910
+ }
3911
+ if (isPreviewing()) {
3912
+ const searchParams = new URL(location.href).searchParams;
3913
+ const searchParamPreviewModel = searchParams.get("builder.preview");
3914
+ const searchParamPreviewId = searchParams.get(
3915
+ `builder.preview.${searchParamPreviewModel}`
3916
+ );
3917
+ const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
3918
+ if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
3919
+ fetchOneEntry({
3920
+ model: props.model,
3921
+ apiKey: props.apiKey,
3922
+ apiVersion: props.builderContextSignal.apiVersion
3923
+ }).then((content) => {
3924
+ if (content) {
3925
+ mergeNewContent(content);
3926
+ }
3927
+ });
3928
+ }
3929
+ }
3930
+ evaluateJsCode();
3931
+ runHttpRequests();
3932
+ emitStateUpdate();
3933
+ }
3934
+ });
3935
+ function onUpdateFn_0() {
3936
+ if (props.content) {
3937
+ mergeNewContent(props.content);
3938
+ }
3939
+ }
3940
+ createEffect2(on2(() => [props.content], onUpdateFn_0));
3941
+ function onUpdateFn_1() {
3942
+ }
3943
+ createEffect2(on2(() => [shouldSendResetCookie()], onUpdateFn_1));
3944
+ function onUpdateFn_2() {
3945
+ evaluateJsCode();
3946
+ }
3947
+ createEffect2(
3948
+ on2(
3949
+ () => [
3950
+ props.builderContextSignal.content?.data?.jsCode,
3951
+ props.builderContextSignal.rootState
3952
+ ],
3953
+ onUpdateFn_2
3954
+ )
3955
+ );
3956
+ function onUpdateFn_3() {
3957
+ runHttpRequests();
3958
+ }
3959
+ createEffect2(
3960
+ on2(
3961
+ () => [props.builderContextSignal.content?.data?.httpRequests],
3962
+ onUpdateFn_3
3963
+ )
3964
+ );
3965
+ function onUpdateFn_4() {
3966
+ emitStateUpdate();
3967
+ }
3968
+ createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
3969
+ return <stdin_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
3970
+ class={props.classNameProp}
3971
+ key={forceReRenderCount()}
3972
+ ref={elementRef}
3973
+ onClick={(event) => onClick(event)}
3974
+ builder-content-id={props.builderContextSignal.content?.id}
3975
+ builder-model={props.model}
3976
+ {...{}}
3977
+ {...props.showContent ? {} : {
3978
+ hidden: true,
3979
+ "aria-hidden": true
3980
+ }}
3981
+ >{props.children}</div></Show9></stdin_default.Provider>;
3982
+ }
3983
+ var Enable_editor_default = EnableEditor;
3984
+
3985
+ // src/components/inlined-script.jsx
3986
+ function InlinedScript(props) {
3987
+ return <script innerHTML={props.scriptStr} id={props.id} />;
3988
+ }
3989
+ var Inlined_script_default = InlinedScript;
3990
+
3991
+ // src/components/content/content.jsx
3992
+ function ContentComponent(props) {
3993
+ const [scriptStr, setScriptStr] = createSignal13(
3994
+ getRenderContentScriptString({
3995
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
3996
+ variationId: props.content?.testVariationId,
3997
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
3998
+ contentId: props.content?.id
3999
+ })
4000
+ );
4001
+ const [registeredComponents, setRegisteredComponents] = createSignal13(
4002
+ [
4003
+ ...getDefaultRegisteredComponents(),
4004
+ // While this `components` object is deprecated, we must maintain support for it.
4005
+ // Since users are able to override our default components, we need to make sure that we do not break such
4006
+ // existing usage.
4007
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
4008
+ // which is the new standard way of providing custom components, and must therefore take precedence.
4009
+ ...components,
4010
+ ...props.customComponents || []
4011
+ ].reduce(
4012
+ (acc, { component, ...info }) => ({
4013
+ ...acc,
4014
+ [info.name]: {
4015
+ component,
4016
+ ...serializeComponentInfo(info)
4017
+ }
4018
+ }),
4019
+ {}
4020
+ )
4021
+ );
4022
+ const [builderContextSignal, setBuilderContextSignal] = createSignal13({
4023
+ content: getContentInitialValue({
4024
+ content: props.content,
4025
+ data: props.data
4026
+ }),
4027
+ localState: void 0,
4028
+ rootState: getContextStateInitialValue({
4029
+ content: props.content,
4030
+ data: props.data,
4031
+ locale: props.locale
4032
+ }),
4033
+ rootSetState: contentSetState,
4034
+ context: props.context || {},
4035
+ apiKey: props.apiKey,
4036
+ apiVersion: props.apiVersion,
4037
+ componentInfos: [
4038
+ ...getDefaultRegisteredComponents(),
4039
+ // While this `components` object is deprecated, we must maintain support for it.
4040
+ // Since users are able to override our default components, we need to make sure that we do not break such
4041
+ // existing usage.
4042
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
4043
+ // which is the new standard way of providing custom components, and must therefore take precedence.
4044
+ ...components,
4045
+ ...props.customComponents || []
4046
+ ].reduce(
4047
+ (acc, { component: _, ...info }) => ({
4048
+ ...acc,
4049
+ [info.name]: serializeComponentInfo(info)
4050
+ }),
4051
+ {}
4052
+ ),
4053
+ inheritedStyles: {}
4054
+ });
4055
+ function contentSetState(newRootState) {
4056
+ setBuilderContextSignal((PREVIOUS_VALUE) => ({
4057
+ ...PREVIOUS_VALUE,
4058
+ rootState: newRootState
4059
+ }));
4060
+ }
4061
+ return <stdin_default2.Provider
4062
+ value={{
4063
+ registeredComponents: registeredComponents()
4064
+ }}
4065
+ ><Enable_editor_default
4066
+ content={props.content}
4067
+ model={props.model}
4068
+ context={props.context}
4069
+ apiKey={props.apiKey}
4070
+ canTrack={props.canTrack}
4071
+ locale={props.locale}
4072
+ includeRefs={props.includeRefs}
4073
+ enrich={props.enrich}
4074
+ classNameProp={props.classNameProp}
4075
+ showContent={props.showContent}
4076
+ builderContextSignal={builderContextSignal()}
4077
+ {...{
4078
+ setBuilderContextSignal
4079
+ }}
4080
+ >
4081
+ <Show10 when={props.isSsrAbTest}><Inlined_script_default scriptStr={scriptStr()} /></Show10>
4082
+ <Show10 when={TARGET !== "reactNative"}><Styles_default
4083
+ contentId={builderContextSignal().content?.id}
4084
+ cssCode={builderContextSignal().content?.data?.cssCode}
4085
+ customFonts={builderContextSignal().content?.data?.customFonts}
4086
+ /></Show10>
4087
+ <Blocks_default
4088
+ blocks={builderContextSignal().content?.data?.blocks}
4089
+ context={builderContextSignal()}
4090
+ registeredComponents={registeredComponents()}
4091
+ />
4092
+ </Enable_editor_default></stdin_default2.Provider>;
4093
+ }
4094
+ var Content_default = ContentComponent;
4095
+
4096
+ // src/components/content-variants/content-variants.jsx
4097
+ function ContentVariants(props) {
4098
+ const [shouldRenderVariants, setShouldRenderVariants] = createSignal14(
4099
+ checkShouldRunVariants({
4100
+ canTrack: getDefaultCanTrack(props.canTrack),
4101
+ content: props.content
4102
+ })
4103
+ );
4104
+ function variantScriptStr() {
4105
+ return getVariantsScriptString(
4106
+ getVariants(props.content).map((value) => ({
4107
+ id: value.testVariationId,
4108
+ testRatio: value.testRatio
4109
+ })),
4110
+ props.content?.id || ""
4111
+ );
4112
+ }
4113
+ function hideVariantsStyleString() {
4114
+ return getVariants(props.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
4115
+ }
4116
+ function defaultContent() {
4117
+ return shouldRenderVariants() ? {
4118
+ ...props.content,
4119
+ testVariationId: props.content?.id
4120
+ } : handleABTestingSync({
4121
+ item: props.content,
4122
+ canTrack: getDefaultCanTrack(props.canTrack)
4123
+ });
4124
+ }
4125
+ onMount3(() => {
4126
+ });
4127
+ return <>
4128
+ <Show11 when={!props.__isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show11>
4129
+ <Show11 when={shouldRenderVariants()}>
4130
+ <Inlined_styles_default
4131
+ id={`variants-styles-${props.content?.id}`}
4132
+ styles={hideVariantsStyleString()}
4133
+ />
4134
+ <Inlined_script_default scriptStr={variantScriptStr()} />
4135
+ <For5 each={getVariants(props.content)}>{(variant, _index) => {
4136
+ const index = _index();
4137
+ return <Content_default
4138
+ key={variant.testVariationId}
4139
+ content={variant}
4140
+ showContent={false}
4141
+ classNameProp={void 0}
4142
+ model={props.model}
4143
+ data={props.data}
4144
+ context={props.context}
4145
+ apiKey={props.apiKey}
4146
+ apiVersion={props.apiVersion}
4147
+ customComponents={props.customComponents}
4148
+ canTrack={props.canTrack}
4149
+ locale={props.locale}
4150
+ includeRefs={props.includeRefs}
4151
+ enrich={props.enrich}
4152
+ isSsrAbTest={shouldRenderVariants()}
4153
+ />;
4154
+ }}</For5>
4155
+ </Show11>
4156
+ <Content_default
4157
+ {...{}}
4158
+ content={defaultContent()}
4159
+ classNameProp={`variant-${props.content?.id}`}
4160
+ showContent={true}
4161
+ model={props.model}
4162
+ data={props.data}
4163
+ context={props.context}
4164
+ apiKey={props.apiKey}
4165
+ apiVersion={props.apiVersion}
4166
+ customComponents={props.customComponents}
4167
+ canTrack={props.canTrack}
4168
+ locale={props.locale}
4169
+ includeRefs={props.includeRefs}
4170
+ enrich={props.enrich}
4171
+ isSsrAbTest={shouldRenderVariants()}
4172
+ />
4173
+ </>;
4174
+ }
4175
+ var Content_variants_default = ContentVariants;
4176
+
4177
+ // src/blocks/symbol/symbol.helpers.js
4178
+ var __defProp17 = Object.defineProperty;
4179
+ var __getOwnPropSymbols17 = Object.getOwnPropertySymbols;
4180
+ var __hasOwnProp17 = Object.prototype.hasOwnProperty;
4181
+ var __propIsEnum17 = Object.prototype.propertyIsEnumerable;
4182
+ var __defNormalProp17 = (obj, key, value) => key in obj ? __defProp17(obj, key, {
4183
+ enumerable: true,
4184
+ configurable: true,
4185
+ writable: true,
4186
+ value
4187
+ }) : obj[key] = value;
4188
+ var __spreadValues17 = (a, b) => {
4189
+ for (var prop in b || (b = {}))
4190
+ if (__hasOwnProp17.call(b, prop))
4191
+ __defNormalProp17(a, prop, b[prop]);
4192
+ if (__getOwnPropSymbols17)
4193
+ for (var prop of __getOwnPropSymbols17(b)) {
4194
+ if (__propIsEnum17.call(b, prop))
4195
+ __defNormalProp17(a, prop, b[prop]);
4196
+ }
4197
+ return a;
4198
+ };
4199
+ var __async6 = (__this, __arguments, generator) => {
4200
+ return new Promise((resolve, reject) => {
4201
+ var fulfilled = (value) => {
4202
+ try {
4203
+ step(generator.next(value));
4204
+ } catch (e) {
4205
+ reject(e);
4206
+ }
4207
+ };
4208
+ var rejected = (value) => {
4209
+ try {
4210
+ step(generator.throw(value));
4211
+ } catch (e) {
4212
+ reject(e);
4213
+ }
4214
+ };
4215
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
4216
+ step((generator = generator.apply(__this, __arguments)).next());
4217
+ });
4218
+ };
4219
+ var fetchSymbolContent = (_0) => __async6(void 0, [_0], function* ({
4220
+ builderContextValue,
4221
+ symbol
4222
+ }) {
4223
+ if ((symbol == null ? void 0 : symbol.model) && (builderContextValue == null ? void 0 : builderContextValue.apiKey)) {
4224
+ return fetchOneEntry(__spreadValues17({
4225
+ model: symbol.model,
4226
+ apiKey: builderContextValue.apiKey,
4227
+ apiVersion: builderContextValue.apiVersion
4228
+ }, (symbol == null ? void 0 : symbol.entry) && {
4229
+ query: {
4230
+ id: symbol.entry
4231
+ }
4232
+ })).catch((err) => {
4233
+ logger.error("Could not fetch symbol content: ", err);
4234
+ return void 0;
4235
+ });
4236
+ }
4237
+ return void 0;
4238
+ });
4239
+
4240
+ // src/blocks/symbol/symbol.jsx
4241
+ function Symbol(props) {
4242
+ const [contentToUse, setContentToUse] = createSignal15(props.symbol?.content);
4243
+ function className() {
4244
+ return [
4245
+ ...[props.attributes.class],
4246
+ "builder-symbol",
4247
+ props.symbol?.inline ? "builder-inline-symbol" : void 0,
4248
+ props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
4249
+ ].filter(Boolean).join(" ");
4250
+ }
4251
+ function setContent() {
4252
+ if (contentToUse())
4253
+ return;
4254
+ fetchSymbolContent({
4255
+ symbol: props.symbol,
4256
+ builderContextValue: props.builderContext
4257
+ }).then((newContent) => {
4258
+ if (newContent) {
4259
+ setContentToUse(newContent);
4260
+ }
4261
+ });
4262
+ }
4263
+ onMount4(() => {
4264
+ setContent();
4265
+ });
4266
+ function onUpdateFn_0() {
4267
+ setContent();
4268
+ }
4269
+ createEffect3(on3(() => [props.symbol], onUpdateFn_0));
4270
+ return <div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
4271
+ __isNestedRender={true}
4272
+ apiVersion={props.builderContext.apiVersion}
4273
+ apiKey={props.builderContext.apiKey}
4274
+ context={props.builderContext.context}
4275
+ customComponents={Object.values(props.builderComponents)}
4276
+ data={{
4277
+ ...props.symbol?.data,
4278
+ ...props.builderContext.localState,
4279
+ ...contentToUse()?.data?.state
4280
+ }}
4281
+ model={props.symbol?.model}
4282
+ content={contentToUse()}
4283
+ /></div>;
4284
+ }
4285
+ var symbol_default = Symbol;
4286
+
4287
+ // src/index-helpers/blocks-exports.js
4288
+ var RenderBlocks = Blocks_default;
4289
+ var RenderContent = Content_variants_default;
4290
+
4291
+ // src/functions/set-editor-settings.js
4292
+ var settings = {};
4293
+ function setEditorSettings(newSettings) {
4294
+ if (isBrowser()) {
4295
+ Object.assign(settings, newSettings);
4296
+ const message = {
4297
+ type: "builder.settingsChange",
4298
+ data: settings
4299
+ };
4300
+ parent.postMessage(message, "*");
4301
+ }
4302
+ }
4303
+
4304
+ // src/functions/fetch-builder-props.js
4305
+ var __defProp18 = Object.defineProperty;
4306
+ var __defProps12 = Object.defineProperties;
4307
+ var __getOwnPropDescs12 = Object.getOwnPropertyDescriptors;
4308
+ var __getOwnPropSymbols18 = Object.getOwnPropertySymbols;
4309
+ var __hasOwnProp18 = Object.prototype.hasOwnProperty;
4310
+ var __propIsEnum18 = Object.prototype.propertyIsEnumerable;
4311
+ var __defNormalProp18 = (obj, key, value) => key in obj ? __defProp18(obj, key, {
4312
+ enumerable: true,
4313
+ configurable: true,
4314
+ writable: true,
4315
+ value
4316
+ }) : obj[key] = value;
4317
+ var __spreadValues18 = (a, b) => {
4318
+ for (var prop in b || (b = {}))
4319
+ if (__hasOwnProp18.call(b, prop))
4320
+ __defNormalProp18(a, prop, b[prop]);
4321
+ if (__getOwnPropSymbols18)
4322
+ for (var prop of __getOwnPropSymbols18(b)) {
4323
+ if (__propIsEnum18.call(b, prop))
4324
+ __defNormalProp18(a, prop, b[prop]);
4325
+ }
4326
+ return a;
4327
+ };
4328
+ var __spreadProps12 = (a, b) => __defProps12(a, __getOwnPropDescs12(b));
4329
+ var __async7 = (__this, __arguments, generator) => {
4330
+ return new Promise((resolve, reject) => {
4331
+ var fulfilled = (value) => {
4332
+ try {
4333
+ step(generator.next(value));
4334
+ } catch (e) {
4335
+ reject(e);
4336
+ }
4337
+ };
4338
+ var rejected = (value) => {
4339
+ try {
4340
+ step(generator.throw(value));
4341
+ } catch (e) {
4342
+ reject(e);
4343
+ }
4344
+ };
4345
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
4346
+ step((generator = generator.apply(__this, __arguments)).next());
4347
+ });
4348
+ };
4349
+ var fetchBuilderProps = (_args) => __async7(void 0, null, function* () {
4350
+ var _a, _b, _c;
4351
+ const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
4352
+ const getContentArgs = __spreadProps12(__spreadValues18({}, _args), {
4353
+ apiKey: _args.apiKey,
4354
+ model: _args.model || "page",
4355
+ userAttributes: __spreadValues18(__spreadValues18({}, _args.userAttributes), urlPath ? {
4356
+ urlPath
4357
+ } : {}),
4358
+ options: getBuilderSearchParams(_args.searchParams || ((_c = _args.url) == null ? void 0 : _c.searchParams) || _args.options)
4359
+ });
4360
+ return {
4361
+ apiKey: getContentArgs.apiKey,
4362
+ model: getContentArgs.model,
4363
+ content: yield fetchOneEntry(getContentArgs)
4364
+ };
4365
+ });
4366
+ export {
4367
+ Blocks_default as Blocks,
4368
+ button_default as Button,
4369
+ columns_default as Columns,
4370
+ Content_variants_default as Content,
4371
+ fragment_default as Fragment,
4372
+ image_default as Image,
4373
+ RenderBlocks,
4374
+ RenderContent,
4375
+ section_default as Section,
4376
+ symbol_default as Symbol,
4377
+ text_default as Text,
4378
+ video_default as Video,
4379
+ _processContentResult,
4380
+ createRegisterComponentMessage,
4381
+ fetchBuilderProps,
4382
+ fetchEntries,
4383
+ fetchOneEntry,
4384
+ getAllContent,
4385
+ getBuilderSearchParams,
4386
+ getContent,
4387
+ isEditing,
4388
+ isPreviewing,
4389
+ register,
4390
+ setEditorSettings,
4391
+ track
4392
+ };