@builder.io/sdk-qwik 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2997 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+
5
+ const qwik = require('@builder.io/qwik');
6
+ const jsxRuntime = require('@builder.io/qwik/jsx-runtime');
7
+
8
+ /** This file should be overriden for each framework. Ideally this would be implemented in Mitosis. */ const TARGET = 'qwik';
9
+
10
+ function isBrowser() {
11
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
12
+ }
13
+
14
+ const registry = {};
15
+ function register(type, info) {
16
+ let typeList = registry[type];
17
+ if (!typeList) typeList = registry[type] = [];
18
+ typeList.push(info);
19
+ if (isBrowser()) {
20
+ const message = {
21
+ type: 'builder.register',
22
+ data: {
23
+ type,
24
+ info
25
+ }
26
+ };
27
+ try {
28
+ parent.postMessage(message, '*');
29
+ if (parent !== window) window.postMessage(message, '*');
30
+ } catch (err) {
31
+ console.debug('Could not postmessage', err);
32
+ }
33
+ }
34
+ }
35
+
36
+ const registerInsertMenu = ()=>{
37
+ register('insertMenu', {
38
+ name: '_default',
39
+ default: true,
40
+ items: [
41
+ {
42
+ name: 'Box'
43
+ },
44
+ {
45
+ name: 'Text'
46
+ },
47
+ {
48
+ name: 'Image'
49
+ },
50
+ {
51
+ name: 'Columns'
52
+ },
53
+ ...TARGET === 'reactNative' ? [] : [
54
+ {
55
+ name: 'Core:Section'
56
+ },
57
+ {
58
+ name: 'Core:Button'
59
+ },
60
+ {
61
+ name: 'Embed'
62
+ },
63
+ {
64
+ name: 'Custom Code'
65
+ }
66
+ ]
67
+ ]
68
+ });
69
+ };
70
+ let isSetupForEditing = false;
71
+ const setupBrowserForEditing = (options = {})=>{
72
+ if (isSetupForEditing) return;
73
+ isSetupForEditing = true;
74
+ if (isBrowser()) {
75
+ window.parent?.postMessage({
76
+ type: 'builder.sdkInfo',
77
+ data: {
78
+ target: TARGET,
79
+ // TODO: compile these in
80
+ // type: process.env.SDK_TYPE,
81
+ // version: process.env.SDK_VERSION,
82
+ supportsPatchUpdates: false,
83
+ // Supports builder-model="..." attribute which is needed to
84
+ // scope our '+ add block' button styling
85
+ supportsAddBlockScoping: true,
86
+ supportsCustomBreakpoints: true
87
+ }
88
+ }, '*');
89
+ window.parent?.postMessage({
90
+ type: 'builder.updateContent',
91
+ data: {
92
+ options
93
+ }
94
+ }, '*');
95
+ window.addEventListener('message', ({ data })=>{
96
+ if (!data?.type) return;
97
+ switch(data.type){
98
+ case 'builder.evaluate':
99
+ {
100
+ const text = data.data.text;
101
+ const args = data.data.arguments || [];
102
+ const id = data.data.id;
103
+ // tslint:disable-next-line:no-function-constructor-with-string-args
104
+ const fn = new Function(text);
105
+ let result;
106
+ let error = null;
107
+ try {
108
+ // eslint-disable-next-line prefer-spread
109
+ result = fn.apply(null, args);
110
+ } catch (err) {
111
+ error = err;
112
+ }
113
+ if (error) window.parent?.postMessage({
114
+ type: 'builder.evaluateError',
115
+ data: {
116
+ id,
117
+ error: error.message
118
+ }
119
+ }, '*');
120
+ else if (result && typeof result.then === 'function') result.then((finalResult)=>{
121
+ window.parent?.postMessage({
122
+ type: 'builder.evaluateResult',
123
+ data: {
124
+ id,
125
+ result: finalResult
126
+ }
127
+ }, '*');
128
+ }).catch(console.error);
129
+ else window.parent?.postMessage({
130
+ type: 'builder.evaluateResult',
131
+ data: {
132
+ result,
133
+ id
134
+ }
135
+ }, '*');
136
+ break;
137
+ }
138
+ }
139
+ });
140
+ }
141
+ };
142
+
143
+ const BuilderContext = qwik.createContext("Builder");
144
+
145
+ function isIframe() {
146
+ return isBrowser() && window.self !== window.top;
147
+ }
148
+
149
+ function isEditing() {
150
+ return isIframe() && window.location.search.indexOf('builder.frameEditing=') !== -1;
151
+ }
152
+
153
+ /**
154
+ * We need to serialize values to a string in case there are Proxy values, as is the case with SolidJS etc.
155
+ */ const fastClone = (obj)=>JSON.parse(JSON.stringify(obj));
156
+
157
+ const SIZES = {
158
+ small: {
159
+ min: 320,
160
+ default: 321,
161
+ max: 640
162
+ },
163
+ medium: {
164
+ min: 641,
165
+ default: 642,
166
+ max: 991
167
+ },
168
+ large: {
169
+ min: 990,
170
+ default: 991,
171
+ max: 1200
172
+ }
173
+ };
174
+ const getMaxWidthQueryForSize = (size, sizeValues = SIZES)=>`@media (max-width: ${sizeValues[size].max}px)`;
175
+ const getSizesForBreakpoints = ({ small , medium })=>{
176
+ const newSizes = fastClone(SIZES); // Note: this helps to get a deep clone of fields like small, medium etc
177
+ if (!small || !medium) return newSizes;
178
+ const smallMin = Math.floor(small / 2);
179
+ newSizes.small = {
180
+ max: small,
181
+ min: smallMin,
182
+ default: smallMin + 1
183
+ };
184
+ const mediumMin = newSizes.small.max + 1;
185
+ newSizes.medium = {
186
+ max: medium,
187
+ min: mediumMin,
188
+ default: mediumMin + 1
189
+ };
190
+ const largeMin = newSizes.medium.max + 1;
191
+ newSizes.large = {
192
+ max: 2000,
193
+ min: largeMin,
194
+ default: largeMin + 1
195
+ };
196
+ return newSizes;
197
+ };
198
+
199
+ function evaluate({ code , context , state , event , isExpression =true }) {
200
+ if (code === '') {
201
+ console.warn('Skipping evaluation of empty code block.');
202
+ return;
203
+ }
204
+ const builder = {
205
+ isEditing: isEditing(),
206
+ isBrowser: isBrowser(),
207
+ isServer: !isBrowser()
208
+ };
209
+ // Be able to handle simple expressions like "state.foo" or "1 + 1"
210
+ // as well as full blocks like "var foo = "bar"; return foo"
211
+ const useReturn = // we disable this for cases where we definitely don't want a return
212
+ isExpression && !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
213
+ const useCode = useReturn ? `return (${code});` : code;
214
+ try {
215
+ return new Function('builder', 'Builder' /* <- legacy */ , 'state', 'context', 'event', useCode)(builder, builder, state, context, event);
216
+ } catch (e) {
217
+ console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Minimal implementation of lodash's _.set
223
+ * https://lodash.com/docs/4.17.15#set
224
+ *
225
+ * See ./set.test.ts for usage examples
226
+ */ const set = (obj, _path, value)=>{
227
+ if (Object(obj) !== obj) return obj;
228
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
229
+ 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;
230
+ return obj;
231
+ };
232
+
233
+ // Noope way for targets to make modifications to the block object if/as needed
234
+ function transformBlock(block) {
235
+ return block;
236
+ }
237
+
238
+ const evaluateBindings = ({ block , context , state })=>{
239
+ if (!block.bindings) return block;
240
+ const copy = fastClone(block);
241
+ const copied = {
242
+ ...copy,
243
+ properties: {
244
+ ...copy.properties
245
+ },
246
+ actions: {
247
+ ...copy.actions
248
+ }
249
+ };
250
+ for(const binding in block.bindings){
251
+ const expression = block.bindings[binding];
252
+ const value = evaluate({
253
+ code: expression,
254
+ state,
255
+ context
256
+ });
257
+ set(copied, binding, value);
258
+ }
259
+ return copied;
260
+ };
261
+ function getProcessedBlock({ block , context , shouldEvaluateBindings , state }) {
262
+ const transformedBlock = transformBlock(block);
263
+ if (shouldEvaluateBindings) return evaluateBindings({
264
+ block: transformedBlock,
265
+ state,
266
+ context
267
+ });
268
+ else return transformedBlock;
269
+ }
270
+
271
+ const camelToKebabCase = (string)=>string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
272
+
273
+ const convertStyleMaptoCSS = (style)=>{
274
+ const cssProps = Object.entries(style).map(([key, value])=>{
275
+ if (typeof value === 'string') return `${camelToKebabCase(key)}: ${value};`;
276
+ });
277
+ return cssProps.join('\n');
278
+ };
279
+ const createCssClass = ({ mediaQuery , className , styles })=>{
280
+ const cssClass = `.${className} {
281
+ ${convertStyleMaptoCSS(styles)}
282
+ }`;
283
+ if (mediaQuery) return `${mediaQuery} {
284
+ ${cssClass}
285
+ }`;
286
+ else return cssClass;
287
+ };
288
+
289
+ // GENERATED BY MITOSIS
290
+ const tag$1 = function tag(props, state) {
291
+ // NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
292
+ // https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
293
+ return "style";
294
+ };
295
+ const RenderInlinedStyles = (props)=>{
296
+ const state = {};
297
+ state.tag = tag$1();
298
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
299
+ children: /*#__PURE__*/ jsxRuntime.jsx(state.tag, {
300
+ children: qwik._wrapSignal(props, "styles")
301
+ })
302
+ });
303
+ };
304
+ const RenderInlinedStyles$1 = RenderInlinedStyles;
305
+
306
+ // GENERATED BY MITOSIS
307
+ const useBlock$1 = function useBlock(props, state) {
308
+ return getProcessedBlock({
309
+ block: props.block,
310
+ state: props.context.state,
311
+ context: props.context.context,
312
+ shouldEvaluateBindings: true
313
+ });
314
+ };
315
+ const css = function css(props, state) {
316
+ const styles = useBlock$1(props).responsiveStyles;
317
+ const content = props.context.content;
318
+ const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
319
+ const largeStyles = styles?.large;
320
+ const mediumStyles = styles?.medium;
321
+ const smallStyles = styles?.small;
322
+ const className = useBlock$1(props).id;
323
+ const largeStylesClass = largeStyles ? createCssClass({
324
+ className,
325
+ styles: largeStyles
326
+ }) : "";
327
+ const mediumStylesClass = mediumStyles ? createCssClass({
328
+ className,
329
+ styles: mediumStyles,
330
+ mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints)
331
+ }) : "";
332
+ const smallStylesClass = smallStyles ? createCssClass({
333
+ className,
334
+ styles: smallStyles,
335
+ mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
336
+ }) : "";
337
+ return [
338
+ largeStylesClass,
339
+ mediumStylesClass,
340
+ smallStylesClass
341
+ ].join(" ");
342
+ };
343
+ const BlockStyles = (props)=>{
344
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
345
+ children: TARGET !== "reactNative" && css(props) ? /*#__PURE__*/ jsxRuntime.jsx(RenderInlinedStyles$1, {
346
+ styles: css(props)
347
+ }) : null
348
+ });
349
+ };
350
+ const BlockStyles$1 = BlockStyles;
351
+
352
+ function capitalizeFirstLetter(string) {
353
+ return string.charAt(0).toUpperCase() + string.slice(1);
354
+ }
355
+ const getEventHandlerName = (key)=>`on${capitalizeFirstLetter(key)}$`;
356
+
357
+ function createEventHandler(value, options) {
358
+ return qwik.inlinedQrl((event)=>{
359
+ const [options, value] = qwik.useLexicalScope();
360
+ return evaluate({
361
+ code: value,
362
+ context: options.context,
363
+ state: options.state,
364
+ event
365
+ });
366
+ }, "createEventHandler_7wCAiJVliNE", [
367
+ options,
368
+ value
369
+ ]);
370
+ }
371
+
372
+ function getBlockActions(options) {
373
+ const obj = {};
374
+ const optionActions = options.block.actions ?? {};
375
+ for(const key in optionActions){
376
+ // eslint-disable-next-line no-prototype-builtins
377
+ if (!optionActions.hasOwnProperty(key)) continue;
378
+ const value = optionActions[key];
379
+ obj[getEventHandlerName(key)] = createEventHandler(value, options);
380
+ }
381
+ return obj;
382
+ }
383
+
384
+ function getBlockComponentOptions(block) {
385
+ return {
386
+ ...block.component?.options,
387
+ ...block.options,
388
+ /**
389
+ * Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
390
+ */ builderBlock: block
391
+ };
392
+ }
393
+
394
+ function getBlockProperties(block) {
395
+ return {
396
+ ...block.properties,
397
+ 'builder-id': block.id,
398
+ class: [
399
+ block.id,
400
+ 'builder-block',
401
+ block.class,
402
+ block.properties?.class
403
+ ].filter(Boolean).join(' ')
404
+ };
405
+ }
406
+
407
+ function getBlockTag(block) {
408
+ return block.tagName || 'div';
409
+ }
410
+
411
+ /**
412
+ * https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
413
+ */ const EMPTY_HTML_ELEMENTS = [
414
+ 'area',
415
+ 'base',
416
+ 'br',
417
+ 'col',
418
+ 'embed',
419
+ 'hr',
420
+ 'img',
421
+ 'input',
422
+ 'keygen',
423
+ 'link',
424
+ 'meta',
425
+ 'param',
426
+ 'source',
427
+ 'track',
428
+ 'wbr'
429
+ ];
430
+ const isEmptyHtmlElement = (tagName)=>{
431
+ return typeof tagName === 'string' && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
432
+ };
433
+
434
+ // GENERATED BY MITOSIS
435
+ const RenderComponent = (props)=>{
436
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
437
+ children: props.componentRef ? /*#__PURE__*/ jsxRuntime.jsxs(props.componentRef, {
438
+ ...props.componentOptions,
439
+ children: [
440
+ (props.blockChildren || []).map(function(child) {
441
+ return /*#__PURE__*/ jsxRuntime.jsx(RenderBlock$1, {
442
+ block: child,
443
+ get context () {
444
+ return props.context;
445
+ },
446
+ [qwik._IMMUTABLE]: {
447
+ context: qwik._wrapSignal(props, "context")
448
+ }
449
+ }, "render-block-" + child.id);
450
+ }),
451
+ (props.blockChildren || []).map(function(child) {
452
+ return /*#__PURE__*/ jsxRuntime.jsx(BlockStyles$1, {
453
+ block: child,
454
+ get context () {
455
+ return props.context;
456
+ },
457
+ [qwik._IMMUTABLE]: {
458
+ context: qwik._wrapSignal(props, "context")
459
+ }
460
+ }, "block-style-" + child.id);
461
+ })
462
+ ]
463
+ }) : null
464
+ });
465
+ };
466
+ const RenderComponent$1 = RenderComponent;
467
+
468
+ // GENERATED BY MITOSIS
469
+ const RenderComponentWithContext = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
470
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
471
+ content: (()=>{
472
+ return props.context.content;
473
+ })(),
474
+ state: (()=>{
475
+ return props.context.state;
476
+ })(),
477
+ context: (()=>{
478
+ return props.context.context;
479
+ })(),
480
+ apiKey: (()=>{
481
+ return props.context.apiKey;
482
+ })(),
483
+ registeredComponents: (()=>{
484
+ return props.context.registeredComponents;
485
+ })(),
486
+ inheritedStyles: (()=>{
487
+ return props.context.inheritedStyles;
488
+ })()
489
+ }));
490
+ return /*#__PURE__*/ jsxRuntime.jsx(RenderComponent$1, {
491
+ get componentRef () {
492
+ return props.componentRef;
493
+ },
494
+ get componentOptions () {
495
+ return props.componentOptions;
496
+ },
497
+ get blockChildren () {
498
+ return props.blockChildren;
499
+ },
500
+ get context () {
501
+ return props.context;
502
+ },
503
+ [qwik._IMMUTABLE]: {
504
+ componentRef: qwik._wrapSignal(props, "componentRef"),
505
+ componentOptions: qwik._wrapSignal(props, "componentOptions"),
506
+ blockChildren: qwik._wrapSignal(props, "blockChildren"),
507
+ context: qwik._wrapSignal(props, "context")
508
+ }
509
+ });
510
+ }, "RenderComponentWithContext_component_nXOUbUnjTAo"));
511
+ const RenderComponentWithContext$1 = RenderComponentWithContext;
512
+
513
+ // GENERATED BY MITOSIS
514
+ /**
515
+ * We can't make this a generic `ProvideContext` function because Vue 2 won't support root slots, e.g.
516
+ *
517
+ * ```vue
518
+ * <template>
519
+ * <slot></slot>
520
+ * </template>
521
+ * ```
522
+ */ const RenderRepeatedBlock = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
523
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
524
+ content: (()=>{
525
+ return props.repeatContext.content;
526
+ })(),
527
+ state: (()=>{
528
+ return props.repeatContext.state;
529
+ })(),
530
+ context: (()=>{
531
+ return props.repeatContext.context;
532
+ })(),
533
+ apiKey: (()=>{
534
+ return props.repeatContext.apiKey;
535
+ })(),
536
+ registeredComponents: (()=>{
537
+ return props.repeatContext.registeredComponents;
538
+ })(),
539
+ inheritedStyles: (()=>{
540
+ return props.repeatContext.inheritedStyles;
541
+ })()
542
+ }));
543
+ return /*#__PURE__*/ jsxRuntime.jsx(RenderBlock$1, {
544
+ get block () {
545
+ return props.block;
546
+ },
547
+ get context () {
548
+ return props.repeatContext;
549
+ },
550
+ [qwik._IMMUTABLE]: {
551
+ block: qwik._wrapSignal(props, "block"),
552
+ context: qwik._wrapSignal(props, "repeatContext")
553
+ }
554
+ });
555
+ }, "RenderRepeatedBlock_component_nRyVBtbGKc8"));
556
+ const RenderRepeatedBlock$1 = RenderRepeatedBlock;
557
+
558
+ // GENERATED BY MITOSIS
559
+ const component = function component(props, state) {
560
+ const componentName = getProcessedBlock({
561
+ block: props.block,
562
+ state: props.context.state,
563
+ context: props.context.context,
564
+ shouldEvaluateBindings: false
565
+ }).component?.name;
566
+ if (!componentName) return null;
567
+ const ref = props.context.registeredComponents[componentName];
568
+ if (!ref) {
569
+ // TODO: Public doc page with more info about this message
570
+ console.warn(`
571
+ Could not find a registered component named "${componentName}".
572
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
573
+ return undefined;
574
+ } else return ref;
575
+ };
576
+ const tag = function tag(props, state) {
577
+ return getBlockTag(useBlock(props));
578
+ };
579
+ const useBlock = function useBlock(props, state) {
580
+ return repeatItemData(props) ? props.block : getProcessedBlock({
581
+ block: props.block,
582
+ state: props.context.state,
583
+ context: props.context.context,
584
+ shouldEvaluateBindings: true
585
+ });
586
+ };
587
+ const actions = function actions(props, state) {
588
+ return getBlockActions({
589
+ block: useBlock(props),
590
+ state: props.context.state,
591
+ context: props.context.context
592
+ });
593
+ };
594
+ const attributes = function attributes(props, state) {
595
+ return {
596
+ ...getBlockProperties(useBlock(props)),
597
+ ...{}
598
+ };
599
+ };
600
+ const shouldWrap = function shouldWrap(props, state) {
601
+ return !component(props)?.noWrap;
602
+ };
603
+ const renderComponentProps = function renderComponentProps(props, state) {
604
+ return {
605
+ blockChildren: useChildren(props),
606
+ componentRef: component(props)?.component,
607
+ componentOptions: {
608
+ ...getBlockComponentOptions(useBlock(props)),
609
+ /**
610
+ * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
611
+ * they are provided to the component itself directly.
612
+ */ ...shouldWrap(props) ? {} : {
613
+ attributes: {
614
+ ...attributes(props),
615
+ ...actions(props)
616
+ }
617
+ }
618
+ },
619
+ context: childrenContext(props)
620
+ };
621
+ };
622
+ const useChildren = function useChildren(props, state) {
623
+ // TO-DO: When should `canHaveChildren` dictate rendering?
624
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
625
+ // but still receive and need to render children.
626
+ // return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
627
+ return useBlock(props).children ?? [];
628
+ };
629
+ const childrenWithoutParentComponent = function childrenWithoutParentComponent(props, state) {
630
+ /**
631
+ * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
632
+ * we render them outside of `componentRef`.
633
+ * NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
634
+ * blocks, and the children will be repeated within those blocks.
635
+ */ const shouldRenderChildrenOutsideRef = !component(props)?.component && !repeatItemData(props);
636
+ return shouldRenderChildrenOutsideRef ? useChildren(props) : [];
637
+ };
638
+ const repeatItemData = function repeatItemData(props, state) {
639
+ /**
640
+ * we don't use `state.useBlock` here because the processing done within its logic includes evaluating the block's bindings,
641
+ * which will not work if there is a repeat.
642
+ */ const { repeat , ...blockWithoutRepeat } = props.block;
643
+ if (!repeat?.collection) return undefined;
644
+ const itemsArray = evaluate({
645
+ code: repeat.collection,
646
+ state: props.context.state,
647
+ context: props.context.context
648
+ });
649
+ if (!Array.isArray(itemsArray)) return undefined;
650
+ const collectionName = repeat.collection.split(".").pop();
651
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
652
+ const repeatArray = itemsArray.map((item, index)=>({
653
+ context: {
654
+ ...props.context,
655
+ state: {
656
+ ...props.context.state,
657
+ $index: index,
658
+ $item: item,
659
+ [itemNameToUse]: item,
660
+ [`$${itemNameToUse}Index`]: index
661
+ }
662
+ },
663
+ block: blockWithoutRepeat
664
+ }));
665
+ return repeatArray;
666
+ };
667
+ const inheritedTextStyles = function inheritedTextStyles(props, state) {
668
+ return {};
669
+ };
670
+ const childrenContext = function childrenContext(props, state) {
671
+ return {
672
+ apiKey: props.context.apiKey,
673
+ state: props.context.state,
674
+ content: props.context.content,
675
+ context: props.context.context,
676
+ registeredComponents: props.context.registeredComponents,
677
+ inheritedStyles: inheritedTextStyles()
678
+ };
679
+ };
680
+ const renderComponentTag = function renderComponentTag(props, state) {
681
+ if (TARGET === "reactNative") return RenderComponentWithContext$1;
682
+ else return RenderComponent$1;
683
+ };
684
+ const RenderBlock = (props)=>{
685
+ const state = {};
686
+ state.tag = tag(props);
687
+ state.renderComponentTag = renderComponentTag();
688
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
689
+ children: shouldWrap(props) ? /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
690
+ children: [
691
+ isEmptyHtmlElement(tag(props)) ? /*#__PURE__*/ jsxRuntime.jsx(state.tag, {
692
+ ...attributes(props),
693
+ ...actions(props)
694
+ }) : null,
695
+ !isEmptyHtmlElement(tag(props)) && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
696
+ return /*#__PURE__*/ jsxRuntime.jsx(RenderRepeatedBlock$1, {
697
+ get repeatContext () {
698
+ return data.context;
699
+ },
700
+ get block () {
701
+ return data.block;
702
+ },
703
+ [qwik._IMMUTABLE]: {
704
+ repeatContext: qwik._wrapSignal(data, "context"),
705
+ block: qwik._wrapSignal(data, "block")
706
+ }
707
+ }, index);
708
+ }) : null,
709
+ !isEmptyHtmlElement(tag(props)) && !repeatItemData(props) ? /*#__PURE__*/ jsxRuntime.jsxs(state.tag, {
710
+ ...attributes(props),
711
+ ...actions(props),
712
+ children: [
713
+ /*#__PURE__*/ jsxRuntime.jsx(state.renderComponentTag, {
714
+ ...renderComponentProps(props)
715
+ }),
716
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
717
+ return /*#__PURE__*/ jsxRuntime.jsx(RenderBlock, {
718
+ block: child,
719
+ context: childrenContext(props)
720
+ }, "render-block-" + child.id);
721
+ }),
722
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
723
+ return /*#__PURE__*/ jsxRuntime.jsx(BlockStyles$1, {
724
+ block: child,
725
+ context: childrenContext(props)
726
+ }, "block-style-" + child.id);
727
+ })
728
+ ]
729
+ }) : null
730
+ ]
731
+ }) : /*#__PURE__*/ jsxRuntime.jsx(state.renderComponentTag, {
732
+ ...renderComponentProps(props)
733
+ })
734
+ });
735
+ };
736
+ const RenderBlock$1 = RenderBlock;
737
+
738
+ // GENERATED BY MITOSIS
739
+ const className = function className(props, state, builderContext) {
740
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
741
+ };
742
+ const onClick$1 = function onClick(props, state, builderContext) {
743
+ if (isEditing() && !props.blocks?.length) window.parent?.postMessage({
744
+ type: "builder.clickEmptyBlocks",
745
+ data: {
746
+ parentElementId: props.parent,
747
+ dataPath: props.path
748
+ }
749
+ }, "*");
750
+ };
751
+ const onMouseEnter = function onMouseEnter(props, state, builderContext) {
752
+ if (isEditing() && !props.blocks?.length) window.parent?.postMessage({
753
+ type: "builder.hoverEmptyBlocks",
754
+ data: {
755
+ parentElementId: props.parent,
756
+ dataPath: props.path
757
+ }
758
+ }, "*");
759
+ };
760
+ const RenderBlocks = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
761
+ qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$3, "RenderBlocks_component_useStylesScoped_0XKYzaR059E"));
762
+ const builderContext = qwik.useContext(BuilderContext);
763
+ const state = {};
764
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
765
+ class: className(props) + " div-RenderBlocks",
766
+ get "builder-path" () {
767
+ return props.path;
768
+ },
769
+ get "builder-parent-id" () {
770
+ return props.parent;
771
+ },
772
+ get style () {
773
+ return props.styleProp;
774
+ },
775
+ onClick$: qwik.inlinedQrl((event)=>{
776
+ const [builderContext, props, state] = qwik.useLexicalScope();
777
+ return onClick$1(props);
778
+ }, "RenderBlocks_component_div_onClick_RzhhZa265Yg", [
779
+ builderContext,
780
+ props,
781
+ state
782
+ ]),
783
+ onMouseEnter$: qwik.inlinedQrl((event)=>{
784
+ const [builderContext, props, state] = qwik.useLexicalScope();
785
+ return onMouseEnter(props);
786
+ }, "RenderBlocks_component_div_onMouseEnter_nG7I7RYG3JQ", [
787
+ builderContext,
788
+ props,
789
+ state
790
+ ]),
791
+ children: [
792
+ props.blocks ? (props.blocks || []).map(function(block) {
793
+ return /*#__PURE__*/ jsxRuntime.jsx(RenderBlock$1, {
794
+ block: block,
795
+ context: builderContext
796
+ }, "render-block-" + block.id);
797
+ }) : null,
798
+ props.blocks ? (props.blocks || []).map(function(block) {
799
+ return /*#__PURE__*/ jsxRuntime.jsx(BlockStyles$1, {
800
+ block: block,
801
+ context: builderContext
802
+ }, "block-style-" + block.id);
803
+ }) : null
804
+ ],
805
+ [qwik._IMMUTABLE]: {
806
+ "builder-path": qwik._wrapSignal(props, "path"),
807
+ "builder-parent-id": qwik._wrapSignal(props, "parent"),
808
+ style: qwik._wrapSignal(props, "styleProp")
809
+ }
810
+ });
811
+ }, "RenderBlocks_component_MYUZ0j1uLsw"));
812
+ const RenderBlocks$1 = RenderBlocks;
813
+ const STYLES$3 = `.div-RenderBlocks {
814
+ display: flex;
815
+ flex-direction: column;
816
+ align-items: stretch; }`;
817
+
818
+ // GENERATED BY MITOSIS
819
+ const getGutterSize = function getGutterSize(props, state) {
820
+ return typeof props.space === "number" ? props.space || 0 : 20;
821
+ };
822
+ const getColumns = function getColumns(props, state) {
823
+ return props.columns || [];
824
+ };
825
+ const getWidth = function getWidth(props, state, index) {
826
+ const columns = getColumns(props);
827
+ return columns[index]?.width || 100 / columns.length;
828
+ };
829
+ const getColumnCssWidth = function getColumnCssWidth(props, state, index) {
830
+ const columns = getColumns(props);
831
+ const gutterSize = getGutterSize(props);
832
+ const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
833
+ return `calc(${getWidth(props, state, index)}% - ${subtractWidth}px)`;
834
+ };
835
+ const maybeApplyForTablet = function maybeApplyForTablet(props, state, prop) {
836
+ const _stackColumnsAt = props.stackColumnsAt || "tablet";
837
+ return _stackColumnsAt === "tablet" ? prop : "inherit";
838
+ };
839
+ const columnsCssVars = function columnsCssVars(props, state) {
840
+ const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
841
+ return {
842
+ "--flex-dir": flexDir,
843
+ "--flex-dir-tablet": maybeApplyForTablet(props, state, flexDir)
844
+ };
845
+ };
846
+ const columnCssVars = function columnCssVars(props, state) {
847
+ const width = "100%";
848
+ const marginLeft = "0";
849
+ return {
850
+ "--column-width": width,
851
+ "--column-margin-left": marginLeft,
852
+ "--column-width-tablet": maybeApplyForTablet(props, state, width),
853
+ "--column-margin-left-tablet": maybeApplyForTablet(props, state, marginLeft)
854
+ };
855
+ };
856
+ const Columns = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
857
+ qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$2, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
858
+ const state = {};
859
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
860
+ class: "builder-columns div-Columns",
861
+ style: columnsCssVars(props, state),
862
+ children: (props.columns || []).map(function(column, index) {
863
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
864
+ class: "builder-column div-Columns-2",
865
+ style: {
866
+ width: getColumnCssWidth(props, state, index),
867
+ marginLeft: `${index === 0 ? 0 : getGutterSize(props)}px`,
868
+ ...columnCssVars(props, state)
869
+ },
870
+ children: /*#__PURE__*/ jsxRuntime.jsx(RenderBlocks$1, {
871
+ get blocks () {
872
+ return column.blocks;
873
+ },
874
+ path: `component.options.columns.${index}.blocks`,
875
+ get parent () {
876
+ return props.builderBlock.id;
877
+ },
878
+ styleProp: {
879
+ flexGrow: "1"
880
+ },
881
+ [qwik._IMMUTABLE]: {
882
+ blocks: qwik._wrapSignal(column, "blocks"),
883
+ parent: qwik._wrapSignal(props.builderBlock, "id")
884
+ }
885
+ })
886
+ }, index);
887
+ })
888
+ });
889
+ }, "Columns_component_7yLj4bxdI6c"));
890
+ const Columns$1 = Columns;
891
+ const STYLES$2 = `.div-Columns {
892
+ display: flex;
893
+ align-items: stretch;
894
+ line-height: normal; }@media (max-width: 991px) { .div-Columns {
895
+ flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-Columns {
896
+ flex-direction: var(--flex-dir); } }.div-Columns-2 {
897
+ display: flex;
898
+ flex-direction: column;
899
+ align-items: stretch; }@media (max-width: 991px) { .div-Columns-2 {
900
+ width: var(--column-width-tablet) !important;
901
+ margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-Columns-2 {
902
+ width: var(--column-width) !important;
903
+ margin-left: var(--column-margin-left) !important; } }`;
904
+
905
+ // Taken from (and modified) the shopify theme script repo
906
+ // https://github.com/Shopify/theme-scripts/blob/bcfb471f2a57d439e2f964a1bb65b67708cc90c3/packages/theme-images/images.js#L59
907
+ function removeProtocol(path) {
908
+ return path.replace(/http(s)?:/, '');
909
+ }
910
+ function updateQueryParam(uri = '', key, value) {
911
+ const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
912
+ const separator = uri.indexOf('?') !== -1 ? '&' : '?';
913
+ if (uri.match(re)) return uri.replace(re, '$1' + key + '=' + encodeURIComponent(value) + '$2');
914
+ return uri + separator + key + '=' + encodeURIComponent(value);
915
+ }
916
+ function getShopifyImageUrl(src, size) {
917
+ if (!src || !src?.match(/cdn\.shopify\.com/) || !size) return src;
918
+ if (size === 'master') return removeProtocol(src);
919
+ const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
920
+ if (match) {
921
+ const prefix = src.split(match[0]);
922
+ const suffix = match[3];
923
+ const useSize = size.match('x') ? size : `${size}x`;
924
+ return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
925
+ }
926
+ return null;
927
+ }
928
+ function getSrcSet(url) {
929
+ if (!url) return url;
930
+ const sizes = [
931
+ 100,
932
+ 200,
933
+ 400,
934
+ 800,
935
+ 1200,
936
+ 1600,
937
+ 2000
938
+ ];
939
+ if (url.match(/builder\.io/)) {
940
+ let srcUrl = url;
941
+ const widthInSrc = Number(url.split('?width=')[1]);
942
+ if (!isNaN(widthInSrc)) srcUrl = `${srcUrl} ${widthInSrc}w`;
943
+ return sizes.filter((size)=>size !== widthInSrc).map((size)=>`${updateQueryParam(url, 'width', size)} ${size}w`).concat([
944
+ srcUrl
945
+ ]).join(', ');
946
+ }
947
+ if (url.match(/cdn\.shopify\.com/)) return sizes.map((size)=>[
948
+ getShopifyImageUrl(url, `${size}x${size}`),
949
+ size
950
+ ]).filter(([sizeUrl])=>!!sizeUrl).map(([sizeUrl, size])=>`${sizeUrl} ${size}w`).concat([
951
+ url
952
+ ]).join(', ');
953
+ return url;
954
+ }
955
+
956
+ // GENERATED BY MITOSIS
957
+ const srcSetToUse = function srcSetToUse(props, state) {
958
+ const imageToUse = props.image || props.src;
959
+ const url = imageToUse;
960
+ if (!url || // We can auto add srcset for cdn.builder.io and shopify
961
+ // images, otherwise you can supply this prop manually
962
+ !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))) return props.srcset;
963
+ if (props.srcset && props.image?.includes("builder.io/api/v1/image")) {
964
+ if (!props.srcset.includes(props.image.split("?")[0])) {
965
+ console.debug("Removed given srcset");
966
+ return getSrcSet(url);
967
+ }
968
+ } else if (props.image && !props.srcset) return getSrcSet(url);
969
+ return getSrcSet(url);
970
+ };
971
+ const webpSrcSet = function webpSrcSet(props, state) {
972
+ if (srcSetToUse(props)?.match(/builder\.io/) && !props.noWebp) return srcSetToUse(props).replace(/\?/g, "?format=webp&");
973
+ else return "";
974
+ };
975
+ const aspectRatioCss = function aspectRatioCss(props, state) {
976
+ const aspectRatioStyles = {
977
+ position: "absolute",
978
+ height: "100%",
979
+ width: "100%",
980
+ left: "0px",
981
+ top: "0px"
982
+ };
983
+ const out = props.aspectRatio ? aspectRatioStyles : undefined;
984
+ return out;
985
+ };
986
+ const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
987
+ qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$1, "Image_component_useStylesScoped_fBMYiVf9fuU"));
988
+ return /*#__PURE__*/ jsxRuntime.jsxs(qwik.Fragment, {
989
+ children: [
990
+ /*#__PURE__*/ jsxRuntime.jsxs("picture", {
991
+ children: [
992
+ webpSrcSet(props) ? /*#__PURE__*/ jsxRuntime.jsx("source", {
993
+ type: "image/webp",
994
+ srcSet: webpSrcSet(props)
995
+ }) : null,
996
+ /*#__PURE__*/ jsxRuntime.jsx("img", {
997
+ loading: "lazy",
998
+ get alt () {
999
+ return props.altText;
1000
+ },
1001
+ role: props.altText ? "presentation" : undefined,
1002
+ style: {
1003
+ objectPosition: props.backgroundPosition || "center",
1004
+ objectFit: props.backgroundSize || "cover",
1005
+ ...aspectRatioCss(props)
1006
+ },
1007
+ class: "builder-image" + (props.className ? " " + props.className : "") + " img-Image",
1008
+ get src () {
1009
+ return props.image;
1010
+ },
1011
+ srcSet: srcSetToUse(props),
1012
+ get sizes () {
1013
+ return props.sizes;
1014
+ },
1015
+ [qwik._IMMUTABLE]: {
1016
+ alt: qwik._wrapSignal(props, "altText"),
1017
+ src: qwik._wrapSignal(props, "image"),
1018
+ sizes: qwik._wrapSignal(props, "sizes")
1019
+ }
1020
+ }),
1021
+ /*#__PURE__*/ jsxRuntime.jsx("source", {
1022
+ srcSet: srcSetToUse(props)
1023
+ })
1024
+ ]
1025
+ }),
1026
+ props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /*#__PURE__*/ jsxRuntime.jsx("div", {
1027
+ class: "builder-image-sizer div-Image",
1028
+ style: {
1029
+ paddingTop: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1030
+ props.aspectRatio * 100 + "%"
1031
+ }
1032
+ }) : null,
1033
+ props.builderBlock?.children?.length && props.fitContent ? /*#__PURE__*/ jsxRuntime.jsx(qwik.Slot, {}) : null,
1034
+ !props.fitContent && props.children ? /*#__PURE__*/ jsxRuntime.jsx("div", {
1035
+ class: "div-Image-2",
1036
+ children: /*#__PURE__*/ jsxRuntime.jsx(qwik.Slot, {})
1037
+ }) : null
1038
+ ]
1039
+ });
1040
+ }, "Image_component_LRxDkFa1EfU"));
1041
+ const Image$1 = Image;
1042
+ const STYLES$1 = `.img-Image {
1043
+ opacity: 1;
1044
+ transition: opacity 0.2s ease-in-out; }.div-Image {
1045
+ width: 100%;
1046
+ pointer-events: none;
1047
+ font-size: 0; }.div-Image-2 {
1048
+ display: flex;
1049
+ flex-direction: column;
1050
+ align-items: stretch;
1051
+ position: absolute;
1052
+ top: 0;
1053
+ left: 0;
1054
+ width: 100%;
1055
+ height: 100%; }`;
1056
+
1057
+ // GENERATED BY MITOSIS
1058
+ const Text = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1059
+ return /*#__PURE__*/ jsxRuntime.jsx("span", {
1060
+ class: "builder-text",
1061
+ get dangerouslySetInnerHTML () {
1062
+ return props.text;
1063
+ },
1064
+ [qwik._IMMUTABLE]: {
1065
+ dangerouslySetInnerHTML: qwik._wrapSignal(props, "text")
1066
+ }
1067
+ });
1068
+ }, "Text_component_15p0cKUxgIE"));
1069
+ const Text$1 = Text;
1070
+
1071
+ // GENERATED BY MITOSIS
1072
+ const videoProps = function videoProps(props, state) {
1073
+ return {
1074
+ ...props.autoPlay === true ? {
1075
+ autoPlay: true
1076
+ } : {},
1077
+ ...props.muted === true ? {
1078
+ muted: true
1079
+ } : {},
1080
+ ...props.controls === true ? {
1081
+ controls: true
1082
+ } : {},
1083
+ ...props.loop === true ? {
1084
+ loop: true
1085
+ } : {},
1086
+ ...props.playsInline === true ? {
1087
+ playsInline: true
1088
+ } : {}
1089
+ };
1090
+ };
1091
+ const spreadProps = function spreadProps(props, state) {
1092
+ return {
1093
+ ...props.attributes,
1094
+ ...videoProps(props)
1095
+ };
1096
+ };
1097
+ const Video = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1098
+ return /*#__PURE__*/ jsxRuntime.jsx("video", {
1099
+ ...spreadProps(props),
1100
+ style: {
1101
+ width: "100%",
1102
+ height: "100%",
1103
+ ...props.attributes?.style,
1104
+ objectFit: props.fit,
1105
+ objectPosition: props.position,
1106
+ // Hack to get object fit to work as expected and
1107
+ // not have the video overflow
1108
+ borderRadius: 1
1109
+ },
1110
+ src: props.video || "no-src",
1111
+ get poster () {
1112
+ return props.posterImage;
1113
+ },
1114
+ [qwik._IMMUTABLE]: {
1115
+ poster: qwik._wrapSignal(props, "posterImage")
1116
+ }
1117
+ });
1118
+ }, "Video_component_qdcTZflYyoQ"));
1119
+ const Video$1 = Video;
1120
+
1121
+ // GENERATED BY MITOSIS
1122
+ const Button = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1123
+ qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
1124
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
1125
+ children: props.link ? /*#__PURE__*/ jsxRuntime.jsx("a", {
1126
+ role: "button",
1127
+ ...props.attributes,
1128
+ get href () {
1129
+ return props.link;
1130
+ },
1131
+ target: props.openLinkInNewTab ? "_blank" : undefined,
1132
+ children: qwik._wrapSignal(props, "text"),
1133
+ [qwik._IMMUTABLE]: {
1134
+ href: qwik._wrapSignal(props, "link")
1135
+ }
1136
+ }) : /*#__PURE__*/ jsxRuntime.jsx("button", {
1137
+ class: "button-Button",
1138
+ ...props.attributes,
1139
+ children: qwik._wrapSignal(props, "text")
1140
+ })
1141
+ });
1142
+ }, "Button_component_gJoMUICXoUQ"));
1143
+ const Button$1 = Button;
1144
+ const STYLES = `.button-Button {
1145
+ all: unset; }`;
1146
+
1147
+ const componentInfo$a = {
1148
+ name: 'Core:Button',
1149
+ builtIn: true,
1150
+ image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',
1151
+ defaultStyles: {
1152
+ // TODO: make min width more intuitive and set one
1153
+ appearance: 'none',
1154
+ paddingTop: '15px',
1155
+ paddingBottom: '15px',
1156
+ paddingLeft: '25px',
1157
+ paddingRight: '25px',
1158
+ backgroundColor: '#000000',
1159
+ color: 'white',
1160
+ borderRadius: '4px',
1161
+ textAlign: 'center',
1162
+ cursor: 'pointer'
1163
+ },
1164
+ inputs: [
1165
+ {
1166
+ name: 'text',
1167
+ type: 'text',
1168
+ defaultValue: 'Click me!',
1169
+ bubble: true
1170
+ },
1171
+ {
1172
+ name: 'link',
1173
+ type: 'url',
1174
+ bubble: true
1175
+ },
1176
+ {
1177
+ name: 'openLinkInNewTab',
1178
+ type: 'boolean',
1179
+ defaultValue: false,
1180
+ friendlyName: 'Open link in new tab'
1181
+ }
1182
+ ],
1183
+ static: true,
1184
+ noWrap: true
1185
+ };
1186
+
1187
+ /**
1188
+ * Input attributes that are functions must be converted to strings before being serialized to JSON.
1189
+ */ // eslint-disable-next-line @typescript-eslint/ban-types
1190
+ const serializeFn = (fnValue)=>{
1191
+ const fnStr = fnValue.toString().trim();
1192
+ // we need to account for a few different fn syntaxes:
1193
+ // 1. `function name(args) => {code}`
1194
+ // 2. `name(args) => {code}`
1195
+ // 3. `(args) => {}`
1196
+ const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
1197
+ return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
1198
+ };
1199
+
1200
+ const componentInfo$9 = {
1201
+ // TODO: ways to statically preprocess JSON for references, functions, etc
1202
+ name: 'Columns',
1203
+ builtIn: true,
1204
+ inputs: [
1205
+ {
1206
+ name: 'columns',
1207
+ type: 'array',
1208
+ broadcast: true,
1209
+ subFields: [
1210
+ {
1211
+ name: 'blocks',
1212
+ type: 'array',
1213
+ hideFromUI: true,
1214
+ defaultValue: [
1215
+ {
1216
+ '@type': '@builder.io/sdk:Element',
1217
+ responsiveStyles: {
1218
+ large: {
1219
+ display: 'flex',
1220
+ flexDirection: 'column',
1221
+ alignItems: 'stretch',
1222
+ flexShrink: '0',
1223
+ position: 'relative',
1224
+ marginTop: '30px',
1225
+ textAlign: 'center',
1226
+ lineHeight: 'normal',
1227
+ height: 'auto',
1228
+ minHeight: '20px',
1229
+ minWidth: '20px',
1230
+ overflow: 'hidden'
1231
+ }
1232
+ },
1233
+ component: {
1234
+ name: 'Image',
1235
+ options: {
1236
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1237
+ backgroundPosition: 'center',
1238
+ backgroundSize: 'cover',
1239
+ aspectRatio: 0.7004048582995948
1240
+ }
1241
+ }
1242
+ },
1243
+ {
1244
+ '@type': '@builder.io/sdk:Element',
1245
+ responsiveStyles: {
1246
+ large: {
1247
+ display: 'flex',
1248
+ flexDirection: 'column',
1249
+ alignItems: 'stretch',
1250
+ flexShrink: '0',
1251
+ position: 'relative',
1252
+ marginTop: '30px',
1253
+ textAlign: 'center',
1254
+ lineHeight: 'normal',
1255
+ height: 'auto'
1256
+ }
1257
+ },
1258
+ component: {
1259
+ name: 'Text',
1260
+ options: {
1261
+ text: '<p>Enter some text...</p>'
1262
+ }
1263
+ }
1264
+ }
1265
+ ]
1266
+ },
1267
+ {
1268
+ name: 'width',
1269
+ type: 'number',
1270
+ hideFromUI: true,
1271
+ helperText: 'Width %, e.g. set to 50 to fill half of the space'
1272
+ },
1273
+ {
1274
+ name: 'link',
1275
+ type: 'url',
1276
+ helperText: 'Optionally set a url that clicking this column will link to'
1277
+ }
1278
+ ],
1279
+ defaultValue: [
1280
+ {
1281
+ blocks: [
1282
+ {
1283
+ '@type': '@builder.io/sdk:Element',
1284
+ responsiveStyles: {
1285
+ large: {
1286
+ display: 'flex',
1287
+ flexDirection: 'column',
1288
+ alignItems: 'stretch',
1289
+ flexShrink: '0',
1290
+ position: 'relative',
1291
+ marginTop: '30px',
1292
+ textAlign: 'center',
1293
+ lineHeight: 'normal',
1294
+ height: 'auto',
1295
+ minHeight: '20px',
1296
+ minWidth: '20px',
1297
+ overflow: 'hidden'
1298
+ }
1299
+ },
1300
+ component: {
1301
+ name: 'Image',
1302
+ options: {
1303
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1304
+ backgroundPosition: 'center',
1305
+ backgroundSize: 'cover',
1306
+ aspectRatio: 0.7004048582995948
1307
+ }
1308
+ }
1309
+ },
1310
+ {
1311
+ '@type': '@builder.io/sdk:Element',
1312
+ responsiveStyles: {
1313
+ large: {
1314
+ display: 'flex',
1315
+ flexDirection: 'column',
1316
+ alignItems: 'stretch',
1317
+ flexShrink: '0',
1318
+ position: 'relative',
1319
+ marginTop: '30px',
1320
+ textAlign: 'center',
1321
+ lineHeight: 'normal',
1322
+ height: 'auto'
1323
+ }
1324
+ },
1325
+ component: {
1326
+ name: 'Text',
1327
+ options: {
1328
+ text: '<p>Enter some text...</p>'
1329
+ }
1330
+ }
1331
+ }
1332
+ ]
1333
+ },
1334
+ {
1335
+ blocks: [
1336
+ {
1337
+ '@type': '@builder.io/sdk:Element',
1338
+ responsiveStyles: {
1339
+ large: {
1340
+ display: 'flex',
1341
+ flexDirection: 'column',
1342
+ alignItems: 'stretch',
1343
+ flexShrink: '0',
1344
+ position: 'relative',
1345
+ marginTop: '30px',
1346
+ textAlign: 'center',
1347
+ lineHeight: 'normal',
1348
+ height: 'auto',
1349
+ minHeight: '20px',
1350
+ minWidth: '20px',
1351
+ overflow: 'hidden'
1352
+ }
1353
+ },
1354
+ component: {
1355
+ name: 'Image',
1356
+ options: {
1357
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1358
+ backgroundPosition: 'center',
1359
+ backgroundSize: 'cover',
1360
+ aspectRatio: 0.7004048582995948
1361
+ }
1362
+ }
1363
+ },
1364
+ {
1365
+ '@type': '@builder.io/sdk:Element',
1366
+ responsiveStyles: {
1367
+ large: {
1368
+ display: 'flex',
1369
+ flexDirection: 'column',
1370
+ alignItems: 'stretch',
1371
+ flexShrink: '0',
1372
+ position: 'relative',
1373
+ marginTop: '30px',
1374
+ textAlign: 'center',
1375
+ lineHeight: 'normal',
1376
+ height: 'auto'
1377
+ }
1378
+ },
1379
+ component: {
1380
+ name: 'Text',
1381
+ options: {
1382
+ text: '<p>Enter some text...</p>'
1383
+ }
1384
+ }
1385
+ }
1386
+ ]
1387
+ }
1388
+ ],
1389
+ onChange: serializeFn((options)=>{
1390
+ function clearWidths() {
1391
+ columns.forEach((col)=>{
1392
+ col.delete('width');
1393
+ });
1394
+ }
1395
+ const columns = options.get('columns');
1396
+ if (Array.isArray(columns)) {
1397
+ const containsColumnWithWidth = !!columns.find((col)=>col.get('width'));
1398
+ if (containsColumnWithWidth) {
1399
+ const containsColumnWithoutWidth = !!columns.find((col)=>!col.get('width'));
1400
+ if (containsColumnWithoutWidth) clearWidths();
1401
+ else {
1402
+ const sumWidths = columns.reduce((memo, col)=>{
1403
+ return memo + col.get('width');
1404
+ }, 0);
1405
+ const widthsDontAddUp = sumWidths !== 100;
1406
+ if (widthsDontAddUp) clearWidths();
1407
+ }
1408
+ }
1409
+ }
1410
+ })
1411
+ },
1412
+ {
1413
+ name: 'space',
1414
+ type: 'number',
1415
+ defaultValue: 20,
1416
+ helperText: 'Size of gap between columns',
1417
+ advanced: true
1418
+ },
1419
+ {
1420
+ name: 'stackColumnsAt',
1421
+ type: 'string',
1422
+ defaultValue: 'tablet',
1423
+ helperText: 'Convert horizontal columns to vertical at what device size',
1424
+ enum: [
1425
+ 'tablet',
1426
+ 'mobile',
1427
+ 'never'
1428
+ ],
1429
+ advanced: true
1430
+ },
1431
+ {
1432
+ name: 'reverseColumnsWhenStacked',
1433
+ type: 'boolean',
1434
+ defaultValue: false,
1435
+ helperText: 'When stacking columns for mobile devices, reverse the ordering',
1436
+ advanced: true
1437
+ }
1438
+ ]
1439
+ };
1440
+
1441
+ const componentInfo$8 = {
1442
+ name: 'Fragment',
1443
+ static: true,
1444
+ hidden: true,
1445
+ builtIn: true,
1446
+ canHaveChildren: true,
1447
+ noWrap: true
1448
+ };
1449
+
1450
+ // GENERATED BY MITOSIS
1451
+ const FragmentComponent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1452
+ return /*#__PURE__*/ jsxRuntime.jsx("span", {
1453
+ children: /*#__PURE__*/ jsxRuntime.jsx(qwik.Slot, {})
1454
+ });
1455
+ }, "FragmentComponent_component_T0AypnadAK0"));
1456
+ const Fragment = FragmentComponent;
1457
+
1458
+ const componentInfo$7 = {
1459
+ name: 'Image',
1460
+ static: true,
1461
+ builtIn: true,
1462
+ 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',
1463
+ defaultStyles: {
1464
+ position: 'relative',
1465
+ minHeight: '20px',
1466
+ minWidth: '20px',
1467
+ overflow: 'hidden'
1468
+ },
1469
+ canHaveChildren: true,
1470
+ inputs: [
1471
+ {
1472
+ name: 'image',
1473
+ type: 'file',
1474
+ bubble: true,
1475
+ allowedFileTypes: [
1476
+ 'jpeg',
1477
+ 'jpg',
1478
+ 'png',
1479
+ 'svg'
1480
+ ],
1481
+ required: true,
1482
+ defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1483
+ onChange: serializeFn((options)=>{
1484
+ const DEFAULT_ASPECT_RATIO = 0.7041;
1485
+ options.delete('srcset');
1486
+ options.delete('noWebp');
1487
+ function loadImage(url, timeout = 60000) {
1488
+ return new Promise((resolve, reject)=>{
1489
+ const img = document.createElement('img');
1490
+ let loaded = false;
1491
+ img.onload = ()=>{
1492
+ loaded = true;
1493
+ resolve(img);
1494
+ };
1495
+ img.addEventListener('error', (event)=>{
1496
+ console.warn('Image load failed', event.error);
1497
+ reject(event.error);
1498
+ });
1499
+ img.src = url;
1500
+ setTimeout(()=>{
1501
+ if (!loaded) reject(new Error('Image load timed out'));
1502
+ }, timeout);
1503
+ });
1504
+ }
1505
+ function round(num) {
1506
+ return Math.round(num * 1000) / 1000;
1507
+ }
1508
+ const value = options.get('image');
1509
+ const aspectRatio = options.get('aspectRatio');
1510
+ // For SVG images - don't render as webp, keep them as SVG
1511
+ fetch(value).then((res)=>res.blob()).then((blob)=>{
1512
+ if (blob.type.includes('svg')) options.set('noWebp', true);
1513
+ });
1514
+ if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) return loadImage(value).then((img)=>{
1515
+ const possiblyUpdatedAspectRatio = options.get('aspectRatio');
1516
+ if (options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
1517
+ if (img.width && img.height) {
1518
+ options.set('aspectRatio', round(img.height / img.width));
1519
+ options.set('height', img.height);
1520
+ options.set('width', img.width);
1521
+ }
1522
+ }
1523
+ });
1524
+ })
1525
+ },
1526
+ {
1527
+ name: 'backgroundSize',
1528
+ type: 'text',
1529
+ defaultValue: 'cover',
1530
+ enum: [
1531
+ {
1532
+ label: 'contain',
1533
+ value: 'contain',
1534
+ helperText: 'The image should never get cropped'
1535
+ },
1536
+ {
1537
+ label: 'cover',
1538
+ value: 'cover',
1539
+ helperText: "The image should fill it's box, cropping when needed"
1540
+ }
1541
+ ]
1542
+ },
1543
+ {
1544
+ name: 'backgroundPosition',
1545
+ type: 'text',
1546
+ defaultValue: 'center',
1547
+ enum: [
1548
+ 'center',
1549
+ 'top',
1550
+ 'left',
1551
+ 'right',
1552
+ 'bottom',
1553
+ 'top left',
1554
+ 'top right',
1555
+ 'bottom left',
1556
+ 'bottom right'
1557
+ ]
1558
+ },
1559
+ {
1560
+ name: 'altText',
1561
+ type: 'string',
1562
+ helperText: 'Text to display when the user has images off'
1563
+ },
1564
+ {
1565
+ name: 'height',
1566
+ type: 'number',
1567
+ hideFromUI: true
1568
+ },
1569
+ {
1570
+ name: 'width',
1571
+ type: 'number',
1572
+ hideFromUI: true
1573
+ },
1574
+ {
1575
+ name: 'sizes',
1576
+ type: 'string',
1577
+ hideFromUI: true
1578
+ },
1579
+ {
1580
+ name: 'srcset',
1581
+ type: 'string',
1582
+ hideFromUI: true
1583
+ },
1584
+ {
1585
+ name: 'lazy',
1586
+ type: 'boolean',
1587
+ defaultValue: true,
1588
+ hideFromUI: true
1589
+ },
1590
+ {
1591
+ name: 'fitContent',
1592
+ type: 'boolean',
1593
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
1594
+ defaultValue: true
1595
+ },
1596
+ {
1597
+ name: 'aspectRatio',
1598
+ type: 'number',
1599
+ 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",
1600
+ advanced: true,
1601
+ defaultValue: 0.7041
1602
+ }
1603
+ ]
1604
+ };
1605
+
1606
+ const componentInfo$6 = {
1607
+ name: 'Core:Section',
1608
+ static: true,
1609
+ builtIn: true,
1610
+ image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',
1611
+ inputs: [
1612
+ {
1613
+ name: 'maxWidth',
1614
+ type: 'number',
1615
+ defaultValue: 1200
1616
+ },
1617
+ {
1618
+ name: 'lazyLoad',
1619
+ type: 'boolean',
1620
+ defaultValue: false,
1621
+ advanced: true,
1622
+ description: 'Only render this section when in view'
1623
+ }
1624
+ ],
1625
+ defaultStyles: {
1626
+ paddingLeft: '20px',
1627
+ paddingRight: '20px',
1628
+ paddingTop: '50px',
1629
+ paddingBottom: '50px',
1630
+ marginTop: '0px',
1631
+ width: '100vw',
1632
+ marginLeft: 'calc(50% - 50vw)'
1633
+ },
1634
+ canHaveChildren: true,
1635
+ defaultChildren: [
1636
+ {
1637
+ '@type': '@builder.io/sdk:Element',
1638
+ responsiveStyles: {
1639
+ large: {
1640
+ textAlign: 'center'
1641
+ }
1642
+ },
1643
+ component: {
1644
+ name: 'Text',
1645
+ options: {
1646
+ 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>"
1647
+ }
1648
+ }
1649
+ }
1650
+ ]
1651
+ };
1652
+
1653
+ // GENERATED BY MITOSIS
1654
+ const SectionComponent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1655
+ return /*#__PURE__*/ jsxRuntime.jsx("section", {
1656
+ ...props.attributes,
1657
+ style: (()=>{
1658
+ props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : undefined;
1659
+ })(),
1660
+ children: /*#__PURE__*/ jsxRuntime.jsx(qwik.Slot, {})
1661
+ });
1662
+ }, "SectionComponent_component_ZWF9iD5WeLg"));
1663
+ const Section = SectionComponent;
1664
+
1665
+ const componentInfo$5 = {
1666
+ name: 'Symbol',
1667
+ noWrap: true,
1668
+ static: true,
1669
+ builtIn: true,
1670
+ inputs: [
1671
+ {
1672
+ name: 'symbol',
1673
+ type: 'uiSymbol'
1674
+ },
1675
+ {
1676
+ name: 'dataOnly',
1677
+ helperText: "Make this a data symbol that doesn't display any UI",
1678
+ type: 'boolean',
1679
+ defaultValue: false,
1680
+ advanced: true,
1681
+ hideFromUI: true
1682
+ },
1683
+ {
1684
+ name: 'inheritState',
1685
+ helperText: 'Inherit the parent component state and data',
1686
+ type: 'boolean',
1687
+ defaultValue: false,
1688
+ advanced: true
1689
+ },
1690
+ {
1691
+ name: 'renderToLiquid',
1692
+ helperText: 'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',
1693
+ type: 'boolean',
1694
+ defaultValue: false,
1695
+ advanced: true,
1696
+ hideFromUI: true
1697
+ },
1698
+ {
1699
+ name: 'useChildren',
1700
+ hideFromUI: true,
1701
+ type: 'boolean'
1702
+ }
1703
+ ]
1704
+ };
1705
+
1706
+ const componentInfo$4 = {
1707
+ name: 'Text',
1708
+ static: true,
1709
+ builtIn: true,
1710
+ 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',
1711
+ inputs: [
1712
+ {
1713
+ name: 'text',
1714
+ type: 'html',
1715
+ required: true,
1716
+ autoFocus: true,
1717
+ bubble: true,
1718
+ defaultValue: 'Enter some text...'
1719
+ }
1720
+ ],
1721
+ defaultStyles: {
1722
+ lineHeight: 'normal',
1723
+ height: 'auto',
1724
+ textAlign: 'center'
1725
+ }
1726
+ };
1727
+
1728
+ const componentInfo$3 = {
1729
+ name: 'Video',
1730
+ canHaveChildren: true,
1731
+ builtIn: true,
1732
+ defaultStyles: {
1733
+ minHeight: '20px',
1734
+ minWidth: '20px'
1735
+ },
1736
+ 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',
1737
+ inputs: [
1738
+ {
1739
+ name: 'video',
1740
+ type: 'file',
1741
+ allowedFileTypes: [
1742
+ 'mp4'
1743
+ ],
1744
+ bubble: true,
1745
+ defaultValue: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f',
1746
+ required: true
1747
+ },
1748
+ {
1749
+ name: 'posterImage',
1750
+ type: 'file',
1751
+ allowedFileTypes: [
1752
+ 'jpeg',
1753
+ 'png'
1754
+ ],
1755
+ helperText: 'Image to show before the video plays'
1756
+ },
1757
+ {
1758
+ name: 'autoPlay',
1759
+ type: 'boolean',
1760
+ defaultValue: true
1761
+ },
1762
+ {
1763
+ name: 'controls',
1764
+ type: 'boolean',
1765
+ defaultValue: false
1766
+ },
1767
+ {
1768
+ name: 'muted',
1769
+ type: 'boolean',
1770
+ defaultValue: true
1771
+ },
1772
+ {
1773
+ name: 'loop',
1774
+ type: 'boolean',
1775
+ defaultValue: true
1776
+ },
1777
+ {
1778
+ name: 'playsInline',
1779
+ type: 'boolean',
1780
+ defaultValue: true
1781
+ },
1782
+ {
1783
+ name: 'fit',
1784
+ type: 'text',
1785
+ defaultValue: 'cover',
1786
+ enum: [
1787
+ 'contain',
1788
+ 'cover',
1789
+ 'fill',
1790
+ 'auto'
1791
+ ]
1792
+ },
1793
+ {
1794
+ name: 'fitContent',
1795
+ type: 'boolean',
1796
+ helperText: 'When child blocks are provided, fit to them instead of using the aspect ratio',
1797
+ defaultValue: true,
1798
+ advanced: true
1799
+ },
1800
+ {
1801
+ name: 'position',
1802
+ type: 'text',
1803
+ defaultValue: 'center',
1804
+ enum: [
1805
+ 'center',
1806
+ 'top',
1807
+ 'left',
1808
+ 'right',
1809
+ 'bottom',
1810
+ 'top left',
1811
+ 'top right',
1812
+ 'bottom left',
1813
+ 'bottom right'
1814
+ ]
1815
+ },
1816
+ {
1817
+ name: 'height',
1818
+ type: 'number',
1819
+ advanced: true
1820
+ },
1821
+ {
1822
+ name: 'width',
1823
+ type: 'number',
1824
+ advanced: true
1825
+ },
1826
+ {
1827
+ name: 'aspectRatio',
1828
+ type: 'number',
1829
+ advanced: true,
1830
+ defaultValue: 0.7004048582995948
1831
+ },
1832
+ {
1833
+ name: 'lazyLoad',
1834
+ type: 'boolean',
1835
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
1836
+ defaultValue: true,
1837
+ advanced: true
1838
+ }
1839
+ ]
1840
+ };
1841
+
1842
+ const componentInfo$2 = {
1843
+ name: 'Embed',
1844
+ static: true,
1845
+ builtIn: true,
1846
+ inputs: [
1847
+ {
1848
+ name: 'url',
1849
+ type: 'url',
1850
+ required: true,
1851
+ defaultValue: '',
1852
+ helperText: 'e.g. enter a youtube url, google map, etc',
1853
+ onChange: serializeFn((options)=>{
1854
+ const url = options.get('url');
1855
+ if (url) {
1856
+ options.set('content', 'Loading...');
1857
+ // TODO: get this out of here!
1858
+ const apiKey = 'ae0e60e78201a3f2b0de4b';
1859
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res)=>res.json()).then((data)=>{
1860
+ if (options.get('url') === url) {
1861
+ if (data.html) options.set('content', data.html);
1862
+ else options.set('content', 'Invalid url, please try another');
1863
+ }
1864
+ }).catch((_err)=>{
1865
+ options.set('content', 'There was an error embedding this URL, please try again or another URL');
1866
+ });
1867
+ } else options.delete('content');
1868
+ })
1869
+ },
1870
+ {
1871
+ name: 'content',
1872
+ type: 'html',
1873
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
1874
+ hideFromUI: true
1875
+ }
1876
+ ]
1877
+ };
1878
+
1879
+ const SCRIPT_MIME_TYPES = [
1880
+ 'text/javascript',
1881
+ 'application/javascript',
1882
+ 'application/ecmascript'
1883
+ ];
1884
+ const isJsScript = (script)=>SCRIPT_MIME_TYPES.includes(script.type);
1885
+
1886
+ // GENERATED BY MITOSIS
1887
+ const findAndRunScripts$1 = function findAndRunScripts(props, state, elem) {
1888
+ if (!elem || !elem.getElementsByTagName) return;
1889
+ const scripts = elem.getElementsByTagName("script");
1890
+ for(let i = 0; i < scripts.length; i++){
1891
+ const script = scripts[i];
1892
+ if (script.src && !state.scriptsInserted.includes(script.src)) {
1893
+ state.scriptsInserted.push(script.src);
1894
+ const newScript = document.createElement("script");
1895
+ newScript.async = true;
1896
+ newScript.src = script.src;
1897
+ document.head.appendChild(newScript);
1898
+ } else if (isJsScript(script) && !state.scriptsRun.includes(script.innerText)) try {
1899
+ state.scriptsRun.push(script.innerText);
1900
+ new Function(script.innerText)();
1901
+ } catch (error) {
1902
+ console.warn("`Embed`: Error running script:", error);
1903
+ }
1904
+ }
1905
+ };
1906
+ const Embed = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1907
+ const elem = qwik.useRef();
1908
+ const state = qwik.useStore({
1909
+ ranInitFn: false,
1910
+ scriptsInserted: [],
1911
+ scriptsRun: []
1912
+ });
1913
+ qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
1914
+ const [elem, props, state] = qwik.useLexicalScope();
1915
+ state && track(state, "ranInitFn");
1916
+ if (elem && !state.ranInitFn) {
1917
+ state.ranInitFn = true;
1918
+ findAndRunScripts$1(props, state, elem);
1919
+ }
1920
+ }, "Embed_component_useWatch_AxgWjrHdlAI", [
1921
+ elem,
1922
+ props,
1923
+ state
1924
+ ]));
1925
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
1926
+ class: "builder-embed",
1927
+ ref: elem,
1928
+ get dangerouslySetInnerHTML () {
1929
+ return props.content;
1930
+ },
1931
+ [qwik._IMMUTABLE]: {
1932
+ dangerouslySetInnerHTML: qwik._wrapSignal(props, "content")
1933
+ }
1934
+ });
1935
+ }, "Embed_component_Uji08ORjXbE"));
1936
+ const embed = Embed;
1937
+
1938
+ // GENERATED BY MITOSIS
1939
+ const ImgComponent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1940
+ return /*#__PURE__*/ jsxRuntime.jsx("img", {
1941
+ style: {
1942
+ objectFit: props.backgroundSize || "cover",
1943
+ objectPosition: props.backgroundPosition || "center"
1944
+ },
1945
+ get alt () {
1946
+ return props.altText;
1947
+ },
1948
+ src: props.imgSrc || props.image,
1949
+ ...props.attributes,
1950
+ [qwik._IMMUTABLE]: {
1951
+ alt: qwik._wrapSignal(props, "altText")
1952
+ }
1953
+ }, isEditing() && props.imgSrc || "default-key");
1954
+ }, "ImgComponent_component_FXvIDBSffO8"));
1955
+ const Img = ImgComponent;
1956
+
1957
+ const componentInfo$1 = {
1958
+ // friendlyName?
1959
+ name: 'Raw:Img',
1960
+ hideFromInsertMenu: true,
1961
+ builtIn: true,
1962
+ 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',
1963
+ inputs: [
1964
+ {
1965
+ name: 'image',
1966
+ bubble: true,
1967
+ type: 'file',
1968
+ allowedFileTypes: [
1969
+ 'jpeg',
1970
+ 'jpg',
1971
+ 'png',
1972
+ 'svg'
1973
+ ],
1974
+ required: true
1975
+ }
1976
+ ],
1977
+ noWrap: true,
1978
+ static: true
1979
+ };
1980
+
1981
+ // GENERATED BY MITOSIS
1982
+ const findAndRunScripts = function findAndRunScripts(props, state, elem) {
1983
+ // TODO: Move this function to standalone one in '@builder.io/utils'
1984
+ if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
1985
+ const scripts = elem.getElementsByTagName("script");
1986
+ for(let i = 0; i < scripts.length; i++){
1987
+ const script = scripts[i];
1988
+ if (script.src) {
1989
+ if (state.scriptsInserted.includes(script.src)) continue;
1990
+ state.scriptsInserted.push(script.src);
1991
+ const newScript = document.createElement("script");
1992
+ newScript.async = true;
1993
+ newScript.src = script.src;
1994
+ document.head.appendChild(newScript);
1995
+ } else if (!script.type || [
1996
+ "text/javascript",
1997
+ "application/javascript",
1998
+ "application/ecmascript"
1999
+ ].includes(script.type)) {
2000
+ if (state.scriptsRun.includes(script.innerText)) continue;
2001
+ try {
2002
+ state.scriptsRun.push(script.innerText);
2003
+ new Function(script.innerText)();
2004
+ } catch (error) {
2005
+ console.warn("`CustomCode`: Error running script:", error);
2006
+ }
2007
+ }
2008
+ }
2009
+ }
2010
+ };
2011
+ const CustomCode = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2012
+ const elem = qwik.useRef();
2013
+ const state = qwik.useStore({
2014
+ scriptsInserted: [],
2015
+ scriptsRun: []
2016
+ });
2017
+ qwik.useClientEffectQrl(qwik.inlinedQrl(()=>{
2018
+ const [elem, props, state] = qwik.useLexicalScope();
2019
+ findAndRunScripts(props, state, elem);
2020
+ }, "CustomCode_component_useClientEffect_4w4c951ufB4", [
2021
+ elem,
2022
+ props,
2023
+ state
2024
+ ]));
2025
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
2026
+ ref: elem,
2027
+ class: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
2028
+ get dangerouslySetInnerHTML () {
2029
+ return props.code;
2030
+ },
2031
+ [qwik._IMMUTABLE]: {
2032
+ dangerouslySetInnerHTML: qwik._wrapSignal(props, "code")
2033
+ }
2034
+ });
2035
+ }, "CustomCode_component_uYOSy7w7Zqw"));
2036
+ const customCode = CustomCode;
2037
+
2038
+ const componentInfo = {
2039
+ name: 'Custom Code',
2040
+ static: true,
2041
+ builtIn: true,
2042
+ requiredPermissions: [
2043
+ 'editCode'
2044
+ ],
2045
+ inputs: [
2046
+ {
2047
+ name: 'code',
2048
+ type: 'html',
2049
+ required: true,
2050
+ defaultValue: '<p>Hello there, I am custom HTML code!</p>',
2051
+ code: true
2052
+ },
2053
+ {
2054
+ name: 'replaceNodes',
2055
+ type: 'boolean',
2056
+ helperText: 'Preserve server rendered dom nodes',
2057
+ advanced: true
2058
+ },
2059
+ {
2060
+ name: 'scriptsClientOnly',
2061
+ type: 'boolean',
2062
+ defaultValue: false,
2063
+ helperText: 'Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads',
2064
+ advanced: true
2065
+ }
2066
+ ]
2067
+ };
2068
+
2069
+ /**
2070
+ * Returns a list of all registered components.
2071
+ * NOTE: This needs to be a function to work around ESM circular dependencies.
2072
+ */ const getDefaultRegisteredComponents = ()=>[
2073
+ {
2074
+ component: Columns$1,
2075
+ ...componentInfo$9
2076
+ },
2077
+ {
2078
+ component: Image$1,
2079
+ ...componentInfo$7
2080
+ },
2081
+ {
2082
+ component: Img,
2083
+ ...componentInfo$1
2084
+ },
2085
+ {
2086
+ component: Text$1,
2087
+ ...componentInfo$4
2088
+ },
2089
+ {
2090
+ component: Video$1,
2091
+ ...componentInfo$3
2092
+ },
2093
+ {
2094
+ component: Symbol$2,
2095
+ ...componentInfo$5
2096
+ },
2097
+ {
2098
+ component: Button$1,
2099
+ ...componentInfo$a
2100
+ },
2101
+ {
2102
+ component: Section,
2103
+ ...componentInfo$6
2104
+ },
2105
+ {
2106
+ component: Fragment,
2107
+ ...componentInfo$8
2108
+ },
2109
+ {
2110
+ component: embed,
2111
+ ...componentInfo$2
2112
+ },
2113
+ {
2114
+ component: customCode,
2115
+ ...componentInfo
2116
+ }
2117
+ ];
2118
+
2119
+ /**
2120
+ * Convert deep object to a flat object with dots
2121
+ *
2122
+ * { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
2123
+ */ function flatten(object, path = null, separator = '.') {
2124
+ return Object.keys(object).reduce((acc, key)=>{
2125
+ const value = object[key];
2126
+ const newPath = [
2127
+ path,
2128
+ key
2129
+ ].filter(Boolean).join(separator);
2130
+ const isObject = [
2131
+ typeof value === 'object',
2132
+ value !== null,
2133
+ !(Array.isArray(value) && value.length === 0)
2134
+ ].every(Boolean);
2135
+ return isObject ? {
2136
+ ...acc,
2137
+ ...flatten(value, newPath, separator)
2138
+ } : {
2139
+ ...acc,
2140
+ [newPath]: value
2141
+ };
2142
+ }, {});
2143
+ }
2144
+
2145
+ const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
2146
+ const BUILDER_OPTIONS_PREFIX = 'options.';
2147
+ const convertSearchParamsToQueryObject = (searchParams)=>{
2148
+ const options = {};
2149
+ searchParams.forEach((value, key)=>{
2150
+ options[key] = value;
2151
+ });
2152
+ return options;
2153
+ };
2154
+ const getBuilderSearchParams = (_options)=>{
2155
+ if (!_options) return {};
2156
+ const options = normalizeSearchParams(_options);
2157
+ const newOptions = {};
2158
+ Object.keys(options).forEach((key)=>{
2159
+ if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2160
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '').replace(BUILDER_OPTIONS_PREFIX, '');
2161
+ newOptions[trimmedKey] = options[key];
2162
+ }
2163
+ });
2164
+ return newOptions;
2165
+ };
2166
+ const getBuilderSearchParamsFromWindow = ()=>{
2167
+ if (!isBrowser()) return {};
2168
+ const searchParams = new URLSearchParams(window.location.search);
2169
+ return getBuilderSearchParams(searchParams);
2170
+ };
2171
+ const normalizeSearchParams = (searchParams)=>searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
2172
+
2173
+ function getGlobalThis() {
2174
+ if (typeof globalThis !== 'undefined') return globalThis;
2175
+ if (typeof window !== 'undefined') return window;
2176
+ if (typeof global !== 'undefined') return global;
2177
+ if (typeof self !== 'undefined') return self;
2178
+ return null;
2179
+ }
2180
+
2181
+ async function getFetch() {
2182
+ const globalFetch = getGlobalThis().fetch;
2183
+ if (typeof globalFetch === 'undefined' && typeof global !== 'undefined') throw new Error('`fetch()` not found, ensure you have it as part of your polyfills.');
2184
+ return globalFetch.default || globalFetch;
2185
+ }
2186
+
2187
+ /**
2188
+ * Only gets one level up from hostname
2189
+ * wwww.example.com -> example.com
2190
+ * www.example.co.uk -> example.co.uk
2191
+ */ const getTopLevelDomain = (host)=>{
2192
+ const parts = host.split('.');
2193
+ if (parts.length > 2) return parts.slice(1).join('.');
2194
+ return host;
2195
+ };
2196
+
2197
+ /**
2198
+ * NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
2199
+ */ const getCookie = async ({ name , canTrack })=>{
2200
+ try {
2201
+ if (!canTrack) return undefined;
2202
+ /**
2203
+ * Extracted from MDN docs
2204
+ * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#example_2_get_a_sample_cookie_named_test2
2205
+ */ return document.cookie.split('; ').find((row)=>row.startsWith(`${name}=`))?.split('=')[1];
2206
+ } catch (err) {
2207
+ console.debug('[COOKIE] GET error: ', err);
2208
+ }
2209
+ };
2210
+ const stringifyCookie = (cookie)=>cookie.map(([key, value])=>value ? `${key}=${value}` : key).join('; ');
2211
+ const SECURE_CONFIG = [
2212
+ [
2213
+ 'secure',
2214
+ ''
2215
+ ],
2216
+ [
2217
+ 'SameSite',
2218
+ 'None'
2219
+ ]
2220
+ ];
2221
+ const createCookieString = ({ name , value , expires })=>{
2222
+ const secure = isBrowser() ? location.protocol === 'https:' : true;
2223
+ const secureObj = secure ? SECURE_CONFIG : [
2224
+ []
2225
+ ];
2226
+ // TODO: need to know if secure server side
2227
+ const expiresObj = expires ? [
2228
+ [
2229
+ 'expires',
2230
+ expires.toUTCString()
2231
+ ]
2232
+ ] : [
2233
+ []
2234
+ ];
2235
+ const cookieValue = [
2236
+ [
2237
+ name,
2238
+ value
2239
+ ],
2240
+ ...expiresObj,
2241
+ [
2242
+ 'path',
2243
+ '/'
2244
+ ],
2245
+ [
2246
+ 'domain',
2247
+ getTopLevelDomain(window.location.hostname)
2248
+ ],
2249
+ ...secureObj
2250
+ ];
2251
+ const cookie = stringifyCookie(cookieValue);
2252
+ return cookie;
2253
+ };
2254
+ /**
2255
+ * NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
2256
+ */ const setCookie = async ({ name , value , expires , canTrack })=>{
2257
+ try {
2258
+ if (!canTrack) return undefined;
2259
+ const cookie = createCookieString({
2260
+ name,
2261
+ value,
2262
+ expires
2263
+ });
2264
+ document.cookie = cookie;
2265
+ } catch (err) {
2266
+ console.warn('[COOKIE] SET error: ', err);
2267
+ }
2268
+ };
2269
+
2270
+ const BUILDER_STORE_PREFIX = 'builderio.variations';
2271
+ const getContentTestKey = (id)=>`${BUILDER_STORE_PREFIX}.${id}`;
2272
+ const getContentVariationCookie = ({ contentId , canTrack })=>getCookie({
2273
+ name: getContentTestKey(contentId),
2274
+ canTrack
2275
+ });
2276
+ const setContentVariationCookie = ({ contentId , canTrack , value })=>setCookie({
2277
+ name: getContentTestKey(contentId),
2278
+ value,
2279
+ canTrack
2280
+ });
2281
+
2282
+ const checkIsDefined = (maybeT)=>maybeT !== null && maybeT !== undefined;
2283
+
2284
+ const checkIsBuilderContentWithVariations = (item)=>checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
2285
+ /**
2286
+ * Randomly assign a variation to this user and store it in cookies/storage
2287
+ */ const getRandomVariationId = ({ id , variations })=>{
2288
+ let n = 0;
2289
+ const random = Math.random();
2290
+ // loop over variations test ratios, incrementing a counter,
2291
+ // until we find the variation that this user should be assigned to
2292
+ for(const id1 in variations){
2293
+ const testRatio = variations[id1]?.testRatio;
2294
+ n += testRatio;
2295
+ if (random < n) return id1;
2296
+ }
2297
+ // `item.variations` does not include the default variation
2298
+ // if we arrive here, then it means that the random number fits in the default variation bucket
2299
+ return id;
2300
+ };
2301
+ const getTestFields = ({ item , testGroupId })=>{
2302
+ const variationValue = item.variations[testGroupId];
2303
+ if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
2304
+ !variationValue) return {
2305
+ testVariationId: item.id,
2306
+ testVariationName: 'Default'
2307
+ };
2308
+ else return {
2309
+ data: variationValue.data,
2310
+ testVariationId: variationValue.id,
2311
+ testVariationName: variationValue.name || (variationValue.id === item.id ? 'Default' : '')
2312
+ };
2313
+ };
2314
+ const getContentVariation = async ({ item , canTrack })=>{
2315
+ // try to find test variation in cookies/storage
2316
+ const testGroupId = await getContentVariationCookie({
2317
+ canTrack,
2318
+ contentId: item.id
2319
+ });
2320
+ const testFields = testGroupId ? getTestFields({
2321
+ item,
2322
+ testGroupId
2323
+ }) : undefined;
2324
+ if (testFields) return testFields;
2325
+ else {
2326
+ // if variation not found in storage, assign a random variation to this user
2327
+ const randomVariationId = getRandomVariationId({
2328
+ variations: item.variations,
2329
+ id: item.id
2330
+ });
2331
+ // store variation in cookies/storage
2332
+ setContentVariationCookie({
2333
+ contentId: item.id,
2334
+ value: randomVariationId,
2335
+ canTrack
2336
+ }).catch((err)=>{
2337
+ console.error('could not store A/B test variation: ', err);
2338
+ });
2339
+ return getTestFields({
2340
+ item,
2341
+ testGroupId: randomVariationId
2342
+ });
2343
+ }
2344
+ };
2345
+ const handleABTesting = async ({ item , canTrack })=>{
2346
+ if (!checkIsBuilderContentWithVariations(item)) return;
2347
+ const variationValue = await getContentVariation({
2348
+ item,
2349
+ canTrack
2350
+ });
2351
+ Object.assign(item, variationValue);
2352
+ };
2353
+
2354
+ async function getContent(options) {
2355
+ return (await getAllContent({
2356
+ ...options,
2357
+ limit: 1
2358
+ })).results[0] || null;
2359
+ }
2360
+ const generateContentUrl = (options)=>{
2361
+ const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , locale , } = options;
2362
+ if (!apiKey) throw new Error('Missing API key');
2363
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}`);
2364
+ const queryOptions = {
2365
+ ...getBuilderSearchParamsFromWindow(),
2366
+ ...normalizeSearchParams(options.options || {})
2367
+ };
2368
+ const flattened = flatten(queryOptions);
2369
+ for(const key in flattened)url.searchParams.set(key, String(flattened[key]));
2370
+ if (userAttributes) url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
2371
+ if (query) {
2372
+ const flattened1 = flatten({
2373
+ query
2374
+ });
2375
+ for(const key1 in flattened1)url.searchParams.set(key1, JSON.stringify(flattened1[key1]));
2376
+ }
2377
+ return url;
2378
+ };
2379
+ async function getAllContent(options) {
2380
+ const url = generateContentUrl(options);
2381
+ const fetch = await getFetch();
2382
+ const content = await fetch(url.href).then((res)=>res.json());
2383
+ const canTrack = options.canTrack !== false;
2384
+ if (canTrack && // This makes sure we have a non-error response with the results array.
2385
+ Array.isArray(content.results)) for (const item of content.results)await handleABTesting({
2386
+ item,
2387
+ canTrack
2388
+ });
2389
+ return content;
2390
+ }
2391
+
2392
+ function isPreviewing() {
2393
+ if (!isBrowser()) return false;
2394
+ if (isEditing()) return false;
2395
+ return Boolean(location.search.indexOf('builder.preview=') !== -1);
2396
+ }
2397
+
2398
+ /**
2399
+ * @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
2400
+ */ const components = [];
2401
+ /**
2402
+ * @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
2403
+ */ function registerComponent(component, info) {
2404
+ components.push({
2405
+ component,
2406
+ ...info
2407
+ });
2408
+ console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
2409
+ return component;
2410
+ }
2411
+ const createRegisterComponentMessage = ({ component: _ , ...info })=>({
2412
+ type: 'builder.registerComponent',
2413
+ data: prepareComponentInfoToSend(info)
2414
+ });
2415
+ const serializeValue = (value)=>typeof value === 'function' ? serializeFn(value) : fastClone(value);
2416
+ const prepareComponentInfoToSend = ({ inputs , ...info })=>({
2417
+ ...fastClone(info),
2418
+ inputs: inputs?.map((input)=>Object.entries(input).reduce((acc, [key, value])=>({
2419
+ ...acc,
2420
+ [key]: serializeValue(value)
2421
+ }), {}))
2422
+ });
2423
+
2424
+ /**
2425
+ * @credit https://stackoverflow.com/a/2117523
2426
+ */ function uuidv4() {
2427
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
2428
+ const r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;
2429
+ return v.toString(16);
2430
+ });
2431
+ }
2432
+ /**
2433
+ * Slightly cleaner and smaller UUIDs
2434
+ */ function uuid() {
2435
+ return uuidv4().replace(/-/g, '');
2436
+ }
2437
+
2438
+ const SESSION_LOCAL_STORAGE_KEY = 'builderSessionId';
2439
+ const getSessionId = async ({ canTrack })=>{
2440
+ if (!canTrack) return undefined;
2441
+ const sessionId = await getCookie({
2442
+ name: SESSION_LOCAL_STORAGE_KEY,
2443
+ canTrack
2444
+ });
2445
+ if (checkIsDefined(sessionId)) return sessionId;
2446
+ else {
2447
+ const newSessionId = createSessionId();
2448
+ setSessionId({
2449
+ id: newSessionId,
2450
+ canTrack
2451
+ });
2452
+ }
2453
+ };
2454
+ const createSessionId = ()=>uuid();
2455
+ const setSessionId = ({ id , canTrack })=>setCookie({
2456
+ name: SESSION_LOCAL_STORAGE_KEY,
2457
+ value: id,
2458
+ canTrack
2459
+ });
2460
+
2461
+ const getLocalStorage = ()=>isBrowser() && typeof localStorage !== 'undefined' ? localStorage : undefined;
2462
+ const getLocalStorageItem = ({ key , canTrack })=>{
2463
+ try {
2464
+ if (canTrack) return getLocalStorage()?.getItem(key);
2465
+ return undefined;
2466
+ } catch (err) {
2467
+ console.debug('[LocalStorage] GET error: ', err);
2468
+ }
2469
+ };
2470
+ const setLocalStorageItem = ({ key , canTrack , value })=>{
2471
+ try {
2472
+ if (canTrack) getLocalStorage()?.setItem(key, value);
2473
+ } catch (err) {
2474
+ console.debug('[LocalStorage] SET error: ', err);
2475
+ }
2476
+ };
2477
+
2478
+ const VISITOR_LOCAL_STORAGE_KEY = 'builderVisitorId';
2479
+ const getVisitorId = ({ canTrack })=>{
2480
+ if (!canTrack) return undefined;
2481
+ const visitorId = getLocalStorageItem({
2482
+ key: VISITOR_LOCAL_STORAGE_KEY,
2483
+ canTrack
2484
+ });
2485
+ if (checkIsDefined(visitorId)) return visitorId;
2486
+ else {
2487
+ const newVisitorId = createVisitorId();
2488
+ setVisitorId({
2489
+ id: newVisitorId,
2490
+ canTrack
2491
+ });
2492
+ }
2493
+ };
2494
+ const createVisitorId = ()=>uuid();
2495
+ const setVisitorId = ({ id , canTrack })=>setLocalStorageItem({
2496
+ key: VISITOR_LOCAL_STORAGE_KEY,
2497
+ value: id,
2498
+ canTrack
2499
+ });
2500
+
2501
+ const getTrackingEventData = async ({ canTrack })=>{
2502
+ if (!canTrack) return {
2503
+ visitorId: undefined,
2504
+ sessionId: undefined
2505
+ };
2506
+ const sessionId = await getSessionId({
2507
+ canTrack
2508
+ });
2509
+ const visitorId = getVisitorId({
2510
+ canTrack
2511
+ });
2512
+ return {
2513
+ sessionId,
2514
+ visitorId
2515
+ };
2516
+ };
2517
+ const createEvent = async ({ type: eventType , canTrack , apiKey , metadata , ...properties })=>({
2518
+ type: eventType,
2519
+ data: {
2520
+ ...properties,
2521
+ metadata: JSON.stringify(metadata),
2522
+ ...await getTrackingEventData({
2523
+ canTrack
2524
+ }),
2525
+ ownerId: apiKey
2526
+ }
2527
+ });
2528
+ async function _track(eventProps) {
2529
+ if (!eventProps.apiKey) {
2530
+ console.error('[Builder.io]: Missing API key for track call. Please provide your API key.');
2531
+ return;
2532
+ }
2533
+ if (!eventProps.canTrack) return;
2534
+ if (isEditing()) return;
2535
+ if (!(isBrowser() || TARGET === 'reactNative')) return;
2536
+ return fetch(`https://builder.io/api/v1/track`, {
2537
+ method: 'POST',
2538
+ body: JSON.stringify({
2539
+ events: [
2540
+ await createEvent(eventProps)
2541
+ ]
2542
+ }),
2543
+ headers: {
2544
+ 'content-type': 'application/json'
2545
+ },
2546
+ mode: 'cors'
2547
+ }).catch((err)=>{
2548
+ console.error('Failed to track: ', err);
2549
+ });
2550
+ }
2551
+ const track = (args)=>_track({
2552
+ ...args,
2553
+ canTrack: true
2554
+ });
2555
+
2556
+ // GENERATED BY MITOSIS
2557
+ const getCssFromFont = function getCssFromFont(props, state, font) {
2558
+ // TODO: compute what font sizes are used and only load those.......
2559
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
2560
+ const name = family.split(",")[0];
2561
+ const url = font.fileUrl ?? font?.files?.regular;
2562
+ let str = "";
2563
+ if (url && family && name) str += `
2564
+ @font-face {
2565
+ font-family: "${family}";
2566
+ src: local("${name}"), url('${url}') format('woff2');
2567
+ font-display: fallback;
2568
+ font-weight: 400;
2569
+ }
2570
+ `.trim();
2571
+ if (font.files) for(const weight in font.files){
2572
+ const isNumber = String(Number(weight)) === weight;
2573
+ if (!isNumber) continue;
2574
+ // TODO: maybe limit number loaded
2575
+ const weightUrl = font.files[weight];
2576
+ if (weightUrl && weightUrl !== url) str += `
2577
+ @font-face {
2578
+ font-family: "${family}";
2579
+ src: url('${weightUrl}') format('woff2');
2580
+ font-display: fallback;
2581
+ font-weight: ${weight};
2582
+ }
2583
+ `.trim();
2584
+ }
2585
+ return str;
2586
+ };
2587
+ const getFontCss = function getFontCss(props, state, { customFonts }) {
2588
+ // TODO: flag for this
2589
+ // if (!this.builder.allowCustomFonts) {
2590
+ // return '';
2591
+ // }
2592
+ // TODO: separate internal data from external
2593
+ return customFonts?.map((font)=>getCssFromFont(props, state, font))?.join(" ") || "";
2594
+ };
2595
+ const injectedStyles = function injectedStyles(props, state) {
2596
+ return `
2597
+ ${props.cssCode || ""}
2598
+ ${getFontCss(props, state, {
2599
+ customFonts: props.customFonts
2600
+ })}`;
2601
+ };
2602
+ const RenderContentStyles = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2603
+ const state = {};
2604
+ return /*#__PURE__*/ jsxRuntime.jsx(RenderInlinedStyles$1, {
2605
+ styles: injectedStyles(props, state)
2606
+ });
2607
+ }, "RenderContentStyles_component_Og0xL34Zbvc"));
2608
+ const RenderContentStyles$1 = RenderContentStyles;
2609
+
2610
+ // GENERATED BY MITOSIS
2611
+ const useContent = function useContent(props, state, elementRef) {
2612
+ if (!props.content && !state.overrideContent) return undefined;
2613
+ const mergedContent = {
2614
+ ...props.content,
2615
+ ...state.overrideContent,
2616
+ data: {
2617
+ ...props.content?.data,
2618
+ ...props.data,
2619
+ ...state.overrideContent?.data
2620
+ }
2621
+ };
2622
+ return mergedContent;
2623
+ };
2624
+ const canTrackToUse = function canTrackToUse(props, state, elementRef) {
2625
+ return props.canTrack || true;
2626
+ };
2627
+ const contentState = function contentState(props, state, elementRef) {
2628
+ return {
2629
+ ...props.content?.data?.state,
2630
+ ...props.data,
2631
+ ...props.locale ? {
2632
+ locale: props.locale
2633
+ } : {},
2634
+ ...state.overrideState
2635
+ };
2636
+ };
2637
+ const contextContext = function contextContext(props, state, elementRef) {
2638
+ return props.context || {};
2639
+ };
2640
+ const allRegisteredComponents = function allRegisteredComponents(props, state, elementRef) {
2641
+ const allComponentsArray = [
2642
+ ...getDefaultRegisteredComponents(),
2643
+ // While this `components` object is deprecated, we must maintain support for it.
2644
+ // Since users are able to override our default components, we need to make sure that we do not break such
2645
+ // existing usage.
2646
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
2647
+ // which is the new standard way of providing custom components, and must therefore take precedence.
2648
+ ...components,
2649
+ ...props.customComponents || []
2650
+ ];
2651
+ const allComponents = allComponentsArray.reduce((acc, curr)=>({
2652
+ ...acc,
2653
+ [curr.name]: curr
2654
+ }), {});
2655
+ return allComponents;
2656
+ };
2657
+ const processMessage = function processMessage(props, state, elementRef, event) {
2658
+ const { data } = event;
2659
+ if (data) switch(data.type){
2660
+ case "builder.contentUpdate":
2661
+ {
2662
+ const messageContent = data.data;
2663
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
2664
+ const contentData = messageContent.data;
2665
+ if (key === props.model) {
2666
+ state.overrideContent = contentData;
2667
+ state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
2668
+ }
2669
+ break;
2670
+ }
2671
+ }
2672
+ };
2673
+ const evaluateJsCode = function evaluateJsCode(props, state, elementRef) {
2674
+ // run any dynamic JS code attached to content
2675
+ const jsCode = useContent(props, state)?.data?.jsCode;
2676
+ if (jsCode) evaluate({
2677
+ code: jsCode,
2678
+ context: contextContext(props),
2679
+ state: contentState(props, state)
2680
+ });
2681
+ };
2682
+ const httpReqsData = function httpReqsData(props, state, elementRef) {
2683
+ return {};
2684
+ };
2685
+ const onClick = function onClick(props, state, elementRef, _event) {
2686
+ if (useContent(props, state)) {
2687
+ const variationId = useContent(props, state)?.testVariationId;
2688
+ const contentId = useContent(props, state)?.id;
2689
+ _track({
2690
+ type: "click",
2691
+ canTrack: canTrackToUse(props),
2692
+ contentId,
2693
+ apiKey: props.apiKey,
2694
+ variationId: variationId !== contentId ? variationId : undefined
2695
+ });
2696
+ }
2697
+ };
2698
+ const evalExpression = function evalExpression(props, state, elementRef, expression) {
2699
+ return expression.replace(/{{([^}]+)}}/g, (_match, group)=>evaluate({
2700
+ code: group,
2701
+ context: contextContext(props),
2702
+ state: contentState(props, state)
2703
+ }));
2704
+ };
2705
+ const handleRequest = function handleRequest(props, state, elementRef, { url , key }) {
2706
+ getFetch().then((fetch)=>fetch(url)).then((response)=>response.json()).then((json)=>{
2707
+ const newOverrideState = {
2708
+ ...state.overrideState,
2709
+ [key]: json
2710
+ };
2711
+ state.overrideState = newOverrideState;
2712
+ }).catch((err)=>{
2713
+ console.log("error fetching dynamic data", url, err);
2714
+ });
2715
+ };
2716
+ const runHttpRequests = function runHttpRequests(props, state, elementRef) {
2717
+ const requests = useContent(props, state)?.data?.httpRequests ?? {};
2718
+ Object.entries(requests).forEach(([key, url])=>{
2719
+ if (url && (!httpReqsData()[key] || isEditing())) {
2720
+ const evaluatedUrl = evalExpression(props, state, elementRef, url);
2721
+ handleRequest(props, state, elementRef, {
2722
+ url: evaluatedUrl,
2723
+ key
2724
+ });
2725
+ }
2726
+ });
2727
+ };
2728
+ const emitStateUpdate = function emitStateUpdate(props, state, elementRef) {
2729
+ if (isEditing()) window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
2730
+ detail: {
2731
+ state: contentState(props, state),
2732
+ ref: {
2733
+ name: props.model
2734
+ }
2735
+ }
2736
+ }));
2737
+ };
2738
+ const shouldRenderContentStyles = function shouldRenderContentStyles(props, state, elementRef) {
2739
+ return Boolean((useContent(props, state)?.data?.cssCode || useContent(props, state)?.data?.customFonts?.length) && TARGET !== "reactNative");
2740
+ };
2741
+ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2742
+ const elementRef = qwik.useRef();
2743
+ const state = qwik.useStore({
2744
+ forceReRenderCount: 0,
2745
+ overrideContent: null,
2746
+ overrideState: {},
2747
+ update: 0
2748
+ });
2749
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
2750
+ content: (()=>{
2751
+ return useContent(props, state);
2752
+ })(),
2753
+ state: (()=>{
2754
+ return contentState(props, state);
2755
+ })(),
2756
+ context: (()=>{
2757
+ return contextContext(props);
2758
+ })(),
2759
+ apiKey: (()=>{
2760
+ return props.apiKey;
2761
+ })(),
2762
+ registeredComponents: (()=>{
2763
+ return allRegisteredComponents(props);
2764
+ })()
2765
+ }));
2766
+ qwik.useClientEffectQrl(qwik.inlinedQrl(()=>{
2767
+ const [elementRef, props, state] = qwik.useLexicalScope();
2768
+ if (!props.apiKey) console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
2769
+ if (isBrowser()) {
2770
+ if (isEditing()) {
2771
+ state.forceReRenderCount = state.forceReRenderCount + 1;
2772
+ registerInsertMenu();
2773
+ setupBrowserForEditing({
2774
+ ...props.locale ? {
2775
+ locale: props.locale
2776
+ } : {},
2777
+ ...props.includeRefs ? {
2778
+ includeRefs: props.includeRefs
2779
+ } : {}
2780
+ });
2781
+ Object.values(allRegisteredComponents(props)).forEach((registeredComponent)=>{
2782
+ const message = createRegisterComponentMessage(registeredComponent);
2783
+ window.parent?.postMessage(message, "*");
2784
+ });
2785
+ window.addEventListener("message", processMessage.bind(null, props, state, elementRef));
2786
+ window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props, state, elementRef));
2787
+ }
2788
+ if (useContent(props, state)) {
2789
+ const variationId = useContent(props, state)?.testVariationId;
2790
+ const contentId = useContent(props, state)?.id;
2791
+ _track({
2792
+ type: "impression",
2793
+ canTrack: canTrackToUse(props),
2794
+ contentId,
2795
+ apiKey: props.apiKey,
2796
+ variationId: variationId !== contentId ? variationId : undefined
2797
+ });
2798
+ }
2799
+ // override normal content in preview mode
2800
+ if (isPreviewing()) {
2801
+ const searchParams = new URL(location.href).searchParams;
2802
+ if (props.model && searchParams.get("builder.preview") === props.model) {
2803
+ const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
2804
+ if (previewApiKey) getContent({
2805
+ model: props.model,
2806
+ apiKey: previewApiKey
2807
+ }).then((content)=>{
2808
+ if (content) state.overrideContent = content;
2809
+ });
2810
+ }
2811
+ }
2812
+ evaluateJsCode(props, state);
2813
+ runHttpRequests(props, state, elementRef);
2814
+ emitStateUpdate(props, state);
2815
+ }
2816
+ }, "RenderContent_component_useClientEffect_cA0sVHIkr5g", [
2817
+ elementRef,
2818
+ props,
2819
+ state
2820
+ ]));
2821
+ qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
2822
+ const [elementRef, props, state] = qwik.useLexicalScope();
2823
+ state.useContent?.data && track(state.useContent?.data, "jsCode");
2824
+ state && track(state, "contentState");
2825
+ evaluateJsCode(props, state);
2826
+ }, "RenderContent_component_useWatch_OIBatobA0hE", [
2827
+ elementRef,
2828
+ props,
2829
+ state
2830
+ ]));
2831
+ qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
2832
+ const [elementRef, props, state] = qwik.useLexicalScope();
2833
+ state.useContent?.data && track(state.useContent?.data, "httpRequests");
2834
+ runHttpRequests(props, state, elementRef);
2835
+ }, "RenderContent_component_useWatch_1_LQM67VNl14k", [
2836
+ elementRef,
2837
+ props,
2838
+ state
2839
+ ]));
2840
+ qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
2841
+ const [elementRef, props, state] = qwik.useLexicalScope();
2842
+ state && track(state, "contentState");
2843
+ emitStateUpdate(props, state);
2844
+ }, "RenderContent_component_useWatch_2_aGi0RpYNBO0", [
2845
+ elementRef,
2846
+ props,
2847
+ state
2848
+ ]));
2849
+ qwik.useCleanupQrl(qwik.inlinedQrl(()=>{
2850
+ const [elementRef, props, state] = qwik.useLexicalScope();
2851
+ if (isBrowser()) {
2852
+ window.removeEventListener("message", processMessage.bind(null, props, state, elementRef));
2853
+ window.removeEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props, state, elementRef));
2854
+ }
2855
+ }, "RenderContent_component_useCleanup_FwcO310HVAI", [
2856
+ elementRef,
2857
+ props,
2858
+ state
2859
+ ]));
2860
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
2861
+ children: useContent(props, state) ? /*#__PURE__*/ jsxRuntime.jsxs("div", {
2862
+ ref: elementRef,
2863
+ onClick$: qwik.inlinedQrl((event)=>{
2864
+ const [elementRef, props, state] = qwik.useLexicalScope();
2865
+ return onClick(props, state);
2866
+ }, "RenderContent_component__Fragment_div_onClick_wLg5o3ZkpC0", [
2867
+ elementRef,
2868
+ props,
2869
+ state
2870
+ ]),
2871
+ "builder-content-id": useContent(props, state)?.id,
2872
+ get "builder-model" () {
2873
+ return props.model;
2874
+ },
2875
+ children: [
2876
+ shouldRenderContentStyles(props, state) ? /*#__PURE__*/ jsxRuntime.jsx(RenderContentStyles$1, {
2877
+ cssCode: useContent(props, state)?.data?.cssCode,
2878
+ customFonts: useContent(props, state)?.data?.customFonts
2879
+ }) : null,
2880
+ /*#__PURE__*/ jsxRuntime.jsx(RenderBlocks$1, {
2881
+ blocks: useContent(props, state)?.data?.blocks
2882
+ }, state.forceReRenderCount)
2883
+ ],
2884
+ [qwik._IMMUTABLE]: {
2885
+ "builder-model": qwik._wrapSignal(props, "model")
2886
+ }
2887
+ }) : null
2888
+ });
2889
+ }, "RenderContent_component_hEAI0ahViXM"));
2890
+ const RenderContent$1 = RenderContent;
2891
+
2892
+ // GENERATED BY MITOSIS
2893
+ const contentToUse = function contentToUse(props, state, builderContext) {
2894
+ return props.symbol?.content || state.fetchedContent;
2895
+ };
2896
+ const Symbol$1 = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2897
+ const builderContext = qwik.useContext(BuilderContext);
2898
+ const state = qwik.useStore({
2899
+ className: "builder-symbol",
2900
+ fetchedContent: null
2901
+ });
2902
+ qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
2903
+ const [builderContext, props, state] = qwik.useLexicalScope();
2904
+ props && track(props, "symbol");
2905
+ state && track(state, "fetchedContent");
2906
+ const symbolToUse = props.symbol;
2907
+ /**
2908
+ * If:
2909
+ * - we have a symbol prop
2910
+ * - yet it does not have any content
2911
+ * - and we have not already stored content from before
2912
+ * - and it has a model name
2913
+ *
2914
+ * then we want to re-fetch the symbol content.
2915
+ */ if (symbolToUse && !symbolToUse.content && !state.fetchedContent && symbolToUse.model) getContent({
2916
+ model: symbolToUse.model,
2917
+ apiKey: builderContext.apiKey,
2918
+ query: {
2919
+ id: symbolToUse.entry
2920
+ }
2921
+ }).then((response)=>{
2922
+ state.fetchedContent = response;
2923
+ });
2924
+ }, "Symbol_component_useWatch_9HNT04zd0Dk", [
2925
+ builderContext,
2926
+ props,
2927
+ state
2928
+ ]));
2929
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
2930
+ ...props.attributes,
2931
+ get class () {
2932
+ return state.className;
2933
+ },
2934
+ children: /*#__PURE__*/ jsxRuntime.jsx(RenderContent$1, {
2935
+ get apiKey () {
2936
+ return builderContext.apiKey;
2937
+ },
2938
+ get context () {
2939
+ return builderContext.context;
2940
+ },
2941
+ customComponents: Object.values(builderContext.registeredComponents),
2942
+ data: {
2943
+ ...props.symbol?.data,
2944
+ ...builderContext.state,
2945
+ ...props.symbol?.content?.data?.state
2946
+ },
2947
+ model: props.symbol?.model,
2948
+ content: contentToUse(props, state),
2949
+ [qwik._IMMUTABLE]: {
2950
+ apiKey: qwik._wrapSignal(builderContext, "apiKey"),
2951
+ context: qwik._wrapSignal(builderContext, "context")
2952
+ }
2953
+ }),
2954
+ [qwik._IMMUTABLE]: {
2955
+ class: qwik._wrapSignal(state, "className")
2956
+ }
2957
+ });
2958
+ }, "Symbol_component_WVvggdkUPdk"));
2959
+ const Symbol$2 = Symbol$1;
2960
+
2961
+ const settings = {};
2962
+ function setEditorSettings(newSettings) {
2963
+ if (isBrowser()) {
2964
+ Object.assign(settings, newSettings);
2965
+ const message = {
2966
+ type: 'builder.settingsChange',
2967
+ data: settings
2968
+ };
2969
+ parent.postMessage(message, '*');
2970
+ }
2971
+ }
2972
+
2973
+ exports.Button = Button$1;
2974
+ exports.Columns = Columns$1;
2975
+ exports.Fragment = Fragment;
2976
+ exports.Image = Image$1;
2977
+ exports.RenderBlocks = RenderBlocks$1;
2978
+ exports.RenderContent = RenderContent$1;
2979
+ exports.Section = Section;
2980
+ exports.Symbol = Symbol$2;
2981
+ exports.Text = Text$1;
2982
+ exports.Video = Video$1;
2983
+ exports.components = components;
2984
+ exports.convertSearchParamsToQueryObject = convertSearchParamsToQueryObject;
2985
+ exports.createRegisterComponentMessage = createRegisterComponentMessage;
2986
+ exports.generateContentUrl = generateContentUrl;
2987
+ exports.getAllContent = getAllContent;
2988
+ exports.getBuilderSearchParams = getBuilderSearchParams;
2989
+ exports.getBuilderSearchParamsFromWindow = getBuilderSearchParamsFromWindow;
2990
+ exports.getContent = getContent;
2991
+ exports.isEditing = isEditing;
2992
+ exports.isPreviewing = isPreviewing;
2993
+ exports.normalizeSearchParams = normalizeSearchParams;
2994
+ exports.register = register;
2995
+ exports.registerComponent = registerComponent;
2996
+ exports.setEditorSettings = setEditorSettings;
2997
+ exports.track = track;