@builder.io/sdk-react 0.7.5 → 0.8.0
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.
- package/lib/browser/index.cjs +8 -8
- package/lib/browser/index.mjs +161 -158
- package/lib/edge/index.cjs +9 -9
- package/lib/edge/index.mjs +174 -171
- package/lib/node/index.cjs +8 -8
- package/lib/node/index.mjs +130 -127
- package/package.json +7 -1
- package/types/constants/sdk-version.d.ts +1 -1
package/lib/node/index.cjs
CHANGED
|
@@ -40,19 +40,19 @@ if (typeof output === 'object' && output !== null) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
output;
|
|
43
|
-
`},getIsolateContext=()=>new ivm.Isolate({memoryLimit:128}).createContextSync(),runInNode=({code:e,builder:t,context:n,event:i,localState:r,rootSetState:o,rootState:a})=>{const c=serverEntry.fastClone({...a,...r}),s=getFunctionArguments({builder:t,context:n,event:i,state:c}),l=getIsolateContext(),u=l.global;u.setSync("global",u.derefInto()),u.setSync("log",function(...S){console.log(...S)}),u.setSync(BUILDER_SET_STATE_NAME,function(S,
|
|
43
|
+
`},getIsolateContext=()=>new ivm.Isolate({memoryLimit:128}).createContextSync(),runInNode=({code:e,builder:t,context:n,event:i,localState:r,rootSetState:o,rootState:a})=>{const c=serverEntry.fastClone({...a,...r}),s=getFunctionArguments({builder:t,context:n,event:i,state:c}),l=getIsolateContext(),u=l.global;u.setSync("global",u.derefInto()),u.setSync("log",function(...S){console.log(...S)}),u.setSync(BUILDER_SET_STATE_NAME,function(S,f){set(a,S,f),o==null||o(a)}),s.forEach(([S,f])=>{const y=typeof f=="object"?new ivm.Reference(S==="builder"?{...f,getUserAttributes:()=>f.getUserAttributes()}:f):null;u.setSync(getSyncValName(S),y)}),u.setSync(INJECTED_IVM_GLOBAL,ivm);const g=processCode({code:e,args:s}),h=l.evalSync(g);try{return JSON.parse(h)}catch{return h}},chooseBrowserOrServerEval=e=>serverEntry.isBrowser()?runInBrowser(e):runInNode(e);function evaluate({code:e,context:t,localState:n,rootState:i,rootSetState:r,event:o,isExpression:a=!0}){if(e===""){serverEntry.logger.warn("Skipping evaluation of empty code block.");return}const c={code:parseCode(e,{isExpression:a}),builder:getBuilderGlobals(),context:t,event:o,rootSetState:r,rootState:i,localState:n};try{return chooseBrowserOrServerEval(c)}catch(s){serverEntry.logger.error("Failed code evaluation: "+s.message,{code:e});return}}function transformBlock(e){return e}const evaluateBindings=({block:e,context:t,localState:n,rootState:i,rootSetState:r})=>{if(!e.bindings)return e;const o=serverEntry.fastClone(e),a={...o,properties:{...o.properties},actions:{...o.actions}};for(const c in e.bindings){const s=e.bindings[c],l=evaluate({code:s,localState:n,rootState:i,rootSetState:r,context:t});set(a,c,l)}return a};function getProcessedBlock({block:e,context:t,shouldEvaluateBindings:n,localState:i,rootState:r,rootSetState:o}){const a=e;return n?evaluateBindings({block:a,localState:i,rootState:r,rootSetState:o,context:t}):a}const EMPTY_HTML_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],isEmptyHtmlElement=e=>typeof e=="string"&&EMPTY_HTML_ELEMENTS.includes(e.toLowerCase()),getComponent=({block:e,context:t,registeredComponents:n})=>{var o;const i=(o=getProcessedBlock({block:e,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,context:t.context,shouldEvaluateBindings:!1}).component)==null?void 0:o.name;if(!i)return null;const r=n[i];if(r)return r;console.warn(`
|
|
44
44
|
Could not find a registered component named "${i}".
|
|
45
45
|
If you registered it, is the file that registered it imported by the file that needs to render it?`)},getRepeatItemData=({block:e,context:t})=>{const{repeat:n,...i}=e;if(!(n!=null&&n.collection))return;const r=evaluate({code:n.collection,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,context:t.context});if(!Array.isArray(r))return;const o=n.collection.split(".").pop(),a=n.itemName||(o?o+"Item":"item");return r.map((s,l)=>({context:{...t,localState:{...t.localState,$index:l,$item:s,[a]:s,[`$${a}Index`]:l}},block:i}))},SIZES={small:{min:320,default:321,max:640},medium:{min:641,default:642,max:991},large:{min:990,default:991,max:1200}},getMaxWidthQueryForSize=(e,t=SIZES)=>`@media (max-width: ${t[e].max}px)`,getSizesForBreakpoints=({small:e,medium:t})=>{const n=serverEntry.fastClone(SIZES);if(!e||!t)return n;const i=Math.floor(e/2);n.small={max:e,min:i,default:i+1};const r=n.small.max+1;n.medium={max:t,min:r,default:r+1};const o=n.medium.max+1;return n.large={max:2e3,min:o,default:o+1},n},camelToKebabCase=e=>e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),convertStyleMapToCSSArray=e=>Object.entries(e).map(([n,i])=>{if(typeof i=="string")return`${camelToKebabCase(n)}: ${i};`}).filter(serverEntry.checkIsDefined),convertStyleMapToCSS=e=>convertStyleMapToCSSArray(e).join(`
|
|
46
46
|
`),createCssClass=({mediaQuery:e,className:t,styles:n})=>{const i=`.${t} {
|
|
47
47
|
${convertStyleMapToCSS(n)}
|
|
48
48
|
}`;return e?`${e} {
|
|
49
49
|
${i}
|
|
50
|
-
}`:i};function InlinedStyles(e){return jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:e.styles},id:e.id})}function BlockStyles(e){function t(){const i=getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0});return serverEntry.checkIsDefined(i.hide)?!i.hide:serverEntry.checkIsDefined(i.show)?i.show:!0}function n(){var
|
|
50
|
+
}`:i};function InlinedStyles(e){return jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:e.styles},id:e.id})}function BlockStyles(e){function t(){const i=getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0});return serverEntry.checkIsDefined(i.hide)?!i.hide:serverEntry.checkIsDefined(i.show)?i.show:!0}function n(){var f;const i=getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0}),r=i.responsiveStyles,o=e.context.content,a=getSizesForBreakpoints(((f=o==null?void 0:o.meta)==null?void 0:f.breakpoints)||{}),c=r==null?void 0:r.large,s=r==null?void 0:r.medium,l=r==null?void 0:r.small,u=i.id;if(!u)return"";const g=c?createCssClass({className:u,styles:c}):"",h=s?createCssClass({className:u,styles:s,mediaQuery:getMaxWidthQueryForSize("medium",a)}):"",S=l?createCssClass({className:u,styles:l,mediaQuery:getMaxWidthQueryForSize("small",a)}):"";return[g,h,S].join(" ")}return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n()&&t()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(InlinedStyles,{styles:n()})}):null})}function capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1)}const getEventHandlerName=e=>`on${capitalizeFirstLetter(e)}`,createEventHandler=(e,t)=>n=>evaluate({code:e,context:t.context,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,event:n,isExpression:!1});function getBlockActions(e){const t={},n=e.block.actions??{};for(const i in n){if(!n.hasOwnProperty(i))continue;const r=n[i];let o=getEventHandlerName(i);if(e.stripPrefix)switch(serverEntry.TARGET){case"vue2":case"vue3":o=o.replace("v-on:","");break;case"svelte":o=o.replace("on:","");break}t[o]=createEventHandler(r,e)}return t}function transformBlockProperties(e){return e.className=e.class,delete e.class,e}const extractRelevantRootBlockProperties=e=>({href:e.href});function getBlockProperties({block:e,context:t}){var i;const n={...extractRelevantRootBlockProperties(e),...e.properties,"builder-id":e.id,style:e.style?getStyleAttribute(e.style):void 0,class:[e.id,"builder-block",e.class,(i=e.properties)==null?void 0:i.class].filter(Boolean).join(" ")};return transformBlockProperties(n)}function getStyleAttribute(e){switch(serverEntry.TARGET){case"svelte":case"vue2":case"vue3":case"solid":return convertStyleMapToCSSArray(e).join(" ");case"qwik":case"reactNative":case"react":case"rsc":return e}}function BlockWrapper(e){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" ",e.hasChildren?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(e.Wrapper,{...getBlockProperties({block:e.block,context:e.context}),...getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0}),children:[" ",e.children," "]})}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(e.Wrapper,{...getBlockProperties({block:e.block,context:e.context}),...getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0})})})," "]})}function InteractiveElement(e){return jsxRuntime.jsx(e.Wrapper,{...e.wrapperProps,attributes:{...getBlockProperties({block:e.block,context:e.context}),...getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})},children:e.children})}const getWrapperProps=({componentOptions:e,builderBlock:t,context:n,componentRef:i,includeBlockProps:r,isInteractive:o,contextValue:a})=>o?{Wrapper:i,block:t,context:n,wrapperProps:e}:{...e,...r?{attributes:getBlockProperties({block:t,context:a})}:{}};function ComponentRef(e){var i,r;const[t,n]=react.useState(()=>e.isInteractive?InteractiveElement:e.componentRef);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.componentRef?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(t,{...getWrapperProps({componentOptions:e.componentOptions,builderBlock:e.builderBlock,context:e.context,componentRef:e.componentRef,includeBlockProps:e.includeBlockProps,isInteractive:e.isInteractive,contextValue:e.context}),children:[(i=e.blockChildren)==null?void 0:i.map(o=>jsxRuntime.jsx(Block,{block:o,context:e.context,registeredComponents:e.registeredComponents},"block-"+o.id)),(r=e.blockChildren)==null?void 0:r.map(o=>jsxRuntime.jsx(BlockStyles,{block:o,context:e.context},"block-style-"+o.id))]})}):null})}function RepeatedBlock(e){const[t,n]=react.useState(()=>e.repeatContext);return jsxRuntime.jsx(builderContext.Provider,{value:t,children:jsxRuntime.jsx(Block,{block:e.block,context:t,registeredComponents:e.registeredComponents})})}function Block(e){var u,g,h,S;function t(){return getComponent({block:e.block,context:e.context,registeredComponents:e.registeredComponents})}function n(){return getRepeatItemData({block:e.block,context:e.context})}function i(){var f;return(f=e.block.repeat)!=null&&f.collection?e.block:getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0})}function r(){return e.block.tagName||"div"}function o(){var R,C;if((R=e.block.repeat)!=null&&R.collection)return!!((C=n==null?void 0:n())!=null&&C.length);const f="hide"in i()?i().hide:!1;return("show"in i()?i().show:!0)&&!f}function a(){var y;return!((y=t==null?void 0:t())!=null&&y.component)&&!n()?i().children??[]:[]}function c(){var f,y,R,C,p;return{blockChildren:i().children??[],componentRef:(f=t==null?void 0:t())==null?void 0:f.component,componentOptions:{...getBlockComponentOptions(i()),builderContext:e.context,...((y=t==null?void 0:t())==null?void 0:y.name)==="Symbol"||((R=t==null?void 0:t())==null?void 0:R.name)==="Columns"?{builderComponents:e.registeredComponents}:{}},context:s,registeredComponents:e.registeredComponents,builderBlock:i(),includeBlockProps:((C=t==null?void 0:t())==null?void 0:C.noWrap)===!0,isInteractive:!((p=t==null?void 0:t())!=null&&p.isRSC)}}const[s,l]=react.useState(()=>e.context);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:o()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(u=t==null?void 0:t())!=null&&u.noWrap?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(ComponentRef,{componentRef:c().componentRef,componentOptions:c().componentOptions,blockChildren:c().blockChildren,context:c().context,registeredComponents:c().registeredComponents,builderBlock:c().builderBlock,includeBlockProps:c().includeBlockProps,isInteractive:c().isInteractive})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[isEmptyHtmlElement(r())?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(BlockWrapper,{Wrapper:r(),block:i(),context:e.context,hasChildren:!1})}):null,!isEmptyHtmlElement(r())&&n()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(g=n())==null?void 0:g.map((f,y)=>jsxRuntime.jsx(RepeatedBlock,{repeatContext:f.context,block:f.block,registeredComponents:e.registeredComponents},y))}):null,!isEmptyHtmlElement(r())&&!n()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(BlockWrapper,{Wrapper:r(),block:i(),context:e.context,hasChildren:!0,children:[jsxRuntime.jsx(ComponentRef,{componentRef:c().componentRef,componentOptions:c().componentOptions,blockChildren:c().blockChildren,context:c().context,registeredComponents:c().registeredComponents,builderBlock:c().builderBlock,includeBlockProps:c().includeBlockProps,isInteractive:c().isInteractive}),(h=a())==null?void 0:h.map(f=>jsxRuntime.jsx(Block,{block:f,context:s,registeredComponents:e.registeredComponents},"block-"+f.id)),(S=a())==null?void 0:S.map(f=>jsxRuntime.jsx(BlockStyles,{block:f,context:s},"block-style-"+f.id))]})}):null]})}):null})}function BlocksWrapper(e){function t(){var r;return"builder-blocks"+((r=e.blocks)!=null&&r.length?"":" no-blocks")}function n(){var r,o;serverEntry.isEditing()&&!((r=e.blocks)!=null&&r.length)&&((o=window.parent)==null||o.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function i(){var r,o;serverEntry.isEditing()&&!((r=e.blocks)!=null&&r.length)&&((o=window.parent)==null||o.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:t()+" div-02c7a115","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:r=>n(),onMouseEnter:r=>i(),onKeyPress:r=>n(),children:e.children}),jsxRuntime.jsx("style",{children:`.div-02c7a115 {
|
|
51
51
|
display: flex;
|
|
52
52
|
flex-direction: column;
|
|
53
53
|
align-items: stretch;
|
|
54
|
-
}`})]})}function Blocks(e){var i,r;const t=react.useContext(builderContext),n=react.useContext(ComponentsContext);return jsxRuntime.jsxs(BlocksWrapper,{blocks:e.blocks,parent:e.parent,path:e.path,styleProp:e.styleProp,children:[e.blocks?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(i=e.blocks)==null?void 0:i.map(o=>jsxRuntime.jsx(Block,{block:o,context:e.context||t,registeredComponents:e.registeredComponents||n.registeredComponents},"render-block-"+o.id))}):null,e.blocks?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(r=e.blocks)==null?void 0:r.map(o=>jsxRuntime.jsx(BlockStyles,{block:o,context:e.context||t},"block-style-"+o.id))}):null]})}function Columns(e){var
|
|
55
|
-
@media (max-width: ${
|
|
54
|
+
}`})]})}function Blocks(e){var i,r;const t=react.useContext(builderContext),n=react.useContext(ComponentsContext);return jsxRuntime.jsxs(BlocksWrapper,{blocks:e.blocks,parent:e.parent,path:e.path,styleProp:e.styleProp,children:[e.blocks?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(i=e.blocks)==null?void 0:i.map(o=>jsxRuntime.jsx(Block,{block:o,context:e.context||t,registeredComponents:e.registeredComponents||n.registeredComponents},"render-block-"+o.id))}):null,e.blocks?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(r=e.blocks)==null?void 0:r.map(o=>jsxRuntime.jsx(BlockStyles,{block:o,context:e.context||t},"block-style-"+o.id))}):null]})}function Columns(e){var C;const[t,n]=react.useState(()=>typeof e.space=="number"?e.space||0:20),[i,r]=react.useState(()=>e.columns||[]),[o,a]=react.useState(()=>e.stackColumnsAt||"tablet");function c(p){var k;return((k=i[p])==null?void 0:k.width)||100/i.length}function s(p){const k=t*(i.length-1)/i.length;return`calc(${c(p)}% - ${k}px)`}function l({stackedStyle:p,desktopStyle:k}){return o==="tablet"?p:k}function u({stackedStyle:p,desktopStyle:k}){return o==="never"?k:p}const[g,h]=react.useState(()=>e.stackColumnsAt==="never"?"row":e.reverseColumnsWhenStacked?"column-reverse":"column");function S(){return{"--flex-dir":g,"--flex-dir-tablet":l({stackedStyle:g,desktopStyle:"row"})}}function f(p){const k=p===0?0:t,E=s(p),I=`${k}px`,T="100%",w=0;return{width:E,["marginLeft"]:I,"--column-width-mobile":u({stackedStyle:T,desktopStyle:E}),"--column-margin-left-mobile":u({stackedStyle:w,desktopStyle:I}),"--column-width-tablet":l({stackedStyle:T,desktopStyle:E}),"--column-margin-left-tablet":l({stackedStyle:w,desktopStyle:I})}}function y(p){var E,I;return getSizesForBreakpoints(((I=(E=e.builderContext.content)==null?void 0:E.meta)==null?void 0:I.breakpoints)||{})[p].max}function R(){return`
|
|
55
|
+
@media (max-width: ${y("medium")}px) {
|
|
56
56
|
.${e.builderBlock.id}-breakpoints {
|
|
57
57
|
flex-direction: var(--flex-dir-tablet);
|
|
58
58
|
align-items: stretch;
|
|
@@ -64,7 +64,7 @@ output;
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
@media (max-width: ${
|
|
67
|
+
@media (max-width: ${y("small")}px) {
|
|
68
68
|
.${e.builderBlock.id}-breakpoints {
|
|
69
69
|
flex-direction: var(--flex-dir);
|
|
70
70
|
align-items: stretch;
|
|
@@ -75,7 +75,7 @@ output;
|
|
|
75
75
|
margin-left: var(--column-margin-left-mobile) !important;
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
-
`}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:`builder-columns ${e.builderBlock.id}-breakpoints div-53636e90`,style:S(),children:[jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(InlinedStyles,{styles:
|
|
78
|
+
`}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:`builder-columns ${e.builderBlock.id}-breakpoints div-53636e90`,style:S(),children:[jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(InlinedStyles,{styles:R()})}),(C=e.columns)==null?void 0:C.map((p,k)=>react.createElement("div",{className:"builder-column div-53636e90-2",style:f(k),key:k},jsxRuntime.jsx(Blocks,{path:`component.options.columns.${k}.blocks`,parent:e.builderBlock.id,styleProp:{flexGrow:"1"},context:e.builderContext,registeredComponents:e.builderComponents,blocks:p.blocks})))]}),jsxRuntime.jsx("style",{children:`.div-53636e90 {
|
|
79
79
|
display: flex;
|
|
80
80
|
line-height: normal;
|
|
81
81
|
}.div-53636e90-2 {
|
|
@@ -196,7 +196,7 @@ output;
|
|
|
196
196
|
"${t}",${JSON.stringify(e)}, ${isHydrationTarget}
|
|
197
197
|
)`,getUpdateVariantVisibilityScript=({contentId:e,variationId:t})=>`window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
|
|
198
198
|
"${t}", "${e}", ${isHydrationTarget}
|
|
199
|
-
)`;function InlinedScript(e){return jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:e.scriptStr},id:e.id||""})}function round(e){return Math.round(e*1e3)/1e3}const findParentElement=(e,t,n=!0)=>{if(!(e instanceof HTMLElement))return null;let i=n?e:e.parentElement;do{if(!i)return null;if(t(i))return i}while(i=i.parentElement);return null},findBuilderParent=e=>findParentElement(e,t=>{const n=t.getAttribute("builder-id")||t.id;return(n==null?void 0:n.indexOf("builder-"))===0}),computeOffset=({event:e,target:t})=>{const n=t.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top,o=round(i/n.width),a=round(r/n.height);return{x:o,y:a}},getInteractionPropertiesForEvent=e=>{const t=e.target,n=t&&findBuilderParent(t),i=(n==null?void 0:n.getAttribute("builder-id"))||(n==null?void 0:n.id);return{targetBuilderElement:i||void 0,metadata:{targetOffset:t?computeOffset({event:e,target:t}):void 0,builderTargetOffset:n?computeOffset({event:e,target:n}):void 0,builderElementIndex:n&&i?[].slice.call(document.getElementsByClassName(i)).indexOf(n):void 0}}},SDK_VERSION="0.
|
|
199
|
+
)`;function InlinedScript(e){return jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:e.scriptStr},id:e.id||""})}function round(e){return Math.round(e*1e3)/1e3}const findParentElement=(e,t,n=!0)=>{if(!(e instanceof HTMLElement))return null;let i=n?e:e.parentElement;do{if(!i)return null;if(t(i))return i}while(i=i.parentElement);return null},findBuilderParent=e=>findParentElement(e,t=>{const n=t.getAttribute("builder-id")||t.id;return(n==null?void 0:n.indexOf("builder-"))===0}),computeOffset=({event:e,target:t})=>{const n=t.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top,o=round(i/n.width),a=round(r/n.height);return{x:o,y:a}},getInteractionPropertiesForEvent=e=>{const t=e.target,n=t&&findBuilderParent(t),i=(n==null?void 0:n.getAttribute("builder-id"))||(n==null?void 0:n.id);return{targetBuilderElement:i||void 0,metadata:{targetOffset:t?computeOffset({event:e,target:t}):void 0,builderTargetOffset:n?computeOffset({event:e,target:n}):void 0,builderElementIndex:n&&i?[].slice.call(document.getElementsByClassName(i)).indexOf(n):void 0}}},SDK_VERSION="0.8.0",registerInsertMenu=()=>{serverEntry.register("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let isSetupForEditing=!1;const setupBrowserForEditing=(e={})=>{var t,n;isSetupForEditing||(isSetupForEditing=!0,serverEntry.isBrowser()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:serverEntry.TARGET,version:SDK_VERSION,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",({data:i})=>{var r,o;if(i!=null&&i.type)switch(i.type){case"builder.evaluate":{const a=i.data.text,c=i.data.arguments||[],s=i.data.id,l=new Function(a);let u,g=null;try{u=l.apply(null,c)}catch(h){g=h}g?(r=window.parent)==null||r.postMessage({type:"builder.evaluateError",data:{id:s,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var S;(S=window.parent)==null||S.postMessage({type:"builder.evaluateResult",data:{id:s,result:h}},"*")}).catch(console.error):(o=window.parent)==null||o.postMessage({type:"builder.evaluateResult",data:{result:u,id:s}},"*");break}}})))};function EnableEditor(e){var E,I,T,w,B,A,P;const t=react.useRef(null),[n,i]=react.useState(()=>0);function r(d){var x,b,v,j,F;const m={...e.builderContextSignal.content,...d,data:{...(x=e.builderContextSignal.content)==null?void 0:x.data,...d==null?void 0:d.data},meta:{...(b=e.builderContextSignal.content)==null?void 0:b.meta,...d==null?void 0:d.meta,breakpoints:((v=d==null?void 0:d.meta)==null?void 0:v.breakpoints)||((F=(j=e.builderContextSignal.content)==null?void 0:j.meta)==null?void 0:F.breakpoints)}};e.setBuilderContextSignal(V=>({...V,content:m}))}react.useState(()=>0);const[o,a]=react.useState(()=>!1);function c(d){var x;const{data:m}=d;if(m)switch(m.type){case"builder.configureSdk":{const b=m.data,{breakpoints:v,contentId:j}=b;if(!j||j!==((x=e.builderContextSignal.content)==null?void 0:x.id))return;v&&r({meta:{breakpoints:v}}),i(n+1);break}case"builder.contentUpdate":{const b=m.data,v=b.key||b.alias||b.entry||b.modelName,j=b.data;v===e.model&&(r(j),i(n+1));break}}}function s(){var m,x;const d=(x=(m=e.builderContextSignal.content)==null?void 0:m.data)==null?void 0:x.jsCode;d&&evaluate({code:d,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[l,u]=react.useState(()=>({})),[g,h]=react.useState(()=>!1);function S(d){var m,x;if(e.builderContextSignal.content){const b=(m=e.builderContextSignal.content)==null?void 0:m.testVariationId,v=(x=e.builderContextSignal.content)==null?void 0:x.id;serverEntry._track({type:"click",canTrack:serverEntry.getDefaultCanTrack(e.canTrack),contentId:v,apiKey:e.apiKey,variationId:b!==v?b:void 0,...getInteractionPropertiesForEvent(d),unique:!g})}g||h(!0)}function f(d){return d.replace(/{{([^}]+)}}/g,(m,x)=>evaluate({code:x,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function y({url:d,key:m}){serverEntry.fetch(d).then(x=>x.json()).then(x=>{var v,j;const b={...e.builderContextSignal.rootState,[m]:x};(j=(v=e.builderContextSignal).rootSetState)==null||j.call(v,b),l[m]=!0}).catch(x=>{console.error("error fetching dynamic data",d,x)})}function R(){var m,x;const d=((x=(m=e.builderContextSignal.content)==null?void 0:m.data)==null?void 0:x.httpRequests)??{};Object.entries(d).forEach(([b,v])=>{if(v&&(!l[b]||serverEntry.isEditing())){const j=f(v);y({url:j,key:b})}})}function C(){serverEntry.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:serverEntry.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function p(d){i(n+1),window.addEventListener("message",c),registerInsertMenu(),setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(m=>{var b;const x=serverEntry.createRegisterComponentMessage(m);(b=window.parent)==null||b.postMessage(x,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",C)}function k(d){const m=new URL(location.href).searchParams,x=m.get("builder.preview"),b=m.get(`builder.preview.${x}`),v=m.get("apiKey")||m.get("builder.space");x===e.model&&v===e.apiKey&&(!e.content||b===e.content.id)&&serverEntry.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(j=>{j&&r(j)})}return react.useEffect(()=>{var d;return(d=t.current)==null||d.addEventListener("initeditingbldr",p),()=>{var m;return(m=t.current)==null?void 0:m.removeEventListener("initeditingbldr",p)}},[]),react.useEffect(()=>{var d;return(d=t.current)==null||d.addEventListener("initpreviewingbldr",k),()=>{var m;return(m=t.current)==null?void 0:m.removeEventListener("initpreviewingbldr",k)}},[]),react.useEffect(()=>{var d,m;if(serverEntry.isBrowser()){if(serverEntry.isEditing()&&t.current&&t.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&serverEntry.getDefaultCanTrack(e.canTrack)){const b=(d=e.builderContextSignal.content)==null?void 0:d.testVariationId,v=(m=e.builderContextSignal.content)==null?void 0:m.id,j=e.apiKey;serverEntry._track({type:"impression",canTrack:!0,contentId:v,apiKey:j,variationId:b!==v?b:void 0})}serverEntry.isPreviewing()&&t.current&&t.current.dispatchEvent(new CustomEvent("initpreviewingbldr"))}},[]),react.useEffect(()=>{e.apiKey||serverEntry.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),s(),R(),C()},[]),react.useEffect(()=>{e.content&&r(e.content)},[e.content]),react.useEffect(()=>{},[o]),react.useEffect(()=>{s()},[(I=(E=e.builderContextSignal.content)==null?void 0:E.data)==null?void 0:I.jsCode,e.builderContextSignal.rootState]),react.useEffect(()=>{R()},[(w=(T=e.builderContextSignal.content)==null?void 0:T.data)==null?void 0:w.httpRequests]),react.useEffect(()=>{C()},[e.builderContextSignal.rootState]),react.useEffect(()=>()=>{serverEntry.isBrowser()&&(window.removeEventListener("message",c),window.removeEventListener("builder:component:stateChangeListenerActivated",C))},[]),jsxRuntime.jsx(builderContext.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?jsxRuntime.jsx(jsxRuntime.Fragment,{children:react.createElement("div",{key:n,ref:t,onClick:d=>S(d),"builder-content-id":(B=e.builderContextSignal.content)==null?void 0:B.id,"builder-model":e.model,...e.showContent?{}:{hidden:!0,"aria-hidden":!0},className:`variant-${((A=e.content)==null?void 0:A.testVariationId)||((P=e.content)==null?void 0:P.id)}`},e.children)}):null})}const getCssFromFont=e=>{var o;const t=e.family+(e.kind&&!e.kind.includes("#")?", "+e.kind:""),n=t.split(",")[0],i=e.fileUrl??((o=e==null?void 0:e.files)==null?void 0:o.regular);let r="";if(i&&t&&n&&(r+=`
|
|
200
200
|
@font-face {
|
|
201
201
|
font-family: "${t}";
|
|
202
202
|
src: local("${n}"), url('${i}') format('woff2');
|
|
@@ -226,4 +226,4 @@ ${getFontCss({customFonts:e.customFonts})}
|
|
|
226
226
|
text-align: inherit;
|
|
227
227
|
font-family: inherit;
|
|
228
228
|
}
|
|
229
|
-
`.trim());return jsxRuntime.jsx(InlinedStyles,{styles:t})}const getContextStateInitialValue=({content:e,data:t,locale:n})=>{var o,a,c;const i={},r=((o=e==null?void 0:e.data)==null?void 0:o.state)||{};return(c=(a=e==null?void 0:e.data)==null?void 0:a.inputs)==null||c.forEach(s=>{s.name&&s.defaultValue!==void 0&&(i[s.name]=s.defaultValue)}),{...i,...r,...t,...n?{locale:n}:{}}},getContentInitialValue=({content:e,data:t})=>e?{...e,data:{...e==null?void 0:e.data,...t},meta:e==null?void 0:e.meta}:void 0;function ContentComponent(e){var s,l,u,g,h,S,
|
|
229
|
+
`.trim());return jsxRuntime.jsx(InlinedStyles,{styles:t})}const getContextStateInitialValue=({content:e,data:t,locale:n})=>{var o,a,c;const i={},r=((o=e==null?void 0:e.data)==null?void 0:o.state)||{};return(c=(a=e==null?void 0:e.data)==null?void 0:a.inputs)==null||c.forEach(s=>{s.name&&s.defaultValue!==void 0&&(i[s.name]=s.defaultValue)}),{...i,...r,...t,...n?{locale:n}:{}}},getContentInitialValue=({content:e,data:t})=>e?{...e,data:{...e==null?void 0:e.data,...t},meta:e==null?void 0:e.meta}:void 0;function ContentComponent(e){var s,l,u,g,h,S,f;const[t,n]=react.useState(()=>{var y,R;return getUpdateVariantVisibilityScript({variationId:(y=e.content)==null?void 0:y.testVariationId,contentId:(R=e.content)==null?void 0:R.id})});function i(y){c(R=>({...R,rootState:y}))}const[r,o]=react.useState(()=>[...getDefaultRegisteredComponents(),...serverEntry.components,...e.customComponents||[]].reduce((y,{component:R,...C})=>({...y,[C.name]:{component:R,...serverEntry.serializeComponentInfo(C)}}),{})),[a,c]=react.useState(()=>({content:getContentInitialValue({content:e.content,data:e.data}),localState:void 0,rootState:getContextStateInitialValue({content:e.content,data:e.data,locale:e.locale}),rootSetState:i,context:e.context||{},apiKey:e.apiKey,apiVersion:e.apiVersion,componentInfos:[...getDefaultRegisteredComponents(),...serverEntry.components,...e.customComponents||[]].reduce((y,{component:R,...C})=>({...y,[C.name]:serverEntry.serializeComponentInfo(C)}),{}),inheritedStyles:{}}));return jsxRuntime.jsx(ComponentsContext.Provider,{value:{registeredComponents:r},children:jsxRuntime.jsxs(EnableEditor,{content:e.content,model:e.model,context:e.context,apiKey:e.apiKey,canTrack:e.canTrack,locale:e.locale,includeRefs:e.includeRefs,enrich:e.enrich,showContent:e.showContent,builderContextSignal:a,setBuilderContextSignal:c,children:[e.isSsrAbTest?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(InlinedScript,{scriptStr:t})}):null,jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(ContentStyles,{contentId:(s=a.content)==null?void 0:s.id,cssCode:(u=(l=a.content)==null?void 0:l.data)==null?void 0:u.cssCode,customFonts:(h=(g=a.content)==null?void 0:g.data)==null?void 0:h.customFonts})}),jsxRuntime.jsx(Blocks,{blocks:(f=(S=a.content)==null?void 0:S.data)==null?void 0:f.blocks,context:a,registeredComponents:r})]})})}function ContentVariants(e){var a,c;const[t,n]=react.useState(()=>checkShouldRenderVariants({canTrack:serverEntry.getDefaultCanTrack(e.canTrack),content:e.content}));function i(){var s;return getUpdateCookieAndStylesScript(getVariants(e.content).map(l=>({id:l.testVariationId,testRatio:l.testRatio})),((s=e.content)==null?void 0:s.id)||"")}function r(){return getVariants(e.content).map(s=>`.variant-${s.testVariationId} { display: none; } `).join("")}function o(){var s;return t?{...e.content,testVariationId:(s=e.content)==null?void 0:s.id}:serverEntry.handleABTestingSync({item:e.content,canTrack:serverEntry.getDefaultCanTrack(e.canTrack)})}return react.useEffect(()=>{},[]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!e.__isNestedRender&&serverEntry.TARGET!=="reactNative"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(InlinedScript,{scriptStr:getScriptString()})}):null,t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(InlinedStyles,{id:`variants-styles-${(a=e.content)==null?void 0:a.id}`,styles:r()}),jsxRuntime.jsx(InlinedScript,{scriptStr:i()}),(c=getVariants(e.content))==null?void 0:c.map(s=>jsxRuntime.jsx(ContentComponent,{content:s,showContent:!1,model:e.model,data:e.data,context:e.context,apiKey:e.apiKey,apiVersion:e.apiVersion,customComponents:e.customComponents,canTrack:e.canTrack,locale:e.locale,includeRefs:e.includeRefs,enrich:e.enrich,isSsrAbTest:t},s.testVariationId))]}):null,jsxRuntime.jsx(ContentComponent,{content:o(),showContent:!0,model:e.model,data:e.data,context:e.context,apiKey:e.apiKey,apiVersion:e.apiVersion,customComponents:e.customComponents,canTrack:e.canTrack,locale:e.locale,includeRefs:e.includeRefs,enrich:e.enrich,isSsrAbTest:t})]})}const fetchSymbolContent=async({builderContextValue:e,symbol:t})=>{if(t!=null&&t.model&&(e!=null&&e.apiKey))return serverEntry.fetchOneEntry({model:t.model,apiKey:e.apiKey,apiVersion:e.apiVersion,...(t==null?void 0:t.entry)&&{query:{id:t.entry}}}).catch(n=>{serverEntry.logger.error("Could not fetch symbol content: ",n)})};function Symbol$1(e){var o,a,c;function t(){var s,l;return[e.attributes.className,"builder-symbol",(s=e.symbol)!=null&&s.inline?"builder-inline-symbol":void 0,(l=e.symbol)!=null&&l.dynamic||e.dynamic?"builder-dynamic-symbol":void 0].filter(Boolean).join(" ")}const[n,i]=react.useState(()=>{var s;return(s=e.symbol)==null?void 0:s.content});function r(){n||fetchSymbolContent({symbol:e.symbol,builderContextValue:e.builderContext}).then(s=>{s&&i(s)})}return react.useEffect(()=>{},[]),react.useEffect(()=>{r()},[e.symbol]),jsxRuntime.jsx("div",{...e.attributes,className:t(),children:jsxRuntime.jsx(ContentVariants,{__isNestedRender:!0,apiVersion:e.builderContext.apiVersion,apiKey:e.builderContext.apiKey,context:e.builderContext.context,customComponents:Object.values(e.builderComponents),data:{...(o=e.symbol)==null?void 0:o.data,...e.builderContext.localState,...(a=n==null?void 0:n.data)==null?void 0:a.state},model:(c=e.symbol)==null?void 0:c.model,content:n})})}const RenderBlocks=Blocks,RenderContent=ContentVariants;exports._processContentResult=serverEntry._processContentResult;exports.createRegisterComponentMessage=serverEntry.createRegisterComponentMessage;exports.fetchBuilderProps=serverEntry.fetchBuilderProps;exports.fetchEntries=serverEntry.fetchEntries;exports.fetchOneEntry=serverEntry.fetchOneEntry;exports.getAllContent=serverEntry.getAllContent;exports.getBuilderSearchParams=serverEntry.getBuilderSearchParams;exports.getContent=serverEntry.getContent;exports.isEditing=serverEntry.isEditing;exports.isPreviewing=serverEntry.isPreviewing;exports.register=serverEntry.register;exports.setEditorSettings=serverEntry.setEditorSettings;exports.track=serverEntry.track;exports.Blocks=Blocks;exports.Button=Button;exports.Columns=Columns;exports.Content=ContentVariants;exports.Fragment=FragmentComponent;exports.Image=Image;exports.RenderBlocks=RenderBlocks;exports.RenderContent=RenderContent;exports.Section=SectionComponent;exports.Symbol=Symbol$1;exports.Text=Text;exports.Video=Video;
|