dsh-codex-subscription 3.2.6 → 3.2.8

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.
@@ -29,39 +29,329 @@ window.__ModuleLoader__.load({
29
29
  //#endregion
30
30
  let react = require("react");
31
31
  react = __toESM(react, 1);
32
- let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
33
- _deepseek_ai_dsh_client_ui_primitives = __toESM(_deepseek_ai_dsh_client_ui_primitives, 1);
34
- let react_dom = require("react-dom");
35
32
  let react_jsx_runtime = require("react/jsx-runtime");
36
- //#region src/client-primitives.js
37
- const IconChevronRightOutline14 = _deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular;
38
- const IconChevronLeftOutline14 = _deepseek_ai_dsh_client_ui_primitives.IconChevronLeftOutlineRegular;
39
- const IconCloseOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconCloseOutlineRegular;
40
- const IconCopyOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular;
41
- const IconDownloadOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconDownloadOutlineRegular;
42
- const IconEditOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconEditOutlineRegular;
33
+ let react_dom = require("react-dom");
34
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ArrowDownTrayIcon.js
35
+ function ArrowDownTrayIcon({ title, titleId, ...props }, svgRef) {
36
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
37
+ xmlns: "http://www.w3.org/2000/svg",
38
+ fill: "none",
39
+ viewBox: "0 0 24 24",
40
+ strokeWidth: 1.5,
41
+ stroke: "currentColor",
42
+ "aria-hidden": "true",
43
+ "data-slot": "icon",
44
+ ref: svgRef,
45
+ "aria-labelledby": titleId
46
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
47
+ strokeLinecap: "round",
48
+ strokeLinejoin: "round",
49
+ d: "M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"
50
+ }));
51
+ }
52
+ const ForwardRef$13 = /*#__PURE__*/ react.forwardRef(ArrowDownTrayIcon);
53
+ //#endregion
54
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ArrowsPointingOutIcon.js
55
+ function ArrowsPointingOutIcon({ title, titleId, ...props }, svgRef) {
56
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
57
+ xmlns: "http://www.w3.org/2000/svg",
58
+ fill: "none",
59
+ viewBox: "0 0 24 24",
60
+ strokeWidth: 1.5,
61
+ stroke: "currentColor",
62
+ "aria-hidden": "true",
63
+ "data-slot": "icon",
64
+ ref: svgRef,
65
+ "aria-labelledby": titleId
66
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
67
+ strokeLinecap: "round",
68
+ strokeLinejoin: "round",
69
+ d: "M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"
70
+ }));
71
+ }
72
+ const ForwardRef$12 = /*#__PURE__*/ react.forwardRef(ArrowsPointingOutIcon);
73
+ //#endregion
74
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ChatBubbleLeftEllipsisIcon.js
75
+ function ChatBubbleLeftEllipsisIcon({ title, titleId, ...props }, svgRef) {
76
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
77
+ xmlns: "http://www.w3.org/2000/svg",
78
+ fill: "none",
79
+ viewBox: "0 0 24 24",
80
+ strokeWidth: 1.5,
81
+ stroke: "currentColor",
82
+ "aria-hidden": "true",
83
+ "data-slot": "icon",
84
+ ref: svgRef,
85
+ "aria-labelledby": titleId
86
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
87
+ strokeLinecap: "round",
88
+ strokeLinejoin: "round",
89
+ d: "M8.625 9.75a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H8.25m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H12m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 0 1 .778-.332 48.294 48.294 0 0 0 5.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"
90
+ }));
91
+ }
92
+ const ForwardRef$11 = /*#__PURE__*/ react.forwardRef(ChatBubbleLeftEllipsisIcon);
93
+ //#endregion
94
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/CheckIcon.js
95
+ function CheckIcon({ title, titleId, ...props }, svgRef) {
96
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
97
+ xmlns: "http://www.w3.org/2000/svg",
98
+ fill: "none",
99
+ viewBox: "0 0 24 24",
100
+ strokeWidth: 1.5,
101
+ stroke: "currentColor",
102
+ "aria-hidden": "true",
103
+ "data-slot": "icon",
104
+ ref: svgRef,
105
+ "aria-labelledby": titleId
106
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
107
+ strokeLinecap: "round",
108
+ strokeLinejoin: "round",
109
+ d: "m4.5 12.75 6 6 9-13.5"
110
+ }));
111
+ }
112
+ const ForwardRef$10 = /*#__PURE__*/ react.forwardRef(CheckIcon);
113
+ //#endregion
114
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ChevronLeftIcon.js
115
+ function ChevronLeftIcon({ title, titleId, ...props }, svgRef) {
116
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
117
+ xmlns: "http://www.w3.org/2000/svg",
118
+ fill: "none",
119
+ viewBox: "0 0 24 24",
120
+ strokeWidth: 1.5,
121
+ stroke: "currentColor",
122
+ "aria-hidden": "true",
123
+ "data-slot": "icon",
124
+ ref: svgRef,
125
+ "aria-labelledby": titleId
126
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
127
+ strokeLinecap: "round",
128
+ strokeLinejoin: "round",
129
+ d: "M15.75 19.5 8.25 12l7.5-7.5"
130
+ }));
131
+ }
132
+ const ForwardRef$8 = /*#__PURE__*/ react.forwardRef(ChevronLeftIcon);
133
+ //#endregion
134
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ChevronRightIcon.js
135
+ function ChevronRightIcon({ title, titleId, ...props }, svgRef) {
136
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
137
+ xmlns: "http://www.w3.org/2000/svg",
138
+ fill: "none",
139
+ viewBox: "0 0 24 24",
140
+ strokeWidth: 1.5,
141
+ stroke: "currentColor",
142
+ "aria-hidden": "true",
143
+ "data-slot": "icon",
144
+ ref: svgRef,
145
+ "aria-labelledby": titleId
146
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
147
+ strokeLinecap: "round",
148
+ strokeLinejoin: "round",
149
+ d: "m8.25 4.5 7.5 7.5-7.5 7.5"
150
+ }));
151
+ }
152
+ const ForwardRef$7 = /*#__PURE__*/ react.forwardRef(ChevronRightIcon);
153
+ //#endregion
154
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/DocumentDuplicateIcon.js
155
+ function DocumentDuplicateIcon({ title, titleId, ...props }, svgRef) {
156
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
157
+ xmlns: "http://www.w3.org/2000/svg",
158
+ fill: "none",
159
+ viewBox: "0 0 24 24",
160
+ strokeWidth: 1.5,
161
+ stroke: "currentColor",
162
+ "aria-hidden": "true",
163
+ "data-slot": "icon",
164
+ ref: svgRef,
165
+ "aria-labelledby": titleId
166
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
167
+ strokeLinecap: "round",
168
+ strokeLinejoin: "round",
169
+ d: "M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75"
170
+ }));
171
+ }
172
+ const ForwardRef$6 = /*#__PURE__*/ react.forwardRef(DocumentDuplicateIcon);
173
+ //#endregion
174
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/EllipsisHorizontalIcon.js
175
+ function EllipsisHorizontalIcon({ title, titleId, ...props }, svgRef) {
176
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
177
+ xmlns: "http://www.w3.org/2000/svg",
178
+ fill: "none",
179
+ viewBox: "0 0 24 24",
180
+ strokeWidth: 1.5,
181
+ stroke: "currentColor",
182
+ "aria-hidden": "true",
183
+ "data-slot": "icon",
184
+ ref: svgRef,
185
+ "aria-labelledby": titleId
186
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
187
+ strokeLinecap: "round",
188
+ strokeLinejoin: "round",
189
+ d: "M6.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM12.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"
190
+ }));
191
+ }
192
+ const ForwardRef$5 = /*#__PURE__*/ react.forwardRef(EllipsisHorizontalIcon);
193
+ //#endregion
194
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PaintBrushIcon.js
195
+ function PaintBrushIcon({ title, titleId, ...props }, svgRef) {
196
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
197
+ xmlns: "http://www.w3.org/2000/svg",
198
+ fill: "none",
199
+ viewBox: "0 0 24 24",
200
+ strokeWidth: 1.5,
201
+ stroke: "currentColor",
202
+ "aria-hidden": "true",
203
+ "data-slot": "icon",
204
+ ref: svgRef,
205
+ "aria-labelledby": titleId
206
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
207
+ strokeLinecap: "round",
208
+ strokeLinejoin: "round",
209
+ d: "M9.53 16.122a3 3 0 0 0-5.78 1.128 2.25 2.25 0 0 1-2.4 2.245 4.5 4.5 0 0 0 8.4-2.245c0-.399-.078-.78-.22-1.128Zm0 0a15.998 15.998 0 0 0 3.388-1.62m-5.043-.025a15.994 15.994 0 0 1 1.622-3.395m3.42 3.42a15.995 15.995 0 0 0 4.764-4.648l3.876-5.814a1.151 1.151 0 0 0-1.597-1.597L14.146 6.32a15.996 15.996 0 0 0-4.649 4.763m3.42 3.42a6.776 6.776 0 0 0-3.42-3.42"
210
+ }));
211
+ }
212
+ const ForwardRef$4 = /*#__PURE__*/ react.forwardRef(PaintBrushIcon);
213
+ //#endregion
214
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PencilSquareIcon.js
215
+ function PencilSquareIcon({ title, titleId, ...props }, svgRef) {
216
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
217
+ xmlns: "http://www.w3.org/2000/svg",
218
+ fill: "none",
219
+ viewBox: "0 0 24 24",
220
+ strokeWidth: 1.5,
221
+ stroke: "currentColor",
222
+ "aria-hidden": "true",
223
+ "data-slot": "icon",
224
+ ref: svgRef,
225
+ "aria-labelledby": titleId
226
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
227
+ strokeLinecap: "round",
228
+ strokeLinejoin: "round",
229
+ d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10"
230
+ }));
231
+ }
232
+ const ForwardRef$3 = /*#__PURE__*/ react.forwardRef(PencilSquareIcon);
233
+ //#endregion
234
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PencilIcon.js
235
+ function PencilIcon({ title, titleId, ...props }, svgRef) {
236
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
237
+ xmlns: "http://www.w3.org/2000/svg",
238
+ fill: "none",
239
+ viewBox: "0 0 24 24",
240
+ strokeWidth: 1.5,
241
+ stroke: "currentColor",
242
+ "aria-hidden": "true",
243
+ "data-slot": "icon",
244
+ ref: svgRef,
245
+ "aria-labelledby": titleId
246
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
247
+ strokeLinecap: "round",
248
+ strokeLinejoin: "round",
249
+ d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"
250
+ }));
251
+ }
252
+ const ForwardRef$2 = /*#__PURE__*/ react.forwardRef(PencilIcon);
253
+ //#endregion
254
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ScissorsIcon.js
255
+ function ScissorsIcon({ title, titleId, ...props }, svgRef) {
256
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
257
+ xmlns: "http://www.w3.org/2000/svg",
258
+ fill: "none",
259
+ viewBox: "0 0 24 24",
260
+ strokeWidth: 1.5,
261
+ stroke: "currentColor",
262
+ "aria-hidden": "true",
263
+ "data-slot": "icon",
264
+ ref: svgRef,
265
+ "aria-labelledby": titleId
266
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
267
+ strokeLinecap: "round",
268
+ strokeLinejoin: "round",
269
+ d: "m7.848 8.25 1.536.887M7.848 8.25a3 3 0 1 1-5.196-3 3 3 0 0 1 5.196 3Zm1.536.887a2.165 2.165 0 0 1 1.083 1.839c.005.351.054.695.14 1.024M9.384 9.137l2.077 1.199M7.848 15.75l1.536-.887m-1.536.887a3 3 0 1 1-5.196 3 3 3 0 0 1 5.196-3Zm1.536-.887a2.165 2.165 0 0 0 1.083-1.838c.005-.352.054-.695.14-1.025m-1.223 2.863 2.077-1.199m0-3.328a4.323 4.323 0 0 1 2.068-1.379l5.325-1.628a4.5 4.5 0 0 1 2.48-.044l.803.215-7.794 4.5m-2.882-1.664A4.33 4.33 0 0 0 10.607 12m3.736 0 7.794 4.5-.802.215a4.5 4.5 0 0 1-2.48-.043l-5.326-1.629a4.324 4.324 0 0 1-2.068-1.379M14.343 12l-2.882 1.664"
270
+ }));
271
+ }
272
+ const ForwardRef$1 = /*#__PURE__*/ react.forwardRef(ScissorsIcon);
273
+ //#endregion
274
+ //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js
275
+ function XMarkIcon({ title, titleId, ...props }, svgRef) {
276
+ return /*#__PURE__*/ react.createElement("svg", Object.assign({
277
+ xmlns: "http://www.w3.org/2000/svg",
278
+ fill: "none",
279
+ viewBox: "0 0 24 24",
280
+ strokeWidth: 1.5,
281
+ stroke: "currentColor",
282
+ "aria-hidden": "true",
283
+ "data-slot": "icon",
284
+ ref: svgRef,
285
+ "aria-labelledby": titleId
286
+ }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
287
+ strokeLinecap: "round",
288
+ strokeLinejoin: "round",
289
+ d: "M6 18 18 6M6 6l12 12"
290
+ }));
291
+ }
292
+ const ForwardRef = /*#__PURE__*/ react.forwardRef(XMarkIcon);
293
+ //#endregion
294
+ //#region src/client-primitives.jsx
295
+ const classes = (...names) => names.filter(Boolean).join(" ");
296
+ const icon = (Icon, size) => function ControlIcon() {
297
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
298
+ width: size,
299
+ height: size,
300
+ "aria-hidden": "true"
301
+ });
302
+ };
303
+ const IconCheckOutline16 = icon(ForwardRef$10, 16);
304
+ const IconChevronLeftOutline14 = icon(ForwardRef$8, 14);
305
+ const IconChevronRightOutline14 = icon(ForwardRef$7, 14);
306
+ const IconCloseOutline16 = icon(ForwardRef, 16);
307
+ const IconCopyOutline16 = icon(ForwardRef$6, 16);
308
+ const IconDownloadOutline16 = icon(ForwardRef$13, 16);
309
+ const IconEditOutline16 = icon(ForwardRef$3, 16);
310
+ (0, react.forwardRef)(function Button({ variant = "ghost", size = "md", icon, className, children, ...props }, ref) {
311
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
312
+ ref,
313
+ type: "button",
314
+ className: classes("dcsButton", className),
315
+ "data-variant": variant,
316
+ "data-size": size,
317
+ ...props,
318
+ children: [icon == null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
319
+ className: "dcsButtonIcon",
320
+ children: icon
321
+ }), children]
322
+ });
323
+ });
324
+ (0, react.forwardRef)(function Input({ className, ...props }, ref) {
325
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
326
+ className: classes("dcsInput", className),
327
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
328
+ ref,
329
+ ...props
330
+ })
331
+ });
332
+ });
43
333
  //#endregion
44
334
  //#region src/subscription-image-viewer-styles.js
45
335
  const SUBSCRIPTION_IMAGE_VIEWER_CSS = String.raw`
46
- .dcsiv-root{position:fixed;inset:0;z-index:1000;pointer-events:auto;overflow:hidden;background:rgba(7,8,10,.68);color:var(--dsw-alias-label-primary-inverted,#fff);outline:0;backdrop-filter:blur(13px) saturate(.72);-webkit-backdrop-filter:blur(13px) saturate(.72)}
336
+ .dcsiv-root{position:fixed;inset:var(--dsh-frame-chrome-top,0px) 0 0;width:auto;height:auto;max-width:none;max-height:none;margin:0;padding:0;border:0;pointer-events:auto;overflow:hidden;overscroll-behavior:none;background:color-mix(in srgb,#101116 94%,var(--dsw-alias-bg-mask-1,#101116));color:var(--dsw-alias-label-primary-inverted,#fff);outline:0}
337
+ .dcsiv-root::backdrop{background:none;touch-action:none}
47
338
  .dcsiv-sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
48
- .dcsiv-topbar{position:absolute;right:50%;bottom:max(22px,env(safe-area-inset-bottom));z-index:6;max-width:calc(100vw - 36px);padding:5px;border:1px solid rgba(255,255,255,.12);border-radius:999px;background:rgba(38,39,43,.86);box-shadow:0 10px 34px rgba(0,0,0,.3);transform:translateX(50%);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)}
49
- .dcsiv-actions{display:flex;align-items:center;gap:2px;overflow-x:auto;scrollbar-width:none}.dcsiv-actions::-webkit-scrollbar{display:none}.dcsiv-button,.dcsiv-download{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:6px;height:36px;padding:0 10px;border:0;border-radius:999px;background:transparent;color:rgba(255,255,255,.9);font:inherit;font-size:12px;text-decoration:none;white-space:nowrap;cursor:pointer}.dcsiv-button:hover,.dcsiv-download:hover,.dcsiv-button[data-active=true]{background:rgba(255,255,255,.12)}.dcsiv-button:focus-visible,.dcsiv-download:focus-visible,.dcsiv-close-floating:focus-visible{outline:2px solid rgba(255,255,255,.9);outline-offset:2px}.dcsiv-button:disabled,.dcsiv-download:disabled{opacity:.38;cursor:default}.dcsiv-icon-only{width:32px;padding:0}.dcsiv-zoom{min-width:44px;color:rgba(255,255,255,.68);font-size:12px;font-variant-numeric:tabular-nums;text-align:center}
50
- .dcsiv-close-floating,.dcsiv-nav{box-sizing:border-box;display:grid;place-items:center;width:44px;height:44px;padding:0;border:1px solid rgba(255,255,255,.16);border-radius:50%;background:rgba(48,49,53,.92);box-shadow:0 8px 24px rgba(0,0,0,.28);color:#fff;cursor:pointer;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}.dcsiv-close-floating{position:absolute;top:max(20px,env(safe-area-inset-top));right:max(20px,env(safe-area-inset-right));z-index:8}.dcsiv-close-floating:hover,.dcsiv-nav:hover{background:rgba(78,79,84,.96)}.dcsiv-close-floating svg,.dcsiv-nav svg{width:18px;height:18px}
339
+ .dcsiv-topbar{position:absolute;right:50%;bottom:max(22px,env(safe-area-inset-bottom));z-index:6;max-width:calc(100vw - 36px);padding:5px;border:1px solid rgba(255,255,255,.12);border-radius:999px;background:#242529;box-shadow:0 6px 18px #0004;transform:translateX(50%)}
340
+ .dcsiv-actions{display:flex;align-items:center;gap:2px;overflow-x:auto;scrollbar-width:none}.dcsiv-actions::-webkit-scrollbar{display:none}.dcsiv-button,.dcsiv-download{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:6px;height:36px;padding:0 10px;border:0;border-radius:999px;background:transparent;color:rgba(255,255,255,.9);font:inherit;font-size:12px;text-decoration:none;white-space:nowrap;cursor:pointer}.dcsiv-button:hover,.dcsiv-download:hover,.dcsiv-button[data-active=true]{background:rgba(255,255,255,.12)}.dcsiv-button:focus-visible,.dcsiv-download:focus-visible,.dcsiv-close-floating:focus-visible{outline:2px solid rgba(255,255,255,.9);outline-offset:2px}.dcsiv-button:disabled,.dcsiv-download:disabled{opacity:.38;cursor:default}.dcsiv-zoom{min-width:44px;color:rgba(255,255,255,.68);font-size:12px;font-variant-numeric:tabular-nums;text-align:center}
341
+ .dcsiv-close-floating{position:absolute;top:max(20px,env(safe-area-inset-top));right:max(20px,env(safe-area-inset-right));z-index:8;display:grid;place-items:center;width:38px;height:38px;padding:0;border:1px solid #fff2;border-radius:50%;background:#242529;color:#fff;cursor:pointer}.dcsiv-close-floating:hover{background:#393a40}.dcsiv-close-floating svg{width:18px;height:18px}
51
342
  .dcsiv-workspace{position:absolute;inset:0;display:grid;min-width:0;min-height:0;padding:68px 24px 72px;box-sizing:border-box}
52
343
  .dcsiv-stage{position:relative;display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden;padding:0;touch-action:none;user-select:none}.dcsiv-stage[data-dragging=true]{cursor:grabbing}.dcsiv-stage[data-annotating=true]{cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='7' fill='none' stroke='white' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='8' fill='none' stroke='%23333'/%3E%3C/svg%3E") 12 12,pointer}
53
- .dcsiv-surface{position:relative;display:inline-flex;max-width:100%;max-height:100%;transform-origin:center;will-change:transform}.dcsiv-image{display:block;max-width:calc(100vw - 72px);max-height:calc(100vh - 154px);border-radius:12px;object-fit:contain;box-shadow:0 22px 60px rgba(0,0,0,.46);user-select:none;-webkit-user-drag:none}
344
+ .dcsiv-surface{position:relative;display:inline-flex;max-width:100%;max-height:100%;transform-origin:center;will-change:transform}.dcsiv-image{display:block;max-width:calc(100vw - 72px);max-height:calc(100dvh - var(--dsh-frame-chrome-top,0px) - 154px);border-radius:var(--dsw-radius-lg,12px);object-fit:contain;box-shadow:var(--dsw-elevation-prominent,0 16px 40px #0005);user-select:none;-webkit-user-drag:none}
54
345
  .dcsiv-annotation{position:absolute;z-index:5;width:24px;height:24px;transform-origin:center;pointer-events:none}.dcsiv-pin{position:absolute;inset:0;display:grid;place-items:center;width:24px;height:24px;padding:0;border:2px solid #fff;border-radius:50%;background:rgba(23,24,27,.94);box-shadow:0 4px 16px rgba(0,0,0,.35);color:#fff;font:inherit;font-size:11px;font-weight:700;cursor:pointer;pointer-events:auto}.dcsiv-pin[data-active=true]{background:var(--dsw-alias-state-business-primary,#3964fe)}
55
- .dcsiv-inline-note{position:absolute;bottom:34px;box-sizing:border-box;display:grid;width:min(300px,calc(100vw - 40px));grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:7px;padding:7px 8px;border:1px solid rgba(255,255,255,.12);border-radius:18px;background:rgba(32,33,37,.94);box-shadow:0 14px 38px rgba(0,0,0,.38);color:#fff;pointer-events:auto;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px)}.dcsiv-annotation[data-x=right] .dcsiv-inline-note{left:-8px}.dcsiv-annotation[data-x=left] .dcsiv-inline-note{right:-8px}.dcsiv-annotation[data-x=center] .dcsiv-inline-note{left:50%;transform:translateX(-50%)}.dcsiv-annotation[data-y=down] .dcsiv-inline-note{top:34px;bottom:auto}.dcsiv-inline-note::after{position:absolute;width:9px;height:9px;background:rgba(32,33,37,.94);content:'';transform:rotate(45deg)}.dcsiv-annotation[data-y=up] .dcsiv-inline-note::after{bottom:-5px}.dcsiv-annotation[data-y=down] .dcsiv-inline-note::after{top:-5px}.dcsiv-annotation[data-x=right] .dcsiv-inline-note::after{left:13px}.dcsiv-annotation[data-x=left] .dcsiv-inline-note::after{right:13px}.dcsiv-annotation[data-x=center] .dcsiv-inline-note::after{left:calc(50% - 4px)}.dcsiv-inline-index{display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--dsw-alias-state-business-primary,#3964fe);color:#fff;font-size:10px;font-weight:700}.dcsiv-inline-note textarea{box-sizing:border-box;width:100%;min-height:24px;max-height:92px;resize:none;overflow:auto;border:0;outline:0;background:transparent;color:#fff;font:inherit;font-size:12px;line-height:18px}.dcsiv-inline-note textarea::placeholder{color:rgba(255,255,255,.44)}.dcsiv-note-remove{display:grid;place-items:center;width:24px;height:24px;padding:0;border:0;border-radius:50%;background:transparent;color:rgba(255,255,255,.68);cursor:pointer}.dcsiv-note-remove:hover{background:rgba(255,255,255,.1);color:#fff}
56
- .dcsiv-nav{position:absolute;top:50%;z-index:4;transform:translateY(-50%)}.dcsiv-prev{left:6px}.dcsiv-next{right:6px}.dcsiv-counter{flex:none;min-width:36px;padding:0 6px;color:rgba(255,255,255,.75);font-size:12px;font-variant-numeric:tabular-nums;text-align:center;white-space:nowrap}
57
- .dcsiv-hint{display:none}
58
- .dcsiv-mask{position:absolute;inset:0;width:100%;height:100%;border-radius:12px;cursor:crosshair;touch-action:none}
346
+ .dcsiv-inline-note{position:absolute;left:var(--note-left);top:var(--note-top);bottom:var(--note-bottom);box-sizing:border-box;display:grid;width:var(--note-width);grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:7px;padding:7px 8px;border:1px solid rgba(255,255,255,.12);border-radius:18px;background:rgba(32,33,37,.94);box-shadow:0 14px 38px rgba(0,0,0,.38);color:#fff;pointer-events:auto;}.dcsiv-inline-note::after{position:absolute;left:var(--note-arrow);top:var(--note-arrow-y);bottom:var(--note-arrow-bottom);width:9px;height:9px;background:rgba(32,33,37,.94);content:'';transform:rotate(45deg)}.dcsiv-inline-index{display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--dsw-alias-state-business-primary,#3964fe);color:#fff;font-size:10px;font-weight:700}.dcsiv-inline-note textarea{box-sizing:border-box;width:100%;min-height:24px;max-height:92px;resize:none;overflow:auto;border:0;outline:0;background:transparent;color:#fff;font:inherit;font-size:12px;line-height:18px}.dcsiv-inline-note textarea::placeholder{color:rgba(255,255,255,.44)}.dcsiv-note-remove{display:grid;place-items:center;width:24px;height:24px;padding:0;border:0;border-radius:50%;background:transparent;color:rgba(255,255,255,.68);cursor:pointer}.dcsiv-note-remove:hover{background:rgba(255,255,255,.1);color:#fff}
347
+ .dcsiv-gallery{display:flex;align-items:center;margin-right:4px;padding-right:4px;border-right:1px solid #fff2}.dcsiv-gallery .dcsiv-nav{width:32px;padding:0}.dcsiv-counter{min-width:30px;color:rgba(255,255,255,.75);font-size:12px;font-variant-numeric:tabular-nums;text-align:center;white-space:nowrap}
348
+ .dcsiv-mask{position:absolute;inset:0;width:100%;height:100%;border-radius:var(--dsw-radius-lg,12px);cursor:crosshair;touch-action:none}
59
349
  .dcsiv-tool-icon{width:16px;height:16px;flex:none}.dcsiv-icon-button,.dcsiv-download[data-compact="true"]{flex:none;width:36px;padding:0!important;justify-content:center}.dcsiv-zoom{min-width:52px;font-variant-numeric:tabular-nums}.dcsiv-divider{flex:none;width:1px;height:18px;margin:0 4px;background:rgba(255,255,255,.14)}.dcsiv-menu{position:fixed;z-index:12;display:flex;flex-direction:column;min-width:170px;max-width:calc(100vw - 24px);max-height:calc(100dvh - 100px);overflow:auto;box-sizing:border-box;padding:6px;border:1px solid rgba(255,255,255,.12);border-radius:12px;background:rgba(32,33,37,.97);box-shadow:0 12px 32px rgba(0,0,0,.4)}.dcsiv-menu button{display:flex;align-items:center;gap:10px;flex:none;width:100%;min-height:36px;height:auto;padding:0 10px;border:0;border-radius:8px;background:none;color:rgba(255,255,255,.9);font:inherit;font-size:13px;text-align:left;white-space:normal;overflow-wrap:anywhere;cursor:pointer}.dcsiv-menu .dcsiv-icon-button{width:100%;padding:8px 10px!important;justify-content:flex-start}.dcsiv-menu button:hover,.dcsiv-menu button:focus-visible{outline:none;background:rgba(255,255,255,.1)}
60
350
  .dcsiv-erase-bar{position:absolute;left:50%;top:22px;z-index:7;display:flex;align-items:center;gap:10px;padding:6px 8px 6px 14px;transform:translateX(-50%);border:1px solid rgba(255,255,255,.1);border-radius:999px;background:rgba(38,39,43,.92);color:rgba(255,255,255,.86);font-size:12px;white-space:nowrap}.dcsiv-erase-bar label{display:inline-flex;align-items:center;gap:6px}.dcsiv-erase-bar input{width:90px}.dcsiv-primary{background:#fff!important;color:#111!important}.dcsiv-primary[data-state="failed"]{color:#c62828!important}.dcsiv-brush-cursor{position:fixed;z-index:9;pointer-events:none;border:1.5px solid #fff;border-radius:50%;corner-shape:round;box-shadow:0 0 0 1px rgba(0,0,0,.45),inset 0 0 0 1px rgba(0,0,0,.25);transform:translate(-50%,-50%)}@media(pointer:fine){.dcsiv-mask{cursor:none}}.dcsiv-button[data-state="pending"] .dcsiv-tool-icon{animation:dcsiv-pulse 1s ease-in-out infinite}.dcsiv-button[data-state="failed"]{color:#ff8a80!important}@keyframes dcsiv-pulse{50%{opacity:.3}}
61
- .dcsiv-copy-notes{position:absolute;right:20px;bottom:22px;z-index:6;display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 11px;border:1px solid rgba(255,255,255,.1);border-radius:999px;background:rgba(38,39,43,.86);color:rgba(255,255,255,.82);font:inherit;font-size:12px;cursor:pointer;backdrop-filter:blur(16px)}
62
351
  .dcsiv-edit-short{display:inline;max-width:180px;overflow:hidden;text-overflow:ellipsis}.dcsiv-actions>*{flex-shrink:0}.dcsiv-download .dcsiv-label{max-width:200px;overflow:hidden;text-overflow:ellipsis}
63
- @media(max-width:760px){.dcsiv-workspace{padding:60px 12px 80px}.dcsiv-image{max-width:calc(100vw - 24px);max-height:calc(100dvh - 148px)}.dcsiv-topbar{bottom:max(12px,env(safe-area-inset-bottom));max-width:calc(100vw - 24px)}.dcsiv-close-floating{top:max(12px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right))}.dcsiv-inline-note{width:min(260px,calc(100vw - 40px))}.dcsiv-copy-notes{display:none}.dcsiv-erase-bar{top:max(64px,env(safe-area-inset-top));max-width:calc(100vw - 24px);box-sizing:border-box;border-radius:18px;flex-wrap:wrap;justify-content:center;white-space:normal}.dcsiv-erase-bar>span{flex-basis:100%;text-align:center}}
64
- @media(max-width:600px){.dcsiv-topbar{padding:4px}.dcsiv-actions{gap:1px}.dcsiv-counter{min-width:30px;padding:0 4px}.dcsiv-button{padding:0 8px}.dcsiv-icon-button,.dcsiv-download[data-compact="true"]{width:36px}.dcsiv-divider{margin:0 3px}.dcsiv-edit-short{max-width:120px}.dcsiv-download .dcsiv-label{display:none}}
352
+ .dcsiv-inline-note[data-draft=true]{grid-template-columns:24px minmax(0,1fr) 24px 24px}.dcsiv-note-remove:disabled{opacity:.38;cursor:default;background:transparent}
353
+ @media(max-width:760px){.dcsiv-workspace{padding:60px 12px 80px}.dcsiv-image{max-width:calc(100vw - 24px);max-height:calc(100dvh - var(--dsh-frame-chrome-top,0px) - 148px)}.dcsiv-topbar{bottom:max(12px,env(safe-area-inset-bottom));max-width:calc(100vw - 24px)}.dcsiv-close-floating{top:max(12px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right))}.dcsiv-erase-bar{top:max(64px,env(safe-area-inset-top));max-width:calc(100vw - 24px);box-sizing:border-box;border-radius:18px;flex-wrap:wrap;justify-content:center;white-space:normal}.dcsiv-erase-bar>span{flex-basis:100%;text-align:center}}
354
+ @media(max-width:600px){.dcsiv-topbar{padding:4px}.dcsiv-actions{gap:1px}.dcsiv-button{padding:0 8px}.dcsiv-icon-button,.dcsiv-download[data-compact="true"]{width:36px}.dcsiv-divider{margin:0 3px}.dcsiv-edit-short{max-width:120px}.dcsiv-download .dcsiv-label{display:none}}
65
355
  @media(max-width:360px){.dcsiv-edit-action{width:36px;padding:0}.dcsiv-edit-short{display:none}}
66
356
  @media(prefers-reduced-motion:reduce){.dcsiv-surface{transition:none}.dcsiv-tool-icon{animation:none!important}}
67
357
  `;
@@ -279,7 +569,8 @@ window.__ModuleLoader__.load({
279
569
  //#endregion
280
570
  //#region src/use-image-source.js
281
571
  function useImageSource(load, identity, preview) {
282
- const [attempt, setAttempt] = (0, react.useState)(0);
572
+ const [retryState, setRetryState] = (0, react.useState)();
573
+ const attempt = retryState?.identity === identity ? retryState.count : 0;
283
574
  const [state, setState] = (0, react.useState)({
284
575
  identity,
285
576
  src: preview,
@@ -329,137 +620,21 @@ window.__ModuleLoader__.load({
329
620
  failed: true,
330
621
  usable: false
331
622
  } : previous),
332
- retry: () => setAttempt((value) => value + 1),
623
+ retry: () => setRetryState((previous) => ({
624
+ identity,
625
+ count: previous?.identity === identity ? previous.count + 1 : 1
626
+ })),
333
627
  attempt
334
628
  };
335
629
  }
336
630
  //#endregion
337
- //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ArrowsPointingOutIcon.js
338
- function ArrowsPointingOutIcon({ title, titleId, ...props }, svgRef) {
339
- return /*#__PURE__*/ react.createElement("svg", Object.assign({
340
- xmlns: "http://www.w3.org/2000/svg",
341
- fill: "none",
342
- viewBox: "0 0 24 24",
343
- strokeWidth: 1.5,
344
- stroke: "currentColor",
345
- "aria-hidden": "true",
346
- "data-slot": "icon",
347
- ref: svgRef,
348
- "aria-labelledby": titleId
349
- }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
350
- strokeLinecap: "round",
351
- strokeLinejoin: "round",
352
- d: "M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"
353
- }));
354
- }
355
- const ForwardRef$5 = /*#__PURE__*/ react.forwardRef(ArrowsPointingOutIcon);
356
- //#endregion
357
- //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ChatBubbleLeftEllipsisIcon.js
358
- function ChatBubbleLeftEllipsisIcon({ title, titleId, ...props }, svgRef) {
359
- return /*#__PURE__*/ react.createElement("svg", Object.assign({
360
- xmlns: "http://www.w3.org/2000/svg",
361
- fill: "none",
362
- viewBox: "0 0 24 24",
363
- strokeWidth: 1.5,
364
- stroke: "currentColor",
365
- "aria-hidden": "true",
366
- "data-slot": "icon",
367
- ref: svgRef,
368
- "aria-labelledby": titleId
369
- }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
370
- strokeLinecap: "round",
371
- strokeLinejoin: "round",
372
- d: "M8.625 9.75a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H8.25m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H12m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 0 1 .778-.332 48.294 48.294 0 0 0 5.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"
373
- }));
374
- }
375
- const ForwardRef$4 = /*#__PURE__*/ react.forwardRef(ChatBubbleLeftEllipsisIcon);
376
- //#endregion
377
- //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/EllipsisHorizontalIcon.js
378
- function EllipsisHorizontalIcon({ title, titleId, ...props }, svgRef) {
379
- return /*#__PURE__*/ react.createElement("svg", Object.assign({
380
- xmlns: "http://www.w3.org/2000/svg",
381
- fill: "none",
382
- viewBox: "0 0 24 24",
383
- strokeWidth: 1.5,
384
- stroke: "currentColor",
385
- "aria-hidden": "true",
386
- "data-slot": "icon",
387
- ref: svgRef,
388
- "aria-labelledby": titleId
389
- }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
390
- strokeLinecap: "round",
391
- strokeLinejoin: "round",
392
- d: "M6.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM12.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"
393
- }));
394
- }
395
- const ForwardRef$3 = /*#__PURE__*/ react.forwardRef(EllipsisHorizontalIcon);
396
- //#endregion
397
- //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PaintBrushIcon.js
398
- function PaintBrushIcon({ title, titleId, ...props }, svgRef) {
399
- return /*#__PURE__*/ react.createElement("svg", Object.assign({
400
- xmlns: "http://www.w3.org/2000/svg",
401
- fill: "none",
402
- viewBox: "0 0 24 24",
403
- strokeWidth: 1.5,
404
- stroke: "currentColor",
405
- "aria-hidden": "true",
406
- "data-slot": "icon",
407
- ref: svgRef,
408
- "aria-labelledby": titleId
409
- }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
410
- strokeLinecap: "round",
411
- strokeLinejoin: "round",
412
- d: "M9.53 16.122a3 3 0 0 0-5.78 1.128 2.25 2.25 0 0 1-2.4 2.245 4.5 4.5 0 0 0 8.4-2.245c0-.399-.078-.78-.22-1.128Zm0 0a15.998 15.998 0 0 0 3.388-1.62m-5.043-.025a15.994 15.994 0 0 1 1.622-3.395m3.42 3.42a15.995 15.995 0 0 0 4.764-4.648l3.876-5.814a1.151 1.151 0 0 0-1.597-1.597L14.146 6.32a15.996 15.996 0 0 0-4.649 4.763m3.42 3.42a6.776 6.776 0 0 0-3.42-3.42"
413
- }));
414
- }
415
- const ForwardRef$2 = /*#__PURE__*/ react.forwardRef(PaintBrushIcon);
416
- //#endregion
417
- //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PencilIcon.js
418
- function PencilIcon({ title, titleId, ...props }, svgRef) {
419
- return /*#__PURE__*/ react.createElement("svg", Object.assign({
420
- xmlns: "http://www.w3.org/2000/svg",
421
- fill: "none",
422
- viewBox: "0 0 24 24",
423
- strokeWidth: 1.5,
424
- stroke: "currentColor",
425
- "aria-hidden": "true",
426
- "data-slot": "icon",
427
- ref: svgRef,
428
- "aria-labelledby": titleId
429
- }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
430
- strokeLinecap: "round",
431
- strokeLinejoin: "round",
432
- d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"
433
- }));
434
- }
435
- const ForwardRef$1 = /*#__PURE__*/ react.forwardRef(PencilIcon);
436
- //#endregion
437
- //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ScissorsIcon.js
438
- function ScissorsIcon({ title, titleId, ...props }, svgRef) {
439
- return /*#__PURE__*/ react.createElement("svg", Object.assign({
440
- xmlns: "http://www.w3.org/2000/svg",
441
- fill: "none",
442
- viewBox: "0 0 24 24",
443
- strokeWidth: 1.5,
444
- stroke: "currentColor",
445
- "aria-hidden": "true",
446
- "data-slot": "icon",
447
- ref: svgRef,
448
- "aria-labelledby": titleId
449
- }, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
450
- strokeLinecap: "round",
451
- strokeLinejoin: "round",
452
- d: "m7.848 8.25 1.536.887M7.848 8.25a3 3 0 1 1-5.196-3 3 3 0 0 1 5.196 3Zm1.536.887a2.165 2.165 0 0 1 1.083 1.839c.005.351.054.695.14 1.024M9.384 9.137l2.077 1.199M7.848 15.75l1.536-.887m-1.536.887a3 3 0 1 1-5.196 3 3 3 0 0 1 5.196-3Zm1.536-.887a2.165 2.165 0 0 0 1.083-1.838c.005-.352.054-.695.14-1.025m-1.223 2.863 2.077-1.199m0-3.328a4.323 4.323 0 0 1 2.068-1.379l5.325-1.628a4.5 4.5 0 0 1 2.48-.044l.803.215-7.794 4.5m-2.882-1.664A4.33 4.33 0 0 0 10.607 12m3.736 0 7.794 4.5-.802.215a4.5 4.5 0 0 1-2.48-.043l-5.326-1.629a4.324 4.324 0 0 1-2.068-1.379M14.343 12l-2.882 1.664"
453
- }));
454
- }
455
- //#endregion
456
631
  //#region src/subscription-image-viewer.jsx
457
632
  const TOOL_ICONS = {
458
- "remove-background": /* @__PURE__ */ react.forwardRef(ScissorsIcon),
459
- erase: ForwardRef$2,
460
- resize: ForwardRef$5,
461
- sketch: ForwardRef$1,
462
- annotate: ForwardRef$4
633
+ "remove-background": ForwardRef$1,
634
+ erase: ForwardRef$4,
635
+ resize: ForwardRef$12,
636
+ sketch: ForwardRef$2,
637
+ annotate: ForwardRef$11
463
638
  };
464
639
  const ToolIcon = ({ id }) => {
465
640
  const Icon = TOOL_ICONS[id];
@@ -562,7 +737,7 @@ window.__ModuleLoader__.load({
562
737
  children: typeof children === "function" ? children(() => setMenu(void 0)) : children
563
738
  }), menu.host) : null] });
564
739
  }
565
- function ViewerAction({ action, annotations, item, service, revision, t, onStartMask, inMenu = false }) {
740
+ function ViewerAction({ action, finishDraft, item, service, revision, onStartMask, inMenu = false }) {
566
741
  const [state, setState] = (0, react.useState)("idle");
567
742
  const active = (0, react.useRef)(true);
568
743
  (0, react.useEffect)(() => {
@@ -576,7 +751,7 @@ window.__ModuleLoader__.load({
576
751
  setState("pending");
577
752
  try {
578
753
  await service.invoke(action, {
579
- annotations,
754
+ annotations: finishDraft(),
580
755
  item,
581
756
  src: item.src,
582
757
  ...extra
@@ -644,8 +819,8 @@ window.__ModuleLoader__.load({
644
819
  type: "button",
645
820
  role,
646
821
  className: "dcsiv-button dcsiv-edit-action",
647
- title: label ?? t("imageEdit"),
648
- "aria-label": label ?? t("imageEdit"),
822
+ title: label,
823
+ "aria-label": label,
649
824
  "data-state": state,
650
825
  disabled: state === "pending",
651
826
  onClick: () => {
@@ -653,7 +828,7 @@ window.__ModuleLoader__.load({
653
828
  },
654
829
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconEditOutline16, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
655
830
  className: "dcsiv-edit-short",
656
- children: state === "idle" ? action.id === "sketch" ? t("imageToSketch") : t("imageEditShort") : label
831
+ children: label
657
832
  })]
658
833
  });
659
834
  }
@@ -716,14 +891,23 @@ window.__ModuleLoader__.load({
716
891
  index: 0
717
892
  });
718
893
  const index = cursor.revision === request?.revision ? cursor.index : request?.index ?? 0;
719
- const setIndex = (update) => setCursor((current) => ({
720
- revision: request.revision,
721
- index: typeof update === "function" ? update(current.revision === request.revision ? current.index : request.index) : update
722
- }));
894
+ const move = (offset) => {
895
+ finishDraft();
896
+ setCursor((current) => {
897
+ const activeIndex = current.revision === request.revision ? current.index : request.index;
898
+ return {
899
+ revision: request.revision,
900
+ index: (activeIndex + offset + request.items.length) % request.items.length
901
+ };
902
+ });
903
+ };
723
904
  const [annotating, setAnnotating] = (0, react.useState)(false);
724
905
  const [annotationsByImage, setAnnotationsByImage] = (0, react.useState)(service.getAnnotationsSnapshot);
725
906
  const annotationsByImageRef = (0, react.useRef)(annotationsByImage);
726
907
  const [selected, setSelected] = (0, react.useState)();
908
+ const [draft, setDraft] = (0, react.useState)();
909
+ const draftRef = (0, react.useRef)();
910
+ draftRef.current = draft;
727
911
  const [focusNote, setFocusNote] = (0, react.useState)();
728
912
  const [copied, setCopied] = (0, react.useState)(false);
729
913
  const [erasing, setErasing] = (0, react.useState)();
@@ -744,6 +928,8 @@ window.__ModuleLoader__.load({
744
928
  const drawingRef = (0, react.useRef)(false);
745
929
  const maskRef = (0, react.useRef)(null);
746
930
  const rootRef = (0, react.useRef)(null);
931
+ const openerRef = (0, react.useRef)();
932
+ if (request) openerRef.current = request.opener;
747
933
  annotationsByImageRef.current = annotationsByImage;
748
934
  (0, react.useEffect)(() => {
749
935
  if (request === void 0) return;
@@ -756,6 +942,10 @@ window.__ModuleLoader__.load({
756
942
  }, [request?.revision]);
757
943
  const item = request?.items[index];
758
944
  const imageSource = useImageSource((0, react.useCallback)(() => item?.reload ? item.reload() : item?.src, [item]), `${request?.revision}:${item?.id}`, item?.src);
945
+ const resolvedItem = imageSource.src === item?.src ? item : {
946
+ ...item,
947
+ src: imageSource.src
948
+ };
759
949
  (0, react.useEffect)(() => () => service.cancelPending(), [
760
950
  service,
761
951
  request?.revision,
@@ -764,7 +954,7 @@ window.__ModuleLoader__.load({
764
954
  const { transform, transformRef, dragging, pixelScale, geometry, stageRef, surfaceRef, imageRef, fit, actual, measure, setZoomAt, resetGesture, pointerHandlers } = useImageTransform(`${request?.revision}:${item?.id}:${item?.src}`);
765
955
  const annotations = item === void 0 ? [] : annotationsByImage[item.id] ?? [];
766
956
  const setAnnotations = (0, react.useCallback)((update) => {
767
- if (item === void 0) return;
957
+ if (item === void 0 || service.getSnapshot()?.revision !== request?.revision) return [];
768
958
  const previous = annotationsByImageRef.current[item.id] ?? [];
769
959
  const next = typeof update === "function" ? update(previous) : update;
770
960
  const snapshot = {
@@ -774,98 +964,124 @@ window.__ModuleLoader__.load({
774
964
  annotationsByImageRef.current = snapshot;
775
965
  service.setAnnotations(item.id, next);
776
966
  setAnnotationsByImage(snapshot);
777
- }, [item?.id, service]);
778
- (0, react.useEffect)(() => {
779
- if (request === void 0) return void 0;
780
- const previousOverflow = document.body.style.overflow;
781
- document.body.style.overflow = "hidden";
782
- rootRef.current?.focus();
783
- const onKeyDown = (event) => {
784
- if (eraseRef.current.erasing !== void 0) {
785
- const key = event.key.toLowerCase();
786
- if (event.key === "Escape") {
787
- event.preventDefault();
788
- if (!eraseRef.current.sending) {
789
- setErasing(void 0);
790
- setStrokes([]);
791
- }
792
- return;
793
- }
794
- if ((event.ctrlKey || event.metaKey) && key === "z") {
795
- event.preventDefault();
796
- if (!eraseRef.current.sending) setStrokes((current) => current.slice(0, -1));
797
- return;
798
- }
799
- if (event.key === "[" || event.key === "]") {
800
- event.preventDefault();
801
- setBrush((value) => Math.round(clamp(value + (event.key === "]" ? .01 : -.01), .01, .15) * 100) / 100);
802
- return;
803
- }
804
- if (event.key === "ArrowLeft" || event.key === "ArrowRight") return;
967
+ return next;
968
+ }, [
969
+ item?.id,
970
+ request?.revision,
971
+ service
972
+ ]);
973
+ const finishDraft = (0, react.useCallback)(() => {
974
+ const pending = draftRef.current;
975
+ const note = pending?.note.trim();
976
+ if (pending) {
977
+ draftRef.current = void 0;
978
+ setDraft(void 0);
979
+ }
980
+ return note ? setAnnotations((current) => [...current, {
981
+ ...pending,
982
+ note
983
+ }]) : annotationsByImageRef.current[item?.id] ?? [];
984
+ }, [item?.id, setAnnotations]);
985
+ const closeViewer = () => {
986
+ finishDraft();
987
+ service.close();
988
+ };
989
+ const open = request !== void 0;
990
+ (0, react.useLayoutEffect)(() => {
991
+ if (!open) return;
992
+ const dialog = rootRef.current;
993
+ dialog.showModal();
994
+ return () => {
995
+ dialog.close();
996
+ const document = dialog.ownerDocument;
997
+ const selector = "dialog:modal, [role=\"dialog\"][aria-modal=\"true\"]";
998
+ if (document.activeElement?.closest(selector)) return;
999
+ const other = Array.from(document.querySelectorAll(selector)).reverse().find((element) => element !== dialog && element.getClientRects().length > 0 && !element.closest("[inert]"));
1000
+ const opener = openerRef.current;
1001
+ const target = other && !other.contains(opener) ? other.querySelector("[data-modal-autofocus]") ?? other : opener;
1002
+ if (target?.isConnected) target.focus({ preventScroll: true });
1003
+ };
1004
+ }, [open]);
1005
+ const consumeKey = (event) => {
1006
+ event.preventDefault();
1007
+ event.stopPropagation();
1008
+ };
1009
+ const dismiss = (event) => {
1010
+ consumeKey(event);
1011
+ if (event.repeat) return;
1012
+ if (eraseRef.current.erasing !== void 0) {
1013
+ if (!eraseRef.current.sending) {
1014
+ setErasing(void 0);
1015
+ setStrokes([]);
805
1016
  }
806
- if (event.key === "Escape") {
807
- event.preventDefault();
808
- if (event.target instanceof Element && event.target.closest(".dcsiv-inline-note") !== null) {
809
- setSelected(void 0);
810
- return;
811
- }
812
- service.close();
1017
+ return;
1018
+ }
1019
+ if (rootRef.current.contains(event.target) && event.target.closest?.(".dcsiv-inline-note")) {
1020
+ draftRef.current = void 0;
1021
+ setSelected(void 0);
1022
+ setDraft(void 0);
1023
+ return;
1024
+ }
1025
+ if (annotating) {
1026
+ finishDraft();
1027
+ setAnnotating(false);
1028
+ return;
1029
+ }
1030
+ closeViewer();
1031
+ };
1032
+ const onKeyDown = (event) => {
1033
+ if (event.defaultPrevented || event.nativeEvent.isComposing) return;
1034
+ if (event.key === "Escape") {
1035
+ dismiss(event);
1036
+ return;
1037
+ }
1038
+ if (event.key === "Tab") {
1039
+ event.stopPropagation();
1040
+ return;
1041
+ }
1042
+ if (eraseRef.current.erasing !== void 0) {
1043
+ const key = event.key.toLowerCase();
1044
+ if ((event.ctrlKey || event.metaKey) && key === "z") {
1045
+ consumeKey(event);
1046
+ if (!eraseRef.current.sending) setStrokes((current) => current.slice(0, -1));
813
1047
  return;
814
1048
  }
815
- const editing = event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement;
816
- if (!editing && event.key === "ArrowLeft" && request.items.length > 1) {
817
- event.preventDefault();
818
- setIndex((value) => (value - 1 + request.items.length) % request.items.length);
819
- } else if (!editing && event.key === "ArrowRight" && request.items.length > 1) {
820
- event.preventDefault();
821
- setIndex((value) => (value + 1) % request.items.length);
822
- } else if (!editing && (event.key === "+" || event.key === "=")) {
823
- event.preventDefault();
824
- const box = stageRef.current?.getBoundingClientRect();
825
- if (box) setZoomAt(transformRef.current.zoom * 1.2, box.left + box.width / 2, box.top + box.height / 2);
826
- } else if (!editing && event.key === "-") {
827
- event.preventDefault();
828
- const box = stageRef.current?.getBoundingClientRect();
829
- if (box) setZoomAt(transformRef.current.zoom / 1.2, box.left + box.width / 2, box.top + box.height / 2);
830
- } else if (!editing && event.key.toLowerCase() === "f") {
831
- event.preventDefault();
832
- fit();
833
- } else if (event.key === "Tab") {
834
- const controls = [...rootRef.current.querySelectorAll("button:not(:disabled),a[href],input:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])")].filter((control) => control.getClientRects().length > 0);
835
- const first = controls[0];
836
- const last = controls.at(-1);
837
- if (event.shiftKey && document.activeElement === first) {
838
- event.preventDefault();
839
- last?.focus();
840
- } else if (!event.shiftKey && document.activeElement === last) {
841
- event.preventDefault();
842
- first?.focus();
843
- }
1049
+ if (event.key === "[" || event.key === "]") {
1050
+ consumeKey(event);
1051
+ setBrush((value) => Math.round(clamp(value + (event.key === "]" ? .01 : -.01), .01, .15) * 100) / 100);
1052
+ return;
844
1053
  }
845
- };
846
- document.addEventListener("keydown", onKeyDown);
847
- return () => {
848
- document.body.style.overflow = previousOverflow;
849
- document.removeEventListener("keydown", onKeyDown);
850
- };
851
- }, [
852
- request,
853
- service,
854
- fit,
855
- setZoomAt
856
- ]);
1054
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") return;
1055
+ }
1056
+ const editing = event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement;
1057
+ if (!editing && event.key === "ArrowLeft" && request.items.length > 1) {
1058
+ consumeKey(event);
1059
+ move(-1);
1060
+ } else if (!editing && event.key === "ArrowRight" && request.items.length > 1) {
1061
+ consumeKey(event);
1062
+ move(1);
1063
+ } else if (!editing && (event.key === "+" || event.key === "=")) {
1064
+ consumeKey(event);
1065
+ const box = stageRef.current?.getBoundingClientRect();
1066
+ if (box) setZoomAt(transformRef.current.zoom * 1.2, box.left + box.width / 2, box.top + box.height / 2);
1067
+ } else if (!editing && event.key === "-") {
1068
+ consumeKey(event);
1069
+ const box = stageRef.current?.getBoundingClientRect();
1070
+ if (box) setZoomAt(transformRef.current.zoom / 1.2, box.left + box.width / 2, box.top + box.height / 2);
1071
+ } else if (!editing && event.key.toLowerCase() === "f") {
1072
+ consumeKey(event);
1073
+ fit();
1074
+ }
1075
+ };
857
1076
  (0, react.useEffect)(() => {
858
1077
  if (focusNote === void 0) return;
859
1078
  (rootRef.current?.querySelector(`[data-note-id="${CSS.escape(focusNote)}"] textarea`))?.focus();
860
1079
  setFocusNote(void 0);
861
- }, [
862
- focusNote,
863
- selected,
864
- annotations.length
865
- ]);
1080
+ }, [focusNote]);
866
1081
  (0, react.useEffect)(() => {
867
1082
  setAnnotating(false);
868
1083
  setSelected(void 0);
1084
+ setDraft(void 0);
869
1085
  setErasing(void 0);
870
1086
  setStrokes([]);
871
1087
  maskOperation.current++;
@@ -932,6 +1148,7 @@ window.__ModuleLoader__.load({
932
1148
  }
933
1149
  };
934
1150
  const startMask = (action) => {
1151
+ finishDraft();
935
1152
  resetGesture();
936
1153
  setAnnotating(false);
937
1154
  setStrokes([]);
@@ -953,8 +1170,8 @@ window.__ModuleLoader__.load({
953
1170
  const mask = await new Promise((resolve, reject) => canvas.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("Mask")), "image/png"));
954
1171
  await service.invoke(erasing, {
955
1172
  mask,
956
- item,
957
- src: item.src,
1173
+ item: resolvedItem,
1174
+ src: resolvedItem.src,
958
1175
  annotations: []
959
1176
  }, request.revision);
960
1177
  if (operation !== maskOperation.current) return;
@@ -968,7 +1185,7 @@ window.__ModuleLoader__.load({
968
1185
  }
969
1186
  };
970
1187
  const addAnnotation = (event) => {
971
- if (!annotating || event.target.closest(".dcsiv-annotation")) return;
1188
+ if (!annotating || !imageRef.current?.naturalWidth || event.target !== imageRef.current) return;
972
1189
  const bounds = surfaceRef.current?.getBoundingClientRect();
973
1190
  if (bounds === void 0) return;
974
1191
  const annotation = {
@@ -977,13 +1194,18 @@ window.__ModuleLoader__.load({
977
1194
  y: clamp((event.clientY - bounds.top) / bounds.height, 0, 1),
978
1195
  note: ""
979
1196
  };
980
- setAnnotations((current) => [...current, annotation]);
981
- setAnnotating(false);
982
- setSelected(annotation.id);
1197
+ finishDraft();
1198
+ setDraft(annotation);
1199
+ setSelected(void 0);
983
1200
  setFocusNote(annotation.id);
984
1201
  };
1202
+ const saveDraft = () => {
1203
+ if (!draft?.note.trim()) return;
1204
+ finishDraft();
1205
+ rootRef.current?.focus();
1206
+ };
985
1207
  const copyNotes = async () => {
986
- const text = noteText(annotations, t);
1208
+ const text = noteText(finishDraft(), t);
987
1209
  if (text === "" || typeof navigator?.clipboard?.writeText !== "function") return;
988
1210
  try {
989
1211
  await navigator.clipboard.writeText(text);
@@ -998,53 +1220,70 @@ window.__ModuleLoader__.load({
998
1220
  if (request === void 0 || item === void 0) return null;
999
1221
  const meta = [item.width && item.height ? `${item.width} × ${item.height}` : void 0, bytesLabel(item.bytes)].filter(Boolean).join(" · ");
1000
1222
  const showCounter = request.items.length > 1;
1001
- const secondaryActions = item.actions.filter((action) => action.kind === "tool" || action.kind === "mask" || action.kind === "choice" || action.id === "sketch");
1002
- const primaryActions = item.actions.filter((action) => !secondaryActions.includes(action));
1223
+ const actions = imageSource.usable ? item.actions : [];
1224
+ const secondaryActions = actions.filter((action) => action.kind === "tool" || action.kind === "mask" || action.kind === "choice" || action.id === "sketch");
1225
+ const primaryActions = actions.filter((action) => !secondaryActions.includes(action));
1226
+ const hasNotes = Boolean(draft?.note.trim()) || annotations.some((annotation) => annotation.note.trim() !== "");
1227
+ const showMore = compact && imageSource.usable || secondaryActions.length > 0 || hasNotes;
1003
1228
  const renderAction = (action, inMenu = false, closeMenu) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerAction, {
1004
1229
  action,
1005
- annotations,
1006
- item,
1230
+ finishDraft,
1231
+ item: resolvedItem,
1007
1232
  service,
1008
1233
  revision: request.revision,
1009
- t,
1010
1234
  onStartMask: (action) => {
1011
1235
  closeMenu?.();
1012
1236
  startMask(action);
1013
1237
  },
1014
1238
  inMenu
1015
1239
  }, `${request.revision}:${index}:${action.id}`);
1016
- const zoomControl = (inMenu) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1240
+ const zoomLabel = t(transform.zoom === 1 ? "imageActual" : "imageFit");
1241
+ const zoomControl = (closeMenu) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1017
1242
  type: "button",
1018
- role: inMenu ? "menuitem" : void 0,
1243
+ role: closeMenu ? "menuitem" : void 0,
1019
1244
  className: "dcsiv-button dcsiv-zoom",
1020
- title: transform.zoom === 1 ? t("imageActual") : t("imageFit"),
1021
- "aria-label": transform.zoom === 1 ? t("imageActual") : t("imageFit"),
1245
+ title: zoomLabel,
1246
+ "aria-label": zoomLabel,
1247
+ "aria-description": t("imageZoomHint"),
1022
1248
  onClick: () => {
1249
+ closeMenu?.();
1023
1250
  if (transform.zoom === 1) actual();
1024
1251
  else fit();
1025
1252
  },
1026
1253
  children: [
1027
1254
  Math.round(transform.zoom * pixelScale * 100),
1028
1255
  "%",
1029
- inMenu ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: transform.zoom === 1 ? t("imageActual") : t("imageFit") }) : null
1256
+ closeMenu ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: zoomLabel }) : null
1030
1257
  ]
1031
1258
  });
1032
1259
  const annotationPosition = (annotation) => {
1033
1260
  const ratio = globalThis.devicePixelRatio || 1;
1034
1261
  const align = (value) => Math.round(value * ratio) / ratio;
1262
+ const x = align(geometry.stageWidth / 2 + transform.x + (annotation.x - .5) * geometry.width * transform.zoom);
1263
+ const y = align(geometry.stageHeight / 2 + transform.y + (annotation.y - .5) * geometry.height * transform.zoom);
1264
+ const width = Math.max(0, Math.min(300, geometry.stageWidth - 16));
1265
+ const left = clamp(x - width / 2, 8, geometry.stageWidth - width - 8);
1035
1266
  return {
1036
- left: align(geometry.stageWidth / 2 + transform.x + (annotation.x - .5) * geometry.width * transform.zoom - 12),
1037
- top: align(geometry.stageHeight / 2 + transform.y + (annotation.y - .5) * geometry.height * transform.zoom - 12),
1267
+ left: x - 12,
1268
+ top: y - 12,
1269
+ "--note-width": `${width}px`,
1270
+ "--note-left": `${left - x + 12}px`,
1271
+ "--note-arrow": `${clamp(x - left - 4, 12, width - 20)}px`,
1272
+ "--note-top": y < 100 ? "34px" : "auto",
1273
+ "--note-bottom": y < 100 ? "auto" : "34px",
1274
+ "--note-arrow-y": y < 100 ? "-5px" : "auto",
1275
+ "--note-arrow-bottom": y < 100 ? "auto" : "-5px",
1038
1276
  visibility: geometry.width > 0 ? "visible" : "hidden"
1039
1277
  };
1040
1278
  };
1041
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1279
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
1042
1280
  ref: rootRef,
1043
1281
  className: "dcsiv-root",
1044
1282
  role: "dialog",
1045
1283
  "aria-modal": "true",
1046
1284
  "aria-label": t("imagePreview"),
1047
- tabIndex: -1,
1285
+ onKeyDown,
1286
+ onCancel: dismiss,
1048
1287
  children: [
1049
1288
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1050
1289
  className: "dcsiv-title dcsiv-sr-only",
@@ -1057,75 +1296,94 @@ window.__ModuleLoader__.load({
1057
1296
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1058
1297
  className: "dcsiv-actions",
1059
1298
  children: [
1060
- showCounter ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1061
- className: "dcsiv-counter",
1062
- role: "status",
1063
- "aria-live": "polite",
1064
- "aria-atomic": "true",
1299
+ showCounter ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1300
+ className: "dcsiv-gallery",
1065
1301
  children: [
1066
- index + 1,
1067
- " / ",
1068
- request.items.length
1302
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1303
+ type: "button",
1304
+ className: "dcsiv-button dcsiv-nav dcsiv-prev",
1305
+ disabled: erasing !== void 0,
1306
+ title: t("imagePrevious"),
1307
+ "aria-label": t("imagePrevious"),
1308
+ onClick: () => move(-1),
1309
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronLeftOutline14, {})
1310
+ }),
1311
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1312
+ className: "dcsiv-counter",
1313
+ role: "status",
1314
+ "aria-live": "polite",
1315
+ "aria-atomic": "true",
1316
+ children: [
1317
+ index + 1,
1318
+ " / ",
1319
+ request.items.length
1320
+ ]
1321
+ }),
1322
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1323
+ type: "button",
1324
+ className: "dcsiv-button dcsiv-nav dcsiv-next",
1325
+ disabled: erasing !== void 0,
1326
+ title: t("imageNext"),
1327
+ "aria-label": t("imageNext"),
1328
+ onClick: () => move(1),
1329
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronRightOutline14, {})
1330
+ })
1069
1331
  ]
1070
1332
  }) : null,
1071
- !compact ? zoomControl(false) : null,
1072
- item.download === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1333
+ !compact && imageSource.usable ? zoomControl() : null,
1334
+ item.download === void 0 ? imageSource.usable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1073
1335
  className: "dcsiv-download",
1074
1336
  "data-compact": "true",
1075
- href: item.src,
1337
+ href: imageSource.src,
1076
1338
  download: downloadName(item.name),
1077
1339
  title: t("imageDownload"),
1078
1340
  "aria-label": t("imageDownload"),
1079
1341
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconDownloadOutline16, {})
1080
1342
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerDownload, {
1081
1343
  download: item.download,
1082
- item,
1344
+ item: resolvedItem,
1083
1345
  t
1084
1346
  }, item.id),
1085
- request.annotations || item.actions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1347
+ imageSource.usable && (request.annotations || actions.length > 0) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1086
1348
  className: "dcsiv-divider",
1087
1349
  "aria-hidden": "true"
1088
1350
  }) : null,
1089
- request.annotations ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1351
+ request.annotations && imageSource.usable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1090
1352
  type: "button",
1091
1353
  className: "dcsiv-button dcsiv-icon-button",
1092
1354
  "data-active": annotating,
1093
1355
  title: annotating ? t("imageAnnotateCancel") : t("imageAnnotate"),
1094
1356
  "aria-label": annotating ? t("imageAnnotateCancel") : t("imageAnnotate"),
1357
+ "aria-description": t("imageAnnotateHint"),
1095
1358
  "aria-pressed": annotating,
1096
1359
  onClick: () => {
1097
1360
  resetGesture();
1361
+ finishDraft();
1362
+ setSelected(void 0);
1098
1363
  setAnnotating((value) => !value);
1099
1364
  },
1100
1365
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: "annotate" })
1101
1366
  }) : null,
1102
- !compact && annotations.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1103
- type: "button",
1104
- className: "dcsiv-button",
1105
- "data-active": selected !== void 0,
1106
- onClick: () => {
1107
- const first = annotations[0];
1108
- setSelected((current) => current === void 0 ? first.id : void 0);
1109
- if (selected === void 0) setFocusNote(first.id);
1110
- },
1111
- children: [
1112
- annotations.length,
1113
- " ",
1114
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1115
- className: "dcsiv-label",
1116
- children: t("imageRegions")
1117
- })
1118
- ]
1119
- }) : null,
1120
1367
  primaryActions.map((action) => renderAction(action)),
1121
- compact ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerMenu, {
1368
+ showMore ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerMenu, {
1122
1369
  label: t("imageMore"),
1123
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ForwardRef$3, {
1370
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ForwardRef$5, {
1124
1371
  className: "dcsiv-tool-icon",
1125
1372
  "aria-hidden": "true"
1126
1373
  }),
1127
- children: (close) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [zoomControl(true), secondaryActions.map((action) => renderAction(action, true, close))] })
1128
- }, `${request.revision}:${index}:more`) : secondaryActions.map((action) => renderAction(action))
1374
+ children: (close) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1375
+ compact && imageSource.usable ? zoomControl(close) : null,
1376
+ secondaryActions.map((action) => renderAction(action, true, close)),
1377
+ hasNotes ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1378
+ type: "button",
1379
+ role: "menuitem",
1380
+ onClick: () => {
1381
+ copyNotes();
1382
+ },
1383
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCopyOutline16, {}), t(copied ? "imageCopied" : "imageCopyNotes")]
1384
+ }) : null
1385
+ ] })
1386
+ }, `${request.revision}:${index}:more`) : null
1129
1387
  ]
1130
1388
  })
1131
1389
  }),
@@ -1134,7 +1392,7 @@ window.__ModuleLoader__.load({
1134
1392
  className: "dcsiv-close-floating",
1135
1393
  title: t("imageClosePreview"),
1136
1394
  "aria-label": t("imageClosePreview"),
1137
- onClick: () => service.close(),
1395
+ onClick: closeViewer,
1138
1396
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCloseOutline16, {})
1139
1397
  }),
1140
1398
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1146,139 +1404,133 @@ window.__ModuleLoader__.load({
1146
1404
  "data-dragging": dragging,
1147
1405
  "data-annotating": annotating || erasing !== void 0,
1148
1406
  onClick: (event) => {
1149
- if (event.target === event.currentTarget && !annotating && !erasing && transform.zoom === 1) service.close();
1407
+ if (event.target === event.currentTarget && !annotating && !erasing && transform.zoom === 1) closeViewer();
1150
1408
  },
1151
1409
  ...!annotating && !erasing ? pointerHandlers : {},
1152
1410
  onDoubleClick: () => {
1153
1411
  if (transform.zoom === 1) actual();
1154
1412
  else fit();
1155
1413
  },
1156
- children: [
1157
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1158
- ref: surfaceRef,
1159
- className: "dcsiv-surface",
1160
- onClick: addAnnotation,
1161
- style: { transform: `translate3d(${transform.x}px,${transform.y}px,0) scale(${transform.zoom})` },
1414
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1415
+ ref: surfaceRef,
1416
+ className: "dcsiv-surface",
1417
+ onClick: addAnnotation,
1418
+ style: { transform: `translate3d(${transform.x}px,${transform.y}px,0) scale(${transform.zoom})` },
1419
+ children: [
1420
+ imageSource.src && (!imageSource.failed || imageSource.usable) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
1421
+ ref: imageRef,
1422
+ className: "dcsiv-image",
1423
+ src: imageSource.src,
1424
+ alt: item.name,
1425
+ draggable: "false",
1426
+ onError: imageSource.fail,
1427
+ onLoad: () => {
1428
+ imageSource.loaded();
1429
+ measure();
1430
+ }
1431
+ }, `${request.revision}:${item.id}:${imageSource.attempt}`) : null,
1432
+ !imageSource.src && !imageSource.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1433
+ role: "status",
1434
+ children: t("imageLoading")
1435
+ }) : null,
1436
+ imageSource.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1437
+ type: "button",
1438
+ className: "dcsiv-button",
1439
+ onClick: imageSource.retry,
1440
+ children: t("imageLoadFailed")
1441
+ }) : null,
1442
+ erasing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("canvas", {
1443
+ ref: maskRef,
1444
+ className: "dcsiv-mask",
1445
+ width: imageRef.current?.naturalWidth || 1,
1446
+ height: imageRef.current?.naturalHeight || 1,
1447
+ "aria-label": t("imageEraseHint"),
1448
+ ...maskHandlers
1449
+ }) : null
1450
+ ]
1451
+ }), (draft ? [...annotations, draft] : annotations).map((annotation, position) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1452
+ className: "dcsiv-annotation",
1453
+ style: annotationPosition(annotation),
1454
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1455
+ type: "button",
1456
+ className: "dcsiv-pin",
1457
+ "data-active": draft === annotation || selected === annotation.id,
1458
+ "aria-label": fill(t("imageAnnotation"), { value: position + 1 }),
1459
+ onClick: () => {
1460
+ if (draft === annotation) {
1461
+ setFocusNote(annotation.id);
1462
+ return;
1463
+ }
1464
+ const opening = selected !== annotation.id;
1465
+ finishDraft();
1466
+ setSelected(opening ? annotation.id : void 0);
1467
+ if (opening) setFocusNote(annotation.id);
1468
+ },
1469
+ children: position + 1
1470
+ }), draft === annotation || selected === annotation.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1471
+ className: "dcsiv-inline-note",
1472
+ "data-note-id": annotation.id,
1473
+ "data-draft": draft === annotation,
1474
+ onClick: (event) => event.stopPropagation(),
1162
1475
  children: [
1163
- imageSource.failed && !imageSource.usable ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
1164
- ref: imageRef,
1165
- className: "dcsiv-image",
1166
- src: imageSource.src,
1167
- alt: item.name,
1168
- draggable: "false",
1169
- onError: imageSource.fail,
1170
- onLoad: () => {
1171
- imageSource.loaded();
1172
- measure();
1476
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1477
+ className: "dcsiv-inline-index",
1478
+ children: position + 1
1479
+ }),
1480
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
1481
+ value: annotation.note,
1482
+ rows: 1,
1483
+ "aria-label": fill(t("imageAnnotation"), { value: position + 1 }),
1484
+ placeholder: t("imageAnnotationPlaceholder"),
1485
+ onChange: (event) => {
1486
+ const note = event.target.value;
1487
+ if (draft === annotation) setDraft({
1488
+ ...draft,
1489
+ note
1490
+ });
1491
+ else setAnnotations((current) => current.map((entry) => entry.id === annotation.id ? {
1492
+ ...entry,
1493
+ note
1494
+ } : entry));
1495
+ },
1496
+ onKeyDown: (event) => {
1497
+ if (!event.nativeEvent.isComposing && (event.key === "Enter" && !event.shiftKey || event.key === "Escape")) {
1498
+ event.preventDefault();
1499
+ event.stopPropagation();
1500
+ event.nativeEvent?.stopImmediatePropagation?.();
1501
+ if (draft === annotation && event.key === "Enter") saveDraft();
1502
+ else {
1503
+ setDraft(void 0);
1504
+ setSelected(void 0);
1505
+ rootRef.current?.focus();
1506
+ }
1507
+ }
1173
1508
  }
1174
- }, `${request.revision}:${item.id}:${imageSource.attempt}`),
1175
- imageSource.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1509
+ }),
1510
+ draft === annotation ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1176
1511
  type: "button",
1177
- className: "dcsiv-button",
1178
- onClick: imageSource.retry,
1179
- children: t("imageLoadFailed")
1512
+ className: "dcsiv-note-remove",
1513
+ "aria-label": t("sketchTextDone"),
1514
+ title: t("sketchTextDone"),
1515
+ disabled: !draft.note.trim(),
1516
+ onClick: saveDraft,
1517
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCheckOutline16, {})
1180
1518
  }) : null,
1181
- erasing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("canvas", {
1182
- ref: maskRef,
1183
- className: "dcsiv-mask",
1184
- width: imageRef.current?.naturalWidth || 1,
1185
- height: imageRef.current?.naturalHeight || 1,
1186
- "aria-label": t("imageEraseHint"),
1187
- ...maskHandlers
1188
- }) : null
1519
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1520
+ type: "button",
1521
+ className: "dcsiv-note-remove",
1522
+ "aria-label": t(draft === annotation ? "cancel" : "imageRemoveAnnotation"),
1523
+ onClick: () => {
1524
+ if (draft === annotation) setDraft(void 0);
1525
+ else setAnnotations((current) => current.filter((entry) => entry.id !== annotation.id));
1526
+ setSelected(void 0);
1527
+ rootRef.current?.focus();
1528
+ },
1529
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCloseOutline16, {})
1530
+ })
1189
1531
  ]
1190
- }),
1191
- annotations.map((annotation, position) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1192
- className: "dcsiv-annotation",
1193
- "data-x": annotation.x < .38 ? "right" : annotation.x > .62 ? "left" : "center",
1194
- "data-y": annotation.y < .28 ? "down" : "up",
1195
- style: annotationPosition(annotation),
1196
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1197
- type: "button",
1198
- className: "dcsiv-pin",
1199
- "data-active": selected === annotation.id,
1200
- "aria-label": fill(t("imageAnnotation"), { value: position + 1 }),
1201
- onClick: (event) => {
1202
- event.stopPropagation();
1203
- const opening = selected !== annotation.id;
1204
- setSelected(opening ? annotation.id : void 0);
1205
- if (opening) setFocusNote(annotation.id);
1206
- },
1207
- children: position + 1
1208
- }), selected === annotation.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1209
- className: "dcsiv-inline-note",
1210
- "data-note-id": annotation.id,
1211
- onClick: (event) => event.stopPropagation(),
1212
- children: [
1213
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1214
- className: "dcsiv-inline-index",
1215
- children: position + 1
1216
- }),
1217
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
1218
- value: annotation.note,
1219
- rows: 1,
1220
- "aria-label": fill(t("imageAnnotation"), { value: position + 1 }),
1221
- placeholder: t("imageAnnotationPlaceholder"),
1222
- onChange: (event) => {
1223
- const note = event.target.value;
1224
- setAnnotations((current) => current.map((entry) => entry.id === annotation.id ? {
1225
- ...entry,
1226
- note
1227
- } : entry));
1228
- },
1229
- onKeyDown: (event) => {
1230
- if (event.key === "Enter" && !event.shiftKey || event.key === "Escape") {
1231
- event.preventDefault();
1232
- event.stopPropagation();
1233
- event.nativeEvent?.stopImmediatePropagation?.();
1234
- setSelected(void 0);
1235
- }
1236
- }
1237
- }),
1238
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1239
- type: "button",
1240
- className: "dcsiv-note-remove",
1241
- "aria-label": t("imageRemoveAnnotation"),
1242
- onClick: (event) => {
1243
- event.stopPropagation();
1244
- setAnnotations((current) => current.filter((entry) => entry.id !== annotation.id));
1245
- setSelected(void 0);
1246
- },
1247
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCloseOutline16, {})
1248
- })
1249
- ]
1250
- }) : null]
1251
- }, annotation.id)),
1252
- showCounter ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1253
- type: "button",
1254
- className: "dcsiv-button dcsiv-icon-only dcsiv-nav dcsiv-prev",
1255
- disabled: erasing !== void 0,
1256
- title: t("imagePrevious"),
1257
- "aria-label": t("imagePrevious"),
1258
- onClick: (event) => {
1259
- event.stopPropagation();
1260
- setIndex((value) => (value - 1 + request.items.length) % request.items.length);
1261
- },
1262
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronLeftOutline14, {})
1263
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1264
- type: "button",
1265
- className: "dcsiv-button dcsiv-icon-only dcsiv-nav dcsiv-next",
1266
- disabled: erasing !== void 0,
1267
- title: t("imageNext"),
1268
- "aria-label": t("imageNext"),
1269
- onClick: (event) => {
1270
- event.stopPropagation();
1271
- setIndex((value) => (value + 1) % request.items.length);
1272
- },
1273
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronRightOutline14, {})
1274
- })] }) : annotating ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1275
- className: "dcsiv-hint",
1276
- children: t("imageAnnotateHint")
1277
- }) : transform.zoom === 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1278
- className: "dcsiv-hint",
1279
- children: t("imageZoomHint")
1280
- }) : null
1281
- ]
1532
+ }) : null]
1533
+ }, annotation.id))]
1282
1534
  }),
1283
1535
  erasing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1284
1536
  className: "dcsiv-erase-bar",
@@ -1332,14 +1584,6 @@ window.__ModuleLoader__.load({
1332
1584
  width: brush * brushCursor.span,
1333
1585
  height: brush * brushCursor.span
1334
1586
  }
1335
- }) : null,
1336
- annotations.some((annotation) => annotation.note.trim() !== "") ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1337
- type: "button",
1338
- className: "dcsiv-copy-notes",
1339
- onClick: () => {
1340
- copyNotes();
1341
- },
1342
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCopyOutline16, {}), copied ? t("imageCopied") : t("imageCopyNotes")]
1343
1587
  }) : null
1344
1588
  ]
1345
1589
  })