UNPKG

1.43 kBJavaScriptView Raw
1import {
2 e,
3 i,
4 t
5} from "./chunk.2JQPDYNA.js";
6import {
7 b
8} from "./chunk.WWAD5WF4.js";
9
10// node_modules/lit-html/directives/class-map.js
11var o = e(class extends i {
12 constructor(t2) {
13 var i2;
14 if (super(t2), t2.type !== t.ATTRIBUTE || "class" !== t2.name || (null === (i2 = t2.strings) || void 0 === i2 ? void 0 : i2.length) > 2)
15 throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
16 }
17 render(t2) {
18 return " " + Object.keys(t2).filter((i2) => t2[i2]).join(" ") + " ";
19 }
20 update(i2, [s]) {
21 var r, o2;
22 if (void 0 === this.et) {
23 this.et = /* @__PURE__ */ new Set(), void 0 !== i2.strings && (this.st = new Set(i2.strings.join(" ").split(/\s/).filter((t2) => "" !== t2)));
24 for (const t2 in s)
25 s[t2] && !(null === (r = this.st) || void 0 === r ? void 0 : r.has(t2)) && this.et.add(t2);
26 return this.render(s);
27 }
28 const e2 = i2.element.classList;
29 this.et.forEach((t2) => {
30 t2 in s || (e2.remove(t2), this.et.delete(t2));
31 });
32 for (const t2 in s) {
33 const i3 = !!s[t2];
34 i3 === this.et.has(t2) || (null === (o2 = this.st) || void 0 === o2 ? void 0 : o2.has(t2)) || (i3 ? (e2.add(t2), this.et.add(t2)) : (e2.remove(t2), this.et.delete(t2)));
35 }
36 return b;
37 }
38});
39
40export {
41 o
42};
43/**
44 * @license
45 * Copyright 2018 Google LLC
46 * SPDX-License-Identifier: BSD-3-Clause
47 */