camox 0.63.0 → 0.66.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 (60) hide show
  1. package/dist/core/createApp.d.ts +28 -28
  2. package/dist/core/createLayout.d.ts +1 -1
  3. package/dist/core/derivedRoutes.js +3 -30
  4. package/dist/core/editing/createEditableBlock.d.ts +604 -604
  5. package/dist/features/canvas/CamoxCanvas.js +195 -173
  6. package/dist/features/canvas/canvasCamera.js +11 -2
  7. package/dist/features/canvas/canvasFrameCapture.js +5 -12
  8. package/dist/features/canvas/canvasFrameDocument.js +90 -29
  9. package/dist/features/canvas/canvasItems.js +22 -6
  10. package/dist/features/canvas/sidebar/ContentSidebar.js +19 -21
  11. package/dist/features/canvas/sidebar/LayoutPageOverview.js +22 -49
  12. package/dist/features/canvas/sidebar/LayoutPageSeo.js +73 -76
  13. package/dist/features/canvas/sidebar/PageInspector.js +61 -50
  14. package/dist/features/canvas/sidebar/PageInspectorSkeleton.js +4 -4
  15. package/dist/features/canvas/useCanvasCamera.js +36 -15
  16. package/dist/features/page/CuratedPageContent.js +2 -1
  17. package/dist/features/page/UnplacedBlockContent.js +52 -0
  18. package/dist/features/preview/components/PageInfo.js +103 -100
  19. package/dist/features/preview/components/PreviewPanel.js +40 -12
  20. package/dist/features/preview/components/SidebarStack.js +78 -9
  21. package/dist/features/preview/strayCaretGuard.js +34 -0
  22. package/dist/features/provider/CoreCamoxProvider.js +5 -3
  23. package/dist/features/routes/pageRuntime.d.ts +2 -0
  24. package/dist/features/routes/pageRuntime.js +8 -5
  25. package/dist/features/runtime/RuntimeChrome.js +66 -40
  26. package/dist/features/runtime/pageApp.js +111 -74
  27. package/dist/features/runtime/pageClient.js +22 -2
  28. package/dist/features/runtime/runtime.d.ts +10 -0
  29. package/dist/features/runtime/runtime.js +314 -4
  30. package/dist/features/runtime/runtimeRoutes.d.ts +5 -0
  31. package/dist/features/runtime/runtimeRoutes.js +5 -0
  32. package/dist/features/studio/components/AgentSidebar.js +3 -3
  33. package/dist/features/studio/components/ChatWidget.js +106 -75
  34. package/dist/features/studio/components/ConnectAgent.js +313 -0
  35. package/dist/features/studio/components/DraftsControl.js +172 -159
  36. package/dist/features/studio/components/Patrol.js +605 -350
  37. package/dist/features/studio/components/ReviewDraftSheet.js +566 -430
  38. package/dist/features/studio/components/Squareling.js +74 -41
  39. package/dist/features/studio/components/ThreadComposer.js +192 -107
  40. package/dist/features/studio/components/ThreadMessages.js +95 -18
  41. package/dist/features/studio/components/UnnamedDraftBar.js +349 -0
  42. package/dist/features/studio/components/clientLogoPaths.js +10 -0
  43. package/dist/features/studio/findingSentence.js +37 -0
  44. package/dist/features/studio/patrollerBio.js +40 -0
  45. package/dist/features/studio/reportSentence.js +15 -0
  46. package/dist/features/studio/studioStore.js +36 -1
  47. package/dist/features/studio/workingSentence.js +10 -7
  48. package/dist/lib/api-client.d.ts +1 -0
  49. package/dist/lib/auth.js +34 -32
  50. package/dist/lib/queries.js +9 -1
  51. package/dist/lib/revisions.js +25 -3
  52. package/dist/lib/server-auth-cookie.js +17 -4
  53. package/dist/lib/studio-reads.d.ts +1 -1
  54. package/dist/lib/studio-reads.js +5 -1
  55. package/dist/lib/use-thread.js +1 -1
  56. package/dist/package.js +1 -1
  57. package/dist/studio.css +1 -1
  58. package/package.json +15 -4
  59. package/dist/features/canvas/sidebar/DerivedPageInspector.js +0 -49
  60. package/dist/features/canvas/sidebar/SingletonPageInspector.js +0 -39
@@ -2,19 +2,21 @@ import { useDraftScope } from "../../../lib/draft-scope.js";
2
2
  import { reads, useReadQuery, useStudioCache } from "../../../lib/studio-reads.js";
3
3
  import { cn } from "../../../lib/utils.js";
4
4
  import { getDraftReadClient } from "../../../lib/api-client.js";
5
- import { draftMutations } from "../../../lib/queries.js";
5
+ import { draftMutations, patrolMutations } from "../../../lib/queries.js";
6
6
  import { previewStore } from "../../preview/previewStore.js";
7
+ import { studioStore } from "../studioStore.js";
7
8
  import { localeLabel } from "../localeOptions.js";
8
9
  import { draftLabel, plural, timeAgo } from "../draftLabel.js";
10
+ import { askAgentMessage, findingSentence, fixLabel } from "../findingSentence.js";
9
11
  import { useShowInCanvas } from "../showInCanvas.js";
10
12
  import { c } from "react/compiler-runtime";
11
13
  import * as React from "react";
12
- import { CONFLICTS_CHANGED_ERROR, REVISION_CHANGED_ERROR, TRANSLATIONS_PENDING_ERROR } from "@camox/api-contract/drafts";
14
+ import { CHECKS_RUNNING_ERROR, CONFLICTS_CHANGED_ERROR, FINDINGS_OPEN_ERROR, REVISION_CHANGED_ERROR, TRANSLATIONS_PENDING_ERROR } from "@camox/api-contract/drafts";
13
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
16
  import { useMutation } from "@tanstack/react-query";
15
17
  import { Button } from "@camox/ui/button";
16
18
  import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@camox/ui/sheet";
17
- import { CircleCheck, OctagonX, Replace, Trash2, TriangleAlert, Unlink } from "lucide-react";
19
+ import { CircleAlert, CircleCheck, OctagonX, Replace, Trash2, TriangleAlert, Unlink } from "lucide-react";
18
20
  import { toast } from "@camox/ui/toaster";
19
21
  import { Skeleton } from "@camox/ui/skeleton";
20
22
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
@@ -77,7 +79,6 @@ function blockerActionLabel(problem) {
77
79
  case "unacceptedFileType": return isImage(problem) ? "Choose another image" : "Choose another file";
78
80
  case "emptyRequiredReference": return "Choose a record";
79
81
  case "danglingReference": return "Choose another record";
80
- case "danglingPageLink": return "Fix the link";
81
82
  case "duplicatePath": return "Fix the path";
82
83
  case "missingMetaTitle": return "Write a meta title";
83
84
  default: return "Show in Canvas";
@@ -144,7 +145,7 @@ function Card(t0) {
144
145
  } else t6 = $[8];
145
146
  let t7;
146
147
  if ($[9] !== children) {
147
- t7 = /* @__PURE__ */ jsx("div", {
148
+ t7 = children && /* @__PURE__ */ jsx("div", {
148
149
  className: "text-muted-foreground text-sm",
149
150
  children
150
151
  });
@@ -248,6 +249,138 @@ function ProblemCards({ problems, tone, icon, onShow, onOpenThread }) {
248
249
  }, `shared:${message}`)];
249
250
  });
250
251
  }
252
+ /** Where the Canvas shows a finding: its block or item on its page. */
253
+ function findingTarget(finding) {
254
+ const { place } = finding;
255
+ if (place?.kind !== "page") return null;
256
+ return {
257
+ pageId: place.pageId,
258
+ locale: finding.locale,
259
+ blockId: place.blockId,
260
+ itemId: place.itemId,
261
+ field: place.blockId ? {
262
+ name: finding.field,
263
+ kind: null
264
+ } : null
265
+ };
266
+ }
267
+ /**
268
+ * One card per open finding of the draft, which holds its publish (ADR 0033), with the Patrol's
269
+ * actions: show it in the Canvas, apply its fix, or dismiss it.
270
+ */
271
+ function FindingCards(t0) {
272
+ const $ = c(19);
273
+ const { projectId, findings, onChanged, onShow } = t0;
274
+ let t1;
275
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
276
+ t1 = patrolMutations.applyFix();
277
+ $[0] = t1;
278
+ } else t1 = $[0];
279
+ let t2;
280
+ if ($[1] !== onChanged) {
281
+ t2 = {
282
+ ...t1,
283
+ onSuccess: (t3) => {
284
+ const { applied } = t3;
285
+ if (!applied) toast.info("The text changed since it was checked, so it's being checked again.");
286
+ onChanged();
287
+ },
288
+ onError: _temp
289
+ };
290
+ $[1] = onChanged;
291
+ $[2] = t2;
292
+ } else t2 = $[2];
293
+ const applyFix = useMutation(t2);
294
+ let t3;
295
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
296
+ t3 = patrolMutations.dismissFinding();
297
+ $[3] = t3;
298
+ } else t3 = $[3];
299
+ let t4;
300
+ if ($[4] !== onChanged) {
301
+ t4 = {
302
+ ...t3,
303
+ onSuccess: onChanged,
304
+ onError: _temp2
305
+ };
306
+ $[4] = onChanged;
307
+ $[5] = t4;
308
+ } else t4 = $[5];
309
+ const dismiss = useMutation(t4);
310
+ const busy = applyFix.isPending || dismiss.isPending;
311
+ let t5;
312
+ if ($[6] !== applyFix || $[7] !== busy || $[8] !== dismiss || $[9] !== findings || $[10] !== onShow || $[11] !== projectId) {
313
+ let t6;
314
+ if ($[13] !== applyFix || $[14] !== busy || $[15] !== dismiss || $[16] !== onShow || $[17] !== projectId) {
315
+ t6 = (finding) => {
316
+ const target = findingTarget(finding);
317
+ return /* @__PURE__ */ jsx(Card, {
318
+ tone: "danger",
319
+ icon: CircleAlert,
320
+ title: findingSentence(finding),
321
+ action: /* @__PURE__ */ jsxs("span", {
322
+ className: "flex flex-wrap gap-1",
323
+ children: [
324
+ target && /* @__PURE__ */ jsx(Button, {
325
+ variant: "outline",
326
+ size: "sm",
327
+ onClick: () => onShow(target),
328
+ children: "Show"
329
+ }),
330
+ finding.fix && /* @__PURE__ */ jsx(Button, {
331
+ variant: "outline",
332
+ size: "sm",
333
+ disabled: busy,
334
+ onClick: () => applyFix.mutate({
335
+ projectId,
336
+ findingId: finding.id
337
+ }),
338
+ children: fixLabel(finding.fix)
339
+ }),
340
+ /* @__PURE__ */ jsx(Button, {
341
+ variant: "outline",
342
+ size: "sm",
343
+ onClick: () => studioStore.trigger.askAgent({ text: askAgentMessage(finding, finding.patroller.role) }),
344
+ children: "Ask the agent"
345
+ }),
346
+ /* @__PURE__ */ jsx(Button, {
347
+ variant: "ghost",
348
+ size: "sm",
349
+ disabled: busy,
350
+ onClick: () => dismiss.mutate({
351
+ projectId,
352
+ findingId: finding.id
353
+ }),
354
+ children: "Dismiss"
355
+ })
356
+ ]
357
+ })
358
+ }, finding.id);
359
+ };
360
+ $[13] = applyFix;
361
+ $[14] = busy;
362
+ $[15] = dismiss;
363
+ $[16] = onShow;
364
+ $[17] = projectId;
365
+ $[18] = t6;
366
+ } else t6 = $[18];
367
+ t5 = findings.map(t6);
368
+ $[6] = applyFix;
369
+ $[7] = busy;
370
+ $[8] = dismiss;
371
+ $[9] = findings;
372
+ $[10] = onShow;
373
+ $[11] = projectId;
374
+ $[12] = t5;
375
+ } else t5 = $[12];
376
+ return t5;
377
+ }
378
+ function _temp2(error_0) {
379
+ return toast.error(error_0.message || "Could not dismiss it");
380
+ }
381
+ function _temp(error) {
382
+ return toast.error(error.message || "Could not apply the fix");
383
+ }
251
384
  /** Who made Live's version of a conflict, as a sentence's subject: a member, a release, or none. */
252
385
  function whoChanged(conflict) {
253
386
  if (conflict.release) return "A release";
@@ -450,9 +583,9 @@ function UseLiveVersionButton(t0) {
450
583
  * then lost changes: one card each, with no section heading.
451
584
  */
452
585
  function Cards(t0) {
453
- const $ = c(33);
586
+ const $ = c(39);
454
587
  const { projectId, preview, onChanged, onShow, onOpenThread } = t0;
455
- const { blockers, conflicts, lost, changes, defaultLocale } = preview;
588
+ const { blockers, findings, conflicts, lost, changes, defaultLocale } = preview;
456
589
  let t1;
457
590
  if ($[0] !== preview.warnings) {
458
591
  t1 = preview.warnings.filter(isShownWarning);
@@ -460,10 +593,10 @@ function Cards(t0) {
460
593
  $[1] = t1;
461
594
  } else t1 = $[1];
462
595
  const warnings = t1;
463
- if (blockers.length + warnings.length + conflicts.length + lost.length === 0) return null;
596
+ if (blockers.length + findings.length + warnings.length + conflicts.length + lost.length === 0) return null;
464
597
  let t2;
465
598
  if ($[2] !== changes) {
466
- t2 = new Set(changes.filter(_temp).map(_temp2));
599
+ t2 = new Set(changes.filter(_temp3).map(_temp4));
467
600
  $[2] = changes;
468
601
  $[3] = t2;
469
602
  } else t2 = $[3];
@@ -483,24 +616,38 @@ function Cards(t0) {
483
616
  $[7] = t3;
484
617
  } else t3 = $[7];
485
618
  let t4;
486
- if ($[8] !== onOpenThread || $[9] !== onShow || $[10] !== warnings) {
487
- t4 = /* @__PURE__ */ jsx(ProblemCards, {
619
+ if ($[8] !== findings || $[9] !== onChanged || $[10] !== onShow || $[11] !== projectId) {
620
+ t4 = /* @__PURE__ */ jsx(FindingCards, {
621
+ projectId,
622
+ findings,
623
+ onChanged,
624
+ onShow
625
+ });
626
+ $[8] = findings;
627
+ $[9] = onChanged;
628
+ $[10] = onShow;
629
+ $[11] = projectId;
630
+ $[12] = t4;
631
+ } else t4 = $[12];
632
+ let t5;
633
+ if ($[13] !== onOpenThread || $[14] !== onShow || $[15] !== warnings) {
634
+ t5 = /* @__PURE__ */ jsx(ProblemCards, {
488
635
  problems: warnings,
489
636
  tone: "warning",
490
637
  icon: TriangleAlert,
491
638
  onShow,
492
639
  onOpenThread
493
640
  });
494
- $[8] = onOpenThread;
495
- $[9] = onShow;
496
- $[10] = warnings;
497
- $[11] = t4;
498
- } else t4 = $[11];
499
- let t5;
500
- if ($[12] !== conflicts || $[13] !== defaultLocale || $[14] !== deleted || $[15] !== onChanged || $[16] !== projectId) {
501
- let t6;
502
- if ($[18] !== defaultLocale || $[19] !== deleted || $[20] !== onChanged || $[21] !== projectId) {
503
- t6 = (conflict) => /* @__PURE__ */ jsxs(Card, {
641
+ $[13] = onOpenThread;
642
+ $[14] = onShow;
643
+ $[15] = warnings;
644
+ $[16] = t5;
645
+ } else t5 = $[16];
646
+ let t6;
647
+ if ($[17] !== conflicts || $[18] !== defaultLocale || $[19] !== deleted || $[20] !== onChanged || $[21] !== projectId) {
648
+ let t7;
649
+ if ($[23] !== defaultLocale || $[24] !== deleted || $[25] !== onChanged || $[26] !== projectId) {
650
+ t7 = (conflict) => /* @__PURE__ */ jsxs(Card, {
504
651
  tone: "warning",
505
652
  icon: Replace,
506
653
  title: conflictTitle(conflict),
@@ -519,25 +666,25 @@ function Cards(t0) {
519
666
  })
520
667
  ]
521
668
  }, conflictKey(conflict));
522
- $[18] = defaultLocale;
523
- $[19] = deleted;
524
- $[20] = onChanged;
525
- $[21] = projectId;
526
- $[22] = t6;
527
- } else t6 = $[22];
528
- t5 = conflicts.map(t6);
529
- $[12] = conflicts;
530
- $[13] = defaultLocale;
531
- $[14] = deleted;
532
- $[15] = onChanged;
533
- $[16] = projectId;
534
- $[17] = t5;
535
- } else t5 = $[17];
536
- let t6;
537
- if ($[23] !== defaultLocale || $[24] !== lost) {
538
- let t7;
539
- if ($[26] !== defaultLocale) {
540
- t7 = (change_1) => /* @__PURE__ */ jsxs(Card, {
669
+ $[23] = defaultLocale;
670
+ $[24] = deleted;
671
+ $[25] = onChanged;
672
+ $[26] = projectId;
673
+ $[27] = t7;
674
+ } else t7 = $[27];
675
+ t6 = conflicts.map(t7);
676
+ $[17] = conflicts;
677
+ $[18] = defaultLocale;
678
+ $[19] = deleted;
679
+ $[20] = onChanged;
680
+ $[21] = projectId;
681
+ $[22] = t6;
682
+ } else t6 = $[22];
683
+ let t7;
684
+ if ($[28] !== defaultLocale || $[29] !== lost) {
685
+ let t8;
686
+ if ($[31] !== defaultLocale) {
687
+ t8 = (change_1) => /* @__PURE__ */ jsxs(Card, {
541
688
  tone: "warning",
542
689
  icon: Unlink,
543
690
  title: change_1.reason === "writtenAfterDeletion" ? change_1.label : `Loses the change to the ${change_1.label}`,
@@ -547,41 +694,43 @@ function Cards(t0) {
547
694
  change_1.id,
548
695
  change_1.locale
549
696
  ]));
550
- $[26] = defaultLocale;
551
- $[27] = t7;
552
- } else t7 = $[27];
553
- t6 = lost.map(t7);
554
- $[23] = defaultLocale;
555
- $[24] = lost;
556
- $[25] = t6;
557
- } else t6 = $[25];
558
- let t7;
559
- if ($[28] !== t3 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6) {
560
- t7 = /* @__PURE__ */ jsxs("ul", {
697
+ $[31] = defaultLocale;
698
+ $[32] = t8;
699
+ } else t8 = $[32];
700
+ t7 = lost.map(t8);
701
+ $[28] = defaultLocale;
702
+ $[29] = lost;
703
+ $[30] = t7;
704
+ } else t7 = $[30];
705
+ let t8;
706
+ if ($[33] !== t3 || $[34] !== t4 || $[35] !== t5 || $[36] !== t6 || $[37] !== t7) {
707
+ t8 = /* @__PURE__ */ jsxs("ul", {
561
708
  className: "flex flex-col gap-2",
562
709
  children: [
563
710
  t3,
564
711
  t4,
565
712
  t5,
566
- t6
713
+ t6,
714
+ t7
567
715
  ]
568
716
  });
569
- $[28] = t3;
570
- $[29] = t4;
571
- $[30] = t5;
572
- $[31] = t6;
573
- $[32] = t7;
574
- } else t7 = $[32];
575
- return t7;
717
+ $[33] = t3;
718
+ $[34] = t4;
719
+ $[35] = t5;
720
+ $[36] = t6;
721
+ $[37] = t7;
722
+ $[38] = t8;
723
+ } else t8 = $[38];
724
+ return t8;
576
725
  }
577
- function _temp2(change_0) {
726
+ function _temp4(change_0) {
578
727
  return JSON.stringify([
579
728
  change_0.entity,
580
729
  change_0.id,
581
730
  change_0.locale
582
731
  ]);
583
732
  }
584
- function _temp(change) {
733
+ function _temp3(change) {
585
734
  return change.change === "deleted";
586
735
  }
587
736
  /** A quiet line saying something is done, with a check, or still running, with a spinner. */
@@ -617,11 +766,10 @@ function StatusLine(t0) {
617
766
  return t3;
618
767
  }
619
768
  /** What Publish sends: the review's token, and the revision a draft with code shows. */
620
- const publishInput = (projectId, shown, publishAnyway) => ({
769
+ const publishInput = (projectId, shown) => ({
621
770
  projectId,
622
771
  token: shown.token,
623
- ...shown.code?.revision && { revision: shown.code.revision },
624
- ...publishAnyway && { publishAnyway }
772
+ ...shown.code?.revision && { revision: shown.code.revision }
625
773
  });
626
774
  /** Why a publish with code went back to the review, as the review says it. */
627
775
  const PUBLISH_ABORTED = {
@@ -632,14 +780,19 @@ const PUBLISH_ABORTED = {
632
780
  liveCodeMoved: "Live's code changed while publishing, and the draft took too long to take it in, so the publish stopped. Try again.",
633
781
  failed: "The publish couldn't finish on Camox's side, and Live is as it was. Try again."
634
782
  };
783
+ /** The patrollers still checking the draft: "The Link checker is checking the draft." */
784
+ function checkingSentence(roles) {
785
+ const who = listFormat.format(roles.map((role) => `the ${role}`));
786
+ return `${who[0].toUpperCase()}${who.slice(1)} ${roles.length > 1 ? "are" : "is"} checking the draft.`;
787
+ }
635
788
  /**
636
789
  * What's fine or still running: the draft is up to date with Live, its latest code changes
637
- * building, its translations, and the page SEO being written.
790
+ * building, its translations, its patrollers' checks, and the page SEO being written.
638
791
  */
639
792
  function StatusLines(t0) {
640
- const $ = c(34);
641
- const { preview, locales, waiting } = t0;
642
- const { conflicts, translating, warnings, code } = preview;
793
+ const $ = c(36);
794
+ const { preview, locales } = t0;
795
+ const { conflicts, translating, checking, warnings, code } = preview;
643
796
  let seoPages;
644
797
  let t1;
645
798
  let t2;
@@ -647,58 +800,56 @@ function StatusLines(t0) {
647
800
  let t4;
648
801
  let t5;
649
802
  let t6;
650
- if ($[0] !== code || $[1] !== conflicts.length || $[2] !== locales || $[3] !== translating || $[4] !== waiting || $[5] !== warnings) {
651
- const translations = locales.filter(_temp3).map(_temp4);
803
+ if ($[0] !== code || $[1] !== conflicts.length || $[2] !== locales || $[3] !== translating || $[4] !== warnings) {
804
+ const translations = locales.filter(_temp5).map(_temp6);
652
805
  let t7;
653
- if ($[13] !== warnings) {
654
- t7 = new Set(warnings.filter(_temp5).map(_temp6));
655
- $[13] = warnings;
656
- $[14] = t7;
657
- } else t7 = $[14];
806
+ if ($[12] !== warnings) {
807
+ t7 = new Set(warnings.filter(_temp7).map(_temp8));
808
+ $[12] = warnings;
809
+ $[13] = t7;
810
+ } else t7 = $[13];
658
811
  seoPages = t7.size;
659
812
  const aborted = code?.publishAborted && !code.publishing ? code.publishAborted : null;
660
813
  t1 = "flex flex-col gap-1.5";
661
- if ($[15] !== aborted) {
814
+ if ($[14] !== aborted) {
662
815
  t2 = aborted && /* @__PURE__ */ jsx("li", {
663
816
  className: "text-sm text-amber-700 dark:text-amber-400",
664
817
  children: PUBLISH_ABORTED[aborted] ?? PUBLISH_ABORTED.failed
665
818
  });
666
- $[15] = aborted;
667
- $[16] = t2;
668
- } else t2 = $[16];
669
- if ($[17] !== code?.includesLive || $[18] !== conflicts.length) {
819
+ $[14] = aborted;
820
+ $[15] = t2;
821
+ } else t2 = $[15];
822
+ if ($[16] !== code?.includesLive || $[17] !== conflicts.length) {
670
823
  t3 = conflicts.length === 0 && (code?.includesLive ?? true) && /* @__PURE__ */ jsx(StatusLine, {
671
824
  done: true,
672
825
  children: "Includes everything published to Live since this draft started"
673
826
  });
674
- $[17] = code?.includesLive;
675
- $[18] = conflicts.length;
676
- $[19] = t3;
677
- } else t3 = $[19];
678
- if ($[20] !== code?.building) {
827
+ $[16] = code?.includesLive;
828
+ $[17] = conflicts.length;
829
+ $[18] = t3;
830
+ } else t3 = $[18];
831
+ if ($[19] !== code?.building) {
679
832
  t4 = code?.building && /* @__PURE__ */ jsx(StatusLine, {
680
833
  done: false,
681
834
  children: "Building the latest changes…"
682
835
  });
683
- $[20] = code?.building;
684
- $[21] = t4;
685
- } else t4 = $[21];
686
- if ($[22] !== code?.publishing) {
836
+ $[19] = code?.building;
837
+ $[20] = t4;
838
+ } else t4 = $[20];
839
+ if ($[21] !== code?.publishing) {
687
840
  t5 = code?.publishing && /* @__PURE__ */ jsx(StatusLine, {
688
841
  done: false,
689
842
  children: "Publishing the new code and content…"
690
843
  });
691
- $[22] = code?.publishing;
692
- $[23] = t5;
693
- } else t5 = $[23];
844
+ $[21] = code?.publishing;
845
+ $[22] = t5;
846
+ } else t5 = $[22];
694
847
  t6 = translating.length > 0 ? /* @__PURE__ */ jsxs(StatusLine, {
695
848
  done: false,
696
849
  children: [
697
850
  "Translating into ",
698
851
  listFormat.format(translating.map(localeLabel)),
699
- ".",
700
- " ",
701
- waiting ? "Publishing once translated." : "Publishing waits for it."
852
+ ". Publishing waits for it."
702
853
  ]
703
854
  }) : translations.length > 0 && /* @__PURE__ */ jsxs(StatusLine, {
704
855
  done: true,
@@ -708,27 +859,41 @@ function StatusLines(t0) {
708
859
  $[1] = conflicts.length;
709
860
  $[2] = locales;
710
861
  $[3] = translating;
711
- $[4] = waiting;
712
- $[5] = warnings;
713
- $[6] = seoPages;
714
- $[7] = t1;
715
- $[8] = t2;
716
- $[9] = t3;
717
- $[10] = t4;
718
- $[11] = t5;
719
- $[12] = t6;
862
+ $[4] = warnings;
863
+ $[5] = seoPages;
864
+ $[6] = t1;
865
+ $[7] = t2;
866
+ $[8] = t3;
867
+ $[9] = t4;
868
+ $[10] = t5;
869
+ $[11] = t6;
720
870
  } else {
721
- seoPages = $[6];
722
- t1 = $[7];
723
- t2 = $[8];
724
- t3 = $[9];
725
- t4 = $[10];
726
- t5 = $[11];
727
- t6 = $[12];
871
+ seoPages = $[5];
872
+ t1 = $[6];
873
+ t2 = $[7];
874
+ t3 = $[8];
875
+ t4 = $[9];
876
+ t5 = $[10];
877
+ t6 = $[11];
728
878
  }
729
879
  let t7;
730
- if ($[24] !== seoPages) {
731
- t7 = seoPages > 0 && /* @__PURE__ */ jsxs(StatusLine, {
880
+ if ($[23] !== checking) {
881
+ t7 = checking.length > 0 && /* @__PURE__ */ jsxs(StatusLine, {
882
+ done: false,
883
+ children: [
884
+ checkingSentence(checking.map(_temp9)),
885
+ " Publishing waits for",
886
+ " ",
887
+ checking.length > 1 ? "them" : "it",
888
+ "."
889
+ ]
890
+ });
891
+ $[23] = checking;
892
+ $[24] = t7;
893
+ } else t7 = $[24];
894
+ let t8;
895
+ if ($[25] !== seoPages) {
896
+ t8 = seoPages > 0 && /* @__PURE__ */ jsxs(StatusLine, {
732
897
  done: false,
733
898
  children: [
734
899
  "Writing SEO for ",
@@ -736,12 +901,12 @@ function StatusLines(t0) {
736
901
  "…"
737
902
  ]
738
903
  });
739
- $[24] = seoPages;
740
- $[25] = t7;
741
- } else t7 = $[25];
742
- let t8;
743
- if ($[26] !== t1 || $[27] !== t2 || $[28] !== t3 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7) {
744
- t8 = /* @__PURE__ */ jsxs("ul", {
904
+ $[25] = seoPages;
905
+ $[26] = t8;
906
+ } else t8 = $[26];
907
+ let t9;
908
+ if ($[27] !== t1 || $[28] !== t2 || $[29] !== t3 || $[30] !== t4 || $[31] !== t5 || $[32] !== t6 || $[33] !== t7 || $[34] !== t8) {
909
+ t9 = /* @__PURE__ */ jsxs("ul", {
745
910
  className: t1,
746
911
  children: [
747
912
  t2,
@@ -749,30 +914,36 @@ function StatusLines(t0) {
749
914
  t4,
750
915
  t5,
751
916
  t6,
752
- t7
917
+ t7,
918
+ t8
753
919
  ]
754
920
  });
755
- $[26] = t1;
756
- $[27] = t2;
757
- $[28] = t3;
758
- $[29] = t4;
759
- $[30] = t5;
760
- $[31] = t6;
761
- $[32] = t7;
762
- $[33] = t8;
763
- } else t8 = $[33];
764
- return t8;
921
+ $[27] = t1;
922
+ $[28] = t2;
923
+ $[29] = t3;
924
+ $[30] = t4;
925
+ $[31] = t5;
926
+ $[32] = t6;
927
+ $[33] = t7;
928
+ $[34] = t8;
929
+ $[35] = t9;
930
+ } else t9 = $[35];
931
+ return t9;
932
+ }
933
+ function _temp9(t0) {
934
+ const { role } = t0;
935
+ return role;
765
936
  }
766
- function _temp6(warning_0) {
937
+ function _temp8(warning_0) {
767
938
  return warning_0.id;
768
939
  }
769
- function _temp5(warning) {
940
+ function _temp7(warning) {
770
941
  return warning.code === "metaTitlePending";
771
942
  }
772
- function _temp4(locale_0) {
943
+ function _temp6(locale_0) {
773
944
  return locale_0.tag;
774
945
  }
775
- function _temp3(locale) {
946
+ function _temp5(locale) {
776
947
  return !locale.isDefault;
777
948
  }
778
949
  /**
@@ -790,7 +961,7 @@ function DraftOverview(t0) {
790
961
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
791
962
  t1 = {
792
963
  ...draftMutations.retryOverview(),
793
- onError: _temp7
964
+ onError: _temp10
794
965
  };
795
966
  $[0] = t1;
796
967
  } else t1 = $[0];
@@ -809,7 +980,7 @@ function DraftOverview(t0) {
809
980
  if (overview.status === "ready") {
810
981
  let t2;
811
982
  if ($[2] !== overview.bullets) {
812
- t2 = overview.bullets.map(_temp8);
983
+ t2 = overview.bullets.map(_temp11);
813
984
  $[2] = overview.bullets;
814
985
  $[3] = t2;
815
986
  } else t2 = $[3];
@@ -850,7 +1021,7 @@ function DraftOverview(t0) {
850
1021
  if (overview.status === "failed") {
851
1022
  let t2;
852
1023
  if ($[11] !== changes) {
853
- t2 = new Set(changes.map(_temp9));
1024
+ t2 = new Set(changes.map(_temp12));
854
1025
  $[11] = changes;
855
1026
  $[12] = t2;
856
1027
  } else t2 = $[12];
@@ -953,13 +1124,13 @@ function DraftOverview(t0) {
953
1124
  } else t2 = $[33];
954
1125
  return t2;
955
1126
  }
956
- function _temp9(change) {
1127
+ function _temp12(change) {
957
1128
  return change.entity === "locale" ? "Languages" : ownerName(change.owner, change.entity);
958
1129
  }
959
- function _temp8(bullet, index) {
1130
+ function _temp11(bullet, index) {
960
1131
  return /* @__PURE__ */ jsx("li", { children: bullet }, index);
961
1132
  }
962
- function _temp7(error) {
1133
+ function _temp10(error) {
963
1134
  return toast.error(error.message || "Could not summarize the draft");
964
1135
  }
965
1136
  /** Switches the studio to Live once its draft ended here, replacing the draft's URL entry. */
@@ -968,9 +1139,13 @@ function useLeaveDraft() {
968
1139
  const draftScope = useDraftScope();
969
1140
  let t0;
970
1141
  if ($[0] !== draftScope) {
971
- t0 = (ended) => {
1142
+ t0 = (ended, t1) => {
1143
+ const { discarded: t2 } = t1 === void 0 ? {} : t1;
1144
+ const discarded = t2 === void 0 ? false : t2;
972
1145
  draftScope.leave(ended);
973
- if (ended) toast.success(`Draft ${ended.outcome}. You're now viewing Live.`);
1146
+ if (!ended) return;
1147
+ const what = discarded ? "Changes discarded" : `Draft ${ended.outcome}`;
1148
+ toast.success(`${what}. You're now viewing Live.`);
974
1149
  };
975
1150
  $[0] = draftScope;
976
1151
  $[1] = t0;
@@ -1014,7 +1189,7 @@ function useRenameDraft(projectId) {
1014
1189
  t2 = {
1015
1190
  mutationFn: t0,
1016
1191
  onSuccess: t1,
1017
- onError: _temp10
1192
+ onError: _temp13
1018
1193
  };
1019
1194
  $[5] = t0;
1020
1195
  $[6] = t1;
@@ -1022,7 +1197,7 @@ function useRenameDraft(projectId) {
1022
1197
  } else t2 = $[7];
1023
1198
  return useMutation(t2);
1024
1199
  }
1025
- function _temp10(error) {
1200
+ function _temp13(error) {
1026
1201
  return toast.error(error.message || "Could not rename the draft");
1027
1202
  }
1028
1203
  /**
@@ -1127,7 +1302,7 @@ function DraftNameInput(t0) {
1127
1302
  * preview is shown. Once the draft ends, the studio switches to Live.
1128
1303
  */
1129
1304
  function ReviewDraftSheet(t0) {
1130
- const $ = c(101);
1305
+ const $ = c(81);
1131
1306
  const { projectId, draftId, open, startRenaming: t1, onOpenChange } = t0;
1132
1307
  const startRenaming = t1 === void 0 ? false : t1;
1133
1308
  const [confirmingDelete, setConfirmingDelete] = React.useState(false);
@@ -1221,24 +1396,26 @@ function ReviewDraftSheet(t0) {
1221
1396
  t11 = $[21];
1222
1397
  }
1223
1398
  React.useEffect(t10, t11);
1399
+ const discard = draft.data?.name === null;
1224
1400
  let t12;
1225
- if ($[22] !== leaveDraft || $[23] !== onOpenChange) {
1401
+ if ($[22] !== discard || $[23] !== leaveDraft || $[24] !== onOpenChange) {
1226
1402
  t12 = (ended) => {
1227
1403
  onOpenChange(false);
1228
- leaveDraft(ended);
1404
+ leaveDraft(ended, { discarded: discard });
1229
1405
  };
1230
- $[22] = leaveDraft;
1231
- $[23] = onOpenChange;
1232
- $[24] = t12;
1233
- } else t12 = $[24];
1406
+ $[22] = discard;
1407
+ $[23] = leaveDraft;
1408
+ $[24] = onOpenChange;
1409
+ $[25] = t12;
1410
+ } else t12 = $[25];
1234
1411
  const leave = t12;
1235
1412
  let t13;
1236
- if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
1413
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
1237
1414
  t13 = draftMutations.publish();
1238
- $[25] = t13;
1239
- } else t13 = $[25];
1415
+ $[26] = t13;
1416
+ } else t13 = $[26];
1240
1417
  let t14;
1241
- if ($[26] !== leave || $[27] !== preview) {
1418
+ if ($[27] !== leave || $[28] !== preview) {
1242
1419
  t14 = (result) => {
1243
1420
  if ("publishing" in result && result.publishing) {
1244
1421
  preview.refetch();
@@ -1249,12 +1426,12 @@ function ReviewDraftSheet(t0) {
1249
1426
  toast.info("This draft has no changes, so there is nothing to publish.");
1250
1427
  preview.refetch();
1251
1428
  };
1252
- $[26] = leave;
1253
- $[27] = preview;
1254
- $[28] = t14;
1255
- } else t14 = $[28];
1429
+ $[27] = leave;
1430
+ $[28] = preview;
1431
+ $[29] = t14;
1432
+ } else t14 = $[29];
1256
1433
  let t15;
1257
- if ($[29] !== preview) {
1434
+ if ($[30] !== preview) {
1258
1435
  t15 = (error) => {
1259
1436
  if (error.code === CONFLICTS_CHANGED_ERROR) {
1260
1437
  toast.error("Live changed since you opened this review. Check the new list.");
@@ -1267,91 +1444,41 @@ function ReviewDraftSheet(t0) {
1267
1444
  return;
1268
1445
  }
1269
1446
  if (error.code === TRANSLATIONS_PENDING_ERROR) {
1270
- toast.info("Translations are still running. Wait for them, or publish anyway.");
1447
+ toast.info("Translations are still running. Publishing waits for them.");
1448
+ preview.refetch();
1449
+ return;
1450
+ }
1451
+ const code = error.code;
1452
+ if (code === FINDINGS_OPEN_ERROR || code === CHECKS_RUNNING_ERROR) {
1453
+ toast.info(error.message);
1271
1454
  preview.refetch();
1272
1455
  return;
1273
1456
  }
1274
1457
  toast.error(error.message || "Could not publish the draft");
1275
1458
  preview.refetch();
1276
1459
  };
1277
- $[29] = preview;
1278
- $[30] = t15;
1279
- } else t15 = $[30];
1460
+ $[30] = preview;
1461
+ $[31] = t15;
1462
+ } else t15 = $[31];
1280
1463
  let t16;
1281
- if ($[31] !== t14 || $[32] !== t15) {
1464
+ if ($[32] !== t14 || $[33] !== t15) {
1282
1465
  t16 = {
1283
1466
  ...t13,
1284
1467
  onSuccess: t14,
1285
1468
  onError: t15
1286
1469
  };
1287
- $[31] = t14;
1288
- $[32] = t15;
1289
- $[33] = t16;
1290
- } else t16 = $[33];
1470
+ $[32] = t14;
1471
+ $[33] = t15;
1472
+ $[34] = t16;
1473
+ } else t16 = $[34];
1291
1474
  const publish = useMutation(t16);
1292
1475
  const data = preview.data;
1293
1476
  const headline = data?.overview.status === "ready" ? data.overview.headline : null;
1294
1477
  const busy = publish.isPending;
1295
- const ready = !!data && data.blockers.length === 0 && !data.code?.building && !data.code?.publishing && !busy && !preview.isFetching;
1478
+ const ready = !!data && data.blockers.length === 0 && data.translating.length === 0 && data.findings.length === 0 && data.checking.length === 0 && !data.code?.building && !data.code?.publishing && !busy && !preview.isFetching;
1296
1479
  let t17;
1297
- if ($[34] !== data?.translating) {
1298
- t17 = data?.translating ?? [];
1299
- $[34] = data?.translating;
1300
- $[35] = t17;
1301
- } else t17 = $[35];
1302
- const translating = t17;
1303
- const [waiting, setWaiting] = React.useState(null);
1304
- const translated = !!data && !preview.isFetching && data.translating.length === 0;
1305
- if (waiting && translated) {
1306
- const appeared = data.conflicts.some((conflict) => !waiting.conflicts.has(conflictKey(conflict)));
1307
- if (data.blockers.length > 0 || appeared) setWaiting(null);
1308
- }
1309
- const { mutate } = publish;
1310
- let t18;
1311
- let t19;
1312
- if ($[36] !== busy || $[37] !== data || $[38] !== mutate || $[39] !== projectId || $[40] !== translated || $[41] !== waiting) {
1313
- t18 = () => {
1314
- if (!waiting || !translated || !data || busy) return;
1315
- mutate(publishInput(projectId, data), { onSettled: () => setWaiting(null) });
1316
- };
1317
- t19 = [
1318
- waiting,
1319
- translated,
1320
- data,
1321
- busy,
1322
- mutate,
1323
- projectId
1324
- ];
1325
- $[36] = busy;
1326
- $[37] = data;
1327
- $[38] = mutate;
1328
- $[39] = projectId;
1329
- $[40] = translated;
1330
- $[41] = waiting;
1331
- $[42] = t18;
1332
- $[43] = t19;
1333
- } else {
1334
- t18 = $[42];
1335
- t19 = $[43];
1336
- }
1337
- React.useEffect(t18, t19);
1338
- let t20;
1339
- if ($[44] !== data || $[45] !== projectId || $[46] !== publish || $[47] !== translating.length) {
1340
- t20 = () => {
1341
- if (!data) return;
1342
- if (translating.length === 0) return publish.mutate(publishInput(projectId, data));
1343
- setWaiting({ conflicts: new Set(data.conflicts.map(conflictKey)) });
1344
- };
1345
- $[44] = data;
1346
- $[45] = projectId;
1347
- $[46] = publish;
1348
- $[47] = translating.length;
1349
- $[48] = t20;
1350
- } else t20 = $[48];
1351
- const publishWhole = t20;
1352
- let t21;
1353
- if ($[49] !== draft.data || $[50] !== headline || $[51] !== projectId) {
1354
- t21 = /* @__PURE__ */ jsx("div", {
1480
+ if ($[35] !== draft.data || $[36] !== headline || $[37] !== projectId) {
1481
+ t17 = /* @__PURE__ */ jsx("div", {
1355
1482
  className: "flex flex-col gap-1 border-b p-4 pr-12",
1356
1483
  children: headline ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(SheetDescription, {
1357
1484
  className: "flex min-w-0 items-center gap-1",
@@ -1384,14 +1511,14 @@ function ReviewDraftSheet(t0) {
1384
1511
  children: "Draft"
1385
1512
  }), /* @__PURE__ */ jsx(SheetDescription, { children: draft.data ? `${draft.data.createdBy.name} · started ${timeAgo(draft.data.createdAt)}` : "Publishing applies this whole draft to Live." })] })
1386
1513
  });
1387
- $[49] = draft.data;
1388
- $[50] = headline;
1389
- $[51] = projectId;
1390
- $[52] = t21;
1391
- } else t21 = $[52];
1392
- let t22;
1393
- if ($[53] !== data || $[54] !== locales || $[55] !== onOpenChange || $[56] !== preview || $[57] !== projectId || $[58] !== showInCanvas || $[59] !== waiting) {
1394
- t22 = data ? /* @__PURE__ */ jsxs("div", {
1514
+ $[35] = draft.data;
1515
+ $[36] = headline;
1516
+ $[37] = projectId;
1517
+ $[38] = t17;
1518
+ } else t17 = $[38];
1519
+ let t18;
1520
+ if ($[39] !== data || $[40] !== locales || $[41] !== onOpenChange || $[42] !== preview || $[43] !== projectId || $[44] !== showInCanvas) {
1521
+ t18 = data ? /* @__PURE__ */ jsxs("div", {
1395
1522
  className: "flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto p-4",
1396
1523
  children: [
1397
1524
  /* @__PURE__ */ jsx(DraftOverview, {
@@ -1413,262 +1540,271 @@ function ReviewDraftSheet(t0) {
1413
1540
  }),
1414
1541
  /* @__PURE__ */ jsx(StatusLines, {
1415
1542
  preview: data,
1416
- locales: locales.data ?? [],
1417
- waiting: !!waiting
1543
+ locales: locales.data ?? []
1418
1544
  })
1419
1545
  ]
1420
1546
  }) : /* @__PURE__ */ jsx("div", {
1421
1547
  className: "flex flex-1 items-center justify-center",
1422
1548
  children: /* @__PURE__ */ jsx(Spinner, { className: "text-muted-foreground" })
1423
1549
  });
1424
- $[53] = data;
1425
- $[54] = locales;
1426
- $[55] = onOpenChange;
1427
- $[56] = preview;
1428
- $[57] = projectId;
1429
- $[58] = showInCanvas;
1430
- $[59] = waiting;
1431
- $[60] = t22;
1432
- } else t22 = $[60];
1433
- let t23;
1434
- let t24;
1435
- if ($[61] === Symbol.for("react.memo_cache_sentinel")) {
1436
- t23 = () => setConfirmingDelete(true);
1437
- t24 = /* @__PURE__ */ jsx(Trash2, {});
1438
- $[61] = t23;
1439
- $[62] = t24;
1550
+ $[39] = data;
1551
+ $[40] = locales;
1552
+ $[41] = onOpenChange;
1553
+ $[42] = preview;
1554
+ $[43] = projectId;
1555
+ $[44] = showInCanvas;
1556
+ $[45] = t18;
1557
+ } else t18 = $[45];
1558
+ let t19;
1559
+ let t20;
1560
+ if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
1561
+ t19 = () => setConfirmingDelete(true);
1562
+ t20 = /* @__PURE__ */ jsx(Trash2, {});
1563
+ $[46] = t19;
1564
+ $[47] = t20;
1440
1565
  } else {
1441
- t23 = $[61];
1442
- t24 = $[62];
1566
+ t19 = $[46];
1567
+ t20 = $[47];
1443
1568
  }
1444
- let t25;
1445
- if ($[63] !== busy) {
1446
- t25 = /* @__PURE__ */ jsxs(Button, {
1569
+ const t21 = discard ? "Discard changes" : "Delete draft";
1570
+ let t22;
1571
+ if ($[48] !== busy || $[49] !== t21) {
1572
+ t22 = /* @__PURE__ */ jsxs(Button, {
1447
1573
  variant: "ghost",
1448
1574
  className: "text-destructive",
1449
1575
  disabled: busy,
1450
- onClick: t23,
1451
- children: [t24, "Delete draft"]
1576
+ onClick: t19,
1577
+ children: [t20, t21]
1452
1578
  });
1453
- $[63] = busy;
1454
- $[64] = t25;
1455
- } else t25 = $[64];
1579
+ $[48] = busy;
1580
+ $[49] = t21;
1581
+ $[50] = t22;
1582
+ } else t22 = $[50];
1583
+ const t23 = !ready;
1584
+ let t24;
1585
+ if ($[51] !== data || $[52] !== projectId || $[53] !== publish) {
1586
+ t24 = () => data && publish.mutate(publishInput(projectId, data));
1587
+ $[51] = data;
1588
+ $[52] = projectId;
1589
+ $[53] = publish;
1590
+ $[54] = t24;
1591
+ } else t24 = $[54];
1592
+ let t25;
1593
+ if ($[55] !== publish.isPending) {
1594
+ t25 = publish.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1595
+ $[55] = publish.isPending;
1596
+ $[56] = t25;
1597
+ } else t25 = $[56];
1456
1598
  let t26;
1457
- if ($[65] !== data || $[66] !== projectId || $[67] !== publish || $[68] !== ready || $[69] !== translating.length) {
1458
- t26 = translating.length > 0 && /* @__PURE__ */ jsx(Button, {
1459
- variant: "outline",
1599
+ if ($[57] !== t23 || $[58] !== t24 || $[59] !== t25) {
1600
+ t26 = /* @__PURE__ */ jsxs(Button, {
1460
1601
  className: "ml-auto",
1461
- disabled: !ready,
1462
- onClick: () => data && publish.mutate(publishInput(projectId, data, true)),
1463
- children: "Publish anyway"
1464
- });
1465
- $[65] = data;
1466
- $[66] = projectId;
1467
- $[67] = publish;
1468
- $[68] = ready;
1469
- $[69] = translating.length;
1470
- $[70] = t26;
1471
- } else t26 = $[70];
1472
- const t27 = translating.length === 0 && "ml-auto";
1473
- let t28;
1474
- if ($[71] !== t27) {
1475
- t28 = cn(t27);
1476
- $[71] = t27;
1477
- $[72] = t28;
1478
- } else t28 = $[72];
1479
- const t29 = !ready || !!waiting;
1480
- let t30;
1481
- if ($[73] !== publish.isPending || $[74] !== waiting) {
1482
- t30 = publish.isPending || waiting ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1483
- $[73] = publish.isPending;
1484
- $[74] = waiting;
1485
- $[75] = t30;
1486
- } else t30 = $[75];
1487
- let t31;
1488
- if ($[76] !== publishWhole || $[77] !== t28 || $[78] !== t29 || $[79] !== t30) {
1489
- t31 = /* @__PURE__ */ jsxs(Button, {
1490
- className: t28,
1491
- disabled: t29,
1492
- onClick: publishWhole,
1493
- children: [t30, "Publish"]
1602
+ disabled: t23,
1603
+ onClick: t24,
1604
+ children: [t25, "Publish"]
1494
1605
  });
1495
- $[76] = publishWhole;
1496
- $[77] = t28;
1497
- $[78] = t29;
1498
- $[79] = t30;
1499
- $[80] = t31;
1500
- } else t31 = $[80];
1501
- let t32;
1502
- if ($[81] !== t25 || $[82] !== t26 || $[83] !== t31) {
1503
- t32 = /* @__PURE__ */ jsx("div", {
1606
+ $[57] = t23;
1607
+ $[58] = t24;
1608
+ $[59] = t25;
1609
+ $[60] = t26;
1610
+ } else t26 = $[60];
1611
+ let t27;
1612
+ if ($[61] !== t22 || $[62] !== t26) {
1613
+ t27 = /* @__PURE__ */ jsx("div", {
1504
1614
  className: "flex flex-col gap-3 border-t p-4",
1505
1615
  children: /* @__PURE__ */ jsxs("div", {
1506
1616
  className: "flex items-center gap-2",
1507
- children: [
1508
- t25,
1509
- t26,
1510
- t31
1511
- ]
1617
+ children: [t22, t26]
1512
1618
  })
1513
1619
  });
1514
- $[81] = t25;
1515
- $[82] = t26;
1516
- $[83] = t31;
1517
- $[84] = t32;
1518
- } else t32 = $[84];
1519
- let t33;
1520
- if ($[85] !== initialFocus || $[86] !== t21 || $[87] !== t22 || $[88] !== t32) {
1521
- t33 = /* @__PURE__ */ jsxs(SheetContent, {
1620
+ $[61] = t22;
1621
+ $[62] = t26;
1622
+ $[63] = t27;
1623
+ } else t27 = $[63];
1624
+ let t28;
1625
+ if ($[64] !== initialFocus || $[65] !== t17 || $[66] !== t18 || $[67] !== t27) {
1626
+ t28 = /* @__PURE__ */ jsxs(SheetContent, {
1522
1627
  ref: popup,
1523
1628
  initialFocus,
1524
1629
  side: "right",
1525
1630
  className: "w-full gap-0 data-[side=right]:sm:max-w-lg",
1526
1631
  children: [
1527
- t21,
1528
- t22,
1529
- t32
1632
+ t17,
1633
+ t18,
1634
+ t27
1530
1635
  ]
1531
1636
  });
1532
- $[85] = initialFocus;
1533
- $[86] = t21;
1534
- $[87] = t22;
1535
- $[88] = t32;
1536
- $[89] = t33;
1537
- } else t33 = $[89];
1538
- let t34;
1539
- if ($[90] !== onOpenChange || $[91] !== open || $[92] !== t33) {
1540
- t34 = /* @__PURE__ */ jsx(Sheet, {
1637
+ $[64] = initialFocus;
1638
+ $[65] = t17;
1639
+ $[66] = t18;
1640
+ $[67] = t27;
1641
+ $[68] = t28;
1642
+ } else t28 = $[68];
1643
+ let t29;
1644
+ if ($[69] !== onOpenChange || $[70] !== open || $[71] !== t28) {
1645
+ t29 = /* @__PURE__ */ jsx(Sheet, {
1541
1646
  open,
1542
1647
  onOpenChange,
1543
- children: t33
1648
+ children: t28
1544
1649
  });
1545
- $[90] = onOpenChange;
1546
- $[91] = open;
1547
- $[92] = t33;
1548
- $[93] = t34;
1549
- } else t34 = $[93];
1550
- let t35;
1551
- if ($[94] !== confirmingDelete || $[95] !== leave || $[96] !== projectId) {
1552
- t35 = /* @__PURE__ */ jsx(DeleteDraftDialog, {
1650
+ $[69] = onOpenChange;
1651
+ $[70] = open;
1652
+ $[71] = t28;
1653
+ $[72] = t29;
1654
+ } else t29 = $[72];
1655
+ let t30;
1656
+ if ($[73] !== confirmingDelete || $[74] !== discard || $[75] !== leave || $[76] !== projectId) {
1657
+ t30 = /* @__PURE__ */ jsx(DeleteDraftDialog, {
1553
1658
  projectId,
1554
1659
  open: confirmingDelete,
1660
+ discard,
1555
1661
  onOpenChange: setConfirmingDelete,
1556
1662
  onDeleted: leave
1557
1663
  });
1558
- $[94] = confirmingDelete;
1559
- $[95] = leave;
1560
- $[96] = projectId;
1561
- $[97] = t35;
1562
- } else t35 = $[97];
1563
- let t36;
1564
- if ($[98] !== t34 || $[99] !== t35) {
1565
- t36 = /* @__PURE__ */ jsxs(Fragment, { children: [t34, t35] });
1566
- $[98] = t34;
1567
- $[99] = t35;
1568
- $[100] = t36;
1569
- } else t36 = $[100];
1570
- return t36;
1664
+ $[73] = confirmingDelete;
1665
+ $[74] = discard;
1666
+ $[75] = leave;
1667
+ $[76] = projectId;
1668
+ $[77] = t30;
1669
+ } else t30 = $[77];
1670
+ let t31;
1671
+ if ($[78] !== t29 || $[79] !== t30) {
1672
+ t31 = /* @__PURE__ */ jsxs(Fragment, { children: [t29, t30] });
1673
+ $[78] = t29;
1674
+ $[79] = t30;
1675
+ $[80] = t31;
1676
+ } else t31 = $[80];
1677
+ return t31;
1571
1678
  }
1572
- /** Asks before deleting the draft the studio is in, then deletes it. */
1679
+ /**
1680
+ * Asks before deleting the draft the studio is in, then deletes it. Deleting an unnamed draft
1681
+ * is discarding its changes: nobody kept them as a draft yet.
1682
+ */
1573
1683
  function DeleteDraftDialog(t0) {
1574
- const $ = c(26);
1575
- const { projectId, open, onOpenChange, onDeleted } = t0;
1576
- let t1;
1577
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1578
- t1 = draftMutations.delete();
1579
- $[0] = t1;
1580
- } else t1 = $[0];
1684
+ const $ = c(36);
1685
+ const { projectId, open, discard: t1, onOpenChange, onDeleted } = t0;
1686
+ const discard = t1 === void 0 ? false : t1;
1581
1687
  let t2;
1688
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1689
+ t2 = draftMutations.delete();
1690
+ $[0] = t2;
1691
+ } else t2 = $[0];
1692
+ let t3;
1582
1693
  if ($[1] !== onDeleted || $[2] !== onOpenChange) {
1583
- t2 = {
1584
- ...t1,
1585
- onSuccess: (t3) => {
1586
- const { ended } = t3;
1694
+ t3 = {
1695
+ ...t2,
1696
+ onSuccess: (t4) => {
1697
+ const { ended } = t4;
1587
1698
  onOpenChange(false);
1588
1699
  onDeleted(ended);
1589
1700
  },
1590
- onError: _temp11
1701
+ onError: _temp14
1591
1702
  };
1592
1703
  $[1] = onDeleted;
1593
1704
  $[2] = onOpenChange;
1594
- $[3] = t2;
1595
- } else t2 = $[3];
1596
- const deleteDraft = useMutation(t2);
1597
- let t3;
1705
+ $[3] = t3;
1706
+ } else t3 = $[3];
1707
+ const deleteDraft = useMutation(t3);
1708
+ let t4;
1598
1709
  if ($[4] !== deleteDraft.isPending || $[5] !== onOpenChange) {
1599
- t3 = (next) => {
1710
+ t4 = (next) => {
1600
1711
  if (!deleteDraft.isPending) onOpenChange(next);
1601
1712
  };
1602
1713
  $[4] = deleteDraft.isPending;
1603
1714
  $[5] = onOpenChange;
1604
- $[6] = t3;
1605
- } else t3 = $[6];
1606
- let t4;
1607
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
1608
- 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." })] });
1609
- $[7] = t4;
1610
- } else t4 = $[7];
1611
- let t5;
1612
- if ($[8] !== deleteDraft.isPending) {
1613
- t5 = /* @__PURE__ */ jsx(AlertDialogCancel, {
1715
+ $[6] = t4;
1716
+ } else t4 = $[6];
1717
+ const t5 = discard ? "Discard these changes?" : "Delete this draft?";
1718
+ let t6;
1719
+ if ($[7] !== t5) {
1720
+ t6 = /* @__PURE__ */ jsx(AlertDialogTitle, { children: t5 });
1721
+ $[7] = t5;
1722
+ $[8] = t6;
1723
+ } else t6 = $[8];
1724
+ const t7 = discard ? "These changes are" : "Every change in this draft is";
1725
+ let t8;
1726
+ if ($[9] !== t7) {
1727
+ t8 = /* @__PURE__ */ jsxs(AlertDialogDescription, { children: [t7, " deleted for everyone. Live stays as it is. This can't be undone."] });
1728
+ $[9] = t7;
1729
+ $[10] = t8;
1730
+ } else t8 = $[10];
1731
+ let t9;
1732
+ if ($[11] !== t6 || $[12] !== t8) {
1733
+ t9 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [t6, t8] });
1734
+ $[11] = t6;
1735
+ $[12] = t8;
1736
+ $[13] = t9;
1737
+ } else t9 = $[13];
1738
+ let t10;
1739
+ if ($[14] !== deleteDraft.isPending) {
1740
+ t10 = /* @__PURE__ */ jsx(AlertDialogCancel, {
1614
1741
  variant: "outline",
1615
1742
  size: "default",
1616
1743
  disabled: deleteDraft.isPending,
1617
1744
  children: "Cancel"
1618
1745
  });
1619
- $[8] = deleteDraft.isPending;
1620
- $[9] = t5;
1621
- } else t5 = $[9];
1622
- let t6;
1623
- if ($[10] !== deleteDraft || $[11] !== projectId) {
1624
- t6 = () => deleteDraft.mutate({ projectId });
1625
- $[10] = deleteDraft;
1626
- $[11] = projectId;
1627
- $[12] = t6;
1628
- } else t6 = $[12];
1629
- let t7;
1630
- if ($[13] !== deleteDraft.isPending) {
1631
- t7 = deleteDraft.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1632
- $[13] = deleteDraft.isPending;
1633
- $[14] = t7;
1634
- } else t7 = $[14];
1635
- let t8;
1636
- if ($[15] !== deleteDraft.isPending || $[16] !== t6 || $[17] !== t7) {
1637
- t8 = /* @__PURE__ */ jsxs(AlertDialogAction, {
1746
+ $[14] = deleteDraft.isPending;
1747
+ $[15] = t10;
1748
+ } else t10 = $[15];
1749
+ let t11;
1750
+ if ($[16] !== deleteDraft || $[17] !== projectId) {
1751
+ t11 = () => deleteDraft.mutate({ projectId });
1752
+ $[16] = deleteDraft;
1753
+ $[17] = projectId;
1754
+ $[18] = t11;
1755
+ } else t11 = $[18];
1756
+ let t12;
1757
+ if ($[19] !== deleteDraft.isPending) {
1758
+ t12 = deleteDraft.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1759
+ $[19] = deleteDraft.isPending;
1760
+ $[20] = t12;
1761
+ } else t12 = $[20];
1762
+ const t13 = discard ? "Discard changes" : "Delete draft";
1763
+ let t14;
1764
+ if ($[21] !== deleteDraft.isPending || $[22] !== t11 || $[23] !== t12 || $[24] !== t13) {
1765
+ t14 = /* @__PURE__ */ jsxs(AlertDialogAction, {
1638
1766
  variant: "destructive",
1639
1767
  disabled: deleteDraft.isPending,
1640
- onClick: t6,
1641
- children: [t7, "Delete draft"]
1768
+ onClick: t11,
1769
+ children: [t12, t13]
1642
1770
  });
1643
- $[15] = deleteDraft.isPending;
1644
- $[16] = t6;
1645
- $[17] = t7;
1646
- $[18] = t8;
1647
- } else t8 = $[18];
1648
- let t9;
1649
- if ($[19] !== t5 || $[20] !== t8) {
1650
- t9 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t4, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t5, t8] })] });
1651
- $[19] = t5;
1652
- $[20] = t8;
1653
- $[21] = t9;
1654
- } else t9 = $[21];
1655
- let t10;
1656
- if ($[22] !== open || $[23] !== t3 || $[24] !== t9) {
1657
- t10 = /* @__PURE__ */ jsx(AlertDialog, {
1771
+ $[21] = deleteDraft.isPending;
1772
+ $[22] = t11;
1773
+ $[23] = t12;
1774
+ $[24] = t13;
1775
+ $[25] = t14;
1776
+ } else t14 = $[25];
1777
+ let t15;
1778
+ if ($[26] !== t10 || $[27] !== t14) {
1779
+ t15 = /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t10, t14] });
1780
+ $[26] = t10;
1781
+ $[27] = t14;
1782
+ $[28] = t15;
1783
+ } else t15 = $[28];
1784
+ let t16;
1785
+ if ($[29] !== t15 || $[30] !== t9) {
1786
+ t16 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t9, t15] });
1787
+ $[29] = t15;
1788
+ $[30] = t9;
1789
+ $[31] = t16;
1790
+ } else t16 = $[31];
1791
+ let t17;
1792
+ if ($[32] !== open || $[33] !== t16 || $[34] !== t4) {
1793
+ t17 = /* @__PURE__ */ jsx(AlertDialog, {
1658
1794
  open,
1659
- onOpenChange: t3,
1660
- children: t9
1795
+ onOpenChange: t4,
1796
+ children: t16
1661
1797
  });
1662
- $[22] = open;
1663
- $[23] = t3;
1664
- $[24] = t9;
1665
- $[25] = t10;
1666
- } else t10 = $[25];
1667
- return t10;
1798
+ $[32] = open;
1799
+ $[33] = t16;
1800
+ $[34] = t4;
1801
+ $[35] = t17;
1802
+ } else t17 = $[35];
1803
+ return t17;
1668
1804
  }
1669
- function _temp11(error) {
1805
+ function _temp14(error) {
1670
1806
  return toast.error(error.message || "Could not delete the draft");
1671
1807
  }
1672
1808
 
1673
1809
  //#endregion
1674
- export { DeleteDraftDialog, ReviewDraftSheet, useLeaveDraft };
1810
+ export { DeleteDraftDialog, ReviewDraftSheet, useLeaveDraft, useRenameDraft };