UNPKG

@joelmturner/zine-viewer-web-component

Version:
761 lines (745 loc) 27.1 kB
/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const R = globalThis, j = R.ShadowRoot && (R.ShadyCSS === void 0 || R.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, D = Symbol(), W = /* @__PURE__ */ new WeakMap(); let se = class { constructor(e, t, s) { if (this._$cssResult$ = !0, s !== D) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = e, this.t = t; } get styleSheet() { let e = this.o; const t = this.t; if (j && e === void 0) { const s = t !== void 0 && t.length === 1; s && (e = W.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), s && W.set(t, e)); } return e; } toString() { return this.cssText; } }; const he = (n) => new se(typeof n == "string" ? n : n + "", void 0, D), le = (n, ...e) => { const t = n.length === 1 ? n[0] : e.reduce((s, i, o) => s + ((r) => { if (r._$cssResult$ === !0) return r.cssText; if (typeof r == "number") return r; throw Error("Value passed to 'css' function must be a 'css' function result: " + r + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); })(i) + n[o + 1], n[0]); return new se(t, n, D); }, de = (n, e) => { if (j) n.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet); else for (const t of e) { const s = document.createElement("style"), i = R.litNonce; i !== void 0 && s.setAttribute("nonce", i), s.textContent = t.cssText, n.appendChild(s); } }, q = j ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((e) => { let t = ""; for (const s of e.cssRules) t += s.cssText; return he(t); })(n) : n; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const { is: ce, defineProperty: ue, getOwnPropertyDescriptor: pe, getOwnPropertyNames: fe, getOwnPropertySymbols: ge, getPrototypeOf: $e } = Object, $ = globalThis, Z = $.trustedTypes, _e = Z ? Z.emptyScript : "", N = $.reactiveElementPolyfillSupport, E = (n, e) => n, L = { toAttribute(n, e) { switch (e) { case Boolean: n = n ? _e : null; break; case Object: case Array: n = n == null ? n : JSON.stringify(n); } return n; }, fromAttribute(n, e) { let t = n; switch (e) { case Boolean: t = n !== null; break; case Number: t = n === null ? null : Number(n); break; case Object: case Array: try { t = JSON.parse(n); } catch { t = null; } } return t; } }, ie = (n, e) => !ce(n, e), J = { attribute: !0, type: String, converter: L, reflect: !1, hasChanged: ie }; Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), $.litPropertyMetadata ?? ($.litPropertyMetadata = /* @__PURE__ */ new WeakMap()); class A extends HTMLElement { static addInitializer(e) { this._$Ei(), (this.l ?? (this.l = [])).push(e); } static get observedAttributes() { return this.finalize(), this._$Eh && [...this._$Eh.keys()]; } static createProperty(e, t = J) { if (t.state && (t.attribute = !1), this._$Ei(), this.elementProperties.set(e, t), !t.noAccessor) { const s = Symbol(), i = this.getPropertyDescriptor(e, s, t); i !== void 0 && ue(this.prototype, e, i); } } static getPropertyDescriptor(e, t, s) { const { get: i, set: o } = pe(this.prototype, e) ?? { get() { return this[t]; }, set(r) { this[t] = r; } }; return { get() { return i == null ? void 0 : i.call(this); }, set(r) { const l = i == null ? void 0 : i.call(this); o.call(this, r), this.requestUpdate(e, l, s); }, configurable: !0, enumerable: !0 }; } static getPropertyOptions(e) { return this.elementProperties.get(e) ?? J; } static _$Ei() { if (this.hasOwnProperty(E("elementProperties"))) return; const e = $e(this); e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties); } static finalize() { if (this.hasOwnProperty(E("finalized"))) return; if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(E("properties"))) { const t = this.properties, s = [...fe(t), ...ge(t)]; for (const i of s) this.createProperty(i, t[i]); } const e = this[Symbol.metadata]; if (e !== null) { const t = litPropertyMetadata.get(e); if (t !== void 0) for (const [s, i] of t) this.elementProperties.set(s, i); } this._$Eh = /* @__PURE__ */ new Map(); for (const [t, s] of this.elementProperties) { const i = this._$Eu(t, s); i !== void 0 && this._$Eh.set(i, t); } this.elementStyles = this.finalizeStyles(this.styles); } static finalizeStyles(e) { const t = []; if (Array.isArray(e)) { const s = new Set(e.flat(1 / 0).reverse()); for (const i of s) t.unshift(q(i)); } else e !== void 0 && t.push(q(e)); return t; } static _$Eu(e, t) { const s = t.attribute; return s === !1 ? void 0 : typeof s == "string" ? s : typeof e == "string" ? e.toLowerCase() : void 0; } constructor() { super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev(); } _$Ev() { var e; this._$ES = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (e = this.constructor.l) == null || e.forEach((t) => t(this)); } addController(e) { var t; (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(e), this.renderRoot !== void 0 && this.isConnected && ((t = e.hostConnected) == null || t.call(e)); } removeController(e) { var t; (t = this._$EO) == null || t.delete(e); } _$E_() { const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties; for (const s of t.keys()) this.hasOwnProperty(s) && (e.set(s, this[s]), delete this[s]); e.size > 0 && (this._$Ep = e); } createRenderRoot() { const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); return de(e, this.constructor.elementStyles), e; } connectedCallback() { var e; this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((t) => { var s; return (s = t.hostConnected) == null ? void 0 : s.call(t); }); } enableUpdating(e) { } disconnectedCallback() { var e; (e = this._$EO) == null || e.forEach((t) => { var s; return (s = t.hostDisconnected) == null ? void 0 : s.call(t); }); } attributeChangedCallback(e, t, s) { this._$AK(e, s); } _$EC(e, t) { var o; const s = this.constructor.elementProperties.get(e), i = this.constructor._$Eu(e, s); if (i !== void 0 && s.reflect === !0) { const r = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : L).toAttribute(t, s.type); this._$Em = e, r == null ? this.removeAttribute(i) : this.setAttribute(i, r), this._$Em = null; } } _$AK(e, t) { var o; const s = this.constructor, i = s._$Eh.get(e); if (i !== void 0 && this._$Em !== i) { const r = s.getPropertyOptions(i), l = typeof r.converter == "function" ? { fromAttribute: r.converter } : ((o = r.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? r.converter : L; this._$Em = i, this[i] = l.fromAttribute(t, r.type), this._$Em = null; } } requestUpdate(e, t, s) { if (e !== void 0) { if (s ?? (s = this.constructor.getPropertyOptions(e)), !(s.hasChanged ?? ie)(this[e], t)) return; this.P(e, t, s); } this.isUpdatePending === !1 && (this._$ES = this._$ET()); } P(e, t, s) { this._$AL.has(e) || this._$AL.set(e, t), s.reflect === !0 && this._$Em !== e && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(e); } async _$ET() { this.isUpdatePending = !0; try { await this._$ES; } catch (t) { Promise.reject(t); } const e = this.scheduleUpdate(); return e != null && await e, !this.isUpdatePending; } scheduleUpdate() { return this.performUpdate(); } performUpdate() { var s; if (!this.isUpdatePending) return; if (!this.hasUpdated) { if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) { for (const [o, r] of this._$Ep) this[o] = r; this._$Ep = void 0; } const i = this.constructor.elementProperties; if (i.size > 0) for (const [o, r] of i) r.wrapped !== !0 || this._$AL.has(o) || this[o] === void 0 || this.P(o, this[o], r); } let e = !1; const t = this._$AL; try { e = this.shouldUpdate(t), e ? (this.willUpdate(t), (s = this._$EO) == null || s.forEach((i) => { var o; return (o = i.hostUpdate) == null ? void 0 : o.call(i); }), this.update(t)) : this._$EU(); } catch (i) { throw e = !1, this._$EU(), i; } e && this._$AE(t); } willUpdate(e) { } _$AE(e) { var t; (t = this._$EO) == null || t.forEach((s) => { var i; return (i = s.hostUpdated) == null ? void 0 : i.call(s); }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e); } _$EU() { this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1; } get updateComplete() { return this.getUpdateComplete(); } getUpdateComplete() { return this._$ES; } shouldUpdate(e) { return !0; } update(e) { this._$Ej && (this._$Ej = this._$Ej.forEach((t) => this._$EC(t, this[t]))), this._$EU(); } updated(e) { } firstUpdated(e) { } } A.elementStyles = [], A.shadowRootOptions = { mode: "open" }, A[E("elementProperties")] = /* @__PURE__ */ new Map(), A[E("finalized")] = /* @__PURE__ */ new Map(), N == null || N({ ReactiveElement: A }), ($.reactiveElementVersions ?? ($.reactiveElementVersions = [])).push("2.0.4"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const w = globalThis, T = w.trustedTypes, K = T ? T.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, ne = "$lit$", g = `lit$${Math.random().toFixed(9).slice(2)}$`, re = "?" + g, me = `<${re}>`, y = document, x = () => y.createComment(""), C = (n) => n === null || typeof n != "object" && typeof n != "function", V = Array.isArray, ye = (n) => V(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", M = `[ \f\r]`, S = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Y = /-->/g, F = />/g, _ = RegExp(`>|${M}(?:([^\\s"'>=/]+)(${M}*=${M}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`, "g"), G = /'/g, Q = /"/g, oe = /^(?:script|style|textarea|title)$/i, Ae = (n) => (e, ...t) => ({ _$litType$: n, strings: e, values: t }), X = Ae(1), b = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), ee = /* @__PURE__ */ new WeakMap(), m = y.createTreeWalker(y, 129); function ae(n, e) { if (!V(n) || !n.hasOwnProperty("raw")) throw Error("invalid template strings array"); return K !== void 0 ? K.createHTML(e) : e; } const be = (n, e) => { const t = n.length - 1, s = []; let i, o = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", r = S; for (let l = 0; l < t; l++) { const a = n[l]; let c, d, h = -1, u = 0; for (; u < a.length && (r.lastIndex = u, d = r.exec(a), d !== null); ) u = r.lastIndex, r === S ? d[1] === "!--" ? r = Y : d[1] !== void 0 ? r = F : d[2] !== void 0 ? (oe.test(d[2]) && (i = RegExp("</" + d[2], "g")), r = _) : d[3] !== void 0 && (r = _) : r === _ ? d[0] === ">" ? (r = i ?? S, h = -1) : d[1] === void 0 ? h = -2 : (h = r.lastIndex - d[2].length, c = d[1], r = d[3] === void 0 ? _ : d[3] === '"' ? Q : G) : r === Q || r === G ? r = _ : r === Y || r === F ? r = S : (r = _, i = void 0); const f = r === _ && n[l + 1].startsWith("/>") ? " " : ""; o += r === S ? a + me : h >= 0 ? (s.push(c), a.slice(0, h) + ne + a.slice(h) + g + f) : a + g + (h === -2 ? l : f); } return [ae(n, o + (n[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s]; }; class U { constructor({ strings: e, _$litType$: t }, s) { let i; this.parts = []; let o = 0, r = 0; const l = e.length - 1, a = this.parts, [c, d] = be(e, t); if (this.el = U.createElement(c, s), m.currentNode = this.el.content, t === 2 || t === 3) { const h = this.el.content.firstChild; h.replaceWith(...h.childNodes); } for (; (i = m.nextNode()) !== null && a.length < l; ) { if (i.nodeType === 1) { if (i.hasAttributes()) for (const h of i.getAttributeNames()) if (h.endsWith(ne)) { const u = d[r++], f = i.getAttribute(h).split(g), H = /([.?@])?(.*)/.exec(u); a.push({ type: 1, index: o, name: H[2], strings: f, ctor: H[1] === "." ? Se : H[1] === "?" ? Ee : H[1] === "@" ? we : z }), i.removeAttribute(h); } else h.startsWith(g) && (a.push({ type: 6, index: o }), i.removeAttribute(h)); if (oe.test(i.tagName)) { const h = i.textContent.split(g), u = h.length - 1; if (u > 0) { i.textContent = T ? T.emptyScript : ""; for (let f = 0; f < u; f++) i.append(h[f], x()), m.nextNode(), a.push({ type: 2, index: ++o }); i.append(h[u], x()); } } } else if (i.nodeType === 8) if (i.data === re) a.push({ type: 2, index: o }); else { let h = -1; for (; (h = i.data.indexOf(g, h + 1)) !== -1; ) a.push({ type: 7, index: o }), h += g.length - 1; } o++; } } static createElement(e, t) { const s = y.createElement("template"); return s.innerHTML = e, s; } } function v(n, e, t = n, s) { var r, l; if (e === b) return e; let i = s !== void 0 ? (r = t._$Co) == null ? void 0 : r[s] : t._$Cl; const o = C(e) ? void 0 : e._$litDirective$; return (i == null ? void 0 : i.constructor) !== o && ((l = i == null ? void 0 : i._$AO) == null || l.call(i, !1), o === void 0 ? i = void 0 : (i = new o(n), i._$AT(n, t, s)), s !== void 0 ? (t._$Co ?? (t._$Co = []))[s] = i : t._$Cl = i), i !== void 0 && (e = v(n, i._$AS(n, e.values), i, s)), e; } class ve { constructor(e, t) { this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t; } get parentNode() { return this._$AM.parentNode; } get _$AU() { return this._$AM._$AU; } u(e) { const { el: { content: t }, parts: s } = this._$AD, i = ((e == null ? void 0 : e.creationScope) ?? y).importNode(t, !0); m.currentNode = i; let o = m.nextNode(), r = 0, l = 0, a = s[0]; for (; a !== void 0; ) { if (r === a.index) { let c; a.type === 2 ? c = new O(o, o.nextSibling, this, e) : a.type === 1 ? c = new a.ctor(o, a.name, a.strings, this, e) : a.type === 6 && (c = new Pe(o, this, e)), this._$AV.push(c), a = s[++l]; } r !== (a == null ? void 0 : a.index) && (o = m.nextNode(), r++); } return m.currentNode = y, i; } p(e) { let t = 0; for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(e, s, t), t += s.strings.length - 2) : s._$AI(e[t])), t++; } } class O { get _$AU() { var e; return ((e = this._$AM) == null ? void 0 : e._$AU) ?? this._$Cv; } constructor(e, t, s, i) { this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = s, this.options = i, this._$Cv = (i == null ? void 0 : i.isConnected) ?? !0; } get parentNode() { let e = this._$AA.parentNode; const t = this._$AM; return t !== void 0 && (e == null ? void 0 : e.nodeType) === 11 && (e = t.parentNode), e; } get startNode() { return this._$AA; } get endNode() { return this._$AB; } _$AI(e, t = this) { e = v(this, e, t), C(e) ? e === p || e == null || e === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : e !== this._$AH && e !== b && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : ye(e) ? this.k(e) : this._(e); } O(e) { return this._$AA.parentNode.insertBefore(e, this._$AB); } T(e) { this._$AH !== e && (this._$AR(), this._$AH = this.O(e)); } _(e) { this._$AH !== p && C(this._$AH) ? this._$AA.nextSibling.data = e : this.T(y.createTextNode(e)), this._$AH = e; } $(e) { var o; const { values: t, _$litType$: s } = e, i = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el = U.createElement(ae(s.h, s.h[0]), this.options)), s); if (((o = this._$AH) == null ? void 0 : o._$AD) === i) this._$AH.p(t); else { const r = new ve(i, this), l = r.u(this.options); r.p(t), this.T(l), this._$AH = r; } } _$AC(e) { let t = ee.get(e.strings); return t === void 0 && ee.set(e.strings, t = new U(e)), t; } k(e) { V(this._$AH) || (this._$AH = [], this._$AR()); const t = this._$AH; let s, i = 0; for (const o of e) i === t.length ? t.push(s = new O(this.O(x()), this.O(x()), this, this.options)) : s = t[i], s._$AI(o), i++; i < t.length && (this._$AR(s && s._$AB.nextSibling, i), t.length = i); } _$AR(e = this._$AA.nextSibling, t) { var s; for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, t); e && e !== this._$AB; ) { const i = e.nextSibling; e.remove(), e = i; } } setConnected(e) { var t; this._$AM === void 0 && (this._$Cv = e, (t = this._$AP) == null || t.call(this, e)); } } class z { get tagName() { return this.element.tagName; } get _$AU() { return this._$AM._$AU; } constructor(e, t, s, i, o) { this.type = 1, this._$AH = p, this._$AN = void 0, this.element = e, this.name = t, this._$AM = i, this.options = o, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = p; } _$AI(e, t = this, s, i) { const o = this.strings; let r = !1; if (o === void 0) e = v(this, e, t, 0), r = !C(e) || e !== this._$AH && e !== b, r && (this._$AH = e); else { const l = e; let a, c; for (e = o[0], a = 0; a < o.length - 1; a++) c = v(this, l[s + a], t, a), c === b && (c = this._$AH[a]), r || (r = !C(c) || c !== this._$AH[a]), c === p ? e = p : e !== p && (e += (c ?? "") + o[a + 1]), this._$AH[a] = c; } r && !i && this.j(e); } j(e) { e === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? ""); } } class Se extends z { constructor() { super(...arguments), this.type = 3; } j(e) { this.element[this.name] = e === p ? void 0 : e; } } class Ee extends z { constructor() { super(...arguments), this.type = 4; } j(e) { this.element.toggleAttribute(this.name, !!e && e !== p); } } class we extends z { constructor(e, t, s, i, o) { super(e, t, s, i, o), this.type = 5; } _$AI(e, t = this) { if ((e = v(this, e, t, 0) ?? p) === b) return; const s = this._$AH, i = e === p && s !== p || e.capture !== s.capture || e.once !== s.once || e.passive !== s.passive, o = e !== p && (s === p || i); i && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, e), this._$AH = e; } handleEvent(e) { var t; typeof this._$AH == "function" ? this._$AH.call(((t = this.options) == null ? void 0 : t.host) ?? this.element, e) : this._$AH.handleEvent(e); } } class Pe { constructor(e, t, s) { this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s; } get _$AU() { return this._$AM._$AU; } _$AI(e) { v(this, e); } } const k = w.litHtmlPolyfillSupport; k == null || k(U, O), (w.litHtmlVersions ?? (w.litHtmlVersions = [])).push("3.2.1"); const xe = (n, e, t) => { const s = (t == null ? void 0 : t.renderBefore) ?? e; let i = s._$litPart$; if (i === void 0) { const o = (t == null ? void 0 : t.renderBefore) ?? null; s._$litPart$ = i = new O(e.insertBefore(x(), o), o, void 0, t ?? {}); } return i._$AI(n), i; }; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ class P extends A { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } createRenderRoot() { var t; const e = super.createRenderRoot(); return (t = this.renderOptions).renderBefore ?? (t.renderBefore = e.firstChild), e; } update(e) { const t = this.render(); this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do = xe(t, this.renderRoot, this.renderOptions); } connectedCallback() { var e; super.connectedCallback(), (e = this._$Do) == null || e.setConnected(!0); } disconnectedCallback() { var e; super.disconnectedCallback(), (e = this._$Do) == null || e.setConnected(!1); } render() { return b; } } var te; P._$litElement$ = !0, P.finalized = !0, (te = globalThis.litElementHydrateSupport) == null || te.call(globalThis, { LitElement: P }); const I = globalThis.litElementPolyfillSupport; I == null || I({ LitElement: P }); (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const Ce = (n) => (e, t) => { t !== void 0 ? t.addInitializer(() => { customElements.define(n, e); }) : customElements.define(n, e); }; var Ue = Object.defineProperty, Oe = Object.getOwnPropertyDescriptor, He = (n, e, t, s) => { for (var i = s > 1 ? void 0 : s ? Oe(e, t) : e, o = n.length - 1, r; o >= 0; o--) (r = n[o]) && (i = (s ? r(e, t, i) : r(i)) || i); return s && i && Ue(e, t, i), i; }; let B = class extends P { constructor() { super(...arguments), this.currentPage = 0; } resizeContainer() { var h, u; const n = (h = this.shadowRoot) == null ? void 0 : h.querySelector( ".container" ), e = (u = this.shadowRoot) == null ? void 0 : u.querySelector(".wrapper"); if (!n || !e) return; const t = parseInt( getComputedStyle(this).getPropertyValue("--canvas-padding") ), s = parseInt( getComputedStyle(this).getPropertyValue("--page-width") ), i = parseInt( getComputedStyle(this).getPropertyValue("--page-height") ), o = s * 2, r = e.clientWidth - t * 2, l = e.clientHeight - t * 2, a = r / o, c = l / i, d = Math.min(a, c); n.style.width = `${o * d}px`, n.style.height = `${i * d}px`; } firstUpdated() { var l, a, c; const n = Array.from(((l = this.shadowRoot) == null ? void 0 : l.querySelectorAll(".page")) || []), e = (a = this.shadowRoot) == null ? void 0 : a.getElementById("prev"), t = (c = this.shadowRoot) == null ? void 0 : c.getElementById("next"); this.resizeContainer(), new ResizeObserver(() => { this.resizeContainer(); }).observe(this); const i = () => { e.disabled = this.currentPage === 0, t.disabled = this.currentPage === n.length; }, o = (d) => { n.forEach((h, u) => { let f; d ? u === 0 && this.currentPage <= 1 ? f = n.length + 1 : u < this.currentPage ? f = n.length - (this.currentPage - u) : f = n.length - u : u === n.length - 1 && this.currentPage >= n.length - 1 ? f = n.length + 1 : u === this.currentPage ? f = n.length : u < this.currentPage ? f = u : f = n.length - u, h.style.zIndex = f.toString(); }); }, r = (d) => { d ? (n[this.currentPage].classList.add("flipped"), this.currentPage++) : (this.currentPage--, n[this.currentPage].classList.remove("flipped")), o(d), i(); }; e.addEventListener("click", () => r(!1)), t.addEventListener("click", () => r(!0)), o(!0), i(); } render() { const n = Array.from(this.children).map((e, t) => { const s = e.getAttribute("img-src"), i = e.getAttribute("back-img-src"); return { imgSrc: s, backImgSrc: i, index: t }; }); return X` <div class="wrapper"> <div class="container"> <div class="zine"> ${n.map( (e) => X`<div class="page" data-page="${e.index + 1}" style="z-index: ${5 - e.index}" > <div class="front"><img src="${e.imgSrc}" /></div> <div class="back"><img src="${e.backImgSrc}" /></div> </div>` )} <button id="prev"></button> <button id="next"></button> </div> </div> </div> `; } }; B.styles = le` :host { --canvas-bg-color: transparent; --canvas-padding: 25px; --page-width: 291px; --page-height: 450px; --spread-width: calc(var(--page-width) * 2); --page-border-radius: 5%; --page-color: #111; --page-bg-color: transparent; --transition-duration: 1s; display: block; width: 100%; height: 100%; } * { box-sizing: border-box; } .wrapper { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: var(--canvas-padding); } .container { display: flex; justify-content: flex-end; align-items: center; position: relative; margin: 0 auto; background: var(--canvas-bg-color); font-family: Arial, sans-serif; border-radius: var(--page-border-radius); } .zine { position: relative; width: 100%; height: 100%; perspective: calc(var(--page-width) * 5); } .page { position: absolute; right: 0; width: 50%; height: 100%; transform-origin: left; transform-style: preserve-3d; transition: transform var(--transition-duration); } .page.flipped { transform: rotateY(-180deg); } .page > div { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; justify-content: center; align-items: center; font-size: 1.2em; background: var(--page-bg-color); } .front { background-color: #fdf6e3; overflow: hidden; & img { border-radius: 0 var(--page-border-radius) var(--page-border-radius) 0; } } .back { transform: rotateY(180deg); background-color: #eee; overflow: hidden; & img { border-radius: var(--page-border-radius) 0 0 var(--page-border-radius); } } #next, #prev { position: absolute; width: 50%; height: 100%; top: 0; bottom: 0; } #prev { left: -25%; } #next { right: 0; } button { padding: 10px 20px; margin: 0 10px; border: none; background-color: transparent; font-size: 16px; cursor: pointer; z-index: 10; } button:disabled { cursor: not-allowed; } img { max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid #ccc; } `; B = He([ Ce("zine-viewer") ], B); export { B as ZineViewer };