`;
}
}
const u = "filter-list-list", y = "filter-list-item", T = "filter-list-input", _ = "filter-list-searchable";
var l, h, b;
class w extends HTMLElement {
constructor() {
super();
d(this, h);
d(this, l, !1);
this._items = [], this._url = "", this._filterstart = !1, this._placeholder = "Liste filtern...", this._queryparam = "", this._startparams = null, this.render();
}
static get observedAttributes() {
return ["data-url"];
}
set items(e) {
Array.isArray(e) && (this._items = e, this.render());
}
get items() {
return this._items;
}
connectedCallback() {
this._url = this.getAttribute("data-url") || "./", this._filterstart = this.getAttribute("data-filterstart") === "true", this._placeholder = this.getAttribute("data-placeholder") || "Liste filtern...", this._queryparam = this.getAttribute("data-queryparam") || "", this._queryparam, this._filterstart && c(this, l, !0), this.addEventListener("input", this.onInput.bind(this)), this.addEventListener("keydown", this.onEnter.bind(this)), this.addEventListener("focusin", this.onGainFocus.bind(this)), this.addEventListener("focusout", this.onLoseFocus.bind(this));
}
attributeChangedCallback(e, i, s) {
e === "data-url" && i !== s && (this._url = s, this.render()), e === "data-filterstart" && i !== s && (this._filterstart = s === "true", this.render()), e === "data-placeholder" && i !== s && (this._placeholder = s, this.render()), e === "data-queryparam" && i !== s && (this._queryparam = s, this.render());
}
onInput(e) {
e.target && e.target.tagName.toLowerCase() === "input" && (this._filter = e.target.value, this.renderList());
}
onGainFocus(e) {
e.target && e.target.tagName.toLowerCase() === "input" && (c(this, l, !1), this.renderList());
}
onLoseFocus(e) {
let i = this.querySelector("input");
if (e.target && e.target === i) {
if (relatedElement = e.relatedTarget, relatedElement && this.contains(relatedElement))
return;
i.value = "", this._filter = "", this._filterstart && c(this, l, !0), this.renderList();
}
}
onEnter(e) {
if (e.target && e.target.tagName.toLowerCase() === "input" && e.key === "Enter") {
e.preventDefault();
const i = this.querySelector("a");
i && i.click();
}
}
mark() {
if (typeof Mark != "function")
return;
let e = this.querySelector("#" + u);
if (!e)
return;
let i = new Mark(e.querySelectorAll("." + _));
this._filter && i.mark(this._filter, {
separateWordSearch: !0
});
}
// INFO: allows for setting a custom HREF of the list item
// The function takes the item as parameter fn(item) and should return a string.
setHREFFunc(e) {
this.getHREF = e, this.render();
}
// INFO: allows for setting a custom link text of the list item
// The function takes the item as parameter fn(item) and should return a string or
// an HTML template literal.
setLinkTextFunc(e) {
this.getLinkText = e, this.render();
}
// INFO: allows for setting the text that will be filtered for.
// The function takes the item as parameter fn(item) and should return a string.
setSearchTextFunc(e) {
this.getSearchText = e, this.render();
}
getHREF(e) {
if (e) {
if (!e.id)
return "";
} else return "";
return e.id;
}
getHREFEncoded(e) {
return encodeURIComponent(this.getHREF(e));
}
getSearchText(e) {
if (e) {
if (!e.name)
return "";
} else return "";
return e.name;
}
getLinkText(e) {
let i = this.getSearchText(e);
return i === "" ? "" : `${i}`;
}
getURL(e) {
if (this._queryparam) {
let i = new URL(window.location), s = new URLSearchParams(i.search);
return s.set(this._queryparam, this.getHREF(e)), s.delete("page"), i.search = s.toString(), i.toString();
}
return this._url + this.getHREFEncoded(e);
}
renderList() {
let e = this.querySelector("#" + u);
e && (e.outerHTML = this.List()), this.mark();
}
render() {
this.innerHTML = `
`;
}
List() {
let e = this._items;
if (this._filter)
if (this._filterstart)
e = this._items.filter((i) => this.getSearchText(i).toLowerCase().startsWith(this._filter.toLowerCase()));
else {
let i = this._filter.split(" ");
e = this._items.filter((s) => i.every((a) => this.getSearchText(s).toLowerCase().includes(a.toLowerCase())));
}
return `
`;
}
hideOverlay() {
this.overlay.parentNode.removeChild(this.overlay), this.overlay = null;
}
}
class S extends HTMLElement {
static get observedAttributes() {
}
constructor() {
super(), this._showall = !1, this.shown = -1, this._headings = [], this._contents = [];
}
connectedCallback() {
this._headings = Array.from(this.querySelectorAll(".tab-list-head")), this._contents = Array.from(this.querySelectorAll(".tab-list-panel")), this.hookupEvtHandlers(), this.hideDependent(), this._headings.length === 1 && this.expand(0);
}
expand(t) {
t < 0 || t >= this._headings.length || (this.shown = t, this._contents.forEach((e, i) => {
i === t ? (e.classList.remove("hidden"), this._headings[i].setAttribute("aria-pressed", "true")) : (e.classList.add("hidden"), this._headings[i].setAttribute("aria-pressed", "false"));
}));
}
hookupEvtHandlers() {
for (let t of this._headings)
t.addEventListener("click", this.handleTabClick.bind(this)), t.classList.add("cursor-pointer"), t.classList.add("select-none"), t.setAttribute("role", "button"), t.setAttribute("aria-pressed", "false"), t.setAttribute("tabindex", "0");
for (let t of this._contents)
t.classList.add("hidden");
}
restore() {
for (let t of this._headings)
t.classList.add("cursor-pointer"), t.classList.add("select-none"), t.setAttribute("role", "button"), t.setAttribute("aria-pressed", "false"), t.setAttribute("tabindex", "0"), t.classList.remove("pointer-events-none"), t.classList.remove("!text-slate-900");
for (let t of this._contents)
t.classList.add("hidden");
}
disable() {
for (let t of this._headings)
t.classList.remove("cursor-pointer"), t.classList.remove("select-none"), t.removeAttribute("role"), t.removeAttribute("aria-pressed"), t.removeAttribute("tabindex"), t.classList.add("pointer-events-none"), t.classList.add("!text-slate-900");
}
showAll() {
this._showall = !0, this.shown = -1, this.disable(), this._contents.forEach((t, e) => {
t.classList.remove("hidden");
let i = this._headings[e], s = i.querySelectorAll(".show-opened");
for (let n of s)
n.classList.add("hidden");
let a = i.querySelectorAll(".show-closed");
for (let n of a)
n.classList.add("hidden");
});
}
default() {
this._showall = !1, this.restore(), this.hideDependent();
}
hideDependent() {
if (this.shown < 0)
for (const t of this._headings)
this._hideAllDep(t, !1);
else
this._headings.forEach((t, e) => {
this._hideAllDep(t, e === this.shown);
});
}
_hideAllDep(t, e) {
const i = t.querySelectorAll(".show-closed");
for (let a of i)
e ? a.classList.add("hidden") : a.classList.remove("hidden");
const s = Array.from(t.querySelectorAll(".show-opened"));
for (let a of s)
e ? a.classList.remove("hidden") : a.classList.add("hidden");
}
handleTabClick(t) {
if (!t.target) {
console.warn("Invalid event target");
return;
}
const e = this.findParentWithClass(t.target, "tab-list-head");
if (!e) {
console.warn("No parent found with class 'tab-list-head'");
return;
}
const i = this._headings.indexOf(e);
i === this.shown ? (this._contents[i].classList.toggle("hidden"), this._headings[i].setAttribute("aria-pressed", "false"), this.shown = -1) : this.expand(i), this.hideDependent();
}
findParentWithClass(t, e) {
for (; t; ) {
if (t.classList && t.classList.contains(e))
return t;
t = t.parentElement;
}
return null;
}
}
class o extends HTMLElement {
static get observedAttributes() {
return ["data-text", "data-abbrevmap"];
}
static get defaultAbbrevMap() {
return {
"#": "Hinweis auf weitere Informationen in der Anmerkung.",
$: "vermutlich",
"+++": "Inhalte aus mehreren Almanachen interpoliert",
B: "Blatt",
BB: "Blätter",
C: "Corrigenda",
Diagr: "Diagramm",
G: "Graphik",
"G-Verz": "Verzeichnis der Kupfer u. ä.",
GG: "Graphiken",
Hrsg: "Herausgeber",
"I-Verz": "Inhaltsverzeichnis",
Kal: "Kalendarium",
Kr: "Karte",
MusB: "Musikbeigabe",
MusBB: "Musikbeigaben",
S: "Seite",
SS: "Seiten",
Sp: "Spiegel",
T: "Titel",
TG: "Titelgraphik, Titelportrait etc",
"TG r": "Titelgraphik, Titelportrait etc recto",
"TG v": "Titelgraphik, Titelportrait etc verso",
Tab: "Tabelle",
UG: "Umschlaggraphik",
"UG r": "Umschlaggraphik recto",
"UG v": "Umschlaggraphik verso",
VB: "Vorsatzblatt",
Vf: "Verfasser",
VrlgM: "Verlagsmitteilung",
Vrwrt: "Vorwort",
ar: "arabische Paginierung",
ar1: "erste arabische Paginierung",
ar2: "zweite arabische Paginierung",
ar3: "dritte arabische Paginierung",
ar4: "vierte arabische Paginierung",
ar5: "fünfte arabische Paginierung",
ar6: "sechste arabische Paginierung",
ar7: "siebte arabische Paginierung",
gA: "graphische Anleitung",
gT: "graphischer Titel",
gTzA: "graphische Tanzanleitung",
nT: "Nachtitel",
röm: "römische Paginierung",
röm1: "erste römische Paginierung",
röm2: "zweite römische Paginierung",
röm3: "dritte römische Paginierung",
röm4: "vierte römische Paginierung",
röm5: "fünfte römische Paginierung",
röm6: "sechste römische Paginierung",
röm7: "siebte römische Paginierung",
vT: "Vortitel",
zT: "Zwischentitel",
"§§": "Hinweis auf Mängel im Almanach (Beschädigungen, fehlende Graphiken, unvollständige Sammlungen etc) in der Anmerkung"
};
}
constructor() {
super(), this._abbrevMap = o.defaultAbbrevMap;
}
connectedCallback() {
this.render();
}
attributeChangedCallback(t, e, i) {
e !== i && (t === "data-abbrevmap" && this._parseAndSetAbbrevMap(i), this.render());
}
_parseAndSetAbbrevMap(t) {
if (!t) {
this._abbrevMap = o.defaultAbbrevMap;
return;
}
try {
this._abbrevMap = JSON.parse(t);
} catch {
this._abbrevMap = o.defaultAbbrevMap;
}
}
setAbbrevMap(t) {
typeof t == "object" && t !== null && (this._abbrevMap = t, this.render());
}
get text() {
return this.getAttribute("data-text") || "";
}
set text(t) {
this.setAttribute("data-text", t);
}
render() {
this.innerHTML = this.transformText(this.text, this._abbrevMap);
}
transformText(t, e) {
let i = "", s = 0;
for (; s < t.length; ) {
if (s > 0 && !this.isSpaceOrPunct(t[s - 1])) {
i += t[s], s++;
continue;
}
const a = this.findLongestAbbrevAt(t, s, e);
if (a) {
const { match: n, meaning: L } = a;
i += `
${L}
${n}
`, s += n.length;
} else
i += t[s], s++;
}
return i;
}
findLongestAbbrevAt(t, e, i) {
let s = null, a = 0;
for (const n of Object.keys(i))
t.startsWith(n, e) && n.length > a && (s = n, a = n.length);
return s ? { match: s, meaning: i[s] } : null;
}
isSpaceOrPunct(t) {
return /\s|[.,;:!?]/.test(t);
}
}
class B extends HTMLElement {
constructor() {
super();
}
connectedCallback() {
this.style.cursor = "pointer", this.addEventListener("click", this.handleClick);
}
disconnectedCallback() {
this.removeEventListener("click", this.handleClick);
}
handleClick(t) {
const e = this.getAttribute("data-jump");
if (e) {
const i = document.querySelector(e);
i ? i.scrollIntoView({ behavior: "smooth" }) : console.warn(`No element found for selector: ${e}`);
}
}
}
var p;
class M extends HTMLElement {
constructor() {
super();
d(this, p, 176);
this._images = [];
}
connectedCallback() {
this._images = Array.from(this.querySelectorAll(".primages")), this.calculateShownImages();
const e = new ResizeObserver((i, s) => {
this.calculateShownImages();
});
this._resizeObserver = e, e.observe(this);
}
disconnectedCallback() {
this._resizeObserver.unobserve(this);
}
calculateShownImages() {
const e = this.getBoundingClientRect();
console.log(e);
const i = Math.floor(e.width / (g(this, p) + 10));
for (let s = 0; s < this._images.length; s++)
s < i - 1 ? this._images[s].classList.remove("hidden") : this._images[s].classList.add("hidden");
}
}
p = new WeakMap();
const C = "filter-list", I = "scroll-button", q = "tool-tip", R = "abbrev-tooltips", P = "int-link", $ = "popup-image", H = "tab-list", N = "filter-pill", O = "image-reel";
customElements.define(P, B);
customElements.define(R, o);
customElements.define(C, w);
customElements.define(I, E);
customElements.define(q, A);
customElements.define($, k);
customElements.define(H, S);
customElements.define(N, x);
customElements.define(O, M);
export {
o as AbbreviationTooltips,
w as FilterList,
E as ScrollButton
};