triiiceratops 0.3.4 → 0.5.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.
package/dist/index.js ADDED
@@ -0,0 +1,2119 @@
1
+ var at = Object.defineProperty;
2
+ var Oe = (n) => {
3
+ throw TypeError(n);
4
+ };
5
+ var it = (n, t, s) => t in n ? at(n, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[t] = s;
6
+ var He = (n, t, s) => it(n, typeof t != "symbol" ? t + "" : t, s), ot = (n, t, s) => t.has(n) || Oe("Cannot " + s);
7
+ var A = (n, t, s) => (ot(n, t, "read from private field"), s ? s.call(n) : t.get(n)), J = (n, t, s) => t.has(n) ? Oe("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s);
8
+ import "svelte/internal/disclose-version";
9
+ import * as e from "svelte/internal/client";
10
+ import { onMount as lt, getContext as ce, setContext as ct, onDestroy as dt } from "svelte";
11
+ import * as gt from "manifesto.js";
12
+ import Fe from "openseadragon";
13
+ import ut from "phosphor-svelte/lib/CaretLeft";
14
+ import ft from "phosphor-svelte/lib/CaretRight";
15
+ import ht from "phosphor-svelte/lib/CaretDown";
16
+ import Ve from "phosphor-svelte/lib/Eye";
17
+ import Be from "phosphor-svelte/lib/EyeSlash";
18
+ import Xe from "phosphor-svelte/lib/X";
19
+ import "svelte/internal/flags/legacy";
20
+ import vt from "phosphor-svelte/lib/ChatCenteredText";
21
+ import pt from "phosphor-svelte/lib/CornersIn";
22
+ import mt from "phosphor-svelte/lib/CornersOut";
23
+ import _t from "phosphor-svelte/lib/Info";
24
+ import qe from "phosphor-svelte/lib/MagnifyingGlass";
25
+ import bt from "phosphor-svelte/lib/List";
26
+ import yt from "phosphor-svelte/lib/Slideshow";
27
+ import xt from "phosphor-svelte/lib/PuzzlePiece";
28
+ import { B as Zr } from "./plugin-DqOSV8lm.js";
29
+ var de;
30
+ class wt {
31
+ constructor() {
32
+ J(this, de, e.state(e.proxy({})));
33
+ }
34
+ get manifests() {
35
+ return e.get(A(this, de));
36
+ }
37
+ set manifests(t) {
38
+ e.set(A(this, de), t, !0);
39
+ }
40
+ async fetchManifest(t) {
41
+ if (!this.manifests[t]) {
42
+ this.manifests[t] = { isFetching: !0 };
43
+ try {
44
+ const s = await fetch(t);
45
+ if (!s.ok)
46
+ throw new Error(`HTTP error! status: ${s.status}`);
47
+ const r = await s.json(), i = gt.parseManifest(r);
48
+ this.manifests[t] = { json: r, manifesto: i, isFetching: !1 };
49
+ } catch (s) {
50
+ this.manifests[t] = { error: s.message, isFetching: !1 };
51
+ }
52
+ }
53
+ }
54
+ getManifest(t) {
55
+ const s = this.manifests[t];
56
+ return s == null ? void 0 : s.manifesto;
57
+ }
58
+ async fetchAnnotationList(t) {
59
+ if (!this.manifests[t])
60
+ try {
61
+ const s = await fetch(t);
62
+ if (s.ok) {
63
+ const r = await s.json();
64
+ this.manifests[t] = { json: r };
65
+ } else
66
+ console.error(`Failed to fetch annotation list: ${t}`);
67
+ } catch (s) {
68
+ console.error(`Error fetching annotation list: ${t}`, s);
69
+ }
70
+ }
71
+ getCanvases(t) {
72
+ const s = this.getManifest(t);
73
+ if (!s)
74
+ return [];
75
+ const r = s.getSequences();
76
+ return !r || !r.length ? [] : r[0].getCanvases();
77
+ }
78
+ getAnnotations(t, s) {
79
+ const r = this.getManifest(t);
80
+ return r ? r.getSequences()[0].getCanvasById(s) ? this.manualGetAnnotations(t, s) : [] : [];
81
+ }
82
+ // We can refactor this to use Manifesto's resource handling later if needed.
83
+ manualGetAnnotations(t, s) {
84
+ const r = this.getManifest(t);
85
+ if (!r) return [];
86
+ const i = r.getSequences()[0].getCanvasById(s);
87
+ if (!i) return [];
88
+ const a = i.__jsonld;
89
+ let M = [];
90
+ const $ = (S) => S.resources || S.items || [];
91
+ return a.otherContent && a.otherContent.forEach((S) => {
92
+ const w = S["@id"] || S.id;
93
+ if (w && !S.resources) {
94
+ const T = this.manifests[w];
95
+ if (T) {
96
+ if (T.json) {
97
+ const L = $(T.json);
98
+ M.push(...L);
99
+ }
100
+ } else
101
+ this.fetchAnnotationList(w);
102
+ } else S.resources && M.push(...S.resources);
103
+ }), a.annotations && a.annotations.forEach((S) => {
104
+ const w = S.id || S["@id"];
105
+ if (w && !S.items) {
106
+ const T = this.manifests[w];
107
+ if (T) {
108
+ if (T.json) {
109
+ const L = $(T.json);
110
+ M.push(...L);
111
+ }
112
+ } else
113
+ this.fetchAnnotationList(w);
114
+ } else S.items && M.push(...S.items);
115
+ }), M;
116
+ }
117
+ }
118
+ de = new WeakMap();
119
+ const le = new wt();
120
+ var ge, ue, fe, he, ve, pe, me, _e, be, ye, xe, we, Se, Ae, Ie, $e, Te, ke, Pe, Me, Ce, je, ze, Le;
121
+ class St {
122
+ constructor(t = null, s = null, r = []) {
123
+ J(this, ge, e.state(null));
124
+ J(this, ue, e.state(null));
125
+ J(this, fe, e.state(!1));
126
+ J(this, he, e.state(!1));
127
+ J(this, ve, e.state(!1));
128
+ J(this, pe, e.state(!1));
129
+ J(this, me, e.state(!1));
130
+ J(this, _e, e.state(!1));
131
+ J(this, be, e.state("bottom"));
132
+ J(this, ye, e.state(e.proxy(/* @__PURE__ */ new Set())));
133
+ J(this, xe, e.state(e.proxy({ x: 20, y: 100 })));
134
+ J(this, we, e.state(e.proxy({ width: 300, height: 400 })));
135
+ J(this, Se, e.state(!1));
136
+ J(this, Ae, e.state(e.proxy({ x: 0, y: 0 })));
137
+ J(this, Ie, e.state(null));
138
+ J(this, $e, e.state(""));
139
+ J(this, Te, e.state(e.proxy([])));
140
+ J(this, ke, e.state(!1));
141
+ J(this, Pe, e.state(!1));
142
+ J(this, Me, e.state(e.proxy([])));
143
+ J(
144
+ this,
145
+ Ce,
146
+ // ==================== PLUGIN STATE ====================
147
+ /** Registered plugins */
148
+ e.state(e.proxy([]))
149
+ );
150
+ J(this, je, e.state(e.proxy([])));
151
+ J(this, ze, e.state(e.proxy([])));
152
+ J(this, Le, e.state(null));
153
+ He(this, "pluginEventHandlers", /* @__PURE__ */ new Map());
154
+ this.manifestId = t || null, this.canvasId = s || null, this.manifestId && le.fetchManifest(this.manifestId);
155
+ for (const i of r)
156
+ this.registerPlugin(i);
157
+ }
158
+ get manifestId() {
159
+ return e.get(A(this, ge));
160
+ }
161
+ set manifestId(t) {
162
+ e.set(A(this, ge), t, !0);
163
+ }
164
+ get canvasId() {
165
+ return e.get(A(this, ue));
166
+ }
167
+ set canvasId(t) {
168
+ e.set(A(this, ue), t, !0);
169
+ }
170
+ get showAnnotations() {
171
+ return e.get(A(this, fe));
172
+ }
173
+ set showAnnotations(t) {
174
+ e.set(A(this, fe), t, !0);
175
+ }
176
+ get showThumbnailGallery() {
177
+ return e.get(A(this, he));
178
+ }
179
+ set showThumbnailGallery(t) {
180
+ e.set(A(this, he), t, !0);
181
+ }
182
+ get isGalleryDockedBottom() {
183
+ return e.get(A(this, ve));
184
+ }
185
+ set isGalleryDockedBottom(t) {
186
+ e.set(A(this, ve), t, !0);
187
+ }
188
+ get isGalleryDockedRight() {
189
+ return e.get(A(this, pe));
190
+ }
191
+ set isGalleryDockedRight(t) {
192
+ e.set(A(this, pe), t, !0);
193
+ }
194
+ get isFullScreen() {
195
+ return e.get(A(this, me));
196
+ }
197
+ set isFullScreen(t) {
198
+ e.set(A(this, me), t, !0);
199
+ }
200
+ get showMetadataDialog() {
201
+ return e.get(A(this, _e));
202
+ }
203
+ set showMetadataDialog(t) {
204
+ e.set(A(this, _e), t, !0);
205
+ }
206
+ get dockSide() {
207
+ return e.get(A(this, be));
208
+ }
209
+ set dockSide(t) {
210
+ e.set(A(this, be), t, !0);
211
+ }
212
+ get visibleAnnotationIds() {
213
+ return e.get(A(this, ye));
214
+ }
215
+ set visibleAnnotationIds(t) {
216
+ e.set(A(this, ye), t, !0);
217
+ }
218
+ get galleryPosition() {
219
+ return e.get(A(this, xe));
220
+ }
221
+ set galleryPosition(t) {
222
+ e.set(A(this, xe), t, !0);
223
+ }
224
+ get gallerySize() {
225
+ return e.get(A(this, we));
226
+ }
227
+ set gallerySize(t) {
228
+ e.set(A(this, we), t, !0);
229
+ }
230
+ get isGalleryDragging() {
231
+ return e.get(A(this, Se));
232
+ }
233
+ set isGalleryDragging(t) {
234
+ e.set(A(this, Se), t, !0);
235
+ }
236
+ get galleryDragOffset() {
237
+ return e.get(A(this, Ae));
238
+ }
239
+ set galleryDragOffset(t) {
240
+ e.set(A(this, Ae), t, !0);
241
+ }
242
+ get dragOverSide() {
243
+ return e.get(A(this, Ie));
244
+ }
245
+ set dragOverSide(t) {
246
+ e.set(A(this, Ie), t, !0);
247
+ }
248
+ get manifest() {
249
+ return this.manifestId ? le.getManifest(this.manifestId) : null;
250
+ }
251
+ get canvases() {
252
+ if (!this.manifestId) return [];
253
+ const t = le.getCanvases(this.manifestId);
254
+ return t.length > 0 && !this.canvasId && setTimeout(
255
+ () => {
256
+ !this.canvasId && t.length > 0 && (this.canvasId = t[0].id);
257
+ },
258
+ 0
259
+ ), t;
260
+ }
261
+ get currentCanvasIndex() {
262
+ return this.canvasId ? this.canvases.findIndex((t) => t.id === this.canvasId) : this.canvases.length > 0 ? 0 : -1;
263
+ }
264
+ get hasNext() {
265
+ return this.currentCanvasIndex < this.canvases.length - 1;
266
+ }
267
+ get hasPrevious() {
268
+ return this.currentCanvasIndex > 0;
269
+ }
270
+ nextCanvas() {
271
+ if (this.hasNext) {
272
+ const t = this.currentCanvasIndex + 1, s = this.canvases[t];
273
+ this.canvasId = s.id;
274
+ }
275
+ }
276
+ previousCanvas() {
277
+ if (this.hasPrevious) {
278
+ const t = this.currentCanvasIndex - 1, s = this.canvases[t];
279
+ this.canvasId = s.id;
280
+ }
281
+ }
282
+ setManifest(t) {
283
+ this.manifestId = t, this.canvasId = null, le.fetchManifest(t);
284
+ }
285
+ setCanvas(t) {
286
+ this.canvasId = t;
287
+ }
288
+ toggleAnnotations() {
289
+ this.showAnnotations = !this.showAnnotations;
290
+ }
291
+ toggleThumbnailGallery() {
292
+ this.showThumbnailGallery = !this.showThumbnailGallery;
293
+ }
294
+ toggleFullScreen() {
295
+ if (document.fullscreenElement)
296
+ document.exitFullscreen();
297
+ else {
298
+ const t = document.getElementById("triiiceratops-viewer");
299
+ t && t.requestFullscreen().catch((s) => {
300
+ console.warn("Fullscreen request failed", s);
301
+ });
302
+ }
303
+ }
304
+ toggleMetadataDialog() {
305
+ this.showMetadataDialog = !this.showMetadataDialog;
306
+ }
307
+ get searchQuery() {
308
+ return e.get(A(this, $e));
309
+ }
310
+ set searchQuery(t) {
311
+ e.set(A(this, $e), t, !0);
312
+ }
313
+ get searchResults() {
314
+ return e.get(A(this, Te));
315
+ }
316
+ set searchResults(t) {
317
+ e.set(A(this, Te), t, !0);
318
+ }
319
+ get isSearching() {
320
+ return e.get(A(this, ke));
321
+ }
322
+ set isSearching(t) {
323
+ e.set(A(this, ke), t, !0);
324
+ }
325
+ get showSearchPanel() {
326
+ return e.get(A(this, Pe));
327
+ }
328
+ set showSearchPanel(t) {
329
+ e.set(A(this, Pe), t, !0);
330
+ }
331
+ toggleSearchPanel() {
332
+ this.showSearchPanel = !this.showSearchPanel, this.showSearchPanel || (this.searchAnnotations = []);
333
+ }
334
+ get searchAnnotations() {
335
+ return e.get(A(this, Me));
336
+ }
337
+ set searchAnnotations(t) {
338
+ e.set(A(this, Me), t, !0);
339
+ }
340
+ get currentCanvasSearchAnnotations() {
341
+ return this.canvasId ? this.searchAnnotations.filter((t) => t.canvasId === this.canvasId) : [];
342
+ }
343
+ async search(t) {
344
+ var s, r;
345
+ if (t.trim()) {
346
+ this.isSearching = !0, this.searchQuery = t, this.searchResults = [];
347
+ try {
348
+ const i = this.manifest;
349
+ if (!i) throw new Error("No manifest loaded");
350
+ let a = i.getService("http://iiif.io/api/search/1/search") || i.getService("http://iiif.io/api/search/0/search");
351
+ if (a || i.__jsonld && i.__jsonld.service && (a = (Array.isArray(i.__jsonld.service) ? i.__jsonld.service : [i.__jsonld.service]).find((p) => p.profile === "http://iiif.io/api/search/1/search" || p.profile === "http://iiif.io/api/search/0/search")), !a) {
352
+ console.warn("No IIIF search service found in manifest"), this.isSearching = !1;
353
+ return;
354
+ }
355
+ const $ = `${a.id || a["@id"]}?q=${encodeURIComponent(t)}`, S = await fetch($);
356
+ if (!S.ok) throw new Error("Search request failed");
357
+ const w = await S.json(), T = w.resources || [], L = [], d = (g) => {
358
+ const p = typeof g == "string" ? g : g["@id"] || g.id;
359
+ if (!p) return null;
360
+ const c = p.split("#xywh=");
361
+ if (c.length < 2) return null;
362
+ const u = c[1].split(",").map(Number);
363
+ return u.length === 4 ? u : null;
364
+ };
365
+ if (w.hits)
366
+ for (const g of w.hits) {
367
+ const p = g.annotations || [];
368
+ for (const c of p) {
369
+ const u = T.find((o) => o["@id"] === c || o.id === c);
370
+ if (u && u.on) {
371
+ const o = typeof u.on == "string" ? u.on : u.on["@id"] || u.on.id, I = o.split("#")[0], R = d(o), j = this.canvases.findIndex((l) => l.id === I);
372
+ if (j >= 0) {
373
+ const l = this.canvases[j];
374
+ let k = "Canvas " + (j + 1);
375
+ try {
376
+ if (l.getLabel) {
377
+ const b = l.getLabel();
378
+ Array.isArray(b) && b.length > 0 ? k = b[0].value : typeof b == "string" && (k = b);
379
+ } else l.label && (typeof l.label == "string" ? k = l.label : Array.isArray(l.label) && (k = (s = l.label[0]) == null ? void 0 : s.value));
380
+ } catch {
381
+ }
382
+ L.push({
383
+ type: "hit",
384
+ before: g.before,
385
+ match: g.match,
386
+ after: g.after,
387
+ canvasIndex: j,
388
+ canvasLabel: String(k),
389
+ bounds: R
390
+ });
391
+ }
392
+ }
393
+ }
394
+ }
395
+ else if (T.length > 0)
396
+ for (const g of T) {
397
+ const p = typeof g.on == "string" ? g.on : g.on["@id"] || g.on.id, c = p.split("#")[0], u = d(p), o = this.canvases.findIndex((I) => I.id === c);
398
+ if (o >= 0) {
399
+ const I = this.canvases[o];
400
+ let R = "Canvas " + (o + 1);
401
+ try {
402
+ if (I.getLabel) {
403
+ const j = I.getLabel();
404
+ Array.isArray(j) && j.length > 0 ? R = j[0].value : typeof j == "string" && (R = j);
405
+ } else I.label && (typeof I.label == "string" ? R = I.label : Array.isArray(I.label) && (R = (r = I.label[0]) == null ? void 0 : r.value));
406
+ } catch {
407
+ }
408
+ L.push({
409
+ type: "resource",
410
+ match: g.resource && g.resource.chars ? g.resource.chars : g.chars || "",
411
+ canvasIndex: o,
412
+ canvasLabel: String(R),
413
+ bounds: u
414
+ });
415
+ }
416
+ }
417
+ this.searchResults = L, this.searchAnnotations = L.filter((g) => g.bounds).map((g, p) => {
418
+ const c = this.canvases[g.canvasIndex], u = `${c.id}#xywh=${g.bounds.join(",")}`;
419
+ return {
420
+ "@id": `urn:search-hit:${p}`,
421
+ "@type": "oa:Annotation",
422
+ motivation: "sc:painting",
423
+ on: u,
424
+ canvasId: c.id,
425
+ resource: { "@type": "cnt:ContentAsText", chars: g.match },
426
+ // Flag to identify styling in Overlay?
427
+ // Or just standard rendering.
428
+ isSearchHit: !0
429
+ };
430
+ });
431
+ } catch (i) {
432
+ console.error("Search error:", i);
433
+ } finally {
434
+ this.isSearching = !1;
435
+ }
436
+ }
437
+ }
438
+ get plugins() {
439
+ return e.get(A(this, Ce));
440
+ }
441
+ set plugins(t) {
442
+ e.set(A(this, Ce), t, !0);
443
+ }
444
+ get pluginMenuButtons() {
445
+ return e.get(A(this, je));
446
+ }
447
+ set pluginMenuButtons(t) {
448
+ e.set(A(this, je), t, !0);
449
+ }
450
+ get pluginPanels() {
451
+ return e.get(A(this, ze));
452
+ }
453
+ set pluginPanels(t) {
454
+ e.set(A(this, ze), t, !0);
455
+ }
456
+ get osdViewer() {
457
+ return e.get(A(this, Le));
458
+ }
459
+ set osdViewer(t) {
460
+ e.set(A(this, Le), t, !0);
461
+ }
462
+ createPluginContext() {
463
+ const t = this;
464
+ return {
465
+ viewerState: t,
466
+ getOSDViewer: () => t.osdViewer,
467
+ registerMenuButton(s) {
468
+ t.pluginMenuButtons.find((r) => r.id === s.id) || (t.pluginMenuButtons = [...t.pluginMenuButtons, s]);
469
+ },
470
+ unregisterMenuButton(s) {
471
+ t.pluginMenuButtons = t.pluginMenuButtons.filter((r) => r.id !== s);
472
+ },
473
+ registerPanel(s) {
474
+ t.pluginPanels.find((r) => r.id === s.id) || (t.pluginPanels = [...t.pluginPanels, s]);
475
+ },
476
+ unregisterPanel(s) {
477
+ t.pluginPanels = t.pluginPanels.filter((r) => r.id !== s);
478
+ },
479
+ emit(s, r) {
480
+ const i = t.pluginEventHandlers.get(s);
481
+ i == null || i.forEach((a) => a(r));
482
+ },
483
+ on(s, r) {
484
+ return t.pluginEventHandlers.has(s) || t.pluginEventHandlers.set(s, /* @__PURE__ */ new Set()), t.pluginEventHandlers.get(s).add(r), () => {
485
+ var i;
486
+ (i = t.pluginEventHandlers.get(s)) == null || i.delete(r);
487
+ };
488
+ }
489
+ };
490
+ }
491
+ /**
492
+ * Register a plugin with this viewer instance.
493
+ */
494
+ registerPlugin(t) {
495
+ if (this.plugins.find((s) => s.id === t.id)) {
496
+ console.warn(`[Triiiceratops] Plugin "${t.id}" already registered`);
497
+ return;
498
+ }
499
+ this.plugins = [...this.plugins, t], t.onRegister(this.createPluginContext()), this.osdViewer && t.onViewerReady && t.onViewerReady(this.osdViewer);
500
+ }
501
+ /**
502
+ * Unregister a plugin by ID.
503
+ */
504
+ unregisterPlugin(t) {
505
+ var r;
506
+ const s = this.plugins.find((i) => i.id === t);
507
+ s && ((r = s.onDestroy) == null || r.call(s), this.plugins = this.plugins.filter((i) => i.id !== t), this.pluginMenuButtons = this.pluginMenuButtons.filter((i) => !i.id.startsWith(`${t}:`)), this.pluginPanels = this.pluginPanels.filter((i) => !i.id.startsWith(`${t}:`)));
508
+ }
509
+ /**
510
+ * Called by OSDViewer when OpenSeadragon is ready.
511
+ */
512
+ notifyOSDReady(t) {
513
+ var s;
514
+ this.osdViewer = t;
515
+ for (const r of this.plugins)
516
+ (s = r.onViewerReady) == null || s.call(r, t);
517
+ }
518
+ /**
519
+ * Destroy all plugins (called on viewer unmount).
520
+ */
521
+ destroyAllPlugins() {
522
+ var t;
523
+ for (const s of this.plugins)
524
+ (t = s.onDestroy) == null || t.call(s);
525
+ this.plugins = [], this.pluginMenuButtons = [], this.pluginPanels = [], this.pluginEventHandlers.clear();
526
+ }
527
+ }
528
+ ge = new WeakMap(), ue = new WeakMap(), fe = new WeakMap(), he = new WeakMap(), ve = new WeakMap(), pe = new WeakMap(), me = new WeakMap(), _e = new WeakMap(), be = new WeakMap(), ye = new WeakMap(), xe = new WeakMap(), we = new WeakMap(), Se = new WeakMap(), Ae = new WeakMap(), Ie = new WeakMap(), $e = new WeakMap(), Te = new WeakMap(), ke = new WeakMap(), Pe = new WeakMap(), Me = new WeakMap(), Ce = new WeakMap(), je = new WeakMap(), ze = new WeakMap(), Le = new WeakMap();
529
+ const ie = "triiiceratops:viewerState";
530
+ function Qe(n) {
531
+ return n.id || n["@id"] || (typeof n.getId == "function" ? n.getId() : "");
532
+ }
533
+ function Ee(n) {
534
+ if (!n) return null;
535
+ const t = n.match(/xywh=(\d+),(\d+),(\d+),(\d+)/);
536
+ return t ? {
537
+ x: parseInt(t[1], 10),
538
+ y: parseInt(t[2], 10),
539
+ w: parseInt(t[3], 10),
540
+ h: parseInt(t[4], 10)
541
+ } : null;
542
+ }
543
+ function At(n) {
544
+ const t = It(n);
545
+ if (t)
546
+ return $t(t);
547
+ const s = Mt(n);
548
+ return s ? {
549
+ type: "RECTANGLE",
550
+ x: s.x,
551
+ y: s.y,
552
+ w: s.w,
553
+ h: s.h
554
+ } : null;
555
+ }
556
+ function It(n) {
557
+ var s, r;
558
+ if (typeof n.getTarget == "function") {
559
+ const i = ((s = n.__jsonld) == null ? void 0 : s.on) || ((r = n.__jsonld) == null ? void 0 : r.target);
560
+ if (i)
561
+ return Ne(i);
562
+ }
563
+ const t = n.target || n.on;
564
+ return t ? Ne(t) : null;
565
+ }
566
+ function Ne(n) {
567
+ if (!n) return null;
568
+ if (Array.isArray(n))
569
+ for (const t of n) {
570
+ const s = Ye(t);
571
+ if (s) return s;
572
+ }
573
+ else
574
+ return Ye(n);
575
+ return null;
576
+ }
577
+ function Ye(n) {
578
+ var s;
579
+ if (!n) return null;
580
+ const t = n.selector || n;
581
+ return (t == null ? void 0 : t.type) === "SvgSelector" && t.value ? t.value : ((s = t == null ? void 0 : t.item) == null ? void 0 : s.type) === "SvgSelector" && t.item.value ? t.item.value : null;
582
+ }
583
+ function $t(n) {
584
+ try {
585
+ const s = new DOMParser().parseFromString(n, "image/svg+xml");
586
+ if (s.documentElement.nodeName === "parsererror")
587
+ return console.warn("Failed to parse SVG selector:", n), null;
588
+ const r = [], i = s.querySelectorAll("polygon");
589
+ for (const $ of i) {
590
+ const S = $.getAttribute("points");
591
+ if (S) {
592
+ const w = Tt(S);
593
+ r.push(...w);
594
+ }
595
+ }
596
+ const a = s.querySelectorAll("path");
597
+ for (const $ of a) {
598
+ const S = $.getAttribute("d");
599
+ if (S) {
600
+ const w = kt(S);
601
+ r.push(...w);
602
+ }
603
+ }
604
+ const M = s.querySelectorAll("circle");
605
+ for (const $ of M) {
606
+ const S = parseFloat($.getAttribute("cx") || "0"), w = parseFloat($.getAttribute("cy") || "0"), T = parseFloat($.getAttribute("r") || "0"), L = Pt(S, w, T);
607
+ r.push(...L);
608
+ }
609
+ return r.length === 0 ? null : {
610
+ type: "POLYGON",
611
+ points: r
612
+ };
613
+ } catch (t) {
614
+ return console.warn("Failed to convert SVG to polygon:", t), null;
615
+ }
616
+ }
617
+ function Tt(n) {
618
+ const t = [], s = n.trim().split(/\s+/);
619
+ for (const r of s) {
620
+ const [i, a] = r.split(",").map((M) => parseFloat(M));
621
+ !isNaN(i) && !isNaN(a) && t.push([i, a]);
622
+ }
623
+ return t;
624
+ }
625
+ function kt(n) {
626
+ const t = [], s = /[ML]\s*([\d.]+)[,\s]+([\d.]+)/g;
627
+ let r;
628
+ for (; (r = s.exec(n)) !== null; ) {
629
+ const i = parseFloat(r[1]), a = parseFloat(r[2]);
630
+ !isNaN(i) && !isNaN(a) && t.push([i, a]);
631
+ }
632
+ return t;
633
+ }
634
+ function Pt(n, t, s, r = 8) {
635
+ const i = [];
636
+ for (let a = 0; a < r; a++) {
637
+ const M = a / r * Math.PI * 2, $ = n + s * Math.cos(M), S = t + s * Math.sin(M);
638
+ i.push([$, S]);
639
+ }
640
+ return i;
641
+ }
642
+ function Mt(n) {
643
+ var s;
644
+ if (typeof n.getTarget == "function") {
645
+ const r = n.getTarget();
646
+ if (typeof r == "string" && r.includes("xywh="))
647
+ return Ee(r);
648
+ const i = (s = n.__jsonld) == null ? void 0 : s.on;
649
+ if (i) {
650
+ const a = Ge(i);
651
+ if (a) return a;
652
+ }
653
+ }
654
+ const t = n.target || n.on;
655
+ return t ? Ge(t) : null;
656
+ }
657
+ function Ge(n) {
658
+ if (!n) return null;
659
+ if (Array.isArray(n))
660
+ for (const t of n) {
661
+ const s = Ge(t);
662
+ if (s) return s;
663
+ }
664
+ if (typeof n == "string" && n.includes("xywh="))
665
+ return Ee(n);
666
+ if (n.selector) {
667
+ const t = n.selector, s = t.item || t;
668
+ if (s.value && typeof s.value == "string" && s.value.includes("xywh="))
669
+ return Ee(s.value);
670
+ }
671
+ return null;
672
+ }
673
+ function Ct(n) {
674
+ let t = "", s = !1;
675
+ if (typeof n.getBody == "function") {
676
+ const r = n.getBody();
677
+ if (r && Array.isArray(r)) {
678
+ const i = [];
679
+ for (const a of r) {
680
+ const M = a.getValue ? a.getValue() : "";
681
+ if (M) {
682
+ i.push(M);
683
+ const $ = a.getFormat ? a.getFormat() : "";
684
+ ($ === "text/html" || $ === "application/html") && (s = !0);
685
+ }
686
+ }
687
+ t = i.join(" ");
688
+ }
689
+ } else {
690
+ const r = (a) => a && (a.chars || a.value || a["cnt:chars"]) || "", i = (a) => a ? a.format === "text/html" || a.type === "TextualBody" : !1;
691
+ if (n.resource) {
692
+ const a = Array.isArray(n.resource) ? n.resource : [n.resource];
693
+ t = a.map(r).filter(Boolean).join(" "), s = a.some(i);
694
+ } else if (n.body) {
695
+ const a = Array.isArray(n.body) ? n.body : [n.body];
696
+ t = a.map(r).filter(Boolean).join(" "), s = a.some(i);
697
+ }
698
+ }
699
+ return t || (typeof n.getLabel == "function" ? t = n.getLabel() || "" : n.label && (t = Array.isArray(n.label) ? n.label.join(" ") : n.label)), { value: t || "Annotation", isHtml: s };
700
+ }
701
+ function jt(n, t, s = !1) {
702
+ const r = Qe(n) || `anno-${t}`, i = At(n);
703
+ if (!i)
704
+ return null;
705
+ const a = Ct(n);
706
+ return {
707
+ id: r,
708
+ geometry: i,
709
+ body: a,
710
+ isSearchHit: s
711
+ };
712
+ }
713
+ function zt(n, t = /* @__PURE__ */ new Set()) {
714
+ return n.map((s, r) => {
715
+ const i = t.has(Qe(s));
716
+ return jt(s, r, i);
717
+ }).filter((s) => s !== null);
718
+ }
719
+ var Lt = e.from_html("<div></div>"), Dt = e.from_svg('<svg class="absolute pointer-events-auto"><title> </title><polygon stroke-width="2"></polygon></svg>'), Et = e.from_html('<div class="w-full h-full relative"><div class="w-full h-full osd-background bg-base-100"></div> <!></div>');
720
+ function We(n, t) {
721
+ e.push(t, !0);
722
+ let s = e.prop(t, "tileSources", 7), r = e.prop(t, "viewerState", 7), i = e.state(void 0), a = e.state(void 0), M = e.state(0), $ = e.derived(() => {
723
+ if (!r().manifestId || !r().canvasId)
724
+ return [];
725
+ const c = le.getAnnotations(r().manifestId, r().canvasId), u = r().currentCanvasSearchAnnotations;
726
+ return [...c, ...u];
727
+ }), S = e.derived(() => {
728
+ const c = /* @__PURE__ */ new Set();
729
+ return r().currentCanvasSearchAnnotations.forEach((u) => {
730
+ const o = u.id || u["@id"];
731
+ o && c.add(o);
732
+ }), c;
733
+ }), w = e.derived(() => zt(e.get($), e.get(S))), T = e.derived(() => {
734
+ if (e.get(M), !e.get(a) || !e.get(w).length)
735
+ return [];
736
+ const c = e.get(a).world.getItemAt(0);
737
+ if (!c)
738
+ return [];
739
+ const u = [];
740
+ for (const o of e.get(w)) {
741
+ if (!o.isSearchHit) if (r().showAnnotations) {
742
+ if (!r().visibleAnnotationIds.has(o.id))
743
+ continue;
744
+ } else continue;
745
+ if (o.geometry.type === "RECTANGLE") {
746
+ const I = c.imageToViewportRectangle(o.geometry.x, o.geometry.y, o.geometry.w, o.geometry.h), R = e.get(a).viewport.viewportToViewerElementRectangle(I);
747
+ u.push({
748
+ id: o.id,
749
+ type: "RECTANGLE",
750
+ rect: {
751
+ x: R.x,
752
+ y: R.y,
753
+ width: R.width,
754
+ height: R.height
755
+ },
756
+ isSearchHit: o.isSearchHit,
757
+ tooltip: o.body.value
758
+ });
759
+ } else if (o.geometry.type === "POLYGON") {
760
+ const I = o.geometry.points.map((y) => {
761
+ const D = c.imageToViewportCoordinates(new Fe.Point(y[0], y[1])), m = e.get(a).viewport.viewportToViewerElementCoordinates(D);
762
+ return [m.x, m.y];
763
+ });
764
+ let R = 1 / 0, j = 1 / 0, l = -1 / 0, k = -1 / 0;
765
+ for (const [y, D] of I)
766
+ R = Math.min(R, y), j = Math.min(j, D), l = Math.max(l, y), k = Math.max(k, D);
767
+ const b = I.map(([y, D]) => [y - R, D - j]);
768
+ u.push({
769
+ id: o.id,
770
+ type: "POLYGON",
771
+ bounds: { x: R, y: j, width: l - R, height: k - j },
772
+ points: b,
773
+ isSearchHit: o.isSearchHit,
774
+ tooltip: o.body.value
775
+ });
776
+ }
777
+ }
778
+ return u;
779
+ });
780
+ lt(() => {
781
+ if (e.get(i))
782
+ return e.set(
783
+ a,
784
+ Fe({
785
+ element: e.get(i),
786
+ tileSources: null,
787
+ // Will be set via effect
788
+ prefixUrl: "",
789
+ // No navigation UI images needed
790
+ showNavigationControl: !1,
791
+ showHomeControl: !1,
792
+ showFullPageControl: !1,
793
+ showSequenceControl: !1,
794
+ showZoomControl: !1,
795
+ showRotationControl: !1,
796
+ animationTime: 0.5,
797
+ springStiffness: 7,
798
+ zoomPerClick: 2
799
+ }),
800
+ !0
801
+ ), r().notifyOSDReady(e.get(a)), () => {
802
+ var c;
803
+ (c = e.get(a)) == null || c.destroy(), r().osdViewer = null;
804
+ };
805
+ }), e.user_effect(() => {
806
+ if (!e.get(a)) return;
807
+ const c = () => {
808
+ e.update(M);
809
+ };
810
+ return e.get(a).addHandler("open", c), e.get(a).addHandler("animation", c), e.get(a).addHandler("resize", c), e.get(a).addHandler("rotate", c), e.get(a).world.addHandler("add-item", c), e.get(a).world.addHandler("remove-item", c), () => {
811
+ e.get(a).removeHandler("open", c), e.get(a).removeHandler("animation", c), e.get(a).removeHandler("resize", c), e.get(a).removeHandler("rotate", c), e.get(a).world.removeHandler("add-item", c), e.get(a).world.removeHandler("remove-item", c);
812
+ };
813
+ }), e.user_effect(() => {
814
+ !e.get(a) || !s() || e.get(a).open(s());
815
+ });
816
+ var L = {
817
+ get tileSources() {
818
+ return s();
819
+ },
820
+ set tileSources(c) {
821
+ s(c), e.flush();
822
+ },
823
+ get viewerState() {
824
+ return r();
825
+ },
826
+ set viewerState(c) {
827
+ r(c), e.flush();
828
+ }
829
+ }, d = Et(), g = e.child(d);
830
+ e.bind_this(g, (c) => e.set(i, c), () => e.get(i));
831
+ var p = e.sibling(g, 2);
832
+ return e.each(p, 17, () => e.get(T), (c) => c.id, (c, u) => {
833
+ var o = e.comment(), I = e.first_child(o);
834
+ {
835
+ var R = (l) => {
836
+ var k = Lt();
837
+ e.template_effect(() => {
838
+ e.set_class(k, 1, `absolute border-2 transition-colors cursor-pointer pointer-events-auto ${e.get(u).isSearchHit ? "border-yellow-400 bg-yellow-400/40 hover:bg-yellow-400/60" : "border-red-500 bg-red-500/20 hover:bg-red-500/40"}`), e.set_style(k, `
839
+ left: ${e.get(u).rect.x ?? ""}px;
840
+ top: ${e.get(u).rect.y ?? ""}px;
841
+ width: ${e.get(u).rect.width ?? ""}px;
842
+ height: ${e.get(u).rect.height ?? ""}px;
843
+ `), e.set_attribute(k, "title", e.get(u).tooltip);
844
+ }), e.append(l, k);
845
+ }, j = (l) => {
846
+ var k = e.comment(), b = e.first_child(k);
847
+ {
848
+ var y = (D) => {
849
+ var m = Dt(), h = e.child(m), N = e.child(h, !0);
850
+ e.reset(h);
851
+ var Q = e.sibling(h);
852
+ e.reset(m), e.template_effect(
853
+ (v) => {
854
+ e.set_style(m, `
855
+ left: ${e.get(u).bounds.x ?? ""}px;
856
+ top: ${e.get(u).bounds.y ?? ""}px;
857
+ width: ${e.get(u).bounds.width ?? ""}px;
858
+ height: ${e.get(u).bounds.height ?? ""}px;
859
+ `), e.set_text(N, e.get(u).tooltip), e.set_attribute(Q, "points", v), e.set_class(Q, 0, `cursor-pointer transition-colors ${e.get(u).isSearchHit ? "fill-yellow-400/40 stroke-yellow-400 hover:fill-yellow-400/60" : "fill-red-500/20 stroke-red-500 hover:fill-red-500/40"}`);
860
+ },
861
+ [() => e.get(u).points.map((v) => v.join(",")).join(" ")]
862
+ ), e.append(D, m);
863
+ };
864
+ e.if(
865
+ b,
866
+ (D) => {
867
+ e.get(u).type === "POLYGON" && D(y);
868
+ },
869
+ !0
870
+ );
871
+ }
872
+ e.append(l, k);
873
+ };
874
+ e.if(I, (l) => {
875
+ e.get(u).type === "RECTANGLE" ? l(R) : l(j, !1);
876
+ });
877
+ }
878
+ e.append(c, o);
879
+ }), e.reset(d), e.append(n, d), e.pop(L);
880
+ }
881
+ e.create_custom_element(We, { tileSources: {}, viewerState: {} }, [], [], !0);
882
+ const Gt = "en";
883
+ let F = () => Gt;
884
+ const Rt = /* @__NO_SIDE_EFFECTS__ */ () => "Hello World", Ot = /* @__NO_SIDE_EFFECTS__ */ () => "Search", Ht = /* @__NO_SIDE_EFFECTS__ */ () => "Close Search", Ft = /* @__NO_SIDE_EFFECTS__ */ () => "Search content...", Vt = /* @__NO_SIDE_EFFECTS__ */ (n) => `No results found for "${n.query}"`, Bt = /* @__NO_SIDE_EFFECTS__ */ () => "Enter a search term to find occurrences within this manifest.", Nt = /* @__NO_SIDE_EFFECTS__ */ (n) => `${n.count} Results`, Yt = /* @__NO_SIDE_EFFECTS__ */ () => "Manifest Metadata", Xt = /* @__NO_SIDE_EFFECTS__ */ () => "Loading...", qt = /* @__NO_SIDE_EFFECTS__ */ () => "Attribution", Qt = /* @__NO_SIDE_EFFECTS__ */ () => "License", Wt = /* @__NO_SIDE_EFFECTS__ */ () => "Close", Ut = /* @__NO_SIDE_EFFECTS__ */ () => "Menu", Kt = /* @__NO_SIDE_EFFECTS__ */ () => "Search", Jt = /* @__NO_SIDE_EFFECTS__ */ () => "Toggle Search", Zt = /* @__NO_SIDE_EFFECTS__ */ () => "Hide Gallery", es = /* @__NO_SIDE_EFFECTS__ */ () => "Show Gallery", ts = /* @__NO_SIDE_EFFECTS__ */ () => "Exit Full Screen", ss = /* @__NO_SIDE_EFFECTS__ */ () => "Enter Full Screen", ns = /* @__NO_SIDE_EFFECTS__ */ () => "Hide Annotations", rs = /* @__NO_SIDE_EFFECTS__ */ () => "Show Annotations", as = /* @__NO_SIDE_EFFECTS__ */ () => "Toggle Annotations", is = /* @__NO_SIDE_EFFECTS__ */ () => "Metadata", os = /* @__NO_SIDE_EFFECTS__ */ () => "Toggle Metadata", ls = /* @__NO_SIDE_EFFECTS__ */ () => "Hide All Annotations", cs = /* @__NO_SIDE_EFFECTS__ */ () => "Show All Annotations", ds = /* @__NO_SIDE_EFFECTS__ */ (n) => `${n.count} Annotations`, gs = /* @__NO_SIDE_EFFECTS__ */ (n) => `(${n.count} visible)`, us = /* @__NO_SIDE_EFFECTS__ */ () => "(No content)", fs = /* @__NO_SIDE_EFFECTS__ */ () => "No annotations available.", hs = /* @__NO_SIDE_EFFECTS__ */ () => "Previous Canvas", vs = /* @__NO_SIDE_EFFECTS__ */ () => "Next Canvas", ps = /* @__NO_SIDE_EFFECTS__ */ () => "Docs", ms = /* @__NO_SIDE_EFFECTS__ */ () => "IIIF Manifest:", _s = /* @__NO_SIDE_EFFECTS__ */ () => "Enter IIIF manifest URL", bs = /* @__NO_SIDE_EFFECTS__ */ () => "Load", ys = /* @__NO_SIDE_EFFECTS__ */ () => "GitHub", xs = /* @__NO_SIDE_EFFECTS__ */ () => "Hallo Welt", ws = /* @__NO_SIDE_EFFECTS__ */ () => "Suche", Ss = /* @__NO_SIDE_EFFECTS__ */ () => "Suche schließen", As = /* @__NO_SIDE_EFFECTS__ */ () => "Inhalt durchsuchen...", Is = /* @__NO_SIDE_EFFECTS__ */ (n) => `Keine Ergebnisse für "${n.query}" gefunden`, $s = /* @__NO_SIDE_EFFECTS__ */ () => "Geben Sie einen Suchbegriff ein, um Vorkommen in diesem Manifest zu finden.", Ts = /* @__NO_SIDE_EFFECTS__ */ (n) => `${n.count} Ergebnisse`, ks = /* @__NO_SIDE_EFFECTS__ */ () => "Manifest-Metadaten", Ps = /* @__NO_SIDE_EFFECTS__ */ () => "Lädt...", Ms = /* @__NO_SIDE_EFFECTS__ */ () => "Quellenangabe", Cs = /* @__NO_SIDE_EFFECTS__ */ () => "Lizenz", js = /* @__NO_SIDE_EFFECTS__ */ () => "Schließen", zs = /* @__NO_SIDE_EFFECTS__ */ () => "Menü", Ls = /* @__NO_SIDE_EFFECTS__ */ () => "Suche", Ds = /* @__NO_SIDE_EFFECTS__ */ () => "Suche umschalten", Es = /* @__NO_SIDE_EFFECTS__ */ () => "Galerie ausblenden", Gs = /* @__NO_SIDE_EFFECTS__ */ () => "Galerie einblenden", Rs = /* @__NO_SIDE_EFFECTS__ */ () => "Vollbildmodus beenden", Os = /* @__NO_SIDE_EFFECTS__ */ () => "Vollbildmodus", Hs = /* @__NO_SIDE_EFFECTS__ */ () => "Annotationen ausblenden", Fs = /* @__NO_SIDE_EFFECTS__ */ () => "Annotationen einblenden", Vs = /* @__NO_SIDE_EFFECTS__ */ () => "Annotationen umschalten", Bs = /* @__NO_SIDE_EFFECTS__ */ () => "Metadaten", Ns = /* @__NO_SIDE_EFFECTS__ */ () => "Metadaten umschalten", Ys = /* @__NO_SIDE_EFFECTS__ */ () => "Alle Annotationen ausblenden", Xs = /* @__NO_SIDE_EFFECTS__ */ () => "Alle Annotationen einblenden", qs = /* @__NO_SIDE_EFFECTS__ */ (n) => `${n.count} Annotationen`, Qs = /* @__NO_SIDE_EFFECTS__ */ (n) => `(${n.count} sichtbar)`, Ws = /* @__NO_SIDE_EFFECTS__ */ () => "(Kein Inhalt)", Us = /* @__NO_SIDE_EFFECTS__ */ () => "Keine Annotationen verfügbar.", Ks = /* @__NO_SIDE_EFFECTS__ */ () => "Vorheriges Canvas", Js = /* @__NO_SIDE_EFFECTS__ */ () => "Nächstes Canvas", Zs = /* @__NO_SIDE_EFFECTS__ */ () => "Doku", en = /* @__NO_SIDE_EFFECTS__ */ () => "IIIF-Manifest:", tn = /* @__NO_SIDE_EFFECTS__ */ () => "IIIF-Manifest-URL eingeben", sn = /* @__NO_SIDE_EFFECTS__ */ () => "Laden", nn = /* @__NO_SIDE_EFFECTS__ */ () => "GitHub", rn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
885
+ de: xs,
886
+ en: Rt
887
+ })[t.languageTag ?? F()](), an = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
888
+ de: ws,
889
+ en: Ot
890
+ })[t.languageTag ?? F()](), on = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
891
+ de: Ss,
892
+ en: Ht
893
+ })[t.languageTag ?? F()](), ln = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
894
+ de: As,
895
+ en: Ft
896
+ })[t.languageTag ?? F()](), cn = /* @__NO_SIDE_EFFECTS__ */ (n, t = {}) => ({
897
+ de: Is,
898
+ en: Vt
899
+ })[t.languageTag ?? F()](n), dn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
900
+ de: $s,
901
+ en: Bt
902
+ })[t.languageTag ?? F()](), gn = /* @__NO_SIDE_EFFECTS__ */ (n, t = {}) => ({
903
+ de: Ts,
904
+ en: Nt
905
+ })[t.languageTag ?? F()](n), un = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
906
+ de: ks,
907
+ en: Yt
908
+ })[t.languageTag ?? F()](), fn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
909
+ de: Ps,
910
+ en: Xt
911
+ })[t.languageTag ?? F()](), hn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
912
+ de: Ms,
913
+ en: qt
914
+ })[t.languageTag ?? F()](), vn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
915
+ de: Cs,
916
+ en: Qt
917
+ })[t.languageTag ?? F()](), pn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
918
+ de: js,
919
+ en: Wt
920
+ })[t.languageTag ?? F()](), mn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
921
+ de: zs,
922
+ en: Ut
923
+ })[t.languageTag ?? F()](), _n = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
924
+ de: Ls,
925
+ en: Kt
926
+ })[t.languageTag ?? F()](), bn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
927
+ de: Ds,
928
+ en: Jt
929
+ })[t.languageTag ?? F()](), yn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
930
+ de: Es,
931
+ en: Zt
932
+ })[t.languageTag ?? F()](), xn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
933
+ de: Gs,
934
+ en: es
935
+ })[t.languageTag ?? F()](), wn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
936
+ de: Rs,
937
+ en: ts
938
+ })[t.languageTag ?? F()](), Sn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
939
+ de: Os,
940
+ en: ss
941
+ })[t.languageTag ?? F()](), An = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
942
+ de: Hs,
943
+ en: ns
944
+ })[t.languageTag ?? F()](), In = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
945
+ de: Fs,
946
+ en: rs
947
+ })[t.languageTag ?? F()](), $n = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
948
+ de: Vs,
949
+ en: as
950
+ })[t.languageTag ?? F()](), Tn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
951
+ de: Bs,
952
+ en: is
953
+ })[t.languageTag ?? F()](), kn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
954
+ de: Ns,
955
+ en: os
956
+ })[t.languageTag ?? F()](), Pn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
957
+ de: Ys,
958
+ en: ls
959
+ })[t.languageTag ?? F()](), Mn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
960
+ de: Xs,
961
+ en: cs
962
+ })[t.languageTag ?? F()](), Cn = /* @__NO_SIDE_EFFECTS__ */ (n, t = {}) => ({
963
+ de: qs,
964
+ en: ds
965
+ })[t.languageTag ?? F()](n), jn = /* @__NO_SIDE_EFFECTS__ */ (n, t = {}) => ({
966
+ de: Qs,
967
+ en: gs
968
+ })[t.languageTag ?? F()](n), zn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
969
+ de: Ws,
970
+ en: us
971
+ })[t.languageTag ?? F()](), Ln = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
972
+ de: Us,
973
+ en: fs
974
+ })[t.languageTag ?? F()](), Dn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
975
+ de: Ks,
976
+ en: hs
977
+ })[t.languageTag ?? F()](), En = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
978
+ de: Js,
979
+ en: vs
980
+ })[t.languageTag ?? F()](), Gn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
981
+ de: Zs,
982
+ en: ps
983
+ })[t.languageTag ?? F()](), Rn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
984
+ de: en,
985
+ en: ms
986
+ })[t.languageTag ?? F()](), On = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
987
+ de: tn,
988
+ en: _s
989
+ })[t.languageTag ?? F()](), Hn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
990
+ de: sn,
991
+ en: bs
992
+ })[t.languageTag ?? F()](), Fn = /* @__NO_SIDE_EFFECTS__ */ (n = {}, t = {}) => ({
993
+ de: nn,
994
+ en: ys
995
+ })[t.languageTag ?? F()](), Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
996
+ __proto__: null,
997
+ annotations_count: Cn,
998
+ attribution: hn,
999
+ close: pn,
1000
+ docs: Gn,
1001
+ enter_full_screen: Sn,
1002
+ exit_full_screen: wn,
1003
+ github: Fn,
1004
+ hello_world: rn,
1005
+ hide_all_annotations: Pn,
1006
+ hide_annotations: An,
1007
+ hide_gallery: yn,
1008
+ iiif_manifest_label: Rn,
1009
+ license: vn,
1010
+ load: Hn,
1011
+ loading: fn,
1012
+ manifest_placeholder: On,
1013
+ menu: mn,
1014
+ metadata: Tn,
1015
+ metadata_label_fallback: un,
1016
+ next_canvas: En,
1017
+ no_annotations_available: Ln,
1018
+ no_content: zn,
1019
+ previous_canvas: Dn,
1020
+ search: _n,
1021
+ search_panel_close: on,
1022
+ search_panel_instruction: dn,
1023
+ search_panel_no_results: cn,
1024
+ search_panel_placeholder: ln,
1025
+ search_panel_results_count: gn,
1026
+ search_panel_title: an,
1027
+ show_all_annotations: Mn,
1028
+ show_annotations: In,
1029
+ show_gallery: xn,
1030
+ toggle_annotations: $n,
1031
+ toggle_metadata: kn,
1032
+ toggle_search: bn,
1033
+ visible_count: jn
1034
+ }, Symbol.toStringTag, { value: "Module" }));
1035
+ let Ue = e.state(e.proxy(F()));
1036
+ const Bn = {
1037
+ get current() {
1038
+ return e.get(Ue);
1039
+ }
1040
+ }, B = new Proxy(Vn, {
1041
+ get(n, t, s) {
1042
+ return e.get(Ue), Reflect.get(n, t, s);
1043
+ }
1044
+ });
1045
+ var Nn = e.from_html('<div class="select-none absolute left-1/2 -translate-x-1/2 bg-base-200/90 backdrop-blur rounded-full shadow-lg px-4 py-2 flex items-center gap-4 z-10 border border-base-300 transition-all duration-200 bottom-4"><button class="btn btn-circle btn-sm btn-ghost"><!></button> <span class="text-sm font-mono tabular-nums text-nowrap"> </span> <button class="btn btn-circle btn-sm btn-ghost"><!></button></div>');
1046
+ function Ke(n, t) {
1047
+ e.push(t, !0);
1048
+ let s = e.prop(t, "viewerState", 7);
1049
+ var r = {
1050
+ get viewerState() {
1051
+ return s();
1052
+ },
1053
+ set viewerState(L) {
1054
+ s(L), e.flush();
1055
+ }
1056
+ }, i = Nn(), a = e.child(i);
1057
+ a.__click = () => s().previousCanvas();
1058
+ var M = e.child(a);
1059
+ ut(M, { size: 20, weight: "bold" }), e.reset(a);
1060
+ var $ = e.sibling(a, 2), S = e.child($);
1061
+ e.reset($);
1062
+ var w = e.sibling($, 2);
1063
+ w.__click = () => s().nextCanvas();
1064
+ var T = e.child(w);
1065
+ return ft(T, { size: 20, weight: "bold" }), e.reset(w), e.reset(i), e.template_effect(
1066
+ (L, d) => {
1067
+ a.disabled = !s().hasPrevious, e.set_attribute(a, "aria-label", L), e.set_text(S, `${s().currentCanvasIndex + 1} / ${s().canvases.length ?? ""}`), w.disabled = !s().hasNext, e.set_attribute(w, "aria-label", d);
1068
+ },
1069
+ [() => B.previous_canvas(), () => B.next_canvas()]
1070
+ ), e.append(n, i), e.pop(r);
1071
+ }
1072
+ e.delegate(["click"]);
1073
+ e.create_custom_element(Ke, { viewerState: {} }, [], [], !0);
1074
+ var Yn = e.from_html('<span class="text-xs opacity-50 truncate max-w-[150px]"> </span>'), Xn = e.from_html('<button class="w-full text-left p-3 hover:bg-base-300 transition-colors cursor-pointer flex gap-3 group/item items-start focus:outline-none focus:bg-base-300"><div class="btn btn-xs btn-circle btn-ghost mt-0.5 shrink-0 pointer-events-none"><!></div> <div class="flex-1 min-w-0"><div class="flex items-start justify-between"><span class="font-bold text-sm text-primary"></span> <!></div> <div><!></div></div></button>'), qn = e.from_html('<div class="p-4 text-center opacity-50 text-sm">No annotations available.</div>'), Qn = e.from_html('<div class="absolute top-4 right-4 z-500 pointer-events-auto transition-all duration-300"><details class="group relative"><summary class="flex items-center gap-2 bg-base-200/90 backdrop-blur shadow-lg rounded-full px-4 py-2 cursor-pointer list-none hover:bg-base-200 transition-all select-none border border-base-300 pointer-events-auto"><button class="btn btn-xs btn-circle btn-ghost"><!></button> <span class="text-sm font-medium"> <span class="opacity-50 text-xs font-normal ml-1"> </span></span> <!></summary> <div class="absolute right-0 mt-2 w-96 bg-base-200/95 backdrop-blur shadow-xl rounded-box p-0 max-h-[60vh] overflow-y-auto border border-base-300 flex flex-col divide-y divide-base-300"></div></details></div>');
1075
+ function Je(n, t) {
1076
+ e.push(t, !0);
1077
+ const s = ce(ie);
1078
+ let r = e.derived(() => {
1079
+ if (!s.manifestId || !s.canvasId)
1080
+ return [];
1081
+ const d = le.getAnnotations(s.manifestId, s.canvasId), g = s.currentCanvasSearchAnnotations;
1082
+ return [...d, ...g];
1083
+ });
1084
+ function i(d) {
1085
+ return d.id || d["@id"] || (typeof d.getId == "function" ? d.getId() : "") || "";
1086
+ }
1087
+ e.user_effect(() => {
1088
+ if (e.get(r).length > 0) {
1089
+ const d = /* @__PURE__ */ new Set();
1090
+ e.get(r).forEach((g) => {
1091
+ const p = i(g);
1092
+ p && d.add(p);
1093
+ }), s.visibleAnnotationIds = d;
1094
+ } else
1095
+ s.visibleAnnotationIds = /* @__PURE__ */ new Set();
1096
+ });
1097
+ let a = e.derived(() => e.get(r).length === 0 ? !1 : e.get(r).every((d) => {
1098
+ const g = i(d);
1099
+ return !g || s.visibleAnnotationIds.has(g);
1100
+ }));
1101
+ function M(d) {
1102
+ s.visibleAnnotationIds.has(d) ? s.visibleAnnotationIds.delete(d) : s.visibleAnnotationIds.add(d), s.visibleAnnotationIds = new Set(s.visibleAnnotationIds);
1103
+ }
1104
+ function $() {
1105
+ if (e.get(a))
1106
+ s.visibleAnnotationIds = /* @__PURE__ */ new Set();
1107
+ else {
1108
+ const d = /* @__PURE__ */ new Set();
1109
+ e.get(r).forEach((g) => {
1110
+ const p = i(g);
1111
+ p && d.add(p);
1112
+ }), s.visibleAnnotationIds = d;
1113
+ }
1114
+ }
1115
+ let S = e.derived(() => e.get(r).length ? e.get(r).map((d) => {
1116
+ let g = "", p = !1;
1117
+ if (typeof d.getBody == "function") {
1118
+ const c = d.getBody();
1119
+ if (c && c.length) {
1120
+ const u = (o) => {
1121
+ const I = o.getValue ? o.getValue() : null;
1122
+ return I || "";
1123
+ };
1124
+ g = c.map((o) => u(o)).filter(Boolean).join(" "), p = c.some((o) => {
1125
+ const I = o.getFormat ? o.getFormat() : "";
1126
+ return I === "text/html" || I === "application/html";
1127
+ });
1128
+ }
1129
+ if (!g && typeof d.getLabel == "function") {
1130
+ const u = d.getLabel();
1131
+ u && (g = u);
1132
+ }
1133
+ } else {
1134
+ const c = (o) => o && (o.chars || o.value || o["cnt:chars"]) || "", u = (o) => o ? o.format === "text/html" || o.type === "TextualBody" : !1;
1135
+ if (d.resource ? Array.isArray(d.resource) ? (g = d.resource.map((o) => c(o)).join(" "), d.resource.some((o) => u(o)) && (p = !0)) : (g = c(d.resource), u(d.resource) && (p = !0)) : d.body && (Array.isArray(d.body) ? (g = d.body.map((o) => c(o)).join(" "), d.body.some((o) => u(o)) && (p = !0)) : (g = c(d.body), u(d.body) && (p = !0))), !g) {
1136
+ const o = d.label || d.name || d.title;
1137
+ o && (g = Array.isArray(o) ? o.join(" ") : o);
1138
+ }
1139
+ }
1140
+ return {
1141
+ id: i(d),
1142
+ content: g,
1143
+ isHtml: p,
1144
+ label: (typeof d.getLabel == "function" ? d.getLabel() : d.label) || ""
1145
+ };
1146
+ }) : []);
1147
+ var w = e.comment(), T = e.first_child(w);
1148
+ {
1149
+ var L = (d) => {
1150
+ var g = Qn(), p = e.child(g), c = e.child(p), u = e.child(c);
1151
+ u.__click = (m) => {
1152
+ m.preventDefault(), $();
1153
+ };
1154
+ var o = e.child(u);
1155
+ {
1156
+ var I = (m) => {
1157
+ Ve(m, { size: 16, weight: "bold" });
1158
+ }, R = (m) => {
1159
+ Be(m, { size: 16, weight: "bold" });
1160
+ };
1161
+ e.if(o, (m) => {
1162
+ e.get(a) ? m(I) : m(R, !1);
1163
+ });
1164
+ }
1165
+ e.reset(u);
1166
+ var j = e.sibling(u, 2), l = e.child(j), k = e.sibling(l), b = e.child(k, !0);
1167
+ e.reset(k), e.reset(j);
1168
+ var y = e.sibling(j, 2);
1169
+ ht(y, {
1170
+ size: 16,
1171
+ weight: "bold",
1172
+ class: "group-open:rotate-180 transition-transform opacity-80"
1173
+ }), e.reset(c);
1174
+ var D = e.sibling(c, 2);
1175
+ e.each(
1176
+ D,
1177
+ 21,
1178
+ () => e.get(S),
1179
+ e.index,
1180
+ (m, h, N) => {
1181
+ const Q = e.derived(() => s.visibleAnnotationIds.has(e.get(h).id));
1182
+ var v = Xn();
1183
+ v.__click = (x) => {
1184
+ x.preventDefault(), M(e.get(h).id);
1185
+ };
1186
+ var P = e.child(v), z = e.child(P);
1187
+ {
1188
+ var X = (x) => {
1189
+ Ve(x, { size: 16, weight: "bold" });
1190
+ }, q = (x) => {
1191
+ Be(x, { size: 16, weight: "bold" });
1192
+ };
1193
+ e.if(z, (x) => {
1194
+ e.get(Q) ? x(X) : x(q, !1);
1195
+ });
1196
+ }
1197
+ e.reset(P);
1198
+ var V = e.sibling(P, 2), G = e.child(V), Y = e.child(G);
1199
+ Y.textContent = `#${N + 1}`;
1200
+ var K = e.sibling(Y, 2);
1201
+ {
1202
+ var ee = (x) => {
1203
+ var W = Yn(), E = e.child(W, !0);
1204
+ e.reset(W), e.template_effect(() => e.set_text(E, e.get(h).label)), e.append(x, W);
1205
+ };
1206
+ e.if(K, (x) => {
1207
+ e.get(h).label && e.get(h).label !== e.get(h).content && x(ee);
1208
+ });
1209
+ }
1210
+ e.reset(G);
1211
+ var re = e.sibling(G, 2), f = e.child(re);
1212
+ {
1213
+ var _ = (x) => {
1214
+ var W = e.comment(), E = e.first_child(W);
1215
+ e.html(E, () => e.get(h).content), e.append(x, W);
1216
+ }, C = (x) => {
1217
+ var W = e.text();
1218
+ e.template_effect(() => e.set_text(W, e.get(h).content || "(No content)")), e.append(x, W);
1219
+ };
1220
+ e.if(f, (x) => {
1221
+ e.get(h).isHtml ? x(_) : x(C, !1);
1222
+ });
1223
+ }
1224
+ e.reset(re), e.reset(V), e.reset(v), e.template_effect(() => e.set_class(re, 1, `text-sm prose prose-sm max-w-none prose-p:my-0 prose-a:text-blue-500 wrap-break-word text-left ${e.get(Q) ? "" : "opacity-50"}`)), e.append(m, v);
1225
+ },
1226
+ (m) => {
1227
+ var h = qn();
1228
+ e.append(m, h);
1229
+ }
1230
+ ), e.reset(D), e.reset(p), e.reset(g), e.template_effect(
1231
+ (m, h, N) => {
1232
+ e.set_attribute(u, "title", m), e.set_text(l, `${h ?? ""} `), e.set_text(b, N);
1233
+ },
1234
+ [
1235
+ () => e.get(a) ? B.hide_all_annotations() : B.show_all_annotations(),
1236
+ () => B.annotations_count({ count: e.get(r).length }),
1237
+ () => B.visible_count({ count: s.visibleAnnotationIds.size })
1238
+ ]
1239
+ ), e.append(d, g);
1240
+ };
1241
+ e.if(T, (d) => {
1242
+ s.showAnnotations && d(L);
1243
+ });
1244
+ }
1245
+ e.append(n, w), e.pop();
1246
+ }
1247
+ e.delegate(["click"]);
1248
+ e.create_custom_element(Je, {}, [], [], !0);
1249
+ var Wn = e.from_html('<img class="object-contain w-full h-full" loading="lazy" draggable="false"/>'), Un = e.from_html('<span class="opacity-20 text-4xl">?</span>'), Kn = e.from_html('<button><div class="aspect-4/3 bg-base-300 rounded overflow-hidden relative w-full flex items-center justify-center"><!></div> <div class="text-xs font-medium truncate w-full opacity-70 group-hover:opacity-100"><span class="font-bold mr-1"> </span> </div></button>'), Jn = e.from_html('<div class="absolute bottom-0 right-0 w-6 h-6 cursor-se-resize resize-handle bg-accent hover:bg-accent-focus transition-colors z-50" style="clip-path: polygon(100% 0, 0 100%, 100% 100%);" role="button" tabindex="0" aria-label="Resize"></div>'), Zn = e.from_html('<div role="group"><span class="font-bold text-primary opacity-50">Dock Top</span></div> <div role="group"><span class="font-bold text-primary opacity-50">Dock Bottom</span></div> <div role="group"><span class="font-bold text-primary opacity-50 vertical-rl rotate-180" style="writing-mode: vertical-rl;">Dock Left</span></div> <div role="group"><span class="font-bold text-primary opacity-50 vertical-rl rotate-180" style="writing-mode: vertical-rl;">Dock Right</span></div>', 1), er = e.from_html('<div><button class="absolute top-1 right-1 btn btn-error btn-xs btn-circle z-20" aria-label="Close Gallery"><!></button> <div><div role="button" tabindex="0" aria-label="Drag Gallery"><div></div></div></div> <div><div></div></div> <!></div> <!>', 1);
1250
+ function oe(n, t) {
1251
+ e.push(t, !0);
1252
+ const s = ce(ie);
1253
+ let r = e.prop(t, "canvases", 7), i = e.state(!1), a = { x: 0, y: 0, w: 0, h: 0 }, M = e.state(null), $ = e.derived(() => !r() || !Array.isArray(r()) ? [] : r().map((l, k) => {
1254
+ let b = "";
1255
+ try {
1256
+ if (l.getThumbnail) {
1257
+ const y = l.getThumbnail();
1258
+ y && (b = typeof y == "string" ? y : y.id || y["@id"]);
1259
+ }
1260
+ } catch (y) {
1261
+ console.warn("Error getting thumbnail", y);
1262
+ }
1263
+ if (!b) {
1264
+ let y = l.getImages();
1265
+ if ((!y || !y.length) && l.getContent && (y = l.getContent()), y && y.length > 0) {
1266
+ const D = y[0];
1267
+ let m = D.getResource ? D.getResource() : null;
1268
+ if (!m && D.getBody) {
1269
+ const h = D.getBody();
1270
+ Array.isArray(h) && h.length > 0 ? m = h[0] : h && (m = h);
1271
+ }
1272
+ if (m && !m.id && !m.__jsonld && (!m.getServices || m.getServices().length === 0) && (m = null), !m) {
1273
+ const h = D.__jsonld || D;
1274
+ h.body && (m = Array.isArray(h.body) ? h.body[0] : h.body);
1275
+ }
1276
+ if (m) {
1277
+ const N = (() => {
1278
+ let v = [];
1279
+ if (m.getServices && (v = m.getServices()), !v || v.length === 0) {
1280
+ const P = m.__jsonld || m;
1281
+ P.service && (v = Array.isArray(P.service) ? P.service : [P.service]);
1282
+ }
1283
+ return v;
1284
+ })();
1285
+ let Q = !1;
1286
+ if (N.length > 0) {
1287
+ const v = N[0];
1288
+ let P = "";
1289
+ try {
1290
+ if (P = v.getProfile ? v.getProfile() : v.profile || "", typeof P == "object" && P) {
1291
+ const q = P;
1292
+ P = q.value || q.id || q["@id"] || JSON.stringify(q);
1293
+ }
1294
+ } catch {
1295
+ }
1296
+ const z = String(P ?? "").toLowerCase();
1297
+ (z.includes("level0") || z.includes("level-0")) && (Q = !0);
1298
+ const X = v.id || v["@id"];
1299
+ Q || (b = `${X}/full/200,/0/default.jpg`);
1300
+ }
1301
+ if (!b && (b = m.id || m["@id"], !b)) {
1302
+ let v = null;
1303
+ if (D.__jsonld && D.__jsonld.body ? v = D.__jsonld.body : D.body && (v = D.body), v) {
1304
+ const P = Array.isArray(v) ? v[0] : v;
1305
+ b = P.id || P["@id"];
1306
+ }
1307
+ }
1308
+ }
1309
+ }
1310
+ }
1311
+ return {
1312
+ id: l.id,
1313
+ label: l.getLabel().length ? l.getLabel()[0].value : `Canvas ${k + 1}`,
1314
+ src: b,
1315
+ index: k
1316
+ };
1317
+ }));
1318
+ function S(l) {
1319
+ if (!s.isGalleryDragging) return;
1320
+ let k = l.clientX - s.galleryDragOffset.x, b = l.clientY - s.galleryDragOffset.y;
1321
+ const y = Math.max(0, window.innerWidth - s.gallerySize.width), D = Math.max(0, window.innerHeight - s.gallerySize.height);
1322
+ k = Math.max(0, Math.min(k, y)), b = Math.max(0, Math.min(b, D)), s.galleryPosition = { x: k, y: b };
1323
+ const m = document.getElementById("triiiceratops-center-panel");
1324
+ if (m) {
1325
+ const h = m.getBoundingClientRect(), N = l.clientX, Q = l.clientY, v = 60;
1326
+ s.dragOverSide = null, N >= h.left && N <= h.left + v ? s.dragOverSide = "left" : N <= h.right && N >= h.right - v ? s.dragOverSide = "right" : Q >= h.top && Q <= h.top + v ? s.dragOverSide = "top" : Q <= h.bottom && Q >= h.bottom - v && (s.dragOverSide = "bottom");
1327
+ }
1328
+ }
1329
+ function w() {
1330
+ const l = s.dragOverSide;
1331
+ s.isGalleryDragging = !1, s.dragOverSide = null, window.removeEventListener("mousemove", S), window.removeEventListener("mouseup", w), l && (s.dockSide = l);
1332
+ }
1333
+ function T(l) {
1334
+ l.stopPropagation(), e.set(i, !0), a = {
1335
+ x: l.clientX,
1336
+ y: l.clientY,
1337
+ w: s.gallerySize.width,
1338
+ h: s.gallerySize.height
1339
+ }, window.addEventListener("mousemove", L), window.addEventListener("mouseup", d);
1340
+ }
1341
+ function L(l) {
1342
+ if (!e.get(i)) return;
1343
+ const k = l.clientX - a.x, b = l.clientY - a.y;
1344
+ s.gallerySize = {
1345
+ width: Math.max(200, a.w + k),
1346
+ height: Math.max(200, a.h + b)
1347
+ };
1348
+ }
1349
+ function d() {
1350
+ e.set(i, !1), window.removeEventListener("mousemove", L), window.removeEventListener("mouseup", d);
1351
+ }
1352
+ function g(l) {
1353
+ s.canvasId = l;
1354
+ }
1355
+ let p = e.state(e.proxy(s.dockSide));
1356
+ e.user_effect(() => {
1357
+ const l = s.dockSide;
1358
+ e.set(p, l === "none" || l === "top" || l === "bottom" || l === "left" || l === "right" ? l : "none", !0);
1359
+ }), e.user_effect(() => {
1360
+ s.dockSide !== e.get(p) && (s.dockSide = e.get(p), s.isGalleryDockedBottom = e.get(p) === "bottom", s.isGalleryDockedRight = e.get(p) === "right");
1361
+ });
1362
+ let c = e.derived(() => e.get(p) === "top" || e.get(p) === "bottom" || e.get(p) === "none" && s.gallerySize.height < 320);
1363
+ function u(l) {
1364
+ if (!l.target.closest(".resize-handle")) {
1365
+ if (e.get(p) !== "none") {
1366
+ let k = Math.max(0, l.clientX - 150), b = Math.max(0, l.clientY - 20);
1367
+ const y = Math.max(0, window.innerWidth - 300), D = Math.max(0, window.innerHeight - 400);
1368
+ k = Math.min(k, y), b = Math.min(b, D), s.galleryPosition = { x: k, y: b }, s.galleryDragOffset = { x: l.clientX - k, y: l.clientY - b }, e.set(p, "none");
1369
+ } else
1370
+ s.galleryDragOffset = {
1371
+ x: l.clientX - s.galleryPosition.x,
1372
+ y: l.clientY - s.galleryPosition.y
1373
+ };
1374
+ s.isGalleryDragging = !0, window.addEventListener("mousemove", S), window.addEventListener("mouseup", w);
1375
+ }
1376
+ }
1377
+ var o = {
1378
+ get canvases() {
1379
+ return r();
1380
+ },
1381
+ set canvases(l) {
1382
+ r(l), e.flush();
1383
+ }
1384
+ }, I = e.comment(), R = e.first_child(I);
1385
+ {
1386
+ var j = (l) => {
1387
+ var k = er(), b = e.first_child(k), y = e.child(b);
1388
+ y.__click = () => s.toggleThumbnailGallery();
1389
+ var D = e.child(y);
1390
+ Xe(D, { size: 16, weight: "bold" }), e.reset(y);
1391
+ var m = e.sibling(y, 2), h = e.child(m);
1392
+ h.__mousedown = u;
1393
+ var N = e.child(h);
1394
+ e.reset(h), e.reset(m);
1395
+ var Q = e.sibling(m, 2), v = e.child(Q);
1396
+ e.each(v, 21, () => e.get($), e.index, (V, G) => {
1397
+ var Y = Kn();
1398
+ Y.__click = () => g(e.get(G).id);
1399
+ var K = e.child(Y), ee = e.child(K);
1400
+ {
1401
+ var re = (E) => {
1402
+ var O = Wn();
1403
+ e.template_effect(() => {
1404
+ e.set_attribute(O, "src", e.get(G).src), e.set_attribute(O, "alt", e.get(G).label);
1405
+ }), e.append(E, O);
1406
+ }, f = (E) => {
1407
+ var O = Un();
1408
+ e.append(E, O);
1409
+ };
1410
+ e.if(ee, (E) => {
1411
+ e.get(G).src ? E(re) : E(f, !1);
1412
+ });
1413
+ }
1414
+ e.reset(K);
1415
+ var _ = e.sibling(K, 2), C = e.child(_), x = e.child(C);
1416
+ e.reset(C);
1417
+ var W = e.sibling(C);
1418
+ e.reset(_), e.reset(Y), e.template_effect(() => {
1419
+ e.set_class(Y, 1, `group flex flex-col gap-1 p-1 rounded hover:bg-base-200 transition-colors text-left relative shrink-0 ${e.get(c) ? "w-[140px]" : ""} ${s.canvasId === e.get(G).id ? "ring-2 ring-primary bg-primary/5" : ""}`), e.set_attribute(Y, "aria-label", `Select canvas ${e.get(G).label ?? ""}`), e.set_text(x, `${e.get(G).index + 1}.`), e.set_text(W, ` ${e.get(G).label ?? ""}`);
1420
+ }), e.append(V, Y);
1421
+ }), e.reset(v), e.reset(Q);
1422
+ var P = e.sibling(Q, 2);
1423
+ {
1424
+ var z = (V) => {
1425
+ var G = Jn();
1426
+ G.__mousedown = T, e.append(V, G);
1427
+ };
1428
+ e.if(P, (V) => {
1429
+ e.get(p) === "none" && V(z);
1430
+ });
1431
+ }
1432
+ e.reset(b), e.bind_this(b, (V) => e.set(M, V), () => e.get(M));
1433
+ var X = e.sibling(b, 2);
1434
+ {
1435
+ var q = (V) => {
1436
+ var G = Zn(), Y = e.first_child(G), K = e.sibling(Y, 2), ee = e.sibling(K, 2), re = e.sibling(ee, 2);
1437
+ e.template_effect(() => {
1438
+ e.set_class(Y, 1, `absolute top-2 left-2 right-2 h-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-200 ${s.dragOverSide === "top" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`), e.set_class(K, 1, `absolute bottom-2 left-2 right-2 h-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-200 ${s.dragOverSide === "bottom" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`), e.set_class(ee, 1, `absolute top-2 bottom-2 left-2 w-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-200 ${s.dragOverSide === "left" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`), e.set_class(re, 1, `absolute top-2 bottom-2 right-2 w-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-300 ${s.dragOverSide === "right" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`);
1439
+ }), e.append(V, G);
1440
+ };
1441
+ e.if(X, (V) => {
1442
+ s.isGalleryDragging && V(q);
1443
+ });
1444
+ }
1445
+ e.template_effect(() => {
1446
+ e.set_class(b, 1, (e.get(p) !== "none" ? `relative z-50 bg-base-100 shadow-xl border-base-300 flex transition-all duration-200 select-none w-full h-full
1447
+ ${e.get(p) === "bottom" || e.get(p) === "top" ? "flex-row border-t" : ""}
1448
+ ${e.get(p) === "left" || e.get(p) === "right" ? "flex-col border-x" : ""}` : "fixed z-900 bg-base-100 shadow-2xl rounded-lg flex flex-col border border-base-300 overflow-hidden select-none") + (s.isGalleryDragging ? " pointer-events-none opacity-80" : "")), e.set_style(b, e.get(p) !== "none" ? "" : `left: ${s.galleryPosition.x}px; top: ${s.galleryPosition.y}px; width: ${s.gallerySize.width}px; height: ${s.gallerySize.height}px;`), e.set_class(m, 1, "bg-base-100 flex shrink-0 select-none relative " + (e.get(p) === "bottom" || e.get(p) === "top" ? "flex-row h-full items-center border-r border-base-200" : "flex-col w-full border-b border-base-200")), e.set_class(h, 1, "cursor-move flex items-center justify-center hover:bg-base-200/50 active:bg-base-200 transition-colors " + (e.get(p) === "bottom" || e.get(p) === "top" ? "w-8 h-full" : "h-6 w-full")), e.set_class(N, 1, "bg-base-300 rounded-full " + (e.get(p) === "bottom" || e.get(p) === "top" ? "w-1.5 h-12" : "w-12 h-1.5")), e.set_class(Q, 1, `flex-1 p-1 bg-base-100 ${e.get(c) ? "overflow-x-auto overflow-y-hidden" : "overflow-y-auto overflow-x-hidden"}`), e.set_class(v, 1, e.clsx(e.get(c) ? "flex flex-row gap-2 h-full items-center" : "grid gap-2")), e.set_style(v, e.get(c) ? "" : "grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));");
1449
+ }), e.append(l, k);
1450
+ };
1451
+ e.if(R, (l) => {
1452
+ s.showThumbnailGallery && l(j);
1453
+ });
1454
+ }
1455
+ return e.append(n, I), e.pop(o);
1456
+ }
1457
+ e.delegate(["click", "mousedown"]);
1458
+ e.create_custom_element(oe, { canvases: {} }, [], [], !0);
1459
+ var tr = e.from_html('<div class="fab fab-flower fab-top-left absolute z-600 pointer-events-auto flex-col items-end transition-all duration-300 bottom-6 right-6"><div class="tooltip tooltip-left"><div tabindex="0" role="button" class="btn btn-lg btn-primary btn-circle shadow-xl"><span class="sr-only"> </span> <!></div></div> <div class="fab-close tooltip tooltip-top"><button><!></button></div> <div class="tooltip tooltip-left"><button><!></button></div> <div class="tooltip tooltip-left"><button><!></button></div> <div class="tooltip tooltip-top"><button><!></button></div> <div class="tooltip tooltip-top"><button><!></button></div></div>');
1460
+ function Ze(n, t) {
1461
+ e.push(t, !1);
1462
+ const s = ce(ie);
1463
+ e.init();
1464
+ var r = tr(), i = e.child(r), a = e.child(i), M = e.child(a), $ = e.child(M, !0);
1465
+ e.reset(M);
1466
+ var S = e.sibling(M, 2);
1467
+ bt(S, { size: 32, weight: "bold" }), e.reset(a), e.reset(i);
1468
+ var w = e.sibling(i, 2), T = e.child(w);
1469
+ T.__click = () => s.toggleSearchPanel();
1470
+ var L = e.child(T);
1471
+ qe(L, { size: 28, weight: "bold" }), e.reset(T), e.reset(w);
1472
+ var d = e.sibling(w, 2), g = e.child(d);
1473
+ g.__click = () => s.toggleThumbnailGallery();
1474
+ var p = e.child(g);
1475
+ yt(p, { size: 28, weight: "bold" }), e.reset(g), e.reset(d);
1476
+ var c = e.sibling(d, 2), u = e.child(c);
1477
+ u.__click = () => s.toggleFullScreen();
1478
+ var o = e.child(u);
1479
+ {
1480
+ var I = (m) => {
1481
+ pt(m, { size: 28, weight: "bold" });
1482
+ }, R = (m) => {
1483
+ mt(m, { size: 28, weight: "bold" });
1484
+ };
1485
+ e.if(o, (m) => {
1486
+ s.isFullScreen ? m(I) : m(R, !1);
1487
+ });
1488
+ }
1489
+ e.reset(u), e.reset(c);
1490
+ var j = e.sibling(c, 2), l = e.child(j);
1491
+ l.__click = () => s.toggleAnnotations();
1492
+ var k = e.child(l);
1493
+ vt(k, { size: 28, weight: "bold" }), e.reset(l), e.reset(j);
1494
+ var b = e.sibling(j, 2), y = e.child(b);
1495
+ y.__click = () => s.toggleMetadataDialog();
1496
+ var D = e.child(y);
1497
+ _t(D, { size: 28, weight: "bold" }), e.reset(y), e.reset(b), e.reset(r), e.template_effect(
1498
+ (m, h, N, Q, v, P, z, X, q, V, G) => {
1499
+ e.set_attribute(i, "data-tip", m), e.set_text($, h), e.set_attribute(w, "data-tip", N), e.set_attribute(T, "aria-label", Q), e.set_class(T, 1, e.clsx([
1500
+ "btn btn-circle btn-lg shadow-lg",
1501
+ s.showSearchPanel && "btn-primary",
1502
+ !s.showSearchPanel && "btn-neutral"
1503
+ ])), e.set_attribute(d, "data-tip", v), e.set_attribute(g, "aria-label", P), e.set_class(g, 1, `btn btn-lg btn-circle shadow-lg ${s.showThumbnailGallery ? "btn-info" : "btn-neutral"}`), e.set_attribute(c, "data-tip", z), e.set_class(u, 1, `btn btn-circle btn-lg shadow-lg transition-all duration-300 ease-out ${s.isFullScreen ? "btn-warning" : "btn-neutral"}`), e.set_attribute(j, "data-tip", X), e.set_attribute(l, "aria-label", q), e.set_class(l, 1, `btn btn-lg btn-circle shadow-lg ${s.showAnnotations ? "btn-error" : "btn-neutral"}`), e.set_attribute(b, "data-tip", V), e.set_attribute(y, "aria-label", G), e.set_class(y, 1, `btn btn-lg btn-circle shadow-lg ${s.showMetadataDialog ? "btn-info" : "btn-neutral"}`);
1504
+ },
1505
+ [
1506
+ () => B.menu(),
1507
+ () => B.menu(),
1508
+ () => B.search(),
1509
+ () => B.toggle_search(),
1510
+ () => s.showThumbnailGallery ? B.hide_gallery() : B.show_gallery(),
1511
+ () => s.showThumbnailGallery ? B.hide_gallery() : B.show_gallery(),
1512
+ () => s.isFullScreen ? B.exit_full_screen() : B.enter_full_screen(),
1513
+ () => s.showAnnotations ? B.hide_annotations() : B.show_annotations(),
1514
+ () => B.toggle_annotations(),
1515
+ () => B.metadata(),
1516
+ () => B.toggle_metadata()
1517
+ ]
1518
+ ), e.append(n, r), e.pop();
1519
+ }
1520
+ e.delegate(["click"]);
1521
+ e.create_custom_element(Ze, {}, [], [], !0);
1522
+ var sr = e.from_html('<div class="tooltip tooltip-right"><button><!></button></div>'), nr = e.from_html('<div class="absolute left-6 bottom-6 z-50 pointer-events-auto flex flex-col items-start transition-all duration-300"><div></div> <div class="tooltip tooltip-right" data-tip="Plugins"><button aria-label="Plugins"><!></button></div></div>');
1523
+ function et(n, t) {
1524
+ e.push(t, !0);
1525
+ const s = ce(ie);
1526
+ let r = e.derived(() => [...s.pluginMenuButtons].sort((w, T) => (w.order ?? 100) - (T.order ?? 100))), i = e.state(!1);
1527
+ function a() {
1528
+ e.set(i, !e.get(i));
1529
+ }
1530
+ var M = e.comment(), $ = e.first_child(M);
1531
+ {
1532
+ var S = (w) => {
1533
+ var T = nr(), L = e.child(T);
1534
+ e.each(L, 21, () => e.get(r), (o) => o.id, (o, I) => {
1535
+ const R = e.derived(() => e.get(I).icon);
1536
+ var j = sr(), l = e.child(j);
1537
+ l.__click = () => {
1538
+ e.get(I).onClick(), e.set(i, !1);
1539
+ };
1540
+ var k = e.child(l);
1541
+ e.component(k, () => e.get(R), (b, y) => {
1542
+ y(b, { size: 28, weight: "bold" });
1543
+ }), e.reset(l), e.reset(j), e.template_effect(
1544
+ (b) => {
1545
+ e.set_attribute(j, "data-tip", e.get(I).tooltip), e.set_attribute(l, "aria-label", e.get(I).tooltip), e.set_class(l, 1, `btn btn-lg btn-circle shadow-lg ${b ?? ""}`);
1546
+ },
1547
+ [
1548
+ () => {
1549
+ var b, y;
1550
+ return (y = (b = e.get(I)).isActive) != null && y.call(b) ? e.get(I).activeClass ?? "btn-primary" : "btn-neutral";
1551
+ }
1552
+ ]
1553
+ ), e.append(o, j);
1554
+ }), e.reset(L);
1555
+ var d = e.sibling(L, 2), g = e.child(d);
1556
+ g.__click = a;
1557
+ var p = e.child(g);
1558
+ {
1559
+ var c = (o) => {
1560
+ Xe(o, { size: 28, weight: "bold" });
1561
+ }, u = (o) => {
1562
+ xt(o, { size: 28, weight: "bold" });
1563
+ };
1564
+ e.if(p, (o) => {
1565
+ e.get(i) ? o(c) : o(u, !1);
1566
+ });
1567
+ }
1568
+ e.reset(g), e.reset(d), e.reset(T), e.template_effect(() => {
1569
+ e.set_class(L, 1, `flex flex-col-reverse gap-3 mb-3 transition-all duration-300 origin-bottom ${e.get(i) ? "opacity-100 translate-y-0 scale-100" : "opacity-0 translate-y-4 scale-90 pointer-events-none"}`), e.set_class(g, 1, `btn btn-lg btn-secondary btn-circle shadow-xl transition-transform duration-300 ${e.get(i) ? "rotate-90" : ""}`);
1570
+ }), e.append(w, T);
1571
+ };
1572
+ e.if($, (w) => {
1573
+ e.get(r).length > 0 && w(S);
1574
+ });
1575
+ }
1576
+ e.append(n, M), e.pop();
1577
+ }
1578
+ e.delegate(["click"]);
1579
+ e.create_custom_element(et, {}, [], [], !0);
1580
+ var rr = e.from_html('<div class="mb-6 prose"><p><!></p></div>'), ar = e.from_html('<dt class="font-bold text-lg opacity-70 mt-6"> </dt> <dd class="text-sm ps-2"><!></dd>', 1), ir = e.from_html('<dt class="font-bold text-lg opacity-70 mt-6"> </dt> <dd class="text-sm ps-2"><a target="_blank" rel="noreferrer" class="link link-primary break-all"> </a></dd>', 1), or = e.from_html('<dt class="font-bold text-lg opacity-70 mt-6"> </dt> <dd class="text-sm ps-2"><!></dd>', 1), lr = e.from_html('<dialog class="modal"><div class="modal-box w-11/12 max-w-5xl"><form method="dialog"><button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button></form> <h3 class="font-bold text-lg mb-4"> </h3> <div class="py-4 overflow-y-auto max-h-[70vh]"><!> <dl class="grid grid-cols-1 md:grid-cols-[200px_1fr]"><!> <!> <!></dl></div> <div class="modal-action"><form method="dialog"><button class="btn"> </button></form></div></div> <form method="dialog" class="modal-backdrop"><button> </button></form></dialog>');
1581
+ function tt(n, t) {
1582
+ e.push(t, !0);
1583
+ const s = ce(ie);
1584
+ let r = e.derived(() => s.manifest), i = e.derived(() => {
1585
+ const v = Bn.current;
1586
+ if (!e.get(r)) return [];
1587
+ const P = e.get(r).getMetadata();
1588
+ return P ? P.map((z) => {
1589
+ let X = "", q = "";
1590
+ const V = (G) => {
1591
+ if (typeof G == "string") return G;
1592
+ if (Array.isArray(G)) {
1593
+ let Y = G.find((K) => K.locale === v || K.language === v);
1594
+ return Y || (Y = G.find((K) => K.locale === "en" || K.language === "en")), Y || (Y = G.find((K) => !K.locale && !K.language)), Y || (Y = G[0]), Y ? Y.value : "";
1595
+ }
1596
+ return String(G);
1597
+ };
1598
+ return z.getLabel ? X = V(z.getLabel()) : z.label && (X = V(z.label)), z.getValue ? q = V(z.getValue()) : z.value && (q = V(z.value)), { label: X, value: q };
1599
+ }) : [];
1600
+ }), a = e.derived(() => e.get(r) ? e.get(r).getDescription() : ""), M = e.derived(() => {
1601
+ var v;
1602
+ return e.get(r) ? (v = e.get(r).getRequiredStatement()) == null ? void 0 : v.getValue() : "";
1603
+ }), $ = e.derived(() => e.get(r) ? e.get(r).getLicense() : "");
1604
+ var S = lr(), w = e.child(S), T = e.child(w), L = e.child(T);
1605
+ L.__click = () => s.toggleMetadataDialog(), e.reset(T);
1606
+ var d = e.sibling(T, 2), g = e.child(d, !0);
1607
+ e.reset(d);
1608
+ var p = e.sibling(d, 2), c = e.child(p);
1609
+ {
1610
+ var u = (v) => {
1611
+ var P = rr(), z = e.child(P), X = e.child(z);
1612
+ e.html(X, () => e.get(a)), e.reset(z), e.reset(P), e.append(v, P);
1613
+ };
1614
+ e.if(c, (v) => {
1615
+ e.get(a) && v(u);
1616
+ });
1617
+ }
1618
+ var o = e.sibling(c, 2), I = e.child(o);
1619
+ {
1620
+ var R = (v) => {
1621
+ var P = ar(), z = e.first_child(P), X = e.child(z, !0);
1622
+ e.reset(z);
1623
+ var q = e.sibling(z, 2), V = e.child(q);
1624
+ e.html(V, () => e.get(M)), e.reset(q), e.template_effect((G) => e.set_text(X, G), [() => B.attribution()]), e.append(v, P);
1625
+ };
1626
+ e.if(I, (v) => {
1627
+ e.get(M) && v(R);
1628
+ });
1629
+ }
1630
+ var j = e.sibling(I, 2);
1631
+ {
1632
+ var l = (v) => {
1633
+ var P = ir(), z = e.first_child(P), X = e.child(z, !0);
1634
+ e.reset(z);
1635
+ var q = e.sibling(z, 2), V = e.child(q), G = e.child(V, !0);
1636
+ e.reset(V), e.reset(q), e.template_effect(
1637
+ (Y) => {
1638
+ e.set_text(X, Y), e.set_attribute(V, "href", e.get($)), e.set_text(G, e.get($));
1639
+ },
1640
+ [() => B.license()]
1641
+ ), e.append(v, P);
1642
+ };
1643
+ e.if(j, (v) => {
1644
+ e.get($) && v(l);
1645
+ });
1646
+ }
1647
+ var k = e.sibling(j, 2);
1648
+ e.each(k, 17, () => e.get(i), e.index, (v, P) => {
1649
+ var z = or(), X = e.first_child(z), q = e.child(X, !0);
1650
+ e.reset(X);
1651
+ var V = e.sibling(X, 2), G = e.child(V);
1652
+ e.html(G, () => e.get(P).value), e.reset(V), e.template_effect(() => e.set_text(q, e.get(P).label)), e.append(v, z);
1653
+ }), e.reset(o), e.reset(p);
1654
+ var b = e.sibling(p, 2), y = e.child(b), D = e.child(y);
1655
+ D.__click = () => s.toggleMetadataDialog();
1656
+ var m = e.child(D, !0);
1657
+ e.reset(D), e.reset(y), e.reset(b), e.reset(w);
1658
+ var h = e.sibling(w, 2), N = e.child(h);
1659
+ N.__click = () => s.toggleMetadataDialog();
1660
+ var Q = e.child(N, !0);
1661
+ e.reset(N), e.reset(h), e.reset(S), e.template_effect(
1662
+ (v, P, z) => {
1663
+ S.open = s.showMetadataDialog, e.set_text(g, v), e.set_text(m, P), e.set_text(Q, z);
1664
+ },
1665
+ [
1666
+ () => e.get(r) ? e.get(r).getLabel().length && e.get(r).getLabel()[0] ? e.get(r).getLabel()[0].value : B.metadata_label_fallback() : B.loading(),
1667
+ () => B.close(),
1668
+ () => B.close()
1669
+ ]
1670
+ ), e.append(n, S), e.pop();
1671
+ }
1672
+ e.delegate(["click"]);
1673
+ e.create_custom_element(tt, {}, [], [], !0);
1674
+ var cr = e.from_html('<span class="loading loading-spinner loading-xs"></span>'), dr = e.from_html('<div class="flex justify-center p-8"><span class="loading loading-spinner loading-lg text-primary"></span></div>'), gr = e.from_html('<div class="text-center opacity-50 p-4"> </div>'), ur = e.from_html('<div class="text-center opacity-50 p-4 text-sm"> </div>'), fr = e.from_html('<div class="leading-relaxed"><span><!></span> <span class="bg-yellow-200 text-yellow-900 font-bold px-0.5 rounded"><!></span> <span><!></span></div>'), hr = e.from_html('<div class="leading-relaxed"> </div>'), vr = e.from_html('<button class="w-full text-left card bg-base-100 shadow hover:shadow-md transition-all p-4 text-sm group border border-transparent hover:border-primary focus:outline-none focus:ring-2 focus:ring-primary"><div class="flex justify-between items-baseline mb-1"><span class="font-bold text-xs opacity-70 bg-base-200 px-1.5 py-0.5 rounded"> </span></div> <!></button>'), pr = e.from_html('<div class="text-xs font-bold opacity-50 uppercase tracking-wider pb-2"> </div> <!>', 1), mr = e.from_html('<div class="h-full w-80 bg-base-200 shadow-2xl z-100 flex flex-col border-l border-base-300" role="dialog"><div class="p-4 bg-base-300 flex justify-between items-center shrink-0"><h2 class="font-bold text-lg"> </h2> <button class="btn btn-sm btn-circle btn-ghost">✕</button></div> <div class="p-4 border-b border-base-300 shrink-0"><div class="join w-full"><input type="text" class="input input-bordered join-item w-full"/> <button class="btn btn-primary join-item"><!></button></div></div> <div class="flex-1 overflow-y-auto p-4 space-y-4"><!></div></div>');
1675
+ function st(n, t) {
1676
+ e.push(t, !0);
1677
+ const s = ce(ie);
1678
+ let r = e.state(e.proxy(s.searchQuery));
1679
+ function i() {
1680
+ s.search(e.get(r));
1681
+ }
1682
+ function a(T) {
1683
+ T.key === "Enter" && i();
1684
+ }
1685
+ function M(T) {
1686
+ const L = s.canvases[T.canvasIndex];
1687
+ L && (s.canvasId = L.id);
1688
+ }
1689
+ var $ = e.comment(), S = e.first_child($);
1690
+ {
1691
+ var w = (T) => {
1692
+ var L = mr(), d = e.child(L), g = e.child(d), p = e.child(g, !0);
1693
+ e.reset(g);
1694
+ var c = e.sibling(g, 2);
1695
+ c.__click = () => s.toggleSearchPanel(), e.reset(d);
1696
+ var u = e.sibling(d, 2), o = e.child(u), I = e.child(o);
1697
+ e.remove_input_defaults(I), I.__keydown = a;
1698
+ var R = e.sibling(I, 2);
1699
+ R.__click = i;
1700
+ var j = e.child(R);
1701
+ {
1702
+ var l = (h) => {
1703
+ var N = cr();
1704
+ e.append(h, N);
1705
+ }, k = (h) => {
1706
+ qe(h, { size: 20, weight: "bold" });
1707
+ };
1708
+ e.if(j, (h) => {
1709
+ s.isSearching ? h(l) : h(k, !1);
1710
+ });
1711
+ }
1712
+ e.reset(R), e.reset(o), e.reset(u);
1713
+ var b = e.sibling(u, 2), y = e.child(b);
1714
+ {
1715
+ var D = (h) => {
1716
+ var N = dr();
1717
+ e.append(h, N);
1718
+ }, m = (h) => {
1719
+ var N = e.comment(), Q = e.first_child(N);
1720
+ {
1721
+ var v = (z) => {
1722
+ var X = gr(), q = e.child(X, !0);
1723
+ e.reset(X), e.template_effect((V) => e.set_text(q, V), [
1724
+ () => B.search_panel_no_results({ query: s.searchQuery })
1725
+ ]), e.append(z, X);
1726
+ }, P = (z) => {
1727
+ var X = e.comment(), q = e.first_child(X);
1728
+ {
1729
+ var V = (Y) => {
1730
+ var K = ur(), ee = e.child(K, !0);
1731
+ e.reset(K), e.template_effect((re) => e.set_text(ee, re), [() => B.search_panel_instruction()]), e.append(Y, K);
1732
+ }, G = (Y) => {
1733
+ var K = pr(), ee = e.first_child(K), re = e.child(ee, !0);
1734
+ e.reset(ee);
1735
+ var f = e.sibling(ee, 2);
1736
+ e.each(f, 17, () => s.searchResults, e.index, (_, C) => {
1737
+ var x = vr();
1738
+ x.__click = () => M(e.get(C));
1739
+ var W = e.child(x), E = e.child(W), O = e.child(E, !0);
1740
+ e.reset(E), e.reset(W);
1741
+ var te = e.sibling(W, 2);
1742
+ {
1743
+ var se = (H) => {
1744
+ var U = fr(), Z = e.child(U), ae = e.child(Z);
1745
+ e.html(ae, () => e.get(C).before), e.reset(Z);
1746
+ var De = e.sibling(Z, 2), nt = e.child(De);
1747
+ e.html(nt, () => e.get(C).match), e.reset(De);
1748
+ var Re = e.sibling(De, 2), rt = e.child(Re);
1749
+ e.html(rt, () => e.get(C).after), e.reset(Re), e.reset(U), e.append(H, U);
1750
+ }, ne = (H) => {
1751
+ var U = hr(), Z = e.child(U, !0);
1752
+ e.reset(U), e.template_effect(() => e.set_text(Z, e.get(C).match)), e.append(H, U);
1753
+ };
1754
+ e.if(te, (H) => {
1755
+ e.get(C).type === "hit" ? H(se) : H(ne, !1);
1756
+ });
1757
+ }
1758
+ e.reset(x), e.template_effect(() => e.set_text(O, e.get(C).canvasLabel)), e.append(_, x);
1759
+ }), e.template_effect((_) => e.set_text(re, _), [
1760
+ () => B.search_panel_results_count({ count: s.searchResults.length })
1761
+ ]), e.append(Y, K);
1762
+ };
1763
+ e.if(
1764
+ q,
1765
+ (Y) => {
1766
+ s.searchResults.length === 0 && !s.searchQuery ? Y(V) : Y(G, !1);
1767
+ },
1768
+ !0
1769
+ );
1770
+ }
1771
+ e.append(z, X);
1772
+ };
1773
+ e.if(
1774
+ Q,
1775
+ (z) => {
1776
+ s.searchResults.length === 0 && s.searchQuery ? z(v) : z(P, !1);
1777
+ },
1778
+ !0
1779
+ );
1780
+ }
1781
+ e.append(h, N);
1782
+ };
1783
+ e.if(y, (h) => {
1784
+ s.isSearching ? h(D) : h(m, !1);
1785
+ });
1786
+ }
1787
+ e.reset(b), e.reset(L), e.template_effect(
1788
+ (h, N, Q, v, P) => {
1789
+ e.set_attribute(L, "aria-label", h), e.set_text(p, N), e.set_attribute(c, "aria-label", Q), e.set_attribute(I, "placeholder", v), e.set_attribute(R, "aria-label", P);
1790
+ },
1791
+ [
1792
+ () => B.search_panel_title(),
1793
+ () => B.search_panel_title(),
1794
+ () => B.search_panel_close(),
1795
+ () => B.search_panel_placeholder(),
1796
+ () => B.search_panel_title()
1797
+ ]
1798
+ ), e.bind_value(I, () => e.get(r), (h) => e.set(r, h)), e.append(T, L);
1799
+ };
1800
+ e.if(S, (T) => {
1801
+ s.showSearchPanel && T(w);
1802
+ });
1803
+ }
1804
+ e.append(n, $), e.pop();
1805
+ }
1806
+ e.delegate(["click", "keydown"]);
1807
+ e.create_custom_element(st, {}, [], [], !0);
1808
+ var _r = e.from_html('<div class="h-full w-[200px] pointer-events-auto relative"><!></div>'), br = e.from_html('<div class="h-full relative pointer-events-auto"><!></div>'), yr = e.from_html('<div class="flex-none h-[140px] w-full pointer-events-auto relative z-20"><!></div>'), xr = e.from_html('<div class="w-full h-full flex items-center justify-center"><span class="loading loading-spinner loading-lg text-primary"></span></div>'), wr = e.from_html('<div class="w-full h-full flex items-center justify-center text-error"> </div>'), Sr = e.from_html('<div class="w-full h-full flex items-center justify-center text-base-content/50">No image found</div>'), Ar = e.from_html('<div class="absolute inset-0 z-40 pointer-events-none"><!></div>'), Ir = e.from_html('<div class="flex-none h-[140px] w-full pointer-events-auto relative z-20"><!></div>'), $r = e.from_html('<div class="relative w-full z-40 pointer-events-auto"><!></div>'), Tr = e.from_html('<div class="h-full relative pointer-events-auto"><!></div>'), kr = e.from_html('<div class="h-full w-[200px] pointer-events-auto relative"><!></div>'), Pr = e.from_html('<div class="h-full relative pointer-events-auto"><!></div>'), Mr = e.from_html('<div id="triiiceratops-viewer" class="flex w-full h-full relative bg-base-100 overflow-hidden"><div class="flex-none flex flex-row z-20 bg-base-200 border-r border-base-300 transition-all"><!> <!></div> <div id="triiiceratops-center-panel" class="flex-1 relative min-w-0 flex flex-col"><!> <div class="flex-1 relative min-h-0 w-full h-full bg-base-100"><!> <!> <!> <!> <!> <!> <!> <!></div> <!> <!></div> <div class="flex-none flex flex-row z-20 bg-base-200 border-l border-base-300 transition-all"><!> <!> <!></div></div>');
1809
+ function Cr(n, t) {
1810
+ e.push(t, !0);
1811
+ let s = e.prop(t, "manifestId", 7), r = e.prop(t, "canvasId", 7), i = e.prop(t, "plugins", 23, () => []);
1812
+ const a = new St(null, r(), i());
1813
+ ct(ie, a), dt(() => {
1814
+ a.destroyAllPlugins();
1815
+ }), e.user_effect(() => {
1816
+ s() && a.setManifest(s());
1817
+ }), e.user_effect(() => {
1818
+ r() && a.setCanvas(r());
1819
+ }), e.user_effect(() => {
1820
+ const f = () => {
1821
+ a.isFullScreen = !!document.fullscreenElement;
1822
+ };
1823
+ return document.addEventListener("fullscreenchange", f), () => {
1824
+ document.removeEventListener("fullscreenchange", f);
1825
+ };
1826
+ });
1827
+ let M = e.derived(() => a.manifest), $ = e.derived(() => a.canvases), S = e.derived(() => a.currentCanvasIndex), w = e.derived(() => {
1828
+ var se, ne;
1829
+ if (!e.get($) || e.get(S) === -1 || !e.get($)[e.get(S)])
1830
+ return (se = e.get(M)) != null && se.isFetching || console.log("TriiiceratopsViewer: No canvas found"), null;
1831
+ const f = e.get($)[e.get(S)];
1832
+ let _ = f.getImages();
1833
+ if ((!_ || !_.length) && f.getContent && (_ = f.getContent()), !_ || !_.length)
1834
+ return f.__jsonld && f.__jsonld.items, (ne = e.get(M)) != null && ne.isFetching || console.log("TriiiceratopsViewer: No images/content in canvas"), null;
1835
+ const C = _[0];
1836
+ let x = C.getResource ? C.getResource() : null;
1837
+ if (!x && C.getBody) {
1838
+ const H = C.getBody();
1839
+ Array.isArray(H) && H.length > 0 ? x = H[0] : H && (x = H);
1840
+ }
1841
+ if (x && !x.id && !x.__jsonld && (!x.getServices || x.getServices().length === 0) && (x = null), !x) {
1842
+ const H = C.__jsonld || C;
1843
+ H.body && (x = Array.isArray(H.body) ? H.body[0] : H.body);
1844
+ }
1845
+ if (!x)
1846
+ return null;
1847
+ const W = (H) => H.id || H["@id"];
1848
+ let E = [];
1849
+ if (x.getServices && (E = x.getServices()), !E.length) {
1850
+ const H = x.__jsonld || x;
1851
+ H.service && (E = Array.isArray(H.service) ? H.service : [H.service]);
1852
+ }
1853
+ if (E.length > 0) {
1854
+ const H = E.find((U) => {
1855
+ const Z = U.getType ? U.getType() : U.type || "", ae = U.getProfile ? U.getProfile() : U.profile || "";
1856
+ return Z === "ImageService1" || Z === "ImageService2" || Z === "ImageService3" || typeof ae == "string" && ae.includes("http://iiif.io/api/image") || typeof ae == "string" && ae === "level0";
1857
+ });
1858
+ if (H) {
1859
+ let U = W(H);
1860
+ return U && !U.endsWith("/info.json") && (U = `${U}/info.json`), U;
1861
+ }
1862
+ }
1863
+ const O = W(x);
1864
+ if (O && O.includes("/iiif/")) {
1865
+ const H = O.split("/"), U = H.findIndex((Z) => Z === "full" || Z.match(/^\d+,\d+,\d+,\d+$/));
1866
+ if (U > 0)
1867
+ return `${H.slice(0, U).join("/")}/info.json`;
1868
+ }
1869
+ return console.log("TriiiceratopsViewer: No service or ID found, returning raw URL"), { type: "image", url: O };
1870
+ });
1871
+ var T = {
1872
+ get manifestId() {
1873
+ return s();
1874
+ },
1875
+ set manifestId(f) {
1876
+ s(f), e.flush();
1877
+ },
1878
+ get canvasId() {
1879
+ return r();
1880
+ },
1881
+ set canvasId(f) {
1882
+ r(f), e.flush();
1883
+ },
1884
+ get plugins() {
1885
+ return i();
1886
+ },
1887
+ set plugins(f = []) {
1888
+ i(f), e.flush();
1889
+ }
1890
+ }, L = Mr(), d = e.child(L), g = e.child(d);
1891
+ {
1892
+ var p = (f) => {
1893
+ var _ = _r(), C = e.child(_);
1894
+ oe(C, {
1895
+ get canvases() {
1896
+ return e.get($);
1897
+ }
1898
+ }), e.reset(_), e.append(f, _);
1899
+ };
1900
+ e.if(g, (f) => {
1901
+ a.showThumbnailGallery && a.dockSide === "left" && f(p);
1902
+ });
1903
+ }
1904
+ var c = e.sibling(g, 2);
1905
+ e.each(c, 17, () => a.pluginPanels, (f) => f.id, (f, _) => {
1906
+ var C = e.comment(), x = e.first_child(C);
1907
+ {
1908
+ var W = (E) => {
1909
+ var O = br(), te = e.child(O);
1910
+ e.component(te, () => e.get(_).component, (se, ne) => {
1911
+ ne(se, e.spread_props(() => e.get(_).props ?? {}));
1912
+ }), e.reset(O), e.append(E, O);
1913
+ };
1914
+ e.if(x, (E) => {
1915
+ e.get(_).isVisible() && e.get(_).position === "left" && E(W);
1916
+ });
1917
+ }
1918
+ e.append(f, C);
1919
+ }), e.reset(d);
1920
+ var u = e.sibling(d, 2), o = e.child(u);
1921
+ {
1922
+ var I = (f) => {
1923
+ var _ = yr(), C = e.child(_);
1924
+ oe(C, {
1925
+ get canvases() {
1926
+ return e.get($);
1927
+ }
1928
+ }), e.reset(_), e.append(f, _);
1929
+ };
1930
+ e.if(o, (f) => {
1931
+ a.showThumbnailGallery && a.dockSide === "top" && f(I);
1932
+ });
1933
+ }
1934
+ var R = e.sibling(o, 2), j = e.child(R);
1935
+ {
1936
+ var l = (f) => {
1937
+ var _ = xr();
1938
+ e.append(f, _);
1939
+ }, k = (f) => {
1940
+ var _ = e.comment(), C = e.first_child(_);
1941
+ {
1942
+ var x = (E) => {
1943
+ var O = wr(), te = e.child(O);
1944
+ e.reset(O), e.template_effect(() => e.set_text(te, `Error: ${e.get(M).error ?? ""}`)), e.append(E, O);
1945
+ }, W = (E) => {
1946
+ var O = e.comment(), te = e.first_child(O);
1947
+ {
1948
+ var se = (H) => {
1949
+ var U = e.comment(), Z = e.first_child(U);
1950
+ e.key(Z, () => e.get(w), (ae) => {
1951
+ We(ae, {
1952
+ get tileSources() {
1953
+ return e.get(w);
1954
+ },
1955
+ get viewerState() {
1956
+ return a;
1957
+ }
1958
+ });
1959
+ }), e.append(H, U);
1960
+ }, ne = (H) => {
1961
+ var U = Sr();
1962
+ e.append(H, U);
1963
+ };
1964
+ e.if(
1965
+ te,
1966
+ (H) => {
1967
+ e.get(w) ? H(se) : H(ne, !1);
1968
+ },
1969
+ !0
1970
+ );
1971
+ }
1972
+ e.append(E, O);
1973
+ };
1974
+ e.if(
1975
+ C,
1976
+ (E) => {
1977
+ var O;
1978
+ (O = e.get(M)) != null && O.error ? E(x) : E(W, !1);
1979
+ },
1980
+ !0
1981
+ );
1982
+ }
1983
+ e.append(f, _);
1984
+ };
1985
+ e.if(j, (f) => {
1986
+ var _;
1987
+ (_ = e.get(M)) != null && _.isFetching ? f(l) : f(k, !1);
1988
+ });
1989
+ }
1990
+ var b = e.sibling(j, 2);
1991
+ Je(b, {});
1992
+ var y = e.sibling(b, 2);
1993
+ tt(y, {});
1994
+ var D = e.sibling(y, 2);
1995
+ Ze(D, {});
1996
+ var m = e.sibling(D, 2);
1997
+ et(m, {});
1998
+ var h = e.sibling(m, 2);
1999
+ e.each(h, 17, () => a.pluginPanels, (f) => f.id, (f, _) => {
2000
+ var C = e.comment(), x = e.first_child(C);
2001
+ {
2002
+ var W = (E) => {
2003
+ var O = Ar(), te = e.child(O);
2004
+ e.component(te, () => e.get(_).component, (se, ne) => {
2005
+ ne(se, e.spread_props(() => e.get(_).props ?? {}));
2006
+ }), e.reset(O), e.append(E, O);
2007
+ };
2008
+ e.if(x, (E) => {
2009
+ e.get(_).isVisible() && e.get(_).position === "overlay" && E(W);
2010
+ });
2011
+ }
2012
+ e.append(f, C);
2013
+ });
2014
+ var N = e.sibling(h, 2);
2015
+ {
2016
+ var Q = (f) => {
2017
+ Ke(f, {
2018
+ get viewerState() {
2019
+ return a;
2020
+ }
2021
+ });
2022
+ };
2023
+ e.if(N, (f) => {
2024
+ e.get($).length > 1 && f(Q);
2025
+ });
2026
+ }
2027
+ var v = e.sibling(N, 2);
2028
+ {
2029
+ var P = (f) => {
2030
+ oe(f, {
2031
+ get canvases() {
2032
+ return e.get($);
2033
+ }
2034
+ });
2035
+ };
2036
+ e.if(v, (f) => {
2037
+ a.showThumbnailGallery && a.dockSide === "none" && f(P);
2038
+ });
2039
+ }
2040
+ e.reset(R);
2041
+ var z = e.sibling(R, 2);
2042
+ {
2043
+ var X = (f) => {
2044
+ var _ = Ir(), C = e.child(_);
2045
+ oe(C, {
2046
+ get canvases() {
2047
+ return e.get($);
2048
+ }
2049
+ }), e.reset(_), e.append(f, _);
2050
+ };
2051
+ e.if(z, (f) => {
2052
+ a.showThumbnailGallery && a.dockSide === "bottom" && f(X);
2053
+ });
2054
+ }
2055
+ var q = e.sibling(z, 2);
2056
+ e.each(q, 17, () => a.pluginPanels, (f) => f.id, (f, _) => {
2057
+ var C = e.comment(), x = e.first_child(C);
2058
+ {
2059
+ var W = (E) => {
2060
+ var O = $r(), te = e.child(O);
2061
+ e.component(te, () => e.get(_).component, (se, ne) => {
2062
+ ne(se, e.spread_props(() => e.get(_).props ?? {}));
2063
+ }), e.reset(O), e.append(E, O);
2064
+ };
2065
+ e.if(x, (E) => {
2066
+ e.get(_).isVisible() && e.get(_).position === "bottom" && E(W);
2067
+ });
2068
+ }
2069
+ e.append(f, C);
2070
+ }), e.reset(u);
2071
+ var V = e.sibling(u, 2), G = e.child(V);
2072
+ {
2073
+ var Y = (f) => {
2074
+ var _ = Tr(), C = e.child(_);
2075
+ st(C, {}), e.reset(_), e.append(f, _);
2076
+ };
2077
+ e.if(G, (f) => {
2078
+ a.showSearchPanel && f(Y);
2079
+ });
2080
+ }
2081
+ var K = e.sibling(G, 2);
2082
+ {
2083
+ var ee = (f) => {
2084
+ var _ = kr(), C = e.child(_);
2085
+ oe(C, {
2086
+ get canvases() {
2087
+ return e.get($);
2088
+ }
2089
+ }), e.reset(_), e.append(f, _);
2090
+ };
2091
+ e.if(K, (f) => {
2092
+ a.showThumbnailGallery && a.dockSide === "right" && f(ee);
2093
+ });
2094
+ }
2095
+ var re = e.sibling(K, 2);
2096
+ return e.each(re, 17, () => a.pluginPanels, (f) => f.id, (f, _) => {
2097
+ var C = e.comment(), x = e.first_child(C);
2098
+ {
2099
+ var W = (E) => {
2100
+ var O = Pr(), te = e.child(O);
2101
+ e.component(te, () => e.get(_).component, (se, ne) => {
2102
+ ne(se, e.spread_props(() => e.get(_).props ?? {}));
2103
+ }), e.reset(O), e.append(E, O);
2104
+ };
2105
+ e.if(x, (E) => {
2106
+ e.get(_).isVisible() && e.get(_).position === "right" && E(W);
2107
+ });
2108
+ }
2109
+ e.append(f, C);
2110
+ }), e.reset(V), e.reset(L), e.append(n, L), e.pop(T);
2111
+ }
2112
+ e.create_custom_element(Cr, { manifestId: {}, canvasId: {}, plugins: {} }, [], [], !0);
2113
+ export {
2114
+ Zr as BasePlugin,
2115
+ wt as ManifestsState,
2116
+ Cr as TriiiceratopsViewer,
2117
+ ie as VIEWER_STATE_KEY,
2118
+ St as ViewerState
2119
+ };