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