@mgamadeus/ddd-design-studio 0.4.0 → 0.5.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.
@@ -1,12 +1,16 @@
1
1
  'use client';
2
2
  import {
3
+ BoardComments,
3
4
  CODE_PARAM,
4
5
  FRAME_GAP,
5
6
  FRAME_LABEL_HEIGHT,
7
+ ViewportToolbar,
8
+ WidthDragHandle,
6
9
  boardCanvasSize,
7
10
  boardCodeOf,
8
11
  buildBoardCodeLink,
9
12
  buildBoardDeepLink,
13
+ buildCommentThreads,
10
14
  buildDesignReference,
11
15
  buildThemeReference,
12
16
  copyTextToClipboard,
@@ -19,21 +23,21 @@ import {
19
23
  isResponsiveBoard,
20
24
  normalizeBoardCode,
21
25
  pageHeightAtWidth,
22
- rotateViewport,
23
26
  splitThemeReference,
27
+ useCheckedContentUrl,
24
28
  useDesignStudio,
25
29
  useDesignStudioComponents,
26
30
  useDesignStudioTexts,
27
- viewportLabel,
31
+ useImageRetry,
28
32
  viewportOfComment,
29
- viewportOfDevice,
30
- viewportWithWidth
31
- } from "../chunk-YYKTDLFF.js";
33
+ viewportWithWidth,
34
+ wasContentUrlLoaded
35
+ } from "../chunk-NCMXGWLC.js";
32
36
 
33
37
  // src/canvas/DesignStudioCanvasScreen.tsx
34
- import { normalizeDddError as normalizeDddError3 } from "@mgamadeus/ddd-web/api";
38
+ import { normalizeDddError as normalizeDddError2 } from "@mgamadeus/ddd-web/api";
35
39
  import {
36
- ClipboardCopy as ClipboardCopy4,
40
+ ClipboardCopy as ClipboardCopy3,
37
41
  ImageDown,
38
42
  Link2,
39
43
  ListFilter,
@@ -48,397 +52,27 @@ import {
48
52
  RefreshCw,
49
53
  Sun,
50
54
  FoldVertical,
55
+ Globe,
51
56
  UnfoldVertical
52
57
  } from "lucide-react";
53
- import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useRef as useRef4, useState as useState8 } from "react";
54
-
55
- // src/canvas/BoardComments.tsx
56
- import { normalizeDddError } from "@mgamadeus/ddd-web/api";
57
- import { Bot, CheckCircle2, ClipboardCopy, Flag, History, Hourglass, MapPin, RotateCcw, Trash2 } from "lucide-react";
58
- import { useState } from "react";
59
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
60
- var buildCommentThreads = (comments) => {
61
- const repliesByRootId = /* @__PURE__ */ new Map();
62
- for (const comment of comments) {
63
- if (comment.parentDesignStudioCommentId != null) {
64
- const replies = repliesByRootId.get(comment.parentDesignStudioCommentId) ?? [];
65
- replies.push(comment);
66
- repliesByRootId.set(comment.parentDesignStudioCommentId, replies);
67
- }
68
- }
69
- let pinNumber = 0;
70
- return comments.filter((comment) => comment.parentDesignStudioCommentId == null).map((root) => ({
71
- root,
72
- replies: repliesByRootId.get(Number(root.id)) ?? [],
73
- pinNumber: root.x != null && root.y != null ? ++pinNumber : null
74
- }));
75
- };
76
- var errorMessage = (error) => normalizeDddError(error, "Request failed").message;
77
- var CommentLine = ({ comment, isOwn, writesAllowed }) => {
78
- const { api, components, formatDateTime, notify } = useDesignStudio();
79
- const { Button } = components;
80
- const [deleteComment, { isLoading: isDeleting }] = api.useDeleteCommentMutation();
81
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
82
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [
83
- comment.authorKind === "AGENT" && /* @__PURE__ */ jsx(Bot, { className: "size-3.5 text-brand-emphasis", "aria-label": "Agent" }),
84
- /* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground", children: comment.authorName ?? "Unknown" }),
85
- /* @__PURE__ */ jsxs("span", { children: [
86
- "\xB7 ",
87
- formatDateTime(comment.changeHistory?.createdTime)
88
- ] }),
89
- isOwn && /* @__PURE__ */ jsx(
90
- Button,
91
- {
92
- variant: "ghost",
93
- size: "icon-sm",
94
- className: "ml-auto size-6",
95
- "aria-label": "Delete comment",
96
- disabled: !writesAllowed || isDeleting,
97
- onClick: () => deleteComment({ designStudioCommentId: Number(comment.id) }).unwrap().catch((error) => notify.error(errorMessage(error))),
98
- children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
99
- }
100
- )
101
- ] }),
102
- /* @__PURE__ */ jsx("p", { className: "text-sm whitespace-pre-wrap break-words", children: comment.text })
103
- ] });
104
- };
105
- var ThreadCard = ({
106
- thread,
107
- onCopyReference,
108
- isHighlighted,
109
- onHighlight,
110
- authAccountId,
111
- writesAllowed,
112
- hasBoardChangedSince,
113
- isExpiring,
114
- onSelectViewport
115
- }) => {
116
- const { root, replies, pinNumber } = thread;
117
- const rootViewport = viewportOfComment(root);
118
- const [replyText, setReplyText] = useState("");
119
- const { api, components, notify } = useDesignStudio();
120
- const { Badge, Button, Textarea } = components;
121
- const [createReply, { isLoading: isReplying }] = api.useReplyToCommentMutation();
122
- const [resolveThread, { isLoading: isResolving }] = api.useResolveCommentMutation();
123
- const [reopenThread, { isLoading: isReopening }] = api.useReopenCommentMutation();
124
- const [patchComment, { isLoading: isPatching }] = api.usePatchCommentMutation();
125
- const [keepThread, { isLoading: isKeeping }] = api.useKeepCommentMutation();
126
- const designStudioCommentId = Number(root.id);
127
- const sendReply = async () => {
128
- try {
129
- await createReply({
130
- designStudioCommentId,
131
- body: { text: replyText }
132
- }).unwrap();
133
- setReplyText("");
134
- } catch (error) {
135
- notify.error(errorMessage(error));
136
- }
137
- };
138
- return (
139
- // biome-ignore lint/a11y/useSemanticElements: an article that highlights its pin on hover / focus, not a control
140
- /* @__PURE__ */ jsxs(
141
- "article",
142
- {
143
- className: cx(
144
- "space-y-3 rounded-2xl bg-card p-4 shadow-surface-raised ring-1 ring-foreground/5",
145
- root.isResolved && "opacity-70",
146
- isHighlighted && "ring-2 ring-brand"
147
- ),
148
- onMouseEnter: onHighlight,
149
- onFocus: onHighlight,
150
- role: "group",
151
- "aria-label": `Comment thread${pinNumber ? ` ${pinNumber}` : ""}`,
152
- children: [
153
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [
154
- pinNumber !== null ? /* @__PURE__ */ jsxs(Badge, { className: "bg-primary text-primary-foreground", children: [
155
- /* @__PURE__ */ jsx(MapPin, { "aria-hidden": true }),
156
- " ",
157
- pinNumber
158
- ] }) : /* @__PURE__ */ jsx(Badge, { variant: "outline", children: "Board" }),
159
- rootViewport && /* @__PURE__ */ jsxs(
160
- "button",
161
- {
162
- type: "button",
163
- className: "rounded-full bg-tint px-2 py-0.5 text-xs font-medium text-muted-foreground tabular-nums hover:bg-tint-strong hover:text-foreground disabled:cursor-default",
164
- title: "Pinned in this viewport: show the board in it",
165
- disabled: !onSelectViewport,
166
- onClick: () => onSelectViewport?.(rootViewport),
167
- children: [
168
- rootViewport.width,
169
- " \xD7 ",
170
- rootViewport.height,
171
- rootViewport.deviceKey ? ` \xB7 ${rootViewport.deviceKey}` : ""
172
- ]
173
- }
174
- ),
175
- root.isDecision && /* @__PURE__ */ jsxs(Badge, { variant: "outline", className: "border-transparent bg-success/15 text-success", children: [
176
- /* @__PURE__ */ jsx(Flag, { "aria-hidden": true }),
177
- " Decision"
178
- ] }),
179
- root.isResolved && /* @__PURE__ */ jsxs(Badge, { variant: "outline", className: "border-transparent bg-tint text-muted-foreground", children: [
180
- "Resolved",
181
- root.resolvedByName ? ` by ${root.resolvedByName}` : ""
182
- ] }),
183
- hasBoardChangedSince && /* @__PURE__ */ jsxs(
184
- Badge,
185
- {
186
- variant: "outline",
187
- className: "border-transparent bg-warning/15 text-warning",
188
- title: "The board file is another version than the one this thread was written on",
189
- children: [
190
- /* @__PURE__ */ jsx(History, { "aria-hidden": true }),
191
- " Board changed since"
192
- ]
193
- }
194
- ),
195
- isExpiring && /* @__PURE__ */ jsxs(
196
- Badge,
197
- {
198
- variant: "outline",
199
- className: "border-transparent bg-tint text-muted-foreground",
200
- title: "Idle threads are deleted; \u201CKeep\u201D or any reply postpones that",
201
- children: [
202
- /* @__PURE__ */ jsx(Hourglass, { "aria-hidden": true }),
203
- " Expires soon"
204
- ]
205
- }
206
- )
207
- ] }),
208
- /* @__PURE__ */ jsx(CommentLine, { comment: root, isOwn: authAccountId !== null && root.authorAccountId === authAccountId, writesAllowed }),
209
- replies.map((reply) => /* @__PURE__ */ jsx("div", { className: "border-l-2 border-border pl-3", children: /* @__PURE__ */ jsx(
210
- CommentLine,
211
- {
212
- comment: reply,
213
- isOwn: authAccountId !== null && reply.authorAccountId === authAccountId,
214
- writesAllowed
215
- }
216
- ) }, String(reply.id))),
217
- /* @__PURE__ */ jsx(
218
- Textarea,
219
- {
220
- value: replyText,
221
- onChange: (event) => setReplyText(event.target.value),
222
- placeholder: "Reply\u2026",
223
- rows: 2,
224
- "aria-label": "Reply",
225
- disabled: !writesAllowed
226
- }
227
- ),
228
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
229
- /* @__PURE__ */ jsx(Button, { size: "sm", variant: "outline", disabled: !writesAllowed || !replyText.trim() || isReplying, onClick: sendReply, children: "Reply" }),
230
- /* @__PURE__ */ jsxs(
231
- Button,
232
- {
233
- size: "sm",
234
- variant: "outline",
235
- disabled: !writesAllowed || isPatching,
236
- "aria-pressed": Boolean(root.isDecision),
237
- onClick: () => patchComment({
238
- designStudioCommentId,
239
- body: { isDecision: !root.isDecision }
240
- }).unwrap().catch((error) => notify.error(errorMessage(error))),
241
- children: [
242
- /* @__PURE__ */ jsx(Flag, {}),
243
- " ",
244
- root.isDecision ? "Not a decision" : "Decision"
245
- ]
246
- }
247
- ),
248
- /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: () => onCopyReference(thread), "aria-label": "Copy for agent", children: [
249
- /* @__PURE__ */ jsx(ClipboardCopy, {}),
250
- " Copy for agent"
251
- ] }),
252
- isExpiring && /* @__PURE__ */ jsx(
253
- Button,
254
- {
255
- size: "sm",
256
- variant: "outline",
257
- disabled: !writesAllowed || isKeeping,
258
- onClick: () => keepThread({ designStudioCommentId }).unwrap().catch((error) => notify.error(errorMessage(error))),
259
- children: "Keep"
260
- }
261
- ),
262
- root.isResolved ? /* @__PURE__ */ jsxs(
263
- Button,
264
- {
265
- size: "sm",
266
- variant: "outline",
267
- className: "ml-auto",
268
- disabled: !writesAllowed || isReopening,
269
- onClick: () => reopenThread({ designStudioCommentId }).unwrap().catch((error) => notify.error(errorMessage(error))),
270
- children: [
271
- /* @__PURE__ */ jsx(RotateCcw, {}),
272
- " Reopen"
273
- ]
274
- }
275
- ) : /* @__PURE__ */ jsxs(
276
- Button,
277
- {
278
- size: "sm",
279
- variant: "outline",
280
- className: "ml-auto",
281
- disabled: !writesAllowed || isResolving,
282
- onClick: async () => {
283
- try {
284
- await resolveThread({
285
- designStudioCommentId,
286
- body: { replyText: replyText.trim() ? replyText : null }
287
- }).unwrap();
288
- setReplyText("");
289
- } catch (error) {
290
- notify.error(errorMessage(error));
291
- }
292
- },
293
- children: [
294
- /* @__PURE__ */ jsx(CheckCircle2, {}),
295
- " Resolve"
296
- ]
297
- }
298
- )
299
- ] })
300
- ]
301
- }
302
- )
303
- );
304
- };
305
- var BoardComments = ({
306
- projectKey,
307
- canvasKey,
308
- board,
309
- threads,
310
- pendingPin,
311
- onClearPendingPin,
312
- highlightedCommentId,
313
- onHighlightComment,
314
- writesAllowed,
315
- showResolved,
316
- onShowResolvedChange,
317
- pinHint,
318
- onCopyThreadReference,
319
- onSelectViewport
320
- }) => {
321
- const [text, setText] = useState("");
322
- const [isDecision, setIsDecision] = useState(false);
323
- const { api, components, notify, useCurrentAccountId } = useDesignStudio();
324
- const { Button, Checkbox, Label, Textarea } = components;
325
- const [createComment, { isLoading }] = api.useCreateCommentMutation();
326
- const authAccountId = useCurrentAccountId();
327
- const { data: expiringData } = api.useExpiringCommentsQuery();
328
- const expiringCommentIds = new Set(
329
- (expiringData?.designStudioComments.elements ?? []).map((comment) => Number(comment.id))
330
- );
331
- const visibleThreads = showResolved ? threads : threads.filter((thread) => !thread.root.isResolved);
332
- const resolvedCount = threads.length - threads.filter((thread) => !thread.root.isResolved).length;
333
- const addComment = async () => {
334
- try {
335
- await createComment({
336
- projectKey,
337
- canvasKey,
338
- boardKey: board.boardKey ?? "",
339
- body: {
340
- text,
341
- x: pendingPin?.x ?? null,
342
- y: pendingPin?.y ?? null,
343
- viewportWidth: pendingPin?.viewport?.width ?? null,
344
- viewportHeight: pendingPin?.viewport?.height ?? null,
345
- deviceKey: pendingPin?.viewport?.deviceKey ?? null,
346
- isDecision
347
- }
348
- }).unwrap();
349
- setText("");
350
- setIsDecision(false);
351
- onClearPendingPin();
352
- } catch (error) {
353
- notify.error(errorMessage(error));
354
- }
355
- };
356
- return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
357
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
358
- /* @__PURE__ */ jsx(Label, { htmlFor: "design-comment-text", className: "flex items-center gap-1.5", children: pendingPin ? /* @__PURE__ */ jsxs(Fragment, { children: [
359
- /* @__PURE__ */ jsx(MapPin, { className: "size-4 text-brand-emphasis", "aria-hidden": true }),
360
- " Comment at the placed pin"
361
- ] }) : "New comment on the board" }),
362
- /* @__PURE__ */ jsx(
363
- Textarea,
364
- {
365
- id: "design-comment-text",
366
- value: text,
367
- onChange: (event) => setText(event.target.value),
368
- placeholder: pendingPin ? "What should change here?" : `Comment\u2026 (${pinHint})`,
369
- rows: 3,
370
- disabled: !writesAllowed
371
- }
372
- ),
373
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
374
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
375
- /* @__PURE__ */ jsx(
376
- Checkbox,
377
- {
378
- id: "design-comment-decision",
379
- checked: isDecision,
380
- onCheckedChange: (checked) => setIsDecision(checked === true),
381
- disabled: !writesAllowed
382
- }
383
- ),
384
- /* @__PURE__ */ jsx(Label, { htmlFor: "design-comment-decision", className: "font-normal", children: "Decision" })
385
- ] }),
386
- pendingPin && /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: onClearPendingPin, children: "Remove pin" }),
387
- /* @__PURE__ */ jsx(Button, { size: "sm", className: "ml-auto", disabled: !writesAllowed || !text.trim() || isLoading || !board.boardKey, onClick: addComment, children: "Comment" })
388
- ] })
389
- ] }),
390
- resolvedCount > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
391
- /* @__PURE__ */ jsx(
392
- Checkbox,
393
- {
394
- id: "design-comment-show-resolved",
395
- checked: showResolved,
396
- onCheckedChange: (checked) => onShowResolvedChange(checked === true)
397
- }
398
- ),
399
- /* @__PURE__ */ jsxs(Label, { htmlFor: "design-comment-show-resolved", className: "font-normal text-muted-foreground", children: [
400
- "Show ",
401
- resolvedCount,
402
- " resolved"
403
- ] })
404
- ] }),
405
- visibleThreads.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No open comments on this board." }),
406
- visibleThreads.map((thread) => /* @__PURE__ */ jsx(
407
- ThreadCard,
408
- {
409
- thread,
410
- onCopyReference: onCopyThreadReference,
411
- onSelectViewport,
412
- isHighlighted: highlightedCommentId === Number(thread.root.id),
413
- onHighlight: () => onHighlightComment(Number(thread.root.id)),
414
- authAccountId,
415
- writesAllowed,
416
- hasBoardChangedSince: Boolean(thread.root.contentHash && board.contentHash) && thread.root.contentHash !== board.contentHash,
417
- isExpiring: expiringCommentIds.has(Number(thread.root.id))
418
- },
419
- String(thread.root.id)
420
- ))
421
- ] });
422
- };
58
+ import { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo2, useRef as useRef4, useState as useState7 } from "react";
423
59
 
424
60
  // src/canvas/BoardFocusView.tsx
425
61
  import {
426
62
  ChevronLeft,
427
63
  ChevronRight,
428
- ClipboardCopy as ClipboardCopy3,
429
- MapPin as MapPin2,
64
+ ClipboardCopy as ClipboardCopy2,
65
+ MapPin,
430
66
  MapPinPlus,
431
- RotateCw,
432
- Smartphone,
433
67
  SquareDashedMousePointer,
434
68
  X
435
69
  } from "lucide-react";
436
- import { useEffect as useEffect4, useRef as useRef2, useState as useState6 } from "react";
70
+ import { useEffect as useEffect3, useRef as useRef2, useState as useState5 } from "react";
437
71
 
438
72
  // src/canvas/BoardNode.tsx
439
73
  import { useStore } from "@xyflow/react";
440
- import { ClipboardCopy as ClipboardCopy2, Download, Maximize2, MessageSquare } from "lucide-react";
441
- import { memo, useEffect as useEffect3, useRef, useState as useState5 } from "react";
74
+ import { ClipboardCopy, Download, Maximize2, MessageSquare } from "lucide-react";
75
+ import { memo, useEffect as useEffect2, useRef, useState as useState4 } from "react";
442
76
 
443
77
  // src/canvas/boardStatus.ts
444
78
  var boardStatusDefinition = (statuses, status) => statuses[status];
@@ -446,10 +80,20 @@ var boardStatusLabel = (statuses, status) => boardStatusDefinition(statuses, sta
446
80
 
447
81
  // src/canvas/boardDetail.ts
448
82
  var SMALL_THUMBNAIL_MAX_RENDERED_WIDTH = 130;
83
+ var PREVIEW_THUMBNAIL_MAX_RENDERED_WIDTH = 800;
449
84
  var LIVE_MIN_RENDERED_WIDTH_RATIO = 0.6;
450
85
  var LIVE_MIN_RENDERED_WIDTH_RATIO_WITHOUT_THUMBNAILS = 0.35;
451
86
  var MAX_LIVE_BOARDS = 6;
452
- var thumbnailVariantForZoom = (zoom, boardWidth) => boardWidth * zoom <= SMALL_THUMBNAIL_MAX_RENDERED_WIDTH ? "small" : "default";
87
+ var thumbnailVariantForZoom = (zoom, boardWidth) => {
88
+ const renderedWidth = boardWidth * zoom;
89
+ if (renderedWidth <= SMALL_THUMBNAIL_MAX_RENDERED_WIDTH) return "small";
90
+ return renderedWidth <= PREVIEW_THUMBNAIL_MAX_RENDERED_WIDTH ? "preview" : "default";
91
+ };
92
+ var thumbnailUrlForVariant = (urls, variant) => {
93
+ if (variant === "small") return urls.thumbnailSmallUrl ?? urls.thumbnailPreviewUrl ?? urls.thumbnailUrl ?? null;
94
+ if (variant === "preview") return urls.thumbnailPreviewUrl ?? urls.thumbnailUrl ?? null;
95
+ return urls.thumbnailUrl ?? null;
96
+ };
453
97
  var isZoomLiveCapable = (zoom, minRatio = LIVE_MIN_RENDERED_WIDTH_RATIO) => zoom >= minRatio;
454
98
  var selectLiveBoardIds = (boards, viewport, screen, maxLiveBoards = MAX_LIVE_BOARDS, minRatio = LIVE_MIN_RENDERED_WIDTH_RATIO) => {
455
99
  if (!isZoomLiveCapable(viewport.zoom, minRatio) || screen.width <= 0 || screen.height <= 0) {
@@ -689,116 +333,8 @@ var useCanvasView = () => {
689
333
  var boardNodeId = (boardKey) => `board-${boardKey}`;
690
334
  var sectionNodeId = (sectionKey) => `section-${sectionKey}`;
691
335
 
692
- // src/canvas/useCheckedContentUrl.ts
693
- import { useEffect, useState as useState2 } from "react";
694
- var MAX_CONCURRENT_LOADS = 2;
695
- var RETRY_DELAYS_MS = [2e3, 5e3, 15e3, 3e4];
696
- var MAX_REMEMBERED_URLS = 24;
697
- var loadedUrls = /* @__PURE__ */ new Set();
698
- var rememberLoadedUrl = (url) => {
699
- loadedUrls.delete(url);
700
- loadedUrls.add(url);
701
- while (loadedUrls.size > MAX_REMEMBERED_URLS) {
702
- const oldestUrl = loadedUrls.values().next().value;
703
- if (oldestUrl === void 0) break;
704
- loadedUrls.delete(oldestUrl);
705
- }
706
- };
707
- var wasContentUrlLoaded = (url) => Boolean(url && loadedUrls.has(url));
708
- var activeLoads = 0;
709
- var waitingLoads = [];
710
- var acquireLoadSlot = () => new Promise((resolve) => {
711
- if (activeLoads < MAX_CONCURRENT_LOADS) {
712
- activeLoads += 1;
713
- resolve();
714
- return;
715
- }
716
- waitingLoads.push(() => {
717
- activeLoads += 1;
718
- resolve();
719
- });
720
- });
721
- var releaseLoadSlot = () => {
722
- activeLoads -= 1;
723
- waitingLoads.shift()?.();
724
- };
725
- var loadUrl = async (url, signal) => {
726
- await acquireLoadSlot();
727
- try {
728
- if (signal.aborted) return false;
729
- const response = await fetch(url, { signal, credentials: "omit", referrerPolicy: "no-referrer" });
730
- if (!response.ok) return false;
731
- await response.blob();
732
- return true;
733
- } catch {
734
- return false;
735
- } finally {
736
- releaseLoadSlot();
737
- }
738
- };
739
- var useCheckedContentUrl = (url) => {
740
- const [checkedUrl, setCheckedUrl] = useState2(
741
- () => url && loadedUrls.has(url) ? url : void 0
742
- );
743
- useEffect(() => {
744
- if (!url) {
745
- setCheckedUrl(void 0);
746
- return;
747
- }
748
- if (loadedUrls.has(url)) {
749
- rememberLoadedUrl(url);
750
- setCheckedUrl(url);
751
- return;
752
- }
753
- setCheckedUrl(void 0);
754
- const abortController = new AbortController();
755
- let retryTimer;
756
- let attempt = 0;
757
- const tryLoad = async () => {
758
- const isLoaded = await loadUrl(url, abortController.signal);
759
- if (abortController.signal.aborted) return;
760
- if (isLoaded) {
761
- rememberLoadedUrl(url);
762
- setCheckedUrl(url);
763
- return;
764
- }
765
- const delay = RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];
766
- attempt += 1;
767
- retryTimer = setTimeout(tryLoad, delay);
768
- };
769
- void tryLoad();
770
- return () => {
771
- abortController.abort();
772
- if (retryTimer) clearTimeout(retryTimer);
773
- };
774
- }, [url]);
775
- return checkedUrl;
776
- };
777
- var useImageRetry = (url) => {
778
- const [attempt, setAttempt] = useState2(0);
779
- const [isFailed, setIsFailed] = useState2(false);
780
- const [previousUrl, setPreviousUrl] = useState2(url);
781
- if (url !== previousUrl) {
782
- setPreviousUrl(url);
783
- setAttempt(0);
784
- setIsFailed(false);
785
- }
786
- useEffect(() => {
787
- if (!isFailed) return;
788
- const retryTimer = setTimeout(
789
- () => {
790
- setIsFailed(false);
791
- setAttempt((previousAttempt) => previousAttempt + 1);
792
- },
793
- RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)]
794
- );
795
- return () => clearTimeout(retryTimer);
796
- }, [isFailed, attempt]);
797
- return { imageKey: `${url ?? ""}#${attempt}`, isFailed, onError: () => setIsFailed(true) };
798
- };
799
-
800
336
  // src/canvas/useDeferredMount.ts
801
- import { useEffect as useEffect2, useState as useState3 } from "react";
337
+ import { useEffect, useState } from "react";
802
338
  var MOUNTS_PER_FRAME = 12;
803
339
  var queue = [];
804
340
  var isScheduled = false;
@@ -813,8 +349,8 @@ var schedule = () => {
813
349
  requestAnimationFrame(flush);
814
350
  };
815
351
  var useDeferredMount = () => {
816
- const [isMounted, setIsMounted] = useState3(false);
817
- useEffect2(() => {
352
+ const [isMounted, setIsMounted] = useState(false);
353
+ useEffect(() => {
818
354
  let isActive = true;
819
355
  const mount = () => {
820
356
  if (isActive) setIsMounted(true);
@@ -830,8 +366,11 @@ var useDeferredMount = () => {
830
366
  return isMounted;
831
367
  };
832
368
 
369
+ // src/canvas/CanvasThumbnail.tsx
370
+ import { useState as useState3 } from "react";
371
+
833
372
  // src/canvas/stableContentUrl.ts
834
- import { useState as useState4 } from "react";
373
+ import { useState as useState2 } from "react";
835
374
  var EXPIRY_MARGIN_SECONDS = 120;
836
375
  var urlByContentKey = /* @__PURE__ */ new Map();
837
376
  var expiryByToken = /* @__PURE__ */ new Map();
@@ -865,7 +404,7 @@ var resolveStableContentUrl = (url) => {
865
404
  return url;
866
405
  };
867
406
  var useStableContentUrl = (url, isDisplayed = false) => {
868
- const [shownUrl, setShownUrl] = useState4(() => url ? resolveStableContentUrl(url) : void 0);
407
+ const [shownUrl, setShownUrl] = useState2(() => url ? resolveStableContentUrl(url) : void 0);
869
408
  if (!url) {
870
409
  if (shownUrl !== void 0) setShownUrl(void 0);
871
410
  return void 0;
@@ -878,9 +417,55 @@ var useStableContentUrl = (url, isDisplayed = false) => {
878
417
  return nextUrl;
879
418
  };
880
419
 
420
+ // src/canvas/CanvasThumbnail.tsx
421
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
422
+ var isSameContent = (first, second) => Boolean(first && second) && withoutContentToken(first) === withoutContentToken(second);
423
+ var CanvasThumbnail = ({ urls, variant, title, imageClassName, isCompact }) => {
424
+ const { apiBaseUrl } = useDesignStudio();
425
+ const texts = useDesignStudioTexts();
426
+ const path = thumbnailUrlForVariant(urls, variant);
427
+ const latestUrl = path ? `${apiBaseUrl}${path}` : void 0;
428
+ const [loadedUrl, setLoadedUrl] = useState3(null);
429
+ const url = useStableContentUrl(latestUrl, isSameContent(loadedUrl, latestUrl));
430
+ const retry = useImageRetry(url);
431
+ if (!url) return null;
432
+ const isLoaded = isSameContent(loadedUrl, url);
433
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
434
+ !loadedUrl && /* @__PURE__ */ jsx(
435
+ "span",
436
+ {
437
+ className: cx(
438
+ "pointer-events-none absolute inset-0 flex flex-col items-center justify-start gap-2 bg-tint px-6 pt-16 text-center text-muted-foreground",
439
+ "animate-pulse motion-reduce:animate-none"
440
+ ),
441
+ children: !isCompact && /* @__PURE__ */ jsxs(Fragment, { children: [
442
+ /* @__PURE__ */ jsx("span", { className: "line-clamp-2 text-[19px] font-semibold", children: title }),
443
+ /* @__PURE__ */ jsx("span", { className: "text-[16px]", children: texts.thumbnailLoading })
444
+ ] })
445
+ }
446
+ ),
447
+ loadedUrl && !isLoaded && // biome-ignore lint/performance/noImgElement: the picture shown before, from the browser cache, under the next one
448
+ /* @__PURE__ */ jsx("img", { src: loadedUrl, alt: "", draggable: false, className: cx("pointer-events-none select-none", imageClassName) }),
449
+ /* @__PURE__ */ jsx(
450
+ "img",
451
+ {
452
+ src: url,
453
+ alt: "",
454
+ loading: "lazy",
455
+ decoding: "async",
456
+ draggable: false,
457
+ onError: retry.onError,
458
+ onLoad: () => setLoadedUrl(url),
459
+ className: cx("pointer-events-none select-none", imageClassName, (retry.isFailed || !isLoaded) && "opacity-0")
460
+ },
461
+ retry.imageKey
462
+ )
463
+ ] });
464
+ };
465
+
881
466
  // src/canvas/BoardNode.tsx
882
467
  import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
883
- var isSameContent = (first, second) => Boolean(first && second) && withoutContentToken(first) === withoutContentToken(second);
468
+ var isSameContent2 = (first, second) => Boolean(first && second) && withoutContentToken(first) === withoutContentToken(second);
884
469
  var designContentUrl = (apiBaseUrl, path) => path ? `${apiBaseUrl}${path}` : void 0;
885
470
  var downloadName = (board, extension) => `${boardCodeOf(board.boardKey ?? "board")}.${extension}`;
886
471
  var CLICK_MAX_MOVE = 5;
@@ -916,25 +501,18 @@ var BoardNodeComponent = ({ id, data }) => {
916
501
  const openThreads = openThreadCounts.get(id) ?? 0;
917
502
  const isReady = useDeferredMount();
918
503
  const isThumbnailMissing = !isResponsive && !board.thumbnailUrl;
919
- const latestThumbnailUrl = designContentUrl(
920
- apiBaseUrl,
921
- thumbnailVariant === "small" ? board.thumbnailSmallUrl ?? board.thumbnailUrl : board.thumbnailUrl
922
- );
923
504
  const latestHtmlUrl = designContentUrl(apiBaseUrl, board.htmlUrl);
924
- const [loadedImageUrl, setLoadedImageUrl] = useState5(null);
925
- const [loadedFrameUrl, setLoadedFrameUrl] = useState5(null);
926
- const thumbnailUrl = useStableContentUrl(latestThumbnailUrl, isSameContent(loadedImageUrl, latestThumbnailUrl));
927
- const htmlUrl = useStableContentUrl(latestHtmlUrl, isSameContent(loadedFrameUrl, latestHtmlUrl));
928
- const isRememberedLive = isThumbnailMissing && thumbnailVariant === "default" && isReady && wasContentUrlLoaded(htmlUrl);
505
+ const [loadedFrameUrl, setLoadedFrameUrl] = useState4(null);
506
+ const htmlUrl = useStableContentUrl(latestHtmlUrl, isSameContent2(loadedFrameUrl, latestHtmlUrl));
507
+ const isRememberedLive = isThumbnailMissing && thumbnailVariant !== "small" && isReady && wasContentUrlLoaded(htmlUrl);
929
508
  const showsLiveHtml = isLive || isRememberedLive;
930
509
  const liveHtmlUrl = useCheckedContentUrl(showsLiveHtml && isReady ? htmlUrl : void 0);
931
- const thumbnailRetry = useImageRetry(thumbnailUrl);
932
- useEffect3(() => {
510
+ useEffect2(() => {
933
511
  if (!liveHtmlUrl) setLoadedFrameUrl(null);
934
512
  }, [liveHtmlUrl]);
935
513
  const title = board.title ?? board.boardKey ?? "";
936
514
  const boardCode = board.code ?? boardCodeOf(board.boardKey ?? "");
937
- const [isDownloadOpen, setIsDownloadOpen] = useState5(false);
515
+ const [isDownloadOpen, setIsDownloadOpen] = useState4(false);
938
516
  const pressPointRef = useRef(null);
939
517
  const isCompact = thumbnailVariant === "small";
940
518
  if (!isReady) {
@@ -967,7 +545,7 @@ var BoardNodeComponent = ({ id, data }) => {
967
545
  "aria-label": `Copy reference of ${title} for an agent`,
968
546
  title: "Copy reference (C)",
969
547
  onClick: () => onCopyReference(id),
970
- children: /* @__PURE__ */ jsx2(ClipboardCopy2, { className: "size-5" })
548
+ children: /* @__PURE__ */ jsx2(ClipboardCopy, { className: "size-5" })
971
549
  }
972
550
  ),
973
551
  !isCompact && /* @__PURE__ */ jsx2(
@@ -1047,25 +625,15 @@ var BoardNodeComponent = ({ id, data }) => {
1047
625
  title
1048
626
  }
1049
627
  ),
1050
- !isResponsive && thumbnailUrl && // biome-ignore lint/performance/noImgElement: canvas thumbnails are API images at canvas scale, next/image cannot optimise them
1051
- /* @__PURE__ */ jsx2(
1052
- "img",
628
+ !isResponsive && !isThumbnailMissing && /* @__PURE__ */ jsx2(
629
+ CanvasThumbnail,
1053
630
  {
1054
- src: thumbnailUrl,
1055
- alt: "",
1056
- width,
1057
- height,
1058
- loading: "lazy",
1059
- decoding: "async",
1060
- draggable: false,
1061
- onError: thumbnailRetry.onError,
1062
- onLoad: () => setLoadedImageUrl(thumbnailUrl),
1063
- className: cx(
1064
- "pointer-events-none absolute inset-0 h-full w-full object-cover object-top select-none",
1065
- thumbnailRetry.isFailed && "invisible"
1066
- )
1067
- },
1068
- thumbnailRetry.imageKey
631
+ urls: board,
632
+ variant: thumbnailVariant,
633
+ title,
634
+ imageClassName: "absolute inset-0 h-full w-full object-cover object-top",
635
+ isCompact
636
+ }
1069
637
  ),
1070
638
  isThumbnailMissing && !isCompact && !(showsLiveHtml && liveHtmlUrl) && /* @__PURE__ */ jsx2("span", { className: "pointer-events-none absolute inset-0 flex items-center justify-center px-6 text-center text-[17px] font-semibold text-muted-foreground", children: texts.thumbnailMissing }),
1071
639
  !isResponsive && showsLiveHtml && liveHtmlUrl && /* @__PURE__ */ jsx2(
@@ -1152,17 +720,12 @@ var ResponsiveBoardFrame = ({
1152
720
  htmlUrl,
1153
721
  title
1154
722
  }) => {
1155
- const { apiBaseUrl } = useDesignStudio();
1156
723
  const texts = useDesignStudioTexts();
1157
724
  const frameWidth = frame.width ?? 0;
1158
725
  const frameHeight = frameCanvasHeight(frame, frameHeightMode);
1159
- const latestThumbnailUrl = designContentUrl(
1160
- apiBaseUrl,
1161
- thumbnailVariant === "small" ? frame.thumbnailSmallUrl ?? frame.thumbnailUrl : frame.thumbnailUrl
726
+ const frameThumbnailVariant = useStore(
727
+ (state) => thumbnailVariant === "small" ? "small" : thumbnailVariantForZoom(state.transform[2], frameWidth)
1162
728
  );
1163
- const [loadedImageUrl, setLoadedImageUrl] = useState5(null);
1164
- const thumbnailUrl = useStableContentUrl(latestThumbnailUrl, isSameContent(loadedImageUrl, latestThumbnailUrl));
1165
- const thumbnailRetry = useImageRetry(thumbnailUrl);
1166
729
  const liveHtmlUrl = useCheckedContentUrl(showsLiveHtml ? htmlUrl : void 0);
1167
730
  const isCut = frameHeightMode === "page" && (frame.pageHeight ?? 0) > frameHeight;
1168
731
  return /* @__PURE__ */ jsxs2("div", { className: "absolute top-0", style: { left, width: frameWidth }, children: [
@@ -1181,23 +744,15 @@ var ResponsiveBoardFrame = ({
1181
744
  className: "relative overflow-hidden rounded-[20px] bg-card shadow-surface-raised ring-1 ring-foreground/10",
1182
745
  style: { width: frameWidth, height: frameHeight },
1183
746
  children: [
1184
- thumbnailUrl && // biome-ignore lint/performance/noImgElement: canvas thumbnails are API images at canvas scale
1185
- /* @__PURE__ */ jsx2(
1186
- "img",
747
+ frame.thumbnailUrl && /* @__PURE__ */ jsx2(
748
+ CanvasThumbnail,
1187
749
  {
1188
- src: thumbnailUrl,
1189
- alt: "",
1190
- loading: "lazy",
1191
- decoding: "async",
1192
- draggable: false,
1193
- onError: thumbnailRetry.onError,
1194
- onLoad: () => setLoadedImageUrl(thumbnailUrl),
1195
- className: cx(
1196
- "pointer-events-none absolute inset-x-0 top-0 w-full select-none",
1197
- thumbnailRetry.isFailed && "invisible"
1198
- )
1199
- },
1200
- thumbnailRetry.imageKey
750
+ urls: frame,
751
+ variant: frameThumbnailVariant,
752
+ title: `${title} \xB7 ${deviceLabel}`,
753
+ imageClassName: "absolute inset-x-0 top-0 w-full",
754
+ isCompact: thumbnailVariant === "small"
755
+ }
1201
756
  ),
1202
757
  !frame.thumbnailUrl && !(showsLiveHtml && liveHtmlUrl) && thumbnailVariant !== "small" && /* @__PURE__ */ jsx2("span", { className: "pointer-events-none absolute inset-0 flex items-center justify-center px-6 text-center text-[17px] font-semibold text-muted-foreground", children: texts.thumbnailMissing }),
1203
758
  showsLiveHtml && liveHtmlUrl && /* @__PURE__ */ jsx2(
@@ -1225,7 +780,7 @@ var ResponsiveBoardFrame = ({
1225
780
  };
1226
781
 
1227
782
  // src/canvas/BoardStatusChips.tsx
1228
- import { normalizeDddError as normalizeDddError2 } from "@mgamadeus/ddd-web/api";
783
+ import { normalizeDddError } from "@mgamadeus/ddd-web/api";
1229
784
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1230
785
  var BoardStatusChips = ({
1231
786
  projectKey,
@@ -1257,7 +812,7 @@ var BoardStatusChips = ({
1257
812
  }).unwrap();
1258
813
  onStatusChanged(status);
1259
814
  } catch (error) {
1260
- notify.error(normalizeDddError2(error, "Request failed").message);
815
+ notify.error(normalizeDddError(error, "Request failed").message);
1261
816
  }
1262
817
  },
1263
818
  className: cx(
@@ -1303,17 +858,17 @@ var BoardFocusView = ({
1303
858
  const { apiBaseUrl, components } = useDesignStudio();
1304
859
  const texts = useDesignStudioTexts();
1305
860
  const { Button, Dialog, DialogContent, DialogDescription, DialogTitle, Textarea } = components;
1306
- const [isPlacingPin, setIsPlacingPin] = useState6(false);
1307
- const [pendingPin, setPendingPin] = useState6(null);
1308
- const [highlightedCommentId, setHighlightedCommentId] = useState6(null);
1309
- const [showResolved, setShowResolved] = useState6(false);
1310
- const [isMarkingRegion, setIsMarkingRegion] = useState6(false);
1311
- const [region, setRegion] = useState6(null);
1312
- const [regionDraft, setRegionDraft] = useState6(null);
1313
- const [referenceNote, setReferenceNote] = useState6("");
1314
- const [isRegionFlashing, setIsRegionFlashing] = useState6(false);
861
+ const [isPlacingPin, setIsPlacingPin] = useState5(false);
862
+ const [pendingPin, setPendingPin] = useState5(null);
863
+ const [highlightedCommentId, setHighlightedCommentId] = useState5(null);
864
+ const [showResolved, setShowResolved] = useState5(false);
865
+ const [isMarkingRegion, setIsMarkingRegion] = useState5(false);
866
+ const [region, setRegion] = useState5(null);
867
+ const [regionDraft, setRegionDraft] = useState5(null);
868
+ const [referenceNote, setReferenceNote] = useState5("");
869
+ const [isRegionFlashing, setIsRegionFlashing] = useState5(false);
1315
870
  const boardKey = board?.boardKey ?? null;
1316
- useEffect4(() => {
871
+ useEffect3(() => {
1317
872
  if (boardKey === null) return;
1318
873
  setPendingPin(null);
1319
874
  setIsPlacingPin(false);
@@ -1323,7 +878,7 @@ var BoardFocusView = ({
1323
878
  setIsMarkingRegion(false);
1324
879
  setReferenceNote("");
1325
880
  }, [boardKey]);
1326
- useEffect4(() => {
881
+ useEffect3(() => {
1327
882
  if (!board) return;
1328
883
  const onKeyDown = (event) => {
1329
884
  const target = event.target;
@@ -1346,10 +901,10 @@ var BoardFocusView = ({
1346
901
  return () => window.removeEventListener("keydown", onKeyDown);
1347
902
  });
1348
903
  const isResponsive = isResponsiveBoard(board) && viewport !== null;
1349
- const [showsDeviceFrame, setShowsDeviceFrame] = useState6(true);
904
+ const [showsDeviceFrame, setShowsDeviceFrame] = useState5(true);
1350
905
  const stageRef = useRef2(null);
1351
- const [stageWidth, setStageWidth] = useState6(0);
1352
- useEffect4(() => {
906
+ const [stageWidth, setStageWidth] = useState5(0);
907
+ useEffect3(() => {
1353
908
  const stage = stageRef.current;
1354
909
  if (!stage || typeof ResizeObserver === "undefined") return;
1355
910
  const observer = new ResizeObserver(() => setStageWidth(stage.clientWidth));
@@ -1578,7 +1133,7 @@ var BoardFocusView = ({
1578
1133
  className: "absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none bg-brand text-card shadow-surface-raised ring-2 ring-card",
1579
1134
  style: { left: pendingPin.x, top: pendingPin.y },
1580
1135
  "aria-hidden": true,
1581
- children: /* @__PURE__ */ jsx4(MapPin2, { className: "size-4" })
1136
+ children: /* @__PURE__ */ jsx4(MapPin, { className: "size-4" })
1582
1137
  }
1583
1138
  )
1584
1139
  ] })
@@ -1616,7 +1171,7 @@ var BoardFocusView = ({
1616
1171
  ),
1617
1172
  region && /* @__PURE__ */ jsx4(Button, { variant: "ghost", size: "sm", onClick: () => setRegion(null), children: "Clear region" }),
1618
1173
  /* @__PURE__ */ jsxs4(Button, { variant: "outline", size: "sm", className: "ml-auto", onClick: copyReference, children: [
1619
- /* @__PURE__ */ jsx4(ClipboardCopy3, {}),
1174
+ /* @__PURE__ */ jsx4(ClipboardCopy2, {}),
1620
1175
  " Copy reference"
1621
1176
  ] })
1622
1177
  ] }),
@@ -1689,101 +1244,6 @@ var BoardFocusView = ({
1689
1244
  }
1690
1245
  ) });
1691
1246
  };
1692
- var ViewportToolbar = ({
1693
- devices,
1694
- viewport,
1695
- hiddenPinCount,
1696
- showsDeviceFrame,
1697
- onShowsDeviceFrameChange,
1698
- onViewportChange
1699
- }) => {
1700
- const { components } = useDesignStudio();
1701
- const { Button } = components;
1702
- return /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-2 border-b border-border px-5 py-2 text-sm", children: [
1703
- /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2", children: [
1704
- /* @__PURE__ */ jsx4("span", { className: "sr-only", children: "Device" }),
1705
- /* @__PURE__ */ jsxs4(
1706
- "select",
1707
- {
1708
- className: "h-8 rounded-lg border border-border bg-card px-2 text-sm",
1709
- value: viewport.deviceKey ?? "",
1710
- onChange: (event) => {
1711
- const device = devices.find((candidate) => candidate.deviceKey === event.target.value);
1712
- if (device) onViewportChange(viewportOfDevice(device));
1713
- },
1714
- children: [
1715
- viewport.deviceKey === null && /* @__PURE__ */ jsx4("option", { value: "", children: "Free width" }),
1716
- devices.map((device) => /* @__PURE__ */ jsxs4("option", { value: device.deviceKey ?? "", children: [
1717
- device.label,
1718
- " \xB7 ",
1719
- device.width,
1720
- " \xD7 ",
1721
- device.height
1722
- ] }, device.deviceKey ?? ""))
1723
- ]
1724
- }
1725
- )
1726
- ] }),
1727
- /* @__PURE__ */ jsxs4(
1728
- Button,
1729
- {
1730
- variant: "outline",
1731
- size: "sm",
1732
- "aria-label": "Rotate (landscape / portrait)",
1733
- onClick: () => onViewportChange(rotateViewport(viewport, devices)),
1734
- children: [
1735
- /* @__PURE__ */ jsx4(RotateCw, {}),
1736
- " Rotate"
1737
- ]
1738
- }
1739
- ),
1740
- /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground tabular-nums", children: viewportLabel(viewport, devices) }),
1741
- /* @__PURE__ */ jsxs4(
1742
- Button,
1743
- {
1744
- variant: showsDeviceFrame ? "default" : "outline",
1745
- size: "sm",
1746
- "aria-pressed": showsDeviceFrame,
1747
- onClick: () => onShowsDeviceFrameChange(!showsDeviceFrame),
1748
- children: [
1749
- /* @__PURE__ */ jsx4(Smartphone, {}),
1750
- " Device frame"
1751
- ]
1752
- }
1753
- ),
1754
- hiddenPinCount > 0 && /* @__PURE__ */ jsxs4("span", { className: "ml-auto text-xs text-muted-foreground", children: [
1755
- hiddenPinCount,
1756
- " open pin(s) in other widths \u2014 pick their size in the comment list"
1757
- ] })
1758
- ] });
1759
- };
1760
- var WidthDragHandle = ({ scale, width, onWidthChange }) => {
1761
- const dragStartRef = useRef2(null);
1762
- return /* @__PURE__ */ jsx4(
1763
- "button",
1764
- {
1765
- type: "button",
1766
- "aria-label": `Viewport width ${width} px: drag to change`,
1767
- className: "absolute top-1/2 -right-6 z-30 h-24 w-3 -translate-y-1/2 cursor-ew-resize touch-none rounded-full bg-foreground/40 hover:bg-foreground/70",
1768
- onPointerDown: (event) => {
1769
- event.currentTarget.setPointerCapture(event.pointerId);
1770
- dragStartRef.current = { clientX: event.clientX, width };
1771
- },
1772
- onPointerMove: (event) => {
1773
- const dragStart = dragStartRef.current;
1774
- if (!dragStart) return;
1775
- onWidthChange(dragStart.width + (event.clientX - dragStart.clientX) / Math.max(0.05, scale));
1776
- },
1777
- onPointerUp: () => {
1778
- dragStartRef.current = null;
1779
- },
1780
- onKeyDown: (event) => {
1781
- if (event.key === "ArrowLeft") onWidthChange(width - 10);
1782
- if (event.key === "ArrowRight") onWidthChange(width + 10);
1783
- }
1784
- }
1785
- );
1786
- };
1787
1247
 
1788
1248
  // src/canvas/DesignCanvasFlow.tsx
1789
1249
  import "@xyflow/react/dist/style.css";
@@ -1798,7 +1258,7 @@ import {
1798
1258
  useStore as useStore3
1799
1259
  } from "@xyflow/react";
1800
1260
  import { ChevronDown, Hand, MousePointer2, Play } from "lucide-react";
1801
- import { useCallback, useEffect as useEffect5, useMemo, useRef as useRef3, useState as useState7 } from "react";
1261
+ import { useCallback, useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState6 } from "react";
1802
1262
 
1803
1263
  // src/canvas/SectionNode.tsx
1804
1264
  import { useStore as useStore2 } from "@xyflow/react";
@@ -1996,7 +1456,7 @@ var reuseUnchangedNodes = (previousNodes, nextNodes) => {
1996
1456
  };
1997
1457
  var useWheelZoom = (containerRef) => {
1998
1458
  const reactFlow = useReactFlow();
1999
- useEffect5(() => {
1459
+ useEffect4(() => {
2000
1460
  const container = containerRef.current;
2001
1461
  if (!container) return;
2002
1462
  const minLogZoom = Math.log(MIN_ZOOM);
@@ -2115,7 +1575,7 @@ var FlowCanvas = ({
2115
1575
  if (liveBoardsTimerRef.current) clearTimeout(liveBoardsTimerRef.current);
2116
1576
  liveBoardsTimerRef.current = null;
2117
1577
  }, []);
2118
- useEffect5(() => cancelLiveBoardsUpdate, [cancelLiveBoardsUpdate]);
1578
+ useEffect4(() => cancelLiveBoardsUpdate, [cancelLiveBoardsUpdate]);
2119
1579
  const updateLiveBoards = useCallback(
2120
1580
  (viewport) => {
2121
1581
  const container = containerRef.current;
@@ -2169,7 +1629,7 @@ var FlowCanvas = ({
2169
1629
  fitRect(layout.bounds, 400);
2170
1630
  }, [fitRect, layout]);
2171
1631
  const handledFitKeyRef = useRef3(null);
2172
- useEffect5(() => {
1632
+ useEffect4(() => {
2173
1633
  if (!fitRequest || handledFitKeyRef.current === fitRequest.key) return;
2174
1634
  handledFitKeyRef.current = fitRequest.key;
2175
1635
  fitNodes(fitRequest.nodeIds);
@@ -2195,7 +1655,7 @@ var FlowCanvas = ({
2195
1655
  }
2196
1656
  }, [layout, initialFitNodeIds, fitNodes, fitRect, reactFlow, updateLiveBoards]);
2197
1657
  const viewportCommitTimerRef = useRef3(null);
2198
- useEffect5(
1658
+ useEffect4(
2199
1659
  () => () => {
2200
1660
  if (viewportCommitTimerRef.current) clearTimeout(viewportCommitTimerRef.current);
2201
1661
  },
@@ -2212,13 +1672,13 @@ var FlowCanvas = ({
2212
1672
  onViewportCommit?.(viewport);
2213
1673
  }, VIEWPORT_COMMIT_MS);
2214
1674
  };
2215
- useEffect5(() => {
1675
+ useEffect4(() => {
2216
1676
  fitInitialView();
2217
1677
  }, [fitInitialView]);
2218
- useEffect5(() => {
1678
+ useEffect4(() => {
2219
1679
  if (hasInitialFitRef.current) updateLiveBoards(reactFlow.getViewport());
2220
1680
  }, [reactFlow, updateLiveBoards]);
2221
- useEffect5(() => {
1681
+ useEffect4(() => {
2222
1682
  const container = containerRef.current;
2223
1683
  if (!container) return;
2224
1684
  const resizeObserver = new ResizeObserver(() => {
@@ -2228,7 +1688,7 @@ var FlowCanvas = ({
2228
1688
  resizeObserver.observe(container);
2229
1689
  return () => resizeObserver.disconnect();
2230
1690
  }, [reactFlow, updateLiveBoards, fitInitialView]);
2231
- useEffect5(() => {
1691
+ useEffect4(() => {
2232
1692
  const onKeyDown = (event) => {
2233
1693
  const target = event.target;
2234
1694
  if (target && (target.tagName === "TEXTAREA" || target.tagName === "INPUT" || target.isContentEditable)) return;
@@ -2265,7 +1725,7 @@ var FlowCanvas = ({
2265
1725
  const presentationStart = findSectionPresentationStart(layout.sections, selectedNodeId, sectionInView());
2266
1726
  if (presentationStart) onPresentSection(presentationStart.sectionId, presentationStart.boardId);
2267
1727
  };
2268
- const [marquee, setMarquee] = useState7(null);
1728
+ const [marquee, setMarquee] = useState6(null);
2269
1729
  const isMarqueeJustEndedRef = useRef3(false);
2270
1730
  const startMarquee = (event) => {
2271
1731
  const target = event.target;
@@ -2442,8 +1902,8 @@ var OPEN_RENDER_STATUSES = /* @__PURE__ */ new Set(["QUEUED", "RUNNING", "WAITIN
2442
1902
  var MAX_PRIORITY_BOARDS = 200;
2443
1903
  var LIVE_UPDATE_TOAST_ID = "design-canvas-live-update";
2444
1904
  var usePageVisible = () => {
2445
- const [isVisible, setIsVisible] = useState8(true);
2446
- useEffect6(() => {
1905
+ const [isVisible, setIsVisible] = useState7(true);
1906
+ useEffect5(() => {
2447
1907
  const update = () => setIsVisible(document.visibilityState === "visible");
2448
1908
  update();
2449
1909
  document.addEventListener("visibilitychange", update);
@@ -2462,7 +1922,7 @@ var useCollapsedSidebarWhileMounted = (useSidebarCollapsed = useNoSidebar) => {
2462
1922
  const collapsedByCanvasRef = useRef4(false);
2463
1923
  const toggleRef = useRef4(toggleCollapsed);
2464
1924
  toggleRef.current = toggleCollapsed;
2465
- useEffect6(() => {
1925
+ useEffect5(() => {
2466
1926
  if (!isCollapsed) {
2467
1927
  collapsedByCanvasRef.current = true;
2468
1928
  toggleRef.current();
@@ -2494,7 +1954,7 @@ var SelectedBoardPanel = ({
2494
1954
  }) => {
2495
1955
  const { Button } = useDesignStudioComponents();
2496
1956
  const texts = useDesignStudioTexts();
2497
- const [showResolved, setShowResolved] = useState8(false);
1957
+ const [showResolved, setShowResolved] = useState7(false);
2498
1958
  return /* @__PURE__ */ jsxs7("div", { className: "space-y-5", children: [
2499
1959
  /* @__PURE__ */ jsxs7("div", { className: "space-y-1", children: [
2500
1960
  board.code && /* @__PURE__ */ jsx7("p", { className: "text-sm font-semibold tabular-nums text-foreground/70", children: board.code }),
@@ -2555,6 +2015,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2555
2015
  api,
2556
2016
  components,
2557
2017
  notify,
2018
+ paths,
2558
2019
  router,
2559
2020
  shell,
2560
2021
  statuses: statusDefinitions,
@@ -2580,17 +2041,17 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2580
2041
  const writeSearchParams = router.useSearchParamsWriter();
2581
2042
  const writesAllowed = useCanWrite();
2582
2043
  const isPageVisible = usePageVisible();
2583
- const [statusOverrides, setStatusOverrides] = useState8(/* @__PURE__ */ new Map());
2584
- const [liveBoardIds, setLiveBoardIds] = useState8(/* @__PURE__ */ new Set());
2585
- const [selectedBoardId, setSelectedBoardId] = useState8(null);
2586
- const [selectedBoardIds, setSelectedBoardIds] = useState8(/* @__PURE__ */ new Set());
2587
- const [focusedBoardId, setFocusedBoardId] = useState8(null);
2588
- const [frameHeightMode, setFrameHeightMode] = useState8("viewport");
2589
- const [chosenFocusViewport, setChosenFocusViewport] = useState8(null);
2590
- const [presentSectionId, setPresentSectionId] = useState8(null);
2591
- const [fitRequest, setFitRequest] = useState8(null);
2592
- const [tool, setTool] = useState8("hand");
2593
- const [isCommentsPanelOpen, setIsCommentsPanelOpen] = useState8(
2044
+ const [statusOverrides, setStatusOverrides] = useState7(/* @__PURE__ */ new Map());
2045
+ const [liveBoardIds, setLiveBoardIds] = useState7(/* @__PURE__ */ new Set());
2046
+ const [selectedBoardId, setSelectedBoardId] = useState7(null);
2047
+ const [selectedBoardIds, setSelectedBoardIds] = useState7(/* @__PURE__ */ new Set());
2048
+ const [focusedBoardId, setFocusedBoardId] = useState7(null);
2049
+ const [frameHeightMode, setFrameHeightMode] = useState7("viewport");
2050
+ const [chosenFocusViewport, setChosenFocusViewport] = useState7(null);
2051
+ const [presentSectionId, setPresentSectionId] = useState7(null);
2052
+ const [fitRequest, setFitRequest] = useState7(null);
2053
+ const [tool, setTool] = useState7("hand");
2054
+ const [isCommentsPanelOpen, setIsCommentsPanelOpen] = useState7(
2594
2055
  () => Boolean(searchParams.get(CODE_PARAM)) || storage.read("commentsPanelOpen") !== "0"
2595
2056
  );
2596
2057
  const canvasState = router.useUrlState(CANVAS_STATE_KEYS, {
@@ -2607,16 +2068,16 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2607
2068
  const setSearch = useCallback2((value) => setCanvasStateValue("q", value), [setCanvasStateValue]);
2608
2069
  const setSectionFilter = useCallback2((value) => setCanvasStateValue("section", value), [setCanvasStateValue]);
2609
2070
  const setStatusFilter = useCallback2((value) => setCanvasStateValue("status", value), [setCanvasStateValue]);
2610
- const [isFullscreen, setIsFullscreen] = useState8(false);
2071
+ const [isFullscreen, setIsFullscreen] = useState7(false);
2611
2072
  const canvasAreaRef = useRef4(null);
2612
- const [canvasAspectRatio, setCanvasAspectRatio] = useState8(null);
2073
+ const [canvasAspectRatio, setCanvasAspectRatio] = useState7(null);
2613
2074
  useCollapsedSidebarWhileMounted(shell?.useSidebarCollapsed);
2614
2075
  const debouncedSearch = canvasState.debounced.q;
2615
- const [codeAtLoad] = useState8(() => searchParams.get(CODE_PARAM));
2616
- const [initialViewport] = useState8(
2076
+ const [codeAtLoad] = useState7(() => searchParams.get(CODE_PARAM));
2077
+ const [initialViewport] = useState7(
2617
2078
  () => codeAtLoad ? null : parseViewportParam(canvasState.values.vp)
2618
2079
  );
2619
- const [hasInitialFilterWithViewport] = useState8(
2080
+ const [hasInitialFilterWithViewport] = useState7(
2620
2081
  () => initialViewport !== null && Boolean(canvasState.values.q.trim() || canvasState.values.section || canvasState.values.status)
2621
2082
  );
2622
2083
  const currentViewportRef = useRef4(initialViewport ? formatViewportParam(initialViewport) : null);
@@ -2641,7 +2102,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2641
2102
  const themes = useMemo2(() => themesData?.designThemes.elements ?? [], [themesData]);
2642
2103
  const isDefaultLook = chosenThemeId === null && chosenMode === null;
2643
2104
  const isLookResolved = isDefaultLook || (overviewData !== void 0 || isOverviewError) && (!hasThemes || themesData !== void 0 || isThemesError);
2644
- const [loadedReferenceTheme, setLoadedReferenceTheme] = useState8(void 0);
2105
+ const [loadedReferenceTheme, setLoadedReferenceTheme] = useState7(void 0);
2645
2106
  const referenceTheme = loadedReferenceTheme !== void 0 ? loadedReferenceTheme : canvasSummary?.referenceTheme;
2646
2107
  const referenceLook = useMemo2(() => splitThemeReference(referenceTheme), [referenceTheme]);
2647
2108
  const referenceThemeId = referenceLook?.themeId ?? null;
@@ -2656,7 +2117,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2656
2117
  () => ({ projectKey, canvasKey, ...themeArgument ? { theme: themeArgument } : {} }),
2657
2118
  [projectKey, canvasKey, themeArgument]
2658
2119
  );
2659
- const [isRenderPolling, setIsRenderPolling] = useState8(false);
2120
+ const [isRenderPolling, setIsRenderPolling] = useState7(false);
2660
2121
  const {
2661
2122
  data,
2662
2123
  currentData: currentCanvasData,
@@ -2690,7 +2151,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2690
2151
  [statuses, statusDefinitions]
2691
2152
  );
2692
2153
  const canvasBoards = canvas?.boards?.elements;
2693
- const [shownBoards, setShownBoards] = useState8({
2154
+ const [shownBoards, setShownBoards] = useState7({
2694
2155
  source: void 0,
2695
2156
  themeReference: "",
2696
2157
  boards: [],
@@ -2750,7 +2211,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2750
2211
  const devices = useMemo2(() => canvas?.devices?.elements ?? [], [canvas?.devices]);
2751
2212
  const hasResponsiveBoards = useMemo2(() => shownBoardList.some((board) => isResponsiveBoard(board)), [shownBoardList]);
2752
2213
  const hasCanvas = Boolean(canvas);
2753
- useEffect6(() => {
2214
+ useEffect5(() => {
2754
2215
  const canvasArea = canvasAreaRef.current;
2755
2216
  if (!canvasArea) return;
2756
2217
  const measure = () => {
@@ -2769,7 +2230,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2769
2230
  const missingThumbnailCount = canvas?.missingThumbnailCount ?? 0;
2770
2231
  const renderStatus = canvas?.renderRequestStatus ?? null;
2771
2232
  const isRenderOpen = renderStatus !== null && OPEN_RENDER_STATUSES.has(renderStatus);
2772
- useEffect6(() => setIsRenderPolling(isRenderOpen), [isRenderOpen]);
2233
+ useEffect5(() => setIsRenderPolling(isRenderOpen), [isRenderOpen]);
2773
2234
  const [requestThumbnailRendering] = api.useRequestThumbnailRenderingMutation();
2774
2235
  const visibleBoardIdsRef = useRef4([]);
2775
2236
  const rememberVisibleBoardIds = useCallback2((visibleBoardIds) => {
@@ -2798,7 +2259,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2798
2259
  },
2799
2260
  [writesAllowed, currentCanvas, themeArgument, projectKey, canvasKey, requestThumbnailRendering]
2800
2261
  );
2801
- useEffect6(() => {
2262
+ useEffect5(() => {
2802
2263
  if (!currentCanvas?.isRendererEnabled || !currentCanvas.missingThumbnailCount) return;
2803
2264
  const currentStatus = currentCanvas.renderRequestStatus ?? null;
2804
2265
  if (currentStatus === "FAILED" || currentStatus !== null && OPEN_RENDER_STATUSES.has(currentStatus)) return;
@@ -2867,7 +2328,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2867
2328
  const filterKey = matchingBoardIds === null ? null : `${debouncedSearch.trim()}|${sectionFilter}|${statusFilter}`;
2868
2329
  const fittedFilterKeyRef = useRef4(null);
2869
2330
  const skipInitialFilterFitRef = useRef4(hasInitialFilterWithViewport);
2870
- useEffect6(() => {
2331
+ useEffect5(() => {
2871
2332
  if (filterKey === null || matchingBoardIds === null) {
2872
2333
  fittedFilterKeyRef.current = null;
2873
2334
  return;
@@ -2916,7 +2377,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2916
2377
  );
2917
2378
  const boardParam = searchParams.get(BOARD_PARAM);
2918
2379
  const isDeepLinkHandledRef = useRef4(false);
2919
- useEffect6(() => {
2380
+ useEffect5(() => {
2920
2381
  if (isDeepLinkHandledRef.current || !boardParam || boards.length === 0) return;
2921
2382
  isDeepLinkHandledRef.current = true;
2922
2383
  const nodeId = boardNodeId(boardParam);
@@ -2927,7 +2388,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2927
2388
  }, [boardParam, boards.length, boardsByNodeId, requestFit, initialViewport]);
2928
2389
  const codeParam = searchParams.get(CODE_PARAM);
2929
2390
  const handledCodeRef = useRef4(null);
2930
- useEffect6(() => {
2391
+ useEffect5(() => {
2931
2392
  if (!codeParam) {
2932
2393
  if (handledCodeRef.current !== null) handledCodeRef.current = "";
2933
2394
  return;
@@ -2953,7 +2414,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2953
2414
  }
2954
2415
  }, [codeParam, codeAtLoad, boards, isCommentsPanelOpen, writeSearchParams, notify, texts, requestFit]);
2955
2416
  const pendingCodeFitRef = useRef4(null);
2956
- useEffect6(() => {
2417
+ useEffect5(() => {
2957
2418
  const nodeId = pendingCodeFitRef.current;
2958
2419
  if (!nodeId || layout.sections.length === 0) return;
2959
2420
  pendingCodeFitRef.current = null;
@@ -3065,7 +2526,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3065
2526
  const seenRevisionRef = useRef4(null);
3066
2527
  const revision = currentRevisionData?.revision;
3067
2528
  const revisionLook = themeArgument ?? "";
3068
- useEffect6(() => {
2529
+ useEffect5(() => {
3069
2530
  if (!revision) return;
3070
2531
  const seen = seenRevisionRef.current;
3071
2532
  seenRevisionRef.current = { look: revisionLook, revision };
@@ -3073,7 +2534,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3073
2534
  void refetchCanvas();
3074
2535
  void refetchComments();
3075
2536
  }, [revision, revisionLook, refetchCanvas, refetchComments]);
3076
- useEffect6(() => {
2537
+ useEffect5(() => {
3077
2538
  if (isPageVisible && seenRevisionRef.current) void refetchRevision();
3078
2539
  }, [isPageVisible, refetchRevision]);
3079
2540
  const showBoard = useCallback2(
@@ -3086,7 +2547,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3086
2547
  );
3087
2548
  const layoutOrderRef = useRef4(layoutOrder);
3088
2549
  layoutOrderRef.current = layoutOrder;
3089
- useEffect6(() => {
2550
+ useEffect5(() => {
3090
2551
  const changedBoardKeys = shownBoards.changedBoardKeys;
3091
2552
  if (changedBoardKeys.length === 0) return;
3092
2553
  const changedNodeIds = new Set(changedBoardKeys.map((boardKey) => boardNodeId(boardKey)));
@@ -3161,7 +2622,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3161
2622
  const presentedSectionTitle = presentSectionId ? layout.sections.find((section) => section.id === presentSectionId)?.title ?? null : null;
3162
2623
  const copySelectedRef = useRef4(copySelectedReferences);
3163
2624
  copySelectedRef.current = copySelectedReferences;
3164
- useEffect6(() => {
2625
+ useEffect5(() => {
3165
2626
  const onKeyDown = (event) => {
3166
2627
  const target = event.target;
3167
2628
  if (target && (target.tagName === "TEXTAREA" || target.tagName === "INPUT" || target.isContentEditable)) return;
@@ -3249,7 +2710,13 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3249
2710
  ] })
3250
2711
  ] })
3251
2712
  ] });
2713
+ const siteStartRoute = selectedBoard?.route ?? (shownBoardList.some((board) => board.route) ? "/" : null);
2714
+ const siteHref = paths.site && siteStartRoute !== null ? `${paths.site(projectKey, canvasKey, siteStartRoute)}${shownLook?.themeId ? `?theme=${encodeURIComponent(shownLook.themeId)}&mode=${shownLook.mode}` : ""}` : null;
3252
2715
  const toolbarEnd = /* @__PURE__ */ jsxs7(Fragment4, { children: [
2716
+ siteHref && /* @__PURE__ */ jsxs7(Tooltip, { children: [
2717
+ /* @__PURE__ */ jsx7(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx7("span", { children: /* @__PURE__ */ jsx7(router.Link, { href: siteHref, className: TOOL_BUTTON_CLASS2, children: /* @__PURE__ */ jsx7(Globe, { className: "size-4", "aria-label": texts.openAsWebsite }) }) }) }),
2718
+ /* @__PURE__ */ jsx7(TooltipContent, { side: "bottom", children: texts.openAsWebsite })
2719
+ ] }),
3253
2720
  hasResponsiveBoards && /* @__PURE__ */ jsxs7(Tooltip, { children: [
3254
2721
  /* @__PURE__ */ jsx7(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx7(
3255
2722
  "button",
@@ -3289,7 +2756,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3289
2756
  "aria-label": `Copy reference of ${selectedBoardIds.size} selected board(s) for an agent (C)`,
3290
2757
  onClick: copySelectedReferences,
3291
2758
  children: [
3292
- /* @__PURE__ */ jsx7(ClipboardCopy4, { className: "size-4" }),
2759
+ /* @__PURE__ */ jsx7(ClipboardCopy3, { className: "size-4" }),
3293
2760
  selectedBoardIds.size > 1 && /* @__PURE__ */ jsx7("span", { className: "absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-brand px-1 text-[10px] font-bold text-foreground", children: selectedBoardIds.size })
3294
2761
  ]
3295
2762
  }
@@ -3401,7 +2868,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3401
2868
  {
3402
2869
  tone: "destructive",
3403
2870
  title: "The canvas could not be loaded",
3404
- description: normalizeDddError3(error, "Request failed").message
2871
+ description: normalizeDddError2(error, "Request failed").message
3405
2872
  }
3406
2873
  ) }),
3407
2874
  (isLoading || !isLookResolved && !canvas) && /* @__PURE__ */ jsx7(Skeleton, { className: "m-6 flex-1 rounded-2xl" }),