haori 0.25.0 → 0.26.0

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/haori.es.js CHANGED
@@ -30,12 +30,12 @@ const X = class X {
30
30
  };
31
31
  X.devMode = !1;
32
32
  let L = X;
33
- const fe = "embedded";
34
- function we(f) {
33
+ const pe = "embedded";
34
+ function De(f) {
35
35
  return f === "embedded" || f === "demo";
36
36
  }
37
- function Ve(f) {
38
- return f === null ? null : we(f) ? f : fe;
37
+ function We(f) {
38
+ return f === null ? null : De(f) ? f : pe;
39
39
  }
40
40
  const V = class V {
41
41
  /**
@@ -53,7 +53,7 @@ const V = class V {
53
53
  * @return 戻り値はありません。
54
54
  */
55
55
  static setRuntime(e) {
56
- V._runtime = we(e) ? e : fe;
56
+ V._runtime = De(e) ? e : pe;
57
57
  }
58
58
  /**
59
59
  * 実行環境からプレフィックスと開発モードかどうかを自動検出します。
@@ -67,7 +67,7 @@ const V = class V {
67
67
  if (e instanceof HTMLScriptElement) {
68
68
  const r = e.getAttribute("data-prefix") || V._prefix;
69
69
  V._prefix = r.endsWith("-") ? r : r + "-";
70
- const i = Ve(
70
+ const i = We(
71
71
  e.getAttribute("data-runtime")
72
72
  );
73
73
  i !== null && (V._runtime = i);
@@ -94,10 +94,10 @@ const V = class V {
94
94
  return V._prefix;
95
95
  }
96
96
  };
97
- V._prefix = "data-", V._runtime = fe;
97
+ V._prefix = "data-", V._runtime = pe;
98
98
  let c = V;
99
99
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
100
- class b {
100
+ class p {
101
101
  /**
102
102
  * 開発モードでのみコンソールに情報を出力します。
103
103
  *
@@ -126,11 +126,11 @@ class b {
126
126
  console.error(e, ...t);
127
127
  }
128
128
  }
129
- const Te = "yyyy/MM/dd HH:mm", je = "en-US", Ae = 1e4;
129
+ const Fe = "yyyy/MM/dd HH:mm", Ke = "en-US", Te = 1e4;
130
130
  function K(f) {
131
131
  return String(f).padStart(2, "0");
132
132
  }
133
- function Re(f, e, t, r, i, n) {
133
+ function Ne(f, e, t, r, i, n) {
134
134
  return {
135
135
  yyyy: String(f).padStart(4, "0"),
136
136
  yy: K(f % 100),
@@ -144,7 +144,7 @@ function Re(f, e, t, r, i, n) {
144
144
  ss: K(n)
145
145
  };
146
146
  }
147
- function De(f, e) {
147
+ function Me(f, e) {
148
148
  let t;
149
149
  try {
150
150
  t = new Intl.DateTimeFormat("en-US", {
@@ -161,12 +161,12 @@ function De(f, e) {
161
161
  return null;
162
162
  }
163
163
  const r = {};
164
- for (const h of t)
165
- h.type !== "literal" && (r[h.type] = h.value);
164
+ for (const d of t)
165
+ d.type !== "literal" && (r[d.type] = d.value);
166
166
  const i = Number(r.year), n = Number(r.month), s = Number(r.day), a = Number(r.hour), o = Number(r.minute), l = Number(r.second);
167
- return !Number.isFinite(i) || !Number.isFinite(n) || !Number.isFinite(s) || !Number.isFinite(a) || !Number.isFinite(o) || !Number.isFinite(l) ? null : Re(i, n, s, a, o, l);
167
+ return !Number.isFinite(i) || !Number.isFinite(n) || !Number.isFinite(s) || !Number.isFinite(a) || !Number.isFinite(o) || !Number.isFinite(l) ? null : Ne(i, n, s, a, o, l);
168
168
  }
169
- function ue(f, e = Te, t) {
169
+ function de(f, e = Fe, t) {
170
170
  if (f == null || f === "")
171
171
  return "";
172
172
  const r = f instanceof Date ? f : new Date(f);
@@ -174,10 +174,10 @@ function ue(f, e = Te, t) {
174
174
  return "";
175
175
  let i;
176
176
  if (typeof t == "string" && t.trim() !== "") {
177
- if (i = De(r, t.trim()), i === null)
177
+ if (i = Me(r, t.trim()), i === null)
178
178
  return "";
179
179
  } else
180
- i = Re(
180
+ i = Ne(
181
181
  r.getFullYear(),
182
182
  r.getMonth() + 1,
183
183
  r.getDate(),
@@ -191,15 +191,15 @@ function ue(f, e = Te, t) {
191
191
  (s, a) => a !== void 0 ? a === "" ? "'" : a : n[s]
192
192
  );
193
193
  }
194
- const qe = "yyyy-MM-dd";
195
- function Fe(f = Te, e) {
196
- return ue(/* @__PURE__ */ new Date(), f, e);
194
+ const ze = "yyyy-MM-dd";
195
+ function xe(f = Fe, e) {
196
+ return de(/* @__PURE__ */ new Date(), f, e);
197
197
  }
198
- function Ne(f = 0, e = qe, t) {
198
+ function Pe(f = 0, e = ze, t) {
199
199
  const r = Number.isFinite(f) ? Math.trunc(f) : 0, i = typeof t == "string" && t.trim() !== "" ? t.trim() : "";
200
200
  let n, s, a;
201
201
  if (i !== "") {
202
- const l = De(/* @__PURE__ */ new Date(), i);
202
+ const l = Me(/* @__PURE__ */ new Date(), i);
203
203
  if (l === null)
204
204
  return "";
205
205
  n = Number(l.yyyy), s = Number(l.MM), a = Number(l.dd);
@@ -208,9 +208,9 @@ function Ne(f = 0, e = qe, t) {
208
208
  n = l.getFullYear(), s = l.getMonth() + 1, a = l.getDate();
209
209
  }
210
210
  const o = new Date(Date.UTC(n, s - 1, a + r));
211
- return ue(o, e, "UTC");
211
+ return de(o, e, "UTC");
212
212
  }
213
- function Me(f, e) {
213
+ function Ie(f, e) {
214
214
  if (f == null)
215
215
  return "";
216
216
  let t;
@@ -229,23 +229,23 @@ function Me(f, e) {
229
229
  const i = Math.max(0, Math.trunc(e));
230
230
  r.minimumFractionDigits = i, r.maximumFractionDigits = i;
231
231
  }
232
- return new Intl.NumberFormat(je, r).format(t);
232
+ return new Intl.NumberFormat(Ke, r).format(t);
233
233
  }
234
- function xe(f, e, t) {
234
+ function ke(f, e, t) {
235
235
  let r, i, n;
236
236
  if (e === void 0 ? (r = 0, i = f, n = 1) : (r = f, i = e, n = t === void 0 ? 1 : t), !Number.isFinite(r) || !Number.isFinite(i) || !Number.isFinite(n) || n === 0)
237
237
  return [];
238
238
  r = Math.trunc(r), i = Math.trunc(i), n = Math.trunc(n);
239
239
  const s = [];
240
240
  if (n > 0)
241
- for (let a = r; a < i && s.length < Ae; a += n)
241
+ for (let a = r; a < i && s.length < Te; a += n)
242
242
  s.push(a);
243
243
  else
244
- for (let a = r; a > i && s.length < Ae; a += n)
244
+ for (let a = r; a > i && s.length < Te; a += n)
245
245
  s.push(a);
246
246
  return s;
247
247
  }
248
- function ke(f, e, t = {}) {
248
+ function Ce(f, e, t = {}) {
249
249
  const r = Math.trunc(Number(f));
250
250
  if (!Number.isFinite(r) || r <= 0)
251
251
  return [];
@@ -260,11 +260,11 @@ function ke(f, e, t = {}) {
260
260
  for (let u = Math.max(0, i - n); u <= Math.min(r - 1, i + n); u += 1)
261
261
  a.add(u);
262
262
  const o = Array.from(a).sort((u, m) => u - m), l = [];
263
- let h = null;
263
+ let d = null;
264
264
  for (const u of o) {
265
- if (h !== null && u - h > 1)
266
- if (u - h === 2) {
267
- const m = h + 1;
265
+ if (d !== null && u - d > 1)
266
+ if (u - d === 2) {
267
+ const m = d + 1;
268
268
  l.push({
269
269
  page: m,
270
270
  label: m + 1,
@@ -278,19 +278,19 @@ function ke(f, e, t = {}) {
278
278
  label: u + 1,
279
279
  active: u === i,
280
280
  ellipsis: !1
281
- }), h = u;
281
+ }), d = u;
282
282
  }
283
283
  return l;
284
284
  }
285
- const We = /^(\d{4})-(\d{1,2})$/, Ke = 1200;
286
- function re(f, e) {
285
+ const Ge = /^(\d{4})-(\d{1,2})$/, Ye = 1200;
286
+ function ie(f, e) {
287
287
  const t = Number(f);
288
288
  return Number.isFinite(t) ? Math.trunc(t) : e;
289
289
  }
290
- function ce(f, e) {
290
+ function he(f, e) {
291
291
  if (typeof f != "string")
292
292
  return "";
293
- const t = We.exec(f.trim());
293
+ const t = Ge.exec(f.trim());
294
294
  if (!t)
295
295
  return "";
296
296
  const r = Number(t[1]), i = Number(t[2]);
@@ -299,48 +299,48 @@ function ce(f, e) {
299
299
  const n = Number.isFinite(e) ? Math.trunc(e) : 0, s = r * 12 + (i - 1) + n, a = Math.floor(s / 12), o = s - a * 12 + 1;
300
300
  return `${String(a).padStart(4, "0")}-${K(o)}`;
301
301
  }
302
- function ze(f) {
302
+ function Je(f) {
303
303
  if (typeof f == "string" && f.trim() !== "")
304
- return ce(f, 0);
304
+ return he(f, 0);
305
305
  const e = /* @__PURE__ */ new Date();
306
306
  return `${String(e.getFullYear()).padStart(4, "0")}-${K(e.getMonth() + 1)}`;
307
307
  }
308
- function Ie(f, e) {
308
+ function Be(f, e) {
309
309
  const t = Math.trunc(Number(f));
310
310
  if (!Number.isFinite(t) || t < 0)
311
311
  return [];
312
- const r = ze(e);
312
+ const r = Je(e);
313
313
  if (r === "")
314
314
  return [];
315
- const i = Math.min(t, Ke), n = [];
315
+ const i = Math.min(t, Ye), n = [];
316
316
  for (let s = 0; s <= i; s += 1) {
317
- const a = ce(r, -s);
317
+ const a = he(r, -s);
318
318
  n.push({ targetMonth: a, label: a.replace(/-/g, "/") });
319
319
  }
320
320
  return n;
321
321
  }
322
- function Pe(f, e) {
322
+ function $e(f, e) {
323
323
  const t = { start: 0, end: 0, total: 0, empty: !0 };
324
324
  if (!f || typeof f != "object")
325
325
  return t;
326
- const r = f, i = re(
326
+ const r = f, i = ie(
327
327
  r.totalElements ?? r.totalCount,
328
328
  0
329
329
  );
330
330
  if (i <= 0)
331
331
  return t;
332
- const n = Math.max(0, re(r.number, 0)), s = Math.max(0, re(r.size, 0)), a = n * s, o = Math.min(a + 1, i);
332
+ const n = Math.max(0, ie(r.number, 0)), s = Math.max(0, ie(r.size, 0)), a = n * s, o = Math.min(a + 1, i);
333
333
  let l;
334
334
  if (e !== void 0 && Number.isFinite(e))
335
335
  l = Math.max(0, Math.trunc(e));
336
336
  else {
337
- const u = re(r.numberOfElements, NaN);
337
+ const u = ie(r.numberOfElements, NaN);
338
338
  l = Number.isFinite(u) ? u : Math.min(s, i - a);
339
339
  }
340
- const h = Math.min(a + l, i);
341
- return { start: o, end: Math.max(h, o), total: i, empty: !1 };
340
+ const d = Math.min(a + l, i);
341
+ return { start: o, end: Math.max(d, o), total: i, empty: !1 };
342
342
  }
343
- function Ce(f, e, t) {
343
+ function Oe(f, e, t) {
344
344
  if (!Array.isArray(f) || f.length === 0)
345
345
  return null;
346
346
  const r = String(t), i = f.find(
@@ -348,7 +348,7 @@ function Ce(f, e, t) {
348
348
  );
349
349
  return i === void 0 ? null : i;
350
350
  }
351
- function Be(f, e) {
351
+ function He(f, e) {
352
352
  if (!Array.isArray(f))
353
353
  return 0;
354
354
  let t = 0;
@@ -361,25 +361,25 @@ function Be(f, e) {
361
361
  }
362
362
  return t;
363
363
  }
364
- function $e(f, e) {
364
+ function Le(f, e) {
365
365
  return e == null || f == null ? String(f) : String(f[e]);
366
366
  }
367
- function Oe(f, e) {
367
+ function Ue(f, e) {
368
368
  if (!Array.isArray(f))
369
369
  return [];
370
370
  const t = /* @__PURE__ */ new Set(), r = [];
371
371
  for (const i of f) {
372
- const n = $e(i, e);
372
+ const n = Le(i, e);
373
373
  t.has(n) || (t.add(n), r.push(i));
374
374
  }
375
375
  return r;
376
376
  }
377
- function He(f, e) {
377
+ function Ve(f, e) {
378
378
  if (!Array.isArray(f))
379
379
  return [];
380
380
  const t = /* @__PURE__ */ new Map(), r = [];
381
381
  for (const i of f) {
382
- const n = $e(i, e), s = t.get(n);
382
+ const n = Le(i, e), s = t.get(n);
383
383
  if (s === void 0) {
384
384
  const a = i == null ? i : i[e];
385
385
  t.set(n, r.length), r.push({ key: a, items: [i] });
@@ -388,20 +388,20 @@ function He(f, e) {
388
388
  }
389
389
  return r;
390
390
  }
391
- const Ge = Object.freeze({
392
- date: ue,
393
- now: Fe,
394
- today: Ne,
395
- number: Me,
396
- pages: ke,
397
- range: xe,
398
- monthAdd: ce,
399
- monthRange: Ie,
400
- pageSummary: Pe,
401
- findBy: Ce,
402
- sum: Be,
403
- distinct: Oe,
404
- groupBy: He
391
+ const Xe = Object.freeze({
392
+ date: de,
393
+ now: xe,
394
+ today: Pe,
395
+ number: Ie,
396
+ pages: Ce,
397
+ range: ke,
398
+ monthAdd: he,
399
+ monthRange: Be,
400
+ pageSummary: $e,
401
+ findBy: Oe,
402
+ sum: He,
403
+ distinct: Ue,
404
+ groupBy: Ve
405
405
  }), B = class B {
406
406
  /**
407
407
  * 明示バインド内に持ち込まれてはならない危険値を返します。
@@ -496,18 +496,18 @@ const Ge = Object.freeze({
496
496
  */
497
497
  static evaluateDetailed(e, t = {}) {
498
498
  if (this.scheduleForbiddenBindingValueCacheReset(), e.trim() === "")
499
- return b.warn("[Haori]", e, "Expression is empty"), { value: null, unresolvedReference: !1 };
499
+ return p.warn("[Haori]", e, "Expression is empty"), { value: null, unresolvedReference: !1 };
500
500
  if (this.containsDangerousPatterns(e)) {
501
501
  const l = this.detectDisallowedKeywords(e);
502
502
  if (l.length > 0) {
503
- const h = l.some((u) => u === "function" || u === "return") ? " Statement keywords are not allowed in expressions; use an arrow function such as `x => ({key: value})` instead of `function(x){ return {key: value}; }`." : " These are statement keywords and cannot be used in expressions.";
504
- b.warn(
503
+ const d = l.some((u) => u === "function" || u === "return") ? " Statement keywords are not allowed in expressions; use an arrow function such as `x => ({key: value})` instead of `function(x){ return {key: value}; }`." : " These are statement keywords and cannot be used in expressions.";
504
+ p.warn(
505
505
  "[Haori]",
506
506
  e,
507
- "Expression uses disallowed keyword(s): " + l.join(", ") + "." + h
507
+ "Expression uses disallowed keyword(s): " + l.join(", ") + "." + d
508
508
  );
509
509
  } else
510
- b.warn(
510
+ p.warn(
511
511
  "[Haori]",
512
512
  e,
513
513
  "Expression contains dangerous patterns"
@@ -517,7 +517,7 @@ const Ge = Object.freeze({
517
517
  const r = this.collectForbiddenKeys(t);
518
518
  if (r.length > 0) {
519
519
  const l = r.join(",");
520
- this.loggedForbiddenKeySignatures.has(l) || (this.loggedForbiddenKeySignatures.add(l), this.scheduleForbiddenKeyLogReset(), b.error(
520
+ this.loggedForbiddenKeySignatures.has(l) || (this.loggedForbiddenKeySignatures.add(l), this.scheduleForbiddenKeyLogReset(), p.error(
521
521
  "[Haori]",
522
522
  "Binding keys are reserved and ignored: " + r.join(", ") + ". These collide with blocked global/prototype names and cannot be used as top-level binding keys; the remaining keys are still evaluated."
523
523
  ));
@@ -528,7 +528,7 @@ const Ge = Object.freeze({
528
528
  /* @__PURE__ */ new WeakSet(),
529
529
  i
530
530
  ))
531
- return b.warn(
531
+ return p.warn(
532
532
  "[Haori]",
533
533
  t,
534
534
  "Binded values contain forbidden values"
@@ -539,7 +539,7 @@ const Ge = Object.freeze({
539
539
  ), s = this.BUILTIN_REFERENCE_PATTERN.test(
540
540
  n
541
541
  );
542
- s && this.BUILTIN_NAMESPACE in t && b.warn(
542
+ s && this.BUILTIN_NAMESPACE in t && p.warn(
543
543
  "[Haori]",
544
544
  `Binding key "${this.BUILTIN_NAMESPACE}" is reserved for built-in helpers; the bound value is ignored in expressions.`
545
545
  );
@@ -549,36 +549,36 @@ const Ge = Object.freeze({
549
549
  s && (a[this.BUILTIN_NAMESPACE] = this.BUILTIN_HELPERS);
550
550
  const o = this.canAttemptMissingIdentifierRecovery(e);
551
551
  for (let l = 0; l <= this.MAX_IDENTIFIER_RECOVERY_COUNT; l += 1) {
552
- const h = this.prepareEvaluator(e, a);
553
- if (h.compileFailed || h.evaluator === null)
552
+ const d = this.prepareEvaluator(e, a);
553
+ if (d.compileFailed || d.evaluator === null)
554
554
  return { value: null, unresolvedReference: !1 };
555
555
  try {
556
556
  const u = [], m = this.wrapBoundValues(a);
557
- return h.bindKeys.forEach((v) => {
558
- u.push(m[v]);
557
+ return d.bindKeys.forEach((y) => {
558
+ u.push(m[y]);
559
559
  }), {
560
560
  value: this.withBlockedPropertyAccess(
561
- () => h.evaluator(...u)
561
+ () => d.evaluator(...u)
562
562
  ),
563
563
  unresolvedReference: !1
564
564
  };
565
565
  } catch (u) {
566
566
  if (o && u instanceof ReferenceError) {
567
- const v = this.extractMissingIdentifier(u);
568
- if (v !== null && this.canRecoverMissingIdentifier(v, a)) {
569
- a[v] = void 0;
567
+ const y = this.extractMissingIdentifier(u);
568
+ if (y !== null && this.canRecoverMissingIdentifier(y, a)) {
569
+ a[y] = void 0;
570
570
  continue;
571
571
  }
572
572
  }
573
573
  const m = this.detectForbiddenIdentifiers(e);
574
- return m.length > 0 && b.warn(
574
+ return m.length > 0 && p.warn(
575
575
  "[Haori]",
576
576
  "Expression references blocked identifier(s): " + m.join(", ") + ". These are blocked in expressions and evaluate to undefined (often the cause of this error). Use spread {...a, ...b} instead of Object.assign.",
577
577
  e
578
- ), b.error("[Haori]", "Expression evaluation error:", e, u), u instanceof ReferenceError ? { value: void 0, unresolvedReference: !0 } : { value: null, unresolvedReference: !1 };
578
+ ), p.error("[Haori]", "Expression evaluation error:", e, u), u instanceof ReferenceError ? { value: void 0, unresolvedReference: !0 } : { value: null, unresolvedReference: !1 };
579
579
  }
580
580
  }
581
- return b.error(
581
+ return p.error(
582
582
  "[Haori]",
583
583
  "Failed to recover missing identifiers:",
584
584
  e,
@@ -612,7 +612,7 @@ return (${e});`;
612
612
  compileFailed: !1
613
613
  };
614
614
  } catch (o) {
615
- return b.error(
615
+ return p.error(
616
616
  "[Haori]",
617
617
  "Failed to compile expression:",
618
618
  e,
@@ -697,12 +697,12 @@ return (${e});`;
697
697
  const r = [];
698
698
  let i = null;
699
699
  for (let n = 0; n < t.length; n++) {
700
- const s = t[n], a = t[n + 1] || null, o = r[r.length - 1] || null, l = t[n - 2] || null, h = t[n - 3] || null;
700
+ const s = t[n], a = t[n + 1] || null, o = r[r.length - 1] || null, l = t[n - 2] || null, d = t[n - 3] || null;
701
701
  if (this.startsObjectKey(
702
702
  o,
703
703
  i,
704
704
  l,
705
- h
705
+ d
706
706
  ) && (s.value === "[" || s.type === "identifier" && this.FORBIDDEN_PROPERTY_NAMES.has(s.value) || s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
707
707
  this.decodeStringLiteral(s.value)
708
708
  )) || s.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(s.value) || this.STRICT_FORBIDDEN_NAMES.includes(s.value) || (i?.value === "." || i?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(s.value)) || o === "member" && s.value !== "]" && s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
@@ -1117,7 +1117,7 @@ return (${e});`;
1117
1117
  }
1118
1118
  };
1119
1119
  B.MAX_IDENTIFIER_RECOVERY_COUNT = 8, B.BUILTIN_NAMESPACE = "haori", B.BUILTIN_HELPERS = {
1120
- ...Ge
1120
+ ...Xe
1121
1121
  }, B.BUILTIN_REFERENCE_PATTERN = /(^|[^\w$.])haori(?![\w$])/, B.forbiddenBindingValueCache = /* @__PURE__ */ new WeakMap(), B.forbiddenBindingValueCacheResetScheduled = !1, B.loggedForbiddenKeySignatures = /* @__PURE__ */ new Set(), B.loggedForbiddenKeyResetScheduled = !1, B.FORBIDDEN_NAMES = [
1122
1122
  // グローバルオブジェクト
1123
1123
  "window",
@@ -1210,7 +1210,7 @@ B.MAX_IDENTIFIER_RECOVERY_COUNT = 8, B.BUILTIN_NAMESPACE = "haori", B.BUILTIN_HE
1210
1210
  "yield"
1211
1211
  ]), B.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
1212
1212
  let G = B;
1213
- class pe {
1213
+ class ye {
1214
1214
  constructor() {
1215
1215
  this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
1216
1216
  }
@@ -1252,13 +1252,13 @@ class pe {
1252
1252
  const r = await t.task();
1253
1253
  t.resolve(r);
1254
1254
  } catch (r) {
1255
- t.reject(r), b.error("[Haori]", `Task ${t.timestamp} failed:`, r);
1255
+ t.reject(r), p.error("[Haori]", `Task ${t.timestamp} failed:`, r);
1256
1256
  }
1257
1257
  if (performance.now() - e > this.MAX_BUDGET)
1258
1258
  break;
1259
1259
  }
1260
1260
  } catch (e) {
1261
- b.error("[Haori]", "Error processing queue:", e);
1261
+ p.error("[Haori]", "Error processing queue:", e);
1262
1262
  } finally {
1263
1263
  this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
1264
1264
  }
@@ -1300,7 +1300,7 @@ class pe {
1300
1300
  async waitForIdle(e = 1e3) {
1301
1301
  let t = 0, r = 0;
1302
1302
  for (; t < 2 && r < e; )
1303
- this.processing || this.queue.length > 0 ? (await this.wait(), t = 0) : t += 1, await pe.nextTick(), r += 1;
1303
+ this.processing || this.queue.length > 0 ? (await this.wait(), t = 0) : t += 1, await ye.nextTick(), r += 1;
1304
1304
  }
1305
1305
  /**
1306
1306
  * 次のフレーム(または 1 マクロタスク)まで待機します。
@@ -1313,7 +1313,7 @@ class pe {
1313
1313
  });
1314
1314
  }
1315
1315
  }
1316
- const be = class be {
1316
+ const Ee = class Ee {
1317
1317
  /**
1318
1318
  * タスクをキューに追加します。
1319
1319
  *
@@ -1340,8 +1340,8 @@ const be = class be {
1340
1340
  return this.ASYNC_QUEUE.waitForIdle(e);
1341
1341
  }
1342
1342
  };
1343
- be.ASYNC_QUEUE = new pe();
1344
- let I = be;
1343
+ Ee.ASYNC_QUEUE = new ye();
1344
+ let I = Ee;
1345
1345
  const x = class x {
1346
1346
  /**
1347
1347
  * 集計状態を初期化します。
@@ -1567,7 +1567,7 @@ const x = class x {
1567
1567
  }
1568
1568
  };
1569
1569
  x.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", x.ELEMENT_STORES = /* @__PURE__ */ new Map();
1570
- let ne = x;
1570
+ let ae = x;
1571
1571
  const Q = class Q {
1572
1572
  /**
1573
1573
  * フラグメントのコンストラクタ。
@@ -1591,10 +1591,10 @@ const Q = class Q {
1591
1591
  t = new j(e);
1592
1592
  break;
1593
1593
  case Node.COMMENT_NODE:
1594
- t = new me(e);
1594
+ t = new ve(e);
1595
1595
  break;
1596
1596
  default:
1597
- return b.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
1597
+ return p.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
1598
1598
  }
1599
1599
  return t;
1600
1600
  }
@@ -1727,7 +1727,7 @@ const z = class z extends S {
1727
1727
  ], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.bindingWorkChain = Promise.resolve(), this.bindingWorkActive = 0, this.initialBindAttribute = null, this.derivedBindingData = null, this.bindingDataCache = null, this.descendantBindingDataCache = null, this.visible = !0, this.display = null, this.displayPriority = null, this.template = null, this.listKey = null, this.renderSignature = null, this.eachInputSignature = null, this.deriveSubtreeSignature = null, this.deriveInputSignature = null, this.freshInitializationSkippable = !1, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.selfWrittenBind = /* @__PURE__ */ new Map(), this.syncValue(), this.initialBindAttribute = e.getAttribute(`${c.prefix}bind`), e.getAttributeNames().forEach((t) => {
1728
1728
  const r = e.getAttribute(t);
1729
1729
  if (r !== null && !this.attributeMap.has(t)) {
1730
- const i = new se(t, r);
1730
+ const i = new oe(t, r);
1731
1731
  this.attributeMap.set(t, i);
1732
1732
  }
1733
1733
  }), e.childNodes.forEach((t) => {
@@ -1771,7 +1771,7 @@ const z = class z extends S {
1771
1771
  removeChild(e) {
1772
1772
  const t = this.children.indexOf(e);
1773
1773
  if (t < 0) {
1774
- b.warn("[Haori]", "Child fragment not found.", e);
1774
+ p.warn("[Haori]", "Child fragment not found.", e);
1775
1775
  return;
1776
1776
  }
1777
1777
  this.children.splice(t, 1), e.setParent(null);
@@ -2110,6 +2110,14 @@ const z = class z extends S {
2110
2110
  if (this.skipChangeValue || this.value === e)
2111
2111
  return Promise.resolve();
2112
2112
  const r = this.getTarget();
2113
+ if (r instanceof HTMLInputElement && r.type === "file")
2114
+ return e === null || e === "" ? (this.value = null, r.value === "" ? Promise.resolve() : I.enqueue(() => {
2115
+ r.value = "";
2116
+ })) : (p.warn(
2117
+ "[Haori]",
2118
+ "A value cannot be assigned to input[type=file]; only clearing is supported.",
2119
+ r
2120
+ ), Promise.resolve());
2113
2121
  if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
2114
2122
  const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
2115
2123
  let s;
@@ -2137,7 +2145,7 @@ const z = class z extends S {
2137
2145
  this.skipChangeValue = !1;
2138
2146
  });
2139
2147
  } else
2140
- return b.warn(
2148
+ return p.warn(
2141
2149
  "[Haori]",
2142
2150
  "setValue is not supported for this element type.",
2143
2151
  r
@@ -2194,6 +2202,9 @@ const z = class z extends S {
2194
2202
  const r = e.value;
2195
2203
  t ? this.value = !1 : r === "false" ? this.value = !0 : this.value = null;
2196
2204
  }
2205
+ } else if (e.type === "file") {
2206
+ const t = e.files;
2207
+ this.value = t && t.length > 0 ? t[0].name : null;
2197
2208
  } else
2198
2209
  this.value = this.normalizeValueForElement(e, e.value);
2199
2210
  else e instanceof HTMLTextAreaElement ? this.value = e.value : e instanceof HTMLSelectElement && (e.multiple ? this.value = Array.from(e.selectedOptions).map(
@@ -2261,10 +2272,10 @@ const z = class z extends S {
2261
2272
  return Promise.resolve();
2262
2273
  if (r === null)
2263
2274
  return e === t ? this.removeAttribute(e) : this.removeAliasedAttribute(e, t);
2264
- const s = new se(e, r);
2275
+ const s = new oe(e, r);
2265
2276
  if (n) {
2266
- const he = this.attributeMap.get(e);
2267
- if (he && (he.isEvaluate || he.isForceEvaluation()) && !s.isEvaluate && !s.isForceEvaluation())
2277
+ const fe = this.attributeMap.get(e);
2278
+ if (fe && (fe.isEvaluate || fe.isForceEvaluation()) && !s.isEvaluate && !s.isForceEvaluation())
2268
2279
  return this.skipMutationAttributes = !0, I.enqueue(() => {
2269
2280
  }).finally(() => {
2270
2281
  this.skipMutationAttributes = !1;
@@ -2276,9 +2287,9 @@ const z = class z extends S {
2276
2287
  element: a,
2277
2288
  rawName: e,
2278
2289
  template: r
2279
- }), l = s.isEvaluate || s.isRawEvaluate, h = e === t && z.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), u = s.isSingleExpression(), m = Y.joinEvaluateResults(o.results), v = o.results.length === 1 ? o.results[0] : m, T = !s.isForceEvaluation() && (t !== e || h || u ? o.hasUnresolvedReference || v === null || v === void 0 || v === !1 : l && m === ""), C = s.isForceEvaluation() ? r : u ? v : m, O = i && s.isEvaluate && t === "value" && (a instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(a.type) || a instanceof HTMLTextAreaElement || a instanceof HTMLSelectElement), E = a.getRootNode(), p = O && a === E.activeElement, y = T || C === null || C === !1 ? null : String(C), R = e !== t && a.getAttribute(e) !== r, P = y === null ? a.hasAttribute(t) : a.getAttribute(t) !== y, F = O && !p && y !== null && a.value !== y, U = t === "checked" && a instanceof HTMLInputElement && (a.type === "checkbox" || a.type === "radio"), $ = t === "selected" && a instanceof HTMLOptionElement, W = E.activeElement, ve = W !== null && (U && a === W || $ && a.closest("select") === W), te = y !== null, ye = U && !ve && a.checked !== te, Ee = $ && !ve && a.selected !== te;
2280
- return !R && !P && !F && !ye && !Ee ? (O && !p && y !== null && (this.value = this.normalizeValueForElement(a, y)), Promise.resolve()) : (this.skipMutationAttributes = !0, I.enqueue(() => {
2281
- R && a.setAttribute(e, r), y === null ? a.removeAttribute(t) : (P && (a.setAttribute(t, y), t === `${c.prefix}bind` && this.recordSelfWrittenBind(y)), O && !p && (this.value = this.normalizeValueForElement(a, y), F && (a.value = y))), ye && (a.checked = te), Ee && (a.selected = te);
2290
+ }), l = s.isEvaluate || s.isRawEvaluate, d = e === t && z.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), u = s.isSingleExpression(), m = Y.joinEvaluateResults(o.results), y = o.results.length === 1 ? o.results[0] : m, T = !s.isForceEvaluation() && (t !== e || d || u ? o.hasUnresolvedReference || y === null || y === void 0 || y === !1 : l && m === ""), k = s.isForceEvaluation() ? r : u ? y : m, H = i && s.isEvaluate && t === "value" && (a instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(a.type) || a instanceof HTMLTextAreaElement || a instanceof HTMLSelectElement), E = a.getRootNode(), b = H && a === E.activeElement, v = T || k === null || k === !1 ? null : String(k), R = e !== t && a.getAttribute(e) !== r, C = v === null ? a.hasAttribute(t) : a.getAttribute(t) !== v, F = H && !b && v !== null && a.value !== v, U = t === "checked" && a instanceof HTMLInputElement && (a.type === "checkbox" || a.type === "radio"), $ = t === "selected" && a instanceof HTMLOptionElement, W = E.activeElement, Ae = W !== null && (U && a === W || $ && a.closest("select") === W), re = v !== null, Se = U && !Ae && a.checked !== re, we = $ && !Ae && a.selected !== re;
2291
+ return !R && !C && !F && !Se && !we ? (H && !b && v !== null && (this.value = this.normalizeValueForElement(a, v)), Promise.resolve()) : (this.skipMutationAttributes = !0, I.enqueue(() => {
2292
+ R && a.setAttribute(e, r), v === null ? a.removeAttribute(t) : (C && (a.setAttribute(t, v), t === `${c.prefix}bind` && this.recordSelfWrittenBind(v)), H && !b && (this.value = this.normalizeValueForElement(a, v), F && (a.value = v))), Se && (a.checked = re), we && (a.selected = re);
2282
2293
  }).finally(() => {
2283
2294
  this.skipMutationAttributes = !1;
2284
2295
  }));
@@ -2397,40 +2408,40 @@ const z = class z extends S {
2397
2408
  if (this.skipMutationNodes)
2398
2409
  return Promise.resolve();
2399
2410
  if (e === this)
2400
- return b.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
2411
+ return p.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
2401
2412
  const i = /* @__PURE__ */ new Set();
2402
2413
  let n = this.parent;
2403
2414
  for (; n; )
2404
2415
  i.add(n), n = n.getParent();
2405
2416
  if (i.has(e))
2406
- return b.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
2417
+ return p.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
2407
2418
  const s = e.getParent() === this;
2408
2419
  let a = -1, o = -1;
2409
2420
  s && (a = this.children.indexOf(e), t !== null && (o = this.children.indexOf(t)));
2410
2421
  const l = e.getParent();
2411
2422
  l !== null && l.removeChild(e);
2412
- let h = r === void 0 ? t?.getTarget() || null : r;
2423
+ let d = r === void 0 ? t?.getTarget() || null : r;
2413
2424
  if (t === null)
2414
2425
  this.children.push(e);
2415
2426
  else {
2416
2427
  let m;
2417
2428
  if (s ? a !== -1 && a < o ? m = o - 1 : m = o : m = this.children.indexOf(t), m === -1) {
2418
- const v = this.resolveInsertionPointFromDom(
2429
+ const y = this.resolveInsertionPointFromDom(
2419
2430
  t,
2420
2431
  !1
2421
2432
  );
2422
- v === null ? (b.warn(
2433
+ y === null ? (p.warn(
2423
2434
  "[Haori]",
2424
2435
  "Reference child not found in children.",
2425
2436
  t
2426
- ), this.children.push(e)) : (this.children.splice(v.index, 0, e), h = v.referenceNode);
2437
+ ), this.children.push(e)) : (this.children.splice(y.index, 0, e), d = y.referenceNode);
2427
2438
  } else
2428
2439
  this.children.splice(m, 0, e);
2429
2440
  }
2430
2441
  e.setParent(this), e.setMounted(this.mounted);
2431
2442
  const u = this.skipMutationNodes;
2432
2443
  return this.skipMutationNodes = !0, I.enqueue(() => {
2433
- this.target.insertBefore(e.getTarget(), h);
2444
+ this.target.insertBefore(e.getTarget(), d);
2434
2445
  }).finally(() => {
2435
2446
  this.skipMutationNodes = u;
2436
2447
  });
@@ -2451,7 +2462,7 @@ const z = class z extends S {
2451
2462
  t,
2452
2463
  !0
2453
2464
  );
2454
- return i === null ? (b.warn(
2465
+ return i === null ? (p.warn(
2455
2466
  "[Haori]",
2456
2467
  "Reference child not found in children.",
2457
2468
  t
@@ -2642,7 +2653,7 @@ class j extends S {
2642
2653
  });
2643
2654
  }
2644
2655
  }
2645
- class me extends S {
2656
+ class ve extends S {
2646
2657
  /**
2647
2658
  * コメントフラグメントのコンストラクタ。
2648
2659
  * 対象コメントノードの内容を初期化します。
@@ -2658,7 +2669,7 @@ class me extends S {
2658
2669
  * @returns クローンされたフラグメント
2659
2670
  */
2660
2671
  clone() {
2661
- const e = new me(this.target.cloneNode(!0));
2672
+ const e = new ve(this.target.cloneNode(!0));
2662
2673
  return e.mounted = !1, e.text = this.text, e;
2663
2674
  }
2664
2675
  /**
@@ -2683,7 +2694,7 @@ class me extends S {
2683
2694
  }));
2684
2695
  }
2685
2696
  }
2686
- const oe = class oe {
2697
+ const ue = class ue {
2687
2698
  /**
2688
2699
  * コンストラクタ。
2689
2700
  *
@@ -2691,7 +2702,7 @@ const oe = class oe {
2691
2702
  */
2692
2703
  constructor(e) {
2693
2704
  this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = e;
2694
- const t = [...e.matchAll(oe.PLACEHOLDER_REGEX)];
2705
+ const t = [...e.matchAll(ue.PLACEHOLDER_REGEX)];
2695
2706
  let r = 0, i = !1, n = !1;
2696
2707
  for (const s of t) {
2697
2708
  s.index > r && this.contents.push({
@@ -2742,7 +2753,7 @@ const oe = class oe {
2742
2753
  */
2743
2754
  checkRawExpressions() {
2744
2755
  for (let e = 0; e < this.contents.length; e++)
2745
- this.contents[e].type === 2 && this.contents.length > 1 && (b.error(
2756
+ this.contents[e].type === 2 && this.contents.length > 1 && (p.error(
2746
2757
  "[Haori]",
2747
2758
  "Raw expressions are not allowed in multi-content expressions."
2748
2759
  ), this.contents[e].type = 1);
@@ -2788,35 +2799,35 @@ const oe = class oe {
2788
2799
  return this.contents.forEach((l) => {
2789
2800
  try {
2790
2801
  if (r(l)) {
2791
- const h = ne.measure(
2802
+ const d = ae.measure(
2792
2803
  () => G.evaluateDetailed(l.text, e)
2793
- ), u = h.value;
2794
- a += h.durationMs, s.push({
2804
+ ), u = d.value;
2805
+ a += d.durationMs, s.push({
2795
2806
  expression: l.text,
2796
- durationMs: h.durationMs
2807
+ durationMs: d.durationMs
2797
2808
  }), o = o || u.unresolvedReference, n.push(u.value);
2798
2809
  } else
2799
2810
  n.push(l.text);
2800
- } catch (h) {
2801
- b.error(
2811
+ } catch (d) {
2812
+ p.error(
2802
2813
  "[Haori]",
2803
2814
  `Error evaluating ${i} expression: ${l.text}`,
2804
- h
2815
+ d
2805
2816
  ), s.push({
2806
2817
  expression: l.text,
2807
2818
  durationMs: 0
2808
2819
  }), n.push("");
2809
2820
  }
2810
- }), ne.record(
2821
+ }), ae.record(
2811
2822
  t,
2812
2823
  s,
2813
2824
  a
2814
2825
  ), { results: n, hasUnresolvedReference: o };
2815
2826
  }
2816
2827
  };
2817
- oe.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
2818
- let Y = oe;
2819
- const le = class le extends Y {
2828
+ ue.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
2829
+ let Y = ue;
2830
+ const ce = class ce extends Y {
2820
2831
  /**
2821
2832
  * コンストラクタ。
2822
2833
  *
@@ -2824,7 +2835,7 @@ const le = class le extends Y {
2824
2835
  * @param text 属性値
2825
2836
  */
2826
2837
  constructor(e, t) {
2827
- super(t), this.forceEvaluation = le.FORCE_EVALUATION_ATTRIBUTES.includes(e);
2838
+ super(t), this.forceEvaluation = ce.FORCE_EVALUATION_ATTRIBUTES.includes(e);
2828
2839
  }
2829
2840
  /**
2830
2841
  * 強制評価フラグを取得します。
@@ -2861,7 +2872,7 @@ const le = class le extends Y {
2861
2872
  (i) => this.forceEvaluation && i.type === 0 || i.type === 1 || i.type === 2,
2862
2873
  "attribute"
2863
2874
  );
2864
- return this.forceEvaluation && r.results.length > 1 ? (b.error(
2875
+ return this.forceEvaluation && r.results.length > 1 ? (p.error(
2865
2876
  "[Haori]",
2866
2877
  "each or if expressions must have a single content.",
2867
2878
  r.results
@@ -2871,7 +2882,7 @@ const le = class le extends Y {
2871
2882
  }) : r;
2872
2883
  }
2873
2884
  };
2874
- le.FORCE_EVALUATION_ATTRIBUTES = [
2885
+ ce.FORCE_EVALUATION_ATTRIBUTES = [
2875
2886
  "data-if",
2876
2887
  "hor-if",
2877
2888
  "data-each",
@@ -2879,7 +2890,7 @@ le.FORCE_EVALUATION_ATTRIBUTES = [
2879
2890
  "data-derive",
2880
2891
  "hor-derive"
2881
2892
  ];
2882
- let se = le;
2893
+ let oe = ce;
2883
2894
  class Z {
2884
2895
  /**
2885
2896
  * 実行モードを取得します。
@@ -2956,7 +2967,7 @@ class Z {
2956
2967
  */
2957
2968
  static openDialog(e) {
2958
2969
  return I.enqueue(() => {
2959
- e instanceof HTMLDialogElement ? (Z.clearMessagesSync(e), e.showModal()) : b.error("[Haori]", "Element is not a dialog: ", e);
2970
+ e instanceof HTMLDialogElement ? (Z.clearMessagesSync(e), e.showModal()) : p.error("[Haori]", "Element is not a dialog: ", e);
2960
2971
  }, !0);
2961
2972
  }
2962
2973
  /**
@@ -2966,7 +2977,7 @@ class Z {
2966
2977
  */
2967
2978
  static closeDialog(e) {
2968
2979
  return I.enqueue(() => {
2969
- e instanceof HTMLDialogElement ? e.close() : b.error("[Haori]", "Element is not a dialog: ", e);
2980
+ e instanceof HTMLDialogElement ? e.close() : p.error("[Haori]", "Element is not a dialog: ", e);
2970
2981
  }, !0);
2971
2982
  }
2972
2983
  /**
@@ -3025,7 +3036,7 @@ class Z {
3025
3036
  * @returns 整形済み文字列。整形できない場合は空文字
3026
3037
  */
3027
3038
  static date(e, t, r) {
3028
- return ue(e, t, r);
3039
+ return de(e, t, r);
3029
3040
  }
3030
3041
  /**
3031
3042
  * 現在日時を指定フォーマットの文字列へ整形します。
@@ -3038,7 +3049,7 @@ class Z {
3038
3049
  * @returns 整形済みの現在日時文字列
3039
3050
  */
3040
3051
  static now(e, t) {
3041
- return Fe(e, t);
3052
+ return xe(e, t);
3042
3053
  }
3043
3054
  /**
3044
3055
  * 現在日付に日数を加減した日付を指定フォーマットの文字列へ整形します。
@@ -3052,7 +3063,7 @@ class Z {
3052
3063
  * @returns 整形済みの日付文字列。timeZone が不正な場合は空文字
3053
3064
  */
3054
3065
  static today(e, t, r) {
3055
- return Ne(e, t, r);
3066
+ return Pe(e, t, r);
3056
3067
  }
3057
3068
  /**
3058
3069
  * 数値を桁区切り・小数桁付きの文字列へ整形します。
@@ -3064,7 +3075,7 @@ class Z {
3064
3075
  * @returns 整形済み文字列。整形できない場合は空文字
3065
3076
  */
3066
3077
  static number(e, t) {
3067
- return Me(e, t);
3078
+ return Ie(e, t);
3068
3079
  }
3069
3080
  /**
3070
3081
  * 整数の配列を生成します(終端は排他)。
@@ -3077,7 +3088,7 @@ class Z {
3077
3088
  * @returns 整数配列
3078
3089
  */
3079
3090
  static range(e, t, r) {
3080
- return xe(e, t, r);
3091
+ return ke(e, t, r);
3081
3092
  }
3082
3093
  /**
3083
3094
  * 番号ページネーション用の表示要素列を生成します。
@@ -3090,7 +3101,7 @@ class Z {
3090
3101
  * @returns 表示要素の配列
3091
3102
  */
3092
3103
  static pages(e, t, r) {
3093
- return ke(e, t, r);
3104
+ return Ce(e, t, r);
3094
3105
  }
3095
3106
  /**
3096
3107
  * `YYYY-MM` 形式の年月文字列に月数を加算します。
@@ -3102,7 +3113,7 @@ class Z {
3102
3113
  * @returns 加算後の年月(`YYYY-MM` 形式)。不正な入力は空文字
3103
3114
  */
3104
3115
  static monthAdd(e, t) {
3105
- return ce(e, t);
3116
+ return he(e, t);
3106
3117
  }
3107
3118
  /**
3108
3119
  * 基準月から過去方向へ `count + 1` 個の年月配列を降順で返します。
@@ -3114,7 +3125,7 @@ class Z {
3114
3125
  * @returns 年月情報の降順配列。不正な入力は空配列
3115
3126
  */
3116
3127
  static monthRange(e, t) {
3117
- return Ie(e, t);
3128
+ return Be(e, t);
3118
3129
  }
3119
3130
  /**
3120
3131
  * ページレスポンスから表示用サマリーを作ります。
@@ -3126,7 +3137,7 @@ class Z {
3126
3137
  * @returns 表示サマリー
3127
3138
  */
3128
3139
  static pageSummary(e, t) {
3129
- return Pe(e, t);
3140
+ return $e(e, t);
3130
3141
  }
3131
3142
  /**
3132
3143
  * 配列から `item[key]` が指定値に一致する最初の要素を返します。
@@ -3140,7 +3151,7 @@ class Z {
3140
3151
  * @returns 一致した最初の要素。無ければ null
3141
3152
  */
3142
3153
  static findBy(e, t, r) {
3143
- return Ce(e, t, r);
3154
+ return Oe(e, t, r);
3144
3155
  }
3145
3156
  /**
3146
3157
  * 配列の数値合計を返します。
@@ -3153,7 +3164,7 @@ class Z {
3153
3164
  * @returns 数値の合計。対象が無ければ 0
3154
3165
  */
3155
3166
  static sum(e, t) {
3156
- return Be(e, t);
3167
+ return He(e, t);
3157
3168
  }
3158
3169
  /**
3159
3170
  * 配列から重複を取り除いた新しい配列を返します。
@@ -3166,7 +3177,7 @@ class Z {
3166
3177
  * @returns 重複排除後の新しい配列。非配列は空配列
3167
3178
  */
3168
3179
  static distinct(e, t) {
3169
- return Oe(e, t);
3180
+ return Ue(e, t);
3170
3181
  }
3171
3182
  /**
3172
3183
  * 配列を `item[key]` ごとのグループへ分けて返します。
@@ -3179,13 +3190,13 @@ class Z {
3179
3190
  * @returns グループ情報の配列。非配列は空配列
3180
3191
  */
3181
3192
  static groupBy(e, t) {
3182
- return He(e, t);
3193
+ return Ve(e, t);
3183
3194
  }
3184
3195
  }
3185
- const Ye = ["addErrorMessage", "clearMessages"];
3186
- function Se() {
3196
+ const Qe = ["addErrorMessage", "clearMessages"];
3197
+ function Re() {
3187
3198
  const e = globalThis.window?.Haori;
3188
- return Ye.every(
3199
+ return Qe.every(
3189
3200
  (r) => typeof e?.[r] == "function"
3190
3201
  ) ? e : Z;
3191
3202
  }
@@ -3202,6 +3213,35 @@ class A {
3202
3213
  const t = {};
3203
3214
  return A.getPartValues(e, t);
3204
3215
  }
3216
+ /**
3217
+ * 入力エレメントから収集する値を解決します。
3218
+ *
3219
+ * `input[type=file]` は選択されたファイルを File オブジェクトとして返します
3220
+ * (内部値は `C:\fakepath\...` の擬似パス文字列にしかならず送信に使えないため、
3221
+ * DOM の `files` から直接取得する)。`multiple` 指定時は File の配列、単一選択時は
3222
+ * File または未選択を表す null を返します。それ以外の要素は内部値を返します。
3223
+ *
3224
+ * @param fragment 対象のElementFragment
3225
+ * @returns 収集する値
3226
+ */
3227
+ static resolveCollectedValue(e) {
3228
+ const t = e.getTarget();
3229
+ if (A.isFileInput(e)) {
3230
+ const r = t, i = r.files ? Array.from(r.files) : [];
3231
+ return r.multiple ? i : i.length > 0 ? i[0] : null;
3232
+ }
3233
+ return e.getValue();
3234
+ }
3235
+ /**
3236
+ * `input[type=file]` かどうかを判定します。
3237
+ *
3238
+ * @param fragment 対象フラグメント
3239
+ * @returns `input[type=file]` の場合 true
3240
+ */
3241
+ static isFileInput(e) {
3242
+ const t = e.getTarget();
3243
+ return t instanceof HTMLInputElement && t.type === "file";
3244
+ }
3205
3245
  /**
3206
3246
  * フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
3207
3247
  * 入力エレメントのname属性、data-form-object属性、data-form-list属性に基づいて値を整理します。
@@ -3215,14 +3255,15 @@ class A {
3215
3255
  return t;
3216
3256
  const r = e.getAttribute("name"), i = e.getAttribute(`${c.prefix}form-object`), n = e.getAttribute(`${c.prefix}form-list`);
3217
3257
  if (r) {
3218
- if (n)
3219
- Array.isArray(t[String(r)]) ? t[String(r)].push(e.getValue()) : t[String(r)] = [e.getValue()];
3220
- else if (A.isGroupedCheckable(e)) {
3258
+ if (n) {
3259
+ const s = A.resolveCollectedValue(e), a = A.isFileInput(e) && Array.isArray(s) ? s : [s];
3260
+ Array.isArray(t[String(r)]) ? t[String(r)].push(...a) : t[String(r)] = a;
3261
+ } else if (A.isGroupedCheckable(e)) {
3221
3262
  const s = e.getTarget(), o = (s instanceof HTMLInputElement ? s.checked : !0) ? e.getValue() : null, l = String(r);
3222
3263
  o === null ? l in t || (t[l] = null) : t[l] === null || t[l] === void 0 ? t[l] = o : Array.isArray(t[l]) ? t[l].push(o) : t[l] = [t[l], o];
3223
3264
  } else
3224
- t[String(r)] = e.getValue();
3225
- i && b.warn(
3265
+ t[String(r)] = A.resolveCollectedValue(e);
3266
+ i && p.warn(
3226
3267
  "Haori",
3227
3268
  `Element cannot have both ${c.prefix}form-object and name attributes.`
3228
3269
  );
@@ -3232,7 +3273,7 @@ class A {
3232
3273
  const s = {};
3233
3274
  for (const a of e.getChildElementFragments())
3234
3275
  A.getPartValues(a, s);
3235
- Object.keys(s).length > 0 && (t[String(i)] = s), n && b.warn(
3276
+ Object.keys(s).length > 0 && (t[String(i)] = s), n && p.warn(
3236
3277
  "Haori",
3237
3278
  `Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
3238
3279
  );
@@ -3314,10 +3355,13 @@ class A {
3314
3355
  * @returns Promise(DOMの更新が完了したら解決される)
3315
3356
  */
3316
3357
  static setPartValues(e, t, r = null, i = !1, n = !0) {
3317
- const s = [], a = e.getAttribute("name"), o = e.getAttribute(`${c.prefix}form-object`), l = e.getAttribute(`${c.prefix}form-list`), h = e.getAttribute(`${c.prefix}form-detach`);
3358
+ const s = [], a = e.getAttribute("name"), o = e.getAttribute(`${c.prefix}form-object`), l = e.getAttribute(`${c.prefix}form-list`), d = e.getAttribute(`${c.prefix}form-detach`);
3318
3359
  if (a) {
3319
- if (!h || i) {
3360
+ if (!d || i) {
3320
3361
  const u = t[String(a)];
3362
+ if (A.isFileInput(e))
3363
+ return (u === null || u === "") && s.push(A.applyFragmentValue(e, null, n)), Promise.all(s).then(() => {
3364
+ });
3321
3365
  l && Array.isArray(u) && r !== null ? s.push(
3322
3366
  A.applyFragmentValue(e, u[r] ?? null, n)
3323
3367
  ) : typeof u > "u" || (Array.isArray(u) && A.isGroupedCheckable(e) || Array.isArray(u) && A.isMultipleSelect(e) || typeof u == "string" || typeof u == "number" || typeof u == "boolean" || u === null ? s.push(
@@ -3347,17 +3391,17 @@ class A {
3347
3391
  const u = t[String(l)];
3348
3392
  if (Array.isArray(u)) {
3349
3393
  const m = e.getChildElementFragments();
3350
- for (let v = 0; v < m.length; v++) {
3351
- const T = m[v];
3352
- u.length > v ? s.push(
3394
+ for (let y = 0; y < m.length; y++) {
3395
+ const T = m[y];
3396
+ u.length > y ? s.push(
3353
3397
  A.setPartValues(
3354
3398
  T,
3355
- u[v],
3356
- v,
3399
+ u[y],
3400
+ y,
3357
3401
  i,
3358
3402
  n
3359
3403
  )
3360
- ) : s.push(A.setPartValues(T, {}, v, i, n));
3404
+ ) : s.push(A.setPartValues(T, {}, y, i, n));
3361
3405
  }
3362
3406
  }
3363
3407
  } else
@@ -3395,7 +3439,7 @@ class A {
3395
3439
  const t = A.collectBindingTargetForms(e);
3396
3440
  for (const r of t) {
3397
3441
  const i = A.getInitialBindingData(r);
3398
- i && await k.setBindingData(r.getTarget(), i);
3442
+ i && await P.setBindingData(r.getTarget(), i);
3399
3443
  }
3400
3444
  A.syncValuesFromDom(e);
3401
3445
  for (const r of t) {
@@ -3403,9 +3447,9 @@ class A {
3403
3447
  if (r.getRawBindingData() === null && i === null)
3404
3448
  continue;
3405
3449
  const n = A.getValues(r), s = r.getAttribute(`${c.prefix}form-arg`), a = { ...i || {} };
3406
- s ? a[String(s)] = n : Object.assign(a, n), await k.setBindingData(r.getTarget(), a);
3450
+ s ? a[String(s)] = n : Object.assign(a, n), await P.setBindingData(r.getTarget(), a);
3407
3451
  }
3408
- await k.evaluateAll(e);
3452
+ await P.evaluateAll(e);
3409
3453
  }
3410
3454
  /**
3411
3455
  * data-bind 属性で宣言された初期バインドデータを取得します。
@@ -3415,7 +3459,7 @@ class A {
3415
3459
  */
3416
3460
  static getInitialBindingData(e) {
3417
3461
  const t = e.getInitialBindAttribute();
3418
- return t === null ? null : k.parseDataBind(t);
3462
+ return t === null ? null : P.parseDataBind(t);
3419
3463
  }
3420
3464
  /**
3421
3465
  * フラグメント配下の入力要素について、内部値を現在の DOM 値と再同期します。
@@ -3488,7 +3532,7 @@ class A {
3488
3532
  * @returns Promise(メッセージのクリアが完了したら解決される)
3489
3533
  */
3490
3534
  static clearMessages(e) {
3491
- return Se().clearMessages(
3535
+ return Re().clearMessages(
3492
3536
  e.getTarget()
3493
3537
  );
3494
3538
  }
@@ -3515,9 +3559,9 @@ class A {
3515
3559
  * @return Promise(メッセージの追加が完了したら解決される)
3516
3560
  */
3517
3561
  static addMessage(e, t, r, i) {
3518
- const n = [], s = Se(), a = s.addMessage, o = (h) => typeof a == "function" ? a.call(s, h, r, i) : s.addErrorMessage(h, r), l = A.findFragmentsByKey(e, t);
3519
- return l.forEach((h) => {
3520
- n.push(o(h.getTarget()));
3562
+ const n = [], s = Re(), a = s.addMessage, o = (d) => typeof a == "function" ? a.call(s, d, r, i) : s.addErrorMessage(d, r), l = A.findFragmentsByKey(e, t);
3563
+ return l.forEach((d) => {
3564
+ n.push(o(d.getTarget()));
3521
3565
  }), l.length === 0 && n.push(o(e.getTarget())), Promise.all(n).then(() => {
3522
3566
  });
3523
3567
  }
@@ -3551,13 +3595,13 @@ class A {
3551
3595
  if (s !== -1 && a !== -1 && s < a) {
3552
3596
  const o = i.substring(0, s);
3553
3597
  if (n === o) {
3554
- const l = i.substring(s + 1, a), h = Number(l);
3555
- if (isNaN(h))
3556
- b.error("Haori", `Invalid index: ${i}`);
3598
+ const l = i.substring(s + 1, a), d = Number(l);
3599
+ if (isNaN(d))
3600
+ p.error("Haori", `Invalid index: ${i}`);
3557
3601
  else {
3558
3602
  const u = e.getChildElementFragments().filter((m) => m.hasAttribute(`${c.prefix}row`));
3559
- h < u.length && r.push(
3560
- ...A.findFragmentByKeyParts(u[h], t.slice(1))
3603
+ d < u.length && r.push(
3604
+ ...A.findFragmentByKeyParts(u[d], t.slice(1))
3561
3605
  );
3562
3606
  }
3563
3607
  }
@@ -3662,8 +3706,8 @@ class N {
3662
3706
  static bindChange(e, t, r, i = "other") {
3663
3707
  const n = [], s = new Set(Object.keys(t || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
3664
3708
  for (const l of o) {
3665
- const h = t?.[l], u = r[l];
3666
- h !== u && n.push(l);
3709
+ const d = t?.[l], u = r[l];
3710
+ d !== u && n.push(l);
3667
3711
  }
3668
3712
  N.dispatch(e, "bindchange", {
3669
3713
  previous: t || {},
@@ -3802,11 +3846,11 @@ class N {
3802
3846
  });
3803
3847
  }
3804
3848
  }
3805
- const Je = {
3849
+ const Ze = {
3806
3850
  401: "unauthorized-redirect",
3807
3851
  403: "forbidden-redirect"
3808
3852
  };
3809
- function Xe(f, e) {
3853
+ function _e(f, e) {
3810
3854
  return f.replace(/\{\{([\s\S]+?)\}\}/g, (t, r) => {
3811
3855
  try {
3812
3856
  const i = G.evaluate(String(r).trim(), e);
@@ -3816,16 +3860,16 @@ function Xe(f, e) {
3816
3860
  }
3817
3861
  });
3818
3862
  }
3819
- function Qe(f, e) {
3863
+ function et(f, e) {
3820
3864
  const t = f.getAttribute(e);
3821
3865
  if (t === null || t === "")
3822
3866
  return null;
3823
3867
  if (!t.includes("{{"))
3824
3868
  return t;
3825
- const r = S.get(f), i = r instanceof M ? r.getBindingData() : {}, n = Xe(t, i);
3869
+ const r = S.get(f), i = r instanceof M ? r.getBindingData() : {}, n = _e(t, i);
3826
3870
  return n === "" ? null : n;
3827
3871
  }
3828
- function Ze(f, e, t) {
3872
+ function tt(f, e, t) {
3829
3873
  const r = f.getAttribute(`${e}-return-param`);
3830
3874
  if (r === null || r === "")
3831
3875
  return t;
@@ -3838,17 +3882,17 @@ function Ze(f, e, t) {
3838
3882
  const i = window.location.pathname + window.location.search + window.location.hash, n = `${encodeURIComponent(r)}=${encodeURIComponent(i)}`, s = t.indexOf("#"), a = s >= 0 ? t.slice(s) : "", o = s >= 0 ? t.slice(0, s) : t, l = o.includes("?") ? "&" : "?";
3839
3883
  return `${o}${l}${n}${a}`;
3840
3884
  }
3841
- function Le(f) {
3842
- const e = Je[f];
3885
+ function je(f) {
3886
+ const e = Ze[f];
3843
3887
  if (e === void 0 || typeof document > "u")
3844
3888
  return !1;
3845
3889
  const t = `${c.prefix}${e}`, r = [];
3846
3890
  document.body && r.push(document.body), document.documentElement && r.push(document.documentElement);
3847
3891
  for (const i of r) {
3848
- const n = Qe(i, t);
3892
+ const n = et(i, t);
3849
3893
  if (n === null)
3850
3894
  continue;
3851
- const s = Ze(i, t, n);
3895
+ const s = tt(i, t, n);
3852
3896
  try {
3853
3897
  if (new URL(s, window.location.href).href === window.location.href)
3854
3898
  return !1;
@@ -3858,7 +3902,7 @@ function Le(f) {
3858
3902
  }
3859
3903
  return !1;
3860
3904
  }
3861
- class Ue {
3905
+ class qe {
3862
3906
  /**
3863
3907
  * URLのクエリパラメータを取得します。
3864
3908
  *
@@ -3896,7 +3940,7 @@ class Ue {
3896
3940
  }
3897
3941
  }
3898
3942
  }
3899
- const _e = [
3943
+ const rt = [
3900
3944
  "addErrorMessage",
3901
3945
  "clearMessages",
3902
3946
  "closeDialog",
@@ -3904,28 +3948,28 @@ const _e = [
3904
3948
  "dialog",
3905
3949
  "openDialog",
3906
3950
  "toast"
3907
- ], et = "__haoriHistoryState__", de = "data-haori-click-lock";
3908
- function ie() {
3951
+ ], it = "__haoriHistoryState__", ge = "data-haori-click-lock";
3952
+ function ne() {
3909
3953
  const e = globalThis.window?.Haori;
3910
- return _e.every(
3954
+ return rt.every(
3911
3955
  (r) => typeof e?.[r] == "function"
3912
3956
  ) ? e : Z;
3913
3957
  }
3914
- const tt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
3915
- function rt(f) {
3916
- return tt.has(f.toUpperCase());
3958
+ const nt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
3959
+ function st(f) {
3960
+ return nt.has(f.toUpperCase());
3917
3961
  }
3918
- function it(f, e) {
3962
+ function at(f, e) {
3919
3963
  for (const [t, r] of Object.entries(e))
3920
3964
  r !== void 0 && (r === null ? f.append(t, "") : Array.isArray(r) ? r.forEach((i) => {
3921
3965
  f.append(t, String(i));
3922
3966
  }) : typeof r == "object" || typeof r == "function" ? f.append(t, JSON.stringify(r)) : f.append(t, String(r)));
3923
3967
  }
3924
- function nt(f, e) {
3968
+ function ot(f, e) {
3925
3969
  const t = new URL(f, window.location.href), r = new URLSearchParams(t.search);
3926
- return it(r, e), t.search = r.toString(), t.toString();
3970
+ return at(r, e), t.search = r.toString(), t.toString();
3927
3971
  }
3928
- function st(f) {
3972
+ function lt(f) {
3929
3973
  return f == null ? null : typeof f == "string" ? f : f instanceof URLSearchParams ? f.toString() : f instanceof FormData ? Array.from(f.entries()).map(([e, t]) => t instanceof File ? [
3930
3974
  e,
3931
3975
  {
@@ -3936,7 +3980,42 @@ function st(f) {
3936
3980
  }
3937
3981
  ] : [e, String(t)]) : String(f);
3938
3982
  }
3939
- function at(f, e) {
3983
+ function te(f) {
3984
+ return f instanceof Blob ? !0 : Array.isArray(f) ? f.some(te) : f !== null && typeof f == "object" ? Object.values(f).some(
3985
+ te
3986
+ ) : !1;
3987
+ }
3988
+ function ut(f) {
3989
+ return Object.values(f).some((e) => e instanceof Blob ? !1 : Array.isArray(e) ? e.some(
3990
+ (t) => !(t instanceof Blob) && te(t)
3991
+ ) : te(e));
3992
+ }
3993
+ function se(f) {
3994
+ return me(A.getValues(f));
3995
+ }
3996
+ function me(f) {
3997
+ const e = (r) => {
3998
+ if (r instanceof File)
3999
+ return r.name;
4000
+ if (r instanceof Blob)
4001
+ return "";
4002
+ if (Array.isArray(r))
4003
+ return r.map(e);
4004
+ if (r !== null && typeof r == "object") {
4005
+ const i = {};
4006
+ for (const [n, s] of Object.entries(
4007
+ r
4008
+ ))
4009
+ i[n] = e(s);
4010
+ return i;
4011
+ }
4012
+ return r;
4013
+ }, t = {};
4014
+ for (const [r, i] of Object.entries(f))
4015
+ t[r] = e(i);
4016
+ return t;
4017
+ }
4018
+ function ct(f, e) {
3940
4019
  const t = new Headers(
3941
4020
  e.headers || void 0
3942
4021
  ), r = Array.from(t.entries()).sort(
@@ -3946,7 +4025,7 @@ function at(f, e) {
3946
4025
  url: f,
3947
4026
  method: String(e.method || "GET").toUpperCase(),
3948
4027
  headers: r,
3949
- body: st(e.body || null)
4028
+ body: lt(e.body || null)
3950
4029
  });
3951
4030
  }
3952
4031
  const g = class g {
@@ -3958,7 +4037,7 @@ const g = class g {
3958
4037
  * @param domEvent 起点となった DOM イベント
3959
4038
  */
3960
4039
  constructor(e, t = null, r = null) {
3961
- this.reentrantBind = !1, g.isElementFragment(e) ? (this.options = g.buildOptions(e, t), this.eventType = t) : (this.options = e, this.eventType = null), this.domEvent = r;
4040
+ this.reentrantBind = !1, this.suppressEmptyReplaceBind = !1, g.isElementFragment(e) ? (this.options = g.buildOptions(e, t), this.eventType = t) : (this.options = e, this.eventType = null), this.domEvent = r;
3962
4041
  }
3963
4042
  /**
3964
4043
  * イベント属性名を正しく生成します。
@@ -4109,7 +4188,7 @@ const g = class g {
4109
4188
  const a = r.trim();
4110
4189
  if (g.SINGLE_PLACEHOLDER_REGEX.test(a))
4111
4190
  return {
4112
- value: k.parseDataBind(n),
4191
+ value: P.parseDataBind(n),
4113
4192
  hasUnresolvedReference: s
4114
4193
  };
4115
4194
  if (a.startsWith("{") || a.startsWith("[")) {
@@ -4118,7 +4197,7 @@ const g = class g {
4118
4197
  e.getBindingData()
4119
4198
  );
4120
4199
  return {
4121
- value: k.parseDataBind(l.value),
4200
+ value: P.parseDataBind(l.value),
4122
4201
  hasUnresolvedReference: s || l.hasUnresolvedReference
4123
4202
  };
4124
4203
  }
@@ -4127,7 +4206,7 @@ const g = class g {
4127
4206
  e.getBindingData()
4128
4207
  );
4129
4208
  return {
4130
- value: k.parseDataBind(o.value),
4209
+ value: P.parseDataBind(o.value),
4131
4210
  hasUnresolvedReference: s || o.hasUnresolvedReference
4132
4211
  };
4133
4212
  }
@@ -4145,22 +4224,22 @@ const g = class g {
4145
4224
  if (t) {
4146
4225
  if (e.hasAttribute(g.attrName(t, "validate")) && (r.valid = !0), e.hasAttribute(g.attrName(t, "confirm")) && (r.confirmMessage = e.getAttribute(g.attrName(t, "confirm")).replace(/\\n/g, `
4147
4226
  `)), e.hasAttribute(g.attrName(t, "data")) && (r.dataAttrName = g.attrName(t, "data")), e.hasAttribute(g.attrName(t, "form"))) {
4148
- const p = e.getRawAttribute(
4227
+ const b = e.getRawAttribute(
4149
4228
  g.attrName(t, "form")
4150
4229
  );
4151
- if (p) {
4152
- const y = document.body.querySelector(p);
4153
- y !== null ? r.formFragment = A.getFormFragment(
4154
- S.get(y)
4155
- ) : b.error(
4230
+ if (b) {
4231
+ const v = document.body.querySelector(b);
4232
+ v !== null ? r.formFragment = A.getFormFragment(
4233
+ S.get(v)
4234
+ ) : p.error(
4156
4235
  "Haori",
4157
- `Form element not found: ${p} (${g.attrName(t, "form")})`
4236
+ `Form element not found: ${b} (${g.attrName(t, "form")})`
4158
4237
  );
4159
4238
  } else
4160
4239
  r.formFragment = A.getFormFragment(e);
4161
- } else (t === "change" || t === "input") && (r.formFragment = A.getFormFragment(e));
4240
+ } else (t === "change" || t === "input") && (r.formFragment = A.getFormFragment(e), r.formFragment === null && g.isNamedInputFragment(e) && (r.selfValueFragment = e));
4162
4241
  if (e.hasAttribute(`${c.prefix}${t}-before-run`)) {
4163
- const p = e.getRawAttribute(
4242
+ const b = e.getRawAttribute(
4164
4243
  `${c.prefix}${t}-before-run`
4165
4244
  );
4166
4245
  try {
@@ -4169,37 +4248,37 @@ const g = class g {
4169
4248
  "fetchOptions",
4170
4249
  `
4171
4250
  "use strict";
4172
- ${p}
4251
+ ${b}
4173
4252
  `
4174
4253
  );
4175
- } catch (y) {
4176
- b.error("Haori", `Invalid before script: ${y}`);
4254
+ } catch (v) {
4255
+ p.error("Haori", `Invalid before script: ${v}`);
4177
4256
  }
4178
4257
  }
4179
4258
  const E = g.attrName(t, "run");
4180
4259
  if (e.hasAttribute(E)) {
4181
- const p = String(e.getAttribute(E) ?? "");
4182
- let y = null;
4260
+ const b = String(e.getAttribute(E) ?? "");
4261
+ let v = null;
4183
4262
  try {
4184
- y = new Function(
4263
+ v = new Function(
4185
4264
  "event",
4186
4265
  `"use strict"; return (
4187
- ${p}
4266
+ ${b}
4188
4267
  );`
4189
4268
  );
4190
4269
  } catch {
4191
4270
  try {
4192
- y = new Function(
4271
+ v = new Function(
4193
4272
  "event",
4194
4273
  `"use strict";
4195
- ${p}
4274
+ ${b}
4196
4275
  `
4197
4276
  );
4198
4277
  } catch (R) {
4199
- b.error("Haori", `Invalid run script: ${R}`);
4278
+ p.error("Haori", `Invalid run script: ${R}`);
4200
4279
  }
4201
4280
  }
4202
- y && (r.runScript = y);
4281
+ v && (r.runScript = v);
4203
4282
  }
4204
4283
  }
4205
4284
  const i = g.attrName(t, "fetch"), n = e.hasAttribute(i);
@@ -4211,28 +4290,28 @@ ${p}
4211
4290
  if (t) {
4212
4291
  const E = g.attrName(t, "fetch-method");
4213
4292
  if (e.hasAttribute(E)) {
4214
- const p = e.getAttributeEvaluation(E);
4215
- p?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = p?.value;
4293
+ const b = e.getAttributeEvaluation(E);
4294
+ b?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = b?.value;
4216
4295
  }
4217
4296
  } else {
4218
4297
  const E = g.attrName(null, "method", !0);
4219
4298
  if (e.hasAttribute(E)) {
4220
- const p = e.getAttributeEvaluation(
4299
+ const b = e.getAttributeEvaluation(
4221
4300
  E
4222
4301
  );
4223
- p?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = p?.value;
4302
+ b?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = b?.value;
4224
4303
  }
4225
4304
  }
4226
4305
  if (t) {
4227
4306
  const E = g.attrName(t, "fetch-headers");
4228
4307
  if (e.hasAttribute(E)) {
4229
- const p = e.getRawAttribute(
4308
+ const b = e.getRawAttribute(
4230
4309
  E
4231
4310
  );
4232
4311
  try {
4233
- s.headers = k.parseDataBind(p);
4234
- } catch (y) {
4235
- b.error("Haori", `Invalid fetch headers: ${y}`);
4312
+ s.headers = P.parseDataBind(b);
4313
+ } catch (v) {
4314
+ p.error("Haori", `Invalid fetch headers: ${v}`);
4236
4315
  }
4237
4316
  }
4238
4317
  } else {
@@ -4242,27 +4321,27 @@ ${p}
4242
4321
  !0
4243
4322
  );
4244
4323
  if (e.hasAttribute(E)) {
4245
- const p = e.getRawAttribute(
4324
+ const b = e.getRawAttribute(
4246
4325
  E
4247
4326
  );
4248
4327
  try {
4249
- s.headers = k.parseDataBind(p);
4250
- } catch (y) {
4251
- b.error("Haori", `Invalid fetch headers: ${y}`);
4328
+ s.headers = P.parseDataBind(b);
4329
+ } catch (v) {
4330
+ p.error("Haori", `Invalid fetch headers: ${v}`);
4252
4331
  }
4253
4332
  }
4254
4333
  }
4255
4334
  if (t) {
4256
4335
  const E = g.attrName(t, "fetch-content-type");
4257
4336
  if (e.hasAttribute(E)) {
4258
- const p = e.getAttributeEvaluation(E);
4259
- p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4337
+ const b = e.getAttributeEvaluation(E);
4338
+ b?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4260
4339
  ...s.headers,
4261
- "Content-Type": p?.value
4340
+ "Content-Type": b?.value
4262
4341
  };
4263
4342
  } else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
4264
- let p = !1;
4265
- s.headers && typeof s.headers == "object" && (p = "Content-Type" in s.headers), p || (s.headers = {
4343
+ let b = !1;
4344
+ s.headers && typeof s.headers == "object" && (b = "Content-Type" in s.headers), b || (s.headers = {
4266
4345
  ...s.headers,
4267
4346
  "Content-Type": "application/json"
4268
4347
  });
@@ -4277,14 +4356,14 @@ ${p}
4277
4356
  !0
4278
4357
  );
4279
4358
  if (e.hasAttribute(E)) {
4280
- const p = e.getAttributeEvaluation(E);
4281
- p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4359
+ const b = e.getAttributeEvaluation(E);
4360
+ b?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4282
4361
  ...s.headers,
4283
- "Content-Type": p?.value
4362
+ "Content-Type": b?.value
4284
4363
  };
4285
4364
  } else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
4286
- let p = !1;
4287
- s.headers && typeof s.headers == "object" && (p = "Content-Type" in s.headers), p || (s.headers = {
4365
+ let b = !1;
4366
+ s.headers && typeof s.headers == "object" && (b = "Content-Type" in s.headers), b || (s.headers = {
4288
4367
  ...s.headers,
4289
4368
  "Content-Type": "application/json"
4290
4369
  });
@@ -4298,11 +4377,11 @@ ${p}
4298
4377
  if (e.hasAttribute(a)) {
4299
4378
  const E = e.getRawAttribute(a);
4300
4379
  if (E) {
4301
- const p = document.body.querySelectorAll(E);
4302
- p.length > 0 ? (r.bindFragments = [], p.forEach((y) => {
4303
- const R = S.get(y);
4380
+ const b = document.body.querySelectorAll(E);
4381
+ b.length > 0 ? (r.bindFragments = [], b.forEach((v) => {
4382
+ const R = S.get(v);
4304
4383
  R && r.bindFragments.push(R);
4305
- })) : b.error(
4384
+ })) : p.error(
4306
4385
  "Haori",
4307
4386
  `Bind element not found: ${E} (${a})`
4308
4387
  );
@@ -4312,57 +4391,57 @@ ${p}
4312
4391
  null,
4313
4392
  "arg",
4314
4393
  !0
4315
- ), h = g.attrName(
4394
+ ), d = g.attrName(
4316
4395
  null,
4317
4396
  "bind-arg",
4318
4397
  !0
4319
4398
  );
4320
4399
  t ? e.hasAttribute(o) && (r.bindArg = e.getRawAttribute(o)) : e.hasAttribute(l) ? r.bindArg = e.getRawAttribute(
4321
4400
  l
4322
- ) : e.hasAttribute(h) && (r.bindArg = e.getRawAttribute(h));
4401
+ ) : e.hasAttribute(d) && (r.bindArg = e.getRawAttribute(d));
4323
4402
  const u = t ? g.attrName(t, "bind-params") : g.attrName(null, "bind-params", !0);
4324
4403
  if (e.hasAttribute(u)) {
4325
4404
  const E = e.getRawAttribute(u);
4326
- r.bindParams = E.split("&").map((p) => p.trim());
4405
+ r.bindParams = E.split("&").map((b) => b.trim());
4327
4406
  }
4328
4407
  const m = t ? g.attrName(t, "bind-append") : g.attrName(null, "bind-append", !0);
4329
4408
  if (e.hasAttribute(m)) {
4330
4409
  const E = e.getRawAttribute(m);
4331
- r.bindAppendParams = E.split("&").map((p) => p.trim()).filter(Boolean);
4410
+ r.bindAppendParams = E.split("&").map((b) => b.trim()).filter(Boolean);
4332
4411
  }
4333
- const v = t ? g.attrName(t, "bind-merge") : g.attrName(null, "bind-merge", !0);
4334
- e.hasAttribute(v) && (r.bindMerge = !0);
4412
+ const y = t ? g.attrName(t, "bind-merge") : g.attrName(null, "bind-merge", !0);
4413
+ e.hasAttribute(y) && (r.bindMerge = !0);
4335
4414
  const T = t ? g.attrName(t, "bind-transform") : g.attrName(null, "bind-transform", !0);
4336
4415
  e.hasAttribute(T) && (r.bindTransform = e.getRawAttribute(T));
4337
- const C = t ? g.attrName(t, "copy-params") : null;
4338
- if (C && e.hasAttribute(C)) {
4339
- const E = e.getRawAttribute(C);
4340
- r.copyParams = E.split("&").map((p) => p.trim()).filter(Boolean);
4416
+ const k = t ? g.attrName(t, "copy-params") : null;
4417
+ if (k && e.hasAttribute(k)) {
4418
+ const E = e.getRawAttribute(k);
4419
+ r.copyParams = E.split("&").map((b) => b.trim()).filter(Boolean);
4341
4420
  }
4342
4421
  if (t) {
4343
4422
  if (e.hasAttribute(g.attrName(t, "adjust"))) {
4344
- const y = e.getRawAttribute(
4423
+ const v = e.getRawAttribute(
4345
4424
  g.attrName(t, "adjust")
4346
4425
  );
4347
- if (y) {
4348
- const R = document.body.querySelectorAll(y);
4349
- R.length > 0 ? (r.adjustFragments = [], R.forEach((P) => {
4350
- const F = S.get(P);
4426
+ if (v) {
4427
+ const R = document.body.querySelectorAll(v);
4428
+ R.length > 0 ? (r.adjustFragments = [], R.forEach((C) => {
4429
+ const F = S.get(C);
4351
4430
  F && r.adjustFragments.push(F);
4352
- })) : b.error(
4431
+ })) : p.error(
4353
4432
  "Haori",
4354
- `Adjust element not found: ${y} (${g.attrName(t, "adjust")})`
4433
+ `Adjust element not found: ${v} (${g.attrName(t, "adjust")})`
4355
4434
  );
4356
4435
  }
4357
4436
  if (e.hasAttribute(g.attrName(t, "adjust-value"))) {
4358
4437
  const R = e.getRawAttribute(
4359
4438
  g.attrName(t, "adjust-value")
4360
- ), P = Number(R);
4361
- isNaN(P) || (r.adjustValue = P);
4439
+ ), C = Number(R);
4440
+ isNaN(C) || (r.adjustValue = C);
4362
4441
  }
4363
4442
  }
4364
4443
  if (e.hasAttribute(g.attrName(t, "row-add")) && (r.rowAdd = !0), e.hasAttribute(g.attrName(t, "row-remove")) && (r.rowRemove = !0), e.hasAttribute(g.attrName(t, "row-prev")) && (r.rowMovePrev = !0), e.hasAttribute(g.attrName(t, "row-next")) && (r.rowMoveNext = !0), e.hasAttribute(`${c.prefix}${t}-after-run`)) {
4365
- const y = e.getRawAttribute(
4444
+ const v = e.getRawAttribute(
4366
4445
  `${c.prefix}${t}-after-run`
4367
4446
  );
4368
4447
  try {
@@ -4370,11 +4449,11 @@ ${p}
4370
4449
  "response",
4371
4450
  `
4372
4451
  "use strict";
4373
- ${y}
4452
+ ${v}
4374
4453
  `
4375
4454
  );
4376
4455
  } catch (R) {
4377
- b.error("Haori", `Invalid after script: ${R}`);
4456
+ p.error("Haori", `Invalid after script: ${R}`);
4378
4457
  }
4379
4458
  }
4380
4459
  if (e.hasAttribute(g.attrName(t, "dialog")) && (r.dialogMessage = e.getAttribute(g.attrName(t, "dialog")).replace(/\\n/g, `
@@ -4382,21 +4461,21 @@ ${y}
4382
4461
  r.toastMessage = e.getAttribute(
4383
4462
  g.attrName(t, "toast")
4384
4463
  );
4385
- const y = e.getRawAttribute(
4464
+ const v = e.getRawAttribute(
4386
4465
  g.attrName(t, "toast-level")
4387
- ), P = ["info", "warning", "error", "success"].includes(y);
4388
- r.toastLevel = P ? y : null;
4466
+ ), C = ["info", "warning", "error", "success"].includes(v);
4467
+ r.toastLevel = C ? v : null;
4389
4468
  }
4390
4469
  if (e.hasAttribute(g.attrName(t, "redirect"))) {
4391
4470
  r.redirectUrl = e.getAttribute(
4392
4471
  g.attrName(t, "redirect")
4393
4472
  );
4394
- const y = g.attrName(
4473
+ const v = g.attrName(
4395
4474
  t,
4396
4475
  "redirect-return-param"
4397
4476
  );
4398
- e.hasAttribute(y) && (r.redirectReturnParam = e.getAttribute(
4399
- y
4477
+ e.hasAttribute(v) && (r.redirectReturnParam = e.getAttribute(
4478
+ v
4400
4479
  ));
4401
4480
  }
4402
4481
  if (e.hasAttribute(g.attrName(t, "scroll-error")) && (r.scrollOnError = !0), e.hasAttribute(g.attrName(t, "scroll")) && (r.scrollTarget = e.getAttribute(
@@ -4404,16 +4483,16 @@ ${y}
4404
4483
  )), e.hasAttribute(g.attrName(t, "history")) && (r.historyUrl = e.getAttribute(
4405
4484
  g.attrName(t, "history")
4406
4485
  )), e.hasAttribute(g.attrName(t, "history-data")) && (r.historyDataAttrName = g.attrName(t, "history-data")), e.hasAttribute(g.attrName(t, "history-form"))) {
4407
- const y = e.getRawAttribute(
4486
+ const v = e.getRawAttribute(
4408
4487
  g.attrName(t, "history-form")
4409
4488
  );
4410
- if (y) {
4411
- const R = document.body.querySelector(y);
4489
+ if (v) {
4490
+ const R = document.body.querySelector(v);
4412
4491
  R !== null ? r.historyFormFragment = A.getFormFragment(
4413
4492
  S.get(R)
4414
- ) : b.error(
4493
+ ) : p.error(
4415
4494
  "Haori",
4416
- `Form element not found: ${y} (${g.attrName(t, "history-form")})`
4495
+ `Form element not found: ${v} (${g.attrName(t, "history-form")})`
4417
4496
  );
4418
4497
  } else
4419
4498
  r.historyFormFragment = A.getFormFragment(e);
@@ -4426,23 +4505,23 @@ ${y}
4426
4505
  "copy",
4427
4506
  "open",
4428
4507
  "close"
4429
- ].forEach((y) => {
4430
- const R = g.attrName(t, y);
4508
+ ].forEach((v) => {
4509
+ const R = g.attrName(t, v);
4431
4510
  if (!e.hasAttribute(R))
4432
4511
  return;
4433
- const P = e.getRawAttribute(R), F = [];
4434
- if (P)
4435
- document.body.querySelectorAll(P).forEach(($) => {
4512
+ const C = e.getRawAttribute(R), F = [];
4513
+ if (C)
4514
+ document.body.querySelectorAll(C).forEach(($) => {
4436
4515
  const W = S.get($);
4437
4516
  W && F.push(W);
4438
- }), F.length === 0 && b.error("Haori", `Element not found: ${P} (${R})`);
4439
- else if (y === "open" || y === "close") {
4517
+ }), F.length === 0 && p.error("Haori", `Element not found: ${C} (${R})`);
4518
+ else if (v === "open" || v === "close") {
4440
4519
  const U = e.getTarget().closest("dialog");
4441
- U ? F.push(S.get(U)) : b.error("Haori", `Ancestor <dialog> not found (${R})`);
4520
+ U ? F.push(S.get(U)) : p.error("Haori", `Ancestor <dialog> not found (${R})`);
4442
4521
  } else
4443
4522
  F.push(e);
4444
4523
  if (F.length > 0)
4445
- switch (y) {
4524
+ switch (v) {
4446
4525
  case "reset-before":
4447
4526
  r.resetBeforeFragments = F;
4448
4527
  break;
@@ -4466,23 +4545,23 @@ ${y}
4466
4545
  break;
4467
4546
  }
4468
4547
  });
4469
- const p = g.attrName(t, "copy-source");
4470
- if (e.hasAttribute(p)) {
4471
- const y = e.getRawAttribute(
4472
- p
4548
+ const b = g.attrName(t, "copy-source");
4549
+ if (e.hasAttribute(b)) {
4550
+ const v = e.getRawAttribute(
4551
+ b
4473
4552
  );
4474
- if (y) {
4475
- const R = document.body.querySelector(y);
4553
+ if (v) {
4554
+ const R = document.body.querySelector(v);
4476
4555
  if (R !== null) {
4477
- const P = S.get(R);
4478
- P ? r.copySourceFragment = P : b.error(
4556
+ const C = S.get(R);
4557
+ C ? r.copySourceFragment = C : p.error(
4479
4558
  "Haori",
4480
- `Element is not managed by Haori: ${y} (${p})`
4559
+ `Element is not managed by Haori: ${v} (${b})`
4481
4560
  );
4482
4561
  } else
4483
- b.error(
4562
+ p.error(
4484
4563
  "Haori",
4485
- `Element not found: ${y} (${p})`
4564
+ `Element not found: ${v} (${b})`
4486
4565
  );
4487
4566
  } else
4488
4567
  r.copySourceFragment = e;
@@ -4493,29 +4572,41 @@ ${y}
4493
4572
  g.attrName(null, "form", !0)
4494
4573
  );
4495
4574
  if (E) {
4496
- const p = document.body.querySelector(E);
4497
- p !== null ? r.formFragment = A.getFormFragment(
4498
- S.get(p)
4499
- ) : b.error(
4575
+ const b = document.body.querySelector(E);
4576
+ b !== null ? r.formFragment = A.getFormFragment(
4577
+ S.get(b)
4578
+ ) : p.error(
4500
4579
  "Haori",
4501
4580
  `Form element not found: ${E} (${g.attrName(null, "fetch-form", !0)})`
4502
4581
  );
4503
4582
  } else
4504
4583
  r.formFragment = A.getFormFragment(e);
4505
4584
  }
4506
- const O = t ? g.attrName(t, "fetch-state") : g.attrName(null, "state", !0);
4507
- if (e.hasAttribute(O)) {
4508
- const E = e.getRawAttribute(O), p = [];
4585
+ const H = t ? g.attrName(t, "fetch-state") : g.attrName(null, "state", !0);
4586
+ if (e.hasAttribute(H)) {
4587
+ const E = e.getRawAttribute(H), b = [];
4509
4588
  E ? (document.body.querySelectorAll(E).forEach((R) => {
4510
- const P = S.get(R);
4511
- P && p.push(P);
4512
- }), p.length === 0 && b.error(
4589
+ const C = S.get(R);
4590
+ C && b.push(C);
4591
+ }), b.length === 0 && p.error(
4513
4592
  "Haori",
4514
- `Element not found: ${E} (${O})`
4515
- )) : p.push(e), p.length > 0 && (r.fetchStateFragments = p);
4593
+ `Element not found: ${E} (${H})`
4594
+ )) : b.push(e), b.length > 0 && (r.fetchStateFragments = b);
4516
4595
  }
4517
4596
  return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [e], r.defaultSelfBind = !0), r;
4518
4597
  }
4598
+ /**
4599
+ * `name` を持つ入力要素(input / select / textarea)のフラグメントかどうかを
4600
+ * 判定します。フォームコンテナが無い change / input で、対象要素自身を値収集の
4601
+ * 対象としてよいかの判定に使います。
4602
+ *
4603
+ * @param fragment 判定対象のフラグメント
4604
+ * @returns `name` を持つ入力要素の場合は true
4605
+ */
4606
+ static isNamedInputFragment(e) {
4607
+ const t = e.getTarget();
4608
+ return t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement ? t.getAttribute("name") !== null : !1;
4609
+ }
4519
4610
  /**
4520
4611
  * ElementFragment の構造的タイプガード。
4521
4612
  *
@@ -4574,41 +4665,41 @@ ${y}
4574
4665
  if (Object.keys(this.options).length === 0 || this.options.formFragment && this.validate(this.options.formFragment) === !1)
4575
4666
  return !1;
4576
4667
  if (this.options.runScript) {
4577
- const h = this.options.targetFragment?.getTarget() ?? null;
4668
+ const d = this.options.targetFragment?.getTarget() ?? null;
4578
4669
  try {
4579
4670
  const u = this.options.runScript.call(
4580
- h,
4671
+ d,
4581
4672
  this.domEvent
4582
4673
  );
4583
4674
  u === !1 && this.domEvent && this.domEvent.preventDefault(), u != null && typeof u.then == "function" && await u;
4584
4675
  } catch (u) {
4585
- b.error("Haori", `Run script execution error: ${u}`);
4676
+ p.error("Haori", `Run script execution error: ${u}`);
4586
4677
  }
4587
4678
  }
4588
4679
  if (!await this.confirm())
4589
4680
  return !1;
4590
4681
  this.options.resetBeforeFragments && this.options.resetBeforeFragments.length > 0 && (await Promise.all(
4591
4682
  this.options.resetBeforeFragments.map(
4592
- (h) => A.reset(h)
4683
+ (d) => A.reset(d)
4593
4684
  )
4594
4685
  ), this.captureHistorySnapshots());
4595
4686
  const r = this.prepareFetchRequest(), i = r.payload;
4596
4687
  let n = r.url, s = r.options;
4597
4688
  if (this.options.beforeCallback) {
4598
- const h = this.options.beforeCallback(
4689
+ const d = this.options.beforeCallback(
4599
4690
  n || null,
4600
4691
  s || null
4601
4692
  );
4602
- if (h != null) {
4603
- if (h === !1 || typeof h == "object" && h.stop)
4693
+ if (d != null) {
4694
+ if (d === !1 || typeof d == "object" && d.stop)
4604
4695
  return !1;
4605
- typeof h == "object" && (n = "fetchUrl" in h ? h.fetchUrl : n, s = "fetchOptions" in h ? h.fetchOptions : s);
4696
+ typeof d == "object" && (n = "fetchUrl" in d ? d.fetchUrl : n, s = "fetchOptions" in d ? d.fetchOptions : s);
4606
4697
  }
4607
4698
  }
4608
4699
  const a = Object.keys(i).length > 0;
4609
4700
  if (n) {
4610
- const h = { ...s || {} }, u = r.requestedMethod, m = r.effectiveMethod, v = r.transportMode === "query-get", T = r.queryString;
4611
- if (v && b.info("Haori demo fetch normalization", {
4701
+ const d = { ...s || {} }, u = r.requestedMethod, m = r.effectiveMethod, y = r.transportMode === "query-get", T = r.queryString;
4702
+ if (y && p.info("Haori demo fetch normalization", {
4612
4703
  runtime: c.runtime,
4613
4704
  requestedMethod: u,
4614
4705
  effectiveMethod: m,
@@ -4617,23 +4708,23 @@ ${y}
4617
4708
  payload: a ? i : void 0,
4618
4709
  queryString: T
4619
4710
  }), this.options.targetFragment && n) {
4620
- const C = performance.now(), O = {
4711
+ const k = performance.now(), H = {
4621
4712
  runtime: c.runtime,
4622
4713
  requestedMethod: u,
4623
4714
  effectiveMethod: m,
4624
- transportMode: v ? "query-get" : "http",
4625
- ...v ? { queryString: T } : {}
4715
+ transportMode: y ? "query-get" : "http",
4716
+ ...y ? { queryString: T } : {}
4626
4717
  };
4627
4718
  return N.fetchStart(
4628
4719
  this.options.targetFragment.getTarget(),
4629
4720
  n,
4630
- h,
4721
+ d,
4631
4722
  a ? i : void 0,
4632
- O
4633
- ), await this.injectFetchState("loading"), fetch(n, h).then((E) => this.handleFetchResult(
4723
+ H
4724
+ ), await this.injectFetchState("loading"), fetch(n, d).then((E) => this.handleFetchResult(
4634
4725
  E,
4635
4726
  n || void 0,
4636
- C
4727
+ k
4637
4728
  )).catch(async (E) => {
4638
4729
  throw n && N.fetchError(
4639
4730
  this.options.targetFragment.getTarget(),
@@ -4646,15 +4737,16 @@ ${y}
4646
4737
  ), E;
4647
4738
  });
4648
4739
  }
4649
- return fetch(n, h).then((C) => this.handleFetchResult(C, n || void 0));
4740
+ return fetch(n, d).then((k) => this.handleFetchResult(k, n || void 0));
4650
4741
  }
4651
4742
  if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && a) {
4652
- const h = this.options.formFragment, u = h.getTarget(), m = /* @__PURE__ */ new Set();
4743
+ const d = this.options.formFragment, u = d.getTarget(), m = /* @__PURE__ */ new Set();
4653
4744
  e && e.appliedDisabledAttribute && this.options.targetFragment && m.add(this.options.targetFragment);
4654
- const v = h.getBindingData();
4655
- Object.assign(v, i), await k.setBindingData(u, v, m);
4745
+ const y = d.getBindingData();
4746
+ Object.assign(y, me(i)), await P.setBindingData(u, y, m);
4656
4747
  }
4657
- const o = a ? i : {}, l = new Response(JSON.stringify(o), {
4748
+ this.suppressEmptyReplaceBind = !a && !this.options.formFragment && (this.eventType === "change" || this.eventType === "input");
4749
+ const o = a ? me(i) : {}, l = new Response(JSON.stringify(o), {
4658
4750
  headers: { "Content-Type": "application/json" }
4659
4751
  });
4660
4752
  return this.handleFetchResult(l);
@@ -4671,12 +4763,12 @@ ${y}
4671
4763
  if (this.eventType !== "click" || !this.options.targetFragment)
4672
4764
  return null;
4673
4765
  const t = this.options.targetFragment.getTarget();
4674
- if (g.RUNNING_CLICK_TARGETS.has(t) || t.matches(":disabled") || t.hasAttribute("disabled") || t.hasAttribute(de))
4766
+ if (g.RUNNING_CLICK_TARGETS.has(t) || t.matches(":disabled") || t.hasAttribute("disabled") || t.hasAttribute(ge))
4675
4767
  return !1;
4676
4768
  const r = t.hasAttribute(
4677
4769
  `${c.prefix}click-no-disabled`
4678
4770
  );
4679
- return g.RUNNING_CLICK_TARGETS.add(t), t.setAttribute(de, ""), r || t.setAttribute("disabled", ""), {
4771
+ return g.RUNNING_CLICK_TARGETS.add(t), t.setAttribute(ge, ""), r || t.setAttribute("disabled", ""), {
4680
4772
  target: t,
4681
4773
  appliedDisabledAttribute: !r
4682
4774
  };
@@ -4688,15 +4780,15 @@ ${y}
4688
4780
  * @returns 戻り値はありません。
4689
4781
  */
4690
4782
  releaseExecutionLock(e) {
4691
- e && (g.RUNNING_CLICK_TARGETS.delete(e.target), e.target.removeAttribute(de), e.appliedDisabledAttribute && e.target.removeAttribute("disabled"));
4783
+ e && (g.RUNNING_CLICK_TARGETS.delete(e.target), e.target.removeAttribute(ge), e.appliedDisabledAttribute && e.target.removeAttribute("disabled"));
4692
4784
  }
4693
4785
  /**
4694
4786
  * フェッチ後の処理を実行します。
4695
4787
  */
4696
4788
  async handleFetchResult(e, t, r) {
4697
- const i = ie();
4789
+ const i = ne();
4698
4790
  if (!e.ok)
4699
- return Le(e.status) || (this.options.targetFragment && t && N.fetchError(
4791
+ return je(e.status) || (this.options.targetFragment && t && N.fetchError(
4700
4792
  this.options.targetFragment.getTarget(),
4701
4793
  t,
4702
4794
  new Error(`${e.status} ${e.statusText}`),
@@ -4729,7 +4821,7 @@ ${y}
4729
4821
  s.push(new g(a, null).run());
4730
4822
  }), this.options.clickFragments && this.options.clickFragments.length > 0)
4731
4823
  for (const a of this.options.clickFragments) {
4732
- await k.evaluateAll(a);
4824
+ await P.evaluateAll(a);
4733
4825
  const o = a.getTarget();
4734
4826
  typeof o.click == "function" ? o.click() : o.dispatchEvent(
4735
4827
  new MouseEvent("click", { bubbles: !0, cancelable: !0 })
@@ -4737,10 +4829,10 @@ ${y}
4737
4829
  }
4738
4830
  if (this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
4739
4831
  const o = a.getTarget();
4740
- o instanceof HTMLElement ? s.push(i.openDialog(o)) : b.error("Haori", "Element is not an HTML element: ", o);
4832
+ o instanceof HTMLElement ? s.push(i.openDialog(o)) : p.error("Haori", "Element is not an HTML element: ", o);
4741
4833
  }), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
4742
4834
  const o = a.getTarget();
4743
- o instanceof HTMLElement ? s.push(i.closeDialog(o)) : b.error("Haori", "Element is not an HTML element: ", o);
4835
+ o instanceof HTMLElement ? s.push(i.closeDialog(o)) : p.error("Haori", "Element is not an HTML element: ", o);
4744
4836
  }), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
4745
4837
  this.options.toastMessage,
4746
4838
  this.options.toastLevel ?? "info"
@@ -4748,12 +4840,12 @@ ${y}
4748
4840
  let a = this.options.redirectUrl;
4749
4841
  const o = this.options.redirectReturnParam;
4750
4842
  if (o) {
4751
- const h = new URLSearchParams(window.location.search).get(o);
4752
- if (h !== null) {
4753
- const u = h.trim();
4754
- Ue.isSafeLocalPath(u) ? a = u : b.warn(
4843
+ const d = new URLSearchParams(window.location.search).get(o);
4844
+ if (d !== null) {
4845
+ const u = d.trim();
4846
+ qe.isSafeLocalPath(u) ? a = u : p.warn(
4755
4847
  "Haori",
4756
- `戻り先パスが安全なローカルパスではないため、既定の遷移先へフォールバックします: ${h}`
4848
+ `戻り先パスが安全なローカルパスではないため、既定の遷移先へフォールバックします: ${d}`
4757
4849
  );
4758
4850
  }
4759
4851
  }
@@ -4775,20 +4867,20 @@ ${y}
4775
4867
  const s = e ? this.options.historyUrl : window.location.pathname, a = new URL(s, window.location.href);
4776
4868
  if (a.origin !== window.location.origin) {
4777
4869
  const l = "history.pushState: cross-origin URL is not allowed: " + a.toString();
4778
- b.error("Haori", l);
4870
+ p.error("Haori", l);
4779
4871
  return;
4780
4872
  }
4781
4873
  const o = (l) => {
4782
- for (const [h, u] of Object.entries(l))
4783
- u != null && (Array.isArray(u) ? u.forEach((m) => a.searchParams.append(h, String(m))) : typeof u == "object" ? a.searchParams.set(h, JSON.stringify(u)) : a.searchParams.set(h, String(u)));
4874
+ for (const [d, u] of Object.entries(l))
4875
+ u != null && (Array.isArray(u) ? u.forEach((m) => a.searchParams.append(d, String(m))) : typeof u == "object" ? a.searchParams.set(d, JSON.stringify(u)) : a.searchParams.set(d, String(u)));
4784
4876
  };
4785
4877
  i && o(t), n && o(r), history.pushState(
4786
- { [et]: !0 },
4878
+ { [it]: !0 },
4787
4879
  "",
4788
4880
  a.toString()
4789
4881
  );
4790
4882
  } catch (s) {
4791
- b.error("Haori", `history.pushState failed: ${s}`);
4883
+ p.error("Haori", `history.pushState failed: ${s}`);
4792
4884
  }
4793
4885
  }
4794
4886
  /**
@@ -4798,10 +4890,10 @@ ${y}
4798
4890
  let t = null;
4799
4891
  this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
4800
4892
  const r = t ? t.getTarget() : document.body;
4801
- await ie().clearMessages(r);
4893
+ await ne().clearMessages(r);
4802
4894
  const i = async (a) => {
4803
4895
  const o = t ? t.getTarget() : document.body;
4804
- await ie().addErrorMessage(o, a);
4896
+ await ne().addErrorMessage(o, a);
4805
4897
  }, n = () => {
4806
4898
  if (!this.options.scrollOnError)
4807
4899
  return;
@@ -4812,35 +4904,35 @@ ${y}
4812
4904
  try {
4813
4905
  const a = await e.json(), o = [];
4814
4906
  if (Array.isArray(a)) {
4815
- const l = /* @__PURE__ */ new Map(), h = [];
4907
+ const l = /* @__PURE__ */ new Map(), d = [];
4816
4908
  for (const u of a)
4817
4909
  if (u && typeof u == "object" && !Array.isArray(u)) {
4818
- const m = u.key, v = u.message, T = typeof m == "string" && m.length > 0 ? m : null, C = typeof v == "string" ? v : v != null ? String(v) : "";
4819
- if (C.length === 0)
4910
+ const m = u.key, y = u.message, T = typeof m == "string" && m.length > 0 ? m : null, k = typeof y == "string" ? y : y != null ? String(y) : "";
4911
+ if (k.length === 0)
4820
4912
  continue;
4821
4913
  if (T !== null) {
4822
- const O = l.get(T) ?? [];
4823
- O.push(C), l.set(T, O);
4914
+ const H = l.get(T) ?? [];
4915
+ H.push(k), l.set(T, H);
4824
4916
  } else
4825
- h.push(C);
4826
- } else typeof u == "string" && u.length > 0 && h.push(u);
4917
+ d.push(k);
4918
+ } else typeof u == "string" && u.length > 0 && d.push(u);
4827
4919
  for (const [u, m] of l)
4828
4920
  o.push({ key: u, message: m.join(`
4829
4921
  `) });
4830
- for (const u of h)
4922
+ for (const u of d)
4831
4923
  o.push({ message: u });
4832
4924
  } else if (a && typeof a == "object") {
4833
4925
  if (typeof a.message == "string" && o.push({ message: a.message }), Array.isArray(a.messages))
4834
4926
  for (const l of a.messages)
4835
4927
  typeof l == "string" && o.push({ message: l });
4836
4928
  if (a.errors && typeof a.errors == "object")
4837
- for (const [l, h] of Object.entries(a.errors))
4838
- Array.isArray(h) ? o.push({ key: l, message: h.join(`
4839
- `) }) : typeof h == "string" ? o.push({ key: l, message: h }) : h != null && o.push({ key: l, message: String(h) });
4929
+ for (const [l, d] of Object.entries(a.errors))
4930
+ Array.isArray(d) ? o.push({ key: l, message: d.join(`
4931
+ `) }) : typeof d == "string" ? o.push({ key: l, message: d }) : d != null && o.push({ key: l, message: String(d) });
4840
4932
  if (o.length === 0)
4841
- for (const [l, h] of Object.entries(a))
4842
- l === "message" || l === "messages" || l === "errors" || (Array.isArray(h) ? o.push({ key: l, message: h.join(`
4843
- `) }) : typeof h == "string" && o.push({ key: l, message: h }));
4933
+ for (const [l, d] of Object.entries(a))
4934
+ l === "message" || l === "messages" || l === "errors" || (Array.isArray(d) ? o.push({ key: l, message: d.join(`
4935
+ `) }) : typeof d == "string" && o.push({ key: l, message: d }));
4844
4936
  }
4845
4937
  if (o.length === 0)
4846
4938
  return await i(`${e.status} ${e.statusText}`), n(), !1;
@@ -4904,7 +4996,7 @@ ${y}
4904
4996
  */
4905
4997
  confirm() {
4906
4998
  const e = this.options.confirmMessage;
4907
- return e == null ? Promise.resolve(!0) : ie().confirm(e);
4999
+ return e == null ? Promise.resolve(!0) : ne().confirm(e);
4908
5000
  }
4909
5001
  /**
4910
5002
  * 結果データを対象のフラグメントにバインドします。
@@ -4925,7 +5017,7 @@ ${y}
4925
5017
  response: i
4926
5018
  });
4927
5019
  } catch (s) {
4928
- b.error("Haori", `Invalid bind-transform: ${s}`);
5020
+ p.error("Haori", `Invalid bind-transform: ${s}`);
4929
5021
  }
4930
5022
  if (this.options.bindParams) {
4931
5023
  const s = {};
@@ -4933,21 +5025,28 @@ ${y}
4933
5025
  i && typeof i == "object" && a in i && (s[a] = i[a]);
4934
5026
  }), i = s;
4935
5027
  }
5028
+ if (this.suppressEmptyReplaceBind && !this.options.bindArg && !this.options.bindMerge && i !== null && typeof i == "object" && !Array.isArray(i) && Object.keys(i).length === 0) {
5029
+ p.warn(
5030
+ "Haori",
5031
+ `Skipped binding because the input has no value to collect; the bind target would be replaced with an empty object. Add a name attribute to the input, or specify ${c.prefix}${this.eventType}-form.`
5032
+ );
5033
+ return;
5034
+ }
4936
5035
  const n = [];
4937
5036
  if (this.options.bindArg)
4938
5037
  this.options.bindFragments.forEach((s) => {
4939
5038
  const a = { ...s.getRawBindingData() ?? {} }, o = this.options.bindArg;
4940
5039
  if (i && typeof i == "object" && !Array.isArray(i)) {
4941
- const l = a[o], h = l && typeof l == "object" && !Array.isArray(l) ? l : {};
5040
+ const l = a[o], d = l && typeof l == "object" && !Array.isArray(l) ? l : {};
4942
5041
  a[o] = this.mergeAppendBindingData(
4943
5042
  s,
4944
5043
  i,
4945
- h
5044
+ d
4946
5045
  );
4947
5046
  } else
4948
5047
  a[o] = i;
4949
5048
  n.push(
4950
- k.setBindingData(
5049
+ P.setBindingData(
4951
5050
  s.getTarget(),
4952
5051
  a,
4953
5052
  /* @__PURE__ */ new Set(),
@@ -4961,13 +5060,13 @@ ${y}
4961
5060
  });
4962
5061
  else if (typeof i == "string") {
4963
5062
  if (this.options.defaultSelfBind) {
4964
- b.warn(
5063
+ p.warn(
4965
5064
  "Haori",
4966
5065
  "string data is not bound because no bind target was specified."
4967
5066
  );
4968
5067
  return;
4969
5068
  }
4970
- return b.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
5069
+ return p.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
4971
5070
  new Error("string data cannot be bound without a bindArg.")
4972
5071
  );
4973
5072
  } else
@@ -4977,7 +5076,7 @@ ${y}
4977
5076
  i
4978
5077
  ), o = this.options.bindMerge ? { ...s.getRawBindingData() ?? {}, ...a } : a;
4979
5078
  n.push(
4980
- k.setBindingData(
5079
+ P.setBindingData(
4981
5080
  s.getTarget(),
4982
5081
  o,
4983
5082
  /* @__PURE__ */ new Set(),
@@ -5018,7 +5117,7 @@ ${y}
5018
5117
  ...i.getBindingData(),
5019
5118
  ...t
5020
5119
  };
5021
- return k.setBindingData(i.getTarget(), n);
5120
+ return P.setBindingData(i.getTarget(), n);
5022
5121
  });
5023
5122
  return Promise.all(r).then(() => {
5024
5123
  });
@@ -5027,7 +5126,7 @@ ${y}
5027
5126
  * copy のコピー元データを取得します。
5028
5127
  */
5029
5128
  resolveCopySourceData() {
5030
- return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ? A.getValues(this.options.copySourceFragment) : { ...this.options.copySourceFragment.getBindingData() } : this.options.formFragment ? A.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
5129
+ return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ? se(this.options.copySourceFragment) : { ...this.options.copySourceFragment.getBindingData() } : this.options.formFragment ? se(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
5031
5130
  }
5032
5131
  /**
5033
5132
  * data 属性とフォーム値を統合した送信データを作成します。
@@ -5045,12 +5144,13 @@ ${y}
5045
5144
  buildPayloadResolution() {
5046
5145
  const e = {};
5047
5146
  let t = !1;
5048
- if (this.options.formFragment && Object.assign(e, A.getValues(this.options.formFragment)), this.options.data && typeof this.options.data == "object" && Object.assign(e, this.options.data), this.options.targetFragment && this.options.dataAttrName) {
5049
- const r = g.resolveDataAttributeDetailed(
5147
+ const r = this.options.formFragment ?? this.options.selfValueFragment;
5148
+ if (r && Object.assign(e, A.getValues(r)), this.options.data && typeof this.options.data == "object" && Object.assign(e, this.options.data), this.options.targetFragment && this.options.dataAttrName) {
5149
+ const i = g.resolveDataAttributeDetailed(
5050
5150
  this.options.targetFragment,
5051
5151
  this.options.dataAttrName
5052
5152
  );
5053
- t = t || r.hasUnresolvedReference, r.value && Object.assign(e, r.value);
5153
+ t = t || i.hasUnresolvedReference, i.value && Object.assign(e, i.value);
5054
5154
  }
5055
5155
  return { payload: e, hasUnresolvedReference: t };
5056
5156
  }
@@ -5087,37 +5187,49 @@ ${y}
5087
5187
  let i = this.options.fetchUrl;
5088
5188
  const n = { ...this.options.fetchOptions || {} }, s = new Headers(
5089
5189
  n.headers || void 0
5090
- ), a = (n.method || "GET").toUpperCase(), o = c.runtime === "demo" && !rt(a), l = o ? "GET" : a;
5091
- if (n.method = l, l === "GET" || l === "HEAD" || l === "OPTIONS")
5092
- Object.keys(t).length > 0 && (i = nt(i, t));
5190
+ ), a = (n.method || "GET").toUpperCase(), o = c.runtime === "demo" && !st(a), l = o ? "GET" : a;
5191
+ if (n.method = l, Object.keys(t).length > 0 && te(t)) {
5192
+ const u = s.get("Content-Type") || "";
5193
+ l !== "GET" && l !== "HEAD" && l !== "OPTIONS" && /multipart\/form-data/i.test(u) ? ut(t) && p.warn(
5194
+ "Haori",
5195
+ `A File value nested under ${c.prefix}form-object / ${c.prefix}form-list cannot be sent. Place file inputs at the top level of the collected form values.`
5196
+ ) : p.warn(
5197
+ "Haori",
5198
+ `A File value cannot be sent without ${c.prefix}fetch-content-type="multipart/form-data" and a body method such as POST.`
5199
+ );
5200
+ }
5201
+ if (l === "GET" || l === "HEAD" || l === "OPTIONS")
5202
+ Object.keys(t).length > 0 && (i = ot(i, t));
5093
5203
  else if (Object.keys(t).length > 0) {
5094
5204
  const u = s.get("Content-Type") || "";
5095
5205
  if (/multipart\/form-data/i.test(u)) {
5096
5206
  s.delete("Content-Type");
5097
5207
  const m = new FormData();
5098
- for (const [v, T] of Object.entries(t))
5099
- T == null ? m.append(v, "") : T instanceof Blob ? m.append(v, T) : Array.isArray(T) ? T.forEach((C) => m.append(v, String(C))) : typeof T == "object" ? m.append(v, JSON.stringify(T)) : m.append(v, String(T));
5208
+ for (const [y, T] of Object.entries(t))
5209
+ T == null ? m.append(y, "") : T instanceof Blob ? m.append(y, T) : Array.isArray(T) ? T.forEach((k) => {
5210
+ k instanceof Blob ? m.append(y, k) : m.append(y, String(k));
5211
+ }) : typeof T == "object" ? m.append(y, JSON.stringify(T)) : m.append(y, String(T));
5100
5212
  n.body = m;
5101
5213
  } else if (/application\/x-www-form-urlencoded/i.test(u)) {
5102
5214
  const m = new URLSearchParams();
5103
- for (const [v, T] of Object.entries(t))
5104
- T !== void 0 && (T === null ? m.append(v, "") : Array.isArray(T) ? T.forEach((C) => m.append(v, String(C))) : typeof T == "object" ? m.append(v, JSON.stringify(T)) : m.append(v, String(T)));
5215
+ for (const [y, T] of Object.entries(t))
5216
+ T !== void 0 && (T === null ? m.append(y, "") : Array.isArray(T) ? T.forEach((k) => m.append(y, String(k))) : typeof T == "object" ? m.append(y, JSON.stringify(T)) : m.append(y, String(T)));
5105
5217
  n.body = m;
5106
5218
  } else
5107
5219
  s.set("Content-Type", "application/json"), n.body = JSON.stringify(t);
5108
5220
  }
5109
5221
  n.headers = s;
5110
- let h;
5111
- return o && (h = new URL(i, window.location.href).search || void 0, s.delete("Content-Type")), {
5222
+ let d;
5223
+ return o && (d = new URL(i, window.location.href).search || void 0, s.delete("Content-Type")), {
5112
5224
  url: i,
5113
5225
  options: n,
5114
5226
  payload: t,
5115
5227
  hasUnresolvedReference: !1,
5116
5228
  requestedMethod: a,
5117
5229
  effectiveMethod: l,
5118
- queryString: h,
5230
+ queryString: d,
5119
5231
  transportMode: o ? "query-get" : "http",
5120
- signature: at(i, n)
5232
+ signature: ct(i, n)
5121
5233
  };
5122
5234
  }
5123
5235
  /**
@@ -5127,7 +5239,7 @@ ${y}
5127
5239
  this.options.targetFragment && this.options.historyDataAttrName ? this.historyDataSnapshot = g.resolveDataAttribute(
5128
5240
  this.options.targetFragment,
5129
5241
  this.options.historyDataAttrName
5130
- ) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? A.getValues(this.options.historyFormFragment) : void 0;
5242
+ ) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? se(this.options.historyFormFragment) : void 0;
5131
5243
  }
5132
5244
  /**
5133
5245
  * history-data の評価値を取得します。
@@ -5149,7 +5261,7 @@ ${y}
5149
5261
  if (this.historyFormSnapshot !== void 0)
5150
5262
  return this.historyFormSnapshot;
5151
5263
  if (this.options.historyFormFragment)
5152
- return A.getValues(this.options.historyFormFragment);
5264
+ return se(this.options.historyFormFragment);
5153
5265
  }
5154
5266
  /**
5155
5267
  * copy-params が指定されている場合は include / exclude を考慮して抽出します。
@@ -5197,11 +5309,11 @@ ${y}
5197
5309
  */
5198
5310
  getRowFragment() {
5199
5311
  if (!this.options.targetFragment)
5200
- return b.error("Haori", "Target fragment is not specified for row operation."), null;
5312
+ return p.error("Haori", "Target fragment is not specified for row operation."), null;
5201
5313
  const e = this.options.targetFragment.closestByAttribute(
5202
5314
  `${c.prefix}row`
5203
5315
  );
5204
- return e || (b.error("Haori", "Row fragment not found."), null);
5316
+ return e || (p.error("Haori", "Row fragment not found."), null);
5205
5317
  }
5206
5318
  /**
5207
5319
  * 行を追加します。
@@ -5217,7 +5329,7 @@ ${y}
5217
5329
  const t = [], r = e.clone();
5218
5330
  return t.push(
5219
5331
  e.getParent().insertAfter(r, e)
5220
- ), t.push(k.evaluateAll(r)), t.push(A.reset(r)), Promise.all(t).then(() => {
5332
+ ), t.push(P.evaluateAll(r)), t.push(A.reset(r)), Promise.all(t).then(() => {
5221
5333
  });
5222
5334
  }
5223
5335
  /**
@@ -5300,14 +5412,14 @@ ${y}
5300
5412
  ...s.getRawBindingData() ?? {},
5301
5413
  _fetch: n
5302
5414
  };
5303
- return k.setBindingData(a, o, /* @__PURE__ */ new Set(), !1, !1);
5415
+ return P.setBindingData(a, o, /* @__PURE__ */ new Set(), !1, !1);
5304
5416
  })
5305
5417
  );
5306
5418
  }
5307
5419
  };
5308
5420
  g.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, g.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/, g.RUNNING_CLICK_TARGETS = /* @__PURE__ */ new WeakSet();
5309
5421
  let q = g;
5310
- class ot {
5422
+ class dt {
5311
5423
  /**
5312
5424
  * 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
5313
5425
  *
@@ -5325,28 +5437,28 @@ class ot {
5325
5437
  try {
5326
5438
  r = await fetch(e, t);
5327
5439
  } catch (n) {
5328
- throw b.error("[Haori]", "Failed to fetch import source:", e, n), new Error(`Failed to fetch: ${e}`);
5440
+ throw p.error("[Haori]", "Failed to fetch import source:", e, n), new Error(`Failed to fetch: ${e}`);
5329
5441
  }
5330
5442
  if (!r.ok) {
5331
- Le(r.status);
5443
+ je(r.status);
5332
5444
  const n = `${r.status} ${r.statusText}`;
5333
- throw b.error("[Haori]", "Import HTTP error:", e, n), new Error(`Failed to load ${e}: ${n}`);
5445
+ throw p.error("[Haori]", "Import HTTP error:", e, n), new Error(`Failed to load ${e}: ${n}`);
5334
5446
  }
5335
5447
  let i;
5336
5448
  try {
5337
5449
  i = await r.text();
5338
5450
  } catch (n) {
5339
- throw b.error("[Haori]", "Failed to read response text:", e, n), new Error(`Failed to read response from: ${e}`);
5451
+ throw p.error("[Haori]", "Failed to read response text:", e, n), new Error(`Failed to read response from: ${e}`);
5340
5452
  }
5341
5453
  try {
5342
5454
  const s = new DOMParser().parseFromString(i, "text/html");
5343
- return s && s.body ? s.body.innerHTML : (b.warn("[Haori]", "No body found in imported document:", e), i);
5455
+ return s && s.body ? s.body.innerHTML : (p.warn("[Haori]", "No body found in imported document:", e), i);
5344
5456
  } catch (n) {
5345
- return b.error("[Haori]", "Failed to parse imported HTML:", e, n), i;
5457
+ return p.error("[Haori]", "Failed to parse imported HTML:", e, n), i;
5346
5458
  }
5347
5459
  }
5348
5460
  }
5349
- const d = class d {
5461
+ const h = class h {
5350
5462
  /**
5351
5463
  * 遅延属性かどうか(完全名で判定)を判定します。
5352
5464
  *
@@ -5354,7 +5466,7 @@ const d = class d {
5354
5466
  * @returns 遅延属性かどうか
5355
5467
  */
5356
5468
  static isDeferredAttributeName(e) {
5357
- return d.DEFERRED_ATTRIBUTE_SUFFIXES.some(
5469
+ return h.DEFERRED_ATTRIBUTE_SUFFIXES.some(
5358
5470
  (t) => e === `${c.prefix}${t}`
5359
5471
  );
5360
5472
  }
@@ -5365,7 +5477,7 @@ const d = class d {
5365
5477
  * @returns 除外対象かどうか
5366
5478
  */
5367
5479
  static isEvaluateAllExcludedAttributeName(e) {
5368
- return d.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
5480
+ return h.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
5369
5481
  (t) => e === `${c.prefix}${t}`
5370
5482
  );
5371
5483
  }
@@ -5377,7 +5489,7 @@ const d = class d {
5377
5489
  * @returns 再評価する場合は true
5378
5490
  */
5379
5491
  static shouldReevaluateAttribute(e, t) {
5380
- return t !== null && !d.isEvaluateAllExcludedAttributeName(e) && d.ATTRIBUTE_PLACEHOLDER_REGEX.test(t);
5492
+ return t !== null && !h.isEvaluateAllExcludedAttributeName(e) && h.ATTRIBUTE_PLACEHOLDER_REGEX.test(t);
5381
5493
  }
5382
5494
  /**
5383
5495
  * data-attr-* 形式の属性名から実際に更新する属性名を取得します。
@@ -5386,7 +5498,7 @@ const d = class d {
5386
5498
  * @returns 実際の属性名。data-attr-* でない場合は null
5387
5499
  */
5388
5500
  static getAliasedAttributeName(e) {
5389
- const t = `${c.prefix}${d.ATTRIBUTE_ALIAS_SUFFIX}`;
5501
+ const t = `${c.prefix}${h.ATTRIBUTE_ALIAS_SUFFIX}`;
5390
5502
  return !e.startsWith(t) || e.length <= t.length ? null : e.slice(t.length);
5391
5503
  }
5392
5504
  /**
@@ -5399,7 +5511,7 @@ const d = class d {
5399
5511
  static isAliasedAttributeReflection(e, t) {
5400
5512
  const r = S.get(e);
5401
5513
  return r instanceof M ? r.hasAttribute(
5402
- `${c.prefix}${d.ATTRIBUTE_ALIAS_SUFFIX}${t}`
5514
+ `${c.prefix}${h.ATTRIBUTE_ALIAS_SUFFIX}${t}`
5403
5515
  ) : !1;
5404
5516
  }
5405
5517
  /**
@@ -5413,8 +5525,8 @@ const d = class d {
5413
5525
  let t = Promise.resolve();
5414
5526
  for (const r of e.getAttributeNames()) {
5415
5527
  const i = e.getRawAttribute(r);
5416
- d.shouldReevaluateAttribute(r, i) && (t = t.then(
5417
- () => d.setAttribute(e.getTarget(), r, i)
5528
+ h.shouldReevaluateAttribute(r, i) && (t = t.then(
5529
+ () => h.setAttribute(e.getTarget(), r, i)
5418
5530
  ));
5419
5531
  }
5420
5532
  return t.then(() => {
@@ -5429,7 +5541,7 @@ const d = class d {
5429
5541
  static reevaluateChildren(e) {
5430
5542
  const t = [];
5431
5543
  return e.getChildren().forEach((r) => {
5432
- r instanceof M ? t.push(d.evaluateAll(r)) : r instanceof j && t.push(d.evaluateText(r));
5544
+ r instanceof M ? t.push(h.evaluateAll(r)) : r instanceof j && t.push(h.evaluateText(r));
5433
5545
  }), Promise.all(t).then(() => {
5434
5546
  });
5435
5547
  }
@@ -5440,7 +5552,7 @@ const d = class d {
5440
5552
  * @returns 再評価状態
5441
5553
  */
5442
5554
  static getReactiveFetchState(e) {
5443
- const t = d.REACTIVE_FETCH_STATES.get(e);
5555
+ const t = h.REACTIVE_FETCH_STATES.get(e);
5444
5556
  if (t)
5445
5557
  return t;
5446
5558
  const r = {
@@ -5448,7 +5560,7 @@ const d = class d {
5448
5560
  running: !1,
5449
5561
  rerunRequested: !1
5450
5562
  };
5451
- return d.REACTIVE_FETCH_STATES.set(e, r), r;
5563
+ return h.REACTIVE_FETCH_STATES.set(e, r), r;
5452
5564
  }
5453
5565
  /**
5454
5566
  * data-import の再評価状態を取得します。
@@ -5457,7 +5569,7 @@ const d = class d {
5457
5569
  * @returns 再評価状態
5458
5570
  */
5459
5571
  static getReactiveImportState(e) {
5460
- const t = d.REACTIVE_IMPORT_STATES.get(e);
5572
+ const t = h.REACTIVE_IMPORT_STATES.get(e);
5461
5573
  if (t)
5462
5574
  return t;
5463
5575
  const r = {
@@ -5465,7 +5577,7 @@ const d = class d {
5465
5577
  running: !1,
5466
5578
  rerunRequested: !1
5467
5579
  };
5468
- return d.REACTIVE_IMPORT_STATES.set(e, r), r;
5580
+ return h.REACTIVE_IMPORT_STATES.set(e, r), r;
5469
5581
  }
5470
5582
  /**
5471
5583
  * bind 更新時に data-fetch / data-import を専用ルートで再評価します。
@@ -5478,9 +5590,9 @@ const d = class d {
5478
5590
  if (t.has(e))
5479
5591
  return Promise.resolve();
5480
5592
  const r = [];
5481
- return e.hasAttribute(`${c.prefix}fetch`) && r.push(d.executeManagedFetch(e)), e.hasAttribute(`${c.prefix}import`) && r.push(d.executeManagedImport(e)), e.getChildren().forEach((i) => {
5593
+ return e.hasAttribute(`${c.prefix}fetch`) && r.push(h.executeManagedFetch(e)), e.hasAttribute(`${c.prefix}import`) && r.push(h.executeManagedImport(e)), e.getChildren().forEach((i) => {
5482
5594
  i instanceof M && r.push(
5483
- d.reevaluateReactiveSpecialAttributes(i, t)
5595
+ h.reevaluateReactiveSpecialAttributes(i, t)
5484
5596
  );
5485
5597
  }), Promise.all(r).then(() => {
5486
5598
  });
@@ -5492,7 +5604,7 @@ const d = class d {
5492
5604
  * @returns 実行完了の Promise
5493
5605
  */
5494
5606
  static executeManagedFetch(e) {
5495
- const t = e.getTarget(), r = d.getReactiveFetchState(t), i = q.resolveAutoFetchSignature(e);
5607
+ const t = e.getTarget(), r = h.getReactiveFetchState(t), i = q.resolveAutoFetchSignature(e);
5496
5608
  if (r.running)
5497
5609
  return (i.hasUnresolvedReference || i.signature !== r.lastSignature) && (r.rerunRequested = !0), Promise.resolve();
5498
5610
  if (i.hasUnresolvedReference || i.signature === null)
@@ -5504,7 +5616,7 @@ const d = class d {
5504
5616
  return n.markReentrantBind(), n.runWithResult().then(() => {
5505
5617
  }).finally(() => {
5506
5618
  if (r.running = !1, r.rerunRequested)
5507
- return r.rerunRequested = !1, d.executeManagedFetch(e);
5619
+ return r.rerunRequested = !1, h.executeManagedFetch(e);
5508
5620
  });
5509
5621
  }
5510
5622
  /**
@@ -5514,7 +5626,7 @@ const d = class d {
5514
5626
  * @returns 実行完了の Promise
5515
5627
  */
5516
5628
  static executeManagedImport(e) {
5517
- const t = e.getTarget(), r = d.getReactiveImportState(t), i = e.getAttributeEvaluation(
5629
+ const t = e.getTarget(), r = h.getReactiveImportState(t), i = e.getAttributeEvaluation(
5518
5630
  `${c.prefix}import`
5519
5631
  ), n = i && !i.hasUnresolvedReference && typeof i.value == "string" && i.value !== "" ? i.value : null;
5520
5632
  if (r.running)
@@ -5525,25 +5637,25 @@ const d = class d {
5525
5637
  return Promise.resolve();
5526
5638
  r.lastUrl = n, r.running = !0;
5527
5639
  const s = performance.now();
5528
- return t.setAttribute(`${c.prefix}importing`, ""), N.importStart(t, n), ot.load(n).then((a) => {
5640
+ return t.setAttribute(`${c.prefix}importing`, ""), N.importStart(t, n), dt.load(n).then((a) => {
5529
5641
  const o = new TextEncoder().encode(a).length;
5530
5642
  return I.enqueue(() => {
5531
5643
  t.innerHTML = a;
5532
5644
  }).then(() => {
5533
5645
  if (t.removeAttribute(`${c.prefix}importing`), N.importEnd(t, n, o, s), !document.body.hasAttribute("data-haori-ready")) {
5534
5646
  const l = [];
5535
- return t.childNodes.forEach((h) => {
5536
- const u = S.get(h);
5537
- u instanceof M ? l.push(d.scan(u.getTarget())) : u instanceof j && l.push(d.evaluateText(u));
5647
+ return t.childNodes.forEach((d) => {
5648
+ const u = S.get(d);
5649
+ u instanceof M ? l.push(h.scan(u.getTarget())) : u instanceof j && l.push(h.evaluateText(u));
5538
5650
  }), Promise.all(l).then(() => {
5539
5651
  });
5540
5652
  }
5541
5653
  });
5542
5654
  }).catch((a) => {
5543
- t.removeAttribute(`${c.prefix}importing`), N.importError(t, n, a), b.error("[Haori]", "Failed to import HTML:", n, a);
5655
+ t.removeAttribute(`${c.prefix}importing`), N.importError(t, n, a), p.error("[Haori]", "Failed to import HTML:", n, a);
5544
5656
  }).finally(() => {
5545
5657
  if (r.running = !1, r.rerunRequested)
5546
- return r.rerunRequested = !1, d.executeManagedImport(e);
5658
+ return r.rerunRequested = !1, h.executeManagedImport(e);
5547
5659
  });
5548
5660
  }
5549
5661
  /**
@@ -5554,7 +5666,7 @@ const d = class d {
5554
5666
  */
5555
5667
  static scan(e) {
5556
5668
  const t = S.get(e);
5557
- return t ? d.initializeElementFragment(t, !1) : Promise.resolve();
5669
+ return t ? h.initializeElementFragment(t, !1) : Promise.resolve();
5558
5670
  }
5559
5671
  /**
5560
5672
  * 新規 each 行を局所初期化します。
@@ -5564,8 +5676,8 @@ const d = class d {
5564
5676
  * @returns 初期化完了の Promise
5565
5677
  */
5566
5678
  static initializeFreshEachRow(e) {
5567
- return d.initializeElementFragment(e, !0).then(() => {
5568
- d.needsScheduledEvaluateAll(e) && d.scheduleEvaluateAll(e);
5679
+ return h.initializeElementFragment(e, !0).then(() => {
5680
+ h.needsScheduledEvaluateAll(e) && h.scheduleEvaluateAll(e);
5569
5681
  });
5570
5682
  }
5571
5683
  /**
@@ -5576,16 +5688,16 @@ const d = class d {
5576
5688
  * @returns 初期化完了の Promise
5577
5689
  */
5578
5690
  static initializeElementFragment(e, t) {
5579
- return d.syncMountedState(e), t && e.isFreshInitializationSkippable() ? Promise.resolve() : d.initializeElementAttributes(e).then(() => {
5580
- if (d.shouldSkipChildInitialization(e, t)) {
5581
- d.refreshDerivedSubtreeSignature(e);
5691
+ return h.syncMountedState(e), t && e.isFreshInitializationSkippable() ? Promise.resolve() : h.initializeElementAttributes(e).then(() => {
5692
+ if (h.shouldSkipChildInitialization(e, t)) {
5693
+ h.refreshDerivedSubtreeSignature(e);
5582
5694
  return;
5583
5695
  }
5584
5696
  const r = [];
5585
5697
  return e.getChildren().forEach((i) => {
5586
- i instanceof M ? r.push(d.initializeElementFragment(i, t)) : i instanceof j && r.push(d.evaluateText(i));
5698
+ i instanceof M ? r.push(h.initializeElementFragment(i, t)) : i instanceof j && r.push(h.evaluateText(i));
5587
5699
  }), Promise.all(r).then(() => {
5588
- d.refreshDerivedSubtreeSignature(e);
5700
+ h.refreshDerivedSubtreeSignature(e);
5589
5701
  });
5590
5702
  });
5591
5703
  }
@@ -5615,10 +5727,10 @@ const d = class d {
5615
5727
  static initializeElementAttributes(e) {
5616
5728
  let t = Promise.resolve();
5617
5729
  const r = /* @__PURE__ */ new Set();
5618
- for (const i of d.PRIORITY_ATTRIBUTE_SUFFIXES) {
5730
+ for (const i of h.PRIORITY_ATTRIBUTE_SUFFIXES) {
5619
5731
  const n = c.prefix + i;
5620
5732
  e.hasAttribute(n) && (t = t.then(
5621
- () => d.setAttribute(
5733
+ () => h.setAttribute(
5622
5734
  e.getTarget(),
5623
5735
  n,
5624
5736
  e.getRawAttribute(n)
@@ -5626,17 +5738,17 @@ const d = class d {
5626
5738
  ), r.add(n));
5627
5739
  }
5628
5740
  for (const i of e.getAttributeNames()) {
5629
- if (r.has(i) || d.isDeferredAttributeName(i))
5741
+ if (r.has(i) || h.isDeferredAttributeName(i))
5630
5742
  continue;
5631
5743
  const n = e.getRawAttribute(i);
5632
5744
  n !== null && (t = t.then(
5633
- () => d.setAttribute(e.getTarget(), i, n)
5745
+ () => h.setAttribute(e.getTarget(), i, n)
5634
5746
  ));
5635
5747
  }
5636
- for (const i of d.DEFERRED_ATTRIBUTE_SUFFIXES) {
5748
+ for (const i of h.DEFERRED_ATTRIBUTE_SUFFIXES) {
5637
5749
  const n = c.prefix + i;
5638
5750
  e.hasAttribute(n) && (t = t.then(
5639
- () => d.setAttribute(
5751
+ () => h.setAttribute(
5640
5752
  e.getTarget(),
5641
5753
  n,
5642
5754
  e.getRawAttribute(n)
@@ -5655,7 +5767,7 @@ const d = class d {
5655
5767
  */
5656
5768
  static shouldSkipChildInitialization(e, t) {
5657
5769
  const r = e.getAttribute(`${c.prefix}if`);
5658
- return e.hasAttribute(`${c.prefix}if`) && d.isHiddenIfCondition(r) ? !0 : t && e.hasAttribute(`${c.prefix}each`);
5770
+ return e.hasAttribute(`${c.prefix}if`) && h.isHiddenIfCondition(r) ? !0 : t && e.hasAttribute(`${c.prefix}each`);
5659
5771
  }
5660
5772
  /**
5661
5773
  * エレメントに属性を設定します。
@@ -5667,7 +5779,7 @@ const d = class d {
5667
5779
  * @returns Promise (DOM操作が完了したときに解決される)
5668
5780
  */
5669
5781
  static setAttribute(e, t, r, i = !1) {
5670
- const n = S.get(e), s = d.getAliasedAttributeName(t);
5782
+ const n = S.get(e), s = h.getAliasedAttributeName(t);
5671
5783
  if (s !== null)
5672
5784
  return r === null ? n.removeAliasedAttribute(t, s) : n.setAliasedAttribute(
5673
5785
  t,
@@ -5684,16 +5796,16 @@ const d = class d {
5684
5796
  else {
5685
5797
  if (i && n instanceof M && n.consumeSelfWrittenBind(r))
5686
5798
  break;
5687
- n.setBindingData(d.parseDataBind(r));
5799
+ n.setBindingData(h.parseDataBind(r));
5688
5800
  }
5689
5801
  break;
5690
5802
  }
5691
5803
  case `${c.prefix}derive`:
5692
- l = d.createDeriveInputSignature(
5804
+ l = h.createDeriveInputSignature(
5693
5805
  n,
5694
5806
  r,
5695
5807
  n.getRawAttribute(`${c.prefix}derive-name`)
5696
- ), o = d.evaluateDerive(
5808
+ ), o = h.evaluateDerive(
5697
5809
  n,
5698
5810
  r,
5699
5811
  n.getRawAttribute(`${c.prefix}derive-name`)
@@ -5701,11 +5813,11 @@ const d = class d {
5701
5813
  }));
5702
5814
  break;
5703
5815
  case `${c.prefix}derive-name`:
5704
- l = d.createDeriveInputSignature(
5816
+ l = h.createDeriveInputSignature(
5705
5817
  n,
5706
5818
  n.getRawAttribute(`${c.prefix}derive`),
5707
5819
  r
5708
- ), o = d.evaluateDerive(
5820
+ ), o = h.evaluateDerive(
5709
5821
  n,
5710
5822
  n.getRawAttribute(`${c.prefix}derive`),
5711
5823
  r
@@ -5713,33 +5825,33 @@ const d = class d {
5713
5825
  }));
5714
5826
  break;
5715
5827
  case `${c.prefix}if`:
5716
- a.push(d.evaluateIf(n));
5828
+ a.push(h.evaluateIf(n));
5717
5829
  break;
5718
5830
  case `${c.prefix}each`:
5719
- a.push(d.evaluateEach(n));
5831
+ a.push(h.evaluateEach(n));
5720
5832
  break;
5721
5833
  case `${c.prefix}fetch`:
5722
- a.push(d.executeManagedFetch(n));
5834
+ a.push(h.executeManagedFetch(n));
5723
5835
  break;
5724
5836
  case `${c.prefix}import`:
5725
- typeof r == "string" && a.push(d.executeManagedImport(n));
5837
+ typeof r == "string" && a.push(h.executeManagedImport(n));
5726
5838
  break;
5727
5839
  case `${c.prefix}url-param`: {
5728
- const h = n.getAttribute(`${c.prefix}url-arg`), u = Ue.readParams();
5729
- if (h === null)
5730
- a.push(d.setBindingData(e, u, /* @__PURE__ */ new Set(), !0));
5840
+ const d = n.getAttribute(`${c.prefix}url-arg`), u = qe.readParams();
5841
+ if (d === null)
5842
+ a.push(h.setBindingData(e, u, /* @__PURE__ */ new Set(), !0));
5731
5843
  else {
5732
5844
  const m = n.getRawBindingData() || {};
5733
- m[String(h)] = u, a.push(d.setBindingData(e, m, /* @__PURE__ */ new Set(), !0));
5845
+ m[String(d)] = u, a.push(h.setBindingData(e, m, /* @__PURE__ */ new Set(), !0));
5734
5846
  }
5735
5847
  break;
5736
5848
  }
5737
5849
  }
5738
5850
  return r === null ? a.push(n.removeAttribute(t)) : a.push(n.setAttribute(t, r, i)), Promise.all(a).then(() => {
5739
5851
  if (o !== null)
5740
- return n.setDeriveInputSignature(l), o.then((h) => {
5741
- if (h)
5742
- return d.reevaluateChildren(n);
5852
+ return n.setDeriveInputSignature(l), o.then((d) => {
5853
+ if (d)
5854
+ return h.reevaluateChildren(n);
5743
5855
  });
5744
5856
  }).then(() => {
5745
5857
  });
@@ -5768,14 +5880,14 @@ const d = class d {
5768
5880
  const o = () => {
5769
5881
  s.markBindingWorkStart();
5770
5882
  const l = s.getRawBindingData() ?? t;
5771
- let h = n ? s.setAttribute(`${c.prefix}bind`, JSON.stringify(l)) : Promise.resolve();
5883
+ let d = n ? s.setAttribute(`${c.prefix}bind`, JSON.stringify(l)) : Promise.resolve();
5772
5884
  if (e.tagName === "FORM") {
5773
5885
  const u = s.getAttribute(`${c.prefix}form-arg`), m = u && l[String(u)] && typeof l[String(u)] == "object" && !Array.isArray(l[String(u)]) ? l[String(u)] : u ? {} : l;
5774
- h = h.then(() => A.syncValues(s, m));
5886
+ d = d.then(() => A.syncValues(s, m));
5775
5887
  }
5776
- return h = h.then(() => d.evaluateAll(s, r)), h = h.then(
5777
- () => d.reevaluateReactiveSpecialAttributes(s, r)
5778
- ), h.then(
5888
+ return d = d.then(() => h.evaluateAll(s, r)), d = d.then(
5889
+ () => h.reevaluateReactiveSpecialAttributes(s, r)
5890
+ ), d.then(
5779
5891
  () => s.markBindingWorkEnd(),
5780
5892
  (u) => {
5781
5893
  throw s.markBindingWorkEnd(), u;
@@ -5825,14 +5937,14 @@ const d = class d {
5825
5937
  if (!t)
5826
5938
  return { resolved: {}, sources: {} };
5827
5939
  const r = t.getBindingData(), i = {}, n = (l) => {
5828
- const h = l.getTarget();
5829
- return h.id ? `#${h.id}` : h.tagName.toLowerCase();
5830
- }, s = (l, h, u, m) => {
5940
+ const d = l.getTarget();
5941
+ return d.id ? `#${d.id}` : d.tagName.toLowerCase();
5942
+ }, s = (l, d, u, m) => {
5831
5943
  if (l)
5832
- for (const v of Object.keys(l))
5833
- v in i || (i[v] = {
5834
- value: l[v],
5835
- source: n(h),
5944
+ for (const y of Object.keys(l))
5945
+ y in i || (i[y] = {
5946
+ value: l[y],
5947
+ source: n(d),
5836
5948
  kind: u,
5837
5949
  depth: m
5838
5950
  });
@@ -5840,7 +5952,7 @@ const d = class d {
5840
5952
  let a = t, o = 0;
5841
5953
  for (; a; )
5842
5954
  a !== t && s(a.getRawDerivedBindingData(), a, "derive", o), s(a.getRawBindingData(), a, "bind", o), a = a.getParent(), o += 1;
5843
- return L.isEnabled() && b.info("[Haori]", "scope dump for", e, { resolved: r, sources: i }), { resolved: r, sources: i };
5955
+ return L.isEnabled() && p.info("[Haori]", "scope dump for", e, { resolved: r, sources: i }), { resolved: r, sources: i };
5844
5956
  }
5845
5957
  /**
5846
5958
  * data-bind 属性の値をパースします。
@@ -5853,7 +5965,7 @@ const d = class d {
5853
5965
  try {
5854
5966
  return JSON.parse(e);
5855
5967
  } catch (t) {
5856
- return b.error("[Haori]", "Invalid JSON in data-bind:", t), {};
5968
+ return p.error("[Haori]", "Invalid JSON in data-bind:", t), {};
5857
5969
  }
5858
5970
  else {
5859
5971
  const t = new URLSearchParams(e), r = {};
@@ -5873,7 +5985,7 @@ const d = class d {
5873
5985
  if (r.isSkipMutationNodes())
5874
5986
  return;
5875
5987
  const i = S.get(t.nextSibling), n = S.get(t);
5876
- n && (r.insertBefore(n, i), n instanceof M ? d.scan(n.getTarget()) : n instanceof j && d.evaluateText(n));
5988
+ n && (r.insertBefore(n, i), n instanceof M ? h.scan(n.getTarget()) : n instanceof j && h.evaluateText(n));
5877
5989
  }
5878
5990
  /**
5879
5991
  * ノードを親要素から削除します。
@@ -5913,11 +6025,11 @@ const d = class d {
5913
6025
  return Promise.resolve();
5914
6026
  const i = [];
5915
6027
  i.push(r.setValue(t));
5916
- const n = d.getFormFragment(r);
6028
+ const n = h.getFormFragment(r);
5917
6029
  if (n) {
5918
6030
  const s = A.getValues(n), a = n.getAttribute(`${c.prefix}form-arg`);
5919
6031
  let o;
5920
- a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(d.setBindingData(n.getTarget(), o));
6032
+ a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(h.setBindingData(n.getTarget(), o));
5921
6033
  }
5922
6034
  return Promise.all(i).then(() => {
5923
6035
  });
@@ -5932,7 +6044,7 @@ const d = class d {
5932
6044
  if (e.getTarget() instanceof HTMLFormElement)
5933
6045
  return e;
5934
6046
  const t = e.getParent();
5935
- return t ? d.getFormFragment(t) : null;
6047
+ return t ? h.getFormFragment(t) : null;
5936
6048
  }
5937
6049
  /**
5938
6050
  * フラグメントとその子要素を評価します。
@@ -5943,21 +6055,21 @@ const d = class d {
5943
6055
  static evaluateAll(e, t = /* @__PURE__ */ new Set()) {
5944
6056
  if (t.has(e))
5945
6057
  return Promise.resolve();
5946
- let r = d.reevaluateInterpolatedAttributes(e);
6058
+ let r = h.reevaluateInterpolatedAttributes(e);
5947
6059
  const i = e.hasAttribute(`${c.prefix}derive`), n = e.hasAttribute(`${c.prefix}if`), s = e.hasAttribute(`${c.prefix}each`), a = e.getRawAttribute(`${c.prefix}derive`), o = e.getRawAttribute(`${c.prefix}derive-name`);
5948
- let l = !1, h = !1, u = null;
6060
+ let l = !1, d = !1, u = null;
5949
6061
  if (!i && e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), !i && e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), i) {
5950
- const m = d.createDeriveInputSignature(
6062
+ const m = h.createDeriveInputSignature(
5951
6063
  e,
5952
6064
  a,
5953
6065
  o
5954
6066
  );
5955
6067
  m === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
5956
- () => d.evaluateDerive(e, a, o).then(
6068
+ () => h.evaluateDerive(e, a, o).then(
5957
6069
  () => {
5958
6070
  }
5959
6071
  )
5960
- )) : e.getDeriveInputSignature() !== m && (r = r.then(() => d.evaluateDerive(
6072
+ )) : e.getDeriveInputSignature() !== m && (r = r.then(() => h.evaluateDerive(
5961
6073
  e,
5962
6074
  a,
5963
6075
  o
@@ -5965,16 +6077,16 @@ const d = class d {
5965
6077
  e.setDeriveInputSignature(m);
5966
6078
  })));
5967
6079
  }
5968
- return n && (r = r.then(() => d.evaluateIf(e))), s ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => d.evaluateEach(e))) : n ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => {
6080
+ return n && (r = r.then(() => h.evaluateIf(e))), s ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => h.evaluateEach(e))) : n ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => {
5969
6081
  })) : (i && (r = r.then(() => {
5970
- if (!d.canSkipStableDerivedSubtree(e)) {
5971
- e.setDeriveSubtreeSignature(null), d.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
6082
+ if (!h.canSkipStableDerivedSubtree(e)) {
6083
+ e.setDeriveSubtreeSignature(null), h.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
5972
6084
  return;
5973
6085
  }
5974
- u = d.createDescendantBindingSignature(
6086
+ u = h.createDescendantBindingSignature(
5975
6087
  e,
5976
6088
  "evaluateAll"
5977
- ), h = !0, l = e.getDeriveSubtreeSignature() !== null && e.getDeriveSubtreeSignature() === u, d.logDerivedSubtreeProfileSnapshot(
6089
+ ), d = !0, l = e.getDeriveSubtreeSignature() !== null && e.getDeriveSubtreeSignature() === u, h.logDerivedSubtreeProfileSnapshot(
5978
6090
  e,
5979
6091
  l ? "skip-hit" : "skip-miss"
5980
6092
  );
@@ -5982,16 +6094,16 @@ const d = class d {
5982
6094
  if (l)
5983
6095
  return;
5984
6096
  const m = [];
5985
- return e.getChildren().forEach((v) => {
5986
- if (v instanceof M) {
5987
- if (d.canSkipUnchangedNestedEach(v))
6097
+ return e.getChildren().forEach((y) => {
6098
+ if (y instanceof M) {
6099
+ if (h.canSkipUnchangedNestedEach(y))
5988
6100
  return;
5989
- m.push(d.evaluateAll(v, t));
5990
- } else v instanceof j && m.push(d.evaluateText(v));
6101
+ m.push(h.evaluateAll(y, t));
6102
+ } else y instanceof j && m.push(h.evaluateText(y));
5991
6103
  }), Promise.all(m).then(() => {
5992
6104
  });
5993
6105
  }).then(() => {
5994
- h && u !== null && e.setDeriveSubtreeSignature(u);
6106
+ d && u !== null && e.setDeriveSubtreeSignature(u);
5995
6107
  }));
5996
6108
  }
5997
6109
  /**
@@ -6019,7 +6131,7 @@ const d = class d {
6019
6131
  const a = {
6020
6132
  [n]: s.value
6021
6133
  };
6022
- return d.createBindingSignature(i) === d.createBindingSignature(a) ? Promise.resolve(!1) : (e.setDerivedBindingData(a), Promise.resolve(!0));
6134
+ return h.createBindingSignature(i) === h.createBindingSignature(a) ? Promise.resolve(!1) : (e.setDerivedBindingData(a), Promise.resolve(!0));
6023
6135
  }
6024
6136
  /**
6025
6137
  * テキストフラグメントを評価します。
@@ -6057,7 +6169,7 @@ const d = class d {
6057
6169
  const t = e.getRawAttribute(`${c.prefix}if`);
6058
6170
  if (typeof t != "string" || t.indexOf("{{") >= 0)
6059
6171
  return;
6060
- const { sources: r } = d.dumpScope(e.getTarget()), i = /* @__PURE__ */ new Set(), n = t.match(/[A-Za-z_$][\w$]*/g) ?? [];
6172
+ const { sources: r } = h.dumpScope(e.getTarget()), i = /* @__PURE__ */ new Set(), n = t.match(/[A-Za-z_$][\w$]*/g) ?? [];
6061
6173
  let s = 0;
6062
6174
  n.forEach((o) => {
6063
6175
  const l = t.indexOf(o, s);
@@ -6066,7 +6178,7 @@ const d = class d {
6066
6178
  const a = {};
6067
6179
  i.forEach((o) => {
6068
6180
  o in r && (a[o] = r[o]);
6069
- }), b.info(
6181
+ }), p.info(
6070
6182
  "[Haori]",
6071
6183
  "data-if is falsy (hidden):",
6072
6184
  t,
@@ -6084,8 +6196,8 @@ const d = class d {
6084
6196
  */
6085
6197
  static evaluateIf(e) {
6086
6198
  const t = [], r = e.getAttribute(`${c.prefix}if`);
6087
- if (d.isHiddenIfCondition(r))
6088
- L.isEnabled() && d.logFalsyIfDiagnostics(e), t.push(
6199
+ if (h.isHiddenIfCondition(r))
6200
+ L.isEnabled() && h.logFalsyIfDiagnostics(e), t.push(
6089
6201
  e.hide().then(() => {
6090
6202
  N.hide(e.getTarget());
6091
6203
  })
@@ -6094,11 +6206,11 @@ const d = class d {
6094
6206
  const i = e.isVisible(), n = [];
6095
6207
  e.getChildren().forEach((s) => {
6096
6208
  s instanceof M ? n.push(
6097
- s.isMounted() ? d.evaluateAll(s) : d.scan(s.getTarget())
6098
- ) : s instanceof j && n.push(d.evaluateText(s));
6209
+ s.isMounted() ? h.evaluateAll(s) : h.scan(s.getTarget())
6210
+ ) : s instanceof j && n.push(h.evaluateText(s));
6099
6211
  }), t.push(
6100
6212
  e.show().then(() => {
6101
- N.show(e.getTarget()), i || d.triggerLoadOnShow(e);
6213
+ N.show(e.getTarget()), i || h.triggerLoadOnShow(e);
6102
6214
  })
6103
6215
  ), t.push(Promise.all(n).then(() => {
6104
6216
  }));
@@ -6118,7 +6230,7 @@ const d = class d {
6118
6230
  static triggerLoadOnShow(e) {
6119
6231
  const t = `${c.prefix}load-`;
6120
6232
  e.getTarget().getAttributeNames().some((i) => i.startsWith(t)) && new q(e, "load").run().catch((i) => {
6121
- b.error("[Haori]", "data-load procedure error (on show):", i);
6233
+ p.error("[Haori]", "data-load procedure error (on show):", i);
6122
6234
  });
6123
6235
  }
6124
6236
  /**
@@ -6128,8 +6240,8 @@ const d = class d {
6128
6240
  * @return 再入制御状態
6129
6241
  */
6130
6242
  static getEachUpdateState(e) {
6131
- let t = d.EACH_UPDATE_STATES.get(e);
6132
- return t || (t = { running: !1, rerunRequested: !1, settled: null }, d.EACH_UPDATE_STATES.set(e, t)), t;
6243
+ let t = h.EACH_UPDATE_STATES.get(e);
6244
+ return t || (t = { running: !1, rerunRequested: !1, settled: null }, h.EACH_UPDATE_STATES.set(e, t)), t;
6133
6245
  }
6134
6246
  /**
6135
6247
  * each要素を評価します。
@@ -6147,8 +6259,8 @@ const d = class d {
6147
6259
  static evaluateEach(e) {
6148
6260
  if (!e.isVisible() || !e.isMounted())
6149
6261
  return Promise.resolve();
6150
- const t = d.getEachUpdateState(e);
6151
- return t.running ? (t.rerunRequested = !0, t.settled ?? Promise.resolve()) : d.runEachUpdateLoop(e, t);
6262
+ const t = h.getEachUpdateState(e);
6263
+ return t.running ? (t.rerunRequested = !0, t.settled ?? Promise.resolve()) : h.runEachUpdateLoop(e, t);
6152
6264
  }
6153
6265
  /**
6154
6266
  * data-each の差分更新を、再評価要求が無くなるまで直列に繰り返し実行します。
@@ -6164,13 +6276,14 @@ const d = class d {
6164
6276
  const r = (async () => {
6165
6277
  try {
6166
6278
  do
6167
- t.rerunRequested = !1, await d.performEachUpdate(e);
6279
+ t.rerunRequested = !1, await h.performEachUpdate(e);
6168
6280
  while (t.rerunRequested);
6169
6281
  const i = e.getTarget();
6170
- i.setAttribute(`${c.prefix}each-done`, ""), d.runEachRenderedScript(i);
6282
+ i.setAttribute(`${c.prefix}each-done`, ""), h.runEachRenderedScript(i);
6171
6283
  } finally {
6172
6284
  t.running = !1, t.settled = null;
6173
6285
  }
6286
+ h.runEachRenderedChange(e);
6174
6287
  })();
6175
6288
  return t.settled = r, r;
6176
6289
  }
@@ -6202,16 +6315,76 @@ ${r}
6202
6315
  ${r}
6203
6316
  `);
6204
6317
  } catch (n) {
6205
- b.error("Haori", `Invalid each-rendered-run script: ${n}`);
6318
+ p.error("[Haori]", `Invalid each-rendered-run script: ${n}`);
6206
6319
  }
6207
6320
  }
6208
6321
  if (i)
6209
6322
  try {
6210
6323
  i.call(e);
6211
6324
  } catch (n) {
6212
- b.error("Haori", `each-rendered-run execution error: ${n}`);
6325
+ p.error("[Haori]", `each-rendered-run execution error: ${n}`);
6213
6326
  }
6214
6327
  }
6328
+ /**
6329
+ * data-each-rendered-change 属性に従い、描画確定後に対象要素へ `change`
6330
+ * イベント(バブリングあり)を発火します。
6331
+ *
6332
+ * API から取得した候補を `data-each` で流し込んだ `<select>` について、
6333
+ * 「既定選択を確定して初期データを取得する」パターンをインライン JS なしで
6334
+ * 宣言できるようにするための属性です。`<select>` はブラウザが先頭 option を
6335
+ * 自動選択するため、描画確定後の `change` がそのまま既定選択の確定になります。
6336
+ *
6337
+ * 描画行が 0 件のときは発火しません(確定すべき既定値が存在しないため)。
6338
+ * この場合は初回発火の判定も消費しないため、行が入った最初の描画で発火します。
6339
+ *
6340
+ * 属性値による動作の違い:
6341
+ * - 省略または `once`: 行が 1 件以上ある最初の描画確定時のみ発火する(既定)。
6342
+ * - `always`: 描画確定ごとに毎回発火する。
6343
+ *
6344
+ * 既定を `once` にしているのは、`change` の手続きが `data-each` の取得元を
6345
+ * 再バインドする構成(候補取得 → 選択確定 → 明細取得 → 再描画)で、毎回発火
6346
+ * させると再帰的な発火ループになり得るためです。
6347
+ *
6348
+ * @param fragment data-each コンテナのフラグメント
6349
+ */
6350
+ static runEachRenderedChange(e) {
6351
+ const t = `${c.prefix}each-rendered-change`, r = e.getTarget();
6352
+ if (!r.hasAttribute(t))
6353
+ return;
6354
+ const i = String(r.getAttribute(t) ?? "").trim().toLowerCase();
6355
+ let n = !1;
6356
+ if (i === "always" ? n = !0 : i !== "" && i !== "once" && (h.EACH_RENDERED_CHANGE_WARNED.has(r) || (h.EACH_RENDERED_CHANGE_WARNED.add(r), p.warn(
6357
+ "[Haori]",
6358
+ `Invalid ${t} value: "${i}". Use "once" (default) or "always".`
6359
+ ))), h.countEachRenderedRows(e) !== 0) {
6360
+ if (!n) {
6361
+ if (h.EACH_RENDERED_CHANGE_FIRED.has(r))
6362
+ return;
6363
+ h.EACH_RENDERED_CHANGE_FIRED.add(r);
6364
+ }
6365
+ try {
6366
+ r.dispatchEvent(new Event("change", { bubbles: !0 }));
6367
+ } catch (s) {
6368
+ p.error("[Haori]", `each-rendered-change dispatch error: ${s}`);
6369
+ }
6370
+ }
6371
+ }
6372
+ /**
6373
+ * data-each コンテナに描画されている行数を返します。
6374
+ *
6375
+ * 行は差分更新で `data-row` 属性が付与されるため、それを数えます。
6376
+ * `data-each-before` / `data-each-after` の固定要素や、テンプレート以外の
6377
+ * 静的な子要素(`data-each-before` の付け忘れを含む)は行数に含めません。
6378
+ *
6379
+ * @param fragment data-each コンテナのフラグメント
6380
+ * @returns 描画済みの行数
6381
+ */
6382
+ static countEachRenderedRows(e) {
6383
+ let t = 0;
6384
+ for (const r of e.getChildElementFragments())
6385
+ r.getTarget().hasAttribute(`${c.prefix}row`) && (t += 1);
6386
+ return t;
6387
+ }
6215
6388
  /**
6216
6389
  * data-each の差分更新本体を実行します(再入制御は呼び出し側で行います)。
6217
6390
  *
@@ -6219,11 +6392,11 @@ ${r}
6219
6392
  * @return 差分更新完了の Promise
6220
6393
  */
6221
6394
  static performEachUpdate(e) {
6222
- const t = d.resolveEachItems(e);
6395
+ const t = h.resolveEachItems(e);
6223
6396
  if (t === null)
6224
6397
  return Promise.reject(new Error("Invalid each attribute."));
6225
6398
  let r = e.getTemplate();
6226
- const i = e.getAttribute(`${c.prefix}each-key`), n = d.createBindingSignature({
6399
+ const i = e.getAttribute(`${c.prefix}each-key`), n = h.createBindingSignature({
6227
6400
  key: i ? String(i) : null,
6228
6401
  items: t
6229
6402
  });
@@ -6233,7 +6406,7 @@ ${r}
6233
6406
  if (!s && a instanceof M) {
6234
6407
  if (a.hasAttribute(`${c.prefix}each-before`) || a.hasAttribute(`${c.prefix}each-after`))
6235
6408
  return;
6236
- r = a.clone(), d.markFreshInitializationSkippable(r), e.setTemplate(r), s = !0, e.removeChild(a);
6409
+ r = a.clone(), h.markFreshInitializationSkippable(r), e.setTemplate(r), s = !0, e.removeChild(a);
6237
6410
  const o = a.getTarget();
6238
6411
  o.parentNode && o.parentNode.removeChild(o), a.setMounted(!1);
6239
6412
  }
@@ -6244,10 +6417,10 @@ ${r}
6244
6417
  ).forEach((l) => {
6245
6418
  if (!s) {
6246
6419
  const u = S.get(l);
6247
- u instanceof M && (r = u.clone(), d.markFreshInitializationSkippable(r), e.setTemplate(r), s = !0);
6420
+ u instanceof M && (r = u.clone(), h.markFreshInitializationSkippable(r), e.setTemplate(r), s = !0);
6248
6421
  }
6249
- const h = S.get(l);
6250
- h instanceof M && e.getChildren().includes(h) && (e.removeChild(h), h.setMounted(!1)), l.parentNode && l.parentNode.removeChild(l);
6422
+ const d = S.get(l);
6423
+ d instanceof M && e.getChildren().includes(d) && (e.removeChild(d), d.setMounted(!1)), l.parentNode && l.parentNode.removeChild(l);
6251
6424
  });
6252
6425
  }
6253
6426
  return this.updateDiff(e, t).then(() => {
@@ -6266,7 +6439,7 @@ ${r}
6266
6439
  */
6267
6440
  static resolveEachItems(e) {
6268
6441
  const t = e.getAttributeEvaluation(`${c.prefix}each`), r = t?.value;
6269
- return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (b.error("[Haori]", "Invalid each attribute:", r), null);
6442
+ return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (p.error("[Haori]", "Invalid each attribute:", r), null);
6270
6443
  }
6271
6444
  /**
6272
6445
  * nested data-each の入力が同値で、要素自身に他の動的要素が無い場合は
@@ -6279,12 +6452,12 @@ ${r}
6279
6452
  if (!e.hasAttribute(`${c.prefix}each`) || e.getEachInputSignature() === null)
6280
6453
  return !1;
6281
6454
  const t = e.getParent();
6282
- if (t?.closestByAttribute(`${c.prefix}derive`) || t?.closestByAttribute(`${c.prefix}derive-name`) || t?.closestByAttribute(`${c.prefix}if`) || t?.closestByAttribute(`${c.prefix}fetch`) || t?.closestByAttribute(`${c.prefix}import`) || d.hasNonEachDynamicElementState(e))
6455
+ if (t?.closestByAttribute(`${c.prefix}derive`) || t?.closestByAttribute(`${c.prefix}derive-name`) || t?.closestByAttribute(`${c.prefix}if`) || t?.closestByAttribute(`${c.prefix}fetch`) || t?.closestByAttribute(`${c.prefix}import`) || h.hasNonEachDynamicElementState(e))
6283
6456
  return !1;
6284
- const r = d.resolveEachItems(e);
6457
+ const r = h.resolveEachItems(e);
6285
6458
  if (r === null)
6286
6459
  return !1;
6287
- const i = e.getAttribute(`${c.prefix}each-key`), n = d.createBindingSignature({
6460
+ const i = e.getAttribute(`${c.prefix}each-key`), n = h.createBindingSignature({
6288
6461
  key: i ? String(i) : null,
6289
6462
  items: r
6290
6463
  });
@@ -6298,7 +6471,7 @@ ${r}
6298
6471
  * @returns 省略可能なら true
6299
6472
  */
6300
6473
  static canSkipStableDerivedSubtree(e) {
6301
- return !e.hasAttribute(`${c.prefix}derive`) || e.hasAttribute(`${c.prefix}if`) || e.hasAttribute(`${c.prefix}each`) || e.hasAttribute(`${c.prefix}fetch`) || e.hasAttribute(`${c.prefix}import`) ? !1 : !d.hasDisallowedDerivedSubtreeDescendant(e);
6474
+ return !e.hasAttribute(`${c.prefix}derive`) || e.hasAttribute(`${c.prefix}if`) || e.hasAttribute(`${c.prefix}each`) || e.hasAttribute(`${c.prefix}fetch`) || e.hasAttribute(`${c.prefix}import`) ? !1 : !h.hasDisallowedDerivedSubtreeDescendant(e);
6302
6475
  }
6303
6476
  /**
6304
6477
  * data-derive subtree skip の初期 PoC で扱わない子孫要素を含むかを返します。
@@ -6307,7 +6480,7 @@ ${r}
6307
6480
  * @returns 含むなら true
6308
6481
  */
6309
6482
  static hasDisallowedDerivedSubtreeDescendant(e) {
6310
- return e.getChildren().some((t) => t instanceof M ? t.hasAttribute(`${c.prefix}derive`) || t.hasAttribute(`${c.prefix}derive-name`) || t.hasAttribute(`${c.prefix}fetch`) || t.hasAttribute(`${c.prefix}import`) ? !0 : d.hasDisallowedDerivedSubtreeDescendant(t) : !1);
6483
+ return e.getChildren().some((t) => t instanceof M ? t.hasAttribute(`${c.prefix}derive`) || t.hasAttribute(`${c.prefix}derive-name`) || t.hasAttribute(`${c.prefix}fetch`) || t.hasAttribute(`${c.prefix}import`) ? !0 : h.hasDisallowedDerivedSubtreeDescendant(t) : !1);
6311
6484
  }
6312
6485
  /**
6313
6486
  * data-derive host が子孫要素へ公開している binding の署名を返します。
@@ -6316,7 +6489,7 @@ ${r}
6316
6489
  * @returns binding 署名
6317
6490
  */
6318
6491
  static createDescendantBindingSignature(e, t) {
6319
- return d.recordDerivedSubtreeSignatureComputation(e, t), d.createBindingSignature(e.getDescendantBindingData());
6492
+ return h.recordDerivedSubtreeSignatureComputation(e, t), h.createBindingSignature(e.getDescendantBindingData());
6320
6493
  }
6321
6494
  /**
6322
6495
  * data-derive 実行前の入力署名を返します。
@@ -6328,7 +6501,7 @@ ${r}
6328
6501
  */
6329
6502
  static createDeriveInputSignature(e, t, r) {
6330
6503
  const i = typeof r == "string" ? r.trim() : "";
6331
- return !t || i === "" ? null : d.createBindingSignature({
6504
+ return !t || i === "" ? null : h.createBindingSignature({
6332
6505
  expression: t,
6333
6506
  name: i,
6334
6507
  scope: e.getBindingData()
@@ -6340,13 +6513,13 @@ ${r}
6340
6513
  * @param fragment 対象フラグメント
6341
6514
  */
6342
6515
  static refreshDerivedSubtreeSignature(e) {
6343
- if (!d.canSkipStableDerivedSubtree(e)) {
6344
- e.setDeriveSubtreeSignature(null), d.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
6516
+ if (!h.canSkipStableDerivedSubtree(e)) {
6517
+ e.setDeriveSubtreeSignature(null), h.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
6345
6518
  return;
6346
6519
  }
6347
6520
  e.setDeriveSubtreeSignature(
6348
- d.createDescendantBindingSignature(e, "refresh")
6349
- ), d.logDerivedSubtreeProfileSnapshot(e, "refresh");
6521
+ h.createDescendantBindingSignature(e, "refresh")
6522
+ ), h.logDerivedSubtreeProfileSnapshot(e, "refresh");
6350
6523
  }
6351
6524
  /**
6352
6525
  * data-derive subtree skip のプロファイルを取得または初期化します。
@@ -6357,11 +6530,11 @@ ${r}
6357
6530
  static getOrCreateDerivedSubtreeProfile(e) {
6358
6531
  if (!L.isEnabled() || !e.hasAttribute(`${c.prefix}derive`))
6359
6532
  return null;
6360
- const t = d.DERIVE_SUBTREE_PROFILES.get(e);
6533
+ const t = h.DERIVE_SUBTREE_PROFILES.get(e);
6361
6534
  if (t)
6362
6535
  return t;
6363
6536
  const r = {
6364
- hostId: d.createDerivedSubtreeHostId(e),
6537
+ hostId: h.createDerivedSubtreeHostId(e),
6365
6538
  signatureComputeTotal: 0,
6366
6539
  signatureComputeFromEvaluateAll: 0,
6367
6540
  signatureComputeFromRefresh: 0,
@@ -6369,7 +6542,7 @@ ${r}
6369
6542
  skipMissCount: 0,
6370
6543
  skipIneligibleCount: 0
6371
6544
  };
6372
- return d.DERIVE_SUBTREE_PROFILES.set(e, r), r;
6545
+ return h.DERIVE_SUBTREE_PROFILES.set(e, r), r;
6373
6546
  }
6374
6547
  /**
6375
6548
  * data-derive subtree host の識別子を作成します。
@@ -6407,7 +6580,7 @@ ${r}
6407
6580
  * @param source 計算元
6408
6581
  */
6409
6582
  static recordDerivedSubtreeSignatureComputation(e, t) {
6410
- const r = d.getOrCreateDerivedSubtreeProfile(e);
6583
+ const r = h.getOrCreateDerivedSubtreeProfile(e);
6411
6584
  if (r !== null) {
6412
6585
  if (r.signatureComputeTotal += 1, t === "refresh") {
6413
6586
  r.signatureComputeFromRefresh += 1;
@@ -6423,8 +6596,8 @@ ${r}
6423
6596
  * @param reason ログ理由
6424
6597
  */
6425
6598
  static logDerivedSubtreeProfileSnapshot(e, t) {
6426
- const r = d.getOrCreateDerivedSubtreeProfile(e);
6427
- r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1), b.info("[Haori][derive-profile]", {
6599
+ const r = h.getOrCreateDerivedSubtreeProfile(e);
6600
+ r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1), p.info("[Haori][derive-profile]", {
6428
6601
  reason: t,
6429
6602
  hostId: r.hostId,
6430
6603
  signatureComputeTotal: r.signatureComputeTotal,
@@ -6466,7 +6639,7 @@ ${r}
6466
6639
  * @returns subtree 全体を省略可能なら true
6467
6640
  */
6468
6641
  static markFreshInitializationSkippable(e) {
6469
- const t = e.getAttributeNames().some((n) => d.isFreshInitializationDynamicAttribute(e, n)), r = e.getChildren().some((n) => n instanceof M ? !d.markFreshInitializationSkippable(n) : n instanceof j ? n.hasDynamicContent() : !1), i = !t && !r;
6642
+ const t = e.getAttributeNames().some((n) => h.isFreshInitializationDynamicAttribute(e, n)), r = e.getChildren().some((n) => n instanceof M ? !h.markFreshInitializationSkippable(n) : n instanceof j ? n.hasDynamicContent() : !1), i = !t && !r;
6470
6643
  return e.setFreshInitializationSkippable(i), i;
6471
6644
  }
6472
6645
  /**
@@ -6491,85 +6664,85 @@ ${r}
6491
6664
  static updateDiff(e, t) {
6492
6665
  const r = e.getTemplate();
6493
6666
  if (r === null)
6494
- return b.error("[Haori]", "Template is not set for each element."), Promise.resolve();
6667
+ return p.error("[Haori]", "Template is not set for each element."), Promise.resolve();
6495
6668
  let i = e.getAttribute(`${c.prefix}each-index`);
6496
6669
  i && (i = String(i));
6497
6670
  const n = e.getAttribute(`${c.prefix}each-key`), s = e.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
6498
- t.forEach((p, y) => {
6499
- const R = d.createListKey(
6500
- p,
6671
+ t.forEach((b, v) => {
6672
+ const R = h.createListKey(
6673
+ b,
6501
6674
  n ? String(n) : null,
6502
- y
6675
+ v
6503
6676
  );
6504
- o.push(R), a.set(R, { item: p, itemIndex: y });
6677
+ o.push(R), a.set(R, { item: b, itemIndex: v });
6505
6678
  });
6506
- const l = new Set(o), h = [];
6507
- let u = e.getChildren().filter((p) => p instanceof M).filter(
6508
- (p) => !p.hasAttribute(`${c.prefix}each-before`) && !p.hasAttribute(`${c.prefix}each-after`)
6679
+ const l = new Set(o), d = [];
6680
+ let u = e.getChildren().filter((b) => b instanceof M).filter(
6681
+ (b) => !b.hasAttribute(`${c.prefix}each-before`) && !b.hasAttribute(`${c.prefix}each-after`)
6509
6682
  );
6510
- const m = u.map((p) => p.getListKey());
6511
- u = u.filter((p) => l.has(String(p.getListKey())) ? !0 : (h.push(p.remove()), !1));
6512
- const v = u.map((p) => p.getListKey()), T = /* @__PURE__ */ new Map();
6513
- u.forEach((p) => {
6514
- const y = p.getListKey();
6515
- y !== null && !T.has(y) && T.set(y, p);
6683
+ const m = u.map((b) => b.getListKey());
6684
+ u = u.filter((b) => l.has(String(b.getListKey())) ? !0 : (d.push(b.remove()), !1));
6685
+ const y = u.map((b) => b.getListKey()), T = /* @__PURE__ */ new Map();
6686
+ u.forEach((b) => {
6687
+ const v = b.getListKey();
6688
+ v !== null && !T.has(v) && T.set(v, b);
6516
6689
  });
6517
- const C = e.getChildElementFragments().slice(), O = C.filter(
6518
- (p) => p.hasAttribute(`${c.prefix}each-before`)
6690
+ const k = e.getChildElementFragments().slice(), H = k.filter(
6691
+ (b) => b.hasAttribute(`${c.prefix}each-before`)
6519
6692
  ).length;
6520
6693
  let E = Promise.resolve();
6521
- return o.forEach((p, y) => {
6522
- const { item: R, itemIndex: P } = a.get(p);
6694
+ return o.forEach((b, v) => {
6695
+ const { item: R, itemIndex: C } = a.get(b);
6523
6696
  let F;
6524
- const U = T.get(p);
6697
+ const U = T.get(b);
6525
6698
  if (U)
6526
6699
  F = U, E = E.then(
6527
- () => d.updateRowFragment(
6700
+ () => h.updateRowFragment(
6528
6701
  F,
6529
6702
  R,
6530
6703
  i,
6531
- P,
6704
+ C,
6532
6705
  s ? String(s) : null,
6533
- p
6706
+ b
6534
6707
  ).then(($) => {
6535
6708
  if ($)
6536
- return d.evaluateAll(F);
6709
+ return h.evaluateAll(F);
6537
6710
  })
6538
6711
  );
6539
6712
  else {
6540
6713
  F = r.clone();
6541
- const $ = O + y;
6714
+ const $ = H + v;
6542
6715
  E = E.then(
6543
- () => d.updateRowFragment(
6716
+ () => h.updateRowFragment(
6544
6717
  F,
6545
6718
  R,
6546
6719
  i,
6547
- P,
6720
+ C,
6548
6721
  s ? String(s) : null,
6549
- p
6722
+ b
6550
6723
  ).then(() => {
6551
- const W = C[$] ?? null;
6724
+ const W = k[$] ?? null;
6552
6725
  return e.insertBefore(F, W).then(() => {
6553
- C.splice($, 0, F);
6554
- }).then(() => d.initializeFreshEachRow(F));
6726
+ k.splice($, 0, F);
6727
+ }).then(() => h.initializeFreshEachRow(F));
6555
6728
  })
6556
6729
  );
6557
6730
  }
6558
- }), Promise.all(h).then(() => E).then(() => {
6559
- const p = o.filter(
6731
+ }), Promise.all(d).then(() => E).then(() => {
6732
+ const b = o.filter(
6560
6733
  ($) => $ !== null
6561
- ), y = v.filter(
6734
+ ), v = y.filter(
6562
6735
  ($) => $ !== null
6563
- ), R = new Set(y), P = p.filter(($) => !R.has($)), U = m.filter(
6736
+ ), R = new Set(v), C = b.filter(($) => !R.has($)), U = m.filter(
6564
6737
  ($) => $ !== null
6565
6738
  ).filter(
6566
6739
  ($) => !l.has($)
6567
6740
  );
6568
6741
  N.eachUpdate(
6569
6742
  e.getTarget(),
6570
- P,
6743
+ C,
6571
6744
  U,
6572
- p
6745
+ b
6573
6746
  );
6574
6747
  });
6575
6748
  }
@@ -6615,11 +6788,11 @@ ${r}
6615
6788
  [n]: t
6616
6789
  }, r && (a[r] = i);
6617
6790
  else
6618
- return b.error(
6791
+ return p.error(
6619
6792
  "[Haori]",
6620
6793
  `Primitive value requires '${c.prefix}each-arg' attribute: ${t}`
6621
6794
  ), Promise.resolve(!1);
6622
- const o = a, l = d.createBindingSignature({
6795
+ const o = a, l = h.createBindingSignature({
6623
6796
  listKey: s,
6624
6797
  bindingData: o
6625
6798
  });
@@ -6637,7 +6810,7 @@ ${r}
6637
6810
  const r = t.pop();
6638
6811
  if (r.getChildElementFragments().forEach((i) => {
6639
6812
  t.push(i);
6640
- }), r !== e && !r.isMounted() && d.hasMountSensitiveAttribute(r))
6813
+ }), r !== e && !r.isMounted() && h.hasMountSensitiveAttribute(r))
6641
6814
  return !0;
6642
6815
  }
6643
6816
  return !1;
@@ -6676,11 +6849,15 @@ ${r}
6676
6849
  return e.toString();
6677
6850
  if (e instanceof Date)
6678
6851
  return `[Date:${e.toISOString()}]`;
6852
+ if (typeof File < "u" && e instanceof File)
6853
+ return `[File:${e.name}:${e.size}:${e.lastModified}:${e.type}]`;
6854
+ if (typeof Blob < "u" && e instanceof Blob)
6855
+ return `[Blob:${e.size}:${e.type}]`;
6679
6856
  if (Array.isArray(e)) {
6680
6857
  if (t.has(e))
6681
6858
  return `[Circular:${t.get(e)}]`;
6682
6859
  const i = `array-${r.value}`;
6683
- return r.value += 1, t.set(e, i), `[${e.map((n) => d.createBindingSignature(n, t, r)).join(",")}]`;
6860
+ return r.value += 1, t.set(e, i), `[${e.map((n) => h.createBindingSignature(n, t, r)).join(",")}]`;
6684
6861
  }
6685
6862
  if (typeof e == "object") {
6686
6863
  if (t.has(e))
@@ -6689,7 +6866,7 @@ ${r}
6689
6866
  r.value += 1, t.set(e, i);
6690
6867
  const n = e;
6691
6868
  return `{${Object.keys(n).sort().map(
6692
- (s) => `${JSON.stringify(s)}:${d.createBindingSignature(
6869
+ (s) => `${JSON.stringify(s)}:${h.createBindingSignature(
6693
6870
  n[s],
6694
6871
  t,
6695
6872
  r
@@ -6705,18 +6882,18 @@ ${r}
6705
6882
  */
6706
6883
  static scheduleEvaluateAll(e) {
6707
6884
  setTimeout(() => {
6708
- d.evaluateAll(e);
6885
+ h.evaluateAll(e);
6709
6886
  }, 100);
6710
6887
  }
6711
6888
  };
6712
- d.ATTRIBUTE_ALIAS_SUFFIX = "attr-", d.PRIORITY_ATTRIBUTE_SUFFIXES = [
6889
+ h.ATTRIBUTE_ALIAS_SUFFIX = "attr-", h.PRIORITY_ATTRIBUTE_SUFFIXES = [
6713
6890
  "bind",
6714
6891
  "url-param",
6715
6892
  "derive-name",
6716
6893
  "derive",
6717
6894
  "if",
6718
6895
  "each"
6719
- ], d.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch"], d.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
6896
+ ], h.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch"], h.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
6720
6897
  "bind",
6721
6898
  "derive",
6722
6899
  "derive-name",
@@ -6725,8 +6902,8 @@ d.ATTRIBUTE_ALIAS_SUFFIX = "attr-", d.PRIORITY_ATTRIBUTE_SUFFIXES = [
6725
6902
  "fetch",
6726
6903
  "import",
6727
6904
  "url-param"
6728
- ], d.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/, d.REACTIVE_FETCH_STATES = /* @__PURE__ */ new WeakMap(), d.REACTIVE_IMPORT_STATES = /* @__PURE__ */ new WeakMap(), d.DERIVE_SUBTREE_PROFILES = /* @__PURE__ */ new WeakMap(), d.EACH_UPDATE_STATES = /* @__PURE__ */ new WeakMap();
6729
- let k = d;
6905
+ ], h.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/, h.REACTIVE_FETCH_STATES = /* @__PURE__ */ new WeakMap(), h.REACTIVE_IMPORT_STATES = /* @__PURE__ */ new WeakMap(), h.DERIVE_SUBTREE_PROFILES = /* @__PURE__ */ new WeakMap(), h.EACH_UPDATE_STATES = /* @__PURE__ */ new WeakMap(), h.EACH_RENDERED_CHANGE_FIRED = /* @__PURE__ */ new WeakSet(), h.EACH_RENDERED_CHANGE_WARNED = /* @__PURE__ */ new WeakSet();
6906
+ let P = h;
6730
6907
  const ee = class ee {
6731
6908
  /**
6732
6909
  * コンストラクタ。
@@ -6734,26 +6911,83 @@ const ee = class ee {
6734
6911
  * @param root 監視対象のルート要素(デフォルトは document )
6735
6912
  */
6736
6913
  constructor(e = document) {
6737
- this.customEventHandlers = /* @__PURE__ */ new Map(), this.onClick = (t) => this.delegate(t, "click"), this.onChange = (t) => this.delegate(t, "change"), this.onInput = (t) => this.delegate(t, "input"), this.onLoadCapture = (t) => this.delegate(t, "load"), this.onWindowLoad = () => {
6738
- const t = document.documentElement, r = S.get(t);
6739
- r && new q(r, "load").run();
6914
+ this.customEventHandlers = /* @__PURE__ */ new Map(), this.builtinListenersAdded = !1, this.deferred = !1, this.deferredProcedures = [], this.onClick = (t) => this.delegate(t, "click"), this.onChange = (t) => this.delegate(t, "change"), this.onInput = (t) => this.delegate(t, "input"), this.onLoadCapture = (t) => this.delegate(t, "load"), this.onWindowLoad = () => {
6915
+ if (this.deferred) {
6916
+ this.deferredProcedures.push(() => this.runWindowLoadProcedure());
6917
+ return;
6918
+ }
6919
+ this.runWindowLoadProcedure();
6740
6920
  }, this.onPopstate = (t) => {
6741
6921
  const r = t.state;
6742
6922
  !r || r[ee.HISTORY_STATE_KEY] !== !0 || location.reload();
6743
6923
  }, this.root = e;
6744
6924
  }
6925
+ /**
6926
+ * ページロード時の `load` 手続きを `<html>` に対して実行します。
6927
+ *
6928
+ * @returns 戻り値はない。
6929
+ */
6930
+ runWindowLoadProcedure() {
6931
+ const e = document.documentElement, t = S.get(e);
6932
+ t && new q(t, "load").run();
6933
+ }
6745
6934
  /**
6746
6935
  * イベントリスナーの登録を開始します。
6747
6936
  * クリック、変更、ロード、popstate イベントを監視し、対応するProcedureを実行します。
6748
6937
  */
6749
6938
  start() {
6750
- this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("input", this.onInput), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 }), window.addEventListener("popstate", this.onPopstate), this.subscribeDeclaredCustomEvents(), this.observeCustomEventDeclarations();
6939
+ this.deferred = !1, this.addBuiltinListeners(), this.subscribeDeclaredCustomEvents(), this.observeCustomEventDeclarations();
6940
+ }
6941
+ /**
6942
+ * 初期化中モードで購読を開始します。
6943
+ *
6944
+ * イベントリスナーの登録だけを先に行い、手続きの実行は `release()` が呼ばれる
6945
+ * まで保留します。`Observer.init()` の初期スキャン中に `data-each-rendered-run`
6946
+ * などから同期的に発火されたイベントが、リスナー未登録のまま失われるのを防ぐ
6947
+ * ためのモードです。保留したイベントは初期化完了後に発火順で処理されます。
6948
+ *
6949
+ * `data-on` の宣言追加を監視する MutationObserver は、初期スキャン中の大量の
6950
+ * ノード追加に対する無駄な走査を避けるため `release()` まで開始しません
6951
+ * (初期スキャン中に追加された宣言は `release()` 時に一括で購読されます)。
6952
+ *
6953
+ * @returns 戻り値はない。
6954
+ */
6955
+ startDeferred() {
6956
+ this.deferred = !0, this.addBuiltinListeners(), this.subscribeDeclaredCustomEvents();
6957
+ }
6958
+ /**
6959
+ * 初期化中モードを解除し、保留していた手続きを発火順に実行します。
6960
+ *
6961
+ * 初期化中モードでない場合は何もしません。
6962
+ *
6963
+ * @returns 戻り値はない。
6964
+ */
6965
+ release() {
6966
+ if (!this.deferred)
6967
+ return;
6968
+ this.deferred = !1, this.subscribeDeclaredCustomEvents(), this.observeCustomEventDeclarations();
6969
+ const e = this.deferredProcedures.splice(0);
6970
+ for (const t of e)
6971
+ try {
6972
+ t();
6973
+ } catch (r) {
6974
+ p.error("[Haori]", "Deferred event handling error:", r);
6975
+ }
6976
+ }
6977
+ /**
6978
+ * 組み込みイベント(click / change / input / load / popstate)のリスナーを登録します。
6979
+ * 二重登録は行いません。
6980
+ *
6981
+ * @returns 戻り値はない。
6982
+ */
6983
+ addBuiltinListeners() {
6984
+ this.builtinListenersAdded || (this.builtinListenersAdded = !0, this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("input", this.onInput), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 }), window.addEventListener("popstate", this.onPopstate));
6751
6985
  }
6752
6986
  /**
6753
6987
  * イベントリスナーの登録を停止します。
6754
6988
  */
6755
6989
  stop() {
6756
- this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("input", this.onInput), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad), window.removeEventListener("popstate", this.onPopstate);
6990
+ this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("input", this.onInput), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad), window.removeEventListener("popstate", this.onPopstate), this.builtinListenersAdded = !1, this.deferred = !1, this.deferredProcedures.length = 0;
6757
6991
  for (const [e, t] of this.customEventHandlers)
6758
6992
  window.removeEventListener(e, t, !0);
6759
6993
  this.customEventHandlers.clear(), this.customEventObserver?.disconnect(), this.customEventObserver = void 0;
@@ -6792,7 +7026,7 @@ const ee = class ee {
6792
7026
  if (e === null || e === "")
6793
7027
  return;
6794
7028
  if (ee.BUILTIN_EVENT_NAMES.has(e)) {
6795
- b.warn(
7029
+ p.warn(
6796
7030
  "[Haori]",
6797
7031
  `data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`
6798
7032
  );
@@ -6811,12 +7045,18 @@ const ee = class ee {
6811
7045
  * @returns 戻り値はない。
6812
7046
  */
6813
7047
  runCustomEventProcedures(e, t) {
7048
+ if (this.deferred) {
7049
+ this.deferredProcedures.push(
7050
+ () => this.runCustomEventProcedures(e, t)
7051
+ );
7052
+ return;
7053
+ }
6814
7054
  this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach((i) => {
6815
7055
  if (i.getAttribute(this.onAttributeName) !== e)
6816
7056
  return;
6817
7057
  const n = S.get(i);
6818
7058
  n instanceof M && new q(n, "on", t).run().catch((s) => {
6819
- b.error("[Haori]", "Procedure execution error:", s);
7059
+ p.error("[Haori]", "Procedure execution error:", s);
6820
7060
  });
6821
7061
  });
6822
7062
  }
@@ -6852,32 +7092,48 @@ const ee = class ee {
6852
7092
  */
6853
7093
  delegate(e, t) {
6854
7094
  const r = this.getElementFromTarget(e.target, t);
6855
- if (!r)
6856
- return;
6857
- if (t === "input") {
6858
- const s = `${c.prefix}input-`;
6859
- if (!r.getAttributeNames().some((o) => o.startsWith(s)))
7095
+ if (r) {
7096
+ if (t === "input") {
7097
+ const i = `${c.prefix}input-`;
7098
+ if (!r.getAttributeNames().some((s) => s.startsWith(i)))
7099
+ return;
7100
+ }
7101
+ if (r.hasAttribute(`${c.prefix}${t}-prevent`) && e.preventDefault(), this.deferred) {
7102
+ this.deferredProcedures.push(() => {
7103
+ r.isConnected && this.runProcedureFor(r, t, e);
7104
+ });
6860
7105
  return;
7106
+ }
7107
+ this.runProcedureFor(r, t, e);
6861
7108
  }
6862
- r.hasAttribute(`${c.prefix}${t}-prevent`) && e.preventDefault();
6863
- const i = S.get(r);
7109
+ }
7110
+ /**
7111
+ * 対象要素に対して、値の同期と手続きの実行を行います。
7112
+ *
7113
+ * @param element 処理対象の要素
7114
+ * @param type イベントタイプ('click', 'change', 'load'など)
7115
+ * @param event 起点となった DOM イベント
7116
+ * @returns 戻り値はない。
7117
+ */
7118
+ runProcedureFor(e, t, r) {
7119
+ const i = S.get(e);
6864
7120
  if (!i)
6865
7121
  return;
6866
- if ((t === "change" || t === "input") && i instanceof M && (i.syncValue(), r instanceof HTMLInputElement && r.type === "radio" && r.name)) {
6867
- const s = document.getElementsByName(r.name);
7122
+ if ((t === "change" || t === "input") && i instanceof M && (i.syncValue(), e instanceof HTMLInputElement && e.type === "radio" && e.name)) {
7123
+ const s = document.getElementsByName(e.name);
6868
7124
  for (const a of Array.from(s)) {
6869
- if (a === r || !(a instanceof HTMLInputElement) || a.type !== "radio" || a.form !== r.form)
7125
+ if (a === e || !(a instanceof HTMLInputElement) || a.type !== "radio" || a.form !== e.form)
6870
7126
  continue;
6871
7127
  const o = S.get(a);
6872
7128
  o instanceof M && o.syncValue();
6873
7129
  }
6874
7130
  }
6875
7131
  const n = () => {
6876
- new q(i, t, e).run().catch((s) => {
6877
- b.error("[Haori]", "Procedure execution error:", s);
7132
+ new q(i, t, r).run().catch((s) => {
7133
+ p.error("[Haori]", "Procedure execution error:", s);
6878
7134
  });
6879
7135
  };
6880
- if (t === "click" && r.hasAttribute(`${c.prefix}click-defer`)) {
7136
+ if (t === "click" && e.hasAttribute(`${c.prefix}click-defer`)) {
6881
7137
  typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => n()) : setTimeout(n, 0);
6882
7138
  return;
6883
7139
  }
@@ -6932,7 +7188,7 @@ ee.HISTORY_STATE_KEY = "__haoriHistoryState__", ee.BUILTIN_EVENT_NAMES = /* @__P
6932
7188
  "input",
6933
7189
  "load"
6934
7190
  ]);
6935
- let ge = ee;
7191
+ let be = ee;
6936
7192
  const D = class D {
6937
7193
  /**
6938
7194
  * ノードが現在の Window に属する HTMLElement かどうかを判定します。
@@ -6970,12 +7226,12 @@ const D = class D {
6970
7226
  t && (t.observer.disconnect(), D.registrations.delete(e));
6971
7227
  const o = new IntersectionObserver(
6972
7228
  (l) => {
6973
- const h = D.registrations.get(e);
6974
- h && l.forEach((u) => {
6975
- !u.isIntersecting || h.running || D.isDisabled(h.fragment) || (h.running = !0, new q(h.fragment, "intersect").runWithResult().then((m) => {
6976
- m && h.once && (h.observer.disconnect(), D.registrations.delete(e));
7229
+ const d = D.registrations.get(e);
7230
+ d && l.forEach((u) => {
7231
+ !u.isIntersecting || d.running || D.isDisabled(d.fragment) || (d.running = !0, new q(d.fragment, "intersect").runWithResult().then((m) => {
7232
+ m && d.once && (d.observer.disconnect(), D.registrations.delete(e));
6977
7233
  }).catch((m) => {
6978
- b.error(
7234
+ p.error(
6979
7235
  "[Haori]",
6980
7236
  "Intersect procedure execution error:",
6981
7237
  m
@@ -7030,7 +7286,7 @@ const D = class D {
7030
7286
  if (typeof r != "string" || r.trim() === "")
7031
7287
  return null;
7032
7288
  const i = document.querySelector(r);
7033
- return D.isHtmlElement(i) ? i : (b.error("[Haori]", `Intersect root element not found: ${r}`), null);
7289
+ return D.isHtmlElement(i) ? i : (p.error("[Haori]", `Intersect root element not found: ${r}`), null);
7034
7290
  }
7035
7291
  static resolveRootMargin(e) {
7036
7292
  const t = `${c.prefix}intersect-root-margin`, r = e.getAttribute(t);
@@ -7061,7 +7317,7 @@ D.CONFIG_KEYS = /* @__PURE__ */ new Set([
7061
7317
  "once"
7062
7318
  ]), D.registrations = /* @__PURE__ */ new Map();
7063
7319
  let _ = D;
7064
- function lt(f) {
7320
+ function ht(f) {
7065
7321
  typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => f()) : Promise.resolve().then(f);
7066
7322
  }
7067
7323
  const w = class w {
@@ -7103,7 +7359,7 @@ const w = class w {
7103
7359
  return;
7104
7360
  const i = w.resolveVarName(r);
7105
7361
  if (i === "") {
7106
- t && (t.observer.disconnect(), w.registrations.delete(e)), b.warn(
7362
+ t && (t.observer.disconnect(), w.registrations.delete(e)), p.warn(
7107
7363
  "[Haori]",
7108
7364
  'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").'
7109
7365
  );
@@ -7117,14 +7373,14 @@ const w = class w {
7117
7373
  t && (t.observer.disconnect(), w.registrations.delete(e));
7118
7374
  const a = new IntersectionObserver(
7119
7375
  (l) => {
7120
- const h = w.registrations.get(e);
7121
- if (!h)
7376
+ const d = w.registrations.get(e);
7377
+ if (!d)
7122
7378
  return;
7123
7379
  let u = !1;
7124
7380
  l.forEach((m) => {
7125
- const v = m.target;
7126
- h.observedRows.has(v) && (m.isIntersecting ? h.visibleRows.has(v) || (h.visibleRows.add(v), u = !0) : h.visibleRows.delete(v) && (u = !0));
7127
- }), u && w.scheduleCompute(h);
7381
+ const y = m.target;
7382
+ d.observedRows.has(y) && (m.isIntersecting ? d.visibleRows.has(y) || (d.visibleRows.add(y), u = !0) : d.visibleRows.delete(y) && (u = !0));
7383
+ }), u && w.scheduleCompute(d);
7128
7384
  },
7129
7385
  {
7130
7386
  root: n,
@@ -7200,7 +7456,7 @@ const w = class w {
7200
7456
  if (typeof r != "string" || r.trim() === "")
7201
7457
  return null;
7202
7458
  const i = document.querySelector(r);
7203
- return w.isHtmlElement(i) ? i : (b.error("[Haori]", `Visible range root element not found: ${r}`), null);
7459
+ return w.isHtmlElement(i) ? i : (p.error("[Haori]", `Visible range root element not found: ${r}`), null);
7204
7460
  }
7205
7461
  /**
7206
7462
  * rootMargin を解決します。
@@ -7243,7 +7499,7 @@ const w = class w {
7243
7499
  * @param registration 対象の登録
7244
7500
  */
7245
7501
  static scheduleCompute(e) {
7246
- e.scheduled || (e.scheduled = !0, lt(() => {
7502
+ e.scheduled || (e.scheduled = !0, ht(() => {
7247
7503
  e.scheduled = !1;
7248
7504
  const t = e.fragment.getTarget();
7249
7505
  w.registrations.get(t) === e && w.computeAndPublish(e);
@@ -7299,7 +7555,7 @@ const w = class w {
7299
7555
  static publish(e, t) {
7300
7556
  const r = w.resolveBindOwner(e.fragment);
7301
7557
  if (!r) {
7302
- b.warn(
7558
+ p.warn(
7303
7559
  "[Haori]",
7304
7560
  "data-each-visible found no ancestor data-bind scope to publish into."
7305
7561
  );
@@ -7310,14 +7566,14 @@ const w = class w {
7310
7566
  };
7311
7567
  n[e.varName] = { ...t };
7312
7568
  const s = e.fragment.getTarget(), a = i === s ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([e.fragment]);
7313
- k.setBindingData(
7569
+ P.setBindingData(
7314
7570
  i,
7315
7571
  n,
7316
7572
  a,
7317
7573
  !1,
7318
7574
  !1
7319
7575
  ).catch((o) => {
7320
- b.error("[Haori]", "Failed to publish visible range:", o);
7576
+ p.error("[Haori]", "Failed to publish visible range:", o);
7321
7577
  });
7322
7578
  }
7323
7579
  /**
@@ -7340,28 +7596,51 @@ const w = class w {
7340
7596
  };
7341
7597
  w.THRESHOLD = 0, w.DEFAULT_ROOT_MARGIN = "0px", w.registrations = /* @__PURE__ */ new Map();
7342
7598
  let J = w;
7343
- const H = class H {
7599
+ const O = class O {
7344
7600
  /**
7345
7601
  * 既存の MutationObserver をすべて停止します。
7346
7602
  */
7347
7603
  static disconnectMutationObservers() {
7348
- H._mutationObservers.forEach((e) => {
7604
+ O._mutationObservers.forEach((e) => {
7349
7605
  e.disconnect();
7350
- }), H._mutationObservers.length = 0;
7606
+ }), O._mutationObservers.length = 0;
7351
7607
  }
7352
7608
  /**
7353
7609
  * 初期化メソッド。
7354
7610
  * ドキュメントのheadとbodyを監視対象として設定します。
7355
7611
  */
7356
7612
  static async init() {
7357
- if (H._initialized)
7613
+ if (O._initialized)
7358
7614
  return;
7359
- H._initialized = !0, H.disconnectMutationObservers();
7360
- const e = await Promise.allSettled([
7361
- k.scan(document.head),
7362
- k.scan(document.body)
7363
- ]), [t, r] = e;
7364
- t.status !== "fulfilled" && b.error("[Haori]", "Failed to build head fragment:", t.reason), r.status !== "fulfilled" && b.error("[Haori]", "Failed to build body fragment:", r.reason), await I.wait(), document.body.setAttribute("data-haori-ready", ""), H.observe(document.head), H.observe(document.body), new ge().start(), _.syncTree(document.body), J.syncTree(document.body);
7615
+ O._initialized = !0, O.disconnectMutationObservers();
7616
+ const e = new be();
7617
+ O._dispatcher = e, e.startDeferred();
7618
+ try {
7619
+ const t = await Promise.allSettled([
7620
+ P.scan(document.head),
7621
+ P.scan(document.body)
7622
+ ]), [r, i] = t;
7623
+ r.status !== "fulfilled" && p.error(
7624
+ "[Haori]",
7625
+ "Failed to build head fragment:",
7626
+ r.reason
7627
+ ), i.status !== "fulfilled" && p.error(
7628
+ "[Haori]",
7629
+ "Failed to build body fragment:",
7630
+ i.reason
7631
+ ), await I.wait(), document.body.setAttribute("data-haori-ready", ""), O.observe(document.head), O.observe(document.body), _.syncTree(document.body), J.syncTree(document.body);
7632
+ } finally {
7633
+ e.release();
7634
+ }
7635
+ }
7636
+ /**
7637
+ * 稼働中の EventDispatcher を返します。
7638
+ *
7639
+ * @internal テストからの購読停止に使用します。
7640
+ * @returns 稼働中の EventDispatcher。未初期化の場合は null。
7641
+ */
7642
+ static getDispatcher() {
7643
+ return O._dispatcher;
7365
7644
  }
7366
7645
  /**
7367
7646
  * 指定ノードが「外部管理」サブツリーに属するかどうかを判定します。
@@ -7388,17 +7667,17 @@ const H = class H {
7388
7667
  const t = new MutationObserver(async (r) => {
7389
7668
  for (const i of r)
7390
7669
  try {
7391
- if (H.isExternallyManaged(i.target))
7670
+ if (O.isExternallyManaged(i.target))
7392
7671
  continue;
7393
7672
  switch (i.type) {
7394
7673
  case "attributes": {
7395
7674
  const n = i.target;
7396
- if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && k.isAliasedAttributeReflection(
7675
+ if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && P.isAliasedAttributeReflection(
7397
7676
  n,
7398
7677
  i.attributeName
7399
7678
  ))
7400
7679
  break;
7401
- k.setAttribute(
7680
+ P.setAttribute(
7402
7681
  n,
7403
7682
  i.attributeName,
7404
7683
  n.getAttribute(i.attributeName),
@@ -7408,16 +7687,16 @@ const H = class H {
7408
7687
  }
7409
7688
  case "childList": {
7410
7689
  Array.from(i.removedNodes).forEach((n) => {
7411
- _.cleanupTree(n), J.cleanupTree(n), k.removeNode(n);
7690
+ _.cleanupTree(n), J.cleanupTree(n), P.removeNode(n);
7412
7691
  }), Array.from(i.addedNodes).forEach((n) => {
7413
- n.parentElement instanceof Element && (k.addNode(n.parentElement, n), _.syncTree(n), J.syncTree(n));
7692
+ n.parentElement instanceof Element && (P.addNode(n.parentElement, n), _.syncTree(n), J.syncTree(n));
7414
7693
  }), i.target instanceof Element && J.syncElement(
7415
7694
  i.target
7416
7695
  );
7417
7696
  break;
7418
7697
  }
7419
7698
  case "characterData": {
7420
- i.target instanceof Text || i.target instanceof Comment ? k.changeText(i.target, i.target.textContent) : b.warn(
7699
+ i.target instanceof Text || i.target instanceof Comment ? P.changeText(i.target, i.target.textContent) : p.warn(
7421
7700
  "[Haori]",
7422
7701
  "Unsupported character data type:",
7423
7702
  i.target
@@ -7425,11 +7704,11 @@ const H = class H {
7425
7704
  break;
7426
7705
  }
7427
7706
  default:
7428
- b.warn("[Haori]", "Unknown mutation type:", i.type);
7707
+ p.warn("[Haori]", "Unknown mutation type:", i.type);
7429
7708
  continue;
7430
7709
  }
7431
7710
  } catch (n) {
7432
- b.error("[Haori]", "Error processing mutation:", n);
7711
+ p.error("[Haori]", "Error processing mutation:", n);
7433
7712
  }
7434
7713
  });
7435
7714
  t.observe(e, {
@@ -7437,23 +7716,23 @@ const H = class H {
7437
7716
  subtree: !0,
7438
7717
  attributes: !0,
7439
7718
  characterData: !0
7440
- }), H._mutationObservers.push(t);
7719
+ }), O._mutationObservers.push(t);
7441
7720
  }
7442
7721
  };
7443
- H._initialized = !1, H._mutationObservers = [];
7444
- let ae = H;
7445
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", ae.init) : ae.init();
7446
- const ut = () => Z.waitForRenders(), ct = "0.25.0";
7722
+ O._initialized = !1, O._mutationObservers = [], O._dispatcher = null;
7723
+ let le = O;
7724
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", le.init) : le.init();
7725
+ const ft = () => Z.waitForRenders(), gt = "0.26.0";
7447
7726
  export {
7448
- k as Core,
7727
+ P as Core,
7449
7728
  c as Env,
7450
7729
  A as Form,
7451
7730
  S as Fragment,
7452
7731
  Z as Haori,
7453
- b as Log,
7732
+ p as Log,
7454
7733
  I as Queue,
7455
7734
  Z as default,
7456
- ct as version,
7457
- ut as waitForRenders
7735
+ gt as version,
7736
+ ft as waitForRenders
7458
7737
  };
7459
7738
  //# sourceMappingURL=haori.es.js.map