@builder.io/sdk-react-nextjs 0.12.1 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/lib/browser/USE_CLIENT_BUNDLE-64b6ec10.cjs +21 -0
  2. package/lib/browser/USE_CLIENT_BUNDLE-e89d3175.js +713 -0
  3. package/lib/{edge/USE_SERVER_BUNDLE-231b55dd.js → browser/USE_SERVER_BUNDLE-d6bec4ec.js} +1 -1
  4. package/lib/{edge/USE_SERVER_BUNDLE-24df6623.cjs → browser/USE_SERVER_BUNDLE-f34c0814.cjs} +1 -1
  5. package/lib/browser/bundle-50ff23eb.cjs +172 -0
  6. package/lib/browser/{bundle-7e2a44d9.js → bundle-f3e8cd29.js} +576 -573
  7. package/lib/browser/index.cjs +1 -1
  8. package/lib/browser/index.mjs +17 -17
  9. package/lib/edge/USE_CLIENT_BUNDLE-2aed408a.cjs +21 -0
  10. package/lib/edge/USE_CLIENT_BUNDLE-a3258a60.js +713 -0
  11. package/lib/{node/USE_SERVER_BUNDLE-33c309df.js → edge/USE_SERVER_BUNDLE-4e9af8f5.js} +1 -1
  12. package/lib/{node/USE_SERVER_BUNDLE-93366161.cjs → edge/USE_SERVER_BUNDLE-e79e6b55.cjs} +1 -1
  13. package/lib/edge/{bundle-44392f6d.js → bundle-cb191300.js} +811 -808
  14. package/lib/edge/{bundle-6d55a6a7.cjs → bundle-d4f509a3.cjs} +37 -33
  15. package/lib/edge/index.cjs +1 -1
  16. package/lib/edge/index.mjs +17 -17
  17. package/lib/node/USE_CLIENT_BUNDLE-98a4fbf4.js +713 -0
  18. package/lib/node/USE_CLIENT_BUNDLE-990b655a.cjs +21 -0
  19. package/lib/{browser/USE_SERVER_BUNDLE-153f7d4b.js → node/USE_SERVER_BUNDLE-b231d861.js} +1 -1
  20. package/lib/{browser/USE_SERVER_BUNDLE-a0bf6d8f.cjs → node/USE_SERVER_BUNDLE-c86a1fb8.cjs} +1 -1
  21. package/lib/node/{bundle-217b5738.js → bundle-11daeaca.js} +166 -163
  22. package/lib/node/{bundle-b9af39ec.cjs → bundle-b2d68b60.cjs} +11 -7
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +17 -17
  25. package/package.json +1 -1
  26. package/types/cjs/components/block/block.helpers.d.ts +0 -1
  27. package/types/cjs/components/block/components/block-wrapper.d.ts +2 -6
  28. package/types/cjs/components/content-variants/content-variants.types.d.ts +4 -0
  29. package/types/cjs/components/dynamic-renderer/dynamic-renderer.d.ts +8 -0
  30. package/types/cjs/components/dynamic-renderer/dynamic-renderer.helpers.d.ts +1 -0
  31. package/types/cjs/constants/sdk-version.d.ts +1 -1
  32. package/types/cjs/functions/is-from-trusted-host.d.ts +3 -0
  33. package/types/cjs/scripts/init-editing.d.ts +1 -0
  34. package/types/esm/components/block/block.helpers.d.ts +0 -1
  35. package/types/esm/components/block/components/block-wrapper.d.ts +2 -6
  36. package/types/esm/components/content-variants/content-variants.types.d.ts +4 -0
  37. package/types/esm/components/dynamic-renderer/dynamic-renderer.d.ts +8 -0
  38. package/types/esm/components/dynamic-renderer/dynamic-renderer.helpers.d.ts +1 -0
  39. package/types/esm/constants/sdk-version.d.ts +1 -1
  40. package/types/esm/functions/is-from-trusted-host.d.ts +3 -0
  41. package/types/esm/scripts/init-editing.d.ts +1 -0
  42. package/lib/browser/USE_CLIENT_BUNDLE-5457b97e.cjs +0 -23
  43. package/lib/browser/USE_CLIENT_BUNDLE-ac9ba054.js +0 -732
  44. package/lib/browser/bundle-6435b7fb.cjs +0 -168
  45. package/lib/edge/USE_CLIENT_BUNDLE-3049fd56.js +0 -732
  46. package/lib/edge/USE_CLIENT_BUNDLE-8922846d.cjs +0 -23
  47. package/lib/node/USE_CLIENT_BUNDLE-09122ff1.cjs +0 -23
  48. package/lib/node/USE_CLIENT_BUNDLE-f4804af3.js +0 -732
@@ -1,732 +0,0 @@
1
- "use client";
2
- import { jsxs as w, Fragment as g, jsx as i } from "react/jsx-runtime";
3
- import { g as T, a as B, i as E, b as R, c as Y, d as P, e as U, _ as H, f as Z, l as p, h as O, j as ee, k as te, r as ne, s as ie, m as ae, n as ce, o as le } from "./bundle-217b5738.js";
4
- import { useRef as N, useState as v, useEffect as b, createContext as oe, createElement as re } from "react";
5
- import { p as de } from "./USE_SERVER_BUNDLE-33c309df.js";
6
- import { useRouter as se } from "next/navigation";
7
- function xe(e) {
8
- return /* @__PURE__ */ w(g, { children: [
9
- e.link ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i(
10
- "a",
11
- {
12
- ...e.attributes,
13
- href: e.link,
14
- target: e.openLinkInNewTab ? "_blank" : void 0,
15
- role: "button",
16
- children: e.text
17
- }
18
- ) }) : /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i(
19
- "button",
20
- {
21
- ...e.attributes,
22
- style: e.attributes.style,
23
- className: e.attributes.className + " button-fdf49de0",
24
- children: e.text
25
- }
26
- ) }),
27
- /* @__PURE__ */ i("style", { children: `.button-fdf49de0 {
28
- all: unset;
29
- }` })
30
- ] });
31
- }
32
- function ve(e) {
33
- return /* @__PURE__ */ w(g, { children: [
34
- " ",
35
- e.hasChildren ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ w(
36
- e.Wrapper,
37
- {
38
- ...T({
39
- block: e.block,
40
- context: e.context
41
- }),
42
- ...B({
43
- block: e.block,
44
- rootState: e.context.rootState,
45
- rootSetState: e.context.rootSetState,
46
- localState: e.context.localState,
47
- context: e.context.context,
48
- stripPrefix: !0
49
- }),
50
- children: [
51
- " ",
52
- e.children,
53
- " "
54
- ]
55
- }
56
- ) }) : /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i(
57
- e.Wrapper,
58
- {
59
- ...T({
60
- block: e.block,
61
- context: e.context
62
- }),
63
- ...B({
64
- block: e.block,
65
- rootState: e.context.rootState,
66
- rootSetState: e.context.rootSetState,
67
- localState: e.context.localState,
68
- context: e.context.context,
69
- stripPrefix: !0
70
- })
71
- }
72
- ) }),
73
- " "
74
- ] });
75
- }
76
- function ye(e) {
77
- return /* @__PURE__ */ i(
78
- e.Wrapper,
79
- {
80
- ...e.wrapperProps,
81
- attributes: e.includeBlockProps ? {
82
- ...T({
83
- block: e.block,
84
- context: e.context
85
- }),
86
- ...B({
87
- block: e.block,
88
- rootState: e.context.rootState,
89
- rootSetState: e.context.rootSetState,
90
- localState: e.context.localState,
91
- context: e.context.context
92
- })
93
- } : {},
94
- children: e.children
95
- }
96
- );
97
- }
98
- function ke(e) {
99
- function c() {
100
- var o;
101
- return "builder-blocks" + ((o = e.blocks) != null && o.length ? "" : " no-blocks");
102
- }
103
- function s() {
104
- var o, u;
105
- E() && !((o = e.blocks) != null && o.length) && ((u = window.parent) == null || u.postMessage(
106
- {
107
- type: "builder.clickEmptyBlocks",
108
- data: {
109
- parentElementId: e.parent,
110
- dataPath: e.path
111
- }
112
- },
113
- "*"
114
- ));
115
- }
116
- function x() {
117
- var o, u;
118
- E() && !((o = e.blocks) != null && o.length) && ((u = window.parent) == null || u.postMessage(
119
- {
120
- type: "builder.hoverEmptyBlocks",
121
- data: {
122
- parentElementId: e.parent,
123
- dataPath: e.path
124
- }
125
- },
126
- "*"
127
- ));
128
- }
129
- return /* @__PURE__ */ w(g, { children: [
130
- /* @__PURE__ */ i(
131
- e.BlocksWrapper,
132
- {
133
- className: c() + " props-blocks-wrapper-4f2c12d8",
134
- "builder-path": e.path,
135
- "builder-parent-id": e.parent,
136
- style: e.styleProp,
137
- onClick: (o) => s(),
138
- onMouseEnter: (o) => x(),
139
- onKeyPress: (o) => s(),
140
- ...e.BlocksWrapperProps,
141
- children: e.children
142
- }
143
- ),
144
- /* @__PURE__ */ i("style", { children: `.props-blocks-wrapper-4f2c12d8 {
145
- display: flex;
146
- flex-direction: column;
147
- align-items: stretch;
148
- }` })
149
- ] });
150
- }
151
- function Ce(e) {
152
- return /* @__PURE__ */ i("span", { children: e.children });
153
- }
154
- function we(e) {
155
- var o, u, S, y;
156
- function c() {
157
- var m;
158
- const r = e.image || e.src;
159
- if (!r || // We can auto add srcset for cdn.builder.io and shopify
160
- // images, otherwise you can supply this prop manually
161
- !(r.match(/builder\.io/) || r.match(/cdn\.shopify\.com/)))
162
- return e.srcset;
163
- if (e.srcset && ((m = e.image) != null && m.includes("builder.io/api/v1/image"))) {
164
- if (!e.srcset.includes(e.image.split("?")[0]))
165
- return console.debug("Removed given srcset"), R(r);
166
- } else if (e.image && !e.srcset)
167
- return R(r);
168
- return R(r);
169
- }
170
- function s() {
171
- var f;
172
- return (f = c == null ? void 0 : c()) != null && f.match(/builder\.io/) && !e.noWebp ? c().replace(/\?/g, "?format=webp&") : "";
173
- }
174
- function x() {
175
- const f = {
176
- position: "absolute",
177
- height: "100%",
178
- width: "100%",
179
- left: "0px",
180
- top: "0px"
181
- };
182
- return e.aspectRatio ? f : void 0;
183
- }
184
- return /* @__PURE__ */ w(g, { children: [
185
- /* @__PURE__ */ w(g, { children: [
186
- /* @__PURE__ */ w("picture", { children: [
187
- s() ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i("source", { type: "image/webp", srcSet: s() }) }) : null,
188
- /* @__PURE__ */ i(
189
- "img",
190
- {
191
- loading: "lazy",
192
- alt: e.altText,
193
- role: e.altText ? "presentation" : void 0,
194
- style: {
195
- objectPosition: e.backgroundPosition || "center",
196
- objectFit: e.backgroundSize || "cover",
197
- ...x()
198
- },
199
- className: "builder-image" + (e.className ? " " + e.className : "") + " img-40c70c9b",
200
- src: e.image,
201
- srcSet: c(),
202
- sizes: e.sizes
203
- }
204
- )
205
- ] }),
206
- e.aspectRatio && !((u = (o = e.builderBlock) == null ? void 0 : o.children) != null && u.length && e.fitContent) ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i(
207
- "div",
208
- {
209
- className: "builder-image-sizer div-40c70c9b",
210
- style: {
211
- paddingTop: e.aspectRatio * 100 + "%"
212
- }
213
- }
214
- ) }) : null,
215
- (y = (S = e.builderBlock) == null ? void 0 : S.children) != null && y.length && e.fitContent ? /* @__PURE__ */ i(g, { children: e.children }) : null,
216
- !e.fitContent && e.children ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i("div", { className: "div-40c70c9b-2", children: e.children }) }) : null
217
- ] }),
218
- /* @__PURE__ */ i("style", { children: `.img-40c70c9b {
219
- opacity: 1;
220
- transition: opacity 0.2s ease-in-out;
221
- }.div-40c70c9b {
222
- width: 100%;
223
- pointer-events: none;
224
- font-size: 0;
225
- }.div-40c70c9b-2 {
226
- display: flex;
227
- flex-direction: column;
228
- align-items: stretch;
229
- position: absolute;
230
- top: 0;
231
- left: 0;
232
- width: 100%;
233
- height: 100%;
234
- }` })
235
- ] });
236
- }
237
- function Ee(e) {
238
- return /* @__PURE__ */ i(
239
- "section",
240
- {
241
- ...e.attributes,
242
- style: {
243
- width: "100%",
244
- alignSelf: "stretch",
245
- flexGrow: 1,
246
- boxSizing: "border-box",
247
- maxWidth: e.maxWidth || 1200,
248
- display: "flex",
249
- flexDirection: "column",
250
- alignItems: "stretch",
251
- marginLeft: "auto",
252
- marginRight: "auto"
253
- },
254
- children: e.children
255
- }
256
- );
257
- }
258
- function Ie(e) {
259
- const c = N(null), [s, x] = v(() => []), [o, u] = v(() => []);
260
- return b(() => {
261
- var y;
262
- if (!((y = c.current) != null && y.getElementsByTagName) || typeof window > "u")
263
- return;
264
- const S = c.current.getElementsByTagName("script");
265
- for (let f = 0; f < S.length; f++) {
266
- const r = S[f];
267
- if (r.src) {
268
- if (s.includes(r.src))
269
- continue;
270
- s.push(r.src);
271
- const m = document.createElement("script");
272
- m.async = !0, m.src = r.src, document.head.appendChild(m);
273
- } else if (!r.type || [
274
- "text/javascript",
275
- "application/javascript",
276
- "application/ecmascript"
277
- ].includes(r.type)) {
278
- if (o.includes(r.innerText))
279
- continue;
280
- try {
281
- o.push(r.innerText), new Function(r.innerText)();
282
- } catch (m) {
283
- console.warn("`CustomCode`: Error running script:", m);
284
- }
285
- }
286
- }
287
- }, []), /* @__PURE__ */ i(
288
- "div",
289
- {
290
- ref: c,
291
- className: "builder-custom-code" + (e.replaceNodes ? " replace-nodes" : ""),
292
- dangerouslySetInnerHTML: { __html: e.code }
293
- }
294
- );
295
- }
296
- function Re(e) {
297
- const c = N(null), [s, x] = v(() => []), [o, u] = v(() => []), [S, y] = v(() => !1);
298
- function f() {
299
- if (!c.current || !c.current.getElementsByTagName)
300
- return;
301
- const r = c.current.getElementsByTagName("script");
302
- for (let m = 0; m < r.length; m++) {
303
- const k = r[m];
304
- if (k.src && !s.includes(k.src)) {
305
- s.push(k.src);
306
- const C = document.createElement("script");
307
- C.async = !0, C.src = k.src, document.head.appendChild(C);
308
- } else if (Y(k) && !o.includes(k.innerText))
309
- try {
310
- o.push(k.innerText), new Function(k.innerText)();
311
- } catch (C) {
312
- console.warn("`Embed`: Error running script:", C);
313
- }
314
- }
315
- }
316
- return b(() => {
317
- c.current && !S && (y(!0), f());
318
- }, [c.current, S]), /* @__PURE__ */ i(
319
- "div",
320
- {
321
- className: "builder-embed",
322
- ref: c,
323
- dangerouslySetInnerHTML: { __html: e.content }
324
- }
325
- );
326
- }
327
- function Pe(e) {
328
- return /* @__PURE__ */ i(
329
- "img",
330
- {
331
- style: {
332
- objectFit: e.backgroundSize || "cover",
333
- objectPosition: e.backgroundPosition || "center"
334
- },
335
- alt: e.altText,
336
- src: e.imgSrc || e.image,
337
- ...e.attributes
338
- },
339
- E() && e.imgSrc || "default-key"
340
- );
341
- }
342
- function Te(e) {
343
- var x, o, u, S, y, f, r;
344
- function c() {
345
- return {
346
- ...e.autoPlay === !0 ? {
347
- autoPlay: !0
348
- } : {},
349
- ...e.muted === !0 ? {
350
- muted: !0
351
- } : {},
352
- ...e.controls === !0 ? {
353
- controls: !0
354
- } : {},
355
- ...e.loop === !0 ? {
356
- loop: !0
357
- } : {},
358
- ...e.playsInline === !0 ? {
359
- playsInline: !0
360
- } : {}
361
- };
362
- }
363
- function s() {
364
- return {
365
- ...c()
366
- };
367
- }
368
- return /* @__PURE__ */ w(
369
- "div",
370
- {
371
- style: {
372
- position: "relative"
373
- },
374
- children: [
375
- /* @__PURE__ */ i(
376
- "video",
377
- {
378
- className: "builder-video",
379
- ...s(),
380
- preload: e.preload || "metadata",
381
- style: {
382
- width: "100%",
383
- height: "100%",
384
- ...(x = e.attributes) == null ? void 0 : x.style,
385
- objectFit: e.fit,
386
- objectPosition: e.position,
387
- // Hack to get object fit to work as expected and
388
- // not have the video overflow
389
- zIndex: 2,
390
- borderRadius: "1px",
391
- ...e.aspectRatio ? {
392
- position: "absolute"
393
- } : null
394
- },
395
- src: e.video || "no-src",
396
- poster: e.posterImage,
397
- children: e.lazyLoad ? null : /* @__PURE__ */ i("source", { type: "video/mp4", src: e.video })
398
- }
399
- ),
400
- e.aspectRatio && !(e.fitContent && ((u = (o = e.builderBlock) == null ? void 0 : o.children) != null && u.length)) ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i(
401
- "div",
402
- {
403
- style: {
404
- width: "100%",
405
- paddingTop: e.aspectRatio * 100 + "%",
406
- pointerEvents: "none",
407
- fontSize: "0px"
408
- }
409
- }
410
- ) }) : null,
411
- (y = (S = e.builderBlock) == null ? void 0 : S.children) != null && y.length && e.fitContent ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i(
412
- "div",
413
- {
414
- style: {
415
- display: "flex",
416
- flexDirection: "column",
417
- alignItems: "stretch"
418
- },
419
- children: e.children
420
- }
421
- ) }) : null,
422
- (r = (f = e.builderBlock) == null ? void 0 : f.children) != null && r.length && !e.fitContent ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ i(
423
- "div",
424
- {
425
- style: {
426
- pointerEvents: "none",
427
- display: "flex",
428
- flexDirection: "column",
429
- alignItems: "stretch",
430
- position: "absolute",
431
- top: "0",
432
- left: "0",
433
- width: "100%",
434
- height: "100%"
435
- },
436
- children: e.children
437
- }
438
- ) }) : null
439
- ]
440
- }
441
- );
442
- }
443
- const ue = oe({
444
- content: null,
445
- context: {},
446
- localState: void 0,
447
- rootSetState() {
448
- },
449
- rootState: {},
450
- apiKey: null,
451
- apiVersion: void 0,
452
- componentInfos: {},
453
- inheritedStyles: {},
454
- BlocksWrapper: "div",
455
- BlocksWrapperProps: {}
456
- });
457
- function Be(e) {
458
- var F, z, M, _, V, q, A;
459
- const c = N(null), [s, x] = v(() => 0);
460
- v(() => !0);
461
- function o(t) {
462
- var a, l;
463
- const n = {
464
- ...e.builderContextSignal.rootState,
465
- ...t
466
- };
467
- e.builderContextSignal.rootSetState ? (l = (a = e.builderContextSignal).rootSetState) == null || l.call(a, n) : e.builderContextSignal.rootState = n;
468
- }
469
- function u(t) {
470
- var a, l, d, h, D;
471
- const n = {
472
- ...e.builderContextSignal.content,
473
- ...t,
474
- data: {
475
- ...(a = e.builderContextSignal.content) == null ? void 0 : a.data,
476
- ...t == null ? void 0 : t.data
477
- },
478
- meta: {
479
- ...(l = e.builderContextSignal.content) == null ? void 0 : l.meta,
480
- ...t == null ? void 0 : t.meta,
481
- breakpoints: ((d = t == null ? void 0 : t.meta) == null ? void 0 : d.breakpoints) || ((D = (h = e.builderContextSignal.content) == null ? void 0 : h.meta) == null ? void 0 : D.breakpoints)
482
- }
483
- };
484
- de({
485
- value: n,
486
- key: n.id
487
- }).then(() => {
488
- X.refresh();
489
- });
490
- }
491
- v(() => 0);
492
- const [S, y] = v(
493
- () => !1
494
- ), [f, r] = v(
495
- () => e.contentWrapper || "div"
496
- );
497
- function m(t) {
498
- var a;
499
- const { data: n } = t;
500
- if (n)
501
- switch (n.type) {
502
- case "builder.configureSdk": {
503
- const l = n.data, { breakpoints: d, contentId: h } = l;
504
- if (!h || h !== ((a = e.builderContextSignal.content) == null ? void 0 : a.id))
505
- return;
506
- d && u({
507
- meta: {
508
- breakpoints: d
509
- }
510
- }), x(s + 1);
511
- break;
512
- }
513
- case "builder.contentUpdate": {
514
- const l = n.data, d = l.key || l.alias || l.entry || l.modelName, h = l.data;
515
- d === e.model && (u(h), x(s + 1));
516
- break;
517
- }
518
- }
519
- }
520
- function k() {
521
- var n, a;
522
- const t = (a = (n = e.builderContextSignal.content) == null ? void 0 : n.data) == null ? void 0 : a.jsCode;
523
- t && O({
524
- code: t,
525
- context: e.context || {},
526
- localState: void 0,
527
- rootState: e.builderContextSignal.rootState,
528
- rootSetState: e.builderContextSignal.rootSetState
529
- });
530
- }
531
- const [C, me] = v(() => ({})), [L, J] = v(() => !1);
532
- function $(t) {
533
- var n, a;
534
- if (e.builderContextSignal.content) {
535
- const l = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, d = (a = e.builderContextSignal.content) == null ? void 0 : a.id;
536
- H({
537
- type: "click",
538
- canTrack: U(e.canTrack),
539
- contentId: d,
540
- apiKey: e.apiKey,
541
- variationId: l !== d ? l : void 0,
542
- ...ee(t),
543
- unique: !L
544
- });
545
- }
546
- L || J(!0);
547
- }
548
- function G(t) {
549
- return t.replace(
550
- /{{([^}]+)}}/g,
551
- (n, a) => O({
552
- code: a,
553
- context: e.context || {},
554
- localState: void 0,
555
- rootState: e.builderContextSignal.rootState,
556
- rootSetState: e.builderContextSignal.rootSetState
557
- })
558
- );
559
- }
560
- function Q({ url: t, key: n }) {
561
- le(t).then((a) => a.json()).then((a) => {
562
- var d, h;
563
- const l = {
564
- ...e.builderContextSignal.rootState,
565
- [n]: a
566
- };
567
- (h = (d = e.builderContextSignal).rootSetState) == null || h.call(d, l), C[n] = !0;
568
- }).catch((a) => {
569
- console.error("error fetching dynamic data", t, a);
570
- });
571
- }
572
- function j() {
573
- var n, a;
574
- const t = ((a = (n = e.builderContextSignal.content) == null ? void 0 : n.data) == null ? void 0 : a.httpRequests) ?? {};
575
- Object.entries(t).forEach(([l, d]) => {
576
- if (d && (!C[l] || E())) {
577
- const h = G(d);
578
- Q({
579
- url: h,
580
- key: l
581
- });
582
- }
583
- });
584
- }
585
- function I() {
586
- E() && window.dispatchEvent(
587
- new CustomEvent(
588
- "builder:component:stateChange",
589
- {
590
- detail: {
591
- state: te(e.builderContextSignal.rootState),
592
- ref: {
593
- name: e.model
594
- }
595
- }
596
- }
597
- )
598
- );
599
- }
600
- function W(t) {
601
- x(s + 1), window.addEventListener("message", m), ne(), ie({
602
- ...e.locale ? {
603
- locale: e.locale
604
- } : {},
605
- ...e.includeRefs ? {
606
- includeRefs: e.includeRefs
607
- } : {},
608
- ...e.enrich ? {
609
- enrich: e.enrich
610
- } : {}
611
- }), Object.values(
612
- e.builderContextSignal.componentInfos
613
- ).forEach((n) => {
614
- var l;
615
- const a = ae(n);
616
- (l = window.parent) == null || l.postMessage(a, "*");
617
- }), window.addEventListener(
618
- "builder:component:stateChangeListenerActivated",
619
- I
620
- );
621
- }
622
- function K(t) {
623
- const n = new URL(location.href).searchParams, a = n.get("builder.preview"), l = n.get(
624
- `builder.preview.${a}`
625
- ), d = n.get("apiKey") || n.get("builder.space");
626
- a === e.model && d === e.apiKey && (!e.content || l === e.content.id) && ce({
627
- model: e.model,
628
- apiKey: e.apiKey,
629
- apiVersion: e.builderContextSignal.apiVersion
630
- }).then((h) => {
631
- h && u(h);
632
- });
633
- }
634
- const X = se();
635
- return b(() => {
636
- var t;
637
- return (t = c.current) == null || t.addEventListener(
638
- "initeditingbldr",
639
- W
640
- ), () => {
641
- var n;
642
- return (n = c.current) == null ? void 0 : n.removeEventListener(
643
- "initeditingbldr",
644
- W
645
- );
646
- };
647
- }, []), b(() => {
648
- var t;
649
- return (t = c.current) == null || t.addEventListener(
650
- "initpreviewingbldr",
651
- K
652
- ), () => {
653
- var n;
654
- return (n = c.current) == null ? void 0 : n.removeEventListener(
655
- "initpreviewingbldr",
656
- K
657
- );
658
- };
659
- }, []), b(() => {
660
- var t, n;
661
- if (P()) {
662
- if (E() && c.current && c.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && U(e.canTrack)) {
663
- const l = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, d = (n = e.builderContextSignal.content) == null ? void 0 : n.id, h = e.apiKey;
664
- H({
665
- type: "impression",
666
- canTrack: !0,
667
- contentId: d,
668
- apiKey: h,
669
- variationId: l !== d ? l : void 0
670
- });
671
- }
672
- Z() && c.current;
673
- }
674
- }, []), b(() => {
675
- e.apiKey || p.error(
676
- "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
677
- ), k(), j(), I();
678
- }, []), b(() => {
679
- }, [e.content]), b(() => {
680
- P() && (window.removeEventListener("message", m), window.addEventListener("message", m));
681
- }, [S]), b(() => {
682
- k();
683
- }, [
684
- (z = (F = e.builderContextSignal.content) == null ? void 0 : F.data) == null ? void 0 : z.jsCode,
685
- e.builderContextSignal.rootState
686
- ]), b(() => {
687
- j();
688
- }, [(_ = (M = e.builderContextSignal.content) == null ? void 0 : M.data) == null ? void 0 : _.httpRequests]), b(() => {
689
- I();
690
- }, [e.builderContextSignal.rootState]), b(() => {
691
- e.data && o(e.data);
692
- }, [e.data]), b(() => {
693
- e.locale && o({
694
- locale: e.locale
695
- });
696
- }, [e.locale]), b(() => () => {
697
- P() && (window.removeEventListener("message", m), window.removeEventListener(
698
- "builder:component:stateChangeListenerActivated",
699
- I
700
- ));
701
- }, []), /* @__PURE__ */ i(ue.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ i(g, { children: /* @__PURE__ */ re(
702
- f,
703
- {
704
- key: s,
705
- ref: c,
706
- onClick: (t) => $(t),
707
- "builder-content-id": (V = e.builderContextSignal.content) == null ? void 0 : V.id,
708
- "builder-model": e.model,
709
- ...e.showContent ? {} : {
710
- hidden: !0,
711
- "aria-hidden": !0
712
- },
713
- ...e.contentWrapperProps,
714
- className: `variant-${((q = e.content) == null ? void 0 : q.testVariationId) || ((A = e.content) == null ? void 0 : A.id)}`
715
- },
716
- e.children
717
- ) }) : null });
718
- }
719
- export {
720
- ve as B,
721
- Ie as C,
722
- Re as E,
723
- Ce as F,
724
- ye as I,
725
- Ee as S,
726
- Te as V,
727
- ke as a,
728
- xe as b,
729
- we as c,
730
- Pe as d,
731
- Be as e
732
- };