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