@annotorious/annotorious 3.0.0-rc.1

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 (183) hide show
  1. package/README.md +6 -0
  2. package/dist/Annotorious.d.ts +15 -0
  3. package/dist/Annotorious.d.ts.map +1 -0
  4. package/dist/AnnotoriousOpts.d.ts +14 -0
  5. package/dist/AnnotoriousOpts.d.ts.map +1 -0
  6. package/dist/annotation/SVGAnnotationLayer.svelte.d.ts +1 -0
  7. package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +11 -0
  8. package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +1 -0
  9. package/dist/annotation/Transform.d.ts +6 -0
  10. package/dist/annotation/Transform.d.ts.map +1 -0
  11. package/dist/annotation/editors/Editor.svelte.d.ts +1 -0
  12. package/dist/annotation/editors/EditorMount.svelte.d.ts +1 -0
  13. package/dist/annotation/editors/Handle.d.ts +14 -0
  14. package/dist/annotation/editors/Handle.d.ts.map +1 -0
  15. package/dist/annotation/editors/editorsRegistry.d.ts +5 -0
  16. package/dist/annotation/editors/editorsRegistry.d.ts.map +1 -0
  17. package/dist/annotation/editors/index.d.ts +7 -0
  18. package/dist/annotation/editors/index.d.ts.map +1 -0
  19. package/dist/annotation/editors/polygon/PolygonEditor.svelte.d.ts +1 -0
  20. package/dist/annotation/editors/polygon/index.d.ts +2 -0
  21. package/dist/annotation/editors/polygon/index.d.ts.map +1 -0
  22. package/dist/annotation/editors/rectangle/RectangleEditor.svelte.d.ts +1 -0
  23. package/dist/annotation/editors/rectangle/index.d.ts +2 -0
  24. package/dist/annotation/editors/rectangle/index.d.ts.map +1 -0
  25. package/dist/annotation/index.d.ts +7 -0
  26. package/dist/annotation/index.d.ts.map +1 -0
  27. package/dist/annotation/shapes/Ellipse.svelte.d.ts +1 -0
  28. package/dist/annotation/shapes/Polygon.svelte.d.ts +1 -0
  29. package/dist/annotation/shapes/Rectangle.svelte.d.ts +1 -0
  30. package/dist/annotation/shapes/index.d.ts +4 -0
  31. package/dist/annotation/shapes/index.d.ts.map +1 -0
  32. package/dist/annotation/tools/DrawingToolConfig.d.ts +8 -0
  33. package/dist/annotation/tools/DrawingToolConfig.d.ts.map +1 -0
  34. package/dist/annotation/tools/ToolMount.svelte.d.ts +1 -0
  35. package/dist/annotation/tools/drawingToolsRegistry.d.ts +17 -0
  36. package/dist/annotation/tools/drawingToolsRegistry.d.ts.map +1 -0
  37. package/dist/annotation/tools/index.d.ts +5 -0
  38. package/dist/annotation/tools/index.d.ts.map +1 -0
  39. package/dist/annotation/tools/polygon/RubberbandPolygon.svelte.d.ts +1 -0
  40. package/dist/annotation/tools/polygon/index.d.ts +2 -0
  41. package/dist/annotation/tools/polygon/index.d.ts.map +1 -0
  42. package/dist/annotation/tools/rectangle/RubberbandRectangle.svelte.d.ts +1 -0
  43. package/dist/annotation/tools/rectangle/index.d.ts +2 -0
  44. package/dist/annotation/tools/rectangle/index.d.ts.map +1 -0
  45. package/dist/annotation/utils/index.d.ts +4 -0
  46. package/dist/annotation/utils/index.d.ts.map +1 -0
  47. package/dist/annotation/utils/math.d.ts +2 -0
  48. package/dist/annotation/utils/math.d.ts.map +1 -0
  49. package/dist/annotation/utils/responsive.d.ts +5 -0
  50. package/dist/annotation/utils/responsive.d.ts.map +1 -0
  51. package/dist/annotation/utils/styling.d.ts +4 -0
  52. package/dist/annotation/utils/styling.d.ts.map +1 -0
  53. package/dist/annotation/utils/touch.d.ts +2 -0
  54. package/dist/annotation/utils/touch.d.ts.map +1 -0
  55. package/dist/annotorious.css +1 -0
  56. package/dist/annotorious.es.js +3890 -0
  57. package/dist/annotorious.es.js.map +1 -0
  58. package/dist/annotorious.js +2 -0
  59. package/dist/annotorious.js.map +1 -0
  60. package/dist/index.d.ts +12 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/model/core/ImageAnnotation.d.ts +9 -0
  63. package/dist/model/core/ImageAnnotation.d.ts.map +1 -0
  64. package/dist/model/core/Shape.d.ts +20 -0
  65. package/dist/model/core/Shape.d.ts.map +1 -0
  66. package/dist/model/core/ellipse/Ellipse.d.ts +12 -0
  67. package/dist/model/core/ellipse/Ellipse.d.ts.map +1 -0
  68. package/dist/model/core/ellipse/ellipseUtils.d.ts +2 -0
  69. package/dist/model/core/ellipse/ellipseUtils.d.ts.map +1 -0
  70. package/dist/model/core/ellipse/index.d.ts +3 -0
  71. package/dist/model/core/ellipse/index.d.ts.map +1 -0
  72. package/dist/model/core/index.d.ts +7 -0
  73. package/dist/model/core/index.d.ts.map +1 -0
  74. package/dist/model/core/polygon/Polygon.d.ts +9 -0
  75. package/dist/model/core/polygon/Polygon.d.ts.map +1 -0
  76. package/dist/model/core/polygon/index.d.ts +3 -0
  77. package/dist/model/core/polygon/index.d.ts.map +1 -0
  78. package/dist/model/core/polygon/polygonUtils.d.ts +2 -0
  79. package/dist/model/core/polygon/polygonUtils.d.ts.map +1 -0
  80. package/dist/model/core/rectangle/Rectangle.d.ts +12 -0
  81. package/dist/model/core/rectangle/Rectangle.d.ts.map +1 -0
  82. package/dist/model/core/rectangle/index.d.ts +3 -0
  83. package/dist/model/core/rectangle/index.d.ts.map +1 -0
  84. package/dist/model/core/rectangle/rectangleUtils.d.ts +4 -0
  85. package/dist/model/core/rectangle/rectangleUtils.d.ts.map +1 -0
  86. package/dist/model/core/shapeUtils.d.ts +35 -0
  87. package/dist/model/core/shapeUtils.d.ts.map +1 -0
  88. package/dist/model/index.d.ts +3 -0
  89. package/dist/model/index.d.ts.map +1 -0
  90. package/dist/model/w3c/W3CImageFormatAdapter.d.ts +7 -0
  91. package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +1 -0
  92. package/dist/model/w3c/fragment/FragmentSelector.d.ts +10 -0
  93. package/dist/model/w3c/fragment/FragmentSelector.d.ts.map +1 -0
  94. package/dist/model/w3c/fragment/index.d.ts +2 -0
  95. package/dist/model/w3c/fragment/index.d.ts.map +1 -0
  96. package/dist/model/w3c/index.d.ts +4 -0
  97. package/dist/model/w3c/index.d.ts.map +1 -0
  98. package/dist/model/w3c/svg/SVG.d.ts +5 -0
  99. package/dist/model/w3c/svg/SVG.d.ts.map +1 -0
  100. package/dist/model/w3c/svg/SVGSelector.d.ts +9 -0
  101. package/dist/model/w3c/svg/SVGSelector.d.ts.map +1 -0
  102. package/dist/model/w3c/svg/index.d.ts +2 -0
  103. package/dist/model/w3c/svg/index.d.ts.map +1 -0
  104. package/dist/state/ImageAnnotationStore.d.ts +11 -0
  105. package/dist/state/ImageAnnotationStore.d.ts.map +1 -0
  106. package/dist/state/ImageAnnotatorState.d.ts +12 -0
  107. package/dist/state/ImageAnnotatorState.d.ts.map +1 -0
  108. package/dist/state/index.d.ts +3 -0
  109. package/dist/state/index.d.ts.map +1 -0
  110. package/dist/state/spatialTree.d.ts +21 -0
  111. package/dist/state/spatialTree.d.ts.map +1 -0
  112. package/dist/themes/index.d.ts +2 -0
  113. package/dist/themes/index.d.ts.map +1 -0
  114. package/dist/themes/smart/index.d.ts +2 -0
  115. package/dist/themes/smart/index.d.ts.map +1 -0
  116. package/dist/themes/smart/setTheme.d.ts +3 -0
  117. package/dist/themes/smart/setTheme.d.ts.map +1 -0
  118. package/package.json +55 -0
  119. package/src/Annotorious.css +74 -0
  120. package/src/Annotorious.ts +158 -0
  121. package/src/AnnotoriousOpts.ts +40 -0
  122. package/src/annotation/SVGAnnotationLayer.svelte +169 -0
  123. package/src/annotation/SVGAnnotationLayerPointerEvent.ts +55 -0
  124. package/src/annotation/Transform.ts +24 -0
  125. package/src/annotation/editors/Editor.svelte +61 -0
  126. package/src/annotation/editors/EditorMount.svelte +44 -0
  127. package/src/annotation/editors/Handle.ts +21 -0
  128. package/src/annotation/editors/editorsRegistry.ts +14 -0
  129. package/src/annotation/editors/index.ts +7 -0
  130. package/src/annotation/editors/polygon/PolygonEditor.svelte +64 -0
  131. package/src/annotation/editors/polygon/index.ts +1 -0
  132. package/src/annotation/editors/rectangle/RectangleEditor.svelte +143 -0
  133. package/src/annotation/editors/rectangle/index.ts +1 -0
  134. package/src/annotation/index.ts +7 -0
  135. package/src/annotation/shapes/Ellipse.svelte +32 -0
  136. package/src/annotation/shapes/Polygon.svelte +26 -0
  137. package/src/annotation/shapes/Rectangle.svelte +32 -0
  138. package/src/annotation/shapes/index.ts +3 -0
  139. package/src/annotation/tools/DrawingToolConfig.ts +9 -0
  140. package/src/annotation/tools/ToolMount.svelte +49 -0
  141. package/src/annotation/tools/drawingToolsRegistry.ts +26 -0
  142. package/src/annotation/tools/index.ts +4 -0
  143. package/src/annotation/tools/polygon/RubberbandPolygon.svelte +165 -0
  144. package/src/annotation/tools/polygon/index.ts +1 -0
  145. package/src/annotation/tools/rectangle/RubberbandRectangle.svelte +131 -0
  146. package/src/annotation/tools/rectangle/index.ts +1 -0
  147. package/src/annotation/utils/index.ts +3 -0
  148. package/src/annotation/utils/math.ts +6 -0
  149. package/src/annotation/utils/responsive.ts +56 -0
  150. package/src/annotation/utils/styling.ts +19 -0
  151. package/src/annotation/utils/touch.ts +1 -0
  152. package/src/index.ts +20 -0
  153. package/src/model/core/ImageAnnotation.ts +14 -0
  154. package/src/model/core/Shape.ts +37 -0
  155. package/src/model/core/ellipse/Ellipse.ts +21 -0
  156. package/src/model/core/ellipse/ellipseUtils.ts +28 -0
  157. package/src/model/core/ellipse/index.ts +2 -0
  158. package/src/model/core/index.ts +6 -0
  159. package/src/model/core/polygon/Polygon.ts +15 -0
  160. package/src/model/core/polygon/index.ts +2 -0
  161. package/src/model/core/polygon/polygonUtils.ts +43 -0
  162. package/src/model/core/rectangle/Rectangle.ts +21 -0
  163. package/src/model/core/rectangle/index.ts +2 -0
  164. package/src/model/core/rectangle/rectangleUtils.ts +17 -0
  165. package/src/model/core/shapeUtils.ts +57 -0
  166. package/src/model/index.ts +2 -0
  167. package/src/model/w3c/W3CImageFormatAdapter.ts +83 -0
  168. package/src/model/w3c/fragment/FragmentSelector.ts +59 -0
  169. package/src/model/w3c/fragment/index.ts +1 -0
  170. package/src/model/w3c/index.ts +3 -0
  171. package/src/model/w3c/svg/SVG.ts +36 -0
  172. package/src/model/w3c/svg/SVGSelector.ts +99 -0
  173. package/src/model/w3c/svg/index.ts +1 -0
  174. package/src/state/ImageAnnotationStore.ts +18 -0
  175. package/src/state/ImageAnnotatorState.ts +88 -0
  176. package/src/state/index.ts +2 -0
  177. package/src/state/spatialTree.ts +108 -0
  178. package/src/themes/dark/index.css +24 -0
  179. package/src/themes/index.ts +1 -0
  180. package/src/themes/light/index.css +30 -0
  181. package/src/themes/smart/index.ts +1 -0
  182. package/src/themes/smart/setTheme.ts +46 -0
  183. package/src/vite-env.d.ts +2 -0
@@ -0,0 +1,3890 @@
1
+ function G() {
2
+ }
3
+ function Wt(e, t) {
4
+ for (const n in t)
5
+ e[n] = t[n];
6
+ return e;
7
+ }
8
+ function Rt(e) {
9
+ return e();
10
+ }
11
+ function lt() {
12
+ return /* @__PURE__ */ Object.create(null);
13
+ }
14
+ function le(e) {
15
+ e.forEach(Rt);
16
+ }
17
+ function j(e) {
18
+ return typeof e == "function";
19
+ }
20
+ function K(e, t) {
21
+ return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function";
22
+ }
23
+ function Jt(e) {
24
+ return Object.keys(e).length === 0;
25
+ }
26
+ function Xt(e, ...t) {
27
+ if (e == null)
28
+ return G;
29
+ const n = e.subscribe(...t);
30
+ return n.unsubscribe ? () => n.unsubscribe() : n;
31
+ }
32
+ function at(e, t, n) {
33
+ e.$$.on_destroy.push(Xt(t, n));
34
+ }
35
+ function Qt(e, t, n, o) {
36
+ if (e) {
37
+ const i = Dt(e, t, n, o);
38
+ return e[0](i);
39
+ }
40
+ }
41
+ function Dt(e, t, n, o) {
42
+ return e[1] && o ? Wt(n.ctx.slice(), e[1](o(t))) : n.ctx;
43
+ }
44
+ function Zt(e, t, n, o) {
45
+ if (e[2] && o) {
46
+ const i = e[2](o(n));
47
+ if (t.dirty === void 0)
48
+ return i;
49
+ if (typeof i == "object") {
50
+ const s = [], r = Math.max(t.dirty.length, i.length);
51
+ for (let l = 0; l < r; l += 1)
52
+ s[l] = t.dirty[l] | i[l];
53
+ return s;
54
+ }
55
+ return t.dirty | i;
56
+ }
57
+ return t.dirty;
58
+ }
59
+ function Kt(e, t, n, o, i, s) {
60
+ if (i) {
61
+ const r = Dt(t, n, o, s);
62
+ e.p(r, i);
63
+ }
64
+ }
65
+ function xt(e) {
66
+ if (e.ctx.length > 32) {
67
+ const t = [], n = e.ctx.length / 32;
68
+ for (let o = 0; o < n; o++)
69
+ t[o] = -1;
70
+ return t;
71
+ }
72
+ return -1;
73
+ }
74
+ function fe(e, t) {
75
+ e.appendChild(t);
76
+ }
77
+ function v(e, t, n) {
78
+ e.insertBefore(t, n || null);
79
+ }
80
+ function O(e) {
81
+ e.parentNode && e.parentNode.removeChild(e);
82
+ }
83
+ function tt(e, t) {
84
+ for (let n = 0; n < e.length; n += 1)
85
+ e[n] && e[n].d(t);
86
+ }
87
+ function R(e) {
88
+ return document.createElementNS("http://www.w3.org/2000/svg", e);
89
+ }
90
+ function Nt(e) {
91
+ return document.createTextNode(e);
92
+ }
93
+ function ee() {
94
+ return Nt(" ");
95
+ }
96
+ function ae() {
97
+ return Nt("");
98
+ }
99
+ function W(e, t, n, o) {
100
+ return e.addEventListener(t, n, o), () => e.removeEventListener(t, n, o);
101
+ }
102
+ function u(e, t, n) {
103
+ n == null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n);
104
+ }
105
+ function $t(e) {
106
+ return Array.from(e.childNodes);
107
+ }
108
+ function ct(e, t, n) {
109
+ e.classList[n ? "add" : "remove"](t);
110
+ }
111
+ function en(e, t, { bubbles: n = !1, cancelable: o = !1 } = {}) {
112
+ const i = document.createEvent("CustomEvent");
113
+ return i.initCustomEvent(e, n, o, t), i;
114
+ }
115
+ let Ie;
116
+ function ke(e) {
117
+ Ie = e;
118
+ }
119
+ function Ut() {
120
+ if (!Ie)
121
+ throw new Error("Function called outside component initialization");
122
+ return Ie;
123
+ }
124
+ function Ce(e) {
125
+ Ut().$$.on_mount.push(e);
126
+ }
127
+ function Me() {
128
+ const e = Ut();
129
+ return (t, n, { cancelable: o = !1 } = {}) => {
130
+ const i = e.$$.callbacks[t];
131
+ if (i) {
132
+ const s = en(t, n, { cancelable: o });
133
+ return i.slice().forEach((r) => {
134
+ r.call(e, s);
135
+ }), !s.defaultPrevented;
136
+ }
137
+ return !0;
138
+ };
139
+ }
140
+ function Ae(e, t) {
141
+ const n = e.$$.callbacks[t.type];
142
+ n && n.slice().forEach((o) => o.call(this, t));
143
+ }
144
+ const be = [], Se = [];
145
+ let Te = [];
146
+ const ft = [], tn = /* @__PURE__ */ Promise.resolve();
147
+ let $e = !1;
148
+ function nn() {
149
+ $e || ($e = !0, tn.then(Gt));
150
+ }
151
+ function et(e) {
152
+ Te.push(e);
153
+ }
154
+ const We = /* @__PURE__ */ new Set();
155
+ let _e = 0;
156
+ function Gt() {
157
+ if (_e !== 0)
158
+ return;
159
+ const e = Ie;
160
+ do {
161
+ try {
162
+ for (; _e < be.length; ) {
163
+ const t = be[_e];
164
+ _e++, ke(t), on(t.$$);
165
+ }
166
+ } catch (t) {
167
+ throw be.length = 0, _e = 0, t;
168
+ }
169
+ for (ke(null), be.length = 0, _e = 0; Se.length; )
170
+ Se.pop()();
171
+ for (let t = 0; t < Te.length; t += 1) {
172
+ const n = Te[t];
173
+ We.has(n) || (We.add(n), n());
174
+ }
175
+ Te.length = 0;
176
+ } while (be.length);
177
+ for (; ft.length; )
178
+ ft.pop()();
179
+ $e = !1, We.clear(), ke(e);
180
+ }
181
+ function on(e) {
182
+ if (e.fragment !== null) {
183
+ e.update(), le(e.before_update);
184
+ const t = e.dirty;
185
+ e.dirty = [-1], e.fragment && e.fragment.p(e.ctx, t), e.after_update.forEach(et);
186
+ }
187
+ }
188
+ function sn(e) {
189
+ const t = [], n = [];
190
+ Te.forEach((o) => e.indexOf(o) === -1 ? t.push(o) : n.push(o)), n.forEach((o) => o()), Te = t;
191
+ }
192
+ const Ge = /* @__PURE__ */ new Set();
193
+ let me;
194
+ function se() {
195
+ me = {
196
+ r: 0,
197
+ c: [],
198
+ p: me
199
+ // parent group
200
+ };
201
+ }
202
+ function re() {
203
+ me.r || le(me.c), me = me.p;
204
+ }
205
+ function D(e, t) {
206
+ e && e.i && (Ge.delete(e), e.i(t));
207
+ }
208
+ function N(e, t, n, o) {
209
+ if (e && e.o) {
210
+ if (Ge.has(e))
211
+ return;
212
+ Ge.add(e), me.c.push(() => {
213
+ Ge.delete(e), o && (n && e.d(1), o());
214
+ }), e.o(t);
215
+ } else
216
+ o && o();
217
+ }
218
+ function pe(e) {
219
+ e && e.c();
220
+ }
221
+ function ue(e, t, n, o) {
222
+ const { fragment: i, after_update: s } = e.$$;
223
+ i && i.m(t, n), o || et(() => {
224
+ const r = e.$$.on_mount.map(Rt).filter(j);
225
+ e.$$.on_destroy ? e.$$.on_destroy.push(...r) : le(r), e.$$.on_mount = [];
226
+ }), s.forEach(et);
227
+ }
228
+ function de(e, t) {
229
+ const n = e.$$;
230
+ n.fragment !== null && (sn(n.after_update), le(n.on_destroy), n.fragment && n.fragment.d(t), n.on_destroy = n.fragment = null, n.ctx = []);
231
+ }
232
+ function rn(e, t) {
233
+ e.$$.dirty[0] === -1 && (be.push(e), nn(), e.$$.dirty.fill(0)), e.$$.dirty[t / 31 | 0] |= 1 << t % 31;
234
+ }
235
+ function te(e, t, n, o, i, s, r, l = [-1]) {
236
+ const a = Ie;
237
+ ke(e);
238
+ const d = e.$$ = {
239
+ fragment: null,
240
+ ctx: [],
241
+ // state
242
+ props: s,
243
+ update: G,
244
+ not_equal: i,
245
+ bound: lt(),
246
+ // lifecycle
247
+ on_mount: [],
248
+ on_destroy: [],
249
+ on_disconnect: [],
250
+ before_update: [],
251
+ after_update: [],
252
+ context: new Map(t.context || (a ? a.$$.context : [])),
253
+ // everything else
254
+ callbacks: lt(),
255
+ dirty: l,
256
+ skip_bound: !1,
257
+ root: t.target || a.$$.root
258
+ };
259
+ r && r(d.root);
260
+ let h = !1;
261
+ if (d.ctx = n ? n(e, t.props || {}, (c, f, ...m) => {
262
+ const g = m.length ? m[0] : f;
263
+ return d.ctx && i(d.ctx[c], d.ctx[c] = g) && (!d.skip_bound && d.bound[c] && d.bound[c](g), h && rn(e, c)), f;
264
+ }) : [], d.update(), h = !0, le(d.before_update), d.fragment = o ? o(d.ctx) : !1, t.target) {
265
+ if (t.hydrate) {
266
+ const c = $t(t.target);
267
+ d.fragment && d.fragment.l(c), c.forEach(O);
268
+ } else
269
+ d.fragment && d.fragment.c();
270
+ t.intro && D(e.$$.fragment), ue(e, t.target, t.anchor, t.customElement), Gt();
271
+ }
272
+ ke(a);
273
+ }
274
+ class ne {
275
+ $destroy() {
276
+ de(this, 1), this.$destroy = G;
277
+ }
278
+ $on(t, n) {
279
+ if (!j(n))
280
+ return G;
281
+ const o = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
282
+ return o.push(n), () => {
283
+ const i = o.indexOf(n);
284
+ i !== -1 && o.splice(i, 1);
285
+ };
286
+ }
287
+ $set(t) {
288
+ this.$$set && !Jt(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
289
+ }
290
+ }
291
+ var z = /* @__PURE__ */ ((e) => (e.ELLIPSE = "ELLIPSE", e.POLYGON = "POLYGON", e.RECTANGLE = "RECTANGLE", e))(z || {});
292
+ const nt = {}, ot = (e, t) => nt[e] = t, ut = (e) => nt[e.type].area(e), ln = (e, t, n) => nt[e.type].intersects(e, t, n), He = (e) => {
293
+ let t = 1 / 0, n = 1 / 0, o = -1 / 0, i = -1 / 0;
294
+ return e.forEach(([s, r]) => {
295
+ t = Math.min(t, s), n = Math.min(n, r), o = Math.max(o, s), i = Math.max(i, r);
296
+ }), { minX: t, minY: n, maxX: o, maxY: i };
297
+ }, an = {
298
+ area: (e) => Math.PI * e.geometry.rx * e.geometry.ry,
299
+ intersects: (e, t, n) => {
300
+ const { cx: o, cy: i, rx: s, ry: r } = e.geometry, l = 0, a = Math.cos(l), d = Math.sin(l), h = t - o, c = n - i, f = a * h + d * c, m = d * h - a * c;
301
+ return f * f / (s * s) + m * m / (r * r) <= 1;
302
+ }
303
+ };
304
+ ot(z.ELLIPSE, an);
305
+ const cn = {
306
+ area: (e) => {
307
+ const { points: t } = e.geometry;
308
+ let n = 0, o = t.length - 1;
309
+ for (let i = 0; i < t.length; i++)
310
+ n += (t[o][0] + t[i][0]) * (t[o][1] - t[i][1]), o = i;
311
+ return Math.abs(0.5 * n);
312
+ },
313
+ intersects: (e, t, n) => {
314
+ const { points: o } = e.geometry;
315
+ let i = !1;
316
+ for (let s = 0, r = o.length - 1; s < o.length; r = s++) {
317
+ const l = o[s][0], a = o[s][1], d = o[r][0], h = o[r][1];
318
+ a > n != h > n && t < (d - l) * (n - a) / (h - a) + l && (i = !i);
319
+ }
320
+ return i;
321
+ }
322
+ };
323
+ ot(z.POLYGON, cn);
324
+ const fn = {
325
+ area: (e) => e.geometry.w * e.geometry.h,
326
+ intersects: (e, t, n) => t >= e.geometry.x && t <= e.geometry.x + e.geometry.w && n >= e.geometry.y && n <= e.geometry.y + e.geometry.h
327
+ };
328
+ ot(z.RECTANGLE, fn);
329
+ const un = (e, t = !1) => {
330
+ const n = typeof e == "string" ? e : e.value, o = /^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g, i = [...n.matchAll(o)][0], [s, r, l, a, d, h, c] = i;
331
+ if (r !== "xywh")
332
+ throw new Error("Unsupported MediaFragment: " + n);
333
+ if (l && l !== "pixel")
334
+ throw new Error(`Unsupported MediaFragment unit: ${l}`);
335
+ const [f, m, g, p] = [a, d, h, c].map(parseFloat);
336
+ return {
337
+ type: z.RECTANGLE,
338
+ geometry: {
339
+ x: f,
340
+ y: m,
341
+ w: g,
342
+ h: p,
343
+ bounds: {
344
+ minX: f,
345
+ minY: t ? m - p : m,
346
+ maxX: f + g,
347
+ maxY: t ? m : m + p
348
+ }
349
+ }
350
+ };
351
+ }, dn = (e) => {
352
+ const { x: t, y: n, w: o, h: i } = e;
353
+ return {
354
+ type: "FragmentSelector",
355
+ conformsTo: "http://www.w3.org/TR/media-frags/",
356
+ value: `xywh=pixel:${t},${n},${o},${i}`
357
+ };
358
+ }, Ht = "http://www.w3.org/2000/svg", dt = (e) => {
359
+ const t = (o) => {
360
+ Array.from(o.attributes).forEach((i) => {
361
+ i.name.startsWith("on") && o.removeAttribute(i.name);
362
+ });
363
+ }, n = e.getElementsByTagName("script");
364
+ return Array.from(n).reverse().forEach((o) => o.parentNode.removeChild(o)), Array.from(e.querySelectorAll("*")).forEach(t), e;
365
+ }, hn = (e) => {
366
+ const o = new XMLSerializer().serializeToString(e.documentElement).replace("<svg>", `<svg xmlns="${Ht}">`);
367
+ return new DOMParser().parseFromString(o, "image/svg+xml").documentElement;
368
+ }, mn = (e) => {
369
+ const n = new DOMParser().parseFromString(e, "image/svg+xml"), o = n.lookupPrefix(Ht), i = n.lookupNamespaceURI(null);
370
+ return o || i ? dt(n).firstChild : dt(hn(n)).firstChild;
371
+ }, gn = (e) => {
372
+ const [t, n, o] = e.match(/(<polygon points=["|'])([^("|')]*)/) || [];
373
+ if (!o)
374
+ return;
375
+ const i = o.split(" ").map((s) => s.split(",").map(parseFloat));
376
+ return {
377
+ type: z.POLYGON,
378
+ geometry: {
379
+ points: i,
380
+ bounds: He(i)
381
+ }
382
+ };
383
+ }, pn = (e) => {
384
+ const t = mn(e), n = parseFloat(t.getAttribute("cx")), o = parseFloat(t.getAttribute("cy")), i = parseFloat(t.getAttribute("rx")), s = parseFloat(t.getAttribute("ry")), r = {
385
+ minX: n - i,
386
+ minY: o - s,
387
+ maxX: n + i,
388
+ maxY: o + s
389
+ };
390
+ return {
391
+ type: z.ELLIPSE,
392
+ geometry: {
393
+ cx: n,
394
+ cy: o,
395
+ rx: i,
396
+ ry: s,
397
+ bounds: r
398
+ }
399
+ };
400
+ }, _n = (e) => {
401
+ const t = typeof e == "string" ? e : e.value;
402
+ if (t.includes("<polygon points="))
403
+ return gn(t);
404
+ if (t.includes("<ellipse "))
405
+ return pn(t);
406
+ }, yn = (e) => {
407
+ let t;
408
+ if (e.type === z.POLYGON) {
409
+ const n = e.geometry, { points: o } = n;
410
+ t = `<svg><polygon points="${o.map((i) => i.join(",")).join(" ")}" /></svg>`;
411
+ } else if (e.type === z.ELLIPSE) {
412
+ const n = e.geometry;
413
+ t = `<svg><ellipse cx="${n.cx}" cy="${n.cy}" rx="${n.rx}" ry="${n.ry}" /></svg>`;
414
+ }
415
+ if (t)
416
+ return { type: "SvgSelector", value: t };
417
+ throw `Unsupported shape type: ${e.type}`;
418
+ };
419
+ let De;
420
+ const wn = new Uint8Array(16);
421
+ function bn() {
422
+ if (!De && (De = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !De))
423
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
424
+ return De(wn);
425
+ }
426
+ const q = [];
427
+ for (let e = 0; e < 256; ++e)
428
+ q.push((e + 256).toString(16).slice(1));
429
+ function En(e, t = 0) {
430
+ return q[e[t + 0]] + q[e[t + 1]] + q[e[t + 2]] + q[e[t + 3]] + "-" + q[e[t + 4]] + q[e[t + 5]] + "-" + q[e[t + 6]] + q[e[t + 7]] + "-" + q[e[t + 8]] + q[e[t + 9]] + "-" + q[e[t + 10]] + q[e[t + 11]] + q[e[t + 12]] + q[e[t + 13]] + q[e[t + 14]] + q[e[t + 15]];
431
+ }
432
+ const An = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ht = {
433
+ randomUUID: An
434
+ };
435
+ function it(e, t, n) {
436
+ if (ht.randomUUID && !t && !e)
437
+ return ht.randomUUID();
438
+ e = e || {};
439
+ const o = e.random || (e.rng || bn)();
440
+ if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, t) {
441
+ n = n || 0;
442
+ for (let i = 0; i < 16; ++i)
443
+ t[n + i] = o[i];
444
+ return t;
445
+ }
446
+ return En(o);
447
+ }
448
+ var mt = Object.prototype.hasOwnProperty;
449
+ function ge(e, t) {
450
+ var n, o;
451
+ if (e === t)
452
+ return !0;
453
+ if (e && t && (n = e.constructor) === t.constructor) {
454
+ if (n === Date)
455
+ return e.getTime() === t.getTime();
456
+ if (n === RegExp)
457
+ return e.toString() === t.toString();
458
+ if (n === Array) {
459
+ if ((o = e.length) === t.length)
460
+ for (; o-- && ge(e[o], t[o]); )
461
+ ;
462
+ return o === -1;
463
+ }
464
+ if (!n || typeof e == "object") {
465
+ o = 0;
466
+ for (n in e)
467
+ if (mt.call(e, n) && ++o && !mt.call(t, n) || !(n in t) || !ge(e[n], t[n]))
468
+ return !1;
469
+ return Object.keys(t).length === o;
470
+ }
471
+ }
472
+ return e !== e && t !== t;
473
+ }
474
+ const ye = [];
475
+ function Fe(e, t = G) {
476
+ let n;
477
+ const o = /* @__PURE__ */ new Set();
478
+ function i(l) {
479
+ if (K(e, l) && (e = l, n)) {
480
+ const a = !ye.length;
481
+ for (const d of o)
482
+ d[1](), ye.push(d, e);
483
+ if (a) {
484
+ for (let d = 0; d < ye.length; d += 2)
485
+ ye[d][0](ye[d + 1]);
486
+ ye.length = 0;
487
+ }
488
+ }
489
+ }
490
+ function s(l) {
491
+ i(l(e));
492
+ }
493
+ function r(l, a = G) {
494
+ const d = [l, a];
495
+ return o.add(d), o.size === 1 && (n = t(i) || G), l(e), () => {
496
+ o.delete(d), o.size === 0 && n && (n(), n = null);
497
+ };
498
+ }
499
+ return { set: i, update: s, subscribe: r };
500
+ }
501
+ const Tn = (e) => {
502
+ const { subscribe: t, set: n } = Fe(null);
503
+ let o = null;
504
+ return t((i) => o = i), e.observe(({ changes: i }) => {
505
+ if (o) {
506
+ i.deleted.some((l) => l.id === o) && n(null);
507
+ const r = i.updated.find(({ oldValue: l }) => l.id === o);
508
+ r && n(r.newValue.id);
509
+ }
510
+ }), {
511
+ get current() {
512
+ return o;
513
+ },
514
+ subscribe: t,
515
+ set: n
516
+ };
517
+ };
518
+ var Ft = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(Ft || {});
519
+ const Je = { selected: [] }, Sn = (e, t = "EDIT") => {
520
+ const { subscribe: n, set: o } = Fe(Je);
521
+ let i = Je;
522
+ n((c) => i = c);
523
+ const s = () => o(Je), r = () => {
524
+ var c;
525
+ return ((c = i.selected) == null ? void 0 : c.length) === 0;
526
+ }, l = (c) => {
527
+ if (i.selected.length === 0)
528
+ return !1;
529
+ const f = typeof c == "string" ? c : c.id;
530
+ return i.selected.some((m) => m.id === f);
531
+ }, a = (c, f) => {
532
+ const m = e.getAnnotation(c);
533
+ if (m) {
534
+ const g = Mn(m, t);
535
+ o(g === "EDIT" ? { selected: [{ id: c, editable: !0 }], pointerEvent: f } : g === "SELECT" ? { selected: [{ id: c }], pointerEvent: f } : { selected: [], pointerEvent: f });
536
+ } else
537
+ console.warn("Invalid selection: " + c);
538
+ }, d = (c, f = !0) => {
539
+ const m = Array.isArray(c) ? c : [c], g = m.map((p) => e.getAnnotation(p)).filter((p) => p);
540
+ o({ selected: g.map(({ id: p }) => ({ id: p, editable: f })) }), g.length !== m.length && console.warn("Invalid selection", c);
541
+ }, h = (c) => {
542
+ if (i.selected.length === 0)
543
+ return !1;
544
+ const { selected: f } = i;
545
+ f.filter(({ id: g }) => c.includes(g)).length > 0 && o({ selected: f.filter(({ id: g }) => !c.includes(g)) });
546
+ };
547
+ return e.observe(({ changes: c }) => h(c.deleted.map((f) => f.id))), {
548
+ clear: s,
549
+ clickSelect: a,
550
+ get selected() {
551
+ return i ? [...i.selected] : null;
552
+ },
553
+ get pointerEvent() {
554
+ return i ? i.pointerEvent : null;
555
+ },
556
+ isEmpty: r,
557
+ isSelected: l,
558
+ setSelected: d,
559
+ subscribe: n
560
+ };
561
+ }, Mn = (e, t) => typeof t == "function" ? t(e) || "EDIT" : t || "EDIT", ui = (e) => {
562
+ const { creator: t, updatedBy: n } = e.target, o = e.bodies.reduce((i, s) => [...i, s.creator, s.updatedBy], []);
563
+ return [
564
+ t,
565
+ n,
566
+ ...o
567
+ ].filter((i) => i);
568
+ }, di = (e, t, n, o) => ({
569
+ id: it(),
570
+ annotation: e.id,
571
+ created: n || /* @__PURE__ */ new Date(),
572
+ creator: o,
573
+ ...t
574
+ }), Ln = (e, t) => {
575
+ const n = new Set(e.bodies.map((o) => o.id));
576
+ return t.bodies.filter((o) => !n.has(o.id));
577
+ }, On = (e, t) => {
578
+ const n = new Set(t.bodies.map((o) => o.id));
579
+ return e.bodies.filter((o) => !n.has(o.id));
580
+ }, vn = (e, t) => t.bodies.map((n) => {
581
+ const o = e.bodies.find((i) => i.id === n.id);
582
+ return { newBody: n, oldBody: o && !ge(o, n) ? o : void 0 };
583
+ }).filter(({ oldBody: n }) => n), Bn = (e, t) => !ge(e.target, t.target), kn = (e, t) => ({
584
+ oldValue: e,
585
+ newValue: t,
586
+ bodiesCreated: Ln(e, t),
587
+ bodiesDeleted: On(e, t),
588
+ bodiesUpdated: vn(e, t),
589
+ targetUpdated: Bn(e, t) ? { oldTarget: e.target, newTarget: t.target } : void 0
590
+ });
591
+ var F = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(F || {});
592
+ const In = (e, t) => {
593
+ var s, r;
594
+ const { changes: n, origin: o } = t;
595
+ if (!(!e.options.origin || e.options.origin === o))
596
+ return !1;
597
+ if (e.options.ignore) {
598
+ const { ignore: l } = e.options, a = (h) => (h == null ? void 0 : h.length) > 0;
599
+ if (!(a(n.created) || a(n.deleted))) {
600
+ const h = (s = n.updated) == null ? void 0 : s.some((f) => a(f.bodiesCreated) || a(f.bodiesDeleted) || a(f.bodiesUpdated)), c = (r = n.updated) == null ? void 0 : r.some((f) => f.targetUpdated);
601
+ if (l === "BODY_ONLY" && h && !c || l === "TARGET_ONLY" && c && !h)
602
+ return !1;
603
+ }
604
+ }
605
+ if (e.options.annotations) {
606
+ const l = /* @__PURE__ */ new Set([
607
+ ...n.created.map((d) => d.id),
608
+ ...n.deleted.map((d) => d.id),
609
+ ...n.updated.map(({ oldValue: d }) => d.id)
610
+ ]);
611
+ return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((d) => l.has(d));
612
+ } else
613
+ return !0;
614
+ }, Cn = (e) => e.id !== void 0, Pn = () => {
615
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (_, w = {}) => n.push({ onChange: _, options: w }), i = (_) => {
616
+ const w = n.findIndex((A) => A.onChange == _);
617
+ w > -1 && n.splice(w, 1);
618
+ }, s = (_, w) => {
619
+ const A = {
620
+ origin: _,
621
+ changes: {
622
+ created: w.created || [],
623
+ updated: w.updated || [],
624
+ deleted: w.deleted || []
625
+ },
626
+ state: [...e.values()]
627
+ };
628
+ n.forEach((S) => {
629
+ In(S, A) && S.onChange(A);
630
+ });
631
+ }, r = (_, w = F.LOCAL) => {
632
+ if (e.get(_.id))
633
+ throw Error(`Cannot add annotation ${_.id} - exists already`);
634
+ e.set(_.id, _), _.bodies.forEach((S) => t.set(S.id, _.id)), s(w, { created: [_] });
635
+ }, l = (_, w = F.LOCAL, A = F.LOCAL) => {
636
+ const S = Cn(w) ? A : w, B = typeof _ == "string" ? w : _, P = typeof _ == "string" ? _ : _.id, Q = e.get(P);
637
+ if (Q) {
638
+ const ce = kn(Q, B);
639
+ P === B.id ? e.set(P, B) : (e.delete(P), e.set(B.id, B)), Q.bodies.forEach((oe) => t.delete(oe.id)), B.bodies.forEach((oe) => t.set(oe.id, B.id)), s(S, { updated: [ce] });
640
+ } else
641
+ throw Error(`Cannot update annotation ${P} - does not exist`);
642
+ }, a = (_, w = F.LOCAL) => {
643
+ const A = e.get(_.annotation);
644
+ if (A) {
645
+ const S = {
646
+ ...A,
647
+ bodies: [...A.bodies, _]
648
+ };
649
+ e.set(A.id, S), t.set(_.id, S.id), s(w, { updated: [{
650
+ oldValue: A,
651
+ newValue: S,
652
+ bodiesCreated: [_]
653
+ }] });
654
+ } else
655
+ console.warn(`Attempt to add body to missing annotation: ${_.annotation}`);
656
+ }, d = () => [...e.values()], h = (_ = F.LOCAL) => {
657
+ const w = [...e.values()];
658
+ e.clear(), t.clear(), s(_, { deleted: w });
659
+ }, c = (_, w = !0, A = F.LOCAL) => {
660
+ if (w) {
661
+ const S = [...e.values()];
662
+ e.clear(), t.clear(), _.forEach((B) => {
663
+ e.set(B.id, B), B.bodies.forEach((P) => t.set(P.id, B.id));
664
+ }), s(A, { created: _, deleted: S });
665
+ } else {
666
+ const S = _.reduce((B, P) => {
667
+ const Q = e.get(P.id);
668
+ return Q ? [...B, Q] : B;
669
+ }, []);
670
+ if (S.length > 0)
671
+ throw Error(`Bulk insert would overwrite the following annotations: ${S.map((B) => B.id).join(", ")}`);
672
+ _.forEach((B) => {
673
+ e.set(B.id, B), B.bodies.forEach((P) => t.set(P.id, B.id));
674
+ }), s(A, { created: _ });
675
+ }
676
+ }, f = (_) => {
677
+ const w = typeof _ == "string" ? _ : _.id, A = e.get(w);
678
+ if (A)
679
+ return e.delete(w), A.bodies.forEach((S) => t.delete(S.id)), A;
680
+ console.warn(`Attempt to delete missing annotation: ${w}`);
681
+ }, m = (_, w = F.LOCAL) => {
682
+ const A = f(_);
683
+ A && s(w, { deleted: [A] });
684
+ }, g = (_, w = F.LOCAL) => {
685
+ const A = _.reduce((S, B) => {
686
+ const P = f(B);
687
+ return P ? [...S, P] : S;
688
+ }, []);
689
+ A.length > 0 && s(w, { deleted: A });
690
+ }, p = (_, w = F.LOCAL) => {
691
+ const A = e.get(_.annotation);
692
+ if (A) {
693
+ const S = A.bodies.find((B) => B.id === _.id);
694
+ if (S) {
695
+ t.delete(S.id);
696
+ const B = {
697
+ ...A,
698
+ bodies: A.bodies.filter((Q) => Q.id !== _.id)
699
+ };
700
+ e.set(A.id, B), s(w, { updated: [{
701
+ oldValue: A,
702
+ newValue: B,
703
+ bodiesDeleted: [S]
704
+ }] });
705
+ } else
706
+ console.warn(`Attempt to delete missing body ${_.id} from annotation ${_.annotation}`);
707
+ } else
708
+ console.warn(`Attempt to delete body from missing annotation ${_.annotation}`);
709
+ }, y = (_) => {
710
+ const w = e.get(_);
711
+ return w ? { ...w } : void 0;
712
+ }, L = (_) => {
713
+ const w = t.get(_);
714
+ if (w) {
715
+ const S = y(w).bodies.find((B) => B.id === _);
716
+ if (S)
717
+ return S;
718
+ console.error(`Store integrity error: body ${_} in index, but not in annotation`);
719
+ } else
720
+ console.warn(`Attempt to retrieve missing body: ${_}`);
721
+ }, E = (_, w) => {
722
+ if (_.annotation !== w.annotation)
723
+ throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
724
+ const A = e.get(_.annotation);
725
+ if (A) {
726
+ const S = A.bodies.find((P) => P.id === _.id), B = {
727
+ ...A,
728
+ bodies: A.bodies.map((P) => P.id === S.id ? w : P)
729
+ };
730
+ return e.set(A.id, B), S.id !== w.id && (t.delete(S.id), t.set(w.id, B.id)), {
731
+ oldValue: A,
732
+ newValue: B,
733
+ bodiesUpdated: [{ oldBody: S, newBody: w }]
734
+ };
735
+ } else
736
+ console.warn(`Attempt to add body to missing annotation ${_.annotation}`);
737
+ }, k = (_, w, A = F.LOCAL) => {
738
+ const S = E(_, w);
739
+ s(A, { updated: [S] });
740
+ }, b = (_, w = F.LOCAL) => {
741
+ const A = _.map((S) => E({ id: S.id, annotation: S.annotation }, S));
742
+ s(w, { updated: A });
743
+ }, Y = (_) => {
744
+ const w = e.get(_.annotation);
745
+ if (w) {
746
+ const A = {
747
+ ...w,
748
+ target: {
749
+ ...w.target,
750
+ ..._
751
+ }
752
+ };
753
+ return e.set(w.id, A), {
754
+ oldValue: w,
755
+ newValue: A,
756
+ targetUpdated: {
757
+ oldTarget: w.target,
758
+ newTarget: _
759
+ }
760
+ };
761
+ } else
762
+ console.warn(`Attempt to update target on missing annotation: ${_.annotation}`);
763
+ };
764
+ return {
765
+ addAnnotation: r,
766
+ addBody: a,
767
+ all: d,
768
+ bulkAddAnnotation: c,
769
+ bulkDeleteAnnotation: g,
770
+ bulkUpdateBodies: b,
771
+ bulkUpdateTargets: (_, w = F.LOCAL) => {
772
+ const A = _.map(Y).filter((S) => S);
773
+ A.length > 0 && s(w, { updated: A });
774
+ },
775
+ clear: h,
776
+ deleteAnnotation: m,
777
+ deleteBody: p,
778
+ getAnnotation: y,
779
+ getBody: L,
780
+ observe: o,
781
+ unobserve: i,
782
+ updateAnnotation: l,
783
+ updateBody: k,
784
+ updateTarget: (_, w = F.LOCAL) => {
785
+ const A = Y(_);
786
+ A && s(w, { updated: [A] });
787
+ }
788
+ };
789
+ }, Yn = (e) => ({
790
+ ...e,
791
+ subscribe: (n) => {
792
+ const o = (i) => n(i.state);
793
+ return e.observe(o), n(e.all()), () => e.unobserve(o);
794
+ }
795
+ }), Rn = () => {
796
+ const { subscribe: e, set: t } = Fe([]);
797
+ return {
798
+ subscribe: e,
799
+ set: t
800
+ };
801
+ }, Xn = (e, t, n, o, i, s) => {
802
+ const r = /* @__PURE__ */ new Map();
803
+ let l = [], a, d;
804
+ const h = (g, p) => {
805
+ r.has(g) ? r.get(g).push(p) : r.set(g, [p]);
806
+ }, c = (g, p) => {
807
+ const y = r.get(g);
808
+ y && y.indexOf(p) > 0 && y.splice(y.indexOf(p), 1);
809
+ }, f = (g, p, y) => {
810
+ r.has(g) && setTimeout(() => {
811
+ r.get(g).forEach((L) => {
812
+ if (i) {
813
+ const E = Array.isArray(p) ? p.map((b) => i.serialize(b)) : i.serialize(p), k = y ? y instanceof PointerEvent ? y : i.serialize(y) : void 0;
814
+ L(E, k);
815
+ } else
816
+ L(p, y);
817
+ });
818
+ }, 1);
819
+ }, m = () => {
820
+ const { selected: g } = t, p = g.map(({ id: y }) => e.getAnnotation(y));
821
+ p.forEach((y) => {
822
+ const L = l.find((E) => E.id === y.id);
823
+ (!L || !ge(L, y)) && f("updateAnnotation", y, L);
824
+ }), l = l.map((y) => {
825
+ const L = p.find(({ id: E }) => E === y.id);
826
+ return L || y;
827
+ });
828
+ };
829
+ return t.subscribe(({ selected: g }) => {
830
+ if (!(l.length === 0 && g.length === 0)) {
831
+ if (l.length === 0 && g.length > 0)
832
+ l = g.map(({ id: p }) => e.getAnnotation(p));
833
+ else if (l.length > 0 && g.length === 0)
834
+ l.forEach((p) => {
835
+ const y = e.getAnnotation(p.id);
836
+ y && !ge(y, p) && f("updateAnnotation", y, p);
837
+ }), l = [];
838
+ else {
839
+ const p = new Set(l.map((E) => E.id)), y = new Set(g.map(({ id: E }) => E));
840
+ l.filter((E) => !y.has(E.id)).forEach((E) => {
841
+ const k = e.getAnnotation(E.id);
842
+ k && !ge(k, E) && f("updateAnnotation", k, E);
843
+ }), l = [
844
+ // Remove annotations that were deselected
845
+ ...l.filter((E) => y.has(E.id)),
846
+ // Add editable annotations that were selected
847
+ ...g.filter(({ id: E }) => !p.has(E)).map(({ id: E }) => e.getAnnotation(E))
848
+ ];
849
+ }
850
+ f("selectionChanged", l);
851
+ }
852
+ }), n.subscribe((g) => {
853
+ !a && g ? f("mouseEnterAnnotation", e.getAnnotation(g)) : a && !g ? f("mouseLeaveAnnotation", e.getAnnotation(a)) : a && g && (f("mouseLeaveAnnotation", e.getAnnotation(a)), f("mouseEnterAnnotation", e.getAnnotation(g))), a = g;
854
+ }), o == null || o.subscribe((g) => f("viewportIntersect", g.map(e.getAnnotation))), e.observe((g) => {
855
+ s && (d && clearTimeout(d), d = setTimeout(m, 1e3));
856
+ const { created: p, deleted: y } = g.changes;
857
+ p.forEach((E) => f("createAnnotation", E)), y.forEach((E) => f("deleteAnnotation", E)), g.changes.updated.filter((E) => [
858
+ ...E.bodiesCreated || [],
859
+ ...E.bodiesDeleted || [],
860
+ ...E.bodiesUpdated || []
861
+ ].length > 0).forEach(({ oldValue: E, newValue: k }) => {
862
+ const b = l.find((Y) => Y.id === E.id) || E;
863
+ l = l.map((Y) => Y.id === E.id ? k : Y), f("updateAnnotation", k, b);
864
+ });
865
+ }, { origin: F.LOCAL }), e.observe((g) => {
866
+ if (l) {
867
+ const p = new Set(l.map((L) => L.id)), y = g.changes.updated.filter(({ newValue: L }) => p.has(L.id)).map(({ newValue: L }) => L);
868
+ y.length > 0 && (l = l.map((L) => {
869
+ const E = y.find((k) => k.id === L.id);
870
+ return E || L;
871
+ }));
872
+ }
873
+ }, { origin: F.REMOTE }), { on: h, off: c, emit: f };
874
+ }, hi = (e) => (t) => t.map((n) => e.serialize(n)), Dn = (e) => (t) => t.reduce((n, o) => {
875
+ const { parsed: i, error: s } = e.parse(o);
876
+ return s ? {
877
+ parsed: n.parsed,
878
+ failed: [...n.failed, o]
879
+ } : {
880
+ parsed: [...n.parsed, i],
881
+ failed: n.failed
882
+ };
883
+ }, { parsed: [], failed: [] }), Nn = (e, t) => {
884
+ const n = (h) => {
885
+ if (t) {
886
+ const { parsed: c, error: f } = t.parse(h);
887
+ c ? e.addAnnotation(c, F.REMOTE) : console.error(f);
888
+ } else
889
+ e.addAnnotation(h, F.REMOTE);
890
+ }, o = () => e.clear(), i = (h) => {
891
+ const c = e.getAnnotation(h);
892
+ return t && c ? t.serialize(c) : c;
893
+ }, s = () => t ? e.all().map(t.serialize) : e.all(), r = (h) => fetch(h).then((c) => c.json()).then((c) => (a(c), c)), l = (h) => {
894
+ if (typeof h == "string") {
895
+ const c = e.getAnnotation(h);
896
+ return e.deleteAnnotation(h), t ? t.serialize(c) : c;
897
+ } else {
898
+ const c = t ? t.parse(h).parsed : h;
899
+ return e.deleteAnnotation(c), h;
900
+ }
901
+ }, a = (h) => {
902
+ if (t) {
903
+ const { parsed: c, failed: f } = Dn(t)(h);
904
+ f.length > 0 && console.warn(`Discarded ${f.length} invalid annotations`, f), e.bulkAddAnnotation(c, !0, F.REMOTE);
905
+ } else
906
+ e.bulkAddAnnotation(h, !0, F.REMOTE);
907
+ };
908
+ return {
909
+ addAnnotation: n,
910
+ clearAnnotations: o,
911
+ getAnnotationById: i,
912
+ getAnnotations: s,
913
+ loadAnnotations: r,
914
+ removeAnnotation: l,
915
+ setAnnotations: a,
916
+ updateAnnotation: (h) => {
917
+ if (t) {
918
+ const c = t.parse(h).parsed, f = t.serialize(e.getAnnotation(c.id));
919
+ return e.updateAnnotation(c), f;
920
+ } else {
921
+ const c = e.getAnnotation(h.id);
922
+ return e.updateAnnotation(h), c;
923
+ }
924
+ }
925
+ };
926
+ };
927
+ let Un = (e) => crypto.getRandomValues(new Uint8Array(e)), Gn = (e, t, n) => {
928
+ let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * t / e.length);
929
+ return (s = t) => {
930
+ let r = "";
931
+ for (; ; ) {
932
+ let l = n(i), a = i;
933
+ for (; a--; )
934
+ if (r += e[l[a] & o] || "", r.length === s)
935
+ return r;
936
+ }
937
+ };
938
+ }, Hn = (e, t = 21) => Gn(e, t, Un), Fn = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((t, n) => (n &= 63, n < 36 ? t += n.toString(36) : n < 62 ? t += (n - 26).toString(36).toUpperCase() : n > 62 ? t += "-" : t += "_", t), "");
939
+ const zn = () => ({ isGuest: !0, id: Hn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), jn = (e) => {
940
+ const t = JSON.stringify(e);
941
+ let n = 0;
942
+ for (let o = 0, i = t.length; o < i; o++) {
943
+ let s = t.charCodeAt(o);
944
+ n = (n << 5) - n + s, n |= 0;
945
+ }
946
+ return `${n}`;
947
+ }, Vn = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
948
+ const { id: o, type: i, purpose: s, value: r, created: l, creator: a, ...d } = n;
949
+ return {
950
+ id: o || `temp-${jn(n)}`,
951
+ annotation: t,
952
+ type: i,
953
+ purpose: s,
954
+ value: r,
955
+ created: l,
956
+ creator: a ? typeof a == "object" ? { ...a } : a : void 0,
957
+ ...d
958
+ };
959
+ }), qn = (e) => e.map((t) => {
960
+ var o;
961
+ const n = { ...t };
962
+ return delete n.annotation, (o = n.id) != null && o.startsWith("temp-") && delete n.id, n;
963
+ }), Wn = [
964
+ "#ff7c00",
965
+ // orange
966
+ "#1ac938",
967
+ // green
968
+ "#e8000b",
969
+ // red
970
+ "#8b2be2",
971
+ // purple
972
+ "#9f4800",
973
+ // brown
974
+ "#f14cc1",
975
+ // pink
976
+ "#ffc400",
977
+ // khaki
978
+ "#00d7ff",
979
+ // cyan
980
+ "#023eff"
981
+ // blue
982
+ ], Jn = () => {
983
+ const e = [...Wn];
984
+ return { assignRandomColor: () => {
985
+ const o = Math.floor(Math.random() * e.length), i = e[o];
986
+ return e.splice(o, 1), i;
987
+ }, releaseColor: (o) => e.push(o) };
988
+ }, Qn = () => {
989
+ const e = Jn();
990
+ return { addUser: (o, i) => {
991
+ const s = e.assignRandomColor();
992
+ return {
993
+ label: i.name || i.id,
994
+ avatar: i.avatar,
995
+ color: s
996
+ };
997
+ }, removeUser: (o) => e.releaseColor(o.appearance.color) };
998
+ };
999
+ let Zn = () => ({
1000
+ emit(e, ...t) {
1001
+ let n = this.events[e] || [];
1002
+ for (let o = 0, i = n.length; o < i; o++)
1003
+ n[o](...t);
1004
+ },
1005
+ events: {},
1006
+ on(e, t) {
1007
+ var n;
1008
+ return (n = this.events[e]) != null && n.push(t) || (this.events[e] = [t]), () => {
1009
+ var o;
1010
+ this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => t !== i);
1011
+ };
1012
+ }
1013
+ });
1014
+ const Kn = (e, t) => e.every((n) => e.includes(n)) && t.every((n) => e.includes(n)), mi = Fn(), gi = (e = Qn()) => {
1015
+ const t = Zn(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (c, f) => {
1016
+ if (n.has(c)) {
1017
+ console.warn("Attempt to add user that is already present", c, f);
1018
+ return;
1019
+ }
1020
+ const m = e.addUser(c, f);
1021
+ n.set(c, {
1022
+ ...f,
1023
+ presenceKey: c,
1024
+ appearance: m
1025
+ });
1026
+ }, s = (c) => {
1027
+ const f = n.get(c);
1028
+ if (!f) {
1029
+ console.warn("Attempt to remove user that is not present", c);
1030
+ return;
1031
+ }
1032
+ e.removeUser(f), n.delete(c);
1033
+ }, r = (c) => {
1034
+ const f = new Set(c.map((p) => p.presenceKey)), m = c.filter(({ presenceKey: p }) => !n.has(p)), g = Array.from(n.values()).filter((p) => !f.has(p.presenceKey));
1035
+ m.forEach(({ presenceKey: p, user: y }) => i(p, y)), g.forEach((p) => {
1036
+ const { presenceKey: y } = p;
1037
+ o.has(y) && t.emit("selectionChange", p, null), s(y);
1038
+ }), (m.length > 0 || g.length > 0) && t.emit("presence", d());
1039
+ }, l = (c, f) => {
1040
+ const m = n.get(c);
1041
+ if (!m) {
1042
+ console.warn("Activity notification from user that is not present");
1043
+ return;
1044
+ }
1045
+ const g = o.get(c);
1046
+ (!g || !Kn(g, f)) && (o.set(c, f), t.emit("selectionChange", m, f));
1047
+ }, a = (c, f) => {
1048
+ const m = n.get(c);
1049
+ if (!m) {
1050
+ console.warn("Selection change for user that is not present", c);
1051
+ return;
1052
+ }
1053
+ f ? o.set(c, f) : o.delete(c), t.emit("selectionChange", m, f);
1054
+ }, d = () => [...Array.from(n.values())];
1055
+ return {
1056
+ getPresentUsers: d,
1057
+ notifyActivity: l,
1058
+ on: (c, f) => t.on(c, f),
1059
+ syncUsers: r,
1060
+ updateSelection: a
1061
+ };
1062
+ }, pi = (e, t = !1) => ({ parse: (i) => xn(i, t), serialize: (i) => $n(i, e) }), xn = (e, t = !1) => {
1063
+ const n = e.id || it(), o = Vn(e.body, n), i = Array.isArray(e.target) ? e.target[0] : e.target, s = Array.isArray(i.selector) ? i.selector[0] : i.selector, r = s.type === "FragmentSelector" ? un(s, t) : s.type === "SvgSelector" ? _n(s) : void 0;
1064
+ return r ? {
1065
+ parsed: {
1066
+ ...e,
1067
+ id: n,
1068
+ bodies: o,
1069
+ target: {
1070
+ annotation: n,
1071
+ selector: r
1072
+ }
1073
+ }
1074
+ } : {
1075
+ error: Error(`Unknown selector type: ${r.type}`)
1076
+ };
1077
+ }, $n = (e, t) => {
1078
+ const n = e.target.selector, o = n.type == z.RECTANGLE ? dn(n.geometry) : yn(n);
1079
+ return {
1080
+ ...e,
1081
+ "@context": "http://www.w3.org/ns/anno.jsonld",
1082
+ id: e.id,
1083
+ type: "Annotation",
1084
+ body: qn(e.bodies),
1085
+ target: {
1086
+ source: t,
1087
+ selector: o
1088
+ }
1089
+ };
1090
+ };
1091
+ function gt(e, t, n) {
1092
+ const o = e.slice();
1093
+ return o[11] = t[n], o[13] = n, o;
1094
+ }
1095
+ function pt(e) {
1096
+ let t, n, o, i, s;
1097
+ return {
1098
+ c() {
1099
+ t = R("rect"), u(t, "class", "a9s-corner-handle"), u(t, "x", n = /*point*/
1100
+ e[11][0] - /*handleSize*/
1101
+ e[3] / 2), u(t, "y", o = /*point*/
1102
+ e[11][1] - /*handleSize*/
1103
+ e[3] / 2), u(
1104
+ t,
1105
+ "height",
1106
+ /*handleSize*/
1107
+ e[3]
1108
+ ), u(
1109
+ t,
1110
+ "width",
1111
+ /*handleSize*/
1112
+ e[3]
1113
+ );
1114
+ },
1115
+ m(r, l) {
1116
+ v(r, t, l), i || (s = W(t, "pointerdown", function() {
1117
+ j(
1118
+ /*grab*/
1119
+ e[10](M(
1120
+ /*idx*/
1121
+ e[13]
1122
+ ))
1123
+ ) && e[10](M(
1124
+ /*idx*/
1125
+ e[13]
1126
+ )).apply(this, arguments);
1127
+ }), i = !0);
1128
+ },
1129
+ p(r, l) {
1130
+ e = r, l & /*geom, handleSize*/
1131
+ 24 && n !== (n = /*point*/
1132
+ e[11][0] - /*handleSize*/
1133
+ e[3] / 2) && u(t, "x", n), l & /*geom, handleSize*/
1134
+ 24 && o !== (o = /*point*/
1135
+ e[11][1] - /*handleSize*/
1136
+ e[3] / 2) && u(t, "y", o), l & /*handleSize*/
1137
+ 8 && u(
1138
+ t,
1139
+ "height",
1140
+ /*handleSize*/
1141
+ e[3]
1142
+ ), l & /*handleSize*/
1143
+ 8 && u(
1144
+ t,
1145
+ "width",
1146
+ /*handleSize*/
1147
+ e[3]
1148
+ );
1149
+ },
1150
+ d(r) {
1151
+ r && O(t), i = !1, s();
1152
+ }
1153
+ };
1154
+ }
1155
+ function eo(e) {
1156
+ let t, n, o, i, s, r, l, a, d, h, c = (
1157
+ /*geom*/
1158
+ e[4].points
1159
+ ), f = [];
1160
+ for (let m = 0; m < c.length; m += 1)
1161
+ f[m] = pt(gt(e, c, m));
1162
+ return {
1163
+ c() {
1164
+ t = R("polygon"), i = ee(), s = R("polygon"), l = ee();
1165
+ for (let m = 0; m < f.length; m += 1)
1166
+ f[m].c();
1167
+ a = ae(), u(t, "class", "a9s-outer"), u(t, "style", n = /*computedStyle*/
1168
+ e[1] ? "display:none;" : void 0), u(t, "points", o = /*geom*/
1169
+ e[4].points.map(_t).join(" ")), u(s, "class", "a9s-inner a9s-shape-handle"), u(
1170
+ s,
1171
+ "style",
1172
+ /*computedStyle*/
1173
+ e[1]
1174
+ ), u(s, "points", r = /*geom*/
1175
+ e[4].points.map(yt).join(" "));
1176
+ },
1177
+ m(m, g) {
1178
+ v(m, t, g), v(m, i, g), v(m, s, g), v(m, l, g);
1179
+ for (let p = 0; p < f.length; p += 1)
1180
+ f[p] && f[p].m(m, g);
1181
+ v(m, a, g), d || (h = [
1182
+ W(t, "pointerdown", function() {
1183
+ j(
1184
+ /*grab*/
1185
+ e[10](M.SHAPE)
1186
+ ) && e[10](M.SHAPE).apply(this, arguments);
1187
+ }),
1188
+ W(s, "pointerdown", function() {
1189
+ j(
1190
+ /*grab*/
1191
+ e[10](M.SHAPE)
1192
+ ) && e[10](M.SHAPE).apply(this, arguments);
1193
+ })
1194
+ ], d = !0);
1195
+ },
1196
+ p(m, g) {
1197
+ if (e = m, g & /*computedStyle*/
1198
+ 2 && n !== (n = /*computedStyle*/
1199
+ e[1] ? "display:none;" : void 0) && u(t, "style", n), g & /*geom*/
1200
+ 16 && o !== (o = /*geom*/
1201
+ e[4].points.map(_t).join(" ")) && u(t, "points", o), g & /*computedStyle*/
1202
+ 2 && u(
1203
+ s,
1204
+ "style",
1205
+ /*computedStyle*/
1206
+ e[1]
1207
+ ), g & /*geom*/
1208
+ 16 && r !== (r = /*geom*/
1209
+ e[4].points.map(yt).join(" ")) && u(s, "points", r), g & /*geom, handleSize, grab, Handle*/
1210
+ 1048) {
1211
+ c = /*geom*/
1212
+ e[4].points;
1213
+ let p;
1214
+ for (p = 0; p < c.length; p += 1) {
1215
+ const y = gt(e, c, p);
1216
+ f[p] ? f[p].p(y, g) : (f[p] = pt(y), f[p].c(), f[p].m(a.parentNode, a));
1217
+ }
1218
+ for (; p < f.length; p += 1)
1219
+ f[p].d(1);
1220
+ f.length = c.length;
1221
+ }
1222
+ },
1223
+ d(m) {
1224
+ m && O(t), m && O(i), m && O(s), m && O(l), tt(f, m), m && O(a), d = !1, le(h);
1225
+ }
1226
+ };
1227
+ }
1228
+ function to(e) {
1229
+ let t, n;
1230
+ return t = new jt({
1231
+ props: {
1232
+ shape: (
1233
+ /*shape*/
1234
+ e[0]
1235
+ ),
1236
+ transform: (
1237
+ /*transform*/
1238
+ e[2]
1239
+ ),
1240
+ editor: (
1241
+ /*editor*/
1242
+ e[5]
1243
+ ),
1244
+ $$slots: {
1245
+ default: [
1246
+ eo,
1247
+ ({ grab: o }) => ({ 10: o }),
1248
+ ({ grab: o }) => o ? 1024 : 0
1249
+ ]
1250
+ },
1251
+ $$scope: { ctx: e }
1252
+ }
1253
+ }), t.$on(
1254
+ "change",
1255
+ /*change_handler*/
1256
+ e[7]
1257
+ ), t.$on(
1258
+ "grab",
1259
+ /*grab_handler*/
1260
+ e[8]
1261
+ ), t.$on(
1262
+ "release",
1263
+ /*release_handler*/
1264
+ e[9]
1265
+ ), {
1266
+ c() {
1267
+ pe(t.$$.fragment);
1268
+ },
1269
+ m(o, i) {
1270
+ ue(t, o, i), n = !0;
1271
+ },
1272
+ p(o, [i]) {
1273
+ const s = {};
1274
+ i & /*shape*/
1275
+ 1 && (s.shape = /*shape*/
1276
+ o[0]), i & /*transform*/
1277
+ 4 && (s.transform = /*transform*/
1278
+ o[2]), i & /*$$scope, geom, handleSize, grab, computedStyle*/
1279
+ 17434 && (s.$$scope = { dirty: i, ctx: o }), t.$set(s);
1280
+ },
1281
+ i(o) {
1282
+ n || (D(t.$$.fragment, o), n = !0);
1283
+ },
1284
+ o(o) {
1285
+ N(t.$$.fragment, o), n = !1;
1286
+ },
1287
+ d(o) {
1288
+ de(t, o);
1289
+ }
1290
+ };
1291
+ }
1292
+ const _t = (e) => e.join(","), yt = (e) => e.join(",");
1293
+ function no(e, t, n) {
1294
+ let o, i, { shape: s } = t, { computedStyle: r = void 0 } = t, { transform: l } = t, { viewportScale: a = 1 } = t;
1295
+ const d = (m, g, p) => {
1296
+ let y;
1297
+ g === M.SHAPE ? y = m.geometry.points.map(([E, k]) => [E + p[0], k + p[1]]) : y = m.geometry.points.map(([E, k], b) => g === M(b) ? [E + p[0], k + p[1]] : [E, k]);
1298
+ const L = He(y);
1299
+ return { ...m, geometry: { points: y, bounds: L } };
1300
+ };
1301
+ function h(m) {
1302
+ Ae.call(this, e, m);
1303
+ }
1304
+ function c(m) {
1305
+ Ae.call(this, e, m);
1306
+ }
1307
+ function f(m) {
1308
+ Ae.call(this, e, m);
1309
+ }
1310
+ return e.$$set = (m) => {
1311
+ "shape" in m && n(0, s = m.shape), "computedStyle" in m && n(1, r = m.computedStyle), "transform" in m && n(2, l = m.transform), "viewportScale" in m && n(6, a = m.viewportScale);
1312
+ }, e.$$.update = () => {
1313
+ e.$$.dirty & /*shape*/
1314
+ 1 && n(4, o = s.geometry), e.$$.dirty & /*viewportScale*/
1315
+ 64 && n(3, i = 10 / a);
1316
+ }, [
1317
+ s,
1318
+ r,
1319
+ l,
1320
+ i,
1321
+ o,
1322
+ d,
1323
+ a,
1324
+ h,
1325
+ c,
1326
+ f
1327
+ ];
1328
+ }
1329
+ class oo extends ne {
1330
+ constructor(t) {
1331
+ super(), te(this, t, no, to, K, {
1332
+ shape: 0,
1333
+ computedStyle: 1,
1334
+ transform: 2,
1335
+ viewportScale: 6
1336
+ });
1337
+ }
1338
+ }
1339
+ function io(e) {
1340
+ let t, n, o, i, s, r, l, a, d, h, c, f, m, g, p, y, L, E, k, b, Y, U, X, _, w, A, S, B, P, Q, ce, oe, Le, Z, I, J, H, V, ie, he, je, x, Pe, Ye, Ve, $, Re, Xe, qe, rt;
1341
+ return {
1342
+ c() {
1343
+ t = R("rect"), l = ee(), a = R("rect"), m = ee(), g = R("rect"), E = ee(), k = R("rect"), X = ee(), _ = R("rect"), B = ee(), P = R("rect"), Le = ee(), Z = R("rect"), H = ee(), V = R("rect"), je = ee(), x = R("rect"), Ve = ee(), $ = R("rect"), u(t, "class", "a9s-outer"), u(t, "style", n = /*computedStyle*/
1344
+ e[1] ? "display:none;" : void 0), u(t, "x", o = /*geom*/
1345
+ e[4].x), u(t, "y", i = /*geom*/
1346
+ e[4].y), u(t, "width", s = /*geom*/
1347
+ e[4].w), u(t, "height", r = /*geom*/
1348
+ e[4].h), u(a, "class", "a9s-inner a9s-shape-handle"), u(
1349
+ a,
1350
+ "style",
1351
+ /*computedStyle*/
1352
+ e[1]
1353
+ ), u(a, "x", d = /*geom*/
1354
+ e[4].x), u(a, "y", h = /*geom*/
1355
+ e[4].y), u(a, "width", c = /*geom*/
1356
+ e[4].w), u(a, "height", f = /*geom*/
1357
+ e[4].h), u(g, "class", "a9s-edge-handle a9s-edge-handle-top"), u(g, "x", p = /*geom*/
1358
+ e[4].x), u(g, "y", y = /*geom*/
1359
+ e[4].y), u(g, "height", 1), u(g, "width", L = /*geom*/
1360
+ e[4].w), u(k, "class", "a9s-edge-handle a9s-edge-handle-right"), u(k, "x", b = /*geom*/
1361
+ e[4].x + /*geom*/
1362
+ e[4].w), u(k, "y", Y = /*geom*/
1363
+ e[4].y), u(k, "height", U = /*geom*/
1364
+ e[4].h), u(k, "width", 1), u(_, "class", "a9s-edge-handle a9s-edge-handle-bottom"), u(_, "x", w = /*geom*/
1365
+ e[4].x), u(_, "y", A = /*geom*/
1366
+ e[4].y + /*geom*/
1367
+ e[4].h), u(_, "height", 1), u(_, "width", S = /*geom*/
1368
+ e[4].w), u(P, "class", "a9s-edge-handle a9s-edge-handle-left"), u(P, "x", Q = /*geom*/
1369
+ e[4].x), u(P, "y", ce = /*geom*/
1370
+ e[4].y), u(P, "height", oe = /*geom*/
1371
+ e[4].h), u(P, "width", 1), u(Z, "class", "a9s-corner-handle a9s-corner-handle-topleft"), u(Z, "x", I = /*geom*/
1372
+ e[4].x - /*handleSize*/
1373
+ e[3] / 2), u(Z, "y", J = /*geom*/
1374
+ e[4].y - /*handleSize*/
1375
+ e[3] / 2), u(
1376
+ Z,
1377
+ "height",
1378
+ /*handleSize*/
1379
+ e[3]
1380
+ ), u(
1381
+ Z,
1382
+ "width",
1383
+ /*handleSize*/
1384
+ e[3]
1385
+ ), u(V, "class", "a9s-corner-handle a9s-corner-handle-topright"), u(V, "x", ie = /*geom*/
1386
+ e[4].x + /*geom*/
1387
+ e[4].w - /*handleSize*/
1388
+ e[3] / 2), u(V, "y", he = /*geom*/
1389
+ e[4].y - /*handleSize*/
1390
+ e[3] / 2), u(
1391
+ V,
1392
+ "height",
1393
+ /*handleSize*/
1394
+ e[3]
1395
+ ), u(
1396
+ V,
1397
+ "width",
1398
+ /*handleSize*/
1399
+ e[3]
1400
+ ), u(x, "class", "a9s-corner-handle a9s-corner-handle-bottomright"), u(x, "x", Pe = /*geom*/
1401
+ e[4].x + /*geom*/
1402
+ e[4].w - /*handleSize*/
1403
+ e[3] / 2), u(x, "y", Ye = /*geom*/
1404
+ e[4].y + /*geom*/
1405
+ e[4].h - /*handleSize*/
1406
+ e[3] / 2), u(
1407
+ x,
1408
+ "height",
1409
+ /*handleSize*/
1410
+ e[3]
1411
+ ), u(
1412
+ x,
1413
+ "width",
1414
+ /*handleSize*/
1415
+ e[3]
1416
+ ), u($, "class", "a9s-corner-handle a9s-corner-handle-bottomleft"), u($, "x", Re = /*geom*/
1417
+ e[4].x - /*handleSize*/
1418
+ e[3] / 2), u($, "y", Xe = /*geom*/
1419
+ e[4].y + /*geom*/
1420
+ e[4].h - /*handleSize*/
1421
+ e[3] / 2), u(
1422
+ $,
1423
+ "height",
1424
+ /*handleSize*/
1425
+ e[3]
1426
+ ), u(
1427
+ $,
1428
+ "width",
1429
+ /*handleSize*/
1430
+ e[3]
1431
+ );
1432
+ },
1433
+ m(C, T) {
1434
+ v(C, t, T), v(C, l, T), v(C, a, T), v(C, m, T), v(C, g, T), v(C, E, T), v(C, k, T), v(C, X, T), v(C, _, T), v(C, B, T), v(C, P, T), v(C, Le, T), v(C, Z, T), v(C, H, T), v(C, V, T), v(C, je, T), v(C, x, T), v(C, Ve, T), v(C, $, T), qe || (rt = [
1435
+ W(t, "pointerdown", function() {
1436
+ j(
1437
+ /*grab*/
1438
+ e[10](M.SHAPE)
1439
+ ) && e[10](M.SHAPE).apply(this, arguments);
1440
+ }),
1441
+ W(a, "pointerdown", function() {
1442
+ j(
1443
+ /*grab*/
1444
+ e[10](M.SHAPE)
1445
+ ) && e[10](M.SHAPE).apply(this, arguments);
1446
+ }),
1447
+ W(g, "pointerdown", function() {
1448
+ j(
1449
+ /*grab*/
1450
+ e[10](M.TOP)
1451
+ ) && e[10](M.TOP).apply(this, arguments);
1452
+ }),
1453
+ W(k, "pointerdown", function() {
1454
+ j(
1455
+ /*grab*/
1456
+ e[10](M.RIGHT)
1457
+ ) && e[10](M.RIGHT).apply(this, arguments);
1458
+ }),
1459
+ W(_, "pointerdown", function() {
1460
+ j(
1461
+ /*grab*/
1462
+ e[10](M.BOTTOM)
1463
+ ) && e[10](M.BOTTOM).apply(this, arguments);
1464
+ }),
1465
+ W(P, "pointerdown", function() {
1466
+ j(
1467
+ /*grab*/
1468
+ e[10](M.LEFT)
1469
+ ) && e[10](M.LEFT).apply(this, arguments);
1470
+ }),
1471
+ W(Z, "pointerdown", function() {
1472
+ j(
1473
+ /*grab*/
1474
+ e[10](M.TOP_LEFT)
1475
+ ) && e[10](M.TOP_LEFT).apply(this, arguments);
1476
+ }),
1477
+ W(V, "pointerdown", function() {
1478
+ j(
1479
+ /*grab*/
1480
+ e[10](M.TOP_RIGHT)
1481
+ ) && e[10](M.TOP_RIGHT).apply(this, arguments);
1482
+ }),
1483
+ W(x, "pointerdown", function() {
1484
+ j(
1485
+ /*grab*/
1486
+ e[10](M.BOTTOM_RIGHT)
1487
+ ) && e[10](M.BOTTOM_RIGHT).apply(this, arguments);
1488
+ }),
1489
+ W($, "pointerdown", function() {
1490
+ j(
1491
+ /*grab*/
1492
+ e[10](M.BOTTOM_LEFT)
1493
+ ) && e[10](M.BOTTOM_LEFT).apply(this, arguments);
1494
+ })
1495
+ ], qe = !0);
1496
+ },
1497
+ p(C, T) {
1498
+ e = C, T & /*computedStyle*/
1499
+ 2 && n !== (n = /*computedStyle*/
1500
+ e[1] ? "display:none;" : void 0) && u(t, "style", n), T & /*geom*/
1501
+ 16 && o !== (o = /*geom*/
1502
+ e[4].x) && u(t, "x", o), T & /*geom*/
1503
+ 16 && i !== (i = /*geom*/
1504
+ e[4].y) && u(t, "y", i), T & /*geom*/
1505
+ 16 && s !== (s = /*geom*/
1506
+ e[4].w) && u(t, "width", s), T & /*geom*/
1507
+ 16 && r !== (r = /*geom*/
1508
+ e[4].h) && u(t, "height", r), T & /*computedStyle*/
1509
+ 2 && u(
1510
+ a,
1511
+ "style",
1512
+ /*computedStyle*/
1513
+ e[1]
1514
+ ), T & /*geom*/
1515
+ 16 && d !== (d = /*geom*/
1516
+ e[4].x) && u(a, "x", d), T & /*geom*/
1517
+ 16 && h !== (h = /*geom*/
1518
+ e[4].y) && u(a, "y", h), T & /*geom*/
1519
+ 16 && c !== (c = /*geom*/
1520
+ e[4].w) && u(a, "width", c), T & /*geom*/
1521
+ 16 && f !== (f = /*geom*/
1522
+ e[4].h) && u(a, "height", f), T & /*geom*/
1523
+ 16 && p !== (p = /*geom*/
1524
+ e[4].x) && u(g, "x", p), T & /*geom*/
1525
+ 16 && y !== (y = /*geom*/
1526
+ e[4].y) && u(g, "y", y), T & /*geom*/
1527
+ 16 && L !== (L = /*geom*/
1528
+ e[4].w) && u(g, "width", L), T & /*geom*/
1529
+ 16 && b !== (b = /*geom*/
1530
+ e[4].x + /*geom*/
1531
+ e[4].w) && u(k, "x", b), T & /*geom*/
1532
+ 16 && Y !== (Y = /*geom*/
1533
+ e[4].y) && u(k, "y", Y), T & /*geom*/
1534
+ 16 && U !== (U = /*geom*/
1535
+ e[4].h) && u(k, "height", U), T & /*geom*/
1536
+ 16 && w !== (w = /*geom*/
1537
+ e[4].x) && u(_, "x", w), T & /*geom*/
1538
+ 16 && A !== (A = /*geom*/
1539
+ e[4].y + /*geom*/
1540
+ e[4].h) && u(_, "y", A), T & /*geom*/
1541
+ 16 && S !== (S = /*geom*/
1542
+ e[4].w) && u(_, "width", S), T & /*geom*/
1543
+ 16 && Q !== (Q = /*geom*/
1544
+ e[4].x) && u(P, "x", Q), T & /*geom*/
1545
+ 16 && ce !== (ce = /*geom*/
1546
+ e[4].y) && u(P, "y", ce), T & /*geom*/
1547
+ 16 && oe !== (oe = /*geom*/
1548
+ e[4].h) && u(P, "height", oe), T & /*geom, handleSize*/
1549
+ 24 && I !== (I = /*geom*/
1550
+ e[4].x - /*handleSize*/
1551
+ e[3] / 2) && u(Z, "x", I), T & /*geom, handleSize*/
1552
+ 24 && J !== (J = /*geom*/
1553
+ e[4].y - /*handleSize*/
1554
+ e[3] / 2) && u(Z, "y", J), T & /*handleSize*/
1555
+ 8 && u(
1556
+ Z,
1557
+ "height",
1558
+ /*handleSize*/
1559
+ e[3]
1560
+ ), T & /*handleSize*/
1561
+ 8 && u(
1562
+ Z,
1563
+ "width",
1564
+ /*handleSize*/
1565
+ e[3]
1566
+ ), T & /*geom, handleSize*/
1567
+ 24 && ie !== (ie = /*geom*/
1568
+ e[4].x + /*geom*/
1569
+ e[4].w - /*handleSize*/
1570
+ e[3] / 2) && u(V, "x", ie), T & /*geom, handleSize*/
1571
+ 24 && he !== (he = /*geom*/
1572
+ e[4].y - /*handleSize*/
1573
+ e[3] / 2) && u(V, "y", he), T & /*handleSize*/
1574
+ 8 && u(
1575
+ V,
1576
+ "height",
1577
+ /*handleSize*/
1578
+ e[3]
1579
+ ), T & /*handleSize*/
1580
+ 8 && u(
1581
+ V,
1582
+ "width",
1583
+ /*handleSize*/
1584
+ e[3]
1585
+ ), T & /*geom, handleSize*/
1586
+ 24 && Pe !== (Pe = /*geom*/
1587
+ e[4].x + /*geom*/
1588
+ e[4].w - /*handleSize*/
1589
+ e[3] / 2) && u(x, "x", Pe), T & /*geom, handleSize*/
1590
+ 24 && Ye !== (Ye = /*geom*/
1591
+ e[4].y + /*geom*/
1592
+ e[4].h - /*handleSize*/
1593
+ e[3] / 2) && u(x, "y", Ye), T & /*handleSize*/
1594
+ 8 && u(
1595
+ x,
1596
+ "height",
1597
+ /*handleSize*/
1598
+ e[3]
1599
+ ), T & /*handleSize*/
1600
+ 8 && u(
1601
+ x,
1602
+ "width",
1603
+ /*handleSize*/
1604
+ e[3]
1605
+ ), T & /*geom, handleSize*/
1606
+ 24 && Re !== (Re = /*geom*/
1607
+ e[4].x - /*handleSize*/
1608
+ e[3] / 2) && u($, "x", Re), T & /*geom, handleSize*/
1609
+ 24 && Xe !== (Xe = /*geom*/
1610
+ e[4].y + /*geom*/
1611
+ e[4].h - /*handleSize*/
1612
+ e[3] / 2) && u($, "y", Xe), T & /*handleSize*/
1613
+ 8 && u(
1614
+ $,
1615
+ "height",
1616
+ /*handleSize*/
1617
+ e[3]
1618
+ ), T & /*handleSize*/
1619
+ 8 && u(
1620
+ $,
1621
+ "width",
1622
+ /*handleSize*/
1623
+ e[3]
1624
+ );
1625
+ },
1626
+ d(C) {
1627
+ C && O(t), C && O(l), C && O(a), C && O(m), C && O(g), C && O(E), C && O(k), C && O(X), C && O(_), C && O(B), C && O(P), C && O(Le), C && O(Z), C && O(H), C && O(V), C && O(je), C && O(x), C && O(Ve), C && O($), qe = !1, le(rt);
1628
+ }
1629
+ };
1630
+ }
1631
+ function so(e) {
1632
+ let t, n;
1633
+ return t = new jt({
1634
+ props: {
1635
+ shape: (
1636
+ /*shape*/
1637
+ e[0]
1638
+ ),
1639
+ transform: (
1640
+ /*transform*/
1641
+ e[2]
1642
+ ),
1643
+ editor: (
1644
+ /*editor*/
1645
+ e[5]
1646
+ ),
1647
+ $$slots: {
1648
+ default: [
1649
+ io,
1650
+ ({ grab: o }) => ({ 10: o }),
1651
+ ({ grab: o }) => o ? 1024 : 0
1652
+ ]
1653
+ },
1654
+ $$scope: { ctx: e }
1655
+ }
1656
+ }), t.$on(
1657
+ "grab",
1658
+ /*grab_handler*/
1659
+ e[7]
1660
+ ), t.$on(
1661
+ "change",
1662
+ /*change_handler*/
1663
+ e[8]
1664
+ ), t.$on(
1665
+ "release",
1666
+ /*release_handler*/
1667
+ e[9]
1668
+ ), {
1669
+ c() {
1670
+ pe(t.$$.fragment);
1671
+ },
1672
+ m(o, i) {
1673
+ ue(t, o, i), n = !0;
1674
+ },
1675
+ p(o, [i]) {
1676
+ const s = {};
1677
+ i & /*shape*/
1678
+ 1 && (s.shape = /*shape*/
1679
+ o[0]), i & /*transform*/
1680
+ 4 && (s.transform = /*transform*/
1681
+ o[2]), i & /*$$scope, geom, handleSize, grab, computedStyle*/
1682
+ 3098 && (s.$$scope = { dirty: i, ctx: o }), t.$set(s);
1683
+ },
1684
+ i(o) {
1685
+ n || (D(t.$$.fragment, o), n = !0);
1686
+ },
1687
+ o(o) {
1688
+ N(t.$$.fragment, o), n = !1;
1689
+ },
1690
+ d(o) {
1691
+ de(t, o);
1692
+ }
1693
+ };
1694
+ }
1695
+ function ro(e, t, n) {
1696
+ let o, i, { shape: s } = t, { computedStyle: r = void 0 } = t, { transform: l } = t, { viewportScale: a = 1 } = t;
1697
+ const d = (m, g, p) => {
1698
+ const y = m.geometry.bounds;
1699
+ let [L, E] = [y.minX, y.minY], [k, b] = [y.maxX, y.maxY];
1700
+ const [Y, U] = p;
1701
+ if (g === M.SHAPE)
1702
+ L += Y, k += Y, E += U, b += U;
1703
+ else {
1704
+ switch (g) {
1705
+ case M.TOP:
1706
+ case M.TOP_LEFT:
1707
+ case M.TOP_RIGHT: {
1708
+ E += U;
1709
+ break;
1710
+ }
1711
+ case M.BOTTOM:
1712
+ case M.BOTTOM_LEFT:
1713
+ case M.BOTTOM_RIGHT: {
1714
+ b += U;
1715
+ break;
1716
+ }
1717
+ }
1718
+ switch (g) {
1719
+ case M.LEFT:
1720
+ case M.TOP_LEFT:
1721
+ case M.BOTTOM_LEFT: {
1722
+ L += Y;
1723
+ break;
1724
+ }
1725
+ case M.RIGHT:
1726
+ case M.TOP_RIGHT:
1727
+ case M.BOTTOM_RIGHT: {
1728
+ k += Y;
1729
+ break;
1730
+ }
1731
+ }
1732
+ }
1733
+ const X = Math.min(L, k), _ = Math.min(E, b), w = Math.abs(k - L), A = Math.abs(b - E);
1734
+ return {
1735
+ ...m,
1736
+ geometry: {
1737
+ x: X,
1738
+ y: _,
1739
+ w,
1740
+ h: A,
1741
+ bounds: {
1742
+ minX: X,
1743
+ minY: _,
1744
+ maxX: X + w,
1745
+ maxY: _ + A
1746
+ }
1747
+ }
1748
+ };
1749
+ };
1750
+ function h(m) {
1751
+ Ae.call(this, e, m);
1752
+ }
1753
+ function c(m) {
1754
+ Ae.call(this, e, m);
1755
+ }
1756
+ function f(m) {
1757
+ Ae.call(this, e, m);
1758
+ }
1759
+ return e.$$set = (m) => {
1760
+ "shape" in m && n(0, s = m.shape), "computedStyle" in m && n(1, r = m.computedStyle), "transform" in m && n(2, l = m.transform), "viewportScale" in m && n(6, a = m.viewportScale);
1761
+ }, e.$$.update = () => {
1762
+ e.$$.dirty & /*shape*/
1763
+ 1 && n(4, o = s.geometry), e.$$.dirty & /*viewportScale*/
1764
+ 64 && n(3, i = 10 / a);
1765
+ }, [
1766
+ s,
1767
+ r,
1768
+ l,
1769
+ i,
1770
+ o,
1771
+ d,
1772
+ a,
1773
+ h,
1774
+ c,
1775
+ f
1776
+ ];
1777
+ }
1778
+ class lo extends ne {
1779
+ constructor(t) {
1780
+ super(), te(this, t, ro, so, K, {
1781
+ shape: 0,
1782
+ computedStyle: 1,
1783
+ transform: 2,
1784
+ viewportScale: 6
1785
+ });
1786
+ }
1787
+ }
1788
+ const zt = /* @__PURE__ */ new Map([
1789
+ [z.RECTANGLE, lo],
1790
+ [z.POLYGON, oo]
1791
+ ]), wt = (e) => zt.get(e.type), ao = (e, t) => zt.set(e, t), M = (e) => `HANDLE-${e}`;
1792
+ M.SHAPE = "SHAPE";
1793
+ M.TOP = "TOP";
1794
+ M.RIGHT = "RIGHT";
1795
+ M.BOTTOM = "BOTTOM";
1796
+ M.LEFT = "LEFT";
1797
+ M.TOP_LEFT = "TOP_LEFT";
1798
+ M.TOP_RIGHT = "TOP_RIGHT";
1799
+ M.BOTTOM_RIGHT = "BOTTOM_RIGHT";
1800
+ M.BOTTOM_LEFT = "BOTTOM_LEFT";
1801
+ const co = (e) => ({}), bt = (e) => ({ grab: (
1802
+ /*onGrab*/
1803
+ e[0]
1804
+ ) });
1805
+ function fo(e) {
1806
+ let t, n, o, i;
1807
+ const s = (
1808
+ /*#slots*/
1809
+ e[7].default
1810
+ ), r = Qt(
1811
+ s,
1812
+ e,
1813
+ /*$$scope*/
1814
+ e[6],
1815
+ bt
1816
+ );
1817
+ return {
1818
+ c() {
1819
+ t = R("g"), r && r.c(), u(t, "class", "a9s-annotation selected");
1820
+ },
1821
+ m(l, a) {
1822
+ v(l, t, a), r && r.m(t, null), n = !0, o || (i = [
1823
+ W(
1824
+ t,
1825
+ "pointerup",
1826
+ /*onRelease*/
1827
+ e[2]
1828
+ ),
1829
+ W(
1830
+ t,
1831
+ "pointermove",
1832
+ /*onPointerMove*/
1833
+ e[1]
1834
+ )
1835
+ ], o = !0);
1836
+ },
1837
+ p(l, [a]) {
1838
+ r && r.p && (!n || a & /*$$scope*/
1839
+ 64) && Kt(
1840
+ r,
1841
+ s,
1842
+ l,
1843
+ /*$$scope*/
1844
+ l[6],
1845
+ n ? Zt(
1846
+ s,
1847
+ /*$$scope*/
1848
+ l[6],
1849
+ a,
1850
+ co
1851
+ ) : xt(
1852
+ /*$$scope*/
1853
+ l[6]
1854
+ ),
1855
+ bt
1856
+ );
1857
+ },
1858
+ i(l) {
1859
+ n || (D(r, l), n = !0);
1860
+ },
1861
+ o(l) {
1862
+ N(r, l), n = !1;
1863
+ },
1864
+ d(l) {
1865
+ l && O(t), r && r.d(l), o = !1, le(i);
1866
+ }
1867
+ };
1868
+ }
1869
+ function uo(e, t, n) {
1870
+ let { $$slots: o = {}, $$scope: i } = t;
1871
+ const s = Me();
1872
+ let { shape: r } = t, { editor: l } = t, { transform: a } = t, d = null, h, c = null;
1873
+ const f = (p) => (y) => {
1874
+ d = p, h = a.elementToImage(y.offsetX, y.offsetY), c = r, y.target.setPointerCapture(y.pointerId), s("grab");
1875
+ }, m = (p) => {
1876
+ if (d) {
1877
+ const [y, L] = a.elementToImage(p.offsetX, p.offsetY), E = [y - h[0], L - h[1]];
1878
+ n(3, r = l(c, d, E)), s("change", r);
1879
+ }
1880
+ }, g = (p) => {
1881
+ p.target.releasePointerCapture(p.pointerId), d = null, c = r, s("release");
1882
+ };
1883
+ return e.$$set = (p) => {
1884
+ "shape" in p && n(3, r = p.shape), "editor" in p && n(4, l = p.editor), "transform" in p && n(5, a = p.transform), "$$scope" in p && n(6, i = p.$$scope);
1885
+ }, [f, m, g, r, l, a, i, o];
1886
+ }
1887
+ class jt extends ne {
1888
+ constructor(t) {
1889
+ super(), te(this, t, uo, fo, K, { shape: 3, editor: 4, transform: 5 });
1890
+ }
1891
+ }
1892
+ const ze = (e, t) => {
1893
+ const n = typeof t == "function" ? t(e) : t;
1894
+ if (n) {
1895
+ const { fill: o, fillOpacity: i } = n;
1896
+ let s = "";
1897
+ return o && (s += `fill:${o};stroke:${o};`), s += `fill-opacity:${i || "0.25"};`, s;
1898
+ }
1899
+ };
1900
+ function ho(e, t, n) {
1901
+ let o;
1902
+ const i = Me();
1903
+ let { annotation: s } = t, { editor: r } = t, { style: l = void 0 } = t, { target: a } = t, { transform: d } = t, { viewportScale: h } = t, c;
1904
+ return Ce(() => (n(6, c = new r({
1905
+ target: a,
1906
+ props: {
1907
+ shape: s.target.selector,
1908
+ computedStyle: o,
1909
+ transform: d,
1910
+ viewportScale: h
1911
+ }
1912
+ })), c.$on("change", (f) => {
1913
+ c.$$set({ shape: f.detail }), i("change", f.detail);
1914
+ }), c.$on("grab", (f) => i("grab", f.detail)), c.$on("release", (f) => i("release", f.detail)), () => {
1915
+ c.$destroy();
1916
+ })), e.$$set = (f) => {
1917
+ "annotation" in f && n(0, s = f.annotation), "editor" in f && n(1, r = f.editor), "style" in f && n(2, l = f.style), "target" in f && n(3, a = f.target), "transform" in f && n(4, d = f.transform), "viewportScale" in f && n(5, h = f.viewportScale);
1918
+ }, e.$$.update = () => {
1919
+ e.$$.dirty & /*annotation, style*/
1920
+ 5 && (o = ze(s, l)), e.$$.dirty & /*editorComponent, transform*/
1921
+ 80 && c && c.$set({ transform: d }), e.$$.dirty & /*editorComponent, viewportScale*/
1922
+ 96 && c && c.$set({ viewportScale: h });
1923
+ }, [s, r, l, a, d, h, c];
1924
+ }
1925
+ class mo extends ne {
1926
+ constructor(t) {
1927
+ super(), te(this, t, ho, null, K, {
1928
+ annotation: 0,
1929
+ editor: 1,
1930
+ style: 2,
1931
+ target: 3,
1932
+ transform: 4,
1933
+ viewportScale: 5
1934
+ });
1935
+ }
1936
+ }
1937
+ function go(e, t, n) {
1938
+ const o = Me();
1939
+ let { drawingMode: i } = t, { target: s } = t, { tool: r } = t, { transform: l } = t, { viewportScale: a } = t, d;
1940
+ return Ce(() => {
1941
+ const h = s.closest("svg"), c = [], f = (m, g, p) => {
1942
+ h.addEventListener(m, g, p), c.push(() => h.removeEventListener(m, g, p));
1943
+ };
1944
+ return n(5, d = new r({
1945
+ target: s,
1946
+ props: {
1947
+ addEventListener: f,
1948
+ drawingMode: i,
1949
+ transform: l,
1950
+ viewportScale: a
1951
+ }
1952
+ })), d.$on("create", (m) => o("create", m.detail)), () => {
1953
+ c.forEach((m) => m()), d.$destroy();
1954
+ };
1955
+ }), e.$$set = (h) => {
1956
+ "drawingMode" in h && n(0, i = h.drawingMode), "target" in h && n(1, s = h.target), "tool" in h && n(2, r = h.tool), "transform" in h && n(3, l = h.transform), "viewportScale" in h && n(4, a = h.viewportScale);
1957
+ }, e.$$.update = () => {
1958
+ e.$$.dirty & /*toolComponent, transform*/
1959
+ 40 && d && d.$set({ transform: l }), e.$$.dirty & /*toolComponent, viewportScale*/
1960
+ 48 && d && d.$set({ viewportScale: a });
1961
+ }, [i, s, r, l, a, d];
1962
+ }
1963
+ class po extends ne {
1964
+ constructor(t) {
1965
+ super(), te(this, t, go, null, K, {
1966
+ drawingMode: 0,
1967
+ target: 1,
1968
+ tool: 2,
1969
+ transform: 3,
1970
+ viewportScale: 4
1971
+ });
1972
+ }
1973
+ }
1974
+ function Et(e) {
1975
+ let t, n;
1976
+ return {
1977
+ c() {
1978
+ t = R("rect"), n = R("rect"), u(t, "class", "a9s-outer"), u(
1979
+ t,
1980
+ "x",
1981
+ /*x*/
1982
+ e[2]
1983
+ ), u(
1984
+ t,
1985
+ "y",
1986
+ /*y*/
1987
+ e[3]
1988
+ ), u(
1989
+ t,
1990
+ "width",
1991
+ /*w*/
1992
+ e[4]
1993
+ ), u(
1994
+ t,
1995
+ "height",
1996
+ /*h*/
1997
+ e[5]
1998
+ ), u(n, "class", "a9s-inner"), u(
1999
+ n,
2000
+ "x",
2001
+ /*x*/
2002
+ e[2]
2003
+ ), u(
2004
+ n,
2005
+ "y",
2006
+ /*y*/
2007
+ e[3]
2008
+ ), u(
2009
+ n,
2010
+ "width",
2011
+ /*w*/
2012
+ e[4]
2013
+ ), u(
2014
+ n,
2015
+ "height",
2016
+ /*h*/
2017
+ e[5]
2018
+ );
2019
+ },
2020
+ m(o, i) {
2021
+ v(o, t, i), v(o, n, i);
2022
+ },
2023
+ p(o, i) {
2024
+ i & /*x*/
2025
+ 4 && u(
2026
+ t,
2027
+ "x",
2028
+ /*x*/
2029
+ o[2]
2030
+ ), i & /*y*/
2031
+ 8 && u(
2032
+ t,
2033
+ "y",
2034
+ /*y*/
2035
+ o[3]
2036
+ ), i & /*w*/
2037
+ 16 && u(
2038
+ t,
2039
+ "width",
2040
+ /*w*/
2041
+ o[4]
2042
+ ), i & /*h*/
2043
+ 32 && u(
2044
+ t,
2045
+ "height",
2046
+ /*h*/
2047
+ o[5]
2048
+ ), i & /*x*/
2049
+ 4 && u(
2050
+ n,
2051
+ "x",
2052
+ /*x*/
2053
+ o[2]
2054
+ ), i & /*y*/
2055
+ 8 && u(
2056
+ n,
2057
+ "y",
2058
+ /*y*/
2059
+ o[3]
2060
+ ), i & /*w*/
2061
+ 16 && u(
2062
+ n,
2063
+ "width",
2064
+ /*w*/
2065
+ o[4]
2066
+ ), i & /*h*/
2067
+ 32 && u(
2068
+ n,
2069
+ "height",
2070
+ /*h*/
2071
+ o[5]
2072
+ );
2073
+ },
2074
+ d(o) {
2075
+ o && O(t), o && O(n);
2076
+ }
2077
+ };
2078
+ }
2079
+ function _o(e) {
2080
+ let t, n = (
2081
+ /*origin*/
2082
+ e[1] && Et(e)
2083
+ );
2084
+ return {
2085
+ c() {
2086
+ t = R("g"), n && n.c(), u(t, "class", "a9s-annotation a9s-rubberband");
2087
+ },
2088
+ m(o, i) {
2089
+ v(o, t, i), n && n.m(t, null), e[9](t);
2090
+ },
2091
+ p(o, [i]) {
2092
+ /*origin*/
2093
+ o[1] ? n ? n.p(o, i) : (n = Et(o), n.c(), n.m(t, null)) : n && (n.d(1), n = null);
2094
+ },
2095
+ i: G,
2096
+ o: G,
2097
+ d(o) {
2098
+ o && O(t), n && n.d(), e[9](null);
2099
+ }
2100
+ };
2101
+ }
2102
+ function yo(e, t, n) {
2103
+ const o = Me();
2104
+ let { addEventListener: i } = t, { drawingMode: s } = t, { transform: r } = t, l, a, d, h, c, f, m, g;
2105
+ const p = (b) => {
2106
+ a = performance.now(), s === "drag" && (n(1, d = r.elementToImage(b.offsetX, b.offsetY)), h = d, n(2, c = d[0]), n(3, f = d[1]), n(4, m = 1), n(5, g = 1));
2107
+ }, y = (b) => {
2108
+ d && (h = r.elementToImage(b.offsetX, b.offsetY), n(2, c = Math.min(h[0], d[0])), n(3, f = Math.min(h[1], d[1])), n(4, m = Math.abs(h[0] - d[0])), n(5, g = Math.abs(h[1] - d[1])));
2109
+ }, L = (b) => {
2110
+ const Y = performance.now() - a;
2111
+ if (s === "click") {
2112
+ if (Y > 300)
2113
+ return;
2114
+ b.stopPropagation(), d ? E() : (n(1, d = r.elementToImage(b.offsetX, b.offsetY)), h = d, n(2, c = d[0]), n(3, f = d[1]), n(4, m = 1), n(5, g = 1));
2115
+ } else
2116
+ d && (Y > 300 || m * g > 100 ? (b.stopPropagation(), E()) : (n(1, d = null), h = null));
2117
+ }, E = () => {
2118
+ if (m * g > 15) {
2119
+ const b = {
2120
+ type: z.RECTANGLE,
2121
+ geometry: {
2122
+ bounds: {
2123
+ minX: c,
2124
+ minY: f,
2125
+ maxX: c + m,
2126
+ maxY: f + g
2127
+ },
2128
+ x: c,
2129
+ y: f,
2130
+ w: m,
2131
+ h: g
2132
+ }
2133
+ };
2134
+ o("create", b);
2135
+ }
2136
+ n(1, d = null), h = null;
2137
+ };
2138
+ Ce(() => {
2139
+ i("pointerdown", p), i("pointermove", y), i("pointerup", L, !0);
2140
+ });
2141
+ function k(b) {
2142
+ Se[b ? "unshift" : "push"](() => {
2143
+ l = b, n(0, l);
2144
+ });
2145
+ }
2146
+ return e.$$set = (b) => {
2147
+ "addEventListener" in b && n(6, i = b.addEventListener), "drawingMode" in b && n(7, s = b.drawingMode), "transform" in b && n(8, r = b.transform);
2148
+ }, [
2149
+ l,
2150
+ d,
2151
+ c,
2152
+ f,
2153
+ m,
2154
+ g,
2155
+ i,
2156
+ s,
2157
+ r,
2158
+ k
2159
+ ];
2160
+ }
2161
+ class wo extends ne {
2162
+ constructor(t) {
2163
+ super(), te(this, t, yo, _o, K, {
2164
+ addEventListener: 6,
2165
+ drawingMode: 7,
2166
+ transform: 8
2167
+ });
2168
+ }
2169
+ }
2170
+ const At = (e, t) => {
2171
+ const n = Math.abs(t[0] - e[0]), o = Math.abs(t[1] - e[1]);
2172
+ return Math.sqrt(Math.pow(n, 2) + Math.pow(o, 2));
2173
+ }, bo = (e, t) => {
2174
+ const { naturalWidth: n, naturalHeight: o } = e;
2175
+ if (!n && !o) {
2176
+ const { width: i, height: s } = e;
2177
+ t.setAttribute("viewBox", `0 0 ${i} ${s}`), e.addEventListener("load", (r) => {
2178
+ const l = r.target;
2179
+ t.setAttribute("viewBox", `0 0 ${l.naturalWidth} ${l.naturalHeight}`);
2180
+ });
2181
+ } else
2182
+ t.setAttribute("viewBox", `0 0 ${n} ${o}`);
2183
+ }, Eo = (e, t) => {
2184
+ bo(e, t);
2185
+ const { subscribe: n, set: o } = Fe(1);
2186
+ let i;
2187
+ return window.ResizeObserver && (i = new ResizeObserver(() => {
2188
+ const r = t.getBoundingClientRect(), { width: l, height: a } = t.viewBox.baseVal, d = Math.max(
2189
+ r.width / l,
2190
+ r.height / a
2191
+ );
2192
+ o(d);
2193
+ }), i.observe(t.parentElement)), { destroy: () => {
2194
+ i && i.disconnect();
2195
+ }, subscribe: n };
2196
+ }, _i = "ontouchstart" in window || navigator.maxTouchPoints > 0;
2197
+ function Qe(e) {
2198
+ const t = e.slice(), n = (
2199
+ /*isClosable*/
2200
+ (t[3] ? (
2201
+ /*points*/
2202
+ t[1]
2203
+ ) : [
2204
+ .../*points*/
2205
+ t[1],
2206
+ /*cursor*/
2207
+ t[2]
2208
+ ]).map((o) => o.join(",")).join(" ")
2209
+ );
2210
+ return t[17] = n, t;
2211
+ }
2212
+ function Tt(e) {
2213
+ let t, n, o, i, s, r = (
2214
+ /*isClosable*/
2215
+ e[3] && St(e)
2216
+ );
2217
+ return {
2218
+ c() {
2219
+ t = R("polygon"), o = R("polygon"), r && r.c(), s = ae(), u(t, "class", "a9s-outer"), u(t, "points", n = /*coords*/
2220
+ e[17]), u(o, "class", "a9s-inner"), u(o, "points", i = /*coords*/
2221
+ e[17]);
2222
+ },
2223
+ m(l, a) {
2224
+ v(l, t, a), v(l, o, a), r && r.m(l, a), v(l, s, a);
2225
+ },
2226
+ p(l, a) {
2227
+ a & /*isClosable, points, cursor*/
2228
+ 14 && n !== (n = /*coords*/
2229
+ l[17]) && u(t, "points", n), a & /*isClosable, points, cursor*/
2230
+ 14 && i !== (i = /*coords*/
2231
+ l[17]) && u(o, "points", i), /*isClosable*/
2232
+ l[3] ? r ? r.p(l, a) : (r = St(l), r.c(), r.m(s.parentNode, s)) : r && (r.d(1), r = null);
2233
+ },
2234
+ d(l) {
2235
+ l && O(t), l && O(o), r && r.d(l), l && O(s);
2236
+ }
2237
+ };
2238
+ }
2239
+ function St(e) {
2240
+ let t, n, o;
2241
+ return {
2242
+ c() {
2243
+ t = R("rect"), u(t, "class", "a9s-corner-handle"), u(t, "x", n = /*points*/
2244
+ e[1][0][0] - /*handleSize*/
2245
+ e[4] / 2), u(t, "y", o = /*points*/
2246
+ e[1][0][1] - /*handleSize*/
2247
+ e[4] / 2), u(
2248
+ t,
2249
+ "height",
2250
+ /*handleSize*/
2251
+ e[4]
2252
+ ), u(
2253
+ t,
2254
+ "width",
2255
+ /*handleSize*/
2256
+ e[4]
2257
+ );
2258
+ },
2259
+ m(i, s) {
2260
+ v(i, t, s);
2261
+ },
2262
+ p(i, s) {
2263
+ s & /*points, handleSize*/
2264
+ 18 && n !== (n = /*points*/
2265
+ i[1][0][0] - /*handleSize*/
2266
+ i[4] / 2) && u(t, "x", n), s & /*points, handleSize*/
2267
+ 18 && o !== (o = /*points*/
2268
+ i[1][0][1] - /*handleSize*/
2269
+ i[4] / 2) && u(t, "y", o), s & /*handleSize*/
2270
+ 16 && u(
2271
+ t,
2272
+ "height",
2273
+ /*handleSize*/
2274
+ i[4]
2275
+ ), s & /*handleSize*/
2276
+ 16 && u(
2277
+ t,
2278
+ "width",
2279
+ /*handleSize*/
2280
+ i[4]
2281
+ );
2282
+ },
2283
+ d(i) {
2284
+ i && O(t);
2285
+ }
2286
+ };
2287
+ }
2288
+ function Ao(e) {
2289
+ let t, n = (
2290
+ /*cursor*/
2291
+ e[2] && Tt(Qe(e))
2292
+ );
2293
+ return {
2294
+ c() {
2295
+ t = R("g"), n && n.c(), u(t, "class", "a9s-annotation a9s-rubberband");
2296
+ },
2297
+ m(o, i) {
2298
+ v(o, t, i), n && n.m(t, null), e[9](t);
2299
+ },
2300
+ p(o, [i]) {
2301
+ /*cursor*/
2302
+ o[2] ? n ? n.p(Qe(o), i) : (n = Tt(Qe(o)), n.c(), n.m(t, null)) : n && (n.d(1), n = null);
2303
+ },
2304
+ i: G,
2305
+ o: G,
2306
+ d(o) {
2307
+ o && O(t), n && n.d(), e[9](null);
2308
+ }
2309
+ };
2310
+ }
2311
+ const To = 20;
2312
+ function So(e, t, n) {
2313
+ let o;
2314
+ const i = Me();
2315
+ let { addEventListener: s } = t, { drawingMode: r } = t, { transform: l } = t, { viewportScale: a = 1 } = t, d, h, c = [], f = null, m = !1;
2316
+ const g = (b) => {
2317
+ if (h = performance.now(), r === "drag" && c.length === 0) {
2318
+ const Y = l.elementToImage(b.offsetX, b.offsetY);
2319
+ c.push(Y), n(2, f = Y);
2320
+ }
2321
+ }, p = (b) => {
2322
+ if (c.length > 0 && (n(2, f = l.elementToImage(b.offsetX, b.offsetY)), c.length > 2)) {
2323
+ const Y = At(f, c[0]) * a;
2324
+ n(3, m = Y < To);
2325
+ }
2326
+ }, y = (b) => {
2327
+ const Y = performance.now() - h;
2328
+ if (r === "click") {
2329
+ if (Y > 300)
2330
+ return;
2331
+ if (b.stopPropagation(), m)
2332
+ E();
2333
+ else if (c.length === 0) {
2334
+ const U = l.elementToImage(b.offsetX, b.offsetY);
2335
+ c.push(U), n(2, f = U);
2336
+ } else
2337
+ c.push(f);
2338
+ } else {
2339
+ if (c.length === 1 && At(c[0], f) <= 4) {
2340
+ n(1, c = []), n(2, f = null);
2341
+ return;
2342
+ }
2343
+ b.stopImmediatePropagation(), m ? E() : c.push(f);
2344
+ }
2345
+ }, L = () => {
2346
+ console.log("dblclick");
2347
+ const b = [...c, f], Y = {
2348
+ type: z.POLYGON,
2349
+ geometry: { bounds: He(b), points: b }
2350
+ };
2351
+ n(1, c = []), n(2, f = null), i("create", Y);
2352
+ }, E = () => {
2353
+ const b = {
2354
+ type: z.POLYGON,
2355
+ geometry: {
2356
+ bounds: He(c),
2357
+ points: [...c]
2358
+ }
2359
+ };
2360
+ n(1, c = []), n(2, f = null), i("create", b);
2361
+ };
2362
+ Ce(() => {
2363
+ s("pointerdown", g, !0), s("pointermove", p), s("pointerup", y, !0), s("dblclick", L, !0);
2364
+ });
2365
+ function k(b) {
2366
+ Se[b ? "unshift" : "push"](() => {
2367
+ d = b, n(0, d);
2368
+ });
2369
+ }
2370
+ return e.$$set = (b) => {
2371
+ "addEventListener" in b && n(5, s = b.addEventListener), "drawingMode" in b && n(6, r = b.drawingMode), "transform" in b && n(7, l = b.transform), "viewportScale" in b && n(8, a = b.viewportScale);
2372
+ }, e.$$.update = () => {
2373
+ e.$$.dirty & /*viewportScale*/
2374
+ 256 && n(4, o = 10 / a);
2375
+ }, [
2376
+ d,
2377
+ c,
2378
+ f,
2379
+ m,
2380
+ o,
2381
+ s,
2382
+ r,
2383
+ l,
2384
+ a,
2385
+ k
2386
+ ];
2387
+ }
2388
+ class Mo extends ne {
2389
+ constructor(t) {
2390
+ super(), te(this, t, So, Ao, K, {
2391
+ addEventListener: 5,
2392
+ drawingMode: 6,
2393
+ transform: 7,
2394
+ viewportScale: 8
2395
+ });
2396
+ }
2397
+ }
2398
+ const st = /* @__PURE__ */ new Map([
2399
+ ["rectangle", { tool: wo }],
2400
+ ["polygon", { tool: Mo }]
2401
+ ]), Lo = () => [...st.keys()], Vt = (e) => st.get(e), Oo = (e, t, n) => st.set(e, { tool: t, opts: n });
2402
+ function vo(e) {
2403
+ let t, n, o, i, s;
2404
+ return {
2405
+ c() {
2406
+ t = R("g"), n = R("ellipse"), i = R("ellipse"), u(n, "class", "a9s-outer"), u(n, "style", o = /*computedStyle*/
2407
+ e[1] ? "display:none;" : void 0), u(
2408
+ n,
2409
+ "cx",
2410
+ /*cx*/
2411
+ e[2]
2412
+ ), u(
2413
+ n,
2414
+ "cy",
2415
+ /*cy*/
2416
+ e[3]
2417
+ ), u(
2418
+ n,
2419
+ "rx",
2420
+ /*rx*/
2421
+ e[4]
2422
+ ), u(
2423
+ n,
2424
+ "ry",
2425
+ /*ry*/
2426
+ e[5]
2427
+ ), u(i, "class", "a9s-inner"), u(
2428
+ i,
2429
+ "style",
2430
+ /*computedStyle*/
2431
+ e[1]
2432
+ ), u(
2433
+ i,
2434
+ "cx",
2435
+ /*cx*/
2436
+ e[2]
2437
+ ), u(
2438
+ i,
2439
+ "cy",
2440
+ /*cy*/
2441
+ e[3]
2442
+ ), u(
2443
+ i,
2444
+ "rx",
2445
+ /*rx*/
2446
+ e[4]
2447
+ ), u(
2448
+ i,
2449
+ "ry",
2450
+ /*ry*/
2451
+ e[5]
2452
+ ), u(t, "data-id", s = /*annotation*/
2453
+ e[0].id);
2454
+ },
2455
+ m(r, l) {
2456
+ v(r, t, l), fe(t, n), fe(t, i);
2457
+ },
2458
+ p(r, [l]) {
2459
+ l & /*computedStyle*/
2460
+ 2 && o !== (o = /*computedStyle*/
2461
+ r[1] ? "display:none;" : void 0) && u(n, "style", o), l & /*computedStyle*/
2462
+ 2 && u(
2463
+ i,
2464
+ "style",
2465
+ /*computedStyle*/
2466
+ r[1]
2467
+ ), l & /*annotation*/
2468
+ 1 && s !== (s = /*annotation*/
2469
+ r[0].id) && u(t, "data-id", s);
2470
+ },
2471
+ i: G,
2472
+ o: G,
2473
+ d(r) {
2474
+ r && O(t);
2475
+ }
2476
+ };
2477
+ }
2478
+ function Bo(e, t, n) {
2479
+ let o, { annotation: i } = t, { geom: s } = t, { style: r = void 0 } = t;
2480
+ const { cx: l, cy: a, rx: d, ry: h } = s;
2481
+ return e.$$set = (c) => {
2482
+ "annotation" in c && n(0, i = c.annotation), "geom" in c && n(6, s = c.geom), "style" in c && n(7, r = c.style);
2483
+ }, e.$$.update = () => {
2484
+ e.$$.dirty & /*annotation, style*/
2485
+ 129 && n(1, o = ze(i, r));
2486
+ }, [i, o, l, a, d, h, s, r];
2487
+ }
2488
+ class ko extends ne {
2489
+ constructor(t) {
2490
+ super(), te(this, t, Bo, vo, K, { annotation: 0, geom: 6, style: 7 });
2491
+ }
2492
+ }
2493
+ function Io(e) {
2494
+ let t, n, o, i, s;
2495
+ return {
2496
+ c() {
2497
+ t = R("g"), n = R("polygon"), i = R("polygon"), u(n, "class", "a9s-outer"), u(n, "style", o = /*computedStyle*/
2498
+ e[1] ? "display:none;" : void 0), u(
2499
+ n,
2500
+ "points",
2501
+ /*points*/
2502
+ e[2].map(Co).join(" ")
2503
+ ), u(i, "class", "a9s-inner"), u(
2504
+ i,
2505
+ "style",
2506
+ /*computedStyle*/
2507
+ e[1]
2508
+ ), u(
2509
+ i,
2510
+ "points",
2511
+ /*points*/
2512
+ e[2].map(Po).join(" ")
2513
+ ), u(t, "data-id", s = /*annotation*/
2514
+ e[0].id);
2515
+ },
2516
+ m(r, l) {
2517
+ v(r, t, l), fe(t, n), fe(t, i);
2518
+ },
2519
+ p(r, [l]) {
2520
+ l & /*computedStyle*/
2521
+ 2 && o !== (o = /*computedStyle*/
2522
+ r[1] ? "display:none;" : void 0) && u(n, "style", o), l & /*computedStyle*/
2523
+ 2 && u(
2524
+ i,
2525
+ "style",
2526
+ /*computedStyle*/
2527
+ r[1]
2528
+ ), l & /*annotation*/
2529
+ 1 && s !== (s = /*annotation*/
2530
+ r[0].id) && u(t, "data-id", s);
2531
+ },
2532
+ i: G,
2533
+ o: G,
2534
+ d(r) {
2535
+ r && O(t);
2536
+ }
2537
+ };
2538
+ }
2539
+ const Co = (e) => e.join(","), Po = (e) => e.join(",");
2540
+ function Yo(e, t, n) {
2541
+ let o, { annotation: i } = t, { geom: s } = t, { style: r = void 0 } = t;
2542
+ const { points: l } = s;
2543
+ return e.$$set = (a) => {
2544
+ "annotation" in a && n(0, i = a.annotation), "geom" in a && n(3, s = a.geom), "style" in a && n(4, r = a.style);
2545
+ }, e.$$.update = () => {
2546
+ e.$$.dirty & /*annotation, style*/
2547
+ 17 && n(1, o = ze(i, r));
2548
+ }, [i, o, l, s, r];
2549
+ }
2550
+ class Ro extends ne {
2551
+ constructor(t) {
2552
+ super(), te(this, t, Yo, Io, K, { annotation: 0, geom: 3, style: 4 });
2553
+ }
2554
+ }
2555
+ function Xo(e) {
2556
+ let t, n, o, i, s;
2557
+ return {
2558
+ c() {
2559
+ t = R("g"), n = R("rect"), i = R("rect"), u(n, "class", "a9s-outer"), u(n, "style", o = /*computedStyle*/
2560
+ e[1] ? "display:none;" : void 0), u(
2561
+ n,
2562
+ "x",
2563
+ /*x*/
2564
+ e[2]
2565
+ ), u(
2566
+ n,
2567
+ "y",
2568
+ /*y*/
2569
+ e[3]
2570
+ ), u(
2571
+ n,
2572
+ "width",
2573
+ /*w*/
2574
+ e[4]
2575
+ ), u(
2576
+ n,
2577
+ "height",
2578
+ /*h*/
2579
+ e[5]
2580
+ ), u(i, "class", "a9s-inner"), u(
2581
+ i,
2582
+ "style",
2583
+ /*computedStyle*/
2584
+ e[1]
2585
+ ), u(
2586
+ i,
2587
+ "x",
2588
+ /*x*/
2589
+ e[2]
2590
+ ), u(
2591
+ i,
2592
+ "y",
2593
+ /*y*/
2594
+ e[3]
2595
+ ), u(
2596
+ i,
2597
+ "width",
2598
+ /*w*/
2599
+ e[4]
2600
+ ), u(
2601
+ i,
2602
+ "height",
2603
+ /*h*/
2604
+ e[5]
2605
+ ), u(t, "data-id", s = /*annotation*/
2606
+ e[0].id);
2607
+ },
2608
+ m(r, l) {
2609
+ v(r, t, l), fe(t, n), fe(t, i);
2610
+ },
2611
+ p(r, [l]) {
2612
+ l & /*computedStyle*/
2613
+ 2 && o !== (o = /*computedStyle*/
2614
+ r[1] ? "display:none;" : void 0) && u(n, "style", o), l & /*computedStyle*/
2615
+ 2 && u(
2616
+ i,
2617
+ "style",
2618
+ /*computedStyle*/
2619
+ r[1]
2620
+ ), l & /*annotation*/
2621
+ 1 && s !== (s = /*annotation*/
2622
+ r[0].id) && u(t, "data-id", s);
2623
+ },
2624
+ i: G,
2625
+ o: G,
2626
+ d(r) {
2627
+ r && O(t);
2628
+ }
2629
+ };
2630
+ }
2631
+ function Do(e, t, n) {
2632
+ let o, { annotation: i } = t, { geom: s } = t, { style: r = void 0 } = t;
2633
+ const { x: l, y: a, w: d, h } = s;
2634
+ return e.$$set = (c) => {
2635
+ "annotation" in c && n(0, i = c.annotation), "geom" in c && n(6, s = c.geom), "style" in c && n(7, r = c.style);
2636
+ }, e.$$.update = () => {
2637
+ e.$$.dirty & /*annotation, style*/
2638
+ 129 && n(1, o = ze(i, r));
2639
+ }, [i, o, l, a, d, h, s, r];
2640
+ }
2641
+ class No extends ne {
2642
+ constructor(t) {
2643
+ super(), te(this, t, Do, Xo, K, { annotation: 0, geom: 6, style: 7 });
2644
+ }
2645
+ }
2646
+ const yi = {
2647
+ elementToImage: (e, t) => [e, t]
2648
+ }, Uo = (e) => ({
2649
+ elementToImage: (t, n) => {
2650
+ const o = e.createSVGPoint();
2651
+ o.x = t, o.y = n;
2652
+ const { x: i, y: s } = o.matrixTransform(e.getCTM().inverse());
2653
+ return [i, s];
2654
+ }
2655
+ }), Go = 250, Ho = (e, t) => {
2656
+ const n = Me();
2657
+ let o;
2658
+ return { onPointerDown: () => o = performance.now(), onPointerUp: (r) => {
2659
+ if (performance.now() - o < Go) {
2660
+ const { x: a, y: d } = Fo(r, e), h = t.getAt(a, d);
2661
+ h ? n("click", { originalEvent: r, annotation: h }) : n("click", { originalEvent: r });
2662
+ }
2663
+ } };
2664
+ }, Fo = (e, t) => {
2665
+ const n = t.createSVGPoint(), o = t.getBoundingClientRect(), i = e.clientX - o.x, s = e.clientY - o.y, { left: r, top: l } = t.getBoundingClientRect();
2666
+ return n.x = i + r, n.y = s + l, n.matrixTransform(t.getScreenCTM().inverse());
2667
+ };
2668
+ function Mt(e, t, n) {
2669
+ const o = e.slice();
2670
+ return o[28] = t[n], o;
2671
+ }
2672
+ function Lt(e, t, n) {
2673
+ const o = e.slice();
2674
+ return o[31] = t[n], o;
2675
+ }
2676
+ function Ze(e) {
2677
+ const t = e.slice(), n = (
2678
+ /*annotation*/
2679
+ t[31].target.selector
2680
+ );
2681
+ return t[34] = n, t;
2682
+ }
2683
+ function Ot(e) {
2684
+ let t = (
2685
+ /*annotation*/
2686
+ e[31].id
2687
+ ), n, o, i = vt(e);
2688
+ return {
2689
+ c() {
2690
+ i.c(), n = ae();
2691
+ },
2692
+ m(s, r) {
2693
+ i.m(s, r), v(s, n, r), o = !0;
2694
+ },
2695
+ p(s, r) {
2696
+ r[0] & /*$store*/
2697
+ 4096 && K(t, t = /*annotation*/
2698
+ s[31].id) ? (se(), N(i, 1, 1, G), re(), i = vt(s), i.c(), D(i, 1), i.m(n.parentNode, n)) : i.p(s, r);
2699
+ },
2700
+ i(s) {
2701
+ o || (D(i), o = !0);
2702
+ },
2703
+ o(s) {
2704
+ N(i), o = !1;
2705
+ },
2706
+ d(s) {
2707
+ s && O(n), i.d(s);
2708
+ }
2709
+ };
2710
+ }
2711
+ function zo(e) {
2712
+ let t, n;
2713
+ return t = new Ro({
2714
+ props: {
2715
+ annotation: (
2716
+ /*annotation*/
2717
+ e[31]
2718
+ ),
2719
+ geom: (
2720
+ /*selector*/
2721
+ e[34].geometry
2722
+ ),
2723
+ style: (
2724
+ /*style*/
2725
+ e[1]
2726
+ )
2727
+ }
2728
+ }), {
2729
+ c() {
2730
+ pe(t.$$.fragment);
2731
+ },
2732
+ m(o, i) {
2733
+ ue(t, o, i), n = !0;
2734
+ },
2735
+ p(o, i) {
2736
+ const s = {};
2737
+ i[0] & /*$store*/
2738
+ 4096 && (s.annotation = /*annotation*/
2739
+ o[31]), i[0] & /*$store*/
2740
+ 4096 && (s.geom = /*selector*/
2741
+ o[34].geometry), i[0] & /*style*/
2742
+ 2 && (s.style = /*style*/
2743
+ o[1]), t.$set(s);
2744
+ },
2745
+ i(o) {
2746
+ n || (D(t.$$.fragment, o), n = !0);
2747
+ },
2748
+ o(o) {
2749
+ N(t.$$.fragment, o), n = !1;
2750
+ },
2751
+ d(o) {
2752
+ de(t, o);
2753
+ }
2754
+ };
2755
+ }
2756
+ function jo(e) {
2757
+ let t, n;
2758
+ return t = new No({
2759
+ props: {
2760
+ annotation: (
2761
+ /*annotation*/
2762
+ e[31]
2763
+ ),
2764
+ geom: (
2765
+ /*selector*/
2766
+ e[34].geometry
2767
+ ),
2768
+ style: (
2769
+ /*style*/
2770
+ e[1]
2771
+ )
2772
+ }
2773
+ }), {
2774
+ c() {
2775
+ pe(t.$$.fragment);
2776
+ },
2777
+ m(o, i) {
2778
+ ue(t, o, i), n = !0;
2779
+ },
2780
+ p(o, i) {
2781
+ const s = {};
2782
+ i[0] & /*$store*/
2783
+ 4096 && (s.annotation = /*annotation*/
2784
+ o[31]), i[0] & /*$store*/
2785
+ 4096 && (s.geom = /*selector*/
2786
+ o[34].geometry), i[0] & /*style*/
2787
+ 2 && (s.style = /*style*/
2788
+ o[1]), t.$set(s);
2789
+ },
2790
+ i(o) {
2791
+ n || (D(t.$$.fragment, o), n = !0);
2792
+ },
2793
+ o(o) {
2794
+ N(t.$$.fragment, o), n = !1;
2795
+ },
2796
+ d(o) {
2797
+ de(t, o);
2798
+ }
2799
+ };
2800
+ }
2801
+ function Vo(e) {
2802
+ let t, n;
2803
+ return t = new ko({
2804
+ props: {
2805
+ annotation: (
2806
+ /*annotation*/
2807
+ e[31]
2808
+ ),
2809
+ geom: (
2810
+ /*selector*/
2811
+ e[34].geometry
2812
+ ),
2813
+ style: (
2814
+ /*style*/
2815
+ e[1]
2816
+ )
2817
+ }
2818
+ }), {
2819
+ c() {
2820
+ pe(t.$$.fragment);
2821
+ },
2822
+ m(o, i) {
2823
+ ue(t, o, i), n = !0;
2824
+ },
2825
+ p(o, i) {
2826
+ const s = {};
2827
+ i[0] & /*$store*/
2828
+ 4096 && (s.annotation = /*annotation*/
2829
+ o[31]), i[0] & /*$store*/
2830
+ 4096 && (s.geom = /*selector*/
2831
+ o[34].geometry), i[0] & /*style*/
2832
+ 2 && (s.style = /*style*/
2833
+ o[1]), t.$set(s);
2834
+ },
2835
+ i(o) {
2836
+ n || (D(t.$$.fragment, o), n = !0);
2837
+ },
2838
+ o(o) {
2839
+ N(t.$$.fragment, o), n = !1;
2840
+ },
2841
+ d(o) {
2842
+ de(t, o);
2843
+ }
2844
+ };
2845
+ }
2846
+ function vt(e) {
2847
+ let t, n, o, i;
2848
+ const s = [Vo, jo, zo], r = [];
2849
+ function l(a, d) {
2850
+ return (
2851
+ /*selector*/
2852
+ a[34].type === z.ELLIPSE ? 0 : (
2853
+ /*selector*/
2854
+ a[34].type === z.RECTANGLE ? 1 : (
2855
+ /*selector*/
2856
+ a[34].type === z.POLYGON ? 2 : -1
2857
+ )
2858
+ )
2859
+ );
2860
+ }
2861
+ return ~(t = l(e)) && (n = r[t] = s[t](e)), {
2862
+ c() {
2863
+ n && n.c(), o = ae();
2864
+ },
2865
+ m(a, d) {
2866
+ ~t && r[t].m(a, d), v(a, o, d), i = !0;
2867
+ },
2868
+ p(a, d) {
2869
+ let h = t;
2870
+ t = l(a), t === h ? ~t && r[t].p(a, d) : (n && (se(), N(r[h], 1, 1, () => {
2871
+ r[h] = null;
2872
+ }), re()), ~t ? (n = r[t], n ? n.p(a, d) : (n = r[t] = s[t](a), n.c()), D(n, 1), n.m(o.parentNode, o)) : n = null);
2873
+ },
2874
+ i(a) {
2875
+ i || (D(n), i = !0);
2876
+ },
2877
+ o(a) {
2878
+ N(n), i = !1;
2879
+ },
2880
+ d(a) {
2881
+ ~t && r[t].d(a), a && O(o);
2882
+ }
2883
+ };
2884
+ }
2885
+ function Bt(e) {
2886
+ let t = !/*isEditable*/
2887
+ e[7](
2888
+ /*annotation*/
2889
+ e[31]
2890
+ ), n, o, i = t && Ot(Ze(e));
2891
+ return {
2892
+ c() {
2893
+ i && i.c(), n = ae();
2894
+ },
2895
+ m(s, r) {
2896
+ i && i.m(s, r), v(s, n, r), o = !0;
2897
+ },
2898
+ p(s, r) {
2899
+ r[0] & /*isEditable, $store*/
2900
+ 4224 && (t = !/*isEditable*/
2901
+ s[7](
2902
+ /*annotation*/
2903
+ s[31]
2904
+ )), t ? i ? (i.p(Ze(s), r), r[0] & /*isEditable, $store*/
2905
+ 4224 && D(i, 1)) : (i = Ot(Ze(s)), i.c(), D(i, 1), i.m(n.parentNode, n)) : i && (se(), N(i, 1, 1, () => {
2906
+ i = null;
2907
+ }), re());
2908
+ },
2909
+ i(s) {
2910
+ o || (D(i), o = !0);
2911
+ },
2912
+ o(s) {
2913
+ N(i), o = !1;
2914
+ },
2915
+ d(s) {
2916
+ i && i.d(s), s && O(n);
2917
+ }
2918
+ };
2919
+ }
2920
+ function kt(e) {
2921
+ let t, n, o, i;
2922
+ const s = [Wo, qo], r = [];
2923
+ function l(a, d) {
2924
+ return (
2925
+ /*editableAnnotations*/
2926
+ a[6] ? 0 : (
2927
+ /*tool*/
2928
+ a[2] && /*drawingEnabled*/
2929
+ a[0] ? 1 : -1
2930
+ )
2931
+ );
2932
+ }
2933
+ return ~(t = l(e)) && (n = r[t] = s[t](e)), {
2934
+ c() {
2935
+ n && n.c(), o = ae();
2936
+ },
2937
+ m(a, d) {
2938
+ ~t && r[t].m(a, d), v(a, o, d), i = !0;
2939
+ },
2940
+ p(a, d) {
2941
+ let h = t;
2942
+ t = l(a), t === h ? ~t && r[t].p(a, d) : (n && (se(), N(r[h], 1, 1, () => {
2943
+ r[h] = null;
2944
+ }), re()), ~t ? (n = r[t], n ? n.p(a, d) : (n = r[t] = s[t](a), n.c()), D(n, 1), n.m(o.parentNode, o)) : n = null);
2945
+ },
2946
+ i(a) {
2947
+ i || (D(n), i = !0);
2948
+ },
2949
+ o(a) {
2950
+ N(n), i = !1;
2951
+ },
2952
+ d(a) {
2953
+ ~t && r[t].d(a), a && O(o);
2954
+ }
2955
+ };
2956
+ }
2957
+ function qo(e) {
2958
+ let t = (
2959
+ /*tool*/
2960
+ e[2]
2961
+ ), n, o, i = It(e);
2962
+ return {
2963
+ c() {
2964
+ i.c(), n = ae();
2965
+ },
2966
+ m(s, r) {
2967
+ i.m(s, r), v(s, n, r), o = !0;
2968
+ },
2969
+ p(s, r) {
2970
+ r[0] & /*tool*/
2971
+ 4 && K(t, t = /*tool*/
2972
+ s[2]) ? (se(), N(i, 1, 1, G), re(), i = It(s), i.c(), D(i, 1), i.m(n.parentNode, n)) : i.p(s, r);
2973
+ },
2974
+ i(s) {
2975
+ o || (D(i), o = !0);
2976
+ },
2977
+ o(s) {
2978
+ N(i), o = !1;
2979
+ },
2980
+ d(s) {
2981
+ s && O(n), i.d(s);
2982
+ }
2983
+ };
2984
+ }
2985
+ function Wo(e) {
2986
+ let t, n, o = (
2987
+ /*editableAnnotations*/
2988
+ e[6]
2989
+ ), i = [];
2990
+ for (let r = 0; r < o.length; r += 1)
2991
+ i[r] = Pt(Mt(e, o, r));
2992
+ const s = (r) => N(i[r], 1, 1, () => {
2993
+ i[r] = null;
2994
+ });
2995
+ return {
2996
+ c() {
2997
+ for (let r = 0; r < i.length; r += 1)
2998
+ i[r].c();
2999
+ t = ae();
3000
+ },
3001
+ m(r, l) {
3002
+ for (let a = 0; a < i.length; a += 1)
3003
+ i[a] && i[a].m(r, l);
3004
+ v(r, t, l), n = !0;
3005
+ },
3006
+ p(r, l) {
3007
+ if (l[0] & /*editableAnnotations, drawingEl, style, transform, $scale, onChangeSelected*/
3008
+ 140370) {
3009
+ o = /*editableAnnotations*/
3010
+ r[6];
3011
+ let a;
3012
+ for (a = 0; a < o.length; a += 1) {
3013
+ const d = Mt(r, o, a);
3014
+ i[a] ? (i[a].p(d, l), D(i[a], 1)) : (i[a] = Pt(d), i[a].c(), D(i[a], 1), i[a].m(t.parentNode, t));
3015
+ }
3016
+ for (se(), a = o.length; a < i.length; a += 1)
3017
+ s(a);
3018
+ re();
3019
+ }
3020
+ },
3021
+ i(r) {
3022
+ if (!n) {
3023
+ for (let l = 0; l < o.length; l += 1)
3024
+ D(i[l]);
3025
+ n = !0;
3026
+ }
3027
+ },
3028
+ o(r) {
3029
+ i = i.filter(Boolean);
3030
+ for (let l = 0; l < i.length; l += 1)
3031
+ N(i[l]);
3032
+ n = !1;
3033
+ },
3034
+ d(r) {
3035
+ tt(i, r), r && O(t);
3036
+ }
3037
+ };
3038
+ }
3039
+ function It(e) {
3040
+ let t, n;
3041
+ return t = new po({
3042
+ props: {
3043
+ target: (
3044
+ /*drawingEl*/
3045
+ e[4]
3046
+ ),
3047
+ tool: (
3048
+ /*tool*/
3049
+ e[2]
3050
+ ),
3051
+ drawingMode: (
3052
+ /*drawingMode*/
3053
+ e[11]
3054
+ ),
3055
+ transform: (
3056
+ /*transform*/
3057
+ e[10]
3058
+ ),
3059
+ viewportScale: (
3060
+ /*$scale*/
3061
+ e[13]
3062
+ )
3063
+ }
3064
+ }), t.$on(
3065
+ "create",
3066
+ /*onSelectionCreated*/
3067
+ e[16]
3068
+ ), {
3069
+ c() {
3070
+ pe(t.$$.fragment);
3071
+ },
3072
+ m(o, i) {
3073
+ ue(t, o, i), n = !0;
3074
+ },
3075
+ p(o, i) {
3076
+ const s = {};
3077
+ i[0] & /*drawingEl*/
3078
+ 16 && (s.target = /*drawingEl*/
3079
+ o[4]), i[0] & /*tool*/
3080
+ 4 && (s.tool = /*tool*/
3081
+ o[2]), i[0] & /*drawingMode*/
3082
+ 2048 && (s.drawingMode = /*drawingMode*/
3083
+ o[11]), i[0] & /*transform*/
3084
+ 1024 && (s.transform = /*transform*/
3085
+ o[10]), i[0] & /*$scale*/
3086
+ 8192 && (s.viewportScale = /*$scale*/
3087
+ o[13]), t.$set(s);
3088
+ },
3089
+ i(o) {
3090
+ n || (D(t.$$.fragment, o), n = !0);
3091
+ },
3092
+ o(o) {
3093
+ N(t.$$.fragment, o), n = !1;
3094
+ },
3095
+ d(o) {
3096
+ de(t, o);
3097
+ }
3098
+ };
3099
+ }
3100
+ function Ct(e) {
3101
+ let t, n;
3102
+ return t = new mo({
3103
+ props: {
3104
+ target: (
3105
+ /*drawingEl*/
3106
+ e[4]
3107
+ ),
3108
+ editor: wt(
3109
+ /*editable*/
3110
+ e[28].target.selector
3111
+ ),
3112
+ annotation: (
3113
+ /*editable*/
3114
+ e[28]
3115
+ ),
3116
+ style: (
3117
+ /*style*/
3118
+ e[1]
3119
+ ),
3120
+ transform: (
3121
+ /*transform*/
3122
+ e[10]
3123
+ ),
3124
+ viewportScale: (
3125
+ /*$scale*/
3126
+ e[13]
3127
+ )
3128
+ }
3129
+ }), t.$on("change", function() {
3130
+ j(
3131
+ /*onChangeSelected*/
3132
+ e[17](
3133
+ /*editable*/
3134
+ e[28]
3135
+ )
3136
+ ) && e[17](
3137
+ /*editable*/
3138
+ e[28]
3139
+ ).apply(this, arguments);
3140
+ }), {
3141
+ c() {
3142
+ pe(t.$$.fragment);
3143
+ },
3144
+ m(o, i) {
3145
+ ue(t, o, i), n = !0;
3146
+ },
3147
+ p(o, i) {
3148
+ e = o;
3149
+ const s = {};
3150
+ i[0] & /*drawingEl*/
3151
+ 16 && (s.target = /*drawingEl*/
3152
+ e[4]), i[0] & /*editableAnnotations*/
3153
+ 64 && (s.editor = wt(
3154
+ /*editable*/
3155
+ e[28].target.selector
3156
+ )), i[0] & /*editableAnnotations*/
3157
+ 64 && (s.annotation = /*editable*/
3158
+ e[28]), i[0] & /*style*/
3159
+ 2 && (s.style = /*style*/
3160
+ e[1]), i[0] & /*transform*/
3161
+ 1024 && (s.transform = /*transform*/
3162
+ e[10]), i[0] & /*$scale*/
3163
+ 8192 && (s.viewportScale = /*$scale*/
3164
+ e[13]), t.$set(s);
3165
+ },
3166
+ i(o) {
3167
+ n || (D(t.$$.fragment, o), n = !0);
3168
+ },
3169
+ o(o) {
3170
+ N(t.$$.fragment, o), n = !1;
3171
+ },
3172
+ d(o) {
3173
+ de(t, o);
3174
+ }
3175
+ };
3176
+ }
3177
+ function Pt(e) {
3178
+ let t = (
3179
+ /*editable*/
3180
+ e[28].id
3181
+ ), n, o, i = Ct(e);
3182
+ return {
3183
+ c() {
3184
+ i.c(), n = ae();
3185
+ },
3186
+ m(s, r) {
3187
+ i.m(s, r), v(s, n, r), o = !0;
3188
+ },
3189
+ p(s, r) {
3190
+ r[0] & /*editableAnnotations*/
3191
+ 64 && K(t, t = /*editable*/
3192
+ s[28].id) ? (se(), N(i, 1, 1, G), re(), i = Ct(s), i.c(), D(i, 1), i.m(n.parentNode, n)) : i.p(s, r);
3193
+ },
3194
+ i(s) {
3195
+ o || (D(i), o = !0);
3196
+ },
3197
+ o(s) {
3198
+ N(i), o = !1;
3199
+ },
3200
+ d(s) {
3201
+ s && O(n), i.d(s);
3202
+ }
3203
+ };
3204
+ }
3205
+ function Jo(e) {
3206
+ let t, n, o, i, s, r, l = (
3207
+ /*$store*/
3208
+ e[12]
3209
+ ), a = [];
3210
+ for (let c = 0; c < l.length; c += 1)
3211
+ a[c] = Bt(Lt(e, l, c));
3212
+ const d = (c) => N(a[c], 1, 1, () => {
3213
+ a[c] = null;
3214
+ });
3215
+ let h = (
3216
+ /*drawingEl*/
3217
+ e[4] && kt(e)
3218
+ );
3219
+ return {
3220
+ c() {
3221
+ t = R("svg"), n = R("g");
3222
+ for (let c = 0; c < a.length; c += 1)
3223
+ a[c].c();
3224
+ o = R("g"), h && h.c(), u(o, "class", "drawing"), u(t, "class", "a9s-annotationlayer"), ct(
3225
+ t,
3226
+ "drawing",
3227
+ /*tool*/
3228
+ e[2]
3229
+ );
3230
+ },
3231
+ m(c, f) {
3232
+ v(c, t, f), fe(t, n);
3233
+ for (let m = 0; m < a.length; m += 1)
3234
+ a[m] && a[m].m(n, null);
3235
+ fe(t, o), h && h.m(o, null), e[24](o), e[25](t), i = !0, s || (r = [
3236
+ W(t, "pointerup", function() {
3237
+ j(
3238
+ /*onPointerUp*/
3239
+ e[8]
3240
+ ) && e[8].apply(this, arguments);
3241
+ }),
3242
+ W(t, "pointerdown", function() {
3243
+ j(
3244
+ /*onPointerDown*/
3245
+ e[9]
3246
+ ) && e[9].apply(this, arguments);
3247
+ })
3248
+ ], s = !0);
3249
+ },
3250
+ p(c, f) {
3251
+ if (e = c, f[0] & /*$store, style, isEditable*/
3252
+ 4226) {
3253
+ l = /*$store*/
3254
+ e[12];
3255
+ let m;
3256
+ for (m = 0; m < l.length; m += 1) {
3257
+ const g = Lt(e, l, m);
3258
+ a[m] ? (a[m].p(g, f), D(a[m], 1)) : (a[m] = Bt(g), a[m].c(), D(a[m], 1), a[m].m(n, null));
3259
+ }
3260
+ for (se(), m = l.length; m < a.length; m += 1)
3261
+ d(m);
3262
+ re();
3263
+ }
3264
+ /*drawingEl*/
3265
+ e[4] ? h ? (h.p(e, f), f[0] & /*drawingEl*/
3266
+ 16 && D(h, 1)) : (h = kt(e), h.c(), D(h, 1), h.m(o, null)) : h && (se(), N(h, 1, 1, () => {
3267
+ h = null;
3268
+ }), re()), (!i || f[0] & /*tool*/
3269
+ 4) && ct(
3270
+ t,
3271
+ "drawing",
3272
+ /*tool*/
3273
+ e[2]
3274
+ );
3275
+ },
3276
+ i(c) {
3277
+ if (!i) {
3278
+ for (let f = 0; f < l.length; f += 1)
3279
+ D(a[f]);
3280
+ D(h), i = !0;
3281
+ }
3282
+ },
3283
+ o(c) {
3284
+ a = a.filter(Boolean);
3285
+ for (let f = 0; f < a.length; f += 1)
3286
+ N(a[f]);
3287
+ N(h), i = !1;
3288
+ },
3289
+ d(c) {
3290
+ c && O(t), tt(a, c), h && h.d(), e[24](null), e[25](null), s = !1, le(r);
3291
+ }
3292
+ };
3293
+ }
3294
+ function Qo(e, t, n) {
3295
+ let o, i, s, r, l, a, d, h, c = G, f = () => (c(), c = Xt(w, (I) => n(13, h = I)), w);
3296
+ e.$$.on_destroy.push(() => c());
3297
+ let { drawingEnabled: m } = t, { image: g } = t, { preferredDrawingMode: p } = t, { state: y } = t, { style: L = void 0 } = t, { tool: E, opts: k } = Vt("rectangle"), { tool: b = E, opts: Y = k } = t, { user: U } = t, X, _, w;
3298
+ Ce(() => f(n(5, w = Eo(g, _))));
3299
+ const { selection: A, store: S } = y;
3300
+ at(e, A, (I) => n(23, a = I)), at(e, S, (I) => n(12, d = I));
3301
+ let B = null, P = null;
3302
+ const Q = (I) => {
3303
+ S.unobserve(B);
3304
+ const J = I.filter(({ editable: H }) => H).map(({ id: H }) => H);
3305
+ J.length > 0 ? (n(6, P = J.map((H) => S.getAnnotation(H))), B = (H) => {
3306
+ const { updated: V } = H.changes;
3307
+ n(6, P = V.map((ie) => ie.newValue));
3308
+ }, S.observe(B, { annotations: J })) : n(6, P = null);
3309
+ }, ce = (I) => {
3310
+ const J = it(), H = {
3311
+ id: J,
3312
+ bodies: [],
3313
+ target: {
3314
+ annotation: J,
3315
+ selector: I.detail,
3316
+ creator: U,
3317
+ created: /* @__PURE__ */ new Date()
3318
+ }
3319
+ };
3320
+ S.addAnnotation(H), A.setSelected(H.id);
3321
+ }, oe = (I) => (J) => {
3322
+ var he;
3323
+ const { target: H } = I, V = 10 * 60 * 1e3, ie = ((he = H.creator) == null ? void 0 : he.id) !== U.id || !H.created || (/* @__PURE__ */ new Date()).getTime() - H.created.getTime() > V;
3324
+ S.updateTarget({
3325
+ ...H,
3326
+ selector: J.detail,
3327
+ created: ie ? H.created : /* @__PURE__ */ new Date(),
3328
+ updated: ie ? /* @__PURE__ */ new Date() : null,
3329
+ updatedBy: ie ? U : null
3330
+ });
3331
+ };
3332
+ function Le(I) {
3333
+ Se[I ? "unshift" : "push"](() => {
3334
+ X = I, n(4, X);
3335
+ });
3336
+ }
3337
+ function Z(I) {
3338
+ Se[I ? "unshift" : "push"](() => {
3339
+ _ = I, n(3, _);
3340
+ });
3341
+ }
3342
+ return e.$$set = (I) => {
3343
+ "drawingEnabled" in I && n(0, m = I.drawingEnabled), "image" in I && n(18, g = I.image), "preferredDrawingMode" in I && n(19, p = I.preferredDrawingMode), "state" in I && n(20, y = I.state), "style" in I && n(1, L = I.style), "tool" in I && n(2, b = I.tool), "opts" in I && n(21, Y = I.opts), "user" in I && n(22, U = I.user);
3344
+ }, e.$$.update = () => {
3345
+ e.$$.dirty[0] & /*opts, preferredDrawingMode*/
3346
+ 2621440 && n(11, o = (Y == null ? void 0 : Y.drawingMode) || p), e.$$.dirty[0] & /*svgEl*/
3347
+ 8 && n(10, i = Uo(_)), e.$$.dirty[0] & /*svgEl*/
3348
+ 8 && n(9, { onPointerDown: s, onPointerUp: r } = Ho(_, S), s, (n(8, r), n(3, _))), e.$$.dirty[0] & /*$selection*/
3349
+ 8388608 && n(7, l = (I) => a.selected.find((J) => J.id === I.id && J.editable)), e.$$.dirty[0] & /*$selection*/
3350
+ 8388608 && Q(a.selected);
3351
+ }, [
3352
+ m,
3353
+ L,
3354
+ b,
3355
+ _,
3356
+ X,
3357
+ w,
3358
+ P,
3359
+ l,
3360
+ r,
3361
+ s,
3362
+ i,
3363
+ o,
3364
+ d,
3365
+ h,
3366
+ A,
3367
+ S,
3368
+ ce,
3369
+ oe,
3370
+ g,
3371
+ p,
3372
+ y,
3373
+ Y,
3374
+ U,
3375
+ a,
3376
+ Le,
3377
+ Z
3378
+ ];
3379
+ }
3380
+ class Zo extends ne {
3381
+ constructor(t) {
3382
+ super(), te(
3383
+ this,
3384
+ t,
3385
+ Qo,
3386
+ Jo,
3387
+ K,
3388
+ {
3389
+ drawingEnabled: 0,
3390
+ image: 18,
3391
+ preferredDrawingMode: 19,
3392
+ state: 20,
3393
+ style: 1,
3394
+ tool: 2,
3395
+ opts: 21,
3396
+ user: 22
3397
+ },
3398
+ null,
3399
+ [-1, -1]
3400
+ );
3401
+ }
3402
+ }
3403
+ function Ko(e, t, n, o, i) {
3404
+ qt(e, t, n || 0, o || e.length - 1, i || xo);
3405
+ }
3406
+ function qt(e, t, n, o, i) {
3407
+ for (; o > n; ) {
3408
+ if (o - n > 600) {
3409
+ var s = o - n + 1, r = t - n + 1, l = Math.log(s), a = 0.5 * Math.exp(2 * l / 3), d = 0.5 * Math.sqrt(l * a * (s - a) / s) * (r - s / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(t - r * a / s + d)), c = Math.min(o, Math.floor(t + (s - r) * a / s + d));
3410
+ qt(e, t, h, c, i);
3411
+ }
3412
+ var f = e[t], m = n, g = o;
3413
+ for (Oe(e, n, t), i(e[o], f) > 0 && Oe(e, n, o); m < g; ) {
3414
+ for (Oe(e, m, g), m++, g--; i(e[m], f) < 0; )
3415
+ m++;
3416
+ for (; i(e[g], f) > 0; )
3417
+ g--;
3418
+ }
3419
+ i(e[n], f) === 0 ? Oe(e, n, g) : (g++, Oe(e, g, o)), g <= t && (n = g + 1), t <= g && (o = g - 1);
3420
+ }
3421
+ }
3422
+ function Oe(e, t, n) {
3423
+ var o = e[t];
3424
+ e[t] = e[n], e[n] = o;
3425
+ }
3426
+ function xo(e, t) {
3427
+ return e < t ? -1 : e > t ? 1 : 0;
3428
+ }
3429
+ class $o {
3430
+ constructor(t = 9) {
3431
+ this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
3432
+ }
3433
+ all() {
3434
+ return this._all(this.data, []);
3435
+ }
3436
+ search(t) {
3437
+ let n = this.data;
3438
+ const o = [];
3439
+ if (!Ue(t, n))
3440
+ return o;
3441
+ const i = this.toBBox, s = [];
3442
+ for (; n; ) {
3443
+ for (let r = 0; r < n.children.length; r++) {
3444
+ const l = n.children[r], a = n.leaf ? i(l) : l;
3445
+ Ue(t, a) && (n.leaf ? o.push(l) : xe(t, a) ? this._all(l, o) : s.push(l));
3446
+ }
3447
+ n = s.pop();
3448
+ }
3449
+ return o;
3450
+ }
3451
+ collides(t) {
3452
+ let n = this.data;
3453
+ if (!Ue(t, n))
3454
+ return !1;
3455
+ const o = [];
3456
+ for (; n; ) {
3457
+ for (let i = 0; i < n.children.length; i++) {
3458
+ const s = n.children[i], r = n.leaf ? this.toBBox(s) : s;
3459
+ if (Ue(t, r)) {
3460
+ if (n.leaf || xe(t, r))
3461
+ return !0;
3462
+ o.push(s);
3463
+ }
3464
+ }
3465
+ n = o.pop();
3466
+ }
3467
+ return !1;
3468
+ }
3469
+ load(t) {
3470
+ if (!(t && t.length))
3471
+ return this;
3472
+ if (t.length < this._minEntries) {
3473
+ for (let o = 0; o < t.length; o++)
3474
+ this.insert(t[o]);
3475
+ return this;
3476
+ }
3477
+ let n = this._build(t.slice(), 0, t.length - 1, 0);
3478
+ if (!this.data.children.length)
3479
+ this.data = n;
3480
+ else if (this.data.height === n.height)
3481
+ this._splitRoot(this.data, n);
3482
+ else {
3483
+ if (this.data.height < n.height) {
3484
+ const o = this.data;
3485
+ this.data = n, n = o;
3486
+ }
3487
+ this._insert(n, this.data.height - n.height - 1, !0);
3488
+ }
3489
+ return this;
3490
+ }
3491
+ insert(t) {
3492
+ return t && this._insert(t, this.data.height - 1), this;
3493
+ }
3494
+ clear() {
3495
+ return this.data = Ee([]), this;
3496
+ }
3497
+ remove(t, n) {
3498
+ if (!t)
3499
+ return this;
3500
+ let o = this.data;
3501
+ const i = this.toBBox(t), s = [], r = [];
3502
+ let l, a, d;
3503
+ for (; o || s.length; ) {
3504
+ if (o || (o = s.pop(), a = s[s.length - 1], l = r.pop(), d = !0), o.leaf) {
3505
+ const h = ei(t, o.children, n);
3506
+ if (h !== -1)
3507
+ return o.children.splice(h, 1), s.push(o), this._condense(s), this;
3508
+ }
3509
+ !d && !o.leaf && xe(o, i) ? (s.push(o), r.push(l), l = 0, a = o, o = o.children[0]) : a ? (l++, o = a.children[l], d = !1) : o = null;
3510
+ }
3511
+ return this;
3512
+ }
3513
+ toBBox(t) {
3514
+ return t;
3515
+ }
3516
+ compareMinX(t, n) {
3517
+ return t.minX - n.minX;
3518
+ }
3519
+ compareMinY(t, n) {
3520
+ return t.minY - n.minY;
3521
+ }
3522
+ toJSON() {
3523
+ return this.data;
3524
+ }
3525
+ fromJSON(t) {
3526
+ return this.data = t, this;
3527
+ }
3528
+ _all(t, n) {
3529
+ const o = [];
3530
+ for (; t; )
3531
+ t.leaf ? n.push(...t.children) : o.push(...t.children), t = o.pop();
3532
+ return n;
3533
+ }
3534
+ _build(t, n, o, i) {
3535
+ const s = o - n + 1;
3536
+ let r = this._maxEntries, l;
3537
+ if (s <= r)
3538
+ return l = Ee(t.slice(n, o + 1)), we(l, this.toBBox), l;
3539
+ i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), l = Ee([]), l.leaf = !1, l.height = i;
3540
+ const a = Math.ceil(s / r), d = a * Math.ceil(Math.sqrt(r));
3541
+ Yt(t, n, o, d, this.compareMinX);
3542
+ for (let h = n; h <= o; h += d) {
3543
+ const c = Math.min(h + d - 1, o);
3544
+ Yt(t, h, c, a, this.compareMinY);
3545
+ for (let f = h; f <= c; f += a) {
3546
+ const m = Math.min(f + a - 1, c);
3547
+ l.children.push(this._build(t, f, m, i - 1));
3548
+ }
3549
+ }
3550
+ return we(l, this.toBBox), l;
3551
+ }
3552
+ _chooseSubtree(t, n, o, i) {
3553
+ for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
3554
+ let s = 1 / 0, r = 1 / 0, l;
3555
+ for (let a = 0; a < n.children.length; a++) {
3556
+ const d = n.children[a], h = Ke(d), c = oi(t, d) - h;
3557
+ c < r ? (r = c, s = h < s ? h : s, l = d) : c === r && h < s && (s = h, l = d);
3558
+ }
3559
+ n = l || n.children[0];
3560
+ }
3561
+ return n;
3562
+ }
3563
+ _insert(t, n, o) {
3564
+ const i = o ? t : this.toBBox(t), s = [], r = this._chooseSubtree(i, this.data, n, s);
3565
+ for (r.children.push(t), Be(r, i); n >= 0 && s[n].children.length > this._maxEntries; )
3566
+ this._split(s, n), n--;
3567
+ this._adjustParentBBoxes(i, s, n);
3568
+ }
3569
+ // split overflowed node into two
3570
+ _split(t, n) {
3571
+ const o = t[n], i = o.children.length, s = this._minEntries;
3572
+ this._chooseSplitAxis(o, s, i);
3573
+ const r = this._chooseSplitIndex(o, s, i), l = Ee(o.children.splice(r, o.children.length - r));
3574
+ l.height = o.height, l.leaf = o.leaf, we(o, this.toBBox), we(l, this.toBBox), n ? t[n - 1].children.push(l) : this._splitRoot(o, l);
3575
+ }
3576
+ _splitRoot(t, n) {
3577
+ this.data = Ee([t, n]), this.data.height = t.height + 1, this.data.leaf = !1, we(this.data, this.toBBox);
3578
+ }
3579
+ _chooseSplitIndex(t, n, o) {
3580
+ let i, s = 1 / 0, r = 1 / 0;
3581
+ for (let l = n; l <= o - n; l++) {
3582
+ const a = ve(t, 0, l, this.toBBox), d = ve(t, l, o, this.toBBox), h = ii(a, d), c = Ke(a) + Ke(d);
3583
+ h < s ? (s = h, i = l, r = c < r ? c : r) : h === s && c < r && (r = c, i = l);
3584
+ }
3585
+ return i || o - n;
3586
+ }
3587
+ // sorts node children by the best axis for split
3588
+ _chooseSplitAxis(t, n, o) {
3589
+ const i = t.leaf ? this.compareMinX : ti, s = t.leaf ? this.compareMinY : ni, r = this._allDistMargin(t, n, o, i), l = this._allDistMargin(t, n, o, s);
3590
+ r < l && t.children.sort(i);
3591
+ }
3592
+ // total margin of all possible split distributions where each node is at least m full
3593
+ _allDistMargin(t, n, o, i) {
3594
+ t.children.sort(i);
3595
+ const s = this.toBBox, r = ve(t, 0, n, s), l = ve(t, o - n, o, s);
3596
+ let a = Ne(r) + Ne(l);
3597
+ for (let d = n; d < o - n; d++) {
3598
+ const h = t.children[d];
3599
+ Be(r, t.leaf ? s(h) : h), a += Ne(r);
3600
+ }
3601
+ for (let d = o - n - 1; d >= n; d--) {
3602
+ const h = t.children[d];
3603
+ Be(l, t.leaf ? s(h) : h), a += Ne(l);
3604
+ }
3605
+ return a;
3606
+ }
3607
+ _adjustParentBBoxes(t, n, o) {
3608
+ for (let i = o; i >= 0; i--)
3609
+ Be(n[i], t);
3610
+ }
3611
+ _condense(t) {
3612
+ for (let n = t.length - 1, o; n >= 0; n--)
3613
+ t[n].children.length === 0 ? n > 0 ? (o = t[n - 1].children, o.splice(o.indexOf(t[n]), 1)) : this.clear() : we(t[n], this.toBBox);
3614
+ }
3615
+ }
3616
+ function ei(e, t, n) {
3617
+ if (!n)
3618
+ return t.indexOf(e);
3619
+ for (let o = 0; o < t.length; o++)
3620
+ if (n(e, t[o]))
3621
+ return o;
3622
+ return -1;
3623
+ }
3624
+ function we(e, t) {
3625
+ ve(e, 0, e.children.length, t, e);
3626
+ }
3627
+ function ve(e, t, n, o, i) {
3628
+ i || (i = Ee(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
3629
+ for (let s = t; s < n; s++) {
3630
+ const r = e.children[s];
3631
+ Be(i, e.leaf ? o(r) : r);
3632
+ }
3633
+ return i;
3634
+ }
3635
+ function Be(e, t) {
3636
+ return e.minX = Math.min(e.minX, t.minX), e.minY = Math.min(e.minY, t.minY), e.maxX = Math.max(e.maxX, t.maxX), e.maxY = Math.max(e.maxY, t.maxY), e;
3637
+ }
3638
+ function ti(e, t) {
3639
+ return e.minX - t.minX;
3640
+ }
3641
+ function ni(e, t) {
3642
+ return e.minY - t.minY;
3643
+ }
3644
+ function Ke(e) {
3645
+ return (e.maxX - e.minX) * (e.maxY - e.minY);
3646
+ }
3647
+ function Ne(e) {
3648
+ return e.maxX - e.minX + (e.maxY - e.minY);
3649
+ }
3650
+ function oi(e, t) {
3651
+ return (Math.max(t.maxX, e.maxX) - Math.min(t.minX, e.minX)) * (Math.max(t.maxY, e.maxY) - Math.min(t.minY, e.minY));
3652
+ }
3653
+ function ii(e, t) {
3654
+ const n = Math.max(e.minX, t.minX), o = Math.max(e.minY, t.minY), i = Math.min(e.maxX, t.maxX), s = Math.min(e.maxY, t.maxY);
3655
+ return Math.max(0, i - n) * Math.max(0, s - o);
3656
+ }
3657
+ function xe(e, t) {
3658
+ return e.minX <= t.minX && e.minY <= t.minY && t.maxX <= e.maxX && t.maxY <= e.maxY;
3659
+ }
3660
+ function Ue(e, t) {
3661
+ return t.minX <= e.maxX && t.minY <= e.maxY && t.maxX >= e.minX && t.maxY >= e.minY;
3662
+ }
3663
+ function Ee(e) {
3664
+ return {
3665
+ children: e,
3666
+ height: 1,
3667
+ leaf: !0,
3668
+ minX: 1 / 0,
3669
+ minY: 1 / 0,
3670
+ maxX: -1 / 0,
3671
+ maxY: -1 / 0
3672
+ };
3673
+ }
3674
+ function Yt(e, t, n, o, i) {
3675
+ const s = [t, n];
3676
+ for (; s.length; ) {
3677
+ if (n = s.pop(), t = s.pop(), n - t <= o)
3678
+ continue;
3679
+ const r = t + Math.ceil((n - t) / o / 2) * o;
3680
+ Ko(e, r, t, n, i), s.push(t, r, r, n);
3681
+ }
3682
+ }
3683
+ const si = () => {
3684
+ const e = new $o(), t = /* @__PURE__ */ new Map(), n = () => [...t.values()], o = () => {
3685
+ e.clear(), t.clear();
3686
+ }, i = (c) => {
3687
+ const { minX: f, minY: m, maxX: g, maxY: p } = c.selector.geometry.bounds, y = { minX: f, minY: m, maxX: g, maxY: p, target: c };
3688
+ e.insert(y), t.set(c.annotation, y);
3689
+ }, s = (c) => {
3690
+ const f = t.get(c.annotation);
3691
+ e.remove(f), t.delete(c.annotation);
3692
+ };
3693
+ return {
3694
+ all: n,
3695
+ clear: o,
3696
+ getAt: (c, f) => {
3697
+ const g = e.search({
3698
+ minX: c,
3699
+ minY: f,
3700
+ maxX: c,
3701
+ maxY: f
3702
+ }).map((p) => p.target).filter((p) => p.selector.type === z.RECTANGLE || ln(p.selector, c, f));
3703
+ if (g.length > 0)
3704
+ return g.sort((p, y) => ut(p.selector) - ut(y.selector)), g[0];
3705
+ },
3706
+ getIntersecting: (c, f, m, g) => e.search({
3707
+ minX: c,
3708
+ minY: f,
3709
+ maxX: c + m,
3710
+ maxY: f + g
3711
+ }).map((p) => p.target),
3712
+ insert: i,
3713
+ remove: s,
3714
+ set: (c, f = !0) => {
3715
+ f && o();
3716
+ const m = c.map((g) => {
3717
+ const { minX: p, minY: y, maxX: L, maxY: E } = g.selector.geometry.bounds;
3718
+ return { minX: p, minY: y, maxX: L, maxY: E, target: g };
3719
+ });
3720
+ m.forEach((g) => t.set(g.target.annotation, g)), e.load(m);
3721
+ },
3722
+ size: () => e.all().length,
3723
+ update: (c, f) => {
3724
+ s(c), i(f);
3725
+ }
3726
+ };
3727
+ }, ri = (e) => {
3728
+ const t = Pn(), n = si(), o = Sn(t, e.pointerSelectAction), i = Tn(t), s = Rn();
3729
+ return t.observe(({ changes: a }) => {
3730
+ n.set(a.created.map((d) => d.target), !1), a.deleted.forEach((d) => n.remove(d.target)), a.updated.forEach(({ oldValue: d, newValue: h }) => n.update(d.target, h.target));
3731
+ }), {
3732
+ store: {
3733
+ ...t,
3734
+ getAt: (a, d) => {
3735
+ const h = n.getAt(a, d);
3736
+ return h ? t.getAnnotation(h.annotation) : void 0;
3737
+ },
3738
+ getIntersecting: (a, d, h, c) => n.getIntersecting(a, d, h, c).map((f) => t.getAnnotation(f.annotation))
3739
+ },
3740
+ selection: o,
3741
+ hover: i,
3742
+ viewport: s
3743
+ };
3744
+ }, li = (e) => {
3745
+ const t = ri(e);
3746
+ return {
3747
+ ...t,
3748
+ store: Yn(t.store)
3749
+ };
3750
+ }, ai = (e) => {
3751
+ let t, n;
3752
+ if (e.nodeName === "CANVAS")
3753
+ t = e, n = t.getContext("2d", { willReadFrequently: !0 });
3754
+ else {
3755
+ const i = e;
3756
+ t = document.createElement("canvas"), t.width = i.width, t.height = i.height, n = t.getContext("2d", { willReadFrequently: !0 }), n.drawImage(i, 0, 0, i.width, i.height);
3757
+ }
3758
+ let o = 0;
3759
+ for (let i = 1; i < 10; i++)
3760
+ for (let s = 1; s < 10; s++) {
3761
+ const r = Math.round(s * t.width / 10), l = Math.round(i * t.height / 10), a = n.getImageData(r, l, 1, 1).data, d = (0.299 * a[0] + 0.587 * a[1] + 0.114 * a[2]) / 255;
3762
+ o += d;
3763
+ }
3764
+ return o / 81;
3765
+ }, ci = (e, t) => {
3766
+ const n = ai(e), o = n > 0.6 ? "dark" : "light";
3767
+ console.log(`[Annotorious] Image brightness: ${n.toFixed(1)}. Setting ${o} theme.`), t.setAttribute("data-theme", o);
3768
+ }, fi = (e) => ({
3769
+ ...e,
3770
+ drawingEnabled: e.drawingEnabled === void 0 ? !0 : e.drawingEnabled,
3771
+ drawingMode: e.drawingMode || "drag",
3772
+ pointerSelectAction: e.pointerSelectAction || Ft.EDIT
3773
+ });
3774
+ const wi = (e, t = {}) => {
3775
+ if (!e)
3776
+ throw "Missing argument: image";
3777
+ const n = typeof e == "string" ? document.getElementById(e) : e, o = fi(t), i = li(o), { hover: s, selection: r, store: l } = i, a = Xn(
3778
+ l,
3779
+ r,
3780
+ s,
3781
+ void 0,
3782
+ o.adapter,
3783
+ o.autoSave
3784
+ );
3785
+ let d = zn(), h = o.style;
3786
+ const c = document.createElement("DIV");
3787
+ c.style.position = "relative", c.style.display = "inline-block", n.style.display = "block", n.parentNode.insertBefore(c, n), c.appendChild(n), ci(n, c);
3788
+ const f = new Zo({
3789
+ target: c,
3790
+ props: {
3791
+ drawingEnabled: o.drawingEnabled,
3792
+ image: n,
3793
+ preferredDrawingMode: o.drawingMode,
3794
+ state: i,
3795
+ style: h,
3796
+ user: d
3797
+ }
3798
+ });
3799
+ f.$on("click", (X) => {
3800
+ const { originalEvent: _, annotation: w } = X.detail;
3801
+ w ? r.clickSelect(w.id, _) : r.isEmpty() || r.clear();
3802
+ });
3803
+ const m = Nn(l, o.adapter), g = (X) => {
3804
+ h = X, f.$set({ style: h });
3805
+ }, p = () => {
3806
+ f.$destroy(), c.parentNode.insertBefore(n, c), c.parentNode.removeChild(c);
3807
+ }, y = () => d, L = (X, _, w) => Oo(X, _, w), E = (X, _) => ao(X, _), k = (X) => {
3808
+ const { tool: _, opts: w } = Vt(X);
3809
+ f.$set({ tool: _, opts: w });
3810
+ }, b = (X) => f.$set({ drawingEnabled: X }), Y = (X) => {
3811
+ X ? r.setSelected(X) : r.clear();
3812
+ }, U = (X) => {
3813
+ d = X, f.$set({ user: X });
3814
+ };
3815
+ return {
3816
+ ...m,
3817
+ get style() {
3818
+ return h;
3819
+ },
3820
+ set style(X) {
3821
+ g(X);
3822
+ },
3823
+ destroy: p,
3824
+ getUser: y,
3825
+ listDrawingTools: Lo,
3826
+ on: a.on,
3827
+ off: a.off,
3828
+ registerDrawingTool: L,
3829
+ registerShapeEditor: E,
3830
+ setDrawingEnabled: b,
3831
+ setDrawingTool: k,
3832
+ setSelected: Y,
3833
+ setUser: U,
3834
+ state: i
3835
+ };
3836
+ };
3837
+ export {
3838
+ jt as Editor,
3839
+ mo as EditorMount,
3840
+ M as Handle,
3841
+ yi as IdentityTransform,
3842
+ mi as PRESENCE_KEY,
3843
+ oo as PolygonEditor,
3844
+ lo as RectangleEditor,
3845
+ fn as RectangleUtil,
3846
+ wo as RubberbandRectangle,
3847
+ Zo as SVGAnnotationLayer,
3848
+ z as ShapeType,
3849
+ po as ToolMount,
3850
+ pi as W3CImageFormat,
3851
+ Ho as addEventListeners,
3852
+ He as boundsFromPoints,
3853
+ ut as computeArea,
3854
+ zn as createAnonymousGuest,
3855
+ Nn as createBaseAnnotator,
3856
+ di as createBody,
3857
+ Qn as createDefaultAppearenceProvider,
3858
+ wi as createImageAnnotator,
3859
+ ri as createImageAnnotatorState,
3860
+ gi as createPresenceState,
3861
+ Uo as createSVGTransform,
3862
+ li as createSvelteImageAnnotatorState,
3863
+ Jn as defaultColorProvider,
3864
+ kn as diffAnnotations,
3865
+ At as distance,
3866
+ Eo as enableResponsive,
3867
+ fi as fillDefaults,
3868
+ ui as getContributors,
3869
+ wt as getEditor,
3870
+ Vt as getTool,
3871
+ ln as intersects,
3872
+ _i as isTouch,
3873
+ Lo as listDrawingTools,
3874
+ Dn as parseAll,
3875
+ un as parseFragmentSelector,
3876
+ _n as parseSVGSelector,
3877
+ Vn as parseW3CBodies,
3878
+ xn as parseW3CImageAnnotation,
3879
+ ao as registerEditor,
3880
+ ot as registerShapeUtil,
3881
+ Oo as registerTool,
3882
+ ai as sampleBrightness,
3883
+ hi as serializeAll,
3884
+ dn as serializeFragmentSelector,
3885
+ yn as serializeSVGSelector,
3886
+ qn as serializeW3CBodies,
3887
+ $n as serializeW3CImageAnnotation,
3888
+ ci as setTheme
3889
+ };
3890
+ //# sourceMappingURL=annotorious.es.js.map