@builder.io/sdk-qwik 0.3.0 → 0.4.0

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 (37) hide show
  1. package/lib/index.qwik.cjs +1012 -656
  2. package/lib/index.qwik.mjs +1013 -657
  3. package/package.json +3 -6
  4. package/types/components/render-block/render-block.helpers.d.ts +0 -1
  5. package/types/components/render-block/render-component-with-context.d.ts +3 -0
  6. package/types/components/render-content/render-content.d.ts +1 -1
  7. package/types/components/render-content/render-content.types.d.ts +11 -2
  8. package/types/components/render-content/wrap-component-ref.d.ts +6 -0
  9. package/types/components/render-content-variants/helpers.d.ts +17 -0
  10. package/types/components/render-content-variants/render-content-variants.d.ts +3 -0
  11. package/types/components/render-inlined-styles.d.ts +1 -0
  12. package/types/constants/sdk-version.d.ts +1 -0
  13. package/types/context/types.d.ts +17 -2
  14. package/types/functions/convert-style-object.d.ts +1 -0
  15. package/types/functions/evaluate.d.ts +4 -3
  16. package/types/functions/evaluate.test.d.ts +1 -0
  17. package/types/functions/get-block-actions-handler.d.ts +1 -1
  18. package/types/functions/get-block-actions.d.ts +1 -1
  19. package/types/functions/get-block-styles.d.ts +6 -0
  20. package/types/functions/get-block-tag.d.ts +3 -0
  21. package/types/functions/get-content/fn.test.d.ts +1 -0
  22. package/types/functions/get-content/index.d.ts +7 -2
  23. package/types/functions/get-content/types.d.ts +6 -0
  24. package/types/functions/get-processed-block.d.ts +2 -2
  25. package/types/functions/mark-mutable.d.ts +2 -0
  26. package/types/functions/sanitize-styles.d.ts +4 -0
  27. package/types/functions/track.d.ts +56 -0
  28. package/types/helpers/ab-tests.d.ts +8 -7
  29. package/types/helpers/canTrack.d.ts +1 -0
  30. package/types/helpers/cookie.d.ts +7 -3
  31. package/types/helpers/logger.d.ts +1 -0
  32. package/types/index-helpers/blocks-exports.d.ts +1 -1
  33. package/types/index.d.ts +8 -7
  34. package/types/scripts/init-editing.d.ts +1 -0
  35. package/types/talk/generators-updated.d.ts +1 -0
  36. package/types/talk/generators.d.ts +6 -0
  37. package/types/types/builder-content.d.ts +1 -3
@@ -34,7 +34,7 @@ const STYLES$3 = `
34
34
  all: unset;
35
35
  }
36
36
  `;
37
- const builderContext = qwik.createContextId("Builder");
37
+ const BuilderContext = qwik.createContextId("Builder");
38
38
  const TARGET = "qwik";
39
39
  function isBrowser() {
40
40
  return typeof window !== "undefined" && typeof document !== "undefined";
@@ -88,7 +88,7 @@ const getSizesForBreakpoints = ({ small, medium }) => {
88
88
  };
89
89
  return newSizes;
90
90
  };
91
- function evaluate({ code, context, state, event, isExpression = true }) {
91
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
92
92
  if (code === "") {
93
93
  console.warn("Skipping evaluation of empty code block.");
94
94
  return;
@@ -101,11 +101,29 @@ function evaluate({ code, context, state, event, isExpression = true }) {
101
101
  const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
102
102
  const useCode = useReturn ? `return (${code});` : code;
103
103
  try {
104
- return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
104
+ return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, flattenState(rootState, localState, rootSetState), context, event);
105
105
  } catch (e) {
106
106
  console.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e);
107
107
  }
108
108
  }
109
+ function flattenState(rootState, localState, rootSetState) {
110
+ if (rootState === localState)
111
+ throw new Error("rootState === localState");
112
+ return new Proxy(rootState, {
113
+ get: (_, prop) => {
114
+ if (localState && prop in localState)
115
+ return localState[prop];
116
+ return rootState[prop];
117
+ },
118
+ set: (_, prop, value) => {
119
+ if (localState && prop in localState)
120
+ throw new Error("Writing to local state is not allowed as it is read-only.");
121
+ rootState[prop] = value;
122
+ rootSetState?.(rootState);
123
+ return true;
124
+ }
125
+ });
126
+ }
109
127
  const set = (obj, _path, value) => {
110
128
  if (Object(obj) !== obj)
111
129
  return obj;
@@ -116,7 +134,7 @@ const set = (obj, _path, value) => {
116
134
  function transformBlock(block) {
117
135
  return block;
118
136
  }
119
- const evaluateBindings = ({ block, context, state }) => {
137
+ const evaluateBindings = ({ block, context, localState, rootState, rootSetState }) => {
120
138
  if (!block.bindings)
121
139
  return block;
122
140
  const copy = fastClone(block);
@@ -133,19 +151,23 @@ const evaluateBindings = ({ block, context, state }) => {
133
151
  const expression = block.bindings[binding];
134
152
  const value = evaluate({
135
153
  code: expression,
136
- state,
154
+ localState,
155
+ rootState,
156
+ rootSetState,
137
157
  context
138
158
  });
139
159
  set(copied, binding, value);
140
160
  }
141
161
  return copied;
142
162
  };
143
- function getProcessedBlock({ block, context, shouldEvaluateBindings, state }) {
163
+ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState }) {
144
164
  const transformedBlock = transformBlock(block);
145
165
  if (shouldEvaluateBindings)
146
166
  return evaluateBindings({
147
167
  block: transformedBlock,
148
- state,
168
+ localState,
169
+ rootState,
170
+ rootSetState,
149
171
  context
150
172
  });
151
173
  else
@@ -175,23 +197,14 @@ const createCssClass = ({ mediaQuery, className, styles }) => {
175
197
  return cssClass;
176
198
  };
177
199
  const RenderInlinedStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
178
- const tag = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
179
- return "style";
180
- }, "RenderInlinedStyles_component_tag_useComputed_S1nSc0C6qB4"));
181
- qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
182
- const [props2, tag2] = qwik.useLexicalScope();
183
- return `<${tag2.value}>${props2.styles}</${tag2.value}>`;
184
- }, "RenderInlinedStyles_component_injectedStyleScript_useComputed_CVKinNBYTxE", [
185
- props,
186
- tag
187
- ]));
188
- return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
189
- children: /* @__PURE__ */ qwik._jsxQ("style", null, {
190
- dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.styles, [
191
- props
192
- ], "p0.styles")
193
- }, null, 3, "zz_0")
194
- }, 1, "zz_2");
200
+ return /* @__PURE__ */ qwik._jsxQ("style", null, {
201
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.styles, [
202
+ props
203
+ ], "p0.styles"),
204
+ id: qwik._fnSignal((p0) => p0.id, [
205
+ props
206
+ ], "p0.id")
207
+ }, null, 3, "zz_0");
195
208
  }, "RenderInlinedStyles_component_ejNQtXd1ahM"));
196
209
  const BlockStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
197
210
  qwik._jsxBranch();
@@ -199,7 +212,9 @@ const BlockStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
199
212
  const [props2] = qwik.useLexicalScope();
200
213
  return getProcessedBlock({
201
214
  block: props2.block,
202
- state: props2.context.state,
215
+ localState: props2.context.localState,
216
+ rootState: props2.context.rootState,
217
+ rootSetState: props2.context.rootSetState,
203
218
  context: props2.context.context,
204
219
  shouldEvaluateBindings: true
205
220
  });
@@ -273,7 +288,9 @@ function createEventHandler(value, options) {
273
288
  return evaluate({
274
289
  code: value2,
275
290
  context: options2.context,
276
- state: options2.state,
291
+ localState: options2.localState,
292
+ rootState: options2.rootState,
293
+ rootSetState: options2.rootSetState,
277
294
  event
278
295
  });
279
296
  }, "createEventHandler_7wCAiJVliNE", [
@@ -360,7 +377,9 @@ const isEmptyHtmlElement = (tagName) => {
360
377
  const getComponent = ({ block, context }) => {
361
378
  const componentName = getProcessedBlock({
362
379
  block,
363
- state: context.state,
380
+ localState: context.localState,
381
+ rootState: context.rootState,
382
+ rootSetState: context.rootSetState,
364
383
  context: context.context,
365
384
  shouldEvaluateBindings: false
366
385
  }).component?.name;
@@ -381,7 +400,9 @@ const getRepeatItemData = ({ block, context }) => {
381
400
  return void 0;
382
401
  const itemsArray = evaluate({
383
402
  code: repeat.collection,
384
- state: context.state,
403
+ localState: context.localState,
404
+ rootState: context.rootState,
405
+ rootSetState: context.rootSetState,
385
406
  context: context.context
386
407
  });
387
408
  if (!Array.isArray(itemsArray))
@@ -391,8 +412,8 @@ const getRepeatItemData = ({ block, context }) => {
391
412
  const repeatArray = itemsArray.map((item, index) => ({
392
413
  context: {
393
414
  ...context,
394
- state: {
395
- ...context.state,
415
+ localState: {
416
+ ...context.localState,
396
417
  $index: index,
397
418
  $item: item,
398
419
  [itemNameToUse]: item,
@@ -403,20 +424,6 @@ const getRepeatItemData = ({ block, context }) => {
403
424
  }));
404
425
  return repeatArray;
405
426
  };
406
- const getProxyState = (context) => {
407
- if (typeof Proxy === "undefined") {
408
- console.error("no Proxy available in this environment, cannot proxy state.");
409
- return context.state;
410
- }
411
- const useState = new Proxy(context.state, {
412
- set: (obj, prop, value) => {
413
- obj[prop] = value;
414
- context.setState?.(obj);
415
- return true;
416
- }
417
- });
418
- return useState;
419
- };
420
427
  const RenderComponent = (props) => {
421
428
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
422
429
  children: props.componentRef ? /* @__PURE__ */ qwik._jsxC(props.componentRef, {
@@ -449,9 +456,11 @@ const RenderComponent = (props) => {
449
456
  }, 1, "R9_1");
450
457
  };
451
458
  const RenderRepeatedBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
452
- qwik.useContextProvider(builderContext, qwik.useStore({
459
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
453
460
  content: props.repeatContext.content,
454
- state: props.repeatContext.state,
461
+ localState: props.repeatContext.localState,
462
+ rootState: props.repeatContext.rootState,
463
+ rootSetState: props.repeatContext.rootSetState,
455
464
  context: props.repeatContext.context,
456
465
  apiKey: props.repeatContext.apiKey,
457
466
  registeredComponents: props.repeatContext.registeredComponents,
@@ -478,8 +487,7 @@ const RenderRepeatedBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qw
478
487
  const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
479
488
  qwik._jsxBranch();
480
489
  const state = qwik.useStore({
481
- proxyState: getProxyState(props.context),
482
- tag: props.block.tagName || "div"
490
+ Tag: props.block.tagName || "div"
483
491
  });
484
492
  const component = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
485
493
  const [props2] = qwik.useLexicalScope();
@@ -490,26 +498,28 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
490
498
  }, "RenderBlock_component_component_useComputed_qb7DMTJ9XGY", [
491
499
  props
492
500
  ]));
493
- const repeatItemData = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
501
+ const repeatItem = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
494
502
  const [props2] = qwik.useLexicalScope();
495
503
  return getRepeatItemData({
496
504
  block: props2.block,
497
505
  context: props2.context
498
506
  });
499
- }, "RenderBlock_component_repeatItemData_useComputed_Q2wkGRsY3KE", [
507
+ }, "RenderBlock_component_repeatItem_useComputed_NslhinGDzrU", [
500
508
  props
501
509
  ]));
502
510
  const useBlock = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
503
- const [props2, repeatItemData2] = qwik.useLexicalScope();
504
- return repeatItemData2.value ? props2.block : getProcessedBlock({
511
+ const [props2, repeatItem2] = qwik.useLexicalScope();
512
+ return repeatItem2.value ? props2.block : getProcessedBlock({
505
513
  block: props2.block,
506
- state: props2.context.state,
514
+ localState: props2.context.localState,
515
+ rootState: props2.context.rootState,
516
+ rootSetState: props2.context.rootSetState,
507
517
  context: props2.context.context,
508
518
  shouldEvaluateBindings: true
509
519
  });
510
520
  }, "RenderBlock_component_useBlock_useComputed_4ZTSqMpaluI", [
511
521
  props,
512
- repeatItemData
522
+ repeatItem
513
523
  ]));
514
524
  const canShowBlock = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
515
525
  const [useBlock2] = qwik.useLexicalScope();
@@ -522,15 +532,16 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
522
532
  useBlock
523
533
  ]));
524
534
  const actions = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
525
- const [props2, state2, useBlock2] = qwik.useLexicalScope();
535
+ const [props2, useBlock2] = qwik.useLexicalScope();
526
536
  return getBlockActions({
527
537
  block: useBlock2.value,
528
- state: props2.context.state,
538
+ rootState: props2.context.rootState,
539
+ rootSetState: props2.context.rootSetState,
540
+ localState: props2.context.localState,
529
541
  context: props2.context.context
530
542
  });
531
543
  }, "RenderBlock_component_actions_useComputed_AOTwdXfwCqY", [
532
544
  props,
533
- state,
534
545
  useBlock
535
546
  ]));
536
547
  const attributes = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
@@ -545,12 +556,12 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
545
556
  useBlock
546
557
  ]));
547
558
  const childrenWithoutParentComponent = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
548
- const [component2, repeatItemData2, useBlock2] = qwik.useLexicalScope();
549
- const shouldRenderChildrenOutsideRef = !component2.value?.component && !repeatItemData2.value;
559
+ const [component2, repeatItem2, useBlock2] = qwik.useLexicalScope();
560
+ const shouldRenderChildrenOutsideRef = !component2.value?.component && !repeatItem2.value;
550
561
  return shouldRenderChildrenOutsideRef ? useBlock2.value.children ?? [] : [];
551
562
  }, "RenderBlock_component_childrenWithoutParentComponent_useComputed_l4hT2V9liQc", [
552
563
  component,
553
- repeatItemData,
564
+ repeatItem,
554
565
  useBlock
555
566
  ]));
556
567
  const childrenContext = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
@@ -561,10 +572,11 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
561
572
  return {
562
573
  apiKey: props2.context.apiKey,
563
574
  apiVersion: props2.context.apiVersion,
564
- state: props2.context.state,
575
+ localState: props2.context.localState,
576
+ rootState: props2.context.rootState,
577
+ rootSetState: props2.context.rootSetState,
565
578
  content: props2.context.content,
566
579
  context: props2.context.context,
567
- setState: props2.context.setState,
568
580
  registeredComponents: props2.context.registeredComponents,
569
581
  inheritedStyles: getInheritedTextStyles()
570
582
  };
@@ -599,11 +611,11 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
599
611
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
600
612
  children: canShowBlock.value ? !component.value?.noWrap ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
601
613
  children: [
602
- isEmptyHtmlElement(state.tag) ? /* @__PURE__ */ qwik._jsxC(state.tag, {
614
+ isEmptyHtmlElement(state.Tag) ? /* @__PURE__ */ qwik._jsxC(state.Tag, {
603
615
  ...attributes.value,
604
616
  ...actions.value
605
617
  }, 0, "9d_0") : null,
606
- !isEmptyHtmlElement(state.tag) && repeatItemData.value ? (repeatItemData.value || []).map(function(data, index) {
618
+ !isEmptyHtmlElement(state.Tag) && repeatItem.value ? (repeatItem.value || []).map(function(data, index) {
607
619
  return /* @__PURE__ */ qwik._jsxC(RenderRepeatedBlock, {
608
620
  get repeatContext() {
609
621
  return data.context;
@@ -617,7 +629,7 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
617
629
  }
618
630
  }, 3, index);
619
631
  }) : null,
620
- !isEmptyHtmlElement(state.tag) && !repeatItemData.value ? /* @__PURE__ */ qwik._jsxC(state.tag, {
632
+ !isEmptyHtmlElement(state.Tag) && !repeatItem.value ? /* @__PURE__ */ qwik._jsxC(state.Tag, {
621
633
  ...attributes.value,
622
634
  ...actions.value,
623
635
  children: [
@@ -658,7 +670,7 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
658
670
  }, 0, "9d_4") : null
659
671
  }, 1, "9d_5");
660
672
  }, "RenderBlock_component_m0hg0zT573Q"));
661
- const onClick$1 = function onClick2(props, state, builderContext2) {
673
+ const onClick$1 = function onClick2(props, state, builderContext) {
662
674
  if (isEditing() && !props.blocks?.length)
663
675
  window.parent?.postMessage({
664
676
  type: "builder.clickEmptyBlocks",
@@ -668,7 +680,7 @@ const onClick$1 = function onClick2(props, state, builderContext2) {
668
680
  }
669
681
  }, "*");
670
682
  };
671
- const onMouseEnter = function onMouseEnter2(props, state, builderContext2) {
683
+ const onMouseEnter = function onMouseEnter2(props, state, builderContext) {
672
684
  if (isEditing() && !props.blocks?.length)
673
685
  window.parent?.postMessage({
674
686
  type: "builder.hoverEmptyBlocks",
@@ -680,7 +692,7 @@ const onMouseEnter = function onMouseEnter2(props, state, builderContext2) {
680
692
  };
681
693
  const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
682
694
  qwik.useStylesScopedQrl(/* @__PURE__ */ qwik.inlinedQrl(STYLES$2, "RenderBlocks_component_useStylesScoped_0XKYzaR059E"));
683
- const builderContext$1 = qwik.useContext(builderContext);
695
+ const builderContext = qwik.useContext(BuilderContext);
684
696
  const state = {};
685
697
  const className = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
686
698
  const [props2] = qwik.useLexicalScope();
@@ -693,7 +705,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
693
705
  const [builderContext2, props2, state2] = qwik.useLexicalScope();
694
706
  return onClick$1(props2);
695
707
  }, "RenderBlocks_component_div_onClick_RzhhZa265Yg", [
696
- builderContext$1,
708
+ builderContext,
697
709
  props,
698
710
  state
699
711
  ]),
@@ -701,7 +713,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
701
713
  const [builderContext2, props2, state2] = qwik.useLexicalScope();
702
714
  return onMouseEnter(props2);
703
715
  }, "RenderBlocks_component_div_onMouseEnter_nG7I7RYG3JQ", [
704
- builderContext$1,
716
+ builderContext,
705
717
  props,
706
718
  state
707
719
  ])
@@ -722,7 +734,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
722
734
  props.blocks ? (props.blocks || []).map(function(block) {
723
735
  return /* @__PURE__ */ qwik._jsxC(RenderBlock, {
724
736
  block,
725
- context: builderContext$1,
737
+ context: builderContext,
726
738
  [qwik._IMMUTABLE]: {
727
739
  context: qwik._IMMUTABLE
728
740
  }
@@ -731,7 +743,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
731
743
  props.blocks ? (props.blocks || []).map(function(block) {
732
744
  return /* @__PURE__ */ qwik._jsxC(BlockStyles, {
733
745
  block,
734
- context: builderContext$1,
746
+ context: builderContext,
735
747
  [qwik._IMMUTABLE]: {
736
748
  context: qwik._IMMUTABLE
737
749
  }
@@ -746,52 +758,54 @@ const STYLES$2 = `
746
758
  align-items: stretch;
747
759
  }
748
760
  `;
749
- const getWidth = function getWidth2(props, state, builderContext2, index) {
761
+ const getWidth = function getWidth2(props, state, builderContext, index) {
750
762
  return state.cols[index]?.width || 100 / state.cols.length;
751
763
  };
752
- const getColumnCssWidth = function getColumnCssWidth2(props, state, builderContext2, index) {
764
+ const getColumnCssWidth = function getColumnCssWidth2(props, state, builderContext, index) {
753
765
  const subtractWidth = state.gutterSize * (state.cols.length - 1) / state.cols.length;
754
- return `calc(${getWidth(props, state, builderContext2, index)}% - ${subtractWidth}px)`;
766
+ return `calc(${getWidth(props, state, builderContext, index)}% - ${subtractWidth}px)`;
755
767
  };
756
- const getTabletStyle = function getTabletStyle2(props, state, builderContext2, { stackedStyle, desktopStyle }) {
768
+ const getTabletStyle = function getTabletStyle2(props, state, builderContext, { stackedStyle, desktopStyle }) {
757
769
  return state.stackAt === "tablet" ? stackedStyle : desktopStyle;
758
770
  };
759
- const getMobileStyle = function getMobileStyle2(props, state, builderContext2, { stackedStyle, desktopStyle }) {
771
+ const getMobileStyle = function getMobileStyle2(props, state, builderContext, { stackedStyle, desktopStyle }) {
760
772
  return state.stackAt === "never" ? desktopStyle : stackedStyle;
761
773
  };
762
- const columnCssVars = function columnCssVars2(props, state, builderContext2, index) {
763
- index === 0 ? 0 : state.gutterSize;
764
- const width = getColumnCssWidth(props, state, builderContext2, index);
765
- const gutterPixels = `${state.gutterSize}px`;
774
+ const columnCssVars = function columnCssVars2(props, state, builderContext, index) {
775
+ const gutter = index === 0 ? 0 : state.gutterSize;
776
+ const width = getColumnCssWidth(props, state, builderContext, index);
777
+ const gutterPixels = `${gutter}px`;
778
+ const mobileWidth = "100%";
779
+ const mobileMarginLeft = 0;
766
780
  return {
767
781
  width,
768
782
  "margin-left": gutterPixels,
769
- "--column-width-mobile": getMobileStyle(props, state, builderContext2, {
770
- stackedStyle: "100%",
783
+ "--column-width-mobile": getMobileStyle(props, state, builderContext, {
784
+ stackedStyle: mobileWidth,
771
785
  desktopStyle: width
772
786
  }),
773
- "--column-margin-left-mobile": getMobileStyle(props, state, builderContext2, {
774
- stackedStyle: 0,
787
+ "--column-margin-left-mobile": getMobileStyle(props, state, builderContext, {
788
+ stackedStyle: mobileMarginLeft,
775
789
  desktopStyle: gutterPixels
776
790
  }),
777
- "--column-width-tablet": getTabletStyle(props, state, builderContext2, {
778
- stackedStyle: "100%",
791
+ "--column-width-tablet": getTabletStyle(props, state, builderContext, {
792
+ stackedStyle: mobileWidth,
779
793
  desktopStyle: width
780
794
  }),
781
- "--column-margin-left-tablet": getTabletStyle(props, state, builderContext2, {
782
- stackedStyle: 0,
795
+ "--column-margin-left-tablet": getTabletStyle(props, state, builderContext, {
796
+ stackedStyle: mobileMarginLeft,
783
797
  desktopStyle: gutterPixels
784
798
  })
785
799
  };
786
800
  };
787
- const getWidthForBreakpointSize = function getWidthForBreakpointSize2(props, state, builderContext2, size) {
788
- const breakpointSizes = getSizesForBreakpoints(builderContext2.content?.meta?.breakpoints || {});
801
+ const getWidthForBreakpointSize = function getWidthForBreakpointSize2(props, state, builderContext, size) {
802
+ const breakpointSizes = getSizesForBreakpoints(builderContext.content?.meta?.breakpoints || {});
789
803
  return breakpointSizes[size].max;
790
804
  };
791
805
  const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
792
806
  qwik._jsxBranch();
793
807
  qwik.useStylesScopedQrl(/* @__PURE__ */ qwik.inlinedQrl(STYLES$1, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
794
- const builderContext$1 = qwik.useContext(builderContext);
808
+ const builderContext = qwik.useContext(BuilderContext);
795
809
  const state = qwik.useStore({
796
810
  cols: props.columns || [],
797
811
  flexDir: props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column",
@@ -808,7 +822,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQr
808
822
  })
809
823
  };
810
824
  }, "Columns_component_columnsCssVars_useComputed_adFEq2RWT9s", [
811
- builderContext$1,
825
+ builderContext,
812
826
  props,
813
827
  state
814
828
  ]));
@@ -840,7 +854,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQr
840
854
  },
841
855
  `;
842
856
  }, "Columns_component_columnsStyles_useComputed_nBtMPbzd1Wc", [
843
- builderContext$1,
857
+ builderContext,
844
858
  props,
845
859
  state
846
860
  ]));
@@ -864,7 +878,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQr
864
878
  }, 3, "c0_0"),
865
879
  (props.columns || []).map(function(column, index) {
866
880
  return /* @__PURE__ */ qwik._jsxQ("div", {
867
- style: columnCssVars(props, state, builderContext$1, index)
881
+ style: columnCssVars(props, state, builderContext, index)
868
882
  }, {
869
883
  class: "builder-column div-Columns-2"
870
884
  }, /* @__PURE__ */ qwik._jsxC(RenderBlocks, {
@@ -962,16 +976,17 @@ const Image = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
962
976
  const srcSetToUse = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
963
977
  const [props2] = qwik.useLexicalScope();
964
978
  const imageToUse = props2.image || props2.src;
965
- if (!imageToUse || !(imageToUse.match(/builder\.io/) || imageToUse.match(/cdn\.shopify\.com/)))
979
+ const url = imageToUse;
980
+ if (!url || !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/)))
966
981
  return props2.srcset;
967
982
  if (props2.srcset && props2.image?.includes("builder.io/api/v1/image")) {
968
983
  if (!props2.srcset.includes(props2.image.split("?")[0])) {
969
984
  console.debug("Removed given srcset");
970
- return getSrcSet(imageToUse);
985
+ return getSrcSet(url);
971
986
  }
972
987
  } else if (props2.image && !props2.srcset)
973
- return getSrcSet(imageToUse);
974
- return getSrcSet(imageToUse);
988
+ return getSrcSet(url);
989
+ return getSrcSet(url);
975
990
  }, "Image_component_srcSetToUse_useComputed_TZMibf9Gpvw", [
976
991
  props
977
992
  ]));
@@ -1074,6 +1089,24 @@ const STYLES = `
1074
1089
  height: 100%;
1075
1090
  }
1076
1091
  `;
1092
+ const SectionComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1093
+ return /* @__PURE__ */ qwik._jsxS("section", {
1094
+ ...props.attributes,
1095
+ style: {
1096
+ width: "100%",
1097
+ alignSelf: "stretch",
1098
+ flexGrow: 1,
1099
+ boxSizing: "border-box",
1100
+ maxWidth: props.maxWidth || 1200,
1101
+ display: "flex",
1102
+ flexDirection: "column",
1103
+ alignItems: "stretch",
1104
+ marginLeft: "auto",
1105
+ marginRight: "auto"
1106
+ },
1107
+ children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "2Y_0")
1108
+ }, null, 0, "2Y_1");
1109
+ }, "SectionComponent_component_ZWF9iD5WeLg"));
1077
1110
  const componentInfo$a = {
1078
1111
  name: "Core:Button",
1079
1112
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
@@ -1388,6 +1421,7 @@ const componentInfo$7 = {
1388
1421
  required: true,
1389
1422
  defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
1390
1423
  onChange: serializeFn((options) => {
1424
+ const DEFAULT_ASPECT_RATIO = 0.7041;
1391
1425
  options.delete("srcset");
1392
1426
  options.delete("noWebp");
1393
1427
  function loadImage(url, timeout = 6e4) {
@@ -1418,10 +1452,10 @@ const componentInfo$7 = {
1418
1452
  if (blob.type.includes("svg"))
1419
1453
  options.set("noWebp", true);
1420
1454
  });
1421
- if (value && (!aspectRatio || aspectRatio === 0.7041))
1455
+ if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO))
1422
1456
  return loadImage(value).then((img) => {
1423
1457
  const possiblyUpdatedAspectRatio = options.get("aspectRatio");
1424
- if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === 0.7041)) {
1458
+ if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
1425
1459
  if (img.width && img.height) {
1426
1460
  options.set("aspectRatio", round2(img.height / img.width));
1427
1461
  options.set("height", img.height);
@@ -1555,24 +1589,6 @@ const componentInfo$6 = {
1555
1589
  }
1556
1590
  ]
1557
1591
  };
1558
- const SectionComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1559
- return /* @__PURE__ */ qwik._jsxS("section", {
1560
- ...props.attributes,
1561
- style: {
1562
- width: "100%",
1563
- alignSelf: "stretch",
1564
- flexGrow: 1,
1565
- boxSizing: "border-box",
1566
- maxWidth: props.maxWidth || 1200,
1567
- display: "flex",
1568
- flexDirection: "column",
1569
- alignItems: "stretch",
1570
- marginLeft: "auto",
1571
- marginRight: "auto"
1572
- },
1573
- children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "2Y_0")
1574
- }, null, 0, "2Y_1");
1575
- }, "SectionComponent_component_ZWF9iD5WeLg"));
1576
1592
  const componentInfo$5 = {
1577
1593
  name: "Symbol",
1578
1594
  noWrap: true,
@@ -1612,431 +1628,30 @@ const componentInfo$5 = {
1612
1628
  }
1613
1629
  ]
1614
1630
  };
1615
- const logger = {
1616
- log: (...message) => console.log("[Builder.io]: ", ...message),
1617
- error: (...message) => console.error("[Builder.io]: ", ...message),
1618
- warn: (...message) => console.warn("[Builder.io]: ", ...message)
1619
- };
1620
- function getGlobalThis() {
1621
- if (typeof globalThis !== "undefined")
1622
- return globalThis;
1623
- if (typeof window !== "undefined")
1624
- return window;
1625
- if (typeof global !== "undefined")
1626
- return global;
1627
- if (typeof self !== "undefined")
1628
- return self;
1629
- return globalThis;
1630
- }
1631
- function getFetch() {
1632
- const globalFetch = getGlobalThis().fetch;
1633
- if (typeof globalFetch === "undefined") {
1634
- console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
1635
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
1636
- throw new Error("Builder SDK could not find a global `fetch` function");
1637
- }
1638
- return globalFetch;
1639
- }
1640
- const fetch$1 = getFetch();
1641
- const getTopLevelDomain = (host) => {
1642
- if (host === "localhost" || host === "127.0.0.1")
1643
- return host;
1644
- const parts = host.split(".");
1645
- if (parts.length > 2)
1646
- return parts.slice(1).join(".");
1647
- return host;
1648
- };
1649
- const getCookie = async ({ name, canTrack }) => {
1650
- try {
1651
- if (!canTrack)
1652
- return void 0;
1653
- return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
1654
- } catch (err) {
1655
- console.debug("[COOKIE] GET error: ", err);
1656
- return void 0;
1657
- }
1658
- };
1659
- const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
1660
- const SECURE_CONFIG = [
1661
- [
1662
- "secure",
1663
- ""
1631
+ const componentInfo$4 = {
1632
+ name: "Text",
1633
+ static: true,
1634
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
1635
+ inputs: [
1636
+ {
1637
+ name: "text",
1638
+ type: "html",
1639
+ required: true,
1640
+ autoFocus: true,
1641
+ bubble: true,
1642
+ defaultValue: "Enter some text..."
1643
+ }
1664
1644
  ],
1665
- [
1666
- "SameSite",
1667
- "None"
1668
- ]
1669
- ];
1670
- const createCookieString = ({ name, value, expires }) => {
1671
- const secure = isBrowser() ? location.protocol === "https:" : true;
1672
- const secureObj = secure ? SECURE_CONFIG : [
1673
- []
1674
- ];
1675
- const expiresObj = expires ? [
1676
- [
1677
- "expires",
1678
- expires.toUTCString()
1679
- ]
1680
- ] : [
1681
- []
1682
- ];
1683
- const cookieValue = [
1684
- [
1685
- name,
1686
- value
1687
- ],
1688
- ...expiresObj,
1689
- [
1690
- "path",
1691
- "/"
1692
- ],
1693
- [
1694
- "domain",
1695
- getTopLevelDomain(window.location.hostname)
1696
- ],
1697
- ...secureObj
1698
- ];
1699
- const cookie = stringifyCookie(cookieValue);
1700
- return cookie;
1701
- };
1702
- const setCookie = async ({ name, value, expires, canTrack }) => {
1703
- try {
1704
- if (!canTrack)
1705
- return;
1706
- const cookie = createCookieString({
1707
- name,
1708
- value,
1709
- expires
1710
- });
1711
- document.cookie = cookie;
1712
- } catch (err) {
1713
- console.warn("[COOKIE] SET error: ", err);
1714
- }
1715
- };
1716
- const getContentTestKey = (id) => `${"builderio.variations"}.${id}`;
1717
- const getContentVariationCookie = ({ contentId, canTrack }) => getCookie({
1718
- name: getContentTestKey(contentId),
1719
- canTrack
1720
- });
1721
- const setContentVariationCookie = ({ contentId, canTrack, value }) => setCookie({
1722
- name: getContentTestKey(contentId),
1723
- value,
1724
- canTrack
1725
- });
1726
- const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
1727
- const getRandomVariationId = ({ id, variations }) => {
1728
- let n = 0;
1729
- const random = Math.random();
1730
- for (const id2 in variations) {
1731
- const testRatio = variations[id2]?.testRatio;
1732
- n += testRatio;
1733
- if (random < n)
1734
- return id2;
1735
- }
1736
- return id;
1737
- };
1738
- const getTestFields = ({ item, testGroupId }) => {
1739
- const variationValue = item.variations[testGroupId];
1740
- if (testGroupId === item.id || !variationValue)
1741
- return {
1742
- testVariationId: item.id,
1743
- testVariationName: "Default"
1744
- };
1745
- else
1746
- return {
1747
- data: variationValue.data,
1748
- testVariationId: variationValue.id,
1749
- testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
1750
- };
1751
- };
1752
- const getContentVariation = async ({ item, canTrack }) => {
1753
- const testGroupId = await getContentVariationCookie({
1754
- canTrack,
1755
- contentId: item.id
1756
- });
1757
- const testFields = testGroupId ? getTestFields({
1758
- item,
1759
- testGroupId
1760
- }) : void 0;
1761
- if (testFields)
1762
- return testFields;
1763
- else {
1764
- const randomVariationId = getRandomVariationId({
1765
- variations: item.variations,
1766
- id: item.id
1767
- });
1768
- setContentVariationCookie({
1769
- contentId: item.id,
1770
- value: randomVariationId,
1771
- canTrack
1772
- }).catch((err) => {
1773
- console.error("could not store A/B test variation: ", err);
1774
- });
1775
- return getTestFields({
1776
- item,
1777
- testGroupId: randomVariationId
1778
- });
1645
+ defaultStyles: {
1646
+ lineHeight: "normal",
1647
+ height: "auto",
1648
+ textAlign: "center"
1779
1649
  }
1780
1650
  };
1781
- const handleABTesting = async ({ item, canTrack }) => {
1782
- if (!checkIsBuilderContentWithVariations(item))
1783
- return;
1784
- const variationValue = await getContentVariation({
1785
- item,
1786
- canTrack
1787
- });
1788
- Object.assign(item, variationValue);
1789
- };
1790
- function flatten(object, path = null, separator = ".") {
1791
- return Object.keys(object).reduce((acc, key) => {
1792
- const value = object[key];
1793
- const newPath = [
1794
- path,
1795
- key
1796
- ].filter(Boolean).join(separator);
1797
- const isObject = [
1798
- typeof value === "object",
1799
- value !== null,
1800
- !(Array.isArray(value) && value.length === 0)
1801
- ].every(Boolean);
1802
- return isObject ? {
1803
- ...acc,
1804
- ...flatten(value, newPath, separator)
1805
- } : {
1806
- ...acc,
1807
- [newPath]: value
1808
- };
1809
- }, {});
1810
- }
1811
- const convertSearchParamsToQueryObject = (searchParams) => {
1812
- const options = {};
1813
- searchParams.forEach((value, key) => {
1814
- options[key] = value;
1815
- });
1816
- return options;
1817
- };
1818
- const getBuilderSearchParams = (_options) => {
1819
- if (!_options)
1820
- return {};
1821
- const options = normalizeSearchParams(_options);
1822
- const newOptions = {};
1823
- Object.keys(options).forEach((key) => {
1824
- if (key.startsWith("builder.")) {
1825
- const trimmedKey = key.replace("builder.", "").replace("options.", "");
1826
- newOptions[trimmedKey] = options[key];
1827
- }
1828
- });
1829
- return newOptions;
1830
- };
1831
- const getBuilderSearchParamsFromWindow = () => {
1832
- if (!isBrowser())
1833
- return {};
1834
- const searchParams = new URLSearchParams(window.location.search);
1835
- return getBuilderSearchParams(searchParams);
1836
- };
1837
- const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
1838
- const DEFAULT_API_VERSION = "v3";
1839
- const generateContentUrl = (options) => {
1840
- const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale, apiVersion = DEFAULT_API_VERSION } = options;
1841
- if (!apiKey)
1842
- throw new Error("Missing API key");
1843
- if (![
1844
- "v2",
1845
- "v3"
1846
- ].includes(apiVersion))
1847
- throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
1848
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
1849
- const queryOptions = {
1850
- ...getBuilderSearchParamsFromWindow(),
1851
- ...normalizeSearchParams(options.options || {})
1852
- };
1853
- const flattened = flatten(queryOptions);
1854
- for (const key in flattened)
1855
- url.searchParams.set(key, String(flattened[key]));
1856
- if (userAttributes)
1857
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
1858
- if (query) {
1859
- const flattened2 = flatten({
1860
- query
1861
- });
1862
- for (const key in flattened2)
1863
- url.searchParams.set(key, JSON.stringify(flattened2[key]));
1864
- }
1865
- return url;
1866
- };
1867
- async function getContent(options) {
1868
- const allContent = await getAllContent({
1869
- ...options,
1870
- limit: 1
1871
- });
1872
- if (allContent && "results" in allContent)
1873
- return allContent?.results[0] || null;
1874
- return null;
1875
- }
1876
- async function getAllContent(options) {
1877
- try {
1878
- const url = generateContentUrl(options);
1879
- const res = await fetch$1(url.href);
1880
- const content = await res.json();
1881
- if ("status" in content && !("results" in content)) {
1882
- logger.error("Error fetching data. ", {
1883
- url,
1884
- content,
1885
- options
1886
- });
1887
- return content;
1888
- }
1889
- const canTrack = options.canTrack !== false;
1890
- try {
1891
- if (canTrack && Array.isArray(content.results))
1892
- for (const item of content.results)
1893
- await handleABTesting({
1894
- item,
1895
- canTrack
1896
- });
1897
- } catch (e) {
1898
- logger.error("Could not setup A/B testing. ", e);
1899
- }
1900
- return content;
1901
- } catch (error) {
1902
- logger.error("Error fetching data. ", error);
1903
- return null;
1904
- }
1905
- }
1906
- const fetchContent = function fetchContent2(props, state, builderContext2) {
1907
- if (!state.contentToUse && props.symbol?.model && builderContext2?.apiKey)
1908
- getContent({
1909
- model: props.symbol.model,
1910
- apiKey: builderContext2.apiKey,
1911
- apiVersion: builderContext2.apiVersion,
1912
- query: {
1913
- id: props.symbol.entry
1914
- }
1915
- }).then((response) => {
1916
- if (response)
1917
- state.contentToUse = response;
1918
- }).catch((err) => {
1919
- logger.error("Could not fetch symbol content: ", err);
1920
- });
1921
- };
1922
- const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1923
- const builderContext$1 = qwik.useContext(builderContext);
1924
- const state = qwik.useStore({
1925
- className: [
1926
- ...[
1927
- props.attributes.class
1928
- ],
1929
- "builder-symbol",
1930
- props.symbol?.inline ? "builder-inline-symbol" : void 0,
1931
- props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
1932
- ].filter(Boolean).join(" "),
1933
- contentToUse: props.symbol?.content
1934
- });
1935
- qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
1936
- const [builderContext2, props2, state2] = qwik.useLexicalScope();
1937
- fetchContent(props2, state2, builderContext2);
1938
- }, "Symbol_component_useVisibleTask_oMPs8W5ZhwE", [
1939
- builderContext$1,
1940
- props,
1941
- state
1942
- ]));
1943
- qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(({ track: track2 }) => {
1944
- const [builderContext2, props2, state2] = qwik.useLexicalScope();
1945
- track2(() => props2.symbol);
1946
- fetchContent(props2, state2, builderContext2);
1947
- }, "Symbol_component_useTask_NIAWAC1bMBo", [
1948
- builderContext$1,
1949
- props,
1950
- state
1951
- ]));
1952
- return /* @__PURE__ */ qwik._jsxS("div", {
1953
- ...props.attributes,
1954
- children: /* @__PURE__ */ qwik._jsxC(RenderContent, {
1955
- get apiVersion() {
1956
- return builderContext$1.apiVersion;
1957
- },
1958
- get apiKey() {
1959
- return builderContext$1.apiKey;
1960
- },
1961
- get context() {
1962
- return builderContext$1.context;
1963
- },
1964
- get customComponents() {
1965
- return Object.values(builderContext$1.registeredComponents);
1966
- },
1967
- get data() {
1968
- return {
1969
- ...props.symbol?.data,
1970
- ...builderContext$1.state,
1971
- ...state.contentToUse?.data?.state
1972
- };
1973
- },
1974
- get model() {
1975
- return props.symbol?.model;
1976
- },
1977
- get content() {
1978
- return state.contentToUse;
1979
- },
1980
- [qwik._IMMUTABLE]: {
1981
- apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
1982
- builderContext$1
1983
- ], "p0.apiVersion"),
1984
- apiKey: qwik._fnSignal((p0) => p0.apiKey, [
1985
- builderContext$1
1986
- ], "p0.apiKey"),
1987
- context: qwik._fnSignal((p0) => p0.context, [
1988
- builderContext$1
1989
- ], "p0.context"),
1990
- customComponents: qwik._fnSignal((p0) => Object.values(p0.registeredComponents), [
1991
- builderContext$1
1992
- ], "Object.values(p0.registeredComponents)"),
1993
- data: qwik._fnSignal((p0, p1, p2) => ({
1994
- ...p1.symbol?.data,
1995
- ...p0.state,
1996
- ...p2.contentToUse?.data?.state
1997
- }), [
1998
- builderContext$1,
1999
- props,
2000
- state
2001
- ], "{...p1.symbol?.data,...p0.state,...p2.contentToUse?.data?.state}"),
2002
- model: qwik._fnSignal((p0) => p0.symbol?.model, [
2003
- props
2004
- ], "p0.symbol?.model"),
2005
- content: qwik._fnSignal((p0) => p0.contentToUse, [
2006
- state
2007
- ], "p0.contentToUse")
2008
- }
2009
- }, 3, "Wt_0")
2010
- }, {
2011
- class: qwik._fnSignal((p0) => p0.className, [
2012
- state
2013
- ], "p0.className")
2014
- }, 0, "Wt_1");
2015
- }, "Symbol_component_WVvggdkUPdk"));
2016
- const componentInfo$4 = {
2017
- name: "Text",
2018
- static: true,
2019
- image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
2020
- inputs: [
2021
- {
2022
- name: "text",
2023
- type: "html",
2024
- required: true,
2025
- autoFocus: true,
2026
- bubble: true,
2027
- defaultValue: "Enter some text..."
2028
- }
2029
- ],
2030
- defaultStyles: {
2031
- lineHeight: "normal",
2032
- height: "auto",
2033
- textAlign: "center"
2034
- }
2035
- };
2036
- const Text = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
2037
- return /* @__PURE__ */ qwik._jsxQ("span", {
2038
- style: {
2039
- outline: "none"
1651
+ const Text = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1652
+ return /* @__PURE__ */ qwik._jsxQ("span", {
1653
+ style: {
1654
+ outline: "none"
2040
1655
  }
2041
1656
  }, {
2042
1657
  class: "builder-text",
@@ -2225,7 +1840,8 @@ const componentInfo$2 = {
2225
1840
  const url = options.get("url");
2226
1841
  if (url) {
2227
1842
  options.set("content", "Loading...");
2228
- return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${"ae0e60e78201a3f2b0de4b"}`).then((res) => res.json()).then((data) => {
1843
+ const apiKey = "ae0e60e78201a3f2b0de4b";
1844
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2229
1845
  if (options.get("url") === url) {
2230
1846
  if (data.html)
2231
1847
  options.set("content", data.html);
@@ -2426,52 +2042,383 @@ const componentInfo = {
2426
2042
  }
2427
2043
  ]
2428
2044
  };
2429
- const getDefaultRegisteredComponents = () => [
2430
- {
2431
- component: Button,
2432
- ...componentInfo$a
2433
- },
2434
- {
2435
- component: Columns,
2436
- ...componentInfo$9
2437
- },
2438
- {
2439
- component: CustomCode,
2440
- ...componentInfo
2441
- },
2442
- {
2443
- component: Embed,
2444
- ...componentInfo$2
2445
- },
2446
- {
2447
- component: FragmentComponent,
2448
- ...componentInfo$8
2449
- },
2450
- {
2451
- component: Image,
2452
- ...componentInfo$7
2453
- },
2454
- {
2455
- component: ImgComponent,
2456
- ...componentInfo$1
2457
- },
2458
- {
2459
- component: SectionComponent,
2460
- ...componentInfo$6
2461
- },
2462
- {
2463
- component: Symbol$1,
2464
- ...componentInfo$5
2465
- },
2466
- {
2467
- component: Text,
2468
- ...componentInfo$4
2469
- },
2470
- {
2471
- component: Video,
2472
- ...componentInfo$3
2045
+ const getDefaultRegisteredComponents = () => [
2046
+ {
2047
+ component: Button,
2048
+ ...componentInfo$a
2049
+ },
2050
+ {
2051
+ component: Columns,
2052
+ ...componentInfo$9
2053
+ },
2054
+ {
2055
+ component: CustomCode,
2056
+ ...componentInfo
2057
+ },
2058
+ {
2059
+ component: Embed,
2060
+ ...componentInfo$2
2061
+ },
2062
+ {
2063
+ component: FragmentComponent,
2064
+ ...componentInfo$8
2065
+ },
2066
+ {
2067
+ component: Image,
2068
+ ...componentInfo$7
2069
+ },
2070
+ {
2071
+ component: ImgComponent,
2072
+ ...componentInfo$1
2073
+ },
2074
+ {
2075
+ component: SectionComponent,
2076
+ ...componentInfo$6
2077
+ },
2078
+ {
2079
+ component: Symbol$1,
2080
+ ...componentInfo$5
2081
+ },
2082
+ {
2083
+ component: Text,
2084
+ ...componentInfo$4
2085
+ },
2086
+ {
2087
+ component: Video,
2088
+ ...componentInfo$3
2089
+ }
2090
+ ];
2091
+ const MSG_PREFIX = "[Builder.io]: ";
2092
+ const logger = {
2093
+ log: (...message) => console.log(MSG_PREFIX, ...message),
2094
+ error: (...message) => console.error(MSG_PREFIX, ...message),
2095
+ warn: (...message) => console.warn(MSG_PREFIX, ...message),
2096
+ debug: (...message) => console.debug(MSG_PREFIX, ...message)
2097
+ };
2098
+ const getTopLevelDomain = (host) => {
2099
+ if (host === "localhost" || host === "127.0.0.1")
2100
+ return host;
2101
+ const parts = host.split(".");
2102
+ if (parts.length > 2)
2103
+ return parts.slice(1).join(".");
2104
+ return host;
2105
+ };
2106
+ const getCookieSync = ({ name, canTrack }) => {
2107
+ try {
2108
+ if (!canTrack)
2109
+ return void 0;
2110
+ return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
2111
+ } catch (err) {
2112
+ logger.warn("[COOKIE] GET error: ", err?.message || err);
2113
+ return void 0;
2114
+ }
2115
+ };
2116
+ const getCookie = async (args) => getCookieSync(args);
2117
+ const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
2118
+ const SECURE_CONFIG = [
2119
+ [
2120
+ "secure",
2121
+ ""
2122
+ ],
2123
+ [
2124
+ "SameSite",
2125
+ "None"
2126
+ ]
2127
+ ];
2128
+ const createCookieString = ({ name, value, expires }) => {
2129
+ const secure = isBrowser() ? location.protocol === "https:" : true;
2130
+ const secureObj = secure ? SECURE_CONFIG : [
2131
+ []
2132
+ ];
2133
+ const expiresObj = expires ? [
2134
+ [
2135
+ "expires",
2136
+ expires.toUTCString()
2137
+ ]
2138
+ ] : [
2139
+ []
2140
+ ];
2141
+ const cookieValue = [
2142
+ [
2143
+ name,
2144
+ value
2145
+ ],
2146
+ ...expiresObj,
2147
+ [
2148
+ "path",
2149
+ "/"
2150
+ ],
2151
+ [
2152
+ "domain",
2153
+ getTopLevelDomain(window.location.hostname)
2154
+ ],
2155
+ ...secureObj
2156
+ ];
2157
+ const cookie = stringifyCookie(cookieValue);
2158
+ return cookie;
2159
+ };
2160
+ const setCookie = async ({ name, value, expires, canTrack }) => {
2161
+ try {
2162
+ if (!canTrack)
2163
+ return;
2164
+ const cookie = createCookieString({
2165
+ name,
2166
+ value,
2167
+ expires
2168
+ });
2169
+ document.cookie = cookie;
2170
+ } catch (err) {
2171
+ logger.warn("[COOKIE] SET error: ", err?.message || err);
2172
+ }
2173
+ };
2174
+ const BUILDER_STORE_PREFIX = "builder.tests";
2175
+ const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
2176
+ const getContentVariationCookie = ({ contentId }) => getCookie({
2177
+ name: getContentTestKey(contentId),
2178
+ canTrack: true
2179
+ });
2180
+ const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
2181
+ name: getContentTestKey(contentId),
2182
+ canTrack: true
2183
+ });
2184
+ const setContentVariationCookie = ({ contentId, value }) => setCookie({
2185
+ name: getContentTestKey(contentId),
2186
+ value,
2187
+ canTrack: true
2188
+ });
2189
+ const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
2190
+ const getRandomVariationId = ({ id, variations }) => {
2191
+ let n = 0;
2192
+ const random = Math.random();
2193
+ for (const id2 in variations) {
2194
+ const testRatio = variations[id2]?.testRatio;
2195
+ n += testRatio;
2196
+ if (random < n)
2197
+ return id2;
2198
+ }
2199
+ return id;
2200
+ };
2201
+ const getAndSetVariantId = (args) => {
2202
+ const randomVariationId = getRandomVariationId(args);
2203
+ setContentVariationCookie({
2204
+ contentId: args.id,
2205
+ value: randomVariationId
2206
+ }).catch((err) => {
2207
+ logger.error("could not store A/B test variation: ", err);
2208
+ });
2209
+ return randomVariationId;
2210
+ };
2211
+ const getTestFields = ({ item, testGroupId }) => {
2212
+ const variationValue = item.variations[testGroupId];
2213
+ if (testGroupId === item.id || !variationValue)
2214
+ return {
2215
+ testVariationId: item.id,
2216
+ testVariationName: "Default"
2217
+ };
2218
+ else
2219
+ return {
2220
+ data: variationValue.data,
2221
+ testVariationId: variationValue.id,
2222
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
2223
+ };
2224
+ };
2225
+ const handleABTestingSync = ({ item, canTrack }) => {
2226
+ if (!canTrack)
2227
+ return item;
2228
+ if (!item)
2229
+ return void 0;
2230
+ if (!checkIsBuilderContentWithVariations(item))
2231
+ return item;
2232
+ const testGroupId = getContentVariationCookieSync({
2233
+ contentId: item.id
2234
+ }) || getAndSetVariantId({
2235
+ variations: item.variations,
2236
+ id: item.id
2237
+ });
2238
+ const variationValue = getTestFields({
2239
+ item,
2240
+ testGroupId
2241
+ });
2242
+ return {
2243
+ ...item,
2244
+ ...variationValue
2245
+ };
2246
+ };
2247
+ const handleABTesting = async ({ item, canTrack }) => {
2248
+ if (!canTrack)
2249
+ return item;
2250
+ if (!checkIsBuilderContentWithVariations(item))
2251
+ return item;
2252
+ const cookieValue = await getContentVariationCookie({
2253
+ contentId: item.id
2254
+ });
2255
+ const testGroupId = cookieValue || getAndSetVariantId({
2256
+ variations: item.variations,
2257
+ id: item.id
2258
+ });
2259
+ const variationValue = getTestFields({
2260
+ item,
2261
+ testGroupId
2262
+ });
2263
+ return {
2264
+ ...item,
2265
+ ...variationValue
2266
+ };
2267
+ };
2268
+ const getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
2269
+ function getGlobalThis() {
2270
+ if (typeof globalThis !== "undefined")
2271
+ return globalThis;
2272
+ if (typeof window !== "undefined")
2273
+ return window;
2274
+ if (typeof global !== "undefined")
2275
+ return global;
2276
+ if (typeof self !== "undefined")
2277
+ return self;
2278
+ return globalThis;
2279
+ }
2280
+ function getFetch() {
2281
+ const globalFetch = getGlobalThis().fetch;
2282
+ if (typeof globalFetch === "undefined") {
2283
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2284
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
2285
+ throw new Error("Builder SDK could not find a global `fetch` function");
2286
+ }
2287
+ return globalFetch;
2288
+ }
2289
+ const fetch$1 = getFetch();
2290
+ function flatten(object, path = null, separator = ".") {
2291
+ return Object.keys(object).reduce((acc, key) => {
2292
+ const value = object[key];
2293
+ const newPath = [
2294
+ path,
2295
+ key
2296
+ ].filter(Boolean).join(separator);
2297
+ const isObject = [
2298
+ typeof value === "object",
2299
+ value !== null,
2300
+ !(Array.isArray(value) && value.length === 0)
2301
+ ].every(Boolean);
2302
+ return isObject ? {
2303
+ ...acc,
2304
+ ...flatten(value, newPath, separator)
2305
+ } : {
2306
+ ...acc,
2307
+ [newPath]: value
2308
+ };
2309
+ }, {});
2310
+ }
2311
+ const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
2312
+ const BUILDER_OPTIONS_PREFIX = "options.";
2313
+ const convertSearchParamsToQueryObject = (searchParams) => {
2314
+ const options = {};
2315
+ searchParams.forEach((value, key) => {
2316
+ options[key] = value;
2317
+ });
2318
+ return options;
2319
+ };
2320
+ const getBuilderSearchParams = (_options) => {
2321
+ if (!_options)
2322
+ return {};
2323
+ const options = normalizeSearchParams(_options);
2324
+ const newOptions = {};
2325
+ Object.keys(options).forEach((key) => {
2326
+ if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2327
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
2328
+ newOptions[trimmedKey] = options[key];
2329
+ }
2330
+ });
2331
+ return newOptions;
2332
+ };
2333
+ const getBuilderSearchParamsFromWindow = () => {
2334
+ if (!isBrowser())
2335
+ return {};
2336
+ const searchParams = new URLSearchParams(window.location.search);
2337
+ return getBuilderSearchParams(searchParams);
2338
+ };
2339
+ const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
2340
+ const DEFAULT_API_VERSION = "v3";
2341
+ const generateContentUrl = (options) => {
2342
+ const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION } = options;
2343
+ if (!apiKey)
2344
+ throw new Error("Missing API key");
2345
+ if (![
2346
+ "v2",
2347
+ "v3"
2348
+ ].includes(apiVersion))
2349
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
2350
+ const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
2351
+ const queryOptions = {
2352
+ ...getBuilderSearchParamsFromWindow(),
2353
+ ...normalizeSearchParams(options.options || {})
2354
+ };
2355
+ const flattened = flatten(queryOptions);
2356
+ for (const key in flattened)
2357
+ url.searchParams.set(key, String(flattened[key]));
2358
+ if (userAttributes)
2359
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
2360
+ if (query) {
2361
+ const flattened2 = flatten({
2362
+ query
2363
+ });
2364
+ for (const key in flattened2)
2365
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
2366
+ }
2367
+ return url;
2368
+ };
2369
+ const checkContentHasResults = (content) => "results" in content;
2370
+ async function getContent(options) {
2371
+ const allContent = await getAllContent({
2372
+ ...options,
2373
+ limit: 1
2374
+ });
2375
+ if (allContent && checkContentHasResults(allContent))
2376
+ return allContent.results[0] || null;
2377
+ return null;
2378
+ }
2379
+ const fetchContent$1 = async (options) => {
2380
+ const url = generateContentUrl(options);
2381
+ const res = await fetch$1(url.href);
2382
+ const content = await res.json();
2383
+ return content;
2384
+ };
2385
+ const processContentResult = async (options, content) => {
2386
+ const canTrack = getDefaultCanTrack(options.canTrack);
2387
+ if (!canTrack)
2388
+ return content;
2389
+ if (!(isBrowser() || TARGET === "reactNative"))
2390
+ return content;
2391
+ try {
2392
+ const newResults = [];
2393
+ for (const item of content.results)
2394
+ newResults.push(await handleABTesting({
2395
+ item,
2396
+ canTrack
2397
+ }));
2398
+ content.results = newResults;
2399
+ } catch (e) {
2400
+ logger.error("Could not process A/B tests. ", e);
2401
+ }
2402
+ return content;
2403
+ };
2404
+ async function getAllContent(options) {
2405
+ try {
2406
+ const url = generateContentUrl(options);
2407
+ const content = await fetchContent$1(options);
2408
+ if (!checkContentHasResults(content)) {
2409
+ logger.error("Error fetching data. ", {
2410
+ url,
2411
+ content,
2412
+ options
2413
+ });
2414
+ return content;
2415
+ }
2416
+ return processContentResult(options, content);
2417
+ } catch (error) {
2418
+ logger.error("Error fetching data. ", error);
2419
+ return null;
2473
2420
  }
2474
- ];
2421
+ }
2475
2422
  function isPreviewing() {
2476
2423
  if (!isBrowser())
2477
2424
  return false;
@@ -2480,14 +2427,6 @@ function isPreviewing() {
2480
2427
  return Boolean(location.search.indexOf("builder.preview=") !== -1);
2481
2428
  }
2482
2429
  const components = [];
2483
- function registerComponent(component, info) {
2484
- components.push({
2485
- component,
2486
- ...info
2487
- });
2488
- console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
2489
- return component;
2490
- }
2491
2430
  const createRegisterComponentMessage = ({ component: _, ...info }) => ({
2492
2431
  type: "builder.registerComponent",
2493
2432
  data: prepareComponentInfoToSend(info)
@@ -2509,11 +2448,12 @@ function uuidv4() {
2509
2448
  function uuid() {
2510
2449
  return uuidv4().replace(/-/g, "");
2511
2450
  }
2451
+ const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
2512
2452
  const getSessionId = async ({ canTrack }) => {
2513
2453
  if (!canTrack)
2514
2454
  return void 0;
2515
2455
  const sessionId = await getCookie({
2516
- name: "builderSessionId",
2456
+ name: SESSION_LOCAL_STORAGE_KEY,
2517
2457
  canTrack
2518
2458
  });
2519
2459
  if (checkIsDefined(sessionId))
@@ -2529,7 +2469,7 @@ const getSessionId = async ({ canTrack }) => {
2529
2469
  };
2530
2470
  const createSessionId = () => uuid();
2531
2471
  const setSessionId = ({ id, canTrack }) => setCookie({
2532
- name: "builderSessionId",
2472
+ name: SESSION_LOCAL_STORAGE_KEY,
2533
2473
  value: id,
2534
2474
  canTrack
2535
2475
  });
@@ -2552,11 +2492,12 @@ const setLocalStorageItem = ({ key, canTrack, value }) => {
2552
2492
  console.debug("[LocalStorage] SET error: ", err);
2553
2493
  }
2554
2494
  };
2495
+ const VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
2555
2496
  const getVisitorId = ({ canTrack }) => {
2556
2497
  if (!canTrack)
2557
2498
  return void 0;
2558
2499
  const visitorId = getLocalStorageItem({
2559
- key: "builderVisitorId",
2500
+ key: VISITOR_LOCAL_STORAGE_KEY,
2560
2501
  canTrack
2561
2502
  });
2562
2503
  if (checkIsDefined(visitorId))
@@ -2572,7 +2513,7 @@ const getVisitorId = ({ canTrack }) => {
2572
2513
  };
2573
2514
  const createVisitorId = () => uuid();
2574
2515
  const setVisitorId = ({ id, canTrack }) => setLocalStorageItem({
2575
- key: "builderVisitorId",
2516
+ key: VISITOR_LOCAL_STORAGE_KEY,
2576
2517
  value: id,
2577
2518
  canTrack
2578
2519
  });
@@ -2730,6 +2671,7 @@ const getInteractionPropertiesForEvent = (event) => {
2730
2671
  }
2731
2672
  };
2732
2673
  };
2674
+ const SDK_VERSION = "0.4.0";
2733
2675
  const registry = {};
2734
2676
  function register(type, info) {
2735
2677
  let typeList = registry[type];
@@ -2797,6 +2739,7 @@ const setupBrowserForEditing = (options = {}) => {
2797
2739
  type: "builder.sdkInfo",
2798
2740
  data: {
2799
2741
  target: TARGET,
2742
+ version: SDK_VERSION,
2800
2743
  supportsPatchUpdates: false,
2801
2744
  supportsAddBlockScoping: true,
2802
2745
  supportsCustomBreakpoints: true
@@ -2856,6 +2799,128 @@ const setupBrowserForEditing = (options = {}) => {
2856
2799
  });
2857
2800
  }
2858
2801
  };
2802
+ const getVariants = (content) => Object.values(content?.variations || {});
2803
+ const checkShouldRunVariants = ({ canTrack, content }) => {
2804
+ const hasVariants = getVariants(content).length > 0;
2805
+ if (!hasVariants)
2806
+ return false;
2807
+ if (!canTrack)
2808
+ return false;
2809
+ if (isBrowser())
2810
+ return false;
2811
+ return true;
2812
+ };
2813
+ function bldrAbTest(contentId, variants, isHydrationTarget2) {
2814
+ function getAndSetVariantId2() {
2815
+ function setCookie2(name, value, days) {
2816
+ let expires = "";
2817
+ if (days) {
2818
+ const date = new Date();
2819
+ date.setTime(date.getTime() + days * 864e5);
2820
+ expires = "; expires=" + date.toUTCString();
2821
+ }
2822
+ document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
2823
+ }
2824
+ function getCookie2(name) {
2825
+ const nameEQ = name + "=";
2826
+ const ca = document.cookie.split(";");
2827
+ for (let i = 0; i < ca.length; i++) {
2828
+ let c = ca[i];
2829
+ while (c.charAt(0) === " ")
2830
+ c = c.substring(1, c.length);
2831
+ if (c.indexOf(nameEQ) === 0)
2832
+ return c.substring(nameEQ.length, c.length);
2833
+ }
2834
+ return null;
2835
+ }
2836
+ const cookieName = `builder.tests.${contentId}`;
2837
+ const variantInCookie = getCookie2(cookieName);
2838
+ const availableIDs = variants.map((vr) => vr.id).concat(contentId);
2839
+ if (variantInCookie && availableIDs.includes(variantInCookie))
2840
+ return variantInCookie;
2841
+ let n = 0;
2842
+ const random = Math.random();
2843
+ for (let i = 0; i < variants.length; i++) {
2844
+ const variant = variants[i];
2845
+ const testRatio = variant.testRatio;
2846
+ n += testRatio;
2847
+ if (random < n) {
2848
+ setCookie2(cookieName, variant.id);
2849
+ return variant.id;
2850
+ }
2851
+ }
2852
+ setCookie2(cookieName, contentId);
2853
+ return contentId;
2854
+ }
2855
+ const winningVariantId = getAndSetVariantId2();
2856
+ const styleEl = document.getElementById(`variants-styles-${contentId}`);
2857
+ if (isHydrationTarget2) {
2858
+ styleEl.remove();
2859
+ const thisScriptEl = document.getElementById(`variants-script-${contentId}`);
2860
+ thisScriptEl?.remove();
2861
+ } else {
2862
+ const newStyleStr = variants.concat({
2863
+ id: contentId
2864
+ }).filter((variant) => variant.id !== winningVariantId).map((value) => {
2865
+ return `.variant-${value.id} { display: none; }
2866
+ `;
2867
+ }).join("");
2868
+ styleEl.innerHTML = newStyleStr;
2869
+ }
2870
+ }
2871
+ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
2872
+ if (!navigator.cookieEnabled)
2873
+ return;
2874
+ function getCookie2(name) {
2875
+ const nameEQ = name + "=";
2876
+ const ca = document.cookie.split(";");
2877
+ for (let i = 0; i < ca.length; i++) {
2878
+ let c = ca[i];
2879
+ while (c.charAt(0) === " ")
2880
+ c = c.substring(1, c.length);
2881
+ if (c.indexOf(nameEQ) === 0)
2882
+ return c.substring(nameEQ.length, c.length);
2883
+ }
2884
+ return null;
2885
+ }
2886
+ const cookieName = `builder.tests.${defaultContentId}`;
2887
+ const variantId = getCookie2(cookieName);
2888
+ const parentDiv = document.querySelector(`[builder-content-id="${variantContentId}"]`);
2889
+ const variantIsDefaultContent = variantContentId === defaultContentId;
2890
+ if (variantId === variantContentId) {
2891
+ if (variantIsDefaultContent)
2892
+ return;
2893
+ parentDiv?.removeAttribute("hidden");
2894
+ parentDiv?.removeAttribute("aria-hidden");
2895
+ } else {
2896
+ if (variantIsDefaultContent) {
2897
+ if (isHydrationTarget2)
2898
+ parentDiv?.remove();
2899
+ else {
2900
+ parentDiv?.setAttribute("hidden", "true");
2901
+ parentDiv?.setAttribute("aria-hidden", "true");
2902
+ }
2903
+ }
2904
+ return;
2905
+ }
2906
+ return;
2907
+ }
2908
+ const isHydrationTarget = (target) => target === "react" || target === "reactNative" || target === "vue3" || target === "vue2";
2909
+ const AB_TEST_FN_NAME = "bldrAbTest";
2910
+ const CONTENT_FN_NAME = "bldrCntntScrpt";
2911
+ const getVariantsScriptString = (variants, contentId) => {
2912
+ const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
2913
+ const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
2914
+ return `
2915
+ const ${AB_TEST_FN_NAME} = ${fnStr}
2916
+ const ${CONTENT_FN_NAME} = ${fnStr2}
2917
+ ${AB_TEST_FN_NAME}("${contentId}", ${JSON.stringify(variants)}, ${isHydrationTarget})
2918
+ `;
2919
+ };
2920
+ const getRenderContentScriptString = ({ parentContentId, contentId }) => {
2921
+ return `
2922
+ ${CONTENT_FN_NAME}("${contentId}", "${parentContentId}", ${isHydrationTarget})`;
2923
+ };
2859
2924
  const getCssFromFont = (font) => {
2860
2925
  const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
2861
2926
  const name = family.split(",")[0];
@@ -2921,7 +2986,7 @@ ${getFontCss({
2921
2986
  text-align: inherit;
2922
2987
  font-family: inherit;
2923
2988
  }
2924
- `
2989
+ `.trim()
2925
2990
  });
2926
2991
  return /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
2927
2992
  get styles() {
@@ -2986,8 +3051,8 @@ const setBreakpoints = function setBreakpoints2(props, state, elementRef, breakp
2986
3051
  }
2987
3052
  };
2988
3053
  };
2989
- const setContextState = function setContextState2(props, state, elementRef, newState) {
2990
- state.contentState = newState;
3054
+ const contentSetState = function contentSetState2(props, state, elementRef, newRootState) {
3055
+ state.contentState = newRootState;
2991
3056
  };
2992
3057
  const processMessage = function processMessage2(props, state, elementRef, event) {
2993
3058
  const { data } = event;
@@ -3021,7 +3086,9 @@ const evaluateJsCode = function evaluateJsCode2(props, state, elementRef) {
3021
3086
  evaluate({
3022
3087
  code: jsCode,
3023
3088
  context: props.context || {},
3024
- state: state.contentState
3089
+ localState: void 0,
3090
+ rootState: state.contentState,
3091
+ rootSetState: contentSetState.bind(null, props, state, elementRef)
3025
3092
  });
3026
3093
  };
3027
3094
  const onClick = function onClick22(props, state, elementRef, event) {
@@ -3045,7 +3112,9 @@ const evalExpression = function evalExpression2(props, state, elementRef, expres
3045
3112
  return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
3046
3113
  code: group,
3047
3114
  context: props.context || {},
3048
- state: state.contentState
3115
+ localState: void 0,
3116
+ rootState: state.contentState,
3117
+ rootSetState: contentSetState.bind(null, props, state, elementRef)
3049
3118
  }));
3050
3119
  };
3051
3120
  const handleRequest = function handleRequest2(props, state, elementRef, { url, key }) {
@@ -3054,7 +3123,7 @@ const handleRequest = function handleRequest2(props, state, elementRef, { url, k
3054
3123
  ...state.contentState,
3055
3124
  [key]: json
3056
3125
  };
3057
- setContextState(props, state, elementRef, newState);
3126
+ contentSetState(props, state, elementRef, newState);
3058
3127
  }).catch((err) => {
3059
3128
  console.error("error fetching dynamic data", url, err);
3060
3129
  });
@@ -3090,9 +3159,12 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3090
3159
  ...getDefaultRegisteredComponents(),
3091
3160
  ...components,
3092
3161
  ...props.customComponents || []
3093
- ].reduce((acc, curr) => ({
3162
+ ].reduce((acc, { component, ...curr }) => ({
3094
3163
  ...acc,
3095
- [curr.name]: curr
3164
+ [curr.name]: {
3165
+ component,
3166
+ ...curr
3167
+ }
3096
3168
  }), {}),
3097
3169
  canTrackToUse: checkIsDefined(props.canTrack) ? props.canTrack : true,
3098
3170
  clicked: false,
@@ -3104,6 +3176,10 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3104
3176
  forceReRenderCount: 0,
3105
3177
  httpReqsData: {},
3106
3178
  overrideContent: null,
3179
+ scriptStr: getRenderContentScriptString({
3180
+ contentId: props.content?.id,
3181
+ parentContentId: props.parentContentId
3182
+ }),
3107
3183
  update: 0,
3108
3184
  useContent: getContentInitialValue({
3109
3185
  content: props.content,
@@ -3112,9 +3188,11 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3112
3188
  }, {
3113
3189
  deep: true
3114
3190
  });
3115
- qwik.useContextProvider(builderContext, qwik.useStore({
3191
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
3116
3192
  content: state.useContent,
3117
- state: state.contentState,
3193
+ localState: void 0,
3194
+ rootState: state.contentState,
3195
+ rootSetState: void 0,
3118
3196
  context: props.context || {},
3119
3197
  apiKey: props.apiKey,
3120
3198
  apiVersion: props.apiVersion,
@@ -3135,6 +3213,9 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3135
3213
  } : {},
3136
3214
  ...props2.includeRefs ? {
3137
3215
  includeRefs: props2.includeRefs
3216
+ } : {},
3217
+ ...props2.enrich ? {
3218
+ enrich: props2.enrich
3138
3219
  } : {}
3139
3220
  });
3140
3221
  Object.values(state2.allRegisteredComponents).forEach((registeredComponent) => {
@@ -3170,7 +3251,7 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3170
3251
  mergeNewContent(props2, state2, elementRef2, content);
3171
3252
  });
3172
3253
  }
3173
- evaluateJsCode(props2, state2);
3254
+ evaluateJsCode(props2, state2, elementRef2);
3174
3255
  runHttpRequests(props2, state2, elementRef2);
3175
3256
  emitStateUpdate(props2, state2);
3176
3257
  }
@@ -3193,7 +3274,7 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3193
3274
  const [elementRef2, props2, state2] = qwik.useLexicalScope();
3194
3275
  track2(() => state2.useContent?.data?.jsCode);
3195
3276
  track2(() => state2.contentState);
3196
- evaluateJsCode(props2, state2);
3277
+ evaluateJsCode(props2, state2, elementRef2);
3197
3278
  }, "RenderContent_component_useTask_1_X59YMGOetns", [
3198
3279
  elementRef,
3199
3280
  props,
@@ -3218,15 +3299,52 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3218
3299
  state
3219
3300
  ]));
3220
3301
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
3221
- children: state.useContent ? /* @__PURE__ */ qwik._jsxQ("div", {
3222
- ref: elementRef
3223
- }, {
3224
- "builder-content-id": qwik._fnSignal((p0) => p0.useContent?.id, [
3225
- state
3226
- ], "p0.useContent?.id"),
3227
- "builder-model": qwik._fnSignal((p0) => p0.model, [
3228
- props
3229
- ], "p0.model"),
3302
+ children: state.useContent ? /* @__PURE__ */ qwik._jsxS("div", {
3303
+ ref: elementRef,
3304
+ ...{},
3305
+ ...props.hideContent ? {
3306
+ hidden: true,
3307
+ "aria-hidden": true
3308
+ } : {},
3309
+ children: [
3310
+ props.isSsrAbTest ? /* @__PURE__ */ qwik._jsxQ("script", null, {
3311
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.scriptStr, [
3312
+ state
3313
+ ], "p0.scriptStr")
3314
+ }, null, 3, "03_0") : null,
3315
+ /* @__PURE__ */ qwik._jsxC(RenderContentStyles, {
3316
+ get contentId() {
3317
+ return state.useContent?.id;
3318
+ },
3319
+ get cssCode() {
3320
+ return state.useContent?.data?.cssCode;
3321
+ },
3322
+ get customFonts() {
3323
+ return state.useContent?.data?.customFonts;
3324
+ },
3325
+ [qwik._IMMUTABLE]: {
3326
+ contentId: qwik._fnSignal((p0) => p0.useContent?.id, [
3327
+ state
3328
+ ], "p0.useContent?.id"),
3329
+ cssCode: qwik._fnSignal((p0) => p0.useContent?.data?.cssCode, [
3330
+ state
3331
+ ], "p0.useContent?.data?.cssCode"),
3332
+ customFonts: qwik._fnSignal((p0) => p0.useContent?.data?.customFonts, [
3333
+ state
3334
+ ], "p0.useContent?.data?.customFonts")
3335
+ }
3336
+ }, 3, "03_1"),
3337
+ /* @__PURE__ */ qwik._jsxC(RenderBlocks, {
3338
+ get blocks() {
3339
+ return state.useContent?.data?.blocks;
3340
+ },
3341
+ [qwik._IMMUTABLE]: {
3342
+ blocks: qwik._fnSignal((p0) => p0.useContent?.data?.blocks, [
3343
+ state
3344
+ ], "p0.useContent?.data?.blocks")
3345
+ }
3346
+ }, 3, state.forceReRenderCount)
3347
+ ],
3230
3348
  onClick$: /* @__PURE__ */ qwik.inlinedQrl((event) => {
3231
3349
  const [elementRef2, props2, state2] = qwik.useLexicalScope();
3232
3350
  return onClick(props2, state2, elementRef2, event);
@@ -3235,42 +3353,285 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3235
3353
  props,
3236
3354
  state
3237
3355
  ])
3238
- }, [
3239
- /* @__PURE__ */ qwik._jsxC(RenderContentStyles, {
3240
- get contentId() {
3241
- return state.useContent?.id;
3356
+ }, {
3357
+ "builder-content-id": qwik._fnSignal((p0) => p0.useContent?.id, [
3358
+ state
3359
+ ], "p0.useContent?.id"),
3360
+ "builder-model": qwik._fnSignal((p0) => p0.model, [
3361
+ props
3362
+ ], "p0.model"),
3363
+ class: qwik._fnSignal((p0) => p0.classNameProp, [
3364
+ props
3365
+ ], "p0.classNameProp")
3366
+ }, 0, "03_2") : null
3367
+ }, 1, "03_3");
3368
+ }, "RenderContent_component_hEAI0ahViXM"));
3369
+ const fetchContent = function fetchContent2(props, state, builderContext) {
3370
+ if (!state.contentToUse && props.symbol?.model && builderContext?.apiKey)
3371
+ getContent({
3372
+ model: props.symbol.model,
3373
+ apiKey: builderContext.apiKey,
3374
+ apiVersion: builderContext.apiVersion,
3375
+ query: {
3376
+ id: props.symbol.entry
3377
+ }
3378
+ }).then((response) => {
3379
+ if (response)
3380
+ state.contentToUse = response;
3381
+ }).catch((err) => {
3382
+ logger.error("Could not fetch symbol content: ", err);
3383
+ });
3384
+ };
3385
+ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
3386
+ const builderContext = qwik.useContext(BuilderContext);
3387
+ const state = qwik.useStore({
3388
+ className: [
3389
+ ...[
3390
+ props.attributes.class
3391
+ ],
3392
+ "builder-symbol",
3393
+ props.symbol?.inline ? "builder-inline-symbol" : void 0,
3394
+ props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
3395
+ ].filter(Boolean).join(" "),
3396
+ contentToUse: props.symbol?.content
3397
+ });
3398
+ qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
3399
+ const [builderContext2, props2, state2] = qwik.useLexicalScope();
3400
+ fetchContent(props2, state2, builderContext2);
3401
+ }, "Symbol_component_useVisibleTask_oMPs8W5ZhwE", [
3402
+ builderContext,
3403
+ props,
3404
+ state
3405
+ ]));
3406
+ qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(({ track: track2 }) => {
3407
+ const [builderContext2, props2, state2] = qwik.useLexicalScope();
3408
+ track2(() => props2.symbol);
3409
+ fetchContent(props2, state2, builderContext2);
3410
+ }, "Symbol_component_useTask_NIAWAC1bMBo", [
3411
+ builderContext,
3412
+ props,
3413
+ state
3414
+ ]));
3415
+ return /* @__PURE__ */ qwik._jsxS("div", {
3416
+ ...props.attributes,
3417
+ children: /* @__PURE__ */ qwik._jsxC(RenderContent, {
3418
+ get apiVersion() {
3419
+ return builderContext.apiVersion;
3420
+ },
3421
+ get apiKey() {
3422
+ return builderContext.apiKey;
3423
+ },
3424
+ get context() {
3425
+ return builderContext.context;
3426
+ },
3427
+ get customComponents() {
3428
+ return Object.values(builderContext.registeredComponents);
3429
+ },
3430
+ get data() {
3431
+ return {
3432
+ ...props.symbol?.data,
3433
+ ...builderContext.localState,
3434
+ ...state.contentToUse?.data?.state
3435
+ };
3436
+ },
3437
+ get model() {
3438
+ return props.symbol?.model;
3439
+ },
3440
+ get content() {
3441
+ return state.contentToUse;
3442
+ },
3443
+ [qwik._IMMUTABLE]: {
3444
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3445
+ builderContext
3446
+ ], "p0.apiVersion"),
3447
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3448
+ builderContext
3449
+ ], "p0.apiKey"),
3450
+ context: qwik._fnSignal((p0) => p0.context, [
3451
+ builderContext
3452
+ ], "p0.context"),
3453
+ customComponents: qwik._fnSignal((p0) => Object.values(p0.registeredComponents), [
3454
+ builderContext
3455
+ ], "Object.values(p0.registeredComponents)"),
3456
+ data: qwik._fnSignal((p0, p1, p2) => ({
3457
+ ...p1.symbol?.data,
3458
+ ...p0.localState,
3459
+ ...p2.contentToUse?.data?.state
3460
+ }), [
3461
+ builderContext,
3462
+ props,
3463
+ state
3464
+ ], "{...p1.symbol?.data,...p0.localState,...p2.contentToUse?.data?.state}"),
3465
+ model: qwik._fnSignal((p0) => p0.symbol?.model, [
3466
+ props
3467
+ ], "p0.symbol?.model"),
3468
+ content: qwik._fnSignal((p0) => p0.contentToUse, [
3469
+ state
3470
+ ], "p0.contentToUse")
3471
+ }
3472
+ }, 3, "Wt_0")
3473
+ }, {
3474
+ class: qwik._fnSignal((p0) => p0.className, [
3475
+ state
3476
+ ], "p0.className")
3477
+ }, 0, "Wt_1");
3478
+ }, "Symbol_component_WVvggdkUPdk"));
3479
+ const RenderContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
3480
+ qwik._jsxBranch();
3481
+ const state = qwik.useStore({
3482
+ contentToRender: checkShouldRunVariants({
3483
+ canTrack: getDefaultCanTrack(props.canTrack),
3484
+ content: props.content
3485
+ }) ? props.content : handleABTestingSync({
3486
+ item: props.content,
3487
+ canTrack: getDefaultCanTrack(props.canTrack)
3488
+ }),
3489
+ hideVariantsStyleString: getVariants(props.content).map((value) => `.variant-${value.id} { display: none; } `).join(""),
3490
+ shouldRenderVariants: checkShouldRunVariants({
3491
+ canTrack: getDefaultCanTrack(props.canTrack),
3492
+ content: props.content
3493
+ }),
3494
+ variantScriptStr: getVariantsScriptString(getVariants(props.content).map((value) => ({
3495
+ id: value.id,
3496
+ testRatio: value.testRatio
3497
+ })), props.content?.id || "")
3498
+ });
3499
+ return /* @__PURE__ */ qwik._jsxC(qwik.Fragment, {
3500
+ children: [
3501
+ state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
3502
+ children: [
3503
+ /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
3504
+ get id() {
3505
+ return `variants-styles-${props.content?.id}`;
3506
+ },
3507
+ get styles() {
3508
+ return state.hideVariantsStyleString;
3509
+ },
3510
+ [qwik._IMMUTABLE]: {
3511
+ id: qwik._fnSignal((p0) => `variants-styles-${p0.content?.id}`, [
3512
+ props
3513
+ ], "`variants-styles-${p0.content?.id}`"),
3514
+ styles: qwik._fnSignal((p0) => p0.hideVariantsStyleString, [
3515
+ state
3516
+ ], "p0.hideVariantsStyleString")
3517
+ }
3518
+ }, 3, "Bz_0"),
3519
+ /* @__PURE__ */ qwik._jsxQ("script", null, {
3520
+ id: qwik._fnSignal((p0) => `variants-script-${p0.content?.id}`, [
3521
+ props
3522
+ ], "`variants-script-${p0.content?.id}`"),
3523
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.variantScriptStr, [
3524
+ state
3525
+ ], "p0.variantScriptStr")
3526
+ }, null, 3, null),
3527
+ (getVariants(props.content) || []).map(function(variant) {
3528
+ return /* @__PURE__ */ qwik._jsxC(RenderContent, {
3529
+ content: variant,
3530
+ get apiKey() {
3531
+ return props.apiKey;
3532
+ },
3533
+ get apiVersion() {
3534
+ return props.apiVersion;
3535
+ },
3536
+ get canTrack() {
3537
+ return props.canTrack;
3538
+ },
3539
+ get customComponents() {
3540
+ return props.customComponents;
3541
+ },
3542
+ hideContent: true,
3543
+ get parentContentId() {
3544
+ return props.content?.id;
3545
+ },
3546
+ get isSsrAbTest() {
3547
+ return state.shouldRenderVariants;
3548
+ },
3549
+ [qwik._IMMUTABLE]: {
3550
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3551
+ props
3552
+ ], "p0.apiKey"),
3553
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3554
+ props
3555
+ ], "p0.apiVersion"),
3556
+ canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3557
+ props
3558
+ ], "p0.canTrack"),
3559
+ customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3560
+ props
3561
+ ], "p0.customComponents"),
3562
+ hideContent: qwik._IMMUTABLE,
3563
+ parentContentId: qwik._fnSignal((p0) => p0.content?.id, [
3564
+ props
3565
+ ], "p0.content?.id"),
3566
+ isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3567
+ state
3568
+ ], "p0.shouldRenderVariants")
3569
+ }
3570
+ }, 3, variant.id);
3571
+ })
3572
+ ]
3573
+ }, 1, "Bz_1") : null,
3574
+ /* @__PURE__ */ qwik._jsxC(RenderContent, {
3575
+ get model() {
3576
+ return props.model;
3242
3577
  },
3243
- get cssCode() {
3244
- return state.useContent?.data?.cssCode;
3578
+ get content() {
3579
+ return state.contentToRender;
3245
3580
  },
3246
- get customFonts() {
3247
- return state.useContent?.data?.customFonts;
3581
+ get apiKey() {
3582
+ return props.apiKey;
3248
3583
  },
3249
- [qwik._IMMUTABLE]: {
3250
- contentId: qwik._fnSignal((p0) => p0.useContent?.id, [
3251
- state
3252
- ], "p0.useContent?.id"),
3253
- cssCode: qwik._fnSignal((p0) => p0.useContent?.data?.cssCode, [
3254
- state
3255
- ], "p0.useContent?.data?.cssCode"),
3256
- customFonts: qwik._fnSignal((p0) => p0.useContent?.data?.customFonts, [
3257
- state
3258
- ], "p0.useContent?.data?.customFonts")
3259
- }
3260
- }, 3, "03_0"),
3261
- /* @__PURE__ */ qwik._jsxC(RenderBlocks, {
3262
- get blocks() {
3263
- return state.useContent?.data?.blocks;
3584
+ get apiVersion() {
3585
+ return props.apiVersion;
3586
+ },
3587
+ get canTrack() {
3588
+ return props.canTrack;
3589
+ },
3590
+ get customComponents() {
3591
+ return props.customComponents;
3592
+ },
3593
+ get classNameProp() {
3594
+ return `variant-${props.content?.id}`;
3595
+ },
3596
+ get parentContentId() {
3597
+ return props.content?.id;
3598
+ },
3599
+ get isSsrAbTest() {
3600
+ return state.shouldRenderVariants;
3264
3601
  },
3265
3602
  [qwik._IMMUTABLE]: {
3266
- blocks: qwik._fnSignal((p0) => p0.useContent?.data?.blocks, [
3603
+ model: qwik._fnSignal((p0) => p0.model, [
3604
+ props
3605
+ ], "p0.model"),
3606
+ content: qwik._fnSignal((p0) => p0.contentToRender, [
3607
+ state
3608
+ ], "p0.contentToRender"),
3609
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3610
+ props
3611
+ ], "p0.apiKey"),
3612
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3613
+ props
3614
+ ], "p0.apiVersion"),
3615
+ canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3616
+ props
3617
+ ], "p0.canTrack"),
3618
+ customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3619
+ props
3620
+ ], "p0.customComponents"),
3621
+ classNameProp: qwik._fnSignal((p0) => `variant-${p0.content?.id}`, [
3622
+ props
3623
+ ], "`variant-${p0.content?.id}`"),
3624
+ parentContentId: qwik._fnSignal((p0) => p0.content?.id, [
3625
+ props
3626
+ ], "p0.content?.id"),
3627
+ isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3267
3628
  state
3268
- ], "p0.useContent?.data?.blocks")
3629
+ ], "p0.shouldRenderVariants")
3269
3630
  }
3270
- }, 3, state.forceReRenderCount)
3271
- ], 1, "03_1") : null
3272
- }, 1, "03_2");
3273
- }, "RenderContent_component_hEAI0ahViXM"));
3631
+ }, 3, "Bz_2")
3632
+ ]
3633
+ }, 1, "Bz_3");
3634
+ }, "RenderContentVariants_component_OMvvre8Ofjw"));
3274
3635
  const settings = {};
3275
3636
  function setEditorSettings(newSettings) {
3276
3637
  if (isBrowser()) {
@@ -3287,22 +3648,17 @@ exports.Columns = Columns;
3287
3648
  exports.Fragment = FragmentComponent;
3288
3649
  exports.Image = Image;
3289
3650
  exports.RenderBlocks = RenderBlocks;
3290
- exports.RenderContent = RenderContent;
3651
+ exports.RenderContent = RenderContentVariants;
3291
3652
  exports.Section = SectionComponent;
3292
3653
  exports.Symbol = Symbol$1;
3293
3654
  exports.Text = Text;
3294
3655
  exports.Video = Video;
3295
- exports.components = components;
3296
- exports.convertSearchParamsToQueryObject = convertSearchParamsToQueryObject;
3297
3656
  exports.createRegisterComponentMessage = createRegisterComponentMessage;
3298
3657
  exports.getAllContent = getAllContent;
3299
- exports.getBuilderSearchParams = getBuilderSearchParams;
3300
- exports.getBuilderSearchParamsFromWindow = getBuilderSearchParamsFromWindow;
3301
3658
  exports.getContent = getContent;
3302
3659
  exports.isEditing = isEditing;
3303
3660
  exports.isPreviewing = isPreviewing;
3304
- exports.normalizeSearchParams = normalizeSearchParams;
3661
+ exports.processContentResult = processContentResult;
3305
3662
  exports.register = register;
3306
- exports.registerComponent = registerComponent;
3307
3663
  exports.setEditorSettings = setEditorSettings;
3308
3664
  exports.track = track;