triiiceratops 0.3.4 → 0.4.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.
@@ -1,1722 +0,0 @@
1
- var ke = (s) => {
2
- throw TypeError(s);
3
- };
4
- var He = (s, t, a) => t.has(s) || ke("Cannot " + a);
5
- var z = (s, t, a) => (He(s, t, "read from private field"), a ? a.call(s) : t.get(s)), Y = (s, t, a) => t.has(s) ? ke("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, a);
6
- import "svelte/internal/disclose-version";
7
- import * as e from "svelte/internal/client";
8
- import { onMount as Ne, getContext as xe, setContext as Ve } from "svelte";
9
- import * as Be from "manifesto.js";
10
- import Ce from "openseadragon";
11
- import Oe from "phosphor-svelte/lib/CaretLeft";
12
- import qe from "phosphor-svelte/lib/CaretRight";
13
- import Ye from "phosphor-svelte/lib/CaretDown";
14
- import je from "phosphor-svelte/lib/Eye";
15
- import Le from "phosphor-svelte/lib/EyeSlash";
16
- import Xe from "phosphor-svelte/lib/X";
17
- import "svelte/internal/flags/legacy";
18
- import Qe from "phosphor-svelte/lib/ChatCenteredText";
19
- import Ue from "phosphor-svelte/lib/CornersIn";
20
- import Ke from "phosphor-svelte/lib/CornersOut";
21
- import We from "phosphor-svelte/lib/Info";
22
- import Ee from "phosphor-svelte/lib/MagnifyingGlass";
23
- import Je from "phosphor-svelte/lib/List";
24
- import Ze from "phosphor-svelte/lib/Slideshow";
25
- var re;
26
- class et {
27
- constructor() {
28
- Y(this, re, e.state(e.proxy({})));
29
- }
30
- get manifests() {
31
- return e.get(z(this, re));
32
- }
33
- set manifests(t) {
34
- e.set(z(this, re), t, !0);
35
- }
36
- async fetchManifest(t) {
37
- if (!this.manifests[t]) {
38
- this.manifests[t] = { isFetching: !0 };
39
- try {
40
- const a = await fetch(t);
41
- if (!a.ok)
42
- throw new Error(`HTTP error! status: ${a.status}`);
43
- const n = await a.json(), c = Be.parseManifest(n);
44
- this.manifests[t] = { json: n, manifesto: c, isFetching: !1 };
45
- } catch (a) {
46
- this.manifests[t] = { error: a.message, isFetching: !1 };
47
- }
48
- }
49
- }
50
- getManifest(t) {
51
- const a = this.manifests[t];
52
- return a == null ? void 0 : a.manifesto;
53
- }
54
- async fetchAnnotationList(t) {
55
- if (!this.manifests[t])
56
- try {
57
- const a = await fetch(t);
58
- if (a.ok) {
59
- const n = await a.json();
60
- this.manifests[t] = { json: n };
61
- } else
62
- console.error(`Failed to fetch annotation list: ${t}`);
63
- } catch (a) {
64
- console.error(`Error fetching annotation list: ${t}`, a);
65
- }
66
- }
67
- getCanvases(t) {
68
- const a = this.getManifest(t);
69
- if (!a)
70
- return [];
71
- const n = a.getSequences();
72
- return !n || !n.length ? [] : n[0].getCanvases();
73
- }
74
- getAnnotations(t, a) {
75
- const n = this.getManifest(t);
76
- return n ? n.getSequences()[0].getCanvasById(a) ? this.manualGetAnnotations(t, a) : [] : [];
77
- }
78
- // We can refactor this to use Manifesto's resource handling later if needed.
79
- manualGetAnnotations(t, a) {
80
- const n = this.getManifest(t);
81
- if (!n) return [];
82
- const c = n.getSequences()[0].getCanvasById(a);
83
- if (!c) return [];
84
- const d = c.__jsonld;
85
- let G = [];
86
- const I = (v) => v.resources || v.items || [];
87
- return d.otherContent && d.otherContent.forEach((v) => {
88
- const S = v["@id"] || v.id;
89
- if (S && !v.resources) {
90
- const L = this.manifests[S];
91
- if (L) {
92
- if (L.json) {
93
- const R = I(L.json);
94
- G.push(...R);
95
- }
96
- } else
97
- this.fetchAnnotationList(S);
98
- } else v.resources && G.push(...v.resources);
99
- }), d.annotations && d.annotations.forEach((v) => {
100
- const S = v.id || v["@id"];
101
- if (S && !v.items) {
102
- const L = this.manifests[S];
103
- if (L) {
104
- if (L.json) {
105
- const R = I(L.json);
106
- G.push(...R);
107
- }
108
- } else
109
- this.fetchAnnotationList(S);
110
- } else v.items && G.push(...v.items);
111
- }), G;
112
- }
113
- }
114
- re = new WeakMap();
115
- const ae = new et();
116
- var ie, oe, le, ce, de, ge, ue, fe, he, ve, pe, me, be, _e, ye;
117
- class tt {
118
- constructor(t) {
119
- Y(this, ie, e.state(null));
120
- Y(this, oe, e.state(null));
121
- Y(this, le, e.state(!1));
122
- Y(this, ce, e.state(!1));
123
- Y(this, de, e.state(!1));
124
- Y(this, ge, e.state(!1));
125
- Y(this, ue, e.state(!1));
126
- Y(this, fe, e.state(!1));
127
- Y(this, he, e.state("none"));
128
- Y(this, ve, e.state(e.proxy(/* @__PURE__ */ new Set())));
129
- Y(this, pe, e.state(""));
130
- Y(this, me, e.state(e.proxy([])));
131
- Y(this, be, e.state(!1));
132
- Y(this, _e, e.state(!1));
133
- Y(this, ye, e.state(e.proxy([])));
134
- this.manifestId = t || null, this.manifestId && ae.fetchManifest(this.manifestId);
135
- }
136
- get manifestId() {
137
- return e.get(z(this, ie));
138
- }
139
- set manifestId(t) {
140
- e.set(z(this, ie), t, !0);
141
- }
142
- get canvasId() {
143
- return e.get(z(this, oe));
144
- }
145
- set canvasId(t) {
146
- e.set(z(this, oe), t, !0);
147
- }
148
- get showAnnotations() {
149
- return e.get(z(this, le));
150
- }
151
- set showAnnotations(t) {
152
- e.set(z(this, le), t, !0);
153
- }
154
- get showThumbnailGallery() {
155
- return e.get(z(this, ce));
156
- }
157
- set showThumbnailGallery(t) {
158
- e.set(z(this, ce), t, !0);
159
- }
160
- get isGalleryDockedBottom() {
161
- return e.get(z(this, de));
162
- }
163
- set isGalleryDockedBottom(t) {
164
- e.set(z(this, de), t, !0);
165
- }
166
- get isGalleryDockedRight() {
167
- return e.get(z(this, ge));
168
- }
169
- set isGalleryDockedRight(t) {
170
- e.set(z(this, ge), t, !0);
171
- }
172
- get isFullScreen() {
173
- return e.get(z(this, ue));
174
- }
175
- set isFullScreen(t) {
176
- e.set(z(this, ue), t, !0);
177
- }
178
- get showMetadataDialog() {
179
- return e.get(z(this, fe));
180
- }
181
- set showMetadataDialog(t) {
182
- e.set(z(this, fe), t, !0);
183
- }
184
- get dockSide() {
185
- return e.get(z(this, he));
186
- }
187
- set dockSide(t) {
188
- e.set(z(this, he), t, !0);
189
- }
190
- get visibleAnnotationIds() {
191
- return e.get(z(this, ve));
192
- }
193
- set visibleAnnotationIds(t) {
194
- e.set(z(this, ve), t, !0);
195
- }
196
- get manifest() {
197
- return this.manifestId ? ae.getManifest(this.manifestId) : null;
198
- }
199
- get canvases() {
200
- if (!this.manifestId) return [];
201
- const t = ae.getCanvases(this.manifestId);
202
- return t.length > 0 && !this.canvasId && setTimeout(
203
- () => {
204
- !this.canvasId && t.length > 0 && (this.canvasId = t[0].id);
205
- },
206
- 0
207
- ), t;
208
- }
209
- get currentCanvasIndex() {
210
- return this.canvasId ? this.canvases.findIndex((t) => t.id === this.canvasId) : this.canvases.length > 0 ? 0 : -1;
211
- }
212
- get hasNext() {
213
- return this.currentCanvasIndex < this.canvases.length - 1;
214
- }
215
- get hasPrevious() {
216
- return this.currentCanvasIndex > 0;
217
- }
218
- nextCanvas() {
219
- if (this.hasNext) {
220
- const t = this.currentCanvasIndex + 1, a = this.canvases[t];
221
- this.canvasId = a.id;
222
- }
223
- }
224
- previousCanvas() {
225
- if (this.hasPrevious) {
226
- const t = this.currentCanvasIndex - 1, a = this.canvases[t];
227
- this.canvasId = a.id;
228
- }
229
- }
230
- setManifest(t) {
231
- this.manifestId = t, this.canvasId = null, ae.fetchManifest(t);
232
- }
233
- setCanvas(t) {
234
- this.canvasId = t;
235
- }
236
- toggleAnnotations() {
237
- this.showAnnotations = !this.showAnnotations;
238
- }
239
- toggleThumbnailGallery() {
240
- this.showThumbnailGallery = !this.showThumbnailGallery;
241
- }
242
- toggleFullScreen() {
243
- if (document.fullscreenElement)
244
- document.exitFullscreen();
245
- else {
246
- const t = document.getElementById("triiiceratops-viewer");
247
- t && t.requestFullscreen().catch((a) => {
248
- console.warn("Fullscreen request failed", a);
249
- });
250
- }
251
- }
252
- toggleMetadataDialog() {
253
- this.showMetadataDialog = !this.showMetadataDialog;
254
- }
255
- get searchQuery() {
256
- return e.get(z(this, pe));
257
- }
258
- set searchQuery(t) {
259
- e.set(z(this, pe), t, !0);
260
- }
261
- get searchResults() {
262
- return e.get(z(this, me));
263
- }
264
- set searchResults(t) {
265
- e.set(z(this, me), t, !0);
266
- }
267
- get isSearching() {
268
- return e.get(z(this, be));
269
- }
270
- set isSearching(t) {
271
- e.set(z(this, be), t, !0);
272
- }
273
- get showSearchPanel() {
274
- return e.get(z(this, _e));
275
- }
276
- set showSearchPanel(t) {
277
- e.set(z(this, _e), t, !0);
278
- }
279
- toggleSearchPanel() {
280
- this.showSearchPanel = !this.showSearchPanel, this.showSearchPanel || (this.searchAnnotations = []);
281
- }
282
- get searchAnnotations() {
283
- return e.get(z(this, ye));
284
- }
285
- set searchAnnotations(t) {
286
- e.set(z(this, ye), t, !0);
287
- }
288
- get currentCanvasSearchAnnotations() {
289
- return this.canvasId ? this.searchAnnotations.filter((t) => t.canvasId === this.canvasId) : [];
290
- }
291
- async search(t) {
292
- var a, n;
293
- if (t.trim()) {
294
- this.isSearching = !0, this.searchQuery = t, this.searchResults = [];
295
- try {
296
- const c = this.manifest;
297
- if (!c) throw new Error("No manifest loaded");
298
- let d = c.getService("http://iiif.io/api/search/1/search") || c.getService("http://iiif.io/api/search/0/search");
299
- if (d || c.__jsonld && c.__jsonld.service && (d = (Array.isArray(c.__jsonld.service) ? c.__jsonld.service : [c.__jsonld.service]).find((u) => u.profile === "http://iiif.io/api/search/1/search" || u.profile === "http://iiif.io/api/search/0/search")), !d) {
300
- console.warn("No IIIF search service found in manifest"), this.isSearching = !1;
301
- return;
302
- }
303
- const I = `${d.id || d["@id"]}?q=${encodeURIComponent(t)}`, v = await fetch(I);
304
- if (!v.ok) throw new Error("Search request failed");
305
- const S = await v.json(), L = S.resources || [], R = [], i = (l) => {
306
- const u = typeof l == "string" ? l : l["@id"] || l.id;
307
- if (!u) return null;
308
- const x = u.split("#xywh=");
309
- if (x.length < 2) return null;
310
- const p = x[1].split(",").map(Number);
311
- return p.length === 4 ? p : null;
312
- };
313
- if (S.hits)
314
- for (const l of S.hits) {
315
- const u = l.annotations || [];
316
- for (const x of u) {
317
- const p = L.find((r) => r["@id"] === x || r.id === x);
318
- if (p && p.on) {
319
- const r = typeof p.on == "string" ? p.on : p.on["@id"] || p.on.id, g = r.split("#")[0], y = i(r), m = this.canvases.findIndex((E) => E.id === g);
320
- if (m >= 0) {
321
- const E = this.canvases[m];
322
- let k = "Canvas " + (m + 1);
323
- try {
324
- if (E.getLabel) {
325
- const T = E.getLabel();
326
- Array.isArray(T) && T.length > 0 ? k = T[0].value : typeof T == "string" && (k = T);
327
- } else E.label && (typeof E.label == "string" ? k = E.label : Array.isArray(E.label) && (k = (a = E.label[0]) == null ? void 0 : a.value));
328
- } catch {
329
- }
330
- R.push({
331
- type: "hit",
332
- before: l.before,
333
- match: l.match,
334
- after: l.after,
335
- canvasIndex: m,
336
- canvasLabel: String(k),
337
- bounds: y
338
- });
339
- }
340
- }
341
- }
342
- }
343
- else if (L.length > 0)
344
- for (const l of L) {
345
- const u = typeof l.on == "string" ? l.on : l.on["@id"] || l.on.id, x = u.split("#")[0], p = i(u), r = this.canvases.findIndex((g) => g.id === x);
346
- if (r >= 0) {
347
- const g = this.canvases[r];
348
- let y = "Canvas " + (r + 1);
349
- try {
350
- if (g.getLabel) {
351
- const m = g.getLabel();
352
- Array.isArray(m) && m.length > 0 ? y = m[0].value : typeof m == "string" && (y = m);
353
- } else g.label && (typeof g.label == "string" ? y = g.label : Array.isArray(g.label) && (y = (n = g.label[0]) == null ? void 0 : n.value));
354
- } catch {
355
- }
356
- R.push({
357
- type: "resource",
358
- match: l.resource && l.resource.chars ? l.resource.chars : l.chars || "",
359
- canvasIndex: r,
360
- canvasLabel: String(y),
361
- bounds: p
362
- });
363
- }
364
- }
365
- this.searchResults = R, this.searchAnnotations = R.filter((l) => l.bounds).map((l, u) => {
366
- const x = this.canvases[l.canvasIndex], p = `${x.id}#xywh=${l.bounds.join(",")}`;
367
- return {
368
- "@id": `urn:search-hit:${u}`,
369
- "@type": "oa:Annotation",
370
- motivation: "sc:painting",
371
- on: p,
372
- canvasId: x.id,
373
- resource: { "@type": "cnt:ContentAsText", chars: l.match },
374
- // Flag to identify styling in Overlay?
375
- // Or just standard rendering.
376
- isSearchHit: !0
377
- };
378
- });
379
- } catch (c) {
380
- console.error("Search error:", c);
381
- } finally {
382
- this.isSearching = !1;
383
- }
384
- }
385
- }
386
- }
387
- ie = new WeakMap(), oe = new WeakMap(), le = new WeakMap(), ce = new WeakMap(), de = new WeakMap(), ge = new WeakMap(), ue = new WeakMap(), fe = new WeakMap(), he = new WeakMap(), ve = new WeakMap(), pe = new WeakMap(), me = new WeakMap(), be = new WeakMap(), _e = new WeakMap(), ye = new WeakMap();
388
- const se = "triiiceratops:viewerState";
389
- function Re(s) {
390
- return s.id || s["@id"] || (typeof s.getId == "function" ? s.getId() : "");
391
- }
392
- function Ie(s) {
393
- if (!s) return null;
394
- const t = s.match(/xywh=(\d+),(\d+),(\d+),(\d+)/);
395
- return t ? {
396
- x: parseInt(t[1], 10),
397
- y: parseInt(t[2], 10),
398
- w: parseInt(t[3], 10),
399
- h: parseInt(t[4], 10)
400
- } : null;
401
- }
402
- function at(s) {
403
- const t = st(s);
404
- if (t)
405
- return nt(t);
406
- const a = lt(s);
407
- return a ? {
408
- type: "RECTANGLE",
409
- x: a.x,
410
- y: a.y,
411
- w: a.w,
412
- h: a.h
413
- } : null;
414
- }
415
- function st(s) {
416
- var a, n;
417
- if (typeof s.getTarget == "function") {
418
- const c = ((a = s.__jsonld) == null ? void 0 : a.on) || ((n = s.__jsonld) == null ? void 0 : n.target);
419
- if (c)
420
- return Me(c);
421
- }
422
- const t = s.target || s.on;
423
- return t ? Me(t) : null;
424
- }
425
- function Me(s) {
426
- if (!s) return null;
427
- if (Array.isArray(s))
428
- for (const t of s) {
429
- const a = Ge(t);
430
- if (a) return a;
431
- }
432
- else
433
- return Ge(s);
434
- return null;
435
- }
436
- function Ge(s) {
437
- var a;
438
- if (!s) return null;
439
- const t = s.selector || s;
440
- return (t == null ? void 0 : t.type) === "SvgSelector" && t.value ? t.value : ((a = t == null ? void 0 : t.item) == null ? void 0 : a.type) === "SvgSelector" && t.item.value ? t.item.value : null;
441
- }
442
- function nt(s) {
443
- try {
444
- const a = new DOMParser().parseFromString(s, "image/svg+xml");
445
- if (a.documentElement.nodeName === "parsererror")
446
- return console.warn("Failed to parse SVG selector:", s), null;
447
- const n = [], c = a.querySelectorAll("polygon");
448
- for (const I of c) {
449
- const v = I.getAttribute("points");
450
- if (v) {
451
- const S = rt(v);
452
- n.push(...S);
453
- }
454
- }
455
- const d = a.querySelectorAll("path");
456
- for (const I of d) {
457
- const v = I.getAttribute("d");
458
- if (v) {
459
- const S = it(v);
460
- n.push(...S);
461
- }
462
- }
463
- const G = a.querySelectorAll("circle");
464
- for (const I of G) {
465
- const v = parseFloat(I.getAttribute("cx") || "0"), S = parseFloat(I.getAttribute("cy") || "0"), L = parseFloat(I.getAttribute("r") || "0"), R = ot(v, S, L);
466
- n.push(...R);
467
- }
468
- return n.length === 0 ? null : {
469
- type: "POLYGON",
470
- points: n
471
- };
472
- } catch (t) {
473
- return console.warn("Failed to convert SVG to polygon:", t), null;
474
- }
475
- }
476
- function rt(s) {
477
- const t = [], a = s.trim().split(/\s+/);
478
- for (const n of a) {
479
- const [c, d] = n.split(",").map((G) => parseFloat(G));
480
- !isNaN(c) && !isNaN(d) && t.push([c, d]);
481
- }
482
- return t;
483
- }
484
- function it(s) {
485
- const t = [], a = /[ML]\s*([\d.]+)[,\s]+([\d.]+)/g;
486
- let n;
487
- for (; (n = a.exec(s)) !== null; ) {
488
- const c = parseFloat(n[1]), d = parseFloat(n[2]);
489
- !isNaN(c) && !isNaN(d) && t.push([c, d]);
490
- }
491
- return t;
492
- }
493
- function ot(s, t, a, n = 8) {
494
- const c = [];
495
- for (let d = 0; d < n; d++) {
496
- const G = d / n * Math.PI * 2, I = s + a * Math.cos(G), v = t + a * Math.sin(G);
497
- c.push([I, v]);
498
- }
499
- return c;
500
- }
501
- function lt(s) {
502
- var a;
503
- if (typeof s.getTarget == "function") {
504
- const n = s.getTarget();
505
- if (typeof n == "string" && n.includes("xywh="))
506
- return Ie(n);
507
- const c = (a = s.__jsonld) == null ? void 0 : a.on;
508
- if (c) {
509
- const d = Te(c);
510
- if (d) return d;
511
- }
512
- }
513
- const t = s.target || s.on;
514
- return t ? Te(t) : null;
515
- }
516
- function Te(s) {
517
- if (!s) return null;
518
- if (Array.isArray(s))
519
- for (const t of s) {
520
- const a = Te(t);
521
- if (a) return a;
522
- }
523
- if (typeof s == "string" && s.includes("xywh="))
524
- return Ie(s);
525
- if (s.selector) {
526
- const t = s.selector, a = t.item || t;
527
- if (a.value && typeof a.value == "string" && a.value.includes("xywh="))
528
- return Ie(a.value);
529
- }
530
- return null;
531
- }
532
- function ct(s) {
533
- let t = "", a = !1;
534
- if (typeof s.getBody == "function") {
535
- const n = s.getBody();
536
- if (n && Array.isArray(n)) {
537
- const c = [];
538
- for (const d of n) {
539
- const G = d.getValue ? d.getValue() : "";
540
- if (G) {
541
- c.push(G);
542
- const I = d.getFormat ? d.getFormat() : "";
543
- (I === "text/html" || I === "application/html") && (a = !0);
544
- }
545
- }
546
- t = c.join(" ");
547
- }
548
- } else {
549
- const n = (d) => d && (d.chars || d.value || d["cnt:chars"]) || "", c = (d) => d ? d.format === "text/html" || d.type === "TextualBody" : !1;
550
- if (s.resource) {
551
- const d = Array.isArray(s.resource) ? s.resource : [s.resource];
552
- t = d.map(n).filter(Boolean).join(" "), a = d.some(c);
553
- } else if (s.body) {
554
- const d = Array.isArray(s.body) ? s.body : [s.body];
555
- t = d.map(n).filter(Boolean).join(" "), a = d.some(c);
556
- }
557
- }
558
- return t || (typeof s.getLabel == "function" ? t = s.getLabel() || "" : s.label && (t = Array.isArray(s.label) ? s.label.join(" ") : s.label)), { value: t || "Annotation", isHtml: a };
559
- }
560
- function dt(s, t, a = !1) {
561
- const n = Re(s) || `anno-${t}`, c = at(s);
562
- if (!c)
563
- return null;
564
- const d = ct(s);
565
- return {
566
- id: n,
567
- geometry: c,
568
- body: d,
569
- isSearchHit: a
570
- };
571
- }
572
- function gt(s, t = /* @__PURE__ */ new Set()) {
573
- return s.map((a, n) => {
574
- const c = t.has(Re(a));
575
- return dt(a, n, c);
576
- }).filter((a) => a !== null);
577
- }
578
- var ut = e.from_html("<div></div>"), ft = e.from_svg('<svg class="absolute pointer-events-auto"><title> </title><polygon stroke-width="2"></polygon></svg>'), ht = e.from_html('<div class="w-full h-full relative"><div class="w-full h-full osd-background bg-base-100"></div> <!></div>');
579
- function vt(s, t) {
580
- e.push(t, !0);
581
- let a = e.state(void 0), n = e.state(void 0), c = e.state(0), d = e.derived(() => {
582
- if (!t.viewerState.manifestId || !t.viewerState.canvasId)
583
- return [];
584
- const i = ae.getAnnotations(t.viewerState.manifestId, t.viewerState.canvasId), l = t.viewerState.currentCanvasSearchAnnotations;
585
- return [...i, ...l];
586
- }), G = e.derived(() => {
587
- const i = /* @__PURE__ */ new Set();
588
- return t.viewerState.currentCanvasSearchAnnotations.forEach((l) => {
589
- const u = l.id || l["@id"];
590
- u && i.add(u);
591
- }), i;
592
- }), I = e.derived(() => gt(e.get(d), e.get(G))), v = e.derived(() => {
593
- if (e.get(c), !e.get(n) || !e.get(I).length)
594
- return [];
595
- const i = e.get(n).world.getItemAt(0);
596
- if (!i)
597
- return [];
598
- const l = [];
599
- for (const u of e.get(I)) {
600
- if (!u.isSearchHit) if (t.viewerState.showAnnotations) {
601
- if (!t.viewerState.visibleAnnotationIds.has(u.id))
602
- continue;
603
- } else continue;
604
- if (u.geometry.type === "RECTANGLE") {
605
- const x = i.imageToViewportRectangle(u.geometry.x, u.geometry.y, u.geometry.w, u.geometry.h), p = e.get(n).viewport.viewportToViewerElementRectangle(x);
606
- l.push({
607
- id: u.id,
608
- type: "RECTANGLE",
609
- rect: {
610
- x: p.x,
611
- y: p.y,
612
- width: p.width,
613
- height: p.height
614
- },
615
- isSearchHit: u.isSearchHit,
616
- tooltip: u.body.value
617
- });
618
- } else if (u.geometry.type === "POLYGON") {
619
- const x = u.geometry.points.map((E) => {
620
- const k = i.imageToViewportCoordinates(new Ce.Point(E[0], E[1])), T = e.get(n).viewport.viewportToViewerElementCoordinates(k);
621
- return [T.x, T.y];
622
- });
623
- let p = 1 / 0, r = 1 / 0, g = -1 / 0, y = -1 / 0;
624
- for (const [E, k] of x)
625
- p = Math.min(p, E), r = Math.min(r, k), g = Math.max(g, E), y = Math.max(y, k);
626
- const m = x.map(([E, k]) => [E - p, k - r]);
627
- l.push({
628
- id: u.id,
629
- type: "POLYGON",
630
- bounds: { x: p, y: r, width: g - p, height: y - r },
631
- points: m,
632
- isSearchHit: u.isSearchHit,
633
- tooltip: u.body.value
634
- });
635
- }
636
- }
637
- return l;
638
- });
639
- Ne(() => {
640
- if (e.get(a))
641
- return e.set(
642
- n,
643
- Ce({
644
- element: e.get(a),
645
- tileSources: null,
646
- // Will be set via effect
647
- prefixUrl: "",
648
- // No navigation UI images needed
649
- showNavigationControl: !1,
650
- showHomeControl: !1,
651
- showFullPageControl: !1,
652
- showSequenceControl: !1,
653
- showZoomControl: !1,
654
- showRotationControl: !1,
655
- animationTime: 0.5,
656
- springStiffness: 7,
657
- zoomPerClick: 2
658
- }),
659
- !0
660
- ), () => {
661
- var i;
662
- (i = e.get(n)) == null || i.destroy();
663
- };
664
- }), e.user_effect(() => {
665
- if (!e.get(n)) return;
666
- const i = () => {
667
- e.update(c);
668
- };
669
- return e.get(n).addHandler("open", i), e.get(n).addHandler("animation", i), e.get(n).addHandler("resize", i), e.get(n).addHandler("rotate", i), e.get(n).world.addHandler("add-item", i), e.get(n).world.addHandler("remove-item", i), () => {
670
- e.get(n).removeHandler("open", i), e.get(n).removeHandler("animation", i), e.get(n).removeHandler("resize", i), e.get(n).removeHandler("rotate", i), e.get(n).world.removeHandler("add-item", i), e.get(n).world.removeHandler("remove-item", i);
671
- };
672
- }), e.user_effect(() => {
673
- !e.get(n) || !t.tileSources || e.get(n).open(t.tileSources);
674
- });
675
- var S = ht(), L = e.child(S);
676
- e.bind_this(L, (i) => e.set(a, i), () => e.get(a));
677
- var R = e.sibling(L, 2);
678
- e.each(R, 17, () => e.get(v), (i) => i.id, (i, l) => {
679
- var u = e.comment(), x = e.first_child(u);
680
- {
681
- var p = (g) => {
682
- var y = ut();
683
- e.template_effect(() => {
684
- e.set_class(y, 1, `absolute border-2 transition-colors cursor-pointer pointer-events-auto ${e.get(l).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(y, `
685
- left: ${e.get(l).rect.x ?? ""}px;
686
- top: ${e.get(l).rect.y ?? ""}px;
687
- width: ${e.get(l).rect.width ?? ""}px;
688
- height: ${e.get(l).rect.height ?? ""}px;
689
- `), e.set_attribute(y, "title", e.get(l).tooltip);
690
- }), e.append(g, y);
691
- }, r = (g) => {
692
- var y = e.comment(), m = e.first_child(y);
693
- {
694
- var E = (k) => {
695
- var T = ft(), _ = e.child(T), C = e.child(_, !0);
696
- e.reset(_);
697
- var b = e.sibling(_);
698
- e.reset(T), e.template_effect(
699
- (o) => {
700
- e.set_style(T, `
701
- left: ${e.get(l).bounds.x ?? ""}px;
702
- top: ${e.get(l).bounds.y ?? ""}px;
703
- width: ${e.get(l).bounds.width ?? ""}px;
704
- height: ${e.get(l).bounds.height ?? ""}px;
705
- `), e.set_text(C, e.get(l).tooltip), e.set_attribute(b, "points", o), e.set_class(b, 0, `cursor-pointer transition-colors ${e.get(l).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"}`);
706
- },
707
- [() => e.get(l).points.map((o) => o.join(",")).join(" ")]
708
- ), e.append(k, T);
709
- };
710
- e.if(
711
- m,
712
- (k) => {
713
- e.get(l).type === "POLYGON" && k(E);
714
- },
715
- !0
716
- );
717
- }
718
- e.append(g, y);
719
- };
720
- e.if(x, (g) => {
721
- e.get(l).type === "RECTANGLE" ? g(p) : g(r, !1);
722
- });
723
- }
724
- e.append(i, u);
725
- }), e.reset(S), e.append(s, S), e.pop();
726
- }
727
- const pt = "en";
728
- let M = () => pt;
729
- const mt = /* @__NO_SIDE_EFFECTS__ */ () => "Hello World", bt = /* @__NO_SIDE_EFFECTS__ */ () => "Search", _t = /* @__NO_SIDE_EFFECTS__ */ () => "Close Search", yt = /* @__NO_SIDE_EFFECTS__ */ () => "Search content...", xt = /* @__NO_SIDE_EFFECTS__ */ (s) => `No results found for "${s.query}"`, wt = /* @__NO_SIDE_EFFECTS__ */ () => "Enter a search term to find occurrences within this manifest.", St = /* @__NO_SIDE_EFFECTS__ */ (s) => `${s.count} Results`, At = /* @__NO_SIDE_EFFECTS__ */ () => "Manifest Metadata", It = /* @__NO_SIDE_EFFECTS__ */ () => "Loading...", Tt = /* @__NO_SIDE_EFFECTS__ */ () => "Attribution", $t = /* @__NO_SIDE_EFFECTS__ */ () => "License", kt = /* @__NO_SIDE_EFFECTS__ */ () => "Close", Ct = /* @__NO_SIDE_EFFECTS__ */ () => "Menu", jt = /* @__NO_SIDE_EFFECTS__ */ () => "Search", Lt = /* @__NO_SIDE_EFFECTS__ */ () => "Toggle Search", Mt = /* @__NO_SIDE_EFFECTS__ */ () => "Hide Gallery", Gt = /* @__NO_SIDE_EFFECTS__ */ () => "Show Gallery", Et = /* @__NO_SIDE_EFFECTS__ */ () => "Exit Full Screen", Rt = /* @__NO_SIDE_EFFECTS__ */ () => "Enter Full Screen", Pt = /* @__NO_SIDE_EFFECTS__ */ () => "Hide Annotations", zt = /* @__NO_SIDE_EFFECTS__ */ () => "Show Annotations", Dt = /* @__NO_SIDE_EFFECTS__ */ () => "Toggle Annotations", Ft = /* @__NO_SIDE_EFFECTS__ */ () => "Metadata", Ht = /* @__NO_SIDE_EFFECTS__ */ () => "Toggle Metadata", Nt = /* @__NO_SIDE_EFFECTS__ */ () => "Hide All Annotations", Vt = /* @__NO_SIDE_EFFECTS__ */ () => "Show All Annotations", Bt = /* @__NO_SIDE_EFFECTS__ */ (s) => `${s.count} Annotations`, Ot = /* @__NO_SIDE_EFFECTS__ */ (s) => `(${s.count} visible)`, qt = /* @__NO_SIDE_EFFECTS__ */ () => "(No content)", Yt = /* @__NO_SIDE_EFFECTS__ */ () => "No annotations available.", Xt = /* @__NO_SIDE_EFFECTS__ */ () => "Previous Canvas", Qt = /* @__NO_SIDE_EFFECTS__ */ () => "Next Canvas", Ut = /* @__NO_SIDE_EFFECTS__ */ () => "Docs", Kt = /* @__NO_SIDE_EFFECTS__ */ () => "IIIF Manifest:", Wt = /* @__NO_SIDE_EFFECTS__ */ () => "Enter IIIF manifest URL", Jt = /* @__NO_SIDE_EFFECTS__ */ () => "Load", Zt = /* @__NO_SIDE_EFFECTS__ */ () => "GitHub", ea = /* @__NO_SIDE_EFFECTS__ */ () => "Hallo Welt", ta = /* @__NO_SIDE_EFFECTS__ */ () => "Suche", aa = /* @__NO_SIDE_EFFECTS__ */ () => "Suche schließen", sa = /* @__NO_SIDE_EFFECTS__ */ () => "Inhalt durchsuchen...", na = /* @__NO_SIDE_EFFECTS__ */ (s) => `Keine Ergebnisse für "${s.query}" gefunden`, ra = /* @__NO_SIDE_EFFECTS__ */ () => "Geben Sie einen Suchbegriff ein, um Vorkommen in diesem Manifest zu finden.", ia = /* @__NO_SIDE_EFFECTS__ */ (s) => `${s.count} Ergebnisse`, oa = /* @__NO_SIDE_EFFECTS__ */ () => "Manifest-Metadaten", la = /* @__NO_SIDE_EFFECTS__ */ () => "Lädt...", ca = /* @__NO_SIDE_EFFECTS__ */ () => "Quellenangabe", da = /* @__NO_SIDE_EFFECTS__ */ () => "Lizenz", ga = /* @__NO_SIDE_EFFECTS__ */ () => "Schließen", ua = /* @__NO_SIDE_EFFECTS__ */ () => "Menü", fa = /* @__NO_SIDE_EFFECTS__ */ () => "Suche", ha = /* @__NO_SIDE_EFFECTS__ */ () => "Suche umschalten", va = /* @__NO_SIDE_EFFECTS__ */ () => "Galerie ausblenden", pa = /* @__NO_SIDE_EFFECTS__ */ () => "Galerie einblenden", ma = /* @__NO_SIDE_EFFECTS__ */ () => "Vollbildmodus beenden", ba = /* @__NO_SIDE_EFFECTS__ */ () => "Vollbildmodus", _a = /* @__NO_SIDE_EFFECTS__ */ () => "Annotationen ausblenden", ya = /* @__NO_SIDE_EFFECTS__ */ () => "Annotationen einblenden", xa = /* @__NO_SIDE_EFFECTS__ */ () => "Annotationen umschalten", wa = /* @__NO_SIDE_EFFECTS__ */ () => "Metadaten", Sa = /* @__NO_SIDE_EFFECTS__ */ () => "Metadaten umschalten", Aa = /* @__NO_SIDE_EFFECTS__ */ () => "Alle Annotationen ausblenden", Ia = /* @__NO_SIDE_EFFECTS__ */ () => "Alle Annotationen einblenden", Ta = /* @__NO_SIDE_EFFECTS__ */ (s) => `${s.count} Annotationen`, $a = /* @__NO_SIDE_EFFECTS__ */ (s) => `(${s.count} sichtbar)`, ka = /* @__NO_SIDE_EFFECTS__ */ () => "(Kein Inhalt)", Ca = /* @__NO_SIDE_EFFECTS__ */ () => "Keine Annotationen verfügbar.", ja = /* @__NO_SIDE_EFFECTS__ */ () => "Vorheriges Canvas", La = /* @__NO_SIDE_EFFECTS__ */ () => "Nächstes Canvas", Ma = /* @__NO_SIDE_EFFECTS__ */ () => "Doku", Ga = /* @__NO_SIDE_EFFECTS__ */ () => "IIIF-Manifest:", Ea = /* @__NO_SIDE_EFFECTS__ */ () => "IIIF-Manifest-URL eingeben", Ra = /* @__NO_SIDE_EFFECTS__ */ () => "Laden", Pa = /* @__NO_SIDE_EFFECTS__ */ () => "GitHub", za = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
730
- de: ea,
731
- en: mt
732
- })[t.languageTag ?? M()](), Da = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
733
- de: ta,
734
- en: bt
735
- })[t.languageTag ?? M()](), Fa = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
736
- de: aa,
737
- en: _t
738
- })[t.languageTag ?? M()](), Ha = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
739
- de: sa,
740
- en: yt
741
- })[t.languageTag ?? M()](), Na = /* @__NO_SIDE_EFFECTS__ */ (s, t = {}) => ({
742
- de: na,
743
- en: xt
744
- })[t.languageTag ?? M()](s), Va = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
745
- de: ra,
746
- en: wt
747
- })[t.languageTag ?? M()](), Ba = /* @__NO_SIDE_EFFECTS__ */ (s, t = {}) => ({
748
- de: ia,
749
- en: St
750
- })[t.languageTag ?? M()](s), Oa = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
751
- de: oa,
752
- en: At
753
- })[t.languageTag ?? M()](), qa = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
754
- de: la,
755
- en: It
756
- })[t.languageTag ?? M()](), Ya = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
757
- de: ca,
758
- en: Tt
759
- })[t.languageTag ?? M()](), Xa = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
760
- de: da,
761
- en: $t
762
- })[t.languageTag ?? M()](), Qa = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
763
- de: ga,
764
- en: kt
765
- })[t.languageTag ?? M()](), Ua = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
766
- de: ua,
767
- en: Ct
768
- })[t.languageTag ?? M()](), Ka = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
769
- de: fa,
770
- en: jt
771
- })[t.languageTag ?? M()](), Wa = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
772
- de: ha,
773
- en: Lt
774
- })[t.languageTag ?? M()](), Ja = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
775
- de: va,
776
- en: Mt
777
- })[t.languageTag ?? M()](), Za = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
778
- de: pa,
779
- en: Gt
780
- })[t.languageTag ?? M()](), es = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
781
- de: ma,
782
- en: Et
783
- })[t.languageTag ?? M()](), ts = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
784
- de: ba,
785
- en: Rt
786
- })[t.languageTag ?? M()](), as = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
787
- de: _a,
788
- en: Pt
789
- })[t.languageTag ?? M()](), ss = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
790
- de: ya,
791
- en: zt
792
- })[t.languageTag ?? M()](), ns = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
793
- de: xa,
794
- en: Dt
795
- })[t.languageTag ?? M()](), rs = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
796
- de: wa,
797
- en: Ft
798
- })[t.languageTag ?? M()](), is = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
799
- de: Sa,
800
- en: Ht
801
- })[t.languageTag ?? M()](), os = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
802
- de: Aa,
803
- en: Nt
804
- })[t.languageTag ?? M()](), ls = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
805
- de: Ia,
806
- en: Vt
807
- })[t.languageTag ?? M()](), cs = /* @__NO_SIDE_EFFECTS__ */ (s, t = {}) => ({
808
- de: Ta,
809
- en: Bt
810
- })[t.languageTag ?? M()](s), ds = /* @__NO_SIDE_EFFECTS__ */ (s, t = {}) => ({
811
- de: $a,
812
- en: Ot
813
- })[t.languageTag ?? M()](s), gs = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
814
- de: ka,
815
- en: qt
816
- })[t.languageTag ?? M()](), us = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
817
- de: Ca,
818
- en: Yt
819
- })[t.languageTag ?? M()](), fs = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
820
- de: ja,
821
- en: Xt
822
- })[t.languageTag ?? M()](), hs = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
823
- de: La,
824
- en: Qt
825
- })[t.languageTag ?? M()](), vs = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
826
- de: Ma,
827
- en: Ut
828
- })[t.languageTag ?? M()](), ps = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
829
- de: Ga,
830
- en: Kt
831
- })[t.languageTag ?? M()](), ms = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
832
- de: Ea,
833
- en: Wt
834
- })[t.languageTag ?? M()](), bs = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
835
- de: Ra,
836
- en: Jt
837
- })[t.languageTag ?? M()](), _s = /* @__NO_SIDE_EFFECTS__ */ (s = {}, t = {}) => ({
838
- de: Pa,
839
- en: Zt
840
- })[t.languageTag ?? M()](), ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
841
- __proto__: null,
842
- annotations_count: cs,
843
- attribution: Ya,
844
- close: Qa,
845
- docs: vs,
846
- enter_full_screen: ts,
847
- exit_full_screen: es,
848
- github: _s,
849
- hello_world: za,
850
- hide_all_annotations: os,
851
- hide_annotations: as,
852
- hide_gallery: Ja,
853
- iiif_manifest_label: ps,
854
- license: Xa,
855
- load: bs,
856
- loading: qa,
857
- manifest_placeholder: ms,
858
- menu: Ua,
859
- metadata: rs,
860
- metadata_label_fallback: Oa,
861
- next_canvas: hs,
862
- no_annotations_available: us,
863
- no_content: gs,
864
- previous_canvas: fs,
865
- search: Ka,
866
- search_panel_close: Fa,
867
- search_panel_instruction: Va,
868
- search_panel_no_results: Na,
869
- search_panel_placeholder: Ha,
870
- search_panel_results_count: Ba,
871
- search_panel_title: Da,
872
- show_all_annotations: ls,
873
- show_annotations: ss,
874
- show_gallery: Za,
875
- toggle_annotations: ns,
876
- toggle_metadata: is,
877
- toggle_search: Wa,
878
- visible_count: ds
879
- }, Symbol.toStringTag, { value: "Module" }));
880
- let Pe = e.state(e.proxy(M()));
881
- const xs = {
882
- get current() {
883
- return e.get(Pe);
884
- }
885
- }, P = new Proxy(ys, {
886
- get(s, t, a) {
887
- return e.get(Pe), Reflect.get(s, t, a);
888
- }
889
- });
890
- var ws = e.from_html('<div><button class="btn btn-circle btn-sm btn-ghost"><!></button> <span class="text-sm font-mono tabular-nums"> </span> <button class="btn btn-circle btn-sm btn-ghost"><!></button></div>');
891
- function Ss(s, t) {
892
- e.push(t, !0);
893
- var a = ws(), n = e.child(a);
894
- n.__click = () => t.viewerState.previousCanvas();
895
- var c = e.child(n);
896
- Oe(c, { size: 20, weight: "bold" }), e.reset(n);
897
- var d = e.sibling(n, 2), G = e.child(d);
898
- e.reset(d);
899
- var I = e.sibling(d, 2);
900
- I.__click = () => t.viewerState.nextCanvas();
901
- var v = e.child(I);
902
- qe(v, { size: 20, weight: "bold" }), e.reset(I), e.reset(a), e.template_effect(
903
- (S, L) => {
904
- e.set_class(a, 1, `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 ${t.viewerState.showThumbnailGallery && t.viewerState.isGalleryDockedBottom ? "bottom-40" : "bottom-4"}`), n.disabled = !t.viewerState.hasPrevious, e.set_attribute(n, "aria-label", S), e.set_text(G, `${t.viewerState.currentCanvasIndex + 1} / ${t.viewerState.canvases.length ?? ""}`), I.disabled = !t.viewerState.hasNext, e.set_attribute(I, "aria-label", L);
905
- },
906
- [() => P.previous_canvas(), () => P.next_canvas()]
907
- ), e.append(s, a), e.pop();
908
- }
909
- e.delegate(["click"]);
910
- var As = e.from_html('<span class="text-xs opacity-50 truncate max-w-[150px]"> </span>'), Is = 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>'), Ts = e.from_html('<div class="p-4 text-center opacity-50 text-sm">No annotations available.</div>'), $s = e.from_html('<div><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>');
911
- function ks(s, t) {
912
- e.push(t, !0);
913
- const a = xe(se);
914
- let n = e.derived(() => {
915
- if (!a.manifestId || !a.canvasId)
916
- return [];
917
- const i = ae.getAnnotations(a.manifestId, a.canvasId), l = a.currentCanvasSearchAnnotations;
918
- return [...i, ...l];
919
- });
920
- function c(i) {
921
- return i.id || i["@id"] || (typeof i.getId == "function" ? i.getId() : "") || "";
922
- }
923
- e.user_effect(() => {
924
- if (e.get(n).length > 0) {
925
- const i = /* @__PURE__ */ new Set();
926
- e.get(n).forEach((l) => {
927
- const u = c(l);
928
- u && i.add(u);
929
- }), a.visibleAnnotationIds = i;
930
- } else
931
- a.visibleAnnotationIds = /* @__PURE__ */ new Set();
932
- });
933
- let d = e.derived(() => e.get(n).length === 0 ? !1 : e.get(n).every((i) => {
934
- const l = c(i);
935
- return !l || a.visibleAnnotationIds.has(l);
936
- }));
937
- function G(i) {
938
- a.visibleAnnotationIds.has(i) ? a.visibleAnnotationIds.delete(i) : a.visibleAnnotationIds.add(i), a.visibleAnnotationIds = new Set(a.visibleAnnotationIds);
939
- }
940
- function I() {
941
- if (e.get(d))
942
- a.visibleAnnotationIds = /* @__PURE__ */ new Set();
943
- else {
944
- const i = /* @__PURE__ */ new Set();
945
- e.get(n).forEach((l) => {
946
- const u = c(l);
947
- u && i.add(u);
948
- }), a.visibleAnnotationIds = i;
949
- }
950
- }
951
- let v = e.derived(() => e.get(n).length ? e.get(n).map((i) => {
952
- let l = "", u = !1;
953
- if (typeof i.getBody == "function") {
954
- const x = i.getBody();
955
- if (x && x.length) {
956
- const p = (r) => {
957
- const g = r.getValue ? r.getValue() : null;
958
- return g || "";
959
- };
960
- l = x.map((r) => p(r)).filter(Boolean).join(" "), u = x.some((r) => {
961
- const g = r.getFormat ? r.getFormat() : "";
962
- return g === "text/html" || g === "application/html";
963
- });
964
- }
965
- if (!l && typeof i.getLabel == "function") {
966
- const p = i.getLabel();
967
- p && (l = p);
968
- }
969
- } else {
970
- const x = (r) => r && (r.chars || r.value || r["cnt:chars"]) || "", p = (r) => r ? r.format === "text/html" || r.type === "TextualBody" : !1;
971
- if (i.resource ? Array.isArray(i.resource) ? (l = i.resource.map((r) => x(r)).join(" "), i.resource.some((r) => p(r)) && (u = !0)) : (l = x(i.resource), p(i.resource) && (u = !0)) : i.body && (Array.isArray(i.body) ? (l = i.body.map((r) => x(r)).join(" "), i.body.some((r) => p(r)) && (u = !0)) : (l = x(i.body), p(i.body) && (u = !0))), !l) {
972
- const r = i.label || i.name || i.title;
973
- r && (l = Array.isArray(r) ? r.join(" ") : r);
974
- }
975
- }
976
- return {
977
- id: c(i),
978
- content: l,
979
- isHtml: u,
980
- label: (typeof i.getLabel == "function" ? i.getLabel() : i.label) || ""
981
- };
982
- }) : []);
983
- var S = e.comment(), L = e.first_child(S);
984
- {
985
- var R = (i) => {
986
- var l = $s(), u = e.child(l), x = e.child(u), p = e.child(x);
987
- p.__click = (b) => {
988
- b.preventDefault(), I();
989
- };
990
- var r = e.child(p);
991
- {
992
- var g = (b) => {
993
- je(b, { size: 16, weight: "bold" });
994
- }, y = (b) => {
995
- Le(b, { size: 16, weight: "bold" });
996
- };
997
- e.if(r, (b) => {
998
- e.get(d) ? b(g) : b(y, !1);
999
- });
1000
- }
1001
- e.reset(p);
1002
- var m = e.sibling(p, 2), E = e.child(m), k = e.sibling(E), T = e.child(k, !0);
1003
- e.reset(k), e.reset(m);
1004
- var _ = e.sibling(m, 2);
1005
- Ye(_, {
1006
- size: 16,
1007
- weight: "bold",
1008
- class: "group-open:rotate-180 transition-transform opacity-80"
1009
- }), e.reset(x);
1010
- var C = e.sibling(x, 2);
1011
- e.each(
1012
- C,
1013
- 21,
1014
- () => e.get(v),
1015
- e.index,
1016
- (b, o, h) => {
1017
- const A = e.derived(() => a.visibleAnnotationIds.has(e.get(o).id));
1018
- var f = Is();
1019
- f.__click = (N) => {
1020
- N.preventDefault(), G(e.get(o).id);
1021
- };
1022
- var D = e.child(f), $ = e.child(D);
1023
- {
1024
- var w = (N) => {
1025
- je(N, { size: 16, weight: "bold" });
1026
- }, j = (N) => {
1027
- Le(N, { size: 16, weight: "bold" });
1028
- };
1029
- e.if($, (N) => {
1030
- e.get(A) ? N(w) : N(j, !1);
1031
- });
1032
- }
1033
- e.reset(D);
1034
- var H = e.sibling(D, 2), V = e.child(H), B = e.child(V);
1035
- B.textContent = `#${h + 1}`;
1036
- var F = e.sibling(B, 2);
1037
- {
1038
- var O = (N) => {
1039
- var X = As(), W = e.child(X, !0);
1040
- e.reset(X), e.template_effect(() => e.set_text(W, e.get(o).label)), e.append(N, X);
1041
- };
1042
- e.if(F, (N) => {
1043
- e.get(o).label && e.get(o).label !== e.get(o).content && N(O);
1044
- });
1045
- }
1046
- e.reset(V);
1047
- var q = e.sibling(V, 2), U = e.child(q);
1048
- {
1049
- var K = (N) => {
1050
- var X = e.comment(), W = e.first_child(X);
1051
- e.html(W, () => e.get(o).content), e.append(N, X);
1052
- }, Q = (N) => {
1053
- var X = e.text();
1054
- e.template_effect(() => e.set_text(X, e.get(o).content || "(No content)")), e.append(N, X);
1055
- };
1056
- e.if(U, (N) => {
1057
- e.get(o).isHtml ? N(K) : N(Q, !1);
1058
- });
1059
- }
1060
- e.reset(q), e.reset(H), e.reset(f), e.template_effect(() => e.set_class(q, 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(A) ? "" : "opacity-50"}`)), e.append(b, f);
1061
- },
1062
- (b) => {
1063
- var o = Ts();
1064
- e.append(b, o);
1065
- }
1066
- ), e.reset(C), e.reset(u), e.reset(l), e.template_effect(
1067
- (b, o, h) => {
1068
- e.set_class(l, 1, `absolute top-4 z-500 pointer-events-auto transition-all duration-300 ${a.showSearchPanel ? a.showThumbnailGallery && a.isGalleryDockedRight ? "right-[536px]" : "right-[336px]" : a.showThumbnailGallery && a.isGalleryDockedRight ? "right-[216px]" : "right-4"}`), e.set_attribute(p, "title", b), e.set_text(E, `${o ?? ""} `), e.set_text(T, h);
1069
- },
1070
- [
1071
- () => e.get(d) ? P.hide_all_annotations() : P.show_all_annotations(),
1072
- () => P.annotations_count({ count: e.get(n).length }),
1073
- () => P.visible_count({ count: a.visibleAnnotationIds.size })
1074
- ]
1075
- ), e.append(i, l);
1076
- };
1077
- e.if(L, (i) => {
1078
- a.showAnnotations && i(R);
1079
- });
1080
- }
1081
- e.append(s, S), e.pop();
1082
- }
1083
- e.delegate(["click"]);
1084
- var Cs = e.from_html('<img class="object-contain w-full h-full" loading="lazy"/>'), js = e.from_html('<span class="opacity-20 text-4xl">?</span>'), Ls = 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>'), Ms = 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>'), Gs = 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), Es = 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);
1085
- function Rs(s, t) {
1086
- e.push(t, !0);
1087
- const a = xe(se);
1088
- let n = e.state(e.proxy({ x: 20, y: 100 })), c = e.state(e.proxy({ width: 300, height: 400 })), d = e.state(!1), G = e.state(!1), I = { x: 0, y: 0 }, v = { x: 0, y: 0, w: 0, h: 0 }, S = e.state(void 0), L = e.derived(() => t.canvases ? t.canvases.map((_, C) => {
1089
- let b = "";
1090
- try {
1091
- if (_.getThumbnail) {
1092
- const o = _.getThumbnail();
1093
- o && (b = typeof o == "string" ? o : o.id || o["@id"]);
1094
- }
1095
- } catch (o) {
1096
- console.warn("Error getting thumbnail", o);
1097
- }
1098
- if (!b) {
1099
- let o = _.getImages();
1100
- if ((!o || !o.length) && _.getContent && (o = _.getContent()), o && o.length > 0) {
1101
- const h = o[0];
1102
- let A = h.getResource ? h.getResource() : null;
1103
- if (!A && h.getBody) {
1104
- const f = h.getBody();
1105
- Array.isArray(f) && f.length > 0 ? A = f[0] : f && (A = f);
1106
- }
1107
- if (A && !A.id && !A.__jsonld && (!A.getServices || A.getServices().length === 0) && (A = null), !A) {
1108
- const f = h.__jsonld || h;
1109
- f.body && (A = Array.isArray(f.body) ? f.body[0] : f.body);
1110
- }
1111
- if (A) {
1112
- const D = (() => {
1113
- let w = [];
1114
- if (A.getServices && (w = A.getServices()), !w || w.length === 0) {
1115
- const j = A.__jsonld || A;
1116
- j.service && (w = Array.isArray(j.service) ? j.service : [j.service]);
1117
- }
1118
- return w;
1119
- })();
1120
- let $ = !1;
1121
- if (D.length > 0) {
1122
- const w = D[0];
1123
- let j = "";
1124
- try {
1125
- j = w.getProfile ? w.getProfile() : w.profile || "", typeof j == "object" && j !== null && (j = j.value || j.id || j["@id"] || JSON.stringify(j));
1126
- } catch {
1127
- }
1128
- const H = String(j).toLowerCase();
1129
- (H.includes("level0") || H.includes("level-0")) && ($ = !0);
1130
- const V = w.id || w["@id"];
1131
- $ || (b = `${V}/full/200,/0/default.jpg`);
1132
- }
1133
- if (!b && (b = A.id || A["@id"], !b)) {
1134
- let w = null;
1135
- if (h.__jsonld && h.__jsonld.body ? w = h.__jsonld.body : h.body && (w = h.body), w) {
1136
- const j = Array.isArray(w) ? w[0] : w;
1137
- b = j.id || j["@id"];
1138
- }
1139
- }
1140
- }
1141
- }
1142
- }
1143
- return {
1144
- id: _.id,
1145
- label: _.getLabel().length ? _.getLabel()[0].value : `Canvas ${C + 1}`,
1146
- src: b,
1147
- index: C
1148
- };
1149
- }) : []);
1150
- function R(_) {
1151
- if (!e.get(d)) return;
1152
- let C = _.clientX - I.x, b = _.clientY - I.y;
1153
- if (e.get(S) && e.get(S).parentElement) {
1154
- const o = e.get(S).parentElement, h = Math.max(0, o.clientWidth - e.get(c).width), A = Math.max(0, o.clientHeight - e.get(c).height);
1155
- C = Math.max(0, Math.min(C, h)), b = Math.max(0, Math.min(b, A));
1156
- }
1157
- e.get(n).x = C, e.get(n).y = b;
1158
- }
1159
- function i() {
1160
- const _ = e.get(g);
1161
- e.set(d, !1), e.set(g, null), window.removeEventListener("mousemove", R), window.removeEventListener("mouseup", i), _ && e.set(r, _, !0);
1162
- }
1163
- function l(_) {
1164
- _.stopPropagation(), e.set(G, !0), v = {
1165
- x: _.clientX,
1166
- y: _.clientY,
1167
- w: e.get(c).width,
1168
- h: e.get(c).height
1169
- }, window.addEventListener("mousemove", u), window.addEventListener("mouseup", x);
1170
- }
1171
- function u(_) {
1172
- if (!e.get(G)) return;
1173
- const C = _.clientX - v.x, b = _.clientY - v.y;
1174
- e.get(c).width = Math.max(200, v.w + C), e.get(c).height = Math.max(200, v.h + b);
1175
- }
1176
- function x() {
1177
- e.set(G, !1), window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", x);
1178
- }
1179
- function p(_) {
1180
- a.canvasId = _;
1181
- }
1182
- let r = e.state("bottom"), g = e.state(null);
1183
- e.user_effect(() => {
1184
- a.dockSide = e.get(r), a.isGalleryDockedBottom = e.get(r) === "bottom", a.isGalleryDockedRight = e.get(r) === "right";
1185
- });
1186
- let y = e.derived(() => e.get(r) === "top" || e.get(r) === "bottom" || e.get(r) === "none" && e.get(c).height < 320);
1187
- function m(_) {
1188
- var C, b;
1189
- if (!_.target.closest(".resize-handle")) {
1190
- if (e.get(r) !== "none") {
1191
- e.set(r, "none");
1192
- const o = ((b = (C = e.get(S)) == null ? void 0 : C.parentElement) == null ? void 0 : b.getBoundingClientRect()) || { left: 0, top: 0 };
1193
- e.set(c, { width: 300, height: 400 }, !0), e.set(
1194
- n,
1195
- {
1196
- x: _.clientX - o.left - 150,
1197
- // Center width
1198
- y: _.clientY - o.top - 20
1199
- // Offset slightly from top
1200
- },
1201
- !0
1202
- );
1203
- }
1204
- e.set(d, !0), I = {
1205
- x: _.clientX - e.get(n).x,
1206
- y: _.clientY - e.get(n).y
1207
- }, window.addEventListener("mousemove", R), window.addEventListener("mouseup", i);
1208
- }
1209
- }
1210
- var E = e.comment(), k = e.first_child(E);
1211
- {
1212
- var T = (_) => {
1213
- var C = Es(), b = e.first_child(C), o = e.child(b);
1214
- o.__click = () => a.toggleThumbnailGallery();
1215
- var h = e.child(o);
1216
- Xe(h, { size: 16, weight: "bold" }), e.reset(o);
1217
- var A = e.sibling(o, 2), f = e.child(A);
1218
- f.__mousedown = m;
1219
- var D = e.child(f);
1220
- e.reset(f), e.reset(A);
1221
- var $ = e.sibling(A, 2), w = e.child($);
1222
- e.each(w, 21, () => e.get(L), e.index, (F, O) => {
1223
- var q = Ls();
1224
- q.__click = () => p(e.get(O).id);
1225
- var U = e.child(q), K = e.child(U);
1226
- {
1227
- var Q = (J) => {
1228
- var Z = Cs();
1229
- e.template_effect(() => {
1230
- e.set_attribute(Z, "src", e.get(O).src), e.set_attribute(Z, "alt", e.get(O).label);
1231
- }), e.append(J, Z);
1232
- }, N = (J) => {
1233
- var Z = js();
1234
- e.append(J, Z);
1235
- };
1236
- e.if(K, (J) => {
1237
- e.get(O).src ? J(Q) : J(N, !1);
1238
- });
1239
- }
1240
- e.reset(U);
1241
- var X = e.sibling(U, 2), W = e.child(X), we = e.child(W);
1242
- e.reset(W);
1243
- var Se = e.sibling(W);
1244
- e.reset(X), e.reset(q), e.template_effect(() => {
1245
- e.set_class(q, 1, `group flex flex-col gap-1 p-1 rounded hover:bg-base-200 transition-colors text-left relative shrink-0 ${e.get(y) ? "w-[140px]" : ""} ${a.canvasId === e.get(O).id ? "ring-2 ring-primary bg-primary/5" : ""}`), e.set_attribute(q, "aria-label", `Select canvas ${e.get(O).label ?? ""}`), e.set_text(we, `${e.get(O).index + 1}.`), e.set_text(Se, ` ${e.get(O).label ?? ""}`);
1246
- }), e.append(F, q);
1247
- }), e.reset(w), e.reset($);
1248
- var j = e.sibling($, 2);
1249
- {
1250
- var H = (F) => {
1251
- var O = Ms();
1252
- O.__mousedown = l, e.append(F, O);
1253
- };
1254
- e.if(j, (F) => {
1255
- e.get(r) === "none" && F(H);
1256
- });
1257
- }
1258
- e.reset(b), e.bind_this(b, (F) => e.set(S, F), () => e.get(S));
1259
- var V = e.sibling(b, 2);
1260
- {
1261
- var B = (F) => {
1262
- var O = Gs(), q = e.first_child(O), U = e.sibling(q, 2), K = e.sibling(U, 2), Q = e.sibling(K, 2);
1263
- e.template_effect(() => {
1264
- e.set_class(q, 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 ${e.get(g) === "top" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`), e.set_class(U, 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 ${e.get(g) === "bottom" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`), e.set_class(K, 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 ${e.get(g) === "left" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`), e.set_class(Q, 1, `absolute top-2 bottom-2 w-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-300 ${a.showSearchPanel ? "right-[328px]" : "right-2"} ${e.get(g) === "right" ? "bg-primary/20 scale-105" : "bg-base-100/50"}`);
1265
- }), e.event("mouseenter", q, () => e.set(g, "top")), e.event("mouseleave", q, () => e.set(g, null)), e.event("mouseenter", U, () => e.set(g, "bottom")), e.event("mouseleave", U, () => e.set(g, null)), e.event("mouseenter", K, () => e.set(g, "left")), e.event("mouseleave", K, () => e.set(g, null)), e.event("mouseenter", Q, () => e.set(g, "right")), e.event("mouseleave", Q, () => e.set(g, null)), e.append(F, O);
1266
- };
1267
- e.if(V, (F) => {
1268
- e.get(d) && F(B);
1269
- });
1270
- }
1271
- e.template_effect(() => {
1272
- e.set_class(b, 1, (e.get(r) !== "none" ? `absolute z-900 bg-base-100 shadow-xl border-base-300 flex transition-all duration-200
1273
- ${e.get(r) === "bottom" ? "flex-row bottom-0 left-0 right-0 h-[140px] border-t" : ""}
1274
- ${e.get(r) === "top" ? "flex-row top-0 left-0 right-0 h-[140px] border-b" : ""}
1275
- ${e.get(r) === "left" ? "flex-col left-0 top-0 bottom-0 w-[200px] border-r" : ""}
1276
- ${e.get(r) === "right" ? `flex-col top-0 bottom-0 w-[200px] border-l ${a.showSearchPanel ? "right-80" : "right-0"}` : ""}` : "absolute z-900 bg-base-100 shadow-2xl rounded-lg flex flex-col border border-base-300 overflow-hidden") + (e.get(d) ? " pointer-events-none opacity-80" : "")), e.set_style(b, e.get(r) !== "none" ? "" : `left: ${e.get(n).x}px; top: ${e.get(n).y}px; width: ${e.get(c).width}px; height: ${e.get(c).height}px;`), e.set_class(A, 1, "bg-base-100 flex shrink-0 select-none relative " + (e.get(r) === "bottom" || e.get(r) === "top" ? "flex-row h-full items-center border-r border-base-200" : "flex-col w-full border-b border-base-200")), e.set_class(f, 1, "cursor-move flex items-center justify-center hover:bg-base-200/50 active:bg-base-200 transition-colors " + (e.get(r) === "bottom" || e.get(r) === "top" ? "w-8 h-full" : "h-6 w-full")), e.set_class(D, 1, "bg-base-300 rounded-full " + (e.get(r) === "bottom" || e.get(r) === "top" ? "w-1.5 h-12" : "w-12 h-1.5")), e.set_class($, 1, `flex-1 p-1 bg-base-100 ${e.get(y) ? "overflow-x-auto overflow-y-hidden" : "overflow-y-auto overflow-x-hidden"}`), e.set_class(w, 1, e.clsx(e.get(y) ? "flex flex-row gap-2 h-full items-center" : "grid gap-2")), e.set_style(w, e.get(y) ? "" : "grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));");
1277
- }), e.append(_, C);
1278
- };
1279
- e.if(k, (_) => {
1280
- a.showThumbnailGallery && _(T);
1281
- });
1282
- }
1283
- e.append(s, E), e.pop();
1284
- }
1285
- e.delegate(["click", "mousedown"]);
1286
- var Ps = e.from_html('<div><div tabindex="0" role="button" class="btn btn-lg btn-primary btn-circle shadow-xl"><span class="sr-only"> </span> <!></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>');
1287
- function zs(s, t) {
1288
- e.push(t, !1);
1289
- const a = xe(se);
1290
- e.init();
1291
- var n = Ps(), c = e.child(n), d = e.child(c), G = e.child(d, !0);
1292
- e.reset(d);
1293
- var I = e.sibling(d, 2);
1294
- Je(I, { size: 32, weight: "bold" }), e.reset(c);
1295
- var v = e.sibling(c, 2), S = e.child(v);
1296
- S.__click = () => a.toggleSearchPanel();
1297
- var L = e.child(S);
1298
- Ee(L, { size: 28, weight: "bold" }), e.reset(S), e.reset(v);
1299
- var R = e.sibling(v, 2), i = e.child(R);
1300
- i.__click = () => a.toggleThumbnailGallery();
1301
- var l = e.child(i);
1302
- Ze(l, { size: 28, weight: "bold" }), e.reset(i), e.reset(R);
1303
- var u = e.sibling(R, 2), x = e.child(u);
1304
- x.__click = () => a.toggleFullScreen();
1305
- var p = e.child(x);
1306
- {
1307
- var r = (C) => {
1308
- Ue(C, { size: 28, weight: "bold" });
1309
- }, g = (C) => {
1310
- Ke(C, { size: 28, weight: "bold" });
1311
- };
1312
- e.if(p, (C) => {
1313
- a.isFullScreen ? C(r) : C(g, !1);
1314
- });
1315
- }
1316
- e.reset(x), e.reset(u);
1317
- var y = e.sibling(u, 2), m = e.child(y);
1318
- m.__click = () => a.toggleAnnotations();
1319
- var E = e.child(m);
1320
- Qe(E, { size: 28, weight: "bold" }), e.reset(m), e.reset(y);
1321
- var k = e.sibling(y, 2), T = e.child(k);
1322
- T.__click = () => a.toggleMetadataDialog();
1323
- var _ = e.child(T);
1324
- We(_, { size: 28, weight: "bold" }), e.reset(T), e.reset(k), e.reset(n), e.template_effect(
1325
- (C, b, o, h, A, f, D, $, w, j, H) => {
1326
- e.set_class(n, 1, `fab fab-flower fab-top-left absolute z-600 pointer-events-auto flex-col items-end transition-all duration-300 ${a.showSearchPanel ? a.showThumbnailGallery && a.isGalleryDockedRight ? "right-[540px]" : "right-[344px]" : a.showThumbnailGallery && a.isGalleryDockedRight ? "right-[220px]" : "right-6"} ${a.showThumbnailGallery && a.dockSide === "bottom" ? "bottom-40" : "bottom-6"}`), e.set_attribute(n, "data-tip", C), e.set_text(G, b), e.set_attribute(v, "data-tip", o), e.set_attribute(S, "aria-label", h), e.set_class(S, 1, e.clsx([
1327
- "btn btn-circle btn-lg shadow-lg",
1328
- a.showSearchPanel && "btn-primary",
1329
- !a.showSearchPanel && "btn-neutral"
1330
- ])), e.set_attribute(R, "data-tip", A), e.set_attribute(i, "aria-label", f), e.set_class(i, 1, `btn btn-lg btn-circle shadow-lg ${a.showThumbnailGallery ? "btn-info" : "btn-neutral"}`), e.set_attribute(u, "data-tip", D), e.set_class(x, 1, `btn btn-circle btn-lg shadow-lg transition-all duration-300 ease-out ${a.isFullScreen ? "btn-warning" : "btn-neutral"}`), e.set_attribute(y, "data-tip", $), e.set_attribute(m, "aria-label", w), e.set_class(m, 1, `btn btn-lg btn-circle shadow-lg ${a.showAnnotations ? "btn-error" : "btn-neutral"}`), e.set_attribute(k, "data-tip", j), e.set_attribute(T, "aria-label", H), e.set_class(T, 1, `btn btn-lg btn-circle shadow-lg ${a.showMetadataDialog ? "btn-info" : "btn-neutral"}`);
1331
- },
1332
- [
1333
- () => P.menu(),
1334
- () => P.menu(),
1335
- () => P.search(),
1336
- () => P.toggle_search(),
1337
- () => a.showThumbnailGallery ? P.hide_gallery() : P.show_gallery(),
1338
- () => a.showThumbnailGallery ? P.hide_gallery() : P.show_gallery(),
1339
- () => a.isFullScreen ? P.exit_full_screen() : P.enter_full_screen(),
1340
- () => a.showAnnotations ? P.hide_annotations() : P.show_annotations(),
1341
- () => P.toggle_annotations(),
1342
- () => P.metadata(),
1343
- () => P.toggle_metadata()
1344
- ]
1345
- ), e.append(s, n), e.pop();
1346
- }
1347
- e.delegate(["click"]);
1348
- var Ds = e.from_html('<div class="mb-6 prose"><p><!></p></div>'), Fs = e.from_html('<dt class="font-bold text-lg opacity-70 mt-6"> </dt> <dd class="text-sm ps-2"><!></dd>', 1), Hs = 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), Ns = e.from_html('<dt class="font-bold text-lg opacity-70 mt-6"> </dt> <dd class="text-sm ps-2"><!></dd>', 1), Vs = 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>');
1349
- function Bs(s, t) {
1350
- e.push(t, !0);
1351
- const a = xe(se);
1352
- let n = e.derived(() => a.manifest), c = e.derived(() => {
1353
- const f = xs.current;
1354
- if (!e.get(n)) return [];
1355
- const D = e.get(n).getMetadata();
1356
- return D ? D.map(($) => {
1357
- let w = "", j = "";
1358
- const H = (V) => {
1359
- if (typeof V == "string") return V;
1360
- if (Array.isArray(V)) {
1361
- let B = V.find((F) => F.locale === f || F.language === f);
1362
- return B || (B = V.find((F) => F.locale === "en" || F.language === "en")), B || (B = V.find((F) => !F.locale && !F.language)), B || (B = V[0]), B ? B.value : "";
1363
- }
1364
- return String(V);
1365
- };
1366
- return $.getLabel ? w = H($.getLabel()) : $.label && (w = H($.label)), $.getValue ? j = H($.getValue()) : $.value && (j = H($.value)), { label: w, value: j };
1367
- }) : [];
1368
- }), d = e.derived(() => e.get(n) ? e.get(n).getDescription() : ""), G = e.derived(() => {
1369
- var f;
1370
- return e.get(n) ? (f = e.get(n).getRequiredStatement()) == null ? void 0 : f.getValue() : "";
1371
- }), I = e.derived(() => e.get(n) ? e.get(n).getLicense() : "");
1372
- var v = Vs(), S = e.child(v), L = e.child(S), R = e.child(L);
1373
- R.__click = () => a.toggleMetadataDialog(), e.reset(L);
1374
- var i = e.sibling(L, 2), l = e.child(i, !0);
1375
- e.reset(i);
1376
- var u = e.sibling(i, 2), x = e.child(u);
1377
- {
1378
- var p = (f) => {
1379
- var D = Ds(), $ = e.child(D), w = e.child($);
1380
- e.html(w, () => e.get(d)), e.reset($), e.reset(D), e.append(f, D);
1381
- };
1382
- e.if(x, (f) => {
1383
- e.get(d) && f(p);
1384
- });
1385
- }
1386
- var r = e.sibling(x, 2), g = e.child(r);
1387
- {
1388
- var y = (f) => {
1389
- var D = Fs(), $ = e.first_child(D), w = e.child($, !0);
1390
- e.reset($);
1391
- var j = e.sibling($, 2), H = e.child(j);
1392
- e.html(H, () => e.get(G)), e.reset(j), e.template_effect((V) => e.set_text(w, V), [() => P.attribution()]), e.append(f, D);
1393
- };
1394
- e.if(g, (f) => {
1395
- e.get(G) && f(y);
1396
- });
1397
- }
1398
- var m = e.sibling(g, 2);
1399
- {
1400
- var E = (f) => {
1401
- var D = Hs(), $ = e.first_child(D), w = e.child($, !0);
1402
- e.reset($);
1403
- var j = e.sibling($, 2), H = e.child(j), V = e.child(H, !0);
1404
- e.reset(H), e.reset(j), e.template_effect(
1405
- (B) => {
1406
- e.set_text(w, B), e.set_attribute(H, "href", e.get(I)), e.set_text(V, e.get(I));
1407
- },
1408
- [() => P.license()]
1409
- ), e.append(f, D);
1410
- };
1411
- e.if(m, (f) => {
1412
- e.get(I) && f(E);
1413
- });
1414
- }
1415
- var k = e.sibling(m, 2);
1416
- e.each(k, 17, () => e.get(c), e.index, (f, D) => {
1417
- var $ = Ns(), w = e.first_child($), j = e.child(w, !0);
1418
- e.reset(w);
1419
- var H = e.sibling(w, 2), V = e.child(H);
1420
- e.html(V, () => e.get(D).value), e.reset(H), e.template_effect(() => e.set_text(j, e.get(D).label)), e.append(f, $);
1421
- }), e.reset(r), e.reset(u);
1422
- var T = e.sibling(u, 2), _ = e.child(T), C = e.child(_);
1423
- C.__click = () => a.toggleMetadataDialog();
1424
- var b = e.child(C, !0);
1425
- e.reset(C), e.reset(_), e.reset(T), e.reset(S);
1426
- var o = e.sibling(S, 2), h = e.child(o);
1427
- h.__click = () => a.toggleMetadataDialog();
1428
- var A = e.child(h, !0);
1429
- e.reset(h), e.reset(o), e.reset(v), e.template_effect(
1430
- (f, D, $) => {
1431
- v.open = a.showMetadataDialog, e.set_text(l, f), e.set_text(b, D), e.set_text(A, $);
1432
- },
1433
- [
1434
- () => e.get(n) ? e.get(n).getLabel().length && e.get(n).getLabel()[0] ? e.get(n).getLabel()[0].value : P.metadata_label_fallback() : P.loading(),
1435
- () => P.close(),
1436
- () => P.close()
1437
- ]
1438
- ), e.append(s, v), e.pop();
1439
- }
1440
- e.delegate(["click"]);
1441
- var Os = e.from_html('<span class="loading loading-spinner loading-xs"></span>'), qs = e.from_html('<div class="flex justify-center p-8"><span class="loading loading-spinner loading-lg text-primary"></span></div>'), Ys = e.from_html('<div class="text-center opacity-50 p-4"> </div>'), Xs = e.from_html('<div class="text-center opacity-50 p-4 text-sm"> </div>'), Qs = 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>'), Us = e.from_html('<div class="leading-relaxed"> </div>'), Ks = 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>'), Ws = e.from_html('<div class="text-xs font-bold opacity-50 uppercase tracking-wider pb-2"> </div> <!>', 1), Js = e.from_html('<div class="absolute top-0 right-0 h-full w-80 bg-base-200 shadow-2xl z-1000 transform transition-transform duration-300 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>');
1442
- function Zs(s, t) {
1443
- e.push(t, !0);
1444
- const a = xe(se);
1445
- let n = e.state(e.proxy(a.searchQuery));
1446
- function c() {
1447
- a.search(e.get(n));
1448
- }
1449
- function d(L) {
1450
- L.key === "Enter" && c();
1451
- }
1452
- function G(L) {
1453
- const R = a.canvases[L.canvasIndex];
1454
- R && (a.canvasId = R.id);
1455
- }
1456
- var I = e.comment(), v = e.first_child(I);
1457
- {
1458
- var S = (L) => {
1459
- var R = Js(), i = e.child(R), l = e.child(i), u = e.child(l, !0);
1460
- e.reset(l);
1461
- var x = e.sibling(l, 2);
1462
- x.__click = () => a.toggleSearchPanel(), e.reset(i);
1463
- var p = e.sibling(i, 2), r = e.child(p), g = e.child(r);
1464
- e.remove_input_defaults(g), g.__keydown = d;
1465
- var y = e.sibling(g, 2);
1466
- y.__click = c;
1467
- var m = e.child(y);
1468
- {
1469
- var E = (o) => {
1470
- var h = Os();
1471
- e.append(o, h);
1472
- }, k = (o) => {
1473
- Ee(o, { size: 20, weight: "bold" });
1474
- };
1475
- e.if(m, (o) => {
1476
- a.isSearching ? o(E) : o(k, !1);
1477
- });
1478
- }
1479
- e.reset(y), e.reset(r), e.reset(p);
1480
- var T = e.sibling(p, 2), _ = e.child(T);
1481
- {
1482
- var C = (o) => {
1483
- var h = qs();
1484
- e.append(o, h);
1485
- }, b = (o) => {
1486
- var h = e.comment(), A = e.first_child(h);
1487
- {
1488
- var f = ($) => {
1489
- var w = Ys(), j = e.child(w, !0);
1490
- e.reset(w), e.template_effect((H) => e.set_text(j, H), [
1491
- () => P.search_panel_no_results({ query: a.searchQuery })
1492
- ]), e.append($, w);
1493
- }, D = ($) => {
1494
- var w = e.comment(), j = e.first_child(w);
1495
- {
1496
- var H = (B) => {
1497
- var F = Xs(), O = e.child(F, !0);
1498
- e.reset(F), e.template_effect((q) => e.set_text(O, q), [() => P.search_panel_instruction()]), e.append(B, F);
1499
- }, V = (B) => {
1500
- var F = Ws(), O = e.first_child(F), q = e.child(O, !0);
1501
- e.reset(O);
1502
- var U = e.sibling(O, 2);
1503
- e.each(U, 17, () => a.searchResults, e.index, (K, Q) => {
1504
- var N = Ks();
1505
- N.__click = () => G(e.get(Q));
1506
- var X = e.child(N), W = e.child(X), we = e.child(W, !0);
1507
- e.reset(W), e.reset(X);
1508
- var Se = e.sibling(X, 2);
1509
- {
1510
- var J = (te) => {
1511
- var ee = Qs(), ne = e.child(ee), ze = e.child(ne);
1512
- e.html(ze, () => e.get(Q).before), e.reset(ne);
1513
- var Ae = e.sibling(ne, 2), De = e.child(Ae);
1514
- e.html(De, () => e.get(Q).match), e.reset(Ae);
1515
- var $e = e.sibling(Ae, 2), Fe = e.child($e);
1516
- e.html(Fe, () => e.get(Q).after), e.reset($e), e.reset(ee), e.append(te, ee);
1517
- }, Z = (te) => {
1518
- var ee = Us(), ne = e.child(ee, !0);
1519
- e.reset(ee), e.template_effect(() => e.set_text(ne, e.get(Q).match)), e.append(te, ee);
1520
- };
1521
- e.if(Se, (te) => {
1522
- e.get(Q).type === "hit" ? te(J) : te(Z, !1);
1523
- });
1524
- }
1525
- e.reset(N), e.template_effect(() => e.set_text(we, e.get(Q).canvasLabel)), e.append(K, N);
1526
- }), e.template_effect((K) => e.set_text(q, K), [
1527
- () => P.search_panel_results_count({ count: a.searchResults.length })
1528
- ]), e.append(B, F);
1529
- };
1530
- e.if(
1531
- j,
1532
- (B) => {
1533
- a.searchResults.length === 0 && !a.searchQuery ? B(H) : B(V, !1);
1534
- },
1535
- !0
1536
- );
1537
- }
1538
- e.append($, w);
1539
- };
1540
- e.if(
1541
- A,
1542
- ($) => {
1543
- a.searchResults.length === 0 && a.searchQuery ? $(f) : $(D, !1);
1544
- },
1545
- !0
1546
- );
1547
- }
1548
- e.append(o, h);
1549
- };
1550
- e.if(_, (o) => {
1551
- a.isSearching ? o(C) : o(b, !1);
1552
- });
1553
- }
1554
- e.reset(T), e.reset(R), e.template_effect(
1555
- (o, h, A, f, D) => {
1556
- e.set_attribute(R, "aria-label", o), e.set_text(u, h), e.set_attribute(x, "aria-label", A), e.set_attribute(g, "placeholder", f), e.set_attribute(y, "aria-label", D);
1557
- },
1558
- [
1559
- () => P.search_panel_title(),
1560
- () => P.search_panel_title(),
1561
- () => P.search_panel_close(),
1562
- () => P.search_panel_placeholder(),
1563
- () => P.search_panel_title()
1564
- ]
1565
- ), e.bind_value(g, () => e.get(n), (o) => e.set(n, o)), e.append(L, R);
1566
- };
1567
- e.if(v, (L) => {
1568
- a.showSearchPanel && L(S);
1569
- });
1570
- }
1571
- e.append(s, I), e.pop();
1572
- }
1573
- e.delegate(["click", "keydown"]);
1574
- var en = e.from_html('<span class="loading loading-spinner loading-lg text-primary"></span>'), tn = e.from_html('<div class="text-error"> </div>'), an = e.from_html('<div class="text-base-content/50">No image found</div>'), sn = e.from_html("<!> <!>", 1), nn = e.from_html('<div id="triiiceratops-viewer" class="w-full h-full relative bg-base-100 flex items-center justify-center"><!> <!> <!> <!> <!> <!></div>');
1575
- function An(s, t) {
1576
- e.push(t, !0);
1577
- const a = new tt();
1578
- Ve(se, a), e.user_effect(() => {
1579
- t.manifestId && a.setManifest(t.manifestId);
1580
- }), e.user_effect(() => {
1581
- const r = () => {
1582
- a.isFullScreen = !!document.fullscreenElement;
1583
- };
1584
- return document.addEventListener("fullscreenchange", r), () => {
1585
- document.removeEventListener("fullscreenchange", r);
1586
- };
1587
- });
1588
- let n = e.derived(() => a.manifest), c = e.derived(() => a.canvases), d = e.derived(() => a.currentCanvasIndex), G = e.derived(() => {
1589
- var C, b;
1590
- if (!e.get(c) || e.get(d) === -1 || !e.get(c)[e.get(d)])
1591
- return (C = e.get(n)) != null && C.isFetching || console.log("TriiiceratopsViewer: No canvas found"), null;
1592
- const r = e.get(c)[e.get(d)];
1593
- let g = r.getImages();
1594
- if ((!g || !g.length) && r.getContent && (g = r.getContent()), !g || !g.length)
1595
- return r.__jsonld && r.__jsonld.items, (b = e.get(n)) != null && b.isFetching || console.log("TriiiceratopsViewer: No images/content in canvas"), null;
1596
- const y = g[0];
1597
- let m = y.getResource ? y.getResource() : null;
1598
- if (!m && y.getBody) {
1599
- const o = y.getBody();
1600
- Array.isArray(o) && o.length > 0 ? m = o[0] : o && (m = o);
1601
- }
1602
- if (m && !m.id && !m.__jsonld && (!m.getServices || m.getServices().length === 0) && (m = null), !m) {
1603
- const o = y.__jsonld || y;
1604
- o.body && (m = Array.isArray(o.body) ? o.body[0] : o.body);
1605
- }
1606
- if (!m)
1607
- return null;
1608
- const E = (o) => o.id || o["@id"];
1609
- let k = [];
1610
- if (m.getServices && (k = m.getServices()), !k.length) {
1611
- const o = m.__jsonld || m;
1612
- o.service && (k = Array.isArray(o.service) ? o.service : [o.service]);
1613
- }
1614
- if (k.length > 0) {
1615
- const o = k.find((h) => {
1616
- const A = h.getType ? h.getType() : h.type || "", f = h.getProfile ? h.getProfile() : h.profile || "";
1617
- return A === "ImageService1" || A === "ImageService2" || A === "ImageService3" || typeof f == "string" && f.includes("http://iiif.io/api/image") || typeof f == "string" && f === "level0";
1618
- });
1619
- if (o) {
1620
- let h = E(o);
1621
- return h && !h.endsWith("/info.json") && (h = `${h}/info.json`), h;
1622
- }
1623
- }
1624
- const T = E(m);
1625
- if (T && T.includes("/iiif/")) {
1626
- const o = T.split("/"), h = o.findIndex((A) => A === "full" || A.match(/^\d+,\d+,\d+,\d+$/));
1627
- if (h > 0)
1628
- return `${o.slice(0, h).join("/")}/info.json`;
1629
- }
1630
- return console.log("TriiiceratopsViewer: No service or ID found, returning raw URL"), { type: "image", url: T };
1631
- });
1632
- var I = nn(), v = e.child(I);
1633
- {
1634
- var S = (r) => {
1635
- var g = en();
1636
- e.append(r, g);
1637
- }, L = (r) => {
1638
- var g = e.comment(), y = e.first_child(g);
1639
- {
1640
- var m = (k) => {
1641
- var T = tn(), _ = e.child(T);
1642
- e.reset(T), e.template_effect(() => e.set_text(_, `Error: ${e.get(n).error ?? ""}`)), e.append(k, T);
1643
- }, E = (k) => {
1644
- var T = e.comment(), _ = e.first_child(T);
1645
- {
1646
- var C = (o) => {
1647
- var h = e.comment(), A = e.first_child(h);
1648
- e.key(A, () => e.get(G), (f) => {
1649
- vt(f, {
1650
- get tileSources() {
1651
- return e.get(G);
1652
- },
1653
- get viewerState() {
1654
- return a;
1655
- }
1656
- });
1657
- }), e.append(o, h);
1658
- }, b = (o) => {
1659
- var h = an();
1660
- e.append(o, h);
1661
- };
1662
- e.if(
1663
- _,
1664
- (o) => {
1665
- e.get(G) ? o(C) : o(b, !1);
1666
- },
1667
- !0
1668
- );
1669
- }
1670
- e.append(k, T);
1671
- };
1672
- e.if(
1673
- y,
1674
- (k) => {
1675
- var T;
1676
- (T = e.get(n)) != null && T.error ? k(m) : k(E, !1);
1677
- },
1678
- !0
1679
- );
1680
- }
1681
- e.append(r, g);
1682
- };
1683
- e.if(v, (r) => {
1684
- var g;
1685
- (g = e.get(n)) != null && g.isFetching ? r(S) : r(L, !1);
1686
- });
1687
- }
1688
- var R = e.sibling(v, 2);
1689
- {
1690
- var i = (r) => {
1691
- var g = sn(), y = e.first_child(g);
1692
- Ss(y, {
1693
- get viewerState() {
1694
- return a;
1695
- }
1696
- });
1697
- var m = e.sibling(y, 2);
1698
- Rs(m, {
1699
- get canvases() {
1700
- return e.get(c);
1701
- }
1702
- }), e.append(r, g);
1703
- };
1704
- e.if(R, (r) => {
1705
- e.get(c).length > 1 && r(i);
1706
- });
1707
- }
1708
- var l = e.sibling(R, 2);
1709
- ks(l, {});
1710
- var u = e.sibling(l, 2);
1711
- Bs(u, {});
1712
- var x = e.sibling(u, 2);
1713
- Zs(x, {});
1714
- var p = e.sibling(x, 2);
1715
- zs(p, {}), e.reset(I), e.append(s, I), e.pop();
1716
- }
1717
- export {
1718
- et as ManifestsState,
1719
- An as TriiiceratopsViewer,
1720
- se as VIEWER_STATE_KEY,
1721
- tt as ViewerState
1722
- };