@embedpdf/plugin-annotation 2.6.2 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +203 -8
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +12 -1
  6. package/dist/lib/annotation-plugin.d.ts +17 -0
  7. package/dist/lib/tools/default-tools.d.ts +2 -0
  8. package/dist/lib/tools/types.d.ts +2 -0
  9. package/dist/lib/types.d.ts +18 -2
  10. package/dist/preact/index.cjs +1 -1
  11. package/dist/preact/index.cjs.map +1 -1
  12. package/dist/preact/index.js +1008 -1058
  13. package/dist/preact/index.js.map +1 -1
  14. package/dist/react/index.cjs +1 -1
  15. package/dist/react/index.cjs.map +1 -1
  16. package/dist/react/index.js +1008 -1058
  17. package/dist/react/index.js.map +1 -1
  18. package/dist/shared/components/annotation-container.d.ts +11 -5
  19. package/dist/shared/components/annotations/circle.d.ts +4 -2
  20. package/dist/shared/components/annotations/free-text.d.ts +4 -1
  21. package/dist/shared/components/annotations/ink.d.ts +3 -1
  22. package/dist/shared/components/annotations/line.d.ts +3 -1
  23. package/dist/shared/components/annotations/polygon.d.ts +3 -2
  24. package/dist/shared/components/annotations/polyline.d.ts +3 -1
  25. package/dist/shared/components/annotations/square.d.ts +4 -2
  26. package/dist/shared/components/annotations.d.ts +0 -1
  27. package/dist/shared/components/appearance-image.d.ts +12 -0
  28. package/dist/shared/components/built-in-renderers.d.ts +2 -0
  29. package/dist/shared/components/text-markup/highlight.d.ts +3 -1
  30. package/dist/shared/components/text-markup/squiggly.d.ts +3 -1
  31. package/dist/shared/components/text-markup/strikeout.d.ts +3 -1
  32. package/dist/shared/components/text-markup/underline.d.ts +3 -1
  33. package/dist/shared/components/types.d.ts +66 -10
  34. package/dist/shared-preact/components/annotation-container.d.ts +11 -5
  35. package/dist/shared-preact/components/annotations/circle.d.ts +4 -2
  36. package/dist/shared-preact/components/annotations/free-text.d.ts +4 -1
  37. package/dist/shared-preact/components/annotations/ink.d.ts +3 -1
  38. package/dist/shared-preact/components/annotations/line.d.ts +3 -1
  39. package/dist/shared-preact/components/annotations/polygon.d.ts +3 -2
  40. package/dist/shared-preact/components/annotations/polyline.d.ts +3 -1
  41. package/dist/shared-preact/components/annotations/square.d.ts +4 -2
  42. package/dist/shared-preact/components/annotations.d.ts +0 -1
  43. package/dist/shared-preact/components/appearance-image.d.ts +12 -0
  44. package/dist/shared-preact/components/built-in-renderers.d.ts +2 -0
  45. package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -1
  46. package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -1
  47. package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -1
  48. package/dist/shared-preact/components/text-markup/underline.d.ts +3 -1
  49. package/dist/shared-preact/components/types.d.ts +66 -10
  50. package/dist/shared-react/components/annotation-container.d.ts +11 -5
  51. package/dist/shared-react/components/annotations/circle.d.ts +4 -2
  52. package/dist/shared-react/components/annotations/free-text.d.ts +4 -1
  53. package/dist/shared-react/components/annotations/ink.d.ts +3 -1
  54. package/dist/shared-react/components/annotations/line.d.ts +3 -1
  55. package/dist/shared-react/components/annotations/polygon.d.ts +3 -2
  56. package/dist/shared-react/components/annotations/polyline.d.ts +3 -1
  57. package/dist/shared-react/components/annotations/square.d.ts +4 -2
  58. package/dist/shared-react/components/annotations.d.ts +0 -1
  59. package/dist/shared-react/components/appearance-image.d.ts +12 -0
  60. package/dist/shared-react/components/built-in-renderers.d.ts +2 -0
  61. package/dist/shared-react/components/text-markup/highlight.d.ts +3 -1
  62. package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -1
  63. package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -1
  64. package/dist/shared-react/components/text-markup/underline.d.ts +3 -1
  65. package/dist/shared-react/components/types.d.ts +66 -10
  66. package/dist/svelte/components/Annotations.svelte.d.ts +0 -7
  67. package/dist/svelte/components/AppearanceImage.svelte.d.ts +8 -0
  68. package/dist/svelte/components/annotations/Circle.svelte.d.ts +1 -10
  69. package/dist/svelte/components/annotations/FreeText.svelte.d.ts +1 -0
  70. package/dist/svelte/components/annotations/Ink.svelte.d.ts +1 -1
  71. package/dist/svelte/components/annotations/Line.svelte.d.ts +1 -0
  72. package/dist/svelte/components/annotations/Polygon.svelte.d.ts +1 -0
  73. package/dist/svelte/components/annotations/Polyline.svelte.d.ts +1 -1
  74. package/dist/svelte/components/annotations/Square.svelte.d.ts +1 -0
  75. package/dist/svelte/components/built-in-renderers.d.ts +2 -0
  76. package/dist/svelte/components/renderers/CircleRenderer.svelte.d.ts +5 -0
  77. package/dist/svelte/components/renderers/FreeTextRenderer.svelte.d.ts +5 -0
  78. package/dist/svelte/components/renderers/HighlightRenderer.svelte.d.ts +5 -0
  79. package/dist/svelte/components/renderers/InkRenderer.svelte.d.ts +5 -0
  80. package/dist/svelte/components/renderers/LineRenderer.svelte.d.ts +5 -0
  81. package/dist/svelte/components/renderers/LinkRenderer.svelte.d.ts +5 -0
  82. package/dist/svelte/components/renderers/PolygonRenderer.svelte.d.ts +5 -0
  83. package/dist/svelte/components/renderers/PolylineRenderer.svelte.d.ts +5 -0
  84. package/dist/svelte/components/renderers/SquareRenderer.svelte.d.ts +5 -0
  85. package/dist/svelte/components/renderers/SquigglyRenderer.svelte.d.ts +5 -0
  86. package/dist/svelte/components/renderers/StampRenderer.svelte.d.ts +5 -0
  87. package/dist/svelte/components/renderers/StrikeoutRenderer.svelte.d.ts +5 -0
  88. package/dist/svelte/components/renderers/UnderlineRenderer.svelte.d.ts +5 -0
  89. package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -0
  90. package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -0
  91. package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -0
  92. package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -0
  93. package/dist/svelte/components/types.d.ts +8 -2
  94. package/dist/svelte/context/renderer-registry.svelte.d.ts +2 -2
  95. package/dist/svelte/context/types.d.ts +63 -2
  96. package/dist/svelte/index.cjs +1 -1
  97. package/dist/svelte/index.cjs.map +1 -1
  98. package/dist/svelte/index.js +2509 -2864
  99. package/dist/svelte/index.js.map +1 -1
  100. package/dist/vue/components/annotation-container.vue.d.ts +8 -3
  101. package/dist/vue/components/annotation-layer.vue.d.ts +1 -20
  102. package/dist/vue/components/annotations/circle.vue.d.ts +18 -5
  103. package/dist/vue/components/annotations/free-text.vue.d.ts +17 -5
  104. package/dist/vue/components/annotations/ink.vue.d.ts +16 -6
  105. package/dist/vue/components/annotations/line.vue.d.ts +20 -5
  106. package/dist/vue/components/annotations/link.vue.d.ts +24 -6
  107. package/dist/vue/components/annotations/polygon.vue.d.ts +21 -5
  108. package/dist/vue/components/annotations/polyline.vue.d.ts +18 -5
  109. package/dist/vue/components/annotations/square.vue.d.ts +18 -5
  110. package/dist/vue/components/annotations/stamp.vue.d.ts +11 -5
  111. package/dist/vue/components/annotations.vue.d.ts +8 -575
  112. package/dist/vue/components/appearance-image.vue.d.ts +9 -0
  113. package/dist/vue/components/built-in-renderers.d.ts +2 -0
  114. package/dist/vue/components/group-selection-box.vue.d.ts +2 -2
  115. package/dist/vue/components/renderers/circle-renderer.vue.d.ts +6 -0
  116. package/dist/vue/components/renderers/free-text-renderer.vue.d.ts +6 -0
  117. package/dist/vue/components/renderers/highlight-renderer.vue.d.ts +6 -0
  118. package/dist/vue/components/renderers/ink-renderer.vue.d.ts +6 -0
  119. package/dist/vue/components/renderers/line-renderer.vue.d.ts +6 -0
  120. package/dist/vue/components/renderers/link-renderer.vue.d.ts +6 -0
  121. package/dist/vue/components/renderers/polygon-renderer.vue.d.ts +6 -0
  122. package/dist/vue/components/renderers/polyline-renderer.vue.d.ts +6 -0
  123. package/dist/vue/components/renderers/square-renderer.vue.d.ts +6 -0
  124. package/dist/vue/components/renderers/squiggly-renderer.vue.d.ts +6 -0
  125. package/dist/vue/components/renderers/stamp-renderer.vue.d.ts +6 -0
  126. package/dist/vue/components/renderers/strikeout-renderer.vue.d.ts +6 -0
  127. package/dist/vue/components/renderers/underline-renderer.vue.d.ts +6 -0
  128. package/dist/vue/components/text-markup/highlight.vue.d.ts +17 -5
  129. package/dist/vue/components/text-markup/squiggly.vue.d.ts +17 -5
  130. package/dist/vue/components/text-markup/strikeout.vue.d.ts +17 -5
  131. package/dist/vue/components/text-markup/underline.vue.d.ts +17 -5
  132. package/dist/vue/context/renderer-registry.d.ts +2 -2
  133. package/dist/vue/context/types.d.ts +63 -2
  134. package/dist/vue/index.cjs +1 -1
  135. package/dist/vue/index.cjs.map +1 -1
  136. package/dist/vue/index.js +1651 -1278
  137. package/dist/vue/index.js.map +1 -1
  138. package/package.json +10 -10
@@ -1,12 +1,12 @@
1
1
  import { createPluginPackage } from "@embedpdf/core";
2
- import { initialDocumentState, AnnotationPlugin, patching, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp, isLink, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
2
+ import { initialDocumentState, AnnotationPlugin, patching, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
3
3
  export * from "@embedpdf/plugin-annotation";
4
4
  import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
5
5
  import { createContext, Fragment as Fragment$1 } from "preact";
6
6
  import { useState, useCallback, useContext, useRef, useEffect, useMemo, useLayoutEffect } from "preact/hooks";
7
7
  import { createPortal } from "preact/compat";
8
8
  import { useCapability, usePlugin, useDocumentPermissions, useDocumentState } from "@embedpdf/core/preact";
9
- import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype } from "@embedpdf/models";
9
+ import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfAnnotationSubtype, blendModeToCss, PdfBlendMode } from "@embedpdf/models";
10
10
  import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
11
11
  import { useSelectionCapability } from "@embedpdf/plugin-selection/preact";
12
12
  import { useInteractionHandles, useDoublePressProps, CounterRotate } from "@embedpdf/utils/preact";
@@ -59,6 +59,43 @@ const useAnnotation = (documentId) => {
59
59
  provides: (provides == null ? void 0 : provides.forDocument(documentId)) ?? null
60
60
  };
61
61
  };
62
+ function AppearanceImage({ appearance, style }) {
63
+ const [imageUrl, setImageUrl] = useState(null);
64
+ const urlRef = useRef(null);
65
+ useEffect(() => {
66
+ const url = URL.createObjectURL(appearance.data);
67
+ setImageUrl(url);
68
+ urlRef.current = url;
69
+ return () => {
70
+ if (urlRef.current) {
71
+ URL.revokeObjectURL(urlRef.current);
72
+ urlRef.current = null;
73
+ }
74
+ };
75
+ }, [appearance.data]);
76
+ const handleImageLoad = () => {
77
+ if (urlRef.current) {
78
+ URL.revokeObjectURL(urlRef.current);
79
+ urlRef.current = null;
80
+ }
81
+ };
82
+ return imageUrl ? /* @__PURE__ */ jsx(
83
+ "img",
84
+ {
85
+ src: imageUrl,
86
+ onLoad: handleImageLoad,
87
+ style: {
88
+ position: "absolute",
89
+ width: "100%",
90
+ height: "100%",
91
+ display: "block",
92
+ pointerEvents: "none",
93
+ userSelect: "none",
94
+ ...style
95
+ }
96
+ }
97
+ ) : null;
98
+ }
62
99
  function AnnotationContainer({
63
100
  scale,
64
101
  documentId,
@@ -69,6 +106,7 @@ function AnnotationContainer({
69
106
  trackedAnnotation,
70
107
  children,
71
108
  isSelected,
109
+ isEditing = false,
72
110
  isMultiSelected = false,
73
111
  isDraggable,
74
112
  isResizable,
@@ -80,6 +118,7 @@ function AnnotationContainer({
80
118
  outlineOffset = 1,
81
119
  onDoubleClick,
82
120
  onSelect,
121
+ appearance,
83
122
  zIndex = 1,
84
123
  resizeUI,
85
124
  vertexUI,
@@ -98,6 +137,7 @@ function AnnotationContainer({
98
137
  const [liveRotation, setLiveRotation] = useState(null);
99
138
  const [cursorScreen, setCursorScreen] = useState(null);
100
139
  const [isHandleHovered, setIsHandleHovered] = useState(false);
140
+ const [gestureActive, setGestureActive] = useState(false);
101
141
  const { provides: annotationCapability } = useAnnotationCapability();
102
142
  const { plugin } = useAnnotationPlugin();
103
143
  const { canModifyAnnotations } = useDocumentPermissions(documentId);
@@ -142,6 +182,9 @@ function AnnotationContainer({
142
182
  if (event.state === "start") {
143
183
  gestureBaseRectRef.current = trackedAnnotation.object.unrotatedRect ?? trackedAnnotation.object.rect;
144
184
  gestureBaseRef.current = trackedAnnotation.object;
185
+ if (type === "resize" || type === "vertex-edit") {
186
+ setGestureActive(true);
187
+ }
145
188
  if (type === "move") {
146
189
  plugin.startDrag(documentId, { annotationIds: [id], pageSize });
147
190
  } else if (type === "resize") {
@@ -202,6 +245,7 @@ function AnnotationContainer({
202
245
  if (event.state === "end") {
203
246
  gestureBaseRectRef.current = null;
204
247
  gestureBaseRef.current = null;
248
+ setGestureActive(false);
205
249
  if (type === "move") plugin.commitDrag(documentId);
206
250
  else if (type === "resize") plugin.commitResize(documentId);
207
251
  }
@@ -315,6 +359,7 @@ function AnnotationContainer({
315
359
  }
316
360
  return currentObject;
317
361
  }, [currentObject, explicitUnrotatedRect]);
362
+ const apActive = !!(appearance == null ? void 0 : appearance.normal) && !gestureActive && !isEditing && !trackedAnnotation.dictMode;
318
363
  return /* @__PURE__ */ jsxs("div", { "data-no-interaction": true, children: [
319
364
  /* @__PURE__ */ jsxs(
320
365
  "div",
@@ -491,7 +536,7 @@ function AnnotationContainer({
491
536
  },
492
537
  children: [
493
538
  (() => {
494
- const childrenRender = typeof children === "function" ? children(childObject) : children;
539
+ const childrenRender = typeof children === "function" ? children(childObject, { appearanceActive: apActive }) : children;
495
540
  const customRender = customAnnotationRenderer == null ? void 0 : customAnnotationRenderer({
496
541
  annotation: childObject,
497
542
  children: childrenRender,
@@ -503,11 +548,15 @@ function AnnotationContainer({
503
548
  pageIndex,
504
549
  onSelect
505
550
  });
506
- if (customRender !== null && customRender !== void 0) {
507
- return customRender;
508
- }
509
- return childrenRender;
551
+ return customRender ?? childrenRender;
510
552
  })(),
553
+ (appearance == null ? void 0 : appearance.normal) && /* @__PURE__ */ jsx(
554
+ AppearanceImage,
555
+ {
556
+ appearance: appearance.normal,
557
+ style: { display: apActive ? "block" : "none" }
558
+ }
559
+ ),
511
560
  isSelected && effectiveIsResizable && !rotationActive && resize.map(
512
561
  ({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
513
562
  key,
@@ -1064,188 +1113,23 @@ function GroupSelectionBox({
1064
1113
  )
1065
1114
  ] });
1066
1115
  }
1067
- function Highlight({
1068
- strokeColor,
1069
- opacity = 0.5,
1070
- segmentRects,
1071
- rect,
1072
- scale,
1073
- onClick,
1074
- style
1075
- }) {
1076
- const resolvedColor = strokeColor ?? "#FFFF00";
1077
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
1078
- "div",
1079
- {
1080
- onPointerDown: onClick,
1081
- onTouchStart: onClick,
1082
- style: {
1083
- position: "absolute",
1084
- left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
1085
- top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
1086
- width: b.size.width * scale,
1087
- height: b.size.height * scale,
1088
- background: resolvedColor,
1089
- opacity,
1090
- pointerEvents: onClick ? "auto" : "none",
1091
- cursor: onClick ? "pointer" : "default",
1092
- zIndex: onClick ? 1 : void 0,
1093
- ...style
1094
- }
1095
- },
1096
- i
1097
- )) });
1098
- }
1099
- function Underline({
1100
- strokeColor,
1101
- opacity = 0.5,
1102
- segmentRects,
1103
- rect,
1104
- scale,
1105
- onClick,
1106
- style
1107
- }) {
1108
- const resolvedColor = strokeColor ?? "#FFFF00";
1109
- const thickness = 2 * scale;
1110
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
1111
- "div",
1112
- {
1113
- onPointerDown: onClick,
1114
- onTouchStart: onClick,
1115
- style: {
1116
- position: "absolute",
1117
- left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
1118
- top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
1119
- width: r.size.width * scale,
1120
- height: r.size.height * scale,
1121
- background: "transparent",
1122
- pointerEvents: onClick ? "auto" : "none",
1123
- cursor: onClick ? "pointer" : "default",
1124
- zIndex: onClick ? 1 : 0,
1125
- ...style
1126
- },
1127
- children: /* @__PURE__ */ jsx(
1128
- "div",
1129
- {
1130
- style: {
1131
- position: "absolute",
1132
- left: 0,
1133
- bottom: 0,
1134
- width: "100%",
1135
- height: thickness,
1136
- background: resolvedColor,
1137
- opacity,
1138
- pointerEvents: "none"
1139
- }
1140
- }
1141
- )
1142
- },
1143
- i
1144
- )) });
1145
- }
1146
- function Strikeout({
1147
- strokeColor,
1148
- opacity = 0.5,
1149
- segmentRects,
1150
- rect,
1151
- scale,
1152
- onClick,
1153
- style
1154
- }) {
1155
- const resolvedColor = strokeColor ?? "#FFFF00";
1156
- const thickness = 2 * scale;
1157
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
1158
- "div",
1159
- {
1160
- onPointerDown: onClick,
1161
- onTouchStart: onClick,
1162
- style: {
1163
- position: "absolute",
1164
- left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
1165
- top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
1166
- width: r.size.width * scale,
1167
- height: r.size.height * scale,
1168
- background: "transparent",
1169
- pointerEvents: onClick ? "auto" : "none",
1170
- cursor: onClick ? "pointer" : "default",
1171
- zIndex: onClick ? 1 : 0,
1172
- ...style
1173
- },
1174
- children: /* @__PURE__ */ jsx(
1175
- "div",
1176
- {
1177
- style: {
1178
- position: "absolute",
1179
- left: 0,
1180
- top: "50%",
1181
- width: "100%",
1182
- height: thickness,
1183
- background: resolvedColor,
1184
- opacity,
1185
- transform: "translateY(-50%)",
1186
- pointerEvents: "none"
1187
- }
1188
- }
1189
- )
1190
- },
1191
- i
1192
- )) });
1193
- }
1194
- function Squiggly({
1195
- strokeColor,
1196
- opacity = 0.5,
1197
- segmentRects,
1198
- rect,
1199
- scale,
1200
- onClick,
1201
- style
1202
- }) {
1203
- const resolvedColor = strokeColor ?? "#FFFF00";
1204
- const amplitude = 2 * scale;
1205
- const period = 6 * scale;
1206
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${period}" height="${amplitude * 2}" viewBox="0 0 ${period} ${amplitude * 2}">
1207
- <path d="M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}"
1208
- fill="none" stroke="${resolvedColor}" stroke-width="${amplitude}" stroke-linecap="round"/>
1209
- </svg>`;
1210
- const svgDataUri = `url("data:image/svg+xml;utf8,${encodeURIComponent(svg)}")`;
1211
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
1212
- "div",
1213
- {
1214
- onPointerDown: onClick,
1215
- onTouchStart: onClick,
1216
- style: {
1217
- position: "absolute",
1218
- left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
1219
- top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
1220
- width: r.size.width * scale,
1221
- height: r.size.height * scale,
1222
- background: "transparent",
1223
- pointerEvents: onClick ? "auto" : "none",
1224
- cursor: onClick ? "pointer" : "default",
1225
- zIndex: onClick ? 1 : 0,
1226
- ...style
1227
- },
1228
- children: /* @__PURE__ */ jsx(
1229
- "div",
1230
- {
1231
- style: {
1232
- position: "absolute",
1233
- left: 0,
1234
- bottom: 0,
1235
- width: "100%",
1236
- height: amplitude * 2,
1237
- backgroundImage: svgDataUri,
1238
- backgroundRepeat: "repeat-x",
1239
- backgroundSize: `${period}px ${amplitude * 2}px`,
1240
- opacity,
1241
- pointerEvents: "none"
1242
- }
1243
- }
1244
- )
1245
- },
1246
- i
1247
- )) });
1116
+ function createRenderer(entry) {
1117
+ return {
1118
+ id: entry.id,
1119
+ matches: (annotation) => entry.matches(annotation),
1120
+ render: (props) => entry.render(props),
1121
+ vertexConfig: entry.vertexConfig,
1122
+ zIndex: entry.zIndex,
1123
+ containerStyle: entry.containerStyle,
1124
+ interactionDefaults: entry.interactionDefaults,
1125
+ useAppearanceStream: entry.useAppearanceStream,
1126
+ isDraggable: entry.isDraggable,
1127
+ onDoubleClick: entry.onDoubleClick,
1128
+ selectOverride: entry.selectOverride,
1129
+ hideSelectionMenu: entry.hideSelectionMenu
1130
+ };
1248
1131
  }
1132
+ const MIN_HIT_AREA_SCREEN_PX$5 = 20;
1249
1133
  function Ink({
1250
1134
  isSelected,
1251
1135
  strokeColor,
@@ -1254,7 +1138,8 @@ function Ink({
1254
1138
  inkList,
1255
1139
  rect,
1256
1140
  scale,
1257
- onClick
1141
+ onClick,
1142
+ appearanceActive = false
1258
1143
  }) {
1259
1144
  const resolvedColor = strokeColor ?? "#000000";
1260
1145
  const paths = useMemo(() => {
@@ -1270,7 +1155,8 @@ function Ink({
1270
1155
  }, [inkList, rect]);
1271
1156
  const width = rect.size.width * scale;
1272
1157
  const height = rect.size.height * scale;
1273
- return /* @__PURE__ */ jsx(
1158
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$5 / scale);
1159
+ return /* @__PURE__ */ jsxs(
1274
1160
  "svg",
1275
1161
  {
1276
1162
  style: {
@@ -1284,28 +1170,46 @@ function Ink({
1284
1170
  width,
1285
1171
  height,
1286
1172
  viewBox: `0 0 ${rect.size.width} ${rect.size.height}`,
1287
- children: paths.map((d, i) => /* @__PURE__ */ jsx(
1288
- "path",
1289
- {
1290
- d,
1291
- fill: "none",
1292
- opacity,
1293
- onPointerDown: onClick,
1294
- onTouchStart: onClick,
1295
- style: {
1296
- cursor: isSelected ? "move" : "pointer",
1297
- pointerEvents: isSelected ? "none" : "visibleStroke",
1298
- stroke: resolvedColor,
1299
- strokeWidth,
1300
- strokeLinecap: "round",
1301
- strokeLinejoin: "round"
1302
- }
1303
- },
1304
- i
1305
- ))
1173
+ children: [
1174
+ paths.map((d, i) => /* @__PURE__ */ jsx(
1175
+ "path",
1176
+ {
1177
+ d,
1178
+ fill: "none",
1179
+ stroke: "transparent",
1180
+ strokeWidth: hitStrokeWidth,
1181
+ onPointerDown: onClick,
1182
+ onTouchStart: onClick,
1183
+ style: {
1184
+ cursor: isSelected ? "move" : "pointer",
1185
+ pointerEvents: isSelected ? "none" : "visibleStroke",
1186
+ strokeLinecap: "round",
1187
+ strokeLinejoin: "round"
1188
+ }
1189
+ },
1190
+ `hit-${i}`
1191
+ )),
1192
+ !appearanceActive && paths.map((d, i) => /* @__PURE__ */ jsx(
1193
+ "path",
1194
+ {
1195
+ d,
1196
+ fill: "none",
1197
+ opacity,
1198
+ style: {
1199
+ pointerEvents: "none",
1200
+ stroke: resolvedColor,
1201
+ strokeWidth,
1202
+ strokeLinecap: "round",
1203
+ strokeLinejoin: "round"
1204
+ }
1205
+ },
1206
+ `vis-${i}`
1207
+ ))
1208
+ ]
1306
1209
  }
1307
1210
  );
1308
1211
  }
1212
+ const MIN_HIT_AREA_SCREEN_PX$4 = 20;
1309
1213
  function Square({
1310
1214
  isSelected,
1311
1215
  color = "#000000",
@@ -1316,7 +1220,8 @@ function Square({
1316
1220
  strokeDashArray,
1317
1221
  rect,
1318
1222
  scale,
1319
- onClick
1223
+ onClick,
1224
+ appearanceActive = false
1320
1225
  }) {
1321
1226
  const { width, height, x, y } = useMemo(() => {
1322
1227
  const outerW = rect.size.width;
@@ -1332,7 +1237,8 @@ function Square({
1332
1237
  }, [rect, strokeWidth]);
1333
1238
  const svgWidth = (width + strokeWidth) * scale;
1334
1239
  const svgHeight = (height + strokeWidth) * scale;
1335
- return /* @__PURE__ */ jsx(
1240
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$4 / scale);
1241
+ return /* @__PURE__ */ jsxs(
1336
1242
  "svg",
1337
1243
  {
1338
1244
  style: {
@@ -1345,31 +1251,50 @@ function Square({
1345
1251
  width: svgWidth,
1346
1252
  height: svgHeight,
1347
1253
  viewBox: `0 0 ${width + strokeWidth} ${height + strokeWidth}`,
1348
- children: /* @__PURE__ */ jsx(
1349
- "rect",
1350
- {
1351
- x,
1352
- y,
1353
- width,
1354
- height,
1355
- fill: color,
1356
- opacity,
1357
- onPointerDown: onClick,
1358
- onTouchStart: onClick,
1359
- style: {
1360
- cursor: isSelected ? "move" : "pointer",
1361
- pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
1362
- stroke: strokeColor ?? color,
1363
- strokeWidth,
1364
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1365
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1254
+ overflow: "visible",
1255
+ children: [
1256
+ /* @__PURE__ */ jsx(
1257
+ "rect",
1258
+ {
1259
+ x,
1260
+ y,
1261
+ width,
1262
+ height,
1263
+ fill: "transparent",
1264
+ stroke: "transparent",
1265
+ strokeWidth: hitStrokeWidth,
1266
+ onPointerDown: onClick,
1267
+ onTouchStart: onClick,
1268
+ style: {
1269
+ cursor: isSelected ? "move" : "pointer",
1270
+ pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
1366
1271
  }
1367
1272
  }
1368
- }
1369
- )
1273
+ ),
1274
+ !appearanceActive && /* @__PURE__ */ jsx(
1275
+ "rect",
1276
+ {
1277
+ x,
1278
+ y,
1279
+ width,
1280
+ height,
1281
+ fill: color,
1282
+ opacity,
1283
+ style: {
1284
+ pointerEvents: "none",
1285
+ stroke: strokeColor ?? color,
1286
+ strokeWidth,
1287
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1288
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1289
+ }
1290
+ }
1291
+ }
1292
+ )
1293
+ ]
1370
1294
  }
1371
1295
  );
1372
1296
  }
1297
+ const MIN_HIT_AREA_SCREEN_PX$3 = 20;
1373
1298
  function Circle({
1374
1299
  color = "#000000",
1375
1300
  strokeColor,
@@ -1380,7 +1305,8 @@ function Circle({
1380
1305
  rect,
1381
1306
  scale,
1382
1307
  onClick,
1383
- isSelected
1308
+ isSelected,
1309
+ appearanceActive = false
1384
1310
  }) {
1385
1311
  const { width, height, cx, cy, rx, ry } = useMemo(() => {
1386
1312
  const outerW = rect.size.width;
@@ -1390,7 +1316,6 @@ function Circle({
1390
1316
  return {
1391
1317
  width: outerW,
1392
1318
  height: outerH,
1393
- // Centre of the fill sits strokeWidth/2 in from the edges
1394
1319
  cx: strokeWidth / 2 + innerW / 2,
1395
1320
  cy: strokeWidth / 2 + innerH / 2,
1396
1321
  rx: innerW / 2,
@@ -1399,7 +1324,8 @@ function Circle({
1399
1324
  }, [rect, strokeWidth]);
1400
1325
  const svgWidth = width * scale;
1401
1326
  const svgHeight = height * scale;
1402
- return /* @__PURE__ */ jsx(
1327
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$3 / scale);
1328
+ return /* @__PURE__ */ jsxs(
1403
1329
  "svg",
1404
1330
  {
1405
1331
  style: {
@@ -1412,31 +1338,50 @@ function Circle({
1412
1338
  width: svgWidth,
1413
1339
  height: svgHeight,
1414
1340
  viewBox: `0 0 ${width} ${height}`,
1415
- children: /* @__PURE__ */ jsx(
1416
- "ellipse",
1417
- {
1418
- cx,
1419
- cy,
1420
- rx,
1421
- ry,
1422
- fill: color,
1423
- opacity,
1424
- onPointerDown: onClick,
1425
- onTouchStart: onClick,
1426
- style: {
1427
- cursor: isSelected ? "move" : "pointer",
1428
- pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
1429
- stroke: strokeColor ?? color,
1430
- strokeWidth,
1431
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1432
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1341
+ overflow: "visible",
1342
+ children: [
1343
+ /* @__PURE__ */ jsx(
1344
+ "ellipse",
1345
+ {
1346
+ cx,
1347
+ cy,
1348
+ rx,
1349
+ ry,
1350
+ fill: "transparent",
1351
+ stroke: "transparent",
1352
+ strokeWidth: hitStrokeWidth,
1353
+ onPointerDown: onClick,
1354
+ onTouchStart: onClick,
1355
+ style: {
1356
+ cursor: isSelected ? "move" : "pointer",
1357
+ pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
1433
1358
  }
1434
1359
  }
1435
- }
1436
- )
1360
+ ),
1361
+ !appearanceActive && /* @__PURE__ */ jsx(
1362
+ "ellipse",
1363
+ {
1364
+ cx,
1365
+ cy,
1366
+ rx,
1367
+ ry,
1368
+ fill: color,
1369
+ opacity,
1370
+ style: {
1371
+ pointerEvents: "none",
1372
+ stroke: strokeColor ?? color,
1373
+ strokeWidth,
1374
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1375
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1376
+ }
1377
+ }
1378
+ }
1379
+ )
1380
+ ]
1437
1381
  }
1438
1382
  );
1439
1383
  }
1384
+ const MIN_HIT_AREA_SCREEN_PX$2 = 20;
1440
1385
  function Line({
1441
1386
  color = "transparent",
1442
1387
  opacity = 1,
@@ -1449,7 +1394,8 @@ function Line({
1449
1394
  lineEndings,
1450
1395
  scale,
1451
1396
  onClick,
1452
- isSelected
1397
+ isSelected,
1398
+ appearanceActive = false
1453
1399
  }) {
1454
1400
  const { x1, y1, x2, y2 } = useMemo(() => {
1455
1401
  return {
@@ -1468,6 +1414,7 @@ function Line({
1468
1414
  }, [lineEndings, strokeWidth, x1, y1, x2, y2]);
1469
1415
  const width = rect.size.width * scale;
1470
1416
  const height = rect.size.height * scale;
1417
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$2 / scale);
1471
1418
  return /* @__PURE__ */ jsxs(
1472
1419
  "svg",
1473
1420
  {
@@ -1490,18 +1437,14 @@ function Line({
1490
1437
  y1,
1491
1438
  x2,
1492
1439
  y2,
1493
- opacity,
1440
+ stroke: "transparent",
1441
+ strokeWidth: hitStrokeWidth,
1494
1442
  onPointerDown: onClick,
1495
1443
  onTouchStart: onClick,
1496
1444
  style: {
1497
1445
  cursor: isSelected ? "move" : "pointer",
1498
1446
  pointerEvents: isSelected ? "none" : "visibleStroke",
1499
- stroke: strokeColor,
1500
- strokeWidth,
1501
- strokeLinecap: "butt",
1502
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1503
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1504
- }
1447
+ strokeLinecap: "butt"
1505
1448
  }
1506
1449
  }
1507
1450
  ),
@@ -1510,19 +1453,16 @@ function Line({
1510
1453
  {
1511
1454
  d: endings.start.d,
1512
1455
  transform: endings.start.transform,
1456
+ fill: "transparent",
1457
+ stroke: "transparent",
1458
+ strokeWidth: hitStrokeWidth,
1513
1459
  onPointerDown: onClick,
1514
1460
  onTouchStart: onClick,
1515
- stroke: strokeColor,
1516
1461
  style: {
1517
1462
  cursor: isSelected ? "move" : "pointer",
1518
- strokeWidth,
1519
- strokeLinecap: "butt",
1520
1463
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1521
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1522
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1523
- }
1524
- },
1525
- fill: endings.start.filled ? color : "none"
1464
+ strokeLinecap: "butt"
1465
+ }
1526
1466
  }
1527
1467
  ),
1528
1468
  endings.end && /* @__PURE__ */ jsx(
@@ -1530,25 +1470,78 @@ function Line({
1530
1470
  {
1531
1471
  d: endings.end.d,
1532
1472
  transform: endings.end.transform,
1533
- stroke: strokeColor,
1473
+ fill: "transparent",
1474
+ stroke: "transparent",
1475
+ strokeWidth: hitStrokeWidth,
1534
1476
  onPointerDown: onClick,
1535
1477
  onTouchStart: onClick,
1536
1478
  style: {
1537
1479
  cursor: isSelected ? "move" : "pointer",
1538
- strokeWidth,
1539
- strokeLinecap: "butt",
1540
1480
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
1541
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1542
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1543
- }
1544
- },
1545
- fill: endings.end.filled ? color : "none"
1481
+ strokeLinecap: "butt"
1482
+ }
1546
1483
  }
1547
- )
1484
+ ),
1485
+ !appearanceActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1486
+ /* @__PURE__ */ jsx(
1487
+ "line",
1488
+ {
1489
+ x1,
1490
+ y1,
1491
+ x2,
1492
+ y2,
1493
+ opacity,
1494
+ style: {
1495
+ pointerEvents: "none",
1496
+ stroke: strokeColor,
1497
+ strokeWidth,
1498
+ strokeLinecap: "butt",
1499
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1500
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1501
+ }
1502
+ }
1503
+ }
1504
+ ),
1505
+ endings.start && /* @__PURE__ */ jsx(
1506
+ "path",
1507
+ {
1508
+ d: endings.start.d,
1509
+ transform: endings.start.transform,
1510
+ stroke: strokeColor,
1511
+ fill: endings.start.filled ? color : "none",
1512
+ style: {
1513
+ pointerEvents: "none",
1514
+ strokeWidth,
1515
+ strokeLinecap: "butt",
1516
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1517
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1518
+ }
1519
+ }
1520
+ }
1521
+ ),
1522
+ endings.end && /* @__PURE__ */ jsx(
1523
+ "path",
1524
+ {
1525
+ d: endings.end.d,
1526
+ transform: endings.end.transform,
1527
+ stroke: strokeColor,
1528
+ fill: endings.end.filled ? color : "none",
1529
+ style: {
1530
+ pointerEvents: "none",
1531
+ strokeWidth,
1532
+ strokeLinecap: "butt",
1533
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1534
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1535
+ }
1536
+ }
1537
+ }
1538
+ )
1539
+ ] })
1548
1540
  ]
1549
1541
  }
1550
1542
  );
1551
1543
  }
1544
+ const MIN_HIT_AREA_SCREEN_PX$1 = 20;
1552
1545
  function Polyline({
1553
1546
  rect,
1554
1547
  vertices,
@@ -1559,7 +1552,8 @@ function Polyline({
1559
1552
  scale,
1560
1553
  isSelected,
1561
1554
  onClick,
1562
- lineEndings
1555
+ lineEndings,
1556
+ appearanceActive = false
1563
1557
  }) {
1564
1558
  const localPts = useMemo(
1565
1559
  () => vertices.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),
@@ -1579,7 +1573,6 @@ function Polyline({
1579
1573
  lineEndings == null ? void 0 : lineEndings.start,
1580
1574
  strokeWidth,
1581
1575
  startRad + Math.PI,
1582
- // tip points outward from line start
1583
1576
  localPts[0].x,
1584
1577
  localPts[0].y
1585
1578
  );
@@ -1587,7 +1580,6 @@ function Polyline({
1587
1580
  lineEndings == null ? void 0 : lineEndings.end,
1588
1581
  strokeWidth,
1589
1582
  endRad,
1590
- // tip points in line direction
1591
1583
  localPts[localPts.length - 1].x,
1592
1584
  localPts[localPts.length - 1].y
1593
1585
  );
@@ -1595,6 +1587,7 @@ function Polyline({
1595
1587
  }, [localPts, lineEndings, strokeWidth]);
1596
1588
  const width = rect.size.width * scale;
1597
1589
  const height = rect.size.height * scale;
1590
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$1 / scale);
1598
1591
  return /* @__PURE__ */ jsxs(
1599
1592
  "svg",
1600
1593
  {
@@ -1614,13 +1607,12 @@ function Polyline({
1614
1607
  "path",
1615
1608
  {
1616
1609
  d: pathData,
1610
+ fill: "none",
1611
+ stroke: "transparent",
1612
+ strokeWidth: hitStrokeWidth,
1617
1613
  onPointerDown: onClick,
1618
1614
  onTouchStart: onClick,
1619
- opacity,
1620
1615
  style: {
1621
- fill: "none",
1622
- stroke: strokeColor ?? color,
1623
- strokeWidth,
1624
1616
  cursor: isSelected ? "move" : "pointer",
1625
1617
  pointerEvents: isSelected ? "none" : "visibleStroke",
1626
1618
  strokeLinecap: "butt",
@@ -1633,13 +1625,13 @@ function Polyline({
1633
1625
  {
1634
1626
  d: endings.start.d,
1635
1627
  transform: endings.start.transform,
1636
- stroke: strokeColor,
1637
- fill: endings.start.filled ? color : "none",
1628
+ fill: "transparent",
1629
+ stroke: "transparent",
1630
+ strokeWidth: hitStrokeWidth,
1638
1631
  onPointerDown: onClick,
1639
1632
  onTouchStart: onClick,
1640
1633
  style: {
1641
1634
  cursor: isSelected ? "move" : "pointer",
1642
- strokeWidth,
1643
1635
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1644
1636
  strokeLinecap: "butt"
1645
1637
  }
@@ -1650,22 +1642,68 @@ function Polyline({
1650
1642
  {
1651
1643
  d: endings.end.d,
1652
1644
  transform: endings.end.transform,
1653
- stroke: strokeColor,
1654
- fill: endings.end.filled ? color : "none",
1645
+ fill: "transparent",
1646
+ stroke: "transparent",
1647
+ strokeWidth: hitStrokeWidth,
1655
1648
  onPointerDown: onClick,
1656
1649
  onTouchStart: onClick,
1657
1650
  style: {
1658
1651
  cursor: isSelected ? "move" : "pointer",
1659
- strokeWidth,
1660
1652
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
1661
1653
  strokeLinecap: "butt"
1662
1654
  }
1663
1655
  }
1664
- )
1656
+ ),
1657
+ !appearanceActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1658
+ /* @__PURE__ */ jsx(
1659
+ "path",
1660
+ {
1661
+ d: pathData,
1662
+ opacity,
1663
+ style: {
1664
+ fill: "none",
1665
+ stroke: strokeColor ?? color,
1666
+ strokeWidth,
1667
+ pointerEvents: "none",
1668
+ strokeLinecap: "butt",
1669
+ strokeLinejoin: "miter"
1670
+ }
1671
+ }
1672
+ ),
1673
+ endings.start && /* @__PURE__ */ jsx(
1674
+ "path",
1675
+ {
1676
+ d: endings.start.d,
1677
+ transform: endings.start.transform,
1678
+ stroke: strokeColor,
1679
+ fill: endings.start.filled ? color : "none",
1680
+ style: {
1681
+ pointerEvents: "none",
1682
+ strokeWidth,
1683
+ strokeLinecap: "butt"
1684
+ }
1685
+ }
1686
+ ),
1687
+ endings.end && /* @__PURE__ */ jsx(
1688
+ "path",
1689
+ {
1690
+ d: endings.end.d,
1691
+ transform: endings.end.transform,
1692
+ stroke: strokeColor,
1693
+ fill: endings.end.filled ? color : "none",
1694
+ style: {
1695
+ pointerEvents: "none",
1696
+ strokeWidth,
1697
+ strokeLinecap: "butt"
1698
+ }
1699
+ }
1700
+ )
1701
+ ] })
1665
1702
  ]
1666
1703
  }
1667
1704
  );
1668
1705
  }
1706
+ const MIN_HIT_AREA_SCREEN_PX = 20;
1669
1707
  function Polygon({
1670
1708
  rect,
1671
1709
  vertices,
@@ -1679,9 +1717,8 @@ function Polygon({
1679
1717
  isSelected,
1680
1718
  onClick,
1681
1719
  currentVertex,
1682
- // A preview-only prop
1683
- handleSize = 14
1684
- // in CSS pixels
1720
+ handleSize = 14,
1721
+ appearanceActive = false
1685
1722
  }) {
1686
1723
  const allPoints = currentVertex ? [...vertices, currentVertex] : vertices;
1687
1724
  const localPts = useMemo(
@@ -1697,6 +1734,7 @@ function Polygon({
1697
1734
  const isPreviewing = currentVertex && vertices.length > 0;
1698
1735
  const width = rect.size.width * scale;
1699
1736
  const height = rect.size.height * scale;
1737
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);
1700
1738
  return /* @__PURE__ */ jsxs(
1701
1739
  "svg",
1702
1740
  {
@@ -1716,62 +1754,89 @@ function Polygon({
1716
1754
  "path",
1717
1755
  {
1718
1756
  d: pathData,
1757
+ fill: "transparent",
1758
+ stroke: "transparent",
1759
+ strokeWidth: hitStrokeWidth,
1719
1760
  onPointerDown: onClick,
1720
1761
  onTouchStart: onClick,
1721
- opacity,
1722
1762
  style: {
1723
- fill: currentVertex ? "none" : color,
1724
- // No fill during preview
1725
- stroke: strokeColor ?? color,
1726
- strokeWidth,
1727
1763
  cursor: isSelected ? "move" : "pointer",
1728
1764
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
1729
1765
  strokeLinecap: "butt",
1730
- strokeLinejoin: "miter",
1731
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1732
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1733
- }
1766
+ strokeLinejoin: "miter"
1734
1767
  }
1735
1768
  }
1736
1769
  ),
1737
- isPreviewing && vertices.length > 1 && /* @__PURE__ */ jsx(
1738
- "path",
1739
- {
1740
- d: `M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`,
1741
- fill: "none",
1742
- style: { stroke: strokeColor, strokeWidth, strokeDasharray: "4,4", opacity: 0.7 }
1743
- }
1744
- ),
1745
- isPreviewing && vertices.length >= 2 && /* @__PURE__ */ jsx(
1746
- "rect",
1747
- {
1748
- x: localPts[0].x - handleSize / scale / 2,
1749
- y: localPts[0].y - handleSize / scale / 2,
1750
- width: handleSize / scale,
1751
- height: handleSize / scale,
1752
- fill: strokeColor,
1753
- opacity: 0.4,
1754
- stroke: strokeColor,
1755
- strokeWidth: strokeWidth / 2
1756
- }
1757
- )
1770
+ !appearanceActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1771
+ /* @__PURE__ */ jsx(
1772
+ "path",
1773
+ {
1774
+ d: pathData,
1775
+ opacity,
1776
+ style: {
1777
+ fill: currentVertex ? "none" : color,
1778
+ stroke: strokeColor ?? color,
1779
+ strokeWidth,
1780
+ pointerEvents: "none",
1781
+ strokeLinecap: "butt",
1782
+ strokeLinejoin: "miter",
1783
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1784
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1785
+ }
1786
+ }
1787
+ }
1788
+ ),
1789
+ isPreviewing && vertices.length > 1 && /* @__PURE__ */ jsx(
1790
+ "path",
1791
+ {
1792
+ d: `M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`,
1793
+ fill: "none",
1794
+ style: {
1795
+ stroke: strokeColor,
1796
+ strokeWidth,
1797
+ strokeDasharray: "4,4",
1798
+ opacity: 0.7,
1799
+ pointerEvents: "none"
1800
+ }
1801
+ }
1802
+ ),
1803
+ isPreviewing && vertices.length >= 2 && /* @__PURE__ */ jsx(
1804
+ "rect",
1805
+ {
1806
+ x: localPts[0].x - handleSize / scale / 2,
1807
+ y: localPts[0].y - handleSize / scale / 2,
1808
+ width: handleSize / scale,
1809
+ height: handleSize / scale,
1810
+ fill: strokeColor,
1811
+ opacity: 0.4,
1812
+ stroke: strokeColor,
1813
+ strokeWidth: strokeWidth / 2,
1814
+ style: { pointerEvents: "none" }
1815
+ }
1816
+ )
1817
+ ] })
1758
1818
  ]
1759
1819
  }
1760
1820
  );
1761
1821
  }
1762
1822
  function FreeText({
1823
+ documentId,
1763
1824
  isSelected,
1764
1825
  isEditing,
1765
1826
  annotation,
1766
1827
  pageIndex,
1767
1828
  scale,
1768
- onClick
1829
+ onClick,
1830
+ appearanceActive = false
1769
1831
  }) {
1770
1832
  const editorRef = useRef(null);
1771
- const { provides: annotationProvides } = useAnnotationCapability();
1833
+ const editingRef = useRef(false);
1834
+ const { provides: annotationCapability } = useAnnotationCapability();
1835
+ const annotationProvides = (annotationCapability == null ? void 0 : annotationCapability.forDocument(documentId)) ?? null;
1772
1836
  const [isIOS, setIsIOS] = useState(false);
1773
1837
  useEffect(() => {
1774
1838
  if (isEditing && editorRef.current) {
1839
+ editingRef.current = true;
1775
1840
  const editor = editorRef.current;
1776
1841
  editor.focus();
1777
1842
  const selection = window.getSelection();
@@ -1794,6 +1859,8 @@ function FreeText({
1794
1859
  }
1795
1860
  }, []);
1796
1861
  const handleBlur = () => {
1862
+ if (!editingRef.current) return;
1863
+ editingRef.current = false;
1797
1864
  if (!annotationProvides) return;
1798
1865
  if (!editorRef.current) return;
1799
1866
  annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {
@@ -1815,7 +1882,8 @@ function FreeText({
1815
1882
  height: annotation.object.rect.size.height * scale,
1816
1883
  cursor: isSelected && !isEditing ? "move" : "default",
1817
1884
  pointerEvents: isSelected && !isEditing ? "none" : "auto",
1818
- zIndex: 2
1885
+ zIndex: 2,
1886
+ opacity: appearanceActive ? 0 : 1
1819
1887
  },
1820
1888
  onPointerDown: onClick,
1821
1889
  onTouchStart: onClick,
@@ -1984,7 +2052,7 @@ function Link({
1984
2052
  }
1985
2053
  return void 0;
1986
2054
  }, [strokeStyle, strokeDashArray, strokeWidth]);
1987
- const isUnderline2 = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;
2055
+ const isUnderline = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;
1988
2056
  return /* @__PURE__ */ jsxs(
1989
2057
  "svg",
1990
2058
  {
@@ -2015,7 +2083,7 @@ function Link({
2015
2083
  }
2016
2084
  }
2017
2085
  ),
2018
- isUnderline2 ? (
2086
+ isUnderline ? (
2019
2087
  // Underline style: line at bottom of rect
2020
2088
  /* @__PURE__ */ jsx(
2021
2089
  "line",
@@ -2055,83 +2123,528 @@ function Link({
2055
2123
  }
2056
2124
  );
2057
2125
  }
2058
- function Annotations(annotationsProps) {
2059
- const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;
2060
- const { provides: annotationCapability } = useAnnotationCapability();
2061
- const { provides: selectionProvides } = useSelectionCapability();
2062
- const [annotations, setAnnotations] = useState([]);
2063
- const { register } = usePointerHandlers({ documentId, pageIndex });
2064
- const [allSelectedIds, setAllSelectedIds] = useState([]);
2065
- const [editingId, setEditingId] = useState(null);
2066
- const annotationProvides = useMemo(
2067
- () => annotationCapability ? annotationCapability.forDocument(documentId) : null,
2068
- [annotationCapability, documentId]
2069
- );
2070
- const isMultiSelected = allSelectedIds.length > 1;
2071
- useEffect(() => {
2072
- if (annotationProvides) {
2073
- const currentState = annotationProvides.getState();
2074
- setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
2075
- setAllSelectedIds(getSelectedAnnotationIds(currentState));
2076
- return annotationProvides.onStateChange((state) => {
2077
- setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
2078
- setAllSelectedIds(getSelectedAnnotationIds(state));
2079
- });
2080
- }
2081
- }, [annotationProvides, pageIndex]);
2082
- const handlers = useMemo(
2083
- () => ({
2084
- onPointerDown: (_, pe) => {
2085
- if (pe.target === pe.currentTarget && annotationProvides) {
2086
- annotationProvides.deselectAnnotation();
2087
- setEditingId(null);
2088
- }
2089
- }
2090
- }),
2091
- [annotationProvides]
2092
- );
2093
- const handleClick = useCallback(
2094
- (e, annotation) => {
2095
- e.stopPropagation();
2096
- if (annotationProvides && selectionProvides) {
2097
- selectionProvides.clear();
2098
- const isModifierPressed = "metaKey" in e ? e.metaKey || e.ctrlKey : false;
2099
- if (isModifierPressed) {
2100
- annotationProvides.toggleSelection(pageIndex, annotation.object.id);
2101
- } else {
2102
- annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
2103
- }
2104
- if (annotation.object.id !== editingId) {
2105
- setEditingId(null);
2106
- }
2107
- }
2108
- },
2109
- [annotationProvides, selectionProvides, editingId, pageIndex]
2110
- );
2111
- const handleLinkClick = useCallback(
2112
- (e, annotation) => {
2113
- e.stopPropagation();
2114
- if (!annotationProvides || !selectionProvides) return;
2115
- selectionProvides.clear();
2116
- if (annotation.object.inReplyToId) {
2117
- const parentId = annotation.object.inReplyToId;
2118
- const parent = annotations.find((a) => a.object.id === parentId);
2119
- if (parent) {
2120
- annotationProvides.selectAnnotation(parent.object.pageIndex, parentId);
2121
- return;
2122
- }
2126
+ function Highlight({
2127
+ strokeColor,
2128
+ opacity = 0.5,
2129
+ segmentRects,
2130
+ rect,
2131
+ scale,
2132
+ onClick,
2133
+ style,
2134
+ appearanceActive = false
2135
+ }) {
2136
+ const resolvedColor = strokeColor ?? "#FFFF00";
2137
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
2138
+ "div",
2139
+ {
2140
+ onPointerDown: onClick,
2141
+ onTouchStart: onClick,
2142
+ style: {
2143
+ position: "absolute",
2144
+ left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
2145
+ top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
2146
+ width: b.size.width * scale,
2147
+ height: b.size.height * scale,
2148
+ background: appearanceActive ? "transparent" : resolvedColor,
2149
+ opacity: appearanceActive ? void 0 : opacity,
2150
+ pointerEvents: onClick ? "auto" : "none",
2151
+ cursor: onClick ? "pointer" : "default",
2152
+ zIndex: onClick ? 1 : void 0,
2153
+ ...style
2123
2154
  }
2124
- annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
2125
2155
  },
2126
- [annotationProvides, selectionProvides, annotations, pageIndex]
2127
- );
2128
- useEffect(() => {
2129
- return register(handlers, {
2130
- documentId
2131
- });
2132
- }, [register, handlers]);
2133
- const selectedAnnotationsOnPage = useMemo(() => {
2134
- return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));
2156
+ i
2157
+ )) });
2158
+ }
2159
+ function Underline({
2160
+ strokeColor,
2161
+ opacity = 0.5,
2162
+ segmentRects,
2163
+ rect,
2164
+ scale,
2165
+ onClick,
2166
+ style,
2167
+ appearanceActive = false
2168
+ }) {
2169
+ const resolvedColor = strokeColor ?? "#FFFF00";
2170
+ const thickness = 2 * scale;
2171
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
2172
+ "div",
2173
+ {
2174
+ onPointerDown: onClick,
2175
+ onTouchStart: onClick,
2176
+ style: {
2177
+ position: "absolute",
2178
+ left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
2179
+ top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
2180
+ width: r.size.width * scale,
2181
+ height: r.size.height * scale,
2182
+ background: "transparent",
2183
+ pointerEvents: onClick ? "auto" : "none",
2184
+ cursor: onClick ? "pointer" : "default",
2185
+ zIndex: onClick ? 1 : 0,
2186
+ ...style
2187
+ },
2188
+ children: !appearanceActive && /* @__PURE__ */ jsx(
2189
+ "div",
2190
+ {
2191
+ style: {
2192
+ position: "absolute",
2193
+ left: 0,
2194
+ bottom: 0,
2195
+ width: "100%",
2196
+ height: thickness,
2197
+ background: resolvedColor,
2198
+ opacity,
2199
+ pointerEvents: "none"
2200
+ }
2201
+ }
2202
+ )
2203
+ },
2204
+ i
2205
+ )) });
2206
+ }
2207
+ function Strikeout({
2208
+ strokeColor,
2209
+ opacity = 0.5,
2210
+ segmentRects,
2211
+ rect,
2212
+ scale,
2213
+ onClick,
2214
+ style,
2215
+ appearanceActive = false
2216
+ }) {
2217
+ const resolvedColor = strokeColor ?? "#FFFF00";
2218
+ const thickness = 2 * scale;
2219
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
2220
+ "div",
2221
+ {
2222
+ onPointerDown: onClick,
2223
+ onTouchStart: onClick,
2224
+ style: {
2225
+ position: "absolute",
2226
+ left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
2227
+ top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
2228
+ width: r.size.width * scale,
2229
+ height: r.size.height * scale,
2230
+ background: "transparent",
2231
+ pointerEvents: onClick ? "auto" : "none",
2232
+ cursor: onClick ? "pointer" : "default",
2233
+ zIndex: onClick ? 1 : 0,
2234
+ ...style
2235
+ },
2236
+ children: !appearanceActive && /* @__PURE__ */ jsx(
2237
+ "div",
2238
+ {
2239
+ style: {
2240
+ position: "absolute",
2241
+ left: 0,
2242
+ top: "50%",
2243
+ width: "100%",
2244
+ height: thickness,
2245
+ background: resolvedColor,
2246
+ opacity,
2247
+ transform: "translateY(-50%)",
2248
+ pointerEvents: "none"
2249
+ }
2250
+ }
2251
+ )
2252
+ },
2253
+ i
2254
+ )) });
2255
+ }
2256
+ function Squiggly({
2257
+ strokeColor,
2258
+ opacity = 0.5,
2259
+ segmentRects,
2260
+ rect,
2261
+ scale,
2262
+ onClick,
2263
+ style,
2264
+ appearanceActive = false
2265
+ }) {
2266
+ const resolvedColor = strokeColor ?? "#FFFF00";
2267
+ const amplitude = 2 * scale;
2268
+ const period = 6 * scale;
2269
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${period}" height="${amplitude * 2}" viewBox="0 0 ${period} ${amplitude * 2}">
2270
+ <path d="M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}"
2271
+ fill="none" stroke="${resolvedColor}" stroke-width="${amplitude}" stroke-linecap="round"/>
2272
+ </svg>`;
2273
+ const svgDataUri = `url("data:image/svg+xml;utf8,${encodeURIComponent(svg)}")`;
2274
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
2275
+ "div",
2276
+ {
2277
+ onPointerDown: onClick,
2278
+ onTouchStart: onClick,
2279
+ style: {
2280
+ position: "absolute",
2281
+ left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
2282
+ top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
2283
+ width: r.size.width * scale,
2284
+ height: r.size.height * scale,
2285
+ background: "transparent",
2286
+ pointerEvents: onClick ? "auto" : "none",
2287
+ cursor: onClick ? "pointer" : "default",
2288
+ zIndex: onClick ? 1 : 0,
2289
+ ...style
2290
+ },
2291
+ children: !appearanceActive && /* @__PURE__ */ jsx(
2292
+ "div",
2293
+ {
2294
+ style: {
2295
+ position: "absolute",
2296
+ left: 0,
2297
+ bottom: 0,
2298
+ width: "100%",
2299
+ height: amplitude * 2,
2300
+ backgroundImage: svgDataUri,
2301
+ backgroundRepeat: "repeat-x",
2302
+ backgroundSize: `${period}px ${amplitude * 2}px`,
2303
+ opacity,
2304
+ pointerEvents: "none"
2305
+ }
2306
+ }
2307
+ )
2308
+ },
2309
+ i
2310
+ )) });
2311
+ }
2312
+ const builtInRenderers = [
2313
+ // --- Drawing ---
2314
+ createRenderer({
2315
+ id: "ink",
2316
+ matches: (a) => a.type === PdfAnnotationSubtype.INK,
2317
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2318
+ Ink,
2319
+ {
2320
+ ...currentObject,
2321
+ isSelected,
2322
+ scale,
2323
+ onClick,
2324
+ appearanceActive
2325
+ }
2326
+ ),
2327
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2328
+ }),
2329
+ // --- Shapes ---
2330
+ createRenderer({
2331
+ id: "square",
2332
+ matches: (a) => a.type === PdfAnnotationSubtype.SQUARE,
2333
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2334
+ Square,
2335
+ {
2336
+ ...currentObject,
2337
+ isSelected,
2338
+ scale,
2339
+ onClick,
2340
+ appearanceActive
2341
+ }
2342
+ ),
2343
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2344
+ }),
2345
+ createRenderer({
2346
+ id: "circle",
2347
+ matches: (a) => a.type === PdfAnnotationSubtype.CIRCLE,
2348
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2349
+ Circle,
2350
+ {
2351
+ ...currentObject,
2352
+ isSelected,
2353
+ scale,
2354
+ onClick,
2355
+ appearanceActive
2356
+ }
2357
+ ),
2358
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2359
+ }),
2360
+ // --- Lines & Vertex-based ---
2361
+ createRenderer({
2362
+ id: "line",
2363
+ matches: (a) => a.type === PdfAnnotationSubtype.LINE,
2364
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2365
+ Line,
2366
+ {
2367
+ ...currentObject,
2368
+ isSelected,
2369
+ scale,
2370
+ onClick,
2371
+ appearanceActive
2372
+ }
2373
+ ) }),
2374
+ vertexConfig: {
2375
+ extractVertices: (a) => [a.linePoints.start, a.linePoints.end],
2376
+ transformAnnotation: (a, v) => ({
2377
+ ...a,
2378
+ linePoints: { start: v[0], end: v[1] }
2379
+ })
2380
+ },
2381
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true }
2382
+ }),
2383
+ createRenderer({
2384
+ id: "polyline",
2385
+ matches: (a) => a.type === PdfAnnotationSubtype.POLYLINE,
2386
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2387
+ Polyline,
2388
+ {
2389
+ ...currentObject,
2390
+ isSelected,
2391
+ scale,
2392
+ onClick,
2393
+ appearanceActive
2394
+ }
2395
+ ) }),
2396
+ vertexConfig: {
2397
+ extractVertices: (a) => a.vertices,
2398
+ transformAnnotation: (a, vertices) => ({ ...a, vertices })
2399
+ },
2400
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true }
2401
+ }),
2402
+ createRenderer({
2403
+ id: "polygon",
2404
+ matches: (a) => a.type === PdfAnnotationSubtype.POLYGON,
2405
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2406
+ Polygon,
2407
+ {
2408
+ ...currentObject,
2409
+ isSelected,
2410
+ scale,
2411
+ onClick,
2412
+ appearanceActive
2413
+ }
2414
+ ) }),
2415
+ vertexConfig: {
2416
+ extractVertices: (a) => a.vertices,
2417
+ transformAnnotation: (a, vertices) => ({ ...a, vertices })
2418
+ },
2419
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true }
2420
+ }),
2421
+ // --- Text Markup ---
2422
+ createRenderer({
2423
+ id: "highlight",
2424
+ matches: (a) => a.type === PdfAnnotationSubtype.HIGHLIGHT,
2425
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2426
+ Highlight,
2427
+ {
2428
+ ...currentObject,
2429
+ scale,
2430
+ onClick,
2431
+ appearanceActive
2432
+ }
2433
+ ),
2434
+ zIndex: 0,
2435
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },
2436
+ containerStyle: (a) => ({
2437
+ mixBlendMode: blendModeToCss(a.blendMode ?? PdfBlendMode.Multiply)
2438
+ })
2439
+ }),
2440
+ createRenderer({
2441
+ id: "underline",
2442
+ matches: (a) => a.type === PdfAnnotationSubtype.UNDERLINE,
2443
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2444
+ Underline,
2445
+ {
2446
+ ...currentObject,
2447
+ scale,
2448
+ onClick,
2449
+ appearanceActive
2450
+ }
2451
+ ),
2452
+ zIndex: 0,
2453
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2454
+ }),
2455
+ createRenderer({
2456
+ id: "strikeout",
2457
+ matches: (a) => a.type === PdfAnnotationSubtype.STRIKEOUT,
2458
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2459
+ Strikeout,
2460
+ {
2461
+ ...currentObject,
2462
+ scale,
2463
+ onClick,
2464
+ appearanceActive
2465
+ }
2466
+ ),
2467
+ zIndex: 0,
2468
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2469
+ }),
2470
+ createRenderer({
2471
+ id: "squiggly",
2472
+ matches: (a) => a.type === PdfAnnotationSubtype.SQUIGGLY,
2473
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2474
+ Squiggly,
2475
+ {
2476
+ ...currentObject,
2477
+ scale,
2478
+ onClick,
2479
+ appearanceActive
2480
+ }
2481
+ ),
2482
+ zIndex: 0,
2483
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2484
+ }),
2485
+ // --- FreeText ---
2486
+ createRenderer({
2487
+ id: "freeText",
2488
+ matches: (a) => a.type === PdfAnnotationSubtype.FREETEXT,
2489
+ render: ({
2490
+ annotation,
2491
+ currentObject,
2492
+ isSelected,
2493
+ isEditing,
2494
+ scale,
2495
+ pageIndex,
2496
+ documentId,
2497
+ onClick,
2498
+ appearanceActive
2499
+ }) => /* @__PURE__ */ jsx(
2500
+ FreeText,
2501
+ {
2502
+ documentId,
2503
+ isSelected,
2504
+ isEditing,
2505
+ annotation: { ...annotation, object: currentObject },
2506
+ pageIndex,
2507
+ scale,
2508
+ onClick,
2509
+ appearanceActive
2510
+ }
2511
+ ),
2512
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },
2513
+ isDraggable: (toolDraggable, { isEditing }) => toolDraggable && !isEditing,
2514
+ onDoubleClick: (id, setEditingId) => setEditingId(id)
2515
+ }),
2516
+ // --- Stamp ---
2517
+ createRenderer({
2518
+ id: "stamp",
2519
+ matches: (a) => a.type === PdfAnnotationSubtype.STAMP,
2520
+ render: ({ annotation, isSelected, documentId, pageIndex, scale, onClick }) => /* @__PURE__ */ jsx(
2521
+ Stamp,
2522
+ {
2523
+ isSelected,
2524
+ annotation,
2525
+ documentId,
2526
+ pageIndex,
2527
+ scale,
2528
+ onClick
2529
+ }
2530
+ ),
2531
+ useAppearanceStream: false,
2532
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2533
+ }),
2534
+ // --- Link ---
2535
+ createRenderer({
2536
+ id: "link",
2537
+ matches: (a) => a.type === PdfAnnotationSubtype.LINK,
2538
+ render: ({ currentObject, isSelected, scale, onClick }) => /* @__PURE__ */ jsx(
2539
+ Link,
2540
+ {
2541
+ ...currentObject,
2542
+ isSelected,
2543
+ scale,
2544
+ onClick,
2545
+ hasIRT: !!currentObject.inReplyToId
2546
+ }
2547
+ ),
2548
+ interactionDefaults: {
2549
+ isDraggable: false,
2550
+ isResizable: false,
2551
+ isRotatable: false
2552
+ },
2553
+ useAppearanceStream: false,
2554
+ selectOverride: (e, annotation, helpers) => {
2555
+ e.stopPropagation();
2556
+ helpers.clearSelection();
2557
+ if (annotation.object.inReplyToId) {
2558
+ const parent = helpers.allAnnotations.find(
2559
+ (a) => a.object.id === annotation.object.inReplyToId
2560
+ );
2561
+ if (parent) {
2562
+ helpers.selectAnnotation(parent.object.pageIndex, parent.object.id);
2563
+ return;
2564
+ }
2565
+ }
2566
+ helpers.selectAnnotation(helpers.pageIndex, annotation.object.id);
2567
+ },
2568
+ hideSelectionMenu: (a) => !!a.inReplyToId
2569
+ })
2570
+ ];
2571
+ function Annotations(annotationsProps) {
2572
+ const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;
2573
+ const { provides: annotationCapability } = useAnnotationCapability();
2574
+ const { provides: selectionProvides } = useSelectionCapability();
2575
+ const [annotations, setAnnotations] = useState([]);
2576
+ const { register } = usePointerHandlers({ documentId, pageIndex });
2577
+ const [allSelectedIds, setAllSelectedIds] = useState([]);
2578
+ const [editingId, setEditingId] = useState(null);
2579
+ const [appearanceMap, setAppearanceMap] = useState({});
2580
+ const prevScaleRef = useRef(scale);
2581
+ const annotationProvides = useMemo(
2582
+ () => annotationCapability ? annotationCapability.forDocument(documentId) : null,
2583
+ [annotationCapability, documentId]
2584
+ );
2585
+ const isMultiSelected = allSelectedIds.length > 1;
2586
+ useEffect(() => {
2587
+ if (annotationProvides) {
2588
+ const currentState = annotationProvides.getState();
2589
+ setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
2590
+ setAllSelectedIds(getSelectedAnnotationIds(currentState));
2591
+ return annotationProvides.onStateChange((state) => {
2592
+ setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
2593
+ setAllSelectedIds(getSelectedAnnotationIds(state));
2594
+ });
2595
+ }
2596
+ }, [annotationProvides, pageIndex]);
2597
+ useEffect(() => {
2598
+ if (!annotationProvides) return;
2599
+ if (prevScaleRef.current !== scale) {
2600
+ annotationProvides.invalidatePageAppearances(pageIndex);
2601
+ prevScaleRef.current = scale;
2602
+ }
2603
+ const task = annotationProvides.getPageAppearances(pageIndex, {
2604
+ scaleFactor: scale,
2605
+ dpr: typeof window !== "undefined" ? window.devicePixelRatio : 1
2606
+ });
2607
+ task.wait(
2608
+ (map) => setAppearanceMap(map),
2609
+ () => setAppearanceMap({})
2610
+ );
2611
+ }, [annotationProvides, pageIndex, scale]);
2612
+ const handlers = useMemo(
2613
+ () => ({
2614
+ onPointerDown: (_, pe) => {
2615
+ if (pe.target === pe.currentTarget && annotationProvides) {
2616
+ annotationProvides.deselectAnnotation();
2617
+ setEditingId(null);
2618
+ }
2619
+ }
2620
+ }),
2621
+ [annotationProvides]
2622
+ );
2623
+ const handleClick = useCallback(
2624
+ (e, annotation) => {
2625
+ e.stopPropagation();
2626
+ if (annotationProvides && selectionProvides) {
2627
+ selectionProvides.clear();
2628
+ const isModifierPressed = "metaKey" in e ? e.metaKey || e.ctrlKey : false;
2629
+ if (isModifierPressed) {
2630
+ annotationProvides.toggleSelection(pageIndex, annotation.object.id);
2631
+ } else {
2632
+ annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
2633
+ }
2634
+ if (annotation.object.id !== editingId) {
2635
+ setEditingId(null);
2636
+ }
2637
+ }
2638
+ },
2639
+ [annotationProvides, selectionProvides, editingId, pageIndex]
2640
+ );
2641
+ useEffect(() => {
2642
+ return register(handlers, {
2643
+ documentId
2644
+ });
2645
+ }, [register, handlers]);
2646
+ const selectedAnnotationsOnPage = useMemo(() => {
2647
+ return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));
2135
2648
  }, [annotations, allSelectedIds]);
2136
2649
  const areAllSelectedDraggable = useMemo(() => {
2137
2650
  if (selectedAnnotationsOnPage.length < 2) return false;
@@ -2206,651 +2719,102 @@ function Annotations(annotationsProps) {
2206
2719
  const allSelected = annotationProvides.getSelectedAnnotations();
2207
2720
  return allSelected.length > 1 && allSelected.every((ta) => ta.object.pageIndex === pageIndex);
2208
2721
  }, [annotationProvides, pageIndex, allSelectedIds]);
2722
+ const getAppearanceForAnnotation = useCallback(
2723
+ (ta) => {
2724
+ if (ta.dictMode) return null;
2725
+ if (ta.object.rotation && ta.object.unrotatedRect) return null;
2726
+ const appearances = appearanceMap[ta.object.id];
2727
+ if (!(appearances == null ? void 0 : appearances.normal)) return null;
2728
+ return appearances;
2729
+ },
2730
+ [appearanceMap]
2731
+ );
2732
+ const allRenderers = useMemo(() => {
2733
+ const external = annotationsProps.annotationRenderers ?? [];
2734
+ const externalIds = new Set(external.map((r) => r.id));
2735
+ return [...external, ...builtInRenderers.filter((r) => !externalIds.has(r.id))];
2736
+ }, [annotationsProps.annotationRenderers]);
2737
+ const resolveRenderer = useCallback(
2738
+ (annotation) => allRenderers.find((r) => r.matches(annotation.object)) ?? null,
2739
+ [allRenderers]
2740
+ );
2741
+ const selectHelpers = useMemo(
2742
+ () => ({
2743
+ defaultSelect: handleClick,
2744
+ selectAnnotation: (pi, id) => annotationProvides == null ? void 0 : annotationProvides.selectAnnotation(pi, id),
2745
+ clearSelection: () => selectionProvides == null ? void 0 : selectionProvides.clear(),
2746
+ allAnnotations: annotations,
2747
+ pageIndex
2748
+ }),
2749
+ [handleClick, annotationProvides, selectionProvides, annotations, pageIndex]
2750
+ );
2209
2751
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2210
2752
  annotations.map((annotation) => {
2753
+ var _a, _b, _c;
2754
+ const renderer = resolveRenderer(annotation);
2755
+ if (!renderer) return null;
2756
+ const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
2211
2757
  const isSelected = allSelectedIds.includes(annotation.object.id);
2212
2758
  const isEditing = editingId === annotation.object.id;
2213
- const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
2214
- for (const renderer of annotationsProps.annotationRenderers ?? []) {
2215
- const element = renderer.tryRender(annotation, {
2759
+ const defaults = renderer.interactionDefaults;
2760
+ const resolvedDraggable = resolveInteractionProp(
2761
+ tool == null ? void 0 : tool.interaction.isDraggable,
2762
+ annotation.object,
2763
+ (defaults == null ? void 0 : defaults.isDraggable) ?? true
2764
+ );
2765
+ const finalDraggable = renderer.isDraggable ? renderer.isDraggable(resolvedDraggable, { isEditing }) : resolvedDraggable;
2766
+ const useAP = ((_a = tool == null ? void 0 : tool.behavior) == null ? void 0 : _a.useAppearanceStream) ?? renderer.useAppearanceStream ?? true;
2767
+ const onSelect = renderer.selectOverride ? (e) => renderer.selectOverride(e, annotation, selectHelpers) : (e) => handleClick(e, annotation);
2768
+ return /* @__PURE__ */ jsx(
2769
+ AnnotationContainer,
2770
+ {
2771
+ trackedAnnotation: annotation,
2216
2772
  isSelected,
2217
- scale,
2218
- pageIndex,
2219
- onClick: (e) => handleClick(e, annotation)
2220
- });
2221
- if (element) {
2222
- return /* @__PURE__ */ jsx(
2223
- AnnotationContainer,
2224
- {
2225
- trackedAnnotation: annotation,
2226
- isSelected,
2227
- isMultiSelected,
2228
- isDraggable: resolveInteractionProp(
2229
- tool == null ? void 0 : tool.interaction.isDraggable,
2230
- annotation.object,
2231
- false
2232
- ),
2233
- isResizable: resolveInteractionProp(
2234
- tool == null ? void 0 : tool.interaction.isResizable,
2235
- annotation.object,
2236
- false
2237
- ),
2238
- lockAspectRatio: resolveInteractionProp(
2239
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2240
- annotation.object,
2241
- false
2242
- ),
2243
- isRotatable: resolveInteractionProp(
2244
- tool == null ? void 0 : tool.interaction.isRotatable,
2245
- annotation.object,
2246
- false
2247
- ),
2248
- selectionMenu,
2249
- onSelect: (e) => handleClick(e, annotation),
2250
- style: {
2251
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2252
- },
2253
- ...annotationsProps,
2254
- children: () => element
2255
- },
2256
- annotation.object.id
2257
- );
2258
- }
2259
- }
2260
- if (isInk(annotation)) {
2261
- return /* @__PURE__ */ jsx(
2262
- AnnotationContainer,
2263
- {
2264
- trackedAnnotation: annotation,
2265
- isSelected,
2266
- isMultiSelected,
2267
- isDraggable: resolveInteractionProp(
2268
- tool == null ? void 0 : tool.interaction.isDraggable,
2269
- annotation.object,
2270
- true
2271
- ),
2272
- isResizable: resolveInteractionProp(
2273
- tool == null ? void 0 : tool.interaction.isResizable,
2274
- annotation.object,
2275
- true
2276
- ),
2277
- lockAspectRatio: resolveInteractionProp(
2278
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2279
- annotation.object,
2280
- false
2281
- ),
2282
- isRotatable: resolveInteractionProp(
2283
- tool == null ? void 0 : tool.interaction.isRotatable,
2284
- annotation.object,
2285
- true
2286
- ),
2287
- selectionMenu,
2288
- onSelect: (e) => handleClick(e, annotation),
2289
- style: {
2290
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2291
- },
2292
- ...annotationsProps,
2293
- children: (obj) => /* @__PURE__ */ jsx(
2294
- Ink,
2295
- {
2296
- ...obj,
2297
- isSelected,
2298
- scale,
2299
- onClick: (e) => handleClick(e, annotation)
2300
- }
2301
- )
2302
- },
2303
- annotation.object.id
2304
- );
2305
- }
2306
- if (isSquare(annotation)) {
2307
- return /* @__PURE__ */ jsx(
2308
- AnnotationContainer,
2309
- {
2310
- trackedAnnotation: annotation,
2311
- isSelected,
2312
- isMultiSelected,
2313
- isDraggable: resolveInteractionProp(
2314
- tool == null ? void 0 : tool.interaction.isDraggable,
2315
- annotation.object,
2316
- true
2317
- ),
2318
- isResizable: resolveInteractionProp(
2319
- tool == null ? void 0 : tool.interaction.isResizable,
2320
- annotation.object,
2321
- true
2322
- ),
2323
- lockAspectRatio: resolveInteractionProp(
2324
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2325
- annotation.object,
2326
- false
2327
- ),
2328
- isRotatable: resolveInteractionProp(
2329
- tool == null ? void 0 : tool.interaction.isRotatable,
2330
- annotation.object,
2331
- true
2332
- ),
2333
- selectionMenu,
2334
- onSelect: (e) => handleClick(e, annotation),
2335
- style: {
2336
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2337
- },
2338
- ...annotationsProps,
2339
- children: (obj) => /* @__PURE__ */ jsx(
2340
- Square,
2341
- {
2342
- ...obj,
2343
- isSelected,
2344
- scale,
2345
- onClick: (e) => handleClick(e, annotation)
2346
- }
2347
- )
2348
- },
2349
- annotation.object.id
2350
- );
2351
- }
2352
- if (isCircle(annotation)) {
2353
- return /* @__PURE__ */ jsx(
2354
- AnnotationContainer,
2355
- {
2356
- trackedAnnotation: annotation,
2357
- isSelected,
2358
- isMultiSelected,
2359
- isDraggable: resolveInteractionProp(
2360
- tool == null ? void 0 : tool.interaction.isDraggable,
2361
- annotation.object,
2362
- true
2363
- ),
2364
- isResizable: resolveInteractionProp(
2365
- tool == null ? void 0 : tool.interaction.isResizable,
2366
- annotation.object,
2367
- true
2368
- ),
2369
- lockAspectRatio: resolveInteractionProp(
2370
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2371
- annotation.object,
2372
- false
2373
- ),
2374
- isRotatable: resolveInteractionProp(
2375
- tool == null ? void 0 : tool.interaction.isRotatable,
2376
- annotation.object,
2377
- true
2378
- ),
2379
- selectionMenu,
2380
- onSelect: (e) => handleClick(e, annotation),
2381
- style: {
2382
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2383
- },
2384
- ...annotationsProps,
2385
- children: (obj) => /* @__PURE__ */ jsx(
2386
- Circle,
2387
- {
2388
- ...obj,
2389
- isSelected,
2390
- scale,
2391
- onClick: (e) => handleClick(e, annotation)
2392
- }
2393
- )
2394
- },
2395
- annotation.object.id
2396
- );
2397
- }
2398
- if (isUnderline(annotation)) {
2399
- return /* @__PURE__ */ jsx(
2400
- AnnotationContainer,
2401
- {
2402
- trackedAnnotation: annotation,
2403
- isSelected,
2404
- isMultiSelected,
2405
- isDraggable: resolveInteractionProp(
2406
- tool == null ? void 0 : tool.interaction.isDraggable,
2407
- annotation.object,
2408
- false
2409
- ),
2410
- isResizable: resolveInteractionProp(
2411
- tool == null ? void 0 : tool.interaction.isResizable,
2412
- annotation.object,
2413
- false
2414
- ),
2415
- lockAspectRatio: resolveInteractionProp(
2416
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2417
- annotation.object,
2418
- false
2419
- ),
2420
- isRotatable: resolveInteractionProp(
2421
- tool == null ? void 0 : tool.interaction.isRotatable,
2422
- annotation.object,
2423
- false
2424
- ),
2425
- selectionMenu,
2426
- onSelect: (e) => handleClick(e, annotation),
2427
- zIndex: 0,
2428
- style: {
2429
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2430
- },
2431
- ...annotationsProps,
2432
- children: (obj) => /* @__PURE__ */ jsx(Underline, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2773
+ isEditing,
2774
+ isMultiSelected,
2775
+ isDraggable: finalDraggable,
2776
+ isResizable: resolveInteractionProp(
2777
+ tool == null ? void 0 : tool.interaction.isResizable,
2778
+ annotation.object,
2779
+ (defaults == null ? void 0 : defaults.isResizable) ?? false
2780
+ ),
2781
+ lockAspectRatio: resolveInteractionProp(
2782
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
2783
+ annotation.object,
2784
+ (defaults == null ? void 0 : defaults.lockAspectRatio) ?? false
2785
+ ),
2786
+ isRotatable: resolveInteractionProp(
2787
+ tool == null ? void 0 : tool.interaction.isRotatable,
2788
+ annotation.object,
2789
+ (defaults == null ? void 0 : defaults.isRotatable) ?? false
2790
+ ),
2791
+ vertexConfig: renderer.vertexConfig,
2792
+ selectionMenu: ((_b = renderer.hideSelectionMenu) == null ? void 0 : _b.call(renderer, annotation.object)) ? void 0 : selectionMenu,
2793
+ onSelect,
2794
+ onDoubleClick: renderer.onDoubleClick ? (e) => {
2795
+ e.stopPropagation();
2796
+ renderer.onDoubleClick(annotation.object.id, setEditingId);
2797
+ } : void 0,
2798
+ zIndex: renderer.zIndex,
2799
+ style: ((_c = renderer.containerStyle) == null ? void 0 : _c.call(renderer, annotation.object)) ?? {
2800
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2433
2801
  },
2434
- annotation.object.id
2435
- );
2436
- }
2437
- if (isStrikeout(annotation)) {
2438
- return /* @__PURE__ */ jsx(
2439
- AnnotationContainer,
2440
- {
2441
- trackedAnnotation: annotation,
2442
- isSelected,
2443
- isMultiSelected,
2444
- isDraggable: resolveInteractionProp(
2445
- tool == null ? void 0 : tool.interaction.isDraggable,
2446
- annotation.object,
2447
- false
2448
- ),
2449
- isResizable: resolveInteractionProp(
2450
- tool == null ? void 0 : tool.interaction.isResizable,
2451
- annotation.object,
2452
- false
2453
- ),
2454
- lockAspectRatio: resolveInteractionProp(
2455
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2456
- annotation.object,
2457
- false
2458
- ),
2459
- isRotatable: resolveInteractionProp(
2460
- tool == null ? void 0 : tool.interaction.isRotatable,
2461
- annotation.object,
2462
- false
2463
- ),
2464
- selectionMenu,
2465
- onSelect: (e) => handleClick(e, annotation),
2466
- zIndex: 0,
2467
- style: {
2468
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2469
- },
2470
- ...annotationsProps,
2471
- children: (obj) => /* @__PURE__ */ jsx(Strikeout, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2472
- },
2473
- annotation.object.id
2474
- );
2475
- }
2476
- if (isSquiggly(annotation)) {
2477
- return /* @__PURE__ */ jsx(
2478
- AnnotationContainer,
2479
- {
2480
- trackedAnnotation: annotation,
2802
+ appearance: useAP ? getAppearanceForAnnotation(annotation) : void 0,
2803
+ ...annotationsProps,
2804
+ children: (currentObject, { appearanceActive }) => renderer.render({
2805
+ annotation,
2806
+ currentObject,
2481
2807
  isSelected,
2482
- isMultiSelected,
2483
- isDraggable: resolveInteractionProp(
2484
- tool == null ? void 0 : tool.interaction.isDraggable,
2485
- annotation.object,
2486
- false
2487
- ),
2488
- isResizable: resolveInteractionProp(
2489
- tool == null ? void 0 : tool.interaction.isResizable,
2490
- annotation.object,
2491
- false
2492
- ),
2493
- lockAspectRatio: resolveInteractionProp(
2494
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2495
- annotation.object,
2496
- false
2497
- ),
2498
- isRotatable: resolveInteractionProp(
2499
- tool == null ? void 0 : tool.interaction.isRotatable,
2500
- annotation.object,
2501
- false
2502
- ),
2503
- selectionMenu,
2504
- onSelect: (e) => handleClick(e, annotation),
2505
- zIndex: 0,
2506
- style: {
2507
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2508
- },
2509
- ...annotationsProps,
2510
- children: (obj) => /* @__PURE__ */ jsx(Squiggly, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2511
- },
2512
- annotation.object.id
2513
- );
2514
- }
2515
- if (isHighlight(annotation)) {
2516
- return /* @__PURE__ */ jsx(
2517
- AnnotationContainer,
2518
- {
2519
- trackedAnnotation: annotation,
2520
- isSelected,
2521
- isMultiSelected,
2522
- isDraggable: resolveInteractionProp(
2523
- tool == null ? void 0 : tool.interaction.isDraggable,
2524
- annotation.object,
2525
- false
2526
- ),
2527
- isResizable: resolveInteractionProp(
2528
- tool == null ? void 0 : tool.interaction.isResizable,
2529
- annotation.object,
2530
- false
2531
- ),
2532
- lockAspectRatio: resolveInteractionProp(
2533
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2534
- annotation.object,
2535
- false
2536
- ),
2537
- isRotatable: resolveInteractionProp(
2538
- tool == null ? void 0 : tool.interaction.isRotatable,
2539
- annotation.object,
2540
- false
2541
- ),
2542
- selectionMenu,
2543
- onSelect: (e) => handleClick(e, annotation),
2544
- zIndex: 0,
2545
- style: {
2546
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply)
2547
- },
2548
- ...annotationsProps,
2549
- children: (obj) => /* @__PURE__ */ jsx(Highlight, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2550
- },
2551
- annotation.object.id
2552
- );
2553
- }
2554
- if (isLine(annotation)) {
2555
- return /* @__PURE__ */ jsx(
2556
- AnnotationContainer,
2557
- {
2558
- trackedAnnotation: annotation,
2559
- isSelected,
2560
- isMultiSelected,
2561
- isDraggable: resolveInteractionProp(
2562
- tool == null ? void 0 : tool.interaction.isDraggable,
2563
- annotation.object,
2564
- true
2565
- ),
2566
- isResizable: resolveInteractionProp(
2567
- tool == null ? void 0 : tool.interaction.isResizable,
2568
- annotation.object,
2569
- false
2570
- ),
2571
- lockAspectRatio: resolveInteractionProp(
2572
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2573
- annotation.object,
2574
- false
2575
- ),
2576
- isRotatable: resolveInteractionProp(
2577
- tool == null ? void 0 : tool.interaction.isRotatable,
2578
- annotation.object,
2579
- true
2580
- ),
2581
- selectionMenu,
2582
- onSelect: (e) => handleClick(e, annotation),
2583
- vertexConfig: {
2584
- extractVertices: (annotation2) => [
2585
- annotation2.linePoints.start,
2586
- annotation2.linePoints.end
2587
- ],
2588
- transformAnnotation: (annotation2, vertices) => {
2589
- return {
2590
- ...annotation2,
2591
- linePoints: {
2592
- start: vertices[0],
2593
- end: vertices[1]
2594
- }
2595
- };
2596
- }
2597
- },
2598
- style: {
2599
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2600
- },
2601
- ...annotationsProps,
2602
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2603
- Line,
2604
- {
2605
- ...obj,
2606
- isSelected,
2607
- scale,
2608
- onClick: (e) => handleClick(e, annotation)
2609
- }
2610
- ) })
2611
- },
2612
- annotation.object.id
2613
- );
2614
- }
2615
- if (isPolyline(annotation)) {
2616
- return /* @__PURE__ */ jsx(
2617
- AnnotationContainer,
2618
- {
2619
- trackedAnnotation: annotation,
2620
- isSelected,
2621
- isMultiSelected,
2622
- isDraggable: resolveInteractionProp(
2623
- tool == null ? void 0 : tool.interaction.isDraggable,
2624
- annotation.object,
2625
- true
2626
- ),
2627
- isResizable: resolveInteractionProp(
2628
- tool == null ? void 0 : tool.interaction.isResizable,
2629
- annotation.object,
2630
- false
2631
- ),
2632
- lockAspectRatio: resolveInteractionProp(
2633
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2634
- annotation.object,
2635
- false
2636
- ),
2637
- isRotatable: resolveInteractionProp(
2638
- tool == null ? void 0 : tool.interaction.isRotatable,
2639
- annotation.object,
2640
- true
2641
- ),
2642
- selectionMenu,
2643
- onSelect: (e) => handleClick(e, annotation),
2644
- vertexConfig: {
2645
- extractVertices: (annotation2) => annotation2.vertices,
2646
- transformAnnotation: (annotation2, vertices) => {
2647
- return {
2648
- ...annotation2,
2649
- vertices
2650
- };
2651
- }
2652
- },
2653
- style: {
2654
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2655
- },
2656
- ...annotationsProps,
2657
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2658
- Polyline,
2659
- {
2660
- ...obj,
2661
- isSelected,
2662
- scale,
2663
- onClick: (e) => handleClick(e, annotation)
2664
- }
2665
- ) })
2666
- },
2667
- annotation.object.id
2668
- );
2669
- }
2670
- if (isPolygon(annotation)) {
2671
- return /* @__PURE__ */ jsx(
2672
- AnnotationContainer,
2673
- {
2674
- trackedAnnotation: annotation,
2675
- isSelected,
2676
- isMultiSelected,
2677
- isDraggable: resolveInteractionProp(
2678
- tool == null ? void 0 : tool.interaction.isDraggable,
2679
- annotation.object,
2680
- true
2681
- ),
2682
- isResizable: resolveInteractionProp(
2683
- tool == null ? void 0 : tool.interaction.isResizable,
2684
- annotation.object,
2685
- false
2686
- ),
2687
- lockAspectRatio: resolveInteractionProp(
2688
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2689
- annotation.object,
2690
- false
2691
- ),
2692
- isRotatable: resolveInteractionProp(
2693
- tool == null ? void 0 : tool.interaction.isRotatable,
2694
- annotation.object,
2695
- true
2696
- ),
2697
- selectionMenu,
2698
- onSelect: (e) => handleClick(e, annotation),
2699
- vertexConfig: {
2700
- extractVertices: (annotation2) => annotation2.vertices,
2701
- transformAnnotation: (annotation2, vertices) => {
2702
- return {
2703
- ...annotation2,
2704
- vertices
2705
- };
2706
- }
2707
- },
2708
- style: {
2709
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2710
- },
2711
- ...annotationsProps,
2712
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2713
- Polygon,
2714
- {
2715
- ...obj,
2716
- isSelected,
2717
- scale,
2718
- onClick: (e) => handleClick(e, annotation)
2719
- }
2720
- ) })
2721
- },
2722
- annotation.object.id
2723
- );
2724
- }
2725
- if (isFreeText(annotation)) {
2726
- return /* @__PURE__ */ jsx(
2727
- AnnotationContainer,
2728
- {
2729
- trackedAnnotation: annotation,
2730
- isSelected,
2731
- isMultiSelected,
2732
- isDraggable: resolveInteractionProp(tool == null ? void 0 : tool.interaction.isDraggable, annotation.object, true) && !isEditing,
2733
- isResizable: resolveInteractionProp(
2734
- tool == null ? void 0 : tool.interaction.isResizable,
2735
- annotation.object,
2736
- true
2737
- ),
2738
- lockAspectRatio: resolveInteractionProp(
2739
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2740
- annotation.object,
2741
- false
2742
- ),
2743
- isRotatable: resolveInteractionProp(
2744
- tool == null ? void 0 : tool.interaction.isRotatable,
2745
- annotation.object,
2746
- true
2747
- ),
2748
- selectionMenu,
2749
- onSelect: (e) => handleClick(e, annotation),
2750
- style: {
2751
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2752
- },
2753
- onDoubleClick: (e) => {
2754
- e.stopPropagation();
2755
- setEditingId(annotation.object.id);
2756
- },
2757
- ...annotationsProps,
2758
- children: (object) => /* @__PURE__ */ jsx(
2759
- FreeText,
2760
- {
2761
- isSelected,
2762
- isEditing,
2763
- annotation: {
2764
- ...annotation,
2765
- object
2766
- },
2767
- pageIndex,
2768
- scale,
2769
- onClick: (e) => handleClick(e, annotation)
2770
- }
2771
- )
2772
- },
2773
- annotation.object.id
2774
- );
2775
- }
2776
- if (isStamp(annotation)) {
2777
- return /* @__PURE__ */ jsx(
2778
- AnnotationContainer,
2779
- {
2780
- trackedAnnotation: annotation,
2781
- isSelected,
2782
- isMultiSelected,
2783
- isDraggable: resolveInteractionProp(
2784
- tool == null ? void 0 : tool.interaction.isDraggable,
2785
- annotation.object,
2786
- true
2787
- ),
2788
- isResizable: resolveInteractionProp(
2789
- tool == null ? void 0 : tool.interaction.isResizable,
2790
- annotation.object,
2791
- true
2792
- ),
2793
- lockAspectRatio: resolveInteractionProp(
2794
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2795
- annotation.object,
2796
- false
2797
- ),
2798
- isRotatable: resolveInteractionProp(
2799
- tool == null ? void 0 : tool.interaction.isRotatable,
2800
- annotation.object,
2801
- true
2802
- ),
2803
- selectionMenu,
2804
- onSelect: (e) => handleClick(e, annotation),
2805
- style: {
2806
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2807
- },
2808
- ...annotationsProps,
2809
- children: (_object) => /* @__PURE__ */ jsx(
2810
- Stamp,
2811
- {
2812
- isSelected,
2813
- annotation,
2814
- documentId,
2815
- pageIndex,
2816
- scale,
2817
- onClick: (e) => handleClick(e, annotation)
2818
- }
2819
- )
2820
- },
2821
- annotation.object.id
2822
- );
2823
- }
2824
- if (isLink(annotation)) {
2825
- const hasIRT = !!annotation.object.inReplyToId;
2826
- return /* @__PURE__ */ jsx(
2827
- AnnotationContainer,
2828
- {
2829
- trackedAnnotation: annotation,
2830
- isSelected,
2831
- isMultiSelected,
2832
- isDraggable: false,
2833
- isResizable: false,
2834
- lockAspectRatio: false,
2835
- isRotatable: false,
2836
- selectionMenu: hasIRT ? void 0 : selectionMenu,
2837
- onSelect: (e) => handleLinkClick(e, annotation),
2838
- ...annotationsProps,
2839
- children: (obj) => /* @__PURE__ */ jsx(
2840
- Link,
2841
- {
2842
- ...obj,
2843
- isSelected,
2844
- scale,
2845
- onClick: (e) => handleLinkClick(e, annotation),
2846
- hasIRT
2847
- }
2848
- )
2849
- },
2850
- annotation.object.id
2851
- );
2852
- }
2853
- return null;
2808
+ isEditing,
2809
+ scale,
2810
+ pageIndex,
2811
+ documentId,
2812
+ onClick: onSelect,
2813
+ appearanceActive
2814
+ })
2815
+ },
2816
+ annotation.object.id
2817
+ );
2854
2818
  }),
2855
2819
  allSelectedOnSamePage && selectedAnnotationsOnPage.length >= 2 && /* @__PURE__ */ jsx(
2856
2820
  GroupSelectionBox,
@@ -3177,20 +3141,6 @@ function AnnotationLayer({
3177
3141
  }
3178
3142
  );
3179
3143
  }
3180
- function createRenderer(entry) {
3181
- return {
3182
- id: entry.id,
3183
- tryRender: (annotation, props) => {
3184
- if (entry.matches(annotation.object)) {
3185
- return entry.render({
3186
- ...props,
3187
- annotation
3188
- });
3189
- }
3190
- return null;
3191
- }
3192
- };
3193
- }
3194
3144
  const AnnotationPluginPackage = createPluginPackage(AnnotationPluginPackage$1).addWrapper(AnnotationRendererProvider).build();
3195
3145
  export {
3196
3146
  AnnotationLayer,