@builder.io/sdk-qwik 0.5.3-3 → 0.5.3-4

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