@builder.io/sdk-qwik 0.0.35 → 0.0.36

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