UNPKG

gk-lit-web-components

Version:

A collection of reusable web components built with Lit for Nuxt.js applications.

919 lines (906 loc) 31.1 kB
import { css as rt, LitElement as nt, html as m } from "lit"; import { animate as ut } from "@lit-labs/motion"; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const ot = (r) => (t, e) => { e !== void 0 ? e.addInitializer(() => { customElements.define(r, t); }) : customElements.define(r, t); }; /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const k = globalThis, q = k.ShadowRoot && (k.ShadyCSS === void 0 || k.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, at = Symbol(), K = /* @__PURE__ */ new WeakMap(); let $t = class { constructor(t, e, s) { if (this._$cssResult$ = !0, s !== at) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t, this.t = e; } get styleSheet() { let t = this.o; const e = this.t; if (q && t === void 0) { const s = e !== void 0 && e.length === 1; s && (t = K.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && K.set(e, t)); } return t; } toString() { return this.cssText; } }; const ft = (r) => new $t(typeof r == "string" ? r : r + "", void 0, at), yt = (r, t) => { if (q) r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet); else for (const e of t) { const s = document.createElement("style"), i = k.litNonce; i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, r.appendChild(s); } }, F = q ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => { let e = ""; for (const s of t.cssRules) e += s.cssText; return ft(e); })(r) : r; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const { is: _t, defineProperty: gt, getOwnPropertyDescriptor: mt, getOwnPropertyNames: vt, getOwnPropertySymbols: At, getPrototypeOf: bt } = Object, _ = globalThis, G = _.trustedTypes, wt = G ? G.emptyScript : "", L = _.reactiveElementPolyfillSupport, C = (r, t) => r, I = { toAttribute(r, t) { switch (t) { case Boolean: r = r ? wt : null; break; case Object: case Array: r = r == null ? r : JSON.stringify(r); } return r; }, fromAttribute(r, t) { let e = r; switch (t) { case Boolean: e = r !== null; break; case Number: e = r === null ? null : Number(r); break; case Object: case Array: try { e = JSON.parse(r); } catch { e = null; } } return e; } }, V = (r, t) => !_t(r, t), Q = { attribute: !0, type: String, converter: I, reflect: !1, useDefault: !1, hasChanged: V }; Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), _.litPropertyMetadata ?? (_.litPropertyMetadata = /* @__PURE__ */ new WeakMap()); class x extends HTMLElement { static addInitializer(t) { this._$Ei(), (this.l ?? (this.l = [])).push(t); } static get observedAttributes() { return this.finalize(), this._$Eh && [...this._$Eh.keys()]; } static createProperty(t, e = Q) { if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) { const s = Symbol(), i = this.getPropertyDescriptor(t, s, e); i !== void 0 && gt(this.prototype, t, i); } } static getPropertyDescriptor(t, e, s) { const { get: i, set: n } = mt(this.prototype, t) ?? { get() { return this[e]; }, set(o) { this[e] = o; } }; return { get: i, set(o) { const h = i == null ? void 0 : i.call(this); n == null || n.call(this, o), this.requestUpdate(t, h, s); }, configurable: !0, enumerable: !0 }; } static getPropertyOptions(t) { return this.elementProperties.get(t) ?? Q; } static _$Ei() { if (this.hasOwnProperty(C("elementProperties"))) return; const t = bt(this); t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties); } static finalize() { if (this.hasOwnProperty(C("finalized"))) return; if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(C("properties"))) { const e = this.properties, s = [...vt(e), ...At(e)]; for (const i of s) this.createProperty(i, e[i]); } const t = this[Symbol.metadata]; if (t !== null) { const e = litPropertyMetadata.get(t); if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i); } this._$Eh = /* @__PURE__ */ new Map(); for (const [e, s] of this.elementProperties) { const i = this._$Eu(e, s); i !== void 0 && this._$Eh.set(i, e); } this.elementStyles = this.finalizeStyles(this.styles); } static finalizeStyles(t) { const e = []; if (Array.isArray(t)) { const s = new Set(t.flat(1 / 0).reverse()); for (const i of s) e.unshift(F(i)); } else t !== void 0 && e.push(F(t)); return e; } static _$Eu(t, e) { const s = e.attribute; return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0; } constructor() { super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev(); } _$Ev() { var t; this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this)); } addController(t) { var e; (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t)); } removeController(t) { var e; (e = this._$EO) == null || e.delete(t); } _$E_() { const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties; for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]); t.size > 0 && (this._$Ep = t); } createRenderRoot() { const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); return yt(t, this.constructor.elementStyles), t; } connectedCallback() { var t; this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => { var s; return (s = e.hostConnected) == null ? void 0 : s.call(e); }); } enableUpdating(t) { } disconnectedCallback() { var t; (t = this._$EO) == null || t.forEach((e) => { var s; return (s = e.hostDisconnected) == null ? void 0 : s.call(e); }); } attributeChangedCallback(t, e, s) { this._$AK(t, s); } _$ET(t, e) { var n; const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s); if (i !== void 0 && s.reflect === !0) { const o = (((n = s.converter) == null ? void 0 : n.toAttribute) !== void 0 ? s.converter : I).toAttribute(e, s.type); this._$Em = t, o == null ? this.removeAttribute(i) : this.setAttribute(i, o), this._$Em = null; } } _$AK(t, e) { var n, o; const s = this.constructor, i = s._$Eh.get(t); if (i !== void 0 && this._$Em !== i) { const h = s.getPropertyOptions(i), a = typeof h.converter == "function" ? { fromAttribute: h.converter } : ((n = h.converter) == null ? void 0 : n.fromAttribute) !== void 0 ? h.converter : I; this._$Em = i, this[i] = a.fromAttribute(e, h.type) ?? ((o = this._$Ej) == null ? void 0 : o.get(i)) ?? null, this._$Em = null; } } requestUpdate(t, e, s) { var i; if (t !== void 0) { const n = this.constructor, o = this[t]; if (s ?? (s = n.getPropertyOptions(t)), !((s.hasChanged ?? V)(o, e) || s.useDefault && s.reflect && o === ((i = this._$Ej) == null ? void 0 : i.get(t)) && !this.hasAttribute(n._$Eu(t, s)))) return; this.C(t, e, s); } this.isUpdatePending === !1 && (this._$ES = this._$EP()); } C(t, e, { useDefault: s, reflect: i, wrapped: n }, o) { s && !(this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Map())).has(t) && (this._$Ej.set(t, o ?? e ?? this[t]), n !== !0 || o !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), i === !0 && this._$Em !== t && (this._$Eq ?? (this._$Eq = /* @__PURE__ */ new Set())).add(t)); } async _$EP() { this.isUpdatePending = !0; try { await this._$ES; } catch (e) { Promise.reject(e); } const t = this.scheduleUpdate(); return t != null && await t, !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 [n, o] of this._$Ep) this[n] = o; this._$Ep = void 0; } const i = this.constructor.elementProperties; if (i.size > 0) for (const [n, o] of i) { const { wrapped: h } = o, a = this[n]; h !== !0 || this._$AL.has(n) || a === void 0 || this.C(n, void 0, o, a); } } let t = !1; const e = this._$AL; try { t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => { var n; return (n = i.hostUpdate) == null ? void 0 : n.call(i); }), this.update(e)) : this._$EM(); } catch (i) { throw t = !1, this._$EM(), i; } t && this._$AE(e); } willUpdate(t) { } _$AE(t) { var e; (e = this._$EO) == null || e.forEach((s) => { var i; return (i = s.hostUpdated) == null ? void 0 : i.call(s); }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t); } _$EM() { this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1; } get updateComplete() { return this.getUpdateComplete(); } getUpdateComplete() { return this._$ES; } shouldUpdate(t) { return !0; } update(t) { this._$Eq && (this._$Eq = this._$Eq.forEach((e) => this._$ET(e, this[e]))), this._$EM(); } updated(t) { } firstUpdated(t) { } } x.elementStyles = [], x.shadowRootOptions = { mode: "open" }, x[C("elementProperties")] = /* @__PURE__ */ new Map(), x[C("finalized")] = /* @__PURE__ */ new Map(), L == null || L({ ReactiveElement: x }), (_.reactiveElementVersions ?? (_.reactiveElementVersions = [])).push("2.1.0"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const Et = { attribute: !0, type: String, converter: I, reflect: !1, hasChanged: V }, xt = (r = Et, t, e) => { const { kind: s, metadata: i } = e; let n = globalThis.litPropertyMetadata.get(i); if (n === void 0 && globalThis.litPropertyMetadata.set(i, n = /* @__PURE__ */ new Map()), s === "setter" && ((r = Object.create(r)).wrapped = !0), n.set(e.name, r), s === "accessor") { const { name: o } = e; return { set(h) { const a = t.get.call(this); t.set.call(this, h), this.requestUpdate(o, a, r); }, init(h) { return h !== void 0 && this.C(o, void 0, r, h), h; } }; } if (s === "setter") { const { name: o } = e; return function(h) { const a = this[o]; t.call(this, h), this.requestUpdate(o, a, r); }; } throw Error("Unsupported decorator location: " + s); }; function O(r) { return (t, e) => typeof e == "object" ? xt(r, t, e) : ((s, i, n) => { const o = i.hasOwnProperty(n); return i.constructor.createProperty(n, s), o ? Object.getOwnPropertyDescriptor(i, n) : void 0; })(r, t, e); } /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ function z(r) { return O({ ...r, state: !0, attribute: !1 }); } var St = Object.defineProperty, Ct = Object.getOwnPropertyDescriptor, b = (r, t, e, s) => { for (var i = s > 1 ? void 0 : s ? Ct(t, e) : t, n = r.length - 1, o; n >= 0; n--) (o = r[n]) && (i = (s ? o(t, e, i) : o(i)) || i); return s && i && St(t, e, i), i; }; let $ = class extends nt { constructor() { super(...arguments), this.sliders = [], this.showTrustMarkers = !1, this.isMarketing = !1, this.currentIndex = 0, this.autoplayInterval = null, this.isHydrated = !1; } connectedCallback() { super.connectedCallback(), this.isHydrated = !0, this.startAutoplay(); } disconnectedCallback() { super.disconnectedCallback(), this.stopAutoplay(); } startAutoplay() { this.isHydrated && (this.stopAutoplay(), this.autoplayInterval = window.setInterval(() => { this.nextSlide(); }, 5e3)); } stopAutoplay() { this.autoplayInterval && (clearInterval(this.autoplayInterval), this.autoplayInterval = null); } nextSlide() { this.isHydrated && (this.currentIndex = (this.currentIndex + 1) % this.sliders.length, this.dispatchEvent( new CustomEvent("slideChange", { detail: { index: this.currentIndex, slide: this.sliders[this.currentIndex] } }) )); } handleSlideClick(r) { this.isHydrated && (this.currentIndex = r, this.startAutoplay(), this.dispatchEvent( new CustomEvent("slideClick", { detail: { index: r, slide: this.sliders[r] } }) )); } handleImageClick(r, t) { this.isHydrated && t.targetUrl && this.dispatchEvent( new CustomEvent("slideLinkClick", { detail: { url: t.targetUrl, slide: t } }) ); } render() { const r = this.isHydrated ? this.sliders : this.sliders.slice(0, 1); return m` <div class="slider-container"> <div class="slider-wrapper"> ${r.map( (t, e) => m` <div class="slide ${e === this.currentIndex ? "active" : ""}" @click=${(s) => this.handleImageClick(s, t)} > <picture> <source media="(max-width: 767px)" srcset=${t.mobileBannerImageUrl} /> <img class="slide-image" src=${t.bannerImageUrl} alt=${t.alt || t.title || ""} loading=${e === 0 ? "eager" : "lazy"} fetchpriority=${e === 0 ? "high" : "low"} /> </picture> ${t.showWaterMark ? m` <img class="watermark" src="/images/water-mark-color.webp" alt="watermark" width="80" height="80" loading="eager" /> ` : ""} </div> ` )} </div> ${this.isHydrated && this.sliders.length > 1 ? m` <div class="pagination"> ${this.sliders.map( (t, e) => m` <div class="pagination-bullet ${e === this.currentIndex ? "active" : ""}" @click=${() => this.handleSlideClick(e)} ></div> ` )} </div> ` : ""} </div> `; } }; $.styles = rt` :host { display: block; --slider-width: 560px; --slider-height: 560px; --mobile-slider-width: 360px; --mobile-slider-height: 360px; } .slider-container { position: relative; width: 100%; max-width: var(--slider-width); margin: 0 auto; } .slider-wrapper { position: relative; width: 100%; height: 0; padding-bottom: 100%; overflow: hidden; border-radius: 12px; } .slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.5s ease-in-out; } .slide.active { opacity: 1; } .slide-image { width: 100%; height: 100%; object-fit: cover; } .pagination { position: absolute; bottom: 20px; left: 0; right: 0; display: flex; justify-content: center; gap: 8px; z-index: 10; } .pagination-bullet { width: 6px; height: 6px; border-radius: 50%; background: var(--md-sys-color-on-background); opacity: 0.5; cursor: pointer; transition: opacity 0.3s ease; } .pagination-bullet.active { opacity: 1; } .watermark { position: absolute; top: 58px; right: 44px; width: 80px; height: 80px; z-index: 10; } @media (max-width: 767px) { .slider-container { max-width: var(--mobile-slider-width); } .watermark { top: 64px; right: 25px; } } `; b([ O({ type: Array }) ], $.prototype, "sliders", 2); b([ O({ type: Boolean }) ], $.prototype, "showTrustMarkers", 2); b([ O({ type: Boolean }) ], $.prototype, "isMarketing", 2); b([ z() ], $.prototype, "currentIndex", 2); b([ z() ], $.prototype, "autoplayInterval", 2); b([ z() ], $.prototype, "isHydrated", 2); $ = b([ ot("banner-slider") ], $); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const P = globalThis, N = P.trustedTypes, X = N ? N.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ht = "$lit$", y = `lit$${Math.random().toFixed(9).slice(2)}$`, lt = "?" + y, Pt = `<${lt}>`, A = document, R = () => A.createComment(""), H = (r) => r === null || typeof r != "object" && typeof r != "function", Z = Array.isArray, Ht = (r) => Z(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", B = `[ \f\r]`, S = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Y = /-->/g, tt = />/g, g = RegExp(`>|${B}(?:([^\\s"'>=/]+)(${B}*=${B}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`, "g"), et = /'/g, st = /"/g, ct = /^(?:script|style|textarea|title)$/i, w = Symbol.for("lit-noChange"), d = Symbol.for("lit-nothing"), it = /* @__PURE__ */ new WeakMap(), v = A.createTreeWalker(A, 129); function dt(r, t) { if (!Z(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array"); return X !== void 0 ? X.createHTML(t) : t; } const Ut = (r, t) => { const e = r.length - 1, s = []; let i, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = S; for (let h = 0; h < e; h++) { const a = r[h]; let c, p, l = -1, u = 0; for (; u < a.length && (o.lastIndex = u, p = o.exec(a), p !== null); ) u = o.lastIndex, o === S ? p[1] === "!--" ? o = Y : p[1] !== void 0 ? o = tt : p[2] !== void 0 ? (ct.test(p[2]) && (i = RegExp("</" + p[2], "g")), o = g) : p[3] !== void 0 && (o = g) : o === g ? p[0] === ">" ? (o = i ?? S, l = -1) : p[1] === void 0 ? l = -2 : (l = o.lastIndex - p[2].length, c = p[1], o = p[3] === void 0 ? g : p[3] === '"' ? st : et) : o === st || o === et ? o = g : o === Y || o === tt ? o = S : (o = g, i = void 0); const f = o === g && r[h + 1].startsWith("/>") ? " " : ""; n += o === S ? a + Pt : l >= 0 ? (s.push(c), a.slice(0, l) + ht + a.slice(l) + y + f) : a + y + (l === -2 ? h : f); } return [dt(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s]; }; class U { constructor({ strings: t, _$litType$: e }, s) { let i; this.parts = []; let n = 0, o = 0; const h = t.length - 1, a = this.parts, [c, p] = Ut(t, e); if (this.el = U.createElement(c, s), v.currentNode = this.el.content, e === 2 || e === 3) { const l = this.el.content.firstChild; l.replaceWith(...l.childNodes); } for (; (i = v.nextNode()) !== null && a.length < h; ) { if (i.nodeType === 1) { if (i.hasAttributes()) for (const l of i.getAttributeNames()) if (l.endsWith(ht)) { const u = p[o++], f = i.getAttribute(l).split(y), T = /([.?@])?(.*)/.exec(u); a.push({ type: 1, index: n, name: T[2], strings: f, ctor: T[1] === "." ? Ot : T[1] === "?" ? Tt : T[1] === "@" ? kt : D }), i.removeAttribute(l); } else l.startsWith(y) && (a.push({ type: 6, index: n }), i.removeAttribute(l)); if (ct.test(i.tagName)) { const l = i.textContent.split(y), u = l.length - 1; if (u > 0) { i.textContent = N ? N.emptyScript : ""; for (let f = 0; f < u; f++) i.append(l[f], R()), v.nextNode(), a.push({ type: 2, index: ++n }); i.append(l[u], R()); } } } else if (i.nodeType === 8) if (i.data === lt) a.push({ type: 2, index: n }); else { let l = -1; for (; (l = i.data.indexOf(y, l + 1)) !== -1; ) a.push({ type: 7, index: n }), l += y.length - 1; } n++; } } static createElement(t, e) { const s = A.createElement("template"); return s.innerHTML = t, s; } } function E(r, t, e = r, s) { var o, h; if (t === w) return t; let i = s !== void 0 ? (o = e._$Co) == null ? void 0 : o[s] : e._$Cl; const n = H(t) ? void 0 : t._$litDirective$; return (i == null ? void 0 : i.constructor) !== n && ((h = i == null ? void 0 : i._$AO) == null || h.call(i, !1), n === void 0 ? i = void 0 : (i = new n(r), i._$AT(r, e, s)), s !== void 0 ? (e._$Co ?? (e._$Co = []))[s] = i : e._$Cl = i), i !== void 0 && (t = E(r, i._$AS(r, t.values), i, s)), t; } class Mt { constructor(t, e) { this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e; } get parentNode() { return this._$AM.parentNode; } get _$AU() { return this._$AM._$AU; } u(t) { const { el: { content: e }, parts: s } = this._$AD, i = ((t == null ? void 0 : t.creationScope) ?? A).importNode(e, !0); v.currentNode = i; let n = v.nextNode(), o = 0, h = 0, a = s[0]; for (; a !== void 0; ) { if (o === a.index) { let c; a.type === 2 ? c = new j(n, n.nextSibling, this, t) : a.type === 1 ? c = new a.ctor(n, a.name, a.strings, this, t) : a.type === 6 && (c = new It(n, this, t)), this._$AV.push(c), a = s[++h]; } o !== (a == null ? void 0 : a.index) && (n = v.nextNode(), o++); } return v.currentNode = A, i; } p(t) { let e = 0; for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++; } } class j { get _$AU() { var t; return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv; } constructor(t, e, s, i) { this.type = 2, this._$AH = d, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this._$Cv = (i == null ? void 0 : i.isConnected) ?? !0; } get parentNode() { let t = this._$AA.parentNode; const e = this._$AM; return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t; } get startNode() { return this._$AA; } get endNode() { return this._$AB; } _$AI(t, e = this) { t = E(this, t, e), H(t) ? t === d || t == null || t === "" ? (this._$AH !== d && this._$AR(), this._$AH = d) : t !== this._$AH && t !== w && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Ht(t) ? this.k(t) : this._(t); } O(t) { return this._$AA.parentNode.insertBefore(t, this._$AB); } T(t) { this._$AH !== t && (this._$AR(), this._$AH = this.O(t)); } _(t) { this._$AH !== d && H(this._$AH) ? this._$AA.nextSibling.data = t : this.T(A.createTextNode(t)), this._$AH = t; } $(t) { var n; const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = U.createElement(dt(s.h, s.h[0]), this.options)), s); if (((n = this._$AH) == null ? void 0 : n._$AD) === i) this._$AH.p(e); else { const o = new Mt(i, this), h = o.u(this.options); o.p(e), this.T(h), this._$AH = o; } } _$AC(t) { let e = it.get(t.strings); return e === void 0 && it.set(t.strings, e = new U(t)), e; } k(t) { Z(this._$AH) || (this._$AH = [], this._$AR()); const e = this._$AH; let s, i = 0; for (const n of t) i === e.length ? e.push(s = new j(this.O(R()), this.O(R()), this, this.options)) : s = e[i], s._$AI(n), i++; i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i); } _$AR(t = this._$AA.nextSibling, e) { var s; for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t && t !== this._$AB; ) { const i = t.nextSibling; t.remove(), t = i; } } setConnected(t) { var e; this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t)); } } class D { get tagName() { return this.element.tagName; } get _$AU() { return this._$AM._$AU; } constructor(t, e, s, i, n) { this.type = 1, this._$AH = d, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = n, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = d; } _$AI(t, e = this, s, i) { const n = this.strings; let o = !1; if (n === void 0) t = E(this, t, e, 0), o = !H(t) || t !== this._$AH && t !== w, o && (this._$AH = t); else { const h = t; let a, c; for (t = n[0], a = 0; a < n.length - 1; a++) c = E(this, h[s + a], e, a), c === w && (c = this._$AH[a]), o || (o = !H(c) || c !== this._$AH[a]), c === d ? t = d : t !== d && (t += (c ?? "") + n[a + 1]), this._$AH[a] = c; } o && !i && this.j(t); } j(t) { t === d ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? ""); } } class Ot extends D { constructor() { super(...arguments), this.type = 3; } j(t) { this.element[this.name] = t === d ? void 0 : t; } } class Tt extends D { constructor() { super(...arguments), this.type = 4; } j(t) { this.element.toggleAttribute(this.name, !!t && t !== d); } } class kt extends D { constructor(t, e, s, i, n) { super(t, e, s, i, n), this.type = 5; } _$AI(t, e = this) { if ((t = E(this, t, e, 0) ?? d) === w) return; const s = this._$AH, i = t === d && s !== d || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, n = t !== d && (s === d || i); i && this.element.removeEventListener(this.name, this, s), n && this.element.addEventListener(this.name, this, t), this._$AH = t; } handleEvent(t) { var e; typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t); } } class It { constructor(t, e, s) { this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s; } get _$AU() { return this._$AM._$AU; } _$AI(t) { E(this, t); } } const W = P.litHtmlPolyfillSupport; W == null || W(U, j), (P.litHtmlVersions ?? (P.litHtmlVersions = [])).push("3.3.0"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const Nt = { ATTRIBUTE: 1 }, Rt = (r) => (...t) => ({ _$litDirective$: r, values: t }); let zt = class { constructor(t) { } get _$AU() { return this._$AM._$AU; } _$AT(t, e, s) { this._$Ct = t, this._$AM = e, this._$Ci = s; } _$AS(t, e) { return this.update(t, e); } update(t, e) { return this.render(...e); } }; /** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const pt = "important", jt = " !" + pt, Dt = Rt(class extends zt { constructor(r) { var t; if (super(r), r.type !== Nt.ATTRIBUTE || r.name !== "style" || ((t = r.strings) == null ? void 0 : t.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute."); } render(r) { return Object.keys(r).reduce((t, e) => { const s = r[e]; return s == null ? t : t + `${e = e.includes("-") ? e : e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s};`; }, ""); } update(r, [t]) { const { style: e } = r.element; if (this.ft === void 0) return this.ft = new Set(Object.keys(t)), this.render(t); for (const s of this.ft) t[s] == null && (this.ft.delete(s), s.includes("-") ? e.removeProperty(s) : e[s] = null); for (const s in t) { const i = t[s]; if (i != null) { this.ft.add(s); const n = typeof i == "string" && i.endsWith(jt); s.includes("-") || n ? e.setProperty(s, n ? i.slice(0, -11) : i, n ? pt : "") : e[s] = i; } } return w; } }), Lt = [ rt` .container { display: flex; align-items: center; justify-content: center; --size: 50vw; width: calc(var(--size) + 80px); gap: 8px; border-radius: 8px; padding: 8px; overflow: hidden; border: 4px solid #002071; background: #e1e2e1; } .card { background: #e1e2e1; border-radius: 8px; border: 1px solid #002071; height: var(--size); min-width: var(--size); padding: 8px; will-change: transform; display: flex; align-items: center; justify-content: center; color: white; font-size: var(--size); cursor: pointer; user-select: none; } ` ]; var Bt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, J = (r, t, e, s) => { for (var i = s > 1 ? void 0 : s ? Wt(t, e) : t, n = r.length - 1, o; n >= 0; n--) (o = r[n]) && (i = (s ? o(t, e, i) : o(i)) || i); return s && i && Bt(t, e, i), i; }; let M = class extends nt { constructor() { super(...arguments), this.selected = 0, this.data = Array(7).fill(null, 0), this.isHydrated = !1; } connectedCallback() { super.connectedCallback(), this.isHydrated = !0; } render() { const r = this.isHydrated ? this.data : this.data.slice(0, 1); return m` <section class="container"> ${r.map((t, e) => { const s = this.data.length, i = Math.trunc(s / 2), n = (s + i + e - this.selected) % s, o = n === 0 || n === s - 1 ? -1 : 1, h = e / this.data.length; return m`<div @click=${this.isHydrated ? n < i ? this.dec : this.inc : void 0} style=${Dt({ order: String(n), zIndex: String(o), background: `hsl( ${Math.trunc(360 * h)}, ${20 + Math.trunc(60 * h)}%, ${30 + Math.trunc(30 * h)}%)` })} class="card" ${this.isHydrated ? ut() : ""} > ${e} </div>`; })} </section> `; } shift(r) { if (!this.isHydrated) return r; const t = this.data.length - 1; return r > t ? 0 : r < 0 ? t : r; } dec() { this.isHydrated && (this.selected = this.shift(this.selected - 1)); } inc() { this.isHydrated && (this.selected = this.shift(this.selected + 1)); } }; M.styles = Lt; J([ O({ type: Number }) ], M.prototype, "selected", 2); J([ z() ], M.prototype, "isHydrated", 2); M = J([ ot("motion-carousel") ], M); export { $ as BannerSlider, M as MotionCarousel };