@builder.io/sdk-qwik 0.5.2 → 0.5.3-1

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.
@@ -0,0 +1,4092 @@
1
+ import { componentQrl, inlinedQrl, useStylesScopedQrl, _jsxC, _jsxS, _fnSignal, createContextId, _jsxQ, _jsxBranch, useStore, useComputedQrl, useLexicalScope, _IMMUTABLE, Slot, useContextProvider, _wrapProp, useContext, createElement, Fragment as Fragment$1, useSignal, useTaskQrl, useVisibleTaskQrl } from "@builder.io/qwik";
2
+ import { Fragment } from "@builder.io/qwik/jsx-runtime";
3
+ const Button = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
4
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES$3, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
5
+ return /* @__PURE__ */ _jsxC(Fragment, {
6
+ children: props.link ? /* @__PURE__ */ _jsxS("a", {
7
+ ...props.attributes,
8
+ children: _fnSignal((p0) => p0.text, [
9
+ props
10
+ ], "p0.text")
11
+ }, {
12
+ role: "button",
13
+ href: _fnSignal((p0) => p0.link, [
14
+ props
15
+ ], "p0.link"),
16
+ target: _fnSignal((p0) => p0.openLinkInNewTab ? "_blank" : void 0, [
17
+ props
18
+ ], 'p0.openLinkInNewTab?"_blank":undefined')
19
+ }, 0, "jc_0") : /* @__PURE__ */ _jsxS("button", {
20
+ ...props.attributes,
21
+ children: _fnSignal((p0) => p0.text, [
22
+ props
23
+ ], "p0.text")
24
+ }, {
25
+ style: _fnSignal((p0) => p0.attributes.style, [
26
+ props
27
+ ], "p0.attributes.style"),
28
+ class: _fnSignal((p0) => p0.attributes.class + " button-Button", [
29
+ props
30
+ ], 'p0.attributes.class+" button-Button"')
31
+ }, 0, null)
32
+ }, 1, "jc_1");
33
+ }, "Button_component_gJoMUICXoUQ"));
34
+ const STYLES$3 = `
35
+ .button-Button {
36
+ all: unset;
37
+ }
38
+ `;
39
+ const builderContext = createContextId("Builder");
40
+ const ComponentsContext = createContextId("Components");
41
+ function getBlockComponentOptions(block) {
42
+ return {
43
+ ...block.component?.options,
44
+ ...block.options,
45
+ builderBlock: block
46
+ };
47
+ }
48
+ const MSG_PREFIX = "[Builder.io]: ";
49
+ const logger = {
50
+ log: (...message) => console.log(MSG_PREFIX, ...message),
51
+ error: (...message) => console.error(MSG_PREFIX, ...message),
52
+ warn: (...message) => console.warn(MSG_PREFIX, ...message),
53
+ debug: (...message) => console.debug(MSG_PREFIX, ...message)
54
+ };
55
+ function isBrowser() {
56
+ return typeof window !== "undefined" && typeof document !== "undefined";
57
+ }
58
+ const TARGET = "qwik";
59
+ function isIframe() {
60
+ return isBrowser() && window.self !== window.top;
61
+ }
62
+ function isEditing() {
63
+ return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
64
+ }
65
+ function isNonNodeServer() {
66
+ const hasNode = () => typeof process !== "undefined" && process?.versions?.node;
67
+ return !isBrowser() && !hasNode();
68
+ }
69
+ let runInNonNode;
70
+ (async () => {
71
+ if (isNonNodeServer())
72
+ runInNonNode = (await import("./non-node-runtime.b19012f1.js")).runInNonNode;
73
+ })();
74
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
75
+ if (code === "") {
76
+ logger.warn("Skipping evaluation of empty code block.");
77
+ return;
78
+ }
79
+ const builder = {
80
+ isEditing: isEditing(),
81
+ isBrowser: isBrowser(),
82
+ isServer: !isBrowser()
83
+ };
84
+ const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
85
+ const useCode = useReturn ? `return (${code});` : code;
86
+ const args = {
87
+ useCode,
88
+ builder,
89
+ context,
90
+ event,
91
+ rootSetState,
92
+ rootState,
93
+ localState
94
+ };
95
+ if (isBrowser())
96
+ return runInBrowser(args);
97
+ if (isNonNodeServer())
98
+ return runInNonNode(args);
99
+ return runInNode(args);
100
+ }
101
+ const runInBrowser = ({ useCode, builder, context, event, localState, rootSetState, rootState }) => {
102
+ const state = flattenState(rootState, localState, rootSetState);
103
+ try {
104
+ return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
105
+ } catch (e) {
106
+ logger.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e);
107
+ }
108
+ };
109
+ const runInNode = (args) => {
110
+ return runInBrowser(args);
111
+ };
112
+ function flattenState(rootState, localState, rootSetState) {
113
+ if (rootState === localState)
114
+ throw new Error("rootState === localState");
115
+ return new Proxy(rootState, {
116
+ get: (_, prop) => {
117
+ if (localState && prop in localState)
118
+ return localState[prop];
119
+ return rootState[prop];
120
+ },
121
+ set: (_, prop, value) => {
122
+ if (localState && prop in localState)
123
+ throw new Error("Writing to local state is not allowed as it is read-only.");
124
+ rootState[prop] = value;
125
+ rootSetState?.(rootState);
126
+ return true;
127
+ }
128
+ });
129
+ }
130
+ const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
131
+ const set = (obj, _path, value) => {
132
+ if (Object(obj) !== obj)
133
+ return obj;
134
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
135
+ path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
136
+ return obj;
137
+ };
138
+ function transformBlock(block) {
139
+ return block;
140
+ }
141
+ const evaluateBindings = ({ block, context, localState, rootState, rootSetState }) => {
142
+ if (!block.bindings)
143
+ return block;
144
+ const copy = fastClone(block);
145
+ const copied = {
146
+ ...copy,
147
+ properties: {
148
+ ...copy.properties
149
+ },
150
+ actions: {
151
+ ...copy.actions
152
+ }
153
+ };
154
+ for (const binding in block.bindings) {
155
+ const expression = block.bindings[binding];
156
+ const value = evaluate({
157
+ code: expression,
158
+ localState,
159
+ rootState,
160
+ rootSetState,
161
+ context
162
+ });
163
+ set(copied, binding, value);
164
+ }
165
+ return copied;
166
+ };
167
+ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState }) {
168
+ const transformedBlock = transformBlock(block);
169
+ if (shouldEvaluateBindings)
170
+ return evaluateBindings({
171
+ block: transformedBlock,
172
+ localState,
173
+ rootState,
174
+ rootSetState,
175
+ context
176
+ });
177
+ else
178
+ return transformedBlock;
179
+ }
180
+ const EMPTY_HTML_ELEMENTS = [
181
+ "area",
182
+ "base",
183
+ "br",
184
+ "col",
185
+ "embed",
186
+ "hr",
187
+ "img",
188
+ "input",
189
+ "keygen",
190
+ "link",
191
+ "meta",
192
+ "param",
193
+ "source",
194
+ "track",
195
+ "wbr"
196
+ ];
197
+ const isEmptyHtmlElement = (tagName) => {
198
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
199
+ };
200
+ const getComponent = ({ block, context, registeredComponents }) => {
201
+ const componentName = getProcessedBlock({
202
+ block,
203
+ localState: context.localState,
204
+ rootState: context.rootState,
205
+ rootSetState: context.rootSetState,
206
+ context: context.context,
207
+ shouldEvaluateBindings: false
208
+ }).component?.name;
209
+ if (!componentName)
210
+ return null;
211
+ const ref = registeredComponents[componentName];
212
+ if (!ref) {
213
+ console.warn(`
214
+ Could not find a registered component named "${componentName}".
215
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
216
+ return void 0;
217
+ } else
218
+ return ref;
219
+ };
220
+ const getRepeatItemData = ({ block, context }) => {
221
+ const { repeat, ...blockWithoutRepeat } = block;
222
+ if (!repeat?.collection)
223
+ return void 0;
224
+ const itemsArray = evaluate({
225
+ code: repeat.collection,
226
+ localState: context.localState,
227
+ rootState: context.rootState,
228
+ rootSetState: context.rootSetState,
229
+ context: context.context
230
+ });
231
+ if (!Array.isArray(itemsArray))
232
+ return void 0;
233
+ const collectionName = repeat.collection.split(".").pop();
234
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
235
+ const repeatArray = itemsArray.map((item, index) => ({
236
+ context: {
237
+ ...context,
238
+ localState: {
239
+ ...context.localState,
240
+ $index: index,
241
+ $item: item,
242
+ [itemNameToUse]: item,
243
+ [`$${itemNameToUse}Index`]: index
244
+ }
245
+ },
246
+ block: blockWithoutRepeat
247
+ }));
248
+ return repeatArray;
249
+ };
250
+ const SIZES = {
251
+ small: {
252
+ min: 320,
253
+ default: 321,
254
+ max: 640
255
+ },
256
+ medium: {
257
+ min: 641,
258
+ default: 642,
259
+ max: 991
260
+ },
261
+ large: {
262
+ min: 990,
263
+ default: 991,
264
+ max: 1200
265
+ }
266
+ };
267
+ const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
268
+ const getSizesForBreakpoints = ({ small, medium }) => {
269
+ const newSizes = fastClone(SIZES);
270
+ if (!small || !medium)
271
+ return newSizes;
272
+ const smallMin = Math.floor(small / 2);
273
+ newSizes.small = {
274
+ max: small,
275
+ min: smallMin,
276
+ default: smallMin + 1
277
+ };
278
+ const mediumMin = newSizes.small.max + 1;
279
+ newSizes.medium = {
280
+ max: medium,
281
+ min: mediumMin,
282
+ default: mediumMin + 1
283
+ };
284
+ const largeMin = newSizes.medium.max + 1;
285
+ newSizes.large = {
286
+ max: 2e3,
287
+ min: largeMin,
288
+ default: largeMin + 1
289
+ };
290
+ return newSizes;
291
+ };
292
+ const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
293
+ const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
294
+ const convertStyleMapToCSSArray = (style) => {
295
+ const cssProps = Object.entries(style).map(([key, value]) => {
296
+ if (typeof value === "string")
297
+ return `${camelToKebabCase(key)}: ${value};`;
298
+ else
299
+ return void 0;
300
+ });
301
+ return cssProps.filter(checkIsDefined);
302
+ };
303
+ const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
304
+ const createCssClass = ({ mediaQuery, className, styles }) => {
305
+ const cssClass = `.${className} {
306
+ ${convertStyleMapToCSS(styles)}
307
+ }`;
308
+ if (mediaQuery)
309
+ return `${mediaQuery} {
310
+ ${cssClass}
311
+ }`;
312
+ else
313
+ return cssClass;
314
+ };
315
+ const InlinedStyles = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
316
+ return /* @__PURE__ */ _jsxQ("style", null, {
317
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.styles, [
318
+ props
319
+ ], "p0.styles"),
320
+ id: _fnSignal((p0) => p0.id, [
321
+ props
322
+ ], "p0.id")
323
+ }, null, 3, "NG_0");
324
+ }, "InlinedStyles_component_IOsg46hMexk"));
325
+ const BlockStyles = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
326
+ _jsxBranch();
327
+ const state = useStore({
328
+ processedBlock: getProcessedBlock({
329
+ block: props.block,
330
+ localState: props.context.localState,
331
+ rootState: props.context.rootState,
332
+ rootSetState: props.context.rootSetState,
333
+ context: props.context.context,
334
+ shouldEvaluateBindings: true
335
+ })
336
+ });
337
+ const canShowBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
338
+ const [state2] = useLexicalScope();
339
+ if (checkIsDefined(state2.processedBlock.hide))
340
+ return !state2.processedBlock.hide;
341
+ if (checkIsDefined(state2.processedBlock.show))
342
+ return state2.processedBlock.show;
343
+ return true;
344
+ }, "BlockStyles_component_canShowBlock_useComputed_YHoS9Lak9z4", [
345
+ state
346
+ ]));
347
+ const css = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
348
+ const [props2, state2] = useLexicalScope();
349
+ const styles = state2.processedBlock.responsiveStyles;
350
+ const content = props2.context.content;
351
+ const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
352
+ const largeStyles = styles?.large;
353
+ const mediumStyles = styles?.medium;
354
+ const smallStyles = styles?.small;
355
+ const className = state2.processedBlock.id;
356
+ if (!className)
357
+ return "";
358
+ const largeStylesClass = largeStyles ? createCssClass({
359
+ className,
360
+ styles: largeStyles
361
+ }) : "";
362
+ const mediumStylesClass = mediumStyles ? createCssClass({
363
+ className,
364
+ styles: mediumStyles,
365
+ mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints)
366
+ }) : "";
367
+ const smallStylesClass = smallStyles ? createCssClass({
368
+ className,
369
+ styles: smallStyles,
370
+ mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
371
+ }) : "";
372
+ return [
373
+ largeStylesClass,
374
+ mediumStylesClass,
375
+ smallStylesClass
376
+ ].join(" ");
377
+ }, "BlockStyles_component_css_useComputed_b9Ru8qTcNik", [
378
+ props,
379
+ state
380
+ ]));
381
+ return /* @__PURE__ */ _jsxC(Fragment, {
382
+ children: css.value && canShowBlock.value ? /* @__PURE__ */ _jsxC(InlinedStyles, {
383
+ get styles() {
384
+ return css.value;
385
+ },
386
+ [_IMMUTABLE]: {
387
+ styles: _fnSignal((p0) => p0.value, [
388
+ css
389
+ ], "p0.value")
390
+ }
391
+ }, 3, "8B_0") : null
392
+ }, 1, "8B_1");
393
+ }, "BlockStyles_component_0lZeirBI638"));
394
+ function capitalizeFirstLetter(string) {
395
+ return string.charAt(0).toUpperCase() + string.slice(1);
396
+ }
397
+ const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}$`;
398
+ function createEventHandler(value, options) {
399
+ return /* @__PURE__ */ inlinedQrl((event) => {
400
+ const [options2, value2] = useLexicalScope();
401
+ return evaluate({
402
+ code: value2,
403
+ context: options2.context,
404
+ localState: options2.localState,
405
+ rootState: options2.rootState,
406
+ rootSetState: options2.rootSetState,
407
+ event
408
+ });
409
+ }, "createEventHandler_7wCAiJVliNE", [
410
+ options,
411
+ value
412
+ ]);
413
+ }
414
+ function getBlockActions(options) {
415
+ const obj = {};
416
+ const optionActions = options.block.actions ?? {};
417
+ for (const key in optionActions) {
418
+ if (!optionActions.hasOwnProperty(key))
419
+ continue;
420
+ const value = optionActions[key];
421
+ let eventHandlerName = getEventHandlerName(key);
422
+ if (options.stripPrefix)
423
+ switch (TARGET) {
424
+ case "vue2":
425
+ case "vue3":
426
+ eventHandlerName = eventHandlerName.replace("v-on:", "");
427
+ break;
428
+ case "svelte":
429
+ eventHandlerName = eventHandlerName.replace("on:", "");
430
+ break;
431
+ }
432
+ obj[eventHandlerName] = createEventHandler(value, options);
433
+ }
434
+ return obj;
435
+ }
436
+ function transformBlockProperties(properties) {
437
+ return properties;
438
+ }
439
+ const extractRelevantRootBlockProperties = (block) => {
440
+ return {
441
+ href: block.href
442
+ };
443
+ };
444
+ function getBlockProperties({ block, context }) {
445
+ const properties = {
446
+ ...extractRelevantRootBlockProperties(block),
447
+ ...block.properties,
448
+ "builder-id": block.id,
449
+ style: block.style ? getStyleAttribute(block.style) : void 0,
450
+ class: [
451
+ block.id,
452
+ "builder-block",
453
+ block.class,
454
+ block.properties?.class
455
+ ].filter(Boolean).join(" ")
456
+ };
457
+ return transformBlockProperties(properties);
458
+ }
459
+ function getStyleAttribute(style) {
460
+ switch (TARGET) {
461
+ case "svelte":
462
+ case "vue2":
463
+ case "vue3":
464
+ case "solid":
465
+ return convertStyleMapToCSSArray(style).join(" ");
466
+ case "qwik":
467
+ case "reactNative":
468
+ case "react":
469
+ case "rsc":
470
+ return style;
471
+ }
472
+ }
473
+ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
474
+ _jsxBranch();
475
+ return /* @__PURE__ */ _jsxC(Fragment, {
476
+ children: props.hasChildren ? /* @__PURE__ */ _jsxC(props.Wrapper, {
477
+ ...getBlockProperties({
478
+ block: props.block,
479
+ context: props.context
480
+ }),
481
+ ...getBlockActions({
482
+ block: props.block,
483
+ rootState: props.context.rootState,
484
+ rootSetState: props.context.rootSetState,
485
+ localState: props.context.localState,
486
+ context: props.context.context,
487
+ stripPrefix: true
488
+ }),
489
+ children: /* @__PURE__ */ _jsxC(Slot, null, 3, "87_0")
490
+ }, 0, "87_1") : /* @__PURE__ */ _jsxC(props.Wrapper, {
491
+ ...getBlockProperties({
492
+ block: props.block,
493
+ context: props.context
494
+ }),
495
+ ...getBlockActions({
496
+ block: props.block,
497
+ rootState: props.context.rootState,
498
+ rootSetState: props.context.rootSetState,
499
+ localState: props.context.localState,
500
+ context: props.context.context,
501
+ stripPrefix: true
502
+ })
503
+ }, 0, "87_2")
504
+ }, 1, "87_3");
505
+ }, "BlockWrapper_component_kOI0j0aW8Nw"));
506
+ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
507
+ return /* @__PURE__ */ _jsxC(props.Wrapper, {
508
+ ...props.wrapperProps,
509
+ attributes: {
510
+ ...getBlockProperties({
511
+ block: props.block,
512
+ context: props.context
513
+ }),
514
+ ...getBlockActions({
515
+ block: props.block,
516
+ rootState: props.context.rootState,
517
+ rootSetState: props.context.rootSetState,
518
+ localState: props.context.localState,
519
+ context: props.context.context
520
+ })
521
+ },
522
+ children: /* @__PURE__ */ _jsxC(Slot, null, 3, "q0_0")
523
+ }, 0, "q0_1");
524
+ }, "InteractiveElement_component_0UqfJpjhn0g"));
525
+ const getWrapperProps = ({ componentOptions, builderBlock, context, componentRef, includeBlockProps, isInteractive, contextValue }) => {
526
+ const interactiveElementProps = {
527
+ Wrapper: componentRef,
528
+ block: builderBlock,
529
+ context,
530
+ wrapperProps: componentOptions
531
+ };
532
+ return isInteractive ? interactiveElementProps : {
533
+ ...componentOptions,
534
+ ...includeBlockProps ? {
535
+ attributes: getBlockProperties({
536
+ block: builderBlock,
537
+ context: contextValue
538
+ })
539
+ } : {}
540
+ };
541
+ };
542
+ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
543
+ const state = useStore({
544
+ Wrapper: props.isInteractive ? InteractiveElement : props.componentRef
545
+ });
546
+ return /* @__PURE__ */ _jsxC(Fragment, {
547
+ children: props.componentRef ? /* @__PURE__ */ _jsxC(state.Wrapper, {
548
+ ...getWrapperProps({
549
+ componentOptions: props.componentOptions,
550
+ builderBlock: props.builderBlock,
551
+ context: props.context,
552
+ componentRef: props.componentRef,
553
+ includeBlockProps: props.includeBlockProps,
554
+ isInteractive: props.isInteractive,
555
+ contextValue: props.context
556
+ }),
557
+ children: [
558
+ (props.blockChildren || []).map(function(child) {
559
+ return /* @__PURE__ */ _jsxC(Block, {
560
+ block: child,
561
+ get context() {
562
+ return props.context;
563
+ },
564
+ get registeredComponents() {
565
+ return props.registeredComponents;
566
+ },
567
+ [_IMMUTABLE]: {
568
+ context: _fnSignal((p0) => p0.context, [
569
+ props
570
+ ], "p0.context"),
571
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
572
+ props
573
+ ], "p0.registeredComponents")
574
+ }
575
+ }, 3, "block-" + child.id);
576
+ }),
577
+ (props.blockChildren || []).map(function(child) {
578
+ return /* @__PURE__ */ _jsxC(BlockStyles, {
579
+ block: child,
580
+ get context() {
581
+ return props.context;
582
+ },
583
+ [_IMMUTABLE]: {
584
+ context: _fnSignal((p0) => p0.context, [
585
+ props
586
+ ], "p0.context")
587
+ }
588
+ }, 3, "block-style-" + child.id);
589
+ })
590
+ ]
591
+ }, 0, "z6_0") : null
592
+ }, 1, "z6_1");
593
+ }, "ComponentRef_component_tFQoBV6UFdc"));
594
+ const RepeatedBlock = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
595
+ const state = useStore({
596
+ store: props.repeatContext
597
+ });
598
+ useContextProvider(builderContext, state.store);
599
+ return /* @__PURE__ */ _jsxC(Block, {
600
+ get block() {
601
+ return props.block;
602
+ },
603
+ get context() {
604
+ return state.store;
605
+ },
606
+ get registeredComponents() {
607
+ return props.registeredComponents;
608
+ },
609
+ [_IMMUTABLE]: {
610
+ block: _fnSignal((p0) => p0.block, [
611
+ props
612
+ ], "p0.block"),
613
+ context: _fnSignal((p0) => p0.store, [
614
+ state
615
+ ], "p0.store"),
616
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
617
+ props
618
+ ], "p0.registeredComponents")
619
+ }
620
+ }, 3, "GO_0");
621
+ }, "RepeatedBlock_component_JK1l2jKcfwA"));
622
+ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
623
+ _jsxBranch();
624
+ const state = useStore({
625
+ childrenContext: props.context
626
+ });
627
+ const blockComponent = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
628
+ const [props2] = useLexicalScope();
629
+ return getComponent({
630
+ block: props2.block,
631
+ context: props2.context,
632
+ registeredComponents: props2.registeredComponents
633
+ });
634
+ }, "Block_component_blockComponent_useComputed_83sGy9Xlsi0", [
635
+ props
636
+ ]));
637
+ const repeatItem = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
638
+ const [props2] = useLexicalScope();
639
+ return getRepeatItemData({
640
+ block: props2.block,
641
+ context: props2.context
642
+ });
643
+ }, "Block_component_repeatItem_useComputed_j31Y3wFqSCM", [
644
+ props
645
+ ]));
646
+ const processedBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
647
+ const [props2, repeatItem2] = useLexicalScope();
648
+ return repeatItem2.value ? props2.block : getProcessedBlock({
649
+ block: props2.block,
650
+ localState: props2.context.localState,
651
+ rootState: props2.context.rootState,
652
+ rootSetState: props2.context.rootSetState,
653
+ context: props2.context.context,
654
+ shouldEvaluateBindings: true
655
+ });
656
+ }, "Block_component_processedBlock_useComputed_ESKw0l5FcBc", [
657
+ props,
658
+ repeatItem
659
+ ]));
660
+ const Tag = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
661
+ const [props2] = useLexicalScope();
662
+ return props2.block.tagName || "div";
663
+ }, "Block_component_Tag_useComputed_eQnDgbcBW2A", [
664
+ props
665
+ ]));
666
+ const canShowBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
667
+ const [processedBlock2] = useLexicalScope();
668
+ if ("hide" in processedBlock2.value)
669
+ return !processedBlock2.value.hide;
670
+ if ("show" in processedBlock2.value)
671
+ return processedBlock2.value.show;
672
+ return true;
673
+ }, "Block_component_canShowBlock_useComputed_NJEFz8ICF08", [
674
+ processedBlock
675
+ ]));
676
+ const childrenWithoutParentComponent = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
677
+ const [blockComponent2, processedBlock2, repeatItem2] = useLexicalScope();
678
+ const shouldRenderChildrenOutsideRef = !blockComponent2.value?.component && !repeatItem2.value;
679
+ return shouldRenderChildrenOutsideRef ? processedBlock2.value.children ?? [] : [];
680
+ }, "Block_component_childrenWithoutParentComponent_useComputed_0WENYGElWnc", [
681
+ blockComponent,
682
+ processedBlock,
683
+ repeatItem
684
+ ]));
685
+ const componentRefProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
686
+ const [blockComponent2, processedBlock2, props2, state2] = useLexicalScope();
687
+ return {
688
+ blockChildren: processedBlock2.value.children ?? [],
689
+ componentRef: blockComponent2.value?.component,
690
+ componentOptions: {
691
+ ...getBlockComponentOptions(processedBlock2.value),
692
+ builderContext: props2.context,
693
+ ...blockComponent2.value?.name === "Symbol" || blockComponent2.value?.name === "Columns" ? {
694
+ builderComponents: props2.registeredComponents
695
+ } : {}
696
+ },
697
+ context: state2.childrenContext,
698
+ registeredComponents: props2.registeredComponents,
699
+ builderBlock: processedBlock2.value,
700
+ includeBlockProps: blockComponent2.value?.noWrap === true,
701
+ isInteractive: !blockComponent2.value?.isRSC
702
+ };
703
+ }, "Block_component_componentRefProps_useComputed_Ikbl8VO04ho", [
704
+ blockComponent,
705
+ processedBlock,
706
+ props,
707
+ state
708
+ ]));
709
+ return /* @__PURE__ */ _jsxC(Fragment, {
710
+ children: canShowBlock.value ? !blockComponent.value?.noWrap ? /* @__PURE__ */ _jsxC(Fragment, {
711
+ children: [
712
+ isEmptyHtmlElement(Tag.value) ? /* @__PURE__ */ _jsxC(BlockWrapper, {
713
+ get Wrapper() {
714
+ return Tag.value;
715
+ },
716
+ get block() {
717
+ return processedBlock.value;
718
+ },
719
+ get context() {
720
+ return props.context;
721
+ },
722
+ hasChildren: false,
723
+ [_IMMUTABLE]: {
724
+ Wrapper: _fnSignal((p0) => p0.value, [
725
+ Tag
726
+ ], "p0.value"),
727
+ block: _fnSignal((p0) => p0.value, [
728
+ processedBlock
729
+ ], "p0.value"),
730
+ context: _fnSignal((p0) => p0.context, [
731
+ props
732
+ ], "p0.context"),
733
+ hasChildren: _IMMUTABLE
734
+ }
735
+ }, 3, "jN_0") : null,
736
+ !isEmptyHtmlElement(Tag.value) && repeatItem.value ? (repeatItem.value || []).map(function(data, index) {
737
+ return /* @__PURE__ */ _jsxC(RepeatedBlock, {
738
+ get repeatContext() {
739
+ return data.context;
740
+ },
741
+ get block() {
742
+ return data.block;
743
+ },
744
+ get registeredComponents() {
745
+ return props.registeredComponents;
746
+ },
747
+ [_IMMUTABLE]: {
748
+ repeatContext: _wrapProp(data, "context"),
749
+ block: _wrapProp(data, "block"),
750
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
751
+ props
752
+ ], "p0.registeredComponents")
753
+ }
754
+ }, 3, index);
755
+ }) : null,
756
+ !isEmptyHtmlElement(Tag.value) && !repeatItem.value ? /* @__PURE__ */ _jsxC(BlockWrapper, {
757
+ get Wrapper() {
758
+ return Tag.value;
759
+ },
760
+ get block() {
761
+ return processedBlock.value;
762
+ },
763
+ get context() {
764
+ return props.context;
765
+ },
766
+ hasChildren: true,
767
+ children: [
768
+ /* @__PURE__ */ _jsxC(ComponentRef, {
769
+ ...componentRefProps.value
770
+ }, 0, "jN_1"),
771
+ (childrenWithoutParentComponent.value || []).map(function(child) {
772
+ return /* @__PURE__ */ _jsxC(Block, {
773
+ block: child,
774
+ get context() {
775
+ return state.childrenContext;
776
+ },
777
+ get registeredComponents() {
778
+ return props.registeredComponents;
779
+ },
780
+ [_IMMUTABLE]: {
781
+ context: _fnSignal((p0) => p0.childrenContext, [
782
+ state
783
+ ], "p0.childrenContext"),
784
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
785
+ props
786
+ ], "p0.registeredComponents")
787
+ }
788
+ }, 3, "block-" + child.id);
789
+ }),
790
+ (childrenWithoutParentComponent.value || []).map(function(child) {
791
+ return /* @__PURE__ */ _jsxC(BlockStyles, {
792
+ block: child,
793
+ get context() {
794
+ return state.childrenContext;
795
+ },
796
+ [_IMMUTABLE]: {
797
+ context: _fnSignal((p0) => p0.childrenContext, [
798
+ state
799
+ ], "p0.childrenContext")
800
+ }
801
+ }, 3, "block-style-" + child.id);
802
+ })
803
+ ],
804
+ [_IMMUTABLE]: {
805
+ Wrapper: _fnSignal((p0) => p0.value, [
806
+ Tag
807
+ ], "p0.value"),
808
+ block: _fnSignal((p0) => p0.value, [
809
+ processedBlock
810
+ ], "p0.value"),
811
+ context: _fnSignal((p0) => p0.context, [
812
+ props
813
+ ], "p0.context"),
814
+ hasChildren: _IMMUTABLE
815
+ }
816
+ }, 1, "jN_2") : null
817
+ ]
818
+ }, 1, "jN_3") : /* @__PURE__ */ _jsxC(ComponentRef, {
819
+ ...componentRefProps.value
820
+ }, 0, "jN_4") : null
821
+ }, 1, "jN_5");
822
+ }, "Block_component_nnPv0RY0U0k"));
823
+ const onClick$1 = function onClick2(props, state) {
824
+ if (isEditing() && !props.blocks?.length)
825
+ window.parent?.postMessage({
826
+ type: "builder.clickEmptyBlocks",
827
+ data: {
828
+ parentElementId: props.parent,
829
+ dataPath: props.path
830
+ }
831
+ }, "*");
832
+ };
833
+ const onMouseEnter = function onMouseEnter2(props, state) {
834
+ if (isEditing() && !props.blocks?.length)
835
+ window.parent?.postMessage({
836
+ type: "builder.hoverEmptyBlocks",
837
+ data: {
838
+ parentElementId: props.parent,
839
+ dataPath: props.path
840
+ }
841
+ }, "*");
842
+ };
843
+ const BlocksWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
844
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES$2, "BlocksWrapper_component_useStylesScoped_Kj0S9AOXQ0o"));
845
+ const className = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
846
+ const [props2] = useLexicalScope();
847
+ return "builder-blocks" + (!props2.blocks?.length ? " no-blocks" : "");
848
+ }, "BlocksWrapper_component_className_useComputed_J5SSSH2Xf08", [
849
+ props
850
+ ]));
851
+ const state = {};
852
+ return /* @__PURE__ */ _jsxQ("div", {
853
+ onClick$: /* @__PURE__ */ inlinedQrl((event) => {
854
+ const [props2, state2] = useLexicalScope();
855
+ return onClick$1(props2);
856
+ }, "BlocksWrapper_component_div_onClick_1NkidSBS3D0", [
857
+ props,
858
+ state
859
+ ]),
860
+ onMouseEnter$: /* @__PURE__ */ inlinedQrl((event) => {
861
+ const [props2, state2] = useLexicalScope();
862
+ return onMouseEnter(props2);
863
+ }, "BlocksWrapper_component_div_onMouseEnter_TxzAP5tI9Zc", [
864
+ props,
865
+ state
866
+ ]),
867
+ onKeyPress$: /* @__PURE__ */ inlinedQrl((event) => {
868
+ const [props2, state2] = useLexicalScope();
869
+ return onClick$1(props2);
870
+ }, "BlocksWrapper_component_div_onKeyPress_Aaf0oNYOi80", [
871
+ props,
872
+ state
873
+ ])
874
+ }, {
875
+ class: _fnSignal((p0) => p0.value + " div-BlocksWrapper", [
876
+ className
877
+ ], 'p0.value+" div-BlocksWrapper"'),
878
+ "builder-path": _fnSignal((p0) => p0.path, [
879
+ props
880
+ ], "p0.path"),
881
+ "builder-parent-id": _fnSignal((p0) => p0.parent, [
882
+ props
883
+ ], "p0.parent"),
884
+ style: _fnSignal((p0) => p0.styleProp, [
885
+ props
886
+ ], "p0.styleProp")
887
+ }, /* @__PURE__ */ _jsxC(Slot, null, 3, "3u_0"), 0, "3u_1");
888
+ }, "BlocksWrapper_component_45hR0o6abzg"));
889
+ const STYLES$2 = `
890
+ .div-BlocksWrapper {
891
+ display: flex;
892
+ flex-direction: column;
893
+ align-items: stretch;
894
+ }
895
+ `;
896
+ const Blocks = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
897
+ const builderContext$1 = useContext(builderContext);
898
+ const componentsContext = useContext(ComponentsContext);
899
+ return /* @__PURE__ */ _jsxC(BlocksWrapper, {
900
+ get blocks() {
901
+ return props.blocks;
902
+ },
903
+ get parent() {
904
+ return props.parent;
905
+ },
906
+ get path() {
907
+ return props.path;
908
+ },
909
+ get styleProp() {
910
+ return props.styleProp;
911
+ },
912
+ children: [
913
+ props.blocks ? (props.blocks || []).map(function(block) {
914
+ return /* @__PURE__ */ _jsxC(Block, {
915
+ block,
916
+ get context() {
917
+ return props.context || builderContext$1;
918
+ },
919
+ get registeredComponents() {
920
+ return props.registeredComponents || componentsContext.registeredComponents;
921
+ },
922
+ [_IMMUTABLE]: {
923
+ context: _fnSignal((p0, p1) => p1.context || p0, [
924
+ builderContext$1,
925
+ props
926
+ ], "p1.context||p0"),
927
+ registeredComponents: _fnSignal((p0, p1) => p1.registeredComponents || p0.registeredComponents, [
928
+ componentsContext,
929
+ props
930
+ ], "p1.registeredComponents||p0.registeredComponents")
931
+ }
932
+ }, 3, "render-block-" + block.id);
933
+ }) : null,
934
+ props.blocks ? (props.blocks || []).map(function(block) {
935
+ return /* @__PURE__ */ _jsxC(BlockStyles, {
936
+ block,
937
+ get context() {
938
+ return props.context || builderContext$1;
939
+ },
940
+ [_IMMUTABLE]: {
941
+ context: _fnSignal((p0, p1) => p1.context || p0, [
942
+ builderContext$1,
943
+ props
944
+ ], "p1.context||p0")
945
+ }
946
+ }, 3, "block-style-" + block.id);
947
+ }) : null
948
+ ],
949
+ [_IMMUTABLE]: {
950
+ blocks: _fnSignal((p0) => p0.blocks, [
951
+ props
952
+ ], "p0.blocks"),
953
+ parent: _fnSignal((p0) => p0.parent, [
954
+ props
955
+ ], "p0.parent"),
956
+ path: _fnSignal((p0) => p0.path, [
957
+ props
958
+ ], "p0.path"),
959
+ styleProp: _fnSignal((p0) => p0.styleProp, [
960
+ props
961
+ ], "p0.styleProp")
962
+ }
963
+ }, 1, "0n_0");
964
+ }, "Blocks_component_PI1ErWPzPEg"));
965
+ const getWidth = function getWidth2(props, state, index) {
966
+ return state.cols[index]?.width || 100 / state.cols.length;
967
+ };
968
+ const getColumnCssWidth = function getColumnCssWidth2(props, state, index) {
969
+ const subtractWidth = state.gutterSize * (state.cols.length - 1) / state.cols.length;
970
+ return `calc(${getWidth(props, state, index)}% - ${subtractWidth}px)`;
971
+ };
972
+ const getTabletStyle = function getTabletStyle2(props, state, { stackedStyle, desktopStyle }) {
973
+ return state.stackAt === "tablet" ? stackedStyle : desktopStyle;
974
+ };
975
+ const getMobileStyle = function getMobileStyle2(props, state, { stackedStyle, desktopStyle }) {
976
+ return state.stackAt === "never" ? desktopStyle : stackedStyle;
977
+ };
978
+ const columnCssVars = function columnCssVars2(props, state, index) {
979
+ const gutter = index === 0 ? 0 : state.gutterSize;
980
+ const width = getColumnCssWidth(props, state, index);
981
+ const gutterPixels = `${gutter}px`;
982
+ const mobileWidth = "100%";
983
+ const mobileMarginLeft = 0;
984
+ const marginLeftKey = "margin-left";
985
+ return {
986
+ width,
987
+ [marginLeftKey]: gutterPixels,
988
+ "--column-width-mobile": getMobileStyle(props, state, {
989
+ stackedStyle: mobileWidth,
990
+ desktopStyle: width
991
+ }),
992
+ "--column-margin-left-mobile": getMobileStyle(props, state, {
993
+ stackedStyle: mobileMarginLeft,
994
+ desktopStyle: gutterPixels
995
+ }),
996
+ "--column-width-tablet": getTabletStyle(props, state, {
997
+ stackedStyle: mobileWidth,
998
+ desktopStyle: width
999
+ }),
1000
+ "--column-margin-left-tablet": getTabletStyle(props, state, {
1001
+ stackedStyle: mobileMarginLeft,
1002
+ desktopStyle: gutterPixels
1003
+ })
1004
+ };
1005
+ };
1006
+ const getWidthForBreakpointSize = function getWidthForBreakpointSize2(props, state, size) {
1007
+ const breakpointSizes = getSizesForBreakpoints(props.builderContext.content?.meta?.breakpoints || {});
1008
+ return breakpointSizes[size].max;
1009
+ };
1010
+ const Columns = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1011
+ _jsxBranch();
1012
+ const state = useStore({
1013
+ cols: props.columns || [],
1014
+ flexDir: props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column",
1015
+ gutterSize: typeof props.space === "number" ? props.space || 0 : 20,
1016
+ stackAt: props.stackColumnsAt || "tablet"
1017
+ });
1018
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES$1, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
1019
+ const columnsCssVars = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1020
+ const [props2, state2] = useLexicalScope();
1021
+ return {
1022
+ "--flex-dir": state2.flexDir,
1023
+ "--flex-dir-tablet": getTabletStyle(props2, state2, {
1024
+ stackedStyle: state2.flexDir,
1025
+ desktopStyle: "row"
1026
+ })
1027
+ };
1028
+ }, "Columns_component_columnsCssVars_useComputed_adFEq2RWT9s", [
1029
+ props,
1030
+ state
1031
+ ]));
1032
+ const columnsStyles = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1033
+ const [props2, state2] = useLexicalScope();
1034
+ return `
1035
+ @media (max-width: ${getWidthForBreakpointSize(props2, state2, "medium")}px) {
1036
+ .${props2.builderBlock.id}-breakpoints {
1037
+ flex-direction: var(--flex-dir-tablet);
1038
+ align-items: stretch;
1039
+ }
1040
+
1041
+ .${props2.builderBlock.id}-breakpoints > .builder-column {
1042
+ width: var(--column-width-tablet) !important;
1043
+ margin-left: var(--column-margin-left-tablet) !important;
1044
+ }
1045
+ }
1046
+
1047
+ @media (max-width: ${getWidthForBreakpointSize(props2, state2, "small")}px) {
1048
+ .${props2.builderBlock.id}-breakpoints {
1049
+ flex-direction: var(--flex-dir);
1050
+ align-items: stretch;
1051
+ }
1052
+
1053
+ .${props2.builderBlock.id}-breakpoints > .builder-column {
1054
+ width: var(--column-width-mobile) !important;
1055
+ margin-left: var(--column-margin-left-mobile) !important;
1056
+ }
1057
+ },
1058
+ `;
1059
+ }, "Columns_component_columnsStyles_useComputed_nBtMPbzd1Wc", [
1060
+ props,
1061
+ state
1062
+ ]));
1063
+ return /* @__PURE__ */ _jsxQ("div", null, {
1064
+ class: _fnSignal((p0) => `builder-columns ${p0.builderBlock.id}-breakpoints div-Columns`, [
1065
+ props
1066
+ ], '`builder-columns ${p0.builderBlock.id}-breakpoints`+" div-Columns"'),
1067
+ style: _fnSignal((p0) => p0.value, [
1068
+ columnsCssVars
1069
+ ], "p0.value")
1070
+ }, [
1071
+ /* @__PURE__ */ _jsxC(InlinedStyles, {
1072
+ get styles() {
1073
+ return columnsStyles.value;
1074
+ },
1075
+ [_IMMUTABLE]: {
1076
+ styles: _fnSignal((p0) => p0.value, [
1077
+ columnsStyles
1078
+ ], "p0.value")
1079
+ }
1080
+ }, 3, "c0_0"),
1081
+ (props.columns || []).map(function(column, index) {
1082
+ return /* @__PURE__ */ createElement("div", {
1083
+ class: "builder-column div-Columns-2",
1084
+ style: columnCssVars(props, state, index),
1085
+ key: index
1086
+ }, /* @__PURE__ */ _jsxC(Blocks, {
1087
+ get blocks() {
1088
+ return column.blocks;
1089
+ },
1090
+ path: `component.options.columns.${index}.blocks`,
1091
+ get parent() {
1092
+ return props.builderBlock.id;
1093
+ },
1094
+ styleProp: {
1095
+ flexGrow: "1"
1096
+ },
1097
+ get context() {
1098
+ return props.builderContext;
1099
+ },
1100
+ get registeredComponents() {
1101
+ return props.builderComponents;
1102
+ },
1103
+ [_IMMUTABLE]: {
1104
+ blocks: _wrapProp(column, "blocks"),
1105
+ parent: _fnSignal((p0) => p0.builderBlock.id, [
1106
+ props
1107
+ ], "p0.builderBlock.id"),
1108
+ context: _fnSignal((p0) => p0.builderContext, [
1109
+ props
1110
+ ], "p0.builderContext"),
1111
+ registeredComponents: _fnSignal((p0) => p0.builderComponents, [
1112
+ props
1113
+ ], "p0.builderComponents")
1114
+ }
1115
+ }, 3, "c0_1"));
1116
+ })
1117
+ ], 1, "c0_2");
1118
+ }, "Columns_component_7yLj4bxdI6c"));
1119
+ const STYLES$1 = `
1120
+ .div-Columns {
1121
+ display: flex;
1122
+ line-height: normal;
1123
+ }
1124
+ .div-Columns-2 {
1125
+ display: flex;
1126
+ flex-direction: column;
1127
+ align-items: stretch;
1128
+ }
1129
+ `;
1130
+ const FragmentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1131
+ return /* @__PURE__ */ _jsxQ("span", null, null, /* @__PURE__ */ _jsxC(Slot, null, 3, "oj_0"), 1, "oj_1");
1132
+ }, "FragmentComponent_component_T0AypnadAK0"));
1133
+ function removeProtocol(path) {
1134
+ return path.replace(/http(s)?:/, "");
1135
+ }
1136
+ function updateQueryParam(uri = "", key, value) {
1137
+ const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
1138
+ const separator = uri.indexOf("?") !== -1 ? "&" : "?";
1139
+ if (uri.match(re))
1140
+ return uri.replace(re, "$1" + key + "=" + encodeURIComponent(value) + "$2");
1141
+ return uri + separator + key + "=" + encodeURIComponent(value);
1142
+ }
1143
+ function getShopifyImageUrl(src, size) {
1144
+ if (!src || !src?.match(/cdn\.shopify\.com/) || !size)
1145
+ return src;
1146
+ if (size === "master")
1147
+ return removeProtocol(src);
1148
+ const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
1149
+ if (match) {
1150
+ const prefix = src.split(match[0]);
1151
+ const suffix = match[3];
1152
+ const useSize = size.match("x") ? size : `${size}x`;
1153
+ return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
1154
+ }
1155
+ return null;
1156
+ }
1157
+ function getSrcSet(url) {
1158
+ if (!url)
1159
+ return url;
1160
+ const sizes = [
1161
+ 100,
1162
+ 200,
1163
+ 400,
1164
+ 800,
1165
+ 1200,
1166
+ 1600,
1167
+ 2e3
1168
+ ];
1169
+ if (url.match(/builder\.io/)) {
1170
+ let srcUrl = url;
1171
+ const widthInSrc = Number(url.split("?width=")[1]);
1172
+ if (!isNaN(widthInSrc))
1173
+ srcUrl = `${srcUrl} ${widthInSrc}w`;
1174
+ return sizes.filter((size) => size !== widthInSrc).map((size) => `${updateQueryParam(url, "width", size)} ${size}w`).concat([
1175
+ srcUrl
1176
+ ]).join(", ");
1177
+ }
1178
+ if (url.match(/cdn\.shopify\.com/))
1179
+ return sizes.map((size) => [
1180
+ getShopifyImageUrl(url, `${size}x${size}`),
1181
+ size
1182
+ ]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([
1183
+ url
1184
+ ]).join(", ");
1185
+ return url;
1186
+ }
1187
+ const Image = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1188
+ _jsxBranch();
1189
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES, "Image_component_useStylesScoped_fBMYiVf9fuU"));
1190
+ const srcSetToUse = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1191
+ const [props2] = useLexicalScope();
1192
+ const imageToUse = props2.image || props2.src;
1193
+ const url = imageToUse;
1194
+ if (!url || !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/)))
1195
+ return props2.srcset;
1196
+ if (props2.srcset && props2.image?.includes("builder.io/api/v1/image")) {
1197
+ if (!props2.srcset.includes(props2.image.split("?")[0])) {
1198
+ console.debug("Removed given srcset");
1199
+ return getSrcSet(url);
1200
+ }
1201
+ } else if (props2.image && !props2.srcset)
1202
+ return getSrcSet(url);
1203
+ return getSrcSet(url);
1204
+ }, "Image_component_srcSetToUse_useComputed_TZMibf9Gpvw", [
1205
+ props
1206
+ ]));
1207
+ const webpSrcSet = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1208
+ const [props2, srcSetToUse2] = useLexicalScope();
1209
+ if (srcSetToUse2.value?.match(/builder\.io/) && !props2.noWebp)
1210
+ return srcSetToUse2.value.replace(/\?/g, "?format=webp&");
1211
+ else
1212
+ return "";
1213
+ }, "Image_component_webpSrcSet_useComputed_01YCu72BBtA", [
1214
+ props,
1215
+ srcSetToUse
1216
+ ]));
1217
+ const aspectRatioCss = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1218
+ const [props2] = useLexicalScope();
1219
+ const aspectRatioStyles = {
1220
+ position: "absolute",
1221
+ height: "100%",
1222
+ width: "100%",
1223
+ left: "0px",
1224
+ top: "0px"
1225
+ };
1226
+ const out = props2.aspectRatio ? aspectRatioStyles : void 0;
1227
+ return out;
1228
+ }, "Image_component_aspectRatioCss_useComputed_yJ1jG0g5fbw", [
1229
+ props
1230
+ ]));
1231
+ return /* @__PURE__ */ _jsxC(Fragment$1, {
1232
+ children: [
1233
+ /* @__PURE__ */ _jsxQ("picture", null, null, [
1234
+ webpSrcSet.value ? /* @__PURE__ */ _jsxQ("source", null, {
1235
+ type: "image/webp",
1236
+ srcSet: _fnSignal((p0) => p0.value, [
1237
+ webpSrcSet
1238
+ ], "p0.value")
1239
+ }, null, 3, "0A_0") : null,
1240
+ /* @__PURE__ */ _jsxQ("img", null, {
1241
+ loading: "lazy",
1242
+ alt: _fnSignal((p0) => p0.altText, [
1243
+ props
1244
+ ], "p0.altText"),
1245
+ role: _fnSignal((p0) => p0.altText ? "presentation" : void 0, [
1246
+ props
1247
+ ], 'p0.altText?"presentation":undefined'),
1248
+ style: _fnSignal((p0, p1) => ({
1249
+ objectPosition: p1.backgroundPosition || "center",
1250
+ objectFit: p1.backgroundSize || "cover",
1251
+ ...p0.value
1252
+ }), [
1253
+ aspectRatioCss,
1254
+ props
1255
+ ], '{objectPosition:p1.backgroundPosition||"center",objectFit:p1.backgroundSize||"cover",...p0.value}'),
1256
+ class: _fnSignal((p0) => "builder-image" + (p0.className ? " " + p0.className : "") + " img-Image", [
1257
+ props
1258
+ ], '"builder-image"+(p0.className?" "+p0.className:"")+" img-Image"'),
1259
+ src: _fnSignal((p0) => p0.image, [
1260
+ props
1261
+ ], "p0.image"),
1262
+ srcSet: _fnSignal((p0) => p0.value, [
1263
+ srcSetToUse
1264
+ ], "p0.value"),
1265
+ sizes: _fnSignal((p0) => p0.sizes, [
1266
+ props
1267
+ ], "p0.sizes")
1268
+ }, null, 3, null)
1269
+ ], 1, null),
1270
+ props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /* @__PURE__ */ _jsxQ("div", null, {
1271
+ class: "builder-image-sizer div-Image",
1272
+ style: _fnSignal((p0) => ({
1273
+ paddingTop: p0.aspectRatio * 100 + "%"
1274
+ }), [
1275
+ props
1276
+ ], '{paddingTop:p0.aspectRatio*100+"%"}')
1277
+ }, null, 3, "0A_1") : null,
1278
+ props.builderBlock?.children?.length && props.fitContent ? /* @__PURE__ */ _jsxC(Slot, null, 3, "0A_2") : null,
1279
+ !props.fitContent && props.children ? /* @__PURE__ */ _jsxQ("div", null, {
1280
+ class: "div-Image-2"
1281
+ }, /* @__PURE__ */ _jsxC(Slot, null, 3, "0A_3"), 1, "0A_4") : null
1282
+ ]
1283
+ }, 1, "0A_5");
1284
+ }, "Image_component_LRxDkFa1EfU"));
1285
+ const STYLES = `
1286
+ .img-Image {
1287
+ opacity: 1;
1288
+ transition: opacity 0.2s ease-in-out;
1289
+ }
1290
+ .div-Image {
1291
+ width: 100%;
1292
+ pointer-events: none;
1293
+ font-size: 0;
1294
+ }
1295
+ .div-Image-2 {
1296
+ display: flex;
1297
+ flex-direction: column;
1298
+ align-items: stretch;
1299
+ position: absolute;
1300
+ top: 0;
1301
+ left: 0;
1302
+ width: 100%;
1303
+ height: 100%;
1304
+ }
1305
+ `;
1306
+ const SectionComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1307
+ return /* @__PURE__ */ _jsxS("section", {
1308
+ ...props.attributes,
1309
+ style: {
1310
+ width: "100%",
1311
+ alignSelf: "stretch",
1312
+ flexGrow: 1,
1313
+ boxSizing: "border-box",
1314
+ maxWidth: props.maxWidth || 1200,
1315
+ display: "flex",
1316
+ flexDirection: "column",
1317
+ alignItems: "stretch",
1318
+ marginLeft: "auto",
1319
+ marginRight: "auto"
1320
+ },
1321
+ children: /* @__PURE__ */ _jsxC(Slot, null, 3, "2Y_0")
1322
+ }, null, 0, "2Y_1");
1323
+ }, "SectionComponent_component_ZWF9iD5WeLg"));
1324
+ const getTopLevelDomain = (host) => {
1325
+ if (host === "localhost" || host === "127.0.0.1")
1326
+ return host;
1327
+ const parts = host.split(".");
1328
+ if (parts.length > 2)
1329
+ return parts.slice(1).join(".");
1330
+ return host;
1331
+ };
1332
+ const getCookieSync = ({ name, canTrack }) => {
1333
+ try {
1334
+ if (!canTrack)
1335
+ return void 0;
1336
+ return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
1337
+ } catch (err) {
1338
+ logger.warn("[COOKIE] GET error: ", err?.message || err);
1339
+ return void 0;
1340
+ }
1341
+ };
1342
+ const getCookie = async (args) => getCookieSync(args);
1343
+ const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
1344
+ const SECURE_CONFIG = [
1345
+ [
1346
+ "secure",
1347
+ ""
1348
+ ],
1349
+ [
1350
+ "SameSite",
1351
+ "None"
1352
+ ]
1353
+ ];
1354
+ const createCookieString = ({ name, value, expires }) => {
1355
+ const secure = isBrowser() ? location.protocol === "https:" : true;
1356
+ const secureObj = secure ? SECURE_CONFIG : [
1357
+ []
1358
+ ];
1359
+ const expiresObj = expires ? [
1360
+ [
1361
+ "expires",
1362
+ expires.toUTCString()
1363
+ ]
1364
+ ] : [
1365
+ []
1366
+ ];
1367
+ const cookieValue = [
1368
+ [
1369
+ name,
1370
+ value
1371
+ ],
1372
+ ...expiresObj,
1373
+ [
1374
+ "path",
1375
+ "/"
1376
+ ],
1377
+ [
1378
+ "domain",
1379
+ getTopLevelDomain(window.location.hostname)
1380
+ ],
1381
+ ...secureObj
1382
+ ];
1383
+ const cookie = stringifyCookie(cookieValue);
1384
+ return cookie;
1385
+ };
1386
+ const setCookie = async ({ name, value, expires, canTrack }) => {
1387
+ try {
1388
+ if (!canTrack)
1389
+ return;
1390
+ const cookie = createCookieString({
1391
+ name,
1392
+ value,
1393
+ expires
1394
+ });
1395
+ document.cookie = cookie;
1396
+ } catch (err) {
1397
+ logger.warn("[COOKIE] SET error: ", err?.message || err);
1398
+ }
1399
+ };
1400
+ const BUILDER_STORE_PREFIX = "builder.tests";
1401
+ const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
1402
+ const getContentVariationCookie = ({ contentId }) => getCookie({
1403
+ name: getContentTestKey(contentId),
1404
+ canTrack: true
1405
+ });
1406
+ const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
1407
+ name: getContentTestKey(contentId),
1408
+ canTrack: true
1409
+ });
1410
+ const setContentVariationCookie = ({ contentId, value }) => setCookie({
1411
+ name: getContentTestKey(contentId),
1412
+ value,
1413
+ canTrack: true
1414
+ });
1415
+ const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
1416
+ const getRandomVariationId = ({ id, variations }) => {
1417
+ let n = 0;
1418
+ const random = Math.random();
1419
+ for (const id2 in variations) {
1420
+ const testRatio = variations[id2]?.testRatio;
1421
+ n += testRatio;
1422
+ if (random < n)
1423
+ return id2;
1424
+ }
1425
+ return id;
1426
+ };
1427
+ const getAndSetVariantId = (args) => {
1428
+ const randomVariationId = getRandomVariationId(args);
1429
+ setContentVariationCookie({
1430
+ contentId: args.id,
1431
+ value: randomVariationId
1432
+ }).catch((err) => {
1433
+ logger.error("could not store A/B test variation: ", err);
1434
+ });
1435
+ return randomVariationId;
1436
+ };
1437
+ const getTestFields = ({ item, testGroupId }) => {
1438
+ const variationValue = item.variations[testGroupId];
1439
+ if (testGroupId === item.id || !variationValue)
1440
+ return {
1441
+ testVariationId: item.id,
1442
+ testVariationName: "Default"
1443
+ };
1444
+ else
1445
+ return {
1446
+ data: variationValue.data,
1447
+ testVariationId: variationValue.id,
1448
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
1449
+ };
1450
+ };
1451
+ const handleABTestingSync = ({ item, canTrack }) => {
1452
+ if (!canTrack)
1453
+ return item;
1454
+ if (!item)
1455
+ return void 0;
1456
+ if (!checkIsBuilderContentWithVariations(item))
1457
+ return item;
1458
+ const testGroupId = getContentVariationCookieSync({
1459
+ contentId: item.id
1460
+ }) || getAndSetVariantId({
1461
+ variations: item.variations,
1462
+ id: item.id
1463
+ });
1464
+ const variationValue = getTestFields({
1465
+ item,
1466
+ testGroupId
1467
+ });
1468
+ return {
1469
+ ...item,
1470
+ ...variationValue
1471
+ };
1472
+ };
1473
+ const handleABTesting = async ({ item, canTrack }) => {
1474
+ if (!canTrack)
1475
+ return item;
1476
+ if (!checkIsBuilderContentWithVariations(item))
1477
+ return item;
1478
+ const cookieValue = await getContentVariationCookie({
1479
+ contentId: item.id
1480
+ });
1481
+ const testGroupId = cookieValue || getAndSetVariantId({
1482
+ variations: item.variations,
1483
+ id: item.id
1484
+ });
1485
+ const variationValue = getTestFields({
1486
+ item,
1487
+ testGroupId
1488
+ });
1489
+ return {
1490
+ ...item,
1491
+ ...variationValue
1492
+ };
1493
+ };
1494
+ const getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
1495
+ const componentInfo$a = {
1496
+ name: "Core:Button",
1497
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
1498
+ defaultStyles: {
1499
+ appearance: "none",
1500
+ paddingTop: "15px",
1501
+ paddingBottom: "15px",
1502
+ paddingLeft: "25px",
1503
+ paddingRight: "25px",
1504
+ backgroundColor: "#000000",
1505
+ color: "white",
1506
+ borderRadius: "4px",
1507
+ textAlign: "center",
1508
+ cursor: "pointer"
1509
+ },
1510
+ inputs: [
1511
+ {
1512
+ name: "text",
1513
+ type: "text",
1514
+ defaultValue: "Click me!",
1515
+ bubble: true
1516
+ },
1517
+ {
1518
+ name: "link",
1519
+ type: "url",
1520
+ bubble: true
1521
+ },
1522
+ {
1523
+ name: "openLinkInNewTab",
1524
+ type: "boolean",
1525
+ defaultValue: false,
1526
+ friendlyName: "Open link in new tab"
1527
+ }
1528
+ ],
1529
+ static: true,
1530
+ noWrap: true
1531
+ };
1532
+ const componentInfo$9 = {
1533
+ name: "Columns",
1534
+ isRSC: true,
1535
+ inputs: [
1536
+ {
1537
+ name: "columns",
1538
+ type: "array",
1539
+ broadcast: true,
1540
+ subFields: [
1541
+ {
1542
+ name: "blocks",
1543
+ type: "array",
1544
+ hideFromUI: true,
1545
+ defaultValue: [
1546
+ {
1547
+ "@type": "@builder.io/sdk:Element",
1548
+ responsiveStyles: {
1549
+ large: {
1550
+ display: "flex",
1551
+ flexDirection: "column",
1552
+ alignItems: "stretch",
1553
+ flexShrink: "0",
1554
+ position: "relative",
1555
+ marginTop: "30px",
1556
+ textAlign: "center",
1557
+ lineHeight: "normal",
1558
+ height: "auto",
1559
+ minHeight: "20px",
1560
+ minWidth: "20px",
1561
+ overflow: "hidden"
1562
+ }
1563
+ },
1564
+ component: {
1565
+ name: "Image",
1566
+ options: {
1567
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1568
+ backgroundPosition: "center",
1569
+ backgroundSize: "cover",
1570
+ aspectRatio: 0.7004048582995948
1571
+ }
1572
+ }
1573
+ },
1574
+ {
1575
+ "@type": "@builder.io/sdk:Element",
1576
+ responsiveStyles: {
1577
+ large: {
1578
+ display: "flex",
1579
+ flexDirection: "column",
1580
+ alignItems: "stretch",
1581
+ flexShrink: "0",
1582
+ position: "relative",
1583
+ marginTop: "30px",
1584
+ textAlign: "center",
1585
+ lineHeight: "normal",
1586
+ height: "auto"
1587
+ }
1588
+ },
1589
+ component: {
1590
+ name: "Text",
1591
+ options: {
1592
+ text: "<p>Enter some text...</p>"
1593
+ }
1594
+ }
1595
+ }
1596
+ ]
1597
+ },
1598
+ {
1599
+ name: "width",
1600
+ type: "number",
1601
+ hideFromUI: true,
1602
+ helperText: "Width %, e.g. set to 50 to fill half of the space"
1603
+ },
1604
+ {
1605
+ name: "link",
1606
+ type: "url",
1607
+ helperText: "Optionally set a url that clicking this column will link to"
1608
+ }
1609
+ ],
1610
+ defaultValue: [
1611
+ {
1612
+ blocks: [
1613
+ {
1614
+ "@type": "@builder.io/sdk:Element",
1615
+ responsiveStyles: {
1616
+ large: {
1617
+ display: "flex",
1618
+ flexDirection: "column",
1619
+ alignItems: "stretch",
1620
+ flexShrink: "0",
1621
+ position: "relative",
1622
+ marginTop: "30px",
1623
+ textAlign: "center",
1624
+ lineHeight: "normal",
1625
+ height: "auto",
1626
+ minHeight: "20px",
1627
+ minWidth: "20px",
1628
+ overflow: "hidden"
1629
+ }
1630
+ },
1631
+ component: {
1632
+ name: "Image",
1633
+ options: {
1634
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1635
+ backgroundPosition: "center",
1636
+ backgroundSize: "cover",
1637
+ aspectRatio: 0.7004048582995948
1638
+ }
1639
+ }
1640
+ },
1641
+ {
1642
+ "@type": "@builder.io/sdk:Element",
1643
+ responsiveStyles: {
1644
+ large: {
1645
+ display: "flex",
1646
+ flexDirection: "column",
1647
+ alignItems: "stretch",
1648
+ flexShrink: "0",
1649
+ position: "relative",
1650
+ marginTop: "30px",
1651
+ textAlign: "center",
1652
+ lineHeight: "normal",
1653
+ height: "auto"
1654
+ }
1655
+ },
1656
+ component: {
1657
+ name: "Text",
1658
+ options: {
1659
+ text: "<p>Enter some text...</p>"
1660
+ }
1661
+ }
1662
+ }
1663
+ ]
1664
+ },
1665
+ {
1666
+ blocks: [
1667
+ {
1668
+ "@type": "@builder.io/sdk:Element",
1669
+ responsiveStyles: {
1670
+ large: {
1671
+ display: "flex",
1672
+ flexDirection: "column",
1673
+ alignItems: "stretch",
1674
+ flexShrink: "0",
1675
+ position: "relative",
1676
+ marginTop: "30px",
1677
+ textAlign: "center",
1678
+ lineHeight: "normal",
1679
+ height: "auto",
1680
+ minHeight: "20px",
1681
+ minWidth: "20px",
1682
+ overflow: "hidden"
1683
+ }
1684
+ },
1685
+ component: {
1686
+ name: "Image",
1687
+ options: {
1688
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1689
+ backgroundPosition: "center",
1690
+ backgroundSize: "cover",
1691
+ aspectRatio: 0.7004048582995948
1692
+ }
1693
+ }
1694
+ },
1695
+ {
1696
+ "@type": "@builder.io/sdk:Element",
1697
+ responsiveStyles: {
1698
+ large: {
1699
+ display: "flex",
1700
+ flexDirection: "column",
1701
+ alignItems: "stretch",
1702
+ flexShrink: "0",
1703
+ position: "relative",
1704
+ marginTop: "30px",
1705
+ textAlign: "center",
1706
+ lineHeight: "normal",
1707
+ height: "auto"
1708
+ }
1709
+ },
1710
+ component: {
1711
+ name: "Text",
1712
+ options: {
1713
+ text: "<p>Enter some text...</p>"
1714
+ }
1715
+ }
1716
+ }
1717
+ ]
1718
+ }
1719
+ ],
1720
+ onChange: (options) => {
1721
+ function clearWidths() {
1722
+ columns.forEach((col) => {
1723
+ col.delete("width");
1724
+ });
1725
+ }
1726
+ const columns = options.get("columns");
1727
+ if (Array.isArray(columns)) {
1728
+ const containsColumnWithWidth = !!columns.find((col) => col.get("width"));
1729
+ if (containsColumnWithWidth) {
1730
+ const containsColumnWithoutWidth = !!columns.find((col) => !col.get("width"));
1731
+ if (containsColumnWithoutWidth)
1732
+ clearWidths();
1733
+ else {
1734
+ const sumWidths = columns.reduce((memo, col) => {
1735
+ return memo + col.get("width");
1736
+ }, 0);
1737
+ const widthsDontAddUp = sumWidths !== 100;
1738
+ if (widthsDontAddUp)
1739
+ clearWidths();
1740
+ }
1741
+ }
1742
+ }
1743
+ }
1744
+ },
1745
+ {
1746
+ name: "space",
1747
+ type: "number",
1748
+ defaultValue: 20,
1749
+ helperText: "Size of gap between columns",
1750
+ advanced: true
1751
+ },
1752
+ {
1753
+ name: "stackColumnsAt",
1754
+ type: "string",
1755
+ defaultValue: "tablet",
1756
+ helperText: "Convert horizontal columns to vertical at what device size",
1757
+ enum: [
1758
+ "tablet",
1759
+ "mobile",
1760
+ "never"
1761
+ ],
1762
+ advanced: true
1763
+ },
1764
+ {
1765
+ name: "reverseColumnsWhenStacked",
1766
+ type: "boolean",
1767
+ defaultValue: false,
1768
+ helperText: "When stacking columns for mobile devices, reverse the ordering",
1769
+ advanced: true
1770
+ }
1771
+ ]
1772
+ };
1773
+ const componentInfo$8 = {
1774
+ name: "Fragment",
1775
+ static: true,
1776
+ hidden: true,
1777
+ canHaveChildren: true,
1778
+ noWrap: true
1779
+ };
1780
+ const componentInfo$7 = {
1781
+ name: "Image",
1782
+ static: true,
1783
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
1784
+ defaultStyles: {
1785
+ position: "relative",
1786
+ minHeight: "20px",
1787
+ minWidth: "20px",
1788
+ overflow: "hidden"
1789
+ },
1790
+ canHaveChildren: true,
1791
+ inputs: [
1792
+ {
1793
+ name: "image",
1794
+ type: "file",
1795
+ bubble: true,
1796
+ allowedFileTypes: [
1797
+ "jpeg",
1798
+ "jpg",
1799
+ "png",
1800
+ "svg"
1801
+ ],
1802
+ required: true,
1803
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
1804
+ onChange: (options) => {
1805
+ const DEFAULT_ASPECT_RATIO = 0.7041;
1806
+ options.delete("srcset");
1807
+ options.delete("noWebp");
1808
+ function loadImage(url, timeout = 6e4) {
1809
+ return new Promise((resolve, reject) => {
1810
+ const img = document.createElement("img");
1811
+ let loaded = false;
1812
+ img.onload = () => {
1813
+ loaded = true;
1814
+ resolve(img);
1815
+ };
1816
+ img.addEventListener("error", (event) => {
1817
+ console.warn("Image load failed", event.error);
1818
+ reject(event.error);
1819
+ });
1820
+ img.src = url;
1821
+ setTimeout(() => {
1822
+ if (!loaded)
1823
+ reject(new Error("Image load timed out"));
1824
+ }, timeout);
1825
+ });
1826
+ }
1827
+ function round2(num) {
1828
+ return Math.round(num * 1e3) / 1e3;
1829
+ }
1830
+ const value = options.get("image");
1831
+ const aspectRatio = options.get("aspectRatio");
1832
+ fetch(value).then((res) => res.blob()).then((blob) => {
1833
+ if (blob.type.includes("svg"))
1834
+ options.set("noWebp", true);
1835
+ });
1836
+ if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO))
1837
+ return loadImage(value).then((img) => {
1838
+ const possiblyUpdatedAspectRatio = options.get("aspectRatio");
1839
+ if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
1840
+ if (img.width && img.height) {
1841
+ options.set("aspectRatio", round2(img.height / img.width));
1842
+ options.set("height", img.height);
1843
+ options.set("width", img.width);
1844
+ }
1845
+ }
1846
+ });
1847
+ }
1848
+ },
1849
+ {
1850
+ name: "backgroundSize",
1851
+ type: "text",
1852
+ defaultValue: "cover",
1853
+ enum: [
1854
+ {
1855
+ label: "contain",
1856
+ value: "contain",
1857
+ helperText: "The image should never get cropped"
1858
+ },
1859
+ {
1860
+ label: "cover",
1861
+ value: "cover",
1862
+ helperText: "The image should fill it's box, cropping when needed"
1863
+ }
1864
+ ]
1865
+ },
1866
+ {
1867
+ name: "backgroundPosition",
1868
+ type: "text",
1869
+ defaultValue: "center",
1870
+ enum: [
1871
+ "center",
1872
+ "top",
1873
+ "left",
1874
+ "right",
1875
+ "bottom",
1876
+ "top left",
1877
+ "top right",
1878
+ "bottom left",
1879
+ "bottom right"
1880
+ ]
1881
+ },
1882
+ {
1883
+ name: "altText",
1884
+ type: "string",
1885
+ helperText: "Text to display when the user has images off"
1886
+ },
1887
+ {
1888
+ name: "height",
1889
+ type: "number",
1890
+ hideFromUI: true
1891
+ },
1892
+ {
1893
+ name: "width",
1894
+ type: "number",
1895
+ hideFromUI: true
1896
+ },
1897
+ {
1898
+ name: "sizes",
1899
+ type: "string",
1900
+ hideFromUI: true
1901
+ },
1902
+ {
1903
+ name: "srcset",
1904
+ type: "string",
1905
+ hideFromUI: true
1906
+ },
1907
+ {
1908
+ name: "lazy",
1909
+ type: "boolean",
1910
+ defaultValue: true,
1911
+ hideFromUI: true
1912
+ },
1913
+ {
1914
+ name: "fitContent",
1915
+ type: "boolean",
1916
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
1917
+ defaultValue: true
1918
+ },
1919
+ {
1920
+ name: "aspectRatio",
1921
+ type: "number",
1922
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
1923
+ advanced: true,
1924
+ defaultValue: 0.7041
1925
+ }
1926
+ ]
1927
+ };
1928
+ const componentInfo$6 = {
1929
+ name: "Core:Section",
1930
+ static: true,
1931
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
1932
+ inputs: [
1933
+ {
1934
+ name: "maxWidth",
1935
+ type: "number",
1936
+ defaultValue: 1200
1937
+ },
1938
+ {
1939
+ name: "lazyLoad",
1940
+ type: "boolean",
1941
+ defaultValue: false,
1942
+ advanced: true,
1943
+ description: "Only render this section when in view"
1944
+ }
1945
+ ],
1946
+ defaultStyles: {
1947
+ paddingLeft: "20px",
1948
+ paddingRight: "20px",
1949
+ paddingTop: "50px",
1950
+ paddingBottom: "50px",
1951
+ marginTop: "0px",
1952
+ width: "100vw",
1953
+ marginLeft: "calc(50% - 50vw)"
1954
+ },
1955
+ canHaveChildren: true,
1956
+ defaultChildren: [
1957
+ {
1958
+ "@type": "@builder.io/sdk:Element",
1959
+ responsiveStyles: {
1960
+ large: {
1961
+ textAlign: "center"
1962
+ }
1963
+ },
1964
+ component: {
1965
+ name: "Text",
1966
+ options: {
1967
+ text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
1968
+ }
1969
+ }
1970
+ }
1971
+ ]
1972
+ };
1973
+ const componentInfo$5 = {
1974
+ name: "Symbol",
1975
+ noWrap: true,
1976
+ static: true,
1977
+ isRSC: true,
1978
+ inputs: [
1979
+ {
1980
+ name: "symbol",
1981
+ type: "uiSymbol"
1982
+ },
1983
+ {
1984
+ name: "dataOnly",
1985
+ helperText: "Make this a data symbol that doesn't display any UI",
1986
+ type: "boolean",
1987
+ defaultValue: false,
1988
+ advanced: true,
1989
+ hideFromUI: true
1990
+ },
1991
+ {
1992
+ name: "inheritState",
1993
+ helperText: "Inherit the parent component state and data",
1994
+ type: "boolean",
1995
+ defaultValue: false,
1996
+ advanced: true
1997
+ },
1998
+ {
1999
+ name: "renderToLiquid",
2000
+ helperText: "Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",
2001
+ type: "boolean",
2002
+ defaultValue: false,
2003
+ advanced: true,
2004
+ hideFromUI: true
2005
+ },
2006
+ {
2007
+ name: "useChildren",
2008
+ hideFromUI: true,
2009
+ type: "boolean"
2010
+ }
2011
+ ]
2012
+ };
2013
+ const componentInfo$4 = {
2014
+ name: "Text",
2015
+ static: true,
2016
+ isRSC: true,
2017
+ 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",
2018
+ inputs: [
2019
+ {
2020
+ name: "text",
2021
+ type: "html",
2022
+ required: true,
2023
+ autoFocus: true,
2024
+ bubble: true,
2025
+ defaultValue: "Enter some text..."
2026
+ }
2027
+ ],
2028
+ defaultStyles: {
2029
+ lineHeight: "normal",
2030
+ height: "auto",
2031
+ textAlign: "center"
2032
+ }
2033
+ };
2034
+ const Text = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2035
+ return /* @__PURE__ */ _jsxQ("span", {
2036
+ style: {
2037
+ outline: "none"
2038
+ }
2039
+ }, {
2040
+ class: "builder-text",
2041
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.text?.toString() || "", [
2042
+ props
2043
+ ], 'p0.text?.toString()||""')
2044
+ }, null, 3, "yO_0");
2045
+ }, "Text_component_15p0cKUxgIE"));
2046
+ const componentInfo$3 = {
2047
+ name: "Video",
2048
+ canHaveChildren: true,
2049
+ defaultStyles: {
2050
+ minHeight: "20px",
2051
+ minWidth: "20px"
2052
+ },
2053
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
2054
+ inputs: [
2055
+ {
2056
+ name: "video",
2057
+ type: "file",
2058
+ allowedFileTypes: [
2059
+ "mp4"
2060
+ ],
2061
+ bubble: true,
2062
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
2063
+ required: true
2064
+ },
2065
+ {
2066
+ name: "posterImage",
2067
+ type: "file",
2068
+ allowedFileTypes: [
2069
+ "jpeg",
2070
+ "png"
2071
+ ],
2072
+ helperText: "Image to show before the video plays"
2073
+ },
2074
+ {
2075
+ name: "autoPlay",
2076
+ type: "boolean",
2077
+ defaultValue: true
2078
+ },
2079
+ {
2080
+ name: "controls",
2081
+ type: "boolean",
2082
+ defaultValue: false
2083
+ },
2084
+ {
2085
+ name: "muted",
2086
+ type: "boolean",
2087
+ defaultValue: true
2088
+ },
2089
+ {
2090
+ name: "loop",
2091
+ type: "boolean",
2092
+ defaultValue: true
2093
+ },
2094
+ {
2095
+ name: "playsInline",
2096
+ type: "boolean",
2097
+ defaultValue: true
2098
+ },
2099
+ {
2100
+ name: "fit",
2101
+ type: "text",
2102
+ defaultValue: "cover",
2103
+ enum: [
2104
+ "contain",
2105
+ "cover",
2106
+ "fill",
2107
+ "auto"
2108
+ ]
2109
+ },
2110
+ {
2111
+ name: "preload",
2112
+ type: "text",
2113
+ defaultValue: "metadata",
2114
+ enum: [
2115
+ "auto",
2116
+ "metadata",
2117
+ "none"
2118
+ ]
2119
+ },
2120
+ {
2121
+ name: "fitContent",
2122
+ type: "boolean",
2123
+ helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
2124
+ defaultValue: true,
2125
+ advanced: true
2126
+ },
2127
+ {
2128
+ name: "position",
2129
+ type: "text",
2130
+ defaultValue: "center",
2131
+ enum: [
2132
+ "center",
2133
+ "top",
2134
+ "left",
2135
+ "right",
2136
+ "bottom",
2137
+ "top left",
2138
+ "top right",
2139
+ "bottom left",
2140
+ "bottom right"
2141
+ ]
2142
+ },
2143
+ {
2144
+ name: "height",
2145
+ type: "number",
2146
+ advanced: true
2147
+ },
2148
+ {
2149
+ name: "width",
2150
+ type: "number",
2151
+ advanced: true
2152
+ },
2153
+ {
2154
+ name: "aspectRatio",
2155
+ type: "number",
2156
+ advanced: true,
2157
+ defaultValue: 0.7004048582995948
2158
+ },
2159
+ {
2160
+ name: "lazyLoad",
2161
+ type: "boolean",
2162
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
2163
+ defaultValue: true,
2164
+ advanced: true
2165
+ }
2166
+ ]
2167
+ };
2168
+ const Video = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2169
+ const videoProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
2170
+ const [props2] = useLexicalScope();
2171
+ return {
2172
+ ...props2.autoPlay === true ? {
2173
+ autoPlay: true
2174
+ } : {},
2175
+ ...props2.muted === true ? {
2176
+ muted: true
2177
+ } : {},
2178
+ ...props2.controls === true ? {
2179
+ controls: true
2180
+ } : {},
2181
+ ...props2.loop === true ? {
2182
+ loop: true
2183
+ } : {},
2184
+ ...props2.playsInline === true ? {
2185
+ playsInline: true
2186
+ } : {}
2187
+ };
2188
+ }, "Video_component_videoProps_useComputed_60AadUGY06E", [
2189
+ props
2190
+ ]));
2191
+ const spreadProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
2192
+ const [props2, videoProps2] = useLexicalScope();
2193
+ return {
2194
+ ...props2.attributes,
2195
+ ...videoProps2.value
2196
+ };
2197
+ }, "Video_component_spreadProps_useComputed_ZdLsx18NYH4", [
2198
+ props,
2199
+ videoProps
2200
+ ]));
2201
+ return /* @__PURE__ */ _jsxS("video", {
2202
+ ...spreadProps.value
2203
+ }, {
2204
+ preload: _fnSignal((p0) => p0.preload || "metadata", [
2205
+ props
2206
+ ], 'p0.preload||"metadata"'),
2207
+ style: _fnSignal((p0) => ({
2208
+ width: "100%",
2209
+ height: "100%",
2210
+ ...p0.attributes?.style,
2211
+ objectFit: p0.fit,
2212
+ objectPosition: p0.position,
2213
+ borderRadius: 1
2214
+ }), [
2215
+ props
2216
+ ], '{width:"100%",height:"100%",...p0.attributes?.style,objectFit:p0.fit,objectPosition:p0.position,borderRadius:1}'),
2217
+ src: _fnSignal((p0) => p0.video || "no-src", [
2218
+ props
2219
+ ], 'p0.video||"no-src"'),
2220
+ poster: _fnSignal((p0) => p0.posterImage, [
2221
+ props
2222
+ ], "p0.posterImage")
2223
+ }, 0, "j7_0");
2224
+ }, "Video_component_qdcTZflYyoQ"));
2225
+ const componentInfo$2 = {
2226
+ name: "Embed",
2227
+ static: true,
2228
+ inputs: [
2229
+ {
2230
+ name: "url",
2231
+ type: "url",
2232
+ required: true,
2233
+ defaultValue: "",
2234
+ helperText: "e.g. enter a youtube url, google map, etc",
2235
+ onChange: (options) => {
2236
+ const url = options.get("url");
2237
+ if (url) {
2238
+ options.set("content", "Loading...");
2239
+ const apiKey = "ae0e60e78201a3f2b0de4b";
2240
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2241
+ if (options.get("url") === url) {
2242
+ if (data.html)
2243
+ options.set("content", data.html);
2244
+ else
2245
+ options.set("content", "Invalid url, please try another");
2246
+ }
2247
+ }).catch((_err) => {
2248
+ options.set("content", "There was an error embedding this URL, please try again or another URL");
2249
+ });
2250
+ } else
2251
+ options.delete("content");
2252
+ }
2253
+ },
2254
+ {
2255
+ name: "content",
2256
+ type: "html",
2257
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
2258
+ hideFromUI: true
2259
+ }
2260
+ ]
2261
+ };
2262
+ const SCRIPT_MIME_TYPES = [
2263
+ "text/javascript",
2264
+ "application/javascript",
2265
+ "application/ecmascript"
2266
+ ];
2267
+ const isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2268
+ const findAndRunScripts$1 = function findAndRunScripts2(props, state, elem) {
2269
+ if (!elem.value || !elem.value.getElementsByTagName)
2270
+ return;
2271
+ const scripts = elem.value.getElementsByTagName("script");
2272
+ for (let i = 0; i < scripts.length; i++) {
2273
+ const script = scripts[i];
2274
+ if (script.src && !state.scriptsInserted.includes(script.src)) {
2275
+ state.scriptsInserted.push(script.src);
2276
+ const newScript = document.createElement("script");
2277
+ newScript.async = true;
2278
+ newScript.src = script.src;
2279
+ document.head.appendChild(newScript);
2280
+ } else if (isJsScript(script) && !state.scriptsRun.includes(script.innerText))
2281
+ try {
2282
+ state.scriptsRun.push(script.innerText);
2283
+ new Function(script.innerText)();
2284
+ } catch (error) {
2285
+ console.warn("`Embed`: Error running script:", error);
2286
+ }
2287
+ }
2288
+ };
2289
+ const Embed = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2290
+ const elem = useSignal();
2291
+ const state = useStore({
2292
+ ranInitFn: false,
2293
+ scriptsInserted: [],
2294
+ scriptsRun: []
2295
+ });
2296
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
2297
+ const [elem2, props2, state2] = useLexicalScope();
2298
+ track2(() => elem2.value);
2299
+ track2(() => state2.ranInitFn);
2300
+ if (elem2.value && !state2.ranInitFn) {
2301
+ state2.ranInitFn = true;
2302
+ findAndRunScripts$1(props2, state2, elem2);
2303
+ }
2304
+ }, "Embed_component_useTask_bg7ez0XUtiM", [
2305
+ elem,
2306
+ props,
2307
+ state
2308
+ ]));
2309
+ return /* @__PURE__ */ _jsxQ("div", {
2310
+ ref: elem
2311
+ }, {
2312
+ class: "builder-embed",
2313
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.content, [
2314
+ props
2315
+ ], "p0.content")
2316
+ }, null, 3, "9r_0");
2317
+ }, "Embed_component_Uji08ORjXbE"));
2318
+ const ImgComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2319
+ return /* @__PURE__ */ _jsxS("img", {
2320
+ ...props.attributes
2321
+ }, {
2322
+ style: _fnSignal((p0) => ({
2323
+ objectFit: p0.backgroundSize || "cover",
2324
+ objectPosition: p0.backgroundPosition || "center"
2325
+ }), [
2326
+ props
2327
+ ], '{objectFit:p0.backgroundSize||"cover",objectPosition:p0.backgroundPosition||"center"}'),
2328
+ alt: _fnSignal((p0) => p0.altText, [
2329
+ props
2330
+ ], "p0.altText"),
2331
+ src: _fnSignal((p0) => p0.imgSrc || p0.image, [
2332
+ props
2333
+ ], "p0.imgSrc||p0.image")
2334
+ }, 0, isEditing() && props.imgSrc || "default-key");
2335
+ }, "ImgComponent_component_FXvIDBSffO8"));
2336
+ const componentInfo$1 = {
2337
+ name: "Raw:Img",
2338
+ hideFromInsertMenu: true,
2339
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
2340
+ inputs: [
2341
+ {
2342
+ name: "image",
2343
+ bubble: true,
2344
+ type: "file",
2345
+ allowedFileTypes: [
2346
+ "jpeg",
2347
+ "jpg",
2348
+ "png",
2349
+ "svg",
2350
+ "gif",
2351
+ "webp"
2352
+ ],
2353
+ required: true
2354
+ }
2355
+ ],
2356
+ noWrap: true,
2357
+ static: true
2358
+ };
2359
+ const findAndRunScripts = function findAndRunScripts22(props, state, elem) {
2360
+ if (elem.value && elem.value.getElementsByTagName && typeof window !== "undefined") {
2361
+ const scripts = elem.value.getElementsByTagName("script");
2362
+ for (let i = 0; i < scripts.length; i++) {
2363
+ const script = scripts[i];
2364
+ if (script.src) {
2365
+ if (state.scriptsInserted.includes(script.src))
2366
+ continue;
2367
+ state.scriptsInserted.push(script.src);
2368
+ const newScript = document.createElement("script");
2369
+ newScript.async = true;
2370
+ newScript.src = script.src;
2371
+ document.head.appendChild(newScript);
2372
+ } else if (!script.type || [
2373
+ "text/javascript",
2374
+ "application/javascript",
2375
+ "application/ecmascript"
2376
+ ].includes(script.type)) {
2377
+ if (state.scriptsRun.includes(script.innerText))
2378
+ continue;
2379
+ try {
2380
+ state.scriptsRun.push(script.innerText);
2381
+ new Function(script.innerText)();
2382
+ } catch (error) {
2383
+ console.warn("`CustomCode`: Error running script:", error);
2384
+ }
2385
+ }
2386
+ }
2387
+ }
2388
+ };
2389
+ const CustomCode = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2390
+ const elem = useSignal();
2391
+ const state = useStore({
2392
+ scriptsInserted: [],
2393
+ scriptsRun: []
2394
+ });
2395
+ useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
2396
+ const [elem2, props2, state2] = useLexicalScope();
2397
+ findAndRunScripts(props2, state2, elem2);
2398
+ }, "CustomCode_component_useVisibleTask_S5QgEQZj6YE", [
2399
+ elem,
2400
+ props,
2401
+ state
2402
+ ]));
2403
+ return /* @__PURE__ */ _jsxQ("div", {
2404
+ ref: elem
2405
+ }, {
2406
+ class: _fnSignal((p0) => "builder-custom-code" + (p0.replaceNodes ? " replace-nodes" : ""), [
2407
+ props
2408
+ ], '"builder-custom-code"+(p0.replaceNodes?" replace-nodes":"")'),
2409
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.code, [
2410
+ props
2411
+ ], "p0.code")
2412
+ }, null, 3, "bY_0");
2413
+ }, "CustomCode_component_uYOSy7w7Zqw"));
2414
+ const componentInfo = {
2415
+ name: "Custom Code",
2416
+ static: true,
2417
+ requiredPermissions: [
2418
+ "editCode"
2419
+ ],
2420
+ inputs: [
2421
+ {
2422
+ name: "code",
2423
+ type: "html",
2424
+ required: true,
2425
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
2426
+ code: true
2427
+ },
2428
+ {
2429
+ name: "replaceNodes",
2430
+ type: "boolean",
2431
+ helperText: "Preserve server rendered dom nodes",
2432
+ advanced: true
2433
+ },
2434
+ {
2435
+ name: "scriptsClientOnly",
2436
+ type: "boolean",
2437
+ defaultValue: false,
2438
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
2439
+ advanced: true
2440
+ }
2441
+ ]
2442
+ };
2443
+ const getDefaultRegisteredComponents = () => [
2444
+ {
2445
+ component: Button,
2446
+ ...componentInfo$a
2447
+ },
2448
+ {
2449
+ component: Columns,
2450
+ ...componentInfo$9
2451
+ },
2452
+ {
2453
+ component: CustomCode,
2454
+ ...componentInfo
2455
+ },
2456
+ {
2457
+ component: Embed,
2458
+ ...componentInfo$2
2459
+ },
2460
+ {
2461
+ component: FragmentComponent,
2462
+ ...componentInfo$8
2463
+ },
2464
+ {
2465
+ component: Image,
2466
+ ...componentInfo$7
2467
+ },
2468
+ {
2469
+ component: ImgComponent,
2470
+ ...componentInfo$1
2471
+ },
2472
+ {
2473
+ component: SectionComponent,
2474
+ ...componentInfo$6
2475
+ },
2476
+ {
2477
+ component: Symbol$1,
2478
+ ...componentInfo$5
2479
+ },
2480
+ {
2481
+ component: Text,
2482
+ ...componentInfo$4
2483
+ },
2484
+ {
2485
+ component: Video,
2486
+ ...componentInfo$3
2487
+ }
2488
+ ];
2489
+ const components = [];
2490
+ const createRegisterComponentMessage = (info) => ({
2491
+ type: "builder.registerComponent",
2492
+ data: info
2493
+ });
2494
+ const serializeFn = (fnValue) => {
2495
+ const fnStr = fnValue.toString().trim();
2496
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
2497
+ return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
2498
+ };
2499
+ const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
2500
+ const serializeComponentInfo = ({ inputs, ...info }) => ({
2501
+ ...fastClone(info),
2502
+ inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
2503
+ ...acc,
2504
+ [key]: serializeValue(value)
2505
+ }), {}))
2506
+ });
2507
+ const getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
2508
+ ...variant,
2509
+ testVariationId: variant.id,
2510
+ id: content?.id
2511
+ }));
2512
+ const checkShouldRunVariants = ({ canTrack, content }) => {
2513
+ const hasVariants = getVariants(content).length > 0;
2514
+ if (!hasVariants)
2515
+ return false;
2516
+ if (!canTrack)
2517
+ return false;
2518
+ if (isBrowser())
2519
+ return false;
2520
+ return true;
2521
+ };
2522
+ function bldrAbTest(contentId, variants, isHydrationTarget2) {
2523
+ function getAndSetVariantId2() {
2524
+ function setCookie2(name, value, days) {
2525
+ let expires = "";
2526
+ if (days) {
2527
+ const date = new Date();
2528
+ date.setTime(date.getTime() + days * 864e5);
2529
+ expires = "; expires=" + date.toUTCString();
2530
+ }
2531
+ document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
2532
+ }
2533
+ function getCookie2(name) {
2534
+ const nameEQ = name + "=";
2535
+ const ca = document.cookie.split(";");
2536
+ for (let i = 0; i < ca.length; i++) {
2537
+ let c = ca[i];
2538
+ while (c.charAt(0) === " ")
2539
+ c = c.substring(1, c.length);
2540
+ if (c.indexOf(nameEQ) === 0)
2541
+ return c.substring(nameEQ.length, c.length);
2542
+ }
2543
+ return null;
2544
+ }
2545
+ const cookieName = `builder.tests.${contentId}`;
2546
+ const variantInCookie = getCookie2(cookieName);
2547
+ const availableIDs = variants.map((vr) => vr.id).concat(contentId);
2548
+ if (variantInCookie && availableIDs.includes(variantInCookie))
2549
+ return variantInCookie;
2550
+ let n = 0;
2551
+ const random = Math.random();
2552
+ for (let i = 0; i < variants.length; i++) {
2553
+ const variant = variants[i];
2554
+ const testRatio = variant.testRatio;
2555
+ n += testRatio;
2556
+ if (random < n) {
2557
+ setCookie2(cookieName, variant.id);
2558
+ return variant.id;
2559
+ }
2560
+ }
2561
+ setCookie2(cookieName, contentId);
2562
+ return contentId;
2563
+ }
2564
+ const winningVariantId = getAndSetVariantId2();
2565
+ const styleEl = document.currentScript?.previousElementSibling;
2566
+ if (isHydrationTarget2) {
2567
+ styleEl.remove();
2568
+ const thisScriptEl = document.currentScript;
2569
+ thisScriptEl?.remove();
2570
+ } else {
2571
+ const newStyleStr = variants.concat({
2572
+ id: contentId
2573
+ }).filter((variant) => variant.id !== winningVariantId).map((value) => {
2574
+ return `.variant-${value.id} { display: none; }
2575
+ `;
2576
+ }).join("");
2577
+ styleEl.innerHTML = newStyleStr;
2578
+ }
2579
+ }
2580
+ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
2581
+ if (!navigator.cookieEnabled)
2582
+ return;
2583
+ function getCookie2(name) {
2584
+ const nameEQ = name + "=";
2585
+ const ca = document.cookie.split(";");
2586
+ for (let i = 0; i < ca.length; i++) {
2587
+ let c = ca[i];
2588
+ while (c.charAt(0) === " ")
2589
+ c = c.substring(1, c.length);
2590
+ if (c.indexOf(nameEQ) === 0)
2591
+ return c.substring(nameEQ.length, c.length);
2592
+ }
2593
+ return null;
2594
+ }
2595
+ const cookieName = `builder.tests.${defaultContentId}`;
2596
+ const variantId = getCookie2(cookieName);
2597
+ const parentDiv = document.currentScript?.parentElement;
2598
+ const variantIsDefaultContent = variantContentId === defaultContentId;
2599
+ if (variantId === variantContentId) {
2600
+ if (variantIsDefaultContent)
2601
+ return;
2602
+ parentDiv?.removeAttribute("hidden");
2603
+ parentDiv?.removeAttribute("aria-hidden");
2604
+ } else {
2605
+ if (variantIsDefaultContent) {
2606
+ if (isHydrationTarget2)
2607
+ parentDiv?.remove();
2608
+ else {
2609
+ parentDiv?.setAttribute("hidden", "true");
2610
+ parentDiv?.setAttribute("aria-hidden", "true");
2611
+ }
2612
+ }
2613
+ return;
2614
+ }
2615
+ return;
2616
+ }
2617
+ const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
2618
+ const isHydrationTarget = getIsHydrationTarget(TARGET);
2619
+ const AB_TEST_FN_NAME = "builderIoAbTest";
2620
+ const CONTENT_FN_NAME = "builderIoRenderContent";
2621
+ const getScriptString = () => {
2622
+ const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
2623
+ const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
2624
+ return `
2625
+ window.${AB_TEST_FN_NAME} = ${fnStr}
2626
+ window.${CONTENT_FN_NAME} = ${fnStr2}
2627
+ `;
2628
+ };
2629
+ const getVariantsScriptString = (variants, contentId) => {
2630
+ return `
2631
+ window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
2632
+ };
2633
+ const getRenderContentScriptString = ({ contentId, variationId }) => {
2634
+ return `
2635
+ window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
2636
+ };
2637
+ const InlinedScript = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2638
+ return /* @__PURE__ */ _jsxQ("script", null, {
2639
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.scriptStr, [
2640
+ props
2641
+ ], "p0.scriptStr"),
2642
+ id: _fnSignal((p0) => p0.id, [
2643
+ props
2644
+ ], "p0.id")
2645
+ }, null, 3, "WO_0");
2646
+ }, "InlinedScript_component_hwThBdhA8rw"));
2647
+ function getGlobalThis() {
2648
+ if (typeof globalThis !== "undefined")
2649
+ return globalThis;
2650
+ if (typeof window !== "undefined")
2651
+ return window;
2652
+ if (typeof global !== "undefined")
2653
+ return global;
2654
+ if (typeof self !== "undefined")
2655
+ return self;
2656
+ return globalThis;
2657
+ }
2658
+ function getFetch() {
2659
+ const globalFetch = getGlobalThis().fetch;
2660
+ if (typeof globalFetch === "undefined") {
2661
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2662
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
2663
+ throw new Error("Builder SDK could not find a global `fetch` function");
2664
+ }
2665
+ return globalFetch;
2666
+ }
2667
+ const fetch$1 = getFetch();
2668
+ function flatten(object, path = null, separator = ".") {
2669
+ return Object.keys(object).reduce((acc, key) => {
2670
+ const value = object[key];
2671
+ const newPath = [
2672
+ path,
2673
+ key
2674
+ ].filter(Boolean).join(separator);
2675
+ const isObject = [
2676
+ typeof value === "object",
2677
+ value !== null,
2678
+ !(Array.isArray(value) && value.length === 0)
2679
+ ].every(Boolean);
2680
+ return isObject ? {
2681
+ ...acc,
2682
+ ...flatten(value, newPath, separator)
2683
+ } : {
2684
+ ...acc,
2685
+ [newPath]: value
2686
+ };
2687
+ }, {});
2688
+ }
2689
+ const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
2690
+ const BUILDER_OPTIONS_PREFIX = "options.";
2691
+ const convertSearchParamsToQueryObject = (searchParams) => {
2692
+ const options = {};
2693
+ searchParams.forEach((value, key) => {
2694
+ options[key] = value;
2695
+ });
2696
+ return options;
2697
+ };
2698
+ const getBuilderSearchParams = (_options) => {
2699
+ if (!_options)
2700
+ return {};
2701
+ const options = normalizeSearchParams(_options);
2702
+ const newOptions = {};
2703
+ Object.keys(options).forEach((key) => {
2704
+ if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2705
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
2706
+ newOptions[trimmedKey] = options[key];
2707
+ }
2708
+ });
2709
+ return newOptions;
2710
+ };
2711
+ const getBuilderSearchParamsFromWindow = () => {
2712
+ if (!isBrowser())
2713
+ return {};
2714
+ const searchParams = new URLSearchParams(window.location.search);
2715
+ return getBuilderSearchParams(searchParams);
2716
+ };
2717
+ const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
2718
+ const DEFAULT_API_VERSION = "v3";
2719
+ const generateContentUrl = (options) => {
2720
+ const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION } = options;
2721
+ if (!apiKey)
2722
+ throw new Error("Missing API key");
2723
+ if (![
2724
+ "v2",
2725
+ "v3"
2726
+ ].includes(apiVersion))
2727
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
2728
+ 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}` : ""}`);
2729
+ const queryOptions = {
2730
+ ...getBuilderSearchParamsFromWindow(),
2731
+ ...normalizeSearchParams(options.options || {})
2732
+ };
2733
+ const flattened = flatten(queryOptions);
2734
+ for (const key in flattened)
2735
+ url.searchParams.set(key, String(flattened[key]));
2736
+ if (userAttributes)
2737
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
2738
+ if (query) {
2739
+ const flattened2 = flatten({
2740
+ query
2741
+ });
2742
+ for (const key in flattened2)
2743
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
2744
+ }
2745
+ return url;
2746
+ };
2747
+ const checkContentHasResults = (content) => "results" in content;
2748
+ async function getContent(options) {
2749
+ const allContent = await getAllContent({
2750
+ ...options,
2751
+ limit: 1
2752
+ });
2753
+ if (allContent)
2754
+ return allContent.results[0] || null;
2755
+ return null;
2756
+ }
2757
+ const fetchContent$1 = async (options) => {
2758
+ const url = generateContentUrl(options);
2759
+ const res = await fetch$1(url.href);
2760
+ const content = await res.json();
2761
+ return content;
2762
+ };
2763
+ const processContentResult = async (options, content, url = generateContentUrl(options)) => {
2764
+ const canTrack = getDefaultCanTrack(options.canTrack);
2765
+ url.search.includes(`preview=`);
2766
+ if (!canTrack)
2767
+ return content;
2768
+ if (!(isBrowser() || TARGET === "reactNative"))
2769
+ return content;
2770
+ try {
2771
+ const newResults = [];
2772
+ for (const item of content.results)
2773
+ newResults.push(await handleABTesting({
2774
+ item,
2775
+ canTrack
2776
+ }));
2777
+ content.results = newResults;
2778
+ } catch (e) {
2779
+ logger.error("Could not process A/B tests. ", e);
2780
+ }
2781
+ return content;
2782
+ };
2783
+ async function getAllContent(options) {
2784
+ try {
2785
+ const url = generateContentUrl(options);
2786
+ const content = await fetchContent$1(options);
2787
+ if (!checkContentHasResults(content)) {
2788
+ logger.error("Error fetching data. ", {
2789
+ url,
2790
+ content,
2791
+ options
2792
+ });
2793
+ return null;
2794
+ }
2795
+ return processContentResult(options, content);
2796
+ } catch (error) {
2797
+ logger.error("Error fetching data. ", error);
2798
+ return null;
2799
+ }
2800
+ }
2801
+ function isPreviewing() {
2802
+ if (!isBrowser())
2803
+ return false;
2804
+ if (isEditing())
2805
+ return false;
2806
+ return Boolean(location.search.indexOf("builder.preview=") !== -1);
2807
+ }
2808
+ function uuidv4() {
2809
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
2810
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
2811
+ return v.toString(16);
2812
+ });
2813
+ }
2814
+ function uuid() {
2815
+ return uuidv4().replace(/-/g, "");
2816
+ }
2817
+ const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
2818
+ const getSessionId = async ({ canTrack }) => {
2819
+ if (!canTrack)
2820
+ return void 0;
2821
+ const sessionId = await getCookie({
2822
+ name: SESSION_LOCAL_STORAGE_KEY,
2823
+ canTrack
2824
+ });
2825
+ if (checkIsDefined(sessionId))
2826
+ return sessionId;
2827
+ else {
2828
+ const newSessionId = createSessionId();
2829
+ setSessionId({
2830
+ id: newSessionId,
2831
+ canTrack
2832
+ });
2833
+ return newSessionId;
2834
+ }
2835
+ };
2836
+ const createSessionId = () => uuid();
2837
+ const setSessionId = ({ id, canTrack }) => setCookie({
2838
+ name: SESSION_LOCAL_STORAGE_KEY,
2839
+ value: id,
2840
+ canTrack
2841
+ });
2842
+ const getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
2843
+ const getLocalStorageItem = ({ key, canTrack }) => {
2844
+ try {
2845
+ if (canTrack)
2846
+ return getLocalStorage()?.getItem(key);
2847
+ return void 0;
2848
+ } catch (err) {
2849
+ console.debug("[LocalStorage] GET error: ", err);
2850
+ return void 0;
2851
+ }
2852
+ };
2853
+ const setLocalStorageItem = ({ key, canTrack, value }) => {
2854
+ try {
2855
+ if (canTrack)
2856
+ getLocalStorage()?.setItem(key, value);
2857
+ } catch (err) {
2858
+ console.debug("[LocalStorage] SET error: ", err);
2859
+ }
2860
+ };
2861
+ const VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
2862
+ const getVisitorId = ({ canTrack }) => {
2863
+ if (!canTrack)
2864
+ return void 0;
2865
+ const visitorId = getLocalStorageItem({
2866
+ key: VISITOR_LOCAL_STORAGE_KEY,
2867
+ canTrack
2868
+ });
2869
+ if (checkIsDefined(visitorId))
2870
+ return visitorId;
2871
+ else {
2872
+ const newVisitorId = createVisitorId();
2873
+ setVisitorId({
2874
+ id: newVisitorId,
2875
+ canTrack
2876
+ });
2877
+ return newVisitorId;
2878
+ }
2879
+ };
2880
+ const createVisitorId = () => uuid();
2881
+ const setVisitorId = ({ id, canTrack }) => setLocalStorageItem({
2882
+ key: VISITOR_LOCAL_STORAGE_KEY,
2883
+ value: id,
2884
+ canTrack
2885
+ });
2886
+ const getLocation = () => {
2887
+ if (isBrowser()) {
2888
+ const parsedLocation = new URL(location.href);
2889
+ if (parsedLocation.pathname === "")
2890
+ parsedLocation.pathname = "/";
2891
+ return parsedLocation;
2892
+ } else {
2893
+ console.warn("Cannot get location for tracking in non-browser environment");
2894
+ return null;
2895
+ }
2896
+ };
2897
+ const getUserAgent = () => typeof navigator === "object" && navigator.userAgent || "";
2898
+ const getUserAttributes = () => {
2899
+ const userAgent = getUserAgent();
2900
+ const isMobile = {
2901
+ Android() {
2902
+ return userAgent.match(/Android/i);
2903
+ },
2904
+ BlackBerry() {
2905
+ return userAgent.match(/BlackBerry/i);
2906
+ },
2907
+ iOS() {
2908
+ return userAgent.match(/iPhone|iPod/i);
2909
+ },
2910
+ Opera() {
2911
+ return userAgent.match(/Opera Mini/i);
2912
+ },
2913
+ Windows() {
2914
+ return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
2915
+ },
2916
+ any() {
2917
+ return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || TARGET === "reactNative";
2918
+ }
2919
+ };
2920
+ const isTablet = userAgent.match(/Tablet|iPad/i);
2921
+ const url = getLocation();
2922
+ return {
2923
+ urlPath: url?.pathname,
2924
+ host: url?.host || url?.hostname,
2925
+ device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
2926
+ };
2927
+ };
2928
+ const getTrackingEventData = async ({ canTrack }) => {
2929
+ if (!canTrack)
2930
+ return {
2931
+ visitorId: void 0,
2932
+ sessionId: void 0
2933
+ };
2934
+ const sessionId = await getSessionId({
2935
+ canTrack
2936
+ });
2937
+ const visitorId = getVisitorId({
2938
+ canTrack
2939
+ });
2940
+ return {
2941
+ sessionId,
2942
+ visitorId
2943
+ };
2944
+ };
2945
+ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...properties }) => ({
2946
+ type: eventType,
2947
+ data: {
2948
+ ...properties,
2949
+ metadata: {
2950
+ url: location.href,
2951
+ ...metadata
2952
+ },
2953
+ ...await getTrackingEventData({
2954
+ canTrack
2955
+ }),
2956
+ userAttributes: getUserAttributes(),
2957
+ ownerId: apiKey
2958
+ }
2959
+ });
2960
+ async function _track(eventProps) {
2961
+ if (!eventProps.apiKey) {
2962
+ logger.error("Missing API key for track call. Please provide your API key.");
2963
+ return;
2964
+ }
2965
+ if (!eventProps.canTrack)
2966
+ return;
2967
+ if (isEditing())
2968
+ return;
2969
+ if (!(isBrowser() || TARGET === "reactNative"))
2970
+ return;
2971
+ return fetch(`https://cdn.builder.io/api/v1/track`, {
2972
+ method: "POST",
2973
+ body: JSON.stringify({
2974
+ events: [
2975
+ await createEvent(eventProps)
2976
+ ]
2977
+ }),
2978
+ headers: {
2979
+ "content-type": "application/json"
2980
+ },
2981
+ mode: "cors"
2982
+ }).catch((err) => {
2983
+ console.error("Failed to track: ", err);
2984
+ });
2985
+ }
2986
+ const track = (args) => _track({
2987
+ ...args,
2988
+ canTrack: true
2989
+ });
2990
+ function round(num) {
2991
+ return Math.round(num * 1e3) / 1e3;
2992
+ }
2993
+ const findParentElement = (target, callback, checkElement = true) => {
2994
+ if (!(target instanceof HTMLElement))
2995
+ return null;
2996
+ let parent2 = checkElement ? target : target.parentElement;
2997
+ do {
2998
+ if (!parent2)
2999
+ return null;
3000
+ const matches = callback(parent2);
3001
+ if (matches)
3002
+ return parent2;
3003
+ } while (parent2 = parent2.parentElement);
3004
+ return null;
3005
+ };
3006
+ const findBuilderParent = (target) => findParentElement(target, (el) => {
3007
+ const id = el.getAttribute("builder-id") || el.id;
3008
+ return Boolean(id?.indexOf("builder-") === 0);
3009
+ });
3010
+ const computeOffset = ({ event, target }) => {
3011
+ const targetRect = target.getBoundingClientRect();
3012
+ const xOffset = event.clientX - targetRect.left;
3013
+ const yOffset = event.clientY - targetRect.top;
3014
+ const xRatio = round(xOffset / targetRect.width);
3015
+ const yRatio = round(yOffset / targetRect.height);
3016
+ return {
3017
+ x: xRatio,
3018
+ y: yRatio
3019
+ };
3020
+ };
3021
+ const getInteractionPropertiesForEvent = (event) => {
3022
+ const target = event.target;
3023
+ const targetBuilderElement = target && findBuilderParent(target);
3024
+ const builderId = targetBuilderElement?.getAttribute("builder-id") || targetBuilderElement?.id;
3025
+ return {
3026
+ targetBuilderElement: builderId || void 0,
3027
+ metadata: {
3028
+ targetOffset: target ? computeOffset({
3029
+ event,
3030
+ target
3031
+ }) : void 0,
3032
+ builderTargetOffset: targetBuilderElement ? computeOffset({
3033
+ event,
3034
+ target: targetBuilderElement
3035
+ }) : void 0,
3036
+ builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
3037
+ }
3038
+ };
3039
+ };
3040
+ const SDK_VERSION = "0.5.3-1";
3041
+ const registry = {};
3042
+ function register(type, info) {
3043
+ let typeList = registry[type];
3044
+ if (!typeList)
3045
+ typeList = registry[type] = [];
3046
+ typeList.push(info);
3047
+ if (isBrowser()) {
3048
+ const message = {
3049
+ type: "builder.register",
3050
+ data: {
3051
+ type,
3052
+ info
3053
+ }
3054
+ };
3055
+ try {
3056
+ parent.postMessage(message, "*");
3057
+ if (parent !== window)
3058
+ window.postMessage(message, "*");
3059
+ } catch (err) {
3060
+ console.debug("Could not postmessage", err);
3061
+ }
3062
+ }
3063
+ }
3064
+ const registerInsertMenu = () => {
3065
+ register("insertMenu", {
3066
+ name: "_default",
3067
+ default: true,
3068
+ items: [
3069
+ {
3070
+ name: "Box"
3071
+ },
3072
+ {
3073
+ name: "Text"
3074
+ },
3075
+ {
3076
+ name: "Image"
3077
+ },
3078
+ {
3079
+ name: "Columns"
3080
+ },
3081
+ ...[
3082
+ {
3083
+ name: "Core:Section"
3084
+ },
3085
+ {
3086
+ name: "Core:Button"
3087
+ },
3088
+ {
3089
+ name: "Embed"
3090
+ },
3091
+ {
3092
+ name: "Custom Code"
3093
+ }
3094
+ ]
3095
+ ]
3096
+ });
3097
+ };
3098
+ let isSetupForEditing = false;
3099
+ const setupBrowserForEditing = (options = {}) => {
3100
+ if (isSetupForEditing)
3101
+ return;
3102
+ isSetupForEditing = true;
3103
+ if (isBrowser()) {
3104
+ window.parent?.postMessage({
3105
+ type: "builder.sdkInfo",
3106
+ data: {
3107
+ target: TARGET,
3108
+ version: SDK_VERSION,
3109
+ supportsPatchUpdates: false,
3110
+ supportsAddBlockScoping: true,
3111
+ supportsCustomBreakpoints: true
3112
+ }
3113
+ }, "*");
3114
+ window.parent?.postMessage({
3115
+ type: "builder.updateContent",
3116
+ data: {
3117
+ options
3118
+ }
3119
+ }, "*");
3120
+ window.addEventListener("message", ({ data }) => {
3121
+ if (!data?.type)
3122
+ return;
3123
+ switch (data.type) {
3124
+ case "builder.evaluate": {
3125
+ const text = data.data.text;
3126
+ const args = data.data.arguments || [];
3127
+ const id = data.data.id;
3128
+ const fn = new Function(text);
3129
+ let result;
3130
+ let error = null;
3131
+ try {
3132
+ result = fn.apply(null, args);
3133
+ } catch (err) {
3134
+ error = err;
3135
+ }
3136
+ if (error)
3137
+ window.parent?.postMessage({
3138
+ type: "builder.evaluateError",
3139
+ data: {
3140
+ id,
3141
+ error: error.message
3142
+ }
3143
+ }, "*");
3144
+ else if (result && typeof result.then === "function")
3145
+ result.then((finalResult) => {
3146
+ window.parent?.postMessage({
3147
+ type: "builder.evaluateResult",
3148
+ data: {
3149
+ id,
3150
+ result: finalResult
3151
+ }
3152
+ }, "*");
3153
+ }).catch(console.error);
3154
+ else
3155
+ window.parent?.postMessage({
3156
+ type: "builder.evaluateResult",
3157
+ data: {
3158
+ result,
3159
+ id
3160
+ }
3161
+ }, "*");
3162
+ break;
3163
+ }
3164
+ }
3165
+ });
3166
+ }
3167
+ };
3168
+ const mergeNewContent = function mergeNewContent2(props, state, elementRef, newContent) {
3169
+ const newContentValue = {
3170
+ ...props.builderContextSignal.content,
3171
+ ...newContent,
3172
+ data: {
3173
+ ...props.builderContextSignal.content?.data,
3174
+ ...newContent?.data
3175
+ },
3176
+ meta: {
3177
+ ...props.builderContextSignal.content?.meta,
3178
+ ...newContent?.meta,
3179
+ breakpoints: newContent?.meta?.breakpoints || props.builderContextSignal.content?.meta?.breakpoints
3180
+ }
3181
+ };
3182
+ props.builderContextSignal.content = newContentValue;
3183
+ };
3184
+ const processMessage = function processMessage2(props, state, elementRef, event) {
3185
+ const { data } = event;
3186
+ if (data)
3187
+ switch (data.type) {
3188
+ case "builder.configureSdk": {
3189
+ const messageContent = data.data;
3190
+ const { breakpoints, contentId } = messageContent;
3191
+ if (!contentId || contentId !== props.builderContextSignal.content?.id)
3192
+ return;
3193
+ if (breakpoints)
3194
+ mergeNewContent(props, state, elementRef, {
3195
+ meta: {
3196
+ breakpoints
3197
+ }
3198
+ });
3199
+ state.forceReRenderCount = state.forceReRenderCount + 1;
3200
+ break;
3201
+ }
3202
+ case "builder.contentUpdate": {
3203
+ const messageContent = data.data;
3204
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3205
+ const contentData = messageContent.data;
3206
+ if (key === props.model) {
3207
+ mergeNewContent(props, state, elementRef, contentData);
3208
+ state.forceReRenderCount = state.forceReRenderCount + 1;
3209
+ }
3210
+ break;
3211
+ }
3212
+ }
3213
+ };
3214
+ const evaluateJsCode = function evaluateJsCode2(props, state, elementRef) {
3215
+ const jsCode = props.builderContextSignal.content?.data?.jsCode;
3216
+ if (jsCode)
3217
+ evaluate({
3218
+ code: jsCode,
3219
+ context: props.context || {},
3220
+ localState: void 0,
3221
+ rootState: props.builderContextSignal.rootState,
3222
+ rootSetState: props.builderContextSignal.rootSetState
3223
+ });
3224
+ };
3225
+ const onClick = function onClick22(props, state, elementRef, event) {
3226
+ if (props.builderContextSignal.content) {
3227
+ const variationId = props.builderContextSignal.content?.testVariationId;
3228
+ const contentId = props.builderContextSignal.content?.id;
3229
+ _track({
3230
+ type: "click",
3231
+ canTrack: state.canTrackToUse,
3232
+ contentId,
3233
+ apiKey: props.apiKey,
3234
+ variationId: variationId !== contentId ? variationId : void 0,
3235
+ ...getInteractionPropertiesForEvent(event),
3236
+ unique: !state.clicked
3237
+ });
3238
+ }
3239
+ if (!state.clicked)
3240
+ state.clicked = true;
3241
+ };
3242
+ const evalExpression = function evalExpression2(props, state, elementRef, expression) {
3243
+ return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
3244
+ code: group,
3245
+ context: props.context || {},
3246
+ localState: void 0,
3247
+ rootState: props.builderContextSignal.rootState,
3248
+ rootSetState: props.builderContextSignal.rootSetState
3249
+ }));
3250
+ };
3251
+ const handleRequest = function handleRequest2(props, state, elementRef, { url, key }) {
3252
+ fetch$1(url).then((response) => response.json()).then((json) => {
3253
+ const newState = {
3254
+ ...props.builderContextSignal.rootState,
3255
+ [key]: json
3256
+ };
3257
+ props.builderContextSignal.rootSetState?.(newState);
3258
+ state.httpReqsData[key] = true;
3259
+ }).catch((err) => {
3260
+ console.error("error fetching dynamic data", url, err);
3261
+ });
3262
+ };
3263
+ const runHttpRequests = function runHttpRequests2(props, state, elementRef) {
3264
+ const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
3265
+ Object.entries(requests).forEach(([key, url]) => {
3266
+ if (url && (!state.httpReqsData[key] || isEditing())) {
3267
+ const evaluatedUrl = evalExpression(props, state, elementRef, url);
3268
+ handleRequest(props, state, elementRef, {
3269
+ url: evaluatedUrl,
3270
+ key
3271
+ });
3272
+ }
3273
+ });
3274
+ };
3275
+ const emitStateUpdate = function emitStateUpdate2(props, state, elementRef) {
3276
+ if (isEditing())
3277
+ window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
3278
+ detail: {
3279
+ state: props.builderContextSignal.rootState,
3280
+ ref: {
3281
+ name: props.model
3282
+ }
3283
+ }
3284
+ }));
3285
+ };
3286
+ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3287
+ _jsxBranch();
3288
+ const elementRef = useSignal();
3289
+ const state = useStore({
3290
+ canTrackToUse: checkIsDefined(props.canTrack) ? props.canTrack : true,
3291
+ clicked: false,
3292
+ forceReRenderCount: 0,
3293
+ httpReqsData: {},
3294
+ lastUpdated: 0,
3295
+ shouldSendResetCookie: false
3296
+ }, {
3297
+ deep: true
3298
+ });
3299
+ useContextProvider(builderContext, props.builderContextSignal);
3300
+ useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
3301
+ const [elementRef2, props2, state2] = useLexicalScope();
3302
+ if (!props2.apiKey)
3303
+ logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
3304
+ if (isBrowser()) {
3305
+ if (isEditing()) {
3306
+ state2.forceReRenderCount = state2.forceReRenderCount + 1;
3307
+ window.addEventListener("message", processMessage.bind(null, props2, state2, elementRef2));
3308
+ registerInsertMenu();
3309
+ setupBrowserForEditing({
3310
+ ...props2.locale ? {
3311
+ locale: props2.locale
3312
+ } : {},
3313
+ ...props2.includeRefs ? {
3314
+ includeRefs: props2.includeRefs
3315
+ } : {},
3316
+ ...props2.enrich ? {
3317
+ enrich: props2.enrich
3318
+ } : {}
3319
+ });
3320
+ Object.values(props2.builderContextSignal.componentInfos).forEach((registeredComponent) => {
3321
+ const message = createRegisterComponentMessage(registeredComponent);
3322
+ window.parent?.postMessage(message, "*");
3323
+ });
3324
+ window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props2, state2, elementRef2));
3325
+ }
3326
+ if (props2.builderContextSignal.content) {
3327
+ const variationId = props2.builderContextSignal.content?.testVariationId;
3328
+ const contentId = props2.builderContextSignal.content?.id;
3329
+ _track({
3330
+ type: "impression",
3331
+ canTrack: state2.canTrackToUse,
3332
+ contentId,
3333
+ apiKey: props2.apiKey,
3334
+ variationId: variationId !== contentId ? variationId : void 0
3335
+ });
3336
+ }
3337
+ if (isPreviewing()) {
3338
+ const searchParams = new URL(location.href).searchParams;
3339
+ const searchParamPreviewModel = searchParams.get("builder.preview");
3340
+ const searchParamPreviewId = searchParams.get(`builder.preview.${searchParamPreviewModel}`);
3341
+ const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
3342
+ if (searchParamPreviewModel === props2.model && previewApiKey === props2.apiKey && (!props2.content || searchParamPreviewId === props2.content.id))
3343
+ getContent({
3344
+ model: props2.model,
3345
+ apiKey: props2.apiKey,
3346
+ apiVersion: props2.builderContextSignal.apiVersion
3347
+ }).then((content) => {
3348
+ if (content)
3349
+ mergeNewContent(props2, state2, elementRef2, content);
3350
+ });
3351
+ }
3352
+ evaluateJsCode(props2);
3353
+ runHttpRequests(props2, state2, elementRef2);
3354
+ emitStateUpdate(props2);
3355
+ }
3356
+ }, "EnableEditor_component_useVisibleTask_Olaxc9jCOFk", [
3357
+ elementRef,
3358
+ props,
3359
+ state
3360
+ ]));
3361
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3362
+ const [elementRef2, props2, state2] = useLexicalScope();
3363
+ track2(() => props2.content);
3364
+ if (props2.content)
3365
+ mergeNewContent(props2, state2, elementRef2, props2.content);
3366
+ }, "EnableEditor_component_useTask_Nb2VI04qp0M", [
3367
+ elementRef,
3368
+ props,
3369
+ state
3370
+ ]));
3371
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3372
+ const [state2] = useLexicalScope();
3373
+ track2(() => state2.shouldSendResetCookie);
3374
+ }, "EnableEditor_component_useTask_1_m0y1Z9vk4eQ", [
3375
+ state
3376
+ ]));
3377
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3378
+ const [elementRef2, props2, state2] = useLexicalScope();
3379
+ track2(() => props2.builderContextSignal.content?.data?.jsCode);
3380
+ track2(() => props2.builderContextSignal.rootState);
3381
+ evaluateJsCode(props2);
3382
+ }, "EnableEditor_component_useTask_2_xVyv0tDqZLs", [
3383
+ elementRef,
3384
+ props,
3385
+ state
3386
+ ]));
3387
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3388
+ const [elementRef2, props2, state2] = useLexicalScope();
3389
+ track2(() => props2.builderContextSignal.content?.data?.httpRequests);
3390
+ runHttpRequests(props2, state2, elementRef2);
3391
+ }, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
3392
+ elementRef,
3393
+ props,
3394
+ state
3395
+ ]));
3396
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3397
+ const [elementRef2, props2, state2] = useLexicalScope();
3398
+ track2(() => props2.builderContextSignal.rootState);
3399
+ emitStateUpdate(props2);
3400
+ }, "EnableEditor_component_useTask_4_moHYZG8uNVU", [
3401
+ elementRef,
3402
+ props,
3403
+ state
3404
+ ]));
3405
+ return /* @__PURE__ */ _jsxC(Fragment, {
3406
+ children: props.builderContextSignal.content ? /* @__PURE__ */ _jsxS("div", {
3407
+ ref: elementRef,
3408
+ ...props.showContent ? {} : {
3409
+ hidden: true,
3410
+ "aria-hidden": true
3411
+ },
3412
+ children: /* @__PURE__ */ _jsxC(Slot, null, 3, "06_0"),
3413
+ onClick$: /* @__PURE__ */ inlinedQrl((event) => {
3414
+ const [elementRef2, props2, state2] = useLexicalScope();
3415
+ return onClick(props2, state2, elementRef2, event);
3416
+ }, "EnableEditor_component__Fragment_div_onClick_1QOkLijjH0M", [
3417
+ elementRef,
3418
+ props,
3419
+ state
3420
+ ])
3421
+ }, {
3422
+ "builder-content-id": _fnSignal((p0) => p0.builderContextSignal.content?.id, [
3423
+ props
3424
+ ], "p0.builderContextSignal.content?.id"),
3425
+ "builder-model": _fnSignal((p0) => p0.model, [
3426
+ props
3427
+ ], "p0.model"),
3428
+ class: _fnSignal((p0) => p0.classNameProp, [
3429
+ props
3430
+ ], "p0.classNameProp")
3431
+ }, 0, state.forceReRenderCount) : null
3432
+ }, 1, "06_1");
3433
+ }, "EnableEditor_component_ko1mO8oaj8k"));
3434
+ const getCssFromFont = (font) => {
3435
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
3436
+ const name = family.split(",")[0];
3437
+ const url = font.fileUrl ?? font?.files?.regular;
3438
+ let str = "";
3439
+ if (url && family && name)
3440
+ str += `
3441
+ @font-face {
3442
+ font-family: "${family}";
3443
+ src: local("${name}"), url('${url}') format('woff2');
3444
+ font-display: fallback;
3445
+ font-weight: 400;
3446
+ }
3447
+ `.trim();
3448
+ if (font.files)
3449
+ for (const weight in font.files) {
3450
+ const isNumber = String(Number(weight)) === weight;
3451
+ if (!isNumber)
3452
+ continue;
3453
+ const weightUrl = font.files[weight];
3454
+ if (weightUrl && weightUrl !== url)
3455
+ str += `
3456
+ @font-face {
3457
+ font-family: "${family}";
3458
+ src: url('${weightUrl}') format('woff2');
3459
+ font-display: fallback;
3460
+ font-weight: ${weight};
3461
+ }
3462
+ `.trim();
3463
+ }
3464
+ return str;
3465
+ };
3466
+ const getFontCss = ({ customFonts }) => {
3467
+ return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
3468
+ };
3469
+ const getCss = ({ cssCode, contentId }) => {
3470
+ if (!cssCode)
3471
+ return "";
3472
+ if (!contentId)
3473
+ return cssCode;
3474
+ return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
3475
+ };
3476
+ const ContentStyles = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3477
+ const state = useStore({
3478
+ injectedStyles: `
3479
+ ${getCss({
3480
+ cssCode: props.cssCode,
3481
+ contentId: props.contentId
3482
+ })}
3483
+ ${getFontCss({
3484
+ customFonts: props.customFonts
3485
+ })}
3486
+
3487
+ .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
3488
+ margin: 0;
3489
+ }
3490
+ .builder-text > p, .builder-text > .builder-paragraph {
3491
+ color: inherit;
3492
+ line-height: inherit;
3493
+ letter-spacing: inherit;
3494
+ font-weight: inherit;
3495
+ font-size: inherit;
3496
+ text-align: inherit;
3497
+ font-family: inherit;
3498
+ }
3499
+ `.trim()
3500
+ });
3501
+ return /* @__PURE__ */ _jsxC(InlinedStyles, {
3502
+ get styles() {
3503
+ return state.injectedStyles;
3504
+ },
3505
+ [_IMMUTABLE]: {
3506
+ styles: _fnSignal((p0) => p0.injectedStyles, [
3507
+ state
3508
+ ], "p0.injectedStyles")
3509
+ }
3510
+ }, 3, "8O_0");
3511
+ }, "ContentStyles_component_Qbhu1myPWm0"));
3512
+ const getContextStateInitialValue = ({ content, data, locale }) => {
3513
+ const defaultValues = {};
3514
+ content?.data?.inputs?.forEach((input) => {
3515
+ if (input.name && input.defaultValue !== void 0 && content?.data?.state && content.data.state[input.name] === void 0)
3516
+ defaultValues[input.name] = input.defaultValue;
3517
+ });
3518
+ const stateToUse = {
3519
+ ...content?.data?.state,
3520
+ ...data,
3521
+ ...locale ? {
3522
+ locale
3523
+ } : {}
3524
+ };
3525
+ return {
3526
+ ...defaultValues,
3527
+ ...stateToUse
3528
+ };
3529
+ };
3530
+ const getContentInitialValue = ({ content, data }) => {
3531
+ return !content ? void 0 : {
3532
+ ...content,
3533
+ data: {
3534
+ ...content?.data,
3535
+ ...data
3536
+ },
3537
+ meta: content?.meta
3538
+ };
3539
+ };
3540
+ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3541
+ _jsxBranch();
3542
+ const state = useStore({
3543
+ builderContextSignal: {
3544
+ content: getContentInitialValue({
3545
+ content: props.content,
3546
+ data: props.data
3547
+ }),
3548
+ localState: void 0,
3549
+ rootState: getContextStateInitialValue({
3550
+ content: props.content,
3551
+ data: props.data,
3552
+ locale: props.locale
3553
+ }),
3554
+ rootSetState: void 0,
3555
+ context: props.context || {},
3556
+ apiKey: props.apiKey,
3557
+ apiVersion: props.apiVersion,
3558
+ componentInfos: [
3559
+ ...getDefaultRegisteredComponents(),
3560
+ ...components,
3561
+ ...props.customComponents || []
3562
+ ].reduce((acc, { component: _, ...info }) => ({
3563
+ ...acc,
3564
+ [info.name]: serializeComponentInfo(info)
3565
+ }), {}),
3566
+ inheritedStyles: {}
3567
+ },
3568
+ registeredComponents: [
3569
+ ...getDefaultRegisteredComponents(),
3570
+ ...components,
3571
+ ...props.customComponents || []
3572
+ ].reduce((acc, { component, ...info }) => ({
3573
+ ...acc,
3574
+ [info.name]: {
3575
+ component,
3576
+ ...serializeComponentInfo(info)
3577
+ }
3578
+ }), {}),
3579
+ scriptStr: getRenderContentScriptString({
3580
+ variationId: props.content?.testVariationId,
3581
+ contentId: props.content?.id
3582
+ })
3583
+ }, {
3584
+ deep: true
3585
+ });
3586
+ useContextProvider(ComponentsContext, useStore({
3587
+ registeredComponents: state.registeredComponents
3588
+ }));
3589
+ return /* @__PURE__ */ _jsxC(EnableEditor, {
3590
+ get content() {
3591
+ return props.content;
3592
+ },
3593
+ get model() {
3594
+ return props.model;
3595
+ },
3596
+ get context() {
3597
+ return props.context;
3598
+ },
3599
+ get apiKey() {
3600
+ return props.apiKey;
3601
+ },
3602
+ get canTrack() {
3603
+ return props.canTrack;
3604
+ },
3605
+ get locale() {
3606
+ return props.locale;
3607
+ },
3608
+ get includeRefs() {
3609
+ return props.includeRefs;
3610
+ },
3611
+ get enrich() {
3612
+ return props.enrich;
3613
+ },
3614
+ get classNameProp() {
3615
+ return props.classNameProp;
3616
+ },
3617
+ get showContent() {
3618
+ return props.showContent;
3619
+ },
3620
+ get builderContextSignal() {
3621
+ return state.builderContextSignal;
3622
+ },
3623
+ children: [
3624
+ props.isSsrAbTest ? /* @__PURE__ */ _jsxC(InlinedScript, {
3625
+ get scriptStr() {
3626
+ return state.scriptStr;
3627
+ },
3628
+ [_IMMUTABLE]: {
3629
+ scriptStr: _fnSignal((p0) => p0.scriptStr, [
3630
+ state
3631
+ ], "p0.scriptStr")
3632
+ }
3633
+ }, 3, "LQ_0") : null,
3634
+ /* @__PURE__ */ _jsxC(ContentStyles, {
3635
+ get contentId() {
3636
+ return state.builderContextSignal.content?.id;
3637
+ },
3638
+ get cssCode() {
3639
+ return state.builderContextSignal.content?.data?.cssCode;
3640
+ },
3641
+ get customFonts() {
3642
+ return state.builderContextSignal.content?.data?.customFonts;
3643
+ },
3644
+ [_IMMUTABLE]: {
3645
+ contentId: _fnSignal((p0) => p0.builderContextSignal.content?.id, [
3646
+ state
3647
+ ], "p0.builderContextSignal.content?.id"),
3648
+ cssCode: _fnSignal((p0) => p0.builderContextSignal.content?.data?.cssCode, [
3649
+ state
3650
+ ], "p0.builderContextSignal.content?.data?.cssCode"),
3651
+ customFonts: _fnSignal((p0) => p0.builderContextSignal.content?.data?.customFonts, [
3652
+ state
3653
+ ], "p0.builderContextSignal.content?.data?.customFonts")
3654
+ }
3655
+ }, 3, "LQ_1"),
3656
+ /* @__PURE__ */ _jsxC(Blocks, {
3657
+ get blocks() {
3658
+ return state.builderContextSignal.content?.data?.blocks;
3659
+ },
3660
+ get context() {
3661
+ return state.builderContextSignal;
3662
+ },
3663
+ get registeredComponents() {
3664
+ return state.registeredComponents;
3665
+ },
3666
+ [_IMMUTABLE]: {
3667
+ blocks: _fnSignal((p0) => p0.builderContextSignal.content?.data?.blocks, [
3668
+ state
3669
+ ], "p0.builderContextSignal.content?.data?.blocks"),
3670
+ context: _fnSignal((p0) => p0.builderContextSignal, [
3671
+ state
3672
+ ], "p0.builderContextSignal"),
3673
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
3674
+ state
3675
+ ], "p0.registeredComponents")
3676
+ }
3677
+ }, 3, "LQ_2")
3678
+ ],
3679
+ [_IMMUTABLE]: {
3680
+ content: _fnSignal((p0) => p0.content, [
3681
+ props
3682
+ ], "p0.content"),
3683
+ model: _fnSignal((p0) => p0.model, [
3684
+ props
3685
+ ], "p0.model"),
3686
+ context: _fnSignal((p0) => p0.context, [
3687
+ props
3688
+ ], "p0.context"),
3689
+ apiKey: _fnSignal((p0) => p0.apiKey, [
3690
+ props
3691
+ ], "p0.apiKey"),
3692
+ canTrack: _fnSignal((p0) => p0.canTrack, [
3693
+ props
3694
+ ], "p0.canTrack"),
3695
+ locale: _fnSignal((p0) => p0.locale, [
3696
+ props
3697
+ ], "p0.locale"),
3698
+ includeRefs: _fnSignal((p0) => p0.includeRefs, [
3699
+ props
3700
+ ], "p0.includeRefs"),
3701
+ enrich: _fnSignal((p0) => p0.enrich, [
3702
+ props
3703
+ ], "p0.enrich"),
3704
+ classNameProp: _fnSignal((p0) => p0.classNameProp, [
3705
+ props
3706
+ ], "p0.classNameProp"),
3707
+ showContent: _fnSignal((p0) => p0.showContent, [
3708
+ props
3709
+ ], "p0.showContent"),
3710
+ builderContextSignal: _fnSignal((p0) => p0.builderContextSignal, [
3711
+ state
3712
+ ], "p0.builderContextSignal")
3713
+ }
3714
+ }, 1, "LQ_3");
3715
+ }, "ContentComponent_component_HIsczUcxjCE"));
3716
+ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3717
+ _jsxBranch();
3718
+ const variantScriptStr = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
3719
+ const [props2] = useLexicalScope();
3720
+ return getVariantsScriptString(getVariants(props2.content).map((value) => ({
3721
+ id: value.testVariationId,
3722
+ testRatio: value.testRatio
3723
+ })), props2.content?.id || "");
3724
+ }, "ContentVariants_component_variantScriptStr_useComputed_ldWqWafT8Ww", [
3725
+ props
3726
+ ]));
3727
+ const hideVariantsStyleString = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
3728
+ const [props2] = useLexicalScope();
3729
+ return getVariants(props2.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
3730
+ }, "ContentVariants_component_hideVariantsStyleString_useComputed_fQIC0fJqAl4", [
3731
+ props
3732
+ ]));
3733
+ const state = useStore({
3734
+ shouldRenderVariants: checkShouldRunVariants({
3735
+ canTrack: getDefaultCanTrack(props.canTrack),
3736
+ content: props.content
3737
+ })
3738
+ });
3739
+ useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
3740
+ }, "ContentVariants_component_useVisibleTask_10cWAqcJ45I"));
3741
+ return /* @__PURE__ */ _jsxC(Fragment$1, {
3742
+ children: [
3743
+ !props.__isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(InlinedScript, {
3744
+ scriptStr: getScriptString()
3745
+ }, 3, "XM_0") : null,
3746
+ state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment, {
3747
+ children: [
3748
+ /* @__PURE__ */ _jsxC(InlinedStyles, {
3749
+ get id() {
3750
+ return `variants-styles-${props.content?.id}`;
3751
+ },
3752
+ get styles() {
3753
+ return hideVariantsStyleString.value;
3754
+ },
3755
+ [_IMMUTABLE]: {
3756
+ id: _fnSignal((p0) => `variants-styles-${p0.content?.id}`, [
3757
+ props
3758
+ ], "`variants-styles-${p0.content?.id}`"),
3759
+ styles: _fnSignal((p0) => p0.value, [
3760
+ hideVariantsStyleString
3761
+ ], "p0.value")
3762
+ }
3763
+ }, 3, "XM_1"),
3764
+ /* @__PURE__ */ _jsxC(InlinedScript, {
3765
+ get scriptStr() {
3766
+ return variantScriptStr.value;
3767
+ },
3768
+ [_IMMUTABLE]: {
3769
+ scriptStr: _fnSignal((p0) => p0.value, [
3770
+ variantScriptStr
3771
+ ], "p0.value")
3772
+ }
3773
+ }, 3, "XM_2"),
3774
+ (getVariants(props.content) || []).map(function(variant) {
3775
+ return /* @__PURE__ */ _jsxC(ContentComponent, {
3776
+ content: variant,
3777
+ showContent: false,
3778
+ classNameProp: void 0,
3779
+ get model() {
3780
+ return props.model;
3781
+ },
3782
+ get data() {
3783
+ return props.data;
3784
+ },
3785
+ get context() {
3786
+ return props.context;
3787
+ },
3788
+ get apiKey() {
3789
+ return props.apiKey;
3790
+ },
3791
+ get apiVersion() {
3792
+ return props.apiVersion;
3793
+ },
3794
+ get customComponents() {
3795
+ return props.customComponents;
3796
+ },
3797
+ get canTrack() {
3798
+ return props.canTrack;
3799
+ },
3800
+ get locale() {
3801
+ return props.locale;
3802
+ },
3803
+ get includeRefs() {
3804
+ return props.includeRefs;
3805
+ },
3806
+ get enrich() {
3807
+ return props.enrich;
3808
+ },
3809
+ get isSsrAbTest() {
3810
+ return state.shouldRenderVariants;
3811
+ },
3812
+ [_IMMUTABLE]: {
3813
+ showContent: _IMMUTABLE,
3814
+ model: _fnSignal((p0) => p0.model, [
3815
+ props
3816
+ ], "p0.model"),
3817
+ data: _fnSignal((p0) => p0.data, [
3818
+ props
3819
+ ], "p0.data"),
3820
+ context: _fnSignal((p0) => p0.context, [
3821
+ props
3822
+ ], "p0.context"),
3823
+ apiKey: _fnSignal((p0) => p0.apiKey, [
3824
+ props
3825
+ ], "p0.apiKey"),
3826
+ apiVersion: _fnSignal((p0) => p0.apiVersion, [
3827
+ props
3828
+ ], "p0.apiVersion"),
3829
+ customComponents: _fnSignal((p0) => p0.customComponents, [
3830
+ props
3831
+ ], "p0.customComponents"),
3832
+ canTrack: _fnSignal((p0) => p0.canTrack, [
3833
+ props
3834
+ ], "p0.canTrack"),
3835
+ locale: _fnSignal((p0) => p0.locale, [
3836
+ props
3837
+ ], "p0.locale"),
3838
+ includeRefs: _fnSignal((p0) => p0.includeRefs, [
3839
+ props
3840
+ ], "p0.includeRefs"),
3841
+ enrich: _fnSignal((p0) => p0.enrich, [
3842
+ props
3843
+ ], "p0.enrich"),
3844
+ isSsrAbTest: _fnSignal((p0) => p0.shouldRenderVariants, [
3845
+ state
3846
+ ], "p0.shouldRenderVariants")
3847
+ }
3848
+ }, 3, variant.testVariationId);
3849
+ })
3850
+ ]
3851
+ }, 1, "XM_3") : null,
3852
+ /* @__PURE__ */ _jsxC(ContentComponent, {
3853
+ content: state.shouldRenderVariants ? props.content : handleABTestingSync({
3854
+ item: props.content,
3855
+ canTrack: getDefaultCanTrack(props.canTrack)
3856
+ }),
3857
+ get classNameProp() {
3858
+ return `variant-${props.content?.id}`;
3859
+ },
3860
+ showContent: true,
3861
+ get model() {
3862
+ return props.model;
3863
+ },
3864
+ get data() {
3865
+ return props.data;
3866
+ },
3867
+ get context() {
3868
+ return props.context;
3869
+ },
3870
+ get apiKey() {
3871
+ return props.apiKey;
3872
+ },
3873
+ get apiVersion() {
3874
+ return props.apiVersion;
3875
+ },
3876
+ get customComponents() {
3877
+ return props.customComponents;
3878
+ },
3879
+ get canTrack() {
3880
+ return props.canTrack;
3881
+ },
3882
+ get locale() {
3883
+ return props.locale;
3884
+ },
3885
+ get includeRefs() {
3886
+ return props.includeRefs;
3887
+ },
3888
+ get enrich() {
3889
+ return props.enrich;
3890
+ },
3891
+ get isSsrAbTest() {
3892
+ return state.shouldRenderVariants;
3893
+ },
3894
+ [_IMMUTABLE]: {
3895
+ classNameProp: _fnSignal((p0) => `variant-${p0.content?.id}`, [
3896
+ props
3897
+ ], "`variant-${p0.content?.id}`"),
3898
+ showContent: _IMMUTABLE,
3899
+ model: _fnSignal((p0) => p0.model, [
3900
+ props
3901
+ ], "p0.model"),
3902
+ data: _fnSignal((p0) => p0.data, [
3903
+ props
3904
+ ], "p0.data"),
3905
+ context: _fnSignal((p0) => p0.context, [
3906
+ props
3907
+ ], "p0.context"),
3908
+ apiKey: _fnSignal((p0) => p0.apiKey, [
3909
+ props
3910
+ ], "p0.apiKey"),
3911
+ apiVersion: _fnSignal((p0) => p0.apiVersion, [
3912
+ props
3913
+ ], "p0.apiVersion"),
3914
+ customComponents: _fnSignal((p0) => p0.customComponents, [
3915
+ props
3916
+ ], "p0.customComponents"),
3917
+ canTrack: _fnSignal((p0) => p0.canTrack, [
3918
+ props
3919
+ ], "p0.canTrack"),
3920
+ locale: _fnSignal((p0) => p0.locale, [
3921
+ props
3922
+ ], "p0.locale"),
3923
+ includeRefs: _fnSignal((p0) => p0.includeRefs, [
3924
+ props
3925
+ ], "p0.includeRefs"),
3926
+ enrich: _fnSignal((p0) => p0.enrich, [
3927
+ props
3928
+ ], "p0.enrich"),
3929
+ isSsrAbTest: _fnSignal((p0) => p0.shouldRenderVariants, [
3930
+ state
3931
+ ], "p0.shouldRenderVariants")
3932
+ }
3933
+ }, 3, "XM_4")
3934
+ ]
3935
+ }, 1, "XM_5");
3936
+ }, "ContentVariants_component_4tFRiQMMEfM"));
3937
+ const fetchContent = async ({ builderContextValue, symbol }) => {
3938
+ if (symbol?.model && builderContextValue?.apiKey)
3939
+ return getContent({
3940
+ model: symbol.model,
3941
+ apiKey: builderContextValue.apiKey,
3942
+ apiVersion: builderContextValue.apiVersion,
3943
+ ...symbol?.entry && {
3944
+ query: {
3945
+ id: symbol.entry
3946
+ }
3947
+ }
3948
+ }).catch((err) => {
3949
+ logger.error("Could not fetch symbol content: ", err);
3950
+ return void 0;
3951
+ });
3952
+ return void 0;
3953
+ };
3954
+ const setContent = function setContent2(props, state) {
3955
+ if (state.contentToUse)
3956
+ return;
3957
+ fetchContent({
3958
+ symbol: props.symbol,
3959
+ builderContextValue: props.builderContext
3960
+ }).then((newContent) => {
3961
+ if (newContent)
3962
+ state.contentToUse = newContent;
3963
+ });
3964
+ };
3965
+ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3966
+ const className = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
3967
+ const [props2] = useLexicalScope();
3968
+ return [
3969
+ props2.attributes.class,
3970
+ "builder-symbol",
3971
+ props2.symbol?.inline ? "builder-inline-symbol" : void 0,
3972
+ props2.symbol?.dynamic || props2.dynamic ? "builder-dynamic-symbol" : void 0
3973
+ ].filter(Boolean).join(" ");
3974
+ }, "Symbol_component_className_useComputed_Wb6GqgtDHpE", [
3975
+ props
3976
+ ]));
3977
+ const state = useStore({
3978
+ contentToUse: props.symbol?.content
3979
+ });
3980
+ useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
3981
+ const [props2, state2] = useLexicalScope();
3982
+ setContent(props2, state2);
3983
+ }, "Symbol_component_useVisibleTask_oMPs8W5ZhwE", [
3984
+ props,
3985
+ state
3986
+ ]));
3987
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3988
+ const [props2, state2] = useLexicalScope();
3989
+ track2(() => props2.symbol);
3990
+ setContent(props2, state2);
3991
+ }, "Symbol_component_useTask_NIAWAC1bMBo", [
3992
+ props,
3993
+ state
3994
+ ]));
3995
+ return /* @__PURE__ */ _jsxS("div", {
3996
+ ...props.attributes,
3997
+ children: /* @__PURE__ */ _jsxC(ContentVariants, {
3998
+ get apiVersion() {
3999
+ return props.builderContext.apiVersion;
4000
+ },
4001
+ get apiKey() {
4002
+ return props.builderContext.apiKey;
4003
+ },
4004
+ get context() {
4005
+ return props.builderContext.context;
4006
+ },
4007
+ get customComponents() {
4008
+ return Object.values(props.builderComponents);
4009
+ },
4010
+ get data() {
4011
+ return {
4012
+ ...props.symbol?.data,
4013
+ ...props.builderContext.localState,
4014
+ ...state.contentToUse?.data?.state
4015
+ };
4016
+ },
4017
+ get model() {
4018
+ return props.symbol?.model;
4019
+ },
4020
+ get content() {
4021
+ return state.contentToUse;
4022
+ },
4023
+ [_IMMUTABLE]: {
4024
+ apiVersion: _fnSignal((p0) => p0.builderContext.apiVersion, [
4025
+ props
4026
+ ], "p0.builderContext.apiVersion"),
4027
+ apiKey: _fnSignal((p0) => p0.builderContext.apiKey, [
4028
+ props
4029
+ ], "p0.builderContext.apiKey"),
4030
+ context: _fnSignal((p0) => p0.builderContext.context, [
4031
+ props
4032
+ ], "p0.builderContext.context"),
4033
+ customComponents: _fnSignal((p0) => Object.values(p0.builderComponents), [
4034
+ props
4035
+ ], "Object.values(p0.builderComponents)"),
4036
+ data: _fnSignal((p0, p1) => ({
4037
+ ...p0.symbol?.data,
4038
+ ...p0.builderContext.localState,
4039
+ ...p1.contentToUse?.data?.state
4040
+ }), [
4041
+ props,
4042
+ state
4043
+ ], "{...p0.symbol?.data,...p0.builderContext.localState,...p1.contentToUse?.data?.state}"),
4044
+ model: _fnSignal((p0) => p0.symbol?.model, [
4045
+ props
4046
+ ], "p0.symbol?.model"),
4047
+ content: _fnSignal((p0) => p0.contentToUse, [
4048
+ state
4049
+ ], "p0.contentToUse")
4050
+ }
4051
+ }, 3, "Wt_0")
4052
+ }, {
4053
+ class: _fnSignal((p0) => p0.value, [
4054
+ className
4055
+ ], "p0.value")
4056
+ }, 0, "Wt_1");
4057
+ }, "Symbol_component_WVvggdkUPdk"));
4058
+ const settings = {};
4059
+ function setEditorSettings(newSettings) {
4060
+ if (isBrowser()) {
4061
+ Object.assign(settings, newSettings);
4062
+ const message = {
4063
+ type: "builder.settingsChange",
4064
+ data: settings
4065
+ };
4066
+ parent.postMessage(message, "*");
4067
+ }
4068
+ }
4069
+ export {
4070
+ Button as B,
4071
+ Columns as C,
4072
+ FragmentComponent as F,
4073
+ Image as I,
4074
+ SectionComponent as S,
4075
+ Text as T,
4076
+ Video as V,
4077
+ isPreviewing as a,
4078
+ setEditorSettings as b,
4079
+ createRegisterComponentMessage as c,
4080
+ getContent as d,
4081
+ getBuilderSearchParams as e,
4082
+ Blocks as f,
4083
+ getAllContent as g,
4084
+ Symbol$1 as h,
4085
+ isEditing as i,
4086
+ ContentVariants as j,
4087
+ logger as l,
4088
+ processContentResult as p,
4089
+ register as r,
4090
+ set as s,
4091
+ track as t
4092
+ };