@builder.io/sdk-react-nextjs 0.14.29 → 0.14.30

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 (100) hide show
  1. package/lib/browser/blocks-exports.cjs +188 -0
  2. package/lib/browser/blocks-exports.mjs +2812 -0
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +25 -26
  5. package/lib/browser/init.cjs +8 -0
  6. package/lib/browser/init.mjs +60 -0
  7. package/lib/browser/server-entry-24a8bb57.js +720 -0
  8. package/lib/browser/server-entry-6927b611.cjs +2 -0
  9. package/lib/browser/server-entry.cjs +1 -0
  10. package/lib/browser/server-entry.mjs +16 -0
  11. package/lib/edge/blocks-exports.cjs +208 -0
  12. package/lib/edge/{bundle-f748b05a.js → blocks-exports.mjs} +2381 -2401
  13. package/lib/edge/index.cjs +1 -1
  14. package/lib/edge/index.mjs +25 -26
  15. package/lib/edge/init.cjs +8 -0
  16. package/lib/edge/init.mjs +60 -0
  17. package/lib/edge/server-entry-24a8bb57.js +720 -0
  18. package/lib/edge/server-entry-6927b611.cjs +2 -0
  19. package/lib/edge/server-entry.cjs +1 -0
  20. package/lib/edge/server-entry.mjs +16 -0
  21. package/lib/node/blocks-exports.cjs +188 -0
  22. package/lib/node/blocks-exports.mjs +2788 -0
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +23 -23
  25. package/lib/node/init.cjs +1 -0
  26. package/lib/node/init.mjs +13 -0
  27. package/lib/node/node-runtime-39bc20c5.cjs +48 -0
  28. package/lib/node/node-runtime-bf50fca0.js +167 -0
  29. package/lib/node/server-entry-3cc55723.js +720 -0
  30. package/lib/node/server-entry-8112afc1.cjs +2 -0
  31. package/lib/node/server-entry.cjs +1 -0
  32. package/lib/node/server-entry.mjs +16 -0
  33. package/package.json +14 -9
  34. package/types/cjs/blocks/BaseText.d.ts +6 -0
  35. package/types/cjs/blocks/raw-text/component-info.d.ts +2 -0
  36. package/types/cjs/blocks/raw-text/index.d.ts +1 -0
  37. package/types/cjs/blocks/raw-text/raw-text.d.ts +7 -0
  38. package/types/cjs/blocks/textarea/component-info.d.ts +2 -0
  39. package/types/cjs/blocks/textarea/index.d.ts +1 -0
  40. package/types/cjs/blocks/textarea/textarea.d.ts +13 -0
  41. package/types/cjs/components/content/index.d.ts +1 -0
  42. package/types/cjs/components/error-boundary.d.ts +11 -0
  43. package/types/cjs/constants/sdk-name.d.ts +1 -0
  44. package/types/cjs/constants/sdk-version.d.ts +1 -1
  45. package/types/cjs/functions/apply-patch-with-mutation.d.ts +10 -0
  46. package/types/cjs/functions/evaluate/edge-runtime/acorn-interpreter.d.ts +2 -0
  47. package/types/cjs/functions/evaluate/edge-runtime/edge-runtime.d.ts +2 -0
  48. package/types/cjs/functions/evaluate/edge-runtime/index.d.ts +1 -0
  49. package/types/cjs/functions/evaluate/node-runtime/index.d.ts +1 -0
  50. package/types/cjs/functions/evaluate/node-runtime/init.d.ts +13 -0
  51. package/types/cjs/functions/evaluate/node-runtime/node-runtime.d.ts +11 -0
  52. package/types/cjs/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +8 -0
  53. package/types/cjs/functions/evaluate/placeholder-runtime.d.ts +2 -0
  54. package/types/cjs/functions/extract-css-var-default-value.d.ts +1 -0
  55. package/types/cjs/functions/is-edge-runtime.d.ts +4 -0
  56. package/types/cjs/functions/on-change.d.ts +7 -0
  57. package/types/cjs/helpers/omit.d.ts +1 -0
  58. package/types/cjs/helpers/time.d.ts +1 -0
  59. package/types/esm/blocks/BaseText.d.ts +6 -0
  60. package/types/esm/blocks/raw-text/component-info.d.ts +2 -0
  61. package/types/esm/blocks/raw-text/index.d.ts +1 -0
  62. package/types/esm/blocks/raw-text/raw-text.d.ts +7 -0
  63. package/types/esm/blocks/textarea/component-info.d.ts +2 -0
  64. package/types/esm/blocks/textarea/index.d.ts +1 -0
  65. package/types/esm/blocks/textarea/textarea.d.ts +13 -0
  66. package/types/esm/components/content/index.d.ts +1 -0
  67. package/types/esm/components/error-boundary.d.ts +11 -0
  68. package/types/esm/constants/sdk-name.d.ts +1 -0
  69. package/types/esm/constants/sdk-version.d.ts +1 -1
  70. package/types/esm/functions/apply-patch-with-mutation.d.ts +10 -0
  71. package/types/esm/functions/evaluate/edge-runtime/acorn-interpreter.d.ts +2 -0
  72. package/types/esm/functions/evaluate/edge-runtime/edge-runtime.d.ts +2 -0
  73. package/types/esm/functions/evaluate/edge-runtime/index.d.ts +1 -0
  74. package/types/esm/functions/evaluate/node-runtime/index.d.ts +1 -0
  75. package/types/esm/functions/evaluate/node-runtime/init.d.ts +13 -0
  76. package/types/esm/functions/evaluate/node-runtime/node-runtime.d.ts +11 -0
  77. package/types/esm/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +8 -0
  78. package/types/esm/functions/evaluate/placeholder-runtime.d.ts +2 -0
  79. package/types/esm/functions/extract-css-var-default-value.d.ts +1 -0
  80. package/types/esm/functions/is-edge-runtime.d.ts +4 -0
  81. package/types/esm/functions/on-change.d.ts +7 -0
  82. package/types/esm/helpers/omit.d.ts +1 -0
  83. package/types/esm/helpers/time.d.ts +1 -0
  84. package/lib/browser/USE_CLIENT_BUNDLE-2675ec3a.js +0 -703
  85. package/lib/browser/USE_CLIENT_BUNDLE-d62c0e9f.cjs +0 -21
  86. package/lib/browser/USE_SERVER_BUNDLE-22146bcb.cjs +0 -1
  87. package/lib/browser/USE_SERVER_BUNDLE-a878761a.js +0 -11
  88. package/lib/browser/bundle-4aca3c04.cjs +0 -169
  89. package/lib/browser/bundle-9acde1f6.js +0 -2832
  90. package/lib/edge/USE_CLIENT_BUNDLE-744a0d92.js +0 -703
  91. package/lib/edge/USE_CLIENT_BUNDLE-ad07ada0.cjs +0 -21
  92. package/lib/edge/USE_SERVER_BUNDLE-50d2bf59.cjs +0 -1
  93. package/lib/edge/USE_SERVER_BUNDLE-d2138019.js +0 -11
  94. package/lib/edge/bundle-6770809f.cjs +0 -189
  95. package/lib/node/USE_CLIENT_BUNDLE-2f8a2b0f.cjs +0 -21
  96. package/lib/node/USE_CLIENT_BUNDLE-bdfd3683.js +0 -703
  97. package/lib/node/USE_SERVER_BUNDLE-786cc2c7.cjs +0 -1
  98. package/lib/node/USE_SERVER_BUNDLE-a6561926.js +0 -11
  99. package/lib/node/bundle-8b02f7d4.cjs +0 -216
  100. package/lib/node/bundle-ca4c205c.js +0 -2953
@@ -1,2953 +0,0 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import "react";
3
- import { LRUCache } from "lru-cache";
4
- import { I as InteractiveElement, B as BlockWrapper, a as BlocksWrapper, D as DynamicRenderer, C as CustomCode, E as Embed, b as ImgComponent, V as Video, c as Button, F as FragmentComponent, d as Image, S as SectionComponent, e as EnableEditor } from "./USE_CLIENT_BUNDLE-bdfd3683.js";
5
- import "next/navigation";
6
- const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), isEmptyElement = (e) => typeof e == "string" && EMPTY_HTML_ELEMENTS.has(e.toLowerCase()), TARGET = "rsc", getClassPropName = () => {
7
- switch (TARGET) {
8
- case "react":
9
- case "reactNative":
10
- case "rsc":
11
- return "className";
12
- case "svelte":
13
- case "vue":
14
- case "solid":
15
- case "qwik":
16
- case "angular":
17
- return "class";
18
- }
19
- };
20
- function getBlockComponentOptions(e) {
21
- var t;
22
- return {
23
- ...(t = e.component) == null ? void 0 : t.options,
24
- ...e.options
25
- };
26
- }
27
- const MSG_PREFIX = "[Builder.io]: ", logger = {
28
- log: (...e) => console.log(MSG_PREFIX, ...e),
29
- error: (...e) => console.error(MSG_PREFIX, ...e),
30
- warn: (...e) => console.warn(MSG_PREFIX, ...e),
31
- debug: (...e) => console.debug(MSG_PREFIX, ...e)
32
- };
33
- function isBrowser() {
34
- return typeof window < "u" && typeof document < "u";
35
- }
36
- const convertSearchParamsToQueryObject = (e) => {
37
- const t = {};
38
- return e.forEach((n, o) => {
39
- t[o] = n;
40
- }), t;
41
- }, normalizeSearchParams = (e) => e instanceof URLSearchParams ? convertSearchParamsToQueryObject(e) : e, getSearchString = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
42
- function isIframe() {
43
- return isBrowser() && window.self !== window.top;
44
- }
45
- function isEditing(e) {
46
- return isIframe() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
47
- getSearchString(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
48
- }
49
- const getLocation = () => {
50
- if (isBrowser()) {
51
- const e = new URL(location.href);
52
- return e.pathname === "" && (e.pathname = "/"), e;
53
- } else
54
- return console.warn("Cannot get location for tracking in non-browser environment"), null;
55
- }, getUserAgent = () => typeof navigator == "object" && navigator.userAgent || "", getUserAttributes = () => {
56
- const e = getUserAgent(), t = {
57
- Android() {
58
- return e.match(/Android/i);
59
- },
60
- BlackBerry() {
61
- return e.match(/BlackBerry/i);
62
- },
63
- iOS() {
64
- return e.match(/iPhone|iPod/i);
65
- },
66
- Opera() {
67
- return e.match(/Opera Mini/i);
68
- },
69
- Windows() {
70
- return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
71
- },
72
- any() {
73
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || TARGET === "reactNative";
74
- }
75
- }, n = e.match(/Tablet|iPad/i), o = getLocation();
76
- return {
77
- urlPath: o == null ? void 0 : o.pathname,
78
- host: (o == null ? void 0 : o.host) || (o == null ? void 0 : o.hostname),
79
- device: n ? "tablet" : t.any() ? "mobile" : "desktop"
80
- };
81
- }, getFunctionArguments = ({
82
- builder: e,
83
- context: t,
84
- event: n,
85
- state: o
86
- }) => Object.entries({
87
- state: o,
88
- Builder: e,
89
- // legacy
90
- builder: e,
91
- context: t,
92
- event: n
93
- }), getBuilderGlobals = () => ({
94
- isEditing: isEditing(),
95
- isBrowser: isBrowser(),
96
- isServer: !isBrowser(),
97
- getUserAttributes: () => getUserAttributes()
98
- }), parseCode = (e, {
99
- isExpression: t = !0
100
- }) => /* we disable this for cases where we definitely don't want a return */ t && !(e.includes(";") || e.includes(" return ") || e.trim().startsWith("return ")) ? `return (${e});` : e, runInBrowser = ({
101
- code: e,
102
- builder: t,
103
- context: n,
104
- event: o,
105
- localState: r,
106
- rootSetState: i,
107
- rootState: a
108
- }) => {
109
- const s = getFunctionArguments({
110
- builder: t,
111
- context: n,
112
- event: o,
113
- state: flattenState({
114
- rootState: a,
115
- localState: r,
116
- rootSetState: i
117
- })
118
- });
119
- return new Function(...s.map(([c]) => c), e)(...s.map(([, c]) => c));
120
- };
121
- function flattenState({
122
- rootState: e,
123
- localState: t,
124
- rootSetState: n
125
- }) {
126
- return new Proxy(e, {
127
- get: (o, r) => {
128
- if (t && r in t)
129
- return t[r];
130
- const i = o[r];
131
- return typeof i == "object" && i !== null ? flattenState({
132
- rootState: i,
133
- localState: void 0,
134
- rootSetState: n ? (a) => {
135
- o[r] = a, n(o);
136
- } : void 0
137
- }) : i;
138
- },
139
- set: (o, r, i) => {
140
- if (t && r in t)
141
- throw new Error("Writing to local state is not allowed as it is read-only.");
142
- return o[r] = i, n == null || n(o), !0;
143
- }
144
- });
145
- }
146
- const fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t, n) => {
147
- if (Object(e) !== e)
148
- return e;
149
- const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
150
- return o.slice(0, -1).reduce((r, i, a) => Object(r[i]) === r[i] ? r[i] : r[i] = Math.abs(Number(o[a + 1])) >> 0 === +o[a + 1] ? [] : {}, e)[o[o.length - 1]] = n, e;
151
- }, noop = () => {
152
- };
153
- let safeDynamicRequire = noop;
154
- try {
155
- safeDynamicRequire = eval("require");
156
- } catch (e) {
157
- }
158
- const getSyncValName = (e) => `bldr_${e}_sync`, BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE", INJECTED_IVM_GLOBAL = "BUILDER_IVM", REF_TO_PROXY_FN = `
159
- var refToProxy = (obj) => {
160
- if (typeof obj !== 'object' || obj === null) {
161
- return obj;
162
- }
163
- return new Proxy({}, {
164
- get(target, key) {
165
- if (key === 'copySync') {
166
- return () => obj.copySync();
167
- }
168
- const val = obj.getSync(key);
169
- if (typeof val?.getSync === 'function') {
170
- return refToProxy(val);
171
- }
172
- return val;
173
- },
174
- set(target, key, value) {
175
- const v = typeof value === 'object' ? new ${INJECTED_IVM_GLOBAL}.Reference(value) : value;
176
- obj.setSync(key, v);
177
- ${BUILDER_SET_STATE_NAME}(key, value)
178
- },
179
- deleteProperty(target, key) {
180
- obj.deleteSync(key);
181
- }
182
- })
183
- }
184
- `, processCode = ({
185
- code: e,
186
- args: t
187
- }) => {
188
- const n = t.map(([o]) => `var ${o} = refToProxy(${getSyncValName(o)}); `).join("");
189
- return `
190
- ${REF_TO_PROXY_FN}
191
- ${n}
192
- function theFunction() {
193
- ${e}
194
- }
195
-
196
- const output = theFunction()
197
-
198
- if (typeof output === 'object' && output !== null) {
199
- return JSON.stringify(output.copySync ? output.copySync() : output);
200
- } else {
201
- return output;
202
- }
203
- `;
204
- };
205
- let IVM_INSTANCE = null, IVM_CONTEXT = null;
206
- const getIvm = () => {
207
- try {
208
- const e = safeDynamicRequire("isolated-vm");
209
- if (e)
210
- return e;
211
- } catch (e) {
212
- logger.error("isolated-vm import error.", e);
213
- }
214
- throw new Error(`${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on Node server.
215
-
216
- In certain Node environments, the SDK requires additional initialization steps. This can be achieved by
217
- importing and calling \`initializeNodeRuntime()\` from "@builder.io/sdk-react/node/init". This must be done in
218
- a server-only execution path within your application.
219
-
220
- Please see the documentation for more information: https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments
221
- `);
222
- };
223
- function setIsolateContext(e = {
224
- memoryLimit: 128
225
- }) {
226
- const t = getIvm(), o = new t.Isolate(e).createContextSync(), r = o.global;
227
- return r.setSync("global", r.derefInto()), r.setSync("log", function(...i) {
228
- console.log(...i);
229
- }), r.setSync(INJECTED_IVM_GLOBAL, t), IVM_CONTEXT = o, o;
230
- }
231
- const getIsolateContext = () => IVM_CONTEXT || setIsolateContext(), runInNode = ({
232
- code: e,
233
- builder: t,
234
- context: n,
235
- event: o,
236
- localState: r,
237
- rootSetState: i,
238
- rootState: a
239
- }) => {
240
- const s = getIvm(), c = fastClone({
241
- ...a,
242
- ...r
243
- }), d = getFunctionArguments({
244
- builder: t,
245
- context: n,
246
- event: o,
247
- state: c
248
- }), f = getIsolateContext(), l = f.global;
249
- l.setSync(BUILDER_SET_STATE_NAME, function(y, p) {
250
- set(a, y, p), i == null || i(a);
251
- }), d.forEach(([y, p]) => {
252
- const v = typeof p == "object" ? new s.Reference(
253
- // workaround: methods with default values for arguments is not being cloned over
254
- y === "builder" ? {
255
- ...p,
256
- getUserAttributes: () => p.getUserAttributes()
257
- } : p
258
- ) : null;
259
- l.setSync(getSyncValName(y), v);
260
- });
261
- const u = processCode({
262
- code: e,
263
- args: d
264
- }), g = f.evalClosureSync(u);
265
- try {
266
- return JSON.parse(g);
267
- } catch {
268
- return g;
269
- }
270
- }, checkIsDefined = (e) => e != null;
271
- function isNodeRuntime() {
272
- var e;
273
- return typeof process < "u" && checkIsDefined((e = process == null ? void 0 : process.versions) == null ? void 0 : e.node);
274
- }
275
- const shouldForceBrowserRuntimeInNode = () => {
276
- var o;
277
- if (!isNodeRuntime())
278
- return !1;
279
- const e = process.arch === "arm64", t = process.version.startsWith("v20"), n = (o = process.env.NODE_OPTIONS) == null ? void 0 : o.includes("--no-node-snapshot");
280
- return e && t && !n ? (logger.log("Skipping usage of `isolated-vm` to avoid crashes in Node v20 on an arm64 machine.\n If you would like to use the `isolated-vm` package on this machine, please provide the `NODE_OPTIONS=--no-node-snapshot` config to your Node process.\n See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.\n "), !0) : !1;
281
- }, chooseBrowserOrServerEval = (e) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(e) : runInNode(e), _EvalCache = class k {
282
- static getCacheKey(t) {
283
- return JSON.stringify({
284
- ...t,
285
- // replace the event with a random number to break cache
286
- // thats because we can't serialize the event object due to circular refs in DOM node refs.
287
- event: t.event ? Math.random() : void 0
288
- });
289
- }
290
- static getCachedValue(t) {
291
- return k.cache.get(t);
292
- }
293
- static setCachedValue(t, n) {
294
- k.cache.size > 20 && k.cache.delete(k.cache.keys().next().value), k.cache.set(t, {
295
- value: n
296
- });
297
- }
298
- };
299
- _EvalCache.cacheLimit = 20;
300
- _EvalCache.cache = /* @__PURE__ */ new Map();
301
- let EvalCache = _EvalCache;
302
- function evaluate({
303
- code: e,
304
- context: t,
305
- localState: n,
306
- rootState: o,
307
- rootSetState: r,
308
- event: i,
309
- isExpression: a = !0,
310
- enableCache: s
311
- }) {
312
- if (e === "")
313
- return;
314
- const c = {
315
- code: parseCode(e, {
316
- isExpression: a
317
- }),
318
- builder: getBuilderGlobals(),
319
- context: t,
320
- event: i,
321
- rootSetState: r,
322
- rootState: o,
323
- localState: n
324
- };
325
- if (s) {
326
- const d = EvalCache.getCacheKey(c), f = EvalCache.getCachedValue(d);
327
- if (f)
328
- return f.value;
329
- }
330
- try {
331
- const d = chooseBrowserOrServerEval(c);
332
- if (s) {
333
- const f = EvalCache.getCacheKey(c);
334
- EvalCache.setCachedValue(f, d);
335
- }
336
- return d;
337
- } catch (d) {
338
- logger.error("Failed code evaluation: " + d.message, {
339
- code: e
340
- });
341
- return;
342
- }
343
- }
344
- function transformBlock(e) {
345
- return e;
346
- }
347
- const evaluateBindings = ({
348
- block: e,
349
- context: t,
350
- localState: n,
351
- rootState: o,
352
- rootSetState: r
353
- }) => {
354
- if (!e.bindings)
355
- return e;
356
- const i = fastClone(e), a = {
357
- ...i,
358
- properties: {
359
- ...i.properties
360
- },
361
- actions: {
362
- ...i.actions
363
- }
364
- };
365
- for (const s in e.bindings) {
366
- const c = e.bindings[s], d = evaluate({
367
- code: c,
368
- localState: n,
369
- rootState: o,
370
- rootSetState: r,
371
- context: t,
372
- enableCache: !0
373
- });
374
- set(a, s, d);
375
- }
376
- return a;
377
- };
378
- function getProcessedBlock({
379
- block: e,
380
- context: t,
381
- shouldEvaluateBindings: n,
382
- localState: o,
383
- rootState: r,
384
- rootSetState: i
385
- }) {
386
- const a = e;
387
- return n ? evaluateBindings({
388
- block: a,
389
- localState: o,
390
- rootState: r,
391
- rootSetState: i,
392
- context: t
393
- }) : a;
394
- }
395
- const camelToKebabCase = (e) => e ? e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase() : "", convertStyleMapToCSSArray = (e) => Object.entries(e).map(([n, o]) => {
396
- if (typeof o == "string")
397
- return `${camelToKebabCase(n)}: ${o};`;
398
- }).filter(checkIsDefined), convertStyleMapToCSS = (e) => convertStyleMapToCSSArray(e).join(`
399
- `), createCssClass = ({
400
- mediaQuery: e,
401
- className: t,
402
- styles: n
403
- }) => {
404
- const o = `.${t} {
405
- ${convertStyleMapToCSS(n)}
406
- }`;
407
- return e ? `${e} {
408
- ${o}
409
- }` : o;
410
- };
411
- function transformStyleProperty({
412
- style: e
413
- }) {
414
- return e;
415
- }
416
- const getStyle = ({
417
- block: e,
418
- context: t
419
- }) => mapStyleObjToStrIfNeeded(transformStyleProperty({
420
- style: e.style || {},
421
- context: t,
422
- block: e
423
- }));
424
- function mapStyleObjToStrIfNeeded(e) {
425
- switch (TARGET) {
426
- case "svelte":
427
- case "vue":
428
- case "solid":
429
- case "angular":
430
- return convertStyleMapToCSSArray(e).join(" ");
431
- case "qwik":
432
- case "reactNative":
433
- case "react":
434
- case "rsc":
435
- return e;
436
- }
437
- }
438
- const getComponent = ({
439
- block: e,
440
- context: t,
441
- registeredComponents: n
442
- }) => {
443
- var i;
444
- const o = (i = getProcessedBlock({
445
- block: e,
446
- localState: t.localState,
447
- rootState: t.rootState,
448
- rootSetState: t.rootSetState,
449
- context: t.context,
450
- shouldEvaluateBindings: !1
451
- }).component) == null ? void 0 : i.name;
452
- if (!o)
453
- return null;
454
- const r = n[o];
455
- if (r)
456
- return r;
457
- console.warn(`
458
- Could not find a registered component named "${o}".
459
- If you registered it, is the file that registered it imported by the file that needs to render it?`);
460
- }, getRepeatItemData = ({
461
- block: e,
462
- context: t
463
- }) => {
464
- const {
465
- repeat: n,
466
- ...o
467
- } = e;
468
- if (!(n != null && n.collection))
469
- return;
470
- const r = evaluate({
471
- code: n.collection,
472
- localState: t.localState,
473
- rootState: t.rootState,
474
- rootSetState: t.rootSetState,
475
- context: t.context,
476
- enableCache: !0
477
- });
478
- if (!Array.isArray(r))
479
- return;
480
- const i = n.collection.split(".").pop(), a = n.itemName || (i ? i + "Item" : "item");
481
- return r.map((c, d) => ({
482
- context: {
483
- ...t,
484
- localState: {
485
- ...t.localState,
486
- $index: d,
487
- $item: c,
488
- [a]: c,
489
- [`$${a}Index`]: d
490
- }
491
- },
492
- block: o
493
- }));
494
- }, provideLinkComponent = (e, t) => e && (e.isRSC && TARGET === "rsc" || ["Core:Button", "Symbol", "Columns", "Form:Form", "Builder: Tabs", "Builder:Accordion"].includes(e.name)) ? {
495
- builderLinkComponent: t
496
- } : {}, provideRegisteredComponents = (e, t) => e && (e.isRSC && TARGET === "rsc" || ["Symbol", "Columns", "Form:Form", "Builder: Tabs", "Builder:Accordion"].includes(e.name)) ? {
497
- builderComponents: t
498
- } : {}, provideBuilderBlock = (e, t) => e && (e.isRSC && TARGET === "rsc" || TARGET === "reactNative" || ["Builder:Accordion", "Columns", "Form:Form", "Builder: Tabs", "Symbol", "Image", "Video"].includes(e.name)) ? {
499
- builderBlock: t
500
- } : {}, provideBuilderContext = (e, t) => e && (e.isRSC && TARGET === "rsc" || ["Builder:Accordion", "Columns", "Form:Form", "Builder: Tabs", "Symbol", "Slot"].includes(e.name)) ? {
501
- builderContext: t
502
- } : {}, SIZES = {
503
- small: {
504
- min: 320,
505
- default: 321,
506
- max: 640
507
- },
508
- medium: {
509
- min: 641,
510
- default: 642,
511
- max: 991
512
- },
513
- large: {
514
- min: 990,
515
- default: 991,
516
- max: 1200
517
- }
518
- }, getMaxWidthQueryForSize = (e, t = SIZES) => `@media (max-width: ${t[e].max}px)`, getSizesForBreakpoints = ({
519
- small: e,
520
- medium: t
521
- }) => {
522
- const n = fastClone(SIZES);
523
- if (!e || !t)
524
- return n;
525
- const o = Math.floor(e / 2);
526
- n.small = {
527
- max: e,
528
- min: o,
529
- default: o + 1
530
- };
531
- const r = n.small.max + 1;
532
- n.medium = {
533
- max: t,
534
- min: r,
535
- default: r + 1
536
- };
537
- const i = n.medium.max + 1;
538
- return n.large = {
539
- max: 2e3,
540
- // TODO: decide upper limit
541
- min: i,
542
- default: i + 1
543
- }, n;
544
- };
545
- function InlinedStyles(e) {
546
- return /* @__PURE__ */ jsx(
547
- "style",
548
- {
549
- dangerouslySetInnerHTML: { __html: e.styles },
550
- "data-id": e.id
551
- }
552
- );
553
- }
554
- function BlockStyles(e) {
555
- const t = function() {
556
- const r = getProcessedBlock({
557
- block: e.block,
558
- localState: e.context.localState,
559
- rootState: e.context.rootState,
560
- rootSetState: e.context.rootSetState,
561
- context: e.context.context,
562
- shouldEvaluateBindings: !0
563
- });
564
- return checkIsDefined(r.hide) ? !r.hide : checkIsDefined(r.show) ? r.show : !0;
565
- }, n = function() {
566
- var m, h, b;
567
- const r = getProcessedBlock({
568
- block: e.block,
569
- localState: e.context.localState,
570
- rootState: e.context.rootState,
571
- rootSetState: e.context.rootSetState,
572
- context: e.context.context,
573
- shouldEvaluateBindings: !0
574
- }), i = r.responsiveStyles, a = e.context.content, s = getSizesForBreakpoints(
575
- ((m = a == null ? void 0 : a.meta) == null ? void 0 : m.breakpoints) || {}
576
- ), c = i == null ? void 0 : i.large, d = i == null ? void 0 : i.medium, f = i == null ? void 0 : i.small, l = r.id;
577
- if (!l)
578
- return "";
579
- const u = c ? createCssClass({
580
- className: l,
581
- styles: c
582
- }) : "", g = d ? createCssClass({
583
- className: l,
584
- styles: d,
585
- mediaQuery: getMaxWidthQueryForSize(
586
- "medium",
587
- s
588
- )
589
- }) : "", y = f ? createCssClass({
590
- className: l,
591
- styles: f,
592
- mediaQuery: getMaxWidthQueryForSize(
593
- "small",
594
- s
595
- )
596
- }) : "", p = r.animations && r.animations.find((S) => S.trigger === "hover");
597
- let v = "";
598
- if (p) {
599
- const S = ((b = (h = p.steps) == null ? void 0 : h[1]) == null ? void 0 : b.styles) || {};
600
- v = createCssClass({
601
- className: `${l}:hover`,
602
- styles: {
603
- ...S,
604
- transition: `all ${p.duration}s ${camelToKebabCase(
605
- p.easing
606
- )}`,
607
- transitionDelay: p.delay ? `${p.delay}s` : "0s"
608
- }
609
- }) || "";
610
- }
611
- return [
612
- u,
613
- g,
614
- y,
615
- v
616
- ].join(" ");
617
- };
618
- return /* @__PURE__ */ jsx(Fragment, { children: n() && t() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { id: "builderio-block", styles: n() }) }) : null });
619
- }
620
- function capitalizeFirstLetter(e) {
621
- return e.charAt(0).toUpperCase() + e.slice(1);
622
- }
623
- const getEventHandlerName = (e) => `on${capitalizeFirstLetter(e)}`, createEventHandler = (e, t) => (n) => evaluate({
624
- code: e,
625
- context: t.context,
626
- localState: t.localState,
627
- rootState: t.rootState,
628
- rootSetState: t.rootSetState,
629
- event: n,
630
- isExpression: !1,
631
- enableCache: !0
632
- });
633
- function getBlockActions(e) {
634
- const t = {}, n = e.block.actions ?? {};
635
- for (const o in n) {
636
- if (!n.hasOwnProperty(o))
637
- continue;
638
- const r = n[o];
639
- let i = getEventHandlerName(o);
640
- if (e.stripPrefix)
641
- switch (TARGET) {
642
- case "vue":
643
- i = i.replace("v-on:", "");
644
- break;
645
- case "svelte":
646
- i = i.replace("on:", "");
647
- break;
648
- }
649
- t[i] = createEventHandler(r, e);
650
- }
651
- return t;
652
- }
653
- function transformBlockProperties({
654
- properties: e
655
- }) {
656
- return e;
657
- }
658
- const extractRelevantRootBlockProperties = (e) => ({
659
- href: e.href
660
- });
661
- function getBlockProperties({
662
- block: e,
663
- context: t
664
- }) {
665
- var o;
666
- const n = {
667
- ...extractRelevantRootBlockProperties(e),
668
- ...e.properties,
669
- "builder-id": e.id,
670
- style: getStyle({
671
- block: e,
672
- context: t
673
- }),
674
- [getClassPropName()]: [e.id, "builder-block", e.class, (o = e.properties) == null ? void 0 : o.class].filter(Boolean).join(" ")
675
- };
676
- return transformBlockProperties({
677
- properties: n,
678
- context: t,
679
- block: e
680
- });
681
- }
682
- const getWrapperProps = ({
683
- componentOptions: e,
684
- builderBlock: t,
685
- context: n,
686
- componentRef: o,
687
- includeBlockProps: r,
688
- isInteractive: i,
689
- contextValue: a
690
- }) => {
691
- const s = {
692
- ...e,
693
- /**
694
- * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
695
- * component itself directly. Otherwise, they are provided to the wrapper element.
696
- */
697
- ...r ? {
698
- attributes: getBlockProperties({
699
- block: t,
700
- context: a
701
- })
702
- } : {}
703
- };
704
- return i ? {
705
- Wrapper: o,
706
- block: t,
707
- context: n,
708
- wrapperProps: e,
709
- includeBlockProps: r
710
- } : s;
711
- };
712
- function ComponentRef(e) {
713
- var n;
714
- const t = e.isInteractive ? InteractiveElement : e.componentRef;
715
- return /* @__PURE__ */ jsx(Fragment, { children: e.componentRef ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
716
- t,
717
- {
718
- ...getWrapperProps({
719
- componentOptions: e.componentOptions,
720
- builderBlock: e.builderBlock,
721
- context: e.context,
722
- componentRef: e.componentRef,
723
- linkComponent: e.linkComponent,
724
- includeBlockProps: e.includeBlockProps,
725
- isInteractive: e.isInteractive,
726
- contextValue: e.context
727
- }),
728
- children: (n = e.blockChildren) == null ? void 0 : n.map((o) => /* @__PURE__ */ jsx(
729
- Block,
730
- {
731
- block: o,
732
- context: e.context,
733
- registeredComponents: e.registeredComponents,
734
- linkComponent: e.linkComponent
735
- },
736
- o.id
737
- ))
738
- }
739
- ) }) : null });
740
- }
741
- function RepeatedBlock(e) {
742
- const t = e.repeatContext;
743
- return /* @__PURE__ */ jsx(
744
- Block,
745
- {
746
- block: e.block,
747
- context: t,
748
- registeredComponents: e.registeredComponents,
749
- linkComponent: e.linkComponent
750
- }
751
- );
752
- }
753
- function Block(e) {
754
- var c, d, f;
755
- const t = function() {
756
- return getComponent({
757
- block: e.block,
758
- context: e.context,
759
- registeredComponents: e.registeredComponents
760
- });
761
- }, n = function() {
762
- return getRepeatItemData({
763
- block: e.block,
764
- context: e.context
765
- });
766
- }, o = function() {
767
- var u;
768
- return (u = e.block.repeat) != null && u.collection ? e.block : getProcessedBlock({
769
- block: e.block,
770
- localState: e.context.localState,
771
- rootState: e.context.rootState,
772
- rootSetState: e.context.rootSetState,
773
- context: e.context.context,
774
- shouldEvaluateBindings: !0
775
- });
776
- }, r = function() {
777
- var g;
778
- return e.block.tagName === "a" || ((g = o().properties) == null ? void 0 : g.href) || o().href ? e.linkComponent || "a" : e.block.tagName || "div";
779
- }, i = function() {
780
- var y, p;
781
- if ((y = e.block.repeat) != null && y.collection)
782
- return !!((p = n()) != null && p.length);
783
- const u = "hide" in o() ? o().hide : !1;
784
- return ("show" in o() ? o().show : !0) && !u;
785
- }, a = function() {
786
- var g;
787
- return !((g = t()) != null && g.component) && !n() ? o().children ?? [] : [];
788
- }, s = function() {
789
- var u, g, y;
790
- return {
791
- blockChildren: o().children ?? [],
792
- componentRef: (u = t()) == null ? void 0 : u.component,
793
- componentOptions: {
794
- ...getBlockComponentOptions(o()),
795
- ...provideBuilderBlock(t(), o()),
796
- ...provideBuilderContext(t(), e.context),
797
- ...provideLinkComponent(t(), e.linkComponent),
798
- ...provideRegisteredComponents(
799
- t(),
800
- e.registeredComponents
801
- )
802
- },
803
- context: e.context,
804
- linkComponent: e.linkComponent,
805
- registeredComponents: e.registeredComponents,
806
- builderBlock: o(),
807
- includeBlockProps: ((g = t()) == null ? void 0 : g.noWrap) === !0,
808
- isInteractive: !((y = t()) != null && y.isRSC)
809
- };
810
- };
811
- return /* @__PURE__ */ jsx(Fragment, { children: i() ? /* @__PURE__ */ jsxs(Fragment, { children: [
812
- /* @__PURE__ */ jsx(BlockStyles, { block: e.block, context: e.context }),
813
- (c = t()) != null && c.noWrap ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
814
- ComponentRef,
815
- {
816
- componentRef: s().componentRef,
817
- componentOptions: s().componentOptions,
818
- blockChildren: s().blockChildren,
819
- context: s().context,
820
- registeredComponents: s().registeredComponents,
821
- linkComponent: s().linkComponent,
822
- builderBlock: s().builderBlock,
823
- includeBlockProps: s().includeBlockProps,
824
- isInteractive: s().isInteractive
825
- }
826
- ) }) : /* @__PURE__ */ jsx(Fragment, { children: n() ? /* @__PURE__ */ jsx(Fragment, { children: (f = n()) == null ? void 0 : f.map((l, u) => /* @__PURE__ */ jsx(
827
- RepeatedBlock,
828
- {
829
- repeatContext: l.context,
830
- block: l.block,
831
- registeredComponents: e.registeredComponents,
832
- linkComponent: e.linkComponent
833
- },
834
- u
835
- )) }) : /* @__PURE__ */ jsxs(
836
- BlockWrapper,
837
- {
838
- Wrapper: r(),
839
- block: o(),
840
- context: e.context,
841
- children: [
842
- /* @__PURE__ */ jsx(
843
- ComponentRef,
844
- {
845
- componentRef: s().componentRef,
846
- componentOptions: s().componentOptions,
847
- blockChildren: s().blockChildren,
848
- context: s().context,
849
- registeredComponents: s().registeredComponents,
850
- linkComponent: s().linkComponent,
851
- builderBlock: s().builderBlock,
852
- includeBlockProps: s().includeBlockProps,
853
- isInteractive: s().isInteractive
854
- }
855
- ),
856
- (d = a()) == null ? void 0 : d.map((l) => /* @__PURE__ */ jsx(
857
- Block,
858
- {
859
- block: l,
860
- registeredComponents: e.registeredComponents,
861
- linkComponent: e.linkComponent,
862
- context: e.context
863
- },
864
- l.id
865
- ))
866
- ]
867
- }
868
- ) })
869
- ] }) : null });
870
- }
871
- function Blocks(e) {
872
- var t, n, o;
873
- return /* @__PURE__ */ jsx(
874
- BlocksWrapper,
875
- {
876
- blocks: e.blocks,
877
- parent: e.parent,
878
- path: e.path,
879
- styleProp: e.styleProp,
880
- BlocksWrapper: (t = e.context) == null ? void 0 : t.BlocksWrapper,
881
- BlocksWrapperProps: (n = e.context) == null ? void 0 : n.BlocksWrapperProps,
882
- children: e.blocks ? /* @__PURE__ */ jsx(Fragment, { children: (o = e.blocks) == null ? void 0 : o.map((r) => /* @__PURE__ */ jsx(
883
- Block,
884
- {
885
- block: r,
886
- linkComponent: e.linkComponent,
887
- context: e.context,
888
- registeredComponents: e.registeredComponents
889
- },
890
- r.id
891
- )) }) : null
892
- }
893
- );
894
- }
895
- const getColumnsClass = (e) => `builder-columns ${e}-breakpoints`;
896
- function Columns(e) {
897
- var p, v;
898
- const t = typeof e.space == "number" ? e.space || 0 : 20, n = e.columns || [], o = e.stackColumnsAt || "tablet", r = function(h) {
899
- return h.link ? e.builderLinkComponent || "a" : "div";
900
- }, i = function(h) {
901
- var b;
902
- return ((b = n[h]) == null ? void 0 : b.width) || 100 / n.length;
903
- }, a = function(h) {
904
- const b = t * (n.length - 1) / n.length;
905
- return `calc(${i(h)}% - ${b}px)`;
906
- }, s = function({
907
- stackedStyle: h,
908
- desktopStyle: b
909
- }) {
910
- return o === "tablet" ? h : b;
911
- }, c = function({
912
- stackedStyle: h,
913
- desktopStyle: b
914
- }) {
915
- return o === "never" ? b : h;
916
- }, d = e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column", f = function() {
917
- return {
918
- "--flex-dir": d,
919
- "--flex-dir-tablet": s({
920
- stackedStyle: d,
921
- desktopStyle: "row"
922
- })
923
- };
924
- }, l = function(h) {
925
- const b = h === 0 ? 0 : t, S = a(h), C = `${b}px`, I = "100%", x = 0;
926
- return {
927
- ...{
928
- display: "flex",
929
- flexDirection: "column",
930
- alignItems: "stretch"
931
- },
932
- width: S,
933
- ["marginLeft"]: C,
934
- "--column-width-mobile": c({
935
- stackedStyle: I,
936
- desktopStyle: S
937
- }),
938
- "--column-margin-left-mobile": c({
939
- stackedStyle: x,
940
- desktopStyle: C
941
- }),
942
- "--column-width-tablet": s({
943
- stackedStyle: I,
944
- desktopStyle: S
945
- }),
946
- "--column-margin-left-tablet": s({
947
- stackedStyle: x,
948
- desktopStyle: C
949
- })
950
- };
951
- }, u = function(h) {
952
- var S, C;
953
- return getSizesForBreakpoints(
954
- ((C = (S = e.builderContext.content) == null ? void 0 : S.meta) == null ? void 0 : C.breakpoints) || {}
955
- )[h].max;
956
- }, g = function() {
957
- return `
958
- @media (max-width: ${u("medium")}px) {
959
- .${e.builderBlock.id}-breakpoints {
960
- flex-direction: var(--flex-dir-tablet);
961
- align-items: stretch;
962
- }
963
-
964
- .${e.builderBlock.id}-breakpoints > .builder-column {
965
- width: var(--column-width-tablet) !important;
966
- margin-left: var(--column-margin-left-tablet) !important;
967
- }
968
- }
969
-
970
- @media (max-width: ${u("small")}px) {
971
- .${e.builderBlock.id}-breakpoints {
972
- flex-direction: var(--flex-dir);
973
- align-items: stretch;
974
- }
975
-
976
- .${e.builderBlock.id}-breakpoints > .builder-column {
977
- width: var(--column-width-mobile) !important;
978
- margin-left: var(--column-margin-left-mobile) !important;
979
- }
980
- },
981
- `;
982
- }, y = function(h, b) {
983
- return {
984
- ...h.link ? {
985
- href: h.link
986
- } : {},
987
- [getClassPropName()]: "builder-column",
988
- style: mapStyleObjToStrIfNeeded(l(b))
989
- };
990
- };
991
- return /* @__PURE__ */ jsxs(Fragment, { children: [
992
- /* @__PURE__ */ jsxs(
993
- "div",
994
- {
995
- className: getColumnsClass((p = e.builderBlock) == null ? void 0 : p.id) + " div-eeca3604",
996
- style: f(),
997
- children: [
998
- /* @__PURE__ */ jsx(InlinedStyles, { id: "builderio-columns", styles: g() }),
999
- (v = e.columns) == null ? void 0 : v.map((m, h) => /* @__PURE__ */ jsx(
1000
- DynamicRenderer,
1001
- {
1002
- TagName: r(m),
1003
- actionAttributes: {},
1004
- attributes: y(m, h),
1005
- children: /* @__PURE__ */ jsx(
1006
- Blocks,
1007
- {
1008
- path: `component.options.columns.${h}.blocks`,
1009
- parent: e.builderBlock.id,
1010
- styleProp: {
1011
- flexGrow: "1"
1012
- },
1013
- context: e.builderContext,
1014
- registeredComponents: e.builderComponents,
1015
- linkComponent: e.builderLinkComponent,
1016
- blocks: m.blocks
1017
- }
1018
- )
1019
- },
1020
- h
1021
- ))
1022
- ]
1023
- }
1024
- ),
1025
- /* @__PURE__ */ jsx("style", { children: `.div-eeca3604 {
1026
- display: flex;
1027
- line-height: normal;
1028
- }` })
1029
- ] });
1030
- }
1031
- function removeProtocol(e) {
1032
- return e.replace(/http(s)?:/, "");
1033
- }
1034
- function updateQueryParam(e = "", t, n) {
1035
- const o = new RegExp("([?&])" + t + "=.*?(&|$)", "i"), r = e.indexOf("?") !== -1 ? "&" : "?";
1036
- return e.match(o) ? e.replace(o, "$1" + t + "=" + encodeURIComponent(n) + "$2") : e + r + t + "=" + encodeURIComponent(n);
1037
- }
1038
- function getShopifyImageUrl(e, t) {
1039
- if (!e || !(e != null && e.match(/cdn\.shopify\.com/)) || !t)
1040
- return e;
1041
- if (t === "master")
1042
- return removeProtocol(e);
1043
- const n = e.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
1044
- if (n) {
1045
- const o = e.split(n[0]), r = n[3], i = t.match("x") ? t : `${t}x`;
1046
- return removeProtocol(`${o[0]}_${i}${r}`);
1047
- }
1048
- return null;
1049
- }
1050
- function getSrcSet(e) {
1051
- if (!e)
1052
- return e;
1053
- const t = [100, 200, 400, 800, 1200, 1600, 2e3];
1054
- if (e.match(/builder\.io/)) {
1055
- let n = e;
1056
- const o = Number(e.split("?width=")[1]);
1057
- return isNaN(o) || (n = `${n} ${o}w`), t.filter((r) => r !== o).map((r) => `${updateQueryParam(e, "width", r)} ${r}w`).concat([n]).join(", ");
1058
- }
1059
- return e.match(/cdn\.shopify\.com/) ? t.map((n) => [getShopifyImageUrl(e, `${n}x${n}`), n]).filter(([n]) => !!n).map(([n, o]) => `${n} ${o}w`).concat([e]).join(", ") : e;
1060
- }
1061
- const getTopLevelDomain = (e) => {
1062
- if (e === "localhost" || e === "127.0.0.1")
1063
- return e;
1064
- const t = e.split(".");
1065
- return t.length > 2 ? t.slice(1).join(".") : e;
1066
- }, getCookieSync = ({
1067
- name: e,
1068
- canTrack: t
1069
- }) => {
1070
- var n;
1071
- try {
1072
- return t ? (n = document.cookie.split("; ").find((o) => o.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
1073
- } catch (o) {
1074
- logger.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o);
1075
- return;
1076
- }
1077
- }, getCookie = async (e) => getCookieSync(e), stringifyCookie = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(checkIsDefined).join("; "), SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]], createCookieString = ({
1078
- name: e,
1079
- value: t,
1080
- expires: n
1081
- }) => {
1082
- const r = (isBrowser() ? location.protocol === "https:" : !0) ? SECURE_CONFIG : [[]], i = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...i, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...r];
1083
- return stringifyCookie(a);
1084
- }, setCookie = async ({
1085
- name: e,
1086
- value: t,
1087
- expires: n,
1088
- canTrack: o
1089
- }) => {
1090
- try {
1091
- if (!o)
1092
- return;
1093
- const r = createCookieString({
1094
- name: e,
1095
- value: t,
1096
- expires: n
1097
- });
1098
- document.cookie = r;
1099
- } catch (r) {
1100
- logger.warn("[COOKIE] SET error: ", (r == null ? void 0 : r.message) || r);
1101
- }
1102
- }, BUILDER_STORE_PREFIX = "builder.tests", getContentTestKey = (e) => `${BUILDER_STORE_PREFIX}.${e}`, getContentVariationCookie = ({
1103
- contentId: e
1104
- }) => getCookie({
1105
- name: getContentTestKey(e),
1106
- canTrack: !0
1107
- }), getContentVariationCookieSync = ({
1108
- contentId: e
1109
- }) => getCookieSync({
1110
- name: getContentTestKey(e),
1111
- canTrack: !0
1112
- }), setContentVariationCookie = ({
1113
- contentId: e,
1114
- value: t
1115
- }) => setCookie({
1116
- name: getContentTestKey(e),
1117
- value: t,
1118
- canTrack: !0
1119
- }), checkIsBuilderContentWithVariations = (e) => checkIsDefined(e.id) && checkIsDefined(e.variations) && Object.keys(e.variations).length > 0, getRandomVariationId = ({
1120
- id: e,
1121
- variations: t
1122
- }) => {
1123
- var r;
1124
- let n = 0;
1125
- const o = Math.random();
1126
- for (const i in t) {
1127
- const a = (r = t[i]) == null ? void 0 : r.testRatio;
1128
- if (n += a, o < n)
1129
- return i;
1130
- }
1131
- return e;
1132
- }, getAndSetVariantId = (e) => {
1133
- const t = getRandomVariationId(e);
1134
- return setContentVariationCookie({
1135
- contentId: e.id,
1136
- value: t
1137
- }).catch((n) => {
1138
- logger.error("could not store A/B test variation: ", n);
1139
- }), t;
1140
- }, getTestFields = ({
1141
- item: e,
1142
- testGroupId: t
1143
- }) => {
1144
- const n = e.variations[t];
1145
- return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
1146
- !n ? {
1147
- testVariationId: e.id,
1148
- testVariationName: "Default"
1149
- } : {
1150
- data: n.data,
1151
- testVariationId: n.id,
1152
- testVariationName: n.name || (n.id === e.id ? "Default" : "")
1153
- };
1154
- }, handleABTestingSync = ({
1155
- item: e,
1156
- canTrack: t
1157
- }) => {
1158
- if (!t)
1159
- return e;
1160
- if (!e)
1161
- return;
1162
- if (!checkIsBuilderContentWithVariations(e))
1163
- return e;
1164
- const n = getContentVariationCookieSync({
1165
- contentId: e.id
1166
- }) || getAndSetVariantId({
1167
- variations: e.variations,
1168
- id: e.id
1169
- }), o = getTestFields({
1170
- item: e,
1171
- testGroupId: n
1172
- });
1173
- return {
1174
- ...e,
1175
- ...o
1176
- };
1177
- }, handleABTesting = async ({
1178
- item: e,
1179
- canTrack: t
1180
- }) => {
1181
- if (!t || !checkIsBuilderContentWithVariations(e))
1182
- return e;
1183
- const o = await getContentVariationCookie({
1184
- contentId: e.id
1185
- }) || getAndSetVariantId({
1186
- variations: e.variations,
1187
- id: e.id
1188
- }), r = getTestFields({
1189
- item: e,
1190
- testGroupId: o
1191
- });
1192
- return {
1193
- ...e,
1194
- ...r
1195
- };
1196
- }, getDefaultCanTrack = (e) => checkIsDefined(e) ? e : !0, componentInfo$b = {
1197
- name: "Core:Button",
1198
- image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
1199
- defaultStyles: {
1200
- // TODO: make min width more intuitive and set one
1201
- appearance: "none",
1202
- paddingTop: "15px",
1203
- paddingBottom: "15px",
1204
- paddingLeft: "25px",
1205
- paddingRight: "25px",
1206
- backgroundColor: "#000000",
1207
- color: "white",
1208
- borderRadius: "4px",
1209
- textAlign: "center",
1210
- cursor: "pointer"
1211
- },
1212
- inputs: [{
1213
- name: "text",
1214
- type: "text",
1215
- defaultValue: "Click me!",
1216
- bubble: !0
1217
- }, {
1218
- name: "link",
1219
- type: "url",
1220
- bubble: !0
1221
- }, {
1222
- name: "openLinkInNewTab",
1223
- type: "boolean",
1224
- defaultValue: !1,
1225
- friendlyName: "Open link in new tab"
1226
- }],
1227
- static: !0,
1228
- noWrap: !0
1229
- }, componentInfo$a = {
1230
- // TODO: ways to statically preprocess JSON for references, functions, etc
1231
- name: "Columns",
1232
- isRSC: !0,
1233
- inputs: [{
1234
- name: "columns",
1235
- type: "array",
1236
- broadcast: !0,
1237
- subFields: [{
1238
- name: "blocks",
1239
- type: "array",
1240
- hideFromUI: !0,
1241
- defaultValue: [{
1242
- "@type": "@builder.io/sdk:Element",
1243
- responsiveStyles: {
1244
- large: {
1245
- display: "flex",
1246
- flexDirection: "column",
1247
- alignItems: "stretch",
1248
- flexShrink: "0",
1249
- position: "relative",
1250
- marginTop: "30px",
1251
- textAlign: "center",
1252
- lineHeight: "normal",
1253
- height: "auto",
1254
- minHeight: "20px",
1255
- minWidth: "20px",
1256
- overflow: "hidden"
1257
- }
1258
- },
1259
- component: {
1260
- name: "Image",
1261
- options: {
1262
- image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1263
- backgroundPosition: "center",
1264
- backgroundSize: "cover",
1265
- aspectRatio: 0.7004048582995948
1266
- }
1267
- }
1268
- }, {
1269
- "@type": "@builder.io/sdk:Element",
1270
- responsiveStyles: {
1271
- large: {
1272
- display: "flex",
1273
- flexDirection: "column",
1274
- alignItems: "stretch",
1275
- flexShrink: "0",
1276
- position: "relative",
1277
- marginTop: "30px",
1278
- textAlign: "center",
1279
- lineHeight: "normal",
1280
- height: "auto"
1281
- }
1282
- },
1283
- component: {
1284
- name: "Text",
1285
- options: {
1286
- text: "<p>Enter some text...</p>"
1287
- }
1288
- }
1289
- }]
1290
- }, {
1291
- name: "width",
1292
- type: "number",
1293
- hideFromUI: !0,
1294
- helperText: "Width %, e.g. set to 50 to fill half of the space"
1295
- }, {
1296
- name: "link",
1297
- type: "url",
1298
- helperText: "Optionally set a url that clicking this column will link to"
1299
- }],
1300
- defaultValue: [{
1301
- blocks: [{
1302
- "@type": "@builder.io/sdk:Element",
1303
- responsiveStyles: {
1304
- large: {
1305
- display: "flex",
1306
- flexDirection: "column",
1307
- alignItems: "stretch",
1308
- flexShrink: "0",
1309
- position: "relative",
1310
- marginTop: "30px",
1311
- textAlign: "center",
1312
- lineHeight: "normal",
1313
- height: "auto",
1314
- minHeight: "20px",
1315
- minWidth: "20px",
1316
- overflow: "hidden"
1317
- }
1318
- },
1319
- component: {
1320
- name: "Image",
1321
- options: {
1322
- image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1323
- backgroundPosition: "center",
1324
- backgroundSize: "cover",
1325
- aspectRatio: 0.7004048582995948
1326
- }
1327
- }
1328
- }, {
1329
- "@type": "@builder.io/sdk:Element",
1330
- responsiveStyles: {
1331
- large: {
1332
- display: "flex",
1333
- flexDirection: "column",
1334
- alignItems: "stretch",
1335
- flexShrink: "0",
1336
- position: "relative",
1337
- marginTop: "30px",
1338
- textAlign: "center",
1339
- lineHeight: "normal",
1340
- height: "auto"
1341
- }
1342
- },
1343
- component: {
1344
- name: "Text",
1345
- options: {
1346
- text: "<p>Enter some text...</p>"
1347
- }
1348
- }
1349
- }]
1350
- }, {
1351
- blocks: [{
1352
- "@type": "@builder.io/sdk:Element",
1353
- responsiveStyles: {
1354
- large: {
1355
- display: "flex",
1356
- flexDirection: "column",
1357
- alignItems: "stretch",
1358
- flexShrink: "0",
1359
- position: "relative",
1360
- marginTop: "30px",
1361
- textAlign: "center",
1362
- lineHeight: "normal",
1363
- height: "auto",
1364
- minHeight: "20px",
1365
- minWidth: "20px",
1366
- overflow: "hidden"
1367
- }
1368
- },
1369
- component: {
1370
- name: "Image",
1371
- options: {
1372
- image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1373
- backgroundPosition: "center",
1374
- backgroundSize: "cover",
1375
- aspectRatio: 0.7004048582995948
1376
- }
1377
- }
1378
- }, {
1379
- "@type": "@builder.io/sdk:Element",
1380
- responsiveStyles: {
1381
- large: {
1382
- display: "flex",
1383
- flexDirection: "column",
1384
- alignItems: "stretch",
1385
- flexShrink: "0",
1386
- position: "relative",
1387
- marginTop: "30px",
1388
- textAlign: "center",
1389
- lineHeight: "normal",
1390
- height: "auto"
1391
- }
1392
- },
1393
- component: {
1394
- name: "Text",
1395
- options: {
1396
- text: "<p>Enter some text...</p>"
1397
- }
1398
- }
1399
- }]
1400
- }],
1401
- onChange: (e) => {
1402
- function t() {
1403
- n.forEach((o) => {
1404
- o.delete("width");
1405
- });
1406
- }
1407
- const n = e.get("columns");
1408
- Array.isArray(n) && n.find((r) => r.get("width")) && (n.find((i) => !i.get("width")) || n.reduce((s, c) => s + c.get("width"), 0) !== 100) && t();
1409
- }
1410
- }, {
1411
- name: "space",
1412
- type: "number",
1413
- defaultValue: 20,
1414
- helperText: "Size of gap between columns",
1415
- advanced: !0
1416
- }, {
1417
- name: "stackColumnsAt",
1418
- type: "string",
1419
- defaultValue: "tablet",
1420
- helperText: "Convert horizontal columns to vertical at what device size",
1421
- enum: ["tablet", "mobile", "never"],
1422
- advanced: !0
1423
- }, {
1424
- name: "reverseColumnsWhenStacked",
1425
- type: "boolean",
1426
- defaultValue: !1,
1427
- helperText: "When stacking columns for mobile devices, reverse the ordering",
1428
- advanced: !0
1429
- }]
1430
- }, componentInfo$9 = {
1431
- name: "Fragment",
1432
- static: !0,
1433
- hidden: !0,
1434
- canHaveChildren: !0,
1435
- noWrap: !0
1436
- }, componentInfo$8 = {
1437
- name: "Image",
1438
- static: !0,
1439
- 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",
1440
- defaultStyles: {
1441
- position: "relative",
1442
- minHeight: "20px",
1443
- minWidth: "20px",
1444
- overflow: "hidden"
1445
- },
1446
- canHaveChildren: !0,
1447
- inputs: [{
1448
- name: "image",
1449
- type: "file",
1450
- bubble: !0,
1451
- allowedFileTypes: ["jpeg", "jpg", "png", "svg", "webp"],
1452
- required: !0,
1453
- defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
1454
- onChange: (e) => {
1455
- e.delete("srcset"), e.delete("noWebp");
1456
- function n(a, s = 6e4) {
1457
- return new Promise((c, d) => {
1458
- const f = document.createElement("img");
1459
- let l = !1;
1460
- f.onload = () => {
1461
- l = !0, c(f);
1462
- }, f.addEventListener("error", (u) => {
1463
- console.warn("Image load failed", u.error), d(u.error);
1464
- }), f.src = a, setTimeout(() => {
1465
- l || d(new Error("Image load timed out"));
1466
- }, s);
1467
- });
1468
- }
1469
- function o(a) {
1470
- return Math.round(a * 1e3) / 1e3;
1471
- }
1472
- const r = e.get("image"), i = e.get("aspectRatio");
1473
- if (fetch(r).then((a) => a.blob()).then((a) => {
1474
- a.type.includes("svg") && e.set("noWebp", !0);
1475
- }), r && (!i || i === 0.7041))
1476
- return n(r).then((a) => {
1477
- const s = e.get("aspectRatio");
1478
- e.get("image") === r && (!s || s === 0.7041) && a.width && a.height && (e.set("aspectRatio", o(a.height / a.width)), e.set("height", a.height), e.set("width", a.width));
1479
- });
1480
- }
1481
- }, {
1482
- name: "backgroundSize",
1483
- type: "text",
1484
- defaultValue: "cover",
1485
- enum: [{
1486
- label: "contain",
1487
- value: "contain",
1488
- helperText: "The image should never get cropped"
1489
- }, {
1490
- label: "cover",
1491
- value: "cover",
1492
- helperText: "The image should fill it's box, cropping when needed"
1493
- }]
1494
- }, {
1495
- name: "backgroundPosition",
1496
- type: "text",
1497
- defaultValue: "center",
1498
- enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
1499
- }, {
1500
- name: "altText",
1501
- type: "string",
1502
- helperText: "Text to display when the user has images off"
1503
- }, {
1504
- name: "height",
1505
- type: "number",
1506
- hideFromUI: !0
1507
- }, {
1508
- name: "width",
1509
- type: "number",
1510
- hideFromUI: !0
1511
- }, {
1512
- name: "sizes",
1513
- type: "string",
1514
- hideFromUI: !0
1515
- }, {
1516
- name: "srcset",
1517
- type: "string",
1518
- hideFromUI: !0
1519
- }, {
1520
- name: "lazy",
1521
- type: "boolean",
1522
- defaultValue: !0,
1523
- hideFromUI: !0
1524
- }, {
1525
- name: "fitContent",
1526
- type: "boolean",
1527
- helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
1528
- defaultValue: !0
1529
- }, {
1530
- name: "highPriority",
1531
- type: "boolean",
1532
- advanced: !0,
1533
- helperText: "Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page."
1534
- }, {
1535
- name: "aspectRatio",
1536
- type: "number",
1537
- 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",
1538
- advanced: !0,
1539
- defaultValue: 0.7041
1540
- }]
1541
- }, componentInfo$7 = {
1542
- name: "Core:Section",
1543
- static: !0,
1544
- image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
1545
- inputs: [{
1546
- name: "maxWidth",
1547
- type: "number",
1548
- defaultValue: 1200
1549
- }, {
1550
- name: "lazyLoad",
1551
- type: "boolean",
1552
- defaultValue: !1,
1553
- advanced: !0,
1554
- description: "Only render this section when in view"
1555
- }],
1556
- defaultStyles: {
1557
- paddingLeft: "20px",
1558
- paddingRight: "20px",
1559
- paddingTop: "50px",
1560
- paddingBottom: "50px",
1561
- marginTop: "0px",
1562
- width: "100vw",
1563
- marginLeft: "calc(50% - 50vw)"
1564
- },
1565
- canHaveChildren: !0,
1566
- defaultChildren: [{
1567
- "@type": "@builder.io/sdk:Element",
1568
- responsiveStyles: {
1569
- large: {
1570
- textAlign: "center"
1571
- }
1572
- },
1573
- component: {
1574
- name: "Text",
1575
- options: {
1576
- 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>"
1577
- }
1578
- }
1579
- }]
1580
- }, componentInfo$6 = {
1581
- name: "Slot",
1582
- isRSC: !0,
1583
- description: "Allow child blocks to be inserted into this content when used as a Symbol",
1584
- docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
1585
- image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
1586
- // Maybe wrap this for canHaveChildren so bind children to this hm
1587
- inputs: [{
1588
- name: "name",
1589
- type: "string",
1590
- required: !0,
1591
- defaultValue: "children"
1592
- }]
1593
- };
1594
- function Slot(e) {
1595
- var t, n, o;
1596
- return /* @__PURE__ */ jsx(
1597
- "div",
1598
- {
1599
- style: {
1600
- pointerEvents: "auto"
1601
- },
1602
- ...!((t = e.builderContext.context) != null && t.symbolId) && {
1603
- "builder-slot": e.name
1604
- },
1605
- children: /* @__PURE__ */ jsx(
1606
- Blocks,
1607
- {
1608
- parent: (n = e.builderContext.context) == null ? void 0 : n.symbolId,
1609
- path: `symbol.data.${e.name}`,
1610
- context: e.builderContext,
1611
- blocks: (o = e.builderContext.rootState) == null ? void 0 : o[e.name]
1612
- }
1613
- )
1614
- }
1615
- );
1616
- }
1617
- const componentInfo$5 = {
1618
- name: "Symbol",
1619
- noWrap: !0,
1620
- static: !0,
1621
- isRSC: !0,
1622
- inputs: [{
1623
- name: "symbol",
1624
- type: "uiSymbol"
1625
- }, {
1626
- name: "dataOnly",
1627
- helperText: "Make this a data symbol that doesn't display any UI",
1628
- type: "boolean",
1629
- defaultValue: !1,
1630
- advanced: !0,
1631
- hideFromUI: !0
1632
- }, {
1633
- name: "inheritState",
1634
- helperText: "Inherit the parent component state and data",
1635
- type: "boolean",
1636
- defaultValue: !1,
1637
- advanced: !0
1638
- }, {
1639
- name: "renderToLiquid",
1640
- helperText: "Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",
1641
- type: "boolean",
1642
- defaultValue: !1,
1643
- advanced: !0,
1644
- hideFromUI: !0
1645
- }, {
1646
- name: "useChildren",
1647
- hideFromUI: !0,
1648
- type: "boolean"
1649
- }]
1650
- }, componentInfo$4 = {
1651
- name: "Text",
1652
- static: !0,
1653
- isRSC: !0,
1654
- 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",
1655
- inputs: [{
1656
- name: "text",
1657
- type: "html",
1658
- required: !0,
1659
- autoFocus: !0,
1660
- bubble: !0,
1661
- defaultValue: "Enter some text..."
1662
- }],
1663
- defaultStyles: {
1664
- lineHeight: "normal",
1665
- height: "auto",
1666
- textAlign: "center"
1667
- }
1668
- };
1669
- function Text(e) {
1670
- var t;
1671
- return /* @__PURE__ */ jsx(
1672
- "div",
1673
- {
1674
- className: "builder-text",
1675
- dangerouslySetInnerHTML: { __html: ((t = e.text) == null ? void 0 : t.toString()) || "" },
1676
- style: {
1677
- outline: "none"
1678
- }
1679
- }
1680
- );
1681
- }
1682
- const componentInfo$3 = {
1683
- name: "Custom Code",
1684
- static: !0,
1685
- requiredPermissions: ["editCode"],
1686
- inputs: [{
1687
- name: "code",
1688
- type: "html",
1689
- required: !0,
1690
- defaultValue: "<p>Hello there, I am custom HTML code!</p>",
1691
- code: !0
1692
- }, {
1693
- name: "replaceNodes",
1694
- type: "boolean",
1695
- helperText: "Preserve server rendered dom nodes",
1696
- advanced: !0
1697
- }, {
1698
- name: "scriptsClientOnly",
1699
- type: "boolean",
1700
- defaultValue: !1,
1701
- helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
1702
- advanced: !0
1703
- }]
1704
- }, componentInfo$2 = {
1705
- name: "Embed",
1706
- static: !0,
1707
- inputs: [{
1708
- name: "url",
1709
- type: "url",
1710
- required: !0,
1711
- defaultValue: "",
1712
- helperText: "e.g. enter a youtube url, google map, etc",
1713
- onChange: (e) => {
1714
- const t = e.get("url");
1715
- if (t) {
1716
- e.set("content", "Loading...");
1717
- const n = _iframelyApiKey;
1718
- return fetch(`https://iframe.ly/api/iframely?url=${t}&api_key=${n}`).then((o) => o.json()).then((o) => {
1719
- e.get("url") === t && (o.html ? e.set("content", o.html) : e.set("content", "Invalid url, please try another"));
1720
- }).catch((o) => {
1721
- e.set("content", "There was an error embedding this URL, please try again or another URL");
1722
- });
1723
- } else
1724
- e.delete("content");
1725
- }
1726
- }, {
1727
- name: "content",
1728
- type: "html",
1729
- defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
1730
- hideFromUI: !0
1731
- }]
1732
- }, SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"], isJsScript = (e) => SCRIPT_MIME_TYPES.includes(e.type), componentInfo$1 = {
1733
- // friendlyName?
1734
- name: "Raw:Img",
1735
- hideFromInsertMenu: !0,
1736
- 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",
1737
- inputs: [{
1738
- name: "image",
1739
- bubble: !0,
1740
- type: "file",
1741
- allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
1742
- required: !0
1743
- }],
1744
- noWrap: !0,
1745
- static: !0
1746
- }, componentInfo = {
1747
- name: "Video",
1748
- canHaveChildren: !0,
1749
- defaultStyles: {
1750
- minHeight: "20px",
1751
- minWidth: "20px"
1752
- },
1753
- 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",
1754
- inputs: [{
1755
- name: "video",
1756
- type: "file",
1757
- allowedFileTypes: ["mp4"],
1758
- bubble: !0,
1759
- defaultValue: "https://cdn.builder.io/o/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd27731a526464deba0016216f5f9e570%2Fcompressed?apiKey=YJIGb4i01jvw0SRdL5Bt&token=d27731a526464deba0016216f5f9e570&alt=media&optimized=true",
1760
- required: !0
1761
- }, {
1762
- name: "posterImage",
1763
- type: "file",
1764
- allowedFileTypes: ["jpeg", "png"],
1765
- helperText: "Image to show before the video plays"
1766
- }, {
1767
- name: "autoPlay",
1768
- type: "boolean",
1769
- defaultValue: !0
1770
- }, {
1771
- name: "controls",
1772
- type: "boolean",
1773
- defaultValue: !1
1774
- }, {
1775
- name: "muted",
1776
- type: "boolean",
1777
- defaultValue: !0
1778
- }, {
1779
- name: "loop",
1780
- type: "boolean",
1781
- defaultValue: !0
1782
- }, {
1783
- name: "playsInline",
1784
- type: "boolean",
1785
- defaultValue: !0
1786
- }, {
1787
- name: "fit",
1788
- type: "text",
1789
- defaultValue: "cover",
1790
- enum: ["contain", "cover", "fill", "auto"]
1791
- }, {
1792
- name: "preload",
1793
- type: "text",
1794
- defaultValue: "metadata",
1795
- enum: ["auto", "metadata", "none"]
1796
- }, {
1797
- name: "fitContent",
1798
- type: "boolean",
1799
- helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
1800
- defaultValue: !0,
1801
- advanced: !0
1802
- }, {
1803
- name: "position",
1804
- type: "text",
1805
- defaultValue: "center",
1806
- enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
1807
- }, {
1808
- name: "height",
1809
- type: "number",
1810
- advanced: !0
1811
- }, {
1812
- name: "width",
1813
- type: "number",
1814
- advanced: !0
1815
- }, {
1816
- name: "aspectRatio",
1817
- type: "number",
1818
- advanced: !0,
1819
- defaultValue: 0.7004048582995948
1820
- }, {
1821
- name: "lazyLoad",
1822
- type: "boolean",
1823
- helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
1824
- defaultValue: !0,
1825
- advanced: !0
1826
- }]
1827
- }, getExtraComponents = () => [{
1828
- component: CustomCode,
1829
- ...componentInfo$3
1830
- }, {
1831
- component: Embed,
1832
- ...componentInfo$2
1833
- }, {
1834
- component: ImgComponent,
1835
- ...componentInfo$1
1836
- }, {
1837
- component: Video,
1838
- ...componentInfo
1839
- }], getDefaultRegisteredComponents = () => [{
1840
- component: Button,
1841
- ...componentInfo$b
1842
- }, {
1843
- component: Columns,
1844
- ...componentInfo$a
1845
- }, {
1846
- component: FragmentComponent,
1847
- ...componentInfo$9
1848
- }, {
1849
- component: Image,
1850
- ...componentInfo$8
1851
- }, {
1852
- component: SectionComponent,
1853
- ...componentInfo$7
1854
- }, {
1855
- component: Slot,
1856
- ...componentInfo$6
1857
- }, {
1858
- component: Symbol$1,
1859
- ...componentInfo$5
1860
- }, {
1861
- component: Text,
1862
- ...componentInfo$4
1863
- }, ...getExtraComponents()], createRegisterComponentMessage = (e) => ({
1864
- type: "builder.registerComponent",
1865
- data: serializeComponentInfo(e)
1866
- }), serializeFn = (e) => {
1867
- const t = e.toString().trim();
1868
- return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
1869
- }, serializeValue = (e) => typeof e == "function" ? serializeFn(e) : fastClone(e), serializeComponentInfo = ({
1870
- inputs: e,
1871
- ...t
1872
- }) => ({
1873
- ...fastClone(t),
1874
- inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((o, [r, i]) => ({
1875
- ...o,
1876
- [r]: serializeValue(i)
1877
- }), {}))
1878
- }), UPDATE_COOKIES_AND_STYLES_SCRIPT = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
1879
- function getAndSetVariantId() {
1880
- function setCookie(name, value, days) {
1881
- let expires = '';
1882
- if (days) {
1883
- const date = new Date();
1884
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
1885
- expires = '; expires=' + date.toUTCString();
1886
- }
1887
- document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';
1888
- }
1889
- function getCookie(name) {
1890
- const nameEQ = name + '=';
1891
- const ca = document.cookie.split(';');
1892
- for (let i = 0; i < ca.length; i++) {
1893
- let c = ca[i];
1894
- while (c.charAt(0) === ' ') c = c.substring(1, c.length);
1895
- if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
1896
- }
1897
- return null;
1898
- }
1899
- const cookieName = \`builder.tests.\${contentId}\`;
1900
- const variantInCookie = getCookie(cookieName);
1901
- const availableIDs = variants.map(vr => vr.id).concat(contentId);
1902
- if (variantInCookie && availableIDs.includes(variantInCookie)) {
1903
- return variantInCookie;
1904
- }
1905
- let n = 0;
1906
- const random = Math.random();
1907
- for (let i = 0; i < variants.length; i++) {
1908
- const variant = variants[i];
1909
- const testRatio = variant.testRatio;
1910
- n += testRatio;
1911
- if (random < n) {
1912
- setCookie(cookieName, variant.id);
1913
- return variant.id;
1914
- }
1915
- }
1916
- setCookie(cookieName, contentId);
1917
- return contentId;
1918
- }
1919
- const winningVariantId = getAndSetVariantId();
1920
- const styleEl = document.currentScript?.previousElementSibling;
1921
- if (isHydrationTarget) {
1922
- styleEl.remove();
1923
- const thisScriptEl = document.currentScript;
1924
- thisScriptEl?.remove();
1925
- } else {
1926
- const newStyleStr = variants.concat({
1927
- id: contentId
1928
- }).filter(variant => variant.id !== winningVariantId).map(value => {
1929
- return \`.variant-\${value.id} { display: none; }
1930
- \`;
1931
- }).join('');
1932
- styleEl.innerHTML = newStyleStr;
1933
- }
1934
- }`, UPDATE_VARIANT_VISIBILITY_SCRIPT = `function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {
1935
- if (!navigator.cookieEnabled) {
1936
- return;
1937
- }
1938
- function getCookie(name) {
1939
- const nameEQ = name + '=';
1940
- const ca = document.cookie.split(';');
1941
- for (let i = 0; i < ca.length; i++) {
1942
- let c = ca[i];
1943
- while (c.charAt(0) === ' ') c = c.substring(1, c.length);
1944
- if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
1945
- }
1946
- return null;
1947
- }
1948
- const cookieName = \`builder.tests.\${defaultContentId}\`;
1949
- const winningVariant = getCookie(cookieName);
1950
- const parentDiv = document.currentScript?.parentElement;
1951
- const isDefaultContent = variantContentId === defaultContentId;
1952
- const isWinningVariant = winningVariant === variantContentId;
1953
- if (isWinningVariant && !isDefaultContent) {
1954
- parentDiv?.removeAttribute('hidden');
1955
- parentDiv?.removeAttribute('aria-hidden');
1956
- } else if (!isWinningVariant && isDefaultContent) {
1957
- parentDiv?.setAttribute('hidden', 'true');
1958
- parentDiv?.setAttribute('aria-hidden', 'true');
1959
- }
1960
- if (isHydrationTarget) {
1961
- if (!isWinningVariant) {
1962
- parentDiv?.remove();
1963
- }
1964
- const thisScriptEl = document.currentScript;
1965
- thisScriptEl?.remove();
1966
- }
1967
- return;
1968
- }`, UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest", UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "builderIoRenderContent", getVariants = (e) => Object.values((e == null ? void 0 : e.variations) || {}).map((t) => ({
1969
- ...t,
1970
- testVariationId: t.id,
1971
- id: e == null ? void 0 : e.id
1972
- })), checkShouldRenderVariants = ({
1973
- canTrack: e,
1974
- content: t
1975
- }) => !(!(getVariants(t).length > 0) || !e || isBrowser()), getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydrationTarget = getIsHydrationTarget(TARGET), getInitVariantsFnsScriptString = () => `
1976
- window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
1977
- window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
1978
- `, getUpdateCookieAndStylesScript = (e, t) => `
1979
- window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
1980
- "${t}",${JSON.stringify(e)}, ${isHydrationTarget}
1981
- )`, getUpdateVariantVisibilityScript = ({
1982
- contentId: e,
1983
- variationId: t
1984
- }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
1985
- "${t}", "${e}", ${isHydrationTarget}
1986
- )`;
1987
- function InlinedScript(e) {
1988
- return /* @__PURE__ */ jsx(
1989
- "script",
1990
- {
1991
- dangerouslySetInnerHTML: { __html: e.scriptStr },
1992
- "data-id": e.id
1993
- }
1994
- );
1995
- }
1996
- const getIdFromSearchParams = (e) => {
1997
- const t = e.get("preview"), n = e.get("overrides." + t);
1998
- return n || logger.warn("No previewed ID found in search params."), n;
1999
- };
2000
- function init() {
2001
- globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
2002
- max: 500,
2003
- // how long to live in ms
2004
- ttl: 1e3 * 60 * 5
2005
- }));
2006
- }
2007
- function getPreviewContent(e) {
2008
- init();
2009
- const t = getIdFromSearchParams(e);
2010
- return typeof t == "string" ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(t) : void 0;
2011
- }
2012
- function getGlobalThis() {
2013
- return typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : globalThis;
2014
- }
2015
- function getFetch() {
2016
- const e = getGlobalThis().fetch;
2017
- if (typeof e > "u")
2018
- throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2019
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
2020
- return e;
2021
- }
2022
- const fetch$1 = getFetch();
2023
- function flatten(e, t = null, n = ".") {
2024
- return Object.keys(e).reduce((o, r) => {
2025
- const i = e[r], a = [t, r].filter(Boolean).join(n);
2026
- return [typeof i == "object", i !== null, !(Array.isArray(i) && i.length === 0)].every(Boolean) ? {
2027
- ...o,
2028
- ...flatten(i, a, n)
2029
- } : {
2030
- ...o,
2031
- [a]: i
2032
- };
2033
- }, {});
2034
- }
2035
- function flattenMongoQuery(e, t, n = {}) {
2036
- for (const o in e) {
2037
- const r = e[o], i = t ? t + "." + o : o;
2038
- r && typeof r == "object" && !Array.isArray(r) && !Object.keys(r).find((a) => a.startsWith("$")) ? flattenMongoQuery(r, i, n) : n[i] = r;
2039
- }
2040
- return n;
2041
- }
2042
- const DEFAULT_API_VERSION = "v3", BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUILDER_OPTIONS_PREFIX = "options.", getBuilderSearchParams = (e) => {
2043
- if (!e)
2044
- return {};
2045
- const t = normalizeSearchParams(e), n = {};
2046
- return Object.keys(t).forEach((o) => {
2047
- if (o.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2048
- const r = o.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
2049
- n[r] = t[o];
2050
- }
2051
- }), n;
2052
- }, getBuilderSearchParamsFromWindow = () => {
2053
- if (!isBrowser())
2054
- return {};
2055
- const e = new URLSearchParams(window.location.search);
2056
- return getBuilderSearchParams(e);
2057
- }, isPositiveNumber = (e) => typeof e == "number" && !isNaN(e) && e >= 0, generateContentUrl = (e) => {
2058
- const {
2059
- limit: t = 30,
2060
- userAttributes: n,
2061
- query: o,
2062
- model: r,
2063
- apiKey: i,
2064
- enrich: a,
2065
- locale: s,
2066
- apiVersion: c = DEFAULT_API_VERSION,
2067
- fields: d,
2068
- omit: f,
2069
- offset: l,
2070
- cacheSeconds: u,
2071
- staleCacheSeconds: g,
2072
- sort: y,
2073
- includeUnpublished: p
2074
- } = e;
2075
- if (!i)
2076
- throw new Error("Missing API key");
2077
- if (!["v3"].includes(c))
2078
- throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);
2079
- const v = t !== 1, m = new URL(`https://cdn.builder.io/api/${c}/content/${r}`);
2080
- if (m.searchParams.set("apiKey", i), m.searchParams.set("limit", String(t)), m.searchParams.set("noTraverse", String(v)), m.searchParams.set("includeRefs", String(!0)), s && m.searchParams.set("locale", s), a && m.searchParams.set("enrich", String(a)), m.searchParams.set("omit", f || "meta.componentsUsed"), d && m.searchParams.set("fields", d), Number.isFinite(l) && l > -1 && m.searchParams.set("offset", String(Math.floor(l))), typeof p == "boolean" && m.searchParams.set("includeUnpublished", String(p)), u && isPositiveNumber(u) && m.searchParams.set("cacheSeconds", String(u)), g && isPositiveNumber(g) && m.searchParams.set("staleCacheSeconds", String(g)), y) {
2081
- const S = flatten({
2082
- sort: y
2083
- });
2084
- for (const C in S)
2085
- m.searchParams.set(C, JSON.stringify(S[C]));
2086
- }
2087
- const h = {
2088
- ...getBuilderSearchParamsFromWindow(),
2089
- ...normalizeSearchParams(e.options || {})
2090
- }, b = flatten(h);
2091
- for (const S in b)
2092
- m.searchParams.set(S, String(b[S]));
2093
- if (n && m.searchParams.set("userAttributes", JSON.stringify(n)), o) {
2094
- const S = flattenMongoQuery({
2095
- query: o
2096
- });
2097
- for (const C in S)
2098
- m.searchParams.set(C, JSON.stringify(S[C]));
2099
- }
2100
- return m;
2101
- }, checkContentHasResults = (e) => "results" in e;
2102
- async function fetchOneEntry(e) {
2103
- const t = await fetchEntries({
2104
- ...e,
2105
- limit: 1
2106
- });
2107
- return t && t[0] || null;
2108
- }
2109
- const _fetchContent = async (e) => {
2110
- const t = generateContentUrl(e);
2111
- return await (await (e.fetch ?? fetch$1)(t.href, e.fetchOptions)).json();
2112
- }, _processContentResult = async (e, t, n = generateContentUrl(e)) => {
2113
- const o = getDefaultCanTrack(e.canTrack);
2114
- if (n.search.includes("preview=")) {
2115
- const i = [];
2116
- for (const a of t.results) {
2117
- const s = getPreviewContent(n.searchParams);
2118
- i.push(s || a);
2119
- }
2120
- t.results = i;
2121
- }
2122
- if (!o || !(isBrowser() || TARGET === "reactNative"))
2123
- return t.results;
2124
- try {
2125
- const i = [];
2126
- for (const a of t.results)
2127
- i.push(await handleABTesting({
2128
- item: a,
2129
- canTrack: o
2130
- }));
2131
- t.results = i;
2132
- } catch (i) {
2133
- logger.error("Could not process A/B tests. ", i);
2134
- }
2135
- return t.results;
2136
- };
2137
- async function fetchEntries(e) {
2138
- try {
2139
- const t = generateContentUrl(e), n = await _fetchContent(e);
2140
- return checkContentHasResults(n) ? _processContentResult(e, n) : (logger.error("Error fetching data. ", {
2141
- url: t,
2142
- content: n,
2143
- options: e
2144
- }), null);
2145
- } catch (t) {
2146
- return logger.error("Error fetching data. ", t), null;
2147
- }
2148
- }
2149
- function isPreviewing(e) {
2150
- const t = e || (isBrowser() ? window.location.search : void 0);
2151
- return t ? getSearchString(t).indexOf("builder.preview=") !== -1 : !1;
2152
- }
2153
- function uuidv4() {
2154
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
2155
- const t = Math.random() * 16 | 0;
2156
- return (e == "x" ? t : t & 3 | 8).toString(16);
2157
- });
2158
- }
2159
- function uuid() {
2160
- return uuidv4().replace(/-/g, "");
2161
- }
2162
- const SESSION_LOCAL_STORAGE_KEY = "builderSessionId", getSessionId = async ({
2163
- canTrack: e
2164
- }) => {
2165
- if (!e)
2166
- return;
2167
- const t = await getCookie({
2168
- name: SESSION_LOCAL_STORAGE_KEY,
2169
- canTrack: e
2170
- });
2171
- if (checkIsDefined(t))
2172
- return t;
2173
- {
2174
- const n = createSessionId();
2175
- return setSessionId({
2176
- id: n,
2177
- canTrack: e
2178
- }), n;
2179
- }
2180
- }, createSessionId = () => uuid(), setSessionId = ({
2181
- id: e,
2182
- canTrack: t
2183
- }) => setCookie({
2184
- name: SESSION_LOCAL_STORAGE_KEY,
2185
- value: e,
2186
- canTrack: t
2187
- }), getLocalStorage = () => isBrowser() && typeof localStorage < "u" ? localStorage : void 0, getLocalStorageItem = ({
2188
- key: e,
2189
- canTrack: t
2190
- }) => {
2191
- var n;
2192
- try {
2193
- return t ? (n = getLocalStorage()) == null ? void 0 : n.getItem(e) : void 0;
2194
- } catch (o) {
2195
- console.debug("[LocalStorage] GET error: ", o);
2196
- return;
2197
- }
2198
- }, setLocalStorageItem = ({
2199
- key: e,
2200
- canTrack: t,
2201
- value: n
2202
- }) => {
2203
- var o;
2204
- try {
2205
- t && ((o = getLocalStorage()) == null || o.setItem(e, n));
2206
- } catch (r) {
2207
- console.debug("[LocalStorage] SET error: ", r);
2208
- }
2209
- }, VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId", getVisitorId = ({
2210
- canTrack: e
2211
- }) => {
2212
- if (!e)
2213
- return;
2214
- const t = getLocalStorageItem({
2215
- key: VISITOR_LOCAL_STORAGE_KEY,
2216
- canTrack: e
2217
- });
2218
- if (checkIsDefined(t))
2219
- return t;
2220
- {
2221
- const n = createVisitorId();
2222
- return setVisitorId({
2223
- id: n,
2224
- canTrack: e
2225
- }), n;
2226
- }
2227
- }, createVisitorId = () => uuid(), setVisitorId = ({
2228
- id: e,
2229
- canTrack: t
2230
- }) => setLocalStorageItem({
2231
- key: VISITOR_LOCAL_STORAGE_KEY,
2232
- value: e,
2233
- canTrack: t
2234
- }), getTrackingEventData = async ({
2235
- canTrack: e
2236
- }) => {
2237
- if (!e)
2238
- return {
2239
- visitorId: void 0,
2240
- sessionId: void 0
2241
- };
2242
- const t = await getSessionId({
2243
- canTrack: e
2244
- }), n = getVisitorId({
2245
- canTrack: e
2246
- });
2247
- return {
2248
- sessionId: t,
2249
- visitorId: n
2250
- };
2251
- }, createEvent = async ({
2252
- type: e,
2253
- canTrack: t,
2254
- apiKey: n,
2255
- metadata: o,
2256
- ...r
2257
- }) => ({
2258
- type: e,
2259
- data: {
2260
- ...r,
2261
- metadata: {
2262
- url: location.href,
2263
- ...o
2264
- },
2265
- ...await getTrackingEventData({
2266
- canTrack: t
2267
- }),
2268
- userAttributes: getUserAttributes(),
2269
- ownerId: n
2270
- }
2271
- });
2272
- async function _track(e) {
2273
- if (!e.apiKey) {
2274
- logger.error("Missing API key for track call. Please provide your API key.");
2275
- return;
2276
- }
2277
- if (e.canTrack && !isEditing() && (isBrowser() || TARGET === "reactNative"))
2278
- return fetch("https://cdn.builder.io/api/v1/track", {
2279
- method: "POST",
2280
- body: JSON.stringify({
2281
- events: [await createEvent(e)]
2282
- }),
2283
- headers: {
2284
- "content-type": "application/json"
2285
- },
2286
- mode: "cors"
2287
- }).catch((t) => {
2288
- console.error("Failed to track: ", t);
2289
- });
2290
- }
2291
- const track = (e) => _track({
2292
- ...e,
2293
- canTrack: !0
2294
- });
2295
- function round(e) {
2296
- return Math.round(e * 1e3) / 1e3;
2297
- }
2298
- const findParentElement = (e, t, n = !0) => {
2299
- if (!(e instanceof HTMLElement))
2300
- return null;
2301
- let o = n ? e : e.parentElement;
2302
- do {
2303
- if (!o)
2304
- return null;
2305
- if (t(o))
2306
- return o;
2307
- } while (o = o.parentElement);
2308
- return null;
2309
- }, findBuilderParent = (e) => findParentElement(e, (t) => {
2310
- const n = t.getAttribute("builder-id") || t.id;
2311
- return (n == null ? void 0 : n.indexOf("builder-")) === 0;
2312
- }), computeOffset = ({
2313
- event: e,
2314
- target: t
2315
- }) => {
2316
- const n = t.getBoundingClientRect(), o = e.clientX - n.left, r = e.clientY - n.top, i = round(o / n.width), a = round(r / n.height);
2317
- return {
2318
- x: i,
2319
- y: a
2320
- };
2321
- }, getInteractionPropertiesForEvent = (e) => {
2322
- const t = e.target, n = t && findBuilderParent(t), o = (n == null ? void 0 : n.getAttribute("builder-id")) || (n == null ? void 0 : n.id);
2323
- return {
2324
- targetBuilderElement: o || void 0,
2325
- metadata: {
2326
- targetOffset: t ? computeOffset({
2327
- event: e,
2328
- target: t
2329
- }) : void 0,
2330
- builderTargetOffset: n ? computeOffset({
2331
- event: e,
2332
- target: n
2333
- }) : void 0,
2334
- builderElementIndex: n && o ? [].slice.call(document.getElementsByClassName(o)).indexOf(n) : void 0
2335
- }
2336
- };
2337
- }, DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
2338
- function isFromTrustedHost(e, t) {
2339
- if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
2340
- return !1;
2341
- const n = new URL(t.origin), o = n.hostname;
2342
- return (e || DEFAULT_TRUSTED_HOSTS).findIndex((r) => r.startsWith("*.") ? o.endsWith(r.slice(1)) : r === o) > -1;
2343
- }
2344
- const SDK_VERSION = "0.14.29", registry = {};
2345
- function register(e, t) {
2346
- let n = registry[e];
2347
- if (n || (n = registry[e] = []), n.push(t), isBrowser()) {
2348
- const o = {
2349
- type: "builder.register",
2350
- data: {
2351
- type: e,
2352
- info: t
2353
- }
2354
- };
2355
- try {
2356
- parent.postMessage(o, "*"), parent !== window && window.postMessage(o, "*");
2357
- } catch (r) {
2358
- console.debug("Could not postmessage", r);
2359
- }
2360
- }
2361
- }
2362
- const registerInsertMenu = () => {
2363
- register("insertMenu", {
2364
- name: "_default",
2365
- default: !0,
2366
- items: [{
2367
- name: "Box"
2368
- }, {
2369
- name: "Text"
2370
- }, {
2371
- name: "Image"
2372
- }, {
2373
- name: "Columns"
2374
- }, {
2375
- name: "Core:Section"
2376
- }, {
2377
- name: "Core:Button"
2378
- }, {
2379
- name: "Embed"
2380
- }, {
2381
- name: "Custom Code"
2382
- }]
2383
- });
2384
- };
2385
- let isSetupForEditing = !1;
2386
- const setupBrowserForEditing = (e = {}) => {
2387
- var t, n;
2388
- isSetupForEditing || (isSetupForEditing = !0, isBrowser() && ((t = window.parent) == null || t.postMessage({
2389
- type: "builder.sdkInfo",
2390
- data: {
2391
- target: TARGET,
2392
- version: SDK_VERSION,
2393
- supportsPatchUpdates: !1,
2394
- // Supports builder-model="..." attribute which is needed to
2395
- // scope our '+ add block' button styling
2396
- supportsAddBlockScoping: !0,
2397
- supportsCustomBreakpoints: !0
2398
- }
2399
- }, "*"), (n = window.parent) == null || n.postMessage({
2400
- type: "builder.updateContent",
2401
- data: {
2402
- options: e
2403
- }
2404
- }, "*"), window.addEventListener("message", (o) => {
2405
- var i, a;
2406
- if (!isFromTrustedHost(e.trustedHosts, o))
2407
- return;
2408
- const {
2409
- data: r
2410
- } = o;
2411
- if (r != null && r.type)
2412
- switch (r.type) {
2413
- case "builder.evaluate": {
2414
- const s = r.data.text, c = r.data.arguments || [], d = r.data.id, f = new Function(s);
2415
- let l, u = null;
2416
- try {
2417
- l = f.apply(null, c);
2418
- } catch (g) {
2419
- u = g;
2420
- }
2421
- u ? (i = window.parent) == null || i.postMessage({
2422
- type: "builder.evaluateError",
2423
- data: {
2424
- id: d,
2425
- error: u.message
2426
- }
2427
- }, "*") : l && typeof l.then == "function" ? l.then((g) => {
2428
- var y;
2429
- (y = window.parent) == null || y.postMessage({
2430
- type: "builder.evaluateResult",
2431
- data: {
2432
- id: d,
2433
- result: g
2434
- }
2435
- }, "*");
2436
- }).catch(console.error) : (a = window.parent) == null || a.postMessage({
2437
- type: "builder.evaluateResult",
2438
- data: {
2439
- result: l,
2440
- id: d
2441
- }
2442
- }, "*");
2443
- break;
2444
- }
2445
- }
2446
- })));
2447
- }, createEditorListener = ({
2448
- model: e,
2449
- trustedHosts: t,
2450
- callbacks: n
2451
- }) => (o) => {
2452
- if (!isFromTrustedHost(t, o))
2453
- return;
2454
- const {
2455
- data: r
2456
- } = o;
2457
- if (r)
2458
- switch (r.type) {
2459
- case "builder.configureSdk": {
2460
- n.configureSdk(r.data);
2461
- break;
2462
- }
2463
- case "builder.triggerAnimation": {
2464
- n.animation(r.data);
2465
- break;
2466
- }
2467
- case "builder.contentUpdate": {
2468
- const i = r.data, a = i.key || i.alias || i.entry || i.modelName, s = i.data;
2469
- a === e && n.contentUpdate(s);
2470
- break;
2471
- }
2472
- }
2473
- }, subscribeToEditor = (e, t, n) => {
2474
- if (!isBrowser)
2475
- return logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
2476
- };
2477
- setupBrowserForEditing();
2478
- const o = createEditorListener({
2479
- callbacks: {
2480
- contentUpdate: t,
2481
- animation: () => {
2482
- },
2483
- configureSdk: () => {
2484
- }
2485
- },
2486
- model: e,
2487
- trustedHosts: n == null ? void 0 : n.trustedHosts
2488
- });
2489
- return window.addEventListener("message", o), () => {
2490
- window.removeEventListener("message", o);
2491
- };
2492
- };
2493
- function assign(e, ...t) {
2494
- const n = Object(e);
2495
- for (let o = 1; o < arguments.length; o++) {
2496
- const r = arguments[o];
2497
- if (r != null)
2498
- for (const i in r)
2499
- Object.prototype.hasOwnProperty.call(r, i) && (n[i] = r[i]);
2500
- }
2501
- return n;
2502
- }
2503
- function warnElementNotPresent(e) {
2504
- console.warn(`Cannot animate element: element with ID ${e} not found!`);
2505
- }
2506
- function augmentAnimation(e, t) {
2507
- const n = getAllStylesUsed(e), o = getComputedStyle(t), r = e.steps[0].styles, i = e.steps[e.steps.length - 1].styles, a = [r, i];
2508
- for (const s of a)
2509
- for (const c of n)
2510
- c in s || (s[c] = o[c]);
2511
- }
2512
- function getAllStylesUsed(e) {
2513
- const t = [];
2514
- for (const n of e.steps)
2515
- for (const o in n.styles)
2516
- t.indexOf(o) === -1 && t.push(o);
2517
- return t;
2518
- }
2519
- function triggerAnimation(e) {
2520
- const t = Array.prototype.slice.call(document.getElementsByClassName(e.elementId || e.id || ""));
2521
- if (!t.length) {
2522
- warnElementNotPresent(e.elementId || e.id || "");
2523
- return;
2524
- }
2525
- Array.from(t).forEach((n) => {
2526
- augmentAnimation(e, n), n.style.transition = "none", n.style.transitionDelay = "0", assign(n.style, e.steps[0].styles), setTimeout(() => {
2527
- n.style.transition = `all ${e.duration}s ${camelToKebabCase(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"), assign(n.style, e.steps[1].styles), setTimeout(() => {
2528
- n.style.transition = "", n.style.transitionDelay = "";
2529
- }, (e.delay || 0) * 1e3 + e.duration * 1e3 + 100);
2530
- });
2531
- });
2532
- }
2533
- const getCssFromFont = (e) => {
2534
- var i;
2535
- const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], o = e.fileUrl ?? ((i = e == null ? void 0 : e.files) == null ? void 0 : i.regular);
2536
- let r = "";
2537
- if (o && t && n && (r += `
2538
- @font-face {
2539
- font-family: "${t}";
2540
- src: local("${n}"), url('${o}') format('woff2');
2541
- font-display: fallback;
2542
- font-weight: 400;
2543
- }
2544
- `.trim()), e.files)
2545
- for (const a in e.files) {
2546
- if (!(String(Number(a)) === a))
2547
- continue;
2548
- const c = e.files[a];
2549
- c && c !== o && (r += `
2550
- @font-face {
2551
- font-family: "${t}";
2552
- src: url('${c}') format('woff2');
2553
- font-display: fallback;
2554
- font-weight: ${a};
2555
- }
2556
- `.trim());
2557
- }
2558
- return r;
2559
- }, getFontCss = ({
2560
- customFonts: e
2561
- }) => {
2562
- var t;
2563
- return ((t = e == null ? void 0 : e.map((n) => getCssFromFont(n))) == null ? void 0 : t.join(" ")) || "";
2564
- }, getCss = ({
2565
- cssCode: e,
2566
- contentId: t
2567
- }) => e ? t ? (e == null ? void 0 : e.replace(/&/g, `div[builder-content-id="${t}"]`)) || "" : e : "", DEFAULT_STYLES = `
2568
- .builder-button {
2569
- all: unset;
2570
- }
2571
-
2572
- .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
2573
- margin: 0;
2574
- }
2575
- .builder-text > p, .builder-text > .builder-paragraph {
2576
- color: inherit;
2577
- line-height: inherit;
2578
- letter-spacing: inherit;
2579
- font-weight: inherit;
2580
- font-size: inherit;
2581
- text-align: inherit;
2582
- font-family: inherit;
2583
- }
2584
- `, getDefaultStyles = (e) => e ? "" : DEFAULT_STYLES, getWrapperClassName = (e) => `variant-${e}`;
2585
- function ContentStyles(e) {
2586
- const t = `
2587
- ${getCss({
2588
- cssCode: e.cssCode,
2589
- contentId: e.contentId
2590
- })}
2591
- ${getFontCss({
2592
- customFonts: e.customFonts
2593
- })}
2594
- ${getDefaultStyles(e.isNestedRender)}
2595
- `.trim();
2596
- return /* @__PURE__ */ jsx(InlinedStyles, { id: "builderio-content", styles: t });
2597
- }
2598
- const getRootStateInitialValue = ({
2599
- content: e,
2600
- data: t,
2601
- locale: n
2602
- }) => {
2603
- var i, a, s;
2604
- const o = {}, r = ((i = e == null ? void 0 : e.data) == null ? void 0 : i.state) || {};
2605
- return (s = (a = e == null ? void 0 : e.data) == null ? void 0 : a.inputs) == null || s.forEach((c) => {
2606
- c.name && c.defaultValue !== void 0 && (o[c.name] = c.defaultValue);
2607
- }), {
2608
- ...o,
2609
- ...r,
2610
- ...t,
2611
- ...n ? {
2612
- locale: n
2613
- } : {}
2614
- };
2615
- }, getContentInitialValue = ({
2616
- content: e,
2617
- data: t
2618
- }) => e ? {
2619
- ...e,
2620
- data: {
2621
- ...e == null ? void 0 : e.data,
2622
- ...t
2623
- },
2624
- meta: e == null ? void 0 : e.meta
2625
- } : void 0;
2626
- function ContentComponent(e) {
2627
- var r, i, a, s, c, d, f, l, u;
2628
- const t = getUpdateVariantVisibilityScript({
2629
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2630
- variationId: (r = e.content) == null ? void 0 : r.testVariationId,
2631
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2632
- contentId: (i = e.content) == null ? void 0 : i.id
2633
- }), n = [
2634
- ...getDefaultRegisteredComponents(),
2635
- ...e.customComponents || []
2636
- ].reduce(
2637
- (g, { component: y, ...p }) => ({
2638
- ...g,
2639
- [p.name]: {
2640
- component: y,
2641
- ...serializeComponentInfo(p)
2642
- }
2643
- }),
2644
- {}
2645
- ), o = {
2646
- content: getContentInitialValue({
2647
- content: e.content,
2648
- data: e.data
2649
- }),
2650
- localState: void 0,
2651
- rootState: getRootStateInitialValue({
2652
- content: e.content,
2653
- data: e.data,
2654
- locale: e.locale
2655
- }),
2656
- rootSetState: void 0,
2657
- context: e.context || {},
2658
- canTrack: e.canTrack,
2659
- apiKey: e.apiKey,
2660
- apiVersion: e.apiVersion,
2661
- componentInfos: [
2662
- ...getDefaultRegisteredComponents(),
2663
- ...e.customComponents || []
2664
- ].reduce(
2665
- (g, { component: y, ...p }) => ({
2666
- ...g,
2667
- [p.name]: serializeComponentInfo(p)
2668
- }),
2669
- {}
2670
- ),
2671
- inheritedStyles: {},
2672
- BlocksWrapper: e.blocksWrapper || "div",
2673
- BlocksWrapperProps: e.blocksWrapperProps || {}
2674
- };
2675
- return /* @__PURE__ */ jsxs(
2676
- EnableEditor,
2677
- {
2678
- content: e.content,
2679
- data: e.data,
2680
- model: e.model,
2681
- context: e.context,
2682
- apiKey: e.apiKey,
2683
- canTrack: e.canTrack,
2684
- locale: e.locale,
2685
- enrich: e.enrich,
2686
- showContent: e.showContent,
2687
- builderContextSignal: o,
2688
- contentWrapper: e.contentWrapper,
2689
- contentWrapperProps: e.contentWrapperProps,
2690
- trustedHosts: e.trustedHosts,
2691
- children: [
2692
- e.isSsrAbTest ? /* @__PURE__ */ jsx(
2693
- InlinedScript,
2694
- {
2695
- id: "builderio-variant-visibility",
2696
- scriptStr: t
2697
- }
2698
- ) : null,
2699
- /* @__PURE__ */ jsx(
2700
- ContentStyles,
2701
- {
2702
- isNestedRender: e.isNestedRender,
2703
- contentId: (a = o.content) == null ? void 0 : a.id,
2704
- cssCode: (c = (s = o.content) == null ? void 0 : s.data) == null ? void 0 : c.cssCode,
2705
- customFonts: (f = (d = o.content) == null ? void 0 : d.data) == null ? void 0 : f.customFonts
2706
- }
2707
- ),
2708
- /* @__PURE__ */ jsx(
2709
- Blocks,
2710
- {
2711
- blocks: (u = (l = o.content) == null ? void 0 : l.data) == null ? void 0 : u.blocks,
2712
- context: o,
2713
- registeredComponents: n,
2714
- linkComponent: e.linkComponent
2715
- }
2716
- )
2717
- ]
2718
- }
2719
- );
2720
- }
2721
- function ContentVariants(e) {
2722
- var i;
2723
- const t = checkShouldRenderVariants({
2724
- canTrack: getDefaultCanTrack(e.canTrack),
2725
- content: e.content
2726
- }), n = function() {
2727
- var s;
2728
- return getUpdateCookieAndStylesScript(
2729
- getVariants(e.content).map((c) => ({
2730
- id: c.testVariationId,
2731
- testRatio: c.testRatio
2732
- })),
2733
- ((s = e.content) == null ? void 0 : s.id) || ""
2734
- );
2735
- }, o = function() {
2736
- return getVariants(e.content).map((s) => `.variant-${s.testVariationId} { display: none; } `).join("");
2737
- }, r = function() {
2738
- var s;
2739
- return t ? {
2740
- ...e.content,
2741
- testVariationId: (s = e.content) == null ? void 0 : s.id
2742
- } : handleABTestingSync({
2743
- item: e.content,
2744
- canTrack: getDefaultCanTrack(e.canTrack)
2745
- });
2746
- };
2747
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2748
- !e.isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ jsx(
2749
- InlinedScript,
2750
- {
2751
- id: "builderio-init-variants-fns",
2752
- scriptStr: getInitVariantsFnsScriptString()
2753
- }
2754
- ) : null,
2755
- t ? /* @__PURE__ */ jsxs(Fragment, { children: [
2756
- /* @__PURE__ */ jsx(
2757
- InlinedStyles,
2758
- {
2759
- id: "builderio-variants",
2760
- styles: o()
2761
- }
2762
- ),
2763
- /* @__PURE__ */ jsx(
2764
- InlinedScript,
2765
- {
2766
- id: "builderio-variants-visibility",
2767
- scriptStr: n()
2768
- }
2769
- ),
2770
- (i = getVariants(e.content)) == null ? void 0 : i.map((a) => /* @__PURE__ */ jsx(
2771
- ContentComponent,
2772
- {
2773
- isNestedRender: e.isNestedRender,
2774
- content: a,
2775
- showContent: !1,
2776
- model: e.model,
2777
- data: e.data,
2778
- context: e.context,
2779
- apiKey: e.apiKey,
2780
- apiVersion: e.apiVersion,
2781
- customComponents: e.customComponents,
2782
- linkComponent: e.linkComponent,
2783
- canTrack: e.canTrack,
2784
- locale: e.locale,
2785
- enrich: e.enrich,
2786
- isSsrAbTest: t,
2787
- blocksWrapper: e.blocksWrapper,
2788
- blocksWrapperProps: e.blocksWrapperProps,
2789
- contentWrapper: e.contentWrapper,
2790
- contentWrapperProps: e.contentWrapperProps,
2791
- trustedHosts: e.trustedHosts
2792
- },
2793
- a.testVariationId
2794
- ))
2795
- ] }) : null,
2796
- /* @__PURE__ */ jsx(
2797
- ContentComponent,
2798
- {
2799
- isNestedRender: e.isNestedRender,
2800
- content: r(),
2801
- showContent: !0,
2802
- model: e.model,
2803
- data: e.data,
2804
- context: e.context,
2805
- apiKey: e.apiKey,
2806
- apiVersion: e.apiVersion,
2807
- customComponents: e.customComponents,
2808
- linkComponent: e.linkComponent,
2809
- canTrack: e.canTrack,
2810
- locale: e.locale,
2811
- enrich: e.enrich,
2812
- isSsrAbTest: t,
2813
- blocksWrapper: e.blocksWrapper,
2814
- blocksWrapperProps: e.blocksWrapperProps,
2815
- contentWrapper: e.contentWrapper,
2816
- contentWrapperProps: e.contentWrapperProps,
2817
- trustedHosts: e.trustedHosts
2818
- }
2819
- )
2820
- ] });
2821
- }
2822
- const fetchSymbolContent = async ({
2823
- builderContextValue: e,
2824
- symbol: t
2825
- }) => {
2826
- if (t != null && t.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
2827
- (e != null && e.apiKey))
2828
- return fetchOneEntry({
2829
- model: t.model,
2830
- apiKey: e.apiKey,
2831
- apiVersion: e.apiVersion,
2832
- ...(t == null ? void 0 : t.entry) && {
2833
- query: {
2834
- id: t.entry
2835
- }
2836
- }
2837
- }).catch((n) => {
2838
- logger.error("Could not fetch symbol content: ", n);
2839
- });
2840
- };
2841
- async function Symbol$1(e) {
2842
- var i, a, s, c, d;
2843
- const t = function() {
2844
- return "div";
2845
- }, n = function() {
2846
- return "div";
2847
- }, o = function() {
2848
- var l, u;
2849
- return [
2850
- e.attributes[getClassPropName()],
2851
- "builder-symbol",
2852
- (l = e.symbol) != null && l.inline ? "builder-inline-symbol" : void 0,
2853
- (u = e.symbol) != null && u.dynamic || e.dynamic ? "builder-dynamic-symbol" : void 0
2854
- ].filter(Boolean).join(" ");
2855
- }, r = ((i = e.symbol) == null ? void 0 : i.content) || await fetchSymbolContent({
2856
- symbol: e.symbol,
2857
- builderContextValue: e.builderContext
2858
- });
2859
- return /* @__PURE__ */ jsx("div", { ...e.attributes, className: o(), children: /* @__PURE__ */ jsx(
2860
- ContentVariants,
2861
- {
2862
- isNestedRender: !0,
2863
- apiVersion: e.builderContext.apiVersion,
2864
- apiKey: e.builderContext.apiKey,
2865
- context: {
2866
- ...e.builderContext.context,
2867
- symbolId: (a = e.builderBlock) == null ? void 0 : a.id
2868
- },
2869
- customComponents: Object.values(e.builderComponents),
2870
- data: {
2871
- ...(s = e.symbol) == null ? void 0 : s.data,
2872
- ...e.builderContext.localState,
2873
- ...(c = r == null ? void 0 : r.data) == null ? void 0 : c.state
2874
- },
2875
- canTrack: e.builderContext.canTrack,
2876
- model: (d = e.symbol) == null ? void 0 : d.model,
2877
- content: r,
2878
- linkComponent: e.builderLinkComponent,
2879
- blocksWrapper: t(),
2880
- contentWrapper: n()
2881
- }
2882
- ) });
2883
- }
2884
- const settings = {};
2885
- function setEditorSettings(e) {
2886
- if (isBrowser()) {
2887
- Object.assign(settings, e);
2888
- const t = {
2889
- type: "builder.settingsChange",
2890
- data: settings
2891
- };
2892
- parent.postMessage(t, "*");
2893
- }
2894
- }
2895
- const fetchBuilderProps = async (e) => {
2896
- var o, r, i;
2897
- const t = e.path || ((o = e.url) == null ? void 0 : o.pathname) || ((r = e.userAttributes) == null ? void 0 : r.urlPath), n = {
2898
- ...e,
2899
- apiKey: e.apiKey,
2900
- model: e.model || "page",
2901
- userAttributes: {
2902
- ...e.userAttributes,
2903
- ...t ? {
2904
- urlPath: t
2905
- } : {}
2906
- },
2907
- options: getBuilderSearchParams(e.searchParams || ((i = e.url) == null ? void 0 : i.searchParams) || e.options)
2908
- };
2909
- return {
2910
- apiKey: n.apiKey,
2911
- model: n.model,
2912
- content: await fetchOneEntry(n)
2913
- };
2914
- };
2915
- export {
2916
- getBuilderSearchParams as A,
2917
- Blocks as B,
2918
- Columns as C,
2919
- track as D,
2920
- subscribeToEditor as E,
2921
- fetchBuilderProps as F,
2922
- _processContentResult as G,
2923
- fetchEntries as H,
2924
- Symbol$1 as S,
2925
- Text as T,
2926
- _track as _,
2927
- getBlockProperties as a,
2928
- getBlockActions as b,
2929
- isEditing as c,
2930
- getSrcSet as d,
2931
- isJsScript as e,
2932
- isBrowser as f,
2933
- getClassPropName as g,
2934
- getDefaultCanTrack as h,
2935
- isEmptyElement as i,
2936
- isPreviewing as j,
2937
- getWrapperClassName as k,
2938
- logger as l,
2939
- createEditorListener as m,
2940
- evaluate as n,
2941
- getInteractionPropertiesForEvent as o,
2942
- fetch$1 as p,
2943
- fastClone as q,
2944
- registerInsertMenu as r,
2945
- setupBrowserForEditing as s,
2946
- triggerAnimation as t,
2947
- createRegisterComponentMessage as u,
2948
- fetchOneEntry as v,
2949
- init as w,
2950
- ContentVariants as x,
2951
- register as y,
2952
- setEditorSettings as z
2953
- };