wrec 0.18.2 → 0.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/wrec.es.js CHANGED
@@ -1,89 +1,83 @@
1
- function M(n, t) {
2
- let e = n;
3
- for (const s of t.split("."))
4
- e = e[s];
5
- return e;
1
+ function R(r, t) {
2
+ let s = r;
3
+ for (const e of t.split("."))
4
+ s = s[e];
5
+ return s;
6
6
  }
7
- function H(n, t, e) {
8
- const s = t.split("."), o = s.length - 1;
9
- let i = n;
10
- s.forEach((r, h) => {
11
- h === o ? i[r] = e : i = i[r];
7
+ function O(r, t, s) {
8
+ const e = t.split("."), o = e.length - 1;
9
+ let i = r;
10
+ e.forEach((n, h) => {
11
+ h === o ? i[n] = s : i = i[n];
12
12
  });
13
13
  }
14
14
  class m extends Error {
15
15
  }
16
- const O = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, P = "a-zA-Z_$", F = P + "0-9", b = `[${P}][${F}]*`, j = /<!--\s*(.*?)\s*-->/, V = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, A = new RegExp(`^this\\.${b}$`), E = new RegExp(`this\\.${b}(\\.${b})*`, "g"), $ = new RegExp(`this\\.${b}(\\.${b})*`), _ = /* @__PURE__ */ new Set(["class", "style"]), N = 5;
17
- function I(n) {
18
- return n instanceof HTMLButtonElement || n instanceof HTMLFieldSetElement || n instanceof HTMLInputElement || n instanceof HTMLSelectElement || n instanceof HTMLTextAreaElement || n instanceof u;
16
+ const k = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, P = "a-zA-Z_$", F = P + "0-9", b = `[${P}][${F}]*`, j = /<!--\s*(.*?)\s*-->/, _ = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, A = new RegExp(`^this\\.${b}$`), y = new RegExp(`this\\.${b}(\\.${b})*`, "g"), N = new RegExp(`this\\.${b}(\\.${b})*`), V = /* @__PURE__ */ new Set(["class", "style"]), $ = 5;
17
+ function I(r) {
18
+ return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof u;
19
19
  }
20
- function D(n) {
21
- const t = new CSSStyleSheet();
22
- for (const e of Array.from(n.cssRules))
23
- t.insertRule(e.cssText);
24
- return t;
25
- }
26
- function z(n, t, e) {
27
- const s = document.createElement(n);
20
+ function q(r, t, s) {
21
+ const e = document.createElement(r);
28
22
  if (t)
29
23
  for (const [o, i] of Object.entries(t))
30
- s.setAttribute(o, i);
31
- return e && (s.innerHTML = e), s;
24
+ e.setAttribute(o, i);
25
+ return s && (e.innerHTML = s), e;
32
26
  }
33
- const B = (n) => n === String ? "" : n === Number ? 0 : n === Boolean ? !1 : n === Array ? [] : n === Object ? {} : void 0;
34
- function w(n) {
27
+ const D = (r) => r === String ? "" : r === Number ? 0 : r === Boolean ? !1 : r === Array ? [] : r === Object ? {} : void 0;
28
+ function w(r) {
35
29
  const t = [];
36
- let e = n.firstElementChild;
37
- for (; e; )
38
- t.push(e), e.shadowRoot && t.push(...w(e.shadowRoot)), e.firstElementChild && t.push(...w(e)), e = e.nextElementSibling;
30
+ let s = r.firstElementChild;
31
+ for (; s; )
32
+ t.push(s), s.shadowRoot && t.push(...w(s.shadowRoot)), s.firstElementChild && t.push(...w(s)), s = s.nextElementSibling;
39
33
  return t;
40
34
  }
41
- const g = (n) => n.substring(N).split(".")[0];
42
- function x(n, t) {
43
- let e = n[0];
44
- return t.forEach((s, o) => {
45
- e += s + n[o + 1];
46
- }), e;
35
+ const E = (r) => r.substring($).split(".")[0];
36
+ function x(r, t) {
37
+ let s = r[0];
38
+ return t.forEach((e, o) => {
39
+ s += e + r[o + 1];
40
+ }), s;
47
41
  }
48
- function T(n) {
49
- const t = typeof n;
42
+ function S(r) {
43
+ const t = typeof r;
50
44
  return t === "string" || t === "number" || t === "boolean";
51
45
  }
52
- function d(n) {
53
- return n.localName === "textarea";
46
+ function d(r) {
47
+ return r.localName === "textarea";
54
48
  }
55
- function R(n) {
56
- const { localName: t } = n;
49
+ function v(r) {
50
+ const { localName: t } = r;
57
51
  return t === "input" || t === "select";
58
52
  }
59
- const q = (n) => n.replace(/<!--[\s\S]*?-->/g, "");
60
- function L(n, t, e, s) {
61
- return n.slice(0, t) + s + n.slice(t + e);
53
+ const B = (r) => r.replace(/<!--[\s\S]*?-->/g, "");
54
+ function L(r, t, s, e) {
55
+ return r.slice(0, t) + e + r.slice(t + s);
62
56
  }
63
- function S(n) {
64
- const t = Number(n);
65
- if (isNaN(t)) throw new m(`can't convert "${n}" to a number`);
57
+ function C(r) {
58
+ const t = Number(r);
59
+ if (isNaN(t)) throw new m(`can't convert "${r}" to a number`);
66
60
  return t;
67
61
  }
68
- function k(n, t, e) {
69
- const [s, o] = t.split(":");
70
- if (T(e))
71
- if (typeof e == "boolean") {
72
- e ? n.setAttribute(s, s) : n.removeAttribute(s);
73
- const i = u.getPropName(s);
74
- n[i] = e;
62
+ function H(r, t, s) {
63
+ const [e, o] = t.split(":");
64
+ if (S(s))
65
+ if (typeof s == "boolean") {
66
+ s ? r.setAttribute(e, e) : r.removeAttribute(e);
67
+ const i = u.getPropName(e);
68
+ r[i] = s;
75
69
  } else {
76
- const i = n.getAttribute(t), r = String(e);
77
- i !== r && (n.setAttribute(s, r), s === "value" && R(n) && (n.value = r));
70
+ const i = r.getAttribute(t), n = String(s);
71
+ i !== n && (r.setAttribute(e, n), e === "value" && v(r) && (r.value = n));
78
72
  }
79
73
  else {
80
74
  const i = u.getPropName(t);
81
- n[i] = e;
75
+ r[i] = s;
82
76
  }
83
77
  }
84
- function C(n, t, e) {
85
- const [s, o] = t.split(":");
86
- n instanceof CSSStyleRule ? n.style.setProperty(s, e) : (k(n, s, e), s === "value" && R(n) && (n.value = e));
78
+ function T(r, t, s) {
79
+ const [e, o] = t.split(":");
80
+ r instanceof CSSStyleRule ? r.style.setProperty(e, s) : (H(r, e, s), e === "value" && v(r) && (r.value = s));
87
81
  }
88
82
  class u extends HTMLElement {
89
83
  // This is used to lookup the camelCase property name
@@ -117,17 +111,15 @@ class u extends HTMLElement {
117
111
  // This is a map from properties to expressions that refer to them.
118
112
  // It is the sma for all instances of a component.
119
113
  // This map cannot be private.
120
- //static propToExprsMap: Map<string, string[]> | null = null;
121
114
  static propToExprsMap;
122
- static stylesheet = null;
123
115
  static template = null;
124
116
  #t = this.constructor;
125
117
  // This is a map from expressions to references to them
126
118
  // which can be found in element text content,
127
119
  // attribute values, and CSS property values.
128
120
  // Each component instance needs its own map.
129
- #s = /* @__PURE__ */ new Map();
130
- #a = {};
121
+ #e = /* @__PURE__ */ new Map();
122
+ #c = {};
131
123
  #i;
132
124
  // For components that set `formAssociated` to true,
133
125
  // this stores in the initial value of each property
@@ -148,157 +140,147 @@ class u extends HTMLElement {
148
140
  const t = this.#t;
149
141
  t.properties || (t.properties = {}), t.propToComputedMap || (t.propToComputedMap = /* @__PURE__ */ new Map()), t.propToExprsMap || (t.propToExprsMap = /* @__PURE__ */ new Map());
150
142
  }
151
- attributeChangedCallback(t, e, s) {
143
+ attributeChangedCallback(t, s, e) {
152
144
  t === "disabled" && this.#m();
153
145
  const o = u.getPropName(t);
154
- if (this.#r(o)) {
155
- const i = this.#E(o, String(s));
146
+ if (this.#n(o)) {
147
+ const i = this.#y(o, String(e));
156
148
  this[o] = i;
157
- const r = this.#a[o];
158
- r && this.setFormValue(r, String(i)), this.propertyChangedCallback(o, e, s);
149
+ const n = this.#c[o];
150
+ n && this.setFormValue(n, String(i)), this.propertyChangedCallback(o, s, e);
159
151
  }
160
152
  }
161
153
  #w() {
162
154
  if (!this.shadowRoot) return;
163
155
  const t = this.#t;
164
- if (t.css) {
165
- let { stylesheet: s } = t;
166
- if (!s) {
167
- s = t.stylesheet = new CSSStyleSheet();
168
- const o = `:host([hidden]) { display: none; } ${t.css}`;
169
- s.replaceSync(o);
170
- }
171
- this.shadowRoot.adoptedStyleSheets = [D(s)];
172
- }
173
- let e = t.template;
174
- if (!e) {
175
- e = t.template = document.createElement("template");
176
- const s = t.html.trim();
177
- e.innerHTML = s.startsWith("<") ? s : `<span><!--${s}--></span>`;
156
+ let { template: s } = t;
157
+ if (!s) {
158
+ s = t.template = document.createElement("template");
159
+ let e = `<style>
160
+ :host([hidden]) { display: none; }`;
161
+ t.css && (e += t.css), e += `</style>
162
+ `;
163
+ let o = t.html.trim();
164
+ o.startsWith("<") || (o = `<span><!--${o}--></span>`), s.innerHTML = e + o;
178
165
  }
179
- this.shadowRoot.replaceChildren(e.content.cloneNode(!0));
166
+ this.shadowRoot.replaceChildren(s.content.cloneNode(!0));
180
167
  }
181
- changed(t, e, s) {
182
- this[e] = s;
168
+ changed(t, s, e) {
169
+ this[s] = e;
183
170
  }
184
171
  connectedCallback() {
185
- this.#O(), this.#R(), this.#w(), this.hasAttribute("disabled") && this.#m(), requestAnimationFrame(() => {
186
- if (this.shadowRoot) {
187
- this.#C(this.shadowRoot), this.#b(this.shadowRoot);
188
- for (const t of this.shadowRoot.adoptedStyleSheets)
189
- this.#N(t);
190
- }
191
- this.#T();
172
+ this.#O(), this.#v(), this.#w(), this.hasAttribute("disabled") && this.#m(), requestAnimationFrame(() => {
173
+ this.shadowRoot && (this.#T(this.shadowRoot), this.#b(this.shadowRoot)), this.#S();
192
174
  });
193
175
  }
194
- #T() {
195
- const t = this.#t, { properties: e } = t;
196
- for (const [s, { computed: o }] of Object.entries(e))
197
- o && (this[s] = this.#o(o));
176
+ #S() {
177
+ const t = this.#t, { properties: s } = t;
178
+ for (const [e, { computed: o }] of Object.entries(s))
179
+ o && (this[e] = this.#o(o));
198
180
  }
199
- #R() {
200
- const t = this.#t, { observedAttributes: e, properties: s } = t;
201
- for (const [o, i] of Object.entries(s))
202
- this.#v(o, i, e);
181
+ #v() {
182
+ const t = this.#t, { observedAttributes: s, properties: e } = t;
183
+ for (const [o, i] of Object.entries(e))
184
+ this.#M(o, i, s);
203
185
  }
204
- #v(t, e, s) {
186
+ #M(t, s, e) {
205
187
  const o = u.getAttrName(t), i = this.hasAttribute(o);
206
- e.required && !i && this.#e(this, t, "is a required attribute");
207
- let r = e.value;
208
- this.hasOwnProperty(t) && (r = this[t], delete this[t]);
209
- const { type: h } = e, c = h === Boolean ? r || i : s.includes(o) && i ? this.#A(t, o) : r || B(h), f = "#" + t;
210
- this[f] = c, e.computed && this.#x(t, e), Object.defineProperty(this, t, {
188
+ s.required && !i && this.#s(this, t, "is a required attribute");
189
+ let n = s.value;
190
+ this.hasOwnProperty(t) && (n = this[t], delete this[t]);
191
+ const { type: h } = s, a = h === Boolean ? n || i : e.includes(o) && i ? this.#A(t, o) : n || D(h), f = "#" + t;
192
+ this[f] = a, s.computed && this.#$(t, s), Object.defineProperty(this, t, {
211
193
  enumerable: !0,
212
194
  get() {
213
195
  return this[f];
214
196
  },
215
- set(a) {
216
- h === Number && typeof a == "string" && (a = S(a));
197
+ set(c) {
198
+ h === Number && typeof c == "string" && (c = C(c));
217
199
  const l = this[f];
218
- if (a === l) return;
219
- this.#j(t, h, a), this[f] = a;
220
- const { state: p, stateProp: y } = this.#t.properties[t];
221
- y && H(p, y, a), this.#k(t), this.#L(t, h, a, o), this.#g(t), this.#H(t, a);
222
- const v = this.#a[t];
223
- v && this.setFormValue(v, String(a)), this.propertyChangedCallback(t, l, a), e.dispatch && this.dispatch("change", { [t]: a });
200
+ if (c === l) return;
201
+ this.#F(t, h, c), this[f] = c;
202
+ const { state: p, stateProp: g } = this.#t.properties[t];
203
+ g && O(p, g, c), this.#L(t), this.#x(t, h, c, o), this.#E(t), this.#H(t, c);
204
+ const M = this.#c[t];
205
+ M && this.setFormValue(M, String(c)), this.propertyChangedCallback(t, l, c), s.dispatch && this.dispatch("change", { [t]: c });
224
206
  }
225
207
  });
226
208
  }
227
209
  #m() {
228
- const t = this.hasAttribute("disabled"), e = w(this.shadowRoot);
229
- for (const s of e)
230
- I(s) && (s.disabled = t);
210
+ const t = this.hasAttribute("disabled"), s = w(this.shadowRoot);
211
+ for (const e of s)
212
+ I(e) && (e.disabled = t);
231
213
  }
232
214
  disconnectedCallback() {
233
- this.#s.clear(), this.#f.clear(), this.#l.clear();
215
+ this.#e.clear(), this.#f.clear(), this.#l.clear();
234
216
  }
235
- dispatch(t, e) {
217
+ dispatch(t, s) {
236
218
  this.dispatchEvent(
237
219
  new CustomEvent(t, {
238
220
  bubbles: !0,
239
221
  // up DOM tree
240
222
  composed: !0,
241
223
  // can pass through shadow DOM
242
- detail: e
224
+ detail: s
243
225
  })
244
226
  );
245
227
  }
246
- displayIfSet(t, e = "block") {
247
- return `display: ${t ? e : "none"}`;
228
+ displayIfSet(t, s = "block") {
229
+ return `display: ${t ? s : "none"}`;
248
230
  }
249
231
  // This inserts a dash before each uppercase letter
250
232
  // that is preceded by a lowercase letter or digit.
251
233
  static elementName() {
252
234
  return this.name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
253
235
  }
254
- #M(t) {
255
- const e = t instanceof u;
256
- for (const s of t.getAttributeNames()) {
257
- const o = t.getAttribute(s), i = this.#y(t, o);
236
+ #R(t) {
237
+ const s = t instanceof u;
238
+ for (const e of t.getAttributeNames()) {
239
+ const o = t.getAttribute(e), i = this.#g(t, o);
258
240
  if (i) {
259
- const r = this[i];
260
- r === void 0 && this.#c(t, s, i), t[i] = r;
261
- let [h, c] = s.split(":");
262
- h === "value" && (c ? (t["on" + c] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(h, this[i])) : c = "change"), e && t.#l.set(
241
+ const n = this[i];
242
+ n === void 0 && this.#a(t, e, i), t[i] = n;
243
+ let [h, a] = e.split(":");
244
+ h === "value" && (a ? (t["on" + a] === void 0 && this.#s(t, e, "refers to an unsupported event name"), t.setAttribute(h, this[i])) : a = "change"), s && t.#l.set(
263
245
  u.getPropName(h),
264
246
  i
265
247
  );
266
248
  }
267
- this.#n(o, t, s);
249
+ this.#r(o, t, e);
268
250
  }
269
251
  }
270
252
  #o(t) {
271
- const e = new Function("return " + t).call(this);
272
- return Array.isArray(e) ? e.join("") : e;
253
+ const s = new Function("return " + t).call(this);
254
+ return Array.isArray(s) ? s.join("") : s;
273
255
  }
274
256
  #P(t) {
275
- const { localName: e } = t;
276
- if (e === "style") {
277
- const { sheet: s } = t, o = s?.cssRules ?? [], i = Array.from(o);
278
- for (const r of i)
279
- if (r.constructor === CSSStyleRule) {
280
- const h = Array.from(r.style);
281
- for (const c of h)
282
- if (c.startsWith("--")) {
283
- const f = r.style.getPropertyValue(c);
284
- this.#n(f, r, c);
257
+ const { localName: s } = t;
258
+ if (s === "style") {
259
+ const { sheet: e } = t, o = e?.cssRules ?? [], i = Array.from(o);
260
+ for (const n of i)
261
+ if (n.constructor === CSSStyleRule) {
262
+ const h = Array.from(n.style);
263
+ for (const a of h)
264
+ if (a.startsWith("--")) {
265
+ const f = n.style.getPropertyValue(a);
266
+ this.#r(f, n, a);
285
267
  }
286
268
  }
287
269
  } else {
288
- let s = "";
270
+ let e = "";
289
271
  if (d(t)) {
290
- this.#n(t.textContent, t);
272
+ this.#r(t.textContent, t);
291
273
  const o = t.textContent?.match(j);
292
- o && (s = o[1]);
274
+ o && (e = o[1]);
293
275
  } else {
294
276
  const o = Array.from(t.childNodes).find(
295
277
  (i) => i.nodeType === Node.COMMENT_NODE
296
278
  );
297
- o && (s = o.textContent?.trim() ?? "");
279
+ o && (e = o.textContent?.trim() ?? "");
298
280
  }
299
- if (s) {
300
- const o = this.#y(t, s);
301
- o && d(t) ? t.textContent = this[o] : this.#n(s, t);
281
+ if (e) {
282
+ const o = this.#g(t, e);
283
+ o && d(t) ? t.textContent = this[o] : this.#r(e, t);
302
284
  }
303
285
  }
304
286
  }
@@ -309,98 +291,87 @@ class u extends HTMLElement {
309
291
  formAssociatedCallback() {
310
292
  let t = this.getAttribute("form-assoc");
311
293
  if (!t) {
312
- const r = this.getAttribute("name");
313
- if (r)
314
- if (this.#r("value"))
315
- t = `value:${r}`;
294
+ const n = this.getAttribute("name");
295
+ if (n)
296
+ if (this.#n("value"))
297
+ t = `value:${n}`;
316
298
  else
317
299
  return;
318
300
  else
319
301
  return;
320
302
  }
321
- const e = {}, s = t.split(",");
322
- for (const r of s) {
323
- const [h, c] = r.split(":");
324
- e[h.trim()] = c.trim();
303
+ const s = {}, e = t.split(",");
304
+ for (const n of e) {
305
+ const [h, a] = n.split(":");
306
+ s[h.trim()] = a.trim();
325
307
  }
326
- this.#a = e, this.#i = new FormData(), this.#h = this.attachInternals(), this.#h.setFormValue(this.#i);
308
+ this.#c = s, this.#i = new FormData(), this.#h = this.attachInternals(), this.#h.setFormValue(this.#i);
327
309
  const o = Object.keys(this.#t.properties), i = this.#f;
328
- for (const r of o)
329
- i[r] = this[r];
310
+ for (const n of o)
311
+ i[n] = this[n];
330
312
  }
331
313
  formResetCallback() {
332
314
  const t = this.#f;
333
- for (const e of Object.keys(t)) {
334
- let s = t[e];
335
- A.test(s) && (s = this.#o(s)), this[e] = s;
315
+ for (const s of Object.keys(t)) {
316
+ let e = t[s];
317
+ A.test(e) && (e = this.#o(e)), this[s] = e;
336
318
  }
337
319
  }
338
320
  static getAttrName(t) {
339
- let e = u.#d.get(t);
340
- return e || (e = t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), u.#d.set(t, e)), e;
321
+ let s = u.#d.get(t);
322
+ return s || (s = t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), u.#d.set(t, s)), s;
341
323
  }
342
324
  static getPropName(t) {
343
- let e = u.#p.get(t);
344
- return e || (e = t.replace(/-([a-z])/g, (s, o) => o.toUpperCase()), u.#p.set(t, e)), e;
325
+ let s = u.#p.get(t);
326
+ return s || (s = t.replace(/-([a-z])/g, (e, o) => o.toUpperCase()), u.#p.set(t, s)), s;
345
327
  }
346
- #$(t, e, s) {
347
- if (s.length !== 1) return;
348
- const [o] = s;
328
+ #N(t, s, e) {
329
+ if (e.length !== 1) return;
330
+ const [o] = e;
349
331
  if (!A.test(o)) return;
350
- const i = R(t) || d(t);
351
- let [r, h] = (e ?? "").split(":");
352
- if (!(i && r === "value" || d(t))) return;
353
- h ? t["on" + h] === void 0 && this.#e(t, e, "refers to an unsupported event name") : h = "change";
354
- const f = g(o);
355
- t.addEventListener(h, (a) => {
356
- const { target: l } = a;
332
+ const i = v(t) || d(t);
333
+ let [n, h] = (s ?? "").split(":");
334
+ if (!(i && n === "value" || d(t))) return;
335
+ h ? t["on" + h] === void 0 && this.#s(t, s, "refers to an unsupported event name") : h = "change";
336
+ const f = E(o);
337
+ t.addEventListener(h, (c) => {
338
+ const { target: l } = c;
357
339
  if (!l) return;
358
- const p = l.value, { type: y } = this.#t.properties[f];
359
- this[f] = y === Number ? S(p) : p, this.#g(f);
340
+ const p = l.value, { type: g } = this.#t.properties[f];
341
+ this[f] = g === Number ? C(p) : p, this.#E(f);
360
342
  });
361
343
  }
362
- #r(t) {
344
+ #n(t) {
363
345
  return !!this.#t.properties[t];
364
346
  }
365
347
  #b(t) {
366
- const e = Array.from(t.querySelectorAll("*"));
367
- for (const s of e)
368
- this.#M(s), s.firstElementChild || this.#P(s);
369
- }
370
- #N(t) {
371
- const e = t.cssRules;
372
- for (const s of Array.from(e))
373
- if (s instanceof CSSStyleRule) {
374
- for (const o of Array.from(s.style))
375
- if (o.startsWith("--")) {
376
- const i = s.style.getPropertyValue(o);
377
- this.#n(i, s, o);
378
- }
379
- }
348
+ const s = Array.from(t.querySelectorAll("*"));
349
+ for (const e of s)
350
+ this.#R(e), e.firstElementChild || this.#P(e);
380
351
  }
381
352
  static get observedAttributes() {
382
353
  const t = Object.keys(this.properties || {}).map(u.getAttrName);
383
354
  return t.includes("disabled") || t.push("disabled"), t;
384
355
  }
385
356
  // Subclasses can override this to add functionality.
386
- propertyChangedCallback(t, e, s) {
357
+ propertyChangedCallback(t, s, e) {
387
358
  }
388
- #y(t, e) {
389
- if (!e || !A.test(e)) return;
390
- const s = g(e);
391
- return this[s] === void 0 && this.#c(t, "", s), s;
359
+ #g(t, s) {
360
+ if (!s || !A.test(s)) return;
361
+ const e = E(s);
362
+ return this[e] === void 0 && this.#a(t, "", e), e;
392
363
  }
393
- #g(t) {
364
+ #E(t) {
394
365
  const o = this.#t.propToExprsMap.get(t) || [];
395
366
  for (const i of o) {
396
- let r = this.#o(i);
397
- const h = this.#s.get(i) ?? [];
398
- for (const c of h)
399
- if (c instanceof HTMLElement)
400
- this.#S(c, r);
401
- else if (!(c instanceof CSSStyleRule)) {
402
- const { element: f, attrName: a } = c;
403
- f instanceof CSSStyleRule ? f.style.setProperty(a, r) : C(f, a, r);
367
+ let n = this.#o(i);
368
+ const h = this.#e.get(i) ?? [];
369
+ for (const a of h)
370
+ if (a instanceof HTMLElement)
371
+ this.#C(a, n);
372
+ else if (!(a instanceof CSSStyleRule)) {
373
+ const { element: f, attrName: c } = a;
374
+ f instanceof CSSStyleRule ? f.style.setProperty(c, n) : T(f, c, n);
404
375
  }
405
376
  }
406
377
  }
@@ -408,184 +379,184 @@ class u extends HTMLElement {
408
379
  const t = this.elementName();
409
380
  customElements.get(t) || customElements.define(t, this);
410
381
  }
411
- #x(t, e) {
412
- const { computed: s, uses: o } = e, i = this.#t.propToComputedMap;
413
- function r(c, f) {
414
- let a = i.get(c);
415
- a || (a = [], i.set(c, a)), a.push([t, f]);
382
+ #$(t, s) {
383
+ const { computed: e, uses: o } = s, i = this.#t.propToComputedMap;
384
+ function n(a, f) {
385
+ let c = i.get(a);
386
+ c || (c = [], i.set(a, c)), c.push([t, f]);
416
387
  }
417
- const h = s.match(E) || [];
418
- for (const c of h) {
419
- const f = c.substring(N);
420
- this[f] === void 0 && this.#c(null, t, f), typeof this[f] != "function" && r(f, s);
388
+ const h = e.match(y) || [];
389
+ for (const a of h) {
390
+ const f = a.substring($);
391
+ this[f] === void 0 && this.#a(null, t, f), typeof this[f] != "function" && n(f, e);
421
392
  }
422
393
  if (o)
423
- for (const c of o.split(","))
424
- r(c, s);
394
+ for (const a of o.split(","))
395
+ n(a, e);
425
396
  }
426
397
  // WARNING: Do not place untrusted JavaScript expressions
427
398
  // in attribute values or the text content of elements!
428
- #n(t, e, s = void 0) {
399
+ #r(t, s, e = void 0) {
429
400
  if (!t) return;
430
- const o = this.#u(e, s, t);
401
+ const o = this.#u(s, e, t);
431
402
  if (!o) {
432
- const c = t.replaceAll("this..", "this.");
433
- s ? C(e, s, c) : "textContent" in e && (e.textContent = c);
403
+ const a = t.replaceAll("this..", "this.");
404
+ e ? T(s, e, a) : "textContent" in s && (s.textContent = a);
434
405
  return;
435
406
  }
436
407
  const i = this.#t;
437
- o.forEach((c) => {
438
- const f = g(c);
408
+ o.forEach((a) => {
409
+ const f = E(a);
439
410
  if (typeof this[f] == "function") return;
440
- const a = i.propToExprsMap;
441
- let l = a.get(f);
442
- l || (l = [], a.set(f, l)), l.includes(t) || l.push(t);
411
+ const c = i.propToExprsMap;
412
+ let l = c.get(f);
413
+ l || (l = [], c.set(f, l)), l.includes(t) || l.push(t);
443
414
  });
444
- for (const [c, f] of this.#s.entries())
445
- for (const a of f) {
446
- const l = a instanceof HTMLElement || a instanceof CSSStyleRule ? a : a.element;
447
- l instanceof CSSStyleRule || l.isConnected || this.#s.set(
448
- c,
449
- f.filter((p) => p !== a)
415
+ for (const [a, f] of this.#e.entries())
416
+ for (const c of f) {
417
+ const l = c instanceof HTMLElement || c instanceof CSSStyleRule ? c : c.element;
418
+ l instanceof CSSStyleRule || l.isConnected || this.#e.set(
419
+ a,
420
+ f.filter((p) => p !== c)
450
421
  );
451
422
  }
452
- let r = this.#s.get(t);
453
- r || (r = [], this.#s.set(t, r)), r.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && this.#$(e, s, o);
423
+ let n = this.#e.get(t);
424
+ n || (n = [], this.#e.set(t, n)), n.push(e ? { element: s, attrName: e } : s), s instanceof HTMLElement && this.#N(s, e, o);
454
425
  const h = this.#o(t);
455
- s ? C(e, s, h) : this.#S(e, h);
426
+ e ? T(s, e, h) : this.#C(s, h);
456
427
  }
457
428
  // This follows the best practice
458
429
  // "Do not override author-set, global attributes."
459
- setAttributeSafe(t, e) {
460
- this.hasAttribute(t) || this.setAttribute(t, e);
430
+ setAttributeSafe(t, s) {
431
+ this.hasAttribute(t) || this.setAttribute(t, s);
461
432
  }
462
- setFormValue(t, e) {
463
- !this.#i || !T(e) || (this.#i.set(t, e), this.#h?.setFormValue(this.#i));
433
+ setFormValue(t, s) {
434
+ !this.#i || !S(s) || (this.#i.set(t, s), this.#h?.setFormValue(this.#i));
464
435
  }
465
- #e(t, e, s) {
436
+ #s(t, s, e) {
466
437
  const o = this.#t, i = t instanceof HTMLElement ? t.localName : "CSS rule";
467
438
  throw new m(
468
- `component ${o.elementName()}` + (t ? `, element "${i}"` : "") + (e ? `, attribute "${e}"` : "") + ` ${s}`
439
+ `component ${o.elementName()}` + (t ? `, element "${i}"` : "") + (s ? `, attribute "${s}"` : "") + ` ${e}`
469
440
  );
470
441
  }
471
- #c(t, e, s) {
472
- this.#e(t, e, `refers to missing property "${s}"`);
442
+ #a(t, s, e) {
443
+ this.#s(t, s, `refers to missing property "${e}"`);
473
444
  }
474
- #A(t, e) {
475
- return this.#E(t, this.getAttribute(e));
445
+ #A(t, s) {
446
+ return this.#y(t, this.getAttribute(s));
476
447
  }
477
- #E(t, e) {
478
- if (e?.match(E)) return e;
479
- const s = this.#t, { type: o } = s.properties[t];
480
- if (o || this.#e(null, t, "does not specify its type"), o === String) return e;
481
- if (o === Number) return S(e);
448
+ #y(t, s) {
449
+ if (s?.match(y)) return s;
450
+ const e = this.#t, { type: o } = e.properties[t];
451
+ if (o || this.#s(null, t, "does not specify its type"), o === String) return s;
452
+ if (o === Number) return C(s);
482
453
  if (o === Boolean)
483
- return e === "true" ? !0 : e === "false" || e === "null" ? !1 : (e && e !== t && this.#e(
454
+ return s === "true" ? !0 : s === "false" || s === "null" ? !1 : (s && s !== t && this.#s(
484
455
  null,
485
456
  t,
486
457
  "is a Boolean attribute, so its value must match attribute name or be missing"
487
- ), e === t);
458
+ ), s === t);
488
459
  }
489
460
  // Updates the matching attribute for a property if there is one.
490
461
  // VS Code thinks this is never called, but it is called by #defineProp.
491
- #L(t, e, s, o) {
492
- if (T(s) && this.hasAttribute(o)) {
493
- const i = e === Boolean ? this.hasAttribute(o) : this.#A(t, o);
494
- s !== i && k(this, t, s);
462
+ #x(t, s, e, o) {
463
+ if (S(e) && this.hasAttribute(o)) {
464
+ const i = s === Boolean ? this.hasAttribute(o) : this.#A(t, o);
465
+ e !== i && H(this, t, e);
495
466
  }
496
467
  }
497
468
  // Updates all computed properties that reference this property.
498
469
  // VS Code thinks this is never called, but it is called by #defineProp.
499
- #k(t) {
500
- const s = this.#t.propToComputedMap.get(t) || [];
501
- for (const [o, i] of s)
470
+ #L(t) {
471
+ const e = this.#t.propToComputedMap.get(t) || [];
472
+ for (const [o, i] of e)
502
473
  this[o] = this.#o(i);
503
474
  }
504
- #S(t, e) {
505
- if (e === void 0) return;
506
- const s = t instanceof HTMLElement, o = typeof e;
507
- o !== "string" && o !== "number" && this.#e(
475
+ #C(t, s) {
476
+ if (s === void 0) return;
477
+ const e = t instanceof HTMLElement, o = typeof s;
478
+ o !== "string" && o !== "number" && this.#s(
508
479
  t,
509
480
  void 0,
510
481
  " computed content is not a string or number"
511
- ), t instanceof HTMLElement && d(t) ? t.value = e : s && o === "string" && e.trim().startsWith("<") ? (t.innerHTML = e, this.#C(t), this.#b(t)) : s && (t.textContent = e);
482
+ ), t instanceof HTMLElement && d(t) ? t.value = s : e && o === "string" && s.trim().startsWith("<") ? (t.innerHTML = s, this.#T(t), this.#b(t)) : e && (t.textContent = s);
512
483
  }
513
484
  // Update corresponding parent web component property if bound to one.
514
485
  // VS Code thinks this is never called, but it is called by #defineProp.
515
- #H(t, e) {
516
- const s = this.#l.get(t);
517
- if (!s) return;
486
+ #H(t, s) {
487
+ const e = this.#l.get(t);
488
+ if (!e) return;
518
489
  const o = this.getRootNode();
519
490
  if (!(o instanceof ShadowRoot)) return;
520
491
  const { host: i } = o;
521
492
  if (!i) return;
522
- const r = i;
523
- r[s] = e;
493
+ const n = i;
494
+ n[e] = s;
524
495
  }
525
496
  /**
526
497
  * @param state - WrecState object
527
498
  * @param map - object whose keys are state properties and
528
499
  * whose values are component properties
529
500
  */
530
- useState(t, e) {
531
- if (!e) {
532
- e = {};
533
- for (const s of Object.keys(t))
534
- e[s] = s;
501
+ useState(t, s) {
502
+ if (!s) {
503
+ s = {};
504
+ for (const e of Object.keys(t))
505
+ s[e] = e;
535
506
  }
536
- this.#F(t, e);
537
- for (const [s, o] of Object.entries(e))
538
- if (this.#r(o)) {
539
- const i = M(t, s);
507
+ this.#k(t, s);
508
+ for (const [e, o] of Object.entries(s))
509
+ if (this.#n(o)) {
510
+ const i = R(t, e);
540
511
  i !== void 0 && (this[o] = i);
541
- const r = this.#t.properties[o];
542
- r.state = t, r.stateProp = s;
512
+ const n = this.#t.properties[o];
513
+ n.state = t, n.stateProp = e;
543
514
  }
544
- t.addListener(this, e);
515
+ t.addListener(this, s);
545
516
  }
546
517
  #O() {
547
- const t = this.#t, e = new Set(Object.keys(t.properties));
548
- for (const o of e)
549
- _.has(o) && this.#e(
518
+ const t = this.#t, s = new Set(Object.keys(t.properties));
519
+ for (const o of s)
520
+ V.has(o) && this.#s(
550
521
  null,
551
522
  "",
552
523
  `property "${o}" is not allowed because it is a reserved attribute`
553
524
  );
554
- const s = this.#t.name;
525
+ const e = this.#t.name;
555
526
  for (const o of this.getAttributeNames())
556
527
  if (o !== "class" && o !== "id" && o !== "disabled" && !o.startsWith("on")) {
557
528
  if (o === "form-assoc") {
558
529
  if (!t.formAssociated)
559
530
  throw new m(
560
- `add "static formAssociated = true;" to class ${s}`
531
+ `add "static formAssociated = true;" to class ${e}`
561
532
  );
562
533
  continue;
563
534
  }
564
- if (!e.has(u.getPropName(o))) {
535
+ if (!s.has(u.getPropName(o))) {
565
536
  if (o === "name") {
566
537
  if (t.formAssociated) continue;
567
538
  throw new m(
568
- `name attribute requires "static formAssociated = true;" in class ${s}`
539
+ `name attribute requires "static formAssociated = true;" in class ${e}`
569
540
  );
570
541
  }
571
- this.#e(null, o, "is not a supported attribute");
542
+ this.#s(null, o, "is not a supported attribute");
572
543
  }
573
544
  }
574
545
  }
575
- #u(t, e, s) {
576
- const o = s.match(E);
546
+ #u(t, s, e) {
547
+ const o = e.match(y);
577
548
  if (o)
578
549
  return o.forEach((i) => {
579
- const r = g(i);
580
- this[r] === void 0 && this.#c(t, e, r);
550
+ const n = E(i);
551
+ this[n] === void 0 && this.#a(t, s, n);
581
552
  }), o;
582
553
  }
583
- #F(t, e) {
584
- for (const [s, o] of Object.entries(e)) {
585
- let i = M(t, s);
554
+ #k(t, s) {
555
+ for (const [e, o] of Object.entries(s)) {
556
+ let i = R(t, e);
586
557
  if (i === void 0)
587
- throw new m(`invalid state path "${s}"`);
588
- i = this[o], this.#r(o) || this.#e(
558
+ throw new m(`invalid state path "${e}"`);
559
+ i = this[o], this.#n(o) || this.#s(
589
560
  null,
590
561
  o,
591
562
  "refers to missing property in useState map"
@@ -593,76 +564,76 @@ class u extends HTMLElement {
593
564
  }
594
565
  }
595
566
  // When type is an array, this can't validate the type of the array elements.
596
- #j(t, e, s) {
597
- if (s instanceof e) return;
598
- let o = typeof s;
567
+ #F(t, s, e) {
568
+ if (e instanceof s) return;
569
+ let o = typeof e;
599
570
  if (o === "object") {
600
- const { constructor: i } = s;
601
- o = i.name, i !== e && this.#e(
571
+ const { constructor: i } = e;
572
+ o = i.name, i !== s && this.#s(
602
573
  null,
603
574
  t,
604
- `was set to a ${o}, but must be a ${e.name}`
575
+ `was set to a ${o}, but must be a ${s.name}`
605
576
  );
606
577
  }
607
- o !== e.name.toLowerCase() && this.#e(
578
+ o !== s.name.toLowerCase() && this.#s(
608
579
  null,
609
580
  t,
610
- `was set to a ${o}, but must be a ${e.name}`
581
+ `was set to a ${o}, but must be a ${s.name}`
611
582
  );
612
583
  }
613
- #C(t) {
614
- const e = Array.from(t.querySelectorAll("*"));
615
- for (const s of e) {
584
+ #T(t) {
585
+ const s = Array.from(t.querySelectorAll("*"));
586
+ for (const e of s) {
616
587
  const o = [];
617
- for (const i of Array.from(s.attributes)) {
618
- const r = i.name;
619
- if (r.startsWith("on")) {
620
- let h = r.slice(2);
588
+ for (const i of Array.from(e.attributes)) {
589
+ const n = i.name;
590
+ if (n.startsWith("on")) {
591
+ let h = n.slice(2);
621
592
  h = h[0].toLowerCase() + h.slice(1).toLowerCase();
622
- const c = i.value;
623
- this.#u(s, r, c);
593
+ const a = i.value;
594
+ this.#u(e, n, a);
624
595
  let f;
625
- typeof this[c] == "function" ? f = (a) => this[c](a) : (this.#u(s, r, c), f = () => this.#o(c)), s.addEventListener(h, f), o.push(r);
596
+ typeof this[a] == "function" ? f = (c) => this[a](c) : (this.#u(e, n, a), f = () => this.#o(a)), e.addEventListener(h, f), o.push(n);
626
597
  }
627
598
  }
628
599
  for (const i of o)
629
- s.removeAttribute(i);
600
+ e.removeAttribute(i);
630
601
  }
631
602
  }
632
603
  }
633
- function Z(n, ...t) {
634
- let e = x(n, t);
604
+ function z(r, ...t) {
605
+ let s = x(r, t);
635
606
  for (; ; ) {
636
- const s = O.exec(e);
637
- if (!s) break;
638
- const o = s[2];
639
- if ($.test(o)) {
640
- const i = s[1];
607
+ const e = k.exec(s);
608
+ if (!e) break;
609
+ const o = e[2];
610
+ if (N.test(o)) {
611
+ const i = e[1];
641
612
  if (!i.startsWith("--")) {
642
- const r = `--${i}: ${o};
613
+ const n = `--${i}: ${o};
643
614
  ${i}: var(--${i})`;
644
- e = L(e, s.index, s[0].length, r);
615
+ s = L(s, e.index, e[0].length, n);
645
616
  }
646
617
  }
647
618
  }
648
- return e;
619
+ return s;
649
620
  }
650
- function K(n, ...t) {
651
- let e = x(n, t);
621
+ function Z(r, ...t) {
622
+ let s = x(r, t);
652
623
  for (; ; ) {
653
- const s = V.exec(e);
654
- if (!s || s[1] === "style") break;
655
- const o = q(s[2]);
656
- if ($.test(o)) {
657
- const i = `<!-- ${o.trim()} -->`, r = s.index + s[0].indexOf(">") + 1;
658
- e = L(e, r, o.length, i);
624
+ const e = _.exec(s);
625
+ if (!e || e[1] === "style") break;
626
+ const o = B(e[2]);
627
+ if (N.test(o)) {
628
+ const i = `<!-- ${o.trim()} -->`, n = e.index + e[0].indexOf(">") + 1;
629
+ s = L(s, n, o.length, i);
659
630
  }
660
631
  }
661
- return e;
632
+ return s;
662
633
  }
663
634
  export {
664
635
  u as Wrec,
665
- z as createElement,
666
- Z as css,
667
- K as html
636
+ q as createElement,
637
+ z as css,
638
+ Z as html
668
639
  };