@builder.io/sdk-solid 4.0.1 → 4.0.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.
@@ -4001,9 +4001,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
4001
4001
  function CustomCode(props) {
4002
4002
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
4003
4003
  const [scriptsRun, setScriptsRun] = createSignal([]);
4004
- let elementRef;
4005
- onMount(() => {
4006
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
4004
+ function runScripts() {
4005
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
4007
4006
  return;
4008
4007
  }
4009
4008
  const scripts = elementRef.getElementsByTagName("script");
@@ -4026,11 +4025,22 @@ function CustomCode(props) {
4026
4025
  scriptsRun().push(script.innerText);
4027
4026
  new Function(script.innerText)();
4028
4027
  } catch (error) {
4029
- console.warn("`CustomCode`: Error running script:", error);
4028
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
4030
4029
  }
4031
4030
  }
4032
4031
  }
4032
+ }
4033
+ let elementRef;
4034
+ onMount(() => {
4035
+ runScripts();
4033
4036
  });
4037
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
4038
+ function onUpdateFn_0() {
4039
+ if (isEditing()) {
4040
+ runScripts();
4041
+ }
4042
+ }
4043
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
4034
4044
  return (() => {
4035
4045
  const _el$ = _tmpl$13();
4036
4046
  const _ref$ = elementRef;
@@ -4094,7 +4104,7 @@ function Embed(props) {
4094
4104
  scriptsRun().push(script.innerText);
4095
4105
  new Function(script.innerText)();
4096
4106
  } catch (error) {
4097
- console.warn("`Embed`: Error running script:", error);
4107
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
4098
4108
  }
4099
4109
  }
4100
4110
  }
@@ -5279,7 +5289,7 @@ function serializeIncludingFunctions(info) {
5279
5289
  }
5280
5290
 
5281
5291
  // src/components/content-variants/inlined-fns.ts
5282
- var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
5292
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
5283
5293
  var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
5284
5294
 
5285
5295
  // src/components/content-variants/helpers.ts
@@ -5308,6 +5318,7 @@ var checkShouldRenderVariants2 = ({
5308
5318
  return true;
5309
5319
  };
5310
5320
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5321
+ var isAngularSDK = TARGET === "angular";
5311
5322
  var isHydrationTarget = getIsHydrationTarget(TARGET);
5312
5323
  var getInitVariantsFnsScriptString = () => `
5313
5324
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -5315,7 +5326,7 @@ var getInitVariantsFnsScriptString = () => `
5315
5326
  `;
5316
5327
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5317
5328
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5318
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5329
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5319
5330
  )`;
5320
5331
  var getUpdateVariantVisibilityScript = ({
5321
5332
  contentId,
@@ -5330,7 +5341,7 @@ function getPreviewContent(_searchParams) {
5330
5341
  }
5331
5342
 
5332
5343
  // src/constants/sdk-version.ts
5333
- var SDK_VERSION = "4.0.1";
5344
+ var SDK_VERSION = "4.0.3";
5334
5345
 
5335
5346
  // src/helpers/sdk-headers.ts
5336
5347
  var getSdkHeaders = () => ({
@@ -6191,6 +6202,7 @@ var getWrapperClassName = (variationId) => {
6191
6202
 
6192
6203
  // src/components/content/components/enable-editor.tsx
6193
6204
  function EnableEditor(props) {
6205
+ createSignal(false);
6194
6206
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
6195
6207
  const [httpReqsData, setHttpReqsData] = createSignal({});
6196
6208
  const [httpReqsPending, setHttpReqsPending] = createSignal({});
@@ -6358,8 +6370,12 @@ function EnableEditor(props) {
6358
6370
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
6359
6371
  }
6360
6372
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
6361
- if (shouldTrackImpression) {
6362
- const variationId = props.builderContextSignal.content?.testVariationId;
6373
+ const winningVariantId = getCookieSync({
6374
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
6375
+ canTrack: true
6376
+ });
6377
+ const variationId = props.builderContextSignal.content?.testVariationId;
6378
+ if (shouldTrackImpression && variationId === winningVariantId) {
6363
6379
  const contentId = props.builderContextSignal.content?.id;
6364
6380
  const apiKeyProp = props.apiKey;
6365
6381
  _track({
@@ -6368,7 +6384,7 @@ function EnableEditor(props) {
6368
6384
  canTrack: true,
6369
6385
  contentId,
6370
6386
  apiKey: apiKeyProp,
6371
- variationId: variationId !== contentId ? variationId : void 0
6387
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
6372
6388
  });
6373
6389
  }
6374
6390
  if (isPreviewing() && !isEditing()) {
@@ -1916,7 +1916,7 @@ function SectionComponent(props) {
1916
1916
  var section_default = SectionComponent;
1917
1917
 
1918
1918
  // src/blocks/symbol/symbol.tsx
1919
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1919
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1920
1920
 
1921
1921
  // src/components/content-variants/content-variants.tsx
1922
1922
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -3625,13 +3625,12 @@ var componentInfo12 = {
3625
3625
  };
3626
3626
 
3627
3627
  // src/blocks/custom-code/custom-code.tsx
3628
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3628
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3629
3629
  function CustomCode(props) {
3630
3630
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3631
3631
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3632
- let elementRef;
3633
- onMount5(() => {
3634
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3632
+ function runScripts() {
3633
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3635
3634
  return;
3636
3635
  }
3637
3636
  const scripts = elementRef.getElementsByTagName("script");
@@ -3658,11 +3657,25 @@ function CustomCode(props) {
3658
3657
  scriptsRun().push(script.innerText);
3659
3658
  new Function(script.innerText)();
3660
3659
  } catch (error) {
3661
- console.warn("`CustomCode`: Error running script:", error);
3660
+ logger.warn(
3661
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3662
+ error
3663
+ );
3662
3664
  }
3663
3665
  }
3664
3666
  }
3667
+ }
3668
+ let elementRef;
3669
+ onMount5(() => {
3670
+ runScripts();
3665
3671
  });
3672
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3673
+ function onUpdateFn_0() {
3674
+ if (isEditing()) {
3675
+ runScripts();
3676
+ }
3677
+ }
3678
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3666
3679
  return <><div
3667
3680
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3668
3681
  ref={elementRef}
@@ -3690,7 +3703,7 @@ var componentInfo13 = {
3690
3703
  };
3691
3704
 
3692
3705
  // src/blocks/embed/embed.tsx
3693
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3706
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3694
3707
 
3695
3708
  // src/blocks/embed/helpers.ts
3696
3709
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3718,7 +3731,7 @@ function Embed(props) {
3718
3731
  scriptsRun().push(script.innerText);
3719
3732
  new Function(script.innerText)();
3720
3733
  } catch (error) {
3721
- console.warn("`Embed`: Error running script:", error);
3734
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
3722
3735
  }
3723
3736
  }
3724
3737
  }
@@ -3732,8 +3745,8 @@ function Embed(props) {
3732
3745
  findAndRunScripts();
3733
3746
  }
3734
3747
  }
3735
- createEffect2(
3736
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3748
+ createEffect3(
3749
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3737
3750
  );
3738
3751
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3739
3752
  }
@@ -4775,7 +4788,7 @@ function serializeIncludingFunctions(info) {
4775
4788
  }
4776
4789
 
4777
4790
  // src/components/content-variants/inlined-fns.ts
4778
- var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
4791
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
4779
4792
  var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
4780
4793
 
4781
4794
  // src/components/content-variants/helpers.ts
@@ -4804,6 +4817,7 @@ var checkShouldRenderVariants2 = ({
4804
4817
  return true;
4805
4818
  };
4806
4819
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4820
+ var isAngularSDK = TARGET === "angular";
4807
4821
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4808
4822
  var getInitVariantsFnsScriptString = () => `
4809
4823
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4811,7 +4825,7 @@ var getInitVariantsFnsScriptString = () => `
4811
4825
  `;
4812
4826
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4813
4827
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4814
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
4828
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4815
4829
  )`;
4816
4830
  var getUpdateVariantVisibilityScript = ({
4817
4831
  contentId,
@@ -4824,8 +4838,8 @@ var getUpdateVariantVisibilityScript = ({
4824
4838
  import {
4825
4839
  Show as Show14,
4826
4840
  onMount as onMount7,
4827
- on as on3,
4828
- createEffect as createEffect3,
4841
+ on as on4,
4842
+ createEffect as createEffect4,
4829
4843
  createMemo as createMemo16,
4830
4844
  createSignal as createSignal16
4831
4845
  } from "solid-js";
@@ -4837,7 +4851,7 @@ function getPreviewContent(_searchParams) {
4837
4851
  }
4838
4852
 
4839
4853
  // src/constants/sdk-version.ts
4840
- var SDK_VERSION = "4.0.1";
4854
+ var SDK_VERSION = "4.0.3";
4841
4855
 
4842
4856
  // src/helpers/sdk-headers.ts
4843
4857
  var getSdkHeaders = () => ({
@@ -5698,6 +5712,7 @@ var getWrapperClassName = (variationId) => {
5698
5712
 
5699
5713
  // src/components/content/components/enable-editor.tsx
5700
5714
  function EnableEditor(props) {
5715
+ const [hasExecuted, setHasExecuted] = createSignal16(false);
5701
5716
  const [ContentWrapper, setContentWrapper] = createSignal16(
5702
5717
  props.contentWrapper || "div"
5703
5718
  );
@@ -5879,8 +5894,12 @@ function EnableEditor(props) {
5879
5894
  );
5880
5895
  }
5881
5896
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
5882
- if (shouldTrackImpression) {
5883
- const variationId = props.builderContextSignal.content?.testVariationId;
5897
+ const winningVariantId = getCookieSync({
5898
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
5899
+ canTrack: true
5900
+ });
5901
+ const variationId = props.builderContextSignal.content?.testVariationId;
5902
+ if (shouldTrackImpression && variationId === winningVariantId) {
5884
5903
  const contentId = props.builderContextSignal.content?.id;
5885
5904
  const apiKeyProp = props.apiKey;
5886
5905
  _track({
@@ -5889,7 +5908,7 @@ function EnableEditor(props) {
5889
5908
  canTrack: true,
5890
5909
  contentId,
5891
5910
  apiKey: apiKeyProp,
5892
- variationId: variationId !== contentId ? variationId : void 0
5911
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
5893
5912
  });
5894
5913
  }
5895
5914
  if (isPreviewing() && !isEditing()) {
@@ -5924,15 +5943,15 @@ function EnableEditor(props) {
5924
5943
  mergeNewContent(props.content);
5925
5944
  }
5926
5945
  }
5927
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5946
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5928
5947
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
5929
5948
  () => props.builderContextSignal.rootState
5930
5949
  );
5931
5950
  function onUpdateFn_1() {
5932
5951
  emitStateUpdate();
5933
5952
  }
5934
- createEffect3(
5935
- on3(
5953
+ createEffect4(
5954
+ on4(
5936
5955
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
5937
5956
  onUpdateFn_1
5938
5957
  )
@@ -5943,7 +5962,7 @@ function EnableEditor(props) {
5943
5962
  mergeNewRootState(props.data);
5944
5963
  }
5945
5964
  }
5946
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5965
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5947
5966
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
5948
5967
  function onUpdateFn_3() {
5949
5968
  if (props.locale) {
@@ -5952,7 +5971,7 @@ function EnableEditor(props) {
5952
5971
  });
5953
5972
  }
5954
5973
  }
5955
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5974
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5956
5975
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
5957
5976
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
5958
5977
  ><Dynamic5
@@ -6330,7 +6349,7 @@ function Symbol(props) {
6330
6349
  function onUpdateFn_0() {
6331
6350
  setContent();
6332
6351
  }
6333
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6352
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6334
6353
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6335
6354
  nonce={props.builderContext.nonce}
6336
6355
  isNestedRender={true}
@@ -3990,9 +3990,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
3990
3990
  function CustomCode(props) {
3991
3991
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
3992
3992
  const [scriptsRun, setScriptsRun] = createSignal([]);
3993
- let elementRef;
3994
- onMount(() => {
3995
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3993
+ function runScripts() {
3994
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3996
3995
  return;
3997
3996
  }
3998
3997
  const scripts = elementRef.getElementsByTagName("script");
@@ -4015,10 +4014,22 @@ function CustomCode(props) {
4015
4014
  scriptsRun().push(script.innerText);
4016
4015
  new Function(script.innerText)();
4017
4016
  } catch (error) {
4017
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
4018
4018
  }
4019
4019
  }
4020
4020
  }
4021
+ }
4022
+ let elementRef;
4023
+ onMount(() => {
4024
+ runScripts();
4021
4025
  });
4026
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
4027
+ function onUpdateFn_0() {
4028
+ if (isEditing()) {
4029
+ runScripts();
4030
+ }
4031
+ }
4032
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
4022
4033
  return (() => {
4023
4034
  const _el$ = _tmpl$13();
4024
4035
  const _ref$ = elementRef;
@@ -4082,6 +4093,7 @@ function Embed(props) {
4082
4093
  scriptsRun().push(script.innerText);
4083
4094
  new Function(script.innerText)();
4084
4095
  } catch (error) {
4096
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
4085
4097
  }
4086
4098
  }
4087
4099
  }
@@ -5265,7 +5277,7 @@ function serializeIncludingFunctions(info) {
5265
5277
  }
5266
5278
 
5267
5279
  // src/components/content-variants/inlined-fns.ts
5268
- var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
5280
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
5269
5281
  var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
5270
5282
 
5271
5283
  // src/components/content-variants/helpers.ts
@@ -5294,6 +5306,7 @@ var checkShouldRenderVariants2 = ({
5294
5306
  return true;
5295
5307
  };
5296
5308
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5309
+ var isAngularSDK = TARGET === "angular";
5297
5310
  var isHydrationTarget = getIsHydrationTarget(TARGET);
5298
5311
  var getInitVariantsFnsScriptString = () => `
5299
5312
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -5301,7 +5314,7 @@ var getInitVariantsFnsScriptString = () => `
5301
5314
  `;
5302
5315
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5303
5316
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5304
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5317
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5305
5318
  )`;
5306
5319
  var getUpdateVariantVisibilityScript = ({
5307
5320
  contentId,
@@ -5316,7 +5329,7 @@ function getPreviewContent(_searchParams) {
5316
5329
  }
5317
5330
 
5318
5331
  // src/constants/sdk-version.ts
5319
- var SDK_VERSION = "4.0.1";
5332
+ var SDK_VERSION = "4.0.3";
5320
5333
 
5321
5334
  // src/helpers/sdk-headers.ts
5322
5335
  var getSdkHeaders = () => ({
@@ -6171,6 +6184,7 @@ var getWrapperClassName = (variationId) => {
6171
6184
 
6172
6185
  // src/components/content/components/enable-editor.tsx
6173
6186
  function EnableEditor(props) {
6187
+ createSignal(false);
6174
6188
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
6175
6189
  const [httpReqsData, setHttpReqsData] = createSignal({});
6176
6190
  const [httpReqsPending, setHttpReqsPending] = createSignal({});
@@ -6337,8 +6351,12 @@ function EnableEditor(props) {
6337
6351
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
6338
6352
  }
6339
6353
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
6340
- if (shouldTrackImpression) {
6341
- const variationId = props.builderContextSignal.content?.testVariationId;
6354
+ const winningVariantId = getCookieSync({
6355
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
6356
+ canTrack: true
6357
+ });
6358
+ const variationId = props.builderContextSignal.content?.testVariationId;
6359
+ if (shouldTrackImpression && variationId === winningVariantId) {
6342
6360
  const contentId = props.builderContextSignal.content?.id;
6343
6361
  const apiKeyProp = props.apiKey;
6344
6362
  _track({
@@ -6347,7 +6365,7 @@ function EnableEditor(props) {
6347
6365
  canTrack: true,
6348
6366
  contentId,
6349
6367
  apiKey: apiKeyProp,
6350
- variationId: variationId !== contentId ? variationId : void 0
6368
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
6351
6369
  });
6352
6370
  }
6353
6371
  if (isPreviewing() && !isEditing()) {
@@ -1908,7 +1908,7 @@ function SectionComponent(props) {
1908
1908
  var section_default = SectionComponent;
1909
1909
 
1910
1910
  // src/blocks/symbol/symbol.tsx
1911
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1911
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1912
1912
 
1913
1913
  // src/components/content-variants/content-variants.tsx
1914
1914
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -3616,13 +3616,12 @@ var componentInfo12 = {
3616
3616
  };
3617
3617
 
3618
3618
  // src/blocks/custom-code/custom-code.tsx
3619
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3619
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3620
3620
  function CustomCode(props) {
3621
3621
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3622
3622
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3623
- let elementRef;
3624
- onMount5(() => {
3625
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3623
+ function runScripts() {
3624
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3626
3625
  return;
3627
3626
  }
3628
3627
  const scripts = elementRef.getElementsByTagName("script");
@@ -3649,10 +3648,25 @@ function CustomCode(props) {
3649
3648
  scriptsRun().push(script.innerText);
3650
3649
  new Function(script.innerText)();
3651
3650
  } catch (error) {
3651
+ logger.warn(
3652
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3653
+ error
3654
+ );
3652
3655
  }
3653
3656
  }
3654
3657
  }
3658
+ }
3659
+ let elementRef;
3660
+ onMount5(() => {
3661
+ runScripts();
3655
3662
  });
3663
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3664
+ function onUpdateFn_0() {
3665
+ if (isEditing()) {
3666
+ runScripts();
3667
+ }
3668
+ }
3669
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3656
3670
  return <><div
3657
3671
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3658
3672
  ref={elementRef}
@@ -3680,7 +3694,7 @@ var componentInfo13 = {
3680
3694
  };
3681
3695
 
3682
3696
  // src/blocks/embed/embed.tsx
3683
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3697
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3684
3698
 
3685
3699
  // src/blocks/embed/helpers.ts
3686
3700
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3708,6 +3722,7 @@ function Embed(props) {
3708
3722
  scriptsRun().push(script.innerText);
3709
3723
  new Function(script.innerText)();
3710
3724
  } catch (error) {
3725
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
3711
3726
  }
3712
3727
  }
3713
3728
  }
@@ -3721,8 +3736,8 @@ function Embed(props) {
3721
3736
  findAndRunScripts();
3722
3737
  }
3723
3738
  }
3724
- createEffect2(
3725
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3739
+ createEffect3(
3740
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3726
3741
  );
3727
3742
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3728
3743
  }
@@ -4763,7 +4778,7 @@ function serializeIncludingFunctions(info) {
4763
4778
  }
4764
4779
 
4765
4780
  // src/components/content-variants/inlined-fns.ts
4766
- var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
4781
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
4767
4782
  var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
4768
4783
 
4769
4784
  // src/components/content-variants/helpers.ts
@@ -4792,6 +4807,7 @@ var checkShouldRenderVariants2 = ({
4792
4807
  return true;
4793
4808
  };
4794
4809
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4810
+ var isAngularSDK = TARGET === "angular";
4795
4811
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4796
4812
  var getInitVariantsFnsScriptString = () => `
4797
4813
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4799,7 +4815,7 @@ var getInitVariantsFnsScriptString = () => `
4799
4815
  `;
4800
4816
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4801
4817
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4802
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
4818
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4803
4819
  )`;
4804
4820
  var getUpdateVariantVisibilityScript = ({
4805
4821
  contentId,
@@ -4812,8 +4828,8 @@ var getUpdateVariantVisibilityScript = ({
4812
4828
  import {
4813
4829
  Show as Show14,
4814
4830
  onMount as onMount7,
4815
- on as on3,
4816
- createEffect as createEffect3,
4831
+ on as on4,
4832
+ createEffect as createEffect4,
4817
4833
  createMemo as createMemo16,
4818
4834
  createSignal as createSignal16
4819
4835
  } from "solid-js";
@@ -4825,7 +4841,7 @@ function getPreviewContent(_searchParams) {
4825
4841
  }
4826
4842
 
4827
4843
  // src/constants/sdk-version.ts
4828
- var SDK_VERSION = "4.0.1";
4844
+ var SDK_VERSION = "4.0.3";
4829
4845
 
4830
4846
  // src/helpers/sdk-headers.ts
4831
4847
  var getSdkHeaders = () => ({
@@ -5680,6 +5696,7 @@ var getWrapperClassName = (variationId) => {
5680
5696
 
5681
5697
  // src/components/content/components/enable-editor.tsx
5682
5698
  function EnableEditor(props) {
5699
+ const [hasExecuted, setHasExecuted] = createSignal16(false);
5683
5700
  const [ContentWrapper, setContentWrapper] = createSignal16(
5684
5701
  props.contentWrapper || "div"
5685
5702
  );
@@ -5860,8 +5877,12 @@ function EnableEditor(props) {
5860
5877
  );
5861
5878
  }
5862
5879
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
5863
- if (shouldTrackImpression) {
5864
- const variationId = props.builderContextSignal.content?.testVariationId;
5880
+ const winningVariantId = getCookieSync({
5881
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
5882
+ canTrack: true
5883
+ });
5884
+ const variationId = props.builderContextSignal.content?.testVariationId;
5885
+ if (shouldTrackImpression && variationId === winningVariantId) {
5865
5886
  const contentId = props.builderContextSignal.content?.id;
5866
5887
  const apiKeyProp = props.apiKey;
5867
5888
  _track({
@@ -5870,7 +5891,7 @@ function EnableEditor(props) {
5870
5891
  canTrack: true,
5871
5892
  contentId,
5872
5893
  apiKey: apiKeyProp,
5873
- variationId: variationId !== contentId ? variationId : void 0
5894
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
5874
5895
  });
5875
5896
  }
5876
5897
  if (isPreviewing() && !isEditing()) {
@@ -5905,15 +5926,15 @@ function EnableEditor(props) {
5905
5926
  mergeNewContent(props.content);
5906
5927
  }
5907
5928
  }
5908
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5929
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5909
5930
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
5910
5931
  () => props.builderContextSignal.rootState
5911
5932
  );
5912
5933
  function onUpdateFn_1() {
5913
5934
  emitStateUpdate();
5914
5935
  }
5915
- createEffect3(
5916
- on3(
5936
+ createEffect4(
5937
+ on4(
5917
5938
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
5918
5939
  onUpdateFn_1
5919
5940
  )
@@ -5924,7 +5945,7 @@ function EnableEditor(props) {
5924
5945
  mergeNewRootState(props.data);
5925
5946
  }
5926
5947
  }
5927
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5948
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5928
5949
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
5929
5950
  function onUpdateFn_3() {
5930
5951
  if (props.locale) {
@@ -5933,7 +5954,7 @@ function EnableEditor(props) {
5933
5954
  });
5934
5955
  }
5935
5956
  }
5936
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5957
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5937
5958
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
5938
5959
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
5939
5960
  ><Dynamic5
@@ -6311,7 +6332,7 @@ function Symbol(props) {
6311
6332
  function onUpdateFn_0() {
6312
6333
  setContent();
6313
6334
  }
6314
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6335
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6315
6336
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6316
6337
  nonce={props.builderContext.nonce}
6317
6338
  isNestedRender={true}