camox 0.3.0 → 0.4.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 (76) hide show
  1. package/dist/components/AuthGate.js +2 -1
  2. package/dist/core/components/AddBlockControlBar.js +117 -44
  3. package/dist/core/components/lexical/InlineContentEditable.js +37 -17
  4. package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
  7. package/dist/core/createBlock.js +1172 -414
  8. package/dist/core/createLayout.js +48 -16
  9. package/dist/core/hooks/useFieldSelection.js +24 -13
  10. package/dist/core/hooks/useIsEditable.js +8 -2
  11. package/dist/core/hooks/useOverlayMessage.js +51 -20
  12. package/dist/features/content/CamoxContent.js +239 -107
  13. package/dist/features/content/components/AssetCard.js +78 -16
  14. package/dist/features/content/components/AssetCardSkeleton.js +11 -4
  15. package/dist/features/content/components/ContentSidebar.js +15 -8
  16. package/dist/features/content/components/UploadDropZone.js +77 -34
  17. package/dist/features/content/components/UploadProgressDrawer.js +201 -58
  18. package/dist/features/metadata/sitemap.js +15 -0
  19. package/dist/features/preview/CamoxPreview.js +447 -179
  20. package/dist/features/preview/components/AddBlockSheet.js +344 -167
  21. package/dist/features/preview/components/AgentChatSheet.js +32 -10
  22. package/dist/features/preview/components/AssetFieldEditor.js +185 -50
  23. package/dist/features/preview/components/AssetLightbox.js +60 -33
  24. package/dist/features/preview/components/AssetPickerGrid.js +203 -71
  25. package/dist/features/preview/components/BlockActionsPopover.js +295 -218
  26. package/dist/features/preview/components/CreatePageSheet.js +3 -3
  27. package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
  28. package/dist/features/preview/components/EditPageSheet.js +241 -86
  29. package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
  30. package/dist/features/preview/components/LinkFieldEditor.js +351 -153
  31. package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
  32. package/dist/features/preview/components/OverlayTracker.js +58 -23
  33. package/dist/features/preview/components/Overlays.js +85 -43
  34. package/dist/features/preview/components/PageContentSheet.js +18 -18
  35. package/dist/features/preview/components/PageLocationFieldset.js +229 -63
  36. package/dist/features/preview/components/PagePicker.js +27 -27
  37. package/dist/features/preview/components/PageTree.js +921 -319
  38. package/dist/features/preview/components/PeekedBlock.js +173 -63
  39. package/dist/features/preview/components/PreviewPanel.js +271 -148
  40. package/dist/features/preview/components/PreviewSideSheet.js +44 -11
  41. package/dist/features/preview/components/PreviewToolbar.js +262 -59
  42. package/dist/features/preview/components/RepeatableItemsList.js +187 -78
  43. package/dist/features/preview/components/ShikiMarkdown.js +46 -20
  44. package/dist/features/preview/components/TextFormatToolbar.js +81 -23
  45. package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
  46. package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
  47. package/dist/features/preview/previewStore.d.ts +2 -2
  48. package/dist/features/provider/CamoxProvider.js +69 -21
  49. package/dist/features/provider/actionsStore.d.ts +2 -2
  50. package/dist/features/provider/components/CamoxAppContext.js +15 -5
  51. package/dist/features/provider/components/CommandPalette.js +199 -92
  52. package/dist/features/provider/useAdminShortcuts.js +80 -64
  53. package/dist/features/routes/pageRoute.js +8 -1
  54. package/dist/features/studio/CamoxStudio.js +45 -9
  55. package/dist/features/studio/components/EnvironmentMenu.js +47 -12
  56. package/dist/features/studio/components/Navbar.js +163 -65
  57. package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -1
  58. package/dist/features/studio/components/ProjectMenu.js +284 -83
  59. package/dist/features/studio/components/UserButton.js +21 -6
  60. package/dist/features/studio/studioStore.d.ts +2 -2
  61. package/dist/features/studio/useTheme.js +128 -74
  62. package/dist/features/vite/definitionsSync.d.ts +7 -12
  63. package/dist/features/vite/definitionsSync.d.ts.map +1 -1
  64. package/dist/features/vite/definitionsSync.js +5 -16
  65. package/dist/features/vite/vite.d.ts +0 -3
  66. package/dist/features/vite/vite.d.ts.map +1 -1
  67. package/dist/features/vite/vite.js +1 -2
  68. package/dist/hooks/use-file-upload.js +11 -11
  69. package/dist/hooks/use-marquee-selection.js +121 -74
  70. package/dist/lib/auth.js +95 -51
  71. package/dist/lib/normalized-data.js +103 -30
  72. package/dist/lib/use-project-room.js +55 -22
  73. package/dist/studio.css +2 -2
  74. package/package.json +29 -26
  75. package/dist/lib/auth.d.ts +0 -2130
  76. package/dist/lib/auth.d.ts.map +0 -1
@@ -6,6 +6,7 @@ import { fieldTypesDictionary } from "../../../core/lib/fieldTypes.js";
6
6
  import { useUpdateBlockPosition } from "./useUpdateBlockPosition.js";
7
7
  import { BlockActionsPopover } from "./BlockActionsPopover.js";
8
8
  import { usePreviewedPage } from "../CamoxPreview.js";
9
+ import { c } from "react/compiler-runtime";
9
10
  import { useSelector } from "@xstate/store/react";
10
11
  import * as React from "react";
11
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -19,44 +20,127 @@ import { CSS } from "@dnd-kit/utilities";
19
20
  import * as Accordion from "@radix-ui/react-accordion";
20
21
  //#region src/features/preview/components/PageTree.tsx
21
22
  function useEmbedTitle(url) {
23
+ const $ = c(3);
22
24
  const [title, setTitle] = React.useState(null);
23
- React.useEffect(() => {
24
- if (!url) return;
25
- setTitle(null);
26
- const controller = new AbortController();
27
- fetch(url, { signal: controller.signal }).then((res) => res.text()).then((html) => {
28
- const match = html.match(/<title[^>]*>([^<]*)<\/title>/i);
29
- if (match?.[1]) setTitle(match[1].trim());
30
- }).catch(() => {});
31
- return () => controller.abort();
32
- }, [url]);
25
+ let t0;
26
+ let t1;
27
+ if ($[0] !== url) {
28
+ t0 = () => {
29
+ if (!url) return;
30
+ setTitle(null);
31
+ const controller = new AbortController();
32
+ fetch(url, { signal: controller.signal }).then(_temp).then((html) => {
33
+ const match = html.match(/<title[^>]*>([^<]*)<\/title>/i);
34
+ if (match?.[1]) setTitle(match[1].trim());
35
+ }).catch(_temp2);
36
+ return () => controller.abort();
37
+ };
38
+ t1 = [url];
39
+ $[0] = url;
40
+ $[1] = t0;
41
+ $[2] = t1;
42
+ } else {
43
+ t0 = $[1];
44
+ t1 = $[2];
45
+ }
46
+ React.useEffect(t0, t1);
33
47
  return title;
34
48
  }
35
- var FieldItem = ({ fieldName, value, fieldType, schemaTitle, arrayItemType, isSelected, onFieldClick, onFieldDoubleClick, onMouseEnter, onMouseLeave }) => {
49
+ function _temp2() {}
50
+ function _temp(res) {
51
+ return res.text();
52
+ }
53
+ var FieldItem = (t0) => {
54
+ const $ = c(29);
55
+ const { fieldName, value, fieldType, schemaTitle, arrayItemType, isSelected, onFieldClick, onFieldDoubleClick, onMouseEnter, onMouseLeave } = t0;
36
56
  const fetchedEmbedTitle = useEmbedTitle(fieldType === "Embed" ? value : null);
37
57
  const fieldDef = fieldType != null ? fieldTypesDictionary[fieldType] : null;
38
- const displayValue = fieldDef ? fieldDef.getLabel(value, {
39
- schemaTitle,
40
- fieldName,
41
- fetchedTitle: fetchedEmbedTitle
42
- }) : JSON.stringify(value);
43
- const FieldIcon = fieldDef?.getIcon({ arrayItemType }) ?? Type;
44
- return /* @__PURE__ */ jsxs("li", {
45
- className: cn("flex items-center gap-1.5 rounded-lg pl-2 pr-1 py-2 cursor-default group/field", isSelected ? "bg-accent" : "hover:bg-accent/75"),
46
- onClick: () => fieldType && onFieldClick(),
47
- onDoubleClick: () => fieldType && onFieldDoubleClick(),
48
- onMouseEnter,
49
- onMouseLeave,
50
- children: [/* @__PURE__ */ jsx(FieldIcon, { className: "size-4 shrink-0" }), /* @__PURE__ */ jsx("span", {
58
+ let t1;
59
+ if ($[0] !== fetchedEmbedTitle || $[1] !== fieldDef || $[2] !== fieldName || $[3] !== schemaTitle || $[4] !== value) {
60
+ t1 = fieldDef ? fieldDef.getLabel(value, {
61
+ schemaTitle,
62
+ fieldName,
63
+ fetchedTitle: fetchedEmbedTitle
64
+ }) : JSON.stringify(value);
65
+ $[0] = fetchedEmbedTitle;
66
+ $[1] = fieldDef;
67
+ $[2] = fieldName;
68
+ $[3] = schemaTitle;
69
+ $[4] = value;
70
+ $[5] = t1;
71
+ } else t1 = $[5];
72
+ const displayValue = t1;
73
+ let t2;
74
+ if ($[6] !== arrayItemType || $[7] !== fieldDef) {
75
+ t2 = fieldDef?.getIcon({ arrayItemType }) ?? Type;
76
+ $[6] = arrayItemType;
77
+ $[7] = fieldDef;
78
+ $[8] = t2;
79
+ } else t2 = $[8];
80
+ const FieldIcon = t2;
81
+ const t3 = isSelected ? "bg-accent" : "hover:bg-accent/75";
82
+ let t4;
83
+ if ($[9] !== t3) {
84
+ t4 = cn("flex items-center gap-1.5 rounded-lg pl-2 pr-1 py-2 cursor-default group/field", t3);
85
+ $[9] = t3;
86
+ $[10] = t4;
87
+ } else t4 = $[10];
88
+ let t5;
89
+ if ($[11] !== fieldType || $[12] !== onFieldClick) {
90
+ t5 = () => fieldType && onFieldClick();
91
+ $[11] = fieldType;
92
+ $[12] = onFieldClick;
93
+ $[13] = t5;
94
+ } else t5 = $[13];
95
+ let t6;
96
+ if ($[14] !== fieldType || $[15] !== onFieldDoubleClick) {
97
+ t6 = () => fieldType && onFieldDoubleClick();
98
+ $[14] = fieldType;
99
+ $[15] = onFieldDoubleClick;
100
+ $[16] = t6;
101
+ } else t6 = $[16];
102
+ let t7;
103
+ if ($[17] !== FieldIcon) {
104
+ t7 = /* @__PURE__ */ jsx(FieldIcon, { className: "size-4 shrink-0" });
105
+ $[17] = FieldIcon;
106
+ $[18] = t7;
107
+ } else t7 = $[18];
108
+ let t8;
109
+ if ($[19] !== displayValue) {
110
+ t8 = /* @__PURE__ */ jsx("span", {
51
111
  className: "text-accent-foreground truncate select-none",
52
112
  children: displayValue
53
- })]
54
- });
113
+ });
114
+ $[19] = displayValue;
115
+ $[20] = t8;
116
+ } else t8 = $[20];
117
+ let t9;
118
+ if ($[21] !== onMouseEnter || $[22] !== onMouseLeave || $[23] !== t4 || $[24] !== t5 || $[25] !== t6 || $[26] !== t7 || $[27] !== t8) {
119
+ t9 = /* @__PURE__ */ jsxs("li", {
120
+ className: t4,
121
+ onClick: t5,
122
+ onDoubleClick: t6,
123
+ onMouseEnter,
124
+ onMouseLeave,
125
+ children: [t7, t8]
126
+ });
127
+ $[21] = onMouseEnter;
128
+ $[22] = onMouseLeave;
129
+ $[23] = t4;
130
+ $[24] = t5;
131
+ $[25] = t6;
132
+ $[26] = t7;
133
+ $[27] = t8;
134
+ $[28] = t9;
135
+ } else t9 = $[28];
136
+ return t9;
55
137
  };
56
- var BlockFields = ({ block }) => {
138
+ var BlockFields = (t0) => {
139
+ const $ = c(2);
140
+ const { block } = t0;
57
141
  const schemaProperties = useCamoxApp().getBlockById(block.type)?.contentSchema.properties;
58
- const selection = useSelector(previewStore, (state) => state.context.selection);
59
- const iframeElement = useSelector(previewStore, (state) => state.context.iframeElement);
142
+ const selection = useSelector(previewStore, _temp3);
143
+ const iframeElement = useSelector(previewStore, _temp4);
60
144
  const selectedFieldName = selection?.type === "block-field" && selection.blockId === String(block.id) ? selection.fieldName : null;
61
145
  const handleFieldClick = (fieldName, fieldType) => {
62
146
  previewStore.send({
@@ -66,359 +150,877 @@ var BlockFields = ({ block }) => {
66
150
  fieldType
67
151
  });
68
152
  };
69
- const handleFieldDoubleClick = (fieldName, fieldType) => {
70
- fieldTypesDictionary[fieldType].onTreeDoubleClick({
153
+ const handleFieldDoubleClick = (fieldName_0, fieldType_0) => {
154
+ fieldTypesDictionary[fieldType_0].onTreeDoubleClick({
71
155
  blockId: String(block.id),
72
- fieldName
156
+ fieldName: fieldName_0
73
157
  });
74
158
  };
75
- const handleFieldMouseEnter = (fieldName, isRepeatable) => {
159
+ const handleFieldMouseEnter = (fieldName_1, isRepeatable) => {
76
160
  if (!iframeElement?.contentWindow) return;
77
161
  if (isRepeatable) {
78
162
  const message = {
79
163
  type: "CAMOX_HOVER_REPEATER",
80
164
  blockId: String(block.id),
81
- fieldName
165
+ fieldName: fieldName_1
82
166
  };
83
167
  iframeElement.contentWindow.postMessage(message, "*");
84
168
  } else {
85
- const message = {
169
+ const message_0 = {
86
170
  type: "CAMOX_HOVER_FIELD",
87
- fieldId: `${String(block.id)}__${fieldName}`
171
+ fieldId: `${String(block.id)}__${fieldName_1}`
88
172
  };
89
- iframeElement.contentWindow.postMessage(message, "*");
173
+ iframeElement.contentWindow.postMessage(message_0, "*");
90
174
  }
91
175
  };
92
- const handleFieldMouseLeave = (fieldName, isRepeatable) => {
176
+ const handleFieldMouseLeave = (fieldName_2, isRepeatable_0) => {
93
177
  if (!iframeElement?.contentWindow) return;
94
- if (isRepeatable) {
95
- const message = {
178
+ if (isRepeatable_0) {
179
+ const message_1 = {
96
180
  type: "CAMOX_HOVER_REPEATER_END",
97
181
  blockId: String(block.id),
98
- fieldName
182
+ fieldName: fieldName_2
99
183
  };
100
- iframeElement.contentWindow.postMessage(message, "*");
184
+ iframeElement.contentWindow.postMessage(message_1, "*");
101
185
  } else {
102
- const message = {
186
+ const message_2 = {
103
187
  type: "CAMOX_HOVER_FIELD_END",
104
- fieldId: `${String(block.id)}__${fieldName}`
188
+ fieldId: `${String(block.id)}__${fieldName_2}`
105
189
  };
106
- iframeElement.contentWindow.postMessage(message, "*");
190
+ iframeElement.contentWindow.postMessage(message_2, "*");
107
191
  }
108
192
  };
109
- return /* @__PURE__ */ jsx("ul", {
110
- className: "my-1 space-y-1 pr-1 pl-7",
111
- children: Object.keys(schemaProperties ?? {}).map((fieldName) => {
112
- const value = block.content[fieldName];
113
- const fieldSchema = schemaProperties?.[fieldName];
114
- if (!fieldSchema) return null;
115
- const fieldType = fieldSchema.fieldType;
116
- const isRepeatable = fieldType === "RepeatableItem";
117
- return /* @__PURE__ */ jsx(FieldItem, {
118
- fieldName,
119
- value,
120
- fieldType,
121
- schemaTitle: fieldSchema?.title,
122
- arrayItemType: fieldSchema?.arrayItemType,
123
- isSelected: selectedFieldName === fieldName,
124
- onFieldClick: () => handleFieldClick(fieldName, fieldType),
125
- onFieldDoubleClick: () => handleFieldDoubleClick(fieldName, fieldType),
126
- onMouseEnter: () => handleFieldMouseEnter(fieldName, isRepeatable),
127
- onMouseLeave: () => handleFieldMouseLeave(fieldName, isRepeatable)
128
- }, fieldName);
129
- })
193
+ const t1 = "my-1 space-y-1 pr-1 pl-7";
194
+ const t2 = Object.keys(schemaProperties ?? {}).map((fieldName_3) => {
195
+ const value = block.content[fieldName_3];
196
+ const fieldSchema = schemaProperties?.[fieldName_3];
197
+ if (!fieldSchema) return null;
198
+ const fieldType_1 = fieldSchema.fieldType;
199
+ const isRepeatable_1 = fieldType_1 === "RepeatableItem";
200
+ return /* @__PURE__ */ jsx(FieldItem, {
201
+ fieldName: fieldName_3,
202
+ value,
203
+ fieldType: fieldType_1,
204
+ schemaTitle: fieldSchema?.title,
205
+ arrayItemType: fieldSchema?.arrayItemType,
206
+ isSelected: selectedFieldName === fieldName_3,
207
+ onFieldClick: () => handleFieldClick(fieldName_3, fieldType_1),
208
+ onFieldDoubleClick: () => handleFieldDoubleClick(fieldName_3, fieldType_1),
209
+ onMouseEnter: () => handleFieldMouseEnter(fieldName_3, isRepeatable_1),
210
+ onMouseLeave: () => handleFieldMouseLeave(fieldName_3, isRepeatable_1)
211
+ }, fieldName_3);
130
212
  });
213
+ let t3;
214
+ if ($[0] !== t2) {
215
+ t3 = /* @__PURE__ */ jsx("ul", {
216
+ className: t1,
217
+ children: t2
218
+ });
219
+ $[0] = t2;
220
+ $[1] = t3;
221
+ } else t3 = $[1];
222
+ return t3;
131
223
  };
132
- function useBlockTreeItem(block, isSelected, isDragging = false) {
224
+ function useBlockTreeItem(block, isSelected, t0) {
225
+ const $ = c(17);
226
+ const isDragging = t0 === void 0 ? false : t0;
133
227
  const [ellipsisPopoverOpen, setEllipsisPopoverOpen] = React.useState(false);
134
- const selection = useSelector(previewStore, (state) => state.context.selection);
135
- const iframeElement = useSelector(previewStore, (state) => state.context.iframeElement);
228
+ const selection = useSelector(previewStore, _temp5);
229
+ const iframeElement = useSelector(previewStore, _temp6);
136
230
  const isParentOfSelection = isSelected && selection != null && selection.type !== "block";
137
231
  const shouldShowHover = !isDragging && !isSelected;
138
232
  const shouldShowActive = isDragging || isSelected && !isParentOfSelection;
139
- const handleBlockMouseEnter = () => {
140
- if (!iframeElement?.contentWindow) return;
141
- const message = {
142
- type: "CAMOX_HOVER_BLOCK",
143
- blockId: String(block.id)
233
+ let t1;
234
+ if ($[0] !== block || $[1] !== iframeElement) {
235
+ t1 = () => {
236
+ if (!iframeElement?.contentWindow) return;
237
+ const message = {
238
+ type: "CAMOX_HOVER_BLOCK",
239
+ blockId: String(block.id)
240
+ };
241
+ iframeElement.contentWindow.postMessage(message, "*");
144
242
  };
145
- iframeElement.contentWindow.postMessage(message, "*");
146
- };
147
- const handleBlockMouseLeave = () => {
148
- if (!iframeElement?.contentWindow) return;
149
- const message = {
150
- type: "CAMOX_HOVER_BLOCK_END",
151
- blockId: String(block.id)
243
+ $[0] = block;
244
+ $[1] = iframeElement;
245
+ $[2] = t1;
246
+ } else t1 = $[2];
247
+ const handleBlockMouseEnter = t1;
248
+ let t2;
249
+ if ($[3] !== block || $[4] !== iframeElement) {
250
+ t2 = () => {
251
+ if (!iframeElement?.contentWindow) return;
252
+ const message_0 = {
253
+ type: "CAMOX_HOVER_BLOCK_END",
254
+ blockId: String(block.id)
255
+ };
256
+ iframeElement.contentWindow.postMessage(message_0, "*");
152
257
  };
153
- iframeElement.contentWindow.postMessage(message, "*");
154
- };
155
- const toggleSelection = () => {
156
- if (isSelected) previewStore.send({ type: "clearSelection" });
157
- else previewStore.send({
158
- type: "setFocusedBlock",
159
- blockId: String(block.id)
160
- });
161
- };
162
- return {
163
- ellipsisPopoverOpen,
164
- setEllipsisPopoverOpen,
165
- isParentOfSelection,
166
- shouldShowHover,
167
- shouldShowActive,
168
- handleBlockMouseEnter,
169
- handleBlockMouseLeave,
170
- toggleSelection
171
- };
258
+ $[3] = block;
259
+ $[4] = iframeElement;
260
+ $[5] = t2;
261
+ } else t2 = $[5];
262
+ const handleBlockMouseLeave = t2;
263
+ let t3;
264
+ if ($[6] !== block || $[7] !== isSelected) {
265
+ t3 = () => {
266
+ if (isSelected) previewStore.send({ type: "clearSelection" });
267
+ else previewStore.send({
268
+ type: "setFocusedBlock",
269
+ blockId: String(block.id)
270
+ });
271
+ };
272
+ $[6] = block;
273
+ $[7] = isSelected;
274
+ $[8] = t3;
275
+ } else t3 = $[8];
276
+ const toggleSelection = t3;
277
+ let t4;
278
+ if ($[9] !== ellipsisPopoverOpen || $[10] !== handleBlockMouseEnter || $[11] !== handleBlockMouseLeave || $[12] !== isParentOfSelection || $[13] !== shouldShowActive || $[14] !== shouldShowHover || $[15] !== toggleSelection) {
279
+ t4 = {
280
+ ellipsisPopoverOpen,
281
+ setEllipsisPopoverOpen,
282
+ isParentOfSelection,
283
+ shouldShowHover,
284
+ shouldShowActive,
285
+ handleBlockMouseEnter,
286
+ handleBlockMouseLeave,
287
+ toggleSelection
288
+ };
289
+ $[9] = ellipsisPopoverOpen;
290
+ $[10] = handleBlockMouseEnter;
291
+ $[11] = handleBlockMouseLeave;
292
+ $[12] = isParentOfSelection;
293
+ $[13] = shouldShowActive;
294
+ $[14] = shouldShowHover;
295
+ $[15] = toggleSelection;
296
+ $[16] = t4;
297
+ } else t4 = $[16];
298
+ return t4;
299
+ }
300
+ function _temp6(state_0) {
301
+ return state_0.context.iframeElement;
172
302
  }
173
- var BlockTreeItemHeader = ({ children, shouldShowHover, shouldShowActive, isParentOfSelection, className, ref, ...props }) => /* @__PURE__ */ jsx("div", {
174
- ref,
175
- className: cn("flex flex-row justify-between items-center gap-1 px-1 max-w-full rounded-lg text-foreground transition-all hover:transition-none", shouldShowHover && "hover:bg-accent/75", shouldShowActive && "bg-accent text-accent-foreground", isParentOfSelection && "bg-accent/25", "data-[state=open]:rounded-b-none", className),
176
- ...props,
177
- children
178
- });
179
- var BlockTreeItemTrigger = ({ displayText, onClick }) => /* @__PURE__ */ jsx("div", {
180
- className: "flex flex-1 items-center gap-1 overflow-x-hidden",
181
- children: /* @__PURE__ */ jsx(Accordion.Trigger, {
182
- asChild: true,
183
- children: /* @__PURE__ */ jsx("button", {
184
- className: cn("cursor-default flex-1 truncate py-2 text-sm text-left rounded-sm", "focus-visible:underline outline-none focus-visible:decoration-ring/50 focus-visible:decoration-4"),
185
- title: displayText,
186
- onClick,
187
- children: displayText
188
- })
189
- })
190
- });
191
- var BlockTreeItemEllipsis = ({ open, className, ...props }) => /* @__PURE__ */ jsx(Button, {
192
- variant: "ghost",
193
- size: "icon-sm",
194
- className: cn("text-muted-foreground hover:text-foreground", open ? "flex" : "hidden group-hover:flex group-focus-within:flex", className),
195
- ...props,
196
- children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" })
197
- });
198
- var BlockTreeItemContent = ({ block }) => /* @__PURE__ */ jsx(Accordion.Content, {
199
- className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down text-muted-foreground data-[state=open]:bg-accent/25 overflow-hidden rounded-b-lg text-sm",
200
- children: /* @__PURE__ */ jsx(BlockFields, { block })
201
- });
303
+ function _temp5(state) {
304
+ return state.context.selection;
305
+ }
306
+ var BlockTreeItemHeader = (t0) => {
307
+ const $ = c(18);
308
+ let children;
309
+ let className;
310
+ let isParentOfSelection;
311
+ let props;
312
+ let ref;
313
+ let shouldShowActive;
314
+ let shouldShowHover;
315
+ if ($[0] !== t0) {
316
+ ({children, shouldShowHover, shouldShowActive, isParentOfSelection, className, ref, ...props} = t0);
317
+ $[0] = t0;
318
+ $[1] = children;
319
+ $[2] = className;
320
+ $[3] = isParentOfSelection;
321
+ $[4] = props;
322
+ $[5] = ref;
323
+ $[6] = shouldShowActive;
324
+ $[7] = shouldShowHover;
325
+ } else {
326
+ children = $[1];
327
+ className = $[2];
328
+ isParentOfSelection = $[3];
329
+ props = $[4];
330
+ ref = $[5];
331
+ shouldShowActive = $[6];
332
+ shouldShowHover = $[7];
333
+ }
334
+ const t1 = shouldShowHover && "hover:bg-accent/75";
335
+ const t2 = shouldShowActive && "bg-accent text-accent-foreground";
336
+ const t3 = isParentOfSelection && "bg-accent/25";
337
+ let t4;
338
+ if ($[8] !== className || $[9] !== t1 || $[10] !== t2 || $[11] !== t3) {
339
+ t4 = cn("flex flex-row justify-between items-center gap-1 px-1 max-w-full rounded-lg text-foreground transition-all hover:transition-none", t1, t2, t3, "data-[state=open]:rounded-b-none", className);
340
+ $[8] = className;
341
+ $[9] = t1;
342
+ $[10] = t2;
343
+ $[11] = t3;
344
+ $[12] = t4;
345
+ } else t4 = $[12];
346
+ let t5;
347
+ if ($[13] !== children || $[14] !== props || $[15] !== ref || $[16] !== t4) {
348
+ t5 = /* @__PURE__ */ jsx("div", {
349
+ ref,
350
+ className: t4,
351
+ ...props,
352
+ children
353
+ });
354
+ $[13] = children;
355
+ $[14] = props;
356
+ $[15] = ref;
357
+ $[16] = t4;
358
+ $[17] = t5;
359
+ } else t5 = $[17];
360
+ return t5;
361
+ };
362
+ var BlockTreeItemTrigger = (t0) => {
363
+ const $ = c(4);
364
+ const { displayText, onClick } = t0;
365
+ let t1;
366
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
367
+ t1 = cn("cursor-default flex-1 truncate py-2 text-sm text-left rounded-sm", "focus-visible:underline outline-none focus-visible:decoration-ring/50 focus-visible:decoration-4");
368
+ $[0] = t1;
369
+ } else t1 = $[0];
370
+ let t2;
371
+ if ($[1] !== displayText || $[2] !== onClick) {
372
+ t2 = /* @__PURE__ */ jsx("div", {
373
+ className: "flex flex-1 items-center gap-1 overflow-x-hidden",
374
+ children: /* @__PURE__ */ jsx(Accordion.Trigger, {
375
+ asChild: true,
376
+ children: /* @__PURE__ */ jsx("button", {
377
+ className: t1,
378
+ title: displayText,
379
+ onClick,
380
+ children: displayText
381
+ })
382
+ })
383
+ });
384
+ $[1] = displayText;
385
+ $[2] = onClick;
386
+ $[3] = t2;
387
+ } else t2 = $[3];
388
+ return t2;
389
+ };
390
+ var BlockTreeItemEllipsis = (t0) => {
391
+ const $ = c(11);
392
+ let className;
393
+ let open;
394
+ let props;
395
+ if ($[0] !== t0) {
396
+ ({open, className, ...props} = t0);
397
+ $[0] = t0;
398
+ $[1] = className;
399
+ $[2] = open;
400
+ $[3] = props;
401
+ } else {
402
+ className = $[1];
403
+ open = $[2];
404
+ props = $[3];
405
+ }
406
+ const t1 = open ? "flex" : "hidden group-hover:flex group-focus-within:flex";
407
+ let t2;
408
+ if ($[4] !== className || $[5] !== t1) {
409
+ t2 = cn("text-muted-foreground hover:text-foreground", t1, className);
410
+ $[4] = className;
411
+ $[5] = t1;
412
+ $[6] = t2;
413
+ } else t2 = $[6];
414
+ let t3;
415
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
416
+ t3 = /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" });
417
+ $[7] = t3;
418
+ } else t3 = $[7];
419
+ let t4;
420
+ if ($[8] !== props || $[9] !== t2) {
421
+ t4 = /* @__PURE__ */ jsx(Button, {
422
+ variant: "ghost",
423
+ size: "icon-sm",
424
+ className: t2,
425
+ ...props,
426
+ children: t3
427
+ });
428
+ $[8] = props;
429
+ $[9] = t2;
430
+ $[10] = t4;
431
+ } else t4 = $[10];
432
+ return t4;
433
+ };
434
+ var BlockTreeItemContent = (t0) => {
435
+ const $ = c(2);
436
+ const { block } = t0;
437
+ let t1;
438
+ if ($[0] !== block) {
439
+ t1 = /* @__PURE__ */ jsx(Accordion.Content, {
440
+ className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down text-muted-foreground data-[state=open]:bg-accent/25 overflow-hidden rounded-b-lg text-sm",
441
+ children: /* @__PURE__ */ jsx(BlockFields, { block })
442
+ });
443
+ $[0] = block;
444
+ $[1] = t1;
445
+ } else t1 = $[1];
446
+ return t1;
447
+ };
202
448
  var animateLayoutChanges = (args) => {
203
449
  const { isSorting, wasDragging } = args;
204
450
  if (isSorting || wasDragging) return false;
205
451
  return defaultAnimateLayoutChanges(args);
206
452
  };
207
- var SortableBlock = ({ block, isSelected }) => {
453
+ var SortableBlock = (t0) => {
454
+ const $ = c(47);
455
+ const { block, isSelected } = t0;
208
456
  const [gripPopoverOpen, setGripPopoverOpen] = React.useState(false);
209
- const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
210
- id: String(block.id),
211
- animateLayoutChanges
212
- });
213
- const style = {
214
- transform: CSS.Transform.toString(transform),
215
- transition,
216
- opacity: isDragging ? 0 : 1
217
- };
457
+ const t1 = String(block.id);
458
+ let t2;
459
+ if ($[0] !== t1) {
460
+ t2 = {
461
+ id: t1,
462
+ animateLayoutChanges
463
+ };
464
+ $[0] = t1;
465
+ $[1] = t2;
466
+ } else t2 = $[1];
467
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable(t2);
468
+ let t3;
469
+ if ($[2] !== transform) {
470
+ t3 = CSS.Transform.toString(transform);
471
+ $[2] = transform;
472
+ $[3] = t3;
473
+ } else t3 = $[3];
474
+ const t4 = isDragging ? 0 : 1;
475
+ let t5;
476
+ if ($[4] !== t3 || $[5] !== t4 || $[6] !== transition) {
477
+ t5 = {
478
+ transform: t3,
479
+ transition,
480
+ opacity: t4
481
+ };
482
+ $[4] = t3;
483
+ $[5] = t4;
484
+ $[6] = transition;
485
+ $[7] = t5;
486
+ } else t5 = $[7];
487
+ const style = t5;
218
488
  const ctx = useBlockTreeItem(block, isSelected, isDragging);
219
- return /* @__PURE__ */ jsx(Accordion.Root, {
220
- type: "single",
221
- collapsible: true,
222
- value: isSelected ? String(block.id) : "",
223
- children: /* @__PURE__ */ jsxs(Accordion.Item, {
224
- value: String(block.id),
489
+ const t6 = isSelected ? String(block.id) : "";
490
+ const t7 = String(block.id);
491
+ let t8;
492
+ let t9;
493
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
494
+ t8 = /* @__PURE__ */ jsx("span", {
495
+ className: "sr-only",
496
+ children: "Click and use arrow keys to reorder"
497
+ });
498
+ t9 = /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" });
499
+ $[8] = t8;
500
+ $[9] = t9;
501
+ } else {
502
+ t8 = $[8];
503
+ t9 = $[9];
504
+ }
505
+ let t10;
506
+ if ($[10] !== attributes || $[11] !== listeners) {
507
+ t10 = /* @__PURE__ */ jsxs(Button, {
508
+ variant: "ghost",
509
+ size: "icon-sm",
510
+ className: "text-muted-foreground hover:text-foreground flex cursor-grab active:cursor-grabbing",
511
+ ...attributes,
512
+ ...listeners,
513
+ children: [t8, t9]
514
+ });
515
+ $[10] = attributes;
516
+ $[11] = listeners;
517
+ $[12] = t10;
518
+ } else t10 = $[12];
519
+ let t11;
520
+ if ($[13] !== block || $[14] !== gripPopoverOpen || $[15] !== t10) {
521
+ t11 = /* @__PURE__ */ jsx(BlockActionsPopover, {
522
+ block,
523
+ open: gripPopoverOpen,
524
+ onOpenChange: setGripPopoverOpen,
525
+ children: t10
526
+ });
527
+ $[13] = block;
528
+ $[14] = gripPopoverOpen;
529
+ $[15] = t10;
530
+ $[16] = t11;
531
+ } else t11 = $[16];
532
+ const t12 = block.summary || block.type;
533
+ let t13;
534
+ if ($[17] !== ctx.toggleSelection || $[18] !== t12) {
535
+ t13 = /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
536
+ displayText: t12,
537
+ onClick: ctx.toggleSelection
538
+ });
539
+ $[17] = ctx.toggleSelection;
540
+ $[18] = t12;
541
+ $[19] = t13;
542
+ } else t13 = $[19];
543
+ let t14;
544
+ if ($[20] !== ctx.ellipsisPopoverOpen) {
545
+ t14 = /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen });
546
+ $[20] = ctx.ellipsisPopoverOpen;
547
+ $[21] = t14;
548
+ } else t14 = $[21];
549
+ let t15;
550
+ if ($[22] !== block || $[23] !== ctx.ellipsisPopoverOpen || $[24] !== ctx.setEllipsisPopoverOpen || $[25] !== t14) {
551
+ t15 = /* @__PURE__ */ jsx(BlockActionsPopover, {
552
+ block,
553
+ open: ctx.ellipsisPopoverOpen,
554
+ onOpenChange: ctx.setEllipsisPopoverOpen,
555
+ children: t14
556
+ });
557
+ $[22] = block;
558
+ $[23] = ctx.ellipsisPopoverOpen;
559
+ $[24] = ctx.setEllipsisPopoverOpen;
560
+ $[25] = t14;
561
+ $[26] = t15;
562
+ } else t15 = $[26];
563
+ let t16;
564
+ if ($[27] !== ctx.isParentOfSelection || $[28] !== ctx.shouldShowActive || $[29] !== ctx.shouldShowHover || $[30] !== t11 || $[31] !== t13 || $[32] !== t15) {
565
+ t16 = /* @__PURE__ */ jsx(Accordion.Header, {
566
+ asChild: true,
567
+ children: /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
568
+ shouldShowHover: ctx.shouldShowHover,
569
+ shouldShowActive: ctx.shouldShowActive,
570
+ isParentOfSelection: ctx.isParentOfSelection,
571
+ children: [
572
+ t11,
573
+ t13,
574
+ t15
575
+ ]
576
+ })
577
+ });
578
+ $[27] = ctx.isParentOfSelection;
579
+ $[28] = ctx.shouldShowActive;
580
+ $[29] = ctx.shouldShowHover;
581
+ $[30] = t11;
582
+ $[31] = t13;
583
+ $[32] = t15;
584
+ $[33] = t16;
585
+ } else t16 = $[33];
586
+ let t17;
587
+ if ($[34] !== block) {
588
+ t17 = /* @__PURE__ */ jsx(BlockTreeItemContent, { block });
589
+ $[34] = block;
590
+ $[35] = t17;
591
+ } else t17 = $[35];
592
+ let t18;
593
+ if ($[36] !== ctx.handleBlockMouseEnter || $[37] !== ctx.handleBlockMouseLeave || $[38] !== setNodeRef || $[39] !== style || $[40] !== t16 || $[41] !== t17 || $[42] !== t7) {
594
+ t18 = /* @__PURE__ */ jsxs(Accordion.Item, {
595
+ value: t7,
225
596
  ref: setNodeRef,
226
597
  style,
227
598
  className: "group",
228
599
  onMouseEnter: ctx.handleBlockMouseEnter,
229
600
  onMouseLeave: ctx.handleBlockMouseLeave,
230
- children: [/* @__PURE__ */ jsx(Accordion.Header, {
231
- asChild: true,
232
- children: /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
233
- shouldShowHover: ctx.shouldShowHover,
234
- shouldShowActive: ctx.shouldShowActive,
235
- isParentOfSelection: ctx.isParentOfSelection,
236
- children: [
237
- /* @__PURE__ */ jsx(BlockActionsPopover, {
238
- block,
239
- open: gripPopoverOpen,
240
- onOpenChange: setGripPopoverOpen,
241
- children: /* @__PURE__ */ jsxs(Button, {
242
- variant: "ghost",
243
- size: "icon-sm",
244
- className: "text-muted-foreground hover:text-foreground flex cursor-grab active:cursor-grabbing",
245
- ...attributes,
246
- ...listeners,
247
- children: [/* @__PURE__ */ jsx("span", {
248
- className: "sr-only",
249
- children: "Click and use arrow keys to reorder"
250
- }), /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" })]
251
- })
252
- }),
253
- /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
254
- displayText: block.summary || block.type,
255
- onClick: ctx.toggleSelection
256
- }),
257
- /* @__PURE__ */ jsx(BlockActionsPopover, {
258
- block,
259
- open: ctx.ellipsisPopoverOpen,
260
- onOpenChange: ctx.setEllipsisPopoverOpen,
261
- children: /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen })
262
- })
263
- ]
264
- })
265
- }), /* @__PURE__ */ jsx(BlockTreeItemContent, { block })]
266
- })
267
- });
601
+ children: [t16, t17]
602
+ });
603
+ $[36] = ctx.handleBlockMouseEnter;
604
+ $[37] = ctx.handleBlockMouseLeave;
605
+ $[38] = setNodeRef;
606
+ $[39] = style;
607
+ $[40] = t16;
608
+ $[41] = t17;
609
+ $[42] = t7;
610
+ $[43] = t18;
611
+ } else t18 = $[43];
612
+ let t19;
613
+ if ($[44] !== t18 || $[45] !== t6) {
614
+ t19 = /* @__PURE__ */ jsx(Accordion.Root, {
615
+ type: "single",
616
+ collapsible: true,
617
+ value: t6,
618
+ children: t18
619
+ });
620
+ $[44] = t18;
621
+ $[45] = t6;
622
+ $[46] = t19;
623
+ } else t19 = $[46];
624
+ return t19;
268
625
  };
269
- var LayoutBlockItem = ({ block, isSelected, layoutName }) => {
270
- const blockDef = useCamoxApp().getBlockById(block.type);
626
+ var LayoutBlockItem = (t0) => {
627
+ const $ = c(38);
628
+ const { block, isSelected, layoutName } = t0;
629
+ const camoxApp = useCamoxApp();
630
+ let t1;
631
+ if ($[0] !== block.type || $[1] !== camoxApp) {
632
+ t1 = camoxApp.getBlockById(block.type);
633
+ $[0] = block.type;
634
+ $[1] = camoxApp;
635
+ $[2] = t1;
636
+ } else t1 = $[2];
637
+ const blockDef = t1;
271
638
  const ctx = useBlockTreeItem(block, isSelected);
272
639
  const displayText = blockDef?.title ?? block.type;
273
- return /* @__PURE__ */ jsx(Accordion.Root, {
274
- type: "single",
275
- collapsible: true,
276
- value: isSelected ? String(block.id) : "",
277
- children: /* @__PURE__ */ jsxs(Accordion.Item, {
278
- value: String(block.id),
640
+ const t2 = isSelected ? String(block.id) : "";
641
+ const t3 = String(block.id);
642
+ let t4;
643
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
644
+ t4 = /* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(LayoutTemplate, { className: "h-4 w-4" }) });
645
+ $[3] = t4;
646
+ } else t4 = $[3];
647
+ let t5;
648
+ if ($[4] !== layoutName) {
649
+ t5 = /* @__PURE__ */ jsx("span", {
650
+ className: "font-semibold",
651
+ children: layoutName
652
+ });
653
+ $[4] = layoutName;
654
+ $[5] = t5;
655
+ } else t5 = $[5];
656
+ let t6;
657
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
658
+ t6 = /* @__PURE__ */ jsx("br", {});
659
+ $[6] = t6;
660
+ } else t6 = $[6];
661
+ let t7;
662
+ if ($[7] !== t5) {
663
+ t7 = /* @__PURE__ */ jsx("div", {
664
+ className: "text-muted-foreground flex size-7 shrink-0 items-center justify-center",
665
+ children: /* @__PURE__ */ jsxs(Tooltip, {
666
+ delayDuration: 500,
667
+ children: [t4, /* @__PURE__ */ jsxs(TooltipContent, { children: [
668
+ "From ",
669
+ t5,
670
+ " layout.",
671
+ t6,
672
+ "Changing the content may affect other pages"
673
+ ] })]
674
+ })
675
+ });
676
+ $[7] = t5;
677
+ $[8] = t7;
678
+ } else t7 = $[8];
679
+ let t8;
680
+ if ($[9] !== ctx.toggleSelection || $[10] !== displayText) {
681
+ t8 = /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
682
+ displayText,
683
+ onClick: ctx.toggleSelection
684
+ });
685
+ $[9] = ctx.toggleSelection;
686
+ $[10] = displayText;
687
+ $[11] = t8;
688
+ } else t8 = $[11];
689
+ const t9 = block.placement;
690
+ let t10;
691
+ if ($[12] !== ctx.ellipsisPopoverOpen) {
692
+ t10 = /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen });
693
+ $[12] = ctx.ellipsisPopoverOpen;
694
+ $[13] = t10;
695
+ } else t10 = $[13];
696
+ let t11;
697
+ if ($[14] !== block || $[15] !== ctx.ellipsisPopoverOpen || $[16] !== ctx.setEllipsisPopoverOpen || $[17] !== t10 || $[18] !== t9) {
698
+ t11 = /* @__PURE__ */ jsx(BlockActionsPopover, {
699
+ block,
700
+ open: ctx.ellipsisPopoverOpen,
701
+ onOpenChange: ctx.setEllipsisPopoverOpen,
702
+ isLayoutBlock: true,
703
+ layoutPlacement: t9,
704
+ children: t10
705
+ });
706
+ $[14] = block;
707
+ $[15] = ctx.ellipsisPopoverOpen;
708
+ $[16] = ctx.setEllipsisPopoverOpen;
709
+ $[17] = t10;
710
+ $[18] = t9;
711
+ $[19] = t11;
712
+ } else t11 = $[19];
713
+ let t12;
714
+ if ($[20] !== ctx.isParentOfSelection || $[21] !== ctx.shouldShowActive || $[22] !== ctx.shouldShowHover || $[23] !== t11 || $[24] !== t7 || $[25] !== t8) {
715
+ t12 = /* @__PURE__ */ jsx(Accordion.Header, {
716
+ asChild: true,
717
+ children: /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
718
+ shouldShowHover: ctx.shouldShowHover,
719
+ shouldShowActive: ctx.shouldShowActive,
720
+ isParentOfSelection: ctx.isParentOfSelection,
721
+ children: [
722
+ t7,
723
+ t8,
724
+ t11
725
+ ]
726
+ })
727
+ });
728
+ $[20] = ctx.isParentOfSelection;
729
+ $[21] = ctx.shouldShowActive;
730
+ $[22] = ctx.shouldShowHover;
731
+ $[23] = t11;
732
+ $[24] = t7;
733
+ $[25] = t8;
734
+ $[26] = t12;
735
+ } else t12 = $[26];
736
+ let t13;
737
+ if ($[27] !== block) {
738
+ t13 = /* @__PURE__ */ jsx(BlockTreeItemContent, { block });
739
+ $[27] = block;
740
+ $[28] = t13;
741
+ } else t13 = $[28];
742
+ let t14;
743
+ if ($[29] !== ctx.handleBlockMouseEnter || $[30] !== ctx.handleBlockMouseLeave || $[31] !== t12 || $[32] !== t13 || $[33] !== t3) {
744
+ t14 = /* @__PURE__ */ jsxs(Accordion.Item, {
745
+ value: t3,
279
746
  className: "group",
280
747
  onMouseEnter: ctx.handleBlockMouseEnter,
281
748
  onMouseLeave: ctx.handleBlockMouseLeave,
282
- children: [/* @__PURE__ */ jsx(Accordion.Header, {
283
- asChild: true,
284
- children: /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
285
- shouldShowHover: ctx.shouldShowHover,
286
- shouldShowActive: ctx.shouldShowActive,
287
- isParentOfSelection: ctx.isParentOfSelection,
288
- children: [
289
- /* @__PURE__ */ jsx("div", {
290
- className: "text-muted-foreground flex size-7 shrink-0 items-center justify-center",
291
- children: /* @__PURE__ */ jsxs(Tooltip, {
292
- delayDuration: 500,
293
- children: [/* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(LayoutTemplate, { className: "h-4 w-4" }) }), /* @__PURE__ */ jsxs(TooltipContent, { children: [
294
- "From ",
295
- /* @__PURE__ */ jsx("span", {
296
- className: "font-semibold",
297
- children: layoutName
298
- }),
299
- " layout.",
300
- /* @__PURE__ */ jsx("br", {}),
301
- "Changing the content may affect other pages"
302
- ] })]
303
- })
304
- }),
305
- /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
306
- displayText,
307
- onClick: ctx.toggleSelection
308
- }),
309
- /* @__PURE__ */ jsx(BlockActionsPopover, {
310
- block,
311
- open: ctx.ellipsisPopoverOpen,
312
- onOpenChange: ctx.setEllipsisPopoverOpen,
313
- isLayoutBlock: true,
314
- layoutPlacement: block.placement,
315
- children: /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen })
316
- })
317
- ]
318
- })
319
- }), /* @__PURE__ */ jsx(BlockTreeItemContent, { block })]
320
- })
321
- });
749
+ children: [t12, t13]
750
+ });
751
+ $[29] = ctx.handleBlockMouseEnter;
752
+ $[30] = ctx.handleBlockMouseLeave;
753
+ $[31] = t12;
754
+ $[32] = t13;
755
+ $[33] = t3;
756
+ $[34] = t14;
757
+ } else t14 = $[34];
758
+ let t15;
759
+ if ($[35] !== t14 || $[36] !== t2) {
760
+ t15 = /* @__PURE__ */ jsx(Accordion.Root, {
761
+ type: "single",
762
+ collapsible: true,
763
+ value: t2,
764
+ children: t14
765
+ });
766
+ $[35] = t14;
767
+ $[36] = t2;
768
+ $[37] = t15;
769
+ } else t15 = $[37];
770
+ return t15;
322
771
  };
323
772
  var PageTree = () => {
324
- const focusedBlockId = useSelector(previewStore, (state) => state.context.selection)?.blockId ?? null;
773
+ const $ = c(53);
774
+ const focusedBlockId = useSelector(previewStore, _temp7)?.blockId ?? null;
325
775
  const page = usePreviewedPage();
326
776
  const { pageBlocks, beforeBlocks: layoutBeforeBlocks, afterBlocks: layoutAfterBlocks } = usePageBlocks(page);
327
777
  const camoxApp = useCamoxApp();
328
778
  const updatePosition = useUpdateBlockPosition();
329
779
  const [activeId, setActiveId] = React.useState(null);
330
- const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: {
331
- distance: 8,
332
- delay: 150,
333
- tolerance: 5
334
- } }), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
335
- const handleDragStart = (event) => {
336
- setActiveId(String(event.active.id));
337
- };
338
- const handleDragEnd = (event) => {
339
- const { active, over } = event;
340
- if (!over || active.id === over.id || !page) {
780
+ let t0;
781
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
782
+ t0 = { activationConstraint: {
783
+ distance: 8,
784
+ delay: 150,
785
+ tolerance: 5
786
+ } };
787
+ $[0] = t0;
788
+ } else t0 = $[0];
789
+ let t1;
790
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
791
+ t1 = { coordinateGetter: sortableKeyboardCoordinates };
792
+ $[1] = t1;
793
+ } else t1 = $[1];
794
+ const sensors = useSensors(useSensor(PointerSensor, t0), useSensor(KeyboardSensor, t1));
795
+ let t2;
796
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
797
+ t2 = (event) => {
798
+ setActiveId(String(event.active.id));
799
+ };
800
+ $[2] = t2;
801
+ } else t2 = $[2];
802
+ const handleDragStart = t2;
803
+ let t3;
804
+ if ($[3] !== page || $[4] !== pageBlocks || $[5] !== updatePosition) {
805
+ t3 = (event_0) => {
806
+ const { active, over } = event_0;
807
+ if (!over || active.id === over.id || !page) {
808
+ setActiveId(null);
809
+ return;
810
+ }
811
+ const oldIndex = pageBlocks.findIndex((block) => String(block.id) === active.id);
812
+ const newIndex = pageBlocks.findIndex((block_0) => String(block_0.id) === over.id);
813
+ if (oldIndex === -1 || newIndex === -1) {
814
+ setActiveId(null);
815
+ return;
816
+ }
817
+ let afterPosition;
818
+ let beforePosition;
819
+ if (oldIndex < newIndex) {
820
+ afterPosition = pageBlocks[newIndex].position;
821
+ beforePosition = newIndex < pageBlocks.length - 1 ? pageBlocks[newIndex + 1].position : void 0;
822
+ } else {
823
+ afterPosition = newIndex > 0 ? pageBlocks[newIndex - 1].position : void 0;
824
+ beforePosition = pageBlocks[newIndex].position;
825
+ }
826
+ updatePosition.mutate({
827
+ id: Number(active.id),
828
+ afterPosition,
829
+ beforePosition
830
+ });
341
831
  setActiveId(null);
342
- return;
343
- }
344
- const oldIndex = pageBlocks.findIndex((block) => String(block.id) === active.id);
345
- const newIndex = pageBlocks.findIndex((block) => String(block.id) === over.id);
346
- if (oldIndex === -1 || newIndex === -1) {
832
+ };
833
+ $[3] = page;
834
+ $[4] = pageBlocks;
835
+ $[5] = updatePosition;
836
+ $[6] = t3;
837
+ } else t3 = $[6];
838
+ const handleDragEnd = t3;
839
+ let t4;
840
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
841
+ t4 = () => {
347
842
  setActiveId(null);
348
- return;
349
- }
350
- let afterPosition;
351
- let beforePosition;
352
- if (oldIndex < newIndex) {
353
- afterPosition = pageBlocks[newIndex].position;
354
- beforePosition = newIndex < pageBlocks.length - 1 ? pageBlocks[newIndex + 1].position : void 0;
355
- } else {
356
- afterPosition = newIndex > 0 ? pageBlocks[newIndex - 1].position : void 0;
357
- beforePosition = pageBlocks[newIndex].position;
358
- }
359
- updatePosition.mutate({
360
- id: Number(active.id),
361
- afterPosition,
362
- beforePosition
363
- });
364
- setActiveId(null);
365
- };
366
- const handleDragCancel = () => {
367
- setActiveId(null);
368
- };
843
+ };
844
+ $[7] = t4;
845
+ } else t4 = $[7];
846
+ const handleDragCancel = t4;
369
847
  if (!page) return null;
370
- const layout = page.layout ? camoxApp.getLayoutById(page.layout.layoutId) : void 0;
371
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
372
- className: "flex flex-col gap-0.5",
373
- children: [
374
- layoutBeforeBlocks.map((block) => /* @__PURE__ */ jsx(LayoutBlockItem, {
375
- block,
376
- isSelected: focusedBlockId === String(block.id),
848
+ let t5;
849
+ if ($[8] !== camoxApp || $[9] !== page.layout) {
850
+ t5 = page.layout ? camoxApp.getLayoutById(page.layout.layoutId) : void 0;
851
+ $[8] = camoxApp;
852
+ $[9] = page.layout;
853
+ $[10] = t5;
854
+ } else t5 = $[10];
855
+ const layout = t5;
856
+ let t6;
857
+ if ($[11] !== focusedBlockId || $[12] !== layout?.title || $[13] !== layoutBeforeBlocks) {
858
+ let t7;
859
+ if ($[15] !== focusedBlockId || $[16] !== layout?.title) {
860
+ t7 = (block_1) => /* @__PURE__ */ jsx(LayoutBlockItem, {
861
+ block: block_1,
862
+ isSelected: focusedBlockId === String(block_1.id),
377
863
  layoutName: layout?.title ?? "Unknown"
378
- }, String(block.id))),
379
- /* @__PURE__ */ jsxs(DndContext, {
380
- sensors,
381
- collisionDetection: closestCenter,
382
- onDragStart: handleDragStart,
383
- onDragEnd: handleDragEnd,
384
- onDragCancel: handleDragCancel,
385
- modifiers: [restrictToVerticalAxis],
386
- children: [/* @__PURE__ */ jsx(SortableContext, {
387
- items: pageBlocks.map((block) => String(block.id)),
388
- strategy: verticalListSortingStrategy,
389
- children: pageBlocks.map((block) => /* @__PURE__ */ jsx(SortableBlock, {
390
- block,
391
- isSelected: focusedBlockId === String(block.id)
392
- }, String(block.id)))
393
- }), /* @__PURE__ */ jsx(DragOverlay, {
394
- dropAnimation: null,
395
- children: activeId ? (() => {
396
- const activeBlock = pageBlocks.find((b) => String(b.id) === activeId);
397
- if (!activeBlock) return null;
398
- return /* @__PURE__ */ jsx("div", {
399
- className: "bg-accent text-accent-foreground rounded-lg shadow-md",
400
- children: /* @__PURE__ */ jsxs("div", {
401
- className: "flex items-center gap-1 px-1 py-2 text-sm",
402
- children: [/* @__PURE__ */ jsx(GripVertical, { className: "text-muted-foreground mx-1.5 h-4 w-4" }), /* @__PURE__ */ jsx("span", {
403
- className: "truncate",
404
- children: activeBlock.summary
405
- })]
406
- })
407
- });
408
- })() : null
409
- })]
410
- }),
411
- layoutAfterBlocks.map((block) => /* @__PURE__ */ jsx(LayoutBlockItem, {
412
- block,
413
- isSelected: focusedBlockId === String(block.id),
864
+ }, String(block_1.id));
865
+ $[15] = focusedBlockId;
866
+ $[16] = layout?.title;
867
+ $[17] = t7;
868
+ } else t7 = $[17];
869
+ t6 = layoutBeforeBlocks.map(t7);
870
+ $[11] = focusedBlockId;
871
+ $[12] = layout?.title;
872
+ $[13] = layoutBeforeBlocks;
873
+ $[14] = t6;
874
+ } else t6 = $[14];
875
+ let t7;
876
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
877
+ t7 = [restrictToVerticalAxis];
878
+ $[18] = t7;
879
+ } else t7 = $[18];
880
+ let t8;
881
+ if ($[19] !== pageBlocks) {
882
+ t8 = pageBlocks.map(_temp8);
883
+ $[19] = pageBlocks;
884
+ $[20] = t8;
885
+ } else t8 = $[20];
886
+ let t9;
887
+ if ($[21] !== focusedBlockId || $[22] !== pageBlocks) {
888
+ let t10;
889
+ if ($[24] !== focusedBlockId) {
890
+ t10 = (block_3) => /* @__PURE__ */ jsx(SortableBlock, {
891
+ block: block_3,
892
+ isSelected: focusedBlockId === String(block_3.id)
893
+ }, String(block_3.id));
894
+ $[24] = focusedBlockId;
895
+ $[25] = t10;
896
+ } else t10 = $[25];
897
+ t9 = pageBlocks.map(t10);
898
+ $[21] = focusedBlockId;
899
+ $[22] = pageBlocks;
900
+ $[23] = t9;
901
+ } else t9 = $[23];
902
+ let t10;
903
+ if ($[26] !== t8 || $[27] !== t9) {
904
+ t10 = /* @__PURE__ */ jsx(SortableContext, {
905
+ items: t8,
906
+ strategy: verticalListSortingStrategy,
907
+ children: t9
908
+ });
909
+ $[26] = t8;
910
+ $[27] = t9;
911
+ $[28] = t10;
912
+ } else t10 = $[28];
913
+ let t11;
914
+ if ($[29] !== activeId || $[30] !== pageBlocks) {
915
+ t11 = activeId ? (() => {
916
+ const activeBlock = pageBlocks.find((b) => String(b.id) === activeId);
917
+ if (!activeBlock) return null;
918
+ return /* @__PURE__ */ jsx("div", {
919
+ className: "bg-accent text-accent-foreground rounded-lg shadow-md",
920
+ children: /* @__PURE__ */ jsxs("div", {
921
+ className: "flex items-center gap-1 px-1 py-2 text-sm",
922
+ children: [/* @__PURE__ */ jsx(GripVertical, { className: "text-muted-foreground mx-1.5 h-4 w-4" }), /* @__PURE__ */ jsx("span", {
923
+ className: "truncate",
924
+ children: activeBlock.summary
925
+ })]
926
+ })
927
+ });
928
+ })() : null;
929
+ $[29] = activeId;
930
+ $[30] = pageBlocks;
931
+ $[31] = t11;
932
+ } else t11 = $[31];
933
+ let t12;
934
+ if ($[32] !== t11) {
935
+ t12 = /* @__PURE__ */ jsx(DragOverlay, {
936
+ dropAnimation: null,
937
+ children: t11
938
+ });
939
+ $[32] = t11;
940
+ $[33] = t12;
941
+ } else t12 = $[33];
942
+ let t13;
943
+ if ($[34] !== handleDragEnd || $[35] !== sensors || $[36] !== t10 || $[37] !== t12) {
944
+ t13 = /* @__PURE__ */ jsxs(DndContext, {
945
+ sensors,
946
+ collisionDetection: closestCenter,
947
+ onDragStart: handleDragStart,
948
+ onDragEnd: handleDragEnd,
949
+ onDragCancel: handleDragCancel,
950
+ modifiers: t7,
951
+ children: [t10, t12]
952
+ });
953
+ $[34] = handleDragEnd;
954
+ $[35] = sensors;
955
+ $[36] = t10;
956
+ $[37] = t12;
957
+ $[38] = t13;
958
+ } else t13 = $[38];
959
+ let t14;
960
+ if ($[39] !== focusedBlockId || $[40] !== layout?.title || $[41] !== layoutAfterBlocks) {
961
+ let t15;
962
+ if ($[43] !== focusedBlockId || $[44] !== layout?.title) {
963
+ t15 = (block_4) => /* @__PURE__ */ jsx(LayoutBlockItem, {
964
+ block: block_4,
965
+ isSelected: focusedBlockId === String(block_4.id),
414
966
  layoutName: layout?.title ?? "Unknown"
415
- }, String(block.id)))
416
- ]
417
- }), /* @__PURE__ */ jsxs(Button, {
418
- variant: "secondary",
419
- onClick: () => previewStore.send({ type: "openAddBlockSheet" }),
420
- children: [/* @__PURE__ */ jsx(Plus, {}), "Add block"]
421
- })] });
967
+ }, String(block_4.id));
968
+ $[43] = focusedBlockId;
969
+ $[44] = layout?.title;
970
+ $[45] = t15;
971
+ } else t15 = $[45];
972
+ t14 = layoutAfterBlocks.map(t15);
973
+ $[39] = focusedBlockId;
974
+ $[40] = layout?.title;
975
+ $[41] = layoutAfterBlocks;
976
+ $[42] = t14;
977
+ } else t14 = $[42];
978
+ let t15;
979
+ if ($[46] !== t13 || $[47] !== t14 || $[48] !== t6) {
980
+ t15 = /* @__PURE__ */ jsxs("div", {
981
+ className: "flex flex-col gap-0.5",
982
+ children: [
983
+ t6,
984
+ t13,
985
+ t14
986
+ ]
987
+ });
988
+ $[46] = t13;
989
+ $[47] = t14;
990
+ $[48] = t6;
991
+ $[49] = t15;
992
+ } else t15 = $[49];
993
+ let t16;
994
+ if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
995
+ t16 = /* @__PURE__ */ jsxs(Button, {
996
+ variant: "secondary",
997
+ onClick: _temp9,
998
+ children: [/* @__PURE__ */ jsx(Plus, {}), "Add block"]
999
+ });
1000
+ $[50] = t16;
1001
+ } else t16 = $[50];
1002
+ let t17;
1003
+ if ($[51] !== t15) {
1004
+ t17 = /* @__PURE__ */ jsxs(Fragment, { children: [t15, t16] });
1005
+ $[51] = t15;
1006
+ $[52] = t17;
1007
+ } else t17 = $[52];
1008
+ return t17;
422
1009
  };
1010
+ function _temp3(state) {
1011
+ return state.context.selection;
1012
+ }
1013
+ function _temp4(state_0) {
1014
+ return state_0.context.iframeElement;
1015
+ }
1016
+ function _temp7(state) {
1017
+ return state.context.selection;
1018
+ }
1019
+ function _temp8(block_2) {
1020
+ return String(block_2.id);
1021
+ }
1022
+ function _temp9() {
1023
+ return previewStore.send({ type: "openAddBlockSheet" });
1024
+ }
423
1025
  //#endregion
424
1026
  export { PageTree };