@builder.io/sdk-react-nextjs 0.17.1 → 0.17.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 (86) hide show
  1. package/lib/browser/blocks/columns/columns.cjs +2 -2
  2. package/lib/browser/blocks/columns/columns.mjs +2 -2
  3. package/lib/browser/blocks/image/image.cjs +3 -3
  4. package/lib/browser/blocks/image/image.mjs +8 -8
  5. package/lib/browser/blocks/text/text.cjs +1 -1
  6. package/lib/browser/blocks/text/text.mjs +6 -24
  7. package/lib/browser/components/awaiter.cjs +1 -1
  8. package/lib/browser/components/block/block.cjs +1 -1
  9. package/lib/browser/components/block/block.mjs +27 -28
  10. package/lib/browser/components/blocks/blocks-wrapper.cjs +1 -1
  11. package/lib/browser/components/blocks/blocks-wrapper.mjs +2 -2
  12. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  13. package/lib/browser/components/content/components/enable-editor.mjs +102 -96
  14. package/lib/browser/constants/sdk-version.cjs +1 -1
  15. package/lib/browser/constants/sdk-version.mjs +1 -1
  16. package/lib/browser/functions/get-block-component-options.cjs +1 -1
  17. package/lib/browser/functions/get-block-component-options.mjs +21 -5
  18. package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
  19. package/lib/browser/functions/get-content/generate-content-url.mjs +60 -40
  20. package/lib/browser/functions/get-processed-block.cjs +1 -1
  21. package/lib/browser/functions/get-processed-block.mjs +18 -19
  22. package/lib/browser/helpers/flatten.cjs +1 -1
  23. package/lib/browser/helpers/flatten.mjs +28 -15
  24. package/lib/edge/blocks/columns/columns.cjs +2 -2
  25. package/lib/edge/blocks/columns/columns.mjs +2 -2
  26. package/lib/edge/blocks/image/image.cjs +3 -3
  27. package/lib/edge/blocks/image/image.mjs +8 -8
  28. package/lib/edge/blocks/text/text.cjs +1 -1
  29. package/lib/edge/blocks/text/text.mjs +6 -24
  30. package/lib/edge/components/awaiter.cjs +1 -1
  31. package/lib/edge/components/block/block.cjs +1 -1
  32. package/lib/edge/components/block/block.mjs +27 -28
  33. package/lib/edge/components/blocks/blocks-wrapper.cjs +1 -1
  34. package/lib/edge/components/blocks/blocks-wrapper.mjs +2 -2
  35. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  36. package/lib/edge/components/content/components/enable-editor.mjs +102 -96
  37. package/lib/edge/constants/sdk-version.cjs +1 -1
  38. package/lib/edge/constants/sdk-version.mjs +1 -1
  39. package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.cjs +5 -5
  40. package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.mjs +25 -28
  41. package/lib/edge/functions/get-block-component-options.cjs +1 -1
  42. package/lib/edge/functions/get-block-component-options.mjs +21 -5
  43. package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
  44. package/lib/edge/functions/get-content/generate-content-url.mjs +60 -40
  45. package/lib/edge/functions/get-processed-block.cjs +1 -1
  46. package/lib/edge/functions/get-processed-block.mjs +18 -19
  47. package/lib/edge/helpers/flatten.cjs +1 -1
  48. package/lib/edge/helpers/flatten.mjs +28 -15
  49. package/lib/node/blocks/columns/columns.cjs +2 -2
  50. package/lib/node/blocks/columns/columns.mjs +2 -2
  51. package/lib/node/blocks/image/image.cjs +3 -3
  52. package/lib/node/blocks/image/image.mjs +8 -8
  53. package/lib/node/blocks/text/text.cjs +1 -1
  54. package/lib/node/blocks/text/text.mjs +6 -24
  55. package/lib/node/components/awaiter.cjs +1 -1
  56. package/lib/node/components/block/block.cjs +1 -1
  57. package/lib/node/components/block/block.mjs +27 -28
  58. package/lib/node/components/blocks/blocks-wrapper.cjs +1 -1
  59. package/lib/node/components/blocks/blocks-wrapper.mjs +2 -2
  60. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  61. package/lib/node/components/content/components/enable-editor.mjs +102 -96
  62. package/lib/node/constants/sdk-version.cjs +1 -1
  63. package/lib/node/constants/sdk-version.mjs +1 -1
  64. package/lib/node/functions/get-block-component-options.cjs +1 -1
  65. package/lib/node/functions/get-block-component-options.mjs +21 -5
  66. package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
  67. package/lib/node/functions/get-content/generate-content-url.mjs +60 -40
  68. package/lib/node/functions/get-processed-block.cjs +1 -1
  69. package/lib/node/functions/get-processed-block.mjs +18 -19
  70. package/lib/node/helpers/flatten.cjs +1 -1
  71. package/lib/node/helpers/flatten.mjs +28 -15
  72. package/package.json +1 -1
  73. package/types/cjs/constants/sdk-version.d.ts +1 -1
  74. package/types/cjs/functions/get-block-component-options.d.ts +2 -1
  75. package/types/cjs/functions/get-processed-block.d.ts +1 -6
  76. package/types/cjs/helpers/flatten.d.ts +6 -0
  77. package/types/cjs/server-index.d.ts +1 -1
  78. package/types/cjs/types/builder-content.d.ts +1 -0
  79. package/types/cjs/types/input.d.ts +10 -0
  80. package/types/esm/constants/sdk-version.d.ts +1 -1
  81. package/types/esm/functions/get-block-component-options.d.ts +2 -1
  82. package/types/esm/functions/get-processed-block.d.ts +1 -6
  83. package/types/esm/helpers/flatten.d.ts +6 -0
  84. package/types/esm/server-index.d.ts +1 -1
  85. package/types/esm/types/builder-content.d.ts +1 -0
  86. package/types/esm/types/input.d.ts +10 -0
@@ -1,23 +1,36 @@
1
- function s(r, l = null, n = ".") {
2
- return Object.keys(r).reduce((o, e) => {
3
- const t = r[e], i = [l, e].filter(Boolean).join(n);
4
- return [typeof t == "object", t !== null, !(Array.isArray(t) && t.length === 0)].every(Boolean) ? {
5
- ...o,
6
- ...s(t, i, n)
1
+ function c(l, s = null, o = ".") {
2
+ return Object.keys(l).reduce((n, t) => {
3
+ const e = l[t], r = [s, t].filter(Boolean).join(o);
4
+ return [typeof e == "object", e !== null, !(Array.isArray(e) && e.length === 0)].every(Boolean) ? {
5
+ ...n,
6
+ ...c(e, r, o)
7
7
  } : {
8
- ...o,
9
- [i]: t
8
+ ...n,
9
+ [r]: e
10
10
  };
11
11
  }, {});
12
12
  }
13
- function c(r, l, n = {}) {
14
- for (const o in r) {
15
- const e = r[o], t = l ? l + "." + o : o;
16
- e && typeof e == "object" && !Array.isArray(e) && !Object.keys(e).find((i) => i.startsWith("$")) ? c(e, t, n) : n[t] = e;
13
+ function i(l, s, o = {}) {
14
+ for (const n in l) {
15
+ const t = l[n], e = s ? s + "." + n : n;
16
+ t && typeof t == "object" && !Array.isArray(t) && !Object.keys(t).find((r) => r.startsWith("$")) ? i(t, e, o) : o[e] = t;
17
17
  }
18
- return n;
18
+ return o;
19
+ }
20
+ function u(l) {
21
+ const s = {};
22
+ for (const o in l) {
23
+ const n = o.split(".");
24
+ let t = s;
25
+ for (let e = 0; e < n.length; e++) {
26
+ const r = n[e];
27
+ e === n.length - 1 ? t[r] = l[o] : (t[r] = t[r] || {}, t = t[r]);
28
+ }
29
+ }
30
+ return s;
19
31
  }
20
32
  export {
21
- s as flatten,
22
- c as flattenMongoQuery
33
+ c as flatten,
34
+ i as flattenMongoQuery,
35
+ u as unflatten
23
36
  };
@@ -1,4 +1,4 @@
1
- "use strict";const o=require("react/jsx-runtime"),W=require("../../components/blocks/blocks.cjs"),j=require("../../components/dynamic-renderer/dynamic-renderer.cjs"),q=require("../../components/inlined-styles.cjs"),z=require("../../constants/device-sizes.cjs"),B=require("../../functions/get-class-prop-name.cjs"),p=require("../../functions/get-style.cjs"),A=require("./helpers.cjs");function N(e){var g,f;const a=function(){return typeof e.space=="number"?e.space||0:20},s=function(){return e.columns||[]},u=function(){return e.stackColumnsAt||"tablet"},y=function(t){return t.link?e.builderLinkComponent||"a":"div"},S=function(t){var i;return((i=s()[t])==null?void 0:i.width)||100/s().length},x=function(t){const i=S(t),l=a()*(s().length-1)*(i/100);return`calc(${i}% - ${l}px)`},c=function({stackedStyle:t,desktopStyle:i}){return u()==="tablet"?t:i},m=function({stackedStyle:t,desktopStyle:i}){return u()==="never"?i:t},d=function(){return e.stackColumnsAt==="never"?"row":e.reverseColumnsWhenStacked?"column-reverse":"column"},C=function(){return{"--flex-dir":d(),"--flex-dir-tablet":c({stackedStyle:d(),desktopStyle:"row"})}},v=function(t){const i=t===0?0:a(),l=x(t),r=`${i}px`,k="100%",h=0;return{...{display:"flex",flexDirection:"column",alignItems:"stretch"},width:l,["marginLeft"]:r,"--column-width-mobile":m({stackedStyle:k,desktopStyle:l}),"--column-margin-left-mobile":m({stackedStyle:h,desktopStyle:r}),"--column-width-tablet":c({stackedStyle:k,desktopStyle:l}),"--column-margin-left-tablet":c({stackedStyle:h,desktopStyle:r})}},b=function(t){var l,r;return z.getSizesForBreakpoints(((r=(l=e.builderContext.content)==null?void 0:l.meta)==null?void 0:r.breakpoints)||{})[t].max},w=function(){const t=`.${e.builderBlock.id}-breakpoints > .builder-column`;return`
1
+ "use strict";const o=require("react/jsx-runtime"),W=require("../../components/blocks/blocks.cjs"),j=require("../../components/dynamic-renderer/dynamic-renderer.cjs"),q=require("../../components/inlined-styles.cjs"),z=require("../../constants/device-sizes.cjs"),B=require("../../functions/get-class-prop-name.cjs"),p=require("../../functions/get-style.cjs"),A=require("./helpers.cjs");function N(e){var g,f;const a=function(){return typeof e.space=="number"?e.space||0:20},s=function(){return e.columns||[]},u=function(){return e.stackColumnsAt||"tablet"},y=function(t){return t.link?e.builderLinkComponent||"a":"div"},S=function(t){var i;return((i=s()[t])==null?void 0:i.width)||100/s().length},x=function(t){const i=S(t),l=a()*(s().length-1)*(i/100);return`calc(${i}% - ${l}px)`},c=function({stackedStyle:t,desktopStyle:i}){return u()==="tablet"?t:i},d=function({stackedStyle:t,desktopStyle:i}){return u()==="never"?i:t},m=function(){return e.stackColumnsAt==="never"?"row":e.reverseColumnsWhenStacked?"column-reverse":"column"},C=function(){return{"--flex-dir":m(),"--flex-dir-tablet":c({stackedStyle:m(),desktopStyle:"row"})}},v=function(t){const i=t===0?0:a(),l=x(t),r=`${i}px`,k="100%",h=0;return{...{display:"flex",flexDirection:"column",alignItems:"stretch"},width:l,["marginLeft"]:r,"--column-width-mobile":d({stackedStyle:k,desktopStyle:l}),"--column-margin-left-mobile":d({stackedStyle:h,desktopStyle:r}),"--column-width-tablet":c({stackedStyle:k,desktopStyle:l}),"--column-margin-left-tablet":c({stackedStyle:h,desktopStyle:r})}},b=function(t){var l,r;return z.getSizesForBreakpoints(((r=(l=e.builderContext.content)==null?void 0:l.meta)==null?void 0:r.breakpoints)||{})[t].max},w=function(){const t=`.${e.builderBlock.id}-breakpoints > .builder-column`;return`
2
2
  @media (max-width: ${b("medium")}px) {
3
3
  .${e.builderBlock.id}-breakpoints {
4
4
  flex-direction: var(--flex-dir-tablet);
@@ -22,7 +22,7 @@
22
22
  margin-left: var(--column-margin-left-mobile) !important;
23
23
  }
24
24
  },
25
- `},$=function(t,i){return{...t.link?{href:t.link}:{},[B.getClassPropName()]:"builder-column",style:p.mapStyleObjToStrIfNeeded(v(i))}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:A.getColumnsClass((g=e.builderBlock)==null?void 0:g.id)+" div-6e395700",style:C(),children:[o.jsx(q,{id:"builderio-columns",styles:w(),nonce:e.builderContext.nonce}),(f=e.columns)==null?void 0:f.map((n,t)=>o.jsx(j,{TagName:y(n),actionAttributes:{},attributes:$(n,t),children:o.jsx(W,{path:`columns.${t}.blocks`,parent:e.builderBlock.id,styleProp:{flexGrow:"1"},context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent,blocks:n.blocks})},t))]}),o.jsx("style",{children:`.div-6e395700 {
25
+ `},$=function(t,i){return{...t.link?{href:t.link}:{},[B.getClassPropName()]:"builder-column",style:p.mapStyleObjToStrIfNeeded(v(i))}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:A.getColumnsClass((g=e.builderBlock)==null?void 0:g.id)+" div-035056da",style:C(),children:[o.jsx(q,{id:"builderio-columns",styles:w(),nonce:e.builderContext.nonce}),(f=e.columns)==null?void 0:f.map((n,t)=>o.jsx(j,{TagName:y(n),actionAttributes:{},attributes:$(n,t),children:o.jsx(W,{path:`columns.${t}.blocks`,parent:e.builderBlock.id,styleProp:{flexGrow:"1"},context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent,blocks:n.blocks})},t))]}),o.jsx("style",{children:`.div-035056da {
26
26
  display: flex;
27
27
  line-height: normal;
28
28
  }`})]})}module.exports=N;
@@ -114,7 +114,7 @@ function q(e) {
114
114
  /* @__PURE__ */ y(
115
115
  "div",
116
116
  {
117
- className: D((b = e.builderBlock) == null ? void 0 : b.id) + " div-6e395700",
117
+ className: D((b = e.builderBlock) == null ? void 0 : b.id) + " div-035056da",
118
118
  style: v(),
119
119
  children: [
120
120
  /* @__PURE__ */ r(
@@ -151,7 +151,7 @@ function q(e) {
151
151
  ]
152
152
  }
153
153
  ),
154
- /* @__PURE__ */ r("style", { children: `.div-6e395700 {
154
+ /* @__PURE__ */ r("style", { children: `.div-035056da {
155
155
  display: flex;
156
156
  line-height: normal;
157
157
  }` })
@@ -1,11 +1,11 @@
1
- "use client";"use strict";const t=require("react/jsx-runtime"),m=require("react"),l=require("./image.helpers.cjs");function b(e){var s,r,u,o,d,g;function n(){var f;const i=e.image||e.src;if(!i||!(typeof i=="string"&&(i.match(/builder\.io/)||i.match(/cdn\.shopify\.com/))))return e.srcset;if(!e.noWebp){if(e.srcset&&((f=e.image)!=null&&f.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),l.getSrcSet(i)}else if(e.image&&!e.srcset)return l.getSrcSet(i);return l.getSrcSet(i)}}function a(){var c;return(c=n==null?void 0:n())!=null&&c.match(/builder\.io/)&&!e.noWebp?n().replace(/\?/g,"?format=webp&"):""}function h(){const c={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?c:void 0}return m.useEffect(()=>{},[]),t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[a()?t.jsx("source",{type:"image/webp",srcSet:a()}):null,t.jsx("img",{loading:e.highPriority?"eager":"lazy",fetchPriority:e.highPriority?"high":"auto",alt:e.altText,role:e.altText?void 0:"presentation",style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...h()},className:"builder-image"+(e.className?" "+e.className:"")+" img-c071ff08",src:e.image,srcSet:n(),sizes:e.sizes})]}),e.aspectRatio&&!((r=(s=e.builderBlock)==null?void 0:s.children)!=null&&r.length&&e.fitContent)?t.jsx("div",{className:"builder-image-sizer div-c071ff08",style:{paddingTop:e.aspectRatio*100+"%"}}):null,(o=(u=e.builderBlock)==null?void 0:u.children)!=null&&o.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&((g=(d=e.builderBlock)==null?void 0:d.children)!=null&&g.length)?t.jsx("div",{className:"div-c071ff08-2",children:e.children}):null]}),t.jsx("style",{children:`.img-c071ff08 {
1
+ "use client";"use strict";const t=require("react/jsx-runtime"),f=require("react"),l=require("./image.helpers.cjs");function b(e){var s,r,u,o,d,g;function n(){var h;const i=e.image||e.src;if(!i||!(typeof i=="string"&&(i.match(/builder\.io/)||i.match(/cdn\.shopify\.com/))))return e.srcset;if(!e.noWebp){if(e.srcset&&((h=e.image)!=null&&h.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),l.getSrcSet(i)}else if(e.image&&!e.srcset)return l.getSrcSet(i);return l.getSrcSet(i)}}function a(){var c;return(c=n==null?void 0:n())!=null&&c.match(/builder\.io/)&&!e.noWebp?n().replace(/\?/g,"?format=webp&"):""}function m(){const c={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?c:void 0}return f.useEffect(()=>{},[]),t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[a()?t.jsx("source",{type:"image/webp",srcSet:a()}):null,t.jsx("img",{loading:e.highPriority?"eager":"lazy",fetchPriority:e.highPriority?"high":"auto",alt:e.altText,role:e.altText?void 0:"presentation",style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...m()},className:"builder-image"+(e.className?" "+e.className:"")+" img-5e5f3633",src:e.image,srcSet:n(),sizes:e.sizes})]}),e.aspectRatio&&!((r=(s=e.builderBlock)==null?void 0:s.children)!=null&&r.length&&e.fitContent)?t.jsx("div",{className:"builder-image-sizer div-5e5f3633",style:{paddingTop:e.aspectRatio*100+"%"}}):null,(o=(u=e.builderBlock)==null?void 0:u.children)!=null&&o.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&((g=(d=e.builderBlock)==null?void 0:d.children)!=null&&g.length)?t.jsx("div",{className:"div-5e5f3633-2",children:e.children}):null]}),t.jsx("style",{children:`.img-5e5f3633 {
2
2
  opacity: 1;
3
3
  transition: opacity 0.2s ease-in-out;
4
- }.div-c071ff08 {
4
+ }.div-5e5f3633 {
5
5
  width: 100%;
6
6
  pointer-events: none;
7
7
  font-size: 0;
8
- }.div-c071ff08-2 {
8
+ }.div-5e5f3633-2 {
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
  align-items: stretch;
@@ -3,7 +3,7 @@ import { jsxs as l, Fragment as a, jsx as t } from "react/jsx-runtime";
3
3
  import { useEffect as v } from "react";
4
4
  import { getSrcSet as o } from "./image.helpers.mjs";
5
5
  function w(e) {
6
- var d, s, u, f, g, m;
6
+ var d, s, u, g, m, f;
7
7
  function n() {
8
8
  var h;
9
9
  const i = e.image || e.src;
@@ -51,7 +51,7 @@ function w(e) {
51
51
  objectFit: e.backgroundSize || "cover",
52
52
  ...b()
53
53
  },
54
- className: "builder-image" + (e.className ? " " + e.className : "") + " img-c071ff08",
54
+ className: "builder-image" + (e.className ? " " + e.className : "") + " img-5e5f3633",
55
55
  src: e.image,
56
56
  srcSet: n(),
57
57
  sizes: e.sizes
@@ -61,23 +61,23 @@ function w(e) {
61
61
  e.aspectRatio && !((s = (d = e.builderBlock) == null ? void 0 : d.children) != null && s.length && e.fitContent) ? /* @__PURE__ */ t(
62
62
  "div",
63
63
  {
64
- className: "builder-image-sizer div-c071ff08",
64
+ className: "builder-image-sizer div-5e5f3633",
65
65
  style: {
66
66
  paddingTop: e.aspectRatio * 100 + "%"
67
67
  }
68
68
  }
69
69
  ) : null,
70
- (f = (u = e.builderBlock) == null ? void 0 : u.children) != null && f.length && e.fitContent ? /* @__PURE__ */ t(a, { children: e.children }) : null,
71
- !e.fitContent && ((m = (g = e.builderBlock) == null ? void 0 : g.children) != null && m.length) ? /* @__PURE__ */ t("div", { className: "div-c071ff08-2", children: e.children }) : null
70
+ (g = (u = e.builderBlock) == null ? void 0 : u.children) != null && g.length && e.fitContent ? /* @__PURE__ */ t(a, { children: e.children }) : null,
71
+ !e.fitContent && ((f = (m = e.builderBlock) == null ? void 0 : m.children) != null && f.length) ? /* @__PURE__ */ t("div", { className: "div-5e5f3633-2", children: e.children }) : null
72
72
  ] }),
73
- /* @__PURE__ */ t("style", { children: `.img-c071ff08 {
73
+ /* @__PURE__ */ t("style", { children: `.img-5e5f3633 {
74
74
  opacity: 1;
75
75
  transition: opacity 0.2s ease-in-out;
76
- }.div-c071ff08 {
76
+ }.div-5e5f3633 {
77
77
  width: 100%;
78
78
  pointer-events: none;
79
79
  font-size: 0;
80
- }.div-c071ff08-2 {
80
+ }.div-5e5f3633-2 {
81
81
  display: flex;
82
82
  flex-direction: column;
83
83
  align-items: stretch;
@@ -1 +1 @@
1
- "use strict";const a=require("react/jsx-runtime"),i=require("../../functions/evaluate/evaluate.cjs");function l(t){const n=function(){var e;const o=t.builderContext,{context:r,localState:c,rootState:s,rootSetState:u}=o;return String(((e=t.text)==null?void 0:e.toString())||"").replace(/{{([^}]+)}}/g,(S,x)=>i.evaluate({code:x,context:r,localState:c,rootState:s,rootSetState:u}))};return a.jsx("div",{className:"builder-text",dangerouslySetInnerHTML:{__html:n()},style:{outline:"none"}})}module.exports=l;
1
+ "use strict";const n=require("react/jsx-runtime");function r(e){var t;return n.jsx("div",{className:"builder-text",dangerouslySetInnerHTML:{__html:((t=e.text)==null?void 0:t.toString())||""},style:{outline:"none"}})}module.exports=r;
@@ -1,29 +1,11 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { evaluate as l } from "../../functions/evaluate/evaluate.mjs";
3
- function f(t) {
4
- return /* @__PURE__ */ a(
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ function o(e) {
3
+ var t;
4
+ return /* @__PURE__ */ n(
5
5
  "div",
6
6
  {
7
7
  className: "builder-text",
8
- dangerouslySetInnerHTML: { __html: function() {
9
- var e;
10
- const o = t.builderContext, {
11
- context: n,
12
- localState: r,
13
- rootState: c,
14
- rootSetState: s
15
- } = o;
16
- return String(((e = t.text) == null ? void 0 : e.toString()) || "").replace(
17
- /{{([^}]+)}}/g,
18
- (d, x) => l({
19
- code: x,
20
- context: n,
21
- localState: r,
22
- rootState: c,
23
- rootSetState: s
24
- })
25
- );
26
- }() },
8
+ dangerouslySetInnerHTML: { __html: ((t = e.text) == null ? void 0 : t.toString()) || "" },
27
9
  style: {
28
10
  outline: "none"
29
11
  }
@@ -31,5 +13,5 @@ function f(t) {
31
13
  );
32
14
  }
33
15
  export {
34
- f as default
16
+ o as default
35
17
  };
@@ -1 +1 @@
1
- "use client";"use strict";const e=require("react/jsx-runtime"),t=require("react");function n(r){return t.useEffect(()=>{},[]),e.jsx(e.Fragment,{children:r.children})}module.exports=n;
1
+ "use client";"use strict";const e=require("react/jsx-runtime"),r=require("react");function n(t){return r.useEffect(()=>{},[]),e.jsx(e.Fragment,{children:t.children})}module.exports=n;
@@ -1 +1 @@
1
- "use strict";const t=require("react/jsx-runtime"),R=require("../../constants/target.cjs"),S=require("../../functions/get-block-component-options.cjs"),j=require("../../functions/get-processed-block.cjs"),P=require("../../functions/is-previewing.cjs");require("../../functions/get-fetch.cjs");const u=require("./block.helpers.cjs"),q=require("./components/block-styles.cjs"),O=require("./components/block-wrapper.cjs"),p=require("./components/component-ref/component-ref.cjs"),g=require("./components/repeated-block.cjs");function b(e){var a,C,x,h;const d=function(){return u.getRepeatItemData({block:e.block,context:e.context})},m={value:null,update:!1},c=function(){var i;if(m.value&&!m.update&&!P.isPreviewing())return m.value;const r=(i=e.block.repeat)!=null&&i.collection?e.block:j.getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0});return m.value=r,m.update=!1,r},l=function(){return u.getComponent({block:c(),registeredComponents:e.registeredComponents,model:e.context.model})},f=function(){var i;return e.block.tagName==="a"||((i=c().properties)==null?void 0:i.href)||c().href?e.linkComponent||"a":e.block.tagName||"div"},B=function(){var s,k;if((s=e.block.repeat)!=null&&s.collection)return!!((k=d())!=null&&k.length);const r="hide"in c()?c().hide:!1;return("show"in c()?c().show:!0)&&!r},v=function(){var i,s;return!((i=l())!=null&&i.component)&&!d()?(s=c().children)!=null?s:[]:[]},n=function(){var r,i,s,k;return{blockChildren:(r=c().children)!=null?r:[],componentRef:(i=l())==null?void 0:i.component,componentOptions:{...S.getBlockComponentOptions(c()),...u.provideBuilderBlock(l(),c()),...u.provideBuilderContext(l(),e.context),...u.provideLinkComponent(l(),e.linkComponent),...u.provideRegisteredComponents(l(),e.registeredComponents,e.context.model)},context:e.context,linkComponent:e.linkComponent,registeredComponents:e.registeredComponents,builderBlock:c(),includeBlockProps:((s=l())==null?void 0:s.noWrap)===!0,isInteractive:!((k=l())!=null&&k.isRSC&&R.TARGET==="rsc")}};return t.jsx(t.Fragment,{children:B()?t.jsxs(t.Fragment,{children:[t.jsx(q,{block:c(),context:e.context}),(a=l())!=null&&a.noWrap?d()?t.jsx(t.Fragment,{children:(h=d())==null?void 0:h.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}):t.jsx(t.Fragment,{children:d()?t.jsx(t.Fragment,{children:(x=d())==null?void 0:x.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsxs(O,{Wrapper:f(),block:c(),context:e.context,children:[t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}),(C=v())==null?void 0:C.map(o=>t.jsx(b,{block:o,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent,context:e.context},o.id))]})})]}):null})}module.exports=b;
1
+ "use strict";const t=require("react/jsx-runtime"),v=require("../../constants/target.cjs"),S=require("../../functions/get-block-component-options.cjs"),j=require("../../functions/get-processed-block.cjs"),P=require("../../functions/is-previewing.cjs");require("../../functions/get-fetch.cjs");const m=require("./block.helpers.cjs"),q=require("./components/block-styles.cjs"),O=require("./components/block-wrapper.cjs"),p=require("./components/component-ref/component-ref.cjs"),g=require("./components/repeated-block.cjs");function b(e){var a,C,x,h;const d=function(){return m.getRepeatItemData({block:e.block,context:e.context})},u={value:null,update:!1},c=function(){var i;if(u.value&&!u.update&&!P.isPreviewing())return u.value;const r=(i=e.block.repeat)!=null&&i.collection?e.block:j.getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context});return u.value=r,u.update=!1,r},l=function(){return m.getComponent({block:c(),registeredComponents:e.registeredComponents,model:e.context.model})},f=function(){var i;return e.block.tagName==="a"||((i=c().properties)==null?void 0:i.href)||c().href?e.linkComponent||"a":e.block.tagName||"div"},B=function(){var s,k;if((s=e.block.repeat)!=null&&s.collection)return!!((k=d())!=null&&k.length);const r="hide"in c()?c().hide:!1;return("show"in c()?c().show:!0)&&!r},R=function(){var i,s;return!((i=l())!=null&&i.component)&&!d()?(s=c().children)!=null?s:[]:[]},n=function(){var r,i,s,k;return{blockChildren:(r=c().children)!=null?r:[],componentRef:(i=l())==null?void 0:i.component,componentOptions:{...S.getBlockComponentOptions(c(),e.context),...m.provideBuilderBlock(l(),c()),...m.provideBuilderContext(l(),e.context),...m.provideLinkComponent(l(),e.linkComponent),...m.provideRegisteredComponents(l(),e.registeredComponents,e.context.model)},context:e.context,linkComponent:e.linkComponent,registeredComponents:e.registeredComponents,builderBlock:c(),includeBlockProps:((s=l())==null?void 0:s.noWrap)===!0,isInteractive:!((k=l())!=null&&k.isRSC&&v.TARGET==="rsc")}};return t.jsx(t.Fragment,{children:B()?t.jsxs(t.Fragment,{children:[t.jsx(q,{block:c(),context:e.context}),(a=l())!=null&&a.noWrap?d()?t.jsx(t.Fragment,{children:(h=d())==null?void 0:h.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}):t.jsx(t.Fragment,{children:d()?t.jsx(t.Fragment,{children:(x=d())==null?void 0:x.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsxs(O,{Wrapper:f(),block:c(),context:e.context,children:[t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}),(C=R())==null?void 0:C.map(o=>t.jsx(b,{block:o,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent,context:e.context},o.id))]})})]}):null})}module.exports=b;
@@ -6,10 +6,10 @@ import { isPreviewing as I } from "../../functions/is-previewing.mjs";
6
6
  import "../../functions/get-fetch.mjs";
7
7
  import { getRepeatItemData as O, getComponent as w, provideBuilderBlock as W, provideBuilderContext as T, provideLinkComponent as L, provideRegisteredComponents as U } from "./block.helpers.mjs";
8
8
  import j from "./components/block-styles.mjs";
9
- import E from "./components/block-wrapper.mjs";
9
+ import N from "./components/block-wrapper.mjs";
10
10
  import x from "./components/component-ref/component-ref.mjs";
11
11
  import b from "./components/repeated-block.mjs";
12
- function N(e) {
12
+ function y(e) {
13
13
  var a, C, p, f;
14
14
  const d = function() {
15
15
  return O({
@@ -19,7 +19,7 @@ function N(e) {
19
19
  }, s = {
20
20
  value: null,
21
21
  update: !1
22
- }, t = function() {
22
+ }, n = function() {
23
23
  var i;
24
24
  if (s.value && !s.update && !I())
25
25
  return s.value;
@@ -28,36 +28,35 @@ function N(e) {
28
28
  localState: e.context.localState,
29
29
  rootState: e.context.rootState,
30
30
  rootSetState: e.context.rootSetState,
31
- context: e.context.context,
32
- shouldEvaluateBindings: !0
31
+ context: e.context.context
33
32
  });
34
33
  return s.value = c, s.update = !1, c;
35
34
  }, r = function() {
36
35
  return w({
37
- block: t(),
36
+ block: n(),
38
37
  registeredComponents: e.registeredComponents,
39
38
  model: e.context.model
40
39
  });
41
40
  }, g = function() {
42
41
  var i;
43
- return e.block.tagName === "a" || ((i = t().properties) == null ? void 0 : i.href) || t().href ? e.linkComponent || "a" : e.block.tagName || "div";
42
+ return e.block.tagName === "a" || ((i = n().properties) == null ? void 0 : i.href) || n().href ? e.linkComponent || "a" : e.block.tagName || "div";
44
43
  }, B = function() {
45
44
  var m, k;
46
45
  if ((m = e.block.repeat) != null && m.collection)
47
46
  return !!((k = d()) != null && k.length);
48
- const c = "hide" in t() ? t().hide : !1;
49
- return ("show" in t() ? t().show : !0) && !c;
47
+ const c = "hide" in n() ? n().hide : !1;
48
+ return ("show" in n() ? n().show : !0) && !c;
50
49
  }, R = function() {
51
50
  var i, m;
52
- return !((i = r()) != null && i.component) && !d() ? (m = t().children) != null ? m : [] : [];
51
+ return !((i = r()) != null && i.component) && !d() ? (m = n().children) != null ? m : [] : [];
53
52
  }, o = function() {
54
53
  var c, i, m, k;
55
54
  return {
56
- blockChildren: (c = t().children) != null ? c : [],
55
+ blockChildren: (c = n().children) != null ? c : [],
57
56
  componentRef: (i = r()) == null ? void 0 : i.component,
58
57
  componentOptions: {
59
- ...S(t()),
60
- ...W(r(), t()),
58
+ ...S(n(), e.context),
59
+ ...W(r(), n()),
61
60
  ...T(r(), e.context),
62
61
  ...L(r(), e.linkComponent),
63
62
  ...U(
@@ -69,18 +68,18 @@ function N(e) {
69
68
  context: e.context,
70
69
  linkComponent: e.linkComponent,
71
70
  registeredComponents: e.registeredComponents,
72
- builderBlock: t(),
71
+ builderBlock: n(),
73
72
  includeBlockProps: ((m = r()) == null ? void 0 : m.noWrap) === !0,
74
73
  isInteractive: !((k = r()) != null && k.isRSC && v === "rsc")
75
74
  };
76
75
  };
77
76
  return /* @__PURE__ */ l(u, { children: B() ? /* @__PURE__ */ h(u, { children: [
78
- /* @__PURE__ */ l(j, { block: t(), context: e.context }),
79
- (a = r()) != null && a.noWrap ? d() ? /* @__PURE__ */ l(u, { children: (f = d()) == null ? void 0 : f.map((n, c) => /* @__PURE__ */ l(
77
+ /* @__PURE__ */ l(j, { block: n(), context: e.context }),
78
+ (a = r()) != null && a.noWrap ? d() ? /* @__PURE__ */ l(u, { children: (f = d()) == null ? void 0 : f.map((t, c) => /* @__PURE__ */ l(
80
79
  b,
81
80
  {
82
- repeatContext: n.context,
83
- block: n.block,
81
+ repeatContext: t.context,
82
+ block: t.block,
84
83
  registeredComponents: e.registeredComponents,
85
84
  linkComponent: e.linkComponent
86
85
  },
@@ -98,20 +97,20 @@ function N(e) {
98
97
  includeBlockProps: o().includeBlockProps,
99
98
  isInteractive: o().isInteractive
100
99
  }
101
- ) : /* @__PURE__ */ l(u, { children: d() ? /* @__PURE__ */ l(u, { children: (p = d()) == null ? void 0 : p.map((n, c) => /* @__PURE__ */ l(
100
+ ) : /* @__PURE__ */ l(u, { children: d() ? /* @__PURE__ */ l(u, { children: (p = d()) == null ? void 0 : p.map((t, c) => /* @__PURE__ */ l(
102
101
  b,
103
102
  {
104
- repeatContext: n.context,
105
- block: n.block,
103
+ repeatContext: t.context,
104
+ block: t.block,
106
105
  registeredComponents: e.registeredComponents,
107
106
  linkComponent: e.linkComponent
108
107
  },
109
108
  c
110
109
  )) }) : /* @__PURE__ */ h(
111
- E,
110
+ N,
112
111
  {
113
112
  Wrapper: g(),
114
- block: t(),
113
+ block: n(),
115
114
  context: e.context,
116
115
  children: [
117
116
  /* @__PURE__ */ l(
@@ -128,15 +127,15 @@ function N(e) {
128
127
  isInteractive: o().isInteractive
129
128
  }
130
129
  ),
131
- (C = R()) == null ? void 0 : C.map((n) => /* @__PURE__ */ l(
132
- N,
130
+ (C = R()) == null ? void 0 : C.map((t) => /* @__PURE__ */ l(
131
+ y,
133
132
  {
134
- block: n,
133
+ block: t,
135
134
  registeredComponents: e.registeredComponents,
136
135
  linkComponent: e.linkComponent,
137
136
  context: e.context
138
137
  },
139
- n.id
138
+ t.id
140
139
  ))
141
140
  ]
142
141
  }
@@ -144,5 +143,5 @@ function N(e) {
144
143
  ] }) : null });
145
144
  }
146
145
  export {
147
- N as default
146
+ y as default
148
147
  };
@@ -1,4 +1,4 @@
1
- "use client";"use strict";const a=require("react/jsx-runtime"),l=require("react"),s=require("../../functions/is-editing.cjs");function d(e){const c=l.useRef(null);function o(){var t;return["builder-blocks",(t=e.blocks)!=null&&t.length?"":"no-blocks",e.classNameProp].filter(Boolean).join(" ")}function i(){if(!e.path)return;const t="component.options.";return e.path.startsWith(t)?e.path:`${t}${e.path||""}`}function r(){var t,n;s.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:i()}},"*"))}function u(){var t,n;s.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:i()}},"*"))}return l.useEffect(()=>{},[]),a.jsxs(a.Fragment,{children:[a.jsx(e.BlocksWrapper,{ref:c,className:o()+" props-blocks-wrapper-215a41e0","builder-path":i(),"builder-parent-id":e.parent,style:e.styleProp,onClick:t=>r(),onMouseEnter:t=>u(),onKeyPress:t=>r(),...e.BlocksWrapperProps,children:e.children}),a.jsx("style",{children:`.props-blocks-wrapper-215a41e0 {
1
+ "use client";"use strict";const i=require("react/jsx-runtime"),l=require("react"),s=require("../../functions/is-editing.cjs");function d(e){const c=l.useRef(null);function o(){var t;return["builder-blocks",(t=e.blocks)!=null&&t.length?"":"no-blocks",e.classNameProp].filter(Boolean).join(" ")}function a(){if(!e.path)return;const t="component.options.";return e.path.startsWith(t)?e.path:`${t}${e.path||""}`}function r(){var t,n;s.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:a()}},"*"))}function u(){var t,n;s.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:a()}},"*"))}return l.useEffect(()=>{},[]),i.jsxs(i.Fragment,{children:[i.jsx(e.BlocksWrapper,{ref:c,className:o()+" props-blocks-wrapper-754e6138","builder-path":a(),"builder-parent-id":e.parent,style:e.styleProp,onClick:t=>r(),onMouseEnter:t=>u(),onKeyPress:t=>r(),...e.BlocksWrapperProps,children:e.children}),i.jsx("style",{children:`.props-blocks-wrapper-754e6138 {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  align-items: stretch;
@@ -50,7 +50,7 @@ function b(e) {
50
50
  e.BlocksWrapper,
51
51
  {
52
52
  ref: o,
53
- className: c() + " props-blocks-wrapper-215a41e0",
53
+ className: c() + " props-blocks-wrapper-754e6138",
54
54
  "builder-path": a(),
55
55
  "builder-parent-id": e.parent,
56
56
  style: e.styleProp,
@@ -61,7 +61,7 @@ function b(e) {
61
61
  children: e.children
62
62
  }
63
63
  ),
64
- /* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-215a41e0 {
64
+ /* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-754e6138 {
65
65
  display: flex;
66
66
  flex-direction: column;
67
67
  align-items: stretch;
@@ -1 +1 @@
1
- "use client";"use strict";const R=require("react/jsx-runtime"),o=require("react"),M=require("../../../context/builder.context.cjs"),N=require("../../../functions/evaluate/evaluate.cjs"),W=require("../../../functions/fast-clone.cjs"),A=require("../../../functions/get-content/index.cjs"),k=require("../../../functions/is-browser.cjs"),g=require("../../../functions/is-editing.cjs"),B=require("../../../functions/is-previewing.cjs"),U=require("../../../functions/log-fetch.cjs"),O=require("../../../functions/register-component.cjs"),P=require("../../../functions/track/index.cjs"),$=require("../../../functions/track/interaction.cjs"),y=require("../../../helpers/canTrack.cjs"),z=require("../../../helpers/preview-lru-cache/set.cjs"),G=require("../../../helpers/subscribe-to-editor.cjs"),H=require("../../../scripts/init-editing.cjs"),J=require("../../block/animator.cjs"),L=require("./enable-editor.helpers.cjs"),Q=require("./styles.helpers.cjs"),X=require("next/navigation");function Y(e){var q,w,I;const d=o.useRef(null);function f(n){var r,i;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(i=(r=e.builderContextSignal).rootSetState)==null||i.call(r,t):e.builderContextSignal.rootState=t}function m(n){var r,i,a,c,s;const t={...e.builderContextSignal.content,...n,data:{...(r=e.builderContextSignal.content)==null?void 0:r.data,...n==null?void 0:n.data},meta:{...(i=e.builderContextSignal.content)==null?void 0:i.meta,...n==null?void 0:n.meta,breakpoints:((a=n==null?void 0:n.meta)==null?void 0:a.breakpoints)||((s=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:s.breakpoints)}};z.postPreviewContent({value:t,key:t.id}).then(()=>{F.refresh()})}function K(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[T,Z]=o.useState(()=>e.contentWrapper||"div");function v(n){return G.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var a;const{breakpoints:r,contentId:i}=t;!i||i!==((a=e.builderContextSignal.content)==null?void 0:a.id)||r&&m({meta:{breakpoints:r}})},animation:t=>{J.triggerAnimation(t)},contentUpdate:t=>{m(t)}}})(n)}const[S,p]=o.useState(()=>({})),[b,ee]=o.useState(()=>({})),[h,_]=o.useState(()=>!1);function j(n){var t,r;if(e.builderContextSignal.content){const i=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,a=(r=e.builderContextSignal.content)==null?void 0:r.id;P._track({apiHost:e.apiHost,type:"click",canTrack:y.getDefaultCanTrack(e.canTrack),contentId:a,apiKey:e.apiKey,variationId:i!==a?i:void 0,...$.getInteractionPropertiesForEvent(n),unique:!h})}h||_(!0)}function D(){var t,r,i;const n=(i=(r=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:r.httpRequests)!=null?i:{};Object.entries(n).forEach(([a,c])=>{if(!c||b[a]||S[a]&&!g.isEditing())return;b[a]=!0;const s=c.replace(/{{([^}]+)}}/g,(l,V)=>String(N.evaluate({code:V,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));U.logFetch(s),fetch(s).then(l=>l.json()).then(l=>{f({[a]:l}),S[a]=!0}).catch(l=>{console.error("error fetching dynamic data",c,l)}).finally(()=>{b[a]=!1})})}function u(){g.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:W.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){window.addEventListener("message",v),H.registerInsertMenu(),H.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(t=>{var r,i;if(!e.model||!((r=t.models)!=null&&r.length)||t.models.includes(e.model)){const a=O.createRegisterComponentMessage(t);(i=window.parent)==null||i.postMessage(a,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",u)}function x(n){const t=new URL(location.href).searchParams,r=t.get("builder.preview"),i=t.get(`builder.overrides.${r}`),a=t.get("apiKey")||t.get("builder.space");r===e.model&&a===e.apiKey&&(!e.content||i===e.content.id)&&A.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(c=>{c&&m(c)})}const F=X.useRouter(),C=o.useRef(!1);return C.current||(D(),u(),C.current=!0),o.useEffect(()=>{var n;return(n=d.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=d.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=d.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=d.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t;if(k.isBrowser()){if(g.isEditing()&&!e.isNestedRender&&d.current&&d.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&y.getDefaultCanTrack(e.canTrack)){const i=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,a=(t=e.builderContextSignal.content)==null?void 0:t.id,c=e.apiKey;P._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:a,apiKey:c,variationId:i!==a?i:void 0})}B.isPreviewing()&&g.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{u()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&f(e.data)},[e.data]),o.useEffect(()=>{e.locale&&f({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{k.isBrowser()&&(window.removeEventListener("message",v),window.removeEventListener("builder:component:stateChangeListenerActivated",u))},[]),R.jsx(M.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||L.needsElementRefDivForEditing()?R.jsx(T,{ref:d,onClick:n=>j(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:Q.getWrapperClassName(((w=e.content)==null?void 0:w.testVariationId)||((I=e.content)==null?void 0:I.id)),style:{display:!e.builderContextSignal.content&&L.needsElementRefDivForEditing()?"none":void 0},...K(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Y;
1
+ "use client";"use strict";const w=require("react/jsx-runtime"),o=require("react"),F=require("../../../context/builder.context.cjs"),V=require("../../../functions/evaluate/evaluate.cjs"),M=require("../../../functions/fast-clone.cjs"),N=require("../../../functions/get-content/index.cjs"),k=require("../../../functions/is-browser.cjs"),g=require("../../../functions/is-editing.cjs"),O=require("../../../functions/is-previewing.cjs"),W=require("../../../functions/log-fetch.cjs"),A=require("../../../functions/register-component.cjs"),y=require("../../../functions/track/index.cjs"),$=require("../../../functions/track/interaction.cjs"),P=require("../../../helpers/canTrack.cjs"),z=require("../../../helpers/preview-lru-cache/set.cjs"),G=require("../../../helpers/subscribe-to-editor.cjs"),L=require("../../../scripts/init-editing.cjs"),J=require("../../block/animator.cjs"),H=require("./enable-editor.helpers.cjs"),Q=require("./styles.helpers.cjs"),X=require("next/navigation");function Y(e){var q,I,R;const l=o.useRef(null);function f(n){var i,a;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(a=(i=e.builderContextSignal).rootSetState)==null||a.call(i,t):e.builderContextSignal.rootState=t}function m(n){var i,a,r,c,d;const t={...e.builderContextSignal.content,...n,data:{...(i=e.builderContextSignal.content)==null?void 0:i.data,...n==null?void 0:n.data},meta:{...(a=e.builderContextSignal.content)==null?void 0:a.meta,...n==null?void 0:n.meta,breakpoints:((r=n==null?void 0:n.meta)==null?void 0:r.breakpoints)||((d=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:d.breakpoints)}};z.postPreviewContent({value:t,key:t.id}).then(()=>{j.refresh()})}function T(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[D,Z]=o.useState(()=>e.contentWrapper||"div");function S(n){return G.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var r;const{breakpoints:i,contentId:a}=t;!a||a!==((r=e.builderContextSignal.content)==null?void 0:r.id)||i&&m({meta:{breakpoints:i}})},animation:t=>{J.triggerAnimation(t)},contentUpdate:t=>{m(t)}}})(n)}const[v,p]=o.useState(()=>({})),[b,ee]=o.useState(()=>({})),[h,K]=o.useState(()=>!1);function _(n){var t,i;if(e.builderContextSignal.content){const a=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,r=(i=e.builderContextSignal.content)==null?void 0:i.id;y._track({apiHost:e.apiHost,type:"click",canTrack:P.getDefaultCanTrack(e.canTrack),contentId:r,apiKey:e.apiKey,variationId:a!==r?a:void 0,...$.getInteractionPropertiesForEvent(n),unique:!h})}h||K(!0)}function U(){var t,i,a;const n=(a=(i=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:i.httpRequests)!=null?a:{};Object.entries(n).forEach(([r,c])=>{if(!c||b[r]||v[r]&&!g.isEditing())return;b[r]=!0;const d=c.replace(/{{([^}]+)}}/g,(s,B)=>String(V.evaluate({code:B,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));W.logFetch(d),fetch(d).then(s=>s.json()).then(s=>{f({[r]:s}),v[r]=!0}).catch(s=>{console.error("error fetching dynamic data",c,s)}).finally(()=>{b[r]=!1})})}function u(){g.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:M.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){window.addEventListener("message",S),L.registerInsertMenu(),L.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(t=>{var i,a;if(!e.model||!((i=t.models)!=null&&i.length)||t.models.includes(e.model)){const r=A.createRegisterComponentMessage(t);(a=window.parent)==null||a.postMessage(r,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",u)}function x(n){var c;const t=new URL(location.href).searchParams,i=t.get("builder.preview"),a=t.get(`builder.overrides.${i}`),r=t.get("apiKey")||t.get("builder.space");(i==="BUILDER_STUDIO"||i===e.model&&r===e.apiKey&&(!e.content||a===e.content.id))&&N.fetchOneEntry({model:e.model||"",apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion,...i==="BUILDER_STUDIO"&&((c=e.context)!=null&&c.symbolId)?{query:{id:e.context.symbolId}}:{}}).then(d=>{d&&m(d)})}const j=X.useRouter(),C=o.useRef(!1);return C.current||(U(),u(),C.current=!0),o.useEffect(()=>{var n;return(n=l.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=l.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=l.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=l.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t;if(k.isBrowser()){if(g.isEditing()&&!e.isNestedRender&&l.current&&l.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&P.getDefaultCanTrack(e.canTrack)){const a=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,r=(t=e.builderContextSignal.content)==null?void 0:t.id,c=e.apiKey;y._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:r,apiKey:c,variationId:a!==r?a:void 0})}O.isPreviewing()&&g.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{u()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&f(e.data)},[e.data]),o.useEffect(()=>{e.locale&&f({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{k.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",u))},[]),w.jsx(F.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||H.needsElementRefDivForEditing()?w.jsx(D,{ref:l,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:Q.getWrapperClassName(((I=e.content)==null?void 0:I.testVariationId)||((R=e.content)==null?void 0:R.id)),style:{display:!e.builderContextSignal.content&&H.needsElementRefDivForEditing()?"none":void 0},...T(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Y;