camox 0.74.1 → 0.76.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 (32) hide show
  1. package/dist/core/lib/artifactRuntime.js +4 -2
  2. package/dist/features/provider/AuthenticatedCamoxProvider.js +75 -63
  3. package/dist/features/renderer/RendererFrames.js +47 -41
  4. package/dist/features/routes/pageRuntime.d.ts +6 -4
  5. package/dist/features/routes/pageRuntime.js +5 -1
  6. package/dist/features/studio/components/ChatWidget.js +137 -121
  7. package/dist/features/studio/components/ClearThread.js +121 -0
  8. package/dist/features/studio/components/DeleteDraftDialog.js +67 -65
  9. package/dist/features/studio/components/DraftBar.js +60 -49
  10. package/dist/features/studio/components/DraftNotices.js +149 -0
  11. package/dist/features/studio/components/DraftsControl.js +217 -180
  12. package/dist/features/studio/components/DraftsSheet.js +387 -0
  13. package/dist/features/studio/components/PublishedTab.js +511 -0
  14. package/dist/features/studio/components/ReviewDraftDialog.js +104 -89
  15. package/dist/features/studio/components/SheetTable.js +46 -0
  16. package/dist/features/studio/components/Specialists.js +1 -1
  17. package/dist/features/studio/components/ThreadMessages.js +376 -171
  18. package/dist/features/studio/draftLabel.js +15 -1
  19. package/dist/features/studio/draftNotice.js +1 -0
  20. package/dist/features/studio/studioStore.js +5 -5
  21. package/dist/features/studio/useArchiveDraft.js +60 -0
  22. package/dist/features/studio/useRestoreDraft.js +70 -0
  23. package/dist/features/studio/viewSwitch.js +19 -11
  24. package/dist/lib/draft-scope.d.ts +1 -1
  25. package/dist/lib/draft-scope.js +6 -3
  26. package/dist/lib/queries.js +12 -1
  27. package/dist/lib/studio-reads.js +22 -0
  28. package/dist/lib/use-project-room.js +19 -13
  29. package/dist/lib/use-thread.js +1 -1
  30. package/dist/package.js +1 -1
  31. package/dist/studio.css +1 -1
  32. package/package.json +4 -4
@@ -5,13 +5,14 @@ import { reads, useReadQuery } from "../../../lib/studio-reads.js";
5
5
  import { cn } from "../../../lib/utils.js";
6
6
  import { BOTTOM_CARD_EDGES, CARD_BODY_EDGES } from "../../preview/components/SidebarStack.js";
7
7
  import { studioStore } from "../studioStore.js";
8
+ import { useRestoreDraft } from "../useRestoreDraft.js";
9
+ import { ThreadMessages } from "./ThreadMessages.js";
8
10
  import { FollowAgentContext } from "../followAgentContext.js";
9
11
  import { useThread } from "../../../lib/use-thread.js";
10
12
  import { useAgentRunToast } from "../agentRunToast.js";
11
13
  import { EditorWhereContext } from "../editorWhereContext.js";
12
14
  import { useEditorSelection } from "../useEditorSelection.js";
13
15
  import { ThreadComposer, useComposerCarrier } from "./ThreadComposer.js";
14
- import { ThreadMessages } from "./ThreadMessages.js";
15
16
  import { c } from "react/compiler-runtime";
16
17
  import * as React from "react";
17
18
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -24,9 +25,10 @@ import { EMPTY_THREAD_VIEW } from "@camox/api-contract/threads";
24
25
  * studio it is only hidden: the studio keeps following the editor's runs there. It follows
25
26
  * where the studio is: the editor's own Live thread on Live, and the draft's thread in a draft.
26
27
  * When the agent on Live hands the editor's request off to a draft, the studio that asked enters
27
- * it, if it still shows Live; the card the Live turn ends on opens it too. Each message tells the
28
- * agent where the editor is: the page they look at, with what they selected on it unless they
29
- * cleared it from the composer, or the Canvas with no page selected. A message the studio sends
28
+ * it, if it still shows Live; the card the Live turn ends on opens it too, or restores it once
29
+ * it's archived. Each message tells the agent where the editor is: the page they look at, with
30
+ * what they selected on it unless they cleared it from the composer, or the Canvas with no page
31
+ * selected. A message the studio sends
30
32
  * from elsewhere (`studioStore`'s `sendToAgent`), such as Fix with agent's, goes out through the
31
33
  * thread it follows, as if the editor had sent it. In a draft, it tells the studio whether a turn
32
34
  * is going in the draft's thread, whoever started it, which publishing waits for.
@@ -135,7 +137,7 @@ function CurrentThread() {
135
137
  return t4;
136
138
  }
137
139
  function Thread(t0) {
138
- const $ = c(48);
140
+ const $ = c(52);
139
141
  const { apiUrl, projectId, draftId, onEnterDraft, onOpenDraft, composerCarry } = t0;
140
142
  let t1;
141
143
  if ($[0] !== onEnterDraft) {
@@ -145,10 +147,22 @@ function Thread(t0) {
145
147
  } else t1 = $[1];
146
148
  const { view, sending, send, stop, error, touched } = useThread(apiUrl, projectId, draftId, t1);
147
149
  useAgentRunToast(view, draftId);
150
+ const { restore } = useRestoreDraft(projectId);
148
151
  let t2;
152
+ if ($[2] !== restore || $[3] !== view.messages) {
153
+ t2 = (restored) => {
154
+ const card = view.messages.find((message) => message.from === "draft" && message.draftId === restored);
155
+ restore(restored, card?.from === "draft" ? card.name : void 0);
156
+ };
157
+ $[2] = restore;
158
+ $[3] = view.messages;
159
+ $[4] = t2;
160
+ } else t2 = $[4];
161
+ const restoreCard = t2;
149
162
  let t3;
150
- if ($[2] !== draftId || $[3] !== view.running) {
151
- t2 = () => {
163
+ let t4;
164
+ if ($[5] !== draftId || $[6] !== view.running) {
165
+ t3 = () => {
152
166
  if (!draftId) return;
153
167
  studioStore.trigger.agentWorking({
154
168
  draftId,
@@ -159,167 +173,169 @@ function Thread(t0) {
159
173
  working: false
160
174
  });
161
175
  };
162
- t3 = [draftId, view.running];
163
- $[2] = draftId;
164
- $[3] = view.running;
165
- $[4] = t2;
166
- $[5] = t3;
176
+ t4 = [draftId, view.running];
177
+ $[5] = draftId;
178
+ $[6] = view.running;
179
+ $[7] = t3;
180
+ $[8] = t4;
167
181
  } else {
168
- t2 = $[4];
169
- t3 = $[5];
182
+ t3 = $[7];
183
+ t4 = $[8];
170
184
  }
171
- React.useEffect(t2, t3);
185
+ React.useEffect(t3, t4);
172
186
  const follow = React.use(FollowAgentContext);
173
- let t4;
174
- if ($[6] !== follow) {
175
- t4 = (batch) => follow?.receive(batch);
176
- $[6] = follow;
177
- $[7] = t4;
178
- } else t4 = $[7];
179
- const followTouched = React.useEffectEvent(t4);
180
187
  let t5;
181
- if ($[8] !== followTouched || $[9] !== touched) {
182
- t5 = () => {
183
- if (touched) followTouched(touched.batch);
184
- };
185
- $[8] = followTouched;
186
- $[9] = touched;
188
+ if ($[9] !== follow) {
189
+ t5 = (batch) => follow?.receive(batch);
190
+ $[9] = follow;
187
191
  $[10] = t5;
188
192
  } else t5 = $[10];
193
+ const followTouched = React.useEffectEvent(t5);
189
194
  let t6;
190
- if ($[11] !== touched) {
191
- t6 = [touched];
192
- $[11] = touched;
193
- $[12] = t6;
194
- } else t6 = $[12];
195
- React.useEffect(t5, t6);
195
+ if ($[11] !== followTouched || $[12] !== touched) {
196
+ t6 = () => {
197
+ if (touched) followTouched(touched.batch);
198
+ };
199
+ $[11] = followTouched;
200
+ $[12] = touched;
201
+ $[13] = t6;
202
+ } else t6 = $[13];
203
+ let t7;
204
+ if ($[14] !== touched) {
205
+ t7 = [touched];
206
+ $[14] = touched;
207
+ $[15] = t7;
208
+ } else t7 = $[15];
209
+ React.useEffect(t6, t7);
196
210
  const where = React.use(EditorWhereContext);
197
211
  const selection = useEditorSelection(where);
198
- let t7;
199
- if ($[13] !== selection) {
200
- t7 = selection ? JSON.stringify([
212
+ let t8;
213
+ if ($[16] !== selection) {
214
+ t8 = selection ? JSON.stringify([
201
215
  selection.blockId,
202
216
  selection.itemId,
203
217
  selection.recordId,
204
218
  selection.fieldName
205
219
  ]) : null;
206
- $[13] = selection;
207
- $[14] = t7;
208
- } else t7 = $[14];
209
- const selectionKey = t7;
220
+ $[16] = selection;
221
+ $[17] = t8;
222
+ } else t8 = $[17];
223
+ const selectionKey = t8;
210
224
  const [cleared, setCleared] = React.useState(null);
211
225
  if (cleared !== null && selectionKey !== cleared) setCleared(null);
212
226
  const carried = selection && selectionKey !== cleared ? selection : void 0;
213
- let t8;
214
- if ($[15] !== carried || $[16] !== follow || $[17] !== send || $[18] !== where) {
215
- t8 = (text) => {
227
+ let t9;
228
+ if ($[18] !== carried || $[19] !== follow || $[20] !== send || $[21] !== where) {
229
+ t9 = (text) => {
216
230
  follow?.resume();
217
231
  send(text, where?.on === "page" && carried ? {
218
232
  ...where,
219
233
  selection: carried
220
234
  } : where);
221
235
  };
222
- $[15] = carried;
223
- $[16] = follow;
224
- $[17] = send;
225
- $[18] = where;
226
- $[19] = t8;
227
- } else t8 = $[19];
228
- const sendFollowing = t8;
236
+ $[18] = carried;
237
+ $[19] = follow;
238
+ $[20] = send;
239
+ $[21] = where;
240
+ $[22] = t9;
241
+ } else t9 = $[22];
242
+ const sendFollowing = t9;
229
243
  const waiting = useSelector(studioStore, _temp);
230
- let t9;
231
- if ($[20] !== sendFollowing) {
232
- t9 = () => {
233
- for (const message of studioStore.getSnapshot().context.agentMessages) {
234
- studioStore.trigger.takeAgentMessage({ id: message.id });
235
- sendFollowing(message.text);
236
- }
237
- };
238
- $[20] = sendFollowing;
239
- $[21] = t9;
240
- } else t9 = $[21];
241
- const sendWaiting = React.useEffectEvent(t9);
242
244
  let t10;
243
- if ($[22] !== sendWaiting || $[23] !== waiting) {
245
+ if ($[23] !== sendFollowing) {
244
246
  t10 = () => {
245
- if (waiting.length > 0) sendWaiting();
247
+ for (const message_0 of studioStore.getSnapshot().context.agentMessages) {
248
+ studioStore.trigger.takeAgentMessage({ id: message_0.id });
249
+ sendFollowing(message_0.text);
250
+ }
246
251
  };
247
- $[22] = sendWaiting;
248
- $[23] = waiting;
252
+ $[23] = sendFollowing;
249
253
  $[24] = t10;
250
254
  } else t10 = $[24];
255
+ const sendWaiting = React.useEffectEvent(t10);
251
256
  let t11;
252
- if ($[25] !== waiting) {
253
- t11 = [waiting];
254
- $[25] = waiting;
255
- $[26] = t11;
256
- } else t11 = $[26];
257
- React.useEffect(t10, t11);
257
+ if ($[25] !== sendWaiting || $[26] !== waiting) {
258
+ t11 = () => {
259
+ if (waiting.length > 0) sendWaiting();
260
+ };
261
+ $[25] = sendWaiting;
262
+ $[26] = waiting;
263
+ $[27] = t11;
264
+ } else t11 = $[27];
258
265
  let t12;
259
- if ($[27] !== onOpenDraft || $[28] !== sending || $[29] !== view) {
260
- t12 = /* @__PURE__ */ jsx(ThreadMessages, {
266
+ if ($[28] !== waiting) {
267
+ t12 = [waiting];
268
+ $[28] = waiting;
269
+ $[29] = t12;
270
+ } else t12 = $[29];
271
+ React.useEffect(t11, t12);
272
+ let t13;
273
+ if ($[30] !== onOpenDraft || $[31] !== restoreCard || $[32] !== sending || $[33] !== view) {
274
+ t13 = /* @__PURE__ */ jsx(ThreadMessages, {
261
275
  view,
262
276
  sending,
263
- onOpenDraft
277
+ onOpenDraft,
278
+ onRestoreDraft: restoreCard
264
279
  });
265
- $[27] = onOpenDraft;
266
- $[28] = sending;
267
- $[29] = view;
268
- $[30] = t12;
269
- } else t12 = $[30];
270
- let t13;
271
- if ($[31] !== error) {
272
- t13 = error && /* @__PURE__ */ jsx("p", {
280
+ $[30] = onOpenDraft;
281
+ $[31] = restoreCard;
282
+ $[32] = sending;
283
+ $[33] = view;
284
+ $[34] = t13;
285
+ } else t13 = $[34];
286
+ let t14;
287
+ if ($[35] !== error) {
288
+ t14 = error && /* @__PURE__ */ jsx("p", {
273
289
  role: "alert",
274
290
  className: "text-destructive px-2 pt-2 text-sm",
275
291
  children: error
276
292
  });
277
- $[31] = error;
278
- $[32] = t13;
279
- } else t13 = $[32];
280
- let t14;
281
- if ($[33] !== carried?.path) {
282
- t14 = carried?.path.at(-1);
283
- $[33] = carried?.path;
284
- $[34] = t14;
285
- } else t14 = $[34];
293
+ $[35] = error;
294
+ $[36] = t14;
295
+ } else t14 = $[36];
286
296
  let t15;
287
- if ($[35] !== selectionKey) {
288
- t15 = () => selectionKey !== null && setCleared(selectionKey);
289
- $[35] = selectionKey;
290
- $[36] = t15;
291
- } else t15 = $[36];
297
+ if ($[37] !== carried?.path) {
298
+ t15 = carried?.path.at(-1);
299
+ $[37] = carried?.path;
300
+ $[38] = t15;
301
+ } else t15 = $[38];
292
302
  let t16;
293
- if ($[37] !== composerCarry || $[38] !== sendFollowing || $[39] !== stop || $[40] !== t14 || $[41] !== t15 || $[42] !== view.running) {
294
- t16 = /* @__PURE__ */ jsx(ThreadComposer, {
303
+ if ($[39] !== selectionKey) {
304
+ t16 = () => selectionKey !== null && setCleared(selectionKey);
305
+ $[39] = selectionKey;
306
+ $[40] = t16;
307
+ } else t16 = $[40];
308
+ let t17;
309
+ if ($[41] !== composerCarry || $[42] !== sendFollowing || $[43] !== stop || $[44] !== t15 || $[45] !== t16 || $[46] !== view.running) {
310
+ t17 = /* @__PURE__ */ jsx(ThreadComposer, {
295
311
  onSend: sendFollowing,
296
312
  onStop: stop,
297
- selection: t14,
298
- onClearSelection: t15,
313
+ selection: t15,
314
+ onClearSelection: t16,
299
315
  running: view.running,
300
316
  carry: composerCarry
301
317
  });
302
- $[37] = composerCarry;
303
- $[38] = sendFollowing;
304
- $[39] = stop;
305
- $[40] = t14;
306
- $[41] = t15;
307
- $[42] = view.running;
308
- $[43] = t16;
309
- } else t16 = $[43];
310
- let t17;
311
- if ($[44] !== t12 || $[45] !== t13 || $[46] !== t16) {
312
- t17 = /* @__PURE__ */ jsxs(Fragment, { children: [
313
- t12,
314
- t13,
315
- t16
316
- ] });
317
- $[44] = t12;
318
- $[45] = t13;
319
- $[46] = t16;
318
+ $[41] = composerCarry;
319
+ $[42] = sendFollowing;
320
+ $[43] = stop;
321
+ $[44] = t15;
322
+ $[45] = t16;
323
+ $[46] = view.running;
320
324
  $[47] = t17;
321
325
  } else t17 = $[47];
322
- return t17;
326
+ let t18;
327
+ if ($[48] !== t13 || $[49] !== t14 || $[50] !== t17) {
328
+ t18 = /* @__PURE__ */ jsxs(Fragment, { children: [
329
+ t13,
330
+ t14,
331
+ t17
332
+ ] });
333
+ $[48] = t13;
334
+ $[49] = t14;
335
+ $[50] = t17;
336
+ $[51] = t18;
337
+ } else t18 = $[51];
338
+ return t18;
323
339
  }
324
340
  function _temp(state) {
325
341
  return state.context.agentMessages;
@@ -0,0 +1,121 @@
1
+ import { publicationMutations } from "../../../lib/queries.js";
2
+ import { c } from "react/compiler-runtime";
3
+ import * as React from "react";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { useMutation } from "@tanstack/react-query";
6
+ import { Button } from "@camox/ui/button";
7
+ import { toast } from "@camox/ui/toaster";
8
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
9
+ import { Spinner } from "@camox/ui/spinner";
10
+
11
+ //#region src/features/studio/components/ClearThread.tsx
12
+ /**
13
+ * Clear thread, for a Publication's thread a secret was pasted into: asks first, then wipes the
14
+ * thread for good. The Publication stays, so it can still be reverted (ADR 0045).
15
+ */
16
+ function ClearThread(t0) {
17
+ const $ = c(24);
18
+ const { projectId, id } = t0;
19
+ const [open, setOpen] = React.useState(false);
20
+ let t1;
21
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
22
+ t1 = {
23
+ ...publicationMutations.clearThread(),
24
+ onSuccess: () => setOpen(false),
25
+ onError: _temp
26
+ };
27
+ $[0] = t1;
28
+ } else t1 = $[0];
29
+ const clearThread = useMutation(t1);
30
+ let t2;
31
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
32
+ t2 = /* @__PURE__ */ jsx(Button, {
33
+ type: "button",
34
+ variant: "ghost",
35
+ size: "sm",
36
+ onClick: () => setOpen(true),
37
+ children: "Clear thread"
38
+ });
39
+ $[1] = t2;
40
+ } else t2 = $[1];
41
+ let t3;
42
+ if ($[2] !== clearThread.isPending) {
43
+ t3 = (next) => {
44
+ if (!clearThread.isPending) setOpen(next);
45
+ };
46
+ $[2] = clearThread.isPending;
47
+ $[3] = t3;
48
+ } else t3 = $[3];
49
+ let t4;
50
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t4 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Clear this thread?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Its messages are deleted for everyone, for good. What was published, and what it replaced, stay. This can't be undone." })] });
52
+ $[4] = t4;
53
+ } else t4 = $[4];
54
+ let t5;
55
+ if ($[5] !== clearThread.isPending) {
56
+ t5 = /* @__PURE__ */ jsx(AlertDialogCancel, {
57
+ variant: "outline",
58
+ size: "default",
59
+ disabled: clearThread.isPending,
60
+ children: "Cancel"
61
+ });
62
+ $[5] = clearThread.isPending;
63
+ $[6] = t5;
64
+ } else t5 = $[6];
65
+ let t6;
66
+ if ($[7] !== clearThread || $[8] !== id || $[9] !== projectId) {
67
+ t6 = () => clearThread.mutate({
68
+ projectId,
69
+ id
70
+ });
71
+ $[7] = clearThread;
72
+ $[8] = id;
73
+ $[9] = projectId;
74
+ $[10] = t6;
75
+ } else t6 = $[10];
76
+ let t7;
77
+ if ($[11] !== clearThread.isPending) {
78
+ t7 = clearThread.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
79
+ $[11] = clearThread.isPending;
80
+ $[12] = t7;
81
+ } else t7 = $[12];
82
+ let t8;
83
+ if ($[13] !== clearThread.isPending || $[14] !== t6 || $[15] !== t7) {
84
+ t8 = /* @__PURE__ */ jsxs(AlertDialogAction, {
85
+ variant: "destructive",
86
+ disabled: clearThread.isPending,
87
+ onClick: t6,
88
+ children: [t7, "Clear thread"]
89
+ });
90
+ $[13] = clearThread.isPending;
91
+ $[14] = t6;
92
+ $[15] = t7;
93
+ $[16] = t8;
94
+ } else t8 = $[16];
95
+ let t9;
96
+ if ($[17] !== t5 || $[18] !== t8) {
97
+ t9 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t4, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t5, t8] })] });
98
+ $[17] = t5;
99
+ $[18] = t8;
100
+ $[19] = t9;
101
+ } else t9 = $[19];
102
+ let t10;
103
+ if ($[20] !== open || $[21] !== t3 || $[22] !== t9) {
104
+ t10 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, /* @__PURE__ */ jsx(AlertDialog, {
105
+ open,
106
+ onOpenChange: t3,
107
+ children: t9
108
+ })] });
109
+ $[20] = open;
110
+ $[21] = t3;
111
+ $[22] = t9;
112
+ $[23] = t10;
113
+ } else t10 = $[23];
114
+ return t10;
115
+ }
116
+ function _temp(error) {
117
+ return toast.error(error.message || "Could not clear the thread");
118
+ }
119
+
120
+ //#endregion
121
+ export { ClearThread };
@@ -7,102 +7,104 @@ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent,
7
7
  import { Spinner } from "@camox/ui/spinner";
8
8
 
9
9
  //#region src/features/studio/components/DeleteDraftDialog.tsx
10
- /** Asks before deleting the draft the studio is in, then deletes it. */
10
+ /** Asks before deleting an archived draft for good, then deletes it (ADR 0046). */
11
11
  function DeleteDraftDialog(t0) {
12
12
  const $ = c(26);
13
- const { projectId, open, onOpenChange, onDeleted } = t0;
13
+ const { projectId, draftId, onOpenChange } = t0;
14
14
  let t1;
15
15
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
16
16
  t1 = draftMutations.delete();
17
17
  $[0] = t1;
18
18
  } else t1 = $[0];
19
19
  let t2;
20
- if ($[1] !== onDeleted || $[2] !== onOpenChange) {
20
+ if ($[1] !== onOpenChange) {
21
21
  t2 = {
22
22
  ...t1,
23
- onSuccess: (t3) => {
24
- const { ended } = t3;
25
- onOpenChange(false);
26
- onDeleted(ended);
27
- },
23
+ onSuccess: () => onOpenChange(false),
28
24
  onError: _temp
29
25
  };
30
- $[1] = onDeleted;
31
- $[2] = onOpenChange;
32
- $[3] = t2;
33
- } else t2 = $[3];
26
+ $[1] = onOpenChange;
27
+ $[2] = t2;
28
+ } else t2 = $[2];
34
29
  const deleteDraft = useMutation(t2);
35
- let t3;
36
- if ($[4] !== deleteDraft.isPending || $[5] !== onOpenChange) {
37
- t3 = (next) => {
30
+ const t3 = draftId !== null;
31
+ let t4;
32
+ if ($[3] !== deleteDraft.isPending || $[4] !== onOpenChange) {
33
+ t4 = (next) => {
38
34
  if (!deleteDraft.isPending) onOpenChange(next);
39
35
  };
40
- $[4] = deleteDraft.isPending;
41
- $[5] = onOpenChange;
42
- $[6] = t3;
43
- } else t3 = $[6];
44
- let t4;
45
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
46
- t4 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete this draft?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Every change in this draft is deleted for everyone. Live stays as it is. This can't be undone." })] });
47
- $[7] = t4;
48
- } else t4 = $[7];
36
+ $[3] = deleteDraft.isPending;
37
+ $[4] = onOpenChange;
38
+ $[5] = t4;
39
+ } else t4 = $[5];
49
40
  let t5;
50
- if ($[8] !== deleteDraft.isPending) {
51
- t5 = /* @__PURE__ */ jsx(AlertDialogCancel, {
41
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
42
+ t5 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete this draft?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Its changes, its thread and its code are deleted for everyone. Live stays as it is. This can't be undone." })] });
43
+ $[6] = t5;
44
+ } else t5 = $[6];
45
+ let t6;
46
+ if ($[7] !== deleteDraft.isPending) {
47
+ t6 = /* @__PURE__ */ jsx(AlertDialogCancel, {
52
48
  variant: "outline",
53
49
  size: "default",
54
50
  disabled: deleteDraft.isPending,
55
51
  children: "Cancel"
56
52
  });
57
- $[8] = deleteDraft.isPending;
58
- $[9] = t5;
59
- } else t5 = $[9];
60
- let t6;
61
- if ($[10] !== deleteDraft || $[11] !== projectId) {
62
- t6 = () => deleteDraft.mutate({ projectId });
63
- $[10] = deleteDraft;
64
- $[11] = projectId;
65
- $[12] = t6;
66
- } else t6 = $[12];
53
+ $[7] = deleteDraft.isPending;
54
+ $[8] = t6;
55
+ } else t6 = $[8];
67
56
  let t7;
57
+ if ($[9] !== deleteDraft || $[10] !== draftId || $[11] !== projectId) {
58
+ t7 = () => {
59
+ if (draftId) deleteDraft.mutate({
60
+ projectId,
61
+ draftId
62
+ });
63
+ };
64
+ $[9] = deleteDraft;
65
+ $[10] = draftId;
66
+ $[11] = projectId;
67
+ $[12] = t7;
68
+ } else t7 = $[12];
69
+ let t8;
68
70
  if ($[13] !== deleteDraft.isPending) {
69
- t7 = deleteDraft.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
71
+ t8 = deleteDraft.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
70
72
  $[13] = deleteDraft.isPending;
71
- $[14] = t7;
72
- } else t7 = $[14];
73
- let t8;
74
- if ($[15] !== deleteDraft.isPending || $[16] !== t6 || $[17] !== t7) {
75
- t8 = /* @__PURE__ */ jsxs(AlertDialogAction, {
73
+ $[14] = t8;
74
+ } else t8 = $[14];
75
+ let t9;
76
+ if ($[15] !== deleteDraft.isPending || $[16] !== t7 || $[17] !== t8) {
77
+ t9 = /* @__PURE__ */ jsxs(AlertDialogAction, {
76
78
  variant: "destructive",
77
79
  disabled: deleteDraft.isPending,
78
- onClick: t6,
79
- children: [t7, "Delete draft"]
80
+ onClick: t7,
81
+ children: [t8, "Delete draft"]
80
82
  });
81
83
  $[15] = deleteDraft.isPending;
82
- $[16] = t6;
83
- $[17] = t7;
84
- $[18] = t8;
85
- } else t8 = $[18];
86
- let t9;
87
- if ($[19] !== t5 || $[20] !== t8) {
88
- t9 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t4, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t5, t8] })] });
89
- $[19] = t5;
90
- $[20] = t8;
91
- $[21] = t9;
92
- } else t9 = $[21];
84
+ $[16] = t7;
85
+ $[17] = t8;
86
+ $[18] = t9;
87
+ } else t9 = $[18];
93
88
  let t10;
94
- if ($[22] !== open || $[23] !== t3 || $[24] !== t9) {
95
- t10 = /* @__PURE__ */ jsx(AlertDialog, {
96
- open,
97
- onOpenChange: t3,
98
- children: t9
89
+ if ($[19] !== t6 || $[20] !== t9) {
90
+ t10 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t5, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t6, t9] })] });
91
+ $[19] = t6;
92
+ $[20] = t9;
93
+ $[21] = t10;
94
+ } else t10 = $[21];
95
+ let t11;
96
+ if ($[22] !== t10 || $[23] !== t3 || $[24] !== t4) {
97
+ t11 = /* @__PURE__ */ jsx(AlertDialog, {
98
+ open: t3,
99
+ onOpenChange: t4,
100
+ children: t10
99
101
  });
100
- $[22] = open;
102
+ $[22] = t10;
101
103
  $[23] = t3;
102
- $[24] = t9;
103
- $[25] = t10;
104
- } else t10 = $[25];
105
- return t10;
104
+ $[24] = t4;
105
+ $[25] = t11;
106
+ } else t11 = $[25];
107
+ return t11;
106
108
  }
107
109
  function _temp(error) {
108
110
  return toast.error(error.message || "Could not delete the draft");