const L = "script[xslt-onload]", w = "xslt-template", E = "xslt-transformed", y = /* @__PURE__ */ new Map(); function v() { let i = htmx.findAll(L); for (let t of i) k(t); } function k(i) { if (i.getAttribute(E) === "true" || !i.hasAttribute(w)) return; let t = "#" + i.getAttribute(w), e = y.get(t); if (!e) { let a = htmx.find(t); if (a) { let s = a.innerHTML ? new DOMParser().parseFromString(a.innerHTML, "application/xml") : a.contentDocument; e = new XSLTProcessor(), e.importStylesheet(s), y.set(t, e); } else throw new Error("Unknown XSLT template: " + t); } let n = new DOMParser().parseFromString(i.innerHTML, "application/xml"), o = e.transformToFragment(n, document), r = new XMLSerializer().serializeToString(o); i.outerHTML = r; } function q() { document.querySelectorAll("template[simple]").forEach((t) => { let e = t.getAttribute("id"), n = t.content; customElements.define( e, class extends HTMLElement { constructor() { super(), this.appendChild(n.cloneNode(!0)), this.slots = this.querySelectorAll("slot"); } connectedCallback() { let o = []; this.slots.forEach((r) => { let a = r.getAttribute("name"), s = this.querySelector(`[slot="${a}"]`); s && (r.replaceWith(s.cloneNode(!0)), o.push(s)); }), o.forEach((r) => { r.remove(); }); } } ); }); } window.highlightObserver = window.highlightObserver || null; window.currentPageContainers = window.currentPageContainers || []; window.currentActiveIndex = window.currentActiveIndex || 0; window.pageObserver = window.pageObserver || null; window.scrollTimeout = window.scrollTimeout || null; function B() { window.highlightObserver && (window.highlightObserver.disconnect(), window.highlightObserver = null); const i = document.querySelectorAll(".newspaper-page-container"); window.highlightObserver = new IntersectionObserver( (t) => { C(); }, { rootMargin: "-20% 0px -70% 0px" } ), i.forEach((t) => { window.highlightObserver.observe(t); }); } function C() { const i = []; document.querySelectorAll(".newspaper-page-container").forEach((e) => { const n = e.getBoundingClientRect(), o = window.innerHeight, r = Math.max(n.top, 0), a = Math.min(n.bottom, o), s = Math.max(0, a - r), l = n.height, g = s / l >= 0.5, u = e.querySelector("img[data-page]"), f = u ? u.getAttribute("data-page") : "unknown"; g && u && f && !i.includes(f) && i.push(f); }), M(i), i.length > 0 && I(i); } function M(i) { document.querySelectorAll(".continuation-entry").forEach((t) => { t.style.display = "none"; }), i.forEach((t) => { const e = document.querySelector(`[data-page-container="${t}"]`); e && e.querySelectorAll(".continuation-entry").forEach((o) => { o.style.display = ""; }); }), H(i), $(); } function H(i) { document.querySelectorAll(".work-title").forEach((t) => { const e = t.getAttribute("data-short-title"); e && (t.textContent = e); }), i.forEach((t) => { const e = document.querySelector(`[data-page-container="${t}"]`); e && e.querySelectorAll(".work-title").forEach((o) => { const r = o.getAttribute("data-full-title"); r && r !== o.getAttribute("data-short-title") && (o.textContent = r); }); }); } function $() { document.querySelectorAll(".page-entry").forEach((i) => { const t = i.querySelectorAll(".inhalts-entry"); let e = !1; t.forEach((n) => { window.getComputedStyle(n).display !== "none" && (e = !0); }), e ? i.style.display = "" : i.style.display = "none"; }); } function S(i) { I([i]); } function I(i) { console.log("markCurrentPagesInInhaltsverzeichnis called with:", i), document.querySelectorAll("[data-page-container]").forEach((e) => { e.hasAttribute("data-beilage") ? (e.classList.remove("border-red-500"), e.classList.add("border-amber-400")) : (e.classList.remove("border-red-500"), e.classList.add("border-slate-300")); }), document.querySelectorAll(".page-number-inhalts").forEach((e) => { e.classList.remove("text-red-600", "font-bold"), e.classList.add("text-slate-700", "font-semibold"), e.style.textDecoration = "", e.style.pointerEvents = "", e.classList.contains("bg-blue-50") ? e.classList.add("hover:bg-blue-100") : e.classList.contains("bg-amber-50") && e.classList.add("hover:bg-amber-100"), !e.classList.contains("bg-amber-50") && !e.classList.contains("bg-blue-50") && e.classList.add("bg-blue-50"); }), document.querySelectorAll(".inhalts-entry").forEach((e) => { e.classList.add("hover:bg-slate-100"), e.style.cursor = ""; }), document.querySelectorAll('.inhalts-entry a[href*="/"]').forEach((e) => { e.classList.remove("no-underline"), e.classList.contains("bg-blue-50") && e.classList.add("hover:bg-blue-100"); }); const t = []; i.forEach((e) => { const n = document.querySelector( `.page-number-inhalts[data-page-number="${e}"]` ); if (n) { n.classList.remove( "text-slate-700", "hover:bg-blue-100", "hover:bg-amber-100" ), n.classList.add("text-red-600", "font-bold"), n.style.textDecoration = "none", n.style.pointerEvents = "none", t.push(n); const o = document.querySelector(`[data-page-container="${e}"]`); o && (o.classList.remove("border-slate-300", "border-amber-400"), o.classList.add("border-red-500")); const r = n.closest(".page-entry"); r && (r.querySelectorAll(".inhalts-entry").forEach((s) => { s.classList.remove("hover:bg-slate-100"), s.style.cursor = "default"; }), r.querySelectorAll('a[href*="/"]').forEach((s) => { s.getAttribute("aria-current") === "page" && (s.style.textDecoration = "none", s.style.pointerEvents = "none", s.classList.add("no-underline"), s.classList.remove("hover:bg-blue-100")); })); } }), t.length > 0 && N(t[0]), document.querySelectorAll(".page-indicator").forEach((e) => { e.classList.remove("text-red-600", "font-bold"), e.classList.add("text-slate-600", "font-semibold"), e.classList.contains("bg-amber-50") || e.classList.add("bg-blue-50"); }), i.forEach((e) => { const n = document.querySelector(`.page-indicator[data-page="${e}"]`); n && (n.classList.remove("text-slate-600"), n.classList.add("text-red-600", "font-bold")); }); } function N(i) { const t = i.closest(".lg\\:overflow-y-auto"); if (t) { const e = t.getBoundingClientRect(), n = i.getBoundingClientRect(), o = n.top < e.top, r = n.bottom > e.bottom; (o || r) && i.scrollIntoView({ behavior: "smooth", block: "center" }); } } function R(i, t, e) { let n = document.querySelector("single-page-viewer"); n || (n = document.createElement("single-page-viewer"), document.body.appendChild(n)); const o = i.closest('[data-beilage="true"]') !== null; n.show(i.src, i.alt, t, o); } function T() { document.getElementById("pageModal").classList.add("hidden"); } function O() { if (window.pageObserver && (window.pageObserver.disconnect(), window.pageObserver = null), window.currentPageContainers = Array.from( document.querySelectorAll(".newspaper-page-container") ), window.currentActiveIndex = 0, p(), document.querySelector(".newspaper-page-container")) { let t = /* @__PURE__ */ new Set(); window.pageObserver = new IntersectionObserver( (e) => { if (e.forEach((n) => { const o = window.currentPageContainers.indexOf(n.target); o !== -1 && (n.isIntersecting ? t.add(o) : t.delete(o)); }), t.size > 0) { const o = Array.from(t).sort((r, a) => r - a)[0]; o !== window.currentActiveIndex && (window.currentActiveIndex = o, p()); } }, { rootMargin: "-20% 0px -70% 0px" } ), window.currentPageContainers.forEach((e) => { window.pageObserver.observe(e); }); } } function V() { if (window.currentActiveIndex > 0) { let i = -1; const t = []; window.currentPageContainers.forEach((n, o) => { const r = n.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), c = Math.max(0, l - s), g = r.height; c / g >= 0.3 && t.push(o); }); const e = Math.min(...t); for (let n = e - 1; n >= 0; n--) if (!t.includes(n)) { i = n; break; } i === -1 && e > 0 && (i = e - 1), i >= 0 && (window.currentActiveIndex = i, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({ behavior: "smooth", block: "start" }), setTimeout(() => { p(); }, 100)); } } function K() { if (window.currentActiveIndex < window.currentPageContainers.length - 1) { let i = -1; const t = []; window.currentPageContainers.forEach((n, o) => { const r = n.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), c = Math.max(0, l - s), g = r.height; c / g >= 0.3 && t.push(o); }); const e = Math.max(...t); for (let n = e + 1; n < window.currentPageContainers.length; n++) if (!t.includes(n)) { i = n; break; } i === -1 && e < window.currentPageContainers.length - 1 && (i = e + 1), i >= 0 && i < window.currentPageContainers.length && (window.currentActiveIndex = i, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({ behavior: "smooth", block: "start" }), setTimeout(() => { p(); }, 100)); } } function z() { if (A()) { const t = document.querySelector("#newspaper-content .newspaper-page-container"); t && t.scrollIntoView({ behavior: "smooth", block: "start" }); } else { const t = document.querySelector('[class*="border-t-2 border-amber-200"]'); t && t.scrollIntoView({ behavior: "smooth", block: "start" }); } } function A() { const i = []; window.currentPageContainers.forEach((t, e) => { const n = t.getBoundingClientRect(), o = window.innerHeight, r = Math.max(n.top, 0), a = Math.min(n.bottom, o), s = Math.max(0, a - r), l = n.height; s / l >= 0.3 && i.push(e); }); for (const t of i) { const e = window.currentPageContainers[t]; if (e && e.id && e.id.includes("beilage-")) return !0; } return !1; } function p() { const i = document.getElementById("prevPageBtn"), t = document.getElementById("nextPageBtn"), e = document.getElementById("beilageBtn"); if (i && (window.currentActiveIndex <= 0 ? i.style.display = "none" : i.style.display = "flex"), t && (window.currentActiveIndex >= window.currentPageContainers.length - 1 ? t.style.display = "none" : t.style.display = "flex"), e) { const n = A(), o = e.querySelector("i"); n ? (e.title = "Zur Hauptausgabe", e.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-700 hover:text-gray-800 border border-gray-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", o && (o.className = "ri-file-text-line text-lg lg:text-xl")) : (e.title = "Zu Beilage", e.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-amber-100 hover:bg-amber-200 text-amber-700 hover:text-amber-800 border border-amber-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", o && (o.className = "ri-attachment-line text-lg lg:text-xl")); } } function j() { const i = document.getElementById("shareLinkBtn"); let t = ""; if (window.currentActiveIndex !== void 0 && window.currentPageContainers && window.currentPageContainers[window.currentActiveIndex]) { const o = window.currentPageContainers[window.currentActiveIndex].querySelector("[data-page]"); o && (t = `#page-${o.getAttribute("data-page")}`); } const e = window.location.origin + window.location.pathname + t; navigator.share ? navigator.share({ title: document.title, url: e }).catch((n) => { x(e, i); }) : x(e, i); } function x(i, t) { if (navigator.clipboard) navigator.clipboard.writeText(i).then(() => { d(t, "Link kopiert!"); }).catch((e) => { d(t, "Kopieren fehlgeschlagen"); }); else { const e = document.createElement("textarea"); e.value = i, document.body.appendChild(e), e.select(); try { const n = document.execCommand("copy"); d(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen"); } catch { d(t, "Kopieren fehlgeschlagen"); } finally { document.body.removeChild(e); } } } function D() { const i = document.getElementById("citationBtn"), t = document.title || "KGPZ", e = window.location.href, n = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), o = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}. Digital verfügbar unter: ${e} (Zugriff: ${n}).`; if (navigator.clipboard) navigator.clipboard.writeText(o).then(() => { d(i, "Zitation kopiert!"); }).catch((r) => { d(i, "Kopieren fehlgeschlagen"); }); else { const r = document.createElement("textarea"); r.value = o, document.body.appendChild(r), r.select(); try { const a = document.execCommand("copy"); d(i, a ? "Zitation kopiert!" : "Kopieren fehlgeschlagen"); } catch { d(i, "Kopieren fehlgeschlagen"); } finally { document.body.removeChild(r); } } } function d(i, t) { const e = document.querySelector(".simple-popup"); e && e.remove(); const n = document.createElement("div"); n.className = "simple-popup", n.textContent = t, n.style.cssText = ` position: fixed; background: #374151; color: white; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity 0.2s ease; white-space: nowrap; `; const o = i.getBoundingClientRect(), r = window.innerHeight, a = window.innerWidth; let s = o.left - 10, l = o.bottom + 8; const c = 120, g = 32; s + c > a && (s = o.right - c + 10), l + g > r && (l = o.top - g - 8), n.style.left = Math.max(5, s) + "px", n.style.top = Math.max(5, l) + "px", document.body.appendChild(n), setTimeout(() => { n.style.opacity = "1"; }, 10), setTimeout(() => { n.style.opacity = "0", setTimeout(() => { n.parentNode && n.remove(); }, 200); }, 2e3); } function P() { const i = window.location.hash; let t = "", e = null; if (i.startsWith("#page-")) { if (t = i.replace("#page-", ""), e = document.getElementById(`page-${t}`), !e) { const n = document.querySelectorAll(".newspaper-page-container[data-pages]"); for (const o of n) { const r = o.getAttribute("data-pages"); if (r && r.split(",").includes(t)) { e = o; break; } } } e || (e = document.getElementById(`beilage-1-page-${t}`) || document.getElementById(`beilage-2-page-${t}`) || document.querySelector(`[id*="beilage"][id*="page-${t}"]`)); } else if (i.startsWith("#beilage-")) { const n = i.match(/#beilage-(\d+)-page-(\d+)/); if (n) { const o = n[1]; t = n[2], e = document.getElementById(`beilage-${o}-page-${t}`); } } e && t && setTimeout(() => { e.scrollIntoView({ behavior: "smooth", block: "start" }), S(t); }, 300); } function b(i, t, e = !1) { let n = ""; e ? n = `#beilage-1-page-${i}` : n = `#page-${i}`; const o = window.location.origin + window.location.pathname + n; if (navigator.clipboard) navigator.clipboard.writeText(o).then(() => { d(t, "Link kopiert!"); }).catch((r) => { d(t, "Kopieren fehlgeschlagen"); }); else { const r = document.createElement("textarea"); r.value = o, document.body.appendChild(r), r.select(); try { const a = document.execCommand("copy"); d(t, a ? "Link kopiert!" : "Kopieren fehlgeschlagen"); } catch { d(t, "Kopieren fehlgeschlagen"); } finally { document.body.removeChild(r); } } } function m(i, t) { const e = document.title || "KGPZ", n = `${window.location.origin}${window.location.pathname}#page-${i}`, o = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), r = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}, Seite ${i}. Digital verfügbar unter: ${n} (Zugriff: ${o}).`; if (navigator.clipboard) navigator.clipboard.writeText(r).then(() => { d(t, "Zitation kopiert!"); }).catch((a) => { d(t, "Kopieren fehlgeschlagen"); }); else { const a = document.createElement("textarea"); a.value = r, document.body.appendChild(a), a.select(); try { const s = document.execCommand("copy"); d(t, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen"); } catch { d(t, "Kopieren fehlgeschlagen"); } finally { document.body.removeChild(a); } } } function h() { B(), O(), window.addEventListener("scroll", function() { clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => { C(), p(); }, 50); }), P(), window.addEventListener("hashchange", P), document.addEventListener("keydown", function(i) { i.key === "Escape" && T(); }); } window.enlargePage = R; window.closeModal = T; window.scrollToPreviousPage = V; window.scrollToNextPage = K; window.scrollToBeilage = z; window.shareCurrentPage = j; window.generateCitation = D; window.copyPagePermalink = b; window.generatePageCitation = m; function _() { v(), q(), document.querySelector(".newspaper-page-container") && h(), htmx.on("htmx:load", function(i) { v(); }), document.body.addEventListener("htmx:afterSwap", function(i) { setTimeout(() => { document.querySelector(".newspaper-page-container") && h(); }, 100); }), document.body.addEventListener("htmx:afterSettle", function(i) { setTimeout(() => { document.querySelector(".newspaper-page-container") && h(); }, 200); }), document.body.addEventListener("htmx:load", function(i) { setTimeout(() => { document.querySelector(".newspaper-page-container") && h(); }, 100); }); } class Z extends HTMLElement { constructor() { super(); } connectedCallback() { this.innerHTML = `