@annotorious/svelte 3.0.0-rc.19 → 3.0.0-rc.20

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 (33) hide show
  1. package/dist/annotorious-svelte.es.js +9 -9
  2. package/dist/annotorious-svelte.es10.js +19 -106
  3. package/dist/annotorious-svelte.es10.js.map +1 -1
  4. package/dist/annotorious-svelte.es11.js +113 -2
  5. package/dist/annotorious-svelte.es11.js.map +1 -1
  6. package/dist/annotorious-svelte.es12.js +2 -4
  7. package/dist/annotorious-svelte.es12.js.map +1 -1
  8. package/dist/annotorious-svelte.es13.js +2 -120
  9. package/dist/annotorious-svelte.es13.js.map +1 -1
  10. package/dist/annotorious-svelte.es14.js +27437 -0
  11. package/dist/annotorious-svelte.es14.js.map +1 -1
  12. package/dist/annotorious-svelte.es15.js +115 -51
  13. package/dist/annotorious-svelte.es15.js.map +1 -1
  14. package/dist/annotorious-svelte.es16.js +2 -0
  15. package/dist/annotorious-svelte.es16.js.map +1 -0
  16. package/dist/annotorious-svelte.es17.js +59 -0
  17. package/dist/annotorious-svelte.es17.js.map +1 -0
  18. package/dist/annotorious-svelte.es2.js +6 -6
  19. package/dist/annotorious-svelte.es3.js +40 -35
  20. package/dist/annotorious-svelte.es3.js.map +1 -1
  21. package/dist/annotorious-svelte.es4.js +4211 -86
  22. package/dist/annotorious-svelte.es4.js.map +1 -1
  23. package/dist/annotorious-svelte.es5.js +91 -104
  24. package/dist/annotorious-svelte.es5.js.map +1 -1
  25. package/dist/annotorious-svelte.es6.js +122 -92
  26. package/dist/annotorious-svelte.es6.js.map +1 -1
  27. package/dist/annotorious-svelte.es7.js +87 -31
  28. package/dist/annotorious-svelte.es7.js.map +1 -1
  29. package/dist/annotorious-svelte.es8.js +40 -30
  30. package/dist/annotorious-svelte.es8.js.map +1 -1
  31. package/dist/annotorious-svelte.es9.js +27 -20
  32. package/dist/annotorious-svelte.es9.js.map +1 -1
  33. package/package.json +13 -8
@@ -1,59 +1,123 @@
1
- import { run_all as i } from "./annotorious-svelte.es6.js";
2
- import { set_current_component as a, current_component as u } from "./annotorious-svelte.es9.js";
3
- const r = [], h = [];
4
- let c = [];
5
- const d = [], p = /* @__PURE__ */ Promise.resolve();
6
- let f = !1;
7
- function w() {
8
- f || (f = !0, p.then(m));
9
- }
10
- function _(e) {
11
- c.push(e);
12
- }
13
- const s = /* @__PURE__ */ new Set();
14
- let l = 0;
15
- function m() {
16
- if (l !== 0)
1
+ var F = { dragStart: !0 }, rt = (e, s, i) => Math.min(Math.max(e, s), i), G = (e) => typeof e == "string", dt = ([e, s], i, d) => {
2
+ const u = (y, f) => f === 0 ? 0 : Math.ceil(y / f) * f;
3
+ return [u(i, e), u(d, s)];
4
+ }, ot = (e, s) => e.some((i) => s.some((d) => i.contains(d)));
5
+ function I(e, s) {
6
+ if (e === void 0)
17
7
  return;
18
- const e = u;
19
- do {
20
- try {
21
- for (; l < r.length; ) {
22
- const t = r[l];
23
- l++, a(t), g(t.$$);
8
+ if (J(e))
9
+ return e.getBoundingClientRect();
10
+ if (typeof e == "object") {
11
+ const { top: d = 0, left: u = 0, right: y = 0, bottom: f = 0 } = e;
12
+ return { top: d, right: window.innerWidth - y, bottom: window.innerHeight - f, left: u };
13
+ }
14
+ if (e === "parent")
15
+ return s.parentNode.getBoundingClientRect();
16
+ const i = document.querySelector(e);
17
+ if (i === null)
18
+ throw new Error("The selector provided for bound doesn't exists in the document.");
19
+ return i.getBoundingClientRect();
20
+ }
21
+ var H = (e, s, i) => e.style.setProperty(s, i), J = (e) => e instanceof HTMLElement, ut = (e, s = {}) => {
22
+ let i, d, { bounds: u, axis: y = "both", gpuAcceleration: f = !0, legacyTranslate: K = !0, transform: L, applyUserSelectHack: P = !0, disabled: O = !1, ignoreMultitouch: Q = !1, recomputeBounds: x = F, grid: T, position: p, cancel: N, handle: D, defaultClass: M = "neodrag", defaultClassDragging: X = "neodrag-dragging", defaultClassDragged: S = "neodrag-dragged", defaultPosition: it = { x: 0, y: 0 }, onDragStart: at, onDrag: st, onDragEnd: lt } = s, B = !1, b = 0, w = 0, A = 0, C = 0, Y = 0, q = 0, { x: $, y: R } = p ? { x: (p == null ? void 0 : p.x) ?? 0, y: (p == null ? void 0 : p.y) ?? 0 } : it;
23
+ W($, R);
24
+ let g, v, E, k, V, Z = "", ct = !!p;
25
+ x = { ...F, ...x };
26
+ const U = document.body.style, m = e.classList;
27
+ function W(t = b, r = w) {
28
+ if (!L) {
29
+ if (K) {
30
+ let a = `${+t}px, ${+r}px`;
31
+ return H(e, "transform", f ? `translate3d(${a}, 0)` : `translate(${a})`);
24
32
  }
25
- } catch (t) {
26
- throw r.length = 0, l = 0, t;
33
+ return H(e, "translate", `${+t}px ${+r}px ${f ? "1px" : ""}`);
34
+ }
35
+ const o = L({ offsetX: t, offsetY: r, rootNode: e });
36
+ G(o) && H(e, "transform", o);
37
+ }
38
+ const j = (t, r) => {
39
+ const o = { offsetX: b, offsetY: w, rootNode: e, currentNode: V };
40
+ e.dispatchEvent(new CustomEvent(t, { detail: o })), r == null || r(o);
41
+ }, z = addEventListener;
42
+ z("pointerdown", tt, !1), z("pointerup", et, !1), z("pointermove", nt, !1), H(e, "touch-action", "none");
43
+ const _ = () => {
44
+ let t = e.offsetWidth / v.width;
45
+ return isNaN(t) && (t = 1), t;
46
+ };
47
+ function tt(t) {
48
+ if (O || t.button === 2 || Q && !t.isPrimary)
49
+ return;
50
+ if (x.dragStart && (g = I(u, e)), G(D) && G(N) && D === N)
51
+ throw new Error("`handle` selector can't be same as `cancel` selector");
52
+ if (m.add(M), E = function(n, c) {
53
+ if (!n)
54
+ return [c];
55
+ if (J(n))
56
+ return [n];
57
+ if (Array.isArray(n))
58
+ return n;
59
+ const h = c.querySelectorAll(n);
60
+ if (h === null)
61
+ throw new Error("Selector passed for `handle` option should be child of the element on which the action is applied");
62
+ return Array.from(h.values());
63
+ }(D, e), k = function(n, c) {
64
+ if (!n)
65
+ return [];
66
+ if (J(n))
67
+ return [n];
68
+ if (Array.isArray(n))
69
+ return n;
70
+ const h = c.querySelectorAll(n);
71
+ if (h === null)
72
+ throw new Error("Selector passed for `cancel` option should be child of the element on which the action is applied");
73
+ return Array.from(h.values());
74
+ }(N, e), i = /(both|x)/.test(y), d = /(both|y)/.test(y), ot(k, E))
75
+ throw new Error("Element being dragged can't be a child of the element on which `cancel` is applied");
76
+ const r = t.composedPath()[0];
77
+ if (!E.some((n) => {
78
+ var c;
79
+ return n.contains(r) || ((c = n.shadowRoot) == null ? void 0 : c.contains(r));
80
+ }) || ot(k, [r]))
81
+ return;
82
+ V = E.length === 1 ? e : E.find((n) => n.contains(r)), B = !0, v = e.getBoundingClientRect(), P && (Z = U.userSelect, U.userSelect = "none"), j("neodrag:start", at);
83
+ const { clientX: o, clientY: a } = t, l = _();
84
+ i && (A = o - $ / l), d && (C = a - R / l), g && (Y = o - v.left, q = a - v.top);
85
+ }
86
+ function et() {
87
+ B && (x.dragEnd && (g = I(u, e)), m.remove(X), m.add(S), P && (U.userSelect = Z), j("neodrag:end", lt), i && (A = b), d && (C = w), B = !1);
88
+ }
89
+ function nt(t) {
90
+ if (!B)
91
+ return;
92
+ x.drag && (g = I(u, e)), m.add(X), t.preventDefault(), v = e.getBoundingClientRect();
93
+ let r = t.clientX, o = t.clientY;
94
+ const a = _();
95
+ if (g) {
96
+ const l = { left: g.left + Y, top: g.top + q, right: g.right + Y - v.width, bottom: g.bottom + q - v.height };
97
+ r = rt(r, l.left, l.right), o = rt(o, l.top, l.bottom);
27
98
  }
28
- for (a(null), r.length = 0, l = 0; h.length; )
29
- h.pop()();
30
- for (let t = 0; t < c.length; t += 1) {
31
- const n = c[t];
32
- s.has(n) || (s.add(n), n());
99
+ if (Array.isArray(T)) {
100
+ let [l, n] = T;
101
+ if (isNaN(+l) || l < 0)
102
+ throw new Error("1st argument of `grid` must be a valid positive number");
103
+ if (isNaN(+n) || n < 0)
104
+ throw new Error("2nd argument of `grid` must be a valid positive number");
105
+ let c = r - A, h = o - C;
106
+ [c, h] = dt([l / a, n / a], c, h), r = A + c, o = C + h;
33
107
  }
34
- c.length = 0;
35
- } while (r.length);
36
- for (; d.length; )
37
- d.pop()();
38
- f = !1, s.clear(), a(e);
39
- }
40
- function g(e) {
41
- if (e.fragment !== null) {
42
- e.update(), i(e.before_update);
43
- const t = e.dirty;
44
- e.dirty = [-1], e.fragment && e.fragment.p(e.ctx, t), e.after_update.forEach(_);
108
+ i && (b = Math.round((r - A) * a)), d && (w = Math.round((o - C) * a)), $ = b, R = w, j("neodrag", st), W();
45
109
  }
46
- }
47
- function y(e) {
48
- const t = [], n = [];
49
- c.forEach((o) => e.indexOf(o) === -1 ? t.push(o) : n.push(o)), n.forEach((o) => o()), c = t;
50
- }
110
+ return { destroy: () => {
111
+ const t = removeEventListener;
112
+ t("pointerdown", tt, !1), t("pointerup", et, !1), t("pointermove", nt, !1);
113
+ }, update: (t) => {
114
+ var o, a;
115
+ y = t.axis || "both", O = t.disabled ?? !1, Q = t.ignoreMultitouch ?? !1, D = t.handle, u = t.bounds, x = t.recomputeBounds ?? F, N = t.cancel, P = t.applyUserSelectHack ?? !0, T = t.grid, f = t.gpuAcceleration ?? !0, K = t.legacyTranslate ?? !0, L = t.transform;
116
+ const r = m.contains(S);
117
+ m.remove(M, S), M = t.defaultClass ?? "neodrag", X = t.defaultClassDragging ?? "neodrag-dragging", S = t.defaultClassDragged ?? "neodrag-dragged", m.add(M), r && m.add(S), ct && ($ = b = ((o = t.position) == null ? void 0 : o.x) ?? b, R = w = ((a = t.position) == null ? void 0 : a.y) ?? w, W());
118
+ } };
119
+ };
51
120
  export {
52
- _ as add_render_callback,
53
- h as binding_callbacks,
54
- r as dirty_components,
55
- m as flush,
56
- y as flush_render_callbacks,
57
- w as schedule_update
121
+ ut as draggable
58
122
  };
59
123
  //# sourceMappingURL=annotorious-svelte.es15.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es15.js","sources":["../../../node_modules/svelte/src/runtime/internal/scheduler.js"],"sourcesContent":["import { run_all } from './utils.js';\nimport { current_component, set_current_component } from './lifecycle.js';\n\nexport const dirty_components = [];\nexport const intros = { enabled: false };\nexport const binding_callbacks = [];\n\nlet render_callbacks = [];\n\nconst flush_callbacks = [];\n\nconst resolved_promise = /* @__PURE__ */ Promise.resolve();\n\nlet update_scheduled = false;\n\n/** @returns {void} */\nexport function schedule_update() {\n\tif (!update_scheduled) {\n\t\tupdate_scheduled = true;\n\t\tresolved_promise.then(flush);\n\t}\n}\n\n/** @returns {Promise<void>} */\nexport function tick() {\n\tschedule_update();\n\treturn resolved_promise;\n}\n\n/** @returns {void} */\nexport function add_render_callback(fn) {\n\trender_callbacks.push(fn);\n}\n\n/** @returns {void} */\nexport function add_flush_callback(fn) {\n\tflush_callbacks.push(fn);\n}\n\n// flush() calls callbacks in this order:\n// 1. All beforeUpdate callbacks, in order: parents before children\n// 2. All bind:this callbacks, in reverse order: children before parents.\n// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT\n// for afterUpdates called during the initial onMount, which are called in\n// reverse order: children before parents.\n// Since callbacks might update component values, which could trigger another\n// call to flush(), the following steps guard against this:\n// 1. During beforeUpdate, any updated components will be added to the\n// dirty_components array and will cause a reentrant call to flush(). Because\n// the flush index is kept outside the function, the reentrant call will pick\n// up where the earlier call left off and go through all dirty components. The\n// current_component value is saved and restored so that the reentrant call will\n// not interfere with the \"parent\" flush() call.\n// 2. bind:this callbacks cannot trigger new flush() calls.\n// 3. During afterUpdate, any updated components will NOT have their afterUpdate\n// callback called a second time; the seen_callbacks set, outside the flush()\n// function, guarantees this behavior.\nconst seen_callbacks = new Set();\n\nlet flushidx = 0; // Do *not* move this inside the flush() function\n\n/** @returns {void} */\nexport function flush() {\n\t// Do not reenter flush while dirty components are updated, as this can\n\t// result in an infinite loop. Instead, let the inner flush handle it.\n\t// Reentrancy is ok afterwards for bindings etc.\n\tif (flushidx !== 0) {\n\t\treturn;\n\t}\n\tconst saved_component = current_component;\n\tdo {\n\t\t// first, call beforeUpdate functions\n\t\t// and update components\n\t\ttry {\n\t\t\twhile (flushidx < dirty_components.length) {\n\t\t\t\tconst component = dirty_components[flushidx];\n\t\t\t\tflushidx++;\n\t\t\t\tset_current_component(component);\n\t\t\t\tupdate(component.$$);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// reset dirty state to not end up in a deadlocked state and then rethrow\n\t\t\tdirty_components.length = 0;\n\t\t\tflushidx = 0;\n\t\t\tthrow e;\n\t\t}\n\t\tset_current_component(null);\n\t\tdirty_components.length = 0;\n\t\tflushidx = 0;\n\t\twhile (binding_callbacks.length) binding_callbacks.pop()();\n\t\t// then, once components are updated, call\n\t\t// afterUpdate functions. This may cause\n\t\t// subsequent updates...\n\t\tfor (let i = 0; i < render_callbacks.length; i += 1) {\n\t\t\tconst callback = render_callbacks[i];\n\t\t\tif (!seen_callbacks.has(callback)) {\n\t\t\t\t// ...so guard against infinite loops\n\t\t\t\tseen_callbacks.add(callback);\n\t\t\t\tcallback();\n\t\t\t}\n\t\t}\n\t\trender_callbacks.length = 0;\n\t} while (dirty_components.length);\n\twhile (flush_callbacks.length) {\n\t\tflush_callbacks.pop()();\n\t}\n\tupdate_scheduled = false;\n\tseen_callbacks.clear();\n\tset_current_component(saved_component);\n}\n\n/** @returns {void} */\nfunction update($$) {\n\tif ($$.fragment !== null) {\n\t\t$$.update();\n\t\trun_all($$.before_update);\n\t\tconst dirty = $$.dirty;\n\t\t$$.dirty = [-1];\n\t\t$$.fragment && $$.fragment.p($$.ctx, dirty);\n\t\t$$.after_update.forEach(add_render_callback);\n\t}\n}\n\n/**\n * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function flush_render_callbacks(fns) {\n\tconst filtered = [];\n\tconst targets = [];\n\trender_callbacks.forEach((c) => (fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)));\n\ttargets.forEach((c) => c());\n\trender_callbacks = filtered;\n}\n"],"names":["dirty_components","binding_callbacks","render_callbacks","flush_callbacks","resolved_promise","update_scheduled","schedule_update","flush","add_render_callback","fn","seen_callbacks","flushidx","saved_component","current_component","component","set_current_component","update","e","i","callback","$$","run_all","dirty","flush_render_callbacks","fns","filtered","targets","c"],"mappings":";;AAGY,MAACA,IAAmB,CAAG,GAEtBC,IAAoB,CAAG;AAEpC,IAAIC,IAAmB,CAAA;AAEvB,MAAMC,IAAkB,CAAA,GAElBC,IAAmC,wBAAQ;AAEjD,IAAIC,IAAmB;AAGhB,SAASC,IAAkB;AACjC,EAAKD,MACJA,IAAmB,IACnBD,EAAiB,KAAKG,CAAK;AAE7B;AASO,SAASC,EAAoBC,GAAI;AACvC,EAAAP,EAAiB,KAAKO,CAAE;AACzB;AAyBA,MAAMC,IAAiB,oBAAI;AAE3B,IAAIC,IAAW;AAGR,SAASJ,IAAQ;AAIvB,MAAII,MAAa;AAChB;AAED,QAAMC,IAAkBC;AACxB,KAAG;AAGF,QAAI;AACH,aAAOF,IAAWX,EAAiB,UAAQ;AAC1C,cAAMc,IAAYd,EAAiBW,CAAQ;AAC3C,QAAAA,KACAI,EAAsBD,CAAS,GAC/BE,EAAOF,EAAU,EAAE;AAAA,MACnB;AAAA,IACD,SAAQG,GAAG;AAEX,YAAAjB,EAAiB,SAAS,GAC1BW,IAAW,GACLM;AAAA,IACN;AAID,SAHAF,EAAsB,IAAI,GAC1Bf,EAAiB,SAAS,GAC1BW,IAAW,GACJV,EAAkB;AAAQ,MAAAA,EAAkB,IAAK,EAAA;AAIxD,aAASiB,IAAI,GAAGA,IAAIhB,EAAiB,QAAQgB,KAAK,GAAG;AACpD,YAAMC,IAAWjB,EAAiBgB,CAAC;AACnC,MAAKR,EAAe,IAAIS,CAAQ,MAE/BT,EAAe,IAAIS,CAAQ,GAC3BA;IAED;AACD,IAAAjB,EAAiB,SAAS;AAAA,EAC5B,SAAUF,EAAiB;AAC1B,SAAOG,EAAgB;AACtB,IAAAA,EAAgB,IAAG;AAEpB,EAAAE,IAAmB,IACnBK,EAAe,MAAK,GACpBK,EAAsBH,CAAe;AACtC;AAGA,SAASI,EAAOI,GAAI;AACnB,MAAIA,EAAG,aAAa,MAAM;AACzB,IAAAA,EAAG,OAAM,GACTC,EAAQD,EAAG,aAAa;AACxB,UAAME,IAAQF,EAAG;AACjB,IAAAA,EAAG,QAAQ,CAAC,EAAE,GACdA,EAAG,YAAYA,EAAG,SAAS,EAAEA,EAAG,KAAKE,CAAK,GAC1CF,EAAG,aAAa,QAAQZ,CAAmB;AAAA,EAC3C;AACF;AAOO,SAASe,EAAuBC,GAAK;AAC3C,QAAMC,IAAW,CAAA,GACXC,IAAU,CAAA;AAChB,EAAAxB,EAAiB,QAAQ,CAACyB,MAAOH,EAAI,QAAQG,CAAC,MAAM,KAAKF,EAAS,KAAKE,CAAC,IAAID,EAAQ,KAAKC,CAAC,CAAE,GAC5FD,EAAQ,QAAQ,CAACC,MAAMA,EAAG,CAAA,GAC1BzB,IAAmBuB;AACpB;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"annotorious-svelte.es15.js","sources":["../../../node_modules/@neodrag/svelte/dist/min/index.js"],"sourcesContent":["var t={dragStart:!0},e=(t,e,n)=>Math.min(Math.max(t,e),n),n=t=>\"string\"==typeof t,r=([t,e],n,r)=>{const o=(t,e)=>0===e?0:Math.ceil(t/e)*e;return[o(n,t),o(r,e)]};var o=(t,e)=>t.some((t=>e.some((e=>t.contains(e)))));function i(t,e){if(void 0===t)return;if(s(t))return t.getBoundingClientRect();if(\"object\"==typeof t){const{top:e=0,left:n=0,right:r=0,bottom:o=0}=t;return{top:e,right:window.innerWidth-r,bottom:window.innerHeight-o,left:n}}if(\"parent\"===t)return e.parentNode.getBoundingClientRect();const n=document.querySelector(t);if(null===n)throw new Error(\"The selector provided for bound doesn't exists in the document.\");return n.getBoundingClientRect()}var a=(t,e,n)=>t.style.setProperty(e,n),s=t=>t instanceof HTMLElement,d=(d,l={})=>{let c,u,{bounds:f,axis:g=\"both\",gpuAcceleration:h=!0,legacyTranslate:p=!0,transform:m,applyUserSelectHack:y=!0,disabled:b=!1,ignoreMultitouch:w=!1,recomputeBounds:v=t,grid:x,position:E,cancel:S,handle:A,defaultClass:C=\"neodrag\",defaultClassDragging:N=\"neodrag-dragging\",defaultClassDragged:D=\"neodrag-dragged\",defaultPosition:M={x:0,y:0},onDragStart:B,onDrag:$,onDragEnd:R}=l,H=!1,L=0,P=0,T=0,X=0,Y=0,q=0,{x:k,y:U}=E?{x:E?.x??0,y:E?.y??0}:M;Q(k,U);let W,j,z,F,G,I=\"\",J=!!E;v={...t,...v};const K=document.body.style,O=d.classList;function Q(t=L,e=P){if(!m){if(p){let n=`${+t}px, ${+e}px`;return a(d,\"transform\",h?`translate3d(${n}, 0)`:`translate(${n})`)}return a(d,\"translate\",`${+t}px ${+e}px ${h?\"1px\":\"\"}`)}const r=m({offsetX:t,offsetY:e,rootNode:d});n(r)&&a(d,\"transform\",r)}const V=(t,e)=>{const n={offsetX:L,offsetY:P,rootNode:d,currentNode:G};d.dispatchEvent(new CustomEvent(t,{detail:n})),e?.(n)};const Z=addEventListener;Z(\"pointerdown\",tt,!1),Z(\"pointerup\",et,!1),Z(\"pointermove\",nt,!1),a(d,\"touch-action\",\"none\");const _=()=>{let t=d.offsetWidth/j.width;return isNaN(t)&&(t=1),t};function tt(t){if(b)return;if(2===t.button)return;if(w&&!t.isPrimary)return;if(v.dragStart&&(W=i(f,d)),n(A)&&n(S)&&A===S)throw new Error(\"`handle` selector can't be same as `cancel` selector\");if(O.add(C),z=function(t,e){if(!t)return[e];if(s(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `handle` option should be child of the element on which the action is applied\");return Array.from(n.values())}(A,d),F=function(t,e){if(!t)return[];if(s(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `cancel` option should be child of the element on which the action is applied\");return Array.from(n.values())}(S,d),c=/(both|x)/.test(g),u=/(both|y)/.test(g),o(F,z))throw new Error(\"Element being dragged can't be a child of the element on which `cancel` is applied\");const e=t.composedPath()[0];if(!z.some((t=>t.contains(e)||t.shadowRoot?.contains(e)))||o(F,[e]))return;G=1===z.length?d:z.find((t=>t.contains(e))),H=!0,j=d.getBoundingClientRect(),y&&(I=K.userSelect,K.userSelect=\"none\"),V(\"neodrag:start\",B);const{clientX:r,clientY:a}=t,l=_();c&&(T=r-k/l),u&&(X=a-U/l),W&&(Y=r-j.left,q=a-j.top)}function et(){H&&(v.dragEnd&&(W=i(f,d)),O.remove(N),O.add(D),y&&(K.userSelect=I),V(\"neodrag:end\",R),c&&(T=L),u&&(X=P),H=!1)}function nt(t){if(!H)return;v.drag&&(W=i(f,d)),O.add(N),t.preventDefault(),j=d.getBoundingClientRect();let n=t.clientX,o=t.clientY;const a=_();if(W){const t={left:W.left+Y,top:W.top+q,right:W.right+Y-j.width,bottom:W.bottom+q-j.height};n=e(n,t.left,t.right),o=e(o,t.top,t.bottom)}if(Array.isArray(x)){let[t,e]=x;if(isNaN(+t)||t<0)throw new Error(\"1st argument of `grid` must be a valid positive number\");if(isNaN(+e)||e<0)throw new Error(\"2nd argument of `grid` must be a valid positive number\");let i=n-T,s=o-X;[i,s]=r([t/a,e/a],i,s),n=T+i,o=X+s}c&&(L=Math.round((n-T)*a)),u&&(P=Math.round((o-X)*a)),k=L,U=P,V(\"neodrag\",$),Q()}return{destroy:()=>{const t=removeEventListener;t(\"pointerdown\",tt,!1),t(\"pointerup\",et,!1),t(\"pointermove\",nt,!1)},update:e=>{g=e.axis||\"both\",b=e.disabled??!1,w=e.ignoreMultitouch??!1,A=e.handle,f=e.bounds,v=e.recomputeBounds??t,S=e.cancel,y=e.applyUserSelectHack??!0,x=e.grid,h=e.gpuAcceleration??!0,p=e.legacyTranslate??!0,m=e.transform;const n=O.contains(D);O.remove(C,D),C=e.defaultClass??\"neodrag\",N=e.defaultClassDragging??\"neodrag-dragging\",D=e.defaultClassDragged??\"neodrag-dragged\",O.add(C),n&&O.add(D),J&&(k=L=e.position?.x??L,U=P=e.position?.y??P,Q())}}};export{d as draggable};"],"names":["t","e","n","r","o","i","s","a","d","l","c","u","f","g","h","p","m","y","b","w","v","x","E","S","A","C","N","D","M","B","$","R","H","L","P","T","X","k","U","Q","W","j","z","F","G","I","J","K","O","V","Z","_a","_b"],"mappings":"AAAA,IAAIA,IAAE,EAAC,WAAU,GAAE,GAAEC,KAAE,CAACD,GAAEC,GAAEC,MAAI,KAAK,IAAI,KAAK,IAAIF,GAAEC,CAAC,GAAEC,CAAC,GAAEA,IAAE,CAAAF,MAAa,OAAOA,KAAjB,UAAmBG,KAAE,CAAC,CAACH,GAAEC,CAAC,GAAEC,GAAEC,MAAI;AAAC,QAAMC,IAAE,CAACJ,GAAEC,MAAQA,MAAJ,IAAM,IAAE,KAAK,KAAKD,IAAEC,CAAC,IAAEA;AAAE,SAAM,CAACG,EAAEF,GAAEF,CAAC,GAAEI,EAAED,GAAEF,CAAC,CAAC;AAAC,GAAMG,KAAE,CAACJ,GAAEC,MAAID,EAAE,KAAM,CAAAA,MAAGC,EAAE,KAAM,CAAAA,MAAGD,EAAE,SAASC,CAAC,CAAC,CAAI;AAAC,SAASI,EAAEL,GAAEC,GAAE;AAAC,MAAYD,MAAT;AAAW;AAAO,MAAGM,EAAEN,CAAC;AAAE,WAAOA,EAAE,sBAAqB;AAAG,MAAa,OAAOA,KAAjB,UAAmB;AAAC,UAAK,EAAC,KAAIC,IAAE,GAAE,MAAKC,IAAE,GAAE,OAAMC,IAAE,GAAE,QAAOC,IAAE,EAAC,IAAEJ;AAAE,WAAM,EAAC,KAAIC,GAAE,OAAM,OAAO,aAAWE,GAAE,QAAO,OAAO,cAAYC,GAAE,MAAKF,EAAC;AAAA,EAAC;AAAC,MAAcF,MAAX;AAAa,WAAOC,EAAE,WAAW;AAAwB,QAAMC,IAAE,SAAS,cAAcF,CAAC;AAAE,MAAUE,MAAP;AAAS,UAAM,IAAI,MAA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lB,GAAEK,IAAEJ,MAAEkB,IAAAnD,EAAE,aAAF,gBAAAmD,EAAY,MAAGlB,GAAEK,EAAC;AAAA,EAAG,EAAC;AAAC;","x_google_ignoreList":[0]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=annotorious-svelte.es16.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotorious-svelte.es16.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import { run_all as i } from "./annotorious-svelte.es7.js";
2
+ import { set_current_component as a, current_component as u } from "./annotorious-svelte.es10.js";
3
+ const r = [], h = [];
4
+ let c = [];
5
+ const d = [], p = /* @__PURE__ */ Promise.resolve();
6
+ let f = !1;
7
+ function w() {
8
+ f || (f = !0, p.then(m));
9
+ }
10
+ function _(e) {
11
+ c.push(e);
12
+ }
13
+ const s = /* @__PURE__ */ new Set();
14
+ let l = 0;
15
+ function m() {
16
+ if (l !== 0)
17
+ return;
18
+ const e = u;
19
+ do {
20
+ try {
21
+ for (; l < r.length; ) {
22
+ const t = r[l];
23
+ l++, a(t), g(t.$$);
24
+ }
25
+ } catch (t) {
26
+ throw r.length = 0, l = 0, t;
27
+ }
28
+ for (a(null), r.length = 0, l = 0; h.length; )
29
+ h.pop()();
30
+ for (let t = 0; t < c.length; t += 1) {
31
+ const n = c[t];
32
+ s.has(n) || (s.add(n), n());
33
+ }
34
+ c.length = 0;
35
+ } while (r.length);
36
+ for (; d.length; )
37
+ d.pop()();
38
+ f = !1, s.clear(), a(e);
39
+ }
40
+ function g(e) {
41
+ if (e.fragment !== null) {
42
+ e.update(), i(e.before_update);
43
+ const t = e.dirty;
44
+ e.dirty = [-1], e.fragment && e.fragment.p(e.ctx, t), e.after_update.forEach(_);
45
+ }
46
+ }
47
+ function y(e) {
48
+ const t = [], n = [];
49
+ c.forEach((o) => e.indexOf(o) === -1 ? t.push(o) : n.push(o)), n.forEach((o) => o()), c = t;
50
+ }
51
+ export {
52
+ _ as add_render_callback,
53
+ h as binding_callbacks,
54
+ r as dirty_components,
55
+ m as flush,
56
+ y as flush_render_callbacks,
57
+ w as schedule_update
58
+ };
59
+ //# sourceMappingURL=annotorious-svelte.es17.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotorious-svelte.es17.js","sources":["../../../node_modules/svelte/src/runtime/internal/scheduler.js"],"sourcesContent":["import { run_all } from './utils.js';\nimport { current_component, set_current_component } from './lifecycle.js';\n\nexport const dirty_components = [];\nexport const intros = { enabled: false };\nexport const binding_callbacks = [];\n\nlet render_callbacks = [];\n\nconst flush_callbacks = [];\n\nconst resolved_promise = /* @__PURE__ */ Promise.resolve();\n\nlet update_scheduled = false;\n\n/** @returns {void} */\nexport function schedule_update() {\n\tif (!update_scheduled) {\n\t\tupdate_scheduled = true;\n\t\tresolved_promise.then(flush);\n\t}\n}\n\n/** @returns {Promise<void>} */\nexport function tick() {\n\tschedule_update();\n\treturn resolved_promise;\n}\n\n/** @returns {void} */\nexport function add_render_callback(fn) {\n\trender_callbacks.push(fn);\n}\n\n/** @returns {void} */\nexport function add_flush_callback(fn) {\n\tflush_callbacks.push(fn);\n}\n\n// flush() calls callbacks in this order:\n// 1. All beforeUpdate callbacks, in order: parents before children\n// 2. All bind:this callbacks, in reverse order: children before parents.\n// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT\n// for afterUpdates called during the initial onMount, which are called in\n// reverse order: children before parents.\n// Since callbacks might update component values, which could trigger another\n// call to flush(), the following steps guard against this:\n// 1. During beforeUpdate, any updated components will be added to the\n// dirty_components array and will cause a reentrant call to flush(). Because\n// the flush index is kept outside the function, the reentrant call will pick\n// up where the earlier call left off and go through all dirty components. The\n// current_component value is saved and restored so that the reentrant call will\n// not interfere with the \"parent\" flush() call.\n// 2. bind:this callbacks cannot trigger new flush() calls.\n// 3. During afterUpdate, any updated components will NOT have their afterUpdate\n// callback called a second time; the seen_callbacks set, outside the flush()\n// function, guarantees this behavior.\nconst seen_callbacks = new Set();\n\nlet flushidx = 0; // Do *not* move this inside the flush() function\n\n/** @returns {void} */\nexport function flush() {\n\t// Do not reenter flush while dirty components are updated, as this can\n\t// result in an infinite loop. Instead, let the inner flush handle it.\n\t// Reentrancy is ok afterwards for bindings etc.\n\tif (flushidx !== 0) {\n\t\treturn;\n\t}\n\tconst saved_component = current_component;\n\tdo {\n\t\t// first, call beforeUpdate functions\n\t\t// and update components\n\t\ttry {\n\t\t\twhile (flushidx < dirty_components.length) {\n\t\t\t\tconst component = dirty_components[flushidx];\n\t\t\t\tflushidx++;\n\t\t\t\tset_current_component(component);\n\t\t\t\tupdate(component.$$);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// reset dirty state to not end up in a deadlocked state and then rethrow\n\t\t\tdirty_components.length = 0;\n\t\t\tflushidx = 0;\n\t\t\tthrow e;\n\t\t}\n\t\tset_current_component(null);\n\t\tdirty_components.length = 0;\n\t\tflushidx = 0;\n\t\twhile (binding_callbacks.length) binding_callbacks.pop()();\n\t\t// then, once components are updated, call\n\t\t// afterUpdate functions. This may cause\n\t\t// subsequent updates...\n\t\tfor (let i = 0; i < render_callbacks.length; i += 1) {\n\t\t\tconst callback = render_callbacks[i];\n\t\t\tif (!seen_callbacks.has(callback)) {\n\t\t\t\t// ...so guard against infinite loops\n\t\t\t\tseen_callbacks.add(callback);\n\t\t\t\tcallback();\n\t\t\t}\n\t\t}\n\t\trender_callbacks.length = 0;\n\t} while (dirty_components.length);\n\twhile (flush_callbacks.length) {\n\t\tflush_callbacks.pop()();\n\t}\n\tupdate_scheduled = false;\n\tseen_callbacks.clear();\n\tset_current_component(saved_component);\n}\n\n/** @returns {void} */\nfunction update($$) {\n\tif ($$.fragment !== null) {\n\t\t$$.update();\n\t\trun_all($$.before_update);\n\t\tconst dirty = $$.dirty;\n\t\t$$.dirty = [-1];\n\t\t$$.fragment && $$.fragment.p($$.ctx, dirty);\n\t\t$$.after_update.forEach(add_render_callback);\n\t}\n}\n\n/**\n * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function flush_render_callbacks(fns) {\n\tconst filtered = [];\n\tconst targets = [];\n\trender_callbacks.forEach((c) => (fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)));\n\ttargets.forEach((c) => c());\n\trender_callbacks = filtered;\n}\n"],"names":["dirty_components","binding_callbacks","render_callbacks","flush_callbacks","resolved_promise","update_scheduled","schedule_update","flush","add_render_callback","fn","seen_callbacks","flushidx","saved_component","current_component","component","set_current_component","update","e","i","callback","$$","run_all","dirty","flush_render_callbacks","fns","filtered","targets","c"],"mappings":";;AAGY,MAACA,IAAmB,CAAG,GAEtBC,IAAoB,CAAG;AAEpC,IAAIC,IAAmB,CAAA;AAEvB,MAAMC,IAAkB,CAAA,GAElBC,IAAmC,wBAAQ;AAEjD,IAAIC,IAAmB;AAGhB,SAASC,IAAkB;AACjC,EAAKD,MACJA,IAAmB,IACnBD,EAAiB,KAAKG,CAAK;AAE7B;AASO,SAASC,EAAoBC,GAAI;AACvC,EAAAP,EAAiB,KAAKO,CAAE;AACzB;AAyBA,MAAMC,IAAiB,oBAAI;AAE3B,IAAIC,IAAW;AAGR,SAASJ,IAAQ;AAIvB,MAAII,MAAa;AAChB;AAED,QAAMC,IAAkBC;AACxB,KAAG;AAGF,QAAI;AACH,aAAOF,IAAWX,EAAiB,UAAQ;AAC1C,cAAMc,IAAYd,EAAiBW,CAAQ;AAC3C,QAAAA,KACAI,EAAsBD,CAAS,GAC/BE,EAAOF,EAAU,EAAE;AAAA,MACnB;AAAA,IACD,SAAQG,GAAG;AAEX,YAAAjB,EAAiB,SAAS,GAC1BW,IAAW,GACLM;AAAA,IACN;AAID,SAHAF,EAAsB,IAAI,GAC1Bf,EAAiB,SAAS,GAC1BW,IAAW,GACJV,EAAkB;AAAQ,MAAAA,EAAkB,IAAK,EAAA;AAIxD,aAASiB,IAAI,GAAGA,IAAIhB,EAAiB,QAAQgB,KAAK,GAAG;AACpD,YAAMC,IAAWjB,EAAiBgB,CAAC;AACnC,MAAKR,EAAe,IAAIS,CAAQ,MAE/BT,EAAe,IAAIS,CAAQ,GAC3BA;IAED;AACD,IAAAjB,EAAiB,SAAS;AAAA,EAC5B,SAAUF,EAAiB;AAC1B,SAAOG,EAAgB;AACtB,IAAAA,EAAgB,IAAG;AAEpB,EAAAE,IAAmB,IACnBK,EAAe,MAAK,GACpBK,EAAsBH,CAAe;AACtC;AAGA,SAASI,EAAOI,GAAI;AACnB,MAAIA,EAAG,aAAa,MAAM;AACzB,IAAAA,EAAG,OAAM,GACTC,EAAQD,EAAG,aAAa;AACxB,UAAME,IAAQF,EAAG;AACjB,IAAAA,EAAG,QAAQ,CAAC,EAAE,GACdA,EAAG,YAAYA,EAAG,SAAS,EAAEA,EAAG,KAAKE,CAAK,GAC1CF,EAAG,aAAa,QAAQZ,CAAmB;AAAA,EAC3C;AACF;AAOO,SAASe,EAAuBC,GAAK;AAC3C,QAAMC,IAAW,CAAA,GACXC,IAAU,CAAA;AAChB,EAAAxB,EAAiB,QAAQ,CAACyB,MAAOH,EAAI,QAAQG,CAAC,MAAM,KAAKF,EAAS,KAAKE,CAAC,IAAID,EAAQ,KAAKC,CAAC,CAAE,GAC5FD,EAAQ,QAAQ,CAACC,MAAMA,EAAG,CAAA,GAC1BzB,IAAmBuB;AACpB;","x_google_ignoreList":[0]}
@@ -1,9 +1,9 @@
1
- import { safe_not_equal as O, component_subscribe as T, create_slot as q, update_slot_base as w, get_all_dirty_from_scope as A, get_slot_changes as N } from "./annotorious-svelte.es6.js";
2
- import { empty as S, insert as E, detach as L, element as X, attr as c } from "./annotorious-svelte.es7.js";
3
- import { transition_in as u, transition_out as p, check_outros as Y, group_outros as j } from "./annotorious-svelte.es8.js";
4
- import { getContext as z, onMount as B } from "./annotorious-svelte.es9.js";
5
- import { SvelteComponent as D, init as F } from "./annotorious-svelte.es10.js";
6
- import "./annotorious-svelte.es11.js";
1
+ import { safe_not_equal as O, component_subscribe as T, create_slot as q, update_slot_base as w, get_all_dirty_from_scope as A, get_slot_changes as N } from "./annotorious-svelte.es7.js";
2
+ import { empty as S, insert as E, detach as L, element as X, attr as c } from "./annotorious-svelte.es8.js";
3
+ import { transition_in as u, transition_out as p, check_outros as Y, group_outros as j } from "./annotorious-svelte.es9.js";
4
+ import { getContext as z, onMount as B } from "./annotorious-svelte.es10.js";
5
+ import { SvelteComponent as D, init as F } from "./annotorious-svelte.es11.js";
6
+ import "./annotorious-svelte.es12.js";
7
7
  const G = (o) => ({ hovered: o & /*hovered*/
8
8
  16 }), b = (o) => ({ hovered: (
9
9
  /*hovered*/
@@ -1,61 +1,66 @@
1
1
  var f = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(f || {});
2
2
  let s;
3
3
  const p = new Uint8Array(16);
4
- function g() {
4
+ function y() {
5
5
  if (!s && (s = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !s))
6
6
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
7
7
  return s(p);
8
8
  }
9
- const e = [];
9
+ const r = [];
10
10
  for (let t = 0; t < 256; ++t)
11
- e.push((t + 256).toString(16).slice(1));
12
- function y(t, o = 0) {
13
- return e[t[o + 0]] + e[t[o + 1]] + e[t[o + 2]] + e[t[o + 3]] + "-" + e[t[o + 4]] + e[t[o + 5]] + "-" + e[t[o + 6]] + e[t[o + 7]] + "-" + e[t[o + 8]] + e[t[o + 9]] + "-" + e[t[o + 10]] + e[t[o + 11]] + e[t[o + 12]] + e[t[o + 13]] + e[t[o + 14]] + e[t[o + 15]];
11
+ r.push((t + 256).toString(16).slice(1));
12
+ function g(t, o = 0) {
13
+ return r[t[o + 0]] + r[t[o + 1]] + r[t[o + 2]] + r[t[o + 3]] + "-" + r[t[o + 4]] + r[t[o + 5]] + "-" + r[t[o + 6]] + r[t[o + 7]] + "-" + r[t[o + 8]] + r[t[o + 9]] + "-" + r[t[o + 10]] + r[t[o + 11]] + r[t[o + 12]] + r[t[o + 13]] + r[t[o + 14]] + r[t[o + 15]];
14
14
  }
15
15
  const m = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), i = {
16
16
  randomUUID: m
17
17
  };
18
- function U(t, o, r) {
18
+ function E(t, o, e) {
19
19
  if (i.randomUUID && !o && !t)
20
20
  return i.randomUUID();
21
21
  t = t || {};
22
- const a = t.random || (t.rng || g)();
23
- if (a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, o) {
24
- r = r || 0;
25
- for (let n = 0; n < 16; ++n)
26
- o[r + n] = a[n];
22
+ const n = t.random || (t.rng || y)();
23
+ if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, o) {
24
+ e = e || 0;
25
+ for (let a = 0; a < 16; ++a)
26
+ o[e + a] = n[a];
27
27
  return o;
28
28
  }
29
- return y(a);
29
+ return g(n);
30
30
  }
31
- const C = (t, o, r, a) => ({
32
- id: U(),
31
+ const R = (t, o, e, n) => ({
32
+ id: E(),
33
33
  annotation: t.id,
34
- created: r || /* @__PURE__ */ new Date(),
35
- creator: a,
34
+ created: e || /* @__PURE__ */ new Date(),
35
+ creator: n,
36
36
  ...o
37
37
  });
38
- var h = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(h || {});
39
- const D = (t) => ({
38
+ var U = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(U || {});
39
+ const v = (t) => ({
40
40
  ...t,
41
41
  subscribe: (o) => {
42
- const r = (a) => o(a.state);
43
- return t.observe(r), o(t.all()), () => t.unobserve(r);
42
+ const e = (n) => o(n.state);
43
+ return t.observe(e), o(t.all()), () => t.unobserve(e);
44
44
  }
45
- });
46
- let E = (t) => crypto.getRandomValues(new Uint8Array(t)), b = (t, o, r) => {
47
- let a = (2 << Math.log(t.length - 1) / Math.LN2) - 1, n = -~(1.6 * a * o / t.length);
45
+ }), h = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
46
+ let b = (t) => crypto.getRandomValues(new Uint8Array(t)), D = (t, o, e) => {
47
+ let n = (2 << Math.log(t.length - 1) / Math.LN2) - 1, a = -~(1.6 * n * o / t.length);
48
48
  return (l = o) => {
49
49
  let c = "";
50
50
  for (; ; ) {
51
- let d = r(n), u = n;
51
+ let d = e(a), u = a;
52
52
  for (; u--; )
53
- if (c += t[d[u] & a] || "", c.length === l)
53
+ if (c += t[d[u] & n] || "", c.length === l)
54
54
  return c;
55
55
  }
56
56
  };
57
- }, R = (t, o = 21) => b(t, o, E), S = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((o, r) => (r &= 63, r < 36 ? o += r.toString(36) : r < 62 ? o += (r - 26).toString(36).toUpperCase() : r > 62 ? o += "-" : o += "_", o), "");
58
- const v = () => ({ isGuest: !0, id: R("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), w = [
57
+ }, C = (t, o = 21) => D(t, o, b), L = (t = 21) => {
58
+ let o = "", e = crypto.getRandomValues(new Uint8Array(t));
59
+ for (; t--; )
60
+ o += h[e[t] & 63];
61
+ return o;
62
+ };
63
+ const w = () => ({ isGuest: !0, id: C("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), O = [
59
64
  "#ff7c00",
60
65
  // orange
61
66
  "#1ac938",
@@ -75,19 +80,19 @@ const v = () => ({ isGuest: !0, id: R("1234567890abcdefghijklmnopqrstuvwxyzABCDE
75
80
  "#023eff"
76
81
  // blue
77
82
  ], A = () => {
78
- const t = [...w];
83
+ const t = [...O];
79
84
  return { assignRandomColor: () => {
80
- const o = Math.floor(Math.random() * t.length), r = t[o];
81
- return t.splice(o, 1), r;
85
+ const o = Math.floor(Math.random() * t.length), e = t[o];
86
+ return t.splice(o, 1), e;
82
87
  }, releaseColor: (o) => t.push(o) };
83
88
  };
84
- S();
89
+ L();
85
90
  export {
86
- h as Origin,
91
+ U as Origin,
87
92
  f as PointerSelectAction,
88
- v as createAnonymousGuest,
89
- C as createBody,
93
+ w as createAnonymousGuest,
94
+ R as createBody,
90
95
  A as defaultColorProvider,
91
- D as toSvelteStore
96
+ v as toSvelteStore
92
97
  };
93
98
  //# sourceMappingURL=annotorious-svelte.es3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es3.js","sources":["../../annotorious-core/dist/annotorious-core.es.js"],"sourcesContent":["var Y = Object.prototype.hasOwnProperty;\nfunction x(e, n) {\n var t, o;\n if (e === n)\n return !0;\n if (e && n && (t = e.constructor) === n.constructor) {\n if (t === Date)\n return e.getTime() === n.getTime();\n if (t === RegExp)\n return e.toString() === n.toString();\n if (t === Array) {\n if ((o = e.length) === n.length)\n for (; o-- && x(e[o], n[o]); )\n ;\n return o === -1;\n }\n if (!t || typeof e == \"object\") {\n o = 0;\n for (t in e)\n if (Y.call(e, t) && ++o && !Y.call(n, t) || !(t in n) || !x(e[t], n[t]))\n return !1;\n return Object.keys(n).length === o;\n }\n }\n return e !== e && n !== n;\n}\nfunction $() {\n}\nfunction W(e, n) {\n return e != e ? n == n : e !== n || e && typeof e == \"object\" || typeof e == \"function\";\n}\nconst k = [];\nfunction _(e, n = $) {\n let t;\n const o = /* @__PURE__ */ new Set();\n function i(b) {\n if (W(e, b) && (e = b, t)) {\n const w = !k.length;\n for (const u of o)\n u[1](), k.push(u, e);\n if (w) {\n for (let u = 0; u < k.length; u += 2)\n k[u][0](k[u + 1]);\n k.length = 0;\n }\n }\n }\n function p(b) {\n i(b(e));\n }\n function U(b, w = $) {\n const u = [b, w];\n return o.add(u), o.size === 1 && (t = n(i, p) || $), b(e), () => {\n o.delete(u), o.size === 0 && t && (t(), t = null);\n };\n }\n return { set: i, update: p, subscribe: U };\n}\nconst be = (e) => {\n const { subscribe: n, set: t } = _();\n let o;\n return n((i) => o = i), e.observe(({ changes: i }) => {\n if (o) {\n (i.deleted || []).some((b) => b.id === o) && t(void 0);\n const U = (i.updated || []).find(({ oldValue: b }) => b.id === o);\n U && t(U.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: n,\n set: t\n };\n};\nvar q = /* @__PURE__ */ ((e) => (e.EDIT = \"EDIT\", e.SELECT = \"SELECT\", e.NONE = \"NONE\", e))(q || {});\nconst V = { selected: [] }, ve = (e, n = \"EDIT\") => {\n const { subscribe: t, set: o } = _(V);\n let i = V;\n t((s) => i = s);\n const p = () => o(V), U = () => {\n var s;\n return ((s = i.selected) == null ? void 0 : s.length) === 0;\n }, b = (s) => {\n if (i.selected.length === 0)\n return !1;\n const g = typeof s == \"string\" ? s : s.id;\n return i.selected.some((y) => y.id === g);\n }, w = (s, g) => {\n const y = e.getAnnotation(s);\n if (y) {\n const A = G(y, n);\n o(A === \"EDIT\" ? { selected: [{ id: s, editable: !0 }], pointerEvent: g } : A === \"SELECT\" ? { selected: [{ id: s }], pointerEvent: g } : { selected: [], pointerEvent: g });\n } else\n console.warn(\"Invalid selection: \" + s);\n }, u = (s, g = !0) => {\n const y = Array.isArray(s) ? s : [s], A = y.map((O) => e.getAnnotation(O)).filter(Boolean);\n o({ selected: A.map(({ id: O }) => ({ id: O, editable: g })) }), A.length !== y.length && console.warn(\"Invalid selection\", s);\n }, S = (s) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: g } = i;\n g.filter(({ id: A }) => s.includes(A)).length > 0 && o({ selected: g.filter(({ id: A }) => !s.includes(A)) });\n };\n return e.observe(({ changes: s }) => S((s.deleted || []).map((g) => g.id))), {\n clear: p,\n clickSelect: w,\n get selected() {\n return i ? [...i.selected] : null;\n },\n get pointerEvent() {\n return i ? i.pointerEvent : null;\n },\n isEmpty: U,\n isSelected: b,\n setSelected: u,\n subscribe: t\n };\n}, G = (e, n) => typeof n == \"function\" ? n(e) || \"EDIT\" : n || \"EDIT\";\nlet z;\nconst H = new Uint8Array(16);\nfunction F() {\n if (!z && (z = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !z))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return z(H);\n}\nconst R = [];\nfor (let e = 0; e < 256; ++e)\n R.push((e + 256).toString(16).slice(1));\nfunction J(e, n = 0) {\n return R[e[n + 0]] + R[e[n + 1]] + R[e[n + 2]] + R[e[n + 3]] + \"-\" + R[e[n + 4]] + R[e[n + 5]] + \"-\" + R[e[n + 6]] + R[e[n + 7]] + \"-\" + R[e[n + 8]] + R[e[n + 9]] + \"-\" + R[e[n + 10]] + R[e[n + 11]] + R[e[n + 12]] + R[e[n + 13]] + R[e[n + 14]] + R[e[n + 15]];\n}\nconst Q = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto), j = {\n randomUUID: Q\n};\nfunction X(e, n, t) {\n if (j.randomUUID && !n && !e)\n return j.randomUUID();\n e = e || {};\n const o = e.random || (e.rng || F)();\n if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, n) {\n t = t || 0;\n for (let i = 0; i < 16; ++i)\n n[t + i] = o[i];\n return n;\n }\n return J(o);\n}\nconst Ce = (e) => {\n const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, p) => [...i, p.creator, p.updatedBy].filter(Boolean), []);\n return [\n n,\n t,\n ...o\n ].filter((i) => i);\n}, we = (e, n, t, o) => ({\n id: X(),\n annotation: e.id,\n created: t || /* @__PURE__ */ new Date(),\n creator: o,\n ...n\n}), Z = (e, n) => {\n const t = new Set(e.bodies.map((o) => o.id));\n return n.bodies.filter((o) => !t.has(o.id));\n}, K = (e, n) => {\n const t = new Set(n.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !t.has(o.id));\n}, ee = (e, n) => n.bodies.map((t) => {\n const o = e.bodies.find((i) => i.id === t.id);\n return { newBody: t, oldBody: o && !x(o, t) ? o : void 0 };\n}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), te = (e, n) => !x(e.target, n.target), M = (e, n) => {\n const t = Z(e, n), o = K(e, n), i = ee(e, n);\n return {\n oldValue: e,\n newValue: n,\n bodiesCreated: t.length > 0 ? t : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: te(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0\n };\n};\nvar ne = /* @__PURE__ */ ((e) => (e.BODY_ONLY = \"BODY_ONLY\", e.TARGET_ONLY = \"TARGET_ONLY\", e))(ne || {}), T = /* @__PURE__ */ ((e) => (e.LOCAL = \"LOCAL\", e.REMOTE = \"REMOTE\", e))(T || {});\nconst oe = (e, n) => {\n var p, U;\n const { changes: t, origin: o } = n;\n if (!(!e.options.origin || e.options.origin === o))\n return !1;\n if (e.options.ignore) {\n const { ignore: b } = e.options, w = (S) => S && S.length > 0;\n if (!(w(t.created) || w(t.deleted))) {\n const S = (p = t.updated) == null ? void 0 : p.some((g) => w(g.bodiesCreated) || w(g.bodiesDeleted) || w(g.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((g) => g.targetUpdated);\n if (b === \"BODY_ONLY\" && S && !s || b === \"TARGET_ONLY\" && s && !S)\n return !1;\n }\n }\n if (e.options.annotations) {\n const b = /* @__PURE__ */ new Set([\n ...(t.created || []).map((u) => u.id),\n ...(t.deleted || []).map((u) => u.id),\n ...(t.updated || []).map(({ oldValue: u }) => u.id)\n ]);\n return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => b.has(u));\n } else\n return !0;\n}, se = (e, n) => {\n const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), p = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), b = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)), w = [\n ...(e.created || []).filter((s) => !p.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: g }) => g.id === s.id).newValue : s),\n ...n.created || []\n ], u = [\n ...(e.deleted || []).filter((s) => !i.has(s.id)),\n ...(n.deleted || []).filter((s) => !t.has(s.id))\n ], S = [\n ...(e.updated || []).filter(({ newValue: s }) => !p.has(s.id)).map((s) => {\n const { oldValue: g, newValue: y } = s;\n if (U.has(y.id)) {\n const A = n.updated.find((O) => O.oldValue.id === y.id).newValue;\n return M(g, A);\n } else\n return s;\n }),\n ...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))\n ];\n return { created: w, deleted: u, updated: S };\n}, ie = (e) => e.id !== void 0, ye = () => {\n const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, l = {}) => t.push({ onChange: d, options: l }), i = (d) => {\n const l = t.findIndex((c) => c.onChange == d);\n l > -1 && t.splice(l, 1);\n }, p = (d, l) => {\n const c = {\n origin: d,\n changes: {\n created: l.created || [],\n updated: l.updated || [],\n deleted: l.deleted || []\n },\n state: [...e.values()]\n };\n t.forEach((f) => {\n oe(f, c) && f.onChange(c);\n });\n }, U = (d, l = T.LOCAL) => {\n if (e.get(d.id))\n throw Error(`Cannot add annotation ${d.id} - exists already`);\n e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(l, { created: [d] });\n }, b = (d, l) => {\n const c = typeof d == \"string\" ? l : d, f = typeof d == \"string\" ? d : d.id, v = e.get(f);\n if (v) {\n const D = M(v, c);\n return f === c.id ? e.set(f, c) : (e.delete(f), e.set(c.id, c)), v.bodies.forEach((B) => n.delete(B.id)), c.bodies.forEach((B) => n.set(B.id, c.id)), D;\n } else\n console.warn(`Cannot update annotation ${f} - does not exist`);\n }, w = (d, l = T.LOCAL, c = T.LOCAL) => {\n const f = ie(l) ? c : l, v = b(d, l);\n v && p(f, { updated: [v] });\n }, u = (d, l = T.LOCAL) => {\n const c = d.reduce((f, v) => {\n const D = b(v);\n return D ? [...f, D] : f;\n }, []);\n c.length > 0 && p(l, { updated: c });\n }, S = (d, l = T.LOCAL) => {\n const c = e.get(d.annotation);\n if (c) {\n const f = {\n ...c,\n bodies: [...c.bodies, d]\n };\n e.set(c.id, f), n.set(d.id, f.id), p(l, { updated: [{\n oldValue: c,\n newValue: f,\n bodiesCreated: [d]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);\n }, s = () => [...e.values()], g = (d = T.LOCAL) => {\n const l = [...e.values()];\n e.clear(), n.clear(), p(d, { deleted: l });\n }, y = (d, l = !0, c = T.LOCAL) => {\n if (l) {\n const f = [...e.values()];\n e.clear(), n.clear(), d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));\n }), p(c, { created: d, deleted: f });\n } else {\n const f = d.reduce((v, D) => {\n const B = e.get(D.id);\n return B ? [...v, B] : v;\n }, []);\n if (f.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${f.map((v) => v.id).join(\", \")}`);\n d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));\n }), p(c, { created: d });\n }\n }, A = (d) => {\n const l = typeof d == \"string\" ? d : d.id, c = e.get(l);\n if (c)\n return e.delete(l), c.bodies.forEach((f) => n.delete(f.id)), c;\n console.warn(`Attempt to delete missing annotation: ${l}`);\n }, O = (d, l = T.LOCAL) => {\n const c = A(d);\n c && p(l, { deleted: [c] });\n }, C = (d, l = T.LOCAL) => {\n const c = d.reduce((f, v) => {\n const D = A(v);\n return D ? [...f, D] : f;\n }, []);\n c.length > 0 && p(l, { deleted: c });\n }, a = (d, l = T.LOCAL) => {\n const c = e.get(d.annotation);\n if (c) {\n const f = c.bodies.find((v) => v.id === d.id);\n if (f) {\n n.delete(f.id);\n const v = {\n ...c,\n bodies: c.bodies.filter((B) => B.id !== d.id)\n };\n e.set(c.id, v), p(l, { updated: [{\n oldValue: c,\n newValue: v,\n bodiesDeleted: [f]\n }] });\n } else\n console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);\n }, m = (d) => {\n const l = e.get(d);\n return l ? { ...l } : void 0;\n }, r = (d) => {\n const l = n.get(d);\n if (l) {\n const f = m(l).bodies.find((v) => v.id === d);\n if (f)\n return f;\n console.error(`Store integrity error: body ${d} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${d}`);\n }, E = (d, l) => {\n if (d.annotation !== l.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const c = e.get(d.annotation);\n if (c) {\n const f = c.bodies.find((D) => D.id === d.id), v = {\n ...c,\n bodies: c.bodies.map((D) => D.id === f.id ? l : D)\n };\n return e.set(c.id, v), f.id !== l.id && (n.delete(f.id), n.set(l.id, v.id)), {\n oldValue: c,\n newValue: v,\n bodiesUpdated: [{ oldBody: f, newBody: l }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${d.annotation}`);\n }, h = (d, l, c = T.LOCAL) => {\n const f = E(d, l);\n f && p(c, { updated: [f] });\n }, L = (d, l = T.LOCAL) => {\n const c = d.map((f) => E({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);\n p(l, { updated: c });\n }, I = (d) => {\n const l = e.get(d.annotation);\n if (l) {\n const c = {\n ...l,\n target: {\n ...l.target,\n ...d\n }\n };\n return e.set(l.id, c), {\n oldValue: l,\n newValue: c,\n targetUpdated: {\n oldTarget: l.target,\n newTarget: d\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${d.annotation}`);\n };\n return {\n addAnnotation: U,\n addBody: S,\n all: s,\n bulkAddAnnotation: y,\n bulkDeleteAnnotation: C,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: L,\n bulkUpdateTargets: (d, l = T.LOCAL) => {\n const c = d.map((f) => I(f)).filter(Boolean);\n c.length > 0 && p(l, { updated: c });\n },\n clear: g,\n deleteAnnotation: O,\n deleteBody: a,\n getAnnotation: m,\n getBody: r,\n observe: o,\n unobserve: i,\n updateAnnotation: w,\n updateBody: h,\n updateTarget: (d, l = T.LOCAL) => {\n const c = I(d);\n c && p(l, { updated: [c] });\n }\n };\n}, Ue = (e) => ({\n ...e,\n subscribe: (t) => {\n const o = (i) => t(i.state);\n return e.observe(o), t(e.all()), () => e.unobserve(o);\n }\n});\nlet P = () => ({\n emit(e, ...n) {\n for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)\n o[t](...n);\n },\n events: {},\n on(e, n) {\n var t;\n return ((t = this.events)[e] || (t[e] = [])).push(n), () => {\n var o;\n this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => n !== i);\n };\n }\n});\nconst de = 250, Le = (e) => {\n const n = P(), t = [];\n let o = -1, i = !1, p = 0;\n const U = (r) => {\n if (!i) {\n const { changes: E } = r, h = performance.now();\n if (h - p > de)\n t.splice(o + 1), t.push(E), o = t.length - 1;\n else {\n const L = t.length - 1;\n t[L] = se(t[L], E);\n }\n p = h;\n }\n i = !1;\n };\n e.observe(U, { origin: T.LOCAL });\n const b = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), w = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), u = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: E }) => E)), S = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: E }) => E)), s = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), g = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);\n return {\n canRedo: () => t.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => e.unobserve(U),\n on: (r, E) => n.on(r, E),\n redo: () => {\n if (t.length - 1 > o) {\n i = !0;\n const { created: r, updated: E, deleted: h } = t[o + 1];\n w(r), S(E), g(h), n.emit(\"redo\", t[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: r, updated: E, deleted: h } = t[o];\n b(r), u(E), s(h), n.emit(\"undo\", t[o]), o -= 1;\n }\n }\n };\n}, Se = () => {\n const { subscribe: e, set: n } = _([]);\n return {\n subscribe: e,\n set: n\n };\n}, Oe = (e, n, t, o) => {\n const { store: i, selection: p, hover: U, viewport: b } = e, w = /* @__PURE__ */ new Map();\n let u = [], S, s;\n const g = (a, m) => {\n w.has(a) ? w.get(a).push(m) : w.set(a, [m]);\n }, y = (a, m) => {\n const r = w.get(a);\n r && r.indexOf(m) > 0 && r.splice(r.indexOf(m), 1);\n }, A = (a, m, r) => {\n w.has(a) && setTimeout(() => {\n w.get(a).forEach((E) => {\n if (t) {\n const h = Array.isArray(m) ? m.map((I) => t.serialize(I)) : t.serialize(m), L = r ? r instanceof PointerEvent ? r : t.serialize(r) : void 0;\n E(h, L);\n } else\n E(m, r);\n });\n }, 1);\n }, O = () => {\n const { selected: a } = p, m = (a || []).map(({ id: r }) => i.getAnnotation(r));\n m.forEach((r) => {\n const E = u.find((h) => h.id === r.id);\n (!E || !x(E, r)) && A(\"updateAnnotation\", r, E);\n }), u = u.map((r) => {\n const E = m.find(({ id: h }) => h === r.id);\n return E || r;\n });\n };\n p.subscribe(({ selected: a }) => {\n if (!(u.length === 0 && a.length === 0)) {\n if (u.length === 0 && a.length > 0)\n u = a.map(({ id: m }) => i.getAnnotation(m));\n else if (u.length > 0 && a.length === 0)\n u.forEach((m) => {\n const r = i.getAnnotation(m.id);\n r && !x(r, m) && A(\"updateAnnotation\", r, m);\n }), u = [];\n else {\n const m = new Set(u.map((h) => h.id)), r = new Set(a.map(({ id: h }) => h));\n u.filter((h) => !r.has(h.id)).forEach((h) => {\n const L = i.getAnnotation(h.id);\n L && !x(L, h) && A(\"updateAnnotation\", L, h);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((h) => r.has(h.id)),\n // Add editable annotations that were selected\n ...a.filter(({ id: h }) => !m.has(h)).map(({ id: h }) => i.getAnnotation(h))\n ];\n }\n A(\"selectionChanged\", u);\n }\n }), U.subscribe((a) => {\n !S && a ? A(\"mouseEnterAnnotation\", i.getAnnotation(a)) : S && !a ? A(\"mouseLeaveAnnotation\", i.getAnnotation(S)) : S && a && (A(\"mouseLeaveAnnotation\", i.getAnnotation(S)), A(\"mouseEnterAnnotation\", i.getAnnotation(a))), S = a;\n }), b == null || b.subscribe((a) => A(\"viewportIntersect\", a.map((m) => i.getAnnotation(m)))), i.observe((a) => {\n o && (s && clearTimeout(s), s = setTimeout(O, 1e3));\n const { created: m, deleted: r } = a.changes;\n (m || []).forEach((h) => A(\"createAnnotation\", h)), (r || []).forEach((h) => A(\"deleteAnnotation\", h)), (a.changes.updated || []).filter((h) => [\n ...h.bodiesCreated || [],\n ...h.bodiesDeleted || [],\n ...h.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: h, newValue: L }) => {\n const I = u.find((N) => N.id === h.id) || h;\n u = u.map((N) => N.id === h.id ? L : N), A(\"updateAnnotation\", L, I);\n });\n }, { origin: T.LOCAL }), i.observe((a) => {\n if (u) {\n const m = new Set(u.map((E) => E.id)), r = (a.changes.updated || []).filter(({ newValue: E }) => m.has(E.id)).map(({ newValue: E }) => E);\n r.length > 0 && (u = u.map((E) => {\n const h = r.find((L) => L.id === E.id);\n return h || E;\n }));\n }\n }, { origin: T.REMOTE });\n const C = (a) => (m) => {\n const { created: r, deleted: E, updated: h } = m;\n (r || []).forEach((L) => A(\"createAnnotation\", L)), (E || []).forEach((L) => A(\"deleteAnnotation\", L)), a ? (h || []).forEach((L) => A(\"updateAnnotation\", L.oldValue, L.newValue)) : (h || []).forEach((L) => A(\"updateAnnotation\", L.newValue, L.oldValue));\n };\n return n.on(\"undo\", C(!0)), n.on(\"redo\", C(!1)), { on: g, off: y, emit: A };\n}, Te = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {\n const { parsed: i, error: p } = e.parse(o);\n return p ? {\n parsed: t.parsed,\n failed: [...t.failed, o]\n } : i ? {\n parsed: [...t.parsed, i],\n failed: t.failed\n } : {\n ...t\n };\n}, { parsed: [], failed: [] }), De = (e, n, t) => {\n const { store: o, selection: i } = e, p = (C) => {\n if (t) {\n const { parsed: a, error: m } = t.parse(C);\n a ? o.addAnnotation(a, T.REMOTE) : console.error(m);\n } else\n o.addAnnotation(C, T.REMOTE);\n }, U = () => i.clear(), b = () => o.clear(), w = (C) => {\n const a = o.getAnnotation(C);\n return t && a ? t.serialize(a) : a;\n }, u = () => t ? o.all().map(t.serialize) : o.all(), S = () => {\n var m;\n const a = (((m = i.selected) == null ? void 0 : m.map((r) => r.id)) || []).map((r) => o.getAnnotation(r)).filter(Boolean);\n return t ? a.map(t.serialize) : a;\n }, s = (C) => fetch(C).then((a) => a.json()).then((a) => (y(a), a)), g = (C) => {\n if (typeof C == \"string\") {\n const a = o.getAnnotation(C);\n if (o.deleteAnnotation(C), a)\n return t ? t.serialize(a) : a;\n } else {\n const a = t ? t.parse(C).parsed : C;\n if (a)\n return o.deleteAnnotation(a), C;\n }\n }, y = (C) => {\n if (t) {\n const { parsed: a, failed: m } = re(t)(C);\n m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(a, !0, T.REMOTE);\n } else\n o.bulkAddAnnotation(C, !0, T.REMOTE);\n }, A = (C) => {\n C ? i.setSelected(C) : i.clear();\n }, O = (C) => {\n if (t) {\n const a = t.parse(C).parsed, m = t.serialize(o.getAnnotation(a.id));\n return o.updateAnnotation(a), m;\n } else {\n const a = o.getAnnotation(C.id);\n return o.updateAnnotation(C), a;\n }\n };\n return {\n addAnnotation: p,\n cancelSelected: U,\n canRedo: n.canRedo,\n canUndo: n.canUndo,\n clearAnnotations: b,\n getAnnotationById: w,\n getAnnotations: u,\n getSelected: S,\n loadAnnotations: s,\n redo: n.redo,\n removeAnnotation: g,\n setAnnotations: y,\n setSelected: A,\n undo: n.undo,\n updateAnnotation: O\n };\n};\nlet ae = (e) => crypto.getRandomValues(new Uint8Array(e)), ce = (e, n, t) => {\n let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);\n return (p = n) => {\n let U = \"\";\n for (; ; ) {\n let b = t(i), w = i;\n for (; w--; )\n if (U += e[b[w] & o] || \"\", U.length === p)\n return U;\n }\n };\n}, le = (e, n = 21) => ce(e, n, ae), ue = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((n, t) => (t &= 63, t < 36 ? n += t.toString(36) : t < 62 ? n += (t - 26).toString(36).toUpperCase() : t > 62 ? n += \"-\" : n += \"_\", n), \"\");\nconst Re = () => ({ isGuest: !0, id: le(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), fe = (e) => {\n const n = JSON.stringify(e);\n let t = 0;\n for (let o = 0, i = n.length; o < i; o++) {\n let p = n.charCodeAt(o);\n t = (t << 5) - t + p, t |= 0;\n }\n return `${t}`;\n}, pe = (e) => e ? typeof e == \"object\" ? { ...e } : e : void 0, Be = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {\n const { id: o, type: i, purpose: p, value: U, created: b, creator: w, ...u } = t;\n return {\n id: o || `temp-${fe(t)}`,\n annotation: n,\n type: i,\n purpose: p,\n value: U,\n created: b ? new Date(b) : void 0,\n creator: pe(w),\n ...u\n };\n}), xe = (e) => e.map((n) => {\n var o, i;\n const t = { ...n };\n return delete t.annotation, (o = t.id) != null && o.startsWith(\"temp-\") && delete t.id, { ...t, created: (i = t.created) == null ? void 0 : i.toISOString() };\n}), ge = [\n \"#ff7c00\",\n // orange\n \"#1ac938\",\n // green\n \"#e8000b\",\n // red\n \"#8b2be2\",\n // purple\n \"#9f4800\",\n // brown\n \"#f14cc1\",\n // pink\n \"#ffc400\",\n // khaki\n \"#00d7ff\",\n // cyan\n \"#023eff\"\n // blue\n], he = () => {\n const e = [...ge];\n return { assignRandomColor: () => {\n const o = Math.floor(Math.random() * e.length), i = e[o];\n return e.splice(o, 1), i;\n }, releaseColor: (o) => e.push(o) };\n}, me = () => {\n const e = he();\n return { addUser: (o, i) => {\n const p = e.assignRandomColor();\n return {\n label: i.name || i.id,\n avatar: i.avatar,\n color: p\n };\n }, removeUser: (o) => e.releaseColor(o.appearance.color) };\n}, Ae = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Ie = ue(), ke = (e = me()) => {\n const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, g) => {\n if (t.has(s)) {\n console.warn(\"Attempt to add user that is already present\", s, g);\n return;\n }\n const y = e.addUser(s, g);\n t.set(s, {\n ...g,\n presenceKey: s,\n appearance: y\n });\n }, p = (s) => {\n const g = t.get(s);\n if (!g) {\n console.warn(\"Attempt to remove user that is not present\", s);\n return;\n }\n e.removeUser(g), t.delete(s);\n }, U = (s) => {\n const g = new Set(s.map((O) => O.presenceKey)), y = s.filter(({ presenceKey: O }) => !t.has(O)), A = Array.from(t.values()).filter((O) => !g.has(O.presenceKey));\n y.forEach(({ presenceKey: O, user: C }) => i(O, C)), A.forEach((O) => {\n const { presenceKey: C } = O;\n o.has(C) && n.emit(\"selectionChange\", O, null), p(C);\n }), (y.length > 0 || A.length > 0) && n.emit(\"presence\", u());\n }, b = (s, g) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Activity notification from user that is not present\");\n return;\n }\n const A = o.get(s);\n (!A || !Ae(A, g)) && (o.set(s, g), n.emit(\"selectionChange\", y, g));\n }, w = (s, g) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Selection change for user that is not present\", s);\n return;\n }\n g ? o.set(s, g) : o.delete(s), n.emit(\"selectionChange\", y, g);\n }, u = () => [...Array.from(t.values())];\n return {\n getPresentUsers: u,\n notifyActivity: b,\n on: (s, g) => n.on(s, g),\n syncUsers: U,\n updateSelection: w\n };\n};\nexport {\n ne as Ignore,\n T as Origin,\n Ie as PRESENCE_KEY,\n q as PointerSelectAction,\n Re as createAnonymousGuest,\n De as createBaseAnnotator,\n we as createBody,\n me as createDefaultAppearenceProvider,\n be as createHoverState,\n Oe as createLifecyleObserver,\n ke as createPresenceState,\n ve as createSelectionState,\n ye as createStore,\n Le as createUndoStack,\n Se as createViewportState,\n he as defaultColorProvider,\n M as diffAnnotations,\n Ce as getContributors,\n se as mergeChanges,\n G as onPointerSelect,\n re as parseAll,\n Be as parseW3CBodies,\n pe as parseW3CUser,\n Te as serializeAll,\n xe as serializeW3CBodies,\n oe as shouldNotify,\n Ue as toSvelteStore\n};\n//# sourceMappingURL=annotorious-core.es.js.map\n"],"names":["q","e","z","H","F","R","J","n","Q","j","X","t","o","i","we","T","Ue","ae","ce","p","U","b","w","le","ue","Re","ge","he"],"mappings":"AA2EG,IAACA,IAAqB,kBAACC,OAAOA,EAAE,OAAO,QAAQA,EAAE,SAAS,UAAUA,EAAE,OAAO,QAAQA,IAAID,KAAK,EAAE;AA4CnG,IAAIE;AACJ,MAAMC,IAAI,IAAI,WAAW,EAAE;AAC3B,SAASC,IAAI;AACX,MAAI,CAACF,MAAMA,IAAI,OAAO,SAAS,OAAO,OAAO,mBAAmB,OAAO,gBAAgB,KAAK,MAAM,GAAG,CAACA;AACpG,UAAM,IAAI,MAAM,0GAA0G;AAC5H,SAAOA,EAAEC,CAAC;AACZ;AACA,MAAME,IAAI,CAAA;AACV,SAASJ,IAAI,GAAGA,IAAI,KAAK,EAAEA;AACzB,EAAAI,EAAE,MAAMJ,IAAI,KAAK,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACxC,SAASK,EAAEL,GAAGM,IAAI,GAAG;AACnB,SAAOF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,MAAMF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,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AwB1GG,IAAK;AAAA,EACP;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAEF,GAAGC,IAAK,MAAM;AACZ,QAAM1B,IAAI,CAAC,GAAGyB,CAAE;AAChB,SAAO,EAAE,mBAAmB,MAAM;AAChC,UAAM,IAAI,KAAK,MAAM,KAAK,OAAM,IAAKzB,EAAE,MAAM,GAAGY,IAAIZ,EAAE,CAAC;AACvD,WAAOA,EAAE,OAAO,GAAG,CAAC,GAAGY;AAAA,EAC3B,GAAK,cAAc,CAAC,MAAMZ,EAAE,KAAK,CAAC;AAClC;AAUuFuB,EAAI;"}
1
+ {"version":3,"file":"annotorious-svelte.es3.js","sources":["../../annotorious-core/dist/annotorious-core.es.js"],"sourcesContent":["var _ = Object.prototype.hasOwnProperty;\nfunction x(e, n) {\n var t, o;\n if (e === n)\n return !0;\n if (e && n && (t = e.constructor) === n.constructor) {\n if (t === Date)\n return e.getTime() === n.getTime();\n if (t === RegExp)\n return e.toString() === n.toString();\n if (t === Array) {\n if ((o = e.length) === n.length)\n for (; o-- && x(e[o], n[o]); )\n ;\n return o === -1;\n }\n if (!t || typeof e == \"object\") {\n o = 0;\n for (t in e)\n if (_.call(e, t) && ++o && !_.call(n, t) || !(t in n) || !x(e[t], n[t]))\n return !1;\n return Object.keys(n).length === o;\n }\n }\n return e !== e && n !== n;\n}\nfunction z() {\n}\nfunction W(e, n) {\n return e != e ? n == n : e !== n || e && typeof e == \"object\" || typeof e == \"function\";\n}\nconst k = [];\nfunction Y(e, n = z) {\n let t;\n const o = /* @__PURE__ */ new Set();\n function i(E) {\n if (W(e, E) && (e = E, t)) {\n const w = !k.length;\n for (const u of o)\n u[1](), k.push(u, e);\n if (w) {\n for (let u = 0; u < k.length; u += 2)\n k[u][0](k[u + 1]);\n k.length = 0;\n }\n }\n }\n function p(E) {\n i(E(e));\n }\n function U(E, w = z) {\n const u = [E, w];\n return o.add(u), o.size === 1 && (t = n(i, p) || z), E(e), () => {\n o.delete(u), o.size === 0 && t && (t(), t = null);\n };\n }\n return { set: i, update: p, subscribe: U };\n}\nconst ve = (e) => {\n const { subscribe: n, set: t } = Y();\n let o;\n return n((i) => o = i), e.observe(({ changes: i }) => {\n if (o) {\n (i.deleted || []).some((E) => E.id === o) && t(void 0);\n const U = (i.updated || []).find(({ oldValue: E }) => E.id === o);\n U && t(U.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: n,\n set: t\n };\n};\nvar q = /* @__PURE__ */ ((e) => (e.EDIT = \"EDIT\", e.SELECT = \"SELECT\", e.NONE = \"NONE\", e))(q || {});\nconst V = { selected: [] }, ye = (e, n = \"EDIT\") => {\n const { subscribe: t, set: o } = Y(V);\n let i = V;\n t((s) => i = s);\n const p = () => o(V), U = () => {\n var s;\n return ((s = i.selected) == null ? void 0 : s.length) === 0;\n }, E = (s) => {\n if (i.selected.length === 0)\n return !1;\n const h = typeof s == \"string\" ? s : s.id;\n return i.selected.some((C) => C.id === h);\n }, w = (s, h) => {\n const C = e.getAnnotation(s);\n if (C) {\n const b = G(C, n);\n o(b === \"EDIT\" ? { selected: [{ id: s, editable: !0 }], pointerEvent: h } : b === \"SELECT\" ? { selected: [{ id: s }], pointerEvent: h } : { selected: [], pointerEvent: h });\n } else\n console.warn(\"Invalid selection: \" + s);\n }, u = (s, h = !0) => {\n const C = Array.isArray(s) ? s : [s], b = C.map((S) => e.getAnnotation(S)).filter(Boolean);\n o({ selected: b.map(({ id: S }) => ({ id: S, editable: h })) }), b.length !== C.length && console.warn(\"Invalid selection\", s);\n }, L = (s) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: h } = i;\n h.filter(({ id: b }) => s.includes(b)).length > 0 && o({ selected: h.filter(({ id: b }) => !s.includes(b)) });\n };\n return e.observe(({ changes: s }) => L((s.deleted || []).map((h) => h.id))), {\n clear: p,\n clickSelect: w,\n get selected() {\n return i ? [...i.selected] : null;\n },\n get pointerEvent() {\n return i ? i.pointerEvent : null;\n },\n isEmpty: U,\n isSelected: E,\n setSelected: u,\n subscribe: t\n };\n}, G = (e, n) => typeof n == \"function\" ? n(e) || \"EDIT\" : n || \"EDIT\";\nlet $;\nconst H = new Uint8Array(16);\nfunction F() {\n if (!$ && ($ = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !$))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return $(H);\n}\nconst D = [];\nfor (let e = 0; e < 256; ++e)\n D.push((e + 256).toString(16).slice(1));\nfunction J(e, n = 0) {\n return D[e[n + 0]] + D[e[n + 1]] + D[e[n + 2]] + D[e[n + 3]] + \"-\" + D[e[n + 4]] + D[e[n + 5]] + \"-\" + D[e[n + 6]] + D[e[n + 7]] + \"-\" + D[e[n + 8]] + D[e[n + 9]] + \"-\" + D[e[n + 10]] + D[e[n + 11]] + D[e[n + 12]] + D[e[n + 13]] + D[e[n + 14]] + D[e[n + 15]];\n}\nconst Q = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto), j = {\n randomUUID: Q\n};\nfunction X(e, n, t) {\n if (j.randomUUID && !n && !e)\n return j.randomUUID();\n e = e || {};\n const o = e.random || (e.rng || F)();\n if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, n) {\n t = t || 0;\n for (let i = 0; i < 16; ++i)\n n[t + i] = o[i];\n return n;\n }\n return J(o);\n}\nconst we = (e) => {\n const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, p) => [...i, p.creator, p.updatedBy].filter(Boolean), []);\n return [\n n,\n t,\n ...o\n ].filter((i) => i);\n}, Ce = (e, n, t, o) => ({\n id: X(),\n annotation: e.id,\n created: t || /* @__PURE__ */ new Date(),\n creator: o,\n ...n\n}), Z = (e, n) => {\n const t = new Set(e.bodies.map((o) => o.id));\n return n.bodies.filter((o) => !t.has(o.id));\n}, K = (e, n) => {\n const t = new Set(n.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !t.has(o.id));\n}, ee = (e, n) => n.bodies.map((t) => {\n const o = e.bodies.find((i) => i.id === t.id);\n return { newBody: t, oldBody: o && !x(o, t) ? o : void 0 };\n}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), te = (e, n) => !x(e.target, n.target), M = (e, n) => {\n const t = Z(e, n), o = K(e, n), i = ee(e, n);\n return {\n oldValue: e,\n newValue: n,\n bodiesCreated: t.length > 0 ? t : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: te(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0\n };\n};\nvar ne = /* @__PURE__ */ ((e) => (e.BODY_ONLY = \"BODY_ONLY\", e.TARGET_ONLY = \"TARGET_ONLY\", e))(ne || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = \"LOCAL\", e.REMOTE = \"REMOTE\", e))(O || {});\nconst oe = (e, n) => {\n var p, U;\n const { changes: t, origin: o } = n;\n if (!(!e.options.origin || e.options.origin === o))\n return !1;\n if (e.options.ignore) {\n const { ignore: E } = e.options, w = (L) => L && L.length > 0;\n if (!(w(t.created) || w(t.deleted))) {\n const L = (p = t.updated) == null ? void 0 : p.some((h) => w(h.bodiesCreated) || w(h.bodiesDeleted) || w(h.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((h) => h.targetUpdated);\n if (E === \"BODY_ONLY\" && L && !s || E === \"TARGET_ONLY\" && s && !L)\n return !1;\n }\n }\n if (e.options.annotations) {\n const E = /* @__PURE__ */ new Set([\n ...(t.created || []).map((u) => u.id),\n ...(t.deleted || []).map((u) => u.id),\n ...(t.updated || []).map(({ oldValue: u }) => u.id)\n ]);\n return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => E.has(u));\n } else\n return !0;\n}, se = (e, n) => {\n const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), p = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), E = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)), w = [\n ...(e.created || []).filter((s) => !p.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: h }) => h.id === s.id).newValue : s),\n ...n.created || []\n ], u = [\n ...(e.deleted || []).filter((s) => !i.has(s.id)),\n ...(n.deleted || []).filter((s) => !t.has(s.id))\n ], L = [\n ...(e.updated || []).filter(({ newValue: s }) => !p.has(s.id)).map((s) => {\n const { oldValue: h, newValue: C } = s;\n if (U.has(C.id)) {\n const b = n.updated.find((S) => S.oldValue.id === C.id).newValue;\n return M(h, b);\n } else\n return s;\n }),\n ...(n.updated || []).filter(({ oldValue: s }) => !E.has(s.id))\n ];\n return { created: w, deleted: u, updated: L };\n}, ie = (e) => e.id !== void 0, Ue = () => {\n const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, l = {}) => t.push({ onChange: d, options: l }), i = (d) => {\n const l = t.findIndex((a) => a.onChange == d);\n l > -1 && t.splice(l, 1);\n }, p = (d, l) => {\n const a = {\n origin: d,\n changes: {\n created: l.created || [],\n updated: l.updated || [],\n deleted: l.deleted || []\n },\n state: [...e.values()]\n };\n t.forEach((f) => {\n oe(f, a) && f.onChange(a);\n });\n }, U = (d, l = O.LOCAL) => {\n if (e.get(d.id))\n throw Error(`Cannot add annotation ${d.id} - exists already`);\n e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(l, { created: [d] });\n }, E = (d, l) => {\n const a = typeof d == \"string\" ? l : d, f = typeof d == \"string\" ? d : d.id, v = e.get(f);\n if (v) {\n const T = M(v, a);\n return f === a.id ? e.set(f, a) : (e.delete(f), e.set(a.id, a)), v.bodies.forEach((B) => n.delete(B.id)), a.bodies.forEach((B) => n.set(B.id, a.id)), T;\n } else\n console.warn(`Cannot update annotation ${f} - does not exist`);\n }, w = (d, l = O.LOCAL, a = O.LOCAL) => {\n const f = ie(l) ? a : l, v = E(d, l);\n v && p(f, { updated: [v] });\n }, u = (d, l = O.LOCAL) => {\n const a = d.reduce((f, v) => {\n const T = E(v);\n return T ? [...f, T] : f;\n }, []);\n a.length > 0 && p(l, { updated: a });\n }, L = (d, l = O.LOCAL) => {\n const a = e.get(d.annotation);\n if (a) {\n const f = {\n ...a,\n bodies: [...a.bodies, d]\n };\n e.set(a.id, f), n.set(d.id, f.id), p(l, { updated: [{\n oldValue: a,\n newValue: f,\n bodiesCreated: [d]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);\n }, s = () => [...e.values()], h = (d = O.LOCAL) => {\n const l = [...e.values()];\n e.clear(), n.clear(), p(d, { deleted: l });\n }, C = (d, l = !0, a = O.LOCAL) => {\n if (l) {\n const f = [...e.values()];\n e.clear(), n.clear(), d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((T) => n.set(T.id, v.id));\n }), p(a, { created: d, deleted: f });\n } else {\n const f = d.reduce((v, T) => {\n const B = e.get(T.id);\n return B ? [...v, B] : v;\n }, []);\n if (f.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${f.map((v) => v.id).join(\", \")}`);\n d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((T) => n.set(T.id, v.id));\n }), p(a, { created: d });\n }\n }, b = (d) => {\n const l = typeof d == \"string\" ? d : d.id, a = e.get(l);\n if (a)\n return e.delete(l), a.bodies.forEach((f) => n.delete(f.id)), a;\n console.warn(`Attempt to delete missing annotation: ${l}`);\n }, S = (d, l = O.LOCAL) => {\n const a = b(d);\n a && p(l, { deleted: [a] });\n }, y = (d, l = O.LOCAL) => {\n const a = d.reduce((f, v) => {\n const T = b(v);\n return T ? [...f, T] : f;\n }, []);\n a.length > 0 && p(l, { deleted: a });\n }, c = (d, l = O.LOCAL) => {\n const a = e.get(d.annotation);\n if (a) {\n const f = a.bodies.find((v) => v.id === d.id);\n if (f) {\n n.delete(f.id);\n const v = {\n ...a,\n bodies: a.bodies.filter((B) => B.id !== d.id)\n };\n e.set(a.id, v), p(l, { updated: [{\n oldValue: a,\n newValue: v,\n bodiesDeleted: [f]\n }] });\n } else\n console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);\n }, g = (d) => {\n const l = e.get(d);\n return l ? { ...l } : void 0;\n }, r = (d) => {\n const l = n.get(d);\n if (l) {\n const f = g(l).bodies.find((v) => v.id === d);\n if (f)\n return f;\n console.error(`Store integrity error: body ${d} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${d}`);\n }, A = (d, l) => {\n if (d.annotation !== l.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const a = e.get(d.annotation);\n if (a) {\n const f = a.bodies.find((T) => T.id === d.id), v = {\n ...a,\n bodies: a.bodies.map((T) => T.id === f.id ? l : T)\n };\n return e.set(a.id, v), f.id !== l.id && (n.delete(f.id), n.set(l.id, v.id)), {\n oldValue: a,\n newValue: v,\n bodiesUpdated: [{ oldBody: f, newBody: l }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${d.annotation}`);\n }, m = (d, l, a = O.LOCAL) => {\n const f = A(d, l);\n f && p(a, { updated: [f] });\n }, R = (d, l = O.LOCAL) => {\n const a = d.map((f) => A({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);\n p(l, { updated: a });\n }, I = (d) => {\n const l = e.get(d.annotation);\n if (l) {\n const a = {\n ...l,\n target: {\n ...l.target,\n ...d\n }\n };\n return e.set(l.id, a), {\n oldValue: l,\n newValue: a,\n targetUpdated: {\n oldTarget: l.target,\n newTarget: d\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${d.annotation}`);\n };\n return {\n addAnnotation: U,\n addBody: L,\n all: s,\n bulkAddAnnotation: C,\n bulkDeleteAnnotation: y,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: R,\n bulkUpdateTargets: (d, l = O.LOCAL) => {\n const a = d.map((f) => I(f)).filter(Boolean);\n a.length > 0 && p(l, { updated: a });\n },\n clear: h,\n deleteAnnotation: S,\n deleteBody: c,\n getAnnotation: g,\n getBody: r,\n observe: o,\n unobserve: i,\n updateAnnotation: w,\n updateBody: m,\n updateTarget: (d, l = O.LOCAL) => {\n const a = I(d);\n a && p(l, { updated: [a] });\n }\n };\n}, Le = (e) => ({\n ...e,\n subscribe: (t) => {\n const o = (i) => t(i.state);\n return e.observe(o), t(e.all()), () => e.unobserve(o);\n }\n});\nlet P = () => ({\n emit(e, ...n) {\n for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)\n o[t](...n);\n },\n events: {},\n on(e, n) {\n var t;\n return ((t = this.events)[e] || (t[e] = [])).push(n), () => {\n var o;\n this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => n !== i);\n };\n }\n});\nconst de = 250, Se = (e) => {\n const n = P(), t = [];\n let o = -1, i = !1, p = 0;\n const U = (r) => {\n if (!i) {\n const { changes: A } = r, m = performance.now();\n if (m - p > de)\n t.splice(o + 1), t.push(A), o = t.length - 1;\n else {\n const R = t.length - 1;\n t[R] = se(t[R], A);\n }\n p = m;\n }\n i = !1;\n };\n e.observe(U, { origin: O.LOCAL });\n const E = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), w = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), u = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: A }) => A)), L = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: A }) => A)), s = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), h = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);\n return {\n canRedo: () => t.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => e.unobserve(U),\n on: (r, A) => n.on(r, A),\n redo: () => {\n if (t.length - 1 > o) {\n i = !0;\n const { created: r, updated: A, deleted: m } = t[o + 1];\n w(r), L(A), h(m), n.emit(\"redo\", t[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: r, updated: A, deleted: m } = t[o];\n E(r), u(A), s(m), n.emit(\"undo\", t[o]), o -= 1;\n }\n }\n };\n}, Oe = () => {\n const { subscribe: e, set: n } = Y([]);\n return {\n subscribe: e,\n set: n\n };\n}, Te = (e, n, t, o) => {\n const { store: i, selection: p, hover: U, viewport: E } = e, w = /* @__PURE__ */ new Map();\n let u = [], L, s;\n const h = (c, g) => {\n w.has(c) ? w.get(c).push(g) : w.set(c, [g]);\n }, C = (c, g) => {\n const r = w.get(c);\n r && r.indexOf(g) > 0 && r.splice(r.indexOf(g), 1);\n }, b = (c, g, r) => {\n w.has(c) && setTimeout(() => {\n w.get(c).forEach((A) => {\n if (t) {\n const m = Array.isArray(g) ? g.map((I) => t.serialize(I)) : t.serialize(g), R = r ? r instanceof PointerEvent ? r : t.serialize(r) : void 0;\n A(m, R);\n } else\n A(g, r);\n });\n }, 1);\n }, S = () => {\n const { selected: c } = p, g = (c || []).map(({ id: r }) => i.getAnnotation(r));\n g.forEach((r) => {\n const A = u.find((m) => m.id === r.id);\n (!A || !x(A, r)) && b(\"updateAnnotation\", r, A);\n }), u = u.map((r) => {\n const A = g.find(({ id: m }) => m === r.id);\n return A || r;\n });\n };\n p.subscribe(({ selected: c }) => {\n if (!(u.length === 0 && c.length === 0)) {\n if (u.length === 0 && c.length > 0)\n u = c.map(({ id: g }) => i.getAnnotation(g));\n else if (u.length > 0 && c.length === 0)\n u.forEach((g) => {\n const r = i.getAnnotation(g.id);\n r && !x(r, g) && b(\"updateAnnotation\", r, g);\n }), u = [];\n else {\n const g = new Set(u.map((m) => m.id)), r = new Set(c.map(({ id: m }) => m));\n u.filter((m) => !r.has(m.id)).forEach((m) => {\n const R = i.getAnnotation(m.id);\n R && !x(R, m) && b(\"updateAnnotation\", R, m);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((m) => r.has(m.id)),\n // Add editable annotations that were selected\n ...c.filter(({ id: m }) => !g.has(m)).map(({ id: m }) => i.getAnnotation(m))\n ];\n }\n b(\"selectionChanged\", u);\n }\n }), U.subscribe((c) => {\n !L && c ? b(\"mouseEnterAnnotation\", i.getAnnotation(c)) : L && !c ? b(\"mouseLeaveAnnotation\", i.getAnnotation(L)) : L && c && (b(\"mouseLeaveAnnotation\", i.getAnnotation(L)), b(\"mouseEnterAnnotation\", i.getAnnotation(c))), L = c;\n }), E == null || E.subscribe((c) => b(\"viewportIntersect\", c.map((g) => i.getAnnotation(g)))), i.observe((c) => {\n o && (s && clearTimeout(s), s = setTimeout(S, 1e3));\n const { created: g, deleted: r } = c.changes;\n (g || []).forEach((m) => b(\"createAnnotation\", m)), (r || []).forEach((m) => b(\"deleteAnnotation\", m)), (c.changes.updated || []).filter((m) => [\n ...m.bodiesCreated || [],\n ...m.bodiesDeleted || [],\n ...m.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: m, newValue: R }) => {\n const I = u.find((N) => N.id === m.id) || m;\n u = u.map((N) => N.id === m.id ? R : N), b(\"updateAnnotation\", R, I);\n });\n }, { origin: O.LOCAL }), i.observe((c) => {\n if (u) {\n const g = new Set(u.map((A) => A.id)), r = (c.changes.updated || []).filter(({ newValue: A }) => g.has(A.id)).map(({ newValue: A }) => A);\n r.length > 0 && (u = u.map((A) => {\n const m = r.find((R) => R.id === A.id);\n return m || A;\n }));\n }\n }, { origin: O.REMOTE });\n const y = (c) => (g) => {\n const { updated: r } = g;\n c ? (r || []).forEach((A) => b(\"updateAnnotation\", A.oldValue, A.newValue)) : (r || []).forEach((A) => b(\"updateAnnotation\", A.newValue, A.oldValue));\n };\n return n.on(\"undo\", y(!0)), n.on(\"redo\", y(!1)), { on: h, off: C, emit: b };\n}, De = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {\n const { parsed: i, error: p } = e.parse(o);\n return p ? {\n parsed: t.parsed,\n failed: [...t.failed, o]\n } : i ? {\n parsed: [...t.parsed, i],\n failed: t.failed\n } : {\n ...t\n };\n}, { parsed: [], failed: [] }), Re = (e, n, t) => {\n const { store: o, selection: i } = e, p = (y) => {\n if (t) {\n const { parsed: c, error: g } = t.parse(y);\n c ? o.addAnnotation(c, O.REMOTE) : console.error(g);\n } else\n o.addAnnotation(y, O.REMOTE);\n }, U = () => i.clear(), E = () => o.clear(), w = (y) => {\n const c = o.getAnnotation(y);\n return t && c ? t.serialize(c) : c;\n }, u = () => t ? o.all().map(t.serialize) : o.all(), L = () => {\n var g;\n const c = (((g = i.selected) == null ? void 0 : g.map((r) => r.id)) || []).map((r) => o.getAnnotation(r)).filter(Boolean);\n return t ? c.map(t.serialize) : c;\n }, s = (y, c = !0) => fetch(y).then((g) => g.json()).then((g) => (C(g, c), g)), h = (y) => {\n if (typeof y == \"string\") {\n const c = o.getAnnotation(y);\n if (o.deleteAnnotation(y), c)\n return t ? t.serialize(c) : c;\n } else {\n const c = t ? t.parse(y).parsed : y;\n if (c)\n return o.deleteAnnotation(c), y;\n }\n }, C = (y, c = !0) => {\n if (t) {\n const { parsed: g, failed: r } = re(t)(y);\n r.length > 0 && console.warn(`Discarded ${r.length} invalid annotations`, r), o.bulkAddAnnotation(g, c, O.REMOTE);\n } else\n o.bulkAddAnnotation(y, c, O.REMOTE);\n }, b = (y) => {\n y ? i.setSelected(y) : i.clear();\n }, S = (y) => {\n if (t) {\n const c = t.parse(y).parsed, g = t.serialize(o.getAnnotation(c.id));\n return o.updateAnnotation(c), g;\n } else {\n const c = o.getAnnotation(y.id);\n return o.updateAnnotation(y), c;\n }\n };\n return {\n addAnnotation: p,\n cancelSelected: U,\n canRedo: n.canRedo,\n canUndo: n.canUndo,\n clearAnnotations: E,\n getAnnotationById: w,\n getAnnotations: u,\n getSelected: L,\n loadAnnotations: s,\n redo: n.redo,\n removeAnnotation: h,\n setAnnotations: C,\n setSelected: b,\n undo: n.undo,\n updateAnnotation: S\n };\n}, ae = \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\";\nlet ce = (e) => crypto.getRandomValues(new Uint8Array(e)), le = (e, n, t) => {\n let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);\n return (p = n) => {\n let U = \"\";\n for (; ; ) {\n let E = t(i), w = i;\n for (; w--; )\n if (U += e[E[w] & o] || \"\", U.length === p)\n return U;\n }\n };\n}, ue = (e, n = 21) => le(e, n, ce), fe = (e = 21) => {\n let n = \"\", t = crypto.getRandomValues(new Uint8Array(e));\n for (; e--; )\n n += ae[t[e] & 63];\n return n;\n};\nconst Be = () => ({ isGuest: !0, id: ue(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), pe = (e) => {\n const n = JSON.stringify(e);\n let t = 0;\n for (let o = 0, i = n.length; o < i; o++) {\n let p = n.charCodeAt(o);\n t = (t << 5) - t + p, t |= 0;\n }\n return `${t}`;\n}, he = (e) => e ? typeof e == \"object\" ? { ...e } : e : void 0, xe = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {\n const { id: o, type: i, purpose: p, value: U, created: E, creator: w, ...u } = t;\n return {\n id: o || `temp-${pe(t)}`,\n annotation: n,\n type: i,\n purpose: p,\n value: U,\n created: E ? new Date(E) : void 0,\n creator: he(w),\n ...u\n };\n}), Ie = (e) => e.map((n) => {\n var o, i;\n const t = { ...n };\n return delete t.annotation, (o = t.id) != null && o.startsWith(\"temp-\") && delete t.id, { ...t, created: (i = t.created) == null ? void 0 : i.toISOString() };\n}), ge = [\n \"#ff7c00\",\n // orange\n \"#1ac938\",\n // green\n \"#e8000b\",\n // red\n \"#8b2be2\",\n // purple\n \"#9f4800\",\n // brown\n \"#f14cc1\",\n // pink\n \"#ffc400\",\n // khaki\n \"#00d7ff\",\n // cyan\n \"#023eff\"\n // blue\n], me = () => {\n const e = [...ge];\n return { assignRandomColor: () => {\n const o = Math.floor(Math.random() * e.length), i = e[o];\n return e.splice(o, 1), i;\n }, releaseColor: (o) => e.push(o) };\n}, Ae = () => {\n const e = me();\n return { addUser: (o, i) => {\n const p = e.assignRandomColor();\n return {\n label: i.name || i.id,\n avatar: i.avatar,\n color: p\n };\n }, removeUser: (o) => e.releaseColor(o.appearance.color) };\n}, be = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), ke = fe(), Ne = (e = Ae()) => {\n const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, h) => {\n if (t.has(s)) {\n console.warn(\"Attempt to add user that is already present\", s, h);\n return;\n }\n const C = e.addUser(s, h);\n t.set(s, {\n ...h,\n presenceKey: s,\n appearance: C\n });\n }, p = (s) => {\n const h = t.get(s);\n if (!h) {\n console.warn(\"Attempt to remove user that is not present\", s);\n return;\n }\n e.removeUser(h), t.delete(s);\n }, U = (s) => {\n const h = new Set(s.map((S) => S.presenceKey)), C = s.filter(({ presenceKey: S }) => !t.has(S)), b = Array.from(t.values()).filter((S) => !h.has(S.presenceKey));\n C.forEach(({ presenceKey: S, user: y }) => i(S, y)), b.forEach((S) => {\n const { presenceKey: y } = S;\n o.has(y) && n.emit(\"selectionChange\", S, null), p(y);\n }), (C.length > 0 || b.length > 0) && n.emit(\"presence\", u());\n }, E = (s, h) => {\n const C = t.get(s);\n if (!C) {\n console.warn(\"Activity notification from user that is not present\");\n return;\n }\n const b = o.get(s);\n (!b || !be(b, h)) && (o.set(s, h), n.emit(\"selectionChange\", C, h));\n }, w = (s, h) => {\n const C = t.get(s);\n if (!C) {\n console.warn(\"Selection change for user that is not present\", s);\n return;\n }\n h ? o.set(s, h) : o.delete(s), n.emit(\"selectionChange\", C, h);\n }, u = () => [...Array.from(t.values())];\n return {\n getPresentUsers: u,\n notifyActivity: E,\n on: (s, h) => n.on(s, h),\n syncUsers: U,\n updateSelection: w\n };\n};\nexport {\n ne as Ignore,\n O as Origin,\n ke as PRESENCE_KEY,\n q as PointerSelectAction,\n Be as createAnonymousGuest,\n Re as createBaseAnnotator,\n Ce as createBody,\n Ae as createDefaultAppearenceProvider,\n ve as createHoverState,\n Te as createLifecyleObserver,\n Ne as createPresenceState,\n ye as createSelectionState,\n Ue as createStore,\n Se as createUndoStack,\n Oe as createViewportState,\n me as defaultColorProvider,\n M as diffAnnotations,\n we as getContributors,\n se as mergeChanges,\n G as onPointerSelect,\n re as parseAll,\n xe as parseW3CBodies,\n he as parseW3CUser,\n De as serializeAll,\n Ie as serializeW3CBodies,\n oe as shouldNotify,\n Le as toSvelteStore\n};\n//# sourceMappingURL=annotorious-core.es.js.map\n"],"names":["q","e","$","H","F","D","J","n","Q","j","X","t","o","i","Ce","O","Le","ae","ce","le","p","U","E","w","ue","fe","Be","ge","me"],"mappings":"AA2EG,IAACA,IAAqB,kBAACC,OAAOA,EAAE,OAAO,QAAQA,EAAE,SAAS,UAAUA,EAAE,OAAO,QAAQA,IAAID,KAAK,EAAE;AA4CnG,IAAIE;AACJ,MAAMC,IAAI,IAAI,WAAW,EAAE;AAC3B,SAASC,IAAI;AACX,MAAI,CAACF,MAAMA,IAAI,OAAO,SAAS,OAAO,OAAO,mBAAmB,OAAO,gBAAgB,KAAK,MAAM,GAAG,CAACA;AACpG,UAAM,IAAI,MAAM,0GAA0G;AAC5H,SAAOA,EAAEC,CAAC;AACZ;AACA,MAAME,IAAI,CAAA;AACV,SAASJ,IAAI,GAAGA,IAAI,KAAK,EAAEA;AACzB,EAAAI,EAAE,MAAMJ,IAAI,KAAK,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACxC,SAASK,EAAEL,GAAGM,IAAI,GAAG;AACnB,SAAOF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC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