triiiceratops 0.11.2 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{ArrowCounterClockwise-B_hB6fl1.js → ArrowCounterClockwise-CM9mGGcp.js} +1 -1
  2. package/dist/X-Bn7S7vUL.js +963 -0
  3. package/dist/{annotation_tool_point-rZvdAtGa.js → annotation_tool_point-LoRp_nrI.js} +1 -1
  4. package/dist/components/DemoHeader.svelte +69 -0
  5. package/dist/components/MetadataDialog.svelte +20 -4
  6. package/dist/components/OSDViewer.svelte +31 -1
  7. package/dist/components/ThumbnailGallery.svelte +226 -35
  8. package/dist/components/Toolbar.svelte +102 -3
  9. package/dist/components/TriiiceratopsViewer.svelte +37 -12
  10. package/dist/{image_filters_reset-CAUhlDWt.js → image_filters_reset-CmWuQiOc.js} +1 -1
  11. package/dist/paraglide/messages/_index.d.ts +9 -0
  12. package/dist/paraglide/messages/_index.js +10 -1
  13. package/dist/paraglide/messages/settings_toggle_show_viewing_mode.d.ts +4 -0
  14. package/dist/paraglide/messages/settings_toggle_show_viewing_mode.js +33 -0
  15. package/dist/paraglide/messages/show_mode_toggle.d.ts +4 -0
  16. package/dist/paraglide/messages/show_mode_toggle.js +33 -0
  17. package/dist/paraglide/messages/toggle_single_page_mode.d.ts +4 -0
  18. package/dist/paraglide/messages/toggle_single_page_mode.js +33 -0
  19. package/dist/paraglide/messages/toggle_two_page_mode.d.ts +4 -0
  20. package/dist/paraglide/messages/toggle_two_page_mode.js +33 -0
  21. package/dist/paraglide/messages/two_page_mode.d.ts +4 -0
  22. package/dist/paraglide/messages/two_page_mode.js +33 -0
  23. package/dist/paraglide/messages/viewing_mode_individuals.d.ts +4 -0
  24. package/dist/paraglide/messages/viewing_mode_individuals.js +33 -0
  25. package/dist/paraglide/messages/viewing_mode_label.d.ts +4 -0
  26. package/dist/paraglide/messages/viewing_mode_label.js +33 -0
  27. package/dist/paraglide/messages/viewing_mode_paged.d.ts +4 -0
  28. package/dist/paraglide/messages/viewing_mode_paged.js +33 -0
  29. package/dist/paraglide/messages/viewing_mode_shift_pairing.d.ts +4 -0
  30. package/dist/paraglide/messages/viewing_mode_shift_pairing.js +33 -0
  31. package/dist/plugins/annotation-editor.js +3 -3
  32. package/dist/plugins/image-manipulation.js +3 -3
  33. package/dist/state/viewer.svelte.d.ts +18 -0
  34. package/dist/state/viewer.svelte.js +142 -8
  35. package/dist/triiiceratops-bundle.js +3068 -2514
  36. package/dist/triiiceratops-element.iife.js +25 -25
  37. package/dist/triiiceratops.css +1 -1
  38. package/dist/types/config.d.ts +33 -0
  39. package/package.json +1 -1
  40. package/dist/X-Boj9jj2h.js +0 -890
@@ -1,890 +0,0 @@
1
- var Ve = Object.defineProperty;
2
- var pe = (a) => {
3
- throw TypeError(a);
4
- };
5
- var Oe = (a, e, s) => e in a ? Ve(a, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[e] = s;
6
- var P = (a, e, s) => Oe(a, typeof e != "symbol" ? e + "" : e, s), Te = (a, e, s) => e.has(a) || pe("Cannot " + s);
7
- var n = (a, e, s) => (Te(a, e, "read from private field"), s ? s.call(a) : e.get(a)), h = (a, e, s) => e.has(a) ? pe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, s);
8
- import * as t from "svelte/internal/client";
9
- import { SvelteMap as fe, SvelteSet as Be } from "svelte/reactivity";
10
- import * as De from "manifesto.js";
11
- import "svelte/internal/disclose-version";
12
- import { hasContext as Ge, getContext as Re } from "svelte";
13
- var V;
14
- class je {
15
- constructor() {
16
- h(this, V, t.state(t.proxy({})));
17
- P(this, "userAnnotations", new fe());
18
- }
19
- get manifests() {
20
- return t.get(n(this, V));
21
- }
22
- set manifests(e) {
23
- t.set(n(this, V), e, !0);
24
- }
25
- // === User Annotations API ===
26
- userAnnotationKey(e, s) {
27
- return `${e}::${s}`;
28
- }
29
- setUserAnnotations(e, s, i) {
30
- const o = this.userAnnotationKey(e, s);
31
- this.userAnnotations.set(o, i);
32
- }
33
- clearUserAnnotations(e, s) {
34
- const i = this.userAnnotationKey(e, s);
35
- this.userAnnotations.has(i) && this.userAnnotations.delete(i);
36
- }
37
- getUserAnnotations(e, s) {
38
- const i = this.userAnnotationKey(e, s);
39
- return this.userAnnotations.get(i) ?? [];
40
- }
41
- // === Manifest Fetching ===
42
- async fetchManifest(e) {
43
- if (!this.manifests[e]) {
44
- this.manifests[e] = { isFetching: !0 };
45
- try {
46
- const s = await fetch(e);
47
- if (!s.ok)
48
- throw new Error(`HTTP error! status: ${s.status}`);
49
- const i = await s.json(), o = De.parseManifest(i);
50
- this.manifests[e] = { json: i, manifesto: o, isFetching: !1 };
51
- } catch (s) {
52
- this.manifests[e] = { error: s.message, isFetching: !1 };
53
- }
54
- }
55
- }
56
- getManifest(e) {
57
- const s = this.manifests[e];
58
- return s == null ? void 0 : s.manifesto;
59
- }
60
- getManifestEntry(e) {
61
- return this.manifests[e];
62
- }
63
- async fetchAnnotationList(e) {
64
- if (!this.manifests[e])
65
- try {
66
- const s = await fetch(e);
67
- if (s.ok) {
68
- const i = await s.json();
69
- this.manifests[e] = { json: i };
70
- } else
71
- console.error(`Failed to fetch annotation list: ${e}`);
72
- } catch (s) {
73
- console.error(`Error fetching annotation list: ${e}`, s);
74
- }
75
- }
76
- getCanvases(e) {
77
- const s = this.getManifest(e);
78
- if (!s)
79
- return [];
80
- const i = s.getSequences();
81
- return !i || !i.length ? [] : i[0].getCanvases();
82
- }
83
- getAnnotations(e, s) {
84
- const i = this.manualGetAnnotations(e, s), o = this.getUserAnnotations(e, s);
85
- return [...i, ...o];
86
- }
87
- // We can refactor this to use Manifesto's resource handling later if needed.
88
- manualGetAnnotations(e, s) {
89
- const i = this.getManifest(e);
90
- if (!i) return [];
91
- const o = i.getSequences()[0].getCanvasById(s);
92
- if (!o) return [];
93
- const p = o.__jsonld, m = [], I = (g) => g.resources || g.items || [];
94
- return p.otherContent && p.otherContent.forEach((g) => {
95
- const v = g["@id"] || g.id;
96
- if (v && !g.resources) {
97
- const w = this.manifests[v];
98
- if (w) {
99
- if (w.json) {
100
- const b = I(w.json);
101
- m.push(...b);
102
- }
103
- } else
104
- this.fetchAnnotationList(v);
105
- } else g.resources && m.push(...g.resources);
106
- }), p.annotations && p.annotations.forEach((g) => {
107
- const v = g.id || g["@id"];
108
- if (v && !g.items) {
109
- const w = this.manifests[v];
110
- if (w) {
111
- if (w.json) {
112
- const b = I(w.json);
113
- m.push(...b);
114
- }
115
- } else
116
- this.fetchAnnotationList(v);
117
- } else g.items && m.push(...g.items);
118
- }), m;
119
- }
120
- }
121
- V = new WeakMap();
122
- const k = new je();
123
- var O, T, B, D, G, R, j, F, Q, z, Z, H, N, U, q, K, $, W, J, X, Y, ee, te, se, ne, ae;
124
- class rt {
125
- constructor(e = null, s = null, i = []) {
126
- h(this, O, t.state(null));
127
- h(this, T, t.state(null));
128
- h(this, B, t.state(!1));
129
- h(this, D, t.state(!1));
130
- h(this, G, t.state(!1));
131
- h(this, R, t.state(!1));
132
- h(this, j, t.state(!1));
133
- h(this, F, t.state(!1));
134
- h(this, Q, t.state(!1));
135
- h(this, z, t.state("bottom"));
136
- P(this, "visibleAnnotationIds", new Be());
137
- h(this, Z, t.state(t.proxy({})));
138
- h(
139
- this,
140
- H,
141
- // Gallery State (Lifted for persistence during re-docking)
142
- t.state(t.proxy({ x: 20, y: 100 }))
143
- );
144
- h(this, N, t.state(t.proxy({ width: 300, height: 400 })));
145
- h(this, U, t.state(!1));
146
- h(this, q, t.state(t.proxy({ x: 0, y: 0 })));
147
- h(this, K, t.state(null));
148
- h(this, $, t.state(null));
149
- P(this, "eventTarget", null);
150
- /**
151
- * Reference to the main viewer DOM element.
152
- * Used for fullscreen toggling.
153
- */
154
- P(this, "viewerElement", null);
155
- h(this, W, t.state(""));
156
- h(this, J, t.state(null));
157
- h(this, X, t.state(t.proxy([])));
158
- h(this, Y, t.state(!1));
159
- h(this, ee, t.state(!1));
160
- h(this, te, t.state(t.proxy([])));
161
- h(
162
- this,
163
- se,
164
- // ==================== PLUGIN STATE ====================
165
- /** Plugin-registered menu buttons */
166
- t.state(t.proxy([]))
167
- );
168
- h(this, ne, t.state(t.proxy([])));
169
- h(this, ae, t.state(null));
170
- P(this, "pluginEventHandlers", new fe());
171
- this.manifestId = e || null, this.canvasId = s || null, this.manifestId && k.fetchManifest(this.manifestId);
172
- for (const o of i)
173
- this.registerPlugin(o);
174
- }
175
- get manifestId() {
176
- return t.get(n(this, O));
177
- }
178
- set manifestId(e) {
179
- t.set(n(this, O), e, !0);
180
- }
181
- get canvasId() {
182
- return t.get(n(this, T));
183
- }
184
- set canvasId(e) {
185
- t.set(n(this, T), e, !0);
186
- }
187
- get showAnnotations() {
188
- return t.get(n(this, B));
189
- }
190
- set showAnnotations(e) {
191
- t.set(n(this, B), e, !0);
192
- }
193
- get showThumbnailGallery() {
194
- return t.get(n(this, D));
195
- }
196
- set showThumbnailGallery(e) {
197
- t.set(n(this, D), e, !0);
198
- }
199
- get toolbarOpen() {
200
- return t.get(n(this, G));
201
- }
202
- set toolbarOpen(e) {
203
- t.set(n(this, G), e, !0);
204
- }
205
- get isGalleryDockedBottom() {
206
- return t.get(n(this, R));
207
- }
208
- set isGalleryDockedBottom(e) {
209
- t.set(n(this, R), e, !0);
210
- }
211
- get isGalleryDockedRight() {
212
- return t.get(n(this, j));
213
- }
214
- set isGalleryDockedRight(e) {
215
- t.set(n(this, j), e, !0);
216
- }
217
- get isFullScreen() {
218
- return t.get(n(this, F));
219
- }
220
- set isFullScreen(e) {
221
- t.set(n(this, F), e, !0);
222
- }
223
- get showMetadataDialog() {
224
- return t.get(n(this, Q));
225
- }
226
- set showMetadataDialog(e) {
227
- t.set(n(this, Q), e, !0);
228
- }
229
- get dockSide() {
230
- return t.get(n(this, z));
231
- }
232
- set dockSide(e) {
233
- t.set(n(this, z), e, !0);
234
- }
235
- get config() {
236
- return t.get(n(this, Z));
237
- }
238
- set config(e) {
239
- t.set(n(this, Z), e, !0);
240
- }
241
- get showToggle() {
242
- return this.config.showToggle ?? !0;
243
- }
244
- get showCanvasNav() {
245
- return this.config.showCanvasNav ?? !0;
246
- }
247
- get showZoomControls() {
248
- return this.config.showZoomControls ?? !0;
249
- }
250
- get galleryPosition() {
251
- return t.get(n(this, H));
252
- }
253
- set galleryPosition(e) {
254
- t.set(n(this, H), e, !0);
255
- }
256
- get gallerySize() {
257
- return t.get(n(this, N));
258
- }
259
- set gallerySize(e) {
260
- t.set(n(this, N), e, !0);
261
- }
262
- get isGalleryDragging() {
263
- return t.get(n(this, U));
264
- }
265
- set isGalleryDragging(e) {
266
- t.set(n(this, U), e, !0);
267
- }
268
- get galleryDragOffset() {
269
- return t.get(n(this, q));
270
- }
271
- set galleryDragOffset(e) {
272
- t.set(n(this, q), e, !0);
273
- }
274
- get dragOverSide() {
275
- return t.get(n(this, K));
276
- }
277
- set dragOverSide(e) {
278
- t.set(n(this, K), e, !0);
279
- }
280
- get galleryCenterPanelRect() {
281
- return t.get(n(this, $));
282
- }
283
- set galleryCenterPanelRect(e) {
284
- t.set(n(this, $), e, !0);
285
- }
286
- setEventTarget(e) {
287
- this.eventTarget = e;
288
- }
289
- /**
290
- * Get current state as a plain object snapshot.
291
- * Safe to use outside Svelte's reactive system.
292
- * NOTE: We calculate currentCanvasIndex inline to avoid triggering the canvases getter
293
- * which can cause infinite loops when it auto-sets canvasId.
294
- */
295
- getSnapshot() {
296
- let e = -1;
297
- return this.manifestId && this.canvasId && (e = k.getCanvases(this.manifestId).findIndex((i) => (i.id || i["@id"] || (i.getCanvasId ? i.getCanvasId() : null) || (i.getId ? i.getId() : null)) === this.canvasId)), {
298
- manifestId: this.manifestId,
299
- canvasId: this.canvasId,
300
- currentCanvasIndex: e,
301
- showAnnotations: this.showAnnotations,
302
- showThumbnailGallery: this.showThumbnailGallery,
303
- showSearchPanel: this.showSearchPanel,
304
- toolbarOpen: this.toolbarOpen,
305
- searchQuery: this.searchQuery,
306
- isFullScreen: this.isFullScreen,
307
- dockSide: this.dockSide
308
- };
309
- }
310
- /**
311
- * Dispatch a state change event to the web component.
312
- * No-op if eventTarget is null (Svelte component usage).
313
- *
314
- * Uses queueMicrotask to dispatch asynchronously AFTER the current
315
- * reactive cycle completes, preventing infinite update loops.
316
- */
317
- dispatchStateChange(e = "statechange") {
318
- console.log(`[ViewerState] Dispatching ${e}`, JSON.stringify(this.getSnapshot())), this.eventTarget && queueMicrotask(() => {
319
- var s;
320
- (s = this.eventTarget) == null || s.dispatchEvent(new CustomEvent(e, { detail: this.getSnapshot(), bubbles: !0, composed: !0 }));
321
- });
322
- }
323
- get manifest() {
324
- return this.manifestId ? k.getManifest(this.manifestId) : null;
325
- }
326
- get manifestEntry() {
327
- return this.manifestId ? k.getManifestEntry(this.manifestId) : null;
328
- }
329
- get canvases() {
330
- return this.manifestId ? k.getCanvases(this.manifestId) : [];
331
- }
332
- get currentCanvasIndex() {
333
- return this.canvasId ? this.canvases.findIndex((e) => (e.id || e["@id"] || (e.getCanvasId ? e.getCanvasId() : null) || (e.getId ? e.getId() : null)) === this.canvasId) : this.canvases.length > 0 ? 0 : -1;
334
- }
335
- get hasNext() {
336
- return this.currentCanvasIndex < this.canvases.length - 1;
337
- }
338
- get hasPrevious() {
339
- return this.currentCanvasIndex > 0;
340
- }
341
- nextCanvas() {
342
- if (this.hasNext) {
343
- const e = this.currentCanvasIndex + 1, s = this.canvases[e];
344
- this.setCanvas(s.id);
345
- }
346
- }
347
- previousCanvas() {
348
- if (this.hasPrevious) {
349
- const e = this.currentCanvasIndex - 1, s = this.canvases[e];
350
- this.setCanvas(s.id);
351
- }
352
- }
353
- zoomIn() {
354
- this.osdViewer && this.osdViewer.viewport && (this.osdViewer.viewport.zoomBy(1.2), this.osdViewer.viewport.applyConstraints());
355
- }
356
- zoomOut() {
357
- this.osdViewer && this.osdViewer.viewport && (this.osdViewer.viewport.zoomBy(0.8), this.osdViewer.viewport.applyConstraints());
358
- }
359
- setManifest(e) {
360
- this.manifestId = e, this.canvasId = null, k.fetchManifest(e), this.dispatchStateChange("manifestchange");
361
- }
362
- setCanvas(e) {
363
- this.canvasId = e, this.dispatchStateChange("canvaschange");
364
- }
365
- updateConfig(e) {
366
- var i;
367
- const s = this.config;
368
- if (this.config = e, e.toolbarOpen !== void 0 && (this.toolbarOpen = e.toolbarOpen), e.gallery && (e.gallery.open !== void 0 && (this.showThumbnailGallery = e.gallery.open), e.gallery.dockPosition !== void 0 && (this.dockSide = e.gallery.dockPosition)), e.search) {
369
- e.search.open !== void 0 && (this.showSearchPanel = e.search.open);
370
- const o = e.search.query, p = (i = s.search) == null ? void 0 : i.query;
371
- o !== void 0 && o !== p && o !== this.searchQuery && this._performSearch(o);
372
- }
373
- e.annotations && e.annotations.open !== void 0 && (this.showAnnotations = e.annotations.open);
374
- }
375
- toggleAnnotations() {
376
- this.showAnnotations = !this.showAnnotations, this.dispatchStateChange();
377
- }
378
- toggleToolbar() {
379
- this.toolbarOpen = !this.toolbarOpen, this.dispatchStateChange();
380
- }
381
- toggleThumbnailGallery() {
382
- this.showThumbnailGallery = !this.showThumbnailGallery, this.dispatchStateChange();
383
- }
384
- setViewerElement(e) {
385
- this.viewerElement = e;
386
- }
387
- toggleFullScreen() {
388
- if (document.fullscreenElement)
389
- document.exitFullscreen();
390
- else {
391
- const e = this.viewerElement || document.getElementById("triiiceratops-viewer");
392
- e ? e.requestFullscreen().catch((s) => {
393
- console.warn("Fullscreen request failed", s);
394
- }) : console.warn("Cannot toggle fullscreen: Viewer element not found");
395
- }
396
- }
397
- toggleMetadataDialog() {
398
- this.showMetadataDialog = !this.showMetadataDialog;
399
- }
400
- get searchQuery() {
401
- return t.get(n(this, W));
402
- }
403
- set searchQuery(e) {
404
- t.set(n(this, W), e, !0);
405
- }
406
- get pendingSearchQuery() {
407
- return t.get(n(this, J));
408
- }
409
- set pendingSearchQuery(e) {
410
- t.set(n(this, J), e, !0);
411
- }
412
- get searchResults() {
413
- return t.get(n(this, X));
414
- }
415
- set searchResults(e) {
416
- t.set(n(this, X), e, !0);
417
- }
418
- get isSearching() {
419
- return t.get(n(this, Y));
420
- }
421
- set isSearching(e) {
422
- t.set(n(this, Y), e, !0);
423
- }
424
- get showSearchPanel() {
425
- return t.get(n(this, ee));
426
- }
427
- set showSearchPanel(e) {
428
- t.set(n(this, ee), e, !0);
429
- }
430
- toggleSearchPanel() {
431
- this.showSearchPanel = !this.showSearchPanel, this.showSearchPanel || (this.searchAnnotations = []), this.dispatchStateChange();
432
- }
433
- get searchAnnotations() {
434
- return t.get(n(this, te));
435
- }
436
- set searchAnnotations(e) {
437
- t.set(n(this, te), e, !0);
438
- }
439
- get currentCanvasSearchAnnotations() {
440
- return this.canvasId ? this.searchAnnotations.filter((e) => e.canvasId === this.canvasId) : [];
441
- }
442
- async search(e) {
443
- this.dispatchStateChange(), await this._performSearch(e), this.dispatchStateChange();
444
- }
445
- async _performSearch(e) {
446
- var s, i;
447
- if (e.trim()) {
448
- this.isSearching = !0, this.searchQuery = e, this.searchResults = [];
449
- try {
450
- const o = this.manifest;
451
- if (!o) {
452
- console.log("[ViewerState] Manifest not loaded, deferring search:", e), this.pendingSearchQuery = e;
453
- return;
454
- }
455
- let p = o.getService("http://iiif.io/api/search/1/search") || o.getService("http://iiif.io/api/search/0/search");
456
- if (p || o.__jsonld && o.__jsonld.service && (p = (Array.isArray(o.__jsonld.service) ? o.__jsonld.service : [o.__jsonld.service]).find((c) => c.profile === "http://iiif.io/api/search/1/search" || c.profile === "http://iiif.io/api/search/0/search")), !p) {
457
- console.warn("No IIIF search service found in manifest"), this.isSearching = !1;
458
- return;
459
- }
460
- const I = `${p.id || p["@id"]}?q=${encodeURIComponent(e)}`, g = await fetch(I);
461
- if (!g.ok) throw new Error("Search request failed");
462
- const v = await g.json(), w = v.resources || [], b = new fe(), ie = (r) => {
463
- const c = typeof r == "string" ? r : r["@id"] || r.id;
464
- if (!c) return null;
465
- const u = c.split("#xywh=");
466
- if (u.length < 2) return null;
467
- const S = u[1].split(",").map(Number);
468
- return S.length === 4 ? S : null;
469
- }, _ = (r) => r ? r.replace(/&lt;mark&gt;/g, "<mark>").replace(/&lt;\/mark&gt;/g, "</mark>") : "";
470
- if (v.hits)
471
- for (const r of v.hits) {
472
- const c = r.annotations || [];
473
- let u = -1, S = null;
474
- const y = [];
475
- for (const l of c) {
476
- const f = w.find((d) => d["@id"] === l || d.id === l);
477
- if (f && f.on) {
478
- const d = typeof f.on == "string" ? f.on : f.on["@id"] || f.on.id, ge = d.split("#")[0], E = ie(d), A = this.canvases.findIndex((x) => x.id === ge);
479
- A >= 0 && (u === -1 && (u = A), E && (y.push(E), S || (S = E)));
480
- }
481
- }
482
- if (u >= 0) {
483
- if (!b.has(u)) {
484
- const l = this.canvases[u];
485
- let f = "Canvas " + (u + 1);
486
- try {
487
- if (l.getLabel) {
488
- const d = l.getLabel();
489
- Array.isArray(d) && d.length > 0 ? f = d[0].value : typeof d == "string" && (f = d);
490
- } else l.label && (typeof l.label == "string" ? f = l.label : Array.isArray(l.label) && (f = (s = l.label[0]) == null ? void 0 : s.value));
491
- } catch {
492
- }
493
- b.set(u, { canvasIndex: u, canvasLabel: String(f), hits: [] });
494
- }
495
- b.get(u).hits.push({
496
- type: "hit",
497
- before: _(r.before),
498
- match: _(r.match),
499
- after: _(r.after),
500
- bounds: S,
501
- allBounds: y
502
- });
503
- }
504
- }
505
- else if (w.length > 0)
506
- for (const r of w) {
507
- const c = typeof r.on == "string" ? r.on : r.on["@id"] || r.on.id, u = c.split("#")[0], S = ie(c), y = this.canvases.findIndex((l) => l.id === u);
508
- if (y >= 0) {
509
- const l = this.canvases[y];
510
- let f = "Canvas " + (y + 1);
511
- try {
512
- if (l.getLabel) {
513
- const d = l.getLabel();
514
- Array.isArray(d) && d.length > 0 ? f = d[0].value : typeof d == "string" && (f = d);
515
- } else l.label && (typeof l.label == "string" ? f = l.label : Array.isArray(l.label) && (f = (i = l.label[0]) == null ? void 0 : i.value));
516
- } catch {
517
- }
518
- b.has(y) || b.set(y, { canvasIndex: y, canvasLabel: String(f), hits: [] }), b.get(y).hits.push({
519
- type: "resource",
520
- match: _(r.resource && r.resource.chars ? r.resource.chars : r.chars || ""),
521
- bounds: S,
522
- allBounds: S ? [S] : []
523
- });
524
- }
525
- }
526
- this.searchResults = Array.from(b.values()).sort((r, c) => r.canvasIndex - c.canvasIndex);
527
- let ue = 0;
528
- this.searchAnnotations = this.searchResults.flatMap((r) => {
529
- const c = this.canvases[r.canvasIndex];
530
- return r.hits.flatMap((u) => (u.allBounds && u.allBounds.length > 0 ? u.allBounds : u.bounds ? [u.bounds] : []).map((y) => {
531
- const l = `${c.id}#xywh=${y.join(",")}`;
532
- return {
533
- "@id": `urn:search-hit:${ue++}`,
534
- "@type": "oa:Annotation",
535
- motivation: "sc:painting",
536
- on: l,
537
- canvasId: c.id,
538
- resource: { "@type": "cnt:ContentAsText", chars: u.match },
539
- // Flag to identify styling in Overlay?
540
- // Or just standard rendering.
541
- isSearchHit: !0
542
- };
543
- }));
544
- });
545
- } catch (o) {
546
- console.error("Search error:", o), this.isSearching = !1;
547
- } finally {
548
- this.pendingSearchQuery || (this.isSearching = !1);
549
- }
550
- }
551
- }
552
- get pluginMenuButtons() {
553
- return t.get(n(this, se));
554
- }
555
- set pluginMenuButtons(e) {
556
- t.set(n(this, se), e, !0);
557
- }
558
- get pluginPanels() {
559
- return t.get(n(this, ne));
560
- }
561
- set pluginPanels(e) {
562
- t.set(n(this, ne), e, !0);
563
- }
564
- get osdViewer() {
565
- return t.get(n(this, ae));
566
- }
567
- set osdViewer(e) {
568
- t.set(n(this, ae), e);
569
- }
570
- registerPlugin(e) {
571
- const s = e.id || `plugin-${Math.random().toString(36).substr(2, 9)}`;
572
- let i = t.state(!1);
573
- const o = {
574
- id: `${s}:toggle`,
575
- icon: e.icon,
576
- tooltip: e.name,
577
- onClick: () => {
578
- t.set(i, !t.get(i));
579
- },
580
- isActive: () => t.get(i),
581
- order: 200
582
- // Default order for simple plugins
583
- }, p = {
584
- id: `${s}:panel`,
585
- component: e.panel,
586
- position: e.position || "left",
587
- isVisible: () => t.get(i),
588
- props: {
589
- ...e.props,
590
- // Pass closer to component
591
- close: () => {
592
- t.set(i, !1);
593
- }
594
- }
595
- };
596
- this.pluginMenuButtons = [...this.pluginMenuButtons, o], this.pluginPanels = [...this.pluginPanels, p], e.onInit && e.onInit(this);
597
- }
598
- /**
599
- * Unregister a plugin's UI components by ID prefix.
600
- * Note: This cleans up the menu button and panel, but doesn't remove listeners attached by the plugin itself
601
- * since we don't have a handle on the plugin instance or its cleanup function anymore.
602
- * Plugins should manage their own cleanup via component lifecycle (onDestroy) if possible.
603
- */
604
- unregisterPlugin(e) {
605
- this.pluginMenuButtons = this.pluginMenuButtons.filter((s) => !s.id.startsWith(`${e}:`)), this.pluginPanels = this.pluginPanels.filter((s) => !s.id.startsWith(`${e}:`));
606
- }
607
- /**
608
- * Notify that OSD viewer is ready.
609
- * With the component-based system, we don't notify plugins individually.
610
- * Instead, plugins should use the OSDViewer instance from context or listen for 'osd-ready' event (if we emitted one).
611
- * But since we have direct access to osdViewer in this state, components can just react to it.
612
- */
613
- notifyOSDReady(e) {
614
- this.osdViewer = e;
615
- }
616
- /**
617
- * Cleanup everything.
618
- */
619
- destroyAllPlugins() {
620
- this.pluginMenuButtons = [], this.pluginPanels = [], this.pluginEventHandlers.clear();
621
- }
622
- }
623
- O = new WeakMap(), T = new WeakMap(), B = new WeakMap(), D = new WeakMap(), G = new WeakMap(), R = new WeakMap(), j = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), z = new WeakMap(), Z = new WeakMap(), H = new WeakMap(), N = new WeakMap(), U = new WeakMap(), q = new WeakMap(), K = new WeakMap(), $ = new WeakMap(), W = new WeakMap(), J = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), se = new WeakMap(), ne = new WeakMap(), ae = new WeakMap();
624
- const ot = "triiiceratops:viewerState";
625
- let ve = Symbol("phosphor-svelte");
626
- function Fe() {
627
- return Ge(ve) ? Re(ve) : {};
628
- }
629
- const Qe = "en", de = (
630
- /** @type {const} */
631
- ["en", "de"]
632
- ), ye = "PARAGLIDE_LOCALE", ze = 3456e4, we = [
633
- "cookie",
634
- "globalVariable",
635
- "baseLocale"
636
- ];
637
- globalThis.__paraglide = {};
638
- let he, me = !1, Se = () => {
639
- let a;
640
- for (const e of we) {
641
- if (e === "cookie")
642
- a = Ue();
643
- else if (e === "baseLocale")
644
- a = Qe;
645
- else if (e === "globalVariable" && he !== void 0)
646
- a = he;
647
- else if (Ie(e) && ce.has(e)) {
648
- const s = ce.get(e);
649
- if (s) {
650
- const i = s.getLocale();
651
- if (i instanceof Promise)
652
- continue;
653
- a = i;
654
- }
655
- }
656
- if (a !== void 0) {
657
- const s = Ne(a);
658
- return me || (he = s, me = !0, be(s, { reload: !1 })), s;
659
- }
660
- }
661
- throw new Error("No locale found. Read the docs https://inlang.com/m/gerre34r/library-inlang-paraglideJs/errors#no-locale-found");
662
- };
663
- const Ze = (a) => {
664
- window.location.reload();
665
- };
666
- let be = (a, e) => {
667
- const s = {
668
- reload: !0,
669
- ...e
670
- };
671
- let i;
672
- try {
673
- i = Se();
674
- } catch {
675
- }
676
- const o = [];
677
- for (const m of we)
678
- if (m === "globalVariable")
679
- he = a;
680
- else if (m === "cookie") {
681
- if (typeof document > "u" || typeof window > "u")
682
- continue;
683
- const I = `${ye}=${a}; path=/; max-age=${ze}`;
684
- document.cookie = I;
685
- } else {
686
- if (m === "baseLocale")
687
- continue;
688
- if (Ie(m) && ce.has(m)) {
689
- const I = ce.get(m);
690
- if (I) {
691
- let g = I.setLocale(a);
692
- g instanceof Promise && (g = g.catch((v) => {
693
- throw new Error(`Custom strategy "${m}" setLocale failed.`, {
694
- cause: v
695
- });
696
- }), o.push(g));
697
- }
698
- }
699
- }
700
- const p = () => {
701
- s.reload && window.location && a !== i && Ze();
702
- };
703
- if (o.length)
704
- return Promise.all(o).then(() => {
705
- p();
706
- });
707
- p();
708
- };
709
- const lt = (a) => {
710
- be = /** @type {SetLocaleFn} */
711
- a;
712
- };
713
- function He(a) {
714
- return typeof a != "string" ? !1 : a ? de.some((e) => e.toLowerCase() === a.toLowerCase()) : !1;
715
- }
716
- function Ne(a) {
717
- if (typeof a != "string")
718
- throw new Error(`Invalid locale: ${a}. Expected a string.`);
719
- const e = a.toLowerCase(), s = de.find((i) => i.toLowerCase() === e);
720
- if (!s)
721
- throw new Error(`Invalid locale: ${a}. Expected one of: ${de.join(", ")}`);
722
- return s;
723
- }
724
- function Ue() {
725
- if (typeof document > "u" || !document.cookie)
726
- return;
727
- const a = document.cookie.match(new RegExp(`(^| )${ye}=([^;]+)`)), e = a == null ? void 0 : a[2];
728
- if (He(e))
729
- return e;
730
- }
731
- const ce = /* @__PURE__ */ new Map();
732
- function Ie(a) {
733
- return typeof a == "string" && /^custom-[A-Za-z0-9_-]+$/.test(a);
734
- }
735
- const qe = (
736
- /** @type {(inputs: {}) => LocalizedString} */
737
- () => (
738
- /** @type {LocalizedString} */
739
- "Close"
740
- )
741
- ), Ke = (
742
- /** @type {(inputs: {}) => LocalizedString} */
743
- () => (
744
- /** @type {LocalizedString} */
745
- "Schließen"
746
- )
747
- ), ht = /* @__NO_SIDE_EFFECTS__ */ (a = {}, e = {}) => (e.locale ?? Se()) === "en" ? qe() : Ke();
748
- var $e = t.from_svg('<path d="M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"></path>'), We = t.from_svg('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z" opacity="0.2"></path><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>', 1), Je = t.from_svg('<path d="M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>'), Xe = t.from_svg('<path d="M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"></path>'), Ye = t.from_svg('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>'), et = t.from_svg('<path d="M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"></path>'), tt = t.from_svg('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');
749
- function ct(a, e) {
750
- t.push(e, !0);
751
- const s = Fe();
752
- let i = t.rest_props(e, ["$$slots", "$$events", "$$legacy", "children"]), o = t.derived(() => e.weight ?? s.weight ?? "regular"), p = t.derived(() => e.color ?? s.color ?? "currentColor"), m = t.derived(() => e.size ?? s.size ?? "1em"), I = t.derived(() => e.mirrored ?? s.mirrored ?? !1);
753
- function g(r) {
754
- let { weight: c, color: u, size: S, mirrored: y, ...l } = r;
755
- return l;
756
- }
757
- var v = tt();
758
- t.attribute_effect(
759
- v,
760
- (r, c) => ({
761
- xmlns: "http://www.w3.org/2000/svg",
762
- role: "img",
763
- width: t.get(m),
764
- height: t.get(m),
765
- fill: t.get(p),
766
- transform: t.get(I) ? "scale(-1, 1)" : void 0,
767
- viewBox: "0 0 256 256",
768
- ...r,
769
- ...c
770
- }),
771
- [() => g(s), () => g(i)]
772
- );
773
- var w = t.child(v);
774
- {
775
- var b = (r) => {
776
- var c = t.comment(), u = t.first_child(c);
777
- t.snippet(u, () => e.children), t.append(r, c);
778
- };
779
- t.if(w, (r) => {
780
- e.children && r(b);
781
- });
782
- }
783
- var ie = t.sibling(w, 2);
784
- {
785
- var _ = (r) => {
786
- var c = $e();
787
- t.append(r, c);
788
- }, ue = (r) => {
789
- var c = t.comment(), u = t.first_child(c);
790
- {
791
- var S = (l) => {
792
- var f = We();
793
- t.next(), t.append(l, f);
794
- }, y = (l) => {
795
- var f = t.comment(), d = t.first_child(f);
796
- {
797
- var ge = (A) => {
798
- var x = Je();
799
- t.append(A, x);
800
- }, E = (A) => {
801
- var x = t.comment(), Ae = t.first_child(x);
802
- {
803
- var _e = (L) => {
804
- var re = Xe();
805
- t.append(L, re);
806
- }, xe = (L) => {
807
- var re = t.comment(), Le = t.first_child(re);
808
- {
809
- var Ce = (C) => {
810
- var oe = Ye();
811
- t.append(C, oe);
812
- }, Me = (C) => {
813
- var oe = t.comment(), Pe = t.first_child(oe);
814
- {
815
- var ke = (M) => {
816
- var le = et();
817
- t.append(M, le);
818
- }, Ee = (M) => {
819
- var le = t.text();
820
- le.nodeValue = (console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'), ""), t.append(M, le);
821
- };
822
- t.if(
823
- Pe,
824
- (M) => {
825
- t.get(o) === "thin" ? M(ke) : M(Ee, !1);
826
- },
827
- !0
828
- );
829
- }
830
- t.append(C, oe);
831
- };
832
- t.if(
833
- Le,
834
- (C) => {
835
- t.get(o) === "regular" ? C(Ce) : C(Me, !1);
836
- },
837
- !0
838
- );
839
- }
840
- t.append(L, re);
841
- };
842
- t.if(
843
- Ae,
844
- (L) => {
845
- t.get(o) === "light" ? L(_e) : L(xe, !1);
846
- },
847
- !0
848
- );
849
- }
850
- t.append(A, x);
851
- };
852
- t.if(
853
- d,
854
- (A) => {
855
- t.get(o) === "fill" ? A(ge) : A(E, !1);
856
- },
857
- !0
858
- );
859
- }
860
- t.append(l, f);
861
- };
862
- t.if(
863
- u,
864
- (l) => {
865
- t.get(o) === "duotone" ? l(S) : l(y, !1);
866
- },
867
- !0
868
- );
869
- }
870
- t.append(r, c);
871
- };
872
- t.if(ie, (r) => {
873
- t.get(o) === "bold" ? r(_) : r(ue, !1);
874
- });
875
- }
876
- t.reset(v), t.append(a, v), t.pop();
877
- }
878
- export {
879
- je as M,
880
- ot as V,
881
- ct as X,
882
- Se as a,
883
- rt as b,
884
- ht as c,
885
- Fe as g,
886
- de as l,
887
- k as m,
888
- lt as o,
889
- be as s
890
- };