@builder.io/sdk-react-nextjs 0.7.1-4 → 0.7.2

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.
Files changed (292) hide show
  1. package/lib/{node/USE_CLIENT_BUNDLE-32bb8c8f.js → browser/USE_CLIENT_BUNDLE-0e3e24e7.js} +142 -142
  2. package/lib/browser/USE_CLIENT_BUNDLE-727780ee.cjs +23 -0
  3. package/lib/{edge/USE_SERVER_BUNDLE-133fe486.cjs → browser/USE_SERVER_BUNDLE-4341bf5c.cjs} +1 -1
  4. package/lib/{edge/USE_SERVER_BUNDLE-2a1fc947.js → browser/USE_SERVER_BUNDLE-ea1618f4.js} +1 -1
  5. package/lib/browser/{bundle-31003427.js → bundle-6f6b7d63.js} +953 -928
  6. package/lib/browser/bundle-fc27d227.cjs +76 -0
  7. package/lib/browser/index.cjs +1 -1
  8. package/lib/browser/index.d.cts +1 -1066
  9. package/lib/browser/index.d.mts +1 -1066
  10. package/lib/browser/index.mjs +3 -3
  11. package/lib/{browser/USE_CLIENT_BUNDLE-2dd6963b.js → edge/USE_CLIENT_BUNDLE-372b4c60.js} +142 -142
  12. package/lib/edge/USE_CLIENT_BUNDLE-f1bfb292.cjs +23 -0
  13. package/lib/{node/USE_SERVER_BUNDLE-86e8b7c7.js → edge/USE_SERVER_BUNDLE-e0effb0f.js} +1 -1
  14. package/lib/{node/USE_SERVER_BUNDLE-25f4a46f.cjs → edge/USE_SERVER_BUNDLE-ea7c665e.cjs} +1 -1
  15. package/lib/edge/{bundle-cfdeec4b.cjs → bundle-0fb39c43.cjs} +30 -30
  16. package/lib/edge/{bundle-1c5ceddb.js → bundle-213a8bf7.js} +1237 -1211
  17. package/lib/edge/index.cjs +1 -1
  18. package/lib/edge/index.d.cts +1 -1066
  19. package/lib/edge/index.d.mts +1 -1066
  20. package/lib/edge/index.mjs +3 -3
  21. package/lib/node/USE_CLIENT_BUNDLE-bdbc178a.cjs +23 -0
  22. package/lib/{edge/USE_CLIENT_BUNDLE-ee929cd6.js → node/USE_CLIENT_BUNDLE-c6d9e08c.js} +142 -142
  23. package/lib/{browser/USE_SERVER_BUNDLE-97369f61.js → node/USE_SERVER_BUNDLE-787d0ec8.js} +1 -1
  24. package/lib/{browser/USE_SERVER_BUNDLE-c110917b.cjs → node/USE_SERVER_BUNDLE-842e66c9.cjs} +1 -1
  25. package/lib/node/bundle-df78531d.cjs +116 -0
  26. package/lib/node/{bundle-844e3979.js → bundle-fb3490a6.js} +794 -769
  27. package/lib/node/index.cjs +1 -1
  28. package/lib/node/index.d.cts +1 -1066
  29. package/lib/node/index.d.mts +1 -1066
  30. package/lib/node/index.mjs +3 -3
  31. package/package.json +9 -5
  32. package/types/cjs/blocks/button/button.d.ts +12 -0
  33. package/types/cjs/blocks/button/component-info.d.ts +2 -0
  34. package/types/cjs/blocks/columns/columns.d.ts +17 -0
  35. package/types/cjs/blocks/columns/component-info.d.ts +2 -0
  36. package/types/cjs/blocks/custom-code/component-info.d.ts +2 -0
  37. package/types/cjs/blocks/custom-code/custom-code.d.ts +7 -0
  38. package/types/cjs/blocks/embed/component-info.d.ts +2 -0
  39. package/types/cjs/blocks/embed/embed.d.ts +6 -0
  40. package/types/cjs/blocks/embed/helpers.d.ts +1 -0
  41. package/types/cjs/blocks/fragment/component-info.d.ts +2 -0
  42. package/types/cjs/blocks/fragment/fragment.d.ts +8 -0
  43. package/types/cjs/blocks/helpers.d.ts +13 -0
  44. package/types/cjs/blocks/image/component-info.d.ts +2 -0
  45. package/types/cjs/blocks/image/image.d.ts +22 -0
  46. package/types/cjs/blocks/image/image.helpers.d.ts +1 -0
  47. package/types/cjs/blocks/img/component-info.d.ts +2 -0
  48. package/types/cjs/blocks/img/img.d.ts +14 -0
  49. package/types/cjs/blocks/section/component-info.d.ts +2 -0
  50. package/types/cjs/blocks/section/section.d.ts +12 -0
  51. package/types/cjs/blocks/symbol/component-info.d.ts +2 -0
  52. package/types/cjs/blocks/symbol/symbol.d.ts +26 -0
  53. package/types/cjs/blocks/symbol/symbol.helpers.d.ts +14 -0
  54. package/types/cjs/blocks/text/component-info.d.ts +2 -0
  55. package/types/cjs/blocks/text/text.d.ts +6 -0
  56. package/types/cjs/blocks/video/component-info.d.ts +2 -0
  57. package/types/cjs/blocks/video/video.d.ts +20 -0
  58. package/types/cjs/components/block/block.d.ts +10 -0
  59. package/types/cjs/components/block/block.helpers.d.ts +13 -0
  60. package/types/cjs/components/block/components/block-styles.d.ts +9 -0
  61. package/types/cjs/components/block/components/block-wrapper.d.ts +18 -0
  62. package/types/cjs/components/block/components/component-ref/component-ref.d.ts +4 -0
  63. package/types/cjs/components/block/components/component-ref/component-ref.helpers.d.ts +28 -0
  64. package/types/cjs/components/block/components/interactive-element.d.ts +12 -0
  65. package/types/cjs/components/block/components/repeated-block.d.ts +10 -0
  66. package/types/cjs/components/block/types.d.ts +6 -0
  67. package/types/cjs/components/blocks/blocks-wrapper.d.ts +11 -0
  68. package/types/cjs/components/blocks/blocks.d.ts +9 -0
  69. package/types/cjs/components/content/components/enable-editor.d.ts +10 -0
  70. package/types/cjs/components/content/components/styles.d.ts +9 -0
  71. package/types/cjs/components/content/components/styles.helpers.d.ts +15 -0
  72. package/types/cjs/components/content/content.d.ts +4 -0
  73. package/types/cjs/components/content/content.helpers.d.ts +7 -0
  74. package/types/cjs/components/content/content.types.d.ts +24 -0
  75. package/types/cjs/components/content/wrap-component-ref.d.ts +6 -0
  76. package/types/cjs/components/content-variants/content-variants.d.ts +10 -0
  77. package/types/cjs/components/content-variants/content-variants.types.d.ts +20 -0
  78. package/types/cjs/components/content-variants/helpers.d.ts +41 -0
  79. package/types/cjs/components/inlined-script.d.ts +7 -0
  80. package/types/cjs/components/inlined-styles.d.ts +7 -0
  81. package/types/cjs/constants/builder-registered-components.d.ts +6 -0
  82. package/types/cjs/constants/device-sizes.d.ts +13 -0
  83. package/types/cjs/constants/sdk-version.d.ts +1 -0
  84. package/types/cjs/constants/target.d.ts +2 -0
  85. package/types/cjs/context/builder.context.d.ts +3 -0
  86. package/types/cjs/context/components.context.d.ts +3 -0
  87. package/types/cjs/context/types.d.ts +35 -0
  88. package/types/cjs/functions/camel-to-kebab-case.d.ts +1 -0
  89. package/types/cjs/functions/deopt.d.ts +4 -0
  90. package/types/cjs/functions/evaluate/browser-runtime/browser.d.ts +4 -0
  91. package/types/cjs/functions/evaluate/browser-runtime/index.d.ts +1 -0
  92. package/types/cjs/functions/evaluate/choose-eval.d.ts +6 -0
  93. package/types/cjs/functions/evaluate/evaluate.d.ts +2 -0
  94. package/types/cjs/functions/evaluate/helpers.d.ts +24 -0
  95. package/types/cjs/functions/evaluate/index.d.ts +1 -0
  96. package/types/cjs/functions/event-handler-name.d.ts +1 -0
  97. package/types/cjs/functions/extract-text-styles.d.ts +4 -0
  98. package/types/cjs/functions/fast-clone.d.ts +4 -0
  99. package/types/cjs/functions/fetch-builder-props.d.ts +53 -0
  100. package/types/cjs/functions/get-block-actions-handler.d.ts +8 -0
  101. package/types/cjs/functions/get-block-actions.d.ts +10 -0
  102. package/types/cjs/functions/get-block-component-options.d.ts +2 -0
  103. package/types/cjs/functions/get-block-properties.d.ts +6 -0
  104. package/types/cjs/functions/get-builder-search-params/index.d.ts +12 -0
  105. package/types/cjs/functions/get-content/generate-content-url.d.ts +2 -0
  106. package/types/cjs/functions/get-content/index.d.ts +28 -0
  107. package/types/cjs/functions/get-content/types.d.ts +142 -0
  108. package/types/cjs/functions/get-fetch.d.ts +1 -0
  109. package/types/cjs/functions/get-global-this.d.ts +4 -0
  110. package/types/cjs/functions/get-processed-block.d.ts +10 -0
  111. package/types/cjs/functions/get-react-native-block-styles.d.ts +7 -0
  112. package/types/cjs/functions/is-browser.d.ts +1 -0
  113. package/types/cjs/functions/is-editing.d.ts +1 -0
  114. package/types/cjs/functions/is-iframe.d.ts +1 -0
  115. package/types/cjs/functions/is-previewing.d.ts +1 -0
  116. package/types/cjs/functions/register-component.d.ts +15 -0
  117. package/types/cjs/functions/register.d.ts +16 -0
  118. package/types/cjs/functions/sanitize-react-native-block-styles.d.ts +3 -0
  119. package/types/cjs/functions/set-editor-settings.d.ts +4 -0
  120. package/types/cjs/functions/set.d.ts +7 -0
  121. package/types/cjs/functions/track/helpers.d.ts +5 -0
  122. package/types/cjs/functions/track/index.d.ts +51 -0
  123. package/types/cjs/functions/track/interaction.d.ts +13 -0
  124. package/types/cjs/functions/transform-block-properties.d.ts +1 -0
  125. package/types/cjs/functions/transform-block.d.ts +2 -0
  126. package/types/cjs/helpers/ab-tests.d.ts +9 -0
  127. package/types/cjs/helpers/canTrack.d.ts +1 -0
  128. package/types/cjs/helpers/cookie.d.ts +19 -0
  129. package/types/cjs/helpers/css.d.ts +7 -0
  130. package/types/cjs/helpers/flatten.d.ts +6 -0
  131. package/types/cjs/helpers/localStorage.d.ts +9 -0
  132. package/types/cjs/helpers/logger.d.ts +6 -0
  133. package/types/cjs/helpers/nullable.d.ts +2 -0
  134. package/types/cjs/helpers/preview-lru-cache/get.d.ts +1 -0
  135. package/types/cjs/helpers/preview-lru-cache/helpers.d.ts +1 -0
  136. package/types/cjs/helpers/preview-lru-cache/init.d.ts +6 -0
  137. package/types/cjs/helpers/preview-lru-cache/set.d.ts +7 -0
  138. package/types/cjs/helpers/preview-lru-cache/types.d.ts +12 -0
  139. package/types/cjs/helpers/sessionId.d.ts +6 -0
  140. package/types/cjs/helpers/url.d.ts +6 -0
  141. package/types/cjs/helpers/uuid.d.ts +8 -0
  142. package/types/cjs/helpers/visitorId.d.ts +6 -0
  143. package/types/cjs/index-helpers/blocks-exports.d.ts +19 -0
  144. package/types/cjs/index-helpers/top-of-file.d.ts +1 -0
  145. package/types/cjs/index.d.ts +7 -0
  146. package/types/cjs/scripts/init-editing.d.ts +6 -0
  147. package/types/cjs/server-index.d.ts +15 -0
  148. package/types/cjs/types/api-version.d.ts +2 -0
  149. package/types/cjs/types/builder-block.d.ts +66 -0
  150. package/types/cjs/types/builder-content.d.ts +44 -0
  151. package/types/cjs/types/builder-props.d.ts +9 -0
  152. package/types/cjs/types/can-track.d.ts +3 -0
  153. package/types/cjs/types/components.d.ts +110 -0
  154. package/types/cjs/types/deep-partial.d.ts +3 -0
  155. package/types/cjs/types/element.d.ts +59 -0
  156. package/types/cjs/types/enforced-partials.d.ts +21 -0
  157. package/types/cjs/types/input.d.ts +121 -0
  158. package/types/cjs/types/targets.d.ts +1 -0
  159. package/types/cjs/types/typescript.d.ts +11 -0
  160. package/types/esm/blocks/button/button.d.ts +12 -0
  161. package/types/esm/blocks/button/component-info.d.ts +2 -0
  162. package/types/esm/blocks/columns/columns.d.ts +17 -0
  163. package/types/esm/blocks/columns/component-info.d.ts +2 -0
  164. package/types/esm/blocks/custom-code/component-info.d.ts +2 -0
  165. package/types/esm/blocks/custom-code/custom-code.d.ts +7 -0
  166. package/types/esm/blocks/embed/component-info.d.ts +2 -0
  167. package/types/esm/blocks/embed/embed.d.ts +6 -0
  168. package/types/esm/blocks/embed/helpers.d.ts +1 -0
  169. package/types/esm/blocks/fragment/component-info.d.ts +2 -0
  170. package/types/esm/blocks/fragment/fragment.d.ts +8 -0
  171. package/types/esm/blocks/helpers.d.ts +13 -0
  172. package/types/esm/blocks/image/component-info.d.ts +2 -0
  173. package/types/esm/blocks/image/image.d.ts +22 -0
  174. package/types/esm/blocks/image/image.helpers.d.ts +1 -0
  175. package/types/esm/blocks/img/component-info.d.ts +2 -0
  176. package/types/esm/blocks/img/img.d.ts +14 -0
  177. package/types/esm/blocks/section/component-info.d.ts +2 -0
  178. package/types/esm/blocks/section/section.d.ts +12 -0
  179. package/types/esm/blocks/symbol/component-info.d.ts +2 -0
  180. package/types/esm/blocks/symbol/symbol.d.ts +26 -0
  181. package/types/esm/blocks/symbol/symbol.helpers.d.ts +14 -0
  182. package/types/esm/blocks/text/component-info.d.ts +2 -0
  183. package/types/esm/blocks/text/text.d.ts +6 -0
  184. package/types/esm/blocks/video/component-info.d.ts +2 -0
  185. package/types/esm/blocks/video/video.d.ts +20 -0
  186. package/types/esm/components/block/block.d.ts +10 -0
  187. package/types/esm/components/block/block.helpers.d.ts +13 -0
  188. package/types/esm/components/block/components/block-styles.d.ts +9 -0
  189. package/types/esm/components/block/components/block-wrapper.d.ts +18 -0
  190. package/types/esm/components/block/components/component-ref/component-ref.d.ts +4 -0
  191. package/types/esm/components/block/components/component-ref/component-ref.helpers.d.ts +28 -0
  192. package/types/esm/components/block/components/interactive-element.d.ts +12 -0
  193. package/types/esm/components/block/components/repeated-block.d.ts +10 -0
  194. package/types/esm/components/block/types.d.ts +6 -0
  195. package/types/esm/components/blocks/blocks-wrapper.d.ts +11 -0
  196. package/types/esm/components/blocks/blocks.d.ts +9 -0
  197. package/types/esm/components/content/components/enable-editor.d.ts +10 -0
  198. package/types/esm/components/content/components/styles.d.ts +9 -0
  199. package/types/esm/components/content/components/styles.helpers.d.ts +15 -0
  200. package/types/esm/components/content/content.d.ts +4 -0
  201. package/types/esm/components/content/content.helpers.d.ts +7 -0
  202. package/types/esm/components/content/content.types.d.ts +24 -0
  203. package/types/esm/components/content/wrap-component-ref.d.ts +6 -0
  204. package/types/esm/components/content-variants/content-variants.d.ts +10 -0
  205. package/types/esm/components/content-variants/content-variants.types.d.ts +20 -0
  206. package/types/esm/components/content-variants/helpers.d.ts +41 -0
  207. package/types/esm/components/inlined-script.d.ts +7 -0
  208. package/types/esm/components/inlined-styles.d.ts +7 -0
  209. package/types/esm/constants/builder-registered-components.d.ts +6 -0
  210. package/types/esm/constants/device-sizes.d.ts +13 -0
  211. package/types/esm/constants/sdk-version.d.ts +1 -0
  212. package/types/esm/constants/target.d.ts +2 -0
  213. package/types/esm/context/builder.context.d.ts +3 -0
  214. package/types/esm/context/components.context.d.ts +3 -0
  215. package/types/esm/context/types.d.ts +35 -0
  216. package/types/esm/functions/camel-to-kebab-case.d.ts +1 -0
  217. package/types/esm/functions/deopt.d.ts +4 -0
  218. package/types/esm/functions/evaluate/browser-runtime/browser.d.ts +4 -0
  219. package/types/esm/functions/evaluate/browser-runtime/index.d.ts +1 -0
  220. package/types/esm/functions/evaluate/choose-eval.d.ts +6 -0
  221. package/types/esm/functions/evaluate/evaluate.d.ts +2 -0
  222. package/types/esm/functions/evaluate/helpers.d.ts +24 -0
  223. package/types/esm/functions/evaluate/index.d.ts +1 -0
  224. package/types/esm/functions/event-handler-name.d.ts +1 -0
  225. package/types/esm/functions/extract-text-styles.d.ts +4 -0
  226. package/types/esm/functions/fast-clone.d.ts +4 -0
  227. package/types/esm/functions/fetch-builder-props.d.ts +53 -0
  228. package/types/esm/functions/get-block-actions-handler.d.ts +8 -0
  229. package/types/esm/functions/get-block-actions.d.ts +10 -0
  230. package/types/esm/functions/get-block-component-options.d.ts +2 -0
  231. package/types/esm/functions/get-block-properties.d.ts +6 -0
  232. package/types/esm/functions/get-builder-search-params/index.d.ts +12 -0
  233. package/types/esm/functions/get-content/generate-content-url.d.ts +2 -0
  234. package/types/esm/functions/get-content/index.d.ts +28 -0
  235. package/types/esm/functions/get-content/types.d.ts +142 -0
  236. package/types/esm/functions/get-fetch.d.ts +1 -0
  237. package/types/esm/functions/get-global-this.d.ts +4 -0
  238. package/types/esm/functions/get-processed-block.d.ts +10 -0
  239. package/types/esm/functions/get-react-native-block-styles.d.ts +7 -0
  240. package/types/esm/functions/is-browser.d.ts +1 -0
  241. package/types/esm/functions/is-editing.d.ts +1 -0
  242. package/types/esm/functions/is-iframe.d.ts +1 -0
  243. package/types/esm/functions/is-previewing.d.ts +1 -0
  244. package/types/esm/functions/register-component.d.ts +15 -0
  245. package/types/esm/functions/register.d.ts +16 -0
  246. package/types/esm/functions/sanitize-react-native-block-styles.d.ts +3 -0
  247. package/types/esm/functions/set-editor-settings.d.ts +4 -0
  248. package/types/esm/functions/set.d.ts +7 -0
  249. package/types/esm/functions/track/helpers.d.ts +5 -0
  250. package/types/esm/functions/track/index.d.ts +51 -0
  251. package/types/esm/functions/track/interaction.d.ts +13 -0
  252. package/types/esm/functions/transform-block-properties.d.ts +1 -0
  253. package/types/esm/functions/transform-block.d.ts +2 -0
  254. package/types/esm/helpers/ab-tests.d.ts +9 -0
  255. package/types/esm/helpers/canTrack.d.ts +1 -0
  256. package/types/esm/helpers/cookie.d.ts +19 -0
  257. package/types/esm/helpers/css.d.ts +7 -0
  258. package/types/esm/helpers/flatten.d.ts +6 -0
  259. package/types/esm/helpers/localStorage.d.ts +9 -0
  260. package/types/esm/helpers/logger.d.ts +6 -0
  261. package/types/esm/helpers/nullable.d.ts +2 -0
  262. package/types/esm/helpers/preview-lru-cache/get.d.ts +1 -0
  263. package/types/esm/helpers/preview-lru-cache/helpers.d.ts +1 -0
  264. package/types/esm/helpers/preview-lru-cache/init.d.ts +6 -0
  265. package/types/esm/helpers/preview-lru-cache/set.d.ts +7 -0
  266. package/types/esm/helpers/preview-lru-cache/types.d.ts +12 -0
  267. package/types/esm/helpers/sessionId.d.ts +6 -0
  268. package/types/esm/helpers/url.d.ts +6 -0
  269. package/types/esm/helpers/uuid.d.ts +8 -0
  270. package/types/esm/helpers/visitorId.d.ts +6 -0
  271. package/types/esm/index-helpers/blocks-exports.d.ts +19 -0
  272. package/types/esm/index-helpers/top-of-file.d.ts +1 -0
  273. package/types/esm/index.d.ts +7 -0
  274. package/types/esm/scripts/init-editing.d.ts +6 -0
  275. package/types/esm/server-index.d.ts +15 -0
  276. package/types/esm/types/api-version.d.ts +2 -0
  277. package/types/esm/types/builder-block.d.ts +66 -0
  278. package/types/esm/types/builder-content.d.ts +44 -0
  279. package/types/esm/types/builder-props.d.ts +9 -0
  280. package/types/esm/types/can-track.d.ts +3 -0
  281. package/types/esm/types/components.d.ts +110 -0
  282. package/types/esm/types/deep-partial.d.ts +3 -0
  283. package/types/esm/types/element.d.ts +59 -0
  284. package/types/esm/types/enforced-partials.d.ts +21 -0
  285. package/types/esm/types/input.d.ts +121 -0
  286. package/types/esm/types/targets.d.ts +1 -0
  287. package/types/esm/types/typescript.d.ts +11 -0
  288. package/lib/browser/USE_CLIENT_BUNDLE-1cdce03b.cjs +0 -23
  289. package/lib/browser/bundle-cbc690cf.cjs +0 -76
  290. package/lib/edge/USE_CLIENT_BUNDLE-ba263633.cjs +0 -23
  291. package/lib/node/USE_CLIENT_BUNDLE-7a982d7c.cjs +0 -23
  292. package/lib/node/bundle-b13f5899.cjs +0 -116
@@ -1,51 +1,20 @@
1
1
  import { LRUCache } from "lru-cache";
2
2
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
3
  import { createElement } from "react";
4
- import { I as InteractiveElement, B as BlockWrapper, a as BlocksWrapper, b as Button, C as CustomCode, E as Embed, F as FragmentComponent, c as Image, d as ImgComponent, S as SectionComponent, V as Video, e as EnableEditor } from "./USE_CLIENT_BUNDLE-32bb8c8f.js";
4
+ import { I as InteractiveElement, B as BlockWrapper, a as BlocksWrapper, b as Button, C as CustomCode, E as Embed, F as FragmentComponent, c as Image, d as ImgComponent, S as SectionComponent, V as Video, e as EnableEditor } from "./USE_CLIENT_BUNDLE-c6d9e08c.js";
5
5
  import "next/navigation";
6
- const fastClone = (e) => JSON.parse(JSON.stringify(e)), SIZES = {
7
- small: {
8
- min: 320,
9
- default: 321,
10
- max: 640
11
- },
12
- medium: {
13
- min: 641,
14
- default: 642,
15
- max: 991
16
- },
17
- large: {
18
- min: 990,
19
- default: 991,
20
- max: 1200
21
- }
22
- }, getMaxWidthQueryForSize = (e, t = SIZES) => `@media (max-width: ${t[e].max}px)`, getSizesForBreakpoints = ({
23
- small: e,
24
- medium: t
25
- }) => {
26
- const n = fastClone(SIZES);
27
- if (!e || !t)
28
- return n;
29
- const o = Math.floor(e / 2);
30
- n.small = {
31
- max: e,
32
- min: o,
33
- default: o + 1
34
- };
35
- const r = n.small.max + 1;
36
- n.medium = {
37
- max: t,
38
- min: r,
39
- default: r + 1
6
+ function getBlockComponentOptions(e) {
7
+ var t;
8
+ return {
9
+ ...(t = e.component) == null ? void 0 : t.options,
10
+ ...e.options,
11
+ /**
12
+ * Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
13
+ */
14
+ builderBlock: e
40
15
  };
41
- const i = n.medium.max + 1;
42
- return n.large = {
43
- max: 2e3,
44
- // TODO: decide upper limit
45
- min: i,
46
- default: i + 1
47
- }, n;
48
- }, TARGET = "rsc", MSG_PREFIX = "[Builder.io]: ", logger = {
16
+ }
17
+ const MSG_PREFIX = "[Builder.io]: ", logger = {
49
18
  log: (...e) => console.log(MSG_PREFIX, ...e),
50
19
  error: (...e) => console.error(MSG_PREFIX, ...e),
51
20
  warn: (...e) => console.warn(MSG_PREFIX, ...e),
@@ -54,6 +23,7 @@ const fastClone = (e) => JSON.parse(JSON.stringify(e)), SIZES = {
54
23
  function isBrowser() {
55
24
  return typeof window < "u" && typeof document < "u";
56
25
  }
26
+ const TARGET = "rsc";
57
27
  function isIframe() {
58
28
  return isBrowser() && window.self !== window.top;
59
29
  }
@@ -120,13 +90,13 @@ const getLocation = () => {
120
90
  rootSetState: i,
121
91
  rootState: a
122
92
  }) => {
123
- const c = getFunctionArguments({
93
+ const s = getFunctionArguments({
124
94
  builder: t,
125
95
  context: n,
126
96
  event: o,
127
97
  state: flattenState(a, r, i)
128
98
  });
129
- return new Function(...c.map(([s]) => s), e)(...c.map(([, s]) => s));
99
+ return new Function(...s.map(([c]) => c), e)(...s.map(([, c]) => c));
130
100
  };
131
101
  function flattenState(e, t, n) {
132
102
  if (e === t)
@@ -140,18 +110,18 @@ function flattenState(e, t, n) {
140
110
  }
141
111
  });
142
112
  }
143
- const noop = () => null;
113
+ const fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t, n) => {
114
+ if (Object(e) !== e)
115
+ return e;
116
+ const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
117
+ return o.slice(0, -1).reduce((r, i, a) => Object(r[i]) === r[i] ? r[i] : r[i] = Math.abs(Number(o[a + 1])) >> 0 === +o[a + 1] ? [] : {}, e)[o[o.length - 1]] = n, e;
118
+ }, noop = () => null;
144
119
  let safeDynamicRequire = noop;
145
120
  try {
146
121
  safeDynamicRequire = eval("require");
147
122
  } catch (e) {
148
123
  }
149
- const set = (e, t, n) => {
150
- if (Object(e) !== e)
151
- return e;
152
- const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
153
- return o.slice(0, -1).reduce((r, i, a) => Object(r[i]) === r[i] ? r[i] : r[i] = Math.abs(Number(o[a + 1])) >> 0 === +o[a + 1] ? [] : {}, e)[o[o.length - 1]] = n, e;
154
- }, ivm = safeDynamicRequire("isolated-vm"), getSyncValName = (e) => `bldr_${e}_sync`, BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE", INJECTED_IVM_GLOBAL = "BUILDER_IVM", REF_TO_PROXY_FN = `
124
+ const ivm = safeDynamicRequire("isolated-vm"), getSyncValName = (e) => `bldr_${e}_sync`, BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE", INJECTED_IVM_GLOBAL = "BUILDER_IVM", REF_TO_PROXY_FN = `
155
125
  var refToProxy = (obj) => {
156
126
  if (typeof obj !== 'object' || obj === null) {
157
127
  return obj;
@@ -208,20 +178,20 @@ output;
208
178
  rootSetState: i,
209
179
  rootState: a
210
180
  }) => {
211
- const c = fastClone({
181
+ const s = fastClone({
212
182
  ...a,
213
183
  ...r
214
- }), s = getFunctionArguments({
184
+ }), c = getFunctionArguments({
215
185
  builder: t,
216
186
  context: n,
217
187
  event: o,
218
- state: c
188
+ state: s
219
189
  }), u = getIsolateContext(), m = u.global;
220
190
  m.setSync("global", m.derefInto()), m.setSync("log", function(...l) {
221
191
  console.log(...l);
222
192
  }), m.setSync(BUILDER_SET_STATE_NAME, function(l, f) {
223
193
  set(a, l, f), i == null || i(a);
224
- }), s.forEach(([l, f]) => {
194
+ }), c.forEach(([l, f]) => {
225
195
  const d = typeof f == "object" ? new ivm.Reference(
226
196
  // workaround: methods with default values for arguments is not being cloned over
227
197
  l === "builder" ? {
@@ -233,7 +203,7 @@ output;
233
203
  }), m.setSync(INJECTED_IVM_GLOBAL, ivm);
234
204
  const h = processCode({
235
205
  code: e,
236
- args: s
206
+ args: c
237
207
  }), p = u.evalSync(h);
238
208
  try {
239
209
  return JSON.parse(p);
@@ -254,7 +224,7 @@ function evaluate({
254
224
  logger.warn("Skipping evaluation of empty code block.");
255
225
  return;
256
226
  }
257
- const c = {
227
+ const s = {
258
228
  code: parseCode(e, {
259
229
  isExpression: a
260
230
  }),
@@ -266,9 +236,9 @@ function evaluate({
266
236
  localState: n
267
237
  };
268
238
  try {
269
- return chooseBrowserOrServerEval(c);
270
- } catch (s) {
271
- logger.error("Failed code evaluation: " + s.message, {
239
+ return chooseBrowserOrServerEval(s);
240
+ } catch (c) {
241
+ logger.error("Failed code evaluation: " + c.message, {
272
242
  code: e
273
243
  });
274
244
  return;
@@ -295,15 +265,15 @@ const evaluateBindings = ({
295
265
  ...i.actions
296
266
  }
297
267
  };
298
- for (const c in e.bindings) {
299
- const s = e.bindings[c], u = evaluate({
300
- code: s,
268
+ for (const s in e.bindings) {
269
+ const c = e.bindings[s], u = evaluate({
270
+ code: c,
301
271
  localState: n,
302
272
  rootState: o,
303
273
  rootSetState: r,
304
274
  context: t
305
275
  });
306
- set(a, c, u);
276
+ set(a, s, u);
307
277
  }
308
278
  return a;
309
279
  };
@@ -324,7 +294,104 @@ function getProcessedBlock({
324
294
  context: t
325
295
  }) : a;
326
296
  }
327
- const camelToKebabCase = (e) => e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase(), checkIsDefined = (e) => e != null, convertStyleMapToCSSArray = (e) => Object.entries(e).map(([n, o]) => {
297
+ 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 = ({
298
+ block: e,
299
+ context: t,
300
+ registeredComponents: n
301
+ }) => {
302
+ var i;
303
+ const o = (i = getProcessedBlock({
304
+ block: e,
305
+ localState: t.localState,
306
+ rootState: t.rootState,
307
+ rootSetState: t.rootSetState,
308
+ context: t.context,
309
+ shouldEvaluateBindings: !1
310
+ }).component) == null ? void 0 : i.name;
311
+ if (!o)
312
+ return null;
313
+ const r = n[o];
314
+ if (r)
315
+ return r;
316
+ console.warn(`
317
+ Could not find a registered component named "${o}".
318
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
319
+ }, getRepeatItemData = ({
320
+ block: e,
321
+ context: t
322
+ }) => {
323
+ const {
324
+ repeat: n,
325
+ ...o
326
+ } = e;
327
+ if (!(n != null && n.collection))
328
+ return;
329
+ const r = evaluate({
330
+ code: n.collection,
331
+ localState: t.localState,
332
+ rootState: t.rootState,
333
+ rootSetState: t.rootSetState,
334
+ context: t.context
335
+ });
336
+ if (!Array.isArray(r))
337
+ return;
338
+ const i = n.collection.split(".").pop(), a = n.itemName || (i ? i + "Item" : "item");
339
+ return r.map((c, u) => ({
340
+ context: {
341
+ ...t,
342
+ localState: {
343
+ ...t.localState,
344
+ $index: u,
345
+ $item: c,
346
+ [a]: c,
347
+ [`$${a}Index`]: u
348
+ }
349
+ },
350
+ block: o
351
+ }));
352
+ }, SIZES = {
353
+ small: {
354
+ min: 320,
355
+ default: 321,
356
+ max: 640
357
+ },
358
+ medium: {
359
+ min: 641,
360
+ default: 642,
361
+ max: 991
362
+ },
363
+ large: {
364
+ min: 990,
365
+ default: 991,
366
+ max: 1200
367
+ }
368
+ }, getMaxWidthQueryForSize = (e, t = SIZES) => `@media (max-width: ${t[e].max}px)`, getSizesForBreakpoints = ({
369
+ small: e,
370
+ medium: t
371
+ }) => {
372
+ const n = fastClone(SIZES);
373
+ if (!e || !t)
374
+ return n;
375
+ const o = Math.floor(e / 2);
376
+ n.small = {
377
+ max: e,
378
+ min: o,
379
+ default: o + 1
380
+ };
381
+ const r = n.small.max + 1;
382
+ n.medium = {
383
+ max: t,
384
+ min: r,
385
+ default: r + 1
386
+ };
387
+ const i = n.medium.max + 1;
388
+ return n.large = {
389
+ max: 2e3,
390
+ // TODO: decide upper limit
391
+ min: i,
392
+ default: i + 1
393
+ }, n;
394
+ }, camelToKebabCase = (e) => e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase(), checkIsDefined = (e) => e != null, convertStyleMapToCSSArray = (e) => Object.entries(e).map(([n, o]) => {
328
395
  if (typeof o == "string")
329
396
  return `${camelToKebabCase(n)}: ${o};`;
330
397
  }).filter(checkIsDefined), convertStyleMapToCSS = (e) => convertStyleMapToCSSArray(e).join(`
@@ -363,111 +430,33 @@ function BlockStyles(e) {
363
430
  rootSetState: e.context.rootSetState,
364
431
  context: e.context.context,
365
432
  shouldEvaluateBindings: !0
366
- }), i = r.responsiveStyles, a = e.context.content, c = getSizesForBreakpoints(
433
+ }), i = r.responsiveStyles, a = e.context.content, s = getSizesForBreakpoints(
367
434
  ((d = a == null ? void 0 : a.meta) == null ? void 0 : d.breakpoints) || {}
368
- ), s = i == null ? void 0 : i.large, u = i == null ? void 0 : i.medium, m = i == null ? void 0 : i.small, h = r.id;
435
+ ), c = i == null ? void 0 : i.large, u = i == null ? void 0 : i.medium, m = i == null ? void 0 : i.small, h = r.id;
369
436
  if (!h)
370
437
  return "";
371
- const p = s ? createCssClass({
438
+ const p = c ? createCssClass({
372
439
  className: h,
373
- styles: s
440
+ styles: c
374
441
  }) : "", l = u ? createCssClass({
375
442
  className: h,
376
443
  styles: u,
377
444
  mediaQuery: getMaxWidthQueryForSize(
378
445
  "medium",
379
- c
446
+ s
380
447
  )
381
448
  }) : "", f = m ? createCssClass({
382
449
  className: h,
383
450
  styles: m,
384
451
  mediaQuery: getMaxWidthQueryForSize(
385
452
  "small",
386
- c
453
+ s
387
454
  )
388
455
  }) : "";
389
456
  return [p, l, f].join(" ");
390
457
  };
391
458
  return /* @__PURE__ */ jsx(Fragment, { children: n() && t() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: n() }) }) : null });
392
459
  }
393
- function getBlockComponentOptions(e) {
394
- var t;
395
- return {
396
- ...(t = e.component) == null ? void 0 : t.options,
397
- ...e.options,
398
- /**
399
- * Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
400
- */
401
- builderBlock: e
402
- };
403
- }
404
- 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 = ({
405
- block: e,
406
- context: t,
407
- registeredComponents: n
408
- }) => {
409
- var i;
410
- const o = (i = getProcessedBlock({
411
- block: e,
412
- localState: t.localState,
413
- rootState: t.rootState,
414
- rootSetState: t.rootSetState,
415
- context: t.context,
416
- shouldEvaluateBindings: !1
417
- }).component) == null ? void 0 : i.name;
418
- if (!o)
419
- return null;
420
- const r = n[o];
421
- if (r)
422
- return r;
423
- console.warn(`
424
- Could not find a registered component named "${o}".
425
- If you registered it, is the file that registered it imported by the file that needs to render it?`);
426
- }, getRepeatItemData = ({
427
- block: e,
428
- context: t
429
- }) => {
430
- const {
431
- repeat: n,
432
- ...o
433
- } = e;
434
- if (!(n != null && n.collection))
435
- return;
436
- const r = evaluate({
437
- code: n.collection,
438
- localState: t.localState,
439
- rootState: t.rootState,
440
- rootSetState: t.rootSetState,
441
- context: t.context
442
- });
443
- if (!Array.isArray(r))
444
- return;
445
- const i = n.collection.split(".").pop(), a = n.itemName || (i ? i + "Item" : "item");
446
- return r.map((s, u) => ({
447
- context: {
448
- ...t,
449
- localState: {
450
- ...t.localState,
451
- $index: u,
452
- $item: s,
453
- [a]: s,
454
- [`$${a}Index`]: u
455
- }
456
- },
457
- block: o
458
- }));
459
- };
460
- function RepeatedBlock(e) {
461
- const t = e.repeatContext;
462
- return /* @__PURE__ */ jsx(
463
- Block,
464
- {
465
- block: e.block,
466
- context: t,
467
- registeredComponents: e.registeredComponents
468
- }
469
- );
470
- }
471
460
  function capitalizeFirstLetter(e) {
472
461
  return e.charAt(0).toUpperCase() + e.slice(1);
473
462
  }
@@ -598,6 +587,17 @@ function ComponentRef(e) {
598
587
  }
599
588
  ) }) : null });
600
589
  }
590
+ function RepeatedBlock(e) {
591
+ const t = e.repeatContext;
592
+ return /* @__PURE__ */ jsx(
593
+ Block,
594
+ {
595
+ block: e.block,
596
+ context: t,
597
+ registeredComponents: e.registeredComponents
598
+ }
599
+ );
600
+ }
601
601
  function Block(e) {
602
602
  var u, m, h, p;
603
603
  const t = function() {
@@ -627,7 +627,7 @@ function Block(e) {
627
627
  }, a = function() {
628
628
  var d;
629
629
  return !((d = t()) != null && d.component) && !n() ? o().children ?? [] : [];
630
- }, c = function() {
630
+ }, s = function() {
631
631
  var f, d, b, y, g;
632
632
  return {
633
633
  blockChildren: o().children ?? [],
@@ -639,14 +639,26 @@ function Block(e) {
639
639
  builderComponents: e.registeredComponents
640
640
  } : {}
641
641
  },
642
- context: s,
642
+ context: c,
643
643
  registeredComponents: e.registeredComponents,
644
644
  builderBlock: o(),
645
645
  includeBlockProps: ((y = t()) == null ? void 0 : y.noWrap) === !0,
646
646
  isInteractive: !((g = t()) != null && g.isRSC)
647
647
  };
648
- }, s = e.context;
649
- return /* @__PURE__ */ jsx(Fragment, { children: i() ? /* @__PURE__ */ jsx(Fragment, { children: (u = t()) != null && u.noWrap ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ComponentRef, { ...c() }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
648
+ }, c = e.context;
649
+ return /* @__PURE__ */ jsx(Fragment, { children: i() ? /* @__PURE__ */ jsx(Fragment, { children: (u = t()) != null && u.noWrap ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
650
+ ComponentRef,
651
+ {
652
+ componentRef: s().componentRef,
653
+ componentOptions: s().componentOptions,
654
+ blockChildren: s().blockChildren,
655
+ context: s().context,
656
+ registeredComponents: s().registeredComponents,
657
+ builderBlock: s().builderBlock,
658
+ includeBlockProps: s().includeBlockProps,
659
+ isInteractive: s().isInteractive
660
+ }
661
+ ) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
650
662
  isEmptyHtmlElement(r()) ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
651
663
  BlockWrapper,
652
664
  {
@@ -673,12 +685,24 @@ function Block(e) {
673
685
  context: e.context,
674
686
  hasChildren: !0,
675
687
  children: [
676
- /* @__PURE__ */ jsx(ComponentRef, { ...c() }),
688
+ /* @__PURE__ */ jsx(
689
+ ComponentRef,
690
+ {
691
+ componentRef: s().componentRef,
692
+ componentOptions: s().componentOptions,
693
+ blockChildren: s().blockChildren,
694
+ context: s().context,
695
+ registeredComponents: s().registeredComponents,
696
+ builderBlock: s().builderBlock,
697
+ includeBlockProps: s().includeBlockProps,
698
+ isInteractive: s().isInteractive
699
+ }
700
+ ),
677
701
  (h = a()) == null ? void 0 : h.map((l) => /* @__PURE__ */ jsx(
678
702
  Block,
679
703
  {
680
704
  block: l,
681
- context: s,
705
+ context: c,
682
706
  registeredComponents: e.registeredComponents
683
707
  },
684
708
  "block-" + l.id
@@ -687,7 +711,7 @@ function Block(e) {
687
711
  BlockStyles,
688
712
  {
689
713
  block: l,
690
- context: s
714
+ context: c
691
715
  },
692
716
  "block-style-" + l.id
693
717
  ))
@@ -740,34 +764,34 @@ function Columns(e) {
740
764
  desktopStyle: b
741
765
  }) {
742
766
  return o === "tablet" ? d : b;
743
- }, c = function({
767
+ }, s = function({
744
768
  stackedStyle: d,
745
769
  desktopStyle: b
746
770
  }) {
747
771
  return o === "never" ? b : d;
748
- }, s = e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column", u = function() {
772
+ }, c = e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column", u = function() {
749
773
  return {
750
- "--flex-dir": s,
774
+ "--flex-dir": c,
751
775
  "--flex-dir-tablet": a({
752
- stackedStyle: s,
776
+ stackedStyle: c,
753
777
  desktopStyle: "row"
754
778
  })
755
779
  };
756
780
  }, m = function(d) {
757
- const b = d === 0 ? 0 : t, y = i(d), g = `${b}px`, v = "100%", x = 0;
781
+ const b = d === 0 ? 0 : t, y = i(d), g = `${b}px`, k = "100%", x = 0;
758
782
  return {
759
783
  width: y,
760
784
  ["marginLeft"]: g,
761
- "--column-width-mobile": c({
762
- stackedStyle: v,
785
+ "--column-width-mobile": s({
786
+ stackedStyle: k,
763
787
  desktopStyle: y
764
788
  }),
765
- "--column-margin-left-mobile": c({
789
+ "--column-margin-left-mobile": s({
766
790
  stackedStyle: x,
767
791
  desktopStyle: g
768
792
  }),
769
793
  "--column-width-tablet": a({
770
- stackedStyle: v,
794
+ stackedStyle: k,
771
795
  desktopStyle: y
772
796
  }),
773
797
  "--column-margin-left-tablet": a({
@@ -811,14 +835,14 @@ function Columns(e) {
811
835
  /* @__PURE__ */ jsxs(
812
836
  "div",
813
837
  {
814
- className: `builder-columns ${e.builderBlock.id}-breakpoints div-666689ca`,
838
+ className: `builder-columns ${e.builderBlock.id}-breakpoints div-0d69fe26`,
815
839
  style: u(),
816
840
  children: [
817
841
  /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: p() }) }),
818
842
  (l = e.columns) == null ? void 0 : l.map((f, d) => /* @__PURE__ */ createElement(
819
843
  "div",
820
844
  {
821
- className: "builder-column div-666689ca-2",
845
+ className: "builder-column div-0d69fe26-2",
822
846
  style: m(d),
823
847
  key: d
824
848
  },
@@ -839,10 +863,10 @@ function Columns(e) {
839
863
  ]
840
864
  }
841
865
  ),
842
- /* @__PURE__ */ jsx("style", { children: `.div-666689ca {
866
+ /* @__PURE__ */ jsx("style", { children: `.div-0d69fe26 {
843
867
  display: flex;
844
868
  line-height: normal;
845
- }.div-666689ca-2 {
869
+ }.div-0d69fe26-2 {
846
870
  display: flex;
847
871
  flex-direction: column;
848
872
  align-items: stretch;
@@ -879,98 +903,142 @@ function getSrcSet(e) {
879
903
  }
880
904
  return e.match(/cdn\.shopify\.com/) ? t.map((n) => [getShopifyImageUrl(e, `${n}x${n}`), n]).filter(([n]) => !!n).map(([n, o]) => `${n} ${o}w`).concat([e]).join(", ") : e;
881
905
  }
882
- const getVariants = (e) => Object.values((e == null ? void 0 : e.variations) || {}).map((t) => ({
883
- ...t,
884
- testVariationId: t.id,
885
- id: e == null ? void 0 : e.id
886
- })), checkShouldRunVariants = ({
887
- canTrack: e,
888
- content: t
889
- }) => !(!(getVariants(t).length > 0) || !e || isBrowser());
890
- function bldrAbTest(e, t, n) {
891
- var a;
892
- function o() {
893
- function c(f, d, b) {
894
- let y = "";
895
- if (b) {
896
- const g = /* @__PURE__ */ new Date();
897
- g.setTime(g.getTime() + b * 24 * 60 * 60 * 1e3), y = "; expires=" + g.toUTCString();
898
- }
899
- document.cookie = f + "=" + (d || "") + y + "; path=/; Secure; SameSite=None";
900
- }
901
- function s(f) {
902
- const d = f + "=", b = document.cookie.split(";");
903
- for (let y = 0; y < b.length; y++) {
904
- let g = b[y];
905
- for (; g.charAt(0) === " "; )
906
- g = g.substring(1, g.length);
907
- if (g.indexOf(d) === 0)
908
- return g.substring(d.length, g.length);
909
- }
910
- return null;
911
- }
912
- const u = `builder.tests.${e}`, m = s(u), h = t.map((f) => f.id).concat(e);
913
- if (m && h.includes(m))
914
- return m;
915
- let p = 0;
916
- const l = Math.random();
917
- for (let f = 0; f < t.length; f++) {
918
- const d = t[f], b = d.testRatio;
919
- if (p += b, l < p)
920
- return c(u, d.id), d.id;
921
- }
922
- return c(u, e), e;
923
- }
924
- const r = o(), i = (a = document.currentScript) == null ? void 0 : a.previousElementSibling;
925
- if (n) {
926
- i.remove();
927
- const c = document.currentScript;
928
- c == null || c.remove();
929
- } else {
930
- const c = t.concat({
931
- id: e
932
- }).filter((s) => s.id !== r).map((s) => `.variant-${s.id} { display: none; }
933
- `).join("");
934
- i.innerHTML = c;
935
- }
936
- }
937
- function bldrCntntScrpt(e, t, n) {
938
- var s;
939
- if (!navigator.cookieEnabled)
906
+ const getTopLevelDomain = (e) => {
907
+ if (e === "localhost" || e === "127.0.0.1")
908
+ return e;
909
+ const t = e.split(".");
910
+ return t.length > 2 ? t.slice(1).join(".") : e;
911
+ }, getCookieSync = ({
912
+ name: e,
913
+ canTrack: t
914
+ }) => {
915
+ var n;
916
+ try {
917
+ return t ? (n = document.cookie.split("; ").find((o) => o.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
918
+ } catch (o) {
919
+ logger.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o);
940
920
  return;
941
- function o(u) {
942
- const m = u + "=", h = document.cookie.split(";");
943
- for (let p = 0; p < h.length; p++) {
944
- let l = h[p];
945
- for (; l.charAt(0) === " "; )
946
- l = l.substring(1, l.length);
947
- if (l.indexOf(m) === 0)
948
- return l.substring(m.length, l.length);
949
- }
950
- return null;
951
921
  }
952
- const r = `builder.tests.${t}`, i = o(r), a = (s = document.currentScript) == null ? void 0 : s.parentElement, c = e === t;
953
- if (i === e) {
954
- if (c)
922
+ }, getCookie = async (e) => getCookieSync(e), stringifyCookie = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(checkIsDefined).join("; "), SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]], createCookieString = ({
923
+ name: e,
924
+ value: t,
925
+ expires: n
926
+ }) => {
927
+ const r = (isBrowser() ? location.protocol === "https:" : !0) ? SECURE_CONFIG : [[]], i = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...i, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...r];
928
+ return stringifyCookie(a);
929
+ }, setCookie = async ({
930
+ name: e,
931
+ value: t,
932
+ expires: n,
933
+ canTrack: o
934
+ }) => {
935
+ try {
936
+ if (!o)
955
937
  return;
956
- a == null || a.removeAttribute("hidden"), a == null || a.removeAttribute("aria-hidden");
957
- } else {
958
- c && (n ? a == null || a.remove() : (a == null || a.setAttribute("hidden", "true"), a == null || a.setAttribute("aria-hidden", "true")));
959
- return;
938
+ const r = createCookieString({
939
+ name: e,
940
+ value: t,
941
+ expires: n
942
+ });
943
+ document.cookie = r;
944
+ } catch (r) {
945
+ logger.warn("[COOKIE] SET error: ", (r == null ? void 0 : r.message) || r);
960
946
  }
961
- }
962
- const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydrationTarget = getIsHydrationTarget(TARGET), AB_TEST_FN_NAME = "builderIoAbTest", CONTENT_FN_NAME = "builderIoRenderContent", getScriptString = () => {
963
- const e = bldrAbTest.toString().replace(/\s+/g, " "), t = bldrCntntScrpt.toString().replace(/\s+/g, " ");
964
- return `
965
- window.${AB_TEST_FN_NAME} = ${e}
966
- window.${CONTENT_FN_NAME} = ${t}
967
- `;
968
- }, getVariantsScriptString = (e, t) => `
969
- window.${AB_TEST_FN_NAME}("${t}",${JSON.stringify(e)}, ${isHydrationTarget})`, getRenderContentScriptString = ({
947
+ }, BUILDER_STORE_PREFIX = "builder.tests", getContentTestKey = (e) => `${BUILDER_STORE_PREFIX}.${e}`, getContentVariationCookie = ({
948
+ contentId: e
949
+ }) => getCookie({
950
+ name: getContentTestKey(e),
951
+ canTrack: !0
952
+ }), getContentVariationCookieSync = ({
953
+ contentId: e
954
+ }) => getCookieSync({
955
+ name: getContentTestKey(e),
956
+ canTrack: !0
957
+ }), setContentVariationCookie = ({
970
958
  contentId: e,
971
- variationId: t
972
- }) => `
973
- window.${CONTENT_FN_NAME}("${t}", "${e}", ${isHydrationTarget})`, componentInfo$a = {
959
+ value: t
960
+ }) => setCookie({
961
+ name: getContentTestKey(e),
962
+ value: t,
963
+ canTrack: !0
964
+ }), checkIsBuilderContentWithVariations = (e) => checkIsDefined(e.id) && checkIsDefined(e.variations) && Object.keys(e.variations).length > 0, getRandomVariationId = ({
965
+ id: e,
966
+ variations: t
967
+ }) => {
968
+ var r;
969
+ let n = 0;
970
+ const o = Math.random();
971
+ for (const i in t) {
972
+ const a = (r = t[i]) == null ? void 0 : r.testRatio;
973
+ if (n += a, o < n)
974
+ return i;
975
+ }
976
+ return e;
977
+ }, getAndSetVariantId = (e) => {
978
+ const t = getRandomVariationId(e);
979
+ return setContentVariationCookie({
980
+ contentId: e.id,
981
+ value: t
982
+ }).catch((n) => {
983
+ logger.error("could not store A/B test variation: ", n);
984
+ }), t;
985
+ }, getTestFields = ({
986
+ item: e,
987
+ testGroupId: t
988
+ }) => {
989
+ const n = e.variations[t];
990
+ return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
991
+ !n ? {
992
+ testVariationId: e.id,
993
+ testVariationName: "Default"
994
+ } : {
995
+ data: n.data,
996
+ testVariationId: n.id,
997
+ testVariationName: n.name || (n.id === e.id ? "Default" : "")
998
+ };
999
+ }, handleABTestingSync = ({
1000
+ item: e,
1001
+ canTrack: t
1002
+ }) => {
1003
+ if (!t)
1004
+ return e;
1005
+ if (!e)
1006
+ return;
1007
+ if (!checkIsBuilderContentWithVariations(e))
1008
+ return e;
1009
+ const n = getContentVariationCookieSync({
1010
+ contentId: e.id
1011
+ }) || getAndSetVariantId({
1012
+ variations: e.variations,
1013
+ id: e.id
1014
+ }), o = getTestFields({
1015
+ item: e,
1016
+ testGroupId: n
1017
+ });
1018
+ return {
1019
+ ...e,
1020
+ ...o
1021
+ };
1022
+ }, handleABTesting = async ({
1023
+ item: e,
1024
+ canTrack: t
1025
+ }) => {
1026
+ if (!t || !checkIsBuilderContentWithVariations(e))
1027
+ return e;
1028
+ const o = await getContentVariationCookie({
1029
+ contentId: e.id
1030
+ }) || getAndSetVariantId({
1031
+ variations: e.variations,
1032
+ id: e.id
1033
+ }), r = getTestFields({
1034
+ item: e,
1035
+ testGroupId: o
1036
+ });
1037
+ return {
1038
+ ...e,
1039
+ ...r
1040
+ };
1041
+ }, getDefaultCanTrack = (e) => checkIsDefined(e) ? e : !0, componentInfo$a = {
974
1042
  name: "Core:Button",
975
1043
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
976
1044
  defaultStyles: {
@@ -1182,7 +1250,7 @@ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydr
1182
1250
  });
1183
1251
  }
1184
1252
  const n = e.get("columns");
1185
- Array.isArray(n) && n.find((r) => r.get("width")) && (n.find((i) => !i.get("width")) || n.reduce((c, s) => c + s.get("width"), 0) !== 100) && t();
1253
+ Array.isArray(n) && n.find((r) => r.get("width")) && (n.find((i) => !i.get("width")) || n.reduce((s, c) => s + c.get("width"), 0) !== 100) && t();
1186
1254
  }
1187
1255
  }, {
1188
1256
  name: "space",
@@ -1205,12 +1273,59 @@ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydr
1205
1273
  advanced: !0
1206
1274
  }]
1207
1275
  }, componentInfo$8 = {
1276
+ name: "Custom Code",
1277
+ static: !0,
1278
+ requiredPermissions: ["editCode"],
1279
+ inputs: [{
1280
+ name: "code",
1281
+ type: "html",
1282
+ required: !0,
1283
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
1284
+ code: !0
1285
+ }, {
1286
+ name: "replaceNodes",
1287
+ type: "boolean",
1288
+ helperText: "Preserve server rendered dom nodes",
1289
+ advanced: !0
1290
+ }, {
1291
+ name: "scriptsClientOnly",
1292
+ type: "boolean",
1293
+ defaultValue: !1,
1294
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
1295
+ advanced: !0
1296
+ }]
1297
+ }, componentInfo$7 = {
1298
+ name: "Embed",
1299
+ static: !0,
1300
+ inputs: [{
1301
+ name: "url",
1302
+ type: "url",
1303
+ required: !0,
1304
+ defaultValue: "",
1305
+ helperText: "e.g. enter a youtube url, google map, etc",
1306
+ onChange: (e) => {
1307
+ const t = e.get("url");
1308
+ if (t)
1309
+ return e.set("content", "Loading..."), fetch(`https://iframe.ly/api/iframely?url=${t}&api_key=ae0e60e78201a3f2b0de4b`).then((o) => o.json()).then((o) => {
1310
+ e.get("url") === t && (o.html ? e.set("content", o.html) : e.set("content", "Invalid url, please try another"));
1311
+ }).catch((o) => {
1312
+ e.set("content", "There was an error embedding this URL, please try again or another URL");
1313
+ });
1314
+ e.delete("content");
1315
+ }
1316
+ }, {
1317
+ name: "content",
1318
+ type: "html",
1319
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
1320
+ hideFromUI: !0
1321
+ }]
1322
+ }, SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"], isJsScript = (e) => SCRIPT_MIME_TYPES.includes(e.type), componentInfo$6 = {
1208
1323
  name: "Fragment",
1209
1324
  static: !0,
1210
1325
  hidden: !0,
1211
1326
  canHaveChildren: !0,
1212
1327
  noWrap: !0
1213
- }, componentInfo$7 = {
1328
+ }, componentInfo$5 = {
1214
1329
  name: "Image",
1215
1330
  static: !0,
1216
1331
  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",
@@ -1230,17 +1345,17 @@ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydr
1230
1345
  defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
1231
1346
  onChange: (e) => {
1232
1347
  e.delete("srcset"), e.delete("noWebp");
1233
- function n(a, c = 6e4) {
1234
- return new Promise((s, u) => {
1348
+ function n(a, s = 6e4) {
1349
+ return new Promise((c, u) => {
1235
1350
  const m = document.createElement("img");
1236
1351
  let h = !1;
1237
1352
  m.onload = () => {
1238
- h = !0, s(m);
1353
+ h = !0, c(m);
1239
1354
  }, m.addEventListener("error", (p) => {
1240
1355
  console.warn("Image load failed", p.error), u(p.error);
1241
1356
  }), m.src = a, setTimeout(() => {
1242
1357
  h || u(new Error("Image load timed out"));
1243
- }, c);
1358
+ }, s);
1244
1359
  });
1245
1360
  }
1246
1361
  function o(a) {
@@ -1251,8 +1366,8 @@ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydr
1251
1366
  a.type.includes("svg") && e.set("noWebp", !0);
1252
1367
  }), r && (!i || i === 0.7041))
1253
1368
  return n(r).then((a) => {
1254
- const c = e.get("aspectRatio");
1255
- e.get("image") === r && (!c || c === 0.7041) && a.width && a.height && (e.set("aspectRatio", o(a.height / a.width)), e.set("height", a.height), e.set("width", a.width));
1369
+ const s = e.get("aspectRatio");
1370
+ e.get("image") === r && (!s || s === 0.7041) && a.width && a.height && (e.set("aspectRatio", o(a.height / a.width)), e.set("height", a.height), e.set("width", a.width));
1256
1371
  });
1257
1372
  }
1258
1373
  }, {
@@ -1310,7 +1425,21 @@ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydr
1310
1425
  advanced: !0,
1311
1426
  defaultValue: 0.7041
1312
1427
  }]
1313
- }, componentInfo$6 = {
1428
+ }, componentInfo$4 = {
1429
+ // friendlyName?
1430
+ name: "Raw:Img",
1431
+ hideFromInsertMenu: !0,
1432
+ 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",
1433
+ inputs: [{
1434
+ name: "image",
1435
+ bubble: !0,
1436
+ type: "file",
1437
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
1438
+ required: !0
1439
+ }],
1440
+ noWrap: !0,
1441
+ static: !0
1442
+ }, componentInfo$3 = {
1314
1443
  name: "Core:Section",
1315
1444
  static: !0,
1316
1445
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
@@ -1349,7 +1478,7 @@ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydr
1349
1478
  }
1350
1479
  }
1351
1480
  }]
1352
- }, componentInfo$5 = {
1481
+ }, componentInfo$2 = {
1353
1482
  name: "Symbol",
1354
1483
  noWrap: !0,
1355
1484
  static: !0,
@@ -1382,7 +1511,7 @@ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydr
1382
1511
  hideFromUI: !0,
1383
1512
  type: "boolean"
1384
1513
  }]
1385
- }, componentInfo$4 = {
1514
+ }, componentInfo$1 = {
1386
1515
  name: "Text",
1387
1516
  static: !0,
1388
1517
  isRSC: !0,
@@ -1414,7 +1543,7 @@ function Text(e) {
1414
1543
  }
1415
1544
  );
1416
1545
  }
1417
- const componentInfo$3 = {
1546
+ const componentInfo = {
1418
1547
  name: "Video",
1419
1548
  canHaveChildren: !0,
1420
1549
  defaultStyles: {
@@ -1495,67 +1624,6 @@ const componentInfo$3 = {
1495
1624
  defaultValue: !0,
1496
1625
  advanced: !0
1497
1626
  }]
1498
- }, componentInfo$2 = {
1499
- name: "Embed",
1500
- static: !0,
1501
- inputs: [{
1502
- name: "url",
1503
- type: "url",
1504
- required: !0,
1505
- defaultValue: "",
1506
- helperText: "e.g. enter a youtube url, google map, etc",
1507
- onChange: (e) => {
1508
- const t = e.get("url");
1509
- if (t)
1510
- return e.set("content", "Loading..."), fetch(`https://iframe.ly/api/iframely?url=${t}&api_key=ae0e60e78201a3f2b0de4b`).then((o) => o.json()).then((o) => {
1511
- e.get("url") === t && (o.html ? e.set("content", o.html) : e.set("content", "Invalid url, please try another"));
1512
- }).catch((o) => {
1513
- e.set("content", "There was an error embedding this URL, please try again or another URL");
1514
- });
1515
- e.delete("content");
1516
- }
1517
- }, {
1518
- name: "content",
1519
- type: "html",
1520
- defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
1521
- hideFromUI: !0
1522
- }]
1523
- }, SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"], isJsScript = (e) => SCRIPT_MIME_TYPES.includes(e.type), componentInfo$1 = {
1524
- // friendlyName?
1525
- name: "Raw:Img",
1526
- hideFromInsertMenu: !0,
1527
- 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",
1528
- inputs: [{
1529
- name: "image",
1530
- bubble: !0,
1531
- type: "file",
1532
- allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
1533
- required: !0
1534
- }],
1535
- noWrap: !0,
1536
- static: !0
1537
- }, componentInfo = {
1538
- name: "Custom Code",
1539
- static: !0,
1540
- requiredPermissions: ["editCode"],
1541
- inputs: [{
1542
- name: "code",
1543
- type: "html",
1544
- required: !0,
1545
- defaultValue: "<p>Hello there, I am custom HTML code!</p>",
1546
- code: !0
1547
- }, {
1548
- name: "replaceNodes",
1549
- type: "boolean",
1550
- helperText: "Preserve server rendered dom nodes",
1551
- advanced: !0
1552
- }, {
1553
- name: "scriptsClientOnly",
1554
- type: "boolean",
1555
- defaultValue: !1,
1556
- helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
1557
- advanced: !0
1558
- }]
1559
1627
  }, getDefaultRegisteredComponents = () => [{
1560
1628
  component: Button,
1561
1629
  ...componentInfo$a
@@ -1564,31 +1632,31 @@ const componentInfo$3 = {
1564
1632
  ...componentInfo$9
1565
1633
  }, {
1566
1634
  component: CustomCode,
1567
- ...componentInfo
1635
+ ...componentInfo$8
1568
1636
  }, {
1569
1637
  component: Embed,
1570
- ...componentInfo$2
1638
+ ...componentInfo$7
1571
1639
  }, {
1572
1640
  component: FragmentComponent,
1573
- ...componentInfo$8
1641
+ ...componentInfo$6
1574
1642
  }, {
1575
1643
  component: Image,
1576
- ...componentInfo$7
1644
+ ...componentInfo$5
1577
1645
  }, {
1578
1646
  component: ImgComponent,
1579
- ...componentInfo$1
1647
+ ...componentInfo$4
1580
1648
  }, {
1581
1649
  component: SectionComponent,
1582
- ...componentInfo$6
1650
+ ...componentInfo$3
1583
1651
  }, {
1584
1652
  component: Symbol$1,
1585
- ...componentInfo$5
1653
+ ...componentInfo$2
1586
1654
  }, {
1587
1655
  component: Text,
1588
- ...componentInfo$4
1656
+ ...componentInfo$1
1589
1657
  }, {
1590
1658
  component: Video,
1591
- ...componentInfo$3
1659
+ ...componentInfo
1592
1660
  }], components = [], createRegisterComponentMessage = (e) => ({
1593
1661
  type: "builder.registerComponent",
1594
1662
  data: serializeComponentInfo(e)
@@ -1604,99 +1672,123 @@ const componentInfo$3 = {
1604
1672
  ...o,
1605
1673
  [r]: serializeValue(i)
1606
1674
  }), {}))
1607
- }), getCssFromFont = (e) => {
1608
- var i;
1609
- const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], o = e.fileUrl ?? ((i = e == null ? void 0 : e.files) == null ? void 0 : i.regular);
1610
- let r = "";
1611
- if (o && t && n && (r += `
1612
- @font-face {
1613
- font-family: "${t}";
1614
- src: local("${n}"), url('${o}') format('woff2');
1615
- font-display: fallback;
1616
- font-weight: 400;
1675
+ }), getVariants = (e) => Object.values((e == null ? void 0 : e.variations) || {}).map((t) => ({
1676
+ ...t,
1677
+ testVariationId: t.id,
1678
+ id: e == null ? void 0 : e.id
1679
+ })), checkShouldRunVariants = ({
1680
+ canTrack: e,
1681
+ content: t
1682
+ }) => !(!(getVariants(t).length > 0) || !e || isBrowser());
1683
+ function bldrAbTest(e, t, n) {
1684
+ var a;
1685
+ function o() {
1686
+ function s(f, d, b) {
1687
+ let y = "";
1688
+ if (b) {
1689
+ const g = /* @__PURE__ */ new Date();
1690
+ g.setTime(g.getTime() + b * 24 * 60 * 60 * 1e3), y = "; expires=" + g.toUTCString();
1691
+ }
1692
+ document.cookie = f + "=" + (d || "") + y + "; path=/; Secure; SameSite=None";
1693
+ }
1694
+ function c(f) {
1695
+ const d = f + "=", b = document.cookie.split(";");
1696
+ for (let y = 0; y < b.length; y++) {
1697
+ let g = b[y];
1698
+ for (; g.charAt(0) === " "; )
1699
+ g = g.substring(1, g.length);
1700
+ if (g.indexOf(d) === 0)
1701
+ return g.substring(d.length, g.length);
1702
+ }
1703
+ return null;
1704
+ }
1705
+ const u = `builder.tests.${e}`, m = c(u), h = t.map((f) => f.id).concat(e);
1706
+ if (m && h.includes(m))
1707
+ return m;
1708
+ let p = 0;
1709
+ const l = Math.random();
1710
+ for (let f = 0; f < t.length; f++) {
1711
+ const d = t[f], b = d.testRatio;
1712
+ if (p += b, l < p)
1713
+ return s(u, d.id), d.id;
1714
+ }
1715
+ return s(u, e), e;
1716
+ }
1717
+ const r = o(), i = (a = document.currentScript) == null ? void 0 : a.previousElementSibling;
1718
+ if (n) {
1719
+ i.remove();
1720
+ const s = document.currentScript;
1721
+ s == null || s.remove();
1722
+ } else {
1723
+ const s = t.concat({
1724
+ id: e
1725
+ }).filter((c) => c.id !== r).map((c) => `.variant-${c.id} { display: none; }
1726
+ `).join("");
1727
+ i.innerHTML = s;
1728
+ }
1617
1729
  }
1618
- `.trim()), e.files)
1619
- for (const a in e.files) {
1620
- if (!(String(Number(a)) === a))
1621
- continue;
1622
- const s = e.files[a];
1623
- s && s !== o && (r += `
1624
- @font-face {
1625
- font-family: "${t}";
1626
- src: url('${s}') format('woff2');
1627
- font-display: fallback;
1628
- font-weight: ${a};
1730
+ function bldrCntntScrpt(e, t, n) {
1731
+ var c;
1732
+ if (!navigator.cookieEnabled)
1733
+ return;
1734
+ function o(u) {
1735
+ const m = u + "=", h = document.cookie.split(";");
1736
+ for (let p = 0; p < h.length; p++) {
1737
+ let l = h[p];
1738
+ for (; l.charAt(0) === " "; )
1739
+ l = l.substring(1, l.length);
1740
+ if (l.indexOf(m) === 0)
1741
+ return l.substring(m.length, l.length);
1742
+ }
1743
+ return null;
1744
+ }
1745
+ const r = `builder.tests.${t}`, i = o(r), a = (c = document.currentScript) == null ? void 0 : c.parentElement, s = e === t;
1746
+ if (i === e) {
1747
+ if (s)
1748
+ return;
1749
+ a == null || a.removeAttribute("hidden"), a == null || a.removeAttribute("aria-hidden");
1750
+ } else {
1751
+ s && (n ? a == null || a.remove() : (a == null || a.setAttribute("hidden", "true"), a == null || a.setAttribute("aria-hidden", "true")));
1752
+ return;
1753
+ }
1629
1754
  }
1630
- `.trim());
1755
+ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydrationTarget = getIsHydrationTarget(TARGET), AB_TEST_FN_NAME = "builderIoAbTest", CONTENT_FN_NAME = "builderIoRenderContent", getScriptString = () => {
1756
+ const e = bldrAbTest.toString().replace(/\s+/g, " "), t = bldrCntntScrpt.toString().replace(/\s+/g, " ");
1757
+ return `
1758
+ window.${AB_TEST_FN_NAME} = ${e}
1759
+ window.${CONTENT_FN_NAME} = ${t}
1760
+ `;
1761
+ }, getVariantsScriptString = (e, t) => `
1762
+ window.${AB_TEST_FN_NAME}("${t}",${JSON.stringify(e)}, ${isHydrationTarget})`, getRenderContentScriptString = ({
1763
+ contentId: e,
1764
+ variationId: t
1765
+ }) => `
1766
+ window.${CONTENT_FN_NAME}("${t}", "${e}", ${isHydrationTarget})`;
1767
+ function InlinedScript(e) {
1768
+ return /* @__PURE__ */ jsx(
1769
+ "script",
1770
+ {
1771
+ dangerouslySetInnerHTML: { __html: e.scriptStr },
1772
+ id: e.id
1631
1773
  }
1632
- return r;
1633
- }, getFontCss = ({
1634
- customFonts: e
1635
- }) => {
1636
- var t;
1637
- return ((t = e == null ? void 0 : e.map((n) => getCssFromFont(n))) == null ? void 0 : t.join(" ")) || "";
1638
- }, getCss = ({
1639
- cssCode: e,
1640
- contentId: t
1641
- }) => e ? t ? (e == null ? void 0 : e.replace(/&/g, `div[builder-content-id="${t}"]`)) || "" : e : "";
1642
- function ContentStyles(e) {
1643
- const t = `
1644
- ${getCss({
1645
- cssCode: e.cssCode,
1646
- contentId: e.contentId
1647
- })}
1648
- ${getFontCss({
1649
- customFonts: e.customFonts
1650
- })}
1651
-
1652
- .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
1653
- margin: 0;
1774
+ );
1654
1775
  }
1655
- .builder-text > p, .builder-text > .builder-paragraph {
1656
- color: inherit;
1657
- line-height: inherit;
1658
- letter-spacing: inherit;
1659
- font-weight: inherit;
1660
- font-size: inherit;
1661
- text-align: inherit;
1662
- font-family: inherit;
1776
+ const getIdFromSearchParams = (e) => {
1777
+ const t = e.get("preview"), n = e.get("overrides." + t);
1778
+ return n || logger.warn("No previewed ID found in search params."), n;
1779
+ };
1780
+ function init() {
1781
+ globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
1782
+ max: 500,
1783
+ // how long to live in ms
1784
+ ttl: 1e3 * 60 * 5
1785
+ }));
1663
1786
  }
1664
- `.trim();
1665
- return /* @__PURE__ */ jsx(InlinedStyles, { styles: t });
1787
+ function getPreviewContent(e) {
1788
+ init();
1789
+ const t = getIdFromSearchParams(e);
1790
+ return typeof t == "string" ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(t) : void 0;
1666
1791
  }
1667
- const getContextStateInitialValue = ({
1668
- content: e,
1669
- data: t,
1670
- locale: n
1671
- }) => {
1672
- var i, a, c;
1673
- const o = {};
1674
- (a = (i = e == null ? void 0 : e.data) == null ? void 0 : i.inputs) == null || a.forEach((s) => {
1675
- var u;
1676
- s.name && s.defaultValue !== void 0 && ((u = e == null ? void 0 : e.data) != null && u.state) && e.data.state[s.name] === void 0 && (o[s.name] = s.defaultValue);
1677
- });
1678
- const r = {
1679
- ...(c = e == null ? void 0 : e.data) == null ? void 0 : c.state,
1680
- ...t,
1681
- ...n ? {
1682
- locale: n
1683
- } : {}
1684
- };
1685
- return {
1686
- ...o,
1687
- ...r
1688
- };
1689
- }, getContentInitialValue = ({
1690
- content: e,
1691
- data: t
1692
- }) => e ? {
1693
- ...e,
1694
- data: {
1695
- ...e == null ? void 0 : e.data,
1696
- ...t
1697
- },
1698
- meta: e == null ? void 0 : e.meta
1699
- } : void 0;
1700
1792
  function getGlobalThis() {
1701
1793
  return typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : globalThis;
1702
1794
  }
@@ -1707,48 +1799,140 @@ function getFetch() {
1707
1799
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
1708
1800
  return e;
1709
1801
  }
1710
- const fetch$1 = getFetch(), getTopLevelDomain = (e) => {
1711
- if (e === "localhost" || e === "127.0.0.1")
1712
- return e;
1713
- const t = e.split(".");
1714
- return t.length > 2 ? t.slice(1).join(".") : e;
1715
- }, getCookieSync = ({
1716
- name: e,
1717
- canTrack: t
1718
- }) => {
1719
- var n;
1720
- try {
1721
- return t ? (n = document.cookie.split("; ").find((o) => o.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
1722
- } catch (o) {
1723
- logger.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o);
1724
- return;
1802
+ const fetch$1 = getFetch();
1803
+ function flatten(e, t = null, n = ".") {
1804
+ return Object.keys(e).reduce((o, r) => {
1805
+ const i = e[r], a = [t, r].filter(Boolean).join(n);
1806
+ return [typeof i == "object", i !== null, !(Array.isArray(i) && i.length === 0)].every(Boolean) ? {
1807
+ ...o,
1808
+ ...flatten(i, a, n)
1809
+ } : {
1810
+ ...o,
1811
+ [a]: i
1812
+ };
1813
+ }, {});
1814
+ }
1815
+ const DEFAULT_API_VERSION = "v3", BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUILDER_OPTIONS_PREFIX = "options.", convertSearchParamsToQueryObject = (e) => {
1816
+ const t = {};
1817
+ return e.forEach((n, o) => {
1818
+ t[o] = n;
1819
+ }), t;
1820
+ }, getBuilderSearchParams = (e) => {
1821
+ if (!e)
1822
+ return {};
1823
+ const t = normalizeSearchParams(e), n = {};
1824
+ return Object.keys(t).forEach((o) => {
1825
+ if (o.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
1826
+ const r = o.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
1827
+ n[r] = t[o];
1828
+ }
1829
+ }), n;
1830
+ }, getBuilderSearchParamsFromWindow = () => {
1831
+ if (!isBrowser())
1832
+ return {};
1833
+ const e = new URLSearchParams(window.location.search);
1834
+ return getBuilderSearchParams(e);
1835
+ }, normalizeSearchParams = (e) => e instanceof URLSearchParams ? convertSearchParamsToQueryObject(e) : e, isPositiveNumber = (e) => typeof e == "number" && !isNaN(e) && e >= 0, generateContentUrl = (e) => {
1836
+ let {
1837
+ noTraverse: t = !1
1838
+ } = e;
1839
+ const {
1840
+ limit: n = 30,
1841
+ userAttributes: o,
1842
+ query: r,
1843
+ model: i,
1844
+ apiKey: a,
1845
+ includeRefs: s = !0,
1846
+ enrich: c,
1847
+ locale: u,
1848
+ apiVersion: m = DEFAULT_API_VERSION,
1849
+ fields: h,
1850
+ omit: p,
1851
+ offset: l,
1852
+ cacheSeconds: f,
1853
+ staleCacheSeconds: d,
1854
+ sort: b,
1855
+ includeUnpublished: y
1856
+ } = e;
1857
+ if (!a)
1858
+ throw new Error("Missing API key");
1859
+ if (!["v2", "v3"].includes(m))
1860
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${m}'`);
1861
+ (e.limit === void 0 || e.limit > 1) && !("noTraverse" in e) && (t = !0);
1862
+ const g = new URL(`https://cdn.builder.io/api/${m}/content/${i}?apiKey=${a}&limit=${n}&noTraverse=${t}&includeRefs=${s}${u ? `&locale=${u}` : ""}${c ? `&enrich=${c}` : ""}`);
1863
+ if (g.searchParams.set("omit", p || "meta.componentsUsed"), h && g.searchParams.set("fields", h), Number.isFinite(l) && l > -1 && g.searchParams.set("offset", String(Math.floor(l))), typeof y == "boolean" && g.searchParams.set("includeUnpublished", String(y)), f && isPositiveNumber(f) && g.searchParams.set("cacheSeconds", String(f)), d && isPositiveNumber(d) && g.searchParams.set("staleCacheSeconds", String(d)), b) {
1864
+ const S = flatten({
1865
+ sort: b
1866
+ });
1867
+ for (const C in S)
1868
+ g.searchParams.set(C, JSON.stringify(S[C]));
1725
1869
  }
1726
- }, getCookie = async (e) => getCookieSync(e), stringifyCookie = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(checkIsDefined).join("; "), SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]], createCookieString = ({
1727
- name: e,
1728
- value: t,
1729
- expires: n
1730
- }) => {
1731
- const r = (isBrowser() ? location.protocol === "https:" : !0) ? SECURE_CONFIG : [[]], i = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...i, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...r];
1732
- return stringifyCookie(a);
1733
- }, setCookie = async ({
1734
- name: e,
1735
- value: t,
1736
- expires: n,
1737
- canTrack: o
1738
- }) => {
1739
- try {
1740
- if (!o)
1741
- return;
1742
- const r = createCookieString({
1743
- name: e,
1744
- value: t,
1745
- expires: n
1870
+ const k = {
1871
+ ...getBuilderSearchParamsFromWindow(),
1872
+ ...normalizeSearchParams(e.options || {})
1873
+ }, x = flatten(k);
1874
+ for (const S in x)
1875
+ g.searchParams.set(S, String(x[S]));
1876
+ if (o && g.searchParams.set("userAttributes", JSON.stringify(o)), r) {
1877
+ const S = flatten({
1878
+ query: r
1746
1879
  });
1747
- document.cookie = r;
1748
- } catch (r) {
1749
- logger.warn("[COOKIE] SET error: ", (r == null ? void 0 : r.message) || r);
1880
+ for (const C in S)
1881
+ g.searchParams.set(C, JSON.stringify(S[C]));
1882
+ }
1883
+ return g;
1884
+ }, checkContentHasResults = (e) => "results" in e;
1885
+ async function fetchOneEntry(e) {
1886
+ const t = await fetchEntries({
1887
+ ...e,
1888
+ limit: 1
1889
+ });
1890
+ return t && t.results[0] || null;
1891
+ }
1892
+ const getContent = fetchOneEntry, _fetchContent = async (e) => {
1893
+ const t = generateContentUrl(e);
1894
+ return await (await fetch$1(t.href)).json();
1895
+ }, _processContentResult = async (e, t, n = generateContentUrl(e)) => {
1896
+ const o = getDefaultCanTrack(e.canTrack);
1897
+ if (n.search.includes("preview=")) {
1898
+ const i = [];
1899
+ for (const a of t.results) {
1900
+ const s = getPreviewContent(n.searchParams);
1901
+ i.push(s || a);
1902
+ }
1903
+ t.results = i;
1904
+ }
1905
+ if (!o || !(isBrowser() || TARGET === "reactNative"))
1906
+ return t;
1907
+ try {
1908
+ const i = [];
1909
+ for (const a of t.results)
1910
+ i.push(await handleABTesting({
1911
+ item: a,
1912
+ canTrack: o
1913
+ }));
1914
+ t.results = i;
1915
+ } catch (i) {
1916
+ logger.error("Could not process A/B tests. ", i);
1750
1917
  }
1918
+ return t;
1751
1919
  };
1920
+ async function fetchEntries(e) {
1921
+ try {
1922
+ const t = generateContentUrl(e), n = await _fetchContent(e);
1923
+ return checkContentHasResults(n) ? _processContentResult(e, n) : (logger.error("Error fetching data. ", {
1924
+ url: t,
1925
+ content: n,
1926
+ options: e
1927
+ }), null);
1928
+ } catch (t) {
1929
+ return logger.error("Error fetching data. ", t), null;
1930
+ }
1931
+ }
1932
+ const getAllContent = fetchEntries;
1933
+ function isPreviewing() {
1934
+ return !isBrowser() || isEditing() ? !1 : location.search.indexOf("builder.preview=") !== -1;
1935
+ }
1752
1936
  function uuidv4() {
1753
1937
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
1754
1938
  const t = Math.random() * 16 | 0;
@@ -1890,7 +2074,50 @@ async function _track(e) {
1890
2074
  const track = (e) => _track({
1891
2075
  ...e,
1892
2076
  canTrack: !0
1893
- }), SDK_VERSION = "0.7.1-4", registry = {};
2077
+ });
2078
+ function round(e) {
2079
+ return Math.round(e * 1e3) / 1e3;
2080
+ }
2081
+ const findParentElement = (e, t, n = !0) => {
2082
+ if (!(e instanceof HTMLElement))
2083
+ return null;
2084
+ let o = n ? e : e.parentElement;
2085
+ do {
2086
+ if (!o)
2087
+ return null;
2088
+ if (t(o))
2089
+ return o;
2090
+ } while (o = o.parentElement);
2091
+ return null;
2092
+ }, findBuilderParent = (e) => findParentElement(e, (t) => {
2093
+ const n = t.getAttribute("builder-id") || t.id;
2094
+ return (n == null ? void 0 : n.indexOf("builder-")) === 0;
2095
+ }), computeOffset = ({
2096
+ event: e,
2097
+ target: t
2098
+ }) => {
2099
+ const n = t.getBoundingClientRect(), o = e.clientX - n.left, r = e.clientY - n.top, i = round(o / n.width), a = round(r / n.height);
2100
+ return {
2101
+ x: i,
2102
+ y: a
2103
+ };
2104
+ }, getInteractionPropertiesForEvent = (e) => {
2105
+ const t = e.target, n = t && findBuilderParent(t), o = (n == null ? void 0 : n.getAttribute("builder-id")) || (n == null ? void 0 : n.id);
2106
+ return {
2107
+ targetBuilderElement: o || void 0,
2108
+ metadata: {
2109
+ targetOffset: t ? computeOffset({
2110
+ event: e,
2111
+ target: t
2112
+ }) : void 0,
2113
+ builderTargetOffset: n ? computeOffset({
2114
+ event: e,
2115
+ target: n
2116
+ }) : void 0,
2117
+ builderElementIndex: n && o ? [].slice.call(document.getElementsByClassName(o)).indexOf(n) : void 0
2118
+ }
2119
+ };
2120
+ }, SDK_VERSION = "0.7.2", registry = {};
1894
2121
  function register(e, t) {
1895
2122
  let n = registry[e];
1896
2123
  if (n || (n = registry[e] = []), n.push(t), isBrowser()) {
@@ -1957,17 +2184,17 @@ const setupBrowserForEditing = (e = {}) => {
1957
2184
  if (o != null && o.type)
1958
2185
  switch (o.type) {
1959
2186
  case "builder.evaluate": {
1960
- const a = o.data.text, c = o.data.arguments || [], s = o.data.id, u = new Function(a);
2187
+ const a = o.data.text, s = o.data.arguments || [], c = o.data.id, u = new Function(a);
1961
2188
  let m, h = null;
1962
2189
  try {
1963
- m = u.apply(null, c);
2190
+ m = u.apply(null, s);
1964
2191
  } catch (p) {
1965
2192
  h = p;
1966
2193
  }
1967
2194
  h ? (r = window.parent) == null || r.postMessage({
1968
2195
  type: "builder.evaluateError",
1969
2196
  data: {
1970
- id: s,
2197
+ id: c,
1971
2198
  error: h.message
1972
2199
  }
1973
2200
  }, "*") : m && typeof m.then == "function" ? m.then((p) => {
@@ -1975,7 +2202,7 @@ const setupBrowserForEditing = (e = {}) => {
1975
2202
  (l = window.parent) == null || l.postMessage({
1976
2203
  type: "builder.evaluateResult",
1977
2204
  data: {
1978
- id: s,
2205
+ id: c,
1979
2206
  result: p
1980
2207
  }
1981
2208
  }, "*");
@@ -1983,310 +2210,108 @@ const setupBrowserForEditing = (e = {}) => {
1983
2210
  type: "builder.evaluateResult",
1984
2211
  data: {
1985
2212
  result: m,
1986
- id: s
2213
+ id: c
1987
2214
  }
1988
2215
  }, "*");
1989
2216
  break;
1990
2217
  }
1991
2218
  }
1992
2219
  })));
1993
- };
1994
- function round(e) {
1995
- return Math.round(e * 1e3) / 1e3;
2220
+ }, getCssFromFont = (e) => {
2221
+ var i;
2222
+ const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], o = e.fileUrl ?? ((i = e == null ? void 0 : e.files) == null ? void 0 : i.regular);
2223
+ let r = "";
2224
+ if (o && t && n && (r += `
2225
+ @font-face {
2226
+ font-family: "${t}";
2227
+ src: local("${n}"), url('${o}') format('woff2');
2228
+ font-display: fallback;
2229
+ font-weight: 400;
1996
2230
  }
1997
- const findParentElement = (e, t, n = !0) => {
1998
- if (!(e instanceof HTMLElement))
1999
- return null;
2000
- let o = n ? e : e.parentElement;
2001
- do {
2002
- if (!o)
2003
- return null;
2004
- if (t(o))
2005
- return o;
2006
- } while (o = o.parentElement);
2007
- return null;
2008
- }, findBuilderParent = (e) => findParentElement(e, (t) => {
2009
- const n = t.getAttribute("builder-id") || t.id;
2010
- return (n == null ? void 0 : n.indexOf("builder-")) === 0;
2011
- }), computeOffset = ({
2012
- event: e,
2013
- target: t
2014
- }) => {
2015
- const n = t.getBoundingClientRect(), o = e.clientX - n.left, r = e.clientY - n.top, i = round(o / n.width), a = round(r / n.height);
2016
- return {
2017
- x: i,
2018
- y: a
2019
- };
2020
- }, getInteractionPropertiesForEvent = (e) => {
2021
- const t = e.target, n = t && findBuilderParent(t), o = (n == null ? void 0 : n.getAttribute("builder-id")) || (n == null ? void 0 : n.id);
2022
- return {
2023
- targetBuilderElement: o || void 0,
2024
- metadata: {
2025
- targetOffset: t ? computeOffset({
2026
- event: e,
2027
- target: t
2028
- }) : void 0,
2029
- builderTargetOffset: n ? computeOffset({
2030
- event: e,
2031
- target: n
2032
- }) : void 0,
2033
- builderElementIndex: n && o ? [].slice.call(document.getElementsByClassName(o)).indexOf(n) : void 0
2231
+ `.trim()), e.files)
2232
+ for (const a in e.files) {
2233
+ if (!(String(Number(a)) === a))
2234
+ continue;
2235
+ const c = e.files[a];
2236
+ c && c !== o && (r += `
2237
+ @font-face {
2238
+ font-family: "${t}";
2239
+ src: url('${c}') format('woff2');
2240
+ font-display: fallback;
2241
+ font-weight: ${a};
2242
+ }
2243
+ `.trim());
2034
2244
  }
2035
- };
2036
- }, BUILDER_STORE_PREFIX = "builder.tests", getContentTestKey = (e) => `${BUILDER_STORE_PREFIX}.${e}`, getContentVariationCookie = ({
2037
- contentId: e
2038
- }) => getCookie({
2039
- name: getContentTestKey(e),
2040
- canTrack: !0
2041
- }), getContentVariationCookieSync = ({
2042
- contentId: e
2043
- }) => getCookieSync({
2044
- name: getContentTestKey(e),
2045
- canTrack: !0
2046
- }), setContentVariationCookie = ({
2047
- contentId: e,
2048
- value: t
2049
- }) => setCookie({
2050
- name: getContentTestKey(e),
2051
- value: t,
2052
- canTrack: !0
2053
- }), checkIsBuilderContentWithVariations = (e) => checkIsDefined(e.id) && checkIsDefined(e.variations) && Object.keys(e.variations).length > 0, getRandomVariationId = ({
2054
- id: e,
2055
- variations: t
2056
- }) => {
2057
- var r;
2058
- let n = 0;
2059
- const o = Math.random();
2060
- for (const i in t) {
2061
- const a = (r = t[i]) == null ? void 0 : r.testRatio;
2062
- if (n += a, o < n)
2063
- return i;
2064
- }
2065
- return e;
2066
- }, getAndSetVariantId = (e) => {
2067
- const t = getRandomVariationId(e);
2068
- return setContentVariationCookie({
2069
- contentId: e.id,
2070
- value: t
2071
- }).catch((n) => {
2072
- logger.error("could not store A/B test variation: ", n);
2073
- }), t;
2074
- }, getTestFields = ({
2075
- item: e,
2076
- testGroupId: t
2245
+ return r;
2246
+ }, getFontCss = ({
2247
+ customFonts: e
2077
2248
  }) => {
2078
- const n = e.variations[t];
2079
- return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
2080
- !n ? {
2081
- testVariationId: e.id,
2082
- testVariationName: "Default"
2083
- } : {
2084
- data: n.data,
2085
- testVariationId: n.id,
2086
- testVariationName: n.name || (n.id === e.id ? "Default" : "")
2087
- };
2088
- }, handleABTestingSync = ({
2089
- item: e,
2090
- canTrack: t
2249
+ var t;
2250
+ return ((t = e == null ? void 0 : e.map((n) => getCssFromFont(n))) == null ? void 0 : t.join(" ")) || "";
2251
+ }, getCss = ({
2252
+ cssCode: e,
2253
+ contentId: t
2254
+ }) => e ? t ? (e == null ? void 0 : e.replace(/&/g, `div[builder-content-id="${t}"]`)) || "" : e : "";
2255
+ function ContentStyles(e) {
2256
+ const t = `
2257
+ ${getCss({
2258
+ cssCode: e.cssCode,
2259
+ contentId: e.contentId
2260
+ })}
2261
+ ${getFontCss({
2262
+ customFonts: e.customFonts
2263
+ })}
2264
+
2265
+ .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
2266
+ margin: 0;
2267
+ }
2268
+ .builder-text > p, .builder-text > .builder-paragraph {
2269
+ color: inherit;
2270
+ line-height: inherit;
2271
+ letter-spacing: inherit;
2272
+ font-weight: inherit;
2273
+ font-size: inherit;
2274
+ text-align: inherit;
2275
+ font-family: inherit;
2276
+ }
2277
+ `.trim();
2278
+ return /* @__PURE__ */ jsx(InlinedStyles, { styles: t });
2279
+ }
2280
+ const getContextStateInitialValue = ({
2281
+ content: e,
2282
+ data: t,
2283
+ locale: n
2091
2284
  }) => {
2092
- if (!t)
2093
- return e;
2094
- if (!e)
2095
- return;
2096
- if (!checkIsBuilderContentWithVariations(e))
2097
- return e;
2098
- const n = getContentVariationCookieSync({
2099
- contentId: e.id
2100
- }) || getAndSetVariantId({
2101
- variations: e.variations,
2102
- id: e.id
2103
- }), o = getTestFields({
2104
- item: e,
2105
- testGroupId: n
2285
+ var i, a, s;
2286
+ const o = {};
2287
+ (a = (i = e == null ? void 0 : e.data) == null ? void 0 : i.inputs) == null || a.forEach((c) => {
2288
+ var u;
2289
+ c.name && c.defaultValue !== void 0 && ((u = e == null ? void 0 : e.data) != null && u.state) && e.data.state[c.name] === void 0 && (o[c.name] = c.defaultValue);
2106
2290
  });
2107
- return {
2108
- ...e,
2109
- ...o
2291
+ const r = {
2292
+ ...(s = e == null ? void 0 : e.data) == null ? void 0 : s.state,
2293
+ ...t,
2294
+ ...n ? {
2295
+ locale: n
2296
+ } : {}
2110
2297
  };
2111
- }, handleABTesting = async ({
2112
- item: e,
2113
- canTrack: t
2114
- }) => {
2115
- if (!t || !checkIsBuilderContentWithVariations(e))
2116
- return e;
2117
- const o = await getContentVariationCookie({
2118
- contentId: e.id
2119
- }) || getAndSetVariantId({
2120
- variations: e.variations,
2121
- id: e.id
2122
- }), r = getTestFields({
2123
- item: e,
2124
- testGroupId: o
2125
- });
2126
2298
  return {
2127
- ...e,
2299
+ ...o,
2128
2300
  ...r
2129
2301
  };
2130
- }, getDefaultCanTrack = (e) => checkIsDefined(e) ? e : !0, getIdFromSearchParams = (e) => {
2131
- const t = e.get("preview"), n = e.get("overrides." + t);
2132
- return n || logger.warn("No previewed ID found in search params."), n;
2133
- };
2134
- function init() {
2135
- globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
2136
- max: 500,
2137
- // how long to live in ms
2138
- ttl: 1e3 * 60 * 5
2139
- }));
2140
- }
2141
- function getPreviewContent(e) {
2142
- init();
2143
- const t = getIdFromSearchParams(e);
2144
- return typeof t == "string" ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(t) : void 0;
2145
- }
2146
- function flatten(e, t = null, n = ".") {
2147
- return Object.keys(e).reduce((o, r) => {
2148
- const i = e[r], a = [t, r].filter(Boolean).join(n);
2149
- return [typeof i == "object", i !== null, !(Array.isArray(i) && i.length === 0)].every(Boolean) ? {
2150
- ...o,
2151
- ...flatten(i, a, n)
2152
- } : {
2153
- ...o,
2154
- [a]: i
2155
- };
2156
- }, {});
2157
- }
2158
- const BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUILDER_OPTIONS_PREFIX = "options.", convertSearchParamsToQueryObject = (e) => {
2159
- const t = {};
2160
- return e.forEach((n, o) => {
2161
- t[o] = n;
2162
- }), t;
2163
- }, getBuilderSearchParams = (e) => {
2164
- if (!e)
2165
- return {};
2166
- const t = normalizeSearchParams(e), n = {};
2167
- return Object.keys(t).forEach((o) => {
2168
- if (o.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2169
- const r = o.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
2170
- n[r] = t[o];
2171
- }
2172
- }), n;
2173
- }, getBuilderSearchParamsFromWindow = () => {
2174
- if (!isBrowser())
2175
- return {};
2176
- const e = new URLSearchParams(window.location.search);
2177
- return getBuilderSearchParams(e);
2178
- }, normalizeSearchParams = (e) => e instanceof URLSearchParams ? convertSearchParamsToQueryObject(e) : e, DEFAULT_API_VERSION = "v3", isPositiveNumber = (e) => typeof e == "number" && !isNaN(e) && e >= 0, generateContentUrl = (e) => {
2179
- let {
2180
- noTraverse: t = !1
2181
- } = e;
2182
- const {
2183
- limit: n = 30,
2184
- userAttributes: o,
2185
- query: r,
2186
- model: i,
2187
- apiKey: a,
2188
- includeRefs: c = !0,
2189
- enrich: s,
2190
- locale: u,
2191
- apiVersion: m = DEFAULT_API_VERSION,
2192
- fields: h,
2193
- omit: p,
2194
- offset: l,
2195
- cacheSeconds: f,
2196
- staleCacheSeconds: d,
2197
- sort: b,
2198
- includeUnpublished: y
2199
- } = e;
2200
- if (!a)
2201
- throw new Error("Missing API key");
2202
- if (!["v2", "v3"].includes(m))
2203
- throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${m}'`);
2204
- (e.limit === void 0 || e.limit > 1) && !("noTraverse" in e) && (t = !0);
2205
- const g = new URL(`https://cdn.builder.io/api/${m}/content/${i}?apiKey=${a}&limit=${n}&noTraverse=${t}&includeRefs=${c}${u ? `&locale=${u}` : ""}${s ? `&enrich=${s}` : ""}`);
2206
- if (g.searchParams.set("omit", p || "meta.componentsUsed"), h && g.searchParams.set("fields", h), Number.isFinite(l) && l > -1 && g.searchParams.set("offset", String(Math.floor(l))), typeof y == "boolean" && g.searchParams.set("includeUnpublished", String(y)), f && isPositiveNumber(f) && g.searchParams.set("cacheSeconds", String(f)), d && isPositiveNumber(d) && g.searchParams.set("staleCacheSeconds", String(d)), b) {
2207
- const S = flatten({
2208
- sort: b
2209
- });
2210
- for (const C in S)
2211
- g.searchParams.set(C, JSON.stringify(S[C]));
2212
- }
2213
- const v = {
2214
- ...getBuilderSearchParamsFromWindow(),
2215
- ...normalizeSearchParams(e.options || {})
2216
- }, x = flatten(v);
2217
- for (const S in x)
2218
- g.searchParams.set(S, String(x[S]));
2219
- if (o && g.searchParams.set("userAttributes", JSON.stringify(o)), r) {
2220
- const S = flatten({
2221
- query: r
2222
- });
2223
- for (const C in S)
2224
- g.searchParams.set(C, JSON.stringify(S[C]));
2225
- }
2226
- return g;
2227
- }, checkContentHasResults = (e) => "results" in e;
2228
- async function fetchOneEntry(e) {
2229
- const t = await fetchEntries({
2230
- ...e,
2231
- limit: 1
2232
- });
2233
- return t && t.results[0] || null;
2234
- }
2235
- const getContent = fetchOneEntry, _fetchContent = async (e) => {
2236
- const t = generateContentUrl(e);
2237
- return await (await fetch$1(t.href)).json();
2238
- }, _processContentResult = async (e, t, n = generateContentUrl(e)) => {
2239
- const o = getDefaultCanTrack(e.canTrack);
2240
- if (n.search.includes("preview=")) {
2241
- const i = [];
2242
- for (const a of t.results) {
2243
- const c = getPreviewContent(n.searchParams);
2244
- i.push(c || a);
2245
- }
2246
- t.results = i;
2247
- }
2248
- if (!o || !(isBrowser() || TARGET === "reactNative"))
2249
- return t;
2250
- try {
2251
- const i = [];
2252
- for (const a of t.results)
2253
- i.push(await handleABTesting({
2254
- item: a,
2255
- canTrack: o
2256
- }));
2257
- t.results = i;
2258
- } catch (i) {
2259
- logger.error("Could not process A/B tests. ", i);
2260
- }
2261
- return t;
2262
- };
2263
- async function fetchEntries(e) {
2264
- try {
2265
- const t = generateContentUrl(e), n = await _fetchContent(e);
2266
- return checkContentHasResults(n) ? _processContentResult(e, n) : (logger.error("Error fetching data. ", {
2267
- url: t,
2268
- content: n,
2269
- options: e
2270
- }), null);
2271
- } catch (t) {
2272
- return logger.error("Error fetching data. ", t), null;
2273
- }
2274
- }
2275
- const getAllContent = fetchEntries;
2276
- function isPreviewing() {
2277
- return !isBrowser() || isEditing() ? !1 : location.search.indexOf("builder.preview=") !== -1;
2278
- }
2279
- function InlinedScript(e) {
2280
- return /* @__PURE__ */ jsx(
2281
- "script",
2282
- {
2283
- dangerouslySetInnerHTML: { __html: e.scriptStr },
2284
- id: e.id
2285
- }
2286
- );
2287
- }
2302
+ }, getContentInitialValue = ({
2303
+ content: e,
2304
+ data: t
2305
+ }) => e ? {
2306
+ ...e,
2307
+ data: {
2308
+ ...e == null ? void 0 : e.data,
2309
+ ...t
2310
+ },
2311
+ meta: e == null ? void 0 : e.meta
2312
+ } : void 0;
2288
2313
  function ContentComponent(e) {
2289
- var r, i, a, c, s, u, m, h, p;
2314
+ var r, i, a, s, c, u, m, h, p;
2290
2315
  const t = getRenderContentScriptString({
2291
2316
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2292
2317
  variationId: (r = e.content) == null ? void 0 : r.testVariationId,
@@ -2363,7 +2388,7 @@ function ContentComponent(e) {
2363
2388
  ContentStyles,
2364
2389
  {
2365
2390
  contentId: (a = o.content) == null ? void 0 : a.id,
2366
- cssCode: (s = (c = o.content) == null ? void 0 : c.data) == null ? void 0 : s.cssCode,
2391
+ cssCode: (c = (s = o.content) == null ? void 0 : s.data) == null ? void 0 : c.cssCode,
2367
2392
  customFonts: (m = (u = o.content) == null ? void 0 : u.data) == null ? void 0 : m.customFonts
2368
2393
  }
2369
2394
  ) }),
@@ -2380,7 +2405,7 @@ function ContentComponent(e) {
2380
2405
  );
2381
2406
  }
2382
2407
  function ContentVariants(e) {
2383
- var i, a, c;
2408
+ var i, a, s;
2384
2409
  const t = checkShouldRunVariants({
2385
2410
  canTrack: getDefaultCanTrack(e.canTrack),
2386
2411
  content: e.content
@@ -2416,10 +2441,10 @@ function ContentVariants(e) {
2416
2441
  }
2417
2442
  ),
2418
2443
  /* @__PURE__ */ jsx(InlinedScript, { scriptStr: n() }),
2419
- (a = getVariants(e.content)) == null ? void 0 : a.map((s) => /* @__PURE__ */ jsx(
2444
+ (a = getVariants(e.content)) == null ? void 0 : a.map((c) => /* @__PURE__ */ jsx(
2420
2445
  ContentComponent,
2421
2446
  {
2422
- content: s,
2447
+ content: c,
2423
2448
  showContent: !1,
2424
2449
  classNameProp: void 0,
2425
2450
  model: e.model,
@@ -2434,14 +2459,14 @@ function ContentVariants(e) {
2434
2459
  enrich: e.enrich,
2435
2460
  isSsrAbTest: t
2436
2461
  },
2437
- s.testVariationId
2462
+ c.testVariationId
2438
2463
  ))
2439
2464
  ] }) : null,
2440
2465
  /* @__PURE__ */ jsx(
2441
2466
  ContentComponent,
2442
2467
  {
2443
2468
  content: r(),
2444
- classNameProp: `variant-${(c = e.content) == null ? void 0 : c.id}`,
2469
+ classNameProp: `variant-${(s = e.content) == null ? void 0 : s.id}`,
2445
2470
  showContent: !0,
2446
2471
  model: e.model,
2447
2472
  data: e.data,
@@ -2480,11 +2505,11 @@ const fetchSymbolContent = async ({
2480
2505
  async function Symbol$1(e) {
2481
2506
  var o, r, i, a;
2482
2507
  const t = function() {
2483
- var s, u;
2508
+ var c, u;
2484
2509
  return [
2485
2510
  e.attributes.className,
2486
2511
  "builder-symbol",
2487
- (s = e.symbol) != null && s.inline ? "builder-inline-symbol" : void 0,
2512
+ (c = e.symbol) != null && c.inline ? "builder-inline-symbol" : void 0,
2488
2513
  (u = e.symbol) != null && u.dynamic || e.dynamic ? "builder-dynamic-symbol" : void 0
2489
2514
  ].filter(Boolean).join(" ");
2490
2515
  }, n = ((o = e.symbol) == null ? void 0 : o.content) || await fetchSymbolContent({
@@ -2572,8 +2597,8 @@ export {
2572
2597
  Columns as t,
2573
2598
  register as u,
2574
2599
  setEditorSettings as v,
2575
- fetchEntries as w,
2576
- getAllContent as x,
2577
- getContent as y,
2578
- _processContentResult as z
2600
+ _processContentResult as w,
2601
+ fetchEntries as x,
2602
+ getAllContent as y,
2603
+ getContent as z
2579
2604
  };