haori 0.24.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 de = "embedded";
34
- function Se(f) {
33
+ const pe = "embedded";
34
+ function De(f) {
35
35
  return f === "embedded" || f === "demo";
36
36
  }
37
- function Oe(f) {
38
- return f === null ? null : Se(f) ? f : de;
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 = Se(e) ? e : de;
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 = Oe(
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 = de;
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 He = "yyyy/MM/dd HH:mm", Le = "en-US", Ee = 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 we(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 we(f, e, t, r, i, n) {
144
144
  ss: K(n)
145
145
  };
146
146
  }
147
- function Ue(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 Ue(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 : we(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 Te(f, e = He, 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 Te(f, e = He, t) {
174
174
  return "";
175
175
  let i;
176
176
  if (typeof t == "string" && t.trim() !== "") {
177
- if (i = Ue(r, t.trim()), i === null)
177
+ if (i = Me(r, t.trim()), i === null)
178
178
  return "";
179
179
  } else
180
- i = we(
180
+ i = Ne(
181
181
  r.getFullYear(),
182
182
  r.getMonth() + 1,
183
183
  r.getDate(),
@@ -191,7 +191,26 @@ function Te(f, e = He, t) {
191
191
  (s, a) => a !== void 0 ? a === "" ? "'" : a : n[s]
192
192
  );
193
193
  }
194
- function Re(f, e) {
194
+ const ze = "yyyy-MM-dd";
195
+ function xe(f = Fe, e) {
196
+ return de(/* @__PURE__ */ new Date(), f, e);
197
+ }
198
+ function Pe(f = 0, e = ze, t) {
199
+ const r = Number.isFinite(f) ? Math.trunc(f) : 0, i = typeof t == "string" && t.trim() !== "" ? t.trim() : "";
200
+ let n, s, a;
201
+ if (i !== "") {
202
+ const l = Me(/* @__PURE__ */ new Date(), i);
203
+ if (l === null)
204
+ return "";
205
+ n = Number(l.yyyy), s = Number(l.MM), a = Number(l.dd);
206
+ } else {
207
+ const l = /* @__PURE__ */ new Date();
208
+ n = l.getFullYear(), s = l.getMonth() + 1, a = l.getDate();
209
+ }
210
+ const o = new Date(Date.UTC(n, s - 1, a + r));
211
+ return de(o, e, "UTC");
212
+ }
213
+ function Ie(f, e) {
195
214
  if (f == null)
196
215
  return "";
197
216
  let t;
@@ -210,23 +229,23 @@ function Re(f, e) {
210
229
  const i = Math.max(0, Math.trunc(e));
211
230
  r.minimumFractionDigits = i, r.maximumFractionDigits = i;
212
231
  }
213
- return new Intl.NumberFormat(Le, r).format(t);
232
+ return new Intl.NumberFormat(Ke, r).format(t);
214
233
  }
215
- function De(f, e, t) {
234
+ function ke(f, e, t) {
216
235
  let r, i, n;
217
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)
218
237
  return [];
219
238
  r = Math.trunc(r), i = Math.trunc(i), n = Math.trunc(n);
220
239
  const s = [];
221
240
  if (n > 0)
222
- for (let a = r; a < i && s.length < Ee; a += n)
241
+ for (let a = r; a < i && s.length < Te; a += n)
223
242
  s.push(a);
224
243
  else
225
- for (let a = r; a > i && s.length < Ee; a += n)
244
+ for (let a = r; a > i && s.length < Te; a += n)
226
245
  s.push(a);
227
246
  return s;
228
247
  }
229
- function Fe(f, e, t = {}) {
248
+ function Ce(f, e, t = {}) {
230
249
  const r = Math.trunc(Number(f));
231
250
  if (!Number.isFinite(r) || r <= 0)
232
251
  return [];
@@ -241,11 +260,11 @@ function Fe(f, e, t = {}) {
241
260
  for (let u = Math.max(0, i - n); u <= Math.min(r - 1, i + n); u += 1)
242
261
  a.add(u);
243
262
  const o = Array.from(a).sort((u, m) => u - m), l = [];
244
- let h = null;
263
+ let d = null;
245
264
  for (const u of o) {
246
- if (h !== null && u - h > 1)
247
- if (u - h === 2) {
248
- const m = h + 1;
265
+ if (d !== null && u - d > 1)
266
+ if (u - d === 2) {
267
+ const m = d + 1;
249
268
  l.push({
250
269
  page: m,
251
270
  label: m + 1,
@@ -259,19 +278,19 @@ function Fe(f, e, t = {}) {
259
278
  label: u + 1,
260
279
  active: u === i,
261
280
  ellipsis: !1
262
- }), h = u;
281
+ }), d = u;
263
282
  }
264
283
  return l;
265
284
  }
266
- const Ve = /^(\d{4})-(\d{1,2})$/, je = 1200;
267
- function re(f, e) {
285
+ const Ge = /^(\d{4})-(\d{1,2})$/, Ye = 1200;
286
+ function ie(f, e) {
268
287
  const t = Number(f);
269
288
  return Number.isFinite(t) ? Math.trunc(t) : e;
270
289
  }
271
- function ue(f, e) {
290
+ function he(f, e) {
272
291
  if (typeof f != "string")
273
292
  return "";
274
- const t = Ve.exec(f.trim());
293
+ const t = Ge.exec(f.trim());
275
294
  if (!t)
276
295
  return "";
277
296
  const r = Number(t[1]), i = Number(t[2]);
@@ -280,48 +299,48 @@ function ue(f, e) {
280
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;
281
300
  return `${String(a).padStart(4, "0")}-${K(o)}`;
282
301
  }
283
- function qe(f) {
302
+ function Je(f) {
284
303
  if (typeof f == "string" && f.trim() !== "")
285
- return ue(f, 0);
304
+ return he(f, 0);
286
305
  const e = /* @__PURE__ */ new Date();
287
306
  return `${String(e.getFullYear()).padStart(4, "0")}-${K(e.getMonth() + 1)}`;
288
307
  }
289
- function Ne(f, e) {
308
+ function Be(f, e) {
290
309
  const t = Math.trunc(Number(f));
291
310
  if (!Number.isFinite(t) || t < 0)
292
311
  return [];
293
- const r = qe(e);
312
+ const r = Je(e);
294
313
  if (r === "")
295
314
  return [];
296
- const i = Math.min(t, je), n = [];
315
+ const i = Math.min(t, Ye), n = [];
297
316
  for (let s = 0; s <= i; s += 1) {
298
- const a = ue(r, -s);
317
+ const a = he(r, -s);
299
318
  n.push({ targetMonth: a, label: a.replace(/-/g, "/") });
300
319
  }
301
320
  return n;
302
321
  }
303
- function Me(f, e) {
322
+ function $e(f, e) {
304
323
  const t = { start: 0, end: 0, total: 0, empty: !0 };
305
324
  if (!f || typeof f != "object")
306
325
  return t;
307
- const r = f, i = re(
326
+ const r = f, i = ie(
308
327
  r.totalElements ?? r.totalCount,
309
328
  0
310
329
  );
311
330
  if (i <= 0)
312
331
  return t;
313
- 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);
314
333
  let l;
315
334
  if (e !== void 0 && Number.isFinite(e))
316
335
  l = Math.max(0, Math.trunc(e));
317
336
  else {
318
- const u = re(r.numberOfElements, NaN);
337
+ const u = ie(r.numberOfElements, NaN);
319
338
  l = Number.isFinite(u) ? u : Math.min(s, i - a);
320
339
  }
321
- const h = Math.min(a + l, i);
322
- 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 };
323
342
  }
324
- function xe(f, e, t) {
343
+ function Oe(f, e, t) {
325
344
  if (!Array.isArray(f) || f.length === 0)
326
345
  return null;
327
346
  const r = String(t), i = f.find(
@@ -329,7 +348,7 @@ function xe(f, e, t) {
329
348
  );
330
349
  return i === void 0 ? null : i;
331
350
  }
332
- function ke(f, e) {
351
+ function He(f, e) {
333
352
  if (!Array.isArray(f))
334
353
  return 0;
335
354
  let t = 0;
@@ -342,25 +361,25 @@ function ke(f, e) {
342
361
  }
343
362
  return t;
344
363
  }
345
- function Ie(f, e) {
364
+ function Le(f, e) {
346
365
  return e == null || f == null ? String(f) : String(f[e]);
347
366
  }
348
- function Pe(f, e) {
367
+ function Ue(f, e) {
349
368
  if (!Array.isArray(f))
350
369
  return [];
351
370
  const t = /* @__PURE__ */ new Set(), r = [];
352
371
  for (const i of f) {
353
- const n = Ie(i, e);
372
+ const n = Le(i, e);
354
373
  t.has(n) || (t.add(n), r.push(i));
355
374
  }
356
375
  return r;
357
376
  }
358
- function Ce(f, e) {
377
+ function Ve(f, e) {
359
378
  if (!Array.isArray(f))
360
379
  return [];
361
380
  const t = /* @__PURE__ */ new Map(), r = [];
362
381
  for (const i of f) {
363
- const n = Ie(i, e), s = t.get(n);
382
+ const n = Le(i, e), s = t.get(n);
364
383
  if (s === void 0) {
365
384
  const a = i == null ? i : i[e];
366
385
  t.set(n, r.length), r.push({ key: a, items: [i] });
@@ -369,18 +388,20 @@ function Ce(f, e) {
369
388
  }
370
389
  return r;
371
390
  }
372
- const We = Object.freeze({
373
- date: Te,
374
- number: Re,
375
- pages: Fe,
376
- range: De,
377
- monthAdd: ue,
378
- monthRange: Ne,
379
- pageSummary: Me,
380
- findBy: xe,
381
- sum: ke,
382
- distinct: Pe,
383
- groupBy: Ce
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
384
405
  }), B = class B {
385
406
  /**
386
407
  * 明示バインド内に持ち込まれてはならない危険値を返します。
@@ -475,18 +496,18 @@ const We = Object.freeze({
475
496
  */
476
497
  static evaluateDetailed(e, t = {}) {
477
498
  if (this.scheduleForbiddenBindingValueCacheReset(), e.trim() === "")
478
- 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 };
479
500
  if (this.containsDangerousPatterns(e)) {
480
501
  const l = this.detectDisallowedKeywords(e);
481
502
  if (l.length > 0) {
482
- 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.";
483
- 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(
484
505
  "[Haori]",
485
506
  e,
486
- "Expression uses disallowed keyword(s): " + l.join(", ") + "." + h
507
+ "Expression uses disallowed keyword(s): " + l.join(", ") + "." + d
487
508
  );
488
509
  } else
489
- b.warn(
510
+ p.warn(
490
511
  "[Haori]",
491
512
  e,
492
513
  "Expression contains dangerous patterns"
@@ -496,7 +517,7 @@ const We = Object.freeze({
496
517
  const r = this.collectForbiddenKeys(t);
497
518
  if (r.length > 0) {
498
519
  const l = r.join(",");
499
- 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(
500
521
  "[Haori]",
501
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."
502
523
  ));
@@ -507,7 +528,7 @@ const We = Object.freeze({
507
528
  /* @__PURE__ */ new WeakSet(),
508
529
  i
509
530
  ))
510
- return b.warn(
531
+ return p.warn(
511
532
  "[Haori]",
512
533
  t,
513
534
  "Binded values contain forbidden values"
@@ -518,7 +539,7 @@ const We = Object.freeze({
518
539
  ), s = this.BUILTIN_REFERENCE_PATTERN.test(
519
540
  n
520
541
  );
521
- s && this.BUILTIN_NAMESPACE in t && b.warn(
542
+ s && this.BUILTIN_NAMESPACE in t && p.warn(
522
543
  "[Haori]",
523
544
  `Binding key "${this.BUILTIN_NAMESPACE}" is reserved for built-in helpers; the bound value is ignored in expressions.`
524
545
  );
@@ -528,36 +549,36 @@ const We = Object.freeze({
528
549
  s && (a[this.BUILTIN_NAMESPACE] = this.BUILTIN_HELPERS);
529
550
  const o = this.canAttemptMissingIdentifierRecovery(e);
530
551
  for (let l = 0; l <= this.MAX_IDENTIFIER_RECOVERY_COUNT; l += 1) {
531
- const h = this.prepareEvaluator(e, a);
532
- if (h.compileFailed || h.evaluator === null)
552
+ const d = this.prepareEvaluator(e, a);
553
+ if (d.compileFailed || d.evaluator === null)
533
554
  return { value: null, unresolvedReference: !1 };
534
555
  try {
535
556
  const u = [], m = this.wrapBoundValues(a);
536
- return h.bindKeys.forEach((v) => {
537
- u.push(m[v]);
557
+ return d.bindKeys.forEach((y) => {
558
+ u.push(m[y]);
538
559
  }), {
539
560
  value: this.withBlockedPropertyAccess(
540
- () => h.evaluator(...u)
561
+ () => d.evaluator(...u)
541
562
  ),
542
563
  unresolvedReference: !1
543
564
  };
544
565
  } catch (u) {
545
566
  if (o && u instanceof ReferenceError) {
546
- const v = this.extractMissingIdentifier(u);
547
- if (v !== null && this.canRecoverMissingIdentifier(v, a)) {
548
- a[v] = void 0;
567
+ const y = this.extractMissingIdentifier(u);
568
+ if (y !== null && this.canRecoverMissingIdentifier(y, a)) {
569
+ a[y] = void 0;
549
570
  continue;
550
571
  }
551
572
  }
552
573
  const m = this.detectForbiddenIdentifiers(e);
553
- return m.length > 0 && b.warn(
574
+ return m.length > 0 && p.warn(
554
575
  "[Haori]",
555
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.",
556
577
  e
557
- ), 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 };
558
579
  }
559
580
  }
560
- return b.error(
581
+ return p.error(
561
582
  "[Haori]",
562
583
  "Failed to recover missing identifiers:",
563
584
  e,
@@ -591,7 +612,7 @@ return (${e});`;
591
612
  compileFailed: !1
592
613
  };
593
614
  } catch (o) {
594
- return b.error(
615
+ return p.error(
595
616
  "[Haori]",
596
617
  "Failed to compile expression:",
597
618
  e,
@@ -676,12 +697,12 @@ return (${e});`;
676
697
  const r = [];
677
698
  let i = null;
678
699
  for (let n = 0; n < t.length; n++) {
679
- 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;
680
701
  if (this.startsObjectKey(
681
702
  o,
682
703
  i,
683
704
  l,
684
- h
705
+ d
685
706
  ) && (s.value === "[" || s.type === "identifier" && this.FORBIDDEN_PROPERTY_NAMES.has(s.value) || s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
686
707
  this.decodeStringLiteral(s.value)
687
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(
@@ -1096,7 +1117,7 @@ return (${e});`;
1096
1117
  }
1097
1118
  };
1098
1119
  B.MAX_IDENTIFIER_RECOVERY_COUNT = 8, B.BUILTIN_NAMESPACE = "haori", B.BUILTIN_HELPERS = {
1099
- ...We
1120
+ ...Xe
1100
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 = [
1101
1122
  // グローバルオブジェクト
1102
1123
  "window",
@@ -1189,7 +1210,7 @@ B.MAX_IDENTIFIER_RECOVERY_COUNT = 8, B.BUILTIN_NAMESPACE = "haori", B.BUILTIN_HE
1189
1210
  "yield"
1190
1211
  ]), B.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
1191
1212
  let G = B;
1192
- class ge {
1213
+ class ye {
1193
1214
  constructor() {
1194
1215
  this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
1195
1216
  }
@@ -1231,13 +1252,13 @@ class ge {
1231
1252
  const r = await t.task();
1232
1253
  t.resolve(r);
1233
1254
  } catch (r) {
1234
- t.reject(r), b.error("[Haori]", `Task ${t.timestamp} failed:`, r);
1255
+ t.reject(r), p.error("[Haori]", `Task ${t.timestamp} failed:`, r);
1235
1256
  }
1236
1257
  if (performance.now() - e > this.MAX_BUDGET)
1237
1258
  break;
1238
1259
  }
1239
1260
  } catch (e) {
1240
- b.error("[Haori]", "Error processing queue:", e);
1261
+ p.error("[Haori]", "Error processing queue:", e);
1241
1262
  } finally {
1242
1263
  this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
1243
1264
  }
@@ -1279,7 +1300,7 @@ class ge {
1279
1300
  async waitForIdle(e = 1e3) {
1280
1301
  let t = 0, r = 0;
1281
1302
  for (; t < 2 && r < e; )
1282
- this.processing || this.queue.length > 0 ? (await this.wait(), t = 0) : t += 1, await ge.nextTick(), r += 1;
1303
+ this.processing || this.queue.length > 0 ? (await this.wait(), t = 0) : t += 1, await ye.nextTick(), r += 1;
1283
1304
  }
1284
1305
  /**
1285
1306
  * 次のフレーム(または 1 マクロタスク)まで待機します。
@@ -1292,7 +1313,7 @@ class ge {
1292
1313
  });
1293
1314
  }
1294
1315
  }
1295
- const me = class me {
1316
+ const Ee = class Ee {
1296
1317
  /**
1297
1318
  * タスクをキューに追加します。
1298
1319
  *
@@ -1319,8 +1340,8 @@ const me = class me {
1319
1340
  return this.ASYNC_QUEUE.waitForIdle(e);
1320
1341
  }
1321
1342
  };
1322
- me.ASYNC_QUEUE = new ge();
1323
- let I = me;
1343
+ Ee.ASYNC_QUEUE = new ye();
1344
+ let I = Ee;
1324
1345
  const x = class x {
1325
1346
  /**
1326
1347
  * 集計状態を初期化します。
@@ -1546,7 +1567,7 @@ const x = class x {
1546
1567
  }
1547
1568
  };
1548
1569
  x.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", x.ELEMENT_STORES = /* @__PURE__ */ new Map();
1549
- let ne = x;
1570
+ let ae = x;
1550
1571
  const Q = class Q {
1551
1572
  /**
1552
1573
  * フラグメントのコンストラクタ。
@@ -1570,10 +1591,10 @@ const Q = class Q {
1570
1591
  t = new j(e);
1571
1592
  break;
1572
1593
  case Node.COMMENT_NODE:
1573
- t = new pe(e);
1594
+ t = new ve(e);
1574
1595
  break;
1575
1596
  default:
1576
- return b.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
1597
+ return p.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
1577
1598
  }
1578
1599
  return t;
1579
1600
  }
@@ -1706,7 +1727,7 @@ const z = class z extends S {
1706
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) => {
1707
1728
  const r = e.getAttribute(t);
1708
1729
  if (r !== null && !this.attributeMap.has(t)) {
1709
- const i = new se(t, r);
1730
+ const i = new oe(t, r);
1710
1731
  this.attributeMap.set(t, i);
1711
1732
  }
1712
1733
  }), e.childNodes.forEach((t) => {
@@ -1750,7 +1771,7 @@ const z = class z extends S {
1750
1771
  removeChild(e) {
1751
1772
  const t = this.children.indexOf(e);
1752
1773
  if (t < 0) {
1753
- b.warn("[Haori]", "Child fragment not found.", e);
1774
+ p.warn("[Haori]", "Child fragment not found.", e);
1754
1775
  return;
1755
1776
  }
1756
1777
  this.children.splice(t, 1), e.setParent(null);
@@ -2089,6 +2110,14 @@ const z = class z extends S {
2089
2110
  if (this.skipChangeValue || this.value === e)
2090
2111
  return Promise.resolve();
2091
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());
2092
2121
  if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
2093
2122
  const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
2094
2123
  let s;
@@ -2116,7 +2145,7 @@ const z = class z extends S {
2116
2145
  this.skipChangeValue = !1;
2117
2146
  });
2118
2147
  } else
2119
- return b.warn(
2148
+ return p.warn(
2120
2149
  "[Haori]",
2121
2150
  "setValue is not supported for this element type.",
2122
2151
  r
@@ -2173,6 +2202,9 @@ const z = class z extends S {
2173
2202
  const r = e.value;
2174
2203
  t ? this.value = !1 : r === "false" ? this.value = !0 : this.value = null;
2175
2204
  }
2205
+ } else if (e.type === "file") {
2206
+ const t = e.files;
2207
+ this.value = t && t.length > 0 ? t[0].name : null;
2176
2208
  } else
2177
2209
  this.value = this.normalizeValueForElement(e, e.value);
2178
2210
  else e instanceof HTMLTextAreaElement ? this.value = e.value : e instanceof HTMLSelectElement && (e.multiple ? this.value = Array.from(e.selectedOptions).map(
@@ -2240,10 +2272,10 @@ const z = class z extends S {
2240
2272
  return Promise.resolve();
2241
2273
  if (r === null)
2242
2274
  return e === t ? this.removeAttribute(e) : this.removeAliasedAttribute(e, t);
2243
- const s = new se(e, r);
2275
+ const s = new oe(e, r);
2244
2276
  if (n) {
2245
- const ce = this.attributeMap.get(e);
2246
- if (ce && (ce.isEvaluate || ce.isForceEvaluation()) && !s.isEvaluate && !s.isForceEvaluation())
2277
+ const fe = this.attributeMap.get(e);
2278
+ if (fe && (fe.isEvaluate || fe.isForceEvaluation()) && !s.isEvaluate && !s.isForceEvaluation())
2247
2279
  return this.skipMutationAttributes = !0, I.enqueue(() => {
2248
2280
  }).finally(() => {
2249
2281
  this.skipMutationAttributes = !1;
@@ -2255,9 +2287,9 @@ const z = class z extends S {
2255
2287
  element: a,
2256
2288
  rawName: e,
2257
2289
  template: r
2258
- }), 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, be = W !== null && (U && a === W || $ && a.closest("select") === W), te = y !== null, ve = U && !be && a.checked !== te, ye = $ && !be && a.selected !== te;
2259
- return !R && !P && !F && !ve && !ye ? (O && !p && y !== null && (this.value = this.normalizeValueForElement(a, y)), Promise.resolve()) : (this.skipMutationAttributes = !0, I.enqueue(() => {
2260
- 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))), ve && (a.checked = te), ye && (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);
2261
2293
  }).finally(() => {
2262
2294
  this.skipMutationAttributes = !1;
2263
2295
  }));
@@ -2376,40 +2408,40 @@ const z = class z extends S {
2376
2408
  if (this.skipMutationNodes)
2377
2409
  return Promise.resolve();
2378
2410
  if (e === this)
2379
- 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"));
2380
2412
  const i = /* @__PURE__ */ new Set();
2381
2413
  let n = this.parent;
2382
2414
  for (; n; )
2383
2415
  i.add(n), n = n.getParent();
2384
2416
  if (i.has(e))
2385
- 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"));
2386
2418
  const s = e.getParent() === this;
2387
2419
  let a = -1, o = -1;
2388
2420
  s && (a = this.children.indexOf(e), t !== null && (o = this.children.indexOf(t)));
2389
2421
  const l = e.getParent();
2390
2422
  l !== null && l.removeChild(e);
2391
- let h = r === void 0 ? t?.getTarget() || null : r;
2423
+ let d = r === void 0 ? t?.getTarget() || null : r;
2392
2424
  if (t === null)
2393
2425
  this.children.push(e);
2394
2426
  else {
2395
2427
  let m;
2396
2428
  if (s ? a !== -1 && a < o ? m = o - 1 : m = o : m = this.children.indexOf(t), m === -1) {
2397
- const v = this.resolveInsertionPointFromDom(
2429
+ const y = this.resolveInsertionPointFromDom(
2398
2430
  t,
2399
2431
  !1
2400
2432
  );
2401
- v === null ? (b.warn(
2433
+ y === null ? (p.warn(
2402
2434
  "[Haori]",
2403
2435
  "Reference child not found in children.",
2404
2436
  t
2405
- ), 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);
2406
2438
  } else
2407
2439
  this.children.splice(m, 0, e);
2408
2440
  }
2409
2441
  e.setParent(this), e.setMounted(this.mounted);
2410
2442
  const u = this.skipMutationNodes;
2411
2443
  return this.skipMutationNodes = !0, I.enqueue(() => {
2412
- this.target.insertBefore(e.getTarget(), h);
2444
+ this.target.insertBefore(e.getTarget(), d);
2413
2445
  }).finally(() => {
2414
2446
  this.skipMutationNodes = u;
2415
2447
  });
@@ -2430,7 +2462,7 @@ const z = class z extends S {
2430
2462
  t,
2431
2463
  !0
2432
2464
  );
2433
- return i === null ? (b.warn(
2465
+ return i === null ? (p.warn(
2434
2466
  "[Haori]",
2435
2467
  "Reference child not found in children.",
2436
2468
  t
@@ -2621,7 +2653,7 @@ class j extends S {
2621
2653
  });
2622
2654
  }
2623
2655
  }
2624
- class pe extends S {
2656
+ class ve extends S {
2625
2657
  /**
2626
2658
  * コメントフラグメントのコンストラクタ。
2627
2659
  * 対象コメントノードの内容を初期化します。
@@ -2637,7 +2669,7 @@ class pe extends S {
2637
2669
  * @returns クローンされたフラグメント
2638
2670
  */
2639
2671
  clone() {
2640
- const e = new pe(this.target.cloneNode(!0));
2672
+ const e = new ve(this.target.cloneNode(!0));
2641
2673
  return e.mounted = !1, e.text = this.text, e;
2642
2674
  }
2643
2675
  /**
@@ -2662,7 +2694,7 @@ class pe extends S {
2662
2694
  }));
2663
2695
  }
2664
2696
  }
2665
- const oe = class oe {
2697
+ const ue = class ue {
2666
2698
  /**
2667
2699
  * コンストラクタ。
2668
2700
  *
@@ -2670,7 +2702,7 @@ const oe = class oe {
2670
2702
  */
2671
2703
  constructor(e) {
2672
2704
  this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = e;
2673
- const t = [...e.matchAll(oe.PLACEHOLDER_REGEX)];
2705
+ const t = [...e.matchAll(ue.PLACEHOLDER_REGEX)];
2674
2706
  let r = 0, i = !1, n = !1;
2675
2707
  for (const s of t) {
2676
2708
  s.index > r && this.contents.push({
@@ -2721,7 +2753,7 @@ const oe = class oe {
2721
2753
  */
2722
2754
  checkRawExpressions() {
2723
2755
  for (let e = 0; e < this.contents.length; e++)
2724
- this.contents[e].type === 2 && this.contents.length > 1 && (b.error(
2756
+ this.contents[e].type === 2 && this.contents.length > 1 && (p.error(
2725
2757
  "[Haori]",
2726
2758
  "Raw expressions are not allowed in multi-content expressions."
2727
2759
  ), this.contents[e].type = 1);
@@ -2767,35 +2799,35 @@ const oe = class oe {
2767
2799
  return this.contents.forEach((l) => {
2768
2800
  try {
2769
2801
  if (r(l)) {
2770
- const h = ne.measure(
2802
+ const d = ae.measure(
2771
2803
  () => G.evaluateDetailed(l.text, e)
2772
- ), u = h.value;
2773
- a += h.durationMs, s.push({
2804
+ ), u = d.value;
2805
+ a += d.durationMs, s.push({
2774
2806
  expression: l.text,
2775
- durationMs: h.durationMs
2807
+ durationMs: d.durationMs
2776
2808
  }), o = o || u.unresolvedReference, n.push(u.value);
2777
2809
  } else
2778
2810
  n.push(l.text);
2779
- } catch (h) {
2780
- b.error(
2811
+ } catch (d) {
2812
+ p.error(
2781
2813
  "[Haori]",
2782
2814
  `Error evaluating ${i} expression: ${l.text}`,
2783
- h
2815
+ d
2784
2816
  ), s.push({
2785
2817
  expression: l.text,
2786
2818
  durationMs: 0
2787
2819
  }), n.push("");
2788
2820
  }
2789
- }), ne.record(
2821
+ }), ae.record(
2790
2822
  t,
2791
2823
  s,
2792
2824
  a
2793
2825
  ), { results: n, hasUnresolvedReference: o };
2794
2826
  }
2795
2827
  };
2796
- oe.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
2797
- let Y = oe;
2798
- 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 {
2799
2831
  /**
2800
2832
  * コンストラクタ。
2801
2833
  *
@@ -2803,7 +2835,7 @@ const le = class le extends Y {
2803
2835
  * @param text 属性値
2804
2836
  */
2805
2837
  constructor(e, t) {
2806
- super(t), this.forceEvaluation = le.FORCE_EVALUATION_ATTRIBUTES.includes(e);
2838
+ super(t), this.forceEvaluation = ce.FORCE_EVALUATION_ATTRIBUTES.includes(e);
2807
2839
  }
2808
2840
  /**
2809
2841
  * 強制評価フラグを取得します。
@@ -2840,7 +2872,7 @@ const le = class le extends Y {
2840
2872
  (i) => this.forceEvaluation && i.type === 0 || i.type === 1 || i.type === 2,
2841
2873
  "attribute"
2842
2874
  );
2843
- return this.forceEvaluation && r.results.length > 1 ? (b.error(
2875
+ return this.forceEvaluation && r.results.length > 1 ? (p.error(
2844
2876
  "[Haori]",
2845
2877
  "each or if expressions must have a single content.",
2846
2878
  r.results
@@ -2850,7 +2882,7 @@ const le = class le extends Y {
2850
2882
  }) : r;
2851
2883
  }
2852
2884
  };
2853
- le.FORCE_EVALUATION_ATTRIBUTES = [
2885
+ ce.FORCE_EVALUATION_ATTRIBUTES = [
2854
2886
  "data-if",
2855
2887
  "hor-if",
2856
2888
  "data-each",
@@ -2858,7 +2890,7 @@ le.FORCE_EVALUATION_ATTRIBUTES = [
2858
2890
  "data-derive",
2859
2891
  "hor-derive"
2860
2892
  ];
2861
- let se = le;
2893
+ let oe = ce;
2862
2894
  class Z {
2863
2895
  /**
2864
2896
  * 実行モードを取得します。
@@ -2935,7 +2967,7 @@ class Z {
2935
2967
  */
2936
2968
  static openDialog(e) {
2937
2969
  return I.enqueue(() => {
2938
- 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);
2939
2971
  }, !0);
2940
2972
  }
2941
2973
  /**
@@ -2945,7 +2977,7 @@ class Z {
2945
2977
  */
2946
2978
  static closeDialog(e) {
2947
2979
  return I.enqueue(() => {
2948
- 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);
2949
2981
  }, !0);
2950
2982
  }
2951
2983
  /**
@@ -3004,7 +3036,34 @@ class Z {
3004
3036
  * @returns 整形済み文字列。整形できない場合は空文字
3005
3037
  */
3006
3038
  static date(e, t, r) {
3007
- return Te(e, t, r);
3039
+ return de(e, t, r);
3040
+ }
3041
+ /**
3042
+ * 現在日時を指定フォーマットの文字列へ整形します。
3043
+ *
3044
+ * テンプレート式中の `haori.now(...)` と同じ実装です。戻り値は呼び出し時刻に
3045
+ * 依存するため冪等ではありません。
3046
+ *
3047
+ * @param format フォーマット文字列(省略時は `yyyy/MM/dd HH:mm`)
3048
+ * @param timeZone IANA タイムゾーン名(例 `Asia/Tokyo`)。省略時はローカルタイムゾーン
3049
+ * @returns 整形済みの現在日時文字列
3050
+ */
3051
+ static now(e, t) {
3052
+ return xe(e, t);
3053
+ }
3054
+ /**
3055
+ * 現在日付に日数を加減した日付を指定フォーマットの文字列へ整形します。
3056
+ *
3057
+ * テンプレート式中の `haori.today(...)` と同じ実装です。戻り値は呼び出し日に
3058
+ * 依存するため冪等ではありません。
3059
+ *
3060
+ * @param offsetDays 現在日付に加減する日数(負数で過去方向、省略時は 0)
3061
+ * @param format フォーマット文字列(省略時は `yyyy-MM-dd`)
3062
+ * @param timeZone IANA タイムゾーン名(例 `Asia/Tokyo`)。省略時はローカルタイムゾーン
3063
+ * @returns 整形済みの日付文字列。timeZone が不正な場合は空文字
3064
+ */
3065
+ static today(e, t, r) {
3066
+ return Pe(e, t, r);
3008
3067
  }
3009
3068
  /**
3010
3069
  * 数値を桁区切り・小数桁付きの文字列へ整形します。
@@ -3016,7 +3075,7 @@ class Z {
3016
3075
  * @returns 整形済み文字列。整形できない場合は空文字
3017
3076
  */
3018
3077
  static number(e, t) {
3019
- return Re(e, t);
3078
+ return Ie(e, t);
3020
3079
  }
3021
3080
  /**
3022
3081
  * 整数の配列を生成します(終端は排他)。
@@ -3029,7 +3088,7 @@ class Z {
3029
3088
  * @returns 整数配列
3030
3089
  */
3031
3090
  static range(e, t, r) {
3032
- return De(e, t, r);
3091
+ return ke(e, t, r);
3033
3092
  }
3034
3093
  /**
3035
3094
  * 番号ページネーション用の表示要素列を生成します。
@@ -3042,7 +3101,7 @@ class Z {
3042
3101
  * @returns 表示要素の配列
3043
3102
  */
3044
3103
  static pages(e, t, r) {
3045
- return Fe(e, t, r);
3104
+ return Ce(e, t, r);
3046
3105
  }
3047
3106
  /**
3048
3107
  * `YYYY-MM` 形式の年月文字列に月数を加算します。
@@ -3054,7 +3113,7 @@ class Z {
3054
3113
  * @returns 加算後の年月(`YYYY-MM` 形式)。不正な入力は空文字
3055
3114
  */
3056
3115
  static monthAdd(e, t) {
3057
- return ue(e, t);
3116
+ return he(e, t);
3058
3117
  }
3059
3118
  /**
3060
3119
  * 基準月から過去方向へ `count + 1` 個の年月配列を降順で返します。
@@ -3066,7 +3125,7 @@ class Z {
3066
3125
  * @returns 年月情報の降順配列。不正な入力は空配列
3067
3126
  */
3068
3127
  static monthRange(e, t) {
3069
- return Ne(e, t);
3128
+ return Be(e, t);
3070
3129
  }
3071
3130
  /**
3072
3131
  * ページレスポンスから表示用サマリーを作ります。
@@ -3078,7 +3137,7 @@ class Z {
3078
3137
  * @returns 表示サマリー
3079
3138
  */
3080
3139
  static pageSummary(e, t) {
3081
- return Me(e, t);
3140
+ return $e(e, t);
3082
3141
  }
3083
3142
  /**
3084
3143
  * 配列から `item[key]` が指定値に一致する最初の要素を返します。
@@ -3092,7 +3151,7 @@ class Z {
3092
3151
  * @returns 一致した最初の要素。無ければ null
3093
3152
  */
3094
3153
  static findBy(e, t, r) {
3095
- return xe(e, t, r);
3154
+ return Oe(e, t, r);
3096
3155
  }
3097
3156
  /**
3098
3157
  * 配列の数値合計を返します。
@@ -3105,7 +3164,7 @@ class Z {
3105
3164
  * @returns 数値の合計。対象が無ければ 0
3106
3165
  */
3107
3166
  static sum(e, t) {
3108
- return ke(e, t);
3167
+ return He(e, t);
3109
3168
  }
3110
3169
  /**
3111
3170
  * 配列から重複を取り除いた新しい配列を返します。
@@ -3118,7 +3177,7 @@ class Z {
3118
3177
  * @returns 重複排除後の新しい配列。非配列は空配列
3119
3178
  */
3120
3179
  static distinct(e, t) {
3121
- return Pe(e, t);
3180
+ return Ue(e, t);
3122
3181
  }
3123
3182
  /**
3124
3183
  * 配列を `item[key]` ごとのグループへ分けて返します。
@@ -3131,13 +3190,13 @@ class Z {
3131
3190
  * @returns グループ情報の配列。非配列は空配列
3132
3191
  */
3133
3192
  static groupBy(e, t) {
3134
- return Ce(e, t);
3193
+ return Ve(e, t);
3135
3194
  }
3136
3195
  }
3137
- const Ke = ["addErrorMessage", "clearMessages"];
3138
- function Ae() {
3196
+ const Qe = ["addErrorMessage", "clearMessages"];
3197
+ function Re() {
3139
3198
  const e = globalThis.window?.Haori;
3140
- return Ke.every(
3199
+ return Qe.every(
3141
3200
  (r) => typeof e?.[r] == "function"
3142
3201
  ) ? e : Z;
3143
3202
  }
@@ -3154,6 +3213,35 @@ class A {
3154
3213
  const t = {};
3155
3214
  return A.getPartValues(e, t);
3156
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
+ }
3157
3245
  /**
3158
3246
  * フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
3159
3247
  * 入力エレメントのname属性、data-form-object属性、data-form-list属性に基づいて値を整理します。
@@ -3167,14 +3255,15 @@ class A {
3167
3255
  return t;
3168
3256
  const r = e.getAttribute("name"), i = e.getAttribute(`${c.prefix}form-object`), n = e.getAttribute(`${c.prefix}form-list`);
3169
3257
  if (r) {
3170
- if (n)
3171
- Array.isArray(t[String(r)]) ? t[String(r)].push(e.getValue()) : t[String(r)] = [e.getValue()];
3172
- 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)) {
3173
3262
  const s = e.getTarget(), o = (s instanceof HTMLInputElement ? s.checked : !0) ? e.getValue() : null, l = String(r);
3174
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];
3175
3264
  } else
3176
- t[String(r)] = e.getValue();
3177
- i && b.warn(
3265
+ t[String(r)] = A.resolveCollectedValue(e);
3266
+ i && p.warn(
3178
3267
  "Haori",
3179
3268
  `Element cannot have both ${c.prefix}form-object and name attributes.`
3180
3269
  );
@@ -3184,7 +3273,7 @@ class A {
3184
3273
  const s = {};
3185
3274
  for (const a of e.getChildElementFragments())
3186
3275
  A.getPartValues(a, s);
3187
- 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(
3188
3277
  "Haori",
3189
3278
  `Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
3190
3279
  );
@@ -3266,10 +3355,13 @@ class A {
3266
3355
  * @returns Promise(DOMの更新が完了したら解決される)
3267
3356
  */
3268
3357
  static setPartValues(e, t, r = null, i = !1, n = !0) {
3269
- 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`);
3270
3359
  if (a) {
3271
- if (!h || i) {
3360
+ if (!d || i) {
3272
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
+ });
3273
3365
  l && Array.isArray(u) && r !== null ? s.push(
3274
3366
  A.applyFragmentValue(e, u[r] ?? null, n)
3275
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(
@@ -3299,17 +3391,17 @@ class A {
3299
3391
  const u = t[String(l)];
3300
3392
  if (Array.isArray(u)) {
3301
3393
  const m = e.getChildElementFragments();
3302
- for (let v = 0; v < m.length; v++) {
3303
- const T = m[v];
3304
- 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(
3305
3397
  A.setPartValues(
3306
3398
  T,
3307
- u[v],
3308
- v,
3399
+ u[y],
3400
+ y,
3309
3401
  i,
3310
3402
  n
3311
3403
  )
3312
- ) : s.push(A.setPartValues(T, {}, v, i, n));
3404
+ ) : s.push(A.setPartValues(T, {}, y, i, n));
3313
3405
  }
3314
3406
  }
3315
3407
  } else
@@ -3347,7 +3439,7 @@ class A {
3347
3439
  const t = A.collectBindingTargetForms(e);
3348
3440
  for (const r of t) {
3349
3441
  const i = A.getInitialBindingData(r);
3350
- i && await k.setBindingData(r.getTarget(), i);
3442
+ i && await P.setBindingData(r.getTarget(), i);
3351
3443
  }
3352
3444
  A.syncValuesFromDom(e);
3353
3445
  for (const r of t) {
@@ -3355,9 +3447,9 @@ class A {
3355
3447
  if (r.getRawBindingData() === null && i === null)
3356
3448
  continue;
3357
3449
  const n = A.getValues(r), s = r.getAttribute(`${c.prefix}form-arg`), a = { ...i || {} };
3358
- 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);
3359
3451
  }
3360
- await k.evaluateAll(e);
3452
+ await P.evaluateAll(e);
3361
3453
  }
3362
3454
  /**
3363
3455
  * data-bind 属性で宣言された初期バインドデータを取得します。
@@ -3367,7 +3459,7 @@ class A {
3367
3459
  */
3368
3460
  static getInitialBindingData(e) {
3369
3461
  const t = e.getInitialBindAttribute();
3370
- return t === null ? null : k.parseDataBind(t);
3462
+ return t === null ? null : P.parseDataBind(t);
3371
3463
  }
3372
3464
  /**
3373
3465
  * フラグメント配下の入力要素について、内部値を現在の DOM 値と再同期します。
@@ -3440,7 +3532,7 @@ class A {
3440
3532
  * @returns Promise(メッセージのクリアが完了したら解決される)
3441
3533
  */
3442
3534
  static clearMessages(e) {
3443
- return Ae().clearMessages(
3535
+ return Re().clearMessages(
3444
3536
  e.getTarget()
3445
3537
  );
3446
3538
  }
@@ -3467,9 +3559,9 @@ class A {
3467
3559
  * @return Promise(メッセージの追加が完了したら解決される)
3468
3560
  */
3469
3561
  static addMessage(e, t, r, i) {
3470
- const n = [], s = Ae(), a = s.addMessage, o = (h) => typeof a == "function" ? a.call(s, h, r, i) : s.addErrorMessage(h, r), l = A.findFragmentsByKey(e, t);
3471
- return l.forEach((h) => {
3472
- 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()));
3473
3565
  }), l.length === 0 && n.push(o(e.getTarget())), Promise.all(n).then(() => {
3474
3566
  });
3475
3567
  }
@@ -3503,13 +3595,13 @@ class A {
3503
3595
  if (s !== -1 && a !== -1 && s < a) {
3504
3596
  const o = i.substring(0, s);
3505
3597
  if (n === o) {
3506
- const l = i.substring(s + 1, a), h = Number(l);
3507
- if (isNaN(h))
3508
- 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}`);
3509
3601
  else {
3510
3602
  const u = e.getChildElementFragments().filter((m) => m.hasAttribute(`${c.prefix}row`));
3511
- h < u.length && r.push(
3512
- ...A.findFragmentByKeyParts(u[h], t.slice(1))
3603
+ d < u.length && r.push(
3604
+ ...A.findFragmentByKeyParts(u[d], t.slice(1))
3513
3605
  );
3514
3606
  }
3515
3607
  }
@@ -3614,8 +3706,8 @@ class N {
3614
3706
  static bindChange(e, t, r, i = "other") {
3615
3707
  const n = [], s = new Set(Object.keys(t || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
3616
3708
  for (const l of o) {
3617
- const h = t?.[l], u = r[l];
3618
- h !== u && n.push(l);
3709
+ const d = t?.[l], u = r[l];
3710
+ d !== u && n.push(l);
3619
3711
  }
3620
3712
  N.dispatch(e, "bindchange", {
3621
3713
  previous: t || {},
@@ -3754,11 +3846,11 @@ class N {
3754
3846
  });
3755
3847
  }
3756
3848
  }
3757
- const ze = {
3849
+ const Ze = {
3758
3850
  401: "unauthorized-redirect",
3759
3851
  403: "forbidden-redirect"
3760
3852
  };
3761
- function Ge(f, e) {
3853
+ function _e(f, e) {
3762
3854
  return f.replace(/\{\{([\s\S]+?)\}\}/g, (t, r) => {
3763
3855
  try {
3764
3856
  const i = G.evaluate(String(r).trim(), e);
@@ -3768,16 +3860,16 @@ function Ge(f, e) {
3768
3860
  }
3769
3861
  });
3770
3862
  }
3771
- function Ye(f, e) {
3863
+ function et(f, e) {
3772
3864
  const t = f.getAttribute(e);
3773
3865
  if (t === null || t === "")
3774
3866
  return null;
3775
3867
  if (!t.includes("{{"))
3776
3868
  return t;
3777
- const r = S.get(f), i = r instanceof M ? r.getBindingData() : {}, n = Ge(t, i);
3869
+ const r = S.get(f), i = r instanceof M ? r.getBindingData() : {}, n = _e(t, i);
3778
3870
  return n === "" ? null : n;
3779
3871
  }
3780
- function Je(f, e, t) {
3872
+ function tt(f, e, t) {
3781
3873
  const r = f.getAttribute(`${e}-return-param`);
3782
3874
  if (r === null || r === "")
3783
3875
  return t;
@@ -3790,17 +3882,17 @@ function Je(f, e, t) {
3790
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("?") ? "&" : "?";
3791
3883
  return `${o}${l}${n}${a}`;
3792
3884
  }
3793
- function Be(f) {
3794
- const e = ze[f];
3885
+ function je(f) {
3886
+ const e = Ze[f];
3795
3887
  if (e === void 0 || typeof document > "u")
3796
3888
  return !1;
3797
3889
  const t = `${c.prefix}${e}`, r = [];
3798
3890
  document.body && r.push(document.body), document.documentElement && r.push(document.documentElement);
3799
3891
  for (const i of r) {
3800
- const n = Ye(i, t);
3892
+ const n = et(i, t);
3801
3893
  if (n === null)
3802
3894
  continue;
3803
- const s = Je(i, t, n);
3895
+ const s = tt(i, t, n);
3804
3896
  try {
3805
3897
  if (new URL(s, window.location.href).href === window.location.href)
3806
3898
  return !1;
@@ -3810,7 +3902,7 @@ function Be(f) {
3810
3902
  }
3811
3903
  return !1;
3812
3904
  }
3813
- class $e {
3905
+ class qe {
3814
3906
  /**
3815
3907
  * URLのクエリパラメータを取得します。
3816
3908
  *
@@ -3848,7 +3940,7 @@ class $e {
3848
3940
  }
3849
3941
  }
3850
3942
  }
3851
- const Xe = [
3943
+ const rt = [
3852
3944
  "addErrorMessage",
3853
3945
  "clearMessages",
3854
3946
  "closeDialog",
@@ -3856,28 +3948,28 @@ const Xe = [
3856
3948
  "dialog",
3857
3949
  "openDialog",
3858
3950
  "toast"
3859
- ], Qe = "__haoriHistoryState__", he = "data-haori-click-lock";
3860
- function ie() {
3951
+ ], it = "__haoriHistoryState__", ge = "data-haori-click-lock";
3952
+ function ne() {
3861
3953
  const e = globalThis.window?.Haori;
3862
- return Xe.every(
3954
+ return rt.every(
3863
3955
  (r) => typeof e?.[r] == "function"
3864
3956
  ) ? e : Z;
3865
3957
  }
3866
- const Ze = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
3867
- function _e(f) {
3868
- return Ze.has(f.toUpperCase());
3958
+ const nt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
3959
+ function st(f) {
3960
+ return nt.has(f.toUpperCase());
3869
3961
  }
3870
- function et(f, e) {
3962
+ function at(f, e) {
3871
3963
  for (const [t, r] of Object.entries(e))
3872
3964
  r !== void 0 && (r === null ? f.append(t, "") : Array.isArray(r) ? r.forEach((i) => {
3873
3965
  f.append(t, String(i));
3874
3966
  }) : typeof r == "object" || typeof r == "function" ? f.append(t, JSON.stringify(r)) : f.append(t, String(r)));
3875
3967
  }
3876
- function tt(f, e) {
3968
+ function ot(f, e) {
3877
3969
  const t = new URL(f, window.location.href), r = new URLSearchParams(t.search);
3878
- return et(r, e), t.search = r.toString(), t.toString();
3970
+ return at(r, e), t.search = r.toString(), t.toString();
3879
3971
  }
3880
- function rt(f) {
3972
+ function lt(f) {
3881
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 ? [
3882
3974
  e,
3883
3975
  {
@@ -3888,7 +3980,42 @@ function rt(f) {
3888
3980
  }
3889
3981
  ] : [e, String(t)]) : String(f);
3890
3982
  }
3891
- function it(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) {
3892
4019
  const t = new Headers(
3893
4020
  e.headers || void 0
3894
4021
  ), r = Array.from(t.entries()).sort(
@@ -3898,7 +4025,7 @@ function it(f, e) {
3898
4025
  url: f,
3899
4026
  method: String(e.method || "GET").toUpperCase(),
3900
4027
  headers: r,
3901
- body: rt(e.body || null)
4028
+ body: lt(e.body || null)
3902
4029
  });
3903
4030
  }
3904
4031
  const g = class g {
@@ -3910,7 +4037,7 @@ const g = class g {
3910
4037
  * @param domEvent 起点となった DOM イベント
3911
4038
  */
3912
4039
  constructor(e, t = null, r = null) {
3913
- 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;
3914
4041
  }
3915
4042
  /**
3916
4043
  * イベント属性名を正しく生成します。
@@ -4061,7 +4188,7 @@ const g = class g {
4061
4188
  const a = r.trim();
4062
4189
  if (g.SINGLE_PLACEHOLDER_REGEX.test(a))
4063
4190
  return {
4064
- value: k.parseDataBind(n),
4191
+ value: P.parseDataBind(n),
4065
4192
  hasUnresolvedReference: s
4066
4193
  };
4067
4194
  if (a.startsWith("{") || a.startsWith("[")) {
@@ -4070,7 +4197,7 @@ const g = class g {
4070
4197
  e.getBindingData()
4071
4198
  );
4072
4199
  return {
4073
- value: k.parseDataBind(l.value),
4200
+ value: P.parseDataBind(l.value),
4074
4201
  hasUnresolvedReference: s || l.hasUnresolvedReference
4075
4202
  };
4076
4203
  }
@@ -4079,7 +4206,7 @@ const g = class g {
4079
4206
  e.getBindingData()
4080
4207
  );
4081
4208
  return {
4082
- value: k.parseDataBind(o.value),
4209
+ value: P.parseDataBind(o.value),
4083
4210
  hasUnresolvedReference: s || o.hasUnresolvedReference
4084
4211
  };
4085
4212
  }
@@ -4097,22 +4224,22 @@ const g = class g {
4097
4224
  if (t) {
4098
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, `
4099
4226
  `)), e.hasAttribute(g.attrName(t, "data")) && (r.dataAttrName = g.attrName(t, "data")), e.hasAttribute(g.attrName(t, "form"))) {
4100
- const p = e.getRawAttribute(
4227
+ const b = e.getRawAttribute(
4101
4228
  g.attrName(t, "form")
4102
4229
  );
4103
- if (p) {
4104
- const y = document.body.querySelector(p);
4105
- y !== null ? r.formFragment = A.getFormFragment(
4106
- S.get(y)
4107
- ) : 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(
4108
4235
  "Haori",
4109
- `Form element not found: ${p} (${g.attrName(t, "form")})`
4236
+ `Form element not found: ${b} (${g.attrName(t, "form")})`
4110
4237
  );
4111
4238
  } else
4112
4239
  r.formFragment = A.getFormFragment(e);
4113
- } 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));
4114
4241
  if (e.hasAttribute(`${c.prefix}${t}-before-run`)) {
4115
- const p = e.getRawAttribute(
4242
+ const b = e.getRawAttribute(
4116
4243
  `${c.prefix}${t}-before-run`
4117
4244
  );
4118
4245
  try {
@@ -4121,37 +4248,37 @@ const g = class g {
4121
4248
  "fetchOptions",
4122
4249
  `
4123
4250
  "use strict";
4124
- ${p}
4251
+ ${b}
4125
4252
  `
4126
4253
  );
4127
- } catch (y) {
4128
- b.error("Haori", `Invalid before script: ${y}`);
4254
+ } catch (v) {
4255
+ p.error("Haori", `Invalid before script: ${v}`);
4129
4256
  }
4130
4257
  }
4131
4258
  const E = g.attrName(t, "run");
4132
4259
  if (e.hasAttribute(E)) {
4133
- const p = String(e.getAttribute(E) ?? "");
4134
- let y = null;
4260
+ const b = String(e.getAttribute(E) ?? "");
4261
+ let v = null;
4135
4262
  try {
4136
- y = new Function(
4263
+ v = new Function(
4137
4264
  "event",
4138
4265
  `"use strict"; return (
4139
- ${p}
4266
+ ${b}
4140
4267
  );`
4141
4268
  );
4142
4269
  } catch {
4143
4270
  try {
4144
- y = new Function(
4271
+ v = new Function(
4145
4272
  "event",
4146
4273
  `"use strict";
4147
- ${p}
4274
+ ${b}
4148
4275
  `
4149
4276
  );
4150
4277
  } catch (R) {
4151
- b.error("Haori", `Invalid run script: ${R}`);
4278
+ p.error("Haori", `Invalid run script: ${R}`);
4152
4279
  }
4153
4280
  }
4154
- y && (r.runScript = y);
4281
+ v && (r.runScript = v);
4155
4282
  }
4156
4283
  }
4157
4284
  const i = g.attrName(t, "fetch"), n = e.hasAttribute(i);
@@ -4163,28 +4290,28 @@ ${p}
4163
4290
  if (t) {
4164
4291
  const E = g.attrName(t, "fetch-method");
4165
4292
  if (e.hasAttribute(E)) {
4166
- const p = e.getAttributeEvaluation(E);
4167
- 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;
4168
4295
  }
4169
4296
  } else {
4170
4297
  const E = g.attrName(null, "method", !0);
4171
4298
  if (e.hasAttribute(E)) {
4172
- const p = e.getAttributeEvaluation(
4299
+ const b = e.getAttributeEvaluation(
4173
4300
  E
4174
4301
  );
4175
- p?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = p?.value;
4302
+ b?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = b?.value;
4176
4303
  }
4177
4304
  }
4178
4305
  if (t) {
4179
4306
  const E = g.attrName(t, "fetch-headers");
4180
4307
  if (e.hasAttribute(E)) {
4181
- const p = e.getRawAttribute(
4308
+ const b = e.getRawAttribute(
4182
4309
  E
4183
4310
  );
4184
4311
  try {
4185
- s.headers = k.parseDataBind(p);
4186
- } catch (y) {
4187
- b.error("Haori", `Invalid fetch headers: ${y}`);
4312
+ s.headers = P.parseDataBind(b);
4313
+ } catch (v) {
4314
+ p.error("Haori", `Invalid fetch headers: ${v}`);
4188
4315
  }
4189
4316
  }
4190
4317
  } else {
@@ -4194,27 +4321,27 @@ ${p}
4194
4321
  !0
4195
4322
  );
4196
4323
  if (e.hasAttribute(E)) {
4197
- const p = e.getRawAttribute(
4324
+ const b = e.getRawAttribute(
4198
4325
  E
4199
4326
  );
4200
4327
  try {
4201
- s.headers = k.parseDataBind(p);
4202
- } catch (y) {
4203
- b.error("Haori", `Invalid fetch headers: ${y}`);
4328
+ s.headers = P.parseDataBind(b);
4329
+ } catch (v) {
4330
+ p.error("Haori", `Invalid fetch headers: ${v}`);
4204
4331
  }
4205
4332
  }
4206
4333
  }
4207
4334
  if (t) {
4208
4335
  const E = g.attrName(t, "fetch-content-type");
4209
4336
  if (e.hasAttribute(E)) {
4210
- const p = e.getAttributeEvaluation(E);
4211
- p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4337
+ const b = e.getAttributeEvaluation(E);
4338
+ b?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4212
4339
  ...s.headers,
4213
- "Content-Type": p?.value
4340
+ "Content-Type": b?.value
4214
4341
  };
4215
4342
  } else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
4216
- let p = !1;
4217
- 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 = {
4218
4345
  ...s.headers,
4219
4346
  "Content-Type": "application/json"
4220
4347
  });
@@ -4229,14 +4356,14 @@ ${p}
4229
4356
  !0
4230
4357
  );
4231
4358
  if (e.hasAttribute(E)) {
4232
- const p = e.getAttributeEvaluation(E);
4233
- p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4359
+ const b = e.getAttributeEvaluation(E);
4360
+ b?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4234
4361
  ...s.headers,
4235
- "Content-Type": p?.value
4362
+ "Content-Type": b?.value
4236
4363
  };
4237
4364
  } else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
4238
- let p = !1;
4239
- 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 = {
4240
4367
  ...s.headers,
4241
4368
  "Content-Type": "application/json"
4242
4369
  });
@@ -4250,11 +4377,11 @@ ${p}
4250
4377
  if (e.hasAttribute(a)) {
4251
4378
  const E = e.getRawAttribute(a);
4252
4379
  if (E) {
4253
- const p = document.body.querySelectorAll(E);
4254
- p.length > 0 ? (r.bindFragments = [], p.forEach((y) => {
4255
- 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);
4256
4383
  R && r.bindFragments.push(R);
4257
- })) : b.error(
4384
+ })) : p.error(
4258
4385
  "Haori",
4259
4386
  `Bind element not found: ${E} (${a})`
4260
4387
  );
@@ -4264,57 +4391,57 @@ ${p}
4264
4391
  null,
4265
4392
  "arg",
4266
4393
  !0
4267
- ), h = g.attrName(
4394
+ ), d = g.attrName(
4268
4395
  null,
4269
4396
  "bind-arg",
4270
4397
  !0
4271
4398
  );
4272
4399
  t ? e.hasAttribute(o) && (r.bindArg = e.getRawAttribute(o)) : e.hasAttribute(l) ? r.bindArg = e.getRawAttribute(
4273
4400
  l
4274
- ) : e.hasAttribute(h) && (r.bindArg = e.getRawAttribute(h));
4401
+ ) : e.hasAttribute(d) && (r.bindArg = e.getRawAttribute(d));
4275
4402
  const u = t ? g.attrName(t, "bind-params") : g.attrName(null, "bind-params", !0);
4276
4403
  if (e.hasAttribute(u)) {
4277
4404
  const E = e.getRawAttribute(u);
4278
- r.bindParams = E.split("&").map((p) => p.trim());
4405
+ r.bindParams = E.split("&").map((b) => b.trim());
4279
4406
  }
4280
4407
  const m = t ? g.attrName(t, "bind-append") : g.attrName(null, "bind-append", !0);
4281
4408
  if (e.hasAttribute(m)) {
4282
4409
  const E = e.getRawAttribute(m);
4283
- r.bindAppendParams = E.split("&").map((p) => p.trim()).filter(Boolean);
4410
+ r.bindAppendParams = E.split("&").map((b) => b.trim()).filter(Boolean);
4284
4411
  }
4285
- const v = t ? g.attrName(t, "bind-merge") : g.attrName(null, "bind-merge", !0);
4286
- 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);
4287
4414
  const T = t ? g.attrName(t, "bind-transform") : g.attrName(null, "bind-transform", !0);
4288
4415
  e.hasAttribute(T) && (r.bindTransform = e.getRawAttribute(T));
4289
- const C = t ? g.attrName(t, "copy-params") : null;
4290
- if (C && e.hasAttribute(C)) {
4291
- const E = e.getRawAttribute(C);
4292
- 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);
4293
4420
  }
4294
4421
  if (t) {
4295
4422
  if (e.hasAttribute(g.attrName(t, "adjust"))) {
4296
- const y = e.getRawAttribute(
4423
+ const v = e.getRawAttribute(
4297
4424
  g.attrName(t, "adjust")
4298
4425
  );
4299
- if (y) {
4300
- const R = document.body.querySelectorAll(y);
4301
- R.length > 0 ? (r.adjustFragments = [], R.forEach((P) => {
4302
- 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);
4303
4430
  F && r.adjustFragments.push(F);
4304
- })) : b.error(
4431
+ })) : p.error(
4305
4432
  "Haori",
4306
- `Adjust element not found: ${y} (${g.attrName(t, "adjust")})`
4433
+ `Adjust element not found: ${v} (${g.attrName(t, "adjust")})`
4307
4434
  );
4308
4435
  }
4309
4436
  if (e.hasAttribute(g.attrName(t, "adjust-value"))) {
4310
4437
  const R = e.getRawAttribute(
4311
4438
  g.attrName(t, "adjust-value")
4312
- ), P = Number(R);
4313
- isNaN(P) || (r.adjustValue = P);
4439
+ ), C = Number(R);
4440
+ isNaN(C) || (r.adjustValue = C);
4314
4441
  }
4315
4442
  }
4316
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`)) {
4317
- const y = e.getRawAttribute(
4444
+ const v = e.getRawAttribute(
4318
4445
  `${c.prefix}${t}-after-run`
4319
4446
  );
4320
4447
  try {
@@ -4322,11 +4449,11 @@ ${p}
4322
4449
  "response",
4323
4450
  `
4324
4451
  "use strict";
4325
- ${y}
4452
+ ${v}
4326
4453
  `
4327
4454
  );
4328
4455
  } catch (R) {
4329
- b.error("Haori", `Invalid after script: ${R}`);
4456
+ p.error("Haori", `Invalid after script: ${R}`);
4330
4457
  }
4331
4458
  }
4332
4459
  if (e.hasAttribute(g.attrName(t, "dialog")) && (r.dialogMessage = e.getAttribute(g.attrName(t, "dialog")).replace(/\\n/g, `
@@ -4334,21 +4461,21 @@ ${y}
4334
4461
  r.toastMessage = e.getAttribute(
4335
4462
  g.attrName(t, "toast")
4336
4463
  );
4337
- const y = e.getRawAttribute(
4464
+ const v = e.getRawAttribute(
4338
4465
  g.attrName(t, "toast-level")
4339
- ), P = ["info", "warning", "error", "success"].includes(y);
4340
- r.toastLevel = P ? y : null;
4466
+ ), C = ["info", "warning", "error", "success"].includes(v);
4467
+ r.toastLevel = C ? v : null;
4341
4468
  }
4342
4469
  if (e.hasAttribute(g.attrName(t, "redirect"))) {
4343
4470
  r.redirectUrl = e.getAttribute(
4344
4471
  g.attrName(t, "redirect")
4345
4472
  );
4346
- const y = g.attrName(
4473
+ const v = g.attrName(
4347
4474
  t,
4348
4475
  "redirect-return-param"
4349
4476
  );
4350
- e.hasAttribute(y) && (r.redirectReturnParam = e.getAttribute(
4351
- y
4477
+ e.hasAttribute(v) && (r.redirectReturnParam = e.getAttribute(
4478
+ v
4352
4479
  ));
4353
4480
  }
4354
4481
  if (e.hasAttribute(g.attrName(t, "scroll-error")) && (r.scrollOnError = !0), e.hasAttribute(g.attrName(t, "scroll")) && (r.scrollTarget = e.getAttribute(
@@ -4356,16 +4483,16 @@ ${y}
4356
4483
  )), e.hasAttribute(g.attrName(t, "history")) && (r.historyUrl = e.getAttribute(
4357
4484
  g.attrName(t, "history")
4358
4485
  )), e.hasAttribute(g.attrName(t, "history-data")) && (r.historyDataAttrName = g.attrName(t, "history-data")), e.hasAttribute(g.attrName(t, "history-form"))) {
4359
- const y = e.getRawAttribute(
4486
+ const v = e.getRawAttribute(
4360
4487
  g.attrName(t, "history-form")
4361
4488
  );
4362
- if (y) {
4363
- const R = document.body.querySelector(y);
4489
+ if (v) {
4490
+ const R = document.body.querySelector(v);
4364
4491
  R !== null ? r.historyFormFragment = A.getFormFragment(
4365
4492
  S.get(R)
4366
- ) : b.error(
4493
+ ) : p.error(
4367
4494
  "Haori",
4368
- `Form element not found: ${y} (${g.attrName(t, "history-form")})`
4495
+ `Form element not found: ${v} (${g.attrName(t, "history-form")})`
4369
4496
  );
4370
4497
  } else
4371
4498
  r.historyFormFragment = A.getFormFragment(e);
@@ -4378,23 +4505,23 @@ ${y}
4378
4505
  "copy",
4379
4506
  "open",
4380
4507
  "close"
4381
- ].forEach((y) => {
4382
- const R = g.attrName(t, y);
4508
+ ].forEach((v) => {
4509
+ const R = g.attrName(t, v);
4383
4510
  if (!e.hasAttribute(R))
4384
4511
  return;
4385
- const P = e.getRawAttribute(R), F = [];
4386
- if (P)
4387
- document.body.querySelectorAll(P).forEach(($) => {
4512
+ const C = e.getRawAttribute(R), F = [];
4513
+ if (C)
4514
+ document.body.querySelectorAll(C).forEach(($) => {
4388
4515
  const W = S.get($);
4389
4516
  W && F.push(W);
4390
- }), F.length === 0 && b.error("Haori", `Element not found: ${P} (${R})`);
4391
- 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") {
4392
4519
  const U = e.getTarget().closest("dialog");
4393
- 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})`);
4394
4521
  } else
4395
4522
  F.push(e);
4396
4523
  if (F.length > 0)
4397
- switch (y) {
4524
+ switch (v) {
4398
4525
  case "reset-before":
4399
4526
  r.resetBeforeFragments = F;
4400
4527
  break;
@@ -4418,23 +4545,23 @@ ${y}
4418
4545
  break;
4419
4546
  }
4420
4547
  });
4421
- const p = g.attrName(t, "copy-source");
4422
- if (e.hasAttribute(p)) {
4423
- const y = e.getRawAttribute(
4424
- p
4548
+ const b = g.attrName(t, "copy-source");
4549
+ if (e.hasAttribute(b)) {
4550
+ const v = e.getRawAttribute(
4551
+ b
4425
4552
  );
4426
- if (y) {
4427
- const R = document.body.querySelector(y);
4553
+ if (v) {
4554
+ const R = document.body.querySelector(v);
4428
4555
  if (R !== null) {
4429
- const P = S.get(R);
4430
- P ? r.copySourceFragment = P : b.error(
4556
+ const C = S.get(R);
4557
+ C ? r.copySourceFragment = C : p.error(
4431
4558
  "Haori",
4432
- `Element is not managed by Haori: ${y} (${p})`
4559
+ `Element is not managed by Haori: ${v} (${b})`
4433
4560
  );
4434
4561
  } else
4435
- b.error(
4562
+ p.error(
4436
4563
  "Haori",
4437
- `Element not found: ${y} (${p})`
4564
+ `Element not found: ${v} (${b})`
4438
4565
  );
4439
4566
  } else
4440
4567
  r.copySourceFragment = e;
@@ -4445,29 +4572,41 @@ ${y}
4445
4572
  g.attrName(null, "form", !0)
4446
4573
  );
4447
4574
  if (E) {
4448
- const p = document.body.querySelector(E);
4449
- p !== null ? r.formFragment = A.getFormFragment(
4450
- S.get(p)
4451
- ) : b.error(
4575
+ const b = document.body.querySelector(E);
4576
+ b !== null ? r.formFragment = A.getFormFragment(
4577
+ S.get(b)
4578
+ ) : p.error(
4452
4579
  "Haori",
4453
4580
  `Form element not found: ${E} (${g.attrName(null, "fetch-form", !0)})`
4454
4581
  );
4455
4582
  } else
4456
4583
  r.formFragment = A.getFormFragment(e);
4457
4584
  }
4458
- const O = t ? g.attrName(t, "fetch-state") : g.attrName(null, "state", !0);
4459
- if (e.hasAttribute(O)) {
4460
- 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 = [];
4461
4588
  E ? (document.body.querySelectorAll(E).forEach((R) => {
4462
- const P = S.get(R);
4463
- P && p.push(P);
4464
- }), p.length === 0 && b.error(
4589
+ const C = S.get(R);
4590
+ C && b.push(C);
4591
+ }), b.length === 0 && p.error(
4465
4592
  "Haori",
4466
- `Element not found: ${E} (${O})`
4467
- )) : 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);
4468
4595
  }
4469
4596
  return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [e], r.defaultSelfBind = !0), r;
4470
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
+ }
4471
4610
  /**
4472
4611
  * ElementFragment の構造的タイプガード。
4473
4612
  *
@@ -4526,41 +4665,41 @@ ${y}
4526
4665
  if (Object.keys(this.options).length === 0 || this.options.formFragment && this.validate(this.options.formFragment) === !1)
4527
4666
  return !1;
4528
4667
  if (this.options.runScript) {
4529
- const h = this.options.targetFragment?.getTarget() ?? null;
4668
+ const d = this.options.targetFragment?.getTarget() ?? null;
4530
4669
  try {
4531
4670
  const u = this.options.runScript.call(
4532
- h,
4671
+ d,
4533
4672
  this.domEvent
4534
4673
  );
4535
4674
  u === !1 && this.domEvent && this.domEvent.preventDefault(), u != null && typeof u.then == "function" && await u;
4536
4675
  } catch (u) {
4537
- b.error("Haori", `Run script execution error: ${u}`);
4676
+ p.error("Haori", `Run script execution error: ${u}`);
4538
4677
  }
4539
4678
  }
4540
4679
  if (!await this.confirm())
4541
4680
  return !1;
4542
4681
  this.options.resetBeforeFragments && this.options.resetBeforeFragments.length > 0 && (await Promise.all(
4543
4682
  this.options.resetBeforeFragments.map(
4544
- (h) => A.reset(h)
4683
+ (d) => A.reset(d)
4545
4684
  )
4546
4685
  ), this.captureHistorySnapshots());
4547
4686
  const r = this.prepareFetchRequest(), i = r.payload;
4548
4687
  let n = r.url, s = r.options;
4549
4688
  if (this.options.beforeCallback) {
4550
- const h = this.options.beforeCallback(
4689
+ const d = this.options.beforeCallback(
4551
4690
  n || null,
4552
4691
  s || null
4553
4692
  );
4554
- if (h != null) {
4555
- if (h === !1 || typeof h == "object" && h.stop)
4693
+ if (d != null) {
4694
+ if (d === !1 || typeof d == "object" && d.stop)
4556
4695
  return !1;
4557
- 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);
4558
4697
  }
4559
4698
  }
4560
4699
  const a = Object.keys(i).length > 0;
4561
4700
  if (n) {
4562
- const h = { ...s || {} }, u = r.requestedMethod, m = r.effectiveMethod, v = r.transportMode === "query-get", T = r.queryString;
4563
- 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", {
4564
4703
  runtime: c.runtime,
4565
4704
  requestedMethod: u,
4566
4705
  effectiveMethod: m,
@@ -4569,23 +4708,23 @@ ${y}
4569
4708
  payload: a ? i : void 0,
4570
4709
  queryString: T
4571
4710
  }), this.options.targetFragment && n) {
4572
- const C = performance.now(), O = {
4711
+ const k = performance.now(), H = {
4573
4712
  runtime: c.runtime,
4574
4713
  requestedMethod: u,
4575
4714
  effectiveMethod: m,
4576
- transportMode: v ? "query-get" : "http",
4577
- ...v ? { queryString: T } : {}
4715
+ transportMode: y ? "query-get" : "http",
4716
+ ...y ? { queryString: T } : {}
4578
4717
  };
4579
4718
  return N.fetchStart(
4580
4719
  this.options.targetFragment.getTarget(),
4581
4720
  n,
4582
- h,
4721
+ d,
4583
4722
  a ? i : void 0,
4584
- O
4585
- ), 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(
4586
4725
  E,
4587
4726
  n || void 0,
4588
- C
4727
+ k
4589
4728
  )).catch(async (E) => {
4590
4729
  throw n && N.fetchError(
4591
4730
  this.options.targetFragment.getTarget(),
@@ -4598,15 +4737,16 @@ ${y}
4598
4737
  ), E;
4599
4738
  });
4600
4739
  }
4601
- 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));
4602
4741
  }
4603
4742
  if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && a) {
4604
- 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();
4605
4744
  e && e.appliedDisabledAttribute && this.options.targetFragment && m.add(this.options.targetFragment);
4606
- const v = h.getBindingData();
4607
- 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);
4608
4747
  }
4609
- 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), {
4610
4750
  headers: { "Content-Type": "application/json" }
4611
4751
  });
4612
4752
  return this.handleFetchResult(l);
@@ -4623,12 +4763,12 @@ ${y}
4623
4763
  if (this.eventType !== "click" || !this.options.targetFragment)
4624
4764
  return null;
4625
4765
  const t = this.options.targetFragment.getTarget();
4626
- if (g.RUNNING_CLICK_TARGETS.has(t) || t.matches(":disabled") || t.hasAttribute("disabled") || t.hasAttribute(he))
4766
+ if (g.RUNNING_CLICK_TARGETS.has(t) || t.matches(":disabled") || t.hasAttribute("disabled") || t.hasAttribute(ge))
4627
4767
  return !1;
4628
4768
  const r = t.hasAttribute(
4629
4769
  `${c.prefix}click-no-disabled`
4630
4770
  );
4631
- return g.RUNNING_CLICK_TARGETS.add(t), t.setAttribute(he, ""), r || t.setAttribute("disabled", ""), {
4771
+ return g.RUNNING_CLICK_TARGETS.add(t), t.setAttribute(ge, ""), r || t.setAttribute("disabled", ""), {
4632
4772
  target: t,
4633
4773
  appliedDisabledAttribute: !r
4634
4774
  };
@@ -4640,15 +4780,15 @@ ${y}
4640
4780
  * @returns 戻り値はありません。
4641
4781
  */
4642
4782
  releaseExecutionLock(e) {
4643
- e && (g.RUNNING_CLICK_TARGETS.delete(e.target), e.target.removeAttribute(he), 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"));
4644
4784
  }
4645
4785
  /**
4646
4786
  * フェッチ後の処理を実行します。
4647
4787
  */
4648
4788
  async handleFetchResult(e, t, r) {
4649
- const i = ie();
4789
+ const i = ne();
4650
4790
  if (!e.ok)
4651
- return Be(e.status) || (this.options.targetFragment && t && N.fetchError(
4791
+ return je(e.status) || (this.options.targetFragment && t && N.fetchError(
4652
4792
  this.options.targetFragment.getTarget(),
4653
4793
  t,
4654
4794
  new Error(`${e.status} ${e.statusText}`),
@@ -4681,7 +4821,7 @@ ${y}
4681
4821
  s.push(new g(a, null).run());
4682
4822
  }), this.options.clickFragments && this.options.clickFragments.length > 0)
4683
4823
  for (const a of this.options.clickFragments) {
4684
- await k.evaluateAll(a);
4824
+ await P.evaluateAll(a);
4685
4825
  const o = a.getTarget();
4686
4826
  typeof o.click == "function" ? o.click() : o.dispatchEvent(
4687
4827
  new MouseEvent("click", { bubbles: !0, cancelable: !0 })
@@ -4689,10 +4829,10 @@ ${y}
4689
4829
  }
4690
4830
  if (this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
4691
4831
  const o = a.getTarget();
4692
- 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);
4693
4833
  }), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
4694
4834
  const o = a.getTarget();
4695
- 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);
4696
4836
  }), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
4697
4837
  this.options.toastMessage,
4698
4838
  this.options.toastLevel ?? "info"
@@ -4700,12 +4840,12 @@ ${y}
4700
4840
  let a = this.options.redirectUrl;
4701
4841
  const o = this.options.redirectReturnParam;
4702
4842
  if (o) {
4703
- const h = new URLSearchParams(window.location.search).get(o);
4704
- if (h !== null) {
4705
- const u = h.trim();
4706
- $e.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(
4707
4847
  "Haori",
4708
- `戻り先パスが安全なローカルパスではないため、既定の遷移先へフォールバックします: ${h}`
4848
+ `戻り先パスが安全なローカルパスではないため、既定の遷移先へフォールバックします: ${d}`
4709
4849
  );
4710
4850
  }
4711
4851
  }
@@ -4727,20 +4867,20 @@ ${y}
4727
4867
  const s = e ? this.options.historyUrl : window.location.pathname, a = new URL(s, window.location.href);
4728
4868
  if (a.origin !== window.location.origin) {
4729
4869
  const l = "history.pushState: cross-origin URL is not allowed: " + a.toString();
4730
- b.error("Haori", l);
4870
+ p.error("Haori", l);
4731
4871
  return;
4732
4872
  }
4733
4873
  const o = (l) => {
4734
- for (const [h, u] of Object.entries(l))
4735
- 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)));
4736
4876
  };
4737
4877
  i && o(t), n && o(r), history.pushState(
4738
- { [Qe]: !0 },
4878
+ { [it]: !0 },
4739
4879
  "",
4740
4880
  a.toString()
4741
4881
  );
4742
4882
  } catch (s) {
4743
- b.error("Haori", `history.pushState failed: ${s}`);
4883
+ p.error("Haori", `history.pushState failed: ${s}`);
4744
4884
  }
4745
4885
  }
4746
4886
  /**
@@ -4750,10 +4890,10 @@ ${y}
4750
4890
  let t = null;
4751
4891
  this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
4752
4892
  const r = t ? t.getTarget() : document.body;
4753
- await ie().clearMessages(r);
4893
+ await ne().clearMessages(r);
4754
4894
  const i = async (a) => {
4755
4895
  const o = t ? t.getTarget() : document.body;
4756
- await ie().addErrorMessage(o, a);
4896
+ await ne().addErrorMessage(o, a);
4757
4897
  }, n = () => {
4758
4898
  if (!this.options.scrollOnError)
4759
4899
  return;
@@ -4764,35 +4904,35 @@ ${y}
4764
4904
  try {
4765
4905
  const a = await e.json(), o = [];
4766
4906
  if (Array.isArray(a)) {
4767
- const l = /* @__PURE__ */ new Map(), h = [];
4907
+ const l = /* @__PURE__ */ new Map(), d = [];
4768
4908
  for (const u of a)
4769
4909
  if (u && typeof u == "object" && !Array.isArray(u)) {
4770
- 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) : "";
4771
- 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)
4772
4912
  continue;
4773
4913
  if (T !== null) {
4774
- const O = l.get(T) ?? [];
4775
- O.push(C), l.set(T, O);
4914
+ const H = l.get(T) ?? [];
4915
+ H.push(k), l.set(T, H);
4776
4916
  } else
4777
- h.push(C);
4778
- } 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);
4779
4919
  for (const [u, m] of l)
4780
4920
  o.push({ key: u, message: m.join(`
4781
4921
  `) });
4782
- for (const u of h)
4922
+ for (const u of d)
4783
4923
  o.push({ message: u });
4784
4924
  } else if (a && typeof a == "object") {
4785
4925
  if (typeof a.message == "string" && o.push({ message: a.message }), Array.isArray(a.messages))
4786
4926
  for (const l of a.messages)
4787
4927
  typeof l == "string" && o.push({ message: l });
4788
4928
  if (a.errors && typeof a.errors == "object")
4789
- for (const [l, h] of Object.entries(a.errors))
4790
- Array.isArray(h) ? o.push({ key: l, message: h.join(`
4791
- `) }) : 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) });
4792
4932
  if (o.length === 0)
4793
- for (const [l, h] of Object.entries(a))
4794
- l === "message" || l === "messages" || l === "errors" || (Array.isArray(h) ? o.push({ key: l, message: h.join(`
4795
- `) }) : 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 }));
4796
4936
  }
4797
4937
  if (o.length === 0)
4798
4938
  return await i(`${e.status} ${e.statusText}`), n(), !1;
@@ -4856,7 +4996,7 @@ ${y}
4856
4996
  */
4857
4997
  confirm() {
4858
4998
  const e = this.options.confirmMessage;
4859
- return e == null ? Promise.resolve(!0) : ie().confirm(e);
4999
+ return e == null ? Promise.resolve(!0) : ne().confirm(e);
4860
5000
  }
4861
5001
  /**
4862
5002
  * 結果データを対象のフラグメントにバインドします。
@@ -4877,7 +5017,7 @@ ${y}
4877
5017
  response: i
4878
5018
  });
4879
5019
  } catch (s) {
4880
- b.error("Haori", `Invalid bind-transform: ${s}`);
5020
+ p.error("Haori", `Invalid bind-transform: ${s}`);
4881
5021
  }
4882
5022
  if (this.options.bindParams) {
4883
5023
  const s = {};
@@ -4885,21 +5025,28 @@ ${y}
4885
5025
  i && typeof i == "object" && a in i && (s[a] = i[a]);
4886
5026
  }), i = s;
4887
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
+ }
4888
5035
  const n = [];
4889
5036
  if (this.options.bindArg)
4890
5037
  this.options.bindFragments.forEach((s) => {
4891
5038
  const a = { ...s.getRawBindingData() ?? {} }, o = this.options.bindArg;
4892
5039
  if (i && typeof i == "object" && !Array.isArray(i)) {
4893
- 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 : {};
4894
5041
  a[o] = this.mergeAppendBindingData(
4895
5042
  s,
4896
5043
  i,
4897
- h
5044
+ d
4898
5045
  );
4899
5046
  } else
4900
5047
  a[o] = i;
4901
5048
  n.push(
4902
- k.setBindingData(
5049
+ P.setBindingData(
4903
5050
  s.getTarget(),
4904
5051
  a,
4905
5052
  /* @__PURE__ */ new Set(),
@@ -4913,13 +5060,13 @@ ${y}
4913
5060
  });
4914
5061
  else if (typeof i == "string") {
4915
5062
  if (this.options.defaultSelfBind) {
4916
- b.warn(
5063
+ p.warn(
4917
5064
  "Haori",
4918
5065
  "string data is not bound because no bind target was specified."
4919
5066
  );
4920
5067
  return;
4921
5068
  }
4922
- 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(
4923
5070
  new Error("string data cannot be bound without a bindArg.")
4924
5071
  );
4925
5072
  } else
@@ -4929,7 +5076,7 @@ ${y}
4929
5076
  i
4930
5077
  ), o = this.options.bindMerge ? { ...s.getRawBindingData() ?? {}, ...a } : a;
4931
5078
  n.push(
4932
- k.setBindingData(
5079
+ P.setBindingData(
4933
5080
  s.getTarget(),
4934
5081
  o,
4935
5082
  /* @__PURE__ */ new Set(),
@@ -4970,7 +5117,7 @@ ${y}
4970
5117
  ...i.getBindingData(),
4971
5118
  ...t
4972
5119
  };
4973
- return k.setBindingData(i.getTarget(), n);
5120
+ return P.setBindingData(i.getTarget(), n);
4974
5121
  });
4975
5122
  return Promise.all(r).then(() => {
4976
5123
  });
@@ -4979,7 +5126,7 @@ ${y}
4979
5126
  * copy のコピー元データを取得します。
4980
5127
  */
4981
5128
  resolveCopySourceData() {
4982
- 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() } : {};
4983
5130
  }
4984
5131
  /**
4985
5132
  * data 属性とフォーム値を統合した送信データを作成します。
@@ -4997,12 +5144,13 @@ ${y}
4997
5144
  buildPayloadResolution() {
4998
5145
  const e = {};
4999
5146
  let t = !1;
5000
- 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) {
5001
- 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(
5002
5150
  this.options.targetFragment,
5003
5151
  this.options.dataAttrName
5004
5152
  );
5005
- t = t || r.hasUnresolvedReference, r.value && Object.assign(e, r.value);
5153
+ t = t || i.hasUnresolvedReference, i.value && Object.assign(e, i.value);
5006
5154
  }
5007
5155
  return { payload: e, hasUnresolvedReference: t };
5008
5156
  }
@@ -5039,37 +5187,49 @@ ${y}
5039
5187
  let i = this.options.fetchUrl;
5040
5188
  const n = { ...this.options.fetchOptions || {} }, s = new Headers(
5041
5189
  n.headers || void 0
5042
- ), a = (n.method || "GET").toUpperCase(), o = c.runtime === "demo" && !_e(a), l = o ? "GET" : a;
5043
- if (n.method = l, l === "GET" || l === "HEAD" || l === "OPTIONS")
5044
- Object.keys(t).length > 0 && (i = tt(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));
5045
5203
  else if (Object.keys(t).length > 0) {
5046
5204
  const u = s.get("Content-Type") || "";
5047
5205
  if (/multipart\/form-data/i.test(u)) {
5048
5206
  s.delete("Content-Type");
5049
5207
  const m = new FormData();
5050
- for (const [v, T] of Object.entries(t))
5051
- 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));
5052
5212
  n.body = m;
5053
5213
  } else if (/application\/x-www-form-urlencoded/i.test(u)) {
5054
5214
  const m = new URLSearchParams();
5055
- for (const [v, T] of Object.entries(t))
5056
- 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)));
5057
5217
  n.body = m;
5058
5218
  } else
5059
5219
  s.set("Content-Type", "application/json"), n.body = JSON.stringify(t);
5060
5220
  }
5061
5221
  n.headers = s;
5062
- let h;
5063
- 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")), {
5064
5224
  url: i,
5065
5225
  options: n,
5066
5226
  payload: t,
5067
5227
  hasUnresolvedReference: !1,
5068
5228
  requestedMethod: a,
5069
5229
  effectiveMethod: l,
5070
- queryString: h,
5230
+ queryString: d,
5071
5231
  transportMode: o ? "query-get" : "http",
5072
- signature: it(i, n)
5232
+ signature: ct(i, n)
5073
5233
  };
5074
5234
  }
5075
5235
  /**
@@ -5079,7 +5239,7 @@ ${y}
5079
5239
  this.options.targetFragment && this.options.historyDataAttrName ? this.historyDataSnapshot = g.resolveDataAttribute(
5080
5240
  this.options.targetFragment,
5081
5241
  this.options.historyDataAttrName
5082
- ) : 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;
5083
5243
  }
5084
5244
  /**
5085
5245
  * history-data の評価値を取得します。
@@ -5101,7 +5261,7 @@ ${y}
5101
5261
  if (this.historyFormSnapshot !== void 0)
5102
5262
  return this.historyFormSnapshot;
5103
5263
  if (this.options.historyFormFragment)
5104
- return A.getValues(this.options.historyFormFragment);
5264
+ return se(this.options.historyFormFragment);
5105
5265
  }
5106
5266
  /**
5107
5267
  * copy-params が指定されている場合は include / exclude を考慮して抽出します。
@@ -5149,11 +5309,11 @@ ${y}
5149
5309
  */
5150
5310
  getRowFragment() {
5151
5311
  if (!this.options.targetFragment)
5152
- 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;
5153
5313
  const e = this.options.targetFragment.closestByAttribute(
5154
5314
  `${c.prefix}row`
5155
5315
  );
5156
- return e || (b.error("Haori", "Row fragment not found."), null);
5316
+ return e || (p.error("Haori", "Row fragment not found."), null);
5157
5317
  }
5158
5318
  /**
5159
5319
  * 行を追加します。
@@ -5169,7 +5329,7 @@ ${y}
5169
5329
  const t = [], r = e.clone();
5170
5330
  return t.push(
5171
5331
  e.getParent().insertAfter(r, e)
5172
- ), 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(() => {
5173
5333
  });
5174
5334
  }
5175
5335
  /**
@@ -5252,14 +5412,14 @@ ${y}
5252
5412
  ...s.getRawBindingData() ?? {},
5253
5413
  _fetch: n
5254
5414
  };
5255
- return k.setBindingData(a, o, /* @__PURE__ */ new Set(), !1, !1);
5415
+ return P.setBindingData(a, o, /* @__PURE__ */ new Set(), !1, !1);
5256
5416
  })
5257
5417
  );
5258
5418
  }
5259
5419
  };
5260
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();
5261
5421
  let q = g;
5262
- class nt {
5422
+ class dt {
5263
5423
  /**
5264
5424
  * 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
5265
5425
  *
@@ -5277,28 +5437,28 @@ class nt {
5277
5437
  try {
5278
5438
  r = await fetch(e, t);
5279
5439
  } catch (n) {
5280
- 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}`);
5281
5441
  }
5282
5442
  if (!r.ok) {
5283
- Be(r.status);
5443
+ je(r.status);
5284
5444
  const n = `${r.status} ${r.statusText}`;
5285
- 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}`);
5286
5446
  }
5287
5447
  let i;
5288
5448
  try {
5289
5449
  i = await r.text();
5290
5450
  } catch (n) {
5291
- 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}`);
5292
5452
  }
5293
5453
  try {
5294
5454
  const s = new DOMParser().parseFromString(i, "text/html");
5295
- 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);
5296
5456
  } catch (n) {
5297
- 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;
5298
5458
  }
5299
5459
  }
5300
5460
  }
5301
- const d = class d {
5461
+ const h = class h {
5302
5462
  /**
5303
5463
  * 遅延属性かどうか(完全名で判定)を判定します。
5304
5464
  *
@@ -5306,7 +5466,7 @@ const d = class d {
5306
5466
  * @returns 遅延属性かどうか
5307
5467
  */
5308
5468
  static isDeferredAttributeName(e) {
5309
- return d.DEFERRED_ATTRIBUTE_SUFFIXES.some(
5469
+ return h.DEFERRED_ATTRIBUTE_SUFFIXES.some(
5310
5470
  (t) => e === `${c.prefix}${t}`
5311
5471
  );
5312
5472
  }
@@ -5317,7 +5477,7 @@ const d = class d {
5317
5477
  * @returns 除外対象かどうか
5318
5478
  */
5319
5479
  static isEvaluateAllExcludedAttributeName(e) {
5320
- return d.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
5480
+ return h.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
5321
5481
  (t) => e === `${c.prefix}${t}`
5322
5482
  );
5323
5483
  }
@@ -5329,7 +5489,7 @@ const d = class d {
5329
5489
  * @returns 再評価する場合は true
5330
5490
  */
5331
5491
  static shouldReevaluateAttribute(e, t) {
5332
- 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);
5333
5493
  }
5334
5494
  /**
5335
5495
  * data-attr-* 形式の属性名から実際に更新する属性名を取得します。
@@ -5338,7 +5498,7 @@ const d = class d {
5338
5498
  * @returns 実際の属性名。data-attr-* でない場合は null
5339
5499
  */
5340
5500
  static getAliasedAttributeName(e) {
5341
- const t = `${c.prefix}${d.ATTRIBUTE_ALIAS_SUFFIX}`;
5501
+ const t = `${c.prefix}${h.ATTRIBUTE_ALIAS_SUFFIX}`;
5342
5502
  return !e.startsWith(t) || e.length <= t.length ? null : e.slice(t.length);
5343
5503
  }
5344
5504
  /**
@@ -5351,7 +5511,7 @@ const d = class d {
5351
5511
  static isAliasedAttributeReflection(e, t) {
5352
5512
  const r = S.get(e);
5353
5513
  return r instanceof M ? r.hasAttribute(
5354
- `${c.prefix}${d.ATTRIBUTE_ALIAS_SUFFIX}${t}`
5514
+ `${c.prefix}${h.ATTRIBUTE_ALIAS_SUFFIX}${t}`
5355
5515
  ) : !1;
5356
5516
  }
5357
5517
  /**
@@ -5365,8 +5525,8 @@ const d = class d {
5365
5525
  let t = Promise.resolve();
5366
5526
  for (const r of e.getAttributeNames()) {
5367
5527
  const i = e.getRawAttribute(r);
5368
- d.shouldReevaluateAttribute(r, i) && (t = t.then(
5369
- () => d.setAttribute(e.getTarget(), r, i)
5528
+ h.shouldReevaluateAttribute(r, i) && (t = t.then(
5529
+ () => h.setAttribute(e.getTarget(), r, i)
5370
5530
  ));
5371
5531
  }
5372
5532
  return t.then(() => {
@@ -5381,7 +5541,7 @@ const d = class d {
5381
5541
  static reevaluateChildren(e) {
5382
5542
  const t = [];
5383
5543
  return e.getChildren().forEach((r) => {
5384
- 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));
5385
5545
  }), Promise.all(t).then(() => {
5386
5546
  });
5387
5547
  }
@@ -5392,7 +5552,7 @@ const d = class d {
5392
5552
  * @returns 再評価状態
5393
5553
  */
5394
5554
  static getReactiveFetchState(e) {
5395
- const t = d.REACTIVE_FETCH_STATES.get(e);
5555
+ const t = h.REACTIVE_FETCH_STATES.get(e);
5396
5556
  if (t)
5397
5557
  return t;
5398
5558
  const r = {
@@ -5400,7 +5560,7 @@ const d = class d {
5400
5560
  running: !1,
5401
5561
  rerunRequested: !1
5402
5562
  };
5403
- return d.REACTIVE_FETCH_STATES.set(e, r), r;
5563
+ return h.REACTIVE_FETCH_STATES.set(e, r), r;
5404
5564
  }
5405
5565
  /**
5406
5566
  * data-import の再評価状態を取得します。
@@ -5409,7 +5569,7 @@ const d = class d {
5409
5569
  * @returns 再評価状態
5410
5570
  */
5411
5571
  static getReactiveImportState(e) {
5412
- const t = d.REACTIVE_IMPORT_STATES.get(e);
5572
+ const t = h.REACTIVE_IMPORT_STATES.get(e);
5413
5573
  if (t)
5414
5574
  return t;
5415
5575
  const r = {
@@ -5417,7 +5577,7 @@ const d = class d {
5417
5577
  running: !1,
5418
5578
  rerunRequested: !1
5419
5579
  };
5420
- return d.REACTIVE_IMPORT_STATES.set(e, r), r;
5580
+ return h.REACTIVE_IMPORT_STATES.set(e, r), r;
5421
5581
  }
5422
5582
  /**
5423
5583
  * bind 更新時に data-fetch / data-import を専用ルートで再評価します。
@@ -5430,9 +5590,9 @@ const d = class d {
5430
5590
  if (t.has(e))
5431
5591
  return Promise.resolve();
5432
5592
  const r = [];
5433
- 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) => {
5434
5594
  i instanceof M && r.push(
5435
- d.reevaluateReactiveSpecialAttributes(i, t)
5595
+ h.reevaluateReactiveSpecialAttributes(i, t)
5436
5596
  );
5437
5597
  }), Promise.all(r).then(() => {
5438
5598
  });
@@ -5444,7 +5604,7 @@ const d = class d {
5444
5604
  * @returns 実行完了の Promise
5445
5605
  */
5446
5606
  static executeManagedFetch(e) {
5447
- 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);
5448
5608
  if (r.running)
5449
5609
  return (i.hasUnresolvedReference || i.signature !== r.lastSignature) && (r.rerunRequested = !0), Promise.resolve();
5450
5610
  if (i.hasUnresolvedReference || i.signature === null)
@@ -5456,7 +5616,7 @@ const d = class d {
5456
5616
  return n.markReentrantBind(), n.runWithResult().then(() => {
5457
5617
  }).finally(() => {
5458
5618
  if (r.running = !1, r.rerunRequested)
5459
- return r.rerunRequested = !1, d.executeManagedFetch(e);
5619
+ return r.rerunRequested = !1, h.executeManagedFetch(e);
5460
5620
  });
5461
5621
  }
5462
5622
  /**
@@ -5466,7 +5626,7 @@ const d = class d {
5466
5626
  * @returns 実行完了の Promise
5467
5627
  */
5468
5628
  static executeManagedImport(e) {
5469
- const t = e.getTarget(), r = d.getReactiveImportState(t), i = e.getAttributeEvaluation(
5629
+ const t = e.getTarget(), r = h.getReactiveImportState(t), i = e.getAttributeEvaluation(
5470
5630
  `${c.prefix}import`
5471
5631
  ), n = i && !i.hasUnresolvedReference && typeof i.value == "string" && i.value !== "" ? i.value : null;
5472
5632
  if (r.running)
@@ -5477,25 +5637,25 @@ const d = class d {
5477
5637
  return Promise.resolve();
5478
5638
  r.lastUrl = n, r.running = !0;
5479
5639
  const s = performance.now();
5480
- return t.setAttribute(`${c.prefix}importing`, ""), N.importStart(t, n), nt.load(n).then((a) => {
5640
+ return t.setAttribute(`${c.prefix}importing`, ""), N.importStart(t, n), dt.load(n).then((a) => {
5481
5641
  const o = new TextEncoder().encode(a).length;
5482
5642
  return I.enqueue(() => {
5483
5643
  t.innerHTML = a;
5484
5644
  }).then(() => {
5485
5645
  if (t.removeAttribute(`${c.prefix}importing`), N.importEnd(t, n, o, s), !document.body.hasAttribute("data-haori-ready")) {
5486
5646
  const l = [];
5487
- return t.childNodes.forEach((h) => {
5488
- const u = S.get(h);
5489
- 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));
5490
5650
  }), Promise.all(l).then(() => {
5491
5651
  });
5492
5652
  }
5493
5653
  });
5494
5654
  }).catch((a) => {
5495
- 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);
5496
5656
  }).finally(() => {
5497
5657
  if (r.running = !1, r.rerunRequested)
5498
- return r.rerunRequested = !1, d.executeManagedImport(e);
5658
+ return r.rerunRequested = !1, h.executeManagedImport(e);
5499
5659
  });
5500
5660
  }
5501
5661
  /**
@@ -5506,7 +5666,7 @@ const d = class d {
5506
5666
  */
5507
5667
  static scan(e) {
5508
5668
  const t = S.get(e);
5509
- return t ? d.initializeElementFragment(t, !1) : Promise.resolve();
5669
+ return t ? h.initializeElementFragment(t, !1) : Promise.resolve();
5510
5670
  }
5511
5671
  /**
5512
5672
  * 新規 each 行を局所初期化します。
@@ -5516,8 +5676,8 @@ const d = class d {
5516
5676
  * @returns 初期化完了の Promise
5517
5677
  */
5518
5678
  static initializeFreshEachRow(e) {
5519
- return d.initializeElementFragment(e, !0).then(() => {
5520
- d.needsScheduledEvaluateAll(e) && d.scheduleEvaluateAll(e);
5679
+ return h.initializeElementFragment(e, !0).then(() => {
5680
+ h.needsScheduledEvaluateAll(e) && h.scheduleEvaluateAll(e);
5521
5681
  });
5522
5682
  }
5523
5683
  /**
@@ -5528,16 +5688,16 @@ const d = class d {
5528
5688
  * @returns 初期化完了の Promise
5529
5689
  */
5530
5690
  static initializeElementFragment(e, t) {
5531
- return d.syncMountedState(e), t && e.isFreshInitializationSkippable() ? Promise.resolve() : d.initializeElementAttributes(e).then(() => {
5532
- if (d.shouldSkipChildInitialization(e, t)) {
5533
- 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);
5534
5694
  return;
5535
5695
  }
5536
5696
  const r = [];
5537
5697
  return e.getChildren().forEach((i) => {
5538
- 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));
5539
5699
  }), Promise.all(r).then(() => {
5540
- d.refreshDerivedSubtreeSignature(e);
5700
+ h.refreshDerivedSubtreeSignature(e);
5541
5701
  });
5542
5702
  });
5543
5703
  }
@@ -5567,10 +5727,10 @@ const d = class d {
5567
5727
  static initializeElementAttributes(e) {
5568
5728
  let t = Promise.resolve();
5569
5729
  const r = /* @__PURE__ */ new Set();
5570
- for (const i of d.PRIORITY_ATTRIBUTE_SUFFIXES) {
5730
+ for (const i of h.PRIORITY_ATTRIBUTE_SUFFIXES) {
5571
5731
  const n = c.prefix + i;
5572
5732
  e.hasAttribute(n) && (t = t.then(
5573
- () => d.setAttribute(
5733
+ () => h.setAttribute(
5574
5734
  e.getTarget(),
5575
5735
  n,
5576
5736
  e.getRawAttribute(n)
@@ -5578,17 +5738,17 @@ const d = class d {
5578
5738
  ), r.add(n));
5579
5739
  }
5580
5740
  for (const i of e.getAttributeNames()) {
5581
- if (r.has(i) || d.isDeferredAttributeName(i))
5741
+ if (r.has(i) || h.isDeferredAttributeName(i))
5582
5742
  continue;
5583
5743
  const n = e.getRawAttribute(i);
5584
5744
  n !== null && (t = t.then(
5585
- () => d.setAttribute(e.getTarget(), i, n)
5745
+ () => h.setAttribute(e.getTarget(), i, n)
5586
5746
  ));
5587
5747
  }
5588
- for (const i of d.DEFERRED_ATTRIBUTE_SUFFIXES) {
5748
+ for (const i of h.DEFERRED_ATTRIBUTE_SUFFIXES) {
5589
5749
  const n = c.prefix + i;
5590
5750
  e.hasAttribute(n) && (t = t.then(
5591
- () => d.setAttribute(
5751
+ () => h.setAttribute(
5592
5752
  e.getTarget(),
5593
5753
  n,
5594
5754
  e.getRawAttribute(n)
@@ -5607,7 +5767,7 @@ const d = class d {
5607
5767
  */
5608
5768
  static shouldSkipChildInitialization(e, t) {
5609
5769
  const r = e.getAttribute(`${c.prefix}if`);
5610
- 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`);
5611
5771
  }
5612
5772
  /**
5613
5773
  * エレメントに属性を設定します。
@@ -5619,7 +5779,7 @@ const d = class d {
5619
5779
  * @returns Promise (DOM操作が完了したときに解決される)
5620
5780
  */
5621
5781
  static setAttribute(e, t, r, i = !1) {
5622
- const n = S.get(e), s = d.getAliasedAttributeName(t);
5782
+ const n = S.get(e), s = h.getAliasedAttributeName(t);
5623
5783
  if (s !== null)
5624
5784
  return r === null ? n.removeAliasedAttribute(t, s) : n.setAliasedAttribute(
5625
5785
  t,
@@ -5636,16 +5796,16 @@ const d = class d {
5636
5796
  else {
5637
5797
  if (i && n instanceof M && n.consumeSelfWrittenBind(r))
5638
5798
  break;
5639
- n.setBindingData(d.parseDataBind(r));
5799
+ n.setBindingData(h.parseDataBind(r));
5640
5800
  }
5641
5801
  break;
5642
5802
  }
5643
5803
  case `${c.prefix}derive`:
5644
- l = d.createDeriveInputSignature(
5804
+ l = h.createDeriveInputSignature(
5645
5805
  n,
5646
5806
  r,
5647
5807
  n.getRawAttribute(`${c.prefix}derive-name`)
5648
- ), o = d.evaluateDerive(
5808
+ ), o = h.evaluateDerive(
5649
5809
  n,
5650
5810
  r,
5651
5811
  n.getRawAttribute(`${c.prefix}derive-name`)
@@ -5653,11 +5813,11 @@ const d = class d {
5653
5813
  }));
5654
5814
  break;
5655
5815
  case `${c.prefix}derive-name`:
5656
- l = d.createDeriveInputSignature(
5816
+ l = h.createDeriveInputSignature(
5657
5817
  n,
5658
5818
  n.getRawAttribute(`${c.prefix}derive`),
5659
5819
  r
5660
- ), o = d.evaluateDerive(
5820
+ ), o = h.evaluateDerive(
5661
5821
  n,
5662
5822
  n.getRawAttribute(`${c.prefix}derive`),
5663
5823
  r
@@ -5665,33 +5825,33 @@ const d = class d {
5665
5825
  }));
5666
5826
  break;
5667
5827
  case `${c.prefix}if`:
5668
- a.push(d.evaluateIf(n));
5828
+ a.push(h.evaluateIf(n));
5669
5829
  break;
5670
5830
  case `${c.prefix}each`:
5671
- a.push(d.evaluateEach(n));
5831
+ a.push(h.evaluateEach(n));
5672
5832
  break;
5673
5833
  case `${c.prefix}fetch`:
5674
- a.push(d.executeManagedFetch(n));
5834
+ a.push(h.executeManagedFetch(n));
5675
5835
  break;
5676
5836
  case `${c.prefix}import`:
5677
- typeof r == "string" && a.push(d.executeManagedImport(n));
5837
+ typeof r == "string" && a.push(h.executeManagedImport(n));
5678
5838
  break;
5679
5839
  case `${c.prefix}url-param`: {
5680
- const h = n.getAttribute(`${c.prefix}url-arg`), u = $e.readParams();
5681
- if (h === null)
5682
- 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));
5683
5843
  else {
5684
5844
  const m = n.getRawBindingData() || {};
5685
- 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));
5686
5846
  }
5687
5847
  break;
5688
5848
  }
5689
5849
  }
5690
5850
  return r === null ? a.push(n.removeAttribute(t)) : a.push(n.setAttribute(t, r, i)), Promise.all(a).then(() => {
5691
5851
  if (o !== null)
5692
- return n.setDeriveInputSignature(l), o.then((h) => {
5693
- if (h)
5694
- return d.reevaluateChildren(n);
5852
+ return n.setDeriveInputSignature(l), o.then((d) => {
5853
+ if (d)
5854
+ return h.reevaluateChildren(n);
5695
5855
  });
5696
5856
  }).then(() => {
5697
5857
  });
@@ -5720,14 +5880,14 @@ const d = class d {
5720
5880
  const o = () => {
5721
5881
  s.markBindingWorkStart();
5722
5882
  const l = s.getRawBindingData() ?? t;
5723
- 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();
5724
5884
  if (e.tagName === "FORM") {
5725
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;
5726
- h = h.then(() => A.syncValues(s, m));
5886
+ d = d.then(() => A.syncValues(s, m));
5727
5887
  }
5728
- return h = h.then(() => d.evaluateAll(s, r)), h = h.then(
5729
- () => d.reevaluateReactiveSpecialAttributes(s, r)
5730
- ), h.then(
5888
+ return d = d.then(() => h.evaluateAll(s, r)), d = d.then(
5889
+ () => h.reevaluateReactiveSpecialAttributes(s, r)
5890
+ ), d.then(
5731
5891
  () => s.markBindingWorkEnd(),
5732
5892
  (u) => {
5733
5893
  throw s.markBindingWorkEnd(), u;
@@ -5777,14 +5937,14 @@ const d = class d {
5777
5937
  if (!t)
5778
5938
  return { resolved: {}, sources: {} };
5779
5939
  const r = t.getBindingData(), i = {}, n = (l) => {
5780
- const h = l.getTarget();
5781
- return h.id ? `#${h.id}` : h.tagName.toLowerCase();
5782
- }, 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) => {
5783
5943
  if (l)
5784
- for (const v of Object.keys(l))
5785
- v in i || (i[v] = {
5786
- value: l[v],
5787
- 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),
5788
5948
  kind: u,
5789
5949
  depth: m
5790
5950
  });
@@ -5792,7 +5952,7 @@ const d = class d {
5792
5952
  let a = t, o = 0;
5793
5953
  for (; a; )
5794
5954
  a !== t && s(a.getRawDerivedBindingData(), a, "derive", o), s(a.getRawBindingData(), a, "bind", o), a = a.getParent(), o += 1;
5795
- 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 };
5796
5956
  }
5797
5957
  /**
5798
5958
  * data-bind 属性の値をパースします。
@@ -5805,7 +5965,7 @@ const d = class d {
5805
5965
  try {
5806
5966
  return JSON.parse(e);
5807
5967
  } catch (t) {
5808
- return b.error("[Haori]", "Invalid JSON in data-bind:", t), {};
5968
+ return p.error("[Haori]", "Invalid JSON in data-bind:", t), {};
5809
5969
  }
5810
5970
  else {
5811
5971
  const t = new URLSearchParams(e), r = {};
@@ -5825,7 +5985,7 @@ const d = class d {
5825
5985
  if (r.isSkipMutationNodes())
5826
5986
  return;
5827
5987
  const i = S.get(t.nextSibling), n = S.get(t);
5828
- 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));
5829
5989
  }
5830
5990
  /**
5831
5991
  * ノードを親要素から削除します。
@@ -5865,11 +6025,11 @@ const d = class d {
5865
6025
  return Promise.resolve();
5866
6026
  const i = [];
5867
6027
  i.push(r.setValue(t));
5868
- const n = d.getFormFragment(r);
6028
+ const n = h.getFormFragment(r);
5869
6029
  if (n) {
5870
6030
  const s = A.getValues(n), a = n.getAttribute(`${c.prefix}form-arg`);
5871
6031
  let o;
5872
- 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));
5873
6033
  }
5874
6034
  return Promise.all(i).then(() => {
5875
6035
  });
@@ -5884,7 +6044,7 @@ const d = class d {
5884
6044
  if (e.getTarget() instanceof HTMLFormElement)
5885
6045
  return e;
5886
6046
  const t = e.getParent();
5887
- return t ? d.getFormFragment(t) : null;
6047
+ return t ? h.getFormFragment(t) : null;
5888
6048
  }
5889
6049
  /**
5890
6050
  * フラグメントとその子要素を評価します。
@@ -5895,21 +6055,21 @@ const d = class d {
5895
6055
  static evaluateAll(e, t = /* @__PURE__ */ new Set()) {
5896
6056
  if (t.has(e))
5897
6057
  return Promise.resolve();
5898
- let r = d.reevaluateInterpolatedAttributes(e);
6058
+ let r = h.reevaluateInterpolatedAttributes(e);
5899
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`);
5900
- let l = !1, h = !1, u = null;
6060
+ let l = !1, d = !1, u = null;
5901
6061
  if (!i && e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), !i && e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), i) {
5902
- const m = d.createDeriveInputSignature(
6062
+ const m = h.createDeriveInputSignature(
5903
6063
  e,
5904
6064
  a,
5905
6065
  o
5906
6066
  );
5907
6067
  m === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
5908
- () => d.evaluateDerive(e, a, o).then(
6068
+ () => h.evaluateDerive(e, a, o).then(
5909
6069
  () => {
5910
6070
  }
5911
6071
  )
5912
- )) : e.getDeriveInputSignature() !== m && (r = r.then(() => d.evaluateDerive(
6072
+ )) : e.getDeriveInputSignature() !== m && (r = r.then(() => h.evaluateDerive(
5913
6073
  e,
5914
6074
  a,
5915
6075
  o
@@ -5917,16 +6077,16 @@ const d = class d {
5917
6077
  e.setDeriveInputSignature(m);
5918
6078
  })));
5919
6079
  }
5920
- 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(() => {
5921
6081
  })) : (i && (r = r.then(() => {
5922
- if (!d.canSkipStableDerivedSubtree(e)) {
5923
- e.setDeriveSubtreeSignature(null), d.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
6082
+ if (!h.canSkipStableDerivedSubtree(e)) {
6083
+ e.setDeriveSubtreeSignature(null), h.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
5924
6084
  return;
5925
6085
  }
5926
- u = d.createDescendantBindingSignature(
6086
+ u = h.createDescendantBindingSignature(
5927
6087
  e,
5928
6088
  "evaluateAll"
5929
- ), h = !0, l = e.getDeriveSubtreeSignature() !== null && e.getDeriveSubtreeSignature() === u, d.logDerivedSubtreeProfileSnapshot(
6089
+ ), d = !0, l = e.getDeriveSubtreeSignature() !== null && e.getDeriveSubtreeSignature() === u, h.logDerivedSubtreeProfileSnapshot(
5930
6090
  e,
5931
6091
  l ? "skip-hit" : "skip-miss"
5932
6092
  );
@@ -5934,16 +6094,16 @@ const d = class d {
5934
6094
  if (l)
5935
6095
  return;
5936
6096
  const m = [];
5937
- return e.getChildren().forEach((v) => {
5938
- if (v instanceof M) {
5939
- if (d.canSkipUnchangedNestedEach(v))
6097
+ return e.getChildren().forEach((y) => {
6098
+ if (y instanceof M) {
6099
+ if (h.canSkipUnchangedNestedEach(y))
5940
6100
  return;
5941
- m.push(d.evaluateAll(v, t));
5942
- } 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));
5943
6103
  }), Promise.all(m).then(() => {
5944
6104
  });
5945
6105
  }).then(() => {
5946
- h && u !== null && e.setDeriveSubtreeSignature(u);
6106
+ d && u !== null && e.setDeriveSubtreeSignature(u);
5947
6107
  }));
5948
6108
  }
5949
6109
  /**
@@ -5971,7 +6131,7 @@ const d = class d {
5971
6131
  const a = {
5972
6132
  [n]: s.value
5973
6133
  };
5974
- 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));
5975
6135
  }
5976
6136
  /**
5977
6137
  * テキストフラグメントを評価します。
@@ -6009,7 +6169,7 @@ const d = class d {
6009
6169
  const t = e.getRawAttribute(`${c.prefix}if`);
6010
6170
  if (typeof t != "string" || t.indexOf("{{") >= 0)
6011
6171
  return;
6012
- 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) ?? [];
6013
6173
  let s = 0;
6014
6174
  n.forEach((o) => {
6015
6175
  const l = t.indexOf(o, s);
@@ -6018,7 +6178,7 @@ const d = class d {
6018
6178
  const a = {};
6019
6179
  i.forEach((o) => {
6020
6180
  o in r && (a[o] = r[o]);
6021
- }), b.info(
6181
+ }), p.info(
6022
6182
  "[Haori]",
6023
6183
  "data-if is falsy (hidden):",
6024
6184
  t,
@@ -6036,8 +6196,8 @@ const d = class d {
6036
6196
  */
6037
6197
  static evaluateIf(e) {
6038
6198
  const t = [], r = e.getAttribute(`${c.prefix}if`);
6039
- if (d.isHiddenIfCondition(r))
6040
- L.isEnabled() && d.logFalsyIfDiagnostics(e), t.push(
6199
+ if (h.isHiddenIfCondition(r))
6200
+ L.isEnabled() && h.logFalsyIfDiagnostics(e), t.push(
6041
6201
  e.hide().then(() => {
6042
6202
  N.hide(e.getTarget());
6043
6203
  })
@@ -6046,11 +6206,11 @@ const d = class d {
6046
6206
  const i = e.isVisible(), n = [];
6047
6207
  e.getChildren().forEach((s) => {
6048
6208
  s instanceof M ? n.push(
6049
- s.isMounted() ? d.evaluateAll(s) : d.scan(s.getTarget())
6050
- ) : 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));
6051
6211
  }), t.push(
6052
6212
  e.show().then(() => {
6053
- N.show(e.getTarget()), i || d.triggerLoadOnShow(e);
6213
+ N.show(e.getTarget()), i || h.triggerLoadOnShow(e);
6054
6214
  })
6055
6215
  ), t.push(Promise.all(n).then(() => {
6056
6216
  }));
@@ -6070,7 +6230,7 @@ const d = class d {
6070
6230
  static triggerLoadOnShow(e) {
6071
6231
  const t = `${c.prefix}load-`;
6072
6232
  e.getTarget().getAttributeNames().some((i) => i.startsWith(t)) && new q(e, "load").run().catch((i) => {
6073
- b.error("[Haori]", "data-load procedure error (on show):", i);
6233
+ p.error("[Haori]", "data-load procedure error (on show):", i);
6074
6234
  });
6075
6235
  }
6076
6236
  /**
@@ -6080,8 +6240,8 @@ const d = class d {
6080
6240
  * @return 再入制御状態
6081
6241
  */
6082
6242
  static getEachUpdateState(e) {
6083
- let t = d.EACH_UPDATE_STATES.get(e);
6084
- 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;
6085
6245
  }
6086
6246
  /**
6087
6247
  * each要素を評価します。
@@ -6099,8 +6259,8 @@ const d = class d {
6099
6259
  static evaluateEach(e) {
6100
6260
  if (!e.isVisible() || !e.isMounted())
6101
6261
  return Promise.resolve();
6102
- const t = d.getEachUpdateState(e);
6103
- 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);
6104
6264
  }
6105
6265
  /**
6106
6266
  * data-each の差分更新を、再評価要求が無くなるまで直列に繰り返し実行します。
@@ -6116,13 +6276,14 @@ const d = class d {
6116
6276
  const r = (async () => {
6117
6277
  try {
6118
6278
  do
6119
- t.rerunRequested = !1, await d.performEachUpdate(e);
6279
+ t.rerunRequested = !1, await h.performEachUpdate(e);
6120
6280
  while (t.rerunRequested);
6121
6281
  const i = e.getTarget();
6122
- i.setAttribute(`${c.prefix}each-done`, ""), d.runEachRenderedScript(i);
6282
+ i.setAttribute(`${c.prefix}each-done`, ""), h.runEachRenderedScript(i);
6123
6283
  } finally {
6124
6284
  t.running = !1, t.settled = null;
6125
6285
  }
6286
+ h.runEachRenderedChange(e);
6126
6287
  })();
6127
6288
  return t.settled = r, r;
6128
6289
  }
@@ -6154,15 +6315,75 @@ ${r}
6154
6315
  ${r}
6155
6316
  `);
6156
6317
  } catch (n) {
6157
- b.error("Haori", `Invalid each-rendered-run script: ${n}`);
6318
+ p.error("[Haori]", `Invalid each-rendered-run script: ${n}`);
6158
6319
  }
6159
6320
  }
6160
6321
  if (i)
6161
6322
  try {
6162
6323
  i.call(e);
6163
6324
  } catch (n) {
6164
- b.error("Haori", `each-rendered-run execution error: ${n}`);
6325
+ p.error("[Haori]", `each-rendered-run execution error: ${n}`);
6326
+ }
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}`);
6165
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;
6166
6387
  }
6167
6388
  /**
6168
6389
  * data-each の差分更新本体を実行します(再入制御は呼び出し側で行います)。
@@ -6171,11 +6392,11 @@ ${r}
6171
6392
  * @return 差分更新完了の Promise
6172
6393
  */
6173
6394
  static performEachUpdate(e) {
6174
- const t = d.resolveEachItems(e);
6395
+ const t = h.resolveEachItems(e);
6175
6396
  if (t === null)
6176
6397
  return Promise.reject(new Error("Invalid each attribute."));
6177
6398
  let r = e.getTemplate();
6178
- const i = e.getAttribute(`${c.prefix}each-key`), n = d.createBindingSignature({
6399
+ const i = e.getAttribute(`${c.prefix}each-key`), n = h.createBindingSignature({
6179
6400
  key: i ? String(i) : null,
6180
6401
  items: t
6181
6402
  });
@@ -6185,7 +6406,7 @@ ${r}
6185
6406
  if (!s && a instanceof M) {
6186
6407
  if (a.hasAttribute(`${c.prefix}each-before`) || a.hasAttribute(`${c.prefix}each-after`))
6187
6408
  return;
6188
- 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);
6189
6410
  const o = a.getTarget();
6190
6411
  o.parentNode && o.parentNode.removeChild(o), a.setMounted(!1);
6191
6412
  }
@@ -6196,10 +6417,10 @@ ${r}
6196
6417
  ).forEach((l) => {
6197
6418
  if (!s) {
6198
6419
  const u = S.get(l);
6199
- 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);
6200
6421
  }
6201
- const h = S.get(l);
6202
- 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);
6203
6424
  });
6204
6425
  }
6205
6426
  return this.updateDiff(e, t).then(() => {
@@ -6218,7 +6439,7 @@ ${r}
6218
6439
  */
6219
6440
  static resolveEachItems(e) {
6220
6441
  const t = e.getAttributeEvaluation(`${c.prefix}each`), r = t?.value;
6221
- 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);
6222
6443
  }
6223
6444
  /**
6224
6445
  * nested data-each の入力が同値で、要素自身に他の動的要素が無い場合は
@@ -6231,12 +6452,12 @@ ${r}
6231
6452
  if (!e.hasAttribute(`${c.prefix}each`) || e.getEachInputSignature() === null)
6232
6453
  return !1;
6233
6454
  const t = e.getParent();
6234
- 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))
6235
6456
  return !1;
6236
- const r = d.resolveEachItems(e);
6457
+ const r = h.resolveEachItems(e);
6237
6458
  if (r === null)
6238
6459
  return !1;
6239
- const i = e.getAttribute(`${c.prefix}each-key`), n = d.createBindingSignature({
6460
+ const i = e.getAttribute(`${c.prefix}each-key`), n = h.createBindingSignature({
6240
6461
  key: i ? String(i) : null,
6241
6462
  items: r
6242
6463
  });
@@ -6250,7 +6471,7 @@ ${r}
6250
6471
  * @returns 省略可能なら true
6251
6472
  */
6252
6473
  static canSkipStableDerivedSubtree(e) {
6253
- 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);
6254
6475
  }
6255
6476
  /**
6256
6477
  * data-derive subtree skip の初期 PoC で扱わない子孫要素を含むかを返します。
@@ -6259,7 +6480,7 @@ ${r}
6259
6480
  * @returns 含むなら true
6260
6481
  */
6261
6482
  static hasDisallowedDerivedSubtreeDescendant(e) {
6262
- 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);
6263
6484
  }
6264
6485
  /**
6265
6486
  * data-derive host が子孫要素へ公開している binding の署名を返します。
@@ -6268,7 +6489,7 @@ ${r}
6268
6489
  * @returns binding 署名
6269
6490
  */
6270
6491
  static createDescendantBindingSignature(e, t) {
6271
- return d.recordDerivedSubtreeSignatureComputation(e, t), d.createBindingSignature(e.getDescendantBindingData());
6492
+ return h.recordDerivedSubtreeSignatureComputation(e, t), h.createBindingSignature(e.getDescendantBindingData());
6272
6493
  }
6273
6494
  /**
6274
6495
  * data-derive 実行前の入力署名を返します。
@@ -6280,7 +6501,7 @@ ${r}
6280
6501
  */
6281
6502
  static createDeriveInputSignature(e, t, r) {
6282
6503
  const i = typeof r == "string" ? r.trim() : "";
6283
- return !t || i === "" ? null : d.createBindingSignature({
6504
+ return !t || i === "" ? null : h.createBindingSignature({
6284
6505
  expression: t,
6285
6506
  name: i,
6286
6507
  scope: e.getBindingData()
@@ -6292,13 +6513,13 @@ ${r}
6292
6513
  * @param fragment 対象フラグメント
6293
6514
  */
6294
6515
  static refreshDerivedSubtreeSignature(e) {
6295
- if (!d.canSkipStableDerivedSubtree(e)) {
6296
- e.setDeriveSubtreeSignature(null), d.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
6516
+ if (!h.canSkipStableDerivedSubtree(e)) {
6517
+ e.setDeriveSubtreeSignature(null), h.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
6297
6518
  return;
6298
6519
  }
6299
6520
  e.setDeriveSubtreeSignature(
6300
- d.createDescendantBindingSignature(e, "refresh")
6301
- ), d.logDerivedSubtreeProfileSnapshot(e, "refresh");
6521
+ h.createDescendantBindingSignature(e, "refresh")
6522
+ ), h.logDerivedSubtreeProfileSnapshot(e, "refresh");
6302
6523
  }
6303
6524
  /**
6304
6525
  * data-derive subtree skip のプロファイルを取得または初期化します。
@@ -6309,11 +6530,11 @@ ${r}
6309
6530
  static getOrCreateDerivedSubtreeProfile(e) {
6310
6531
  if (!L.isEnabled() || !e.hasAttribute(`${c.prefix}derive`))
6311
6532
  return null;
6312
- const t = d.DERIVE_SUBTREE_PROFILES.get(e);
6533
+ const t = h.DERIVE_SUBTREE_PROFILES.get(e);
6313
6534
  if (t)
6314
6535
  return t;
6315
6536
  const r = {
6316
- hostId: d.createDerivedSubtreeHostId(e),
6537
+ hostId: h.createDerivedSubtreeHostId(e),
6317
6538
  signatureComputeTotal: 0,
6318
6539
  signatureComputeFromEvaluateAll: 0,
6319
6540
  signatureComputeFromRefresh: 0,
@@ -6321,7 +6542,7 @@ ${r}
6321
6542
  skipMissCount: 0,
6322
6543
  skipIneligibleCount: 0
6323
6544
  };
6324
- return d.DERIVE_SUBTREE_PROFILES.set(e, r), r;
6545
+ return h.DERIVE_SUBTREE_PROFILES.set(e, r), r;
6325
6546
  }
6326
6547
  /**
6327
6548
  * data-derive subtree host の識別子を作成します。
@@ -6359,7 +6580,7 @@ ${r}
6359
6580
  * @param source 計算元
6360
6581
  */
6361
6582
  static recordDerivedSubtreeSignatureComputation(e, t) {
6362
- const r = d.getOrCreateDerivedSubtreeProfile(e);
6583
+ const r = h.getOrCreateDerivedSubtreeProfile(e);
6363
6584
  if (r !== null) {
6364
6585
  if (r.signatureComputeTotal += 1, t === "refresh") {
6365
6586
  r.signatureComputeFromRefresh += 1;
@@ -6375,8 +6596,8 @@ ${r}
6375
6596
  * @param reason ログ理由
6376
6597
  */
6377
6598
  static logDerivedSubtreeProfileSnapshot(e, t) {
6378
- const r = d.getOrCreateDerivedSubtreeProfile(e);
6379
- 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]", {
6380
6601
  reason: t,
6381
6602
  hostId: r.hostId,
6382
6603
  signatureComputeTotal: r.signatureComputeTotal,
@@ -6418,7 +6639,7 @@ ${r}
6418
6639
  * @returns subtree 全体を省略可能なら true
6419
6640
  */
6420
6641
  static markFreshInitializationSkippable(e) {
6421
- 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;
6422
6643
  return e.setFreshInitializationSkippable(i), i;
6423
6644
  }
6424
6645
  /**
@@ -6443,85 +6664,85 @@ ${r}
6443
6664
  static updateDiff(e, t) {
6444
6665
  const r = e.getTemplate();
6445
6666
  if (r === null)
6446
- 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();
6447
6668
  let i = e.getAttribute(`${c.prefix}each-index`);
6448
6669
  i && (i = String(i));
6449
6670
  const n = e.getAttribute(`${c.prefix}each-key`), s = e.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
6450
- t.forEach((p, y) => {
6451
- const R = d.createListKey(
6452
- p,
6671
+ t.forEach((b, v) => {
6672
+ const R = h.createListKey(
6673
+ b,
6453
6674
  n ? String(n) : null,
6454
- y
6675
+ v
6455
6676
  );
6456
- o.push(R), a.set(R, { item: p, itemIndex: y });
6677
+ o.push(R), a.set(R, { item: b, itemIndex: v });
6457
6678
  });
6458
- const l = new Set(o), h = [];
6459
- let u = e.getChildren().filter((p) => p instanceof M).filter(
6460
- (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`)
6461
6682
  );
6462
- const m = u.map((p) => p.getListKey());
6463
- u = u.filter((p) => l.has(String(p.getListKey())) ? !0 : (h.push(p.remove()), !1));
6464
- const v = u.map((p) => p.getListKey()), T = /* @__PURE__ */ new Map();
6465
- u.forEach((p) => {
6466
- const y = p.getListKey();
6467
- 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);
6468
6689
  });
6469
- const C = e.getChildElementFragments().slice(), O = C.filter(
6470
- (p) => p.hasAttribute(`${c.prefix}each-before`)
6690
+ const k = e.getChildElementFragments().slice(), H = k.filter(
6691
+ (b) => b.hasAttribute(`${c.prefix}each-before`)
6471
6692
  ).length;
6472
6693
  let E = Promise.resolve();
6473
- return o.forEach((p, y) => {
6474
- const { item: R, itemIndex: P } = a.get(p);
6694
+ return o.forEach((b, v) => {
6695
+ const { item: R, itemIndex: C } = a.get(b);
6475
6696
  let F;
6476
- const U = T.get(p);
6697
+ const U = T.get(b);
6477
6698
  if (U)
6478
6699
  F = U, E = E.then(
6479
- () => d.updateRowFragment(
6700
+ () => h.updateRowFragment(
6480
6701
  F,
6481
6702
  R,
6482
6703
  i,
6483
- P,
6704
+ C,
6484
6705
  s ? String(s) : null,
6485
- p
6706
+ b
6486
6707
  ).then(($) => {
6487
6708
  if ($)
6488
- return d.evaluateAll(F);
6709
+ return h.evaluateAll(F);
6489
6710
  })
6490
6711
  );
6491
6712
  else {
6492
6713
  F = r.clone();
6493
- const $ = O + y;
6714
+ const $ = H + v;
6494
6715
  E = E.then(
6495
- () => d.updateRowFragment(
6716
+ () => h.updateRowFragment(
6496
6717
  F,
6497
6718
  R,
6498
6719
  i,
6499
- P,
6720
+ C,
6500
6721
  s ? String(s) : null,
6501
- p
6722
+ b
6502
6723
  ).then(() => {
6503
- const W = C[$] ?? null;
6724
+ const W = k[$] ?? null;
6504
6725
  return e.insertBefore(F, W).then(() => {
6505
- C.splice($, 0, F);
6506
- }).then(() => d.initializeFreshEachRow(F));
6726
+ k.splice($, 0, F);
6727
+ }).then(() => h.initializeFreshEachRow(F));
6507
6728
  })
6508
6729
  );
6509
6730
  }
6510
- }), Promise.all(h).then(() => E).then(() => {
6511
- const p = o.filter(
6731
+ }), Promise.all(d).then(() => E).then(() => {
6732
+ const b = o.filter(
6512
6733
  ($) => $ !== null
6513
- ), y = v.filter(
6734
+ ), v = y.filter(
6514
6735
  ($) => $ !== null
6515
- ), 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(
6516
6737
  ($) => $ !== null
6517
6738
  ).filter(
6518
6739
  ($) => !l.has($)
6519
6740
  );
6520
6741
  N.eachUpdate(
6521
6742
  e.getTarget(),
6522
- P,
6743
+ C,
6523
6744
  U,
6524
- p
6745
+ b
6525
6746
  );
6526
6747
  });
6527
6748
  }
@@ -6567,11 +6788,11 @@ ${r}
6567
6788
  [n]: t
6568
6789
  }, r && (a[r] = i);
6569
6790
  else
6570
- return b.error(
6791
+ return p.error(
6571
6792
  "[Haori]",
6572
6793
  `Primitive value requires '${c.prefix}each-arg' attribute: ${t}`
6573
6794
  ), Promise.resolve(!1);
6574
- const o = a, l = d.createBindingSignature({
6795
+ const o = a, l = h.createBindingSignature({
6575
6796
  listKey: s,
6576
6797
  bindingData: o
6577
6798
  });
@@ -6589,7 +6810,7 @@ ${r}
6589
6810
  const r = t.pop();
6590
6811
  if (r.getChildElementFragments().forEach((i) => {
6591
6812
  t.push(i);
6592
- }), r !== e && !r.isMounted() && d.hasMountSensitiveAttribute(r))
6813
+ }), r !== e && !r.isMounted() && h.hasMountSensitiveAttribute(r))
6593
6814
  return !0;
6594
6815
  }
6595
6816
  return !1;
@@ -6628,11 +6849,15 @@ ${r}
6628
6849
  return e.toString();
6629
6850
  if (e instanceof Date)
6630
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}]`;
6631
6856
  if (Array.isArray(e)) {
6632
6857
  if (t.has(e))
6633
6858
  return `[Circular:${t.get(e)}]`;
6634
6859
  const i = `array-${r.value}`;
6635
- 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(",")}]`;
6636
6861
  }
6637
6862
  if (typeof e == "object") {
6638
6863
  if (t.has(e))
@@ -6641,7 +6866,7 @@ ${r}
6641
6866
  r.value += 1, t.set(e, i);
6642
6867
  const n = e;
6643
6868
  return `{${Object.keys(n).sort().map(
6644
- (s) => `${JSON.stringify(s)}:${d.createBindingSignature(
6869
+ (s) => `${JSON.stringify(s)}:${h.createBindingSignature(
6645
6870
  n[s],
6646
6871
  t,
6647
6872
  r
@@ -6657,18 +6882,18 @@ ${r}
6657
6882
  */
6658
6883
  static scheduleEvaluateAll(e) {
6659
6884
  setTimeout(() => {
6660
- d.evaluateAll(e);
6885
+ h.evaluateAll(e);
6661
6886
  }, 100);
6662
6887
  }
6663
6888
  };
6664
- d.ATTRIBUTE_ALIAS_SUFFIX = "attr-", d.PRIORITY_ATTRIBUTE_SUFFIXES = [
6889
+ h.ATTRIBUTE_ALIAS_SUFFIX = "attr-", h.PRIORITY_ATTRIBUTE_SUFFIXES = [
6665
6890
  "bind",
6666
6891
  "url-param",
6667
6892
  "derive-name",
6668
6893
  "derive",
6669
6894
  "if",
6670
6895
  "each"
6671
- ], d.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch"], d.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
6896
+ ], h.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch"], h.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
6672
6897
  "bind",
6673
6898
  "derive",
6674
6899
  "derive-name",
@@ -6677,8 +6902,8 @@ d.ATTRIBUTE_ALIAS_SUFFIX = "attr-", d.PRIORITY_ATTRIBUTE_SUFFIXES = [
6677
6902
  "fetch",
6678
6903
  "import",
6679
6904
  "url-param"
6680
- ], 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();
6681
- 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;
6682
6907
  const ee = class ee {
6683
6908
  /**
6684
6909
  * コンストラクタ。
@@ -6686,26 +6911,83 @@ const ee = class ee {
6686
6911
  * @param root 監視対象のルート要素(デフォルトは document )
6687
6912
  */
6688
6913
  constructor(e = document) {
6689
- 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 = () => {
6690
- const t = document.documentElement, r = S.get(t);
6691
- 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();
6692
6920
  }, this.onPopstate = (t) => {
6693
6921
  const r = t.state;
6694
6922
  !r || r[ee.HISTORY_STATE_KEY] !== !0 || location.reload();
6695
6923
  }, this.root = e;
6696
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
+ }
6697
6934
  /**
6698
6935
  * イベントリスナーの登録を開始します。
6699
6936
  * クリック、変更、ロード、popstate イベントを監視し、対応するProcedureを実行します。
6700
6937
  */
6701
6938
  start() {
6702
- 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));
6703
6985
  }
6704
6986
  /**
6705
6987
  * イベントリスナーの登録を停止します。
6706
6988
  */
6707
6989
  stop() {
6708
- 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;
6709
6991
  for (const [e, t] of this.customEventHandlers)
6710
6992
  window.removeEventListener(e, t, !0);
6711
6993
  this.customEventHandlers.clear(), this.customEventObserver?.disconnect(), this.customEventObserver = void 0;
@@ -6744,7 +7026,7 @@ const ee = class ee {
6744
7026
  if (e === null || e === "")
6745
7027
  return;
6746
7028
  if (ee.BUILTIN_EVENT_NAMES.has(e)) {
6747
- b.warn(
7029
+ p.warn(
6748
7030
  "[Haori]",
6749
7031
  `data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`
6750
7032
  );
@@ -6763,12 +7045,18 @@ const ee = class ee {
6763
7045
  * @returns 戻り値はない。
6764
7046
  */
6765
7047
  runCustomEventProcedures(e, t) {
7048
+ if (this.deferred) {
7049
+ this.deferredProcedures.push(
7050
+ () => this.runCustomEventProcedures(e, t)
7051
+ );
7052
+ return;
7053
+ }
6766
7054
  this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach((i) => {
6767
7055
  if (i.getAttribute(this.onAttributeName) !== e)
6768
7056
  return;
6769
7057
  const n = S.get(i);
6770
7058
  n instanceof M && new q(n, "on", t).run().catch((s) => {
6771
- b.error("[Haori]", "Procedure execution error:", s);
7059
+ p.error("[Haori]", "Procedure execution error:", s);
6772
7060
  });
6773
7061
  });
6774
7062
  }
@@ -6804,32 +7092,48 @@ const ee = class ee {
6804
7092
  */
6805
7093
  delegate(e, t) {
6806
7094
  const r = this.getElementFromTarget(e.target, t);
6807
- if (!r)
6808
- return;
6809
- if (t === "input") {
6810
- const s = `${c.prefix}input-`;
6811
- 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
+ });
6812
7105
  return;
7106
+ }
7107
+ this.runProcedureFor(r, t, e);
6813
7108
  }
6814
- r.hasAttribute(`${c.prefix}${t}-prevent`) && e.preventDefault();
6815
- 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);
6816
7120
  if (!i)
6817
7121
  return;
6818
- if ((t === "change" || t === "input") && i instanceof M && (i.syncValue(), r instanceof HTMLInputElement && r.type === "radio" && r.name)) {
6819
- 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);
6820
7124
  for (const a of Array.from(s)) {
6821
- 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)
6822
7126
  continue;
6823
7127
  const o = S.get(a);
6824
7128
  o instanceof M && o.syncValue();
6825
7129
  }
6826
7130
  }
6827
7131
  const n = () => {
6828
- new q(i, t, e).run().catch((s) => {
6829
- b.error("[Haori]", "Procedure execution error:", s);
7132
+ new q(i, t, r).run().catch((s) => {
7133
+ p.error("[Haori]", "Procedure execution error:", s);
6830
7134
  });
6831
7135
  };
6832
- if (t === "click" && r.hasAttribute(`${c.prefix}click-defer`)) {
7136
+ if (t === "click" && e.hasAttribute(`${c.prefix}click-defer`)) {
6833
7137
  typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => n()) : setTimeout(n, 0);
6834
7138
  return;
6835
7139
  }
@@ -6884,7 +7188,7 @@ ee.HISTORY_STATE_KEY = "__haoriHistoryState__", ee.BUILTIN_EVENT_NAMES = /* @__P
6884
7188
  "input",
6885
7189
  "load"
6886
7190
  ]);
6887
- let fe = ee;
7191
+ let be = ee;
6888
7192
  const D = class D {
6889
7193
  /**
6890
7194
  * ノードが現在の Window に属する HTMLElement かどうかを判定します。
@@ -6922,12 +7226,12 @@ const D = class D {
6922
7226
  t && (t.observer.disconnect(), D.registrations.delete(e));
6923
7227
  const o = new IntersectionObserver(
6924
7228
  (l) => {
6925
- const h = D.registrations.get(e);
6926
- h && l.forEach((u) => {
6927
- !u.isIntersecting || h.running || D.isDisabled(h.fragment) || (h.running = !0, new q(h.fragment, "intersect").runWithResult().then((m) => {
6928
- 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));
6929
7233
  }).catch((m) => {
6930
- b.error(
7234
+ p.error(
6931
7235
  "[Haori]",
6932
7236
  "Intersect procedure execution error:",
6933
7237
  m
@@ -6982,7 +7286,7 @@ const D = class D {
6982
7286
  if (typeof r != "string" || r.trim() === "")
6983
7287
  return null;
6984
7288
  const i = document.querySelector(r);
6985
- 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);
6986
7290
  }
6987
7291
  static resolveRootMargin(e) {
6988
7292
  const t = `${c.prefix}intersect-root-margin`, r = e.getAttribute(t);
@@ -7013,7 +7317,7 @@ D.CONFIG_KEYS = /* @__PURE__ */ new Set([
7013
7317
  "once"
7014
7318
  ]), D.registrations = /* @__PURE__ */ new Map();
7015
7319
  let _ = D;
7016
- function st(f) {
7320
+ function ht(f) {
7017
7321
  typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => f()) : Promise.resolve().then(f);
7018
7322
  }
7019
7323
  const w = class w {
@@ -7055,7 +7359,7 @@ const w = class w {
7055
7359
  return;
7056
7360
  const i = w.resolveVarName(r);
7057
7361
  if (i === "") {
7058
- t && (t.observer.disconnect(), w.registrations.delete(e)), b.warn(
7362
+ t && (t.observer.disconnect(), w.registrations.delete(e)), p.warn(
7059
7363
  "[Haori]",
7060
7364
  'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").'
7061
7365
  );
@@ -7069,14 +7373,14 @@ const w = class w {
7069
7373
  t && (t.observer.disconnect(), w.registrations.delete(e));
7070
7374
  const a = new IntersectionObserver(
7071
7375
  (l) => {
7072
- const h = w.registrations.get(e);
7073
- if (!h)
7376
+ const d = w.registrations.get(e);
7377
+ if (!d)
7074
7378
  return;
7075
7379
  let u = !1;
7076
7380
  l.forEach((m) => {
7077
- const v = m.target;
7078
- h.observedRows.has(v) && (m.isIntersecting ? h.visibleRows.has(v) || (h.visibleRows.add(v), u = !0) : h.visibleRows.delete(v) && (u = !0));
7079
- }), 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);
7080
7384
  },
7081
7385
  {
7082
7386
  root: n,
@@ -7152,7 +7456,7 @@ const w = class w {
7152
7456
  if (typeof r != "string" || r.trim() === "")
7153
7457
  return null;
7154
7458
  const i = document.querySelector(r);
7155
- 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);
7156
7460
  }
7157
7461
  /**
7158
7462
  * rootMargin を解決します。
@@ -7195,7 +7499,7 @@ const w = class w {
7195
7499
  * @param registration 対象の登録
7196
7500
  */
7197
7501
  static scheduleCompute(e) {
7198
- e.scheduled || (e.scheduled = !0, st(() => {
7502
+ e.scheduled || (e.scheduled = !0, ht(() => {
7199
7503
  e.scheduled = !1;
7200
7504
  const t = e.fragment.getTarget();
7201
7505
  w.registrations.get(t) === e && w.computeAndPublish(e);
@@ -7251,7 +7555,7 @@ const w = class w {
7251
7555
  static publish(e, t) {
7252
7556
  const r = w.resolveBindOwner(e.fragment);
7253
7557
  if (!r) {
7254
- b.warn(
7558
+ p.warn(
7255
7559
  "[Haori]",
7256
7560
  "data-each-visible found no ancestor data-bind scope to publish into."
7257
7561
  );
@@ -7262,14 +7566,14 @@ const w = class w {
7262
7566
  };
7263
7567
  n[e.varName] = { ...t };
7264
7568
  const s = e.fragment.getTarget(), a = i === s ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([e.fragment]);
7265
- k.setBindingData(
7569
+ P.setBindingData(
7266
7570
  i,
7267
7571
  n,
7268
7572
  a,
7269
7573
  !1,
7270
7574
  !1
7271
7575
  ).catch((o) => {
7272
- b.error("[Haori]", "Failed to publish visible range:", o);
7576
+ p.error("[Haori]", "Failed to publish visible range:", o);
7273
7577
  });
7274
7578
  }
7275
7579
  /**
@@ -7292,28 +7596,51 @@ const w = class w {
7292
7596
  };
7293
7597
  w.THRESHOLD = 0, w.DEFAULT_ROOT_MARGIN = "0px", w.registrations = /* @__PURE__ */ new Map();
7294
7598
  let J = w;
7295
- const H = class H {
7599
+ const O = class O {
7296
7600
  /**
7297
7601
  * 既存の MutationObserver をすべて停止します。
7298
7602
  */
7299
7603
  static disconnectMutationObservers() {
7300
- H._mutationObservers.forEach((e) => {
7604
+ O._mutationObservers.forEach((e) => {
7301
7605
  e.disconnect();
7302
- }), H._mutationObservers.length = 0;
7606
+ }), O._mutationObservers.length = 0;
7303
7607
  }
7304
7608
  /**
7305
7609
  * 初期化メソッド。
7306
7610
  * ドキュメントのheadとbodyを監視対象として設定します。
7307
7611
  */
7308
7612
  static async init() {
7309
- if (H._initialized)
7613
+ if (O._initialized)
7310
7614
  return;
7311
- H._initialized = !0, H.disconnectMutationObservers();
7312
- const e = await Promise.allSettled([
7313
- k.scan(document.head),
7314
- k.scan(document.body)
7315
- ]), [t, r] = e;
7316
- 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 fe().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;
7317
7644
  }
7318
7645
  /**
7319
7646
  * 指定ノードが「外部管理」サブツリーに属するかどうかを判定します。
@@ -7340,17 +7667,17 @@ const H = class H {
7340
7667
  const t = new MutationObserver(async (r) => {
7341
7668
  for (const i of r)
7342
7669
  try {
7343
- if (H.isExternallyManaged(i.target))
7670
+ if (O.isExternallyManaged(i.target))
7344
7671
  continue;
7345
7672
  switch (i.type) {
7346
7673
  case "attributes": {
7347
7674
  const n = i.target;
7348
- 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(
7349
7676
  n,
7350
7677
  i.attributeName
7351
7678
  ))
7352
7679
  break;
7353
- k.setAttribute(
7680
+ P.setAttribute(
7354
7681
  n,
7355
7682
  i.attributeName,
7356
7683
  n.getAttribute(i.attributeName),
@@ -7360,16 +7687,16 @@ const H = class H {
7360
7687
  }
7361
7688
  case "childList": {
7362
7689
  Array.from(i.removedNodes).forEach((n) => {
7363
- _.cleanupTree(n), J.cleanupTree(n), k.removeNode(n);
7690
+ _.cleanupTree(n), J.cleanupTree(n), P.removeNode(n);
7364
7691
  }), Array.from(i.addedNodes).forEach((n) => {
7365
- 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));
7366
7693
  }), i.target instanceof Element && J.syncElement(
7367
7694
  i.target
7368
7695
  );
7369
7696
  break;
7370
7697
  }
7371
7698
  case "characterData": {
7372
- 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(
7373
7700
  "[Haori]",
7374
7701
  "Unsupported character data type:",
7375
7702
  i.target
@@ -7377,11 +7704,11 @@ const H = class H {
7377
7704
  break;
7378
7705
  }
7379
7706
  default:
7380
- b.warn("[Haori]", "Unknown mutation type:", i.type);
7707
+ p.warn("[Haori]", "Unknown mutation type:", i.type);
7381
7708
  continue;
7382
7709
  }
7383
7710
  } catch (n) {
7384
- b.error("[Haori]", "Error processing mutation:", n);
7711
+ p.error("[Haori]", "Error processing mutation:", n);
7385
7712
  }
7386
7713
  });
7387
7714
  t.observe(e, {
@@ -7389,23 +7716,23 @@ const H = class H {
7389
7716
  subtree: !0,
7390
7717
  attributes: !0,
7391
7718
  characterData: !0
7392
- }), H._mutationObservers.push(t);
7719
+ }), O._mutationObservers.push(t);
7393
7720
  }
7394
7721
  };
7395
- H._initialized = !1, H._mutationObservers = [];
7396
- let ae = H;
7397
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", ae.init) : ae.init();
7398
- const at = () => Z.waitForRenders(), ot = "0.24.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";
7399
7726
  export {
7400
- k as Core,
7727
+ P as Core,
7401
7728
  c as Env,
7402
7729
  A as Form,
7403
7730
  S as Fragment,
7404
7731
  Z as Haori,
7405
- b as Log,
7732
+ p as Log,
7406
7733
  I as Queue,
7407
7734
  Z as default,
7408
- ot as version,
7409
- at as waitForRenders
7735
+ gt as version,
7736
+ ft as waitForRenders
7410
7737
  };
7411
7738
  //# sourceMappingURL=haori.es.js.map