dsh-codex-subscription 3.2.2 → 3.2.3

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.
@@ -45,22 +45,24 @@ window.__ModuleLoader__.load({
45
45
  const SUBSCRIPTION_IMAGE_VIEWER_CSS = String.raw`
46
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)}
47
47
  .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:22px;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:32px;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{position:absolute;top:20px;right:20px;z-index:8;display:grid;place-items:center;width:42px;height:42px;padding:0;border:1px solid rgba(255,255,255,.1);border-radius:50%;background:rgba(48,49,53,.82);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:hover{background:rgba(66,67,72,.92)}
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}
51
51
  .dcsiv-workspace{position:absolute;inset:0;display:grid;min-width:0;min-height:0;padding:68px 24px 72px;box-sizing:border-box}
52
52
  .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
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}
54
54
  .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
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;width:42px;height:42px;padding:0;transform:translateY(-50%);background:rgba(48,49,53,.82);box-shadow:0 8px 24px rgba(0,0,0,.28);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}.dcsiv-prev{left:6px}.dcsiv-next{right:6px}.dcsiv-counter{position:absolute;bottom:8px;left:50%;padding:5px 10px;border-radius:999px;background:rgba(38,39,43,.86);color:rgba(255,255,255,.72);font-size:11px;transform:translateX(-50%);backdrop-filter:blur(16px)}
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
57
  .dcsiv-hint{display:none}
58
58
  .dcsiv-mask{position:absolute;inset:0;width:100%;height:100%;border-radius:12px;cursor:crosshair;touch-action:none}
59
- .dcsiv-tool-icon{width:16px;height:16px;flex:none}.dcsiv-icon-button,.dcsiv-download[data-compact="true"]{width:34px;padding:0!important;justify-content:center}.dcsiv-zoom{min-width:52px;font-variant-numeric:tabular-nums}.dcsiv-divider{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:150px;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{height:32px;padding:0 10px;border:0;border-radius:8px;background:none;color:rgba(255,255,255,.9);font:inherit;font-size:13px;text-align:left;cursor:pointer}.dcsiv-menu button:hover,.dcsiv-menu button:focus-visible{outline:none;background:rgba(255,255,255,.1)}
59
+ .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
60
  .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
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
- .dcsiv-edit-short{display:none}
63
- @media(max-width:760px){.dcsiv-actions{flex-wrap:wrap;justify-content:center}.dcsiv-edit-short{display:inline;white-space:normal;max-width:min(280px,calc(100vw - 80px))}.dcsiv-edit-action{height:auto;min-height:32px}.dcsiv-close-floating{top:12px;right:12px;width:40px;height:40px}.dcsiv-workspace{padding:60px 12px 68px}.dcsiv-image{max-width:calc(100vw - 24px);max-height:calc(100vh - 136px)}.dcsiv-topbar{bottom:12px;max-width:calc(100vw - 24px)}.dcsiv-button{padding:0 8px}.dcsiv-button span.dcsiv-label{display:none}.dcsiv-inline-note{width:min(260px,calc(100vw - 40px))}.dcsiv-copy-notes{display:none}}
62
+ .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}}
65
+ @media(max-width:360px){.dcsiv-edit-action{width:36px;padding:0}.dcsiv-edit-short{display:none}}
64
66
  @media(prefers-reduced-motion:reduce){.dcsiv-surface{transition:none}.dcsiv-tool-icon{animation:none!important}}
65
67
  `;
66
68
  //#endregion
@@ -275,6 +277,63 @@ window.__ModuleLoader__.load({
275
277
  paintEraseStrokes(context, strokes, width, height, "#fff");
276
278
  }
277
279
  //#endregion
280
+ //#region src/use-image-source.js
281
+ function useImageSource(load, identity, preview) {
282
+ const [attempt, setAttempt] = (0, react.useState)(0);
283
+ const [state, setState] = (0, react.useState)({
284
+ identity,
285
+ src: preview,
286
+ failed: false,
287
+ usable: false
288
+ });
289
+ (0, react.useEffect)(() => {
290
+ let live = true;
291
+ setState((previous) => ({
292
+ identity,
293
+ src: previous.identity === identity ? previous.src : preview,
294
+ failed: false,
295
+ usable: previous.identity === identity && previous.usable
296
+ }));
297
+ Promise.resolve().then(() => attempt === 0 && preview ? preview : load()).then((src) => {
298
+ if (live) setState((previous) => ({
299
+ identity,
300
+ src,
301
+ failed: !src,
302
+ usable: previous.identity === identity && previous.src === src && previous.usable
303
+ }));
304
+ }, () => {
305
+ if (live) setState((previous) => ({
306
+ ...previous,
307
+ failed: true
308
+ }));
309
+ });
310
+ return () => {
311
+ live = false;
312
+ };
313
+ }, [
314
+ identity,
315
+ load,
316
+ preview,
317
+ attempt
318
+ ]);
319
+ return {
320
+ src: state.identity === identity ? state.src : preview,
321
+ failed: state.identity === identity && state.failed,
322
+ usable: state.identity === identity && state.usable,
323
+ loaded: () => setState((previous) => previous.identity === identity ? {
324
+ ...previous,
325
+ usable: true
326
+ } : previous),
327
+ fail: () => setState((previous) => previous.identity === identity ? {
328
+ ...previous,
329
+ failed: true,
330
+ usable: false
331
+ } : previous),
332
+ retry: () => setAttempt((value) => value + 1),
333
+ attempt
334
+ };
335
+ }
336
+ //#endregion
278
337
  //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ArrowsPointingOutIcon.js
279
338
  function ArrowsPointingOutIcon({ title, titleId, ...props }, svgRef) {
280
339
  return /*#__PURE__*/ react.createElement("svg", Object.assign({
@@ -293,7 +352,7 @@ window.__ModuleLoader__.load({
293
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"
294
353
  }));
295
354
  }
296
- const ForwardRef$4 = /*#__PURE__*/ react.forwardRef(ArrowsPointingOutIcon);
355
+ const ForwardRef$5 = /*#__PURE__*/ react.forwardRef(ArrowsPointingOutIcon);
297
356
  //#endregion
298
357
  //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ChatBubbleLeftEllipsisIcon.js
299
358
  function ChatBubbleLeftEllipsisIcon({ title, titleId, ...props }, svgRef) {
@@ -313,7 +372,27 @@ window.__ModuleLoader__.load({
313
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"
314
373
  }));
315
374
  }
316
- const ForwardRef$3 = /*#__PURE__*/ react.forwardRef(ChatBubbleLeftEllipsisIcon);
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);
317
396
  //#endregion
318
397
  //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PaintBrushIcon.js
319
398
  function PaintBrushIcon({ title, titleId, ...props }, svgRef) {
@@ -378,9 +457,9 @@ window.__ModuleLoader__.load({
378
457
  const TOOL_ICONS = {
379
458
  "remove-background": /* @__PURE__ */ react.forwardRef(ScissorsIcon),
380
459
  erase: ForwardRef$2,
381
- resize: ForwardRef$4,
460
+ resize: ForwardRef$5,
382
461
  sketch: ForwardRef$1,
383
- annotate: ForwardRef$3
462
+ annotate: ForwardRef$4
384
463
  };
385
464
  const ToolIcon = ({ id }) => {
386
465
  const Icon = TOOL_ICONS[id];
@@ -399,23 +478,23 @@ window.__ModuleLoader__.load({
399
478
  const noteText = (annotations, t) => annotations.map((annotation, index) => {
400
479
  return `${fill(t("imageAnnotation"), { value: index + 1 })} (${Math.round(annotation.x * 100)}%, ${Math.round(annotation.y * 100)}%): ${annotation.note.trim()}`;
401
480
  }).filter((line) => !line.endsWith(": ")).join("\n");
402
- function ViewerAction({ action, annotations, item, service, revision, t, onStartMask }) {
403
- const [state, setState] = (0, react.useState)("idle");
481
+ const compactQuery = "(max-width: 600px)";
482
+ const compactSnapshot = () => globalThis.matchMedia?.(compactQuery).matches ?? false;
483
+ const subscribeCompact = (listener) => {
484
+ const query = globalThis.matchMedia?.(compactQuery);
485
+ query?.addEventListener("change", listener);
486
+ return () => query?.removeEventListener("change", listener);
487
+ };
488
+ function ViewerMenu({ label, children, icon, role, disabled, state }) {
404
489
  const [menu, setMenu] = (0, react.useState)();
405
- const active = (0, react.useRef)(true);
406
490
  const menuRef = (0, react.useRef)(null);
407
491
  const menuButtonRef = (0, react.useRef)(null);
408
- (0, react.useEffect)(() => {
409
- active.current = true;
410
- return () => {
411
- active.current = false;
412
- };
413
- }, []);
414
492
  (0, react.useEffect)(() => {
415
493
  if (menu === void 0) return void 0;
416
494
  menuRef.current?.querySelector("[role=\"menuitem\"]")?.focus();
417
495
  const onKeyDown = (event) => {
418
- const items = [...menuRef.current?.querySelectorAll("[role=\"menuitem\"]") ?? []];
496
+ if (!menuRef.current?.contains(event.target) && event.target !== menuButtonRef.current) return;
497
+ const items = [...menuRef.current?.querySelectorAll("[role=\"menuitem\"]:not(:disabled)") ?? []];
419
498
  if (event.key === "Escape") {
420
499
  event.preventDefault();
421
500
  event.stopPropagation();
@@ -426,46 +505,104 @@ window.__ModuleLoader__.load({
426
505
  event.stopPropagation();
427
506
  const step = event.key === "ArrowDown" ? 1 : -1;
428
507
  items[(items.indexOf(document.activeElement) + step + items.length) % items.length].focus();
429
- } else if (event.key === "Tab") setMenu(void 0);
508
+ } else if (event.key === "Home" || event.key === "End") {
509
+ event.preventDefault();
510
+ event.stopPropagation();
511
+ (event.key === "Home" ? items[0] : items.at(-1))?.focus();
512
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
513
+ event.preventDefault();
514
+ event.stopPropagation();
515
+ } else if (event.key === "Tab") {
516
+ setMenu(void 0);
517
+ menuButtonRef.current?.focus();
518
+ }
430
519
  };
431
520
  const onPointerDown = (event) => {
432
- if (!menuRef.current?.contains(event.target) && !menuButtonRef.current?.contains(event.target)) setMenu(void 0);
521
+ if (!menuRef.current?.contains(event.target) && !menuButtonRef.current?.contains(event.target) && !event.target.closest?.(".dcsiv-menu")) setMenu(void 0);
433
522
  };
523
+ const onResize = () => setMenu(void 0);
434
524
  window.addEventListener("keydown", onKeyDown, true);
435
525
  window.addEventListener("pointerdown", onPointerDown, true);
526
+ window.addEventListener("resize", onResize);
436
527
  return () => {
437
528
  window.removeEventListener("keydown", onKeyDown, true);
438
529
  window.removeEventListener("pointerdown", onPointerDown, true);
530
+ window.removeEventListener("resize", onResize);
439
531
  };
440
532
  }, [menu]);
533
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
534
+ ref: menuButtonRef,
535
+ type: "button",
536
+ role,
537
+ "aria-haspopup": "menu",
538
+ "aria-expanded": menu !== void 0,
539
+ "data-state": state,
540
+ disabled,
541
+ onClick: (event) => {
542
+ const box = event.currentTarget.getBoundingClientRect();
543
+ const host = event.currentTarget.closest(".dcsiv-root");
544
+ setMenu((value) => value === void 0 && host ? {
545
+ host,
546
+ style: {
547
+ right: Math.max(12, window.innerWidth - box.right),
548
+ bottom: window.innerHeight - box.top + 8
549
+ }
550
+ } : void 0);
551
+ },
552
+ className: "dcsiv-button dcsiv-icon-button",
553
+ title: label,
554
+ "aria-label": label,
555
+ children: icon
556
+ }), menu ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
557
+ ref: menuRef,
558
+ className: "dcsiv-menu",
559
+ role: "menu",
560
+ "aria-label": label,
561
+ style: menu.style,
562
+ children: typeof children === "function" ? children(() => setMenu(void 0)) : children
563
+ }), menu.host) : null] });
564
+ }
565
+ function ViewerAction({ action, annotations, item, service, revision, t, onStartMask, inMenu = false }) {
566
+ const [state, setState] = (0, react.useState)("idle");
567
+ const active = (0, react.useRef)(true);
568
+ (0, react.useEffect)(() => {
569
+ active.current = true;
570
+ return () => {
571
+ active.current = false;
572
+ };
573
+ }, []);
441
574
  const invoke = async (extra = {}) => {
442
575
  if (state === "pending") return;
443
576
  setState("pending");
444
577
  try {
445
- await action.onInvoke({
578
+ await service.invoke(action, {
446
579
  annotations,
447
580
  item,
448
581
  src: item.src,
449
582
  ...extra
450
- });
451
- if (!active.current || service.getSnapshot()?.revision !== revision) return;
452
- setState("idle");
583
+ }, revision);
584
+ if (service.getSnapshot()?.revision !== revision) return;
585
+ if (active.current) setState("idle");
453
586
  if (action.closeOnSuccess) service.close();
454
- } catch {
455
- if (active.current) setState("failed");
587
+ } catch (error) {
588
+ if (active.current) setState(error?.name === "AbortError" ? "idle" : "failed");
456
589
  }
457
590
  };
458
591
  const label = state === "pending" ? action.pendingLabel : state === "failed" ? action.errorLabel : action.label;
592
+ const role = inMenu ? "menuitem" : void 0;
593
+ const tool = (id) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id }), inMenu ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }) : null] });
459
594
  if (action.kind === "mask") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
460
595
  type: "button",
596
+ role,
461
597
  className: "dcsiv-button dcsiv-icon-button",
462
598
  title: action.label,
463
599
  "aria-label": action.label,
464
600
  onClick: () => onStartMask(action),
465
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: action.id })
601
+ children: tool(action.id)
466
602
  });
467
603
  if (action.kind === "tool") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
468
604
  type: "button",
605
+ role,
469
606
  className: "dcsiv-button dcsiv-icon-button",
470
607
  title: label,
471
608
  "aria-label": label,
@@ -474,75 +611,50 @@ window.__ModuleLoader__.load({
474
611
  onClick: () => {
475
612
  invoke();
476
613
  },
477
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: action.id })
614
+ children: tool(action.id)
478
615
  });
479
616
  if (action.id === "sketch" && state === "idle") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
480
617
  type: "button",
618
+ role,
481
619
  className: "dcsiv-button dcsiv-icon-button",
482
620
  title: action.label,
483
621
  "aria-label": action.label,
484
622
  onClick: () => {
485
623
  invoke();
486
624
  },
487
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: "sketch" })
625
+ children: tool("sketch")
488
626
  });
489
- if (action.kind === "choice") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
490
- ref: menuButtonRef,
491
- type: "button",
492
- "aria-haspopup": "menu",
493
- "aria-expanded": menu !== void 0,
494
- "data-state": state,
627
+ if (action.kind === "choice") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerMenu, {
628
+ label,
629
+ role,
630
+ state,
495
631
  disabled: state === "pending",
496
- onClick: (event) => {
497
- const box = event.currentTarget.getBoundingClientRect();
498
- const host = event.currentTarget.closest(".dcsiv-root");
499
- setMenu((value) => value === void 0 && host ? {
500
- host,
501
- style: {
502
- left: box.left,
503
- bottom: window.innerHeight - box.top + 8
504
- }
505
- } : void 0);
506
- },
507
- className: "dcsiv-button dcsiv-icon-button",
508
- title: label,
509
- "aria-label": label,
510
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: action.id })
511
- }), menu ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
512
- ref: menuRef,
513
- className: "dcsiv-menu",
514
- role: "menu",
515
- "aria-label": action.label,
516
- style: menu.style,
517
- children: action.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
632
+ icon: tool(action.id),
633
+ children: (close) => action.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
518
634
  type: "button",
519
635
  role: "menuitem",
520
636
  onClick: () => {
521
- setMenu(void 0);
637
+ close();
522
638
  invoke({ option: option.value });
523
639
  },
524
640
  children: option.label
525
641
  }, option.value))
526
- }), menu.host) : null] });
642
+ });
527
643
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
528
644
  type: "button",
645
+ role,
529
646
  className: "dcsiv-button dcsiv-edit-action",
647
+ title: label ?? t("imageEdit"),
530
648
  "aria-label": label ?? t("imageEdit"),
649
+ "data-state": state,
531
650
  disabled: state === "pending",
532
651
  onClick: () => {
533
652
  invoke();
534
653
  },
535
- children: [
536
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconEditOutline16, {}),
537
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
538
- className: "dcsiv-label",
539
- children: label ?? t("imageEdit")
540
- }),
541
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
542
- className: "dcsiv-edit-short",
543
- children: state === "idle" ? action.id === "sketch" ? t("imageToSketch") : t("imageEditShort") : label
544
- })
545
- ]
654
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconEditOutline16, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
655
+ className: "dcsiv-edit-short",
656
+ children: state === "idle" ? action.id === "sketch" ? t("imageToSketch") : t("imageEditShort") : label
657
+ })]
546
658
  });
547
659
  }
548
660
  function ViewerDownload({ download, item, t }) {
@@ -598,6 +710,7 @@ window.__ModuleLoader__.load({
598
710
  }
599
711
  function SubscriptionImageViewerOverlay({ service, t }) {
600
712
  const request = (0, react.useSyncExternalStore)(service.subscribe, service.getSnapshot);
713
+ const compact = (0, react.useSyncExternalStore)(subscribeCompact, compactSnapshot, () => false);
601
714
  const [cursor, setCursor] = (0, react.useState)({
602
715
  revision: 0,
603
716
  index: 0
@@ -618,6 +731,7 @@ window.__ModuleLoader__.load({
618
731
  const [brush, setBrush] = (0, react.useState)(.05);
619
732
  const [sending, setSending] = (0, react.useState)(false);
620
733
  const [sendFailed, setSendFailed] = (0, react.useState)(false);
734
+ const maskOperation = (0, react.useRef)(0);
621
735
  const [brushCursor, setBrushCursor] = (0, react.useState)();
622
736
  const eraseRef = (0, react.useRef)({
623
737
  erasing: void 0,
@@ -636,8 +750,17 @@ window.__ModuleLoader__.load({
636
750
  setAnnotating(false);
637
751
  setSelected(void 0);
638
752
  setCopied(false);
753
+ const saved = service.getAnnotationsSnapshot();
754
+ annotationsByImageRef.current = saved;
755
+ setAnnotationsByImage(saved);
639
756
  }, [request?.revision]);
640
757
  const item = request?.items[index];
758
+ const imageSource = useImageSource((0, react.useCallback)(() => item?.reload ? item.reload() : item?.src, [item]), `${request?.revision}:${item?.id}`, item?.src);
759
+ (0, react.useEffect)(() => () => service.cancelPending(), [
760
+ service,
761
+ request?.revision,
762
+ item?.id
763
+ ]);
641
764
  const { transform, transformRef, dragging, pixelScale, geometry, stageRef, surfaceRef, imageRef, fit, actual, measure, setZoomAt, resetGesture, pointerHandlers } = useImageTransform(`${request?.revision}:${item?.id}:${item?.src}`);
642
765
  const annotations = item === void 0 ? [] : annotationsByImage[item.id] ?? [];
643
766
  const setAnnotations = (0, react.useCallback)((update) => {
@@ -708,7 +831,7 @@ window.__ModuleLoader__.load({
708
831
  event.preventDefault();
709
832
  fit();
710
833
  } else if (event.key === "Tab") {
711
- const controls = [...rootRef.current.querySelectorAll("button:not(:disabled),a[href],input:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])")];
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);
712
835
  const first = controls[0];
713
836
  const last = controls.at(-1);
714
837
  if (event.shiftKey && document.activeElement === first) {
@@ -745,6 +868,12 @@ window.__ModuleLoader__.load({
745
868
  setSelected(void 0);
746
869
  setErasing(void 0);
747
870
  setStrokes([]);
871
+ maskOperation.current++;
872
+ setSending(false);
873
+ setSendFailed(false);
874
+ return () => {
875
+ maskOperation.current++;
876
+ };
748
877
  }, [
749
878
  item?.id,
750
879
  item?.src,
@@ -814,26 +943,28 @@ window.__ModuleLoader__.load({
814
943
  const image = imageRef.current;
815
944
  if (!erasing || strokes.length === 0 || image === null || sending) return;
816
945
  setSending(true);
946
+ const operation = ++maskOperation.current;
817
947
  setSendFailed(false);
818
948
  try {
819
949
  const canvas = document.createElement("canvas");
820
- canvas.width = image.naturalWidth;
821
- canvas.height = image.naturalHeight;
950
+ canvas.width = item.width ?? image.naturalWidth;
951
+ canvas.height = item.height ?? image.naturalHeight;
822
952
  paintEraseMask(canvas.getContext("2d"), strokes, canvas.width, canvas.height);
823
953
  const mask = await new Promise((resolve, reject) => canvas.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("Mask")), "image/png"));
824
- await erasing.onInvoke({
954
+ await service.invoke(erasing, {
825
955
  mask,
826
956
  item,
827
957
  src: item.src,
828
958
  annotations: []
829
- });
959
+ }, request.revision);
960
+ if (operation !== maskOperation.current) return;
830
961
  setErasing(void 0);
831
962
  setStrokes([]);
832
963
  if (erasing.closeOnSuccess) service.close();
833
964
  } catch {
834
- setSendFailed(true);
965
+ if (operation === maskOperation.current) setSendFailed(true);
835
966
  } finally {
836
- setSending(false);
967
+ if (operation === maskOperation.current) setSending(false);
837
968
  }
838
969
  };
839
970
  const addAnnotation = (event) => {
@@ -867,6 +998,37 @@ window.__ModuleLoader__.load({
867
998
  if (request === void 0 || item === void 0) return null;
868
999
  const meta = [item.width && item.height ? `${item.width} × ${item.height}` : void 0, bytesLabel(item.bytes)].filter(Boolean).join(" · ");
869
1000
  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));
1003
+ const renderAction = (action, inMenu = false, closeMenu) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerAction, {
1004
+ action,
1005
+ annotations,
1006
+ item,
1007
+ service,
1008
+ revision: request.revision,
1009
+ t,
1010
+ onStartMask: (action) => {
1011
+ closeMenu?.();
1012
+ startMask(action);
1013
+ },
1014
+ inMenu
1015
+ }, `${request.revision}:${index}:${action.id}`);
1016
+ const zoomControl = (inMenu) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1017
+ type: "button",
1018
+ role: inMenu ? "menuitem" : void 0,
1019
+ className: "dcsiv-button dcsiv-zoom",
1020
+ title: transform.zoom === 1 ? t("imageActual") : t("imageFit"),
1021
+ "aria-label": transform.zoom === 1 ? t("imageActual") : t("imageFit"),
1022
+ onClick: () => {
1023
+ if (transform.zoom === 1) actual();
1024
+ else fit();
1025
+ },
1026
+ children: [
1027
+ Math.round(transform.zoom * pixelScale * 100),
1028
+ "%",
1029
+ inMenu ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: transform.zoom === 1 ? t("imageActual") : t("imageFit") }) : null
1030
+ ]
1031
+ });
870
1032
  const annotationPosition = (annotation) => {
871
1033
  const ratio = globalThis.devicePixelRatio || 1;
872
1034
  const align = (value) => Math.round(value * ratio) / ratio;
@@ -895,9 +1057,38 @@ window.__ModuleLoader__.load({
895
1057
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
896
1058
  className: "dcsiv-actions",
897
1059
  children: [
898
- request.annotations ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1060
+ showCounter ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1061
+ className: "dcsiv-counter",
1062
+ role: "status",
1063
+ "aria-live": "polite",
1064
+ "aria-atomic": "true",
1065
+ children: [
1066
+ index + 1,
1067
+ " / ",
1068
+ request.items.length
1069
+ ]
1070
+ }) : null,
1071
+ !compact ? zoomControl(false) : null,
1072
+ item.download === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1073
+ className: "dcsiv-download",
1074
+ "data-compact": "true",
1075
+ href: item.src,
1076
+ download: downloadName(item.name),
1077
+ title: t("imageDownload"),
1078
+ "aria-label": t("imageDownload"),
1079
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconDownloadOutline16, {})
1080
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerDownload, {
1081
+ download: item.download,
1082
+ item,
1083
+ t
1084
+ }, item.id),
1085
+ request.annotations || item.actions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1086
+ className: "dcsiv-divider",
1087
+ "aria-hidden": "true"
1088
+ }) : null,
1089
+ request.annotations ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
899
1090
  type: "button",
900
- className: annotating ? "dcsiv-button" : "dcsiv-button dcsiv-icon-button",
1091
+ className: "dcsiv-button dcsiv-icon-button",
901
1092
  "data-active": annotating,
902
1093
  title: annotating ? t("imageAnnotateCancel") : t("imageAnnotate"),
903
1094
  "aria-label": annotating ? t("imageAnnotateCancel") : t("imageAnnotate"),
@@ -906,12 +1097,9 @@ window.__ModuleLoader__.load({
906
1097
  resetGesture();
907
1098
  setAnnotating((value) => !value);
908
1099
  },
909
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: "annotate" }), annotating ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
910
- className: "dcsiv-label",
911
- children: t("imageAnnotateCancel")
912
- }) : null]
1100
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: "annotate" })
913
1101
  }) : null,
914
- annotations.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1102
+ !compact && annotations.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
915
1103
  type: "button",
916
1104
  className: "dcsiv-button",
917
1105
  "data-active": selected !== void 0,
@@ -929,49 +1117,22 @@ window.__ModuleLoader__.load({
929
1117
  })
930
1118
  ]
931
1119
  }) : null,
932
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
933
- type: "button",
934
- className: "dcsiv-button dcsiv-zoom",
935
- title: transform.zoom === 1 ? t("imageActual") : t("imageFit"),
936
- "aria-label": transform.zoom === 1 ? t("imageActual") : t("imageFit"),
937
- onClick: () => {
938
- if (transform.zoom === 1) actual();
939
- else fit();
940
- },
941
- children: [Math.round(transform.zoom * pixelScale * 100), "%"]
942
- }),
943
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
944
- className: "dcsiv-divider",
945
- "aria-hidden": "true"
946
- }),
947
- item.download === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
948
- className: "dcsiv-download",
949
- "data-compact": "true",
950
- href: item.src,
951
- download: downloadName(item.name),
952
- title: t("imageDownload"),
953
- "aria-label": t("imageDownload"),
954
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconDownloadOutline16, {})
955
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerDownload, {
956
- download: item.download,
957
- item,
958
- t
959
- }, item.id),
960
- item.actions.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerAction, {
961
- action,
962
- annotations,
963
- item,
964
- service,
965
- revision: request.revision,
966
- t,
967
- onStartMask: startMask
968
- }, `${request.revision}:${index}:${action.id}`))
1120
+ primaryActions.map((action) => renderAction(action)),
1121
+ compact ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerMenu, {
1122
+ label: t("imageMore"),
1123
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ForwardRef$3, {
1124
+ className: "dcsiv-tool-icon",
1125
+ "aria-hidden": "true"
1126
+ }),
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))
969
1129
  ]
970
1130
  })
971
1131
  }),
972
1132
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
973
1133
  type: "button",
974
1134
  className: "dcsiv-close-floating",
1135
+ title: t("imageClosePreview"),
975
1136
  "aria-label": t("imageClosePreview"),
976
1137
  onClick: () => service.close(),
977
1138
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCloseOutline16, {})
@@ -998,23 +1159,34 @@ window.__ModuleLoader__.load({
998
1159
  className: "dcsiv-surface",
999
1160
  onClick: addAnnotation,
1000
1161
  style: { transform: `translate3d(${transform.x}px,${transform.y}px,0) scale(${transform.zoom})` },
1001
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
1002
- ref: imageRef,
1003
- className: "dcsiv-image",
1004
- src: item.src,
1005
- alt: item.name,
1006
- draggable: "false",
1007
- onLoad: () => {
1008
- measure();
1009
- }
1010
- }, `${request.revision}:${item.id}`), erasing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("canvas", {
1011
- ref: maskRef,
1012
- className: "dcsiv-mask",
1013
- width: imageRef.current?.naturalWidth || 1,
1014
- height: imageRef.current?.naturalHeight || 1,
1015
- "aria-label": t("imageEraseHint"),
1016
- ...maskHandlers
1017
- }) : null]
1162
+ 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();
1173
+ }
1174
+ }, `${request.revision}:${item.id}:${imageSource.attempt}`),
1175
+ imageSource.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1176
+ type: "button",
1177
+ className: "dcsiv-button",
1178
+ onClick: imageSource.retry,
1179
+ children: t("imageLoadFailed")
1180
+ }) : 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
1189
+ ]
1018
1190
  }),
1019
1191
  annotations.map((annotation, position) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1020
1192
  className: "dcsiv-annotation",
@@ -1077,36 +1249,29 @@ window.__ModuleLoader__.load({
1077
1249
  ]
1078
1250
  }) : null]
1079
1251
  }, annotation.id)),
1080
- showCounter ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1081
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1082
- type: "button",
1083
- className: "dcsiv-button dcsiv-icon-only dcsiv-nav dcsiv-prev",
1084
- "aria-label": t("imagePrevious"),
1085
- onClick: (event) => {
1086
- event.stopPropagation();
1087
- setIndex((value) => (value - 1 + request.items.length) % request.items.length);
1088
- },
1089
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronLeftOutline14, {})
1090
- }),
1091
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1092
- type: "button",
1093
- className: "dcsiv-button dcsiv-icon-only dcsiv-nav dcsiv-next",
1094
- "aria-label": t("imageNext"),
1095
- onClick: (event) => {
1096
- event.stopPropagation();
1097
- setIndex((value) => (value + 1) % request.items.length);
1098
- },
1099
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronRightOutline14, {})
1100
- }),
1101
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1102
- className: "dcsiv-counter",
1103
- children: [
1104
- index + 1,
1105
- " / ",
1106
- request.items.length
1107
- ]
1108
- })
1109
- ] }) : annotating ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
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", {
1110
1275
  className: "dcsiv-hint",
1111
1276
  children: t("imageAnnotateHint")
1112
1277
  }) : transform.zoom === 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {