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
@@ -0,0 +1,1734 @@
1
+ import { useAuthContext, useProjectUuid } from "../../lib/auth.js";
2
+ import { parseLocalePath } from "../../lib/locale-path.js";
3
+ import { useOptionalDraftScope } from "../../lib/draft-scope.js";
4
+ import { useViewLocale } from "../../lib/view-locale-context.js";
5
+ import { NavigationProvider, useLocation, useNavigate } from "../navigation/navigation.js";
6
+ import { useCamoxApp } from "../provider/components/CamoxAppContext.js";
7
+ import { reads, useReadQuery, useStudioCache } from "../../lib/studio-reads.js";
8
+ import { pageMutations } from "../../lib/queries.js";
9
+ import { useLocalizedPath } from "../../lib/view-locale.js";
10
+ import { canvasStore, setShelfCollapsed, useCollapsedShelves } from "./canvasStore.js";
11
+ import { STUDIO_CANVAS_PATH, blockCatalogPath, matchBlockCatalogPath } from "../studio/routes.js";
12
+ import { previewStore } from "../preview/previewStore.js";
13
+ import { PREVIEW_PAGE_SLOT_ATTRIBUTE, PreviewPageFrameContext } from "../preview/previewPageFrame.js";
14
+ import { PreviewPreparationContext } from "../preview/previewPreparation.js";
15
+ import { canvasBlockOverlap } from "./canvasFrameDocument.js";
16
+ import { CanvasWorkspaceContext } from "./canvasZoom.js";
17
+ import { PageRecordContext, getPageRecord } from "../preview/pageRecord.js";
18
+ import { CuratedBlockShortcuts } from "../preview/components/PreviewPanel.js";
19
+ import { FollowAgentContext } from "../studio/followAgentContext.js";
20
+ import { useCanvasFrameMode } from "./canvasFrameMode.js";
21
+ import { useCanvasNearness } from "./useCanvasNearness.js";
22
+ import { CanvasBlockFrame } from "./CanvasBlockFrame.js";
23
+ import { CanvasBlockHeader } from "./CanvasBlockHeader.js";
24
+ import { CANVAS_DEVICES, canvasLayoutId, canvasPageId, derivedLayoutIdOf, getCanvasPages } from "./canvasPages.js";
25
+ import { CANVAS_SLOT_WIDTH, canvasBlockKey, canvasSnapTargets, getBlockCatalog, getCanvasShelves, getDefaultCollapsedShelves, isCanvasBlock, isCanvasShelfShown, positionCanvasShelves } from "./canvasItems.js";
26
+ import { CanvasOverlaysShownContext } from "./CanvasOverlays.js";
27
+ import { CanvasPageEdge } from "./CanvasPageEdge.js";
28
+ import { CANVAS_THUMBNAIL_MAX_ZOOM, CanvasThumbnailsContext, canvasThumbnailsSupported, createCanvasThumbnails, useCanvasThumbnail } from "./canvasThumbnails.js";
29
+ import { CanvasPageFrame } from "./CanvasPageFrame.js";
30
+ import { CanvasPageHeader } from "./CanvasPageHeader.js";
31
+ import { CanvasPreviewPageSlot } from "./CanvasPreviewPageSlot.js";
32
+ import { CANVAS_WORLD_TRANSFORM, canvasScreenAbove, canvasScreenLength, canvasScreenX } from "./canvasScreenSpace.js";
33
+ import { selectedCanvasPage } from "./canvasSelection.js";
34
+ import { CanvasShelfMarkers } from "./CanvasShelfMarker.js";
35
+ import { CanvasSidebar } from "./sidebar/CanvasSidebar.js";
36
+ import { useCanvasCamera } from "./useCanvasCamera.js";
37
+ import { useDiscoveredPreviewPaths } from "./useDiscoveredPreviewPaths.js";
38
+ import { c } from "react/compiler-runtime";
39
+ import * as React from "react";
40
+ import { useSelector } from "@xstate/store-react";
41
+ import { jsx, jsxs } from "react/jsx-runtime";
42
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
43
+ import { createStore as createStore$1 } from "@xstate/store";
44
+
45
+ //#region src/features/canvas/CamoxCanvas.tsx
46
+ function usePreparationFailure(error, t0) {
47
+ const $ = c(5);
48
+ const selected = t0 === void 0 ? true : t0;
49
+ const preparation = React.useContext(PreviewPreparationContext);
50
+ let t1;
51
+ let t2;
52
+ if ($[0] !== error || $[1] !== preparation || $[2] !== selected) {
53
+ t1 = () => {
54
+ if (error && selected) preparation?.fail(error);
55
+ };
56
+ t2 = [
57
+ error,
58
+ selected,
59
+ preparation
60
+ ];
61
+ $[0] = error;
62
+ $[1] = preparation;
63
+ $[2] = selected;
64
+ $[3] = t1;
65
+ $[4] = t2;
66
+ } else {
67
+ t1 = $[3];
68
+ t2 = $[4];
69
+ }
70
+ React.useEffect(t1, t2);
71
+ }
72
+ function PreparationFailure(t0) {
73
+ const { error, selected } = t0;
74
+ usePreparationFailure(error, selected);
75
+ return null;
76
+ }
77
+ function CanvasMessage(t0) {
78
+ const $ = c(2);
79
+ const { children } = t0;
80
+ let t1;
81
+ if ($[0] !== children) {
82
+ t1 = /* @__PURE__ */ jsx("div", {
83
+ className: "text-muted-foreground grid min-h-64 place-items-center p-8 text-center text-sm",
84
+ children
85
+ });
86
+ $[0] = children;
87
+ $[1] = t1;
88
+ } else t1 = $[1];
89
+ return t1;
90
+ }
91
+ /** A per-card error boundary, so a failing frame never takes the Canvas down. */
92
+ var CanvasFrameBoundary = class extends React.Component {
93
+ state = { error: null };
94
+ static getDerivedStateFromError(error) {
95
+ return { error };
96
+ }
97
+ render() {
98
+ if (!this.state.error) return this.props.children;
99
+ return /* @__PURE__ */ jsxs(CanvasMessage, { children: [/* @__PURE__ */ jsx(PreparationFailure, {
100
+ error: this.state.error,
101
+ selected: this.props.selected ?? false
102
+ }), /* @__PURE__ */ jsxs("div", {
103
+ role: "alert",
104
+ children: [
105
+ /* @__PURE__ */ jsxs("p", { children: [
106
+ "This ",
107
+ this.props.subject,
108
+ " could not be rendered."
109
+ ] }),
110
+ /* @__PURE__ */ jsx("p", {
111
+ className: "mt-2",
112
+ children: this.state.error.message
113
+ }),
114
+ /* @__PURE__ */ jsx("button", {
115
+ className: "mt-4 underline",
116
+ onClick: () => this.setState({ error: null }),
117
+ children: "Try again"
118
+ })
119
+ ]
120
+ })] });
121
+ }
122
+ };
123
+ /**
124
+ * A Page loads its frame once it first comes near the Canvas viewport, and the
125
+ * selected Page right away, wherever the camera is. The frame then stays
126
+ * mounted, but only runs while selected and the camera is still.
127
+ *
128
+ * Zoomed out, or away from the camera, a Page shows a still image of its frame
129
+ * instead, once it has one: the frame unmounts. Its frame comes back near the
130
+ * camera when zoomed in, out of sight until it settles, so the swap doesn't show.
131
+ * Frames come and go only while the camera is still.
132
+ */
133
+ function CanvasPagePreview(props) {
134
+ const $ = c(53);
135
+ const ref = React.useRef(null);
136
+ const { near, reached } = useCanvasNearness(ref);
137
+ let t0;
138
+ if ($[0] !== near || $[1] !== props.selected) {
139
+ t0 = {
140
+ near,
141
+ selected: props.selected
142
+ };
143
+ $[0] = near;
144
+ $[1] = props.selected;
145
+ $[2] = t0;
146
+ } else t0 = $[2];
147
+ const mode = useCanvasFrameMode(t0);
148
+ const workspaceKey = React.use(CanvasWorkspaceContext)?.workspaceKey;
149
+ const draftId = useOptionalDraftScope().draftId;
150
+ const { locale } = useViewLocale();
151
+ let t1;
152
+ if ($[3] !== draftId || $[4] !== locale || $[5] !== props.derivedLayoutId || $[6] !== props.pathname || $[7] !== props.runtimeBasePath || $[8] !== props.viewport.width) {
153
+ t1 = JSON.stringify([
154
+ draftId,
155
+ locale,
156
+ props.runtimeBasePath,
157
+ props.pathname,
158
+ props.derivedLayoutId ?? null,
159
+ props.viewport.width
160
+ ]);
161
+ $[3] = draftId;
162
+ $[4] = locale;
163
+ $[5] = props.derivedLayoutId;
164
+ $[6] = props.pathname;
165
+ $[7] = props.runtimeBasePath;
166
+ $[8] = props.viewport.width;
167
+ $[9] = t1;
168
+ } else t1 = $[9];
169
+ const key = t1;
170
+ const { thumbnails, thumbnail, refreshing } = useCanvasThumbnail(key);
171
+ let t2;
172
+ if ($[10] !== thumbnails || $[11] !== workspaceKey) {
173
+ t2 = (state) => {
174
+ if (!thumbnails || workspaceKey == null) return false;
175
+ return (state.context.views[workspaceKey]?.camera.scale ?? .4) < CANVAS_THUMBNAIL_MAX_ZOOM;
176
+ };
177
+ $[10] = thumbnails;
178
+ $[11] = workspaceKey;
179
+ $[12] = t2;
180
+ } else t2 = $[12];
181
+ const zoomedOut = useSelector(canvasStore, t2);
182
+ const [loaded, setLoaded] = React.useState(false);
183
+ if ((reached || props.selected) && !loaded) setLoaded(true);
184
+ const wantsLive = props.selected || near && !zoomedOut;
185
+ const wantsFrame = loaded && (wantsLive || refreshing || !thumbnail);
186
+ const [frameShown, setFrameShown] = React.useState(false);
187
+ const [settledFrame, setSettledFrame] = React.useState(null);
188
+ const [settles, setSettles] = React.useState(0);
189
+ const [captured, setCaptured] = React.useState(0);
190
+ const captureRequested = settles > captured;
191
+ const waiting = frameShown !== wantsFrame || captureRequested;
192
+ let t3;
193
+ if ($[13] !== thumbnails || $[14] !== waiting || $[15] !== workspaceKey) {
194
+ t3 = (state_0) => !!thumbnails && waiting && workspaceKey != null && !!state_0.context.moving[workspaceKey];
195
+ $[13] = thumbnails;
196
+ $[14] = waiting;
197
+ $[15] = workspaceKey;
198
+ $[16] = t3;
199
+ } else t3 = $[16];
200
+ const moving = useSelector(canvasStore, t3);
201
+ if (frameShown !== wantsFrame && (!moving || !thumbnail)) {
202
+ setFrameShown(wantsFrame);
203
+ if (!wantsFrame) {
204
+ setSettledFrame(null);
205
+ setCaptured(settles);
206
+ }
207
+ }
208
+ const imageShown = !!thumbnail && !(frameShown && settledFrame && wantsLive);
209
+ const stale = !!thumbnail?.stale && near && !wantsLive;
210
+ let t4;
211
+ let t5;
212
+ if ($[17] !== key || $[18] !== stale || $[19] !== thumbnails) {
213
+ t4 = () => {
214
+ if (!stale || !thumbnails) return;
215
+ return thumbnails.requestRefresh(key);
216
+ };
217
+ t5 = [
218
+ stale,
219
+ thumbnails,
220
+ key
221
+ ];
222
+ $[17] = key;
223
+ $[18] = stale;
224
+ $[19] = thumbnails;
225
+ $[20] = t4;
226
+ $[21] = t5;
227
+ } else {
228
+ t4 = $[20];
229
+ t5 = $[21];
230
+ }
231
+ React.useEffect(t4, t5);
232
+ let t6;
233
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
234
+ t6 = (frame) => {
235
+ setSettledFrame(frame);
236
+ setSettles(_temp);
237
+ };
238
+ $[22] = t6;
239
+ } else t6 = $[22];
240
+ const onSettled = t6;
241
+ const resting = mode === "resting";
242
+ const started = React.useRef(0);
243
+ let t7;
244
+ let t8;
245
+ if ($[23] !== captureRequested || $[24] !== key || $[25] !== moving || $[26] !== props.derivedLayoutId || $[27] !== props.pageId || $[28] !== props.pathname || $[29] !== resting || $[30] !== settledFrame || $[31] !== settles || $[32] !== thumbnails) {
246
+ t7 = () => {
247
+ if (!captureRequested || moving || resting || !settledFrame || !thumbnails) return;
248
+ if (started.current >= settles) return;
249
+ const request = settles;
250
+ started.current = request;
251
+ const pixelRatio = window.devicePixelRatio;
252
+ const options = {
253
+ scale: Math.min(1, CANVAS_THUMBNAIL_MAX_ZOOM * pixelRatio),
254
+ blockOverlap: canvasBlockOverlap(CANVAS_THUMBNAIL_MAX_ZOOM, pixelRatio)
255
+ };
256
+ const tokens = [
257
+ props.pathname,
258
+ props.pageId,
259
+ props.derivedLayoutId
260
+ ].filter(_temp2);
261
+ thumbnails.capture(key, settledFrame, tokens, options).catch((error) => {
262
+ thumbnails.abandon(key);
263
+ console.warn(`[camox] Could not capture ${props.pathname} for the Canvas.`, error);
264
+ }).finally(() => setCaptured((count_0) => Math.max(count_0, request)));
265
+ };
266
+ t8 = [
267
+ captureRequested,
268
+ settles,
269
+ moving,
270
+ resting,
271
+ settledFrame,
272
+ thumbnails,
273
+ key,
274
+ props.pathname,
275
+ props.pageId,
276
+ props.derivedLayoutId
277
+ ];
278
+ $[23] = captureRequested;
279
+ $[24] = key;
280
+ $[25] = moving;
281
+ $[26] = props.derivedLayoutId;
282
+ $[27] = props.pageId;
283
+ $[28] = props.pathname;
284
+ $[29] = resting;
285
+ $[30] = settledFrame;
286
+ $[31] = settles;
287
+ $[32] = thumbnails;
288
+ $[33] = t7;
289
+ $[34] = t8;
290
+ } else {
291
+ t7 = $[33];
292
+ t8 = $[34];
293
+ }
294
+ React.useEffect(t7, t8);
295
+ const t9 = near || props.selected ? void 0 : "hidden";
296
+ let t10;
297
+ if ($[35] !== props.viewport.height || $[36] !== t9) {
298
+ t10 = {
299
+ position: "relative",
300
+ minHeight: props.viewport.height,
301
+ visibility: t9
302
+ };
303
+ $[35] = props.viewport.height;
304
+ $[36] = t9;
305
+ $[37] = t10;
306
+ } else t10 = $[37];
307
+ let t11;
308
+ if ($[38] !== frameShown || $[39] !== imageShown || $[40] !== mode || $[41] !== props || $[42] !== thumbnails) {
309
+ t11 = frameShown && /* @__PURE__ */ jsx("div", {
310
+ style: { visibility: imageShown ? "hidden" : void 0 },
311
+ children: /* @__PURE__ */ jsx(CanvasPageFrameLoader, {
312
+ ...props,
313
+ mode,
314
+ onSettled: thumbnails ? onSettled : void 0
315
+ })
316
+ });
317
+ $[38] = frameShown;
318
+ $[39] = imageShown;
319
+ $[40] = mode;
320
+ $[41] = props;
321
+ $[42] = thumbnails;
322
+ $[43] = t11;
323
+ } else t11 = $[43];
324
+ let t12;
325
+ if ($[44] !== frameShown || $[45] !== imageShown || $[46] !== props || $[47] !== thumbnail) {
326
+ t12 = imageShown && thumbnail && /* @__PURE__ */ jsx("img", {
327
+ src: thumbnail.url,
328
+ alt: "",
329
+ draggable: false,
330
+ "data-canvas-thumbnail": "",
331
+ onClick: (event) => {
332
+ if (!event.currentTarget.closest("[data-canvas-pan]")) props.onSelect();
333
+ },
334
+ style: {
335
+ display: "block",
336
+ width: thumbnail.width,
337
+ height: thumbnail.height,
338
+ ...frameShown ? {
339
+ position: "absolute",
340
+ top: 0,
341
+ left: 0
342
+ } : {}
343
+ }
344
+ });
345
+ $[44] = frameShown;
346
+ $[45] = imageShown;
347
+ $[46] = props;
348
+ $[47] = thumbnail;
349
+ $[48] = t12;
350
+ } else t12 = $[48];
351
+ let t13;
352
+ if ($[49] !== t10 || $[50] !== t11 || $[51] !== t12) {
353
+ t13 = /* @__PURE__ */ jsxs("div", {
354
+ ref,
355
+ style: t10,
356
+ children: [t11, t12]
357
+ });
358
+ $[49] = t10;
359
+ $[50] = t11;
360
+ $[51] = t12;
361
+ $[52] = t13;
362
+ } else t13 = $[52];
363
+ return t13;
364
+ }
365
+ function _temp2(token) {
366
+ return !!token;
367
+ }
368
+ function _temp(count) {
369
+ return count + 1;
370
+ }
371
+ function CanvasPageFrameLoader(t0) {
372
+ const $ = c(23);
373
+ const { pathname, runtimeBasePath, derivedLayoutId, pageId, viewport, selected, hovered, mode, onActivate, onSettled } = t0;
374
+ const projectUuid = useProjectUuid();
375
+ let t1;
376
+ if ($[0] !== derivedLayoutId || $[1] !== pathname || $[2] !== projectUuid || $[3] !== runtimeBasePath) {
377
+ t1 = reads.canvasFrame({
378
+ projectUuid,
379
+ runtimeBasePath,
380
+ pathname,
381
+ derivedLayoutId
382
+ });
383
+ $[0] = derivedLayoutId;
384
+ $[1] = pathname;
385
+ $[2] = projectUuid;
386
+ $[3] = runtimeBasePath;
387
+ $[4] = t1;
388
+ } else t1 = $[4];
389
+ const { data, error, isPending, isFetching, refetch } = useReadQuery(t1);
390
+ usePreparationFailure(isFetching ? null : error, selected);
391
+ if (isPending) {
392
+ let t2;
393
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
394
+ t2 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsx("span", {
395
+ role: "status",
396
+ children: "Loading page…"
397
+ }) });
398
+ $[5] = t2;
399
+ } else t2 = $[5];
400
+ return t2;
401
+ }
402
+ if (error) {
403
+ let t2;
404
+ if ($[6] !== error.message) {
405
+ t2 = /* @__PURE__ */ jsx("p", { children: error.message });
406
+ $[6] = error.message;
407
+ $[7] = t2;
408
+ } else t2 = $[7];
409
+ let t3;
410
+ if ($[8] !== refetch) {
411
+ t3 = /* @__PURE__ */ jsx("button", {
412
+ className: "mt-4 underline",
413
+ onClick: () => void refetch(),
414
+ children: "Try again"
415
+ });
416
+ $[8] = refetch;
417
+ $[9] = t3;
418
+ } else t3 = $[9];
419
+ let t4;
420
+ if ($[10] !== t2 || $[11] !== t3) {
421
+ t4 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsxs("div", {
422
+ role: "alert",
423
+ children: [t2, t3]
424
+ }) });
425
+ $[10] = t2;
426
+ $[11] = t3;
427
+ $[12] = t4;
428
+ } else t4 = $[12];
429
+ return t4;
430
+ }
431
+ let t2;
432
+ if ($[13] !== data || $[14] !== hovered || $[15] !== mode || $[16] !== onActivate || $[17] !== onSettled || $[18] !== pageId || $[19] !== selected || $[20] !== viewport.height || $[21] !== viewport.width) {
433
+ t2 = /* @__PURE__ */ jsx(CanvasPageFrame, {
434
+ input: data,
435
+ width: viewport.width,
436
+ viewportHeight: viewport.height,
437
+ pageId,
438
+ selected,
439
+ hovered,
440
+ mode,
441
+ onActivate,
442
+ onSettled
443
+ });
444
+ $[13] = data;
445
+ $[14] = hovered;
446
+ $[15] = mode;
447
+ $[16] = onActivate;
448
+ $[17] = onSettled;
449
+ $[18] = pageId;
450
+ $[19] = selected;
451
+ $[20] = viewport.height;
452
+ $[21] = viewport.width;
453
+ $[22] = t2;
454
+ } else t2 = $[22];
455
+ return t2;
456
+ }
457
+ const SNAP_FLASH_KEYFRAMES = [
458
+ { opacity: 0 },
459
+ {
460
+ opacity: 1,
461
+ offset: .15
462
+ },
463
+ { opacity: 0 }
464
+ ];
465
+ const SNAP_FLASH_TIMING = {
466
+ duration: 600,
467
+ easing: "ease-out"
468
+ };
469
+ /** A frame header above an item's slot, at a constant on-screen height. */
470
+ function CanvasHeaderSlot(t0) {
471
+ const $ = c(10);
472
+ const { itemKey, left, children } = t0;
473
+ let t1;
474
+ if ($[0] !== left) {
475
+ t1 = canvasScreenX(left);
476
+ $[0] = left;
477
+ $[1] = t1;
478
+ } else t1 = $[1];
479
+ let t2;
480
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
481
+ t2 = canvasScreenAbove(52);
482
+ $[2] = t2;
483
+ } else t2 = $[2];
484
+ const t3 = `translate(${t1}, ${t2})`;
485
+ let t4;
486
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
487
+ t4 = canvasScreenLength(CANVAS_SLOT_WIDTH);
488
+ $[3] = t4;
489
+ } else t4 = $[3];
490
+ let t5;
491
+ if ($[4] !== t3) {
492
+ t5 = {
493
+ height: 52,
494
+ transform: t3,
495
+ width: t4,
496
+ willChange: "transform",
497
+ zIndex: 2
498
+ };
499
+ $[4] = t3;
500
+ $[5] = t5;
501
+ } else t5 = $[5];
502
+ let t6;
503
+ if ($[6] !== children || $[7] !== itemKey || $[8] !== t5) {
504
+ t6 = /* @__PURE__ */ jsx("div", {
505
+ "data-canvas-header": itemKey,
506
+ className: "@container/canvas-header absolute top-0 left-0 pb-3",
507
+ style: t5,
508
+ children
509
+ });
510
+ $[6] = children;
511
+ $[7] = itemKey;
512
+ $[8] = t5;
513
+ $[9] = t6;
514
+ } else t6 = $[9];
515
+ return t6;
516
+ }
517
+ /** World-space room above and below a frame narrower than its area. */
518
+ const CANVAS_FRAMED_PADDING = 40;
519
+ /**
520
+ * An item's area in the Canvas row, which the camera snaps to, with the item's
521
+ * frame centered in it. A frame narrower than its area shows the area in a
522
+ * shade of its own, with room above and below the frame.
523
+ */
524
+ function CanvasSlot(t0) {
525
+ const $ = c(7);
526
+ const { itemKey, framed, children } = t0;
527
+ const t1 = framed || void 0;
528
+ const t2 = framed ? CANVAS_FRAMED_PADDING : 0;
529
+ let t3;
530
+ if ($[0] !== t2) {
531
+ t3 = {
532
+ width: CANVAS_SLOT_WIDTH,
533
+ paddingBlock: t2
534
+ };
535
+ $[0] = t2;
536
+ $[1] = t3;
537
+ } else t3 = $[1];
538
+ let t4;
539
+ if ($[2] !== children || $[3] !== itemKey || $[4] !== t1 || $[5] !== t3) {
540
+ t4 = /* @__PURE__ */ jsx("div", {
541
+ "data-canvas-slot": itemKey,
542
+ "data-canvas-slot-shaded": t1,
543
+ className: "data-canvas-slot-shaded:bg-foreground/5 flex shrink-0 justify-center",
544
+ style: t3,
545
+ children
546
+ });
547
+ $[2] = children;
548
+ $[3] = itemKey;
549
+ $[4] = t1;
550
+ $[5] = t3;
551
+ $[6] = t4;
552
+ } else t4 = $[6];
553
+ return t4;
554
+ }
555
+ /**
556
+ * The Page whose header the pointer is over, which outlines its frame. Kept out
557
+ * of the Canvas's state, so hovering re-renders only the frames it outlines.
558
+ */
559
+ function createCanvasHover() {
560
+ return createStore$1({
561
+ context: { pageKey: null },
562
+ on: { set: (context, event) => context.pageKey === event.pageKey ? context : { pageKey: event.pageKey } }
563
+ });
564
+ }
565
+ /** A Block Catalog block's area in the Canvas row, with its frame. */
566
+ function CanvasBlockItem(t0) {
567
+ const $ = c(24);
568
+ const { itemKey, block, projectId, runtimeBasePath, viewport, framed, selected, selectBlock } = t0;
569
+ let t1;
570
+ if ($[0] !== viewport.width) {
571
+ t1 = { width: viewport.width };
572
+ $[0] = viewport.width;
573
+ $[1] = t1;
574
+ } else t1 = $[1];
575
+ let t2;
576
+ if ($[2] !== block || $[3] !== selectBlock) {
577
+ t2 = () => selectBlock(block);
578
+ $[2] = block;
579
+ $[3] = selectBlock;
580
+ $[4] = t2;
581
+ } else t2 = $[4];
582
+ let t3;
583
+ if ($[5] !== block || $[6] !== projectId || $[7] !== runtimeBasePath || $[8] !== selected || $[9] !== t2 || $[10] !== viewport.height || $[11] !== viewport.width) {
584
+ t3 = /* @__PURE__ */ jsx(CanvasFrameBoundary, {
585
+ subject: "block",
586
+ children: /* @__PURE__ */ jsx(CanvasBlockFrame, {
587
+ block,
588
+ projectId,
589
+ runtimeBasePath,
590
+ width: viewport.width,
591
+ viewportHeight: viewport.height,
592
+ selected,
593
+ onSelect: t2
594
+ })
595
+ });
596
+ $[5] = block;
597
+ $[6] = projectId;
598
+ $[7] = runtimeBasePath;
599
+ $[8] = selected;
600
+ $[9] = t2;
601
+ $[10] = viewport.height;
602
+ $[11] = viewport.width;
603
+ $[12] = t3;
604
+ } else t3 = $[12];
605
+ let t4;
606
+ if ($[13] !== framed) {
607
+ t4 = /* @__PURE__ */ jsx(CanvasPageEdge, { shaded: framed });
608
+ $[13] = framed;
609
+ $[14] = t4;
610
+ } else t4 = $[14];
611
+ let t5;
612
+ if ($[15] !== block._internal.id || $[16] !== t1 || $[17] !== t3 || $[18] !== t4) {
613
+ t5 = /* @__PURE__ */ jsxs("div", {
614
+ "data-canvas-block": block._internal.id,
615
+ className: "bg-background relative shrink-0 shadow-xl ring-1 ring-black/10",
616
+ style: t1,
617
+ children: [t3, t4]
618
+ });
619
+ $[15] = block._internal.id;
620
+ $[16] = t1;
621
+ $[17] = t3;
622
+ $[18] = t4;
623
+ $[19] = t5;
624
+ } else t5 = $[19];
625
+ let t6;
626
+ if ($[20] !== framed || $[21] !== itemKey || $[22] !== t5) {
627
+ t6 = /* @__PURE__ */ jsx(CanvasSlot, {
628
+ itemKey,
629
+ framed,
630
+ children: t5
631
+ });
632
+ $[20] = framed;
633
+ $[21] = itemKey;
634
+ $[22] = t5;
635
+ $[23] = t6;
636
+ } else t6 = $[23];
637
+ return t6;
638
+ }
639
+ /** A Page's area in the Canvas row, with its frame. */
640
+ function CanvasPageItem(t0) {
641
+ const $ = c(40);
642
+ const { page, pathname, selected, previewed, collapsed, framed, viewport, runtimeBasePath, onActivate, selectPage, hover } = t0;
643
+ let t1;
644
+ if ($[0] !== page.key) {
645
+ t1 = (state) => state.context.pageKey === page.key;
646
+ $[0] = page.key;
647
+ $[1] = t1;
648
+ } else t1 = $[1];
649
+ const hovered = useSelector(hover, t1);
650
+ let t2;
651
+ if ($[2] !== onActivate || $[3] !== pathname || $[4] !== selectPage) {
652
+ t2 = (owner, source, release) => {
653
+ if (!pathname) return;
654
+ onActivate(pathname, owner, release);
655
+ if (source === "interaction") selectPage(pathname);
656
+ };
657
+ $[2] = onActivate;
658
+ $[3] = pathname;
659
+ $[4] = selectPage;
660
+ $[5] = t2;
661
+ } else t2 = $[5];
662
+ const onPageActivate = t2;
663
+ let t3;
664
+ if ($[6] !== previewed) {
665
+ t3 = previewed ? { [PREVIEW_PAGE_SLOT_ATTRIBUTE]: "" } : {};
666
+ $[6] = previewed;
667
+ $[7] = t3;
668
+ } else t3 = $[7];
669
+ let t4;
670
+ if ($[8] !== viewport.height || $[9] !== viewport.width) {
671
+ t4 = {
672
+ width: viewport.width,
673
+ minHeight: viewport.height
674
+ };
675
+ $[8] = viewport.height;
676
+ $[9] = viewport.width;
677
+ $[10] = t4;
678
+ } else t4 = $[10];
679
+ let t5;
680
+ if ($[11] !== collapsed || $[12] !== framed || $[13] !== hovered || $[14] !== onPageActivate || $[15] !== page || $[16] !== pathname || $[17] !== previewed || $[18] !== runtimeBasePath || $[19] !== selectPage || $[20] !== selected || $[21] !== viewport) {
681
+ t5 = previewed ? /* @__PURE__ */ jsx(CanvasPreviewPageSlot, {
682
+ pageId: canvasPageId(page),
683
+ layoutId: canvasLayoutId(page),
684
+ width: viewport.width,
685
+ viewportHeight: viewport.height,
686
+ selected,
687
+ hovered,
688
+ hidden: collapsed,
689
+ shaded: framed,
690
+ onActivate: onPageActivate
691
+ }) : pathname ? /* @__PURE__ */ jsx(CanvasPagePreview, {
692
+ hovered,
693
+ pathname,
694
+ runtimeBasePath,
695
+ derivedLayoutId: derivedLayoutIdOf(page),
696
+ pageId: canvasPageId(page),
697
+ viewport,
698
+ selected,
699
+ onActivate: onPageActivate,
700
+ onSelect: () => selectPage(pathname)
701
+ }) : /* @__PURE__ */ jsx(CanvasMessage, { children: "Choose a page path above to preview this layout." });
702
+ $[11] = collapsed;
703
+ $[12] = framed;
704
+ $[13] = hovered;
705
+ $[14] = onPageActivate;
706
+ $[15] = page;
707
+ $[16] = pathname;
708
+ $[17] = previewed;
709
+ $[18] = runtimeBasePath;
710
+ $[19] = selectPage;
711
+ $[20] = selected;
712
+ $[21] = viewport;
713
+ $[22] = t5;
714
+ } else t5 = $[22];
715
+ let t6;
716
+ if ($[23] !== pathname || $[24] !== selected || $[25] !== t5) {
717
+ t6 = /* @__PURE__ */ jsx(CanvasFrameBoundary, {
718
+ subject: "page",
719
+ selected,
720
+ children: t5
721
+ }, pathname);
722
+ $[23] = pathname;
723
+ $[24] = selected;
724
+ $[25] = t5;
725
+ $[26] = t6;
726
+ } else t6 = $[26];
727
+ let t7;
728
+ if ($[27] !== framed) {
729
+ t7 = /* @__PURE__ */ jsx(CanvasPageEdge, { shaded: framed });
730
+ $[27] = framed;
731
+ $[28] = t7;
732
+ } else t7 = $[28];
733
+ let t8;
734
+ if ($[29] !== page.key || $[30] !== pathname || $[31] !== t3 || $[32] !== t4 || $[33] !== t6 || $[34] !== t7) {
735
+ t8 = /* @__PURE__ */ jsxs("div", {
736
+ "data-canvas-page": page.key,
737
+ "data-canvas-pathname": pathname,
738
+ ...t3,
739
+ className: "bg-background relative shrink-0 shadow-xl ring-1 ring-black/10",
740
+ style: t4,
741
+ children: [t6, t7]
742
+ });
743
+ $[29] = page.key;
744
+ $[30] = pathname;
745
+ $[31] = t3;
746
+ $[32] = t4;
747
+ $[33] = t6;
748
+ $[34] = t7;
749
+ $[35] = t8;
750
+ } else t8 = $[35];
751
+ let t9;
752
+ if ($[36] !== framed || $[37] !== page.key || $[38] !== t8) {
753
+ t9 = /* @__PURE__ */ jsx(CanvasSlot, {
754
+ itemKey: page.key,
755
+ framed,
756
+ children: t8
757
+ });
758
+ $[36] = framed;
759
+ $[37] = page.key;
760
+ $[38] = t8;
761
+ $[39] = t9;
762
+ } else t9 = $[39];
763
+ return t9;
764
+ }
765
+ /** A block header with the number of Pages placing the block. */
766
+ function CanvasBlockUsageHeader(t0) {
767
+ const $ = c(7);
768
+ const { projectId, block, onSelect } = t0;
769
+ let t1;
770
+ if ($[0] !== block._internal.id || $[1] !== projectId) {
771
+ t1 = reads.pagesUsingBlock({
772
+ projectId,
773
+ type: block._internal.id
774
+ });
775
+ $[0] = block._internal.id;
776
+ $[1] = projectId;
777
+ $[2] = t1;
778
+ } else t1 = $[2];
779
+ const t2 = useReadQuery(t1).data?.length;
780
+ let t3;
781
+ if ($[3] !== block || $[4] !== onSelect || $[5] !== t2) {
782
+ t3 = /* @__PURE__ */ jsx(CanvasBlockHeader, {
783
+ block,
784
+ pageCount: t2,
785
+ onSelect
786
+ });
787
+ $[3] = block;
788
+ $[4] = onSelect;
789
+ $[5] = t2;
790
+ $[6] = t3;
791
+ } else t3 = $[6];
792
+ return t3;
793
+ }
794
+ /** Gives a Page a new nickname, keeping its path. */
795
+ function useRenamePage() {
796
+ const $ = c(4);
797
+ const studioCache = useStudioCache();
798
+ let t0;
799
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
800
+ t0 = pageMutations.update();
801
+ $[0] = t0;
802
+ } else t0 = $[0];
803
+ const updatePage = useMutation(t0);
804
+ let t1;
805
+ if ($[1] !== studioCache || $[2] !== updatePage) {
806
+ t1 = async (pageId, nickname) => {
807
+ const page = await studioCache.ensure(reads.page({ id: pageId }));
808
+ await updatePage.mutateAsync({
809
+ id: pageId,
810
+ nickname,
811
+ pathSegment: page.pathSegment,
812
+ parentPageId: page.parentPageId
813
+ });
814
+ };
815
+ $[1] = studioCache;
816
+ $[2] = updatePage;
817
+ $[3] = t1;
818
+ } else t1 = $[3];
819
+ return t1;
820
+ }
821
+ /**
822
+ * The still images of a workspace's Pages, where the browser draws them faithfully. They refresh
823
+ * while the camera is still, and all go stale when the website's code changes.
824
+ */
825
+ function useWorkspaceThumbnails(workspaceKey) {
826
+ const $ = c(13);
827
+ const queryClient = useQueryClient();
828
+ const app = useCamoxApp();
829
+ let t0;
830
+ if ($[0] !== queryClient) {
831
+ t0 = () => canvasThumbnailsSupported() ? createCanvasThumbnails(queryClient) : null;
832
+ $[0] = queryClient;
833
+ $[1] = t0;
834
+ } else t0 = $[1];
835
+ const [thumbnails] = React.useState(t0);
836
+ let t1;
837
+ let t2;
838
+ if ($[2] !== thumbnails) {
839
+ t1 = () => thumbnails?.connect();
840
+ t2 = [thumbnails];
841
+ $[2] = thumbnails;
842
+ $[3] = t1;
843
+ $[4] = t2;
844
+ } else {
845
+ t1 = $[3];
846
+ t2 = $[4];
847
+ }
848
+ React.useEffect(t1, t2);
849
+ let t3;
850
+ let t4;
851
+ if ($[5] !== thumbnails || $[6] !== workspaceKey) {
852
+ t3 = () => {
853
+ if (!thumbnails) return;
854
+ const update = () => thumbnails.setMoving(!!canvasStore.getSnapshot().context.moving[workspaceKey]);
855
+ update();
856
+ const subscription = canvasStore.subscribe(update);
857
+ return () => subscription.unsubscribe();
858
+ };
859
+ t4 = [thumbnails, workspaceKey];
860
+ $[5] = thumbnails;
861
+ $[6] = workspaceKey;
862
+ $[7] = t3;
863
+ $[8] = t4;
864
+ } else {
865
+ t3 = $[7];
866
+ t4 = $[8];
867
+ }
868
+ React.useEffect(t3, t4);
869
+ const previousApp = React.useRef(app);
870
+ let t5;
871
+ let t6;
872
+ if ($[9] !== app || $[10] !== thumbnails) {
873
+ t5 = () => {
874
+ if (previousApp.current === app) return;
875
+ previousApp.current = app;
876
+ thumbnails?.markAllStale();
877
+ };
878
+ t6 = [app, thumbnails];
879
+ $[9] = app;
880
+ $[10] = thumbnails;
881
+ $[11] = t5;
882
+ $[12] = t6;
883
+ } else {
884
+ t5 = $[11];
885
+ t6 = $[12];
886
+ }
887
+ React.useEffect(t5, t6);
888
+ return thumbnails;
889
+ }
890
+ function CanvasWorkspace(t0) {
891
+ const $ = c(89);
892
+ const { ref, projectId, pages, blocks, selectedPage, selectedBlock, previewedPage, intendedItemKey, runtimeBasePath, viewport, onActivate, onSelectionIntent } = t0;
893
+ const { apiUrl, projectUuid } = useAuthContext();
894
+ const renamePage = useRenamePage();
895
+ const location = useLocation();
896
+ const navigate = useNavigate();
897
+ const previewPageFrame = React.use(PreviewPageFrameContext);
898
+ const localized = useLocalizedPath();
899
+ const [hover] = React.useState(createCanvasHover);
900
+ const selectedPath = location.pathname;
901
+ const previewedPath = previewPageFrame?.pathname;
902
+ const follow = React.use(FollowAgentContext);
903
+ let t1;
904
+ if ($[0] !== location.hash || $[1] !== location.search || $[2] !== navigate || $[3] !== onSelectionIntent) {
905
+ t1 = (pathname) => {
906
+ onSelectionIntent(pathname);
907
+ navigate({
908
+ to: `${pathname}${location.search}${location.hash}`,
909
+ source: "canvas"
910
+ });
911
+ };
912
+ $[0] = location.hash;
913
+ $[1] = location.search;
914
+ $[2] = navigate;
915
+ $[3] = onSelectionIntent;
916
+ $[4] = t1;
917
+ } else t1 = $[4];
918
+ const goToItem = t1;
919
+ let t2;
920
+ if ($[5] !== follow || $[6] !== goToItem) {
921
+ t2 = (pathname_0) => {
922
+ follow?.takeOver();
923
+ goToItem(pathname_0);
924
+ };
925
+ $[5] = follow;
926
+ $[6] = goToItem;
927
+ $[7] = t2;
928
+ } else t2 = $[7];
929
+ const selectPage = t2;
930
+ let t3;
931
+ if ($[8] !== localized || $[9] !== selectPage) {
932
+ t3 = (block) => selectPage(localized(blockCatalogPath(block._internal.id)));
933
+ $[8] = localized;
934
+ $[9] = selectPage;
935
+ $[10] = t3;
936
+ } else t3 = $[10];
937
+ const selectBlock = t3;
938
+ let t4;
939
+ if ($[11] !== selectBlock || $[12] !== selectPage) {
940
+ t4 = {
941
+ selectPage,
942
+ selectBlock
943
+ };
944
+ $[11] = selectBlock;
945
+ $[12] = selectPage;
946
+ $[13] = t4;
947
+ } else t4 = $[13];
948
+ const latestSelect = React.useRef(t4);
949
+ let t5;
950
+ if ($[14] !== selectBlock || $[15] !== selectPage) {
951
+ t5 = () => {
952
+ latestSelect.current = {
953
+ selectPage,
954
+ selectBlock
955
+ };
956
+ };
957
+ $[14] = selectBlock;
958
+ $[15] = selectPage;
959
+ $[16] = t5;
960
+ } else t5 = $[16];
961
+ React.useLayoutEffect(t5);
962
+ let t6;
963
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
964
+ t6 = (pathname_1) => latestSelect.current.selectPage(pathname_1);
965
+ $[17] = t6;
966
+ } else t6 = $[17];
967
+ const selectFramePage = t6;
968
+ let t7;
969
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
970
+ t7 = (block_0) => latestSelect.current.selectBlock(block_0);
971
+ $[18] = t7;
972
+ } else t7 = $[18];
973
+ const selectFrameBlock = t7;
974
+ let t8;
975
+ if ($[19] !== apiUrl || $[20] !== projectUuid || $[21] !== runtimeBasePath) {
976
+ t8 = JSON.stringify([
977
+ apiUrl,
978
+ projectUuid,
979
+ runtimeBasePath
980
+ ]);
981
+ $[19] = apiUrl;
982
+ $[20] = projectUuid;
983
+ $[21] = runtimeBasePath;
984
+ $[22] = t8;
985
+ } else t8 = $[22];
986
+ const workspaceKey = t8;
987
+ let t9;
988
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
989
+ t9 = {};
990
+ $[23] = t9;
991
+ } else t9 = $[23];
992
+ const [previewPathnames, setPreviewPathnames] = React.useState(t9);
993
+ const shelves = getCanvasShelves(pages, blocks);
994
+ let t10;
995
+ if ($[24] !== selectedBlock || $[25] !== selectedPage?.key) {
996
+ t10 = selectedPage?.key ?? (selectedBlock && canvasBlockKey(selectedBlock._internal.id));
997
+ $[24] = selectedBlock;
998
+ $[25] = selectedPage?.key;
999
+ $[26] = t10;
1000
+ } else t10 = $[26];
1001
+ const selectedItemKey = t10;
1002
+ const collapsedShelves = useCollapsedShelves(workspaceKey, getDefaultCollapsedShelves(shelves), shelves.find((shelf) => shelf.items.some((t11) => {
1003
+ const { key } = t11;
1004
+ return key === selectedItemKey;
1005
+ }))?.key);
1006
+ let t12;
1007
+ if ($[27] !== collapsedShelves || $[28] !== workspaceKey) {
1008
+ t12 = (shelfKey) => setShelfCollapsed(workspaceKey, shelfKey, !collapsedShelves.has(shelfKey));
1009
+ $[27] = collapsedShelves;
1010
+ $[28] = workspaceKey;
1011
+ $[29] = t12;
1012
+ } else t12 = $[29];
1013
+ const toggleShelf = t12;
1014
+ const { items, markers, width } = positionCanvasShelves(shelves, collapsedShelves);
1015
+ const positions = new Map(items.map(_temp3));
1016
+ const blocksByKey = new Map(items.filter(isCanvasBlock).map(_temp4));
1017
+ const pageSlots = new Map(pages.map((page) => [page.key, {
1018
+ page,
1019
+ left: positions.get(page.key),
1020
+ pathname: page.key === selectedPage?.key ? selectedPath : previewedPath && page.key === previewedPage?.key ? previewedPath : previewPathnames[page.key] ?? page.pathname
1021
+ }]));
1022
+ const selectedKey = selectedItemKey && positions.has(selectedItemKey) ? selectedItemKey : null;
1023
+ const hiddenSelectedShelf = shelves.find((shelf_0) => collapsedShelves.has(shelf_0.key) && shelf_0.items.some((t13) => {
1024
+ const { key: key_0 } = t13;
1025
+ return key_0 === selectedItemKey;
1026
+ }))?.key;
1027
+ const framed = viewport.width < CANVAS_SLOT_WIDTH;
1028
+ const snapTargets = canvasSnapTargets(items);
1029
+ const snapRingRef = React.useRef(null);
1030
+ const snapFlash = React.useRef(null);
1031
+ let t14;
1032
+ if ($[30] !== selectedKey) {
1033
+ t14 = (t15) => {
1034
+ const { key: key_1 } = t15;
1035
+ return key_1 === selectedKey;
1036
+ };
1037
+ $[30] = selectedKey;
1038
+ $[31] = t14;
1039
+ } else t14 = $[31];
1040
+ let t15;
1041
+ if ($[32] !== goToItem || $[33] !== localized) {
1042
+ t15 = () => goToItem(localized(STUDIO_CANVAS_PATH));
1043
+ $[32] = goToItem;
1044
+ $[33] = localized;
1045
+ $[34] = t15;
1046
+ } else t15 = $[34];
1047
+ let t16;
1048
+ if ($[35] !== follow) {
1049
+ t16 = () => follow?.takeOver();
1050
+ $[35] = follow;
1051
+ $[36] = t16;
1052
+ } else t16 = $[36];
1053
+ const { viewportRef, contentRef, flyTo, mirrorCamera, keepInView, reveal, fitAll } = useCanvasCamera(workspaceKey, snapTargets.find(t14), {
1054
+ targets: snapTargets,
1055
+ width,
1056
+ onSelect: (key_2) => {
1057
+ const block_1 = blocksByKey.get(key_2);
1058
+ if (block_1) return selectBlock(block_1);
1059
+ const pathname_2 = pageSlots.get(key_2)?.pathname;
1060
+ if (pathname_2) selectPage(pathname_2);
1061
+ },
1062
+ selected: intendedItemKey && positions.has(intendedItemKey) ? intendedItemKey : null,
1063
+ onDeselect: t15,
1064
+ onSnap: () => {
1065
+ snapFlash.current = snapRingRef.current?.animate(SNAP_FLASH_KEYFRAMES, SNAP_FLASH_TIMING) ?? null;
1066
+ },
1067
+ onSnapStretched: () => snapFlash.current?.cancel(),
1068
+ onEditorMove: t16
1069
+ });
1070
+ let t17;
1071
+ if ($[37] !== mirrorCamera || $[38] !== reveal || $[39] !== workspaceKey) {
1072
+ t17 = {
1073
+ workspaceKey,
1074
+ mirrorCamera,
1075
+ reveal
1076
+ };
1077
+ $[37] = mirrorCamera;
1078
+ $[38] = reveal;
1079
+ $[39] = workspaceKey;
1080
+ $[40] = t17;
1081
+ } else t17 = $[40];
1082
+ const workspace = t17;
1083
+ const thumbnails = useWorkspaceThumbnails(workspaceKey);
1084
+ const collapsingShelf = React.useRef(null);
1085
+ React.useLayoutEffect(() => {
1086
+ const marker = markers.find((t18) => {
1087
+ const { key: key_3 } = t18;
1088
+ return key_3 === collapsingShelf.current;
1089
+ });
1090
+ collapsingShelf.current = null;
1091
+ if (marker) keepInView(marker.start, 12);
1092
+ });
1093
+ const instructionsId = React.useId();
1094
+ const previousPath = React.useRef(selectedPath);
1095
+ React.useEffect(() => {
1096
+ if (previousPath.current === selectedPath) return;
1097
+ if (location.source !== "canvas" && hiddenSelectedShelf) {
1098
+ setShelfCollapsed(workspaceKey, hiddenSelectedShelf, false);
1099
+ return;
1100
+ }
1101
+ if (location.source !== "canvas" && !selectedKey) return;
1102
+ previousPath.current = selectedPath;
1103
+ }, [
1104
+ selectedPath,
1105
+ location.source,
1106
+ selectedKey,
1107
+ hiddenSelectedShelf,
1108
+ workspaceKey
1109
+ ]);
1110
+ const [pendingFlight, setPendingFlight] = React.useState(null);
1111
+ const pendingFlightPlaced = !!pendingFlight && positions.has(pendingFlight);
1112
+ let t19;
1113
+ let t20;
1114
+ if ($[41] !== flyTo || $[42] !== pendingFlight || $[43] !== pendingFlightPlaced) {
1115
+ t19 = () => {
1116
+ if (!pendingFlight || !pendingFlightPlaced) return;
1117
+ setPendingFlight(null);
1118
+ flyTo(pendingFlight);
1119
+ };
1120
+ t20 = [
1121
+ pendingFlight,
1122
+ pendingFlightPlaced,
1123
+ flyTo
1124
+ ];
1125
+ $[41] = flyTo;
1126
+ $[42] = pendingFlight;
1127
+ $[43] = pendingFlightPlaced;
1128
+ $[44] = t19;
1129
+ $[45] = t20;
1130
+ } else {
1131
+ t19 = $[44];
1132
+ t20 = $[45];
1133
+ }
1134
+ React.useEffect(t19, t20);
1135
+ let t21;
1136
+ let t22;
1137
+ if ($[46] !== fitAll) {
1138
+ t21 = () => {
1139
+ let answered = canvasStore.getSnapshot().context.overviewRequests;
1140
+ const subscription = canvasStore.subscribe((t23) => {
1141
+ const { context } = t23;
1142
+ if (context.overviewRequests === answered) return;
1143
+ answered = context.overviewRequests;
1144
+ fitAll();
1145
+ });
1146
+ return () => subscription.unsubscribe();
1147
+ };
1148
+ t22 = [fitAll];
1149
+ $[46] = fitAll;
1150
+ $[47] = t21;
1151
+ $[48] = t22;
1152
+ } else {
1153
+ t21 = $[47];
1154
+ t22 = $[48];
1155
+ }
1156
+ React.useEffect(t21, t22);
1157
+ React.useImperativeHandle(ref, () => ({
1158
+ showItem(key_4) {
1159
+ const shelf_1 = shelves.find((candidate) => candidate.items.some((item_1) => item_1.key === key_4));
1160
+ const item_2 = shelf_1?.items.find((candidate_0) => candidate_0.key === key_4);
1161
+ if (!shelf_1 || !item_2) return;
1162
+ const pathname_3 = item_2.kind === "block" ? localized(blockCatalogPath(item_2.block._internal.id)) : pageSlots.get(key_4)?.pathname;
1163
+ if (pathname_3 && pathname_3 !== selectedPath) {
1164
+ navigate({ to: `${pathname_3}${location.search}${location.hash}` });
1165
+ return;
1166
+ }
1167
+ if (collapsedShelves.has(shelf_1.key)) toggleShelf(shelf_1.key);
1168
+ setPendingFlight(key_4);
1169
+ },
1170
+ showWholeCanvas() {
1171
+ selectPage(localized(STUDIO_CANVAS_PATH));
1172
+ fitAll();
1173
+ }
1174
+ }));
1175
+ const t23 = "region";
1176
+ const t24 = "Page canvas";
1177
+ const t25 = 0;
1178
+ const t26 = true;
1179
+ const t27 = "bg-muted relative min-h-0 min-w-0 flex-1 touch-none overflow-clip outline-none *:*:[--canvas-x:initial] *:*:[--canvas-y:initial] data-[canvas-pan]:cursor-grab data-[canvas-pan]:**:cursor-[inherit]! data-[canvas-pan=dragging]:cursor-grabbing data-[canvas-pan]:[&_iframe]:pointer-events-none";
1180
+ let t28;
1181
+ if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
1182
+ t28 = {
1183
+ userSelect: "none",
1184
+ overscrollBehavior: "none"
1185
+ };
1186
+ $[49] = t28;
1187
+ } else t28 = $[49];
1188
+ const t29 = !!intendedItemKey;
1189
+ let t30;
1190
+ if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
1191
+ t30 = {
1192
+ gap: 480,
1193
+ transform: CANVAS_WORLD_TRANSFORM,
1194
+ transformOrigin: "0 0"
1195
+ };
1196
+ $[50] = t30;
1197
+ } else t30 = $[50];
1198
+ const t31 = shelves.map((shelf_2) => {
1199
+ if (!isCanvasShelfShown(shelf_2)) return null;
1200
+ const collapsed = collapsedShelves.has(shelf_2.key) || shelf_2.items.length === 0;
1201
+ return /* @__PURE__ */ jsx("div", {
1202
+ "data-canvas-shelf": shelf_2.key,
1203
+ inert: collapsed,
1204
+ className: `flex shrink-0 items-start ${collapsed ? "invisible w-0" : ""}`,
1205
+ style: { gap: 240 },
1206
+ children: (collapsed && shelf_2.unmountedWhenCollapsed ? [] : shelf_2.items).map((item_3) => {
1207
+ if (item_3.kind === "block") return /* @__PURE__ */ jsx(CanvasBlockItem, {
1208
+ itemKey: item_3.key,
1209
+ block: item_3.block,
1210
+ projectId,
1211
+ runtimeBasePath,
1212
+ viewport,
1213
+ framed,
1214
+ selected: item_3.block._internal.id === selectedBlock?._internal.id,
1215
+ selectBlock: selectFrameBlock
1216
+ }, item_3.key);
1217
+ const slot = pageSlots.get(item_3.key);
1218
+ if (!slot) return null;
1219
+ const { page: page_0, pathname: pathname_4 } = slot;
1220
+ return /* @__PURE__ */ jsx(CanvasPageItem, {
1221
+ page: page_0,
1222
+ pathname: pathname_4,
1223
+ selected: page_0.key === selectedPage?.key,
1224
+ hover,
1225
+ previewed: !!previewPageFrame && page_0.key === previewedPage?.key && pathname_4 === previewedPath,
1226
+ collapsed,
1227
+ framed,
1228
+ viewport,
1229
+ runtimeBasePath,
1230
+ onActivate,
1231
+ selectPage: selectFramePage
1232
+ }, page_0.key);
1233
+ })
1234
+ }, shelf_2.key);
1235
+ });
1236
+ let t32;
1237
+ if ($[51] !== contentRef || $[52] !== t31) {
1238
+ t32 = /* @__PURE__ */ jsx("div", {
1239
+ ref: contentRef,
1240
+ "data-canvas-items": true,
1241
+ className: "absolute top-0 left-0 flex w-max items-start in-data-[canvas-promoted]:will-change-transform",
1242
+ style: t30,
1243
+ children: t31
1244
+ });
1245
+ $[51] = contentRef;
1246
+ $[52] = t31;
1247
+ $[53] = t32;
1248
+ } else t32 = $[53];
1249
+ let t33;
1250
+ if ($[54] !== t29 || $[55] !== t32) {
1251
+ t33 = /* @__PURE__ */ jsx(CanvasOverlaysShownContext, {
1252
+ value: t29,
1253
+ children: t32
1254
+ });
1255
+ $[54] = t29;
1256
+ $[55] = t32;
1257
+ $[56] = t33;
1258
+ } else t33 = $[56];
1259
+ let t34;
1260
+ if ($[57] !== t33 || $[58] !== thumbnails) {
1261
+ t34 = /* @__PURE__ */ jsx(CanvasThumbnailsContext, {
1262
+ value: thumbnails,
1263
+ children: t33
1264
+ });
1265
+ $[57] = t33;
1266
+ $[58] = thumbnails;
1267
+ $[59] = t34;
1268
+ } else t34 = $[59];
1269
+ let t35;
1270
+ if ($[60] !== t34 || $[61] !== workspace) {
1271
+ t35 = /* @__PURE__ */ jsx(CanvasWorkspaceContext, {
1272
+ value: workspace,
1273
+ children: t34
1274
+ });
1275
+ $[60] = t34;
1276
+ $[61] = workspace;
1277
+ $[62] = t35;
1278
+ } else t35 = $[62];
1279
+ let t36;
1280
+ if ($[63] !== toggleShelf) {
1281
+ t36 = (marker_0) => {
1282
+ if (!marker_0.collapsed) collapsingShelf.current = marker_0.key;
1283
+ toggleShelf(marker_0.key);
1284
+ };
1285
+ $[63] = toggleShelf;
1286
+ $[64] = t36;
1287
+ } else t36 = $[64];
1288
+ let t37;
1289
+ if ($[65] !== markers || $[66] !== t36) {
1290
+ t37 = /* @__PURE__ */ jsx(CanvasShelfMarkers, {
1291
+ markers,
1292
+ onToggle: t36
1293
+ });
1294
+ $[65] = markers;
1295
+ $[66] = t36;
1296
+ $[67] = t37;
1297
+ } else t37 = $[67];
1298
+ const t39 = [...pageSlots.values()].map((t38) => {
1299
+ const { page: page_1, pathname: pathname_5, left } = t38;
1300
+ return left === void 0 ? null : /* @__PURE__ */ jsx(CanvasHeaderSlot, {
1301
+ itemKey: page_1.key,
1302
+ left,
1303
+ children: /* @__PURE__ */ jsx(CanvasPageHeader, {
1304
+ page: page_1,
1305
+ pathname: pathname_5,
1306
+ onRename: page_1.kind === "curated" ? (nickname) => renamePage(page_1.pageId, nickname) : void 0,
1307
+ selected: page_1.key === selectedPage?.key,
1308
+ onHoverChange: (hovered) => hover.send({
1309
+ type: "set",
1310
+ pageKey: hovered ? page_1.key : null
1311
+ }),
1312
+ onSelect: () => {
1313
+ if (!pathname_5) return;
1314
+ selectPage(pathname_5);
1315
+ },
1316
+ onChange: (path) => {
1317
+ const inLocale = localized(path);
1318
+ setPreviewPathnames((current) => ({
1319
+ ...current,
1320
+ [page_1.key]: inLocale
1321
+ }));
1322
+ selectPage(inLocale);
1323
+ }
1324
+ })
1325
+ }, page_1.key);
1326
+ });
1327
+ let t40;
1328
+ if ($[68] !== projectId || $[69] !== selectBlock) {
1329
+ t40 = (t41) => {
1330
+ const { key: key_5, left: left_0, block: block_2 } = t41;
1331
+ return /* @__PURE__ */ jsx(CanvasHeaderSlot, {
1332
+ itemKey: key_5,
1333
+ left: left_0,
1334
+ children: /* @__PURE__ */ jsx(CanvasBlockUsageHeader, {
1335
+ projectId,
1336
+ block: block_2,
1337
+ onSelect: () => selectBlock(block_2)
1338
+ })
1339
+ }, key_5);
1340
+ };
1341
+ $[68] = projectId;
1342
+ $[69] = selectBlock;
1343
+ $[70] = t40;
1344
+ } else t40 = $[70];
1345
+ const t41 = items.filter(isCanvasBlock).map(t40);
1346
+ let t42;
1347
+ if ($[71] !== pages.length) {
1348
+ t42 = !pages.length && /* @__PURE__ */ jsx(CanvasMessage, { children: "No pages to preview yet." });
1349
+ $[71] = pages.length;
1350
+ $[72] = t42;
1351
+ } else t42 = $[72];
1352
+ let t43;
1353
+ if ($[73] !== instructionsId) {
1354
+ t43 = /* @__PURE__ */ jsx("p", {
1355
+ id: instructionsId,
1356
+ className: "sr-only",
1357
+ children: "Scroll, or hold Space and drag, to pan. Pinch or Ctrl/⌘ + scroll to zoom. Click a page to edit it. Focus the canvas and use plus or minus to zoom, arrow keys to pan, 0 for 100%, or Home / Shift+1 to fit all pages."
1358
+ });
1359
+ $[73] = instructionsId;
1360
+ $[74] = t43;
1361
+ } else t43 = $[74];
1362
+ let t44;
1363
+ if ($[75] === Symbol.for("react.memo_cache_sentinel")) {
1364
+ t44 = { zIndex: 2 };
1365
+ $[75] = t44;
1366
+ } else t44 = $[75];
1367
+ let t45;
1368
+ if ($[76] !== snapRingRef) {
1369
+ t45 = /* @__PURE__ */ jsx("div", {
1370
+ ref: snapRingRef,
1371
+ "aria-hidden": true,
1372
+ "data-canvas-snap-ring": true,
1373
+ className: "ring-primary pointer-events-none absolute inset-0 opacity-0 ring-3 ring-inset",
1374
+ style: t44
1375
+ });
1376
+ $[76] = snapRingRef;
1377
+ $[77] = t45;
1378
+ } else t45 = $[77];
1379
+ let t46;
1380
+ if ($[78] !== instructionsId || $[79] !== t28 || $[80] !== t35 || $[81] !== t37 || $[82] !== t39 || $[83] !== t41 || $[84] !== t42 || $[85] !== t43 || $[86] !== t45 || $[87] !== viewportRef) {
1381
+ t46 = /* @__PURE__ */ jsxs("div", {
1382
+ ref: viewportRef,
1383
+ role: t23,
1384
+ "aria-label": t24,
1385
+ "aria-describedby": instructionsId,
1386
+ tabIndex: t25,
1387
+ "data-camox-canvas": t26,
1388
+ className: t27,
1389
+ style: t28,
1390
+ children: [
1391
+ t35,
1392
+ t37,
1393
+ t39,
1394
+ t41,
1395
+ t42,
1396
+ t43,
1397
+ t45
1398
+ ]
1399
+ });
1400
+ $[78] = instructionsId;
1401
+ $[79] = t28;
1402
+ $[80] = t35;
1403
+ $[81] = t37;
1404
+ $[82] = t39;
1405
+ $[83] = t41;
1406
+ $[84] = t42;
1407
+ $[85] = t43;
1408
+ $[86] = t45;
1409
+ $[87] = viewportRef;
1410
+ $[88] = t46;
1411
+ } else t46 = $[88];
1412
+ return t46;
1413
+ }
1414
+ function _temp4(item_0) {
1415
+ return [item_0.key, item_0.block];
1416
+ }
1417
+ function _temp3(item) {
1418
+ return [item.key, item.left];
1419
+ }
1420
+ function CamoxCanvas(t0) {
1421
+ const $ = c(60);
1422
+ const { runtimeBasePath } = t0;
1423
+ const app = useCamoxApp();
1424
+ const renamePage = useRenamePage();
1425
+ const location = useLocation();
1426
+ const viewportMode = useSelector(previewStore, _temp5);
1427
+ const viewport = CANVAS_DEVICES[viewportMode === "full" ? "desktop" : viewportMode];
1428
+ const [activeFrame, setActiveFrame] = React.useState(null);
1429
+ const selectedPath = location.pathname;
1430
+ const previousPath = React.useRef(selectedPath);
1431
+ let t1;
1432
+ let t2;
1433
+ if ($[0] !== activeFrame || $[1] !== selectedPath) {
1434
+ t1 = () => {
1435
+ if (previousPath.current === selectedPath) return;
1436
+ previousPath.current = selectedPath;
1437
+ if (!activeFrame || activeFrame.pathname === selectedPath) return;
1438
+ activeFrame.release();
1439
+ setActiveFrame(null);
1440
+ };
1441
+ t2 = [activeFrame, selectedPath];
1442
+ $[0] = activeFrame;
1443
+ $[1] = selectedPath;
1444
+ $[2] = t1;
1445
+ $[3] = t2;
1446
+ } else {
1447
+ t1 = $[2];
1448
+ t2 = $[3];
1449
+ }
1450
+ React.useLayoutEffect(t1, t2);
1451
+ let t3;
1452
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
1453
+ t3 = [];
1454
+ $[4] = t3;
1455
+ } else t3 = $[4];
1456
+ React.useEffect(_temp7, t3);
1457
+ const projectUuid = useProjectUuid();
1458
+ let t4;
1459
+ if ($[5] !== projectUuid) {
1460
+ t4 = reads.project({ projectUuid });
1461
+ $[5] = projectUuid;
1462
+ $[6] = t4;
1463
+ } else t4 = $[6];
1464
+ const project = useReadQuery(t4);
1465
+ let t5;
1466
+ if ($[7] !== projectUuid) {
1467
+ t5 = reads.pageList({ projectUuid });
1468
+ $[7] = projectUuid;
1469
+ $[8] = t5;
1470
+ } else t5 = $[8];
1471
+ const t6 = !!project.data;
1472
+ let t7;
1473
+ if ($[9] !== t6) {
1474
+ t7 = { enabled: t6 };
1475
+ $[9] = t6;
1476
+ $[10] = t7;
1477
+ } else t7 = $[10];
1478
+ const pages = useReadQuery(t5, t7);
1479
+ const discoveredPaths = useDiscoveredPreviewPaths(runtimeBasePath);
1480
+ const viewLocale = useViewLocale();
1481
+ const canvasPages = pages.data ? getCanvasPages(pages.data, app.getLayouts(), discoveredPaths, viewLocale.locale) : [];
1482
+ const selectionAt = (runtimePath) => {
1483
+ const pathname = parseLocalePath(runtimePath, viewLocale.locales).path;
1484
+ if (pathname === "/camox/canvas") return {};
1485
+ const blockId = matchBlockCatalogPath(pathname);
1486
+ if (!blockId) return { page: selectedCanvasPage(canvasPages, app.getLayouts(), runtimePath, viewLocale.locales) };
1487
+ const block = app.getBlockById(blockId);
1488
+ return { block: block && !block._internal.layoutOnly ? block : void 0 };
1489
+ };
1490
+ const { page: selectedPage, block: selectedBlock } = selectionAt(location.pathname);
1491
+ const previewedPath = React.use(PreviewPageFrameContext)?.pathname;
1492
+ const previewedPage = previewedPath ? selectionAt(previewedPath).page : void 0;
1493
+ const [intent, setIntent] = React.useState(null);
1494
+ if (intent && intent.from !== location.pathname) setIntent(null);
1495
+ const intended = intent?.from === location.pathname ? intent.to : location;
1496
+ const intendedSelection = selectionAt(intended.pathname);
1497
+ const navigate = useNavigate();
1498
+ const workspace = React.useRef(null);
1499
+ let t8;
1500
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
1501
+ t8 = { enabled: false };
1502
+ $[11] = t8;
1503
+ } else t8 = $[11];
1504
+ const { data: intendedFrameInput } = useReadQuery(reads.canvasFrame({
1505
+ projectUuid,
1506
+ runtimeBasePath,
1507
+ pathname: intended.pathname,
1508
+ derivedLayoutId: derivedLayoutIdOf(intendedSelection.page)
1509
+ }), t8);
1510
+ const recordResult = derivedLayoutIdOf(intendedSelection.page) ? intendedFrameInput?.derived?.result : void 0;
1511
+ let t9;
1512
+ if ($[12] !== recordResult) {
1513
+ t9 = getPageRecord(recordResult);
1514
+ $[12] = recordResult;
1515
+ $[13] = t9;
1516
+ } else t9 = $[13];
1517
+ const pageRecord = t9;
1518
+ usePreparationFailure((!project.isFetching ? project.error : null) ?? (!pages.isFetching ? pages.error : null));
1519
+ const preparation = React.useContext(PreviewPreparationContext);
1520
+ React.useEffect(() => {
1521
+ if (project.isPending || pages.isPending || project.error || pages.error) return;
1522
+ if (selectedBlock || parseLocalePath(location.pathname, viewLocale.locales).path === "/camox/canvas") {
1523
+ preparation?.ready();
1524
+ return;
1525
+ }
1526
+ if (selectedPage) return;
1527
+ preparation?.fail(/* @__PURE__ */ new Error(`No canvas page matches ${location.pathname}.`));
1528
+ }, [
1529
+ project.isPending,
1530
+ pages.isPending,
1531
+ project.error,
1532
+ pages.error,
1533
+ selectedPage,
1534
+ selectedBlock,
1535
+ location.pathname,
1536
+ viewLocale.locales,
1537
+ preparation
1538
+ ]);
1539
+ if (project.error || pages.error) {
1540
+ let t10;
1541
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
1542
+ t10 = /* @__PURE__ */ jsx("p", { children: "Could not load the site’s pages." });
1543
+ $[14] = t10;
1544
+ } else t10 = $[14];
1545
+ let t11;
1546
+ if ($[15] !== pages || $[16] !== project) {
1547
+ t11 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsxs("div", {
1548
+ role: "alert",
1549
+ children: [t10, /* @__PURE__ */ jsx("button", {
1550
+ className: "mt-4 underline",
1551
+ onClick: () => {
1552
+ if (project.error) project.refetch();
1553
+ else pages.refetch();
1554
+ },
1555
+ children: "Try again"
1556
+ })]
1557
+ }) });
1558
+ $[15] = pages;
1559
+ $[16] = project;
1560
+ $[17] = t11;
1561
+ } else t11 = $[17];
1562
+ return t11;
1563
+ }
1564
+ if (project.isPending || pages.isPending) {
1565
+ let t10;
1566
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
1567
+ t10 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsx("span", {
1568
+ role: "status",
1569
+ children: "Loading canvas…"
1570
+ }) });
1571
+ $[18] = t10;
1572
+ } else t10 = $[18];
1573
+ return t10;
1574
+ }
1575
+ const editingOwner = activeFrame?.pathname === intended.pathname ? activeFrame.owner : null;
1576
+ const blockCatalog = getBlockCatalog(app.getBlocks());
1577
+ const intendedItemKey = intendedSelection.page?.key ?? (intendedSelection.block && canvasBlockKey(intendedSelection.block._internal.id));
1578
+ const t10 = "flex min-h-0 flex-1 overflow-hidden";
1579
+ const t11 = selectedPage?.kind === "curated" && /* @__PURE__ */ jsx(CuratedBlockShortcuts, {});
1580
+ const T0 = NavigationProvider;
1581
+ const T1 = PageRecordContext;
1582
+ const T2 = CanvasSidebar;
1583
+ const t12 = intendedSelection.page;
1584
+ const t13 = intendedSelection.block && {
1585
+ block: intendedSelection.block,
1586
+ projectId: project.data.id
1587
+ };
1588
+ const t14 = getCanvasShelves(canvasPages, blockCatalog);
1589
+ let t15;
1590
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
1591
+ t15 = (key) => workspace.current?.showItem(key);
1592
+ $[19] = t15;
1593
+ } else t15 = $[19];
1594
+ let t16;
1595
+ if ($[20] !== intendedItemKey || $[21] !== t14) {
1596
+ t16 = {
1597
+ shelves: t14,
1598
+ selectedKey: intendedItemKey,
1599
+ onShowItem: t15
1600
+ };
1601
+ $[20] = intendedItemKey;
1602
+ $[21] = t14;
1603
+ $[22] = t16;
1604
+ } else t16 = $[22];
1605
+ let t17;
1606
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
1607
+ t17 = () => workspace.current?.showWholeCanvas();
1608
+ $[23] = t17;
1609
+ } else t17 = $[23];
1610
+ let t18;
1611
+ if ($[24] !== T2 || $[25] !== editingOwner || $[26] !== intendedSelection || $[27] !== pageRecord || $[28] !== renamePage || $[29] !== t13 || $[30] !== t16) {
1612
+ t18 = /* @__PURE__ */ jsx(T2, {
1613
+ page: t12,
1614
+ catalog: t13,
1615
+ navigator: t16,
1616
+ onShowWholeCanvas: t17,
1617
+ onRenamePage: renamePage,
1618
+ owner: editingOwner,
1619
+ pageRecord
1620
+ });
1621
+ $[24] = T2;
1622
+ $[25] = editingOwner;
1623
+ $[26] = intendedSelection;
1624
+ $[27] = pageRecord;
1625
+ $[28] = renamePage;
1626
+ $[29] = t13;
1627
+ $[30] = t16;
1628
+ $[31] = t18;
1629
+ } else t18 = $[31];
1630
+ let t19;
1631
+ if ($[32] !== T1 || $[33] !== recordResult || $[34] !== t18) {
1632
+ t19 = /* @__PURE__ */ jsx(T1, {
1633
+ value: recordResult,
1634
+ children: t18
1635
+ });
1636
+ $[32] = T1;
1637
+ $[33] = recordResult;
1638
+ $[34] = t18;
1639
+ $[35] = t19;
1640
+ } else t19 = $[35];
1641
+ let t20;
1642
+ if ($[36] !== T0 || $[37] !== intended || $[38] !== navigate || $[39] !== t19) {
1643
+ t20 = /* @__PURE__ */ jsx(T0, {
1644
+ location: intended,
1645
+ navigate,
1646
+ children: t19
1647
+ });
1648
+ $[36] = T0;
1649
+ $[37] = intended;
1650
+ $[38] = navigate;
1651
+ $[39] = t19;
1652
+ $[40] = t20;
1653
+ } else t20 = $[40];
1654
+ let t21;
1655
+ if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
1656
+ t21 = (pathname_0, owner, release) => setActiveFrame({
1657
+ pathname: pathname_0,
1658
+ owner,
1659
+ release
1660
+ });
1661
+ $[41] = t21;
1662
+ } else t21 = $[41];
1663
+ let t22;
1664
+ if ($[42] !== location || $[43] !== setIntent) {
1665
+ t22 = (pathname_1) => setIntent({
1666
+ from: location.pathname,
1667
+ to: {
1668
+ ...location,
1669
+ pathname: pathname_1,
1670
+ href: new URL(`${pathname_1}${location.search}${location.hash}`, window.location.href).href
1671
+ }
1672
+ });
1673
+ $[42] = location;
1674
+ $[43] = setIntent;
1675
+ $[44] = t22;
1676
+ } else t22 = $[44];
1677
+ let t23;
1678
+ if ($[45] !== blockCatalog || $[46] !== canvasPages || $[47] !== intendedItemKey || $[48] !== previewedPage || $[49] !== project.data.id || $[50] !== runtimeBasePath || $[51] !== selectedBlock || $[52] !== selectedPage || $[53] !== t22 || $[54] !== viewport) {
1679
+ t23 = /* @__PURE__ */ jsx(CanvasWorkspace, {
1680
+ ref: workspace,
1681
+ projectId: project.data.id,
1682
+ pages: canvasPages,
1683
+ blocks: blockCatalog,
1684
+ selectedPage,
1685
+ selectedBlock,
1686
+ previewedPage,
1687
+ intendedItemKey,
1688
+ runtimeBasePath,
1689
+ viewport,
1690
+ onActivate: t21,
1691
+ onSelectionIntent: t22
1692
+ }, project.data.id);
1693
+ $[45] = blockCatalog;
1694
+ $[46] = canvasPages;
1695
+ $[47] = intendedItemKey;
1696
+ $[48] = previewedPage;
1697
+ $[49] = project.data.id;
1698
+ $[50] = runtimeBasePath;
1699
+ $[51] = selectedBlock;
1700
+ $[52] = selectedPage;
1701
+ $[53] = t22;
1702
+ $[54] = viewport;
1703
+ $[55] = t23;
1704
+ } else t23 = $[55];
1705
+ let t24;
1706
+ if ($[56] !== t11 || $[57] !== t20 || $[58] !== t23) {
1707
+ t24 = /* @__PURE__ */ jsxs("div", {
1708
+ className: t10,
1709
+ children: [
1710
+ t11,
1711
+ t20,
1712
+ t23
1713
+ ]
1714
+ });
1715
+ $[56] = t11;
1716
+ $[57] = t20;
1717
+ $[58] = t23;
1718
+ $[59] = t24;
1719
+ } else t24 = $[59];
1720
+ return t24;
1721
+ }
1722
+ function _temp7() {
1723
+ previewStore.send({ type: "clearSelection" });
1724
+ return _temp6;
1725
+ }
1726
+ function _temp6() {
1727
+ previewStore.send({ type: "clearSelection" });
1728
+ }
1729
+ function _temp5(state) {
1730
+ return state.context.viewportMode;
1731
+ }
1732
+
1733
+ //#endregion
1734
+ export { CamoxCanvas };