@annotorious/react 3.0.0-rc.18 → 3.0.0-rc.2
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.
- package/dist/Annotorious.d.ts +26 -2
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/annotorious-react.css +1 -1
- package/dist/annotorious-react.es.js +34 -33
- package/dist/annotorious-react.es.js.map +1 -1
- package/dist/annotorious-react.es10.js +2 -36
- package/dist/annotorious-react.es10.js.map +1 -1
- package/dist/annotorious-react.es11.js +8 -15
- package/dist/annotorious-react.es11.js.map +1 -1
- package/dist/annotorious-react.es12.js +2 -6
- package/dist/annotorious-react.es12.js.map +1 -1
- package/dist/annotorious-react.es13.js +3751 -7
- package/dist/annotorious-react.es13.js.map +1 -1
- package/dist/annotorious-react.es14.js +28 -152
- package/dist/annotorious-react.es14.js.map +1 -1
- package/dist/annotorious-react.es15.js +33 -18908
- package/dist/annotorious-react.es15.js.map +1 -1
- package/dist/annotorious-react.es16.js +16 -32
- package/dist/annotorious-react.es16.js.map +1 -1
- package/dist/annotorious-react.es17.js +4 -2
- package/dist/annotorious-react.es17.js.map +1 -1
- package/dist/annotorious-react.es18.js +8 -599
- package/dist/annotorious-react.es18.js.map +1 -1
- package/dist/annotorious-react.es19.js +152 -29
- package/dist/annotorious-react.es19.js.map +1 -1
- package/dist/annotorious-react.es2.js +24 -24
- package/dist/annotorious-react.es2.js.map +1 -1
- package/dist/annotorious-react.es20.js +6 -2
- package/dist/annotorious-react.es20.js.map +1 -1
- package/dist/annotorious-react.es21.js +2 -2
- package/dist/annotorious-react.es22.js +33 -0
- package/dist/annotorious-react.es22.js.map +1 -0
- package/dist/annotorious-react.es23.js +602 -0
- package/dist/annotorious-react.es23.js.map +1 -0
- package/dist/annotorious-react.es24.js +20611 -0
- package/dist/annotorious-react.es24.js.map +1 -0
- package/dist/annotorious-react.es25.js +35 -0
- package/dist/annotorious-react.es25.js.map +1 -0
- package/dist/annotorious-react.es26.js +5 -0
- package/dist/annotorious-react.es26.js.map +1 -0
- package/dist/annotorious-react.es27.js +5 -0
- package/dist/annotorious-react.es27.js.map +1 -0
- package/dist/annotorious-react.es28.js +24 -0
- package/dist/annotorious-react.es28.js.map +1 -0
- package/dist/annotorious-react.es29.js +5 -0
- package/dist/annotorious-react.es29.js.map +1 -0
- package/dist/annotorious-react.es30.js +20 -0
- package/dist/annotorious-react.es30.js.map +1 -0
- package/dist/annotorious-react.es31.js +7 -0
- package/dist/annotorious-react.es31.js.map +1 -0
- package/dist/annotorious-react.es32.js +11 -0
- package/dist/annotorious-react.es32.js.map +1 -0
- package/dist/annotorious-react.es33.js +10 -0
- package/dist/annotorious-react.es33.js.map +1 -0
- package/dist/annotorious-react.es4.js +8 -8
- package/dist/annotorious-react.es4.js.map +1 -1
- package/dist/annotorious-react.es5.js +10 -10
- package/dist/annotorious-react.es5.js.map +1 -1
- package/dist/annotorious-react.es6.js +4 -1
- package/dist/annotorious-react.es6.js.map +1 -1
- package/dist/annotorious-react.es7.js +4 -1
- package/dist/annotorious-react.es7.js.map +1 -1
- package/dist/annotorious-react.es8.js +7 -80
- package/dist/annotorious-react.es8.js.map +1 -1
- package/dist/annotorious-react.es9.js +2 -31
- package/dist/annotorious-react.es9.js.map +1 -1
- package/dist/index.d.ts +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
- package/package.json +8 -17
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import w from "openseadragon";
|
|
2
|
+
const L = (i, h) => {
|
|
3
|
+
const e = i.element.getBoundingClientRect(), { minX: n, minY: l, maxX: t, maxY: c } = h.target.selector.geometry.bounds, s = i.viewport.imageToViewerElementCoordinates(new w.Point(n, l)), x = i.viewport.imageToViewerElementCoordinates(new w.Point(t, c));
|
|
4
|
+
return {
|
|
5
|
+
x: s.x + e.x,
|
|
6
|
+
right: x.x + e.x,
|
|
7
|
+
y: s.y + e.y,
|
|
8
|
+
bottom: x.y + e.y,
|
|
9
|
+
width: x.x - s.x,
|
|
10
|
+
height: x.y - s.y
|
|
11
|
+
};
|
|
12
|
+
}, T = (i, h, e, n = 5) => {
|
|
13
|
+
const l = i.element.getBoundingClientRect(), t = L(i, h), c = t.y - l.y, s = l.right - t.x, x = l.bottom - t.bottom, d = t.x - l.left, o = e.firstElementChild.getBoundingClientRect(), g = c / o.height, y = s / o.width, a = x / o.height, r = d / o.width, $ = () => {
|
|
14
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.y - n - o.height}px`;
|
|
15
|
+
}, f = () => {
|
|
16
|
+
e.style.left = `${t.right - o.width}px`, e.style.top = `${t.y - n - o.height}px`;
|
|
17
|
+
}, B = () => {
|
|
18
|
+
e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.y}px`;
|
|
19
|
+
}, v = () => {
|
|
20
|
+
e.style.left = `${t.right + n}px`, e.style.top = `${t.y}px`;
|
|
21
|
+
}, R = () => {
|
|
22
|
+
e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.bottom - o.height}px`;
|
|
23
|
+
}, C = () => {
|
|
24
|
+
e.style.left = `${t.x + t.width + n}px`, e.style.top = `${t.bottom - o.height}px`;
|
|
25
|
+
}, A = () => {
|
|
26
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.bottom + n}px`;
|
|
27
|
+
}, E = () => {
|
|
28
|
+
e.style.left = `${t.right - o.width}px`, e.style.top = `${t.bottom + n}px`;
|
|
29
|
+
}, b = [g, y, a, r], m = b.indexOf(Math.max(...b));
|
|
30
|
+
m === 0 ? y > r ? $() : f() : m === 1 ? g > a ? C() : v() : m === 2 ? y > r ? A() : E() : g > a ? R() : B();
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
T as setPosition
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=annotorious-react.es25.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es25.js","sources":["../src/openseadragon/setPosition.ts"],"sourcesContent":["import { ImageAnnotation } from '@annotorious/annotorious';\nimport OpenSeadragon from 'openseadragon';\n\nconst getAnnotationDomRect = (viewer: OpenSeadragon.Viewer, annotation: ImageAnnotation) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n \n // Annotation bounds (image coordinates)\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n // Annotation coordinates - viewer element coordinates\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // Account for viewer element offset\n return {\n x: topLeft.x + viewerBounds.x,\n right: bottomRight.x + viewerBounds.x,\n y: topLeft.y + viewerBounds.y,\n bottom: bottomRight.y + viewerBounds.y,\n width: bottomRight.x - topLeft.x,\n height: bottomRight.y - topLeft.y,\n };\n}\n\nexport const setPosition = (\n viewer: OpenSeadragon.Viewer, \n annotation: ImageAnnotation, \n popup: HTMLElement,\n sideOffset: number = 5\n) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n const annoBounds = getAnnotationDomRect(viewer, annotation);\n\n // Available space above, right, below, left the annotation in the viewport\n const availableAbove = annoBounds.y - viewerBounds.y;\n const availableRight = viewerBounds.right - annoBounds.x;\n const availableBelow = viewerBounds.bottom - annoBounds.bottom;\n const availableLeft = annoBounds.x - viewerBounds.left;\n\n // Popup element bounds\n const popupBounds = popup.firstElementChild.getBoundingClientRect();\n\n // Eight possible base alignment anchor points\n //\n // topleft topright\n // * *\n // leftdown * |---------------------| * rightdown\n // | |\n // | |\n // | |\n // leftup * |---------------------| * rightup\n // * * \n // bottomleft bottomright\n //\n // We'll position the popup at the cardinal direction\n // with the highest ratio: available space vs. popup size.\n const ratioAbove = availableAbove / popupBounds.height;\n const ratioRight = availableRight / popupBounds.width;\n const ratioBelow = availableBelow / popupBounds.height;\n const ratioLeft = availableLeft / popupBounds.width;\n\n const topleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const topright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const leftdown = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n } \n\n const rightdown = () => {\n popup.style.left = `${annoBounds.right + sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n }\n\n const leftup = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const rightup = () => {\n popup.style.left = `${annoBounds.x + annoBounds.width + sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const bottomleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const bottomright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const ratios = [ratioAbove, ratioRight, ratioBelow, ratioLeft];\n const maxIdx = ratios.indexOf(Math.max(...ratios));\n\n if (maxIdx === 0) {\n // Main orientation: above\n if (ratioRight > ratioLeft)\n topleft();\n else \n topright();\n } else if (maxIdx === 1) {\n // Main orientation: right\n if (ratioAbove > ratioBelow)\n rightup();\n else\n rightdown();\n } else if (maxIdx === 2) {\n // Main orientation: below\n if (ratioRight > ratioLeft)\n bottomleft();\n else\n bottomright();\n } else {\n // Main orientation: left\n if (ratioAbove > ratioBelow)\n leftup();\n else \n leftdown();\n }\n}"],"names":["getAnnotationDomRect","viewer","annotation","viewerBounds","minX","minY","maxX","maxY","topLeft","OpenSeadragon","bottomRight","setPosition","popup","sideOffset","annoBounds","availableAbove","availableRight","availableBelow","availableLeft","popupBounds","ratioAbove","ratioRight","ratioBelow","ratioLeft","topleft","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IAAaE,IACPO,MAEEF,MACHM,MAAW,IAEhBZ,IAAaE,IACJO,MAECC,MAGVX,IAAaE,IACRM,MAEEF;AAEf;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es26.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es27.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const f = [
|
|
2
|
+
"#ff7c00",
|
|
3
|
+
// orange
|
|
4
|
+
"#1ac938",
|
|
5
|
+
// green
|
|
6
|
+
"#e8000b",
|
|
7
|
+
// red
|
|
8
|
+
"#8b2be2",
|
|
9
|
+
// purple
|
|
10
|
+
"#9f4800",
|
|
11
|
+
// brown
|
|
12
|
+
"#f14cc1",
|
|
13
|
+
// pink
|
|
14
|
+
"#ffc400",
|
|
15
|
+
// khaki
|
|
16
|
+
"#00d7ff",
|
|
17
|
+
// cyan
|
|
18
|
+
"#023eff"
|
|
19
|
+
// blue
|
|
20
|
+
];
|
|
21
|
+
export {
|
|
22
|
+
f as DEFAULT_PALETTE
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=annotorious-react.es28.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es28.js","sources":["../../annotorious-core/src/presence/ColorPalette.ts"],"sourcesContent":["// SEABORN_BRIGHT\nexport const DEFAULT_PALETTE: Palette = [\n '#ff7c00', // orange\n '#1ac938', // green\n '#e8000b', // red\n '#8b2be2', // purple\n '#9f4800', // brown\n '#f14cc1', // pink\n '#ffc400', // khaki\n '#00d7ff', // cyan\n '#023eff' // blue\n];\n\nexport type Palette = string[];"],"names":["DEFAULT_PALETTE"],"mappings":"AACO,MAAMA,IAA2B;AAAA,EACtC;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
let o = (n = 21) => crypto.getRandomValues(new Uint8Array(n)).reduce((r, e) => (e &= 63, e < 36 ? r += e.toString(36) : e < 62 ? r += (e - 26).toString(36).toUpperCase() : e > 62 ? r += "-" : r += "_", r), "");
|
|
2
|
+
export {
|
|
3
|
+
o as nanoid
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=annotorious-react.es29.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es29.js","sources":["../../../node_modules/nanoid/index.browser.js"],"sourcesContent":["export { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n"],"names":["nanoid","size","id","byte"],"mappings":"AAmBU,IAACA,IAAS,CAACC,IAAO,OAC1B,OAAO,gBAAgB,IAAI,WAAWA,CAAI,CAAC,EAAE,OAAO,CAACC,GAAIC,OACvDA,KAAQ,IACJA,IAAO,KACTD,KAAMC,EAAK,SAAS,EAAE,IACbA,IAAO,KAChBD,MAAOC,IAAO,IAAI,SAAS,EAAE,EAAE,YAAa,IACnCA,IAAO,KAChBD,KAAM,MAENA,KAAM,KAEDA,IACN,EAAE;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import e from "./annotorious-react.es31.js";
|
|
2
|
+
import i from "./annotorious-react.es32.js";
|
|
3
|
+
import { unsafeStringify as d } from "./annotorious-react.es33.js";
|
|
4
|
+
function g(n, m, t) {
|
|
5
|
+
if (e.randomUUID && !m && !n)
|
|
6
|
+
return e.randomUUID();
|
|
7
|
+
n = n || {};
|
|
8
|
+
const r = n.random || (n.rng || i)();
|
|
9
|
+
if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, m) {
|
|
10
|
+
t = t || 0;
|
|
11
|
+
for (let a = 0; a < 16; ++a)
|
|
12
|
+
m[t + a] = r[a];
|
|
13
|
+
return m;
|
|
14
|
+
}
|
|
15
|
+
return d(r);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
g as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=annotorious-react.es30.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es30.js","sources":["../../../node_modules/uuid/dist/esm-browser/v4.js"],"sourcesContent":["import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;"],"names":["v4","options","buf","offset","native","rnds","rng","i","unsafeStringify"],"mappings":";;;AAIA,SAASA,EAAGC,GAASC,GAAKC,GAAQ;AAChC,MAAIC,EAAO,cAAc,CAACF,KAAO,CAACD;AAChC,WAAOG,EAAO;AAGhB,EAAAH,IAAUA,KAAW;AACrB,QAAMI,IAAOJ,EAAQ,WAAWA,EAAQ,OAAOK;AAK/C,MAHAD,EAAK,CAAC,IAAIA,EAAK,CAAC,IAAI,KAAO,IAC3BA,EAAK,CAAC,IAAIA,EAAK,CAAC,IAAI,KAAO,KAEvBH,GAAK;AACP,IAAAC,IAASA,KAAU;AAEnB,aAASI,IAAI,GAAGA,IAAI,IAAI,EAAEA;AACxB,MAAAL,EAAIC,IAASI,CAAC,IAAIF,EAAKE,CAAC;AAG1B,WAAOL;AAAA,EACR;AAED,SAAOM,EAAgBH,CAAI;AAC7B;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es31.js","sources":["../../../node_modules/uuid/dist/esm-browser/native.js"],"sourcesContent":["const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};"],"names":["randomUUID","native"],"mappings":"AAAA,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,cAAc,OAAO,WAAW,KAAK,MAAM,GACvFC,IAAA;AAAA,EACb,YAAAD;AACF;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let t;
|
|
2
|
+
const e = new Uint8Array(16);
|
|
3
|
+
function o() {
|
|
4
|
+
if (!t && (t = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !t))
|
|
5
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
6
|
+
return t(e);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
o as default
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=annotorious-react.es32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es32.js","sources":["../../../node_modules/uuid/dist/esm-browser/rng.js"],"sourcesContent":["// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}"],"names":["getRandomValues","rnds8","rng"],"mappings":"AAGA,IAAIA;AACJ,MAAMC,IAAQ,IAAI,WAAW,EAAE;AAChB,SAASC,IAAM;AAE5B,MAAI,CAACF,MAEHA,IAAkB,OAAO,SAAW,OAAe,OAAO,mBAAmB,OAAO,gBAAgB,KAAK,MAAM,GAE3G,CAACA;AACH,UAAM,IAAI,MAAM,0GAA0G;AAI9H,SAAOA,EAAgBC,CAAK;AAC9B;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const i = [];
|
|
2
|
+
for (let n = 0; n < 256; ++n)
|
|
3
|
+
i.push((n + 256).toString(16).slice(1));
|
|
4
|
+
function c(n, u = 0) {
|
|
5
|
+
return i[n[u + 0]] + i[n[u + 1]] + i[n[u + 2]] + i[n[u + 3]] + "-" + i[n[u + 4]] + i[n[u + 5]] + "-" + i[n[u + 6]] + i[n[u + 7]] + "-" + i[n[u + 8]] + i[n[u + 9]] + "-" + i[n[u + 10]] + i[n[u + 11]] + i[n[u + 12]] + i[n[u + 13]] + i[n[u + 14]] + i[n[u + 15]];
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
c as unsafeStringify
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=annotorious-react.es33.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es33.js","sources":["../../../node_modules/uuid/dist/esm-browser/stringify.js"],"sourcesContent":["import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;"],"names":["byteToHex","i","unsafeStringify","arr","offset"],"mappings":"AAMA,MAAMA,IAAY,CAAA;AAElB,SAASC,IAAI,GAAGA,IAAI,KAAK,EAAEA;AACzB,EAAAD,EAAU,MAAMC,IAAI,KAAO,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAG3C,SAASC,EAAgBC,GAAKC,IAAS,GAAG;AAG/C,SAAOJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAI,MAAMJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAI,MAAMJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAI,MAAMJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAAI,MAAMJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAAIJ,EAAUG,EAAIC,IAAS,EAAE,CAAC;AACnf;","x_google_ignoreList":[0]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as s } from "./annotorious-react.es17.js";
|
|
2
2
|
import { forwardRef as g } from "react";
|
|
3
|
-
import { useDraggable as i } from "./annotorious-react.
|
|
4
|
-
const
|
|
5
|
-
const { children:
|
|
6
|
-
return i(o, { onDragStart:
|
|
3
|
+
import { useDraggable as i } from "./annotorious-react.es19.js";
|
|
4
|
+
const d = g((r, o) => {
|
|
5
|
+
const { children: a, className: t, onDragStart: n, onDragEnd: e } = r;
|
|
6
|
+
return i(o, { onDragStart: n, onDragEnd: e, cancel: "button, .no-drag" }), /* @__PURE__ */ s(
|
|
7
7
|
"div",
|
|
8
8
|
{
|
|
9
9
|
ref: o,
|
|
10
|
-
className:
|
|
10
|
+
className: t,
|
|
11
11
|
style: { position: "absolute" },
|
|
12
|
-
children:
|
|
12
|
+
children: a
|
|
13
13
|
}
|
|
14
14
|
);
|
|
15
15
|
});
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
d as Draggable
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=annotorious-react.es4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es4.js","sources":["../src/AnnotoriousPopup.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useDraggable } from '@neodrag/react';\n\nexport interface AnnotoriousPopupProps {\n\n selected: { annotation: ImageAnnotation, editable?: boolean }[];\n\n}\n\nexport interface DraggableProps {\n\n children: ReactNode;\n\n className?: string;\n\n onDragStart?(): void;\n\n onDragEnd?(): void;\n\n}\n\nexport const Draggable = forwardRef((props: DraggableProps, ref: React.MutableRefObject<HTMLDivElement>) => {\n\n const { children, className, onDragStart, onDragEnd } = props;\n\n useDraggable(ref, { onDragStart, onDragEnd, cancel: 'button, .no-drag' });\n\n return (\n <div \n ref={ref} \n className={className} \n style={{ position: 'absolute' }}>\n {children}\n </div>\n )\n\n});"],"names":["Draggable","forwardRef","props","ref","children","className","onDragStart","onDragEnd","useDraggable","jsx"],"mappings":";;;AAsBO,MAAMA,IAAYC,EAAW,CAACC,GAAuBC,MAAiD;AAE3G,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,aAAAC,GAAa,WAAAC,MAAcL;AAExDM,SAAAA,EAAaL,GAAK,EAAE,aAAAG,GAAa,WAAAC,GAAW,QAAQ,oBAAoB,
|
|
1
|
+
{"version":3,"file":"annotorious-react.es4.js","sources":["../src/AnnotoriousPopup.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useDraggable } from '@neodrag/react';\n\nexport interface AnnotoriousPopupProps {\n\n selected: { annotation: ImageAnnotation, editable?: boolean }[];\n\n}\n\nexport interface DraggableProps {\n\n children: ReactNode;\n\n className?: string;\n\n onDragStart?(): void;\n\n onDragEnd?(): void;\n\n}\n\nexport const Draggable = forwardRef((props: DraggableProps, ref: React.MutableRefObject<HTMLDivElement>) => {\n\n const { children, className, onDragStart, onDragEnd } = props;\n\n useDraggable(ref, { onDragStart, onDragEnd, cancel: 'button, .no-drag' });\n\n return (\n <div \n ref={ref} \n className={className} \n style={{ position: 'absolute' }}>\n {children}\n </div>\n )\n\n});"],"names":["Draggable","forwardRef","props","ref","children","className","onDragStart","onDragEnd","useDraggable","jsx"],"mappings":";;;AAsBO,MAAMA,IAAYC,EAAW,CAACC,GAAuBC,MAAiD;AAE3G,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,aAAAC,GAAa,WAAAC,MAAcL;AAExDM,SAAAA,EAAaL,GAAK,EAAE,aAAAG,GAAa,WAAAC,GAAW,QAAQ,oBAAoB,GAGtE,gBAAAE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,WAAAE;AAAA,MACA,OAAO,EAAE,UAAU,WAAW;AAAA,MAC7B,UAAAD;AAAA,IAAA;AAAA,EAAA;AAIP,CAAC;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Children as
|
|
3
|
-
import { createImageAnnotator as u } from "
|
|
4
|
-
import { AnnotoriousContext as
|
|
5
|
-
const
|
|
6
|
-
const { children:
|
|
1
|
+
import { jsx as a, Fragment as g } from "./annotorious-react.es17.js";
|
|
2
|
+
import { Children as d, useContext as x, useEffect as e, cloneElement as h } from "react";
|
|
3
|
+
import { createImageAnnotator as u } from "./annotorious-react.es13.js";
|
|
4
|
+
import { AnnotoriousContext as y } from "./annotorious-react.es2.js";
|
|
5
|
+
const I = (t) => {
|
|
6
|
+
const { children: n, tool: A, ...i } = t, l = d.only(n), { anno: o, setAnno: r } = x(y), c = (m) => {
|
|
7
7
|
if (!o) {
|
|
8
|
-
const f =
|
|
9
|
-
|
|
8
|
+
const f = m.target, s = u(f, i);
|
|
9
|
+
r(s);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
return e(() => {
|
|
@@ -15,9 +15,9 @@ const F = (t) => {
|
|
|
15
15
|
o && o.setFilter(t.filter);
|
|
16
16
|
}, [t.filter]), e(() => {
|
|
17
17
|
o && o.setStyle(t.style);
|
|
18
|
-
}, [t.style]), /* @__PURE__ */
|
|
18
|
+
}, [t.style]), /* @__PURE__ */ a(g, { children: h(l, { onLoad: c }) });
|
|
19
19
|
};
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
I as ImageAnnotator
|
|
22
22
|
};
|
|
23
23
|
//# sourceMappingURL=annotorious-react.es5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: DrawingTool\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (props.tool && anno) anno.setDrawingTool(props.tool);\n }, [props.tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [props.style]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IACd;AAAA,EAAA;AAGF,SAAAE,EAAU,MAAM;AACd,IAAIf,EAAM,QAAQM,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EACrD,GAAA,CAACA,EAAM,MAAMM,CAAI,CAAC,GAErBS,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: DrawingTool\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (props.tool && anno) anno.setDrawingTool(props.tool);\n }, [props.tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [props.style]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IACd;AAAA,EAAA;AAGF,SAAAE,EAAU,MAAM;AACd,IAAIf,EAAM,QAAQM,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EACrD,GAAA,CAACA,EAAM,MAAMM,CAAI,CAAC,GAErBS,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,0BAEN,UAAagB,EAAAZ,GAAO,EAAE,QAAAM,GAAsC,EAAE,CAAA;AAE1E;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"annotorious-react.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"annotorious-react.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,85 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
function g() {
|
|
5
|
-
if (!c && (c = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !c))
|
|
6
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
7
|
-
return c(p);
|
|
8
|
-
}
|
|
9
|
-
const o = [];
|
|
10
|
-
for (let t = 0; t < 256; ++t)
|
|
11
|
-
o.push((t + 256).toString(16).slice(1));
|
|
12
|
-
function y(t, r = 0) {
|
|
13
|
-
return o[t[r + 0]] + o[t[r + 1]] + o[t[r + 2]] + o[t[r + 3]] + "-" + o[t[r + 4]] + o[t[r + 5]] + "-" + o[t[r + 6]] + o[t[r + 7]] + "-" + o[t[r + 8]] + o[t[r + 9]] + "-" + o[t[r + 10]] + o[t[r + 11]] + o[t[r + 12]] + o[t[r + 13]] + o[t[r + 14]] + o[t[r + 15]];
|
|
14
|
-
}
|
|
15
|
-
const m = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), i = {
|
|
16
|
-
randomUUID: m
|
|
17
|
-
};
|
|
18
|
-
function U(t, r, e) {
|
|
19
|
-
if (i.randomUUID && !r && !t)
|
|
20
|
-
return i.randomUUID();
|
|
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, r) {
|
|
24
|
-
e = e || 0;
|
|
25
|
-
for (let n = 0; n < 16; ++n)
|
|
26
|
-
r[e + n] = a[n];
|
|
27
|
-
return r;
|
|
28
|
-
}
|
|
29
|
-
return y(a);
|
|
30
|
-
}
|
|
31
|
-
const b = (t, r, e, a) => ({
|
|
32
|
-
id: U(),
|
|
33
|
-
annotation: t.id,
|
|
34
|
-
created: e || /* @__PURE__ */ new Date(),
|
|
35
|
-
creator: a,
|
|
36
|
-
...r
|
|
37
|
-
});
|
|
38
|
-
var h = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(h || {});
|
|
39
|
-
let E = (t) => crypto.getRandomValues(new Uint8Array(t)), R = (t, r, e) => {
|
|
40
|
-
let a = (2 << Math.log(t.length - 1) / Math.LN2) - 1, n = -~(1.6 * a * r / t.length);
|
|
41
|
-
return (d = r) => {
|
|
42
|
-
let s = "";
|
|
43
|
-
for (; ; ) {
|
|
44
|
-
let l = e(n), u = n;
|
|
45
|
-
for (; u--; )
|
|
46
|
-
if (s += t[l[u] & a] || "", s.length === d)
|
|
47
|
-
return s;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}, w = (t, r = 21) => R(t, r, E), C = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((r, e) => (e &= 63, e < 36 ? r += e.toString(36) : e < 62 ? r += (e - 26).toString(36).toUpperCase() : e > 62 ? r += "-" : r += "_", r), "");
|
|
51
|
-
const A = () => ({ isGuest: !0, id: w("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), D = [
|
|
52
|
-
"#ff7c00",
|
|
53
|
-
// orange
|
|
54
|
-
"#1ac938",
|
|
55
|
-
// green
|
|
56
|
-
"#e8000b",
|
|
57
|
-
// red
|
|
58
|
-
"#8b2be2",
|
|
59
|
-
// purple
|
|
60
|
-
"#9f4800",
|
|
61
|
-
// brown
|
|
62
|
-
"#f14cc1",
|
|
63
|
-
// pink
|
|
64
|
-
"#ffc400",
|
|
65
|
-
// khaki
|
|
66
|
-
"#00d7ff",
|
|
67
|
-
// cyan
|
|
68
|
-
"#023eff"
|
|
69
|
-
// blue
|
|
70
|
-
], I = () => {
|
|
71
|
-
const t = [...D];
|
|
1
|
+
import { DEFAULT_PALETTE as s } from "./annotorious-react.es28.js";
|
|
2
|
+
const a = () => {
|
|
3
|
+
const o = [...s];
|
|
72
4
|
return { assignRandomColor: () => {
|
|
73
|
-
const r = Math.floor(Math.random() *
|
|
74
|
-
return
|
|
75
|
-
}, releaseColor: (r) =>
|
|
5
|
+
const r = Math.floor(Math.random() * o.length), n = o[r];
|
|
6
|
+
return o.splice(r, 1), n;
|
|
7
|
+
}, releaseColor: (r) => o.push(r) };
|
|
76
8
|
};
|
|
77
|
-
C();
|
|
78
9
|
export {
|
|
79
|
-
|
|
80
|
-
f as PointerSelectAction,
|
|
81
|
-
A as createAnonymousGuest,
|
|
82
|
-
b as createBody,
|
|
83
|
-
I as defaultColorProvider
|
|
10
|
+
a as defaultColorProvider
|
|
84
11
|
};
|
|
85
12
|
//# sourceMappingURL=annotorious-react.es8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es8.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","ae","ce","p","U","b","w","le","ue","Re","ge","he"],"mappings":"AA2EG,IAACA,IAAqB,kBAACC,OA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AC,IAAIT,CAAC,KAAK,IAAIO,EAAE,WAAWD;AACvC,iBAAOC;AAAA,IACZ;AAAA,EACL;AACA,GAAGG,IAAK,CAACrB,GAAGM,IAAI,OAAOU,EAAGhB,GAAGM,GAAGS,CAAE,GAAGO,IAAK,CAACtB,IAAI,OAAO,OAAO,gBAAgB,IAAI,WAAWA,CAAC,CAAC,EAAE,OAAO,CAACM,GAAGI,OAAOA,KAAK,IAAIA,IAAI,KAAKJ,KAAKI,EAAE,SAAS,EAAE,IAAIA,IAAI,KAAKJ,MAAMI,IAAI,IAAI,SAAS,EAAE,EAAE,YAAW,IAAKA,IAAI,KAAKJ,KAAK,MAAMA,KAAK,KAAKA,IAAI,EAAE;AAC7O,MAACiB,IAAK,OAAO,EAAE,SAAS,IAAI,IAAIF,EAAG,mEAAmE,EAAE,EAAC,MAwB1GG,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,QAAMzB,IAAI,CAAC,GAAGwB,CAAE;AAChB,SAAO,EAAE,mBAAmB,MAAM;AAChC,UAAMb,IAAI,KAAK,MAAM,KAAK,OAAM,IAAKX,EAAE,MAAM,GAAGY,IAAIZ,EAAEW,CAAC;AACvD,WAAOX,EAAE,OAAOW,GAAG,CAAC,GAAGC;AAAA,EAC3B,GAAK,cAAc,CAACD,MAAMX,EAAE,KAAKW,CAAC;AAClC;AAUuFW,EAAI;"}
|
|
1
|
+
{"version":3,"file":"annotorious-react.es8.js","sources":["../../annotorious-core/src/presence/AppearanceProvider.ts"],"sourcesContent":["import type { User } from '../model';\nimport type { Appearance } from './Appearance';\nimport type { PresentUser } from './PresentUser';\nimport { DEFAULT_PALETTE } from './ColorPalette';\n\nexport interface AppearanceProvider {\n\n addUser(presenceKey: string, user: User): Appearance;\n\n removeUser(user: PresentUser): void;\n\n}\n\nexport const defaultColorProvider = () => {\n\n const unassignedColors = [...DEFAULT_PALETTE];\n\n const assignRandomColor = () => {\n const rnd = Math.floor(Math.random() * unassignedColors.length);\n const color = unassignedColors[rnd];\n\n unassignedColors.splice(rnd, 1);\n\n return color;\n }\n\n const releaseColor = (color: string) =>\n unassignedColors.push(color);\n\n return { assignRandomColor, releaseColor };\n\n}\n\nexport const createDefaultAppearenceProvider = () => {\n\n const colorProvider = defaultColorProvider();\n\n const addUser = (presenceKey: string, user: User): Appearance => {\n const color = colorProvider.assignRandomColor();\n\n return {\n label: user.name || user.id,\n avatar: user.avatar,\n color\n };\n }\n\n const removeUser = (user: PresentUser) =>\n colorProvider.releaseColor(user.appearance.color);\n\n return { addUser, removeUser }\n \n}"],"names":["defaultColorProvider","unassignedColors","DEFAULT_PALETTE","rnd","color"],"mappings":";AAaO,MAAMA,IAAuB,MAAM;AAElC,QAAAC,IAAmB,CAAC,GAAGC,CAAe;AAcrC,SAAA,EAAE,mBAZiB,MAAM;AAC9B,UAAMC,IAAM,KAAK,MAAM,KAAK,WAAWF,EAAiB,MAAM,GACxDG,IAAQH,EAAiBE,CAAG;AAEjB,WAAAF,EAAA,OAAOE,GAAK,CAAC,GAEvBC;AAAA,EAAA,GAMmB,cAHP,CAACA,MACpBH,EAAiB,KAAKG,CAAK;AAI/B;"}
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { createOSDAnnotator as g } from "./annotorious-react.es15.js";
|
|
4
|
-
import { AnnotoriousContext as m } from "./annotorious-react.es2.js";
|
|
5
|
-
const s = w({ viewer: null, setViewer: null }), S = (e) => {
|
|
6
|
-
const { children: x, tool: r, ...d } = e, [o, f] = u(), { anno: t, setAnno: l } = a(m);
|
|
7
|
-
return i(() => {
|
|
8
|
-
if (o) {
|
|
9
|
-
const n = g(o, d);
|
|
10
|
-
return e.drawingEnabled !== void 0 && n.setDrawingEnabled(e.drawingEnabled), e.filter && n.setFilter(e.filter), e.style && n.setStyle(e.style), e.tool && n.setDrawingTool(e.tool), l(n), () => {
|
|
11
|
-
n.destroy(), l(void 0);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}, [o]), i(() => {
|
|
15
|
-
t && t.setDrawingEnabled(e.drawingEnabled);
|
|
16
|
-
}, [e.drawingEnabled]), i(() => {
|
|
17
|
-
t && t.setFilter(e.filter);
|
|
18
|
-
}, [e.filter]), i(() => {
|
|
19
|
-
t && t.setStyle(e.style);
|
|
20
|
-
}, [e.style]), i(() => {
|
|
21
|
-
t && t.setDrawingTool(r);
|
|
22
|
-
}, [r]), /* @__PURE__ */ c.jsx(s.Provider, { value: { viewer: o, setViewer: f }, children: e.children });
|
|
23
|
-
}, A = () => {
|
|
24
|
-
const { viewer: e } = a(s);
|
|
25
|
-
return e;
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
S as OpenSeadragonAnnotator,
|
|
29
|
-
s as OpenSeadragonAnnotatorContext,
|
|
30
|
-
A as useViewer
|
|
31
|
-
};
|
|
1
|
+
import { nanoid as o } from "./annotorious-react.es29.js";
|
|
2
|
+
o();
|
|
32
3
|
//# sourceMappingURL=annotorious-react.es9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es9.js","sources":["
|
|
1
|
+
{"version":3,"file":"annotorious-react.es9.js","sources":["../../annotorious-core/src/presence/PresenceState.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport { createNanoEvents, type Unsubscribe } from 'nanoevents';\nimport type { User } from '../model';\nimport type { PresentUser } from './PresentUser';\nimport type { PresenceEvents } from './PresenceEvents';\nimport { createDefaultAppearenceProvider } from './AppearanceProvider';\nimport type { AppearanceProvider } from './AppearanceProvider';\n\nexport interface PresenceState {\n\n // Get users currently present to this room\n getPresentUsers(): PresentUser[];\n\n // Notify of a given present user's activity on the given annotations\n notifyActivity(presenceKey: string, annotationIds: string[]): void;\n\n // Add a listener for the given presence event\n on<E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]): Unsubscribe;\n\n // Initial sync - which users are present under which keys\n syncUsers(state: { presenceKey: string, user: User }[]): void;\n\n // Update the selection state for the given prresent user\n updateSelection(presenceKey: string, selection: string[] | null): void;\n\n}\n\nconst isListEqual = (listA: any[], listB: any[]) => \n listA.every(a => listA.includes(a)) && listB.every(b => listA.includes(b));\n\n// This client's presence key\nexport const PRESENCE_KEY = nanoid();\n\nexport const createPresenceState = (\n appearanceProvider: AppearanceProvider = createDefaultAppearenceProvider()\n): PresenceState => {\n\n const emitter = createNanoEvents<PresenceEvents>();\n\n const presentUsers = new Map<string, PresentUser>();\n\n const selectionStates = new Map<string, string[]>();\n\n const addUser = (presenceKey: string, user: User) => {\n if (presentUsers.has(presenceKey)) {\n console.warn('Attempt to add user that is already present', presenceKey, user);\n return; \n }\n\n const appearance = appearanceProvider.addUser(presenceKey, user);\n\n presentUsers.set(presenceKey, { \n ...user,\n presenceKey,\n appearance\n });\n }\n\n const removeUser = (presenceKey: string) => {\n const user = presentUsers.get(presenceKey);\n if (!user) {\n console.warn('Attempt to remove user that is not present', presenceKey);\n return;\n }\n\n appearanceProvider.removeUser(user);\n\n presentUsers.delete(presenceKey);\n }\n\n const syncUsers = (state: { presenceKey: string, user: User }[]) => {\n // const keys = new Set(others.map(s => s.presenceKey));\n const keys = new Set(state.map(s => s.presenceKey));\n\n // These users need to be added to the presentUsers list\n // const toAdd = others.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n const toAdd = state.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n\n // These users need to be dropped from the list\n const toRemove = Array.from(presentUsers.values()).filter(presentUser =>\n !keys.has(presentUser.presenceKey));\n\n toAdd.forEach(({ presenceKey, user }) => addUser(presenceKey, user));\n\n toRemove.forEach(user => {\n const { presenceKey } = user;\n\n // If this user has a selection, fire deselect event\n if (selectionStates.has(presenceKey))\n emitter.emit('selectionChange', user, null);\n\n removeUser(presenceKey)\n });\n\n if (toAdd.length > 0 || toRemove.length > 0)\n emitter.emit('presence', getPresentUsers());\n }\n\n const notifyActivity = (presenceKey: string, annotationIds: string[]) => { \n const user = presentUsers.get(presenceKey);\n \n if (!user) {\n console.warn('Activity notification from user that is not present');\n return;\n }\n\n const currentSelection = selectionStates.get(presenceKey);\n\n // Was there a selection change we might have missed?\n if (!currentSelection || !isListEqual(currentSelection, annotationIds)) {\n selectionStates.set(presenceKey, annotationIds);\n emitter.emit('selectionChange', user, annotationIds);\n }\n }\n\n const updateSelection = (presenceKey: string, selection: string[] | null) => {\n const from = presentUsers.get(presenceKey);\n if (!from) {\n console.warn('Selection change for user that is not present', presenceKey);\n return;\n }\n\n if (selection)\n selectionStates.set(presenceKey, selection);\n else \n selectionStates.delete(presenceKey);\n\n emitter.emit('selectionChange', from, selection);\n }\n\n const getPresentUsers = () =>\n [...Array.from(presentUsers.values())];\n \n const on = <E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]) =>\n emitter.on(event, callback);\n\n return {\n getPresentUsers,\n notifyActivity,\n on,\n syncUsers,\n updateSelection\n }\n\n}"],"names":["nanoid"],"mappings":";AA+B4BA,EAAO;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,18 +3,21 @@ export * from './AnnotoriousPlugin';
|
|
|
3
3
|
export * from './AnnotoriousPopup';
|
|
4
4
|
export * from './ImageAnnotator';
|
|
5
5
|
export * from './openseadragon';
|
|
6
|
-
export type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export { _createBody as createBody };
|
|
6
|
+
export type { LifecycleEvents } from '@annotorious/core/src/lifecycle';
|
|
7
|
+
export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, DrawingStyle, FormatAdapter, ParseResult, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget, W3CSelector } from '@annotorious/core/src/model';
|
|
8
|
+
import { defaultColorProvider as _defaultColorProvider } from '@annotorious/core/src/presence';
|
|
10
9
|
export { _defaultColorProvider as defaultColorProvider };
|
|
10
|
+
export type { Appearance, AppearanceProvider, PresenceEvents, PresenceProvider, PresenceState, PresentUser } from '@annotorious/core/src/presence';
|
|
11
|
+
export type { HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver } from '@annotorious/core/src/state';
|
|
12
|
+
import { Origin as _Origin, PointerSelectAction as _PointerSelectAction } from '@annotorious/core/src/state';
|
|
11
13
|
export { _Origin as Origin };
|
|
12
14
|
export { _PointerSelectAction as PointerSelectAction };
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
export declare const ShapeType: typeof _ShapeType;
|
|
17
|
-
export declare const W3CImageFormat: (source: string, invertY?: boolean) => import("@annotorious/annotorious").W3CImageFormatAdapter;
|
|
15
|
+
import { createBody as _createBody } from '@annotorious/core/src/utils';
|
|
16
|
+
export { _createBody as createBody };
|
|
17
|
+
export type { ImageAnnotator as AnnotoriousImageAnnotator, ImageAnnotation } from '@annotorious/annotorious';
|
|
18
18
|
export type { OpenSeadragonAnnotator as AnnotoriousOpenSeadragonAnnotator } from '@annotorious/openseadragon';
|
|
19
|
+
import { ShapeType as _ShapeType, W3CImageFormat as _W3CImageFormat } from '@annotorious/annotorious';
|
|
20
|
+
export { _ShapeType as ShapeType };
|
|
21
|
+
export { _W3CImageFormat as W3CImageFormat };
|
|
19
22
|
export type { Viewer } from 'openseadragon';
|
|
20
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,iBAAiB,CAAC;AAGhC,OAAO,0CAA0C,CAAC;AAClD,OAAO,0DAA0D,CAAC;
|
|
1
|
+
{"version":3,"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