react-iiif-vault 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/bundle.d.ts +1058 -0
  2. package/dist/bundle.global.js +227 -0
  3. package/dist/canvas-panel.cjs +46 -0
  4. package/dist/canvas-panel.d.cts +11 -0
  5. package/dist/canvas-panel.d.ts +11 -0
  6. package/dist/canvas-panel.js +1 -0
  7. package/dist/chunk-HEVA2EDS.js +47 -0
  8. package/dist/chunk-YSH2CIKG.js +1 -0
  9. package/dist/index-BZirmhnp.d.cts +188 -0
  10. package/dist/index-Cxs6aAuK.d.ts +188 -0
  11. package/dist/index.cjs +47 -0
  12. package/dist/index.d.cts +721 -0
  13. package/dist/index.d.ts +721 -0
  14. package/dist/index.js +1 -0
  15. package/dist/useRenderingStrategy-Xj9yQm4y.d.cts +145 -0
  16. package/dist/useRenderingStrategy-Xj9yQm4y.d.ts +145 -0
  17. package/dist/utils.cjs +1 -0
  18. package/dist/utils.d.cts +32 -0
  19. package/dist/utils.d.ts +32 -0
  20. package/dist/utils.js +1 -0
  21. package/package.json +67 -70
  22. package/.build/types/canvas-panel/Viewer.d.ts +0 -14
  23. package/.build/types/canvas-panel/context/overlays.d.ts +0 -3
  24. package/.build/types/canvas-panel/context/world-size.d.ts +0 -2
  25. package/.build/types/canvas-panel/index.d.ts +0 -46
  26. package/.build/types/canvas-panel/render/Annotation.d.ts +0 -8
  27. package/.build/types/canvas-panel/render/AnnotationPage.d.ts +0 -7
  28. package/.build/types/canvas-panel/render/Audio.d.ts +0 -11
  29. package/.build/types/canvas-panel/render/Canvas.d.ts +0 -34
  30. package/.build/types/canvas-panel/render/CanvasBackground.d.ts +0 -4
  31. package/.build/types/canvas-panel/render/DefaultCanvasFallback.d.ts +0 -6
  32. package/.build/types/canvas-panel/render/Image.d.ts +0 -16
  33. package/.build/types/canvas-panel/render/Model.d.ts +0 -7
  34. package/.build/types/canvas-panel/render/Video.d.ts +0 -12
  35. package/.build/types/canvas-panel/render/VideoYouTube.d.ts +0 -12
  36. package/.build/types/components/CanvasAnnotations.d.ts +0 -10
  37. package/.build/types/components/CombinedMetadata.d.ts +0 -4
  38. package/.build/types/components/Image.d.ts +0 -15
  39. package/.build/types/components/ManifestMetadata.d.ts +0 -4
  40. package/.build/types/components/Metadata.d.ts +0 -39
  41. package/.build/types/components/SequenceThumbnails.d.ts +0 -29
  42. package/.build/types/components/SingleCanvasThumbnail.d.ts +0 -20
  43. package/.build/types/context/AnnotationContext.d.ts +0 -5
  44. package/.build/types/context/AnnotationPageContext.d.ts +0 -5
  45. package/.build/types/context/CanvasContext.d.ts +0 -5
  46. package/.build/types/context/CollectionContext.d.ts +0 -5
  47. package/.build/types/context/ContextBridge.d.ts +0 -14
  48. package/.build/types/context/ImageServiceLoaderContext.d.ts +0 -4
  49. package/.build/types/context/ManifestContext.d.ts +0 -5
  50. package/.build/types/context/MediaContext.d.ts +0 -17
  51. package/.build/types/context/RangeContext.d.ts +0 -5
  52. package/.build/types/context/ResourceContext.d.ts +0 -15
  53. package/.build/types/context/VaultContext.d.ts +0 -14
  54. package/.build/types/context/ViewerPresetContext.d.ts +0 -3
  55. package/.build/types/context/VisibleCanvasContext.d.ts +0 -4
  56. package/.build/types/demo/demo.d.ts +0 -1
  57. package/.build/types/demo/media-controls.d.ts +0 -1
  58. package/.build/types/demo/viewer-controls.d.ts +0 -1
  59. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +0 -12
  60. package/.build/types/features/rendering-strategy/audio-strategy.d.ts +0 -3
  61. package/.build/types/features/rendering-strategy/get-rendering-strategy.d.ts +0 -11
  62. package/.build/types/features/rendering-strategy/image-strategy.d.ts +0 -12
  63. package/.build/types/features/rendering-strategy/rendering-utils.d.ts +0 -12
  64. package/.build/types/features/rendering-strategy/resource-types.d.ts +0 -55
  65. package/.build/types/features/rendering-strategy/strategies.d.ts +0 -31
  66. package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +0 -16
  67. package/.build/types/features/rendering-strategy/video-strategy.d.ts +0 -3
  68. package/.build/types/future-helpers/ranges.d.ts +0 -7
  69. package/.build/types/future-helpers/sequences.d.ts +0 -8
  70. package/.build/types/hooks/useAnnotation.d.ts +0 -8
  71. package/.build/types/hooks/useAnnotationPage.d.ts +0 -8
  72. package/.build/types/hooks/useAnnotationPageManager.d.ts +0 -10
  73. package/.build/types/hooks/useAnnotationsAtTime.d.ts +0 -4
  74. package/.build/types/hooks/useCanvas.d.ts +0 -8
  75. package/.build/types/hooks/useCanvasClock.d.ts +0 -1
  76. package/.build/types/hooks/useCanvasSelector.d.ts +0 -0
  77. package/.build/types/hooks/useCanvasSubset.d.ts +0 -2
  78. package/.build/types/hooks/useCanvasTimeline.d.ts +0 -0
  79. package/.build/types/hooks/useCollection.d.ts +0 -8
  80. package/.build/types/hooks/useDispatch.d.ts +0 -2
  81. package/.build/types/hooks/useEnabledAnnotationPageIds.d.ts +0 -1
  82. package/.build/types/hooks/useEventListener.d.ts +0 -4
  83. package/.build/types/hooks/useExistingVault.d.ts +0 -2
  84. package/.build/types/hooks/useExternalCollection.d.ts +0 -13
  85. package/.build/types/hooks/useExternalManifest.d.ts +0 -13
  86. package/.build/types/hooks/useExternalResource.d.ts +0 -16
  87. package/.build/types/hooks/useImage.d.ts +0 -10
  88. package/.build/types/hooks/useImageService.d.ts +0 -9
  89. package/.build/types/hooks/useImageTile.d.ts +0 -11
  90. package/.build/types/hooks/useLoadImageService.d.ts +0 -6
  91. package/.build/types/hooks/useManifest.d.ts +0 -8
  92. package/.build/types/hooks/usePaintables.d.ts +0 -9
  93. package/.build/types/hooks/usePaintingAnnotations.d.ts +0 -5
  94. package/.build/types/hooks/useRange.d.ts +0 -8
  95. package/.build/types/hooks/useRenderingStrategy.d.ts +0 -15
  96. package/.build/types/hooks/useResourceEvents.d.ts +0 -3
  97. package/.build/types/hooks/useResources.d.ts +0 -1
  98. package/.build/types/hooks/useSearchService.d.ts +0 -2
  99. package/.build/types/hooks/useSimpleMediaPlayer.d.ts +0 -32
  100. package/.build/types/hooks/useStyleHelper.d.ts +0 -1
  101. package/.build/types/hooks/useStyles.d.ts +0 -3
  102. package/.build/types/hooks/useThumbnail.d.ts +0 -5
  103. package/.build/types/hooks/useVault.d.ts +0 -2
  104. package/.build/types/hooks/useVaultEffect.d.ts +0 -2
  105. package/.build/types/hooks/useVaultSelector.d.ts +0 -2
  106. package/.build/types/hooks/useVirtualAnnotationPage.d.ts +0 -14
  107. package/.build/types/hooks/useVirtualAnnotationPageContext.d.ts +0 -671
  108. package/.build/types/hooks/useVirtualCanvas.d.ts +0 -0
  109. package/.build/types/index.d.ts +0 -72
  110. package/.build/types/utility/flatten-annotation-page-ids.d.ts +0 -7
  111. package/.build/types/utility/i18n-utils.d.ts +0 -30
  112. package/.build/types/utils.d.ts +0 -2
  113. package/.build/types/viewers/SimpleViewerContext.d.ts +0 -6
  114. package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +0 -19
  115. package/.build/types/viewers/SimpleViewerContext.types.d.ts +0 -46
  116. package/.build/types/viewers/SingleCanvasContext.d.ts +0 -1
  117. package/dist/bundle/cjs/index.js +0 -49
  118. package/dist/bundle/cjs/index.js.map +0 -1
  119. package/dist/bundle/esm/index.mjs +0 -3314
  120. package/dist/bundle/esm/index.mjs.map +0 -1
  121. package/dist/canvas-panel/cjs/canvas-panel.js +0 -47
  122. package/dist/canvas-panel/cjs/canvas-panel.js.map +0 -1
  123. package/dist/canvas-panel/esm/canvas-panel.mjs +0 -1853
  124. package/dist/canvas-panel/esm/canvas-panel.mjs.map +0 -1
  125. package/dist/index.umd.js +0 -393
  126. package/dist/index.umd.js.map +0 -1
  127. package/dist/react17/cjs/index.js +0 -49
  128. package/dist/react17/cjs/index.js.map +0 -1
  129. package/dist/react17/esm/index.mjs +0 -3314
  130. package/dist/react17/esm/index.mjs.map +0 -1
  131. package/dist/utils/cjs/utils.js +0 -2
  132. package/dist/utils/cjs/utils.js.map +0 -1
  133. package/dist/utils/esm/utils.mjs +0 -238
  134. package/dist/utils/esm/utils.mjs.map +0 -1
@@ -1,1853 +0,0 @@
1
- import { jsx as u, jsxs as I, Fragment as $ } from "react/jsx-runtime";
2
- import B, { createContext as F, Component as rt, createElement as Pe, isValidElement as it, useContext as T, useMemo as y, useState as L, useEffect as N, useCallback as P, useRef as q, useLayoutEffect as Ie, Fragment as te, useReducer as ot, forwardRef as Me, useImperativeHandle as at } from "react";
3
- import { AtlasAuto as st, ModeContext as ut, mergeStyles as ct, RegionHighlight as lt, TileSet as dt, HTMLPortal as ft } from "@atlas-viewer/atlas";
4
- import { globalVault as Ae, Vault as be } from "@iiif/helpers/vault";
5
- import { createStylesHelper as Te } from "@iiif/helpers/styles";
6
- import { expandTarget as le } from "@iiif/helpers/annotation-targets";
7
- import { expandTarget as ht } from "@iiif/helpers";
8
- import { ImageServiceLoader as gt, getImageServices as mt } from "@atlas-viewer/iiif-image-api";
9
- import { createThumbnailHelper as vt } from "@iiif/helpers/thumbnail";
10
- const pt = F(null), se = {
11
- didCatch: !1,
12
- error: null
13
- };
14
- class yt extends rt {
15
- constructor(t) {
16
- super(t), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = se;
17
- }
18
- static getDerivedStateFromError(t) {
19
- return {
20
- didCatch: !0,
21
- error: t
22
- };
23
- }
24
- resetErrorBoundary() {
25
- const {
26
- error: t
27
- } = this.state;
28
- if (t !== null) {
29
- for (var n, r, i = arguments.length, o = new Array(i), a = 0; a < i; a++)
30
- o[a] = arguments[a];
31
- (n = (r = this.props).onReset) === null || n === void 0 || n.call(r, {
32
- args: o,
33
- reason: "imperative-api"
34
- }), this.setState(se);
35
- }
36
- }
37
- componentDidCatch(t, n) {
38
- var r, i;
39
- (r = (i = this.props).onError) === null || r === void 0 || r.call(i, t, n);
40
- }
41
- componentDidUpdate(t, n) {
42
- const {
43
- didCatch: r
44
- } = this.state, {
45
- resetKeys: i
46
- } = this.props;
47
- if (r && n.error !== null && xt(t.resetKeys, i)) {
48
- var o, a;
49
- (o = (a = this.props).onReset) === null || o === void 0 || o.call(a, {
50
- next: i,
51
- prev: t.resetKeys,
52
- reason: "keys"
53
- }), this.setState(se);
54
- }
55
- }
56
- render() {
57
- const {
58
- children: t,
59
- fallbackRender: n,
60
- FallbackComponent: r,
61
- fallback: i
62
- } = this.props, {
63
- didCatch: o,
64
- error: a
65
- } = this.state;
66
- let s = t;
67
- if (o) {
68
- const c = {
69
- error: a,
70
- resetErrorBoundary: this.resetErrorBoundary
71
- };
72
- if (typeof n == "function")
73
- s = n(c);
74
- else if (r)
75
- s = Pe(r, c);
76
- else if (i === null || it(i))
77
- s = i;
78
- else
79
- throw a;
80
- }
81
- return Pe(pt.Provider, {
82
- value: {
83
- didCatch: o,
84
- error: a,
85
- resetErrorBoundary: this.resetErrorBoundary
86
- }
87
- }, s);
88
- }
89
- }
90
- function xt() {
91
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
92
- return e.length !== t.length || e.some((n, r) => !Object.is(n, t[r]));
93
- }
94
- const wt = {
95
- collection: void 0,
96
- manifest: void 0,
97
- range: void 0,
98
- canvas: void 0,
99
- annotation: void 0,
100
- annotationPage: void 0
101
- }, fe = B.createContext(wt), z = () => T(fe);
102
- function re({ value: e, children: t }) {
103
- const n = z(), r = y(() => ({
104
- ...n,
105
- ...e
106
- }), [e, n]);
107
- return /* @__PURE__ */ u(fe.Provider, { value: r, children: t });
108
- }
109
- const ie = B.createContext({
110
- vault: null,
111
- setVaultInstance: (e) => {
112
- }
113
- });
114
- function he({
115
- vault: e,
116
- vaultOptions: t,
117
- useGlobal: n,
118
- resources: r,
119
- children: i
120
- }) {
121
- const [o, a] = L(() => e || (n ? Ae(t) : t ? new be(t) : new be()));
122
- return /* @__PURE__ */ u(ie.Provider, { value: { vault: o, setVaultInstance: a }, children: /* @__PURE__ */ u(re, { value: r || {}, children: i }) });
123
- }
124
- function ge(e) {
125
- const t = T(ie);
126
- return e || (t && t.vault ? t.vault : Ae());
127
- }
128
- function St(e, { noCache: t = !1 } = {}) {
129
- const n = typeof e == "string" ? e : e.id, r = ge(), [i, o] = L(n), [a, s] = L(void 0), c = y(() => r.get(n, { skipSelfReturn: !0 }) || void 0, [n, r]), [d, l] = L(c);
130
- return N(() => {
131
- (async () => {
132
- try {
133
- const f = c && !t ? c : await r.load(n), v = f ? f.id || f["@id"] : null;
134
- f && i !== v && o(v), l(f);
135
- } catch (f) {
136
- s(f);
137
- }
138
- })();
139
- }, [n, t]), {
140
- isLoaded: !!d,
141
- id: i,
142
- requestId: n,
143
- error: a,
144
- resource: d,
145
- cached: !!(d && d === c)
146
- };
147
- }
148
- function Pt(e, t) {
149
- const { id: n, isLoaded: r, error: i, resource: o, requestId: a, cached: s } = St(
150
- e,
151
- t
152
- );
153
- return { id: n, isLoaded: r, error: i, manifest: o, requestId: a, cached: s };
154
- }
155
- function bt({ manifest: e, children: t }) {
156
- return /* @__PURE__ */ u(re, { value: { manifest: e }, children: t });
157
- }
158
- function me({ canvas: e, children: t }) {
159
- return /* @__PURE__ */ u(re, { value: { canvas: e }, children: t });
160
- }
161
- const O = () => {
162
- const { vault: e } = T(ie);
163
- if (e === null)
164
- throw new Error("Vault not found. Ensure you have your provider set up correctly.");
165
- return e;
166
- };
167
- function R(e, t = []) {
168
- const n = O(), [r, i] = L(() => e(n.getState(), n));
169
- return N(() => n.subscribe(
170
- (o) => e(o, n),
171
- (o) => {
172
- i(o);
173
- },
174
- !1
175
- ), t), r;
176
- }
177
- const oe = B.createContext([]);
178
- function Re() {
179
- const e = T(oe);
180
- return R(
181
- (t) => e.map((n) => t.iiif.entities.Canvas[n]).filter(Boolean),
182
- [e]
183
- );
184
- }
185
- function K(e = {}, t = []) {
186
- const { id: n, selector: r } = e, i = z();
187
- O();
188
- const o = n || i.manifest, a = R(
189
- (s) => o ? s.iiif.entities.Manifest[o] : void 0,
190
- [o]
191
- );
192
- return y(() => {
193
- if (a)
194
- return r ? r(a) : a;
195
- }, [a, r, ...t]);
196
- }
197
- function Ct({ range: e, children: t }) {
198
- return /* @__PURE__ */ u(re, { value: { range: e }, children: t });
199
- }
200
- function Ve(e, t) {
201
- var r;
202
- const n = [];
203
- for (const i of t.items)
204
- if (i.type === "SpecificResource" && ((r = i.source) == null ? void 0 : r.type) === "Canvas" && (i.source.id.indexOf("#") !== -1 ? n.push({ id: i.source.id.split("#")[0], type: "Canvas" }) : n.push(i.source)), i.type === "Range" && n.push(...Ve(e, e.get(i))), i.type === "SpecificResource") {
205
- const o = typeof i.source == "string" ? i.source : i.source.id;
206
- n.push({ id: o, type: "Canvas" });
207
- }
208
- return n;
209
- }
210
- function Et(e, t, { disablePaging: n, skipNonPaged: r } = {}) {
211
- const i = t.behavior, o = i.includes("paged"), a = o ? !1 : i.includes("continuous"), s = o || a ? !1 : i.includes("individuals"), c = t.type === "Manifest" ? t.items : Ve(e, t);
212
- if (a)
213
- return [c, [c.map((m, g) => g)]];
214
- if (s || !o || n)
215
- return [c, c.map((m, g) => [g])];
216
- const d = [];
217
- let l = [];
218
- const f = () => {
219
- l.length && (d.push([...l]), l = []);
220
- };
221
- let v = 0, p = !1;
222
- for (let m = 0; m < c.length; m++) {
223
- const g = e.get(c[m]);
224
- if (g.behavior.includes("non-paged")) {
225
- m === v && v++, r || (f(), d.push([m]), f());
226
- continue;
227
- }
228
- if (m === v || g.behavior.includes("facing-pages")) {
229
- l.length && (p = !0), f(), d.push([m]), f();
230
- continue;
231
- }
232
- if (l.push(m), p) {
233
- f(), p = !1;
234
- continue;
235
- }
236
- l.length > 1 && f();
237
- }
238
- return l.length && f(), [c, d];
239
- }
240
- function It(e = {}, t = []) {
241
- const { id: n, selector: r } = e, i = z(), o = n || i.range, a = R((s) => o ? s.iiif.entities.Range[o] : void 0, [o]);
242
- return y(() => {
243
- if (a)
244
- return r ? r(a) : a;
245
- }, [a, r, ...t]);
246
- }
247
- function Mt({ startCanvas: e, disablePaging: t }) {
248
- var m;
249
- const n = O(), r = K(), i = It(), [o, a] = L(void 0), s = i || r;
250
- if (!s)
251
- throw new Error("Nothing selected");
252
- const [c, d] = y(
253
- () => Et(n, s, { disablePaging: t }),
254
- [n, s, t]
255
- ), l = P(
256
- (g) => {
257
- const w = d.findIndex((x) => x.includes(g));
258
- a(w === -1 ? 0 : w);
259
- },
260
- [c, d]
261
- ), f = P(
262
- (g) => {
263
- const w = c.findIndex((x) => x.id === g);
264
- w !== -1 ? l(w) : a(0);
265
- },
266
- [c, d]
267
- ), v = P(() => {
268
- a((g) => g >= d.length - 1 ? g : g + 1);
269
- }, [d]), p = P(() => {
270
- a((g) => g <= 0 ? 0 : g - 1);
271
- }, [d]);
272
- return typeof o > "u" && (e ? f(e) : a(0)), {
273
- visibleItems: ((m = d[o]) == null ? void 0 : m.map((g) => c[g].id)) || [],
274
- cursor: o,
275
- items: c,
276
- sequence: d,
277
- hasPrevious: o > 0,
278
- hasNext: o < d.length - 1,
279
- setSequenceIndex: a,
280
- setCanvasIndex: l,
281
- setCanvasId: f,
282
- next: v,
283
- previous: p
284
- };
285
- }
286
- const J = () => {
287
- }, ae = F({
288
- setCurrentCanvasId: J,
289
- setCurrentCanvasIndex: J,
290
- nextCanvas: J,
291
- previousCanvas: J,
292
- items: [],
293
- sequence: [],
294
- setSequenceIndex: J,
295
- currentSequenceIndex: 0,
296
- hasNext: !1,
297
- hasPrevious: !1
298
- });
299
- function At(e) {
300
- const t = K(), {
301
- cursor: n,
302
- visibleItems: r,
303
- next: i,
304
- sequence: o,
305
- items: a,
306
- setCanvasIndex: s,
307
- setCanvasId: c,
308
- previous: d,
309
- setSequenceIndex: l,
310
- hasNext: f,
311
- hasPrevious: v
312
- } = Mt({
313
- startCanvas: e.startCanvas,
314
- disablePaging: e.pagingEnabled === !1
315
- }), p = y(
316
- () => ({
317
- sequence: o,
318
- items: a,
319
- // Extra functions.
320
- setCurrentCanvasId: c,
321
- nextCanvas: i,
322
- previousCanvas: d,
323
- totalCanvases: a.length,
324
- setCurrentCanvasIndex: s,
325
- setSequenceIndex: l,
326
- currentSequenceIndex: n,
327
- hasNext: f,
328
- hasPrevious: v
329
- }),
330
- [o, a, c, i, d, a, s, l, n]
331
- );
332
- return t ? r.length === 0 ? null : /* @__PURE__ */ u(ae.Provider, { value: p, children: /* @__PURE__ */ u(oe.Provider, { value: r, children: /* @__PURE__ */ u(me, { canvas: r[0], children: e.children }) }) }) : (console.warn("The manifest passed to the provider is not a valid IIIF manifest."), /* @__PURE__ */ u("div", { children: "Sorry, something went wrong." }));
333
- }
334
- function Tt(e) {
335
- const t = ge(e.vault), n = Pt(e.manifest);
336
- if (!n)
337
- return console.warn("The manifest passed to the provider is not a valid IIIF manifest."), /* @__PURE__ */ u("div", { children: "Sorry, something went wrong." });
338
- if (n.error)
339
- return /* @__PURE__ */ u("div", { children: n.error.toString() });
340
- if (!n.isLoaded)
341
- return /* @__PURE__ */ u("div", { children: "Loading..." });
342
- const r = /* @__PURE__ */ u(At, { ...e, children: e.children });
343
- return /* @__PURE__ */ u(he, { vault: t, children: /* @__PURE__ */ u(bt, { manifest: n.id, children: e.rangeId ? /* @__PURE__ */ u(Ct, { range: e.rangeId, children: r }) : r }) });
344
- }
345
- function Rt() {
346
- return T(ae);
347
- }
348
- function Vt() {
349
- return {
350
- VaultContext: T(ie),
351
- ResourceContext: T(fe),
352
- SimpleViewerReactContext: T(ae),
353
- VisibleCanvasReactContext: T(oe)
354
- };
355
- }
356
- function Ot(e) {
357
- return /* @__PURE__ */ u(he, { vault: e.bridge.VaultContext.vault || void 0, resources: e.bridge.ResourceContext, children: /* @__PURE__ */ u(oe.Provider, { value: e.bridge.VisibleCanvasReactContext, children: /* @__PURE__ */ u(ae.Provider, { value: e.bridge.SimpleViewerReactContext, children: e.children }) }) });
358
- }
359
- const U = function(e) {
360
- return function() {
361
- const t = { type: e, getType: () => e, toString: () => e };
362
- return (n, r) => ({
363
- ...t,
364
- ...n !== void 0 && { payload: n },
365
- ...r !== void 0 && { meta: r }
366
- });
367
- };
368
- }, Lt = "@iiif/IMPORT_ENTITIES", kt = "@iiif/MODIFY_ENTITY_FIELD", Nt = "@iiif/REORDER_ENTITY_FIELD", Ft = "@iiif/ADD_REFERENCE", Ut = "@iiif/UPDATE_REFERENCE", Dt = "@iiif/REMOVE_REFERENCE", _t = "@iiif/ADD_METADATA", qt = "@iiif/REMOVE_METADATA", Bt = "@iiif/UPDATE_METADATA", jt = "@iiif/REORDER_METADATA", Ht = U(Lt)(), $t = U(kt)(), Yt = U(Nt)(), zt = U(Ft)(), Kt = U(Dt)(), Wt = U(Ut)(), Gt = U(_t)(), Qt = U(Bt)(), Jt = U(qt)(), Zt = U(jt)(), ue = {
369
- importEntities: Ht,
370
- modifyEntityField: $t,
371
- reorderEntityField: Yt,
372
- addReference: zt,
373
- removeReference: Kt,
374
- updateReference: Wt,
375
- addMetadata: Gt,
376
- removeMetadata: Jt,
377
- updateMetadata: Qt,
378
- reorderMetadata: Zt
379
- };
380
- function Xt() {
381
- const t = O().getStore();
382
- return y(() => (n) => t.dispatch(n), [t]);
383
- }
384
- function Ce(e) {
385
- return typeof e != "string" && e && e.bindToVault;
386
- }
387
- function en() {
388
- const e = O(), t = q([]), n = Xt(), r = y(() => `vault://annotation-page/${(/* @__PURE__ */ new Date()).getTime()}/${Math.round(Math.random() * 1e9).toString(16)}`, []);
389
- Ie(() => {
390
- const s = {
391
- id: r,
392
- type: "AnnotationPage",
393
- behavior: [],
394
- label: null,
395
- thumbnail: [],
396
- summary: null,
397
- requiredStatement: null,
398
- metadata: [],
399
- rights: null,
400
- provider: [],
401
- items: [],
402
- seeAlso: [],
403
- homepage: [],
404
- rendering: [],
405
- service: []
406
- };
407
- n(
408
- ue.importEntities({
409
- entities: {
410
- AnnotationPage: {
411
- [s.id]: s
412
- }
413
- }
414
- })
415
- );
416
- }, [r]);
417
- const i = R(
418
- (s) => r ? s.iiif.entities.AnnotationPage[r] : null,
419
- [r]
420
- ), o = P(
421
- (s, c) => {
422
- if (r) {
423
- if (Ce(s)) {
424
- const f = s;
425
- f.__vault || f.bindToVault(e), s = typeof f.source == "string" ? f.source : f.source.id, t.current[s] = f;
426
- } else
427
- typeof s != "string" && (s = s.id);
428
- const d = e.get({ id: r, type: "AnnotationPage" }), l = e.get({ id: s, type: "Annotation" });
429
- d && l && (d.items.find((f) => f.id === l.id) || n(
430
- ue.addReference({
431
- id: r,
432
- type: "AnnotationPage",
433
- key: "items",
434
- reference: {
435
- id: s,
436
- type: "Annotation"
437
- },
438
- index: c
439
- })
440
- ));
441
- }
442
- },
443
- [r]
444
- ), a = P(
445
- (s) => {
446
- r && (Ce(s) ? s = typeof s.source == "string" ? s.source : s.source.id : typeof s != "string" && (s = s.id), t.current[s] && t.current[s].beforeRemove(), e.get({ id: r, type: "AnnotationPage" }) && n(
447
- ue.removeReference({
448
- id: r,
449
- type: "AnnotationPage",
450
- key: "items",
451
- reference: {
452
- id: s,
453
- type: "Annotation"
454
- }
455
- })
456
- ));
457
- },
458
- [r]
459
- );
460
- return [
461
- i,
462
- {
463
- addAnnotation: o,
464
- removeAnnotation: a
465
- }
466
- ];
467
- }
468
- const Oe = F(null);
469
- function tn() {
470
- const e = T(Oe);
471
- return [
472
- e.fullPage,
473
- {
474
- addAnnotation: e.addAnnotation,
475
- removeAnnotation: e.removeAnnotation
476
- }
477
- ];
478
- }
479
- function nn({ children: e }) {
480
- const [t, { addAnnotation: n, removeAnnotation: r }] = en();
481
- return /* @__PURE__ */ u(
482
- Oe.Provider,
483
- {
484
- value: y(() => ({ fullPage: t, addAnnotation: n, removeAnnotation: r }), [t]),
485
- children: e
486
- }
487
- );
488
- }
489
- function rn({
490
- width: e,
491
- style: t,
492
- height: n,
493
- error: r,
494
- resetErrorBoundary: i
495
- }) {
496
- return /* @__PURE__ */ I("div", { style: { width: e, height: n, minHeight: 500, ...t || {}, background: "#f9f9f9" }, children: [
497
- /* @__PURE__ */ u("h3", { children: "Error occurred" }),
498
- /* @__PURE__ */ u("p", { children: r.message }),
499
- /* @__PURE__ */ u("button", { onClick: i, children: "Reset" })
500
- ] });
501
- }
502
- const ve = F(null);
503
- function on() {
504
- return T(ve);
505
- }
506
- const Le = F(
507
- () => {
508
- }
509
- ), ke = F(
510
- () => {
511
- }
512
- );
513
- function Y(e, t, n, r, i = []) {
514
- const o = T(e === "portal" ? ke : Le);
515
- N(() => (e !== "none" && o(t, n, r), () => {
516
- o(t, null);
517
- }), [t, e, o, ...i]);
518
- }
519
- function j(e = {}, t = []) {
520
- const { id: n, selector: r } = e, i = z(), o = n || i.canvas, a = R((s) => o ? s.iiif.entities.Canvas[o] : void 0, [o]);
521
- return y(() => {
522
- if (a)
523
- return r ? r(a) : a;
524
- }, [a, r, ...t]);
525
- }
526
- const Ne = F(() => {
527
- });
528
- function an(e) {
529
- const t = j(), n = T(Ne);
530
- N(() => t && t.id ? (n(t.id, e), () => n(t.id, -1)) : () => {
531
- }, [t, e]);
532
- }
533
- function sn({
534
- children: e,
535
- errorFallback: t,
536
- outerContainerProps: n = {},
537
- worldScale: r,
538
- ...i
539
- }) {
540
- const [o, a] = L(), s = Vt(), c = t || rn, [d, l] = L({}), f = Object.entries(d), [v, p] = L({}), m = Object.entries(v), [g, w] = L({}), x = y(() => r || Math.max(...Object.values(g)), [g]), M = y(() => ({ maxOverZoom: x || 1, ...i.runtimeOptions || {} }), [x, i.runtimeOptions]), b = P((C, A) => {
541
- w((k) => {
542
- if (A === -1) {
543
- const { [C]: h, ...D } = k;
544
- return D;
545
- }
546
- return { ...k, [C]: A };
547
- });
548
- }, []), W = P((C, A, k) => {
549
- l(({ [C]: h, ...D }) => A ? {
550
- ...D,
551
- [C]: { element: A, props: k }
552
- } : D);
553
- }, []), Z = P((C, A, k) => {
554
- p(({ [C]: h, ...D }) => A ? {
555
- ...D,
556
- [C]: { element: A, props: k }
557
- } : D);
558
- }, []);
559
- return /* @__PURE__ */ I(yt, { resetKeys: [], fallbackRender: (C) => /* @__PURE__ */ u(c, { ...i, ...C }), children: [
560
- /* @__PURE__ */ u(
561
- st,
562
- {
563
- ...i,
564
- containerProps: { style: { position: "relative" }, ...i.containerProps || {} },
565
- htmlChildren: /* @__PURE__ */ u($, { children: f.map(([C, { element: A, props: k }]) => /* @__PURE__ */ u(B.Fragment, { children: /* @__PURE__ */ u(A, { ...k || {} }) }, C)) }),
566
- onCreated: (C) => {
567
- a(C), i.onCreated && i.onCreated(C);
568
- },
569
- runtimeOptions: M,
570
- children: /* @__PURE__ */ u(ve.Provider, { value: o, children: /* @__PURE__ */ u(Ne.Provider, { value: b, children: /* @__PURE__ */ u(Le.Provider, { value: W, children: /* @__PURE__ */ u(ke.Provider, { value: Z, children: /* @__PURE__ */ u(Ot, { bridge: s, children: /* @__PURE__ */ u(ut.Provider, { value: i.mode || "explore", children: /* @__PURE__ */ u(nn, { children: e }) }) }) }) }) }) })
571
- }
572
- ),
573
- /* @__PURE__ */ u("div", { children: m.map(([C, { element: A, props: k }]) => /* @__PURE__ */ u(B.Fragment, { children: /* @__PURE__ */ u(A, { ...k || {} }) }, C)) })
574
- ] });
575
- }
576
- const X = {}, Fe = {
577
- get(e) {
578
- return e;
579
- },
580
- setMetaValue([e, t, n], r) {
581
- const i = Fe.getResourceMeta(e, t), o = i ? i[n] : void 0, a = typeof r == "function" ? r(o) : r;
582
- X[e] = {
583
- ...X[e] || {},
584
- [t]: {
585
- ...(X[e] || {})[t] || {},
586
- [n]: a
587
- }
588
- };
589
- },
590
- getResourceMeta: (e, t) => {
591
- const n = X[e];
592
- if (n)
593
- return t ? n[t] : n;
594
- }
595
- };
596
- function un(e = Fe) {
597
- return {
598
- addEventListener(t, n, r, i) {
599
- if (t)
600
- return e.setMetaValue(
601
- [t.id, "eventManager", n],
602
- (o) => {
603
- const a = o || [];
604
- for (const s of a)
605
- if (s.callback === r)
606
- return a;
607
- return [...a, { callback: r, scope: i }];
608
- }
609
- ), r;
610
- },
611
- removeEventListener(t, n, r) {
612
- t && e.setMetaValue(
613
- [t.id, "eventManager", n],
614
- (i) => (i || []).filter((o) => o.callback !== r)
615
- );
616
- },
617
- getListenersAsProps(t, n) {
618
- const r = typeof t == "string" ? { id: t } : t;
619
- if (!r || !r.id)
620
- return {};
621
- const i = e.getResourceMeta(r.id, "eventManager"), o = {};
622
- if (i && r)
623
- for (const a of Object.keys(i))
624
- o[a] = (s) => {
625
- const c = e.get(r);
626
- for (const { callback: d, scope: l } of i[a] || [])
627
- (!l || n && l.indexOf(n) !== -1) && d(s, c);
628
- };
629
- return o;
630
- }
631
- };
632
- }
633
- function Ue(e, t) {
634
- const n = O(), r = y(() => un(n), [n]), i = R(() => e && e.id ? n.getResourceMeta(e.id, "eventManager") : null, [e]);
635
- return y(() => e ? r.getListenersAsProps(e, t) : {}, [i, e, n, t]);
636
- }
637
- function ne(e, t) {
638
- const n = O(), r = y(() => Te(n), [n]);
639
- return R(() => {
640
- if (!e)
641
- return null;
642
- const i = r.getAppliedStyles(e.id);
643
- return i ? t ? i[t] : i : void 0;
644
- }, [e, t]);
645
- }
646
- function De(e = {}, t = []) {
647
- const { id: n, selector: r } = e, i = z(), o = O(), a = n || i.annotation, s = R(
648
- (d) => a ? d.iiif.entities.Annotation[a] : void 0,
649
- [a]
650
- ), c = R(
651
- (d) => s && s.body ? s.body.map((l) => l ? l.type === "SpecificResource" ? {
652
- ...l,
653
- source: o.get(l)
654
- } : l ? d.iiif.entities[l.type][l.id] : null : null).filter(Boolean) : [],
655
- [s]
656
- );
657
- return y(() => {
658
- if (!s)
659
- return;
660
- const d = {
661
- ...s,
662
- body: c,
663
- target: le(s.target, { typeMap: o.getState().iiif.mapping })
664
- };
665
- return r ? r(d) : d;
666
- }, [s, r, c, ...t]);
667
- }
668
- const _e = ({
669
- id: e,
670
- style: t,
671
- className: n,
672
- interactive: r
673
- }) => {
674
- const i = De({ id: e }), o = ne(i, "atlas"), a = ne(i, "html"), s = Ue(i, ["atlas"]), c = j(), d = y(() => ct(t, o), [t, o]);
675
- return c && i && i.target && i.target.selector && i.target.selector.type === "BoxSelector" && i.target.source && (i.target.source.id === c.id || i.target.source === c.id) ? /* @__PURE__ */ u(
676
- lt,
677
- {
678
- id: i.id,
679
- isEditing: !0,
680
- region: i.target.selector.spatial,
681
- style: d,
682
- className: (a == null ? void 0 : a.className) || n,
683
- interactive: !!(a != null && a.href || r),
684
- href: (a == null ? void 0 : a.href) || null,
685
- title: (a == null ? void 0 : a.title) || null,
686
- hrefTarget: (a == null ? void 0 : a.target) || null,
687
- onClick: () => {
688
- },
689
- ...s
690
- }
691
- ) : null;
692
- };
693
- function cn(e = {}, t = []) {
694
- const { id: n, selector: r } = e, i = z(), o = n || i.annotationPage, a = R(
695
- (s) => o ? s.iiif.entities.AnnotationPage[o] : void 0,
696
- [o]
697
- );
698
- return y(() => {
699
- if (a)
700
- return r ? r(a) : a;
701
- }, [a, ...t]);
702
- }
703
- const de = ({
704
- className: e,
705
- page: t
706
- }) => {
707
- var o;
708
- const n = cn({ id: t.id }) || t, r = ne(n, "atlas"), i = ne(n, "html");
709
- return R((a) => n.id ? a.iiif.entities.AnnotationPage[n.id] : null, []), /* @__PURE__ */ u(te, { children: (o = n.items) == null ? void 0 : o.map((a) => /* @__PURE__ */ u(
710
- _e,
711
- {
712
- id: a.id,
713
- style: r,
714
- className: (i == null ? void 0 : i.className) || e
715
- },
716
- a.id
717
- )) });
718
- };
719
- function qe({
720
- id: e,
721
- image: t,
722
- thumbnail: n,
723
- isStatic: r,
724
- x: i = 0,
725
- y: o = 0,
726
- children: a,
727
- selector: s,
728
- onClick: c,
729
- enableSizes: d
730
- }) {
731
- var f, v;
732
- const l = y(() => {
733
- if (!(!s || s.spatial.x === 0 && s.spatial.y === 0))
734
- return s.spatial;
735
- }, [s]);
736
- return /* @__PURE__ */ u(
737
- "world-object",
738
- {
739
- x: i + t.target.spatial.x,
740
- y: o + t.target.spatial.y,
741
- width: t.target.spatial.width,
742
- height: t.target.spatial.height,
743
- onClick: c,
744
- children: t.service ? /* @__PURE__ */ I(te, { children: [
745
- /* @__PURE__ */ u(
746
- dt,
747
- {
748
- tiles: {
749
- id: t.service.id || t.service["@id"] || "unknown",
750
- height: t.height,
751
- width: t.width,
752
- imageService: t.service,
753
- thumbnail: n && n.type === "fixed" ? n : void 0
754
- },
755
- enableSizes: d,
756
- x: 0,
757
- y: 0,
758
- width: (f = t.target) == null ? void 0 : f.spatial.width,
759
- height: (v = t.target) == null ? void 0 : v.spatial.height,
760
- crop: l
761
- }
762
- ),
763
- a
764
- ] }, "service") : /* @__PURE__ */ I(te, { children: [
765
- /* @__PURE__ */ u(
766
- "world-image",
767
- {
768
- onClick: c,
769
- uri: t.id,
770
- target: { x: 0, y: 0, width: t.target.spatial.width, height: t.target.spatial.height },
771
- display: t.width && t.height ? {
772
- width: t.width,
773
- height: t.height
774
- } : void 0,
775
- crop: l
776
- }
777
- ),
778
- a
779
- ] }, "no-service")
780
- },
781
- e + (t.service ? "server" : "no-service")
782
- );
783
- }
784
- function Be(e, t) {
785
- const { selector: n, source: r } = ht(t);
786
- if (r.id !== e.id)
787
- return [null, r];
788
- const i = {
789
- type: "BoxSelector",
790
- spatial: {
791
- x: 0,
792
- y: 0,
793
- width: Number(e.width),
794
- height: Number(e.height)
795
- }
796
- };
797
- return [
798
- n ? n.type === "TemporalSelector" ? {
799
- type: "TemporalBoxSelector",
800
- temporal: n.temporal,
801
- spatial: i.spatial
802
- } : n : null,
803
- r
804
- ];
805
- }
806
- const ln = {
807
- makeChoice: () => {
808
- }
809
- }, ce = { type: "unknown" }, E = (e) => ({ type: "unknown", reason: e, annotations: { pages: [] } }), dn = (e, t) => ({ type: "empty", width: e, height: t, annotations: { pages: [] }, image: null, images: [] });
810
- function fn(e, t) {
811
- var r;
812
- const n = (r = e == null ? void 0 : e.iiif) == null ? void 0 : r.meta[t];
813
- return n ? n.annotationPageManager : null;
814
- }
815
- function hn(e, t) {
816
- return R(
817
- (n) => {
818
- const r = [];
819
- if (!e)
820
- return r;
821
- const i = Object.keys(n.iiif.entities.AnnotationPage);
822
- for (const o of i)
823
- if (!t || t.indexOf(o) !== -1) {
824
- const a = fn(n, o);
825
- a && a.views && a.views[e] && r.push(o);
826
- }
827
- return r;
828
- },
829
- [e, t]
830
- );
831
- }
832
- function gn({
833
- canvas: e,
834
- manifest: t,
835
- all: n,
836
- canvases: r
837
- }) {
838
- const i = [];
839
- if (t)
840
- for (const o of t.annotations)
841
- i.indexOf(o.id) === -1 && i.push(o.id);
842
- if (n) {
843
- if (r && r.length)
844
- for (const o of r)
845
- for (const a of o.annotations)
846
- i.indexOf(a.id) === -1 && i.push(a.id);
847
- } else if (e)
848
- for (const o of e.annotations)
849
- i.indexOf(o.id) === -1 && i.push(o.id);
850
- return i;
851
- }
852
- function mn(e, t) {
853
- var r;
854
- const n = (r = e == null ? void 0 : e.iiif) == null ? void 0 : r.meta[t];
855
- return n ? n.annotationPageManager : null;
856
- }
857
- function vn(e, t = {}) {
858
- const n = O(), r = K(), i = j(), o = Re(), a = y(() => gn({
859
- all: t.all,
860
- manifest: r,
861
- canvas: i,
862
- canvases: o
863
- }), [t.all, i, o, r]), s = hn(e, t.all ? void 0 : a), c = P(
864
- (l) => {
865
- e && n.setMetaValue(
866
- [l, "annotationPageManager", "views"],
867
- (f) => f && !f[e] ? f : {
868
- ...f || {},
869
- [e]: !1
870
- }
871
- );
872
- },
873
- [e, n]
874
- ), d = P(
875
- (l, f = {}) => {
876
- if (!e)
877
- return;
878
- const v = n.getState(), p = [];
879
- if (f != null && f.deselectOthers) {
880
- const m = Object.keys(v.iiif.entities.AnnotationPage);
881
- for (const g of m) {
882
- const w = mn(v, g);
883
- w && w.views && w.views[e] && p.push(g);
884
- }
885
- }
886
- for (const m of p)
887
- c(m);
888
- n.setMetaValue(
889
- [l, "annotationPageManager", "views"],
890
- (m) => m && m[e] ? m : {
891
- ...m || {},
892
- [e]: !0
893
- }
894
- );
895
- },
896
- [e, c, n]
897
- );
898
- return {
899
- availablePageIds: a,
900
- enabledPageIds: s,
901
- setPageEnabled: d,
902
- setPageDisabled: c
903
- };
904
- }
905
- function pn(e, t) {
906
- return R((n, r) => r.get(e.map((i) => ({ id: i, type: t }))), [e, t]);
907
- }
908
- const yn = B.createContext(new gt());
909
- function je() {
910
- return T(yn);
911
- }
912
- function xn() {
913
- const e = je(), [t, n] = L({}), r = q(!1);
914
- return N(() => () => {
915
- r.current = !0;
916
- }, []), [P(
917
- (o, { height: a, width: s }) => {
918
- if (o) {
919
- const c = o.id || o["@id"], d = e.loadServiceSync({
920
- id: c,
921
- width: o.width || s,
922
- height: o.height || a,
923
- source: o
924
- });
925
- d ? o = d : t[c] || (r.current || n((l) => ({
926
- ...l,
927
- [c]: "loading"
928
- })), e.loadService({
929
- id: c,
930
- width: o.width || s,
931
- height: o.height || a
932
- }).then(() => {
933
- r.current || n((l) => ({
934
- ...l,
935
- [c]: "done"
936
- }));
937
- }));
938
- }
939
- return o;
940
- },
941
- [e, t]
942
- ), t];
943
- }
944
- function wn(e = {}) {
945
- const t = De(), n = j(e.canvasId ? { id: e.canvasId } : void 0);
946
- return R(
947
- (r, i) => {
948
- if (!n)
949
- return [];
950
- if (t && e.enableSingleAnnotation)
951
- return [t];
952
- const o = i.get(n.items), a = [];
953
- for (const s of o)
954
- a.push(...i.get(s.items));
955
- return a;
956
- },
957
- [n]
958
- );
959
- }
960
- function Sn(e) {
961
- return e.type === "SpecificResource" ? [e.source, { selector: e.selector }] : [e, { selector: null }];
962
- }
963
- const ee = {}, He = {
964
- get(e) {
965
- return e;
966
- },
967
- setMetaValue([e, t, n], r) {
968
- const i = He.getResourceMeta(e, t), o = i ? i[n] : void 0, a = typeof r == "function" ? r(o) : r;
969
- ee[e] = {
970
- ...ee[e] || {},
971
- [t]: {
972
- ...(ee[e] || {})[t] || {},
973
- [n]: a
974
- }
975
- };
976
- },
977
- getResourceMeta: (e, t) => {
978
- const n = ee[e];
979
- if (n)
980
- return t ? n[t] : n;
981
- }
982
- };
983
- function Pn(e = He) {
984
- function t(i) {
985
- const o = i ? typeof i == "string" ? e.get(i) : i : null;
986
- if (!o)
987
- return [];
988
- const a = e.get(o.items, { parent: o }), s = [];
989
- for (const c of a)
990
- s.push(...e.get(c.items, { parent: c }));
991
- return s;
992
- }
993
- function n(i, o = []) {
994
- const a = Array.isArray(i) ? i : t(i), s = [];
995
- let c = null;
996
- const d = [];
997
- for (const l of a) {
998
- if (l.type !== "Annotation")
999
- throw new Error("getPaintables() accept either a canvas or list of annotations");
1000
- const f = Array.from(Array.isArray(l.body) ? l.body : [l.body]);
1001
- for (const v of f) {
1002
- const [p, { selector: m }] = Sn(v), g = e.get(p), w = (g.type || "unknown").toLowerCase();
1003
- if (w === "choice") {
1004
- const x = e.get(g.items, { parent: g.id }), M = o.length ? o.map((b) => x.find((W) => W.id === b)).filter(Boolean) : [x[0]];
1005
- M.length === 0 && M.push(x[0]), c = {
1006
- type: "single-choice",
1007
- items: x.map((b) => ({
1008
- id: b.id,
1009
- label: b.label,
1010
- selected: M.indexOf(b) !== -1
1011
- })),
1012
- label: p.label
1013
- }, f.push(...M);
1014
- continue;
1015
- }
1016
- s.indexOf(w) === -1 && s.push(w), d.push({
1017
- type: w,
1018
- annotationId: l.id,
1019
- resource: g,
1020
- target: l.target,
1021
- selector: m
1022
- });
1023
- }
1024
- }
1025
- return {
1026
- types: s,
1027
- items: d,
1028
- choice: c
1029
- };
1030
- }
1031
- function r(i) {
1032
- const { choice: o } = n(i);
1033
- return o;
1034
- }
1035
- return {
1036
- getAllPaintingAnnotations: t,
1037
- getPaintables: n,
1038
- extractChoices: r
1039
- };
1040
- }
1041
- function bn(e, t = []) {
1042
- const n = O(), r = y(() => Pn(n), []), i = wn({ enableSingleAnnotation: e == null ? void 0 : e.enableSingleAnnotation }), [o, a] = L((e == null ? void 0 : e.defaultChoices) || []), s = y(
1043
- () => r.getPaintables(i, o),
1044
- [n, i, o, ...t]
1045
- ), d = { makeChoice: P(
1046
- (l, { deselectOthers: f = !0, deselect: v = !1 } = {}) => {
1047
- if (s.choice) {
1048
- if (s.choice.type !== "single-choice")
1049
- throw new Error("Complex choice not supported yet");
1050
- a((p) => {
1051
- if (v) {
1052
- const g = p.filter((w) => w !== l);
1053
- if (g.length === 0) {
1054
- const w = s.items[0].resource.id;
1055
- return w ? [w] : [];
1056
- }
1057
- return g;
1058
- }
1059
- if (f)
1060
- return [l];
1061
- const m = [...p];
1062
- if (m.length === 0 && s.items.length) {
1063
- const g = s.items[0].resource.id;
1064
- g && m.push(g);
1065
- }
1066
- return p.indexOf(l) !== -1 ? p : [...p, l];
1067
- });
1068
- }
1069
- },
1070
- [s.choice]
1071
- ) };
1072
- return [s, d];
1073
- }
1074
- const Cn = ["model/gltf-binary"];
1075
- function En(e, t) {
1076
- const r = t.items[0].resource;
1077
- return r.format ? Cn.indexOf(r.format) === -1 ? E(`3D format: ${r.format} is unsupported`) : {
1078
- type: "3d-model",
1079
- model: r
1080
- } : E("Unknown format");
1081
- }
1082
- function In(e, t) {
1083
- var r;
1084
- if (!e.duration)
1085
- return E("No duration on canvas");
1086
- if (t.items.length > 1)
1087
- return E("Only one audio source supported");
1088
- const n = (r = t.items[0]) == null ? void 0 : r.resource;
1089
- return n ? n.format ? {
1090
- type: "media",
1091
- media: {
1092
- annotationId: t.items[0].annotationId,
1093
- duration: e.duration,
1094
- url: n.id,
1095
- type: "Sound",
1096
- target: {
1097
- type: "TemporalSelector",
1098
- temporal: {
1099
- startTime: 0,
1100
- endTime: e.duration
1101
- }
1102
- },
1103
- format: n.format,
1104
- selector: {
1105
- type: "TemporalSelector",
1106
- temporal: {
1107
- startTime: 0,
1108
- endTime: e.duration
1109
- }
1110
- }
1111
- },
1112
- annotations: {
1113
- pages: []
1114
- }
1115
- } : E("Audio does not have format") : E("Unknown audio");
1116
- }
1117
- function Mn(e, t, n) {
1118
- const r = [];
1119
- for (const i of t.items) {
1120
- const o = i.resource && i.resource.type === "SpecificResource" ? i.resource.source : i.resource;
1121
- if (!o.id)
1122
- return E("No resource Identifier");
1123
- let a;
1124
- if (o.service) {
1125
- const p = mt(o);
1126
- p[0] && (a = n(p[0], e));
1127
- }
1128
- const s = {
1129
- type: "BoxSelector",
1130
- spatial: {
1131
- x: 0,
1132
- y: 0,
1133
- width: Number(e.width),
1134
- height: Number(e.height)
1135
- }
1136
- }, [c, d] = Be(e, i.target);
1137
- if (!(d.id === e.id || decodeURIComponent(d.id || "") === (e.id || "")))
1138
- continue;
1139
- i.resource.width && i.resource.height && (i.resource.width, i.resource.height);
1140
- let l = i.resource.type === "SpecificResource" ? le(i.resource) : null;
1141
- if (i.selector) {
1142
- const p = le({
1143
- type: "SpecificResource",
1144
- source: i.resource,
1145
- selector: i.selector
1146
- });
1147
- p && (l = p);
1148
- }
1149
- const f = l && l.selector && (l.selector.type === "BoxSelector" || l.selector.type === "TemporalBoxSelector") ? {
1150
- type: "BoxSelector",
1151
- spatial: {
1152
- x: l.selector.spatial.x,
1153
- y: l.selector.spatial.y,
1154
- width: l.selector.spatial.width,
1155
- height: l.selector.spatial.height
1156
- }
1157
- } : void 0;
1158
- a && !a.id && (a.id = a["@id"]);
1159
- const v = {
1160
- id: o.id,
1161
- type: "Image",
1162
- annotationId: i.annotationId,
1163
- width: Number(c || f ? o.width : e.width),
1164
- height: Number(c || f ? o.height : e.height),
1165
- service: a,
1166
- sizes: a && a.sizes ? a.sizes : o.width && o.height ? [{ width: o.width, height: o.height }] : [],
1167
- target: c && c.type !== "PointSelector" ? c : s,
1168
- selector: f
1169
- };
1170
- r.push(v);
1171
- }
1172
- return {
1173
- type: "images",
1174
- image: r[0],
1175
- images: r,
1176
- choice: t.choice
1177
- };
1178
- }
1179
- function $e(e, t = {}, n) {
1180
- const r = e.language || n || "none";
1181
- switch (e.type) {
1182
- case "TextualBody": {
1183
- typeof e.value < "u" && (t[r] = e.value);
1184
- break;
1185
- }
1186
- case "List":
1187
- case "Composite":
1188
- case "Choice":
1189
- e.items && e.items.forEach((i) => $e(i, t, r));
1190
- }
1191
- return t;
1192
- }
1193
- function An(e, t) {
1194
- const n = [];
1195
- return t.items.forEach((r) => {
1196
- if (r.resource) {
1197
- const [i] = Be(e, r.target);
1198
- n.push({ annotationId: r.annotationId, text: $e(r.resource), target: i });
1199
- }
1200
- }), {
1201
- type: "textual-content",
1202
- items: n
1203
- };
1204
- }
1205
- const Tn = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;
1206
- function Rn(e, t) {
1207
- var s;
1208
- const n = t.items.filter((c) => c.type === "video");
1209
- let r = !1;
1210
- if (e.duration || (r = !0), n.length > 1)
1211
- return E("Only one video source supported");
1212
- const i = (s = n[0]) == null ? void 0 : s.resource, o = !!(i.service || []).find(
1213
- (c) => (c.profile || "").includes("youtube.com")
1214
- );
1215
- if (!o && r)
1216
- return E("Video does not have duration");
1217
- if (!i)
1218
- return E("Unknown video");
1219
- if ((!i.format || i.format === "text/html") && !o)
1220
- return E("Video does not have format");
1221
- const a = {
1222
- annotationId: t.items[0].annotationId,
1223
- duration: e.duration,
1224
- url: i.id,
1225
- type: "Video",
1226
- items: [],
1227
- target: {
1228
- type: "TemporalSelector",
1229
- temporal: {
1230
- startTime: 0,
1231
- endTime: e.duration
1232
- }
1233
- },
1234
- format: i.format,
1235
- selector: {
1236
- type: "TemporalSelector",
1237
- temporal: {
1238
- startTime: 0,
1239
- endTime: e.duration
1240
- }
1241
- }
1242
- };
1243
- if (o) {
1244
- a.type = "VideoYouTube";
1245
- const c = i.id.match(Tn);
1246
- if (!c[1])
1247
- return E("Video is not known youtube video");
1248
- a.youTubeId = c[1];
1249
- }
1250
- return {
1251
- type: "media",
1252
- media: a,
1253
- annotations: {
1254
- pages: []
1255
- }
1256
- };
1257
- }
1258
- function Vn({ canvas: e, paintables: t, supports: n, loadImageService: r }) {
1259
- if (!e)
1260
- return console.log("No canvas"), ce;
1261
- if (t.types.length === 0)
1262
- return n.indexOf("empty") !== -1 ? dn(e.width, e.height) : (console.log("No paintables"), ce);
1263
- if (t.types.length !== 1)
1264
- if (t.types.length === 2 && t.types.indexOf("text") !== -1)
1265
- t.types = t.types.filter((o) => o !== "text");
1266
- else
1267
- return n.indexOf("complex-timeline") === -1 ? E("Complex timeline not supported") : E("ComplexTimelineStrategy not yet supported");
1268
- const i = t.types[0];
1269
- return i === "image" ? n.indexOf("images") === -1 ? E("Image not supported") : Mn(e, t, r) : i === "Model" || i === "model" ? n.indexOf("3d-model") === -1 ? E("3D not supported") : En(e, t) : i === "textualbody" ? n.indexOf("textual-content") === -1 ? E("Textual content not supported") : An(e, t) : i === "sound" || i === "audio" ? n.indexOf("media") === -1 ? E("Media not supported") : In(e, t) : i === "video" ? n.indexOf("media") === -1 ? E("Media not supported") : Rn(e, t) : ce;
1270
- }
1271
- function On(e) {
1272
- const t = K(), n = j(), r = O(), [i, o] = xn(), { enabledPageIds: a } = vn((e == null ? void 0 : e.annotationPageManagerId) || (t == null ? void 0 : t.id) || (n == null ? void 0 : n.id), {
1273
- all: !1
1274
- }), s = pn(a, "AnnotationPage"), c = (e == null ? void 0 : e.strategies) || [
1275
- "empty",
1276
- "images",
1277
- "media",
1278
- "textual-content",
1279
- "complex-timeline"
1280
- ], [d, l] = bn(e, [o]), f = y(() => Vn({ canvas: n, paintables: d, supports: c, loadImageService: i }), [n, d, r, l.makeChoice]);
1281
- return y(() => f.type === "unknown" ? [f, ln] : [
1282
- {
1283
- ...f,
1284
- annotations: { pages: s }
1285
- },
1286
- l
1287
- ], [f, s]);
1288
- }
1289
- const Ln = (e, t = []) => {
1290
- const n = O();
1291
- N(() => {
1292
- e(n);
1293
- }, [n, ...t]);
1294
- };
1295
- function kn(e, t, { canvasId: n, manifestId: r } = {}) {
1296
- const i = O(), o = je(), a = y(() => vt(i, { imageServiceLoader: o }), [i, o]), [s, c] = L(), d = K(r ? { id: r } : void 0), l = j(n ? { id: n } : void 0), f = l || d, v = q(!1);
1297
- if (N(() => (v.current = !1, () => {
1298
- v.current = !0;
1299
- }), []), !f)
1300
- throw new Error("Must be called under a manifest or canvas context.");
1301
- return Ln(
1302
- (p) => {
1303
- a.getBestThumbnailAtSize(f, e, t).then((m) => {
1304
- m.best && !v.current && c(m.best);
1305
- });
1306
- },
1307
- [f]
1308
- ), s;
1309
- }
1310
- function Nn(e) {
1311
- return { isMuted: !1, playRequested: !1, isPlaying: !1, isFinished: !1, volume: 100, duration: e };
1312
- }
1313
- function Fn(e, t) {
1314
- switch (t.type) {
1315
- case "FINISHED":
1316
- return { ...e, isFinished: !0, isPlaying: !1, playRequested: !1 };
1317
- case "PLAY_PAUSE":
1318
- return { ...e, isFinished: !1, isPlaying: !e.isPlaying };
1319
- case "PLAY_REQUESTED":
1320
- return { ...e, isFinished: !1, playRequested: !0 };
1321
- case "PAUSE":
1322
- return { ...e, isPlaying: !1 };
1323
- case "PLAY":
1324
- return { ...e, isFinished: !1, playRequested: !1, isPlaying: !0 };
1325
- case "MUTE":
1326
- return { ...e, isMuted: !0 };
1327
- case "SET_VOLUME":
1328
- return { ...e, volume: t.volume, isMuted: t.volume === 0 };
1329
- case "TOGGLE_MUTE":
1330
- return { ...e, isMuted: !e.isMuted };
1331
- case "UNMUTE":
1332
- return { ...e, isMuted: !1 };
1333
- }
1334
- return e;
1335
- }
1336
- function Un(e) {
1337
- const t = Math.round(e);
1338
- return `${Math.floor(t / 60)}:${`${t % 60}`.padStart(2, "0")}`;
1339
- }
1340
- function pe(e) {
1341
- const [t, n] = ot(Fn, Nn(e.duration)), r = q(null), i = q(null), o = q(null), a = q(!1), s = P(() => {
1342
- i.current && r.current && (i.current.innerHTML = Un(r.current.currentTime), o.current && (o.current.style.width = `${r.current.currentTime / e.duration * 100}%`), a.current !== r.current.muted && (a.current = r.current.muted, n(r.current.muted ? { type: "MUTE" } : { type: "UNMUTE" })));
1343
- }, [e.duration]), c = P(() => {
1344
- r.current && (n({ type: "PLAY_REQUESTED" }), r.current.play().then(() => {
1345
- n({ type: "PLAY" });
1346
- }), s());
1347
- }, [s]), d = P(() => {
1348
- r.current && (r.current.duration > 0 && r.current.paused ? c() : l());
1349
- }, [s]), l = P(() => {
1350
- r.current && (r.current.pause(), n({ type: "PAUSE" }), s());
1351
- }, [s]), f = P(() => {
1352
- r.current && (r.current.muted = !r.current.muted, n(r.current.muted ? { type: "MUTE" } : { type: "UNMUTE" }));
1353
- }, []), v = P(() => {
1354
- r.current && (r.current.muted = !0, n({ type: "MUTE" }));
1355
- }, []), p = P(() => {
1356
- r.current && (r.current.muted = !1, n({ type: "UNMUTE" }));
1357
- }, []), m = P((x) => {
1358
- r.current && (r.current.muted = !1, r.current.volume = x / 100, n({ type: "SET_VOLUME", volume: x }));
1359
- }, []), g = P((x) => {
1360
- r.current && (r.current.currentTime = Math.max(0, Math.min(x * e.duration, e.duration)), s());
1361
- }, []), w = P((x) => {
1362
- r.current && (r.current.currentTime = Math.max(0, Math.min(x, e.duration)), s());
1363
- }, []);
1364
- return N(() => {
1365
- const x = setInterval(() => {
1366
- s();
1367
- }, 350);
1368
- return () => clearInterval(x);
1369
- }, [s, e.duration]), N(() => {
1370
- const x = () => {
1371
- n({ type: "FINISHED" });
1372
- }, M = r.current;
1373
- return M == null || M.addEventListener("ended", x), () => M == null ? void 0 : M.removeEventListener("ended", x);
1374
- }, []), [
1375
- { element: r, currentTime: i, progress: o },
1376
- t,
1377
- {
1378
- play: c,
1379
- pause: l,
1380
- playPause: d,
1381
- mute: v,
1382
- unmute: p,
1383
- toggleMute: f,
1384
- setVolume: m,
1385
- setDurationPercent: g,
1386
- setTime: w
1387
- }
1388
- ];
1389
- }
1390
- const Dn = F(null), _n = F(null), qn = F(null);
1391
- function Ye({
1392
- actions: e,
1393
- state: t,
1394
- children: n,
1395
- currentTime: r,
1396
- progress: i,
1397
- element: o
1398
- }) {
1399
- return /* @__PURE__ */ u(qn.Provider, { value: { currentTime: r, progress: i, element: o }, children: /* @__PURE__ */ u(_n.Provider, { value: e, children: /* @__PURE__ */ u(Dn.Provider, { value: t, children: n }) }) });
1400
- }
1401
- function ze({ media: e, children: t }) {
1402
- const [{ element: n, currentTime: r, progress: i }, o, a] = pe({ duration: e.duration });
1403
- return /* @__PURE__ */ I(
1404
- Ye,
1405
- {
1406
- state: o,
1407
- actions: a,
1408
- currentTime: r,
1409
- progress: i,
1410
- element: n,
1411
- children: [
1412
- /* @__PURE__ */ u("audio", { ref: n, src: e.url }),
1413
- t
1414
- ]
1415
- }
1416
- );
1417
- }
1418
- function Ke({
1419
- media: e,
1420
- mediaControlsDeps: t,
1421
- children: n
1422
- }) {
1423
- return Y("portal", "audio", ze, { media: e, children: n }, [e, ...t || []]), null;
1424
- }
1425
- function We({
1426
- element: e,
1427
- media: t,
1428
- playPause: n
1429
- }) {
1430
- return /* @__PURE__ */ I("div", { className: "video-container", part: "video-container", onClick: n, children: [
1431
- /* @__PURE__ */ u("style", { children: `
1432
- .video-container {
1433
- position: absolute;
1434
- top: 0;
1435
- bottom: 0;
1436
- left: 0;
1437
- right: 0;
1438
- background: #000;
1439
- z-index: 13;
1440
- display: flex;
1441
- justify-content: center;
1442
- pointer-events: visible;
1443
- }
1444
- ` }),
1445
- /* @__PURE__ */ u("video", { ref: e, src: t.url, style: { width: "100%", objectFit: "contain" } })
1446
- ] });
1447
- }
1448
- function Ge({
1449
- media: e,
1450
- mediaControlsDeps: t,
1451
- children: n
1452
- }) {
1453
- const [{ element: r, currentTime: i, progress: o }, a, s] = pe({ duration: e.duration });
1454
- return Y("overlay", "video-element", We, {
1455
- element: r,
1456
- media: e,
1457
- playPause: s.playPause
1458
- }), Y(
1459
- "portal",
1460
- "custom-controls",
1461
- Ye,
1462
- {
1463
- state: a,
1464
- actions: s,
1465
- currentTime: i,
1466
- progress: o,
1467
- element: r,
1468
- children: n
1469
- },
1470
- [i, a, e, ...t || []]
1471
- ), null;
1472
- }
1473
- function Qe({ model: e }) {
1474
- return /* @__PURE__ */ I($, { children: [
1475
- /* @__PURE__ */ u("style", { children: `
1476
- .model-container {
1477
- position: absolute;
1478
- top: 0;
1479
- bottom: 0;
1480
- left: 0;
1481
- right: 0;
1482
- background: #000;
1483
- z-index: 13;
1484
- display: flex;
1485
- justify-content: center;
1486
- pointer-events: visible;
1487
- }
1488
- ` }),
1489
- /* @__PURE__ */ u("div", { className: "model-container", children: /* @__PURE__ */ u(
1490
- "model-viewer",
1491
- {
1492
- "interaction-prompt": "none",
1493
- style: { width: "100%", height: "100%" },
1494
- "camera-controls": "",
1495
- "ar-status": "not-presenting",
1496
- src: e.id
1497
- }
1498
- ) })
1499
- ] });
1500
- }
1501
- function Je({ model: e, name: t }) {
1502
- return Y("overlay", `model-${t}`, Qe, { model: e }, [e]), null;
1503
- }
1504
- function Ze({ style: e }) {
1505
- const t = j();
1506
- return !t || !t.height || !t.width ? null : /* @__PURE__ */ u(
1507
- "box",
1508
- {
1509
- interactive: !1,
1510
- target: { x: 0, y: 0, width: Number(t.width), height: Number(t.height) },
1511
- style: e
1512
- }
1513
- );
1514
- }
1515
- const Bn = B.createContext("en");
1516
- function Xe() {
1517
- return B.useContext(Bn);
1518
- }
1519
- function Ee(e) {
1520
- return e.indexOf("-") !== -1 ? e.slice(0, e.indexOf("-")) : e;
1521
- }
1522
- function jn({ as: e, language: t, children: n, viewingDirection: r, ...i }) {
1523
- const o = Xe();
1524
- return y(() => Ee(o) === Ee(t), [o, t]) ? e ? /* @__PURE__ */ u(e, { ...i, children: n }) : /* @__PURE__ */ u("span", { ...i, children: n }) : e ? /* @__PURE__ */ u(e, { ...i, lang: t, dir: r, children: n }) : /* @__PURE__ */ u("span", { ...i, lang: t, dir: r, children: n });
1525
- }
1526
- function Hn(e, t, n) {
1527
- if (t.length === 0)
1528
- return;
1529
- if (t.length === 1)
1530
- return t[0];
1531
- if (t.indexOf(e) !== -1)
1532
- return e;
1533
- const r = e.indexOf("-") !== -1 ? e.slice(0, e.indexOf("-")) : null;
1534
- if (r && t.indexOf(r) !== -1)
1535
- return r;
1536
- for (const i of n)
1537
- if (t.indexOf(i) !== -1)
1538
- return i;
1539
- return t.indexOf("none") !== -1 ? "none" : t.indexOf("@none") !== -1 ? "@none" : t[0];
1540
- }
1541
- const $n = (e, t = []) => {
1542
- const n = Xe();
1543
- return y(() => {
1544
- const r = e();
1545
- return Hn(n, r, []);
1546
- }, [n, ...t]);
1547
- };
1548
- function Yn(e, t, n = `
1549
- `) {
1550
- const r = $n(() => Object.keys(e || {}), [e]);
1551
- return [
1552
- y(() => {
1553
- if (!e)
1554
- return t || "";
1555
- if (typeof e == "string")
1556
- return e;
1557
- const i = r ? e[r] : void 0;
1558
- return i ? typeof i == "string" ? i : i.join(n) : "";
1559
- }, [r, t, e]),
1560
- r
1561
- ];
1562
- }
1563
- function zn({
1564
- as: e,
1565
- defaultText: t,
1566
- enableDangerouslySetInnerHTML: n,
1567
- children: r,
1568
- separator: i,
1569
- ...o
1570
- }) {
1571
- const [a, s] = Yn(r, t, i);
1572
- return s ? /* @__PURE__ */ u(
1573
- jn,
1574
- {
1575
- ...o,
1576
- as: e,
1577
- language: s,
1578
- title: n ? void 0 : a,
1579
- dangerouslySetInnerHTML: n ? {
1580
- __html: a
1581
- } : void 0,
1582
- children: n ? void 0 : a
1583
- }
1584
- ) : e ? /* @__PURE__ */ u(e, { ...o, children: a }) : /* @__PURE__ */ u(
1585
- "span",
1586
- {
1587
- ...o,
1588
- title: n ? void 0 : a,
1589
- dangerouslySetInnerHTML: n ? {
1590
- __html: a
1591
- } : void 0,
1592
- children: n ? void 0 : a
1593
- }
1594
- );
1595
- }
1596
- function Kn({
1597
- element: e,
1598
- media: t,
1599
- playPause: n
1600
- }) {
1601
- const r = q(null);
1602
- return t.youTubeId ? /* @__PURE__ */ I("div", { className: "video-container", part: "video-container", onClick: n, children: [
1603
- /* @__PURE__ */ u("style", { children: `
1604
- .video-container {
1605
- position: absolute;
1606
- top: 0;
1607
- bottom: 0;
1608
- left: 0;
1609
- right: 0;
1610
- background: #000;
1611
- z-index: 13;
1612
- display: flex;
1613
- justify-content: center;
1614
- pointer-events: visible;
1615
- }
1616
- .video-yt {
1617
- border: none;
1618
- width: 100%;
1619
- object-fit: contain;
1620
- }
1621
- ` }),
1622
- /* @__PURE__ */ u(
1623
- "iframe",
1624
- {
1625
- className: "video-yt",
1626
- ref: r,
1627
- src: `https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,
1628
- referrerPolicy: "no-referrer",
1629
- sandbox: "allow-scripts allow-same-origin allow-presentation"
1630
- }
1631
- )
1632
- ] }) : null;
1633
- }
1634
- function Wn({
1635
- media: e,
1636
- mediaControlsDeps: t,
1637
- children: n
1638
- }) {
1639
- const [{ element: r, currentTime: i, progress: o }, a, s] = pe({ duration: e.duration });
1640
- return Y("overlay", "video-element", Kn, {
1641
- element: r,
1642
- media: e,
1643
- playPause: s.playPause
1644
- }), null;
1645
- }
1646
- function et({
1647
- x: e,
1648
- y: t,
1649
- onChoiceChange: n,
1650
- registerActions: r,
1651
- defaultChoices: i,
1652
- isStatic: o,
1653
- renderViewerControls: a,
1654
- renderMediaControls: s,
1655
- viewControlsDeps: c,
1656
- mediaControlsDeps: d,
1657
- strategies: l,
1658
- throwOnUnknown: f,
1659
- backgroundStyle: v,
1660
- alwaysShowBackground: p,
1661
- keepCanvasScale: m = !1,
1662
- enableSizes: g = !1,
1663
- enableYouTube: w = !0,
1664
- onClickPaintingAnnotation: x,
1665
- children: M
1666
- }) {
1667
- const b = j(), W = Ue(b, ["deep-zoom"]), [Z] = tn(), C = on(), A = O(), k = y(() => Te(A), [A]), [h, D] = On({
1668
- strategies: l || ["images"],
1669
- defaultChoices: i == null ? void 0 : i.map(({ id: S }) => S)
1670
- }), ye = h.type === "images" ? h.choice : void 0, tt = y(() => m ? 1 : Math.max(
1671
- 1,
1672
- ...h.type === "images" ? h.images.map((S) => {
1673
- var H;
1674
- return (S.width || 0) / ((H = S.target) == null ? void 0 : H.spatial.width);
1675
- }) : []
1676
- ), [m, h]);
1677
- an(tt), N(() => {
1678
- r && r(D);
1679
- }, [h.annotations]), N(() => {
1680
- if (i)
1681
- for (const S of i)
1682
- typeof S.opacity < "u" && k.applyStyles({ id: S.id }, "atlas", {
1683
- opacity: S.opacity
1684
- });
1685
- }, [i]), Ie(() => {
1686
- n && n(ye);
1687
- }, [ye]), Y(
1688
- C && (h.type === "images" || h.type === "empty" || h.type === "textual-content" && a) ? "overlay" : "none",
1689
- `canvas-portal-controls-${b == null ? void 0 : b.id}`,
1690
- ve.Provider,
1691
- a ? {
1692
- value: C || null,
1693
- children: a(h)
1694
- } : {},
1695
- [b, C, h, ...c || []]
1696
- );
1697
- const _ = kn({ maxWidth: 256, maxHeight: 256 });
1698
- if (!b)
1699
- return null;
1700
- const xe = b.accompanyingCanvas, G = _ && _.type === "fixed" ? /* @__PURE__ */ u("world-object", { height: b.height, width: b.width, x: e, y: t, children: /* @__PURE__ */ u(
1701
- "world-image",
1702
- {
1703
- uri: _.id,
1704
- target: { x: 0, y: 0, width: b.width, height: b.height },
1705
- display: _.width && _.height ? {
1706
- width: _.width,
1707
- height: _.height
1708
- } : void 0,
1709
- crop: void 0
1710
- }
1711
- ) }) : null;
1712
- if (h.type === "unknown") {
1713
- if (G)
1714
- return G;
1715
- if (f)
1716
- throw new Error(h.reason || "Unknown image strategy");
1717
- return null;
1718
- }
1719
- const we = /* @__PURE__ */ I(te, { children: [
1720
- Z ? /* @__PURE__ */ u(de, { page: Z }) : null,
1721
- h.annotations && h.annotations.pages ? h.annotations.pages.map((S) => /* @__PURE__ */ u(de, { page: S }, S.id)) : null,
1722
- M
1723
- ] }), nt = h.type === "images" ? h.images.length : 0;
1724
- return /* @__PURE__ */ I($, { children: [
1725
- /* @__PURE__ */ I(
1726
- "world-object",
1727
- {
1728
- height: b.height,
1729
- width: b.width,
1730
- x: e,
1731
- y: t,
1732
- ...W,
1733
- children: [
1734
- h.type === "empty" || p ? /* @__PURE__ */ u(Ze, { style: v }) : null,
1735
- h.type === "textual-content" ? h.items.map((S, H) => {
1736
- var Q;
1737
- return /* @__PURE__ */ I($, { children: [
1738
- /* @__PURE__ */ u(
1739
- ft,
1740
- {
1741
- onClick: x ? (Se) => {
1742
- Se.stopPropagation(), x(S.annotationId, S, Se);
1743
- } : void 0,
1744
- target: ((Q = S.target) == null ? void 0 : Q.spatial) || void 0,
1745
- children: /* @__PURE__ */ u("div", { "data-textual-content": !0, children: /* @__PURE__ */ u(zn, { enableDangerouslySetInnerHTML: !0, children: S.text }) })
1746
- },
1747
- H
1748
- ),
1749
- we
1750
- ] });
1751
- }) : null,
1752
- h.type === "images" ? /* @__PURE__ */ I($, { children: [
1753
- h.images.map((S, H) => /* @__PURE__ */ u(
1754
- qe,
1755
- {
1756
- isStatic: o,
1757
- image: S,
1758
- id: S.id,
1759
- thumbnail: H === 0 ? _ : void 0,
1760
- selector: S.selector,
1761
- enableSizes: g,
1762
- onClick: x ? (Q) => {
1763
- Q.stopPropagation(), x(S.annotationId, S, Q);
1764
- } : void 0
1765
- },
1766
- S.id + H
1767
- )),
1768
- we
1769
- ] }) : null,
1770
- h.type === "3d-model" ? /* @__PURE__ */ u(Je, { model: h.model }) : null,
1771
- h.type === "media" ? /* @__PURE__ */ u($, { children: h.media.type === "Sound" ? /* @__PURE__ */ I(Ke, { media: h.media, mediaControlsDeps: d, children: [
1772
- G,
1773
- s ? s(h) : null
1774
- ] }) : h.media.type === "Video" ? /* @__PURE__ */ I(Ge, { media: h.media, mediaControlsDeps: d, children: [
1775
- G,
1776
- s ? s(h) : null
1777
- ] }) : h.media.type === "VideoYouTube" && w ? /* @__PURE__ */ I(Wn, { media: h.media, mediaControlsDeps: d, children: [
1778
- G,
1779
- s ? s(h) : null
1780
- ] }) : null }) : null
1781
- ]
1782
- },
1783
- `${b.id}/${h.type}/${nt}`
1784
- ),
1785
- h.type === "media" && h.media.type === "Sound" && xe ? /* @__PURE__ */ u(me, { canvas: xe.id, children: /* @__PURE__ */ u(et, { renderViewerControls: a }) }) : null
1786
- ] });
1787
- }
1788
- const Gn = Me(function(t, n) {
1789
- const r = K(), i = Re(), o = Rt(), { ViewerControls: a, MediaControls: s } = t.components || {};
1790
- if (at(n, () => o, [o]), !r)
1791
- return /* @__PURE__ */ u("div", {});
1792
- let c = 0;
1793
- return /* @__PURE__ */ I($, { children: [
1794
- t.header,
1795
- /* @__PURE__ */ u(
1796
- V.Viewer,
1797
- {
1798
- height: t.height,
1799
- mode: t.mode,
1800
- children: i.map((d, l) => {
1801
- const f = c;
1802
- return c += d.width + (t.spacing || 0), /* @__PURE__ */ u(me, { canvas: d.id, children: /* @__PURE__ */ u(
1803
- V.RenderCanvas,
1804
- {
1805
- strategies: ["3d-model", "media", "images", "empty", "textual-content"],
1806
- renderViewerControls: l === 0 && a ? () => /* @__PURE__ */ u(a, {}) : void 0,
1807
- renderMediaControls: l === 0 && s ? () => /* @__PURE__ */ u(s, {}) : void 0,
1808
- x: f,
1809
- ...t.canvasProps || {},
1810
- children: t.annotations
1811
- },
1812
- d.id
1813
- ) }, d.id);
1814
- })
1815
- },
1816
- t.reuseAtlas ? "" : o.currentSequenceIndex
1817
- ),
1818
- t.children
1819
- ] });
1820
- }), V = Me(function({ children: t, height: n, annotations: r, canvasProps: i, spacing: o, header: a, components: s, mode: c, reuseAtlas: d, ...l }, f) {
1821
- const v = ge();
1822
- return /* @__PURE__ */ u(he, { vault: v, children: /* @__PURE__ */ u(Tt, { ...l, children: /* @__PURE__ */ u(
1823
- Gn,
1824
- {
1825
- ref: f,
1826
- height: n,
1827
- components: s,
1828
- spacing: o,
1829
- canvasProps: i,
1830
- annotations: r,
1831
- header: a,
1832
- mode: c,
1833
- reuseAtlas: d,
1834
- children: t
1835
- }
1836
- ) }) });
1837
- });
1838
- V.RenderImage = qe;
1839
- V.RenderCanvas = et;
1840
- V.RenderAnnotationPage = de;
1841
- V.RenderAnnotation = _e;
1842
- V.Viewer = sn;
1843
- V.CanvasBackground = Ze;
1844
- V.Audio = Ke;
1845
- V.Video = Ge;
1846
- V.Model = Je;
1847
- V.AudioHTML = ze;
1848
- V.VideoHTML = We;
1849
- V.ModelHTML = Qe;
1850
- export {
1851
- V as CanvasPanel
1852
- };
1853
- //# sourceMappingURL=canvas-panel.mjs.map