camox 0.44.0 → 0.45.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.
Files changed (411) hide show
  1. package/dist/components/AuthGate.js +0 -6
  2. package/dist/components/DeviceSelector.js +96 -0
  3. package/dist/components/PlatformLabel.js +20 -24
  4. package/dist/core/components/lexical/HighlightNode.js +1 -1
  5. package/dist/core/components/lexical/InlineContentEditable.js +15 -19
  6. package/dist/core/components/lexical/InlineLexicalEditor.js +54 -74
  7. package/dist/core/components/lexical/InlineStylesPlugin.js +53 -53
  8. package/dist/core/components/lexical/MaxLengthPlugin.js +59 -0
  9. package/dist/core/components/lexical/SelectionBroadcaster.js +53 -54
  10. package/dist/core/components/lexical/SidebarLexicalEditor.js +322 -229
  11. package/dist/core/components/lexical/SummaryToggleGuard.js +42 -0
  12. package/dist/core/components/lexical/TextLinkPopover.js +169 -180
  13. package/dist/core/createApp.d.ts +241 -312
  14. package/dist/core/createApp.js +123 -29
  15. package/dist/core/createBlock.d.ts +5 -5
  16. package/dist/core/createBlock.js +385 -152
  17. package/dist/core/createCollection.d.ts +55 -0
  18. package/dist/core/createCollection.js +93 -0
  19. package/dist/core/createLayout.d.ts +197 -61
  20. package/dist/core/createLayout.js +114 -56
  21. package/dist/core/defineDocument.d.ts +3 -5
  22. package/dist/core/derivedRoutes.js +49 -1
  23. package/dist/core/dom.d.ts +13 -4
  24. package/dist/core/dom.js +44 -1
  25. package/dist/core/editing/BlockEditingRuntime.d.ts +16 -0
  26. package/dist/core/editing/BlockEditingRuntime.js +6 -15
  27. package/dist/core/editing/CompleteBlockEditingRuntime.js +28 -23
  28. package/dist/core/editing/createEditableBlock.d.ts +754 -633
  29. package/dist/core/editing/createEditableBlock.js +2113 -1066
  30. package/dist/core/editing/referenceWrites.js +51 -0
  31. package/dist/core/editing/useLatestRecord.js +90 -0
  32. package/dist/core/hooks/useArtifactHost.js +139 -0
  33. package/dist/core/hooks/useFieldSelection.js +43 -18
  34. package/dist/core/hooks/useIsEditable.js +12 -10
  35. package/dist/core/hooks/useOverlayMessage.js +15 -19
  36. package/dist/core/lib/artifact.d.ts +21 -0
  37. package/dist/core/lib/artifact.js +154 -0
  38. package/dist/core/lib/artifactColors.js +123 -0
  39. package/dist/core/lib/artifactData.d.ts +1 -0
  40. package/dist/core/lib/artifactData.js +131 -0
  41. package/dist/core/lib/artifactHost.js +205 -0
  42. package/dist/core/lib/artifactRuntime.js +36 -0
  43. package/dist/core/lib/artifactTheme.js +57 -0
  44. package/dist/core/lib/contentType.d.ts +302 -106
  45. package/dist/core/lib/contentType.js +201 -173
  46. package/dist/core/lib/fieldTypes.js +3 -0
  47. package/dist/core/lib/iconTypes.d.ts +3 -3
  48. package/dist/core/lib/icons.d.ts +4 -4
  49. package/dist/core/lib/icons.js +40 -44
  50. package/dist/core/lib/imagePlaceholder.js +177 -0
  51. package/dist/core/lib/imageTransform.js +1 -1
  52. package/dist/core/lib/lexicalReact.d.ts +3 -1
  53. package/dist/core/lib/lexicalState.js +1 -1
  54. package/dist/core/lib/previewPaused.js +9 -0
  55. package/dist/core/lib/recordScope.js +316 -0
  56. package/dist/core/lib/reference.d.ts +81 -0
  57. package/dist/core/lib/reference.js +29 -0
  58. package/dist/core/lib/textLinks.js +7 -5
  59. package/dist/core/lib/textStyles.d.ts +5 -7
  60. package/dist/core/lib/textStyles.js +2 -2
  61. package/dist/core/notFound.d.ts +7 -0
  62. package/dist/core/notFound.js +11 -0
  63. package/dist/core/pageDestinations.js +6 -3
  64. package/dist/core/recordItem.js +34 -0
  65. package/dist/core/requestContext.d.ts +26 -0
  66. package/dist/core/requestContext.js +20 -0
  67. package/dist/features/canvas/CamoxCanvas.js +1734 -0
  68. package/dist/features/canvas/CanvasBlockFrame.js +353 -0
  69. package/dist/features/canvas/CanvasBlockHeader.js +55 -0
  70. package/dist/features/canvas/CanvasLoadingScreen.js +35 -0
  71. package/dist/features/canvas/CanvasOverlays.js +254 -0
  72. package/dist/features/canvas/CanvasPageEdge.js +87 -0
  73. package/dist/features/canvas/CanvasPageFrame.js +335 -0
  74. package/dist/features/canvas/CanvasPageHeader.js +125 -0
  75. package/dist/features/canvas/CanvasPreviewPageSlot.js +103 -0
  76. package/dist/features/canvas/CanvasShelfMarker.js +255 -0
  77. package/dist/features/canvas/DerivedPagePathInput.js +238 -0
  78. package/dist/features/canvas/canvasCamera.js +229 -0
  79. package/dist/features/canvas/canvasFlight.js +104 -0
  80. package/dist/features/canvas/canvasFrameCapture.js +364 -0
  81. package/dist/features/canvas/canvasFrameDocument.js +317 -0
  82. package/dist/features/canvas/canvasFrameMode.js +53 -0
  83. package/dist/features/canvas/canvasInsertionSeams.js +44 -0
  84. package/dist/features/canvas/canvasItems.js +120 -0
  85. package/dist/features/canvas/canvasOverlayGeometry.js +240 -0
  86. package/dist/features/canvas/canvasPages.js +79 -0
  87. package/dist/features/canvas/canvasScreenSpace.js +26 -0
  88. package/dist/features/canvas/canvasSelection.js +18 -0
  89. package/dist/features/canvas/canvasStore.js +149 -0
  90. package/dist/features/canvas/canvasThumbnails.js +304 -0
  91. package/dist/features/canvas/canvasZoom.js +10 -0
  92. package/dist/features/canvas/sidebar/CanvasInspector.js +202 -0
  93. package/dist/features/canvas/sidebar/CanvasNavigator.js +226 -0
  94. package/dist/features/canvas/sidebar/CanvasSidebar.js +60 -0
  95. package/dist/features/canvas/sidebar/CanvasSidebarFrame.js +48 -0
  96. package/dist/features/canvas/sidebar/CanvasSidebarSkeleton.js +39 -0
  97. package/dist/features/canvas/sidebar/CatalogBlockInspector.js +189 -0
  98. package/dist/features/canvas/sidebar/CuratedPageInspector.js +69 -0
  99. package/dist/features/canvas/sidebar/DerivedPageInspector.js +37 -0
  100. package/dist/features/canvas/sidebar/LayoutPageBlocks.js +78 -0
  101. package/dist/features/canvas/sidebar/LayoutPageOverview.js +71 -0
  102. package/dist/features/canvas/sidebar/PageInspector.js +157 -0
  103. package/dist/features/canvas/sidebar/PageInspectorSkeleton.js +90 -0
  104. package/dist/features/canvas/sidebar/PageOverview.js +27 -0
  105. package/dist/features/canvas/sidebar/SingletonPageInspector.js +31 -0
  106. package/dist/features/canvas/useCanvasCamera.js +803 -0
  107. package/dist/features/canvas/useCanvasFrame.js +149 -0
  108. package/dist/features/canvas/useCanvasFrameInput.js +97 -0
  109. package/dist/features/canvas/useCanvasNearness.js +57 -0
  110. package/dist/features/canvas/useDiscoveredPreviewPaths.js +62 -0
  111. package/dist/features/content/CamoxContent.d.ts +2 -5
  112. package/dist/features/content/CamoxContent.js +174 -271
  113. package/dist/features/content/CollectionItemSheetContext.js +106 -0
  114. package/dist/features/content/ContentAssets.js +315 -0
  115. package/dist/features/content/ContentCollection.js +663 -0
  116. package/dist/features/content/collection-form.js +58 -0
  117. package/dist/features/content/components/AssetCard.js +80 -84
  118. package/dist/features/content/components/AssetCardSkeleton.js +4 -8
  119. package/dist/features/content/components/ContentSidebar.js +129 -18
  120. package/dist/features/content/components/ContentSidebarGroup.js +37 -0
  121. package/dist/features/content/components/DeleteCollectionItemButton.js +202 -0
  122. package/dist/features/content/components/MissingFromLocale.js +282 -0
  123. package/dist/features/content/components/UploadDropZone.js +27 -31
  124. package/dist/features/content/components/UploadProgressDrawer.js +90 -98
  125. package/dist/features/navigation/navigation.d.ts +66 -20
  126. package/dist/features/navigation/navigation.js +257 -90
  127. package/dist/features/og/defaultFonts.js +8 -8
  128. package/dist/features/og/geist-variable-ttf-base64.js +1 -1
  129. package/dist/features/og/imageResponse.d.ts +8 -0
  130. package/dist/features/og/imageResponse.js +26 -0
  131. package/dist/features/page/CuratedPageContent.js +167 -0
  132. package/dist/features/page/DerivedPageContent.js +26 -30
  133. package/dist/features/page/SharedLayoutContent.js +25 -27
  134. package/dist/features/preview/CamoxPreview.d.ts +23 -61
  135. package/dist/features/preview/CamoxPreview.js +816 -537
  136. package/dist/features/preview/EditablePageContent.js +1 -1
  137. package/dist/features/preview/EditablePageExperience.js +16 -22
  138. package/dist/features/preview/components/AddBlockDialog.js +270 -0
  139. package/dist/features/preview/components/AssetFieldEditor.js +173 -154
  140. package/dist/features/preview/components/AssetLightbox.js +181 -134
  141. package/dist/features/preview/components/AssetPickerModal.js +153 -170
  142. package/dist/features/preview/components/BlockActionsPopover.js +150 -149
  143. package/dist/features/preview/components/BlockErrorBoundary.js +8 -12
  144. package/dist/features/preview/components/BlockThumbnail.js +176 -100
  145. package/dist/features/preview/components/CanvasPreview.js +243 -0
  146. package/dist/features/preview/components/CreatePageModal.js +128 -137
  147. package/dist/features/preview/components/DebouncedFieldEditor.js +29 -33
  148. package/dist/features/preview/components/DerivedLayoutDialog.js +21 -19
  149. package/dist/features/preview/components/DrillRow.js +150 -0
  150. package/dist/features/preview/components/FieldOverlayStyles.js +11 -8
  151. package/dist/features/preview/components/FieldToolbar.js +160 -110
  152. package/dist/features/preview/components/Frame.js +108 -20
  153. package/dist/features/preview/components/IconFieldEditor.js +62 -66
  154. package/dist/features/preview/components/ItemFieldsEditor.js +231 -205
  155. package/dist/features/preview/components/LinkFieldEditor.js +135 -139
  156. package/dist/features/preview/components/Metadata.js +22 -30
  157. package/dist/features/preview/components/MobilePreviewDrawer.js +89 -108
  158. package/dist/features/preview/components/MultipleAssetFieldEditor.js +334 -246
  159. package/dist/features/preview/components/OverlayTracker.js +9 -41
  160. package/dist/features/preview/components/Overlays.js +81 -69
  161. package/dist/features/preview/components/PageInfo.js +1748 -0
  162. package/dist/features/preview/components/PageInfoSkeleton.js +51 -0
  163. package/dist/features/preview/components/PageLocationFieldset.js +112 -116
  164. package/dist/features/preview/components/PageNavigatorHeader.js +24 -0
  165. package/dist/features/preview/components/PageNicknameField.js +22 -26
  166. package/dist/features/preview/components/PagePicker.js +128 -130
  167. package/dist/features/preview/components/PageTree.js +525 -532
  168. package/dist/features/preview/components/PreviewActivation.js +28 -32
  169. package/dist/features/preview/components/PreviewPanel.js +620 -319
  170. package/dist/features/preview/components/PreviewToolbar.js +105 -333
  171. package/dist/features/preview/components/RecordCard.js +80 -0
  172. package/dist/features/preview/components/RecordCombobox.js +178 -0
  173. package/dist/features/preview/components/ReferenceFieldEditor.js +149 -0
  174. package/dist/features/preview/components/ReferenceListFieldEditor.js +432 -0
  175. package/dist/features/preview/components/RemovedBlockPlaceholder.js +95 -0
  176. package/dist/features/preview/components/RepeatableItemsList.js +125 -138
  177. package/dist/features/preview/components/SelectionEditor.js +993 -0
  178. package/dist/features/preview/components/ShikiMarkdown.js +14 -18
  179. package/dist/features/preview/components/SidebarSection.js +52 -64
  180. package/dist/features/preview/components/StudioEditingFallback.js +56 -0
  181. package/dist/features/preview/components/UnlinkAssetButton.js +104 -107
  182. package/dist/features/preview/components/blockGridNavigation.js +15 -0
  183. package/dist/features/preview/components/contentFieldSchema.js +8 -0
  184. package/dist/features/preview/components/useFieldWriter.js +200 -0
  185. package/dist/features/preview/components/useRecordView.js +383 -0
  186. package/dist/features/preview/components/useRepeatableItemActions.js +35 -37
  187. package/dist/features/preview/components/useUpdateBlockPosition.js +37 -37
  188. package/dist/features/preview/editingFrame.js +197 -0
  189. package/dist/features/preview/overlayHighlights.js +17 -44
  190. package/dist/features/preview/overlayMessages.js +72 -1
  191. package/dist/features/preview/pageRecord.js +189 -0
  192. package/dist/features/preview/previewConstants.js +6 -2
  193. package/dist/features/preview/previewPageFrame.js +95 -0
  194. package/dist/features/preview/previewPreparation.js +7 -0
  195. package/dist/features/preview/previewSelection.js +32 -63
  196. package/dist/features/preview/previewStore.js +225 -123
  197. package/dist/features/preview/referencePickerFocus.js +29 -0
  198. package/dist/features/preview/repeatableItemTargets.js +56 -0
  199. package/dist/features/preview/selectionReveal.js +21 -0
  200. package/dist/features/preview/usePreviewViewportActions.js +114 -0
  201. package/dist/features/preview/viewportContinuity.js +109 -0
  202. package/dist/features/provider/AuthenticatedCamoxProvider.js +69 -44
  203. package/dist/features/provider/CamoxProvider.d.ts +3 -6
  204. package/dist/features/provider/CamoxProvider.js +38 -50
  205. package/dist/features/provider/CoreCamoxProvider.js +66 -50
  206. package/dist/features/provider/LocalhostPreviewProvider.js +78 -114
  207. package/dist/features/provider/PreviewSignInPage.js +54 -0
  208. package/dist/features/provider/components/CamoxAppContext.js +11 -11
  209. package/dist/features/provider/components/CommandPalette.js +75 -82
  210. package/dist/features/provider/useAdminShortcuts.js +7 -11
  211. package/dist/features/routes/pageRuntime.d.ts +44 -4
  212. package/dist/features/routes/pageRuntime.js +244 -137
  213. package/dist/features/runtime/RuntimeChrome.js +117 -115
  214. package/dist/features/runtime/alternates.js +64 -0
  215. package/dist/features/runtime/analytics.d.ts +7 -0
  216. package/dist/features/runtime/analytics.js +66 -0
  217. package/dist/features/runtime/artifactSources.js +87 -0
  218. package/dist/features/runtime/editingFallback.js +20 -0
  219. package/dist/features/runtime/linkPrefetch.js +97 -0
  220. package/dist/features/runtime/livePages.js +62 -0
  221. package/dist/features/runtime/llmsTxt.js +40 -0
  222. package/dist/features/runtime/loopbackFetch.js +18 -0
  223. package/dist/features/runtime/navigationAccessibility.js +51 -0
  224. package/dist/features/runtime/navigationTarget.js +23 -2
  225. package/dist/features/runtime/pageApp.js +229 -158
  226. package/dist/features/runtime/pageBlockTypes.js +20 -0
  227. package/dist/features/runtime/pageClient.d.ts +2 -4
  228. package/dist/features/runtime/pageClient.js +18 -3
  229. package/dist/features/runtime/pageNavigation.js +254 -32
  230. package/dist/features/runtime/pageServer.d.ts +2 -4
  231. package/dist/features/runtime/pageServer.js +6 -2
  232. package/dist/features/runtime/pageViewport.js +7 -0
  233. package/dist/features/runtime/runtime.d.ts +59 -24
  234. package/dist/features/runtime/runtime.js +779 -191
  235. package/dist/features/runtime/runtimeChromeLoader.js +58 -0
  236. package/dist/features/runtime/runtimeRoutes.d.ts +19 -0
  237. package/dist/features/runtime/runtimeRoutes.js +25 -0
  238. package/dist/features/runtime/scrollRestoration.js +133 -0
  239. package/dist/features/runtime/studioApp.d.ts +4 -3
  240. package/dist/features/runtime/studioApp.js +5 -9
  241. package/dist/features/runtime/studioClient.d.ts +2 -4
  242. package/dist/features/runtime/studioClient.js +12 -3
  243. package/dist/features/runtime/studioServer.d.ts +2 -4
  244. package/dist/features/runtime/studioServer.js +6 -1
  245. package/dist/features/runtime/worker.d.ts +6 -0
  246. package/dist/features/runtime/worker.js +23 -0
  247. package/dist/features/runtime/workerRequest.js +44 -0
  248. package/dist/features/studio/CamoxStudio.d.ts +2 -6
  249. package/dist/features/studio/CamoxStudio.js +34 -49
  250. package/dist/features/studio/FollowAgentProvider.js +338 -0
  251. package/dist/features/studio/components/ChatSidebar.js +356 -0
  252. package/dist/features/studio/components/DraftsControl.js +676 -0
  253. package/dist/features/studio/components/FaviconDialog.js +318 -0
  254. package/dist/features/studio/components/LocalePicker.js +785 -0
  255. package/dist/features/studio/components/Navbar.js +123 -103
  256. package/dist/features/studio/components/ProjectMenu.js +239 -260
  257. package/dist/features/studio/components/RenameDraftDialog.js +206 -0
  258. package/dist/features/studio/components/ReviewDraftSheet.js +1472 -0
  259. package/dist/features/studio/components/ThreadComposer.js +157 -0
  260. package/dist/features/studio/components/ThreadMarkdown.js +113 -0
  261. package/dist/features/studio/components/ThreadMessages.js +270 -0
  262. package/dist/features/studio/components/UserButton.js +34 -23
  263. package/dist/features/studio/draftLabel.js +33 -0
  264. package/dist/features/studio/draftNotice.js +13 -0
  265. package/dist/features/studio/followAgent.js +250 -0
  266. package/dist/features/studio/followAgentContext.js +7 -0
  267. package/dist/features/studio/localeOptions.js +118 -0
  268. package/dist/features/studio/localeSwitch.js +19 -0
  269. package/dist/features/studio/routes.js +48 -1
  270. package/dist/features/studio/studioStore.js +64 -1
  271. package/dist/features/studio/useTheme.js +24 -27
  272. package/dist/features/vite/artifactRuntimeMinification.js +36 -0
  273. package/dist/features/vite/blockBoilerplate.js +6 -5
  274. package/dist/features/vite/blockChunks.js +31 -0
  275. package/dist/features/vite/bundlerLogs.js +17 -0
  276. package/dist/features/vite/definitionsSync.js +158 -226
  277. package/dist/features/vite/devAuthentication.js +4 -16
  278. package/dist/features/vite/devSignIn.js +87 -0
  279. package/dist/features/vite/iconGeneration.js +1 -1
  280. package/dist/features/vite/layoutGeneration.js +11 -1
  281. package/dist/features/vite/publishSeededContent.js +30 -0
  282. package/dist/features/vite/routeGeneration.js +6 -7
  283. package/dist/features/vite/runtimeDev.js +80 -99
  284. package/dist/features/vite/vite.d.ts +51 -31
  285. package/dist/features/vite/vite.js +224 -127
  286. package/dist/features/vite/workerBuild.js +39 -0
  287. package/dist/hooks/use-debounced-field.js +116 -47
  288. package/dist/hooks/use-file-upload.js +114 -67
  289. package/dist/hooks/use-marquee-selection.js +32 -36
  290. package/dist/hooks/use-page-destinations.js +69 -37
  291. package/dist/lib/api-client-server.d.ts +5 -0
  292. package/dist/lib/api-client-server.js +10 -4
  293. package/dist/lib/api-client.d.ts +6 -0
  294. package/dist/lib/api-client.js +51 -16
  295. package/dist/lib/api-socket.js +17 -0
  296. package/dist/lib/auth-page-styles.js +39 -0
  297. package/dist/lib/auth.js +117 -61
  298. package/dist/lib/collection-cache.js +23 -0
  299. package/dist/lib/draft-scope.d.ts +4 -0
  300. package/dist/lib/draft-scope.js +222 -0
  301. package/dist/lib/html.js +12 -0
  302. package/dist/lib/link-pages.js +154 -0
  303. package/dist/lib/locale-path.d.ts +22 -0
  304. package/dist/lib/locale-path.js +57 -0
  305. package/dist/lib/normalized-data.js +252 -152
  306. package/dist/lib/preview-handoff.js +2 -2
  307. package/dist/lib/queries.d.ts +11 -0
  308. package/dist/lib/queries.js +70 -141
  309. package/dist/lib/studio-reads.d.ts +14 -0
  310. package/dist/lib/studio-reads.js +574 -0
  311. package/dist/lib/use-project-room.js +50 -50
  312. package/dist/lib/use-thread.js +310 -0
  313. package/dist/lib/utils.js +25 -29
  314. package/dist/lib/view-locale-context.js +22 -0
  315. package/dist/lib/view-locale.js +46 -0
  316. package/dist/package.js +5 -0
  317. package/dist/studio-overlays.css +41 -151
  318. package/dist/studio.css +2 -2
  319. package/package.json +70 -73
  320. package/skills/camox/SKILL.md +16 -11
  321. package/skills/camox/references/artifacts.md +179 -0
  322. package/skills/camox/references/block-definitions.md +75 -59
  323. package/skills/camox/references/cli-common.md +9 -11
  324. package/skills/camox/references/cli-content.md +92 -69
  325. package/skills/camox/references/cli-publishing.md +26 -0
  326. package/skills/camox/references/dom-integrations.md +27 -0
  327. package/skills/camox/references/field-styling.md +4 -4
  328. package/skills/camox/references/layout-definitions.md +16 -14
  329. package/skills/camox/references/localization.md +56 -0
  330. package/skills/camox/references/routed-layouts.md +133 -15
  331. package/skills/camox-expand/SKILL.md +69 -0
  332. package/skills/camox-expand/references/jobs.md +39 -0
  333. package/skills/camoxify/SKILL.md +29 -7
  334. package/dist/core/components/AddBlockControlBar.js +0 -78
  335. package/dist/core/hooks/useRequireDraftSource.js +0 -23
  336. package/dist/features/metadata/sitemap.d.ts +0 -8
  337. package/dist/features/metadata/sitemap.js +0 -17
  338. package/dist/features/og/imageResponse.node.d.ts +0 -12
  339. package/dist/features/og/imageResponse.node.js +0 -49
  340. package/dist/features/og/imageResponse.workerd.d.ts +0 -12
  341. package/dist/features/og/imageResponse.workerd.js +0 -40
  342. package/dist/features/page/PublishedPageContent.js +0 -205
  343. package/dist/features/page/PublishedPageExperience.js +0 -23
  344. package/dist/features/preview/DerivedPreview.js +0 -134
  345. package/dist/features/preview/commentsEnabled.js +0 -8
  346. package/dist/features/preview/components/AddBlockSidebar.js +0 -381
  347. package/dist/features/preview/components/AttachedComments.js +0 -331
  348. package/dist/features/preview/components/CommentHeader.js +0 -122
  349. package/dist/features/preview/components/CommentSidebar.js +0 -29
  350. package/dist/features/preview/components/CommentTargetQuote.js +0 -167
  351. package/dist/features/preview/components/DerivedLayoutSidebar.d.ts +0 -5
  352. package/dist/features/preview/components/DerivedLayoutSidebar.js +0 -179
  353. package/dist/features/preview/components/DerivedPageInfoSidebar.js +0 -69
  354. package/dist/features/preview/components/LeftSidebar.js +0 -68
  355. package/dist/features/preview/components/PageEditorSidebar.js +0 -563
  356. package/dist/features/preview/components/PageInfoSidebar.js +0 -1551
  357. package/dist/features/preview/components/PageNavigatorSidebar.js +0 -78
  358. package/dist/features/preview/components/PageStatusBadge.js +0 -97
  359. package/dist/features/preview/components/PeekedBlock.js +0 -217
  360. package/dist/features/preview/components/PreviewComments.js +0 -56
  361. package/dist/features/preview/components/PreviewToolbarSpacer.js +0 -43
  362. package/dist/features/preview/components/PublicationRow.js +0 -422
  363. package/dist/features/preview/components/PublishDialog.js +0 -194
  364. package/dist/features/preview/components/RightSidebar.js +0 -59
  365. package/dist/features/preview/components/SendFeedbackDialog.js +0 -83
  366. package/dist/features/preview/previewCommentsStore.js +0 -135
  367. package/dist/features/preview/publication.js +0 -81
  368. package/dist/features/preview/usePageComments.js +0 -39
  369. package/dist/features/runtime/SharedChromeContext.js +0 -7
  370. package/dist/features/studio/components/EnvironmentMenu.js +0 -425
  371. package/dist/features/vite/appGeneration.js +0 -89
  372. package/dist/lib/view-queries.js +0 -28
  373. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/Matches.d.ts +0 -114
  374. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/RouterProvider.d.ts +0 -25
  375. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/config.d.ts +0 -1
  376. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/defer.d.ts +0 -1
  377. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/fileRoute.d.ts +0 -20
  378. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/global.d.ts +0 -8
  379. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/hash-scroll.d.ts +0 -1
  380. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/index.d.ts +0 -18
  381. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/link.d.ts +0 -161
  382. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/load-matches.d.ts +0 -6
  383. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/location.d.ts +0 -54
  384. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/lru-cache.d.ts +0 -8
  385. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/manifest.d.ts +0 -32
  386. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.d.ts +0 -115
  387. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/not-found.d.ts +0 -1
  388. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/redirect.d.ts +0 -49
  389. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/rewrite.d.ts +0 -1
  390. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/root.d.ts +0 -6
  391. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/route.d.ts +0 -343
  392. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/routeInfo.d.ts +0 -48
  393. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/router.d.ts +0 -695
  394. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.d.ts +0 -1
  395. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchMiddleware.d.ts +0 -1
  396. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchParams.d.ts +0 -5
  397. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/RawStream.d.ts +0 -38
  398. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/seroval-plugins.d.ts +0 -1
  399. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/transformer.d.ts +0 -65
  400. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/stores.d.ts +0 -69
  401. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/structuralSharing.d.ts +0 -1
  402. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/typePrimitives.d.ts +0 -1
  403. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderData.d.ts +0 -1
  404. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderDeps.d.ts +0 -1
  405. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useNavigate.d.ts +0 -10
  406. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useParams.d.ts +0 -1
  407. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useRouteContext.d.ts +0 -1
  408. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useSearch.d.ts +0 -1
  409. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/utils.d.ts +0 -28
  410. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/validators.d.ts +0 -49
  411. package/skills/camox/references/cli-environments.md +0 -37
@@ -1,31 +1,54 @@
1
- import { useLocation } from "../../features/navigation/navigation.js";
2
- import { useProjectSlug } from "../../lib/auth.js";
3
- import { isFileMarker, isItemMarker, resolveFileMarker, useNormalizedData } from "../../lib/normalized-data.js";
4
- import { Type as Type$1, resolveToMarkdown } from "../lib/contentType.js";
1
+ import { artifactFrameProps, artifactPlaceholderProps, artifactStandInProps, isArtifactSource } from "../lib/artifact.js";
2
+ import { artifactData } from "../lib/artifactData.js";
3
+ import { resolveBlockFields, resolveToMarkdown } from "../lib/contentType.js";
4
+ import { useProjectUuid } from "../../lib/auth.js";
5
+ import { useLocation, useNavigate } from "../../features/navigation/navigation.js";
6
+ import { useOptionalCamoxApp } from "../../features/provider/components/CamoxAppContext.js";
7
+ import { LinkedRecordsProvider, isItemMarker, queryResultIds, resolveAssetValue, useNormalizedData } from "../../lib/normalized-data.js";
8
+ import { reads, useStudioCache } from "../../lib/studio-reads.js";
9
+ import { useLinkPages } from "../../lib/link-pages.js";
10
+ import { ArtifactsRunContext, useArtifactHost, useInitialArtifactData } from "../hooks/useArtifactHost.js";
5
11
  import { IconSvg } from "../lib/icons.js";
12
+ import { renderImagePlaceholder } from "../lib/imagePlaceholder.js";
6
13
  import { buildImageSrcSet, getDefaultImageSizes, getDefaultImageWidth, transformImageUrl } from "../lib/imageTransform.js";
7
14
  import { markdownToReactNodes } from "../lib/lexicalReact.js";
8
- import { blockMutations, pageQueries, projectQueries, repeatableItemMutations } from "../../lib/queries.js";
9
- import { previewStore, selectIsCommentMode } from "../../features/preview/previewStore.js";
10
- import { usePreviewSelection } from "../../features/preview/previewSelection.js";
15
+ import { resolveReference, resolveReferenceList } from "../lib/reference.js";
16
+ import { blockMutations, collectionMutations, repeatableItemMutations } from "../../lib/queries.js";
17
+ import { referencePickerFocus } from "../../features/preview/referencePickerFocus.js";
18
+ import { invalidateCollectionRecordViews } from "../../lib/collection-cache.js";
19
+ import { selectionBlockId } from "../../features/preview/previewStore.js";
11
20
  import { useFrame } from "../../features/preview/components/Frame.js";
12
- import { postOverlayMessage } from "../../features/preview/overlayMessages.js";
13
- import { AddBlockControlBar } from "../components/AddBlockControlBar.js";
14
- import { InlineLexicalEditor } from "../components/lexical/InlineLexicalEditor.js";
15
- import { useFieldSelection } from "../hooks/useFieldSelection.js";
16
21
  import { useIsEditable } from "../hooks/useIsEditable.js";
22
+ import { CanvasWorkspaceContext } from "../../features/canvas/canvasZoom.js";
23
+ import { PreviewEditingOwnerContext, usePreviewSelection, usePreviewTargetSelection } from "../../features/preview/previewSelection.js";
24
+ import { overlayFieldId, recordPlacementId } from "../../features/preview/overlayMessages.js";
25
+ import { useLatestRecord } from "./useLatestRecord.js";
26
+ import { referenceWritesFor } from "./referenceWrites.js";
27
+ import { registerRepeatableItem } from "../../features/preview/repeatableItemTargets.js";
28
+ import { revealScrollDelta } from "../../features/preview/selectionReveal.js";
29
+ import { InlineLexicalEditor } from "../components/lexical/InlineLexicalEditor.js";
30
+ import { useFieldSelection, useRecordSelection } from "../hooks/useFieldSelection.js";
17
31
  import { useOverlayMessage } from "../hooks/useOverlayMessage.js";
18
32
  import { useOverlayState } from "../hooks/useOverlayState.js";
19
33
  import { c } from "react/compiler-runtime";
34
+ import * as React from "react";
35
+ import { isQueryBacked } from "@camox/api-contract";
20
36
  import { Type } from "@sinclair/typebox";
21
- import { useMutation, useQuery } from "@tanstack/react-query";
22
37
  import { generateKeyBetween } from "fractional-indexing";
23
- import * as React from "react";
24
38
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
25
- import { useSelector } from "@xstate/store-react";
26
- import { createPortal } from "react-dom";
39
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
27
40
 
28
41
  //#region src/core/editing/createEditableBlock.tsx
42
+ /** The pages links lead to in the locale viewed, for the studio's editors, who read the project. */
43
+ function useEditorLinkPages() {
44
+ const $ = c(1);
45
+ let t0;
46
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
47
+ t0 = { fetchProject: true };
48
+ $[0] = t0;
49
+ } else t0 = $[0];
50
+ return useLinkPages(useProjectUuid(), t0);
51
+ }
29
52
  /** Normalize legacy links (no `type` field) to the new union shape */
30
53
  const normalizeLinkValue = (value) => {
31
54
  if (!value.type) return {
@@ -42,7 +65,7 @@ const normalizeLinkValue = (value) => {
42
65
  * resolves inconsistently across environments, causing hydration mismatches.
43
66
  */
44
67
  const resolveLinkHref = (link, pages, currentPathname) => {
45
- if (link.type === "page") return (pages?.find((p) => String(p.id) === link.pageId))?.fullPath ?? currentPathname;
68
+ if (link.type === "page") return (pages?.find((p) => p.id === link.pageId))?.fullPath ?? currentPathname;
46
69
  if (!link.href || link.href.startsWith("#")) return `${currentPathname}${link.href ?? ""}`;
47
70
  return link.href;
48
71
  };
@@ -106,7 +129,7 @@ function buildPeekItems(properties, blockId, parentItemId, content, allItems, co
106
129
  const markers = [];
107
130
  let prevPosition = null;
108
131
  for (let i = 0; i < defaultCount; i++) {
109
- const itemId = --counter.value;
132
+ const itemId = `peek_${++counter.value}`;
110
133
  const position = generateKeyBetween(prevPosition, null);
111
134
  prevPosition = position;
112
135
  allItems.push({
@@ -119,7 +142,10 @@ function buildPeekItems(properties, blockId, parentItemId, content, allItems, co
119
142
  summary: "",
120
143
  position,
121
144
  createdAt: 0,
122
- updatedAt: 0
145
+ updatedAt: 0,
146
+ projectId: null,
147
+ sharedContentType: null,
148
+ references: {}
123
149
  });
124
150
  markers.push({ _itemId: itemId });
125
151
  const nestedContent = {};
@@ -134,20 +160,21 @@ function buildPeekItems(properties, blockId, parentItemId, content, allItems, co
134
160
  }
135
161
  }
136
162
  function createEditableBlock(options) {
137
- const typeboxSchema = Type.Object(options.content);
163
+ const fields = resolveBlockFields(options);
164
+ const typeboxSchema = Type.Object(fields.content);
138
165
  const contentSchema = {
139
166
  type: "object",
140
167
  title: options.title,
141
168
  description: options.description,
142
169
  properties: typeboxSchema.properties,
143
- required: Object.keys(options.content),
144
- toMarkdown: resolveToMarkdown(options.toMarkdown, options.settings, "block")
170
+ required: Object.keys(fields.content),
171
+ toMarkdown: resolveToMarkdown(options.toMarkdown, fields.settings, "block", fields.content)
145
172
  };
146
- const settingsTypeboxSchema = options.settings ? Type.Object(options.settings) : null;
173
+ const settingsTypeboxSchema = fields.settings ? Type.Object(fields.settings) : null;
147
174
  const settingsSchema = settingsTypeboxSchema ? {
148
175
  type: "object",
149
176
  properties: settingsTypeboxSchema.properties,
150
- required: Object.keys(options.settings)
177
+ required: Object.keys(fields.settings)
151
178
  } : void 0;
152
179
  const contentDefaults = {};
153
180
  const contentDefaultsForStorage = {};
@@ -173,102 +200,64 @@ function createEditableBlock(options) {
173
200
  for (const [key, prop] of Object.entries(settingsTypeboxSchema.properties)) if ("default" in prop) settingsDefaults[key] = prop.default;
174
201
  }
175
202
  const Context = React.createContext(null);
176
- const RepeaterItemContext = React.createContext(null);
177
- const RepeaterHoverContext = React.createContext(false);
178
- /**
179
- * Build a field ID that matches the sidebar's `getFieldId` format.
180
- * Root fields: blockId__fieldName
181
- * Repeater item fields: blockId__itemId__fieldName
182
- */
183
- const getOverlayFieldId = (blockId, repeaterContext, fieldName) => {
184
- if (repeaterContext?.itemId != null) return `${blockId}__${repeaterContext.itemId}__${fieldName}`;
185
- return `${blockId}__${fieldName}`;
186
- };
203
+ const RepeatableItemContext = React.createContext(null);
204
+ const ReferenceContext = React.createContext(null);
205
+ const RepeaterHoverContext = React.createContext(null);
206
+ const getOverlayFieldId = (blockId, fieldName, scope = {}) => scope.reference ? overlayFieldId(blockId, fieldName, { placement: scope.reference.placement }) : overlayFieldId(blockId, fieldName, { itemId: scope.itemId });
187
207
  const Field = (t0) => {
188
- const $ = c(34);
189
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
190
- for (let $i = 0; $i < 34; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
191
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
192
- }
208
+ const $ = c(40);
193
209
  const { name, textStyle, linkStyle, children } = t0;
194
210
  const selectTarget = usePreviewSelection();
195
- const isCommentMode = useSelector(previewStore, selectIsCommentMode);
196
211
  const blockContext = React.use(Context);
197
212
  if (!blockContext) throw new Error("Field must be used within a Block Component");
198
213
  const { blockId, content, mode } = blockContext;
199
214
  const isContentEditable = useIsEditable(mode);
200
215
  const elementRef = React.useRef(null);
201
216
  const { window: iframeWindow } = useFrame();
202
- const projectSlug = useProjectSlug();
217
+ const pages = useEditorLinkPages();
203
218
  let t1;
204
- if ($[1] !== projectSlug) {
205
- t1 = projectQueries.getBySlug(projectSlug);
206
- $[1] = projectSlug;
207
- $[2] = t1;
208
- } else t1 = $[2];
209
- const { data: project } = useQuery(t1);
210
- let t2;
211
- if ($[3] !== project?.id) {
212
- t2 = pageQueries.list(project?.id ?? 0);
213
- $[3] = project?.id;
214
- $[4] = t2;
215
- } else t2 = $[4];
216
- const t3 = !!project;
217
- let t4;
218
- if ($[5] !== t2 || $[6] !== t3) {
219
- t4 = {
220
- ...t2,
221
- enabled: t3
222
- };
223
- $[5] = t2;
224
- $[6] = t3;
225
- $[7] = t4;
226
- } else t4 = $[7];
227
- const { data: pages } = useQuery(t4);
228
- let t5;
229
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
230
- t5 = { select: _temp };
231
- $[8] = t5;
232
- } else t5 = $[8];
233
- const currentPathname = useLocation(t5);
234
- const repeaterContext = React.use(RepeaterItemContext);
235
- const fieldId = getOverlayFieldId(blockId, repeaterContext, String(name));
219
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
220
+ t1 = { select: _temp };
221
+ $[0] = t1;
222
+ } else t1 = $[0];
223
+ const currentPathname = useLocation(t1);
224
+ const repeaterContext = React.use(RepeatableItemContext);
225
+ const reference = React.use(ReferenceContext);
226
+ const fieldId = getOverlayFieldId(blockId, String(name), {
227
+ itemId: repeaterContext?.itemId,
228
+ reference
229
+ });
236
230
  const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
237
231
  const [isHovered, setIsHovered] = React.useState(false);
238
232
  const [isEditorFocused, setIsEditorFocused] = React.useState(false);
239
- const isSelectedFromSelection = useFieldSelection(blockId, String(name), "String", repeaterContext?.itemId);
240
- const overlayState = useOverlayState(isHovered, isEditorFocused || isSelectedFromSelection);
233
+ const isBlockFieldSelected = useFieldSelection(blockId, String(name), "String", repeaterContext?.itemId);
234
+ const isRecordFieldSelected = useRecordSelection(reference?.placement ?? null, String(name));
235
+ const overlayState = useOverlayState(isHovered, isEditorFocused || (reference ? isRecordFieldSelected : isBlockFieldSelected));
241
236
  const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", { fieldId });
242
- let t6;
243
- let t7;
244
- if ($[9] !== isHoveredFromSidebar) {
245
- t6 = () => {
246
- setIsHovered(isHoveredFromSidebar);
247
- };
248
- t7 = [isHoveredFromSidebar];
249
- $[9] = isHoveredFromSidebar;
250
- $[10] = t6;
251
- $[11] = t7;
252
- } else {
253
- t6 = $[10];
254
- t7 = $[11];
237
+ const [prevSidebarHover, setPrevSidebarHover] = React.useState(isHoveredFromSidebar);
238
+ if (prevSidebarHover !== isHoveredFromSidebar) {
239
+ setPrevSidebarHover(isHoveredFromSidebar);
240
+ setIsHovered(isHoveredFromSidebar);
255
241
  }
256
- React.useEffect(t6, t7);
257
- let t8;
258
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
259
- t8 = blockMutations.updateContent();
260
- $[12] = t8;
261
- } else t8 = $[12];
262
- const updateBlockContent = useMutation(t8);
263
- let t9;
264
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
265
- t9 = repeatableItemMutations.updateContent();
266
- $[13] = t9;
267
- } else t9 = $[13];
268
- const updateRepeatableContent = useMutation(t9);
269
- let t10;
270
- if ($[14] !== blockId || $[15] !== name || $[16] !== repeaterContext || $[17] !== updateBlockContent || $[18] !== updateRepeatableContent) {
271
- t10 = (newValue) => {
242
+ let t2;
243
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
244
+ t2 = blockMutations.updateContent();
245
+ $[1] = t2;
246
+ } else t2 = $[1];
247
+ const updateBlockContent = useMutation(t2);
248
+ let t3;
249
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
250
+ t3 = repeatableItemMutations.updateContent();
251
+ $[2] = t3;
252
+ } else t3 = $[2];
253
+ const updateRepeatableContent = useMutation(t3);
254
+ let t4;
255
+ if ($[3] !== blockId || $[4] !== name || $[5] !== reference || $[6] !== repeaterContext || $[7] !== updateBlockContent || $[8] !== updateRepeatableContent) {
256
+ t4 = (newValue) => {
257
+ if (reference) {
258
+ reference.update(String(name), newValue);
259
+ return;
260
+ }
272
261
  if (repeaterContext) {
273
262
  const { itemId } = repeaterContext;
274
263
  if (itemId != null) updateRepeatableContent.mutate({
@@ -280,17 +269,22 @@ function createEditableBlock(options) {
280
269
  content: { [name]: newValue }
281
270
  });
282
271
  };
283
- $[14] = blockId;
284
- $[15] = name;
285
- $[16] = repeaterContext;
286
- $[17] = updateBlockContent;
287
- $[18] = updateRepeatableContent;
288
- $[19] = t10;
289
- } else t10 = $[19];
290
- const handleChange = t10;
291
- let t11;
292
- if ($[20] !== blockId || $[21] !== name || $[22] !== repeaterContext || $[23] !== selectTarget) {
293
- t11 = (event) => {
272
+ $[3] = blockId;
273
+ $[4] = name;
274
+ $[5] = reference;
275
+ $[6] = repeaterContext;
276
+ $[7] = updateBlockContent;
277
+ $[8] = updateRepeatableContent;
278
+ $[9] = t4;
279
+ } else t4 = $[9];
280
+ const handleChange = t4;
281
+ let t5;
282
+ if ($[10] !== blockId || $[11] !== name || $[12] !== reference || $[13] !== repeaterContext || $[14] !== selectTarget) {
283
+ t5 = () => {
284
+ if (reference) {
285
+ reference.selectRecordField(String(name), "String");
286
+ return;
287
+ }
294
288
  selectTarget(repeaterContext?.itemId != null ? {
295
289
  type: "item-field",
296
290
  blockId,
@@ -302,168 +296,187 @@ function createEditableBlock(options) {
302
296
  blockId,
303
297
  fieldName: String(name),
304
298
  fieldType: "String"
305
- }, event);
299
+ });
306
300
  };
307
- $[20] = blockId;
308
- $[21] = name;
309
- $[22] = repeaterContext;
310
- $[23] = selectTarget;
311
- $[24] = t11;
312
- } else t11 = $[24];
313
- const selectField = t11;
314
- let t12;
315
- if ($[25] !== selectField) {
316
- t12 = () => {
317
- if (selectIsCommentMode(previewStore.getSnapshot())) return;
301
+ $[10] = blockId;
302
+ $[11] = name;
303
+ $[12] = reference;
304
+ $[13] = repeaterContext;
305
+ $[14] = selectTarget;
306
+ $[15] = t5;
307
+ } else t5 = $[15];
308
+ const selectField = t5;
309
+ let t6;
310
+ if ($[16] !== selectField) {
311
+ t6 = () => {
318
312
  setIsEditorFocused(true);
319
313
  selectField();
320
314
  };
321
- $[25] = selectField;
322
- $[26] = t12;
323
- } else t12 = $[26];
324
- const handleFocus = t12;
325
- let t13;
326
- if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
327
- t13 = () => {
315
+ $[16] = selectField;
316
+ $[17] = t6;
317
+ } else t6 = $[17];
318
+ const handleFocus = t6;
319
+ let t7;
320
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
321
+ t7 = () => {
328
322
  setIsEditorFocused(false);
329
323
  };
330
- $[27] = t13;
331
- } else t13 = $[27];
332
- const handleBlur = t13;
333
- let t14;
334
- if ($[28] !== isContentEditable) {
335
- t14 = () => {
324
+ $[18] = t7;
325
+ } else t7 = $[18];
326
+ const handleBlur = t7;
327
+ let t8;
328
+ if ($[19] !== isContentEditable) {
329
+ t8 = () => {
336
330
  if (isContentEditable) setIsHovered(true);
337
331
  };
338
- $[28] = isContentEditable;
339
- $[29] = t14;
340
- } else t14 = $[29];
341
- const handleMouseEnter = t14;
342
- let t15;
343
- if ($[30] !== isContentEditable) {
344
- t15 = () => {
332
+ $[19] = isContentEditable;
333
+ $[20] = t8;
334
+ } else t8 = $[20];
335
+ const handleMouseEnter = t8;
336
+ let t9;
337
+ if ($[21] !== isContentEditable) {
338
+ t9 = () => {
345
339
  if (isContentEditable) setIsHovered(false);
346
340
  };
347
- $[30] = isContentEditable;
348
- $[31] = t15;
349
- } else t15 = $[31];
350
- const handleMouseLeave = t15;
341
+ $[21] = isContentEditable;
342
+ $[22] = t9;
343
+ } else t9 = $[22];
344
+ const handleMouseLeave = t9;
351
345
  const fieldData = { text: fieldValue };
352
- if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({ children: markdownToReactNodes(fieldValue, {
353
- pages,
354
- fallbackHref: currentPathname,
355
- textStyle,
356
- linkStyle
357
- }) }, fieldData) });
358
- const t16 = children({
359
- ref: elementRef,
360
- "data-camox-field-id": fieldId,
361
- ...overlayState,
362
- "data-camox-overlay-mode": options.synced ? "synced" : void 0,
363
- onMouseEnter: handleMouseEnter,
364
- onMouseLeave: handleMouseLeave,
365
- onClickCapture: selectField,
366
- children: isCommentMode ? markdownToReactNodes(fieldValue, {
346
+ const fieldSchema = repeaterContext ? repeaterContext.itemSchema?.[name] : (blockContext.sourceSchema ?? typeboxSchema.properties)[name];
347
+ let t10;
348
+ if ($[23] !== currentPathname || $[24] !== fieldValue || $[25] !== linkStyle || $[26] !== pages || $[27] !== textStyle) {
349
+ t10 = () => markdownToReactNodes(fieldValue, {
367
350
  pages,
368
351
  fallbackHref: currentPathname,
369
352
  textStyle,
370
353
  linkStyle
371
- }) : /* @__PURE__ */ jsx(InlineLexicalEditor, {
354
+ });
355
+ $[23] = currentPathname;
356
+ $[24] = fieldValue;
357
+ $[25] = linkStyle;
358
+ $[26] = pages;
359
+ $[27] = textStyle;
360
+ $[28] = t10;
361
+ } else t10 = $[28];
362
+ const text = t10;
363
+ if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({ children: text() }, fieldData) });
364
+ const t11 = fieldSchema?.maxLength;
365
+ let t12;
366
+ if ($[29] !== currentPathname || $[30] !== fieldValue || $[31] !== handleChange || $[32] !== handleFocus || $[33] !== linkStyle || $[34] !== pages || $[35] !== t11 || $[36] !== textStyle) {
367
+ t12 = /* @__PURE__ */ jsx(InlineLexicalEditor, {
372
368
  textStyle,
373
369
  linkStyle,
374
370
  pages,
375
371
  fallbackHref: currentPathname,
376
372
  initialState: fieldValue,
377
373
  externalState: fieldValue,
374
+ maxLength: t11,
378
375
  onChange: handleChange,
379
376
  onFocus: handleFocus,
380
377
  onBlur: handleBlur
381
- })
378
+ });
379
+ $[29] = currentPathname;
380
+ $[30] = fieldValue;
381
+ $[31] = handleChange;
382
+ $[32] = handleFocus;
383
+ $[33] = linkStyle;
384
+ $[34] = pages;
385
+ $[35] = t11;
386
+ $[36] = textStyle;
387
+ $[37] = t12;
388
+ } else t12 = $[37];
389
+ const t13 = children({
390
+ ref: elementRef,
391
+ "data-camox-field-id": fieldId,
392
+ ...overlayState,
393
+ "data-camox-overlay-mode": reference ? "reference" : options.synced ? "synced" : void 0,
394
+ onMouseEnter: handleMouseEnter,
395
+ onMouseLeave: handleMouseLeave,
396
+ onClickCapture: selectField,
397
+ children: t12
382
398
  }, fieldData);
383
- let t17;
384
- if ($[32] !== t16) {
385
- t17 = /* @__PURE__ */ jsx(Fragment, { children: t16 });
386
- $[32] = t16;
387
- $[33] = t17;
388
- } else t17 = $[33];
389
- return t17;
399
+ let t14;
400
+ if ($[38] !== t13) {
401
+ t14 = /* @__PURE__ */ jsx(Fragment, { children: t13 });
402
+ $[38] = t13;
403
+ $[39] = t14;
404
+ } else t14 = $[39];
405
+ return t14;
390
406
  };
391
407
  const Icon = (t0) => {
392
- const $ = c(34);
393
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
394
- for (let $i = 0; $i < 34; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
395
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
396
- }
408
+ const $ = c(33);
397
409
  let name;
398
410
  let props;
399
- if ($[1] !== t0) {
411
+ if ($[0] !== t0) {
400
412
  ({name, ...props} = t0);
401
- $[1] = t0;
402
- $[2] = name;
403
- $[3] = props;
413
+ $[0] = t0;
414
+ $[1] = name;
415
+ $[2] = props;
404
416
  } else {
405
- name = $[2];
406
- props = $[3];
417
+ name = $[1];
418
+ props = $[2];
407
419
  }
408
420
  const block = React.use(Context);
409
- const item = React.use(RepeaterItemContext);
421
+ const item = React.use(RepeatableItemContext);
410
422
  const selectTarget = usePreviewSelection();
411
423
  if (!block) throw new Error("Icon must be used within a Block Component");
412
424
  const editable = useIsEditable(block.mode);
413
425
  const fieldName = String(name);
414
426
  const value = item ? item.itemContent[name] : block.content[name];
415
- let t1;
416
- if ($[4] !== block.blockId || $[5] !== fieldName || $[6] !== item) {
417
- t1 = getOverlayFieldId(block.blockId, item, fieldName);
418
- $[4] = block.blockId;
419
- $[5] = fieldName;
420
- $[6] = item;
421
- $[7] = t1;
422
- } else t1 = $[7];
423
- const fieldId = t1;
427
+ const t1 = item?.itemId;
428
+ let t2;
429
+ if ($[3] !== block.blockId || $[4] !== fieldName || $[5] !== t1) {
430
+ t2 = getOverlayFieldId(block.blockId, fieldName, { itemId: t1 });
431
+ $[3] = block.blockId;
432
+ $[4] = fieldName;
433
+ $[5] = t1;
434
+ $[6] = t2;
435
+ } else t2 = $[6];
436
+ const fieldId = t2;
424
437
  const { window: iframeWindow } = useFrame();
425
438
  const [isHovered, setIsHovered] = React.useState(false);
426
439
  const isFocused = useFieldSelection(block.blockId, fieldName, "Icon", item?.itemId);
427
- let t2;
428
- if ($[8] !== fieldId) {
429
- t2 = { fieldId };
430
- $[8] = fieldId;
431
- $[9] = t2;
432
- } else t2 = $[9];
433
- const isHoveredFromSidebar = useOverlayMessage(iframeWindow, editable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t2);
440
+ let t3;
441
+ if ($[7] !== fieldId) {
442
+ t3 = { fieldId };
443
+ $[7] = fieldId;
444
+ $[8] = t3;
445
+ } else t3 = $[8];
446
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, editable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t3);
434
447
  const overlayState = useOverlayState(isHovered || isHoveredFromSidebar, isFocused);
435
- const t3 = editable ? fieldId : void 0;
436
- const t4 = editable ? "icon" : void 0;
437
- let t5;
438
- if ($[10] !== editable || $[11] !== overlayState) {
439
- t5 = editable ? overlayState : {};
440
- $[10] = editable;
441
- $[11] = overlayState;
442
- $[12] = t5;
443
- } else t5 = $[12];
444
- const t6 = editable && options.synced ? "synced" : void 0;
445
- let t7;
448
+ const t4 = editable ? fieldId : void 0;
449
+ const t5 = editable ? "icon" : void 0;
450
+ let t6;
451
+ if ($[9] !== editable || $[10] !== overlayState) {
452
+ t6 = editable ? overlayState : {};
453
+ $[9] = editable;
454
+ $[10] = overlayState;
455
+ $[11] = t6;
456
+ } else t6 = $[11];
457
+ const t7 = editable && options.synced ? "synced" : void 0;
446
458
  let t8;
447
- if ($[13] !== editable || $[14] !== props) {
448
- t7 = (event) => {
459
+ let t9;
460
+ if ($[12] !== editable || $[13] !== props) {
461
+ t8 = (event) => {
449
462
  if (editable) setIsHovered(true);
450
463
  props.onMouseEnter?.(event);
451
464
  };
452
- t8 = (event_0) => {
465
+ t9 = (event_0) => {
453
466
  if (editable) setIsHovered(false);
454
467
  props.onMouseLeave?.(event_0);
455
468
  };
456
- $[13] = editable;
457
- $[14] = props;
458
- $[15] = t7;
459
- $[16] = t8;
469
+ $[12] = editable;
470
+ $[13] = props;
471
+ $[14] = t8;
472
+ $[15] = t9;
460
473
  } else {
461
- t7 = $[15];
462
- t8 = $[16];
474
+ t8 = $[14];
475
+ t9 = $[15];
463
476
  }
464
- let t9;
465
- if ($[17] !== block.blockId || $[18] !== editable || $[19] !== fieldName || $[20] !== item || $[21] !== props.onClickCapture || $[22] !== selectTarget) {
466
- t9 = editable ? (event_1) => selectTarget(item?.itemId != null ? {
477
+ let t10;
478
+ if ($[16] !== block.blockId || $[17] !== editable || $[18] !== fieldName || $[19] !== item || $[20] !== props.onClickCapture || $[21] !== selectTarget) {
479
+ t10 = editable ? () => selectTarget(item?.itemId != null ? {
467
480
  type: "item-field",
468
481
  blockId: block.blockId,
469
482
  itemId: item.itemId,
@@ -474,47 +487,43 @@ function createEditableBlock(options) {
474
487
  blockId: block.blockId,
475
488
  fieldName,
476
489
  fieldType: "Icon"
477
- }, event_1) : props.onClickCapture;
478
- $[17] = block.blockId;
479
- $[18] = editable;
480
- $[19] = fieldName;
481
- $[20] = item;
482
- $[21] = props.onClickCapture;
483
- $[22] = selectTarget;
484
- $[23] = t9;
485
- } else t9 = $[23];
486
- let t10;
487
- if ($[24] !== props || $[25] !== t3 || $[26] !== t4 || $[27] !== t5 || $[28] !== t6 || $[29] !== t7 || $[30] !== t8 || $[31] !== t9 || $[32] !== value) {
488
- t10 = /* @__PURE__ */ jsx(IconSvg, {
490
+ }) : props.onClickCapture;
491
+ $[16] = block.blockId;
492
+ $[17] = editable;
493
+ $[18] = fieldName;
494
+ $[19] = item;
495
+ $[20] = props.onClickCapture;
496
+ $[21] = selectTarget;
497
+ $[22] = t10;
498
+ } else t10 = $[22];
499
+ let t11;
500
+ if ($[23] !== props || $[24] !== t10 || $[25] !== t4 || $[26] !== t5 || $[27] !== t6 || $[28] !== t7 || $[29] !== t8 || $[30] !== t9 || $[31] !== value) {
501
+ t11 = /* @__PURE__ */ jsx(IconSvg, {
489
502
  ...props,
490
503
  iconId: value,
491
- "data-camox-field-id": t3,
492
- "data-camox-field-type": t4,
493
- ...t5,
494
- "data-camox-overlay-mode": t6,
495
- onMouseEnter: t7,
496
- onMouseLeave: t8,
497
- onClickCapture: t9
504
+ "data-camox-field-id": t4,
505
+ "data-camox-field-type": t5,
506
+ ...t6,
507
+ "data-camox-overlay-mode": t7,
508
+ onMouseEnter: t8,
509
+ onMouseLeave: t9,
510
+ onClickCapture: t10
498
511
  });
499
- $[24] = props;
500
- $[25] = t3;
501
- $[26] = t4;
502
- $[27] = t5;
503
- $[28] = t6;
504
- $[29] = t7;
505
- $[30] = t8;
506
- $[31] = t9;
507
- $[32] = value;
508
- $[33] = t10;
509
- } else t10 = $[33];
510
- return t10;
512
+ $[23] = props;
513
+ $[24] = t10;
514
+ $[25] = t4;
515
+ $[26] = t5;
516
+ $[27] = t6;
517
+ $[28] = t7;
518
+ $[29] = t8;
519
+ $[30] = t9;
520
+ $[31] = value;
521
+ $[32] = t11;
522
+ } else t11 = $[32];
523
+ return t11;
511
524
  };
512
525
  const Embed = (t0) => {
513
- const $ = c(39);
514
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
515
- for (let $i = 0; $i < 39; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
516
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
517
- }
526
+ const $ = c(40);
518
527
  const { name, children } = t0;
519
528
  const selectTarget = usePreviewSelection();
520
529
  const blockContext = React.use(Context);
@@ -522,26 +531,37 @@ function createEditableBlock(options) {
522
531
  const { blockId, content, mode } = blockContext;
523
532
  const isContentEditable = useIsEditable(mode);
524
533
  const { window: iframeWindow } = useFrame();
525
- const repeaterContext = React.use(RepeaterItemContext);
534
+ const repeaterContext = React.use(RepeatableItemContext);
526
535
  const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
536
+ const reference = React.use(ReferenceContext);
527
537
  const t1 = String(name);
528
- let t2;
529
- if ($[1] !== blockId || $[2] !== repeaterContext || $[3] !== t1) {
530
- t2 = getOverlayFieldId(blockId, repeaterContext, t1);
531
- $[1] = blockId;
532
- $[2] = repeaterContext;
533
- $[3] = t1;
534
- $[4] = t2;
535
- } else t2 = $[4];
536
- const fieldId = t2;
538
+ const t2 = repeaterContext?.itemId;
539
+ let t3;
540
+ if ($[0] !== blockId || $[1] !== reference || $[2] !== t1 || $[3] !== t2) {
541
+ t3 = getOverlayFieldId(blockId, t1, {
542
+ itemId: t2,
543
+ reference
544
+ });
545
+ $[0] = blockId;
546
+ $[1] = reference;
547
+ $[2] = t1;
548
+ $[3] = t2;
549
+ $[4] = t3;
550
+ } else t3 = $[4];
551
+ const fieldId = t3;
537
552
  const [isHovered, setIsHovered] = React.useState(false);
538
- const overlayState = useOverlayState(isHovered);
553
+ const isRecordFieldSelected = useRecordSelection(reference?.placement ?? null, String(name));
554
+ const overlayState = useOverlayState(isHovered, reference != null && isRecordFieldSelected);
539
555
  const embedRef = React.useRef(null);
540
556
  const itemId = repeaterContext?.itemId;
541
- let t3;
542
- if ($[5] !== blockId || $[6] !== isContentEditable || $[7] !== itemId || $[8] !== name || $[9] !== selectTarget) {
543
- t3 = (event) => {
557
+ let t4;
558
+ if ($[5] !== blockId || $[6] !== isContentEditable || $[7] !== itemId || $[8] !== name || $[9] !== reference || $[10] !== selectTarget) {
559
+ t4 = () => {
544
560
  if (!isContentEditable) return;
561
+ if (reference) {
562
+ reference.selectRecordField(String(name), "Embed");
563
+ return;
564
+ }
545
565
  selectTarget(itemId != null ? {
546
566
  type: "item-field",
547
567
  blockId,
@@ -553,20 +573,21 @@ function createEditableBlock(options) {
553
573
  blockId,
554
574
  fieldName: String(name),
555
575
  fieldType: "Embed"
556
- }, event);
576
+ });
557
577
  };
558
578
  $[5] = blockId;
559
579
  $[6] = isContentEditable;
560
580
  $[7] = itemId;
561
581
  $[8] = name;
562
- $[9] = selectTarget;
563
- $[10] = t3;
564
- } else t3 = $[10];
565
- const selectField = t3;
566
- let t4;
582
+ $[9] = reference;
583
+ $[10] = selectTarget;
584
+ $[11] = t4;
585
+ } else t4 = $[11];
586
+ const selectField = t4;
567
587
  let t5;
568
- if ($[11] !== iframeWindow || $[12] !== isContentEditable || $[13] !== selectField) {
569
- t4 = () => {
588
+ let t6;
589
+ if ($[12] !== iframeWindow || $[13] !== isContentEditable || $[14] !== selectField) {
590
+ t5 = () => {
570
591
  if (!isContentEditable || !iframeWindow) return;
571
592
  let timer;
572
593
  const handleBlur = () => {
@@ -575,11 +596,7 @@ function createEditableBlock(options) {
575
596
  const activeElement = iframeWindow.document.activeElement;
576
597
  if (activeElement?.tagName !== "IFRAME") return;
577
598
  if (!embedRef.current?.contains(activeElement)) return;
578
- selectField({
579
- currentTarget: embedRef.current,
580
- preventDefault() {},
581
- stopPropagation() {}
582
- });
599
+ selectField();
583
600
  }, 0);
584
601
  };
585
602
  iframeWindow.addEventListener("blur", handleBlur);
@@ -588,50 +605,46 @@ function createEditableBlock(options) {
588
605
  iframeWindow.removeEventListener("blur", handleBlur);
589
606
  };
590
607
  };
591
- t5 = [
608
+ t6 = [
592
609
  isContentEditable,
593
610
  iframeWindow,
594
611
  selectField
595
612
  ];
596
- $[11] = iframeWindow;
597
- $[12] = isContentEditable;
598
- $[13] = selectField;
599
- $[14] = t4;
613
+ $[12] = iframeWindow;
614
+ $[13] = isContentEditable;
615
+ $[14] = selectField;
600
616
  $[15] = t5;
617
+ $[16] = t6;
601
618
  } else {
602
- t4 = $[14];
603
619
  t5 = $[15];
620
+ t6 = $[16];
604
621
  }
605
- React.useEffect(t4, t5);
606
- let t6;
607
- if ($[16] !== fieldId) {
608
- t6 = { fieldId };
609
- $[16] = fieldId;
610
- $[17] = t6;
611
- } else t6 = $[17];
612
- const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t6);
622
+ React.useEffect(t5, t6);
613
623
  let t7;
614
- let t8;
615
- if ($[18] !== isHoveredFromSidebar) {
616
- t7 = () => {
617
- setIsHovered(isHoveredFromSidebar);
618
- };
619
- t8 = [isHoveredFromSidebar];
620
- $[18] = isHoveredFromSidebar;
621
- $[19] = t7;
622
- $[20] = t8;
623
- } else {
624
- t7 = $[19];
625
- t8 = $[20];
624
+ if ($[17] !== fieldId) {
625
+ t7 = { fieldId };
626
+ $[17] = fieldId;
627
+ $[18] = t7;
628
+ } else t7 = $[18];
629
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t7);
630
+ const [prevSidebarHover, setPrevSidebarHover] = React.useState(isHoveredFromSidebar);
631
+ if (prevSidebarHover !== isHoveredFromSidebar) {
632
+ setPrevSidebarHover(isHoveredFromSidebar);
633
+ setIsHovered(isHoveredFromSidebar);
626
634
  }
627
- React.useEffect(t7, t8);
628
- const t9 = isContentEditable ? fieldId : void 0;
629
- const t10 = isContentEditable ? "embed" : void 0;
635
+ const t8 = isContentEditable ? fieldId : void 0;
636
+ const t9 = isContentEditable ? "embed" : void 0;
637
+ let t10;
638
+ if ($[19] !== isContentEditable || $[20] !== overlayState) {
639
+ t10 = isContentEditable ? overlayState : {};
640
+ $[19] = isContentEditable;
641
+ $[20] = overlayState;
642
+ $[21] = t10;
643
+ } else t10 = $[21];
630
644
  let t11;
631
- if ($[21] !== isContentEditable || $[22] !== overlayState) {
632
- t11 = isContentEditable ? overlayState : {};
633
- $[21] = isContentEditable;
634
- $[22] = overlayState;
645
+ if ($[22] !== reference) {
646
+ t11 = assetOverlayMode(reference);
647
+ $[22] = reference;
635
648
  $[23] = t11;
636
649
  } else t11 = $[23];
637
650
  let t12;
@@ -654,14 +667,14 @@ function createEditableBlock(options) {
654
667
  $[30] = t14;
655
668
  } else t14 = $[30];
656
669
  let t15;
657
- if ($[31] !== selectField || $[32] !== t10 || $[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14 || $[37] !== t9) {
670
+ if ($[31] !== selectField || $[32] !== t10 || $[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14 || $[37] !== t8 || $[38] !== t9) {
658
671
  t15 = /* @__PURE__ */ jsx("div", {
659
672
  ref: embedRef,
660
673
  onClickCapture: selectField,
661
- "data-camox-field-id": t9,
662
- "data-camox-field-type": t10,
663
- ...t11,
664
- "data-camox-overlay-mode": options.synced ? "synced" : void 0,
674
+ "data-camox-field-id": t8,
675
+ "data-camox-field-type": t9,
676
+ ...t10,
677
+ "data-camox-overlay-mode": t11,
665
678
  onMouseEnter: t12,
666
679
  onMouseLeave: t13,
667
680
  children: t14
@@ -672,101 +685,282 @@ function createEditableBlock(options) {
672
685
  $[34] = t12;
673
686
  $[35] = t13;
674
687
  $[36] = t14;
675
- $[37] = t9;
676
- $[38] = t15;
677
- } else t15 = $[38];
688
+ $[37] = t8;
689
+ $[38] = t9;
690
+ $[39] = t15;
691
+ } else t15 = $[39];
678
692
  return t15;
679
693
  };
694
+ const Artifact = (t0) => {
695
+ const $ = c(53);
696
+ const { name, children } = t0;
697
+ const selectTarget = usePreviewSelection();
698
+ const blockContext = React.use(Context);
699
+ if (!blockContext) throw new Error("Artifact must be used within a Block Component");
700
+ const { blockId, content, mode } = blockContext;
701
+ const isContentEditable = useIsEditable(mode);
702
+ const { window: iframeWindow } = useFrame();
703
+ const repeaterContext = React.use(RepeatableItemContext);
704
+ const value = repeaterContext ? repeaterContext.itemContent[name] : content[name];
705
+ const itemId = repeaterContext?.itemId;
706
+ const fieldName = String(name);
707
+ let t1;
708
+ if ($[0] !== blockId || $[1] !== fieldName || $[2] !== itemId) {
709
+ t1 = getOverlayFieldId(blockId, fieldName, { itemId });
710
+ $[0] = blockId;
711
+ $[1] = fieldName;
712
+ $[2] = itemId;
713
+ $[3] = t1;
714
+ } else t1 = $[3];
715
+ const fieldId = t1;
716
+ const [isHovered, setIsHovered] = React.useState(false);
717
+ let t2;
718
+ if ($[4] !== fieldId) {
719
+ t2 = { fieldId };
720
+ $[4] = fieldId;
721
+ $[5] = t2;
722
+ } else t2 = $[5];
723
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t2);
724
+ const overlayState = useOverlayState(isHovered || isHoveredFromSidebar);
725
+ let t3;
726
+ if ($[6] !== blockId || $[7] !== fieldName || $[8] !== itemId || $[9] !== selectTarget) {
727
+ t3 = () => {
728
+ selectTarget(itemId != null ? {
729
+ type: "item-field",
730
+ blockId,
731
+ itemId,
732
+ fieldName,
733
+ fieldType: "Artifact"
734
+ } : {
735
+ type: "block-field",
736
+ blockId,
737
+ fieldName,
738
+ fieldType: "Artifact"
739
+ });
740
+ };
741
+ $[6] = blockId;
742
+ $[7] = fieldName;
743
+ $[8] = itemId;
744
+ $[9] = selectTarget;
745
+ $[10] = t3;
746
+ } else t3 = $[10];
747
+ const selectField = t3;
748
+ const { filesMap } = useNormalizedData();
749
+ const pages = useEditorLinkPages();
750
+ let t4;
751
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
752
+ t4 = { select: _temp2 };
753
+ $[11] = t4;
754
+ } else t4 = $[11];
755
+ const currentPathname = useLocation(t4);
756
+ let t5;
757
+ if ($[12] !== blockContext.settings || $[13] !== content || $[14] !== currentPathname || $[15] !== fieldName || $[16] !== filesMap || $[17] !== pages || $[18] !== repeaterContext) {
758
+ let t6;
759
+ if ($[20] !== currentPathname || $[21] !== pages) {
760
+ t6 = (link) => resolveLinkHref(normalizeLinkValue(link), pages, currentPathname);
761
+ $[20] = currentPathname;
762
+ $[21] = pages;
763
+ $[22] = t6;
764
+ } else t6 = $[22];
765
+ let t7;
766
+ if ($[23] !== filesMap) {
767
+ t7 = (asset) => resolveAssetValue(asset, filesMap);
768
+ $[23] = filesMap;
769
+ $[24] = t7;
770
+ } else t7 = $[24];
771
+ t5 = artifactData(repeaterContext ? repeaterContext.itemSchema?.[fieldName] : typeboxSchema.properties[fieldName], repeaterContext ? {
772
+ content: repeaterContext.itemContent,
773
+ settings: repeaterContext.itemSettings
774
+ } : {
775
+ content,
776
+ settings: blockContext.settings
777
+ }, {
778
+ linkHref: t6,
779
+ asset: t7
780
+ });
781
+ $[12] = blockContext.settings;
782
+ $[13] = content;
783
+ $[14] = currentPathname;
784
+ $[15] = fieldName;
785
+ $[16] = filesMap;
786
+ $[17] = pages;
787
+ $[18] = repeaterContext;
788
+ $[19] = t5;
789
+ } else t5 = $[19];
790
+ const data = t5;
791
+ const canvas = React.use(CanvasWorkspaceContext) !== null;
792
+ const fieldSchema = repeaterContext ? repeaterContext.itemSchema?.[fieldName] : (blockContext.sourceSchema ?? typeboxSchema.properties)[fieldName];
793
+ let t6;
794
+ if ($[25] !== canvas || $[26] !== isContentEditable) {
795
+ t6 = {
796
+ editing: isContentEditable,
797
+ canvas
798
+ };
799
+ $[25] = canvas;
800
+ $[26] = isContentEditable;
801
+ $[27] = t6;
802
+ } else t6 = $[27];
803
+ const t7 = fieldSchema?.size;
804
+ const t8 = useNavigate();
805
+ let t9;
806
+ if ($[28] !== data || $[29] !== t6 || $[30] !== t7 || $[31] !== t8) {
807
+ t9 = {
808
+ studio: t6,
809
+ data,
810
+ size: t7,
811
+ navigate: t8
812
+ };
813
+ $[28] = data;
814
+ $[29] = t6;
815
+ $[30] = t7;
816
+ $[31] = t8;
817
+ $[32] = t9;
818
+ } else t9 = $[32];
819
+ const hostProps = useArtifactHost(t9);
820
+ const initialData = useInitialArtifactData(value, data);
821
+ const fontLinks = useOptionalCamoxApp()?.getArtifactFontLinks();
822
+ const runs = React.use(ArtifactsRunContext);
823
+ const frame = children({
824
+ ...!isArtifactSource(value) ? artifactPlaceholderProps() : runs ? artifactFrameProps(value, {
825
+ fontLinks,
826
+ data: initialData
827
+ }) : artifactStandInProps(value),
828
+ ...hostProps
829
+ });
830
+ let t10;
831
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
832
+ t10 = {
833
+ position: "relative",
834
+ height: "100%"
835
+ };
836
+ $[33] = t10;
837
+ } else t10 = $[33];
838
+ const t11 = isContentEditable ? selectField : void 0;
839
+ const t12 = isContentEditable ? fieldId : void 0;
840
+ const t13 = isContentEditable ? "artifact" : void 0;
841
+ let t14;
842
+ if ($[34] !== isContentEditable || $[35] !== overlayState) {
843
+ t14 = isContentEditable ? overlayState : {};
844
+ $[34] = isContentEditable;
845
+ $[35] = overlayState;
846
+ $[36] = t14;
847
+ } else t14 = $[36];
848
+ let t15;
849
+ if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
850
+ t15 = assetOverlayMode(null);
851
+ $[37] = t15;
852
+ } else t15 = $[37];
853
+ let t16;
854
+ if ($[38] !== isContentEditable) {
855
+ t16 = isContentEditable ? () => setIsHovered(true) : void 0;
856
+ $[38] = isContentEditable;
857
+ $[39] = t16;
858
+ } else t16 = $[39];
859
+ let t17;
860
+ if ($[40] !== isContentEditable) {
861
+ t17 = isContentEditable ? () => setIsHovered(false) : void 0;
862
+ $[40] = isContentEditable;
863
+ $[41] = t17;
864
+ } else t17 = $[41];
865
+ let t18;
866
+ if ($[42] !== isContentEditable) {
867
+ t18 = isContentEditable && /* @__PURE__ */ jsx("div", {
868
+ "aria-hidden": true,
869
+ "data-camox-artifact-layer": "",
870
+ style: {
871
+ position: "absolute",
872
+ inset: 0,
873
+ cursor: "pointer"
874
+ }
875
+ });
876
+ $[42] = isContentEditable;
877
+ $[43] = t18;
878
+ } else t18 = $[43];
879
+ let t19;
880
+ if ($[44] !== frame || $[45] !== t11 || $[46] !== t12 || $[47] !== t13 || $[48] !== t14 || $[49] !== t16 || $[50] !== t17 || $[51] !== t18) {
881
+ t19 = /* @__PURE__ */ jsxs("div", {
882
+ style: t10,
883
+ onClickCapture: t11,
884
+ "data-camox-field-id": t12,
885
+ "data-camox-field-type": t13,
886
+ ...t14,
887
+ "data-camox-overlay-mode": t15,
888
+ onMouseEnter: t16,
889
+ onMouseLeave: t17,
890
+ children: [frame, t18]
891
+ });
892
+ $[44] = frame;
893
+ $[45] = t11;
894
+ $[46] = t12;
895
+ $[47] = t13;
896
+ $[48] = t14;
897
+ $[49] = t16;
898
+ $[50] = t17;
899
+ $[51] = t18;
900
+ $[52] = t19;
901
+ } else t19 = $[52];
902
+ return t19;
903
+ };
680
904
  const Link = (t0) => {
681
- const $ = c(32);
682
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
683
- for (let $i = 0; $i < 32; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
684
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
685
- }
905
+ const $ = c(21);
686
906
  const { name, children } = t0;
687
907
  const selectTarget = usePreviewSelection();
688
- const isCommentMode = useSelector(previewStore, selectIsCommentMode);
689
908
  const blockContext = React.use(Context);
690
909
  if (!blockContext) throw new Error("Link must be used within a Block Component");
691
910
  const { blockId, content, mode } = blockContext;
692
911
  const isContentEditable = useIsEditable(mode);
693
912
  const elementRef = React.useRef(null);
694
913
  const { window: iframeWindow } = useFrame();
695
- const repeaterContext = React.use(RepeaterItemContext);
696
- const fieldValue = normalizeLinkValue(repeaterContext ? repeaterContext.itemContent[name] : content[name]);
914
+ const repeaterContext = React.use(RepeatableItemContext);
915
+ const rawFieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
916
+ const fieldValue = normalizeLinkValue(rawFieldValue);
697
917
  let t1;
698
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
918
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
699
919
  t1 = blockMutations.updateContent();
700
- $[1] = t1;
701
- } else t1 = $[1];
920
+ $[0] = t1;
921
+ } else t1 = $[0];
702
922
  const updateBlockContent = useMutation(t1);
703
923
  let t2;
704
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
924
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
705
925
  t2 = repeatableItemMutations.updateContent();
706
- $[2] = t2;
707
- } else t2 = $[2];
926
+ $[1] = t2;
927
+ } else t2 = $[1];
708
928
  const updateRepeatableContent = useMutation(t2);
709
- const projectSlug = useProjectSlug();
929
+ const pages = useEditorLinkPages();
710
930
  let t3;
711
- if ($[3] !== projectSlug) {
712
- t3 = projectQueries.getBySlug(projectSlug);
713
- $[3] = projectSlug;
714
- $[4] = t3;
715
- } else t3 = $[4];
716
- const { data: project } = useQuery(t3);
717
- let t4;
718
- if ($[5] !== project?.id) {
719
- t4 = pageQueries.list(project?.id ?? 0);
720
- $[5] = project?.id;
721
- $[6] = t4;
722
- } else t4 = $[6];
723
- const t5 = !!project;
724
- let t6;
725
- if ($[7] !== t4 || $[8] !== t5) {
726
- t6 = {
727
- ...t4,
728
- enabled: t5
729
- };
730
- $[7] = t4;
731
- $[8] = t5;
732
- $[9] = t6;
733
- } else t6 = $[9];
734
- const { data: pages } = useQuery(t6);
735
- let t7;
736
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
737
- t7 = { select: _temp2 };
738
- $[10] = t7;
739
- } else t7 = $[10];
740
- const resolvedHref = resolveLinkHref(fieldValue, pages, useLocation(t7));
741
- const fieldId = getOverlayFieldId(blockId, repeaterContext, String(name));
931
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
932
+ t3 = { select: _temp3 };
933
+ $[2] = t3;
934
+ } else t3 = $[2];
935
+ const currentPathname = useLocation(t3);
936
+ const resolvedHref = resolveLinkHref(fieldValue, pages, currentPathname);
937
+ const fieldId = getOverlayFieldId(blockId, String(name), { itemId: repeaterContext?.itemId });
742
938
  const [isEditing, setIsEditing] = React.useState(false);
743
939
  const [displayText, setDisplayText] = React.useState(fieldValue.text);
744
940
  const [isHovered, setIsHovered] = React.useState(false);
745
941
  const [isEditorFocused, setIsEditorFocused] = React.useState(false);
746
942
  const isSelectedFromSelection = useFieldSelection(blockId, String(name), "Link", repeaterContext?.itemId);
747
943
  const overlayState = useOverlayState(isHovered, isEditorFocused || isSelectedFromSelection);
748
- React.useEffect(() => {
944
+ const [syncedText, setSyncedText] = React.useState({
945
+ text: fieldValue.text,
946
+ isEditing
947
+ });
948
+ if (syncedText.text !== fieldValue.text || syncedText.isEditing !== isEditing) {
949
+ setSyncedText({
950
+ text: fieldValue.text,
951
+ isEditing
952
+ });
749
953
  if (!isEditing) setDisplayText(fieldValue.text);
750
- }, [fieldValue.text, isEditing]);
954
+ }
751
955
  const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", { fieldId });
752
- let t8;
753
- let t9;
754
- if ($[11] !== isHoveredFromSidebar) {
755
- t8 = () => {
756
- setIsHovered(isHoveredFromSidebar);
757
- };
758
- t9 = [isHoveredFromSidebar];
759
- $[11] = isHoveredFromSidebar;
760
- $[12] = t8;
761
- $[13] = t9;
762
- } else {
763
- t8 = $[12];
764
- t9 = $[13];
956
+ const [prevSidebarHover, setPrevSidebarHover] = React.useState(isHoveredFromSidebar);
957
+ if (prevSidebarHover !== isHoveredFromSidebar) {
958
+ setPrevSidebarHover(isHoveredFromSidebar);
959
+ setIsHovered(isHoveredFromSidebar);
765
960
  }
766
- React.useEffect(t8, t9);
767
- let t10;
768
- if ($[14] !== blockId || $[15] !== name || $[16] !== repeaterContext || $[17] !== updateBlockContent || $[18] !== updateRepeatableContent) {
769
- t10 = (newLinkValue) => {
961
+ let t4;
962
+ if ($[3] !== blockId || $[4] !== name || $[5] !== repeaterContext || $[6] !== updateBlockContent || $[7] !== updateRepeatableContent) {
963
+ t4 = (newLinkValue) => {
770
964
  if (repeaterContext?.itemId != null) updateRepeatableContent.mutate({
771
965
  id: repeaterContext.itemId,
772
966
  content: { [name]: newLinkValue }
@@ -776,14 +970,14 @@ function createEditableBlock(options) {
776
970
  content: { [name]: newLinkValue }
777
971
  });
778
972
  };
779
- $[14] = blockId;
780
- $[15] = name;
781
- $[16] = repeaterContext;
782
- $[17] = updateBlockContent;
783
- $[18] = updateRepeatableContent;
784
- $[19] = t10;
785
- } else t10 = $[19];
786
- const saveLinkValue = t10;
973
+ $[3] = blockId;
974
+ $[4] = name;
975
+ $[5] = repeaterContext;
976
+ $[6] = updateBlockContent;
977
+ $[7] = updateRepeatableContent;
978
+ $[8] = t4;
979
+ } else t4 = $[8];
980
+ const saveLinkValue = t4;
787
981
  const handleInput = (e) => {
788
982
  const newText = e.target.textContent || "";
789
983
  saveLinkValue({
@@ -791,9 +985,9 @@ function createEditableBlock(options) {
791
985
  text: newText
792
986
  });
793
987
  };
794
- let t11;
795
- if ($[20] !== blockId || $[21] !== name || $[22] !== repeaterContext || $[23] !== selectTarget) {
796
- t11 = (event) => {
988
+ let t5;
989
+ if ($[9] !== blockId || $[10] !== name || $[11] !== repeaterContext || $[12] !== selectTarget) {
990
+ t5 = () => {
797
991
  selectTarget(repeaterContext?.itemId != null ? {
798
992
  type: "item-field",
799
993
  blockId,
@@ -805,36 +999,35 @@ function createEditableBlock(options) {
805
999
  blockId,
806
1000
  fieldName: String(name),
807
1001
  fieldType: "Link"
808
- }, event);
1002
+ });
809
1003
  };
810
- $[20] = blockId;
811
- $[21] = name;
812
- $[22] = repeaterContext;
813
- $[23] = selectTarget;
814
- $[24] = t11;
815
- } else t11 = $[24];
816
- const selectField = t11;
817
- let t12;
818
- if ($[25] !== selectField) {
819
- t12 = () => {
820
- if (selectIsCommentMode(previewStore.getSnapshot())) return;
1004
+ $[9] = blockId;
1005
+ $[10] = name;
1006
+ $[11] = repeaterContext;
1007
+ $[12] = selectTarget;
1008
+ $[13] = t5;
1009
+ } else t5 = $[13];
1010
+ const selectField = t5;
1011
+ let t6;
1012
+ if ($[14] !== selectField) {
1013
+ t6 = () => {
821
1014
  setIsEditing(true);
822
1015
  setIsEditorFocused(true);
823
1016
  selectField();
824
1017
  };
825
- $[25] = selectField;
826
- $[26] = t12;
827
- } else t12 = $[26];
828
- const handleFocus = t12;
829
- let t13;
830
- if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
831
- t13 = () => {
1018
+ $[14] = selectField;
1019
+ $[15] = t6;
1020
+ } else t6 = $[15];
1021
+ const handleFocus = t6;
1022
+ let t7;
1023
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
1024
+ t7 = () => {
832
1025
  setIsEditing(false);
833
1026
  setIsEditorFocused(false);
834
1027
  };
835
- $[27] = t13;
836
- } else t13 = $[27];
837
- const handleBlur = t13;
1028
+ $[16] = t7;
1029
+ } else t7 = $[16];
1030
+ const handleBlur = t7;
838
1031
  const linkData = {
839
1032
  text: displayText,
840
1033
  href: resolvedHref,
@@ -846,18 +1039,18 @@ function createEditableBlock(options) {
846
1039
  rel: fieldValue.newTab ? "noreferrer" : void 0,
847
1040
  children: fieldValue.text
848
1041
  }, linkData) });
849
- let t14;
850
- let t15;
851
- if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
852
- t14 = () => setIsHovered(true);
853
- t15 = () => setIsHovered(false);
854
- $[28] = t14;
855
- $[29] = t15;
1042
+ let t8;
1043
+ let t9;
1044
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
1045
+ t8 = () => setIsHovered(true);
1046
+ t9 = () => setIsHovered(false);
1047
+ $[17] = t8;
1048
+ $[18] = t9;
856
1049
  } else {
857
- t14 = $[28];
858
- t15 = $[29];
1050
+ t8 = $[17];
1051
+ t9 = $[18];
859
1052
  }
860
- const t16 = children({
1053
+ const t10 = children({
861
1054
  ref: elementRef,
862
1055
  to: resolvedHref,
863
1056
  target: fieldValue.newTab ? "_blank" : void 0,
@@ -866,32 +1059,32 @@ function createEditableBlock(options) {
866
1059
  "data-camox-field-id": fieldId,
867
1060
  ...overlayState,
868
1061
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
869
- contentEditable: !isCommentMode,
1062
+ contentEditable: true,
870
1063
  onClickCapture: selectField,
871
- onClick: _temp3,
1064
+ onClick: _temp4,
872
1065
  onInput: handleInput,
873
1066
  onFocus: handleFocus,
874
1067
  onBlur: handleBlur,
875
- onMouseEnter: t14,
876
- onMouseLeave: t15,
877
- onKeyDown: _temp4,
1068
+ onMouseEnter: t8,
1069
+ onMouseLeave: t9,
1070
+ onKeyDown: _temp5,
878
1071
  spellCheck: false,
879
1072
  suppressContentEditableWarning: true
880
1073
  }, linkData);
881
- let t17;
882
- if ($[30] !== t16) {
883
- t17 = /* @__PURE__ */ jsx(Fragment, { children: t16 });
884
- $[30] = t16;
885
- $[31] = t17;
886
- } else t17 = $[31];
887
- return t17;
1074
+ let t11;
1075
+ if ($[19] !== t10) {
1076
+ t11 = /* @__PURE__ */ jsx(Fragment, { children: t10 });
1077
+ $[19] = t10;
1078
+ $[20] = t11;
1079
+ } else t11 = $[20];
1080
+ return t11;
1081
+ };
1082
+ const assetOverlayMode = (reference) => {
1083
+ if (reference) return "reference";
1084
+ return options.synced ? "synced" : void 0;
888
1085
  };
889
1086
  const Image = (t0) => {
890
- const $ = c(22);
891
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
892
- for (let $i = 0; $i < 22; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
893
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
894
- }
1087
+ const $ = c(30);
895
1088
  const { name, children } = t0;
896
1089
  const selectTarget = usePreviewSelection();
897
1090
  const blockContext = React.use(Context);
@@ -899,44 +1092,53 @@ function createEditableBlock(options) {
899
1092
  const { blockId, content, mode } = blockContext;
900
1093
  const isContentEditable = useIsEditable(mode);
901
1094
  const { window: iframeWindow } = useFrame();
902
- const repeaterContext = React.use(RepeaterItemContext);
1095
+ const repeaterContext = React.use(RepeatableItemContext);
903
1096
  const { filesMap } = useNormalizedData();
904
1097
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
905
- const rawValue = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
1098
+ const rawValue = resolveAssetValue(rawSource, filesMap);
906
1099
  const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
907
1100
  const fieldValue = rawValue ?? defaultValue;
908
1101
  const isInlineArrayItem = repeaterContext != null && repeaterContext.itemId == null;
909
1102
  const overlayFieldName = isInlineArrayItem ? repeaterContext.arrayFieldName : String(name);
910
1103
  const overlayItemId = isInlineArrayItem ? repeaterContext.containerItemId : repeaterContext?.itemId;
911
- const fieldId = overlayItemId != null ? `${blockId}__${overlayItemId}__${overlayFieldName}` : `${blockId}__${overlayFieldName}`;
912
- const [isHovered, setIsHovered] = React.useState(false);
913
- const overlayState = useOverlayState(isHovered, useFieldSelection(blockId, overlayFieldName, "Image", overlayItemId));
1104
+ const reference = React.use(ReferenceContext);
914
1105
  let t1;
915
- if ($[1] !== fieldId) {
916
- t1 = { fieldId };
917
- $[1] = fieldId;
918
- $[2] = t1;
919
- } else t1 = $[2];
920
- const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t1);
1106
+ if ($[0] !== blockId || $[1] !== overlayFieldName || $[2] !== overlayItemId || $[3] !== reference) {
1107
+ t1 = getOverlayFieldId(blockId, overlayFieldName, {
1108
+ itemId: overlayItemId,
1109
+ reference
1110
+ });
1111
+ $[0] = blockId;
1112
+ $[1] = overlayFieldName;
1113
+ $[2] = overlayItemId;
1114
+ $[3] = reference;
1115
+ $[4] = t1;
1116
+ } else t1 = $[4];
1117
+ const fieldId = t1;
1118
+ const [isHovered, setIsHovered] = React.useState(false);
1119
+ const isBlockFieldSelected = useFieldSelection(blockId, overlayFieldName, "Image", overlayItemId);
1120
+ const isRecordFieldSelected = useRecordSelection(reference?.placement ?? null, overlayFieldName);
1121
+ const overlayState = useOverlayState(isHovered, reference ? isRecordFieldSelected : isBlockFieldSelected);
921
1122
  let t2;
922
- let t3;
923
- if ($[3] !== isHoveredFromSidebar) {
924
- t2 = () => {
925
- setIsHovered(isHoveredFromSidebar);
926
- };
927
- t3 = [isHoveredFromSidebar];
928
- $[3] = isHoveredFromSidebar;
929
- $[4] = t2;
930
- $[5] = t3;
931
- } else {
932
- t2 = $[4];
933
- t3 = $[5];
1123
+ if ($[5] !== fieldId) {
1124
+ t2 = { fieldId };
1125
+ $[5] = fieldId;
1126
+ $[6] = t2;
1127
+ } else t2 = $[6];
1128
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t2);
1129
+ const [prevSidebarHover, setPrevSidebarHover] = React.useState(isHoveredFromSidebar);
1130
+ if (prevSidebarHover !== isHoveredFromSidebar) {
1131
+ setPrevSidebarHover(isHoveredFromSidebar);
1132
+ setIsHovered(isHoveredFromSidebar);
934
1133
  }
935
- React.useEffect(t2, t3);
936
- let t4;
937
- if ($[6] !== blockId || $[7] !== isContentEditable || $[8] !== overlayFieldName || $[9] !== overlayItemId || $[10] !== selectTarget) {
938
- t4 = (event) => {
1134
+ let t3;
1135
+ if ($[7] !== blockId || $[8] !== isContentEditable || $[9] !== isInlineArrayItem || $[10] !== overlayFieldName || $[11] !== overlayItemId || $[12] !== reference || $[13] !== selectTarget) {
1136
+ t3 = () => {
939
1137
  if (!isContentEditable) return;
1138
+ if (reference) {
1139
+ reference.selectRecordField(overlayFieldName, isInlineArrayItem ? "ImageList" : "Image");
1140
+ return;
1141
+ }
940
1142
  selectTarget(overlayItemId != null ? {
941
1143
  type: "item-field",
942
1144
  blockId,
@@ -948,16 +1150,18 @@ function createEditableBlock(options) {
948
1150
  blockId,
949
1151
  fieldName: overlayFieldName,
950
1152
  fieldType: "Image"
951
- }, event);
1153
+ });
952
1154
  };
953
- $[6] = blockId;
954
- $[7] = isContentEditable;
955
- $[8] = overlayFieldName;
956
- $[9] = overlayItemId;
957
- $[10] = selectTarget;
958
- $[11] = t4;
959
- } else t4 = $[11];
960
- const handleClick = t4;
1155
+ $[7] = blockId;
1156
+ $[8] = isContentEditable;
1157
+ $[9] = isInlineArrayItem;
1158
+ $[10] = overlayFieldName;
1159
+ $[11] = overlayItemId;
1160
+ $[12] = reference;
1161
+ $[13] = selectTarget;
1162
+ $[14] = t3;
1163
+ } else t3 = $[14];
1164
+ const handleClick = t3;
961
1165
  const imageProps = {
962
1166
  src: transformImageUrl(fieldValue.url, {
963
1167
  width: getDefaultImageWidth(),
@@ -968,91 +1172,121 @@ function createEditableBlock(options) {
968
1172
  sizes: getDefaultImageSizes(),
969
1173
  alt: fieldValue.alt
970
1174
  };
971
- if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children(imageProps, fieldValue) });
972
- const t5 = "image";
973
- const t6 = options.synced ? "synced" : void 0;
974
- let t7;
975
- let t8;
976
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
977
- t7 = () => setIsHovered(true);
978
- t8 = () => setIsHovered(false);
979
- $[12] = t7;
980
- $[13] = t8;
1175
+ const renderedImage = renderImagePlaceholder(fieldValue, children(imageProps, fieldValue));
1176
+ if (!isContentEditable) {
1177
+ let t4;
1178
+ if ($[15] !== renderedImage) {
1179
+ t4 = /* @__PURE__ */ jsx(Fragment, { children: renderedImage });
1180
+ $[15] = renderedImage;
1181
+ $[16] = t4;
1182
+ } else t4 = $[16];
1183
+ return t4;
1184
+ }
1185
+ let t4;
1186
+ if ($[17] !== reference) {
1187
+ t4 = assetOverlayMode(reference);
1188
+ $[17] = reference;
1189
+ $[18] = t4;
1190
+ } else t4 = $[18];
1191
+ let t5;
1192
+ let t6;
1193
+ if ($[19] !== setIsHovered) {
1194
+ t5 = () => setIsHovered(true);
1195
+ t6 = () => setIsHovered(false);
1196
+ $[19] = setIsHovered;
1197
+ $[20] = t5;
1198
+ $[21] = t6;
981
1199
  } else {
982
- t7 = $[12];
983
- t8 = $[13];
1200
+ t5 = $[20];
1201
+ t6 = $[21];
984
1202
  }
985
- const t9 = children(imageProps, fieldValue);
986
- let t10;
987
- if ($[14] !== fieldId || $[15] !== handleClick || $[16] !== overlayState || $[17] !== t6 || $[18] !== t7 || $[19] !== t8 || $[20] !== t9) {
988
- t10 = /* @__PURE__ */ jsx("div", {
1203
+ let t7;
1204
+ if ($[22] !== fieldId || $[23] !== handleClick || $[24] !== overlayState || $[25] !== renderedImage || $[26] !== t4 || $[27] !== t5 || $[28] !== t6) {
1205
+ t7 = /* @__PURE__ */ jsx("div", {
989
1206
  "data-camox-field-id": fieldId,
990
- "data-camox-field-type": t5,
1207
+ "data-camox-field-type": "image",
991
1208
  ...overlayState,
992
- "data-camox-overlay-mode": t6,
993
- onMouseEnter: t7,
994
- onMouseLeave: t8,
1209
+ "data-camox-overlay-mode": t4,
1210
+ onMouseEnter: t5,
1211
+ onMouseLeave: t6,
995
1212
  onClickCapture: handleClick,
996
- children: t9
1213
+ children: renderedImage
997
1214
  });
998
- $[14] = fieldId;
999
- $[15] = handleClick;
1000
- $[16] = overlayState;
1001
- $[17] = t6;
1002
- $[18] = t7;
1003
- $[19] = t8;
1004
- $[20] = t9;
1005
- $[21] = t10;
1006
- } else t10 = $[21];
1007
- return t10;
1215
+ $[22] = fieldId;
1216
+ $[23] = handleClick;
1217
+ $[24] = overlayState;
1218
+ $[25] = renderedImage;
1219
+ $[26] = t4;
1220
+ $[27] = t5;
1221
+ $[28] = t6;
1222
+ $[29] = t7;
1223
+ } else t7 = $[29];
1224
+ return t7;
1008
1225
  };
1009
1226
  const File = (t0) => {
1010
- const $ = c(9);
1011
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
1012
- for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1013
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
1014
- }
1227
+ const $ = c(2);
1015
1228
  const { name, children } = t0;
1016
1229
  const blockContext = React.use(Context);
1017
1230
  if (!blockContext) throw new Error("File must be used within a Block Component");
1018
- const { content } = blockContext;
1019
- const repeaterContext = React.use(RepeaterItemContext);
1231
+ const { blockId, content, mode } = blockContext;
1232
+ const isContentEditable = useIsEditable(mode);
1233
+ const { window: iframeWindow } = useFrame();
1234
+ const repeaterContext = React.use(RepeatableItemContext);
1235
+ const reference = React.use(ReferenceContext);
1020
1236
  const { filesMap } = useNormalizedData();
1021
1237
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
1022
- let t1;
1023
- if ($[1] !== children || $[2] !== filesMap || $[3] !== name || $[4] !== rawSource || $[5] !== repeaterContext) {
1024
- const rawValue = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
1025
- const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
1026
- const fieldValue = rawValue ?? defaultValue;
1027
- t1 = children({
1028
- href: fieldValue.url,
1029
- download: fieldValue.filename
1030
- }, fieldValue);
1031
- $[1] = children;
1032
- $[2] = filesMap;
1033
- $[3] = name;
1034
- $[4] = rawSource;
1035
- $[5] = repeaterContext;
1036
- $[6] = t1;
1037
- } else t1 = $[6];
1238
+ const rawValue = resolveAssetValue(rawSource, filesMap);
1239
+ const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
1240
+ const fieldValue = rawValue ?? defaultValue;
1241
+ const isInlineArrayItem = repeaterContext != null && repeaterContext.itemId == null;
1242
+ const overlayFieldName = isInlineArrayItem ? repeaterContext.arrayFieldName : String(name);
1243
+ const fieldId = getOverlayFieldId(blockId, overlayFieldName, { reference });
1244
+ const selectable = reference != null && isContentEditable;
1245
+ const [isHovered, setIsHovered] = React.useState(false);
1246
+ const isFocused = useRecordSelection(reference?.placement ?? null, overlayFieldName);
1247
+ const overlayState = useOverlayState(isHovered, isFocused);
1248
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, selectable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", { fieldId });
1249
+ const [prevSidebarHover, setPrevSidebarHover] = React.useState(isHoveredFromSidebar);
1250
+ if (prevSidebarHover !== isHoveredFromSidebar) {
1251
+ setPrevSidebarHover(isHoveredFromSidebar);
1252
+ setIsHovered(isHoveredFromSidebar);
1253
+ }
1254
+ const linkProps = {
1255
+ href: fieldValue.url,
1256
+ download: fieldValue.filename
1257
+ };
1258
+ const editableLinkProps = selectable ? {
1259
+ "data-camox-field-id": fieldId,
1260
+ "data-camox-field-type": "file",
1261
+ ...overlayState,
1262
+ "data-camox-overlay-mode": assetOverlayMode(reference),
1263
+ onMouseEnter: () => setIsHovered(true),
1264
+ onMouseLeave: () => setIsHovered(false),
1265
+ onClickCapture: () => reference.selectRecordField(overlayFieldName, isInlineArrayItem ? "FileList" : "File"),
1266
+ onClick: _temp6
1267
+ } : null;
1268
+ const t1 = children({
1269
+ ...linkProps,
1270
+ ...editableLinkProps
1271
+ }, fieldValue);
1038
1272
  let t2;
1039
- if ($[7] !== t1) {
1273
+ if ($[0] !== t1) {
1040
1274
  t2 = /* @__PURE__ */ jsx(Fragment, { children: t1 });
1041
- $[7] = t1;
1042
- $[8] = t2;
1043
- } else t2 = $[8];
1275
+ $[0] = t1;
1276
+ $[1] = t2;
1277
+ } else t2 = $[1];
1044
1278
  return t2;
1045
1279
  };
1046
1280
  const ASSET_LIST_SELF_KEY = "__camox_asset_self__";
1047
1281
  const _AssetList = ({ name, children }) => {
1048
1282
  const blockContext = React.use(Context);
1049
1283
  if (!blockContext) throw new Error("ImageList/FileList must be used within a Block Component");
1050
- const parentRepeaterContext = React.use(RepeaterItemContext);
1284
+ const parentRepeaterContext = React.use(RepeatableItemContext);
1051
1285
  const { filesMap } = useNormalizedData();
1052
1286
  const fieldName = String(name);
1053
- const fieldSchema = parentRepeaterContext ? typeboxSchema.properties[parentRepeaterContext.arrayFieldName]?.items?.properties?.[fieldName] : typeboxSchema.properties[fieldName];
1287
+ const fieldSchema = parentRepeaterContext ? typeboxSchema.properties[parentRepeaterContext.arrayFieldName]?.items?.properties?.[fieldName] : (blockContext.sourceSchema ?? typeboxSchema.properties)[fieldName];
1054
1288
  const ft = fieldSchema?.fieldType;
1055
- if (ft !== "ImageList" && ft !== "FileList") throw new Error(`"${fieldName}" is not a Type.ImageList or Type.FileList field`);
1289
+ if (ft !== "ImageList" && ft !== "FileList") throw new Error(`"${fieldName}" is not an imageList or fileList field`);
1056
1290
  const source = parentRepeaterContext ? parentRepeaterContext.itemContent[fieldName] : blockContext.content[fieldName];
1057
1291
  let arr = Array.isArray(source) ? source : [];
1058
1292
  if (arr.length === 0) {
@@ -1060,12 +1294,12 @@ function createEditableBlock(options) {
1060
1294
  const itemDefault = fieldSchema.items?.default;
1061
1295
  if (defaultCount > 0 && itemDefault) arr = Array.from({ length: defaultCount }, () => itemDefault);
1062
1296
  }
1063
- const resolved = arr.map((v) => isFileMarker(v) ? resolveFileMarker(v, filesMap) : v).filter((v) => v != null && typeof v === "object" && "url" in v);
1297
+ const resolved = arr.map((v) => resolveAssetValue(v, filesMap)).filter((v) => v != null && typeof v === "object" && "url" in v);
1064
1298
  const Single = ft === "ImageList" ? Image : File;
1065
1299
  return /* @__PURE__ */ jsx(RepeaterHoverProvider, {
1066
1300
  blockId: blockContext.blockId,
1067
1301
  fieldName,
1068
- children: resolved.map((value, index) => /* @__PURE__ */ jsx(RepeaterItemContext.Provider, {
1302
+ children: resolved.map((value, index) => /* @__PURE__ */ jsx(RepeatableItemContext.Provider, {
1069
1303
  value: {
1070
1304
  arrayFieldName: fieldName,
1071
1305
  itemIndex: index,
@@ -1083,150 +1317,172 @@ function createEditableBlock(options) {
1083
1317
  };
1084
1318
  const ImageList = _AssetList;
1085
1319
  const FileList = _AssetList;
1086
- const RepeaterItemWrapper = (t0) => {
1087
- const $ = c(23);
1088
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
1089
- for (let $i = 0; $i < 23; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1090
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
1091
- }
1092
- const { itemId, blockId, mode, children } = t0;
1320
+ const RepeatableItemWrapper = (t0) => {
1321
+ const $ = c(21);
1322
+ const { itemId, blockId, nesting, mode, children } = t0;
1093
1323
  const isContentEditable = useIsEditable(mode);
1094
1324
  const { window: iframeWindow } = useFrame();
1095
- const selectTarget = usePreviewSelection();
1096
- const isCommentMode = useSelector(previewStore, selectIsCommentMode);
1325
+ const fragmentRef = React.useRef(null);
1326
+ const registrationRef = React.useRef(null);
1097
1327
  const [isLocallyHovered, setIsLocallyHovered] = React.useState(false);
1098
- const isRepeaterHovered = React.useContext(RepeaterHoverContext);
1099
- let t1;
1100
- if ($[1] !== blockId || $[2] !== itemId) {
1101
- t1 = (state) => {
1102
- const selection = state.context.selection;
1103
- return selection?.type === "item" && selection.blockId === blockId && selection.itemId === itemId;
1104
- };
1105
- $[1] = blockId;
1106
- $[2] = itemId;
1107
- $[3] = t1;
1108
- } else t1 = $[3];
1109
- const isSelected = useSelector(previewStore, t1);
1110
- const t2 = String(blockId);
1111
- const t3 = String(itemId);
1112
- let t4;
1113
- if ($[4] !== t2 || $[5] !== t3) {
1114
- t4 = {
1115
- blockId: t2,
1116
- itemId: t3
1328
+ const hoveredRepeaterGroup = React.useContext(RepeaterHoverContext);
1329
+ const selection = usePreviewTargetSelection();
1330
+ const isSelected = selection?.type === "item" && selection.blockId === blockId && selection.itemId === itemId;
1331
+ const t1 = String(blockId);
1332
+ const t2 = String(itemId);
1333
+ let t3;
1334
+ if ($[0] !== t1 || $[1] !== t2) {
1335
+ t3 = {
1336
+ blockId: t1,
1337
+ itemId: t2
1117
1338
  };
1118
- $[4] = t2;
1119
- $[5] = t3;
1120
- $[6] = t4;
1121
- } else t4 = $[6];
1122
- const overlayState = useOverlayState(useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER_ITEM", "CAMOX_HOVER_REPEATER_ITEM_END", t4) || isRepeaterHovered || isCommentMode && isLocallyHovered, isSelected);
1339
+ $[0] = t1;
1340
+ $[1] = t2;
1341
+ $[2] = t3;
1342
+ } else t3 = $[2];
1343
+ const t4 = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATABLE_ITEM", "CAMOX_HOVER_REPEATABLE_ITEM_END", t3) || hoveredRepeaterGroup !== null || isLocallyHovered;
1123
1344
  let t5;
1124
- if ($[7] !== blockId || $[8] !== isCommentMode || $[9] !== isContentEditable || $[10] !== itemId || $[11] !== selectTarget) {
1125
- t5 = (event) => {
1126
- if (!isContentEditable || !isCommentMode || itemId == null) return;
1127
- const target = event.target;
1128
- if (target.closest("[data-camox-field-id]")) return;
1129
- if (target.closest("[data-camox-repeater-item-id], [data-camox-block-id], [data-camox-comment-block-id]") !== event.currentTarget) return;
1130
- selectTarget({
1131
- type: "item",
1345
+ if ($[3] !== hoveredRepeaterGroup || $[4] !== isSelected || $[5] !== t4) {
1346
+ t5 = {
1347
+ hovered: t4,
1348
+ focused: isSelected,
1349
+ hoverGroup: hoveredRepeaterGroup,
1350
+ synced: !!options.synced
1351
+ };
1352
+ $[3] = hoveredRepeaterGroup;
1353
+ $[4] = isSelected;
1354
+ $[5] = t4;
1355
+ $[6] = t5;
1356
+ } else t5 = $[6];
1357
+ const overlayState = t5;
1358
+ const document = iframeWindow?.document;
1359
+ let t6;
1360
+ let t7;
1361
+ if ($[7] !== blockId || $[8] !== document || $[9] !== isContentEditable || $[10] !== itemId || $[11] !== nesting) {
1362
+ t6 = () => {
1363
+ const fragment = fragmentRef.current;
1364
+ if (!isContentEditable || itemId == null || !document || !fragment) return;
1365
+ const registration = registerRepeatableItem(document, {
1366
+ hovered: false,
1367
+ focused: false,
1368
+ hoverGroup: null,
1369
+ synced: false,
1370
+ fragment,
1132
1371
  blockId,
1133
- itemId
1134
- }, event);
1372
+ itemId,
1373
+ nesting
1374
+ });
1375
+ registrationRef.current = registration;
1376
+ return () => {
1377
+ registrationRef.current = null;
1378
+ registration.unregister();
1379
+ };
1135
1380
  };
1381
+ t7 = [
1382
+ isContentEditable,
1383
+ document,
1384
+ blockId,
1385
+ itemId,
1386
+ nesting
1387
+ ];
1136
1388
  $[7] = blockId;
1137
- $[8] = isCommentMode;
1389
+ $[8] = document;
1138
1390
  $[9] = isContentEditable;
1139
1391
  $[10] = itemId;
1140
- $[11] = selectTarget;
1141
- $[12] = t5;
1142
- } else t5 = $[12];
1143
- const handleClick = t5;
1144
- const t6 = isContentEditable ? itemId : void 0;
1145
- let t7;
1146
- let t8;
1147
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
1148
- t7 = () => setIsLocallyHovered(true);
1149
- t8 = () => setIsLocallyHovered(false);
1392
+ $[11] = nesting;
1393
+ $[12] = t6;
1150
1394
  $[13] = t7;
1151
- $[14] = t8;
1152
1395
  } else {
1396
+ t6 = $[12];
1153
1397
  t7 = $[13];
1154
- t8 = $[14];
1155
1398
  }
1156
- let t9;
1157
- if ($[15] !== isContentEditable || $[16] !== overlayState) {
1158
- t9 = isContentEditable ? overlayState : {};
1159
- $[15] = isContentEditable;
1160
- $[16] = overlayState;
1161
- $[17] = t9;
1162
- } else t9 = $[17];
1399
+ React.useLayoutEffect(t6, t7);
1400
+ let t8;
1401
+ if ($[14] !== overlayState) {
1402
+ t8 = () => {
1403
+ registrationRef.current?.update(overlayState);
1404
+ };
1405
+ $[14] = overlayState;
1406
+ $[15] = t8;
1407
+ } else t8 = $[15];
1408
+ React.useLayoutEffect(t8);
1163
1409
  let t10;
1164
- if ($[18] !== children || $[19] !== handleClick || $[20] !== t6 || $[21] !== t9) {
1165
- t10 = /* @__PURE__ */ jsx("div", {
1166
- "data-camox-repeater-item-id": t6,
1167
- onClickCapture: handleClick,
1168
- onMouseEnter: t7,
1169
- onMouseLeave: t8,
1170
- ...t9,
1171
- "data-camox-overlay-mode": options.synced ? "synced" : void 0,
1410
+ let t9;
1411
+ if ($[16] !== isContentEditable) {
1412
+ t9 = () => {
1413
+ const fragment_0 = fragmentRef.current;
1414
+ if (!isContentEditable || !fragment_0) return;
1415
+ const enter = () => setIsLocallyHovered(true);
1416
+ const leave = () => setIsLocallyHovered(false);
1417
+ fragment_0.addEventListener("mouseenter", enter);
1418
+ fragment_0.addEventListener("mouseleave", leave);
1419
+ return () => {
1420
+ fragment_0.removeEventListener("mouseenter", enter);
1421
+ fragment_0.removeEventListener("mouseleave", leave);
1422
+ };
1423
+ };
1424
+ t10 = [isContentEditable];
1425
+ $[16] = isContentEditable;
1426
+ $[17] = t10;
1427
+ $[18] = t9;
1428
+ } else {
1429
+ t10 = $[17];
1430
+ t9 = $[18];
1431
+ }
1432
+ React.useEffect(t9, t10);
1433
+ let t11;
1434
+ if ($[19] !== children) {
1435
+ t11 = /* @__PURE__ */ jsx(React.Fragment, {
1436
+ ref: fragmentRef,
1172
1437
  children
1173
1438
  });
1174
- $[18] = children;
1175
- $[19] = handleClick;
1176
- $[20] = t6;
1177
- $[21] = t9;
1178
- $[22] = t10;
1179
- } else t10 = $[22];
1180
- return t10;
1439
+ $[19] = children;
1440
+ $[20] = t11;
1441
+ } else t11 = $[20];
1442
+ return t11;
1181
1443
  };
1182
1444
  const RepeaterHoverProvider = (t0) => {
1183
- const $ = c(7);
1184
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
1185
- for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1186
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
1187
- }
1445
+ const $ = c(6);
1188
1446
  const { blockId, fieldName, children } = t0;
1189
1447
  const isContentEditable = useIsEditable("site");
1190
1448
  const { window: iframeWindow } = useFrame();
1449
+ const hoverGroup = React.useId();
1191
1450
  const t1 = String(blockId);
1192
1451
  let t2;
1193
- if ($[1] !== fieldName || $[2] !== t1) {
1452
+ if ($[0] !== fieldName || $[1] !== t1) {
1194
1453
  t2 = {
1195
1454
  blockId: t1,
1196
1455
  fieldName
1197
1456
  };
1198
- $[1] = fieldName;
1199
- $[2] = t1;
1200
- $[3] = t2;
1201
- } else t2 = $[3];
1202
- const isHovered = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER", "CAMOX_HOVER_REPEATER_END", t2);
1203
- let t3;
1204
- if ($[4] !== children || $[5] !== isHovered) {
1205
- t3 = /* @__PURE__ */ jsx(RepeaterHoverContext.Provider, {
1206
- value: isHovered,
1457
+ $[0] = fieldName;
1458
+ $[1] = t1;
1459
+ $[2] = t2;
1460
+ } else t2 = $[2];
1461
+ const t3 = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER", "CAMOX_HOVER_REPEATER_END", t2) ? hoverGroup : null;
1462
+ let t4;
1463
+ if ($[3] !== children || $[4] !== t3) {
1464
+ t4 = /* @__PURE__ */ jsx(RepeaterHoverContext.Provider, {
1465
+ value: t3,
1207
1466
  children
1208
1467
  });
1209
- $[4] = children;
1210
- $[5] = isHovered;
1211
- $[6] = t3;
1212
- } else t3 = $[6];
1213
- return t3;
1468
+ $[3] = children;
1469
+ $[4] = t3;
1470
+ $[5] = t4;
1471
+ } else t4 = $[5];
1472
+ return t4;
1214
1473
  };
1215
1474
  const Repeater = (t0) => {
1216
- const $ = c(27);
1217
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
1218
- for (let $i = 0; $i < 27; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1219
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
1220
- }
1475
+ const $ = c(29);
1221
1476
  const { name, children } = t0;
1222
1477
  const blockContext = React.use(Context);
1223
1478
  if (!blockContext) throw new Error("Repeater must be used within a Block Component");
1224
1479
  const { blockId, content, mode } = blockContext;
1225
- const parentRepeaterContext = React.use(RepeaterItemContext);
1480
+ const parentRepeaterContext = React.use(RepeatableItemContext);
1226
1481
  const fieldName = String(name);
1227
1482
  const ItemField = Field;
1228
1483
  const ItemLink = Link;
1229
1484
  const ItemEmbed = Embed;
1485
+ const ItemArtifact = Artifact;
1230
1486
  const ItemImage = Image;
1231
1487
  const ItemImageList = _AssetList;
1232
1488
  const ItemFileList = _AssetList;
@@ -1234,30 +1490,38 @@ function createEditableBlock(options) {
1234
1490
  const ItemRepeater = Repeater;
1235
1491
  const source = parentRepeaterContext ? parentRepeaterContext.itemContent[name] : content[name];
1236
1492
  const { itemsMap } = useNormalizedData();
1237
- let T0;
1238
1493
  let t1;
1494
+ if ($[0] !== source) {
1495
+ t1 = source ?? [];
1496
+ $[0] = source;
1497
+ $[1] = t1;
1498
+ } else t1 = $[1];
1499
+ const storedValue = t1;
1500
+ if (!Array.isArray(storedValue)) throw new Error(`Field "${String(name)}" is not an array`);
1501
+ let T0;
1239
1502
  let t2;
1240
1503
  let t3;
1241
- if ($[1] !== blockId || $[2] !== children || $[3] !== fieldName || $[4] !== itemsMap || $[5] !== mode || $[6] !== name || $[7] !== parentRepeaterContext?.containerItemId || $[8] !== source) {
1242
- let arrayValue = source ?? [];
1243
- if (!Array.isArray(arrayValue)) throw new Error(`Field "${String(name)}" is not an array`);
1244
- let t4;
1504
+ let t4;
1505
+ if ($[2] !== blockId || $[3] !== children || $[4] !== fieldName || $[5] !== itemsMap || $[6] !== mode || $[7] !== parentRepeaterContext || $[8] !== storedValue) {
1506
+ let t5;
1245
1507
  if ($[13] !== itemsMap) {
1246
- t4 = (item) => {
1508
+ t5 = (item) => {
1247
1509
  if (isItemMarker(item)) return itemsMap.get(item._itemId) ?? null;
1248
1510
  return item;
1249
1511
  };
1250
1512
  $[13] = itemsMap;
1251
- $[14] = t4;
1252
- } else t4 = $[14];
1253
- arrayValue = arrayValue.map(t4).filter(Boolean);
1513
+ $[14] = t5;
1514
+ } else t5 = $[14];
1515
+ const arrayValue = storedValue.map(t5).filter(Boolean);
1254
1516
  const settingsDefaultsForField = repeatableItemSettingsDefaults[fieldName];
1517
+ const itemSchema = (parentRepeaterContext ? parentRepeaterContext.itemSchema?.[fieldName] : typeboxSchema.properties[fieldName])?.items?.properties;
1518
+ const nesting = parentRepeaterContext ? (parentRepeaterContext.nesting ?? 0) + 1 : 0;
1255
1519
  T0 = RepeaterHoverProvider;
1256
- t1 = blockId;
1257
- t2 = fieldName;
1258
- let t5;
1259
- if ($[15] !== blockId || $[16] !== children || $[17] !== fieldName || $[18] !== mode || $[19] !== parentRepeaterContext?.containerItemId || $[20] !== settingsDefaultsForField) {
1260
- t5 = (item_0, index) => {
1520
+ t2 = blockId;
1521
+ t3 = fieldName;
1522
+ let t6;
1523
+ if ($[15] !== blockId || $[16] !== children || $[17] !== fieldName || $[18] !== itemSchema || $[19] !== mode || $[20] !== nesting || $[21] !== parentRepeaterContext?.containerItemId || $[22] !== settingsDefaultsForField) {
1524
+ t6 = (item_0, index) => {
1261
1525
  const isDbItem = item_0.content !== void 0 && item_0.id != null;
1262
1526
  const itemContent = {
1263
1527
  ...repeatableItemDefaults[fieldName],
@@ -1274,25 +1538,31 @@ function createEditableBlock(options) {
1274
1538
  Link: ItemLink,
1275
1539
  Icon,
1276
1540
  Embed: ItemEmbed,
1541
+ Artifact: ItemArtifact,
1277
1542
  Image: ItemImage,
1278
1543
  File: ItemFile,
1279
1544
  ImageList: ItemImageList,
1280
1545
  FileList: ItemFileList,
1281
1546
  Repeater: ItemRepeater,
1547
+ Reference,
1548
+ ReferenceList,
1282
1549
  useSetting: useItemSetting
1283
1550
  };
1284
- return /* @__PURE__ */ jsx(RepeaterItemContext.Provider, {
1551
+ return /* @__PURE__ */ jsx(RepeatableItemContext.Provider, {
1285
1552
  value: {
1286
1553
  arrayFieldName: fieldName,
1287
1554
  itemIndex: index,
1288
1555
  itemContent,
1289
1556
  itemSettings,
1290
1557
  itemId,
1291
- containerItemId: itemId ?? parentRepeaterContext?.containerItemId
1558
+ containerItemId: itemId ?? parentRepeaterContext?.containerItemId,
1559
+ itemSchema,
1560
+ nesting
1292
1561
  },
1293
- children: /* @__PURE__ */ jsx(RepeaterItemWrapper, {
1562
+ children: /* @__PURE__ */ jsx(RepeatableItemWrapper, {
1294
1563
  itemId,
1295
1564
  blockId,
1565
+ nesting,
1296
1566
  mode,
1297
1567
  children: children(itemApi, index)
1298
1568
  })
@@ -1301,486 +1571,1269 @@ function createEditableBlock(options) {
1301
1571
  $[15] = blockId;
1302
1572
  $[16] = children;
1303
1573
  $[17] = fieldName;
1304
- $[18] = mode;
1305
- $[19] = parentRepeaterContext?.containerItemId;
1306
- $[20] = settingsDefaultsForField;
1307
- $[21] = t5;
1308
- } else t5 = $[21];
1309
- t3 = arrayValue.map(t5);
1310
- $[1] = blockId;
1311
- $[2] = children;
1312
- $[3] = fieldName;
1313
- $[4] = itemsMap;
1314
- $[5] = mode;
1315
- $[6] = name;
1316
- $[7] = parentRepeaterContext?.containerItemId;
1317
- $[8] = source;
1574
+ $[18] = itemSchema;
1575
+ $[19] = mode;
1576
+ $[20] = nesting;
1577
+ $[21] = parentRepeaterContext?.containerItemId;
1578
+ $[22] = settingsDefaultsForField;
1579
+ $[23] = t6;
1580
+ } else t6 = $[23];
1581
+ t4 = arrayValue.map(t6);
1582
+ $[2] = blockId;
1583
+ $[3] = children;
1584
+ $[4] = fieldName;
1585
+ $[5] = itemsMap;
1586
+ $[6] = mode;
1587
+ $[7] = parentRepeaterContext;
1588
+ $[8] = storedValue;
1318
1589
  $[9] = T0;
1319
- $[10] = t1;
1320
- $[11] = t2;
1321
- $[12] = t3;
1590
+ $[10] = t2;
1591
+ $[11] = t3;
1592
+ $[12] = t4;
1322
1593
  } else {
1323
1594
  T0 = $[9];
1324
- t1 = $[10];
1325
- t2 = $[11];
1326
- t3 = $[12];
1595
+ t2 = $[10];
1596
+ t3 = $[11];
1597
+ t4 = $[12];
1327
1598
  }
1328
- let t4;
1329
- if ($[22] !== T0 || $[23] !== t1 || $[24] !== t2 || $[25] !== t3) {
1330
- t4 = /* @__PURE__ */ jsx(T0, {
1331
- blockId: t1,
1332
- fieldName: t2,
1333
- children: t3
1599
+ let t5;
1600
+ if ($[24] !== T0 || $[25] !== t2 || $[26] !== t3 || $[27] !== t4) {
1601
+ t5 = /* @__PURE__ */ jsx(T0, {
1602
+ blockId: t2,
1603
+ fieldName: t3,
1604
+ children: t4
1334
1605
  });
1335
- $[22] = T0;
1336
- $[23] = t1;
1337
- $[24] = t2;
1338
- $[25] = t3;
1339
- $[26] = t4;
1340
- } else t4 = $[26];
1341
- return t4;
1606
+ $[24] = T0;
1607
+ $[25] = t2;
1608
+ $[26] = t3;
1609
+ $[27] = t4;
1610
+ $[28] = t5;
1611
+ } else t5 = $[28];
1612
+ return t5;
1342
1613
  };
1343
1614
  const BlockComponent = (t0) => {
1344
- const $ = c(74);
1345
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
1346
- for (let $i = 0; $i < 74; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1347
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
1348
- }
1615
+ const $ = c(62);
1349
1616
  const { blockData, mode, isFirstBlock, showAddBlockTop, showAddBlockBottom, addBlockAfterPosition } = t0;
1350
1617
  const isContentEditable = useIsEditable(mode);
1351
1618
  const { window: iframeWindow } = useFrame();
1352
1619
  const [isHovered, setIsHovered] = React.useState(false);
1353
- const isCommentMode = useSelector(previewStore, selectIsCommentMode);
1354
- const selection = useSelector(previewStore, _temp5);
1355
- const isAddBlockSidebarOpen = useSelector(previewStore, _temp6);
1620
+ const selection = usePreviewTargetSelection();
1356
1621
  const selectTarget = usePreviewSelection();
1357
- const isBlockSelected = selection?.blockId === blockData._id;
1358
- const overlayState = useOverlayState(isHovered && !isBlockSelected, isBlockSelected);
1359
- const ref = React.useRef(null);
1360
- const [isFirstRender, setIsFirstRender] = React.useState(true);
1361
1622
  let t1;
1623
+ if ($[0] !== selection) {
1624
+ t1 = selectionBlockId(selection);
1625
+ $[0] = selection;
1626
+ $[1] = t1;
1627
+ } else t1 = $[1];
1628
+ const isBlockSelected = t1 === blockData._id;
1629
+ const overlayState = useOverlayState(isHovered, isBlockSelected);
1630
+ const ref = React.useRef(null);
1631
+ const canvasWorkspace = React.use(CanvasWorkspaceContext);
1632
+ const mounted = React.useRef(false);
1362
1633
  let t2;
1363
- if ($[1] !== isFirstRender) {
1364
- t1 = () => {
1365
- if (isFirstRender) setIsFirstRender(false);
1366
- };
1367
- t2 = [isFirstRender];
1368
- $[1] = isFirstRender;
1369
- $[2] = t1;
1370
- $[3] = t2;
1371
- } else {
1372
- t1 = $[2];
1373
- t2 = $[3];
1374
- }
1375
- React.useEffect(t1, t2);
1376
- let t3;
1377
- if ($[4] !== isBlockSelected || $[5] !== isFirstRender) {
1378
- t3 = () => {
1379
- if (!isBlockSelected || !ref.current) return;
1380
- ref.current.scrollIntoView({
1381
- behavior: isFirstRender ? "instant" : "smooth",
1382
- block: isFirstRender ? "start" : "nearest"
1634
+ if ($[2] !== canvasWorkspace || $[3] !== isBlockSelected) {
1635
+ t2 = () => {
1636
+ const element = ref.current;
1637
+ const immediate = !mounted.current;
1638
+ mounted.current = true;
1639
+ if (!isBlockSelected || !element) return;
1640
+ if (canvasWorkspace) {
1641
+ canvasWorkspace.reveal(element, immediate);
1642
+ return;
1643
+ }
1644
+ const view = element.ownerDocument.defaultView;
1645
+ if (!view) return;
1646
+ const rect = element.getBoundingClientRect();
1647
+ const top = revealScrollDelta(rect, {
1648
+ top: 0,
1649
+ bottom: view.innerHeight
1650
+ });
1651
+ if (top) view.scrollBy({
1652
+ top,
1653
+ behavior: immediate ? "instant" : "smooth"
1383
1654
  });
1384
1655
  };
1385
- $[4] = isBlockSelected;
1386
- $[5] = isFirstRender;
1387
- $[6] = t3;
1388
- } else t3 = $[6];
1389
- let t4;
1390
- if ($[7] !== blockData._id || $[8] !== isBlockSelected || $[9] !== isFirstRender) {
1391
- t4 = [
1656
+ $[2] = canvasWorkspace;
1657
+ $[3] = isBlockSelected;
1658
+ $[4] = t2;
1659
+ } else t2 = $[4];
1660
+ let t3;
1661
+ if ($[5] !== blockData._id || $[6] !== canvasWorkspace || $[7] !== isBlockSelected) {
1662
+ t3 = [
1392
1663
  blockData._id,
1393
1664
  isBlockSelected,
1394
- isFirstRender
1665
+ canvasWorkspace
1395
1666
  ];
1396
- $[7] = blockData._id;
1397
- $[8] = isBlockSelected;
1398
- $[9] = isFirstRender;
1399
- $[10] = t4;
1400
- } else t4 = $[10];
1401
- React.useEffect(t3, t4);
1402
- const t5 = String(blockData._id);
1403
- let t6;
1404
- if ($[11] !== t5) {
1405
- t6 = { blockId: t5 };
1406
- $[11] = t5;
1407
- $[12] = t6;
1408
- } else t6 = $[12];
1409
- const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t6);
1410
- let t7;
1411
- let t8;
1412
- if ($[13] !== isHoveredFromSidebar) {
1413
- t7 = () => {
1414
- setIsHovered(isHoveredFromSidebar);
1415
- };
1416
- t8 = [isHoveredFromSidebar];
1417
- $[13] = isHoveredFromSidebar;
1418
- $[14] = t7;
1419
- $[15] = t8;
1420
- } else {
1421
- t7 = $[14];
1422
- t8 = $[15];
1667
+ $[5] = blockData._id;
1668
+ $[6] = canvasWorkspace;
1669
+ $[7] = isBlockSelected;
1670
+ $[8] = t3;
1671
+ } else t3 = $[8];
1672
+ React.useEffect(t2, t3);
1673
+ const t4 = String(blockData._id);
1674
+ let t5;
1675
+ if ($[9] !== t4) {
1676
+ t5 = { blockId: t4 };
1677
+ $[9] = t4;
1678
+ $[10] = t5;
1679
+ } else t5 = $[10];
1680
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t5);
1681
+ const [prevSidebarHover, setPrevSidebarHover] = React.useState(isHoveredFromSidebar);
1682
+ if (prevSidebarHover !== isHoveredFromSidebar) {
1683
+ setPrevSidebarHover(isHoveredFromSidebar);
1684
+ setIsHovered(isHoveredFromSidebar);
1423
1685
  }
1424
- React.useEffect(t7, t8);
1425
1686
  let result;
1426
- if ($[16] !== blockData.content) {
1687
+ if ($[11] !== blockData.content) {
1427
1688
  result = { ...blockData.content };
1428
1689
  for (const key in result) {
1429
1690
  const value = result[key];
1430
1691
  if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(_temp7);
1431
1692
  }
1432
- $[16] = blockData.content;
1433
- $[17] = result;
1434
- } else result = $[17];
1693
+ $[11] = blockData.content;
1694
+ $[12] = result;
1695
+ } else result = $[12];
1435
1696
  const normalizedContent = result;
1436
- let t9;
1437
- if ($[18] !== blockData._id || $[19] !== isCommentMode || $[20] !== isContentEditable || $[21] !== selectTarget) {
1438
- t9 = (e) => {
1697
+ let t6;
1698
+ if ($[13] !== blockData._id || $[14] !== isContentEditable || $[15] !== selectTarget) {
1699
+ t6 = (e) => {
1439
1700
  if (!isContentEditable) return;
1440
1701
  const target = e.target;
1441
1702
  if (target.closest("[data-camox-field-id]")) return;
1442
- if (isCommentMode && target.closest("[data-camox-repeater-item-id]")) return;
1443
- if (target.closest("[data-camox-block-id], [data-camox-comment-block-id]") !== e.currentTarget) return;
1703
+ if (target.closest("[data-camox-block-id]") !== e.currentTarget) return;
1444
1704
  selectTarget({
1445
1705
  type: "block",
1446
1706
  blockId: blockData._id
1447
- }, e);
1707
+ });
1448
1708
  };
1449
- $[18] = blockData._id;
1450
- $[19] = isCommentMode;
1451
- $[20] = isContentEditable;
1452
- $[21] = selectTarget;
1453
- $[22] = t9;
1454
- } else t9 = $[22];
1455
- const handleClick = t9;
1456
- let t10;
1457
- if ($[23] !== isContentEditable) {
1458
- t10 = () => {
1459
- if (isContentEditable) setIsHovered(true);
1709
+ $[13] = blockData._id;
1710
+ $[14] = isContentEditable;
1711
+ $[15] = selectTarget;
1712
+ $[16] = t6;
1713
+ } else t6 = $[16];
1714
+ const handleClick = t6;
1715
+ let t7;
1716
+ if ($[17] !== isContentEditable) {
1717
+ t7 = () => {
1718
+ if (!isContentEditable) return;
1719
+ setIsHovered(true);
1460
1720
  };
1461
- $[23] = isContentEditable;
1462
- $[24] = t10;
1463
- } else t10 = $[24];
1464
- const handleMouseEnter = t10;
1465
- let t11;
1466
- if ($[25] !== isContentEditable) {
1467
- t11 = () => {
1468
- if (isContentEditable) setIsHovered(false);
1721
+ $[17] = isContentEditable;
1722
+ $[18] = t7;
1723
+ } else t7 = $[18];
1724
+ const handleMouseEnter = t7;
1725
+ let t8;
1726
+ if ($[19] !== isContentEditable) {
1727
+ t8 = () => {
1728
+ if (!isContentEditable) return;
1729
+ setIsHovered(false);
1469
1730
  };
1470
- $[25] = isContentEditable;
1471
- $[26] = t11;
1472
- } else t11 = $[26];
1473
- const handleMouseLeave = t11;
1474
- let t12;
1475
- if ($[27] !== addBlockAfterPosition || $[28] !== blockData.position) {
1476
- t12 = (insertPosition) => {
1477
- postOverlayMessage({
1478
- type: "CAMOX_ADD_BLOCK_REQUEST",
1479
- blockPosition: blockData.position,
1480
- insertPosition,
1481
- ...addBlockAfterPosition !== void 0 && { afterPosition: addBlockAfterPosition }
1482
- });
1731
+ $[19] = isContentEditable;
1732
+ $[20] = t8;
1733
+ } else t8 = $[20];
1734
+ const handleMouseLeave = t8;
1735
+ const shouldShowOverlay = isContentEditable && (overlayState["data-camox-hovered"] || overlayState["data-camox-focused"]);
1736
+ const t9 = blockData._id;
1737
+ let t10;
1738
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
1739
+ t10 = {
1740
+ position: "relative",
1741
+ scrollMargin: "5rem"
1483
1742
  };
1484
- $[27] = addBlockAfterPosition;
1485
- $[28] = blockData.position;
1743
+ $[21] = t10;
1744
+ } else t10 = $[21];
1745
+ const t11 = isContentEditable ? blockData._id : void 0;
1746
+ let t12;
1747
+ if ($[22] !== addBlockAfterPosition || $[23] !== blockData.position || $[24] !== isContentEditable || $[25] !== isFirstBlock || $[26] !== mode || $[27] !== showAddBlockBottom || $[28] !== showAddBlockTop) {
1748
+ t12 = isContentEditable ? JSON.stringify({
1749
+ position: blockData.position,
1750
+ before: showAddBlockTop ?? (mode !== "layout" && !isFirstBlock),
1751
+ after: showAddBlockBottom ?? mode !== "layout",
1752
+ ...addBlockAfterPosition !== void 0 ? { afterPosition: addBlockAfterPosition } : {}
1753
+ }) : void 0;
1754
+ $[22] = addBlockAfterPosition;
1755
+ $[23] = blockData.position;
1756
+ $[24] = isContentEditable;
1757
+ $[25] = isFirstBlock;
1758
+ $[26] = mode;
1759
+ $[27] = showAddBlockBottom;
1760
+ $[28] = showAddBlockTop;
1486
1761
  $[29] = t12;
1487
1762
  } else t12 = $[29];
1488
- const handleAddBlockClick = t12;
1489
- const shouldShowOverlay = isContentEditable && (overlayState["data-camox-hovered"] || overlayState["data-camox-focused"]) && !isAddBlockSidebarOpen;
1490
- const shouldShowAddBlockOverlay = isAddBlockSidebarOpen && mode !== "peek";
1491
1763
  let t13;
1492
- if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
1493
- t13 = {
1494
- position: "relative",
1495
- scrollMargin: "5rem",
1496
- background: "var(--background)"
1497
- };
1498
- $[30] = t13;
1499
- } else t13 = $[30];
1500
- const t14 = isContentEditable ? blockData._id : void 0;
1764
+ if ($[30] !== overlayState || $[31] !== shouldShowOverlay) {
1765
+ t13 = shouldShowOverlay ? overlayState : {};
1766
+ $[30] = overlayState;
1767
+ $[31] = shouldShowOverlay;
1768
+ $[32] = t13;
1769
+ } else t13 = $[32];
1770
+ const t14 = blockData._id;
1501
1771
  let t15;
1502
- if ($[31] !== overlayState || $[32] !== shouldShowOverlay) {
1503
- t15 = shouldShowOverlay ? overlayState : {};
1504
- $[31] = overlayState;
1505
- $[32] = shouldShowOverlay;
1506
- $[33] = t15;
1507
- } else t15 = $[33];
1508
- const t16 = blockData._id;
1509
- let t17;
1510
- if ($[34] !== blockData.content) {
1511
- t17 = {
1772
+ if ($[33] !== blockData.content) {
1773
+ t15 = {
1512
1774
  ...contentDefaults,
1513
1775
  ...blockData.content
1514
1776
  };
1515
- $[34] = blockData.content;
1516
- $[35] = t17;
1517
- } else t17 = $[35];
1518
- const merged = t17;
1777
+ $[33] = blockData.content;
1778
+ $[34] = t15;
1779
+ } else t15 = $[34];
1780
+ const merged = t15;
1519
1781
  let overrides;
1520
- if ($[36] !== merged) {
1782
+ if ($[35] !== merged) {
1521
1783
  overrides = {};
1522
1784
  for (const key_0 in merged) {
1523
1785
  const val = merged[key_0];
1524
1786
  if (val && typeof val === "object" && "url" in val && !val.url && contentDefaults[key_0]) overrides[key_0] = contentDefaults[key_0];
1525
1787
  }
1526
- $[36] = merged;
1527
- $[37] = overrides;
1528
- } else overrides = $[37];
1529
- let t18;
1530
- if ($[38] !== merged || $[39] !== overrides) {
1531
- t18 = {
1788
+ $[35] = merged;
1789
+ $[36] = overrides;
1790
+ } else overrides = $[36];
1791
+ let t16;
1792
+ if ($[37] !== merged || $[38] !== overrides) {
1793
+ t16 = {
1532
1794
  ...merged,
1533
1795
  ...overrides
1534
1796
  };
1535
- $[38] = merged;
1536
- $[39] = overrides;
1537
- $[40] = t18;
1538
- } else t18 = $[40];
1539
- const t19 = t18;
1540
- let t20;
1541
- if ($[41] !== blockData.settings) {
1542
- t20 = {
1797
+ $[37] = merged;
1798
+ $[38] = overrides;
1799
+ $[39] = t16;
1800
+ } else t16 = $[39];
1801
+ const t17 = t16;
1802
+ let t18;
1803
+ if ($[40] !== blockData.settings) {
1804
+ t18 = {
1543
1805
  ...settingsDefaults,
1544
1806
  ...blockData.settings
1545
1807
  };
1546
- $[41] = blockData.settings;
1547
- $[42] = t20;
1548
- } else t20 = $[42];
1549
- const t21 = t20;
1550
- let t22;
1551
- if ($[43] !== blockData._id || $[44] !== isHovered || $[45] !== mode || $[46] !== t19 || $[47] !== t21) {
1552
- t22 = {
1553
- blockId: t16,
1554
- content: t19,
1555
- settings: t21,
1808
+ $[40] = blockData.settings;
1809
+ $[41] = t18;
1810
+ } else t18 = $[41];
1811
+ const t19 = t18;
1812
+ let t20;
1813
+ if ($[42] !== blockData._id || $[43] !== isHovered || $[44] !== mode || $[45] !== t17 || $[46] !== t19) {
1814
+ t20 = {
1815
+ blockId: t14,
1816
+ content: t17,
1817
+ settings: t19,
1556
1818
  mode,
1557
1819
  isHovered,
1558
1820
  setIsHovered
1559
1821
  };
1560
- $[43] = blockData._id;
1561
- $[44] = isHovered;
1562
- $[45] = mode;
1822
+ $[42] = blockData._id;
1823
+ $[43] = isHovered;
1824
+ $[44] = mode;
1825
+ $[45] = t17;
1563
1826
  $[46] = t19;
1564
- $[47] = t21;
1565
- $[48] = t22;
1566
- } else t22 = $[48];
1567
- let t23;
1568
- if ($[49] !== normalizedContent) {
1569
- t23 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
1570
- $[49] = normalizedContent;
1571
- $[50] = t23;
1572
- } else t23 = $[50];
1573
- let t24;
1574
- if ($[51] !== t22 || $[52] !== t23) {
1575
- t24 = /* @__PURE__ */ jsx(Context.Provider, {
1576
- value: t22,
1577
- children: t23
1578
- });
1579
- $[51] = t22;
1580
- $[52] = t23;
1581
- $[53] = t24;
1582
- } else t24 = $[53];
1583
- const t25 = shouldShowAddBlockOverlay || void 0;
1584
- let t26;
1585
- if ($[54] !== t25) {
1586
- t26 = /* @__PURE__ */ jsx("div", {
1587
- className: "camox-sheet-overlay",
1588
- "data-camox-visible": t25
1827
+ $[47] = t20;
1828
+ } else t20 = $[47];
1829
+ let t21;
1830
+ if ($[48] !== normalizedContent) {
1831
+ t21 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
1832
+ $[48] = normalizedContent;
1833
+ $[49] = t21;
1834
+ } else t21 = $[49];
1835
+ let t22;
1836
+ if ($[50] !== t20 || $[51] !== t21) {
1837
+ t22 = /* @__PURE__ */ jsx(Context.Provider, {
1838
+ value: t20,
1839
+ children: t21
1589
1840
  });
1590
- $[54] = t25;
1591
- $[55] = t26;
1592
- } else t26 = $[55];
1593
- let t27;
1594
- if ($[56] !== handleAddBlockClick || $[57] !== isAddBlockSidebarOpen || $[58] !== isCommentMode || $[59] !== isFirstBlock || $[60] !== mode || $[61] !== shouldShowOverlay || $[62] !== showAddBlockBottom || $[63] !== showAddBlockTop) {
1595
- t27 = shouldShowOverlay && !isCommentMode && /* @__PURE__ */ jsxs(Fragment, { children: [(showAddBlockTop ?? (mode !== "layout" && !isFirstBlock)) && /* @__PURE__ */ jsx(AddBlockControlBar, {
1596
- position: "top",
1597
- hidden: isAddBlockSidebarOpen,
1598
- onMouseLeave: () => setIsHovered(false),
1599
- onClick: () => handleAddBlockClick("before")
1600
- }), (showAddBlockBottom ?? mode !== "layout") && /* @__PURE__ */ jsx(AddBlockControlBar, {
1601
- position: "bottom",
1602
- hidden: isAddBlockSidebarOpen,
1603
- onMouseLeave: () => setIsHovered(false),
1604
- onClick: () => handleAddBlockClick("after")
1605
- })] });
1606
- $[56] = handleAddBlockClick;
1607
- $[57] = isAddBlockSidebarOpen;
1608
- $[58] = isCommentMode;
1609
- $[59] = isFirstBlock;
1610
- $[60] = mode;
1611
- $[61] = shouldShowOverlay;
1612
- $[62] = showAddBlockBottom;
1613
- $[63] = showAddBlockTop;
1614
- $[64] = t27;
1615
- } else t27 = $[64];
1616
- let t28;
1617
- if ($[65] !== handleClick || $[66] !== handleMouseEnter || $[67] !== handleMouseLeave || $[68] !== t14 || $[69] !== t15 || $[70] !== t24 || $[71] !== t26 || $[72] !== t27) {
1618
- t28 = /* @__PURE__ */ jsxs("div", {
1841
+ $[50] = t20;
1842
+ $[51] = t21;
1843
+ $[52] = t22;
1844
+ } else t22 = $[52];
1845
+ let t23;
1846
+ if ($[53] !== blockData._id || $[54] !== handleClick || $[55] !== handleMouseEnter || $[56] !== handleMouseLeave || $[57] !== t11 || $[58] !== t12 || $[59] !== t13 || $[60] !== t22) {
1847
+ t23 = /* @__PURE__ */ jsx("div", {
1619
1848
  className: "group visual-editing-block",
1849
+ "data-camox-viewport-block": t9,
1620
1850
  ref,
1621
- style: t13,
1622
- "data-camox-block-id": t14,
1623
- ...t15,
1851
+ style: t10,
1852
+ "data-camox-block-id": t11,
1853
+ "data-camox-block-insertion": t12,
1854
+ ...t13,
1624
1855
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
1625
1856
  onClickCapture: handleClick,
1626
1857
  onMouseEnter: handleMouseEnter,
1627
1858
  onMouseLeave: handleMouseLeave,
1628
- children: [
1629
- t24,
1630
- t26,
1631
- t27
1632
- ]
1859
+ children: t22
1633
1860
  });
1634
- $[65] = handleClick;
1635
- $[66] = handleMouseEnter;
1636
- $[67] = handleMouseLeave;
1637
- $[68] = t14;
1638
- $[69] = t15;
1639
- $[70] = t24;
1640
- $[71] = t26;
1641
- $[72] = t27;
1642
- $[73] = t28;
1643
- } else t28 = $[73];
1644
- return t28;
1861
+ $[53] = blockData._id;
1862
+ $[54] = handleClick;
1863
+ $[55] = handleMouseEnter;
1864
+ $[56] = handleMouseLeave;
1865
+ $[57] = t11;
1866
+ $[58] = t12;
1867
+ $[59] = t13;
1868
+ $[60] = t22;
1869
+ $[61] = t23;
1870
+ } else t23 = $[61];
1871
+ return t23;
1645
1872
  };
1646
1873
  const useSetting = (name) => {
1647
1874
  const ctx = React.use(Context);
1648
1875
  if (!ctx) throw new Error("useSetting must be used within a Block Component");
1649
1876
  return ctx.settings[name];
1650
1877
  };
1651
- /**
1652
- * Wraps block content that renders outside the block's visual bounds (fixed navbars, modals, portals, etc.).
1653
- * Provides the same hover, selection, and sheet overlays as the main BlockComponent.
1654
- */
1655
- const Detached = (t0) => {
1656
- const $ = c(32);
1657
- if ($[0] !== "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6") {
1658
- for (let $i = 0; $i < 32; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1659
- $[0] = "8c4e70844cd2f2752041099dd31f8aabc30492cc078e28f85c1026ddf30f63b6";
1878
+ const ReferencePrimitive = (t0) => {
1879
+ const $ = c(6);
1880
+ let Primitive;
1881
+ let props;
1882
+ if ($[0] !== t0) {
1883
+ ({primitive: Primitive, ...props} = t0);
1884
+ $[0] = t0;
1885
+ $[1] = Primitive;
1886
+ $[2] = props;
1887
+ } else {
1888
+ Primitive = $[1];
1889
+ props = $[2];
1660
1890
  }
1891
+ if (React.use(Context).content[props.name] == null) return null;
1892
+ let t1;
1893
+ if ($[3] !== Primitive || $[4] !== props) {
1894
+ t1 = /* @__PURE__ */ jsx(Primitive, { ...props });
1895
+ $[3] = Primitive;
1896
+ $[4] = props;
1897
+ $[5] = t1;
1898
+ } else t1 = $[5];
1899
+ return t1;
1900
+ };
1901
+ const ReferenceImage = (props) => {
1902
+ const $ = c(2);
1903
+ let t0;
1904
+ if ($[0] !== props) {
1905
+ t0 = /* @__PURE__ */ jsx(ReferencePrimitive, {
1906
+ primitive: Image,
1907
+ ...props
1908
+ });
1909
+ $[0] = props;
1910
+ $[1] = t0;
1911
+ } else t0 = $[1];
1912
+ return t0;
1913
+ };
1914
+ const ReferenceFile = (props) => {
1915
+ const $ = c(2);
1916
+ let t0;
1917
+ if ($[0] !== props) {
1918
+ t0 = /* @__PURE__ */ jsx(ReferencePrimitive, {
1919
+ primitive: File,
1920
+ ...props
1921
+ });
1922
+ $[0] = props;
1923
+ $[1] = t0;
1924
+ } else t0 = $[1];
1925
+ return t0;
1926
+ };
1927
+ const ReferenceEmbed = (props) => {
1928
+ const $ = c(2);
1929
+ let t0;
1930
+ if ($[0] !== props) {
1931
+ t0 = /* @__PURE__ */ jsx(ReferencePrimitive, {
1932
+ primitive: Embed,
1933
+ ...props
1934
+ });
1935
+ $[0] = props;
1936
+ $[1] = t0;
1937
+ } else t0 = $[1];
1938
+ return t0;
1939
+ };
1940
+ const ReferenceImageList = (props) => {
1941
+ const $ = c(2);
1942
+ let t0;
1943
+ if ($[0] !== props) {
1944
+ t0 = /* @__PURE__ */ jsx(ReferencePrimitive, {
1945
+ primitive: ImageList,
1946
+ ...props
1947
+ });
1948
+ $[0] = props;
1949
+ $[1] = t0;
1950
+ } else t0 = $[1];
1951
+ return t0;
1952
+ };
1953
+ const ReferenceFileList = (props) => {
1954
+ const $ = c(2);
1955
+ let t0;
1956
+ if ($[0] !== props) {
1957
+ t0 = /* @__PURE__ */ jsx(ReferencePrimitive, {
1958
+ primitive: FileList,
1959
+ ...props
1960
+ });
1961
+ $[0] = props;
1962
+ $[1] = t0;
1963
+ } else t0 = $[1];
1964
+ return t0;
1965
+ };
1966
+ const placementOf = (block, owner, fieldName, recordId) => {
1967
+ if (owner.layoutId != null) return {
1968
+ layoutId: owner.layoutId,
1969
+ recordId
1970
+ };
1971
+ if (owner.outer) return {
1972
+ ...owner.outer,
1973
+ nested: {
1974
+ fieldName,
1975
+ recordId
1976
+ }
1977
+ };
1978
+ return {
1979
+ blockId: block.blockId,
1980
+ ...owner.itemId == null ? {} : { itemId: owner.itemId },
1981
+ fieldName,
1982
+ recordId
1983
+ };
1984
+ };
1985
+ const usePlacedRecord = (block, owner, fieldName, record) => {
1986
+ const $ = c(40);
1987
+ const studioCache = useStudioCache();
1988
+ const selectTarget = usePreviewSelection();
1989
+ const projectUuid = useProjectUuid();
1990
+ const queryClient = useQueryClient();
1991
+ let t0;
1992
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1993
+ t0 = collectionMutations.edit();
1994
+ $[0] = t0;
1995
+ } else t0 = $[0];
1996
+ const mutation = useMutation(t0);
1997
+ const [error, setError] = React.useState(null);
1998
+ const [pointerHovered, setPointerHovered] = React.useState(false);
1999
+ const editable = useIsEditable(block.mode);
2000
+ let t1;
2001
+ if ($[1] !== block || $[2] !== fieldName || $[3] !== owner || $[4] !== record) {
2002
+ t1 = record ? placementOf(block, owner, fieldName, record.id) : null;
2003
+ $[1] = block;
2004
+ $[2] = fieldName;
2005
+ $[3] = owner;
2006
+ $[4] = record;
2007
+ $[5] = t1;
2008
+ } else t1 = $[5];
2009
+ const placement = t1;
2010
+ const selected = useRecordSelection(placement);
2011
+ const { window: iframeWindow } = useFrame();
2012
+ let t2;
2013
+ if ($[6] !== placement) {
2014
+ t2 = placement ? recordPlacementId(placement) : void 0;
2015
+ $[6] = placement;
2016
+ $[7] = t2;
2017
+ } else t2 = $[7];
2018
+ let t3;
2019
+ if ($[8] !== t2) {
2020
+ t3 = { fieldId: t2 };
2021
+ $[8] = t2;
2022
+ $[9] = t3;
2023
+ } else t3 = $[9];
2024
+ const sidebarHovered = useOverlayMessage(iframeWindow, editable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t3);
2025
+ let t4;
2026
+ if ($[10] !== editable || $[11] !== placement || $[12] !== selectTarget) {
2027
+ t4 = (event) => {
2028
+ if (!editable || !placement) return;
2029
+ if (event.target.closest("[data-camox-field-id]") !== event.currentTarget) return;
2030
+ selectTarget({
2031
+ type: "record",
2032
+ ...placement
2033
+ });
2034
+ };
2035
+ $[10] = editable;
2036
+ $[11] = placement;
2037
+ $[12] = selectTarget;
2038
+ $[13] = t4;
2039
+ } else t4 = $[13];
2040
+ const selectRecord = t4;
2041
+ let t5;
2042
+ if ($[14] !== editable || $[15] !== placement || $[16] !== selectTarget) {
2043
+ t5 = (recordFieldName, recordFieldType) => {
2044
+ if (!editable || !placement) return;
2045
+ selectTarget({
2046
+ type: "record-field",
2047
+ ...placement,
2048
+ recordFieldName,
2049
+ recordFieldType
2050
+ });
2051
+ };
2052
+ $[14] = editable;
2053
+ $[15] = placement;
2054
+ $[16] = selectTarget;
2055
+ $[17] = t5;
2056
+ } else t5 = $[17];
2057
+ const selectRecordField = t5;
2058
+ let t6;
2059
+ if ($[18] !== editable || $[19] !== mutation || $[20] !== projectUuid || $[21] !== queryClient || $[22] !== record || $[23] !== studioCache) {
2060
+ t6 = (field, value) => {
2061
+ if (!record || !editable) return;
2062
+ setError(null);
2063
+ referenceWritesFor(queryClient).save(record, field, value, async (input) => {
2064
+ const saved = await mutation.mutateAsync({
2065
+ ...input,
2066
+ projectUuid
2067
+ });
2068
+ studioCache.set(reads.record({
2069
+ projectUuid,
2070
+ collectionId: record.collectionId,
2071
+ id: record.id
2072
+ }), saved);
2073
+ invalidateCollectionRecordViews(studioCache, projectUuid, record.collectionId);
2074
+ return saved;
2075
+ }).catch((cause) => {
2076
+ setError(cause instanceof Error ? cause.message : "Could not save item");
2077
+ });
2078
+ };
2079
+ $[18] = editable;
2080
+ $[19] = mutation;
2081
+ $[20] = projectUuid;
2082
+ $[21] = queryClient;
2083
+ $[22] = record;
2084
+ $[23] = studioCache;
2085
+ $[24] = t6;
2086
+ } else t6 = $[24];
2087
+ const update = t6;
2088
+ const t7 = pointerHovered || sidebarHovered;
2089
+ let t8;
2090
+ if ($[25] !== placement || $[26] !== selectRecordField || $[27] !== update) {
2091
+ t8 = placement ? {
2092
+ placement,
2093
+ selectRecordField,
2094
+ update
2095
+ } : null;
2096
+ $[25] = placement;
2097
+ $[26] = selectRecordField;
2098
+ $[27] = update;
2099
+ $[28] = t8;
2100
+ } else t8 = $[28];
2101
+ let t10;
2102
+ let t9;
2103
+ if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
2104
+ t9 = () => setPointerHovered(true);
2105
+ t10 = () => setPointerHovered(false);
2106
+ $[29] = t10;
2107
+ $[30] = t9;
2108
+ } else {
2109
+ t10 = $[29];
2110
+ t9 = $[30];
2111
+ }
2112
+ let t11;
2113
+ if ($[31] !== selectRecord) {
2114
+ t11 = {
2115
+ onClickCapture: selectRecord,
2116
+ onMouseEnter: t9,
2117
+ onMouseLeave: t10
2118
+ };
2119
+ $[31] = selectRecord;
2120
+ $[32] = t11;
2121
+ } else t11 = $[32];
2122
+ let t12;
2123
+ if ($[33] !== editable || $[34] !== error || $[35] !== selected || $[36] !== t11 || $[37] !== t7 || $[38] !== t8) {
2124
+ t12 = {
2125
+ editable,
2126
+ error,
2127
+ selected,
2128
+ hovered: t7,
2129
+ reference: t8,
2130
+ wrapperProps: t11
2131
+ };
2132
+ $[33] = editable;
2133
+ $[34] = error;
2134
+ $[35] = selected;
2135
+ $[36] = t11;
2136
+ $[37] = t7;
2137
+ $[38] = t8;
2138
+ $[39] = t12;
2139
+ } else t12 = $[39];
2140
+ return t12;
2141
+ };
2142
+ const RecordScope = (t0) => {
2143
+ const $ = c(15);
2144
+ const { block, field, record, reference, children } = t0;
2145
+ const t1 = record.content;
2146
+ let t2;
2147
+ if ($[0] !== block || $[1] !== field.referenceSchema.properties || $[2] !== t1) {
2148
+ t2 = {
2149
+ ...block,
2150
+ content: t1,
2151
+ sourceSchema: field.referenceSchema.properties
2152
+ };
2153
+ $[0] = block;
2154
+ $[1] = field.referenceSchema.properties;
2155
+ $[2] = t1;
2156
+ $[3] = t2;
2157
+ } else t2 = $[3];
2158
+ let t3;
2159
+ if ($[4] !== children || $[5] !== record.id || $[6] !== record.label || $[7] !== reference.placement.nested) {
2160
+ t3 = children({
2161
+ id: record.id,
2162
+ label: record.label,
2163
+ Field,
2164
+ Image: ReferenceImage,
2165
+ File: ReferenceFile,
2166
+ Embed: ReferenceEmbed,
2167
+ ImageList: ReferenceImageList,
2168
+ FileList: ReferenceFileList,
2169
+ ...reference.placement.nested ? {} : {
2170
+ Reference,
2171
+ ReferenceList
2172
+ }
2173
+ });
2174
+ $[4] = children;
2175
+ $[5] = record.id;
2176
+ $[6] = record.label;
2177
+ $[7] = reference.placement.nested;
2178
+ $[8] = t3;
2179
+ } else t3 = $[8];
2180
+ let t4;
2181
+ if ($[9] !== t2 || $[10] !== t3) {
2182
+ t4 = /* @__PURE__ */ jsx(RepeatableItemContext.Provider, {
2183
+ value: null,
2184
+ children: /* @__PURE__ */ jsx(Context.Provider, {
2185
+ value: t2,
2186
+ children: t3
2187
+ })
2188
+ });
2189
+ $[9] = t2;
2190
+ $[10] = t3;
2191
+ $[11] = t4;
2192
+ } else t4 = $[11];
2193
+ let t5;
2194
+ if ($[12] !== reference || $[13] !== t4) {
2195
+ t5 = /* @__PURE__ */ jsx(ReferenceContext.Provider, {
2196
+ value: reference,
2197
+ children: t4
2198
+ });
2199
+ $[12] = reference;
2200
+ $[13] = t4;
2201
+ $[14] = t5;
2202
+ } else t5 = $[14];
2203
+ return t5;
2204
+ };
2205
+ const useCollectionTitle = (fieldName, field) => {
2206
+ const $ = c(4);
2207
+ const camoxApp = useOptionalCamoxApp();
2208
+ let t0;
2209
+ if ($[0] !== camoxApp || $[1] !== field || $[2] !== fieldName) {
2210
+ t0 = camoxApp?.getCollectionById(field.collectionId)?._internal.title ?? field.title ?? fieldName;
2211
+ $[0] = camoxApp;
2212
+ $[1] = field;
2213
+ $[2] = fieldName;
2214
+ $[3] = t0;
2215
+ } else t0 = $[3];
2216
+ return t0;
2217
+ };
2218
+ const useReferenceField = (block, fieldName) => {
2219
+ const item = React.use(RepeatableItemContext);
2220
+ const outer = React.use(ReferenceContext)?.placement ?? null;
2221
+ const owner = {
2222
+ itemId: item?.itemId,
2223
+ outer
2224
+ };
2225
+ const fieldType = "Reference";
2226
+ const recordFieldSelected = useRecordSelection(outer, fieldName);
2227
+ const blockFieldSelected = useFieldSelection(block.blockId, fieldName, fieldType, owner.itemId);
2228
+ const fieldSelection = outer ? {
2229
+ type: "record-field",
2230
+ ...outer,
2231
+ recordFieldName: fieldName,
2232
+ recordFieldType: fieldType
2233
+ } : owner.itemId == null ? {
2234
+ type: "block-field",
2235
+ blockId: block.blockId,
2236
+ fieldName,
2237
+ fieldType
2238
+ } : {
2239
+ type: "item-field",
2240
+ blockId: block.blockId,
2241
+ itemId: owner.itemId,
2242
+ fieldName,
2243
+ fieldType
2244
+ };
2245
+ return {
2246
+ owner,
2247
+ field: item ? item.itemSchema?.[fieldName] : (block.sourceSchema ?? typeboxSchema.properties)[fieldName],
2248
+ stored: item ? item.itemContent[fieldName] : block.content[fieldName],
2249
+ fieldId: outer ? overlayFieldId(block.blockId, fieldName, { placement: outer }) : overlayFieldId(block.blockId, fieldName, { itemId: owner.itemId }),
2250
+ fieldSelection,
2251
+ fieldSelected: outer ? recordFieldSelected : blockFieldSelected
2252
+ };
2253
+ };
2254
+ const ReferencePlaceholder = (t0) => {
2255
+ const $ = c(13);
2256
+ let children;
2257
+ let fieldId;
2258
+ let fieldSelection;
2259
+ let props;
2260
+ if ($[0] !== t0) {
2261
+ ({fieldId, fieldSelection, children, ...props} = t0);
2262
+ $[0] = t0;
2263
+ $[1] = children;
2264
+ $[2] = fieldId;
2265
+ $[3] = fieldSelection;
2266
+ $[4] = props;
2267
+ } else {
2268
+ children = $[1];
2269
+ fieldId = $[2];
2270
+ fieldSelection = $[3];
2271
+ props = $[4];
2272
+ }
2273
+ const selectTarget = usePreviewSelection();
2274
+ let t1;
2275
+ if ($[5] !== fieldId || $[6] !== fieldSelection || $[7] !== selectTarget) {
2276
+ t1 = () => {
2277
+ selectTarget(fieldSelection);
2278
+ referencePickerFocus.send({
2279
+ type: "request",
2280
+ fieldId
2281
+ });
2282
+ };
2283
+ $[5] = fieldId;
2284
+ $[6] = fieldSelection;
2285
+ $[7] = selectTarget;
2286
+ $[8] = t1;
2287
+ } else t1 = $[8];
2288
+ let t2;
2289
+ if ($[9] !== children || $[10] !== props || $[11] !== t1) {
2290
+ t2 = /* @__PURE__ */ jsx("button", {
2291
+ type: "button",
2292
+ "data-camox-reference-placeholder": "",
2293
+ className: "camox-reference-placeholder",
2294
+ ...props,
2295
+ onClick: t1,
2296
+ children
2297
+ });
2298
+ $[9] = children;
2299
+ $[10] = props;
2300
+ $[11] = t1;
2301
+ $[12] = t2;
2302
+ } else t2 = $[12];
2303
+ return t2;
2304
+ };
2305
+ const PlacedRecordWrapper = (t0) => {
2306
+ const $ = c(10);
2307
+ const { fieldId, record, placedRecord, overlay, children } = t0;
2308
+ const t1 = record?.id;
2309
+ const t2 = record?.label;
2310
+ let t3;
2311
+ if ($[0] !== placedRecord.error) {
2312
+ t3 = placedRecord.error && /* @__PURE__ */ jsxs("p", {
2313
+ role: "alert",
2314
+ children: ["Could not save item. ", placedRecord.error]
2315
+ });
2316
+ $[0] = placedRecord.error;
2317
+ $[1] = t3;
2318
+ } else t3 = $[1];
2319
+ let t4;
2320
+ if ($[2] !== children || $[3] !== fieldId || $[4] !== overlay || $[5] !== placedRecord.wrapperProps || $[6] !== t1 || $[7] !== t2 || $[8] !== t3) {
2321
+ t4 = /* @__PURE__ */ jsxs("div", {
2322
+ "data-camox-field-id": fieldId,
2323
+ "data-camox-collection-record-id": t1,
2324
+ "data-camox-reference-label": t2,
2325
+ "data-camox-overlay-mode": "reference",
2326
+ ...overlay,
2327
+ ...placedRecord.wrapperProps,
2328
+ children: [children, t3]
2329
+ });
2330
+ $[2] = children;
2331
+ $[3] = fieldId;
2332
+ $[4] = overlay;
2333
+ $[5] = placedRecord.wrapperProps;
2334
+ $[6] = t1;
2335
+ $[7] = t2;
2336
+ $[8] = t3;
2337
+ $[9] = t4;
2338
+ } else t4 = $[9];
2339
+ return t4;
2340
+ };
2341
+ const Reference = (t0) => {
2342
+ const $ = c(21);
2343
+ const { name, children } = t0;
2344
+ const block = React.use(Context);
2345
+ const { recordsMap } = useNormalizedData();
2346
+ const { window: iframeWindow } = useFrame();
2347
+ if (!block) throw new Error("Reference must be used within a Block Component");
2348
+ const fieldName = String(name);
2349
+ const { owner, field, stored, fieldId, fieldSelection, fieldSelected } = useReferenceField(block, fieldName);
2350
+ const collectionTitle = useCollectionTitle(fieldName, field);
2351
+ let t1;
2352
+ if ($[0] !== field.collectionId || $[1] !== recordsMap || $[2] !== stored) {
2353
+ t1 = resolveReference(stored, field.collectionId, recordsMap);
2354
+ $[0] = field.collectionId;
2355
+ $[1] = recordsMap;
2356
+ $[2] = stored;
2357
+ $[3] = t1;
2358
+ } else t1 = $[3];
2359
+ const record = t1;
2360
+ const placedRecord = usePlacedRecord(block, owner, fieldName, record);
2361
+ const { editable } = placedRecord;
2362
+ let t2;
2363
+ if ($[4] !== fieldId) {
2364
+ t2 = { fieldId };
2365
+ $[4] = fieldId;
2366
+ $[5] = t2;
2367
+ } else t2 = $[5];
2368
+ const fieldHovered = useOverlayMessage(iframeWindow, editable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t2);
2369
+ const overlay = useOverlayState(placedRecord.hovered || fieldHovered, fieldSelected || placedRecord.selected);
2370
+ if (!record && !editable) return null;
2371
+ let t3;
2372
+ if ($[6] !== block || $[7] !== children || $[8] !== collectionTitle || $[9] !== field || $[10] !== fieldId || $[11] !== fieldSelection || $[12] !== placedRecord.reference || $[13] !== record) {
2373
+ t3 = record && placedRecord.reference ? /* @__PURE__ */ jsx(RecordScope, {
2374
+ block,
2375
+ field,
2376
+ record,
2377
+ reference: placedRecord.reference,
2378
+ children
2379
+ }) : /* @__PURE__ */ jsxs(ReferencePlaceholder, {
2380
+ fieldId,
2381
+ fieldSelection,
2382
+ children: ["Select ", collectionTitle]
2383
+ });
2384
+ $[6] = block;
2385
+ $[7] = children;
2386
+ $[8] = collectionTitle;
2387
+ $[9] = field;
2388
+ $[10] = fieldId;
2389
+ $[11] = fieldSelection;
2390
+ $[12] = placedRecord.reference;
2391
+ $[13] = record;
2392
+ $[14] = t3;
2393
+ } else t3 = $[14];
2394
+ const rendered = t3;
2395
+ if (!editable) return rendered;
2396
+ let t4;
2397
+ if ($[15] !== fieldId || $[16] !== overlay || $[17] !== placedRecord || $[18] !== record || $[19] !== rendered) {
2398
+ t4 = /* @__PURE__ */ jsx(PlacedRecordWrapper, {
2399
+ fieldId,
2400
+ record,
2401
+ placedRecord,
2402
+ overlay,
2403
+ children: rendered
2404
+ });
2405
+ $[15] = fieldId;
2406
+ $[16] = overlay;
2407
+ $[17] = placedRecord;
2408
+ $[18] = record;
2409
+ $[19] = rendered;
2410
+ $[20] = t4;
2411
+ } else t4 = $[20];
2412
+ return t4;
2413
+ };
2414
+ const ListedRecord = (t0) => {
2415
+ const $ = c(14);
2416
+ const { block, owner, field, fieldName, record, listHovered, children } = t0;
2417
+ const placedRecord = usePlacedRecord(block, owner, fieldName, record);
2418
+ const overlay = useOverlayState(placedRecord.hovered || listHovered, placedRecord.selected);
2419
+ if (!placedRecord.reference) return null;
2420
+ let t1;
2421
+ if ($[0] !== block || $[1] !== children || $[2] !== field || $[3] !== placedRecord.reference || $[4] !== record) {
2422
+ t1 = /* @__PURE__ */ jsx(RecordScope, {
2423
+ block,
2424
+ field,
2425
+ record,
2426
+ reference: placedRecord.reference,
2427
+ children
2428
+ });
2429
+ $[0] = block;
2430
+ $[1] = children;
2431
+ $[2] = field;
2432
+ $[3] = placedRecord.reference;
2433
+ $[4] = record;
2434
+ $[5] = t1;
2435
+ } else t1 = $[5];
2436
+ const rendered = t1;
2437
+ if (!placedRecord.editable) return rendered;
2438
+ let t2;
2439
+ if ($[6] !== placedRecord.reference.placement) {
2440
+ t2 = recordPlacementId(placedRecord.reference.placement);
2441
+ $[6] = placedRecord.reference.placement;
2442
+ $[7] = t2;
2443
+ } else t2 = $[7];
2444
+ let t3;
2445
+ if ($[8] !== overlay || $[9] !== placedRecord || $[10] !== record || $[11] !== rendered || $[12] !== t2) {
2446
+ t3 = /* @__PURE__ */ jsx(PlacedRecordWrapper, {
2447
+ fieldId: t2,
2448
+ record,
2449
+ placedRecord,
2450
+ overlay,
2451
+ children: rendered
2452
+ });
2453
+ $[8] = overlay;
2454
+ $[9] = placedRecord;
2455
+ $[10] = record;
2456
+ $[11] = rendered;
2457
+ $[12] = t2;
2458
+ $[13] = t3;
2459
+ } else t3 = $[13];
2460
+ return t3;
2461
+ };
2462
+ const LayoutRecord = (t0) => {
2463
+ const $ = c(25);
2464
+ const { layoutId, record, properties, children } = t0;
2465
+ const t1 = record.content;
2466
+ let t2;
2467
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2468
+ t2 = {};
2469
+ $[0] = t2;
2470
+ } else t2 = $[0];
2471
+ let t3;
2472
+ if ($[1] !== properties || $[2] !== t1) {
2473
+ t3 = {
2474
+ blockId: "",
2475
+ content: t1,
2476
+ sourceSchema: properties,
2477
+ settings: t2,
2478
+ isHovered: false,
2479
+ setIsHovered: _temp8,
2480
+ mode: "layout"
2481
+ };
2482
+ $[1] = properties;
2483
+ $[2] = t1;
2484
+ $[3] = t3;
2485
+ } else t3 = $[3];
2486
+ const block = t3;
2487
+ let t4;
2488
+ if ($[4] !== layoutId) {
2489
+ t4 = {
2490
+ itemId: void 0,
2491
+ outer: null,
2492
+ layoutId
2493
+ };
2494
+ $[4] = layoutId;
2495
+ $[5] = t4;
2496
+ } else t4 = $[5];
2497
+ const placedRecord = usePlacedRecord(block, t4, "", record);
2498
+ const overlay = useOverlayState(placedRecord.hovered, placedRecord.selected);
2499
+ if (!placedRecord.reference) return null;
2500
+ let t5;
2501
+ if ($[6] !== properties) {
2502
+ t5 = { referenceSchema: { properties } };
2503
+ $[6] = properties;
2504
+ $[7] = t5;
2505
+ } else t5 = $[7];
2506
+ let t6;
2507
+ if ($[8] !== block || $[9] !== children || $[10] !== placedRecord.reference || $[11] !== record || $[12] !== t5) {
2508
+ t6 = /* @__PURE__ */ jsx(RecordScope, {
2509
+ block,
2510
+ field: t5,
2511
+ record,
2512
+ reference: placedRecord.reference,
2513
+ children
2514
+ });
2515
+ $[8] = block;
2516
+ $[9] = children;
2517
+ $[10] = placedRecord.reference;
2518
+ $[11] = record;
2519
+ $[12] = t5;
2520
+ $[13] = t6;
2521
+ } else t6 = $[13];
2522
+ let t7;
2523
+ if ($[14] !== record.references || $[15] !== t6) {
2524
+ t7 = /* @__PURE__ */ jsx(LinkedRecordsProvider, {
2525
+ references: record.references,
2526
+ children: t6
2527
+ });
2528
+ $[14] = record.references;
2529
+ $[15] = t6;
2530
+ $[16] = t7;
2531
+ } else t7 = $[16];
2532
+ const rendered = t7;
2533
+ if (!placedRecord.editable) return rendered;
2534
+ let t8;
2535
+ if ($[17] !== placedRecord.reference.placement) {
2536
+ t8 = recordPlacementId(placedRecord.reference.placement);
2537
+ $[17] = placedRecord.reference.placement;
2538
+ $[18] = t8;
2539
+ } else t8 = $[18];
2540
+ let t9;
2541
+ if ($[19] !== overlay || $[20] !== placedRecord || $[21] !== record || $[22] !== rendered || $[23] !== t8) {
2542
+ t9 = /* @__PURE__ */ jsx(PlacedRecordWrapper, {
2543
+ fieldId: t8,
2544
+ record,
2545
+ placedRecord,
2546
+ overlay,
2547
+ children: rendered
2548
+ });
2549
+ $[19] = overlay;
2550
+ $[20] = placedRecord;
2551
+ $[21] = record;
2552
+ $[22] = rendered;
2553
+ $[23] = t8;
2554
+ $[24] = t9;
2555
+ } else t9 = $[24];
2556
+ return t9;
2557
+ };
2558
+ const LayoutItem = (t0) => {
2559
+ const $ = c(9);
2560
+ const { collectionId, labelField, properties, record, children, fallback } = t0;
2561
+ const editingOwner = React.use(PreviewEditingOwnerContext);
2562
+ let t1;
2563
+ if ($[0] !== collectionId || $[1] !== labelField || $[2] !== record) {
2564
+ t1 = {
2565
+ collectionId,
2566
+ labelField,
2567
+ loaded: record
2568
+ };
2569
+ $[0] = collectionId;
2570
+ $[1] = labelField;
2571
+ $[2] = record;
2572
+ $[3] = t1;
2573
+ } else t1 = $[3];
2574
+ const latest = useLatestRecord(t1);
2575
+ if (editingOwner?.kind !== "layout" || !latest) return fallback;
2576
+ let t2;
2577
+ if ($[4] !== children || $[5] !== editingOwner.layoutId || $[6] !== latest || $[7] !== properties) {
2578
+ t2 = /* @__PURE__ */ jsx(LayoutRecord, {
2579
+ layoutId: editingOwner.layoutId,
2580
+ properties,
2581
+ record: latest,
2582
+ children
2583
+ });
2584
+ $[4] = children;
2585
+ $[5] = editingOwner.layoutId;
2586
+ $[6] = latest;
2587
+ $[7] = properties;
2588
+ $[8] = t2;
2589
+ } else t2 = $[8];
2590
+ return t2;
2591
+ };
2592
+ const ReferenceList = (t0) => {
2593
+ const $ = c(44);
2594
+ const { name, children } = t0;
2595
+ const block = React.use(Context);
2596
+ const normalizedData = useNormalizedData();
2597
+ const { recordsMap } = normalizedData;
2598
+ const { window: iframeWindow } = useFrame();
2599
+ if (!block) throw new Error("ReferenceList must be used within a Block Component");
2600
+ const editable = useIsEditable(block.mode);
2601
+ const fieldName = String(name);
2602
+ const { owner, field, stored, fieldId, fieldSelection } = useReferenceField(block, fieldName);
2603
+ const collectionTitle = useCollectionTitle(fieldName, field);
2604
+ let t1;
2605
+ if ($[0] !== fieldId) {
2606
+ t1 = { fieldId };
2607
+ $[0] = fieldId;
2608
+ $[1] = t1;
2609
+ } else t1 = $[1];
2610
+ const listHovered = useOverlayMessage(iframeWindow, editable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t1);
2611
+ const placeholderOverlay = useOverlayState(listHovered);
2612
+ let t2;
2613
+ if ($[2] !== field) {
2614
+ t2 = isQueryBacked(field);
2615
+ $[2] = field;
2616
+ $[3] = t2;
2617
+ } else t2 = $[3];
2618
+ const queryBacked = t2;
2619
+ let t3;
2620
+ if ($[4] !== block.blockId || $[5] !== fieldName || $[6] !== normalizedData || $[7] !== owner || $[8] !== queryBacked || $[9] !== stored) {
2621
+ t3 = queryBacked ? queryResultIds(normalizedData, {
2622
+ blockId: block.blockId,
2623
+ itemId: owner.itemId
2624
+ }, fieldName) : stored;
2625
+ $[4] = block.blockId;
2626
+ $[5] = fieldName;
2627
+ $[6] = normalizedData;
2628
+ $[7] = owner;
2629
+ $[8] = queryBacked;
2630
+ $[9] = stored;
2631
+ $[10] = t3;
2632
+ } else t3 = $[10];
2633
+ const ids = t3;
2634
+ let t4;
2635
+ let t5;
2636
+ if ($[11] !== block || $[12] !== children || $[13] !== collectionTitle || $[14] !== editable || $[15] !== field || $[16] !== fieldId || $[17] !== fieldName || $[18] !== fieldSelection || $[19] !== ids || $[20] !== listHovered || $[21] !== owner || $[22] !== placeholderOverlay || $[23] !== queryBacked || $[24] !== recordsMap) {
2637
+ t5 = Symbol.for("react.early_return_sentinel");
2638
+ bb0: {
2639
+ const records = resolveReferenceList(ids, field.collectionId, recordsMap);
2640
+ if (records.length === 0) {
2641
+ if (!editable || queryBacked) {
2642
+ t5 = null;
2643
+ break bb0;
2644
+ }
2645
+ let t6;
2646
+ if ($[27] !== fieldSelection.type) {
2647
+ t6 = fieldSelection.type === "record-field" ? { recordFieldType: "ReferenceList" } : { fieldType: "ReferenceList" };
2648
+ $[27] = fieldSelection.type;
2649
+ $[28] = t6;
2650
+ } else t6 = $[28];
2651
+ let t7;
2652
+ if ($[29] !== fieldSelection || $[30] !== t6) {
2653
+ t7 = {
2654
+ ...fieldSelection,
2655
+ ...t6
2656
+ };
2657
+ $[29] = fieldSelection;
2658
+ $[30] = t6;
2659
+ $[31] = t7;
2660
+ } else t7 = $[31];
2661
+ const t8 = t7;
2662
+ let t9;
2663
+ if ($[32] !== collectionTitle || $[33] !== fieldId || $[34] !== placeholderOverlay || $[35] !== t8) {
2664
+ t9 = /* @__PURE__ */ jsxs(ReferencePlaceholder, {
2665
+ fieldId,
2666
+ fieldSelection: t8,
2667
+ "data-camox-field-id": fieldId,
2668
+ "data-camox-overlay-mode": "reference",
2669
+ ...placeholderOverlay,
2670
+ children: ["Add ", collectionTitle]
2671
+ });
2672
+ $[32] = collectionTitle;
2673
+ $[33] = fieldId;
2674
+ $[34] = placeholderOverlay;
2675
+ $[35] = t8;
2676
+ $[36] = t9;
2677
+ } else t9 = $[36];
2678
+ t5 = t9;
2679
+ break bb0;
2680
+ }
2681
+ let t6;
2682
+ if ($[37] !== block || $[38] !== children || $[39] !== field || $[40] !== fieldName || $[41] !== listHovered || $[42] !== owner) {
2683
+ t6 = (record) => /* @__PURE__ */ jsx(ListedRecord, {
2684
+ block,
2685
+ owner,
2686
+ field,
2687
+ fieldName,
2688
+ record,
2689
+ listHovered,
2690
+ children
2691
+ }, record.id);
2692
+ $[37] = block;
2693
+ $[38] = children;
2694
+ $[39] = field;
2695
+ $[40] = fieldName;
2696
+ $[41] = listHovered;
2697
+ $[42] = owner;
2698
+ $[43] = t6;
2699
+ } else t6 = $[43];
2700
+ t4 = records.map(t6);
2701
+ }
2702
+ $[11] = block;
2703
+ $[12] = children;
2704
+ $[13] = collectionTitle;
2705
+ $[14] = editable;
2706
+ $[15] = field;
2707
+ $[16] = fieldId;
2708
+ $[17] = fieldName;
2709
+ $[18] = fieldSelection;
2710
+ $[19] = ids;
2711
+ $[20] = listHovered;
2712
+ $[21] = owner;
2713
+ $[22] = placeholderOverlay;
2714
+ $[23] = queryBacked;
2715
+ $[24] = recordsMap;
2716
+ $[25] = t4;
2717
+ $[26] = t5;
2718
+ } else {
2719
+ t4 = $[25];
2720
+ t5 = $[26];
2721
+ }
2722
+ if (t5 !== Symbol.for("react.early_return_sentinel")) return t5;
2723
+ return t4;
2724
+ };
2725
+ const Detached = (t0) => {
2726
+ const $ = c(30);
1661
2727
  const { children } = t0;
1662
2728
  const ctx = React.use(Context);
1663
2729
  if (!ctx) throw new Error("Detached must be used within a Block Component");
1664
2730
  const { blockId, mode, isHovered, setIsHovered } = ctx;
1665
2731
  const isContentEditable = useIsEditable(mode);
1666
2732
  const { window: iframeWindow } = useFrame();
1667
- const selection = useSelector(previewStore, _temp8);
1668
- const isAddBlockSidebarOpen = useSelector(previewStore, _temp9);
2733
+ const selection = usePreviewTargetSelection();
1669
2734
  const selectTarget = usePreviewSelection();
1670
- const isBlockSelected = selection?.blockId === blockId;
1671
- const overlayState = useOverlayState(isHovered && !isBlockSelected, isBlockSelected);
1672
- const t1 = String(blockId);
1673
- let t2;
1674
- if ($[1] !== t1) {
1675
- t2 = { blockId: t1 };
2735
+ let t1;
2736
+ if ($[0] !== selection) {
2737
+ t1 = selectionBlockId(selection);
2738
+ $[0] = selection;
1676
2739
  $[1] = t1;
1677
- $[2] = t2;
1678
- } else t2 = $[2];
1679
- const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t2);
2740
+ } else t1 = $[1];
2741
+ const overlayState = useOverlayState(isHovered, t1 === blockId);
2742
+ const t2 = String(blockId);
1680
2743
  let t3;
2744
+ if ($[2] !== t2) {
2745
+ t3 = { blockId: t2 };
2746
+ $[2] = t2;
2747
+ $[3] = t3;
2748
+ } else t3 = $[3];
2749
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t3);
1681
2750
  let t4;
1682
- if ($[3] !== isHoveredFromSidebar || $[4] !== setIsHovered) {
1683
- t3 = () => {
2751
+ let t5;
2752
+ if ($[4] !== isHoveredFromSidebar || $[5] !== setIsHovered) {
2753
+ t4 = () => {
1684
2754
  setIsHovered(isHoveredFromSidebar);
1685
2755
  };
1686
- t4 = [isHoveredFromSidebar, setIsHovered];
1687
- $[3] = isHoveredFromSidebar;
1688
- $[4] = setIsHovered;
1689
- $[5] = t3;
2756
+ t5 = [isHoveredFromSidebar, setIsHovered];
2757
+ $[4] = isHoveredFromSidebar;
2758
+ $[5] = setIsHovered;
1690
2759
  $[6] = t4;
2760
+ $[7] = t5;
1691
2761
  } else {
1692
- t3 = $[5];
1693
2762
  t4 = $[6];
2763
+ t5 = $[7];
1694
2764
  }
1695
- React.useEffect(t3, t4);
1696
- const shouldShowOverlay = isContentEditable && (overlayState["data-camox-hovered"] || overlayState["data-camox-focused"]) && !isAddBlockSidebarOpen;
1697
- const shouldHideForAddBlockSidebar = isAddBlockSidebarOpen && mode !== "peek";
1698
- let t5;
1699
- if ($[7] !== blockId || $[8] !== isContentEditable || $[9] !== selectTarget) {
1700
- t5 = (e) => {
2765
+ React.useEffect(t4, t5);
2766
+ const shouldShowOverlay = isContentEditable && (overlayState["data-camox-hovered"] || overlayState["data-camox-focused"]);
2767
+ let t6;
2768
+ if ($[8] !== blockId || $[9] !== isContentEditable || $[10] !== selectTarget) {
2769
+ t6 = (e) => {
1701
2770
  if (!isContentEditable) return;
1702
2771
  const target = e.target;
1703
2772
  if (target.closest("[data-camox-field-id]")) return;
1704
- if (selectIsCommentMode(previewStore.getSnapshot()) && target.closest("[data-camox-repeater-item-id]")) return;
1705
- if (target.closest("[data-camox-block-id], [data-camox-comment-block-id]") !== e.currentTarget) return;
2773
+ if (target.closest("[data-camox-block-id]") !== e.currentTarget) return;
1706
2774
  selectTarget({
1707
2775
  type: "block",
1708
2776
  blockId
1709
- }, e);
1710
- };
1711
- $[7] = blockId;
1712
- $[8] = isContentEditable;
1713
- $[9] = selectTarget;
1714
- $[10] = t5;
1715
- } else t5 = $[10];
1716
- const handleClick = t5;
1717
- let t6;
1718
- if ($[11] !== isContentEditable || $[12] !== setIsHovered) {
1719
- t6 = () => {
1720
- if (isContentEditable) setIsHovered(true);
2777
+ });
1721
2778
  };
1722
- $[11] = isContentEditable;
1723
- $[12] = setIsHovered;
1724
- $[13] = t6;
1725
- } else t6 = $[13];
1726
- const handleMouseEnter = t6;
2779
+ $[8] = blockId;
2780
+ $[9] = isContentEditable;
2781
+ $[10] = selectTarget;
2782
+ $[11] = t6;
2783
+ } else t6 = $[11];
2784
+ const handleClick = t6;
1727
2785
  let t7;
1728
- if ($[14] !== isContentEditable || $[15] !== setIsHovered) {
2786
+ if ($[12] !== isContentEditable || $[13] !== setIsHovered) {
1729
2787
  t7 = () => {
2788
+ if (isContentEditable) setIsHovered(true);
2789
+ };
2790
+ $[12] = isContentEditable;
2791
+ $[13] = setIsHovered;
2792
+ $[14] = t7;
2793
+ } else t7 = $[14];
2794
+ const handleMouseEnter = t7;
2795
+ let t8;
2796
+ if ($[15] !== isContentEditable || $[16] !== setIsHovered) {
2797
+ t8 = () => {
1730
2798
  if (isContentEditable) setIsHovered(false);
1731
2799
  };
1732
- $[14] = isContentEditable;
1733
- $[15] = setIsHovered;
1734
- $[16] = t7;
1735
- } else t7 = $[16];
1736
- const handleMouseLeave = t7;
1737
- const [container, setContainer] = React.useState(null);
1738
- const t8 = isContentEditable ? blockId : void 0;
1739
- const t9 = shouldHideForAddBlockSidebar ? 0 : 1;
2800
+ $[15] = isContentEditable;
2801
+ $[16] = setIsHovered;
2802
+ $[17] = t8;
2803
+ } else t8 = $[17];
2804
+ const handleMouseLeave = t8;
2805
+ const t9 = isContentEditable ? blockId : void 0;
1740
2806
  let t10;
1741
- if ($[17] !== children || $[18] !== handleClick || $[19] !== handleMouseEnter || $[20] !== handleMouseLeave || $[21] !== t8 || $[22] !== t9) {
1742
- t10 = children({
1743
- "data-camox-comment-block-id": t8,
1744
- ref: setContainer,
1745
- style: { opacity: t9 },
2807
+ if ($[18] !== overlayState || $[19] !== shouldShowOverlay) {
2808
+ t10 = shouldShowOverlay ? overlayState : {};
2809
+ $[18] = overlayState;
2810
+ $[19] = shouldShowOverlay;
2811
+ $[20] = t10;
2812
+ } else t10 = $[20];
2813
+ let t11;
2814
+ if ($[21] !== children || $[22] !== handleClick || $[23] !== handleMouseEnter || $[24] !== handleMouseLeave || $[25] !== t10 || $[26] !== t9) {
2815
+ t11 = children({
2816
+ "data-camox-block-id": t9,
2817
+ ...t10,
2818
+ "data-camox-overlay-mode": options.synced ? "synced" : void 0,
1746
2819
  onClickCapture: handleClick,
1747
2820
  onMouseEnter: handleMouseEnter,
1748
2821
  onMouseLeave: handleMouseLeave
1749
2822
  });
1750
- $[17] = children;
1751
- $[18] = handleClick;
1752
- $[19] = handleMouseEnter;
1753
- $[20] = handleMouseLeave;
1754
- $[21] = t8;
1755
- $[22] = t9;
1756
- $[23] = t10;
1757
- } else t10 = $[23];
1758
- let t11;
1759
- if ($[24] !== blockId || $[25] !== container || $[26] !== overlayState || $[27] !== shouldShowOverlay) {
1760
- t11 = container && createPortal(/* @__PURE__ */ jsx(Fragment, { children: shouldShowOverlay && /* @__PURE__ */ jsx("div", {
1761
- "data-camox-block-id": blockId,
1762
- "data-camox-detached": true,
1763
- ...overlayState,
1764
- "data-camox-overlay-mode": options.synced ? "synced" : void 0,
1765
- style: {
1766
- position: "absolute",
1767
- pointerEvents: "none",
1768
- zIndex: 10
1769
- }
1770
- }) }), container);
1771
- $[24] = blockId;
1772
- $[25] = container;
1773
- $[26] = overlayState;
1774
- $[27] = shouldShowOverlay;
1775
- $[28] = t11;
1776
- } else t11 = $[28];
2823
+ $[21] = children;
2824
+ $[22] = handleClick;
2825
+ $[23] = handleMouseEnter;
2826
+ $[24] = handleMouseLeave;
2827
+ $[25] = t10;
2828
+ $[26] = t9;
2829
+ $[27] = t11;
2830
+ } else t11 = $[27];
1777
2831
  let t12;
1778
- if ($[29] !== t10 || $[30] !== t11) {
1779
- t12 = /* @__PURE__ */ jsxs(Fragment, { children: [t10, t11] });
1780
- $[29] = t10;
1781
- $[30] = t11;
1782
- $[31] = t12;
1783
- } else t12 = $[31];
2832
+ if ($[28] !== t11) {
2833
+ t12 = /* @__PURE__ */ jsx(Fragment, { children: t11 });
2834
+ $[28] = t11;
2835
+ $[29] = t12;
2836
+ } else t12 = $[29];
1784
2837
  return t12;
1785
2838
  };
1786
2839
  return {
@@ -1788,20 +2841,19 @@ function createEditableBlock(options) {
1788
2841
  Icon,
1789
2842
  Field,
1790
2843
  Embed,
2844
+ Artifact,
1791
2845
  Link,
1792
2846
  Image,
1793
2847
  File,
1794
2848
  ImageList,
1795
2849
  FileList,
1796
2850
  Repeater,
2851
+ Reference,
2852
+ ReferenceList,
1797
2853
  useSetting,
1798
2854
  _internal: {
1799
- /**
1800
- * The react component to be used at the page level when mapping on blocks content.
1801
- * It exposes context that will be consumed by the Field component, and provides visual editing
1802
- * capabilities (e.g. delete and reorder blocks).
1803
- */
1804
2855
  Component: BlockComponent,
2856
+ LayoutItem,
1805
2857
  id: options.id,
1806
2858
  title: options.title,
1807
2859
  description: options.description,
@@ -1833,7 +2885,7 @@ function createEditableBlock(options) {
1833
2885
  return { ...settingsDefaults };
1834
2886
  },
1835
2887
  getPeekBundle: () => {
1836
- const PEEK_BLOCK_ID = -1;
2888
+ const PEEK_BLOCK_ID = "peek";
1837
2889
  const counter = { value: 0 };
1838
2890
  const allItems = [];
1839
2891
  const content = { ...contentDefaults };
@@ -1846,7 +2898,7 @@ function createEditableBlock(options) {
1846
2898
  type: options.id,
1847
2899
  content,
1848
2900
  settings: settingsDefaults,
1849
- placement: null,
2901
+ slot: null,
1850
2902
  summary: "",
1851
2903
  position: "",
1852
2904
  createdAt: 0,
@@ -1865,27 +2917,22 @@ function _temp(l) {
1865
2917
  function _temp2(l) {
1866
2918
  return l.pathname;
1867
2919
  }
1868
- function _temp3(e_0) {
2920
+ function _temp3(l) {
2921
+ return l.pathname;
2922
+ }
2923
+ function _temp4(e_0) {
1869
2924
  return e_0.preventDefault();
1870
2925
  }
1871
- function _temp4(e_1) {
2926
+ function _temp5(e_1) {
1872
2927
  if (e_1.key === "Escape") e_1.target.blur();
1873
2928
  }
1874
- function _temp5(state) {
1875
- return state.context.selection;
1876
- }
1877
- function _temp6(state_0) {
1878
- return state_0.context.isAddBlockSidebarOpen;
2929
+ function _temp6(event) {
2930
+ return event.preventDefault();
1879
2931
  }
1880
2932
  function _temp7(item) {
1881
2933
  return item.content;
1882
2934
  }
1883
- function _temp8(state) {
1884
- return state.context.selection;
1885
- }
1886
- function _temp9(state_0) {
1887
- return state_0.context.isAddBlockSidebarOpen;
1888
- }
2935
+ function _temp8() {}
1889
2936
 
1890
2937
  //#endregion
1891
2938
  export { createEditableBlock };