haori 0.22.3 → 0.24.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
@@ -1,23 +1,23 @@
1
- const J = class J {
1
+ const X = class X {
2
2
  /**
3
3
  * 開発モードの状態を取得します。
4
4
  *
5
5
  * @returns 開発モードならtrue、そうでなければfalse
6
6
  */
7
7
  static isEnabled() {
8
- return J.devMode;
8
+ return X.devMode;
9
9
  }
10
10
  /**
11
11
  * 開発モードを有効化します。
12
12
  */
13
13
  static enable() {
14
- J.devMode = !0;
14
+ X.devMode = !0;
15
15
  }
16
16
  /**
17
17
  * 開発モードを無効化します。
18
18
  */
19
19
  static disable() {
20
- J.devMode = !1;
20
+ X.devMode = !1;
21
21
  }
22
22
  /**
23
23
  * 開発モードを切り替えます。
@@ -25,11 +25,11 @@ const J = class J {
25
25
  * @param enabled trueで有効化、falseで無効化
26
26
  */
27
27
  static set(e) {
28
- J.devMode = e;
28
+ X.devMode = e;
29
29
  }
30
30
  };
31
- J.devMode = !1;
32
- let L = J;
31
+ X.devMode = !1;
32
+ let L = X;
33
33
  const de = "embedded";
34
34
  function Se(f) {
35
35
  return f === "embedded" || f === "demo";
@@ -37,14 +37,14 @@ function Se(f) {
37
37
  function Oe(f) {
38
38
  return f === null ? null : Se(f) ? f : de;
39
39
  }
40
- const U = class U {
40
+ const V = class V {
41
41
  /**
42
42
  * 実行モードを取得します。
43
43
  *
44
44
  * @returns 実行モード。
45
45
  */
46
46
  static get runtime() {
47
- return U._runtime;
47
+ return V._runtime;
48
48
  }
49
49
  /**
50
50
  * 実行モードを設定します。
@@ -53,7 +53,7 @@ const U = class U {
53
53
  * @return 戻り値はありません。
54
54
  */
55
55
  static setRuntime(e) {
56
- U._runtime = Se(e) ? e : de;
56
+ V._runtime = Se(e) ? e : de;
57
57
  }
58
58
  /**
59
59
  * 実行環境からプレフィックスと開発モードかどうかを自動検出します。
@@ -65,14 +65,14 @@ const U = class U {
65
65
  try {
66
66
  const e = document.currentScript || document.querySelector('script[src*="haori"]');
67
67
  if (e instanceof HTMLScriptElement) {
68
- const r = e.getAttribute("data-prefix") || U._prefix;
69
- U._prefix = r.endsWith("-") ? r : r + "-";
68
+ const r = e.getAttribute("data-prefix") || V._prefix;
69
+ V._prefix = r.endsWith("-") ? r : r + "-";
70
70
  const i = Oe(
71
71
  e.getAttribute("data-runtime")
72
72
  );
73
- i !== null && (U._runtime = i);
73
+ i !== null && (V._runtime = i);
74
74
  }
75
- if (e instanceof HTMLScriptElement && e.hasAttribute(`${U._prefix}dev`)) {
75
+ if (e instanceof HTMLScriptElement && e.hasAttribute(`${V._prefix}dev`)) {
76
76
  L.set(!0);
77
77
  return;
78
78
  }
@@ -91,13 +91,13 @@ const U = class U {
91
91
  * @returns プレフィックス
92
92
  */
93
93
  static get prefix() {
94
- return U._prefix;
94
+ return V._prefix;
95
95
  }
96
96
  };
97
- U._prefix = "data-", U._runtime = de;
98
- let c = U;
97
+ V._prefix = "data-", V._runtime = de;
98
+ let c = V;
99
99
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
100
- class m {
100
+ class b {
101
101
  /**
102
102
  * 開発モードでのみコンソールに情報を出力します。
103
103
  *
@@ -127,21 +127,21 @@ class m {
127
127
  }
128
128
  }
129
129
  const He = "yyyy/MM/dd HH:mm", Le = "en-US", Ee = 1e4;
130
- function W(f) {
130
+ function K(f) {
131
131
  return String(f).padStart(2, "0");
132
132
  }
133
133
  function we(f, e, t, r, i, n) {
134
134
  return {
135
135
  yyyy: String(f).padStart(4, "0"),
136
- yy: W(f % 100),
137
- MM: W(e),
136
+ yy: K(f % 100),
137
+ MM: K(e),
138
138
  M: String(e),
139
- dd: W(t),
139
+ dd: K(t),
140
140
  d: String(t),
141
- HH: W(r),
141
+ HH: K(r),
142
142
  H: String(r),
143
- mm: W(i),
144
- ss: W(n)
143
+ mm: K(i),
144
+ ss: K(n)
145
145
  };
146
146
  }
147
147
  function Ue(f, e) {
@@ -226,7 +226,7 @@ function De(f, e, t) {
226
226
  s.push(a);
227
227
  return s;
228
228
  }
229
- function Ne(f, e, t = {}) {
229
+ function Fe(f, e, t = {}) {
230
230
  const r = Math.trunc(Number(f));
231
231
  if (!Number.isFinite(r) || r <= 0)
232
232
  return [];
@@ -240,16 +240,16 @@ function Ne(f, e, t = {}) {
240
240
  a.add(u);
241
241
  for (let u = Math.max(0, i - n); u <= Math.min(r - 1, i + n); u += 1)
242
242
  a.add(u);
243
- const o = Array.from(a).sort((u, p) => u - p), l = [];
243
+ const o = Array.from(a).sort((u, m) => u - m), l = [];
244
244
  let h = null;
245
245
  for (const u of o) {
246
246
  if (h !== null && u - h > 1)
247
247
  if (u - h === 2) {
248
- const p = h + 1;
248
+ const m = h + 1;
249
249
  l.push({
250
- page: p,
251
- label: p + 1,
252
- active: p === i,
250
+ page: m,
251
+ label: m + 1,
252
+ active: m === i,
253
253
  ellipsis: !1
254
254
  });
255
255
  } else
@@ -278,15 +278,15 @@ function ue(f, e) {
278
278
  if (i < 1 || i > 12)
279
279
  return "";
280
280
  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
- return `${String(a).padStart(4, "0")}-${W(o)}`;
281
+ return `${String(a).padStart(4, "0")}-${K(o)}`;
282
282
  }
283
283
  function qe(f) {
284
284
  if (typeof f == "string" && f.trim() !== "")
285
285
  return ue(f, 0);
286
286
  const e = /* @__PURE__ */ new Date();
287
- return `${String(e.getFullYear()).padStart(4, "0")}-${W(e.getMonth() + 1)}`;
287
+ return `${String(e.getFullYear()).padStart(4, "0")}-${K(e.getMonth() + 1)}`;
288
288
  }
289
- function Fe(f, e) {
289
+ function Ne(f, e) {
290
290
  const t = Math.trunc(Number(f));
291
291
  if (!Number.isFinite(t) || t < 0)
292
292
  return [];
@@ -342,15 +342,15 @@ function ke(f, e) {
342
342
  }
343
343
  return t;
344
344
  }
345
- function Pe(f, e) {
345
+ function Ie(f, e) {
346
346
  return e == null || f == null ? String(f) : String(f[e]);
347
347
  }
348
- function Ie(f, e) {
348
+ function Pe(f, e) {
349
349
  if (!Array.isArray(f))
350
350
  return [];
351
351
  const t = /* @__PURE__ */ new Set(), r = [];
352
352
  for (const i of f) {
353
- const n = Pe(i, e);
353
+ const n = Ie(i, e);
354
354
  t.has(n) || (t.add(n), r.push(i));
355
355
  }
356
356
  return r;
@@ -360,7 +360,7 @@ function Ce(f, e) {
360
360
  return [];
361
361
  const t = /* @__PURE__ */ new Map(), r = [];
362
362
  for (const i of f) {
363
- const n = Pe(i, e), s = t.get(n);
363
+ const n = Ie(i, e), s = t.get(n);
364
364
  if (s === void 0) {
365
365
  const a = i == null ? i : i[e];
366
366
  t.set(n, r.length), r.push({ key: a, items: [i] });
@@ -372,14 +372,14 @@ function Ce(f, e) {
372
372
  const We = Object.freeze({
373
373
  date: Te,
374
374
  number: Re,
375
- pages: Ne,
375
+ pages: Fe,
376
376
  range: De,
377
377
  monthAdd: ue,
378
- monthRange: Fe,
378
+ monthRange: Ne,
379
379
  pageSummary: Me,
380
380
  findBy: xe,
381
381
  sum: ke,
382
- distinct: Ie,
382
+ distinct: Pe,
383
383
  groupBy: Ce
384
384
  }), B = class B {
385
385
  /**
@@ -475,18 +475,18 @@ const We = Object.freeze({
475
475
  */
476
476
  static evaluateDetailed(e, t = {}) {
477
477
  if (this.scheduleForbiddenBindingValueCacheReset(), e.trim() === "")
478
- return m.warn("[Haori]", e, "Expression is empty"), { value: null, unresolvedReference: !1 };
478
+ return b.warn("[Haori]", e, "Expression is empty"), { value: null, unresolvedReference: !1 };
479
479
  if (this.containsDangerousPatterns(e)) {
480
480
  const l = this.detectDisallowedKeywords(e);
481
481
  if (l.length > 0) {
482
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
- m.warn(
483
+ b.warn(
484
484
  "[Haori]",
485
485
  e,
486
486
  "Expression uses disallowed keyword(s): " + l.join(", ") + "." + h
487
487
  );
488
488
  } else
489
- m.warn(
489
+ b.warn(
490
490
  "[Haori]",
491
491
  e,
492
492
  "Expression contains dangerous patterns"
@@ -496,7 +496,7 @@ const We = Object.freeze({
496
496
  const r = this.collectForbiddenKeys(t);
497
497
  if (r.length > 0) {
498
498
  const l = r.join(",");
499
- this.loggedForbiddenKeySignatures.has(l) || (this.loggedForbiddenKeySignatures.add(l), this.scheduleForbiddenKeyLogReset(), m.error(
499
+ this.loggedForbiddenKeySignatures.has(l) || (this.loggedForbiddenKeySignatures.add(l), this.scheduleForbiddenKeyLogReset(), b.error(
500
500
  "[Haori]",
501
501
  "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
502
  ));
@@ -507,7 +507,7 @@ const We = Object.freeze({
507
507
  /* @__PURE__ */ new WeakSet(),
508
508
  i
509
509
  ))
510
- return m.warn(
510
+ return b.warn(
511
511
  "[Haori]",
512
512
  t,
513
513
  "Binded values contain forbidden values"
@@ -518,7 +518,7 @@ const We = Object.freeze({
518
518
  ), s = this.BUILTIN_REFERENCE_PATTERN.test(
519
519
  n
520
520
  );
521
- s && this.BUILTIN_NAMESPACE in t && m.warn(
521
+ s && this.BUILTIN_NAMESPACE in t && b.warn(
522
522
  "[Haori]",
523
523
  `Binding key "${this.BUILTIN_NAMESPACE}" is reserved for built-in helpers; the bound value is ignored in expressions.`
524
524
  );
@@ -532,9 +532,9 @@ const We = Object.freeze({
532
532
  if (h.compileFailed || h.evaluator === null)
533
533
  return { value: null, unresolvedReference: !1 };
534
534
  try {
535
- const u = [], p = this.wrapBoundValues(a);
535
+ const u = [], m = this.wrapBoundValues(a);
536
536
  return h.bindKeys.forEach((v) => {
537
- u.push(p[v]);
537
+ u.push(m[v]);
538
538
  }), {
539
539
  value: this.withBlockedPropertyAccess(
540
540
  () => h.evaluator(...u)
@@ -549,15 +549,15 @@ const We = Object.freeze({
549
549
  continue;
550
550
  }
551
551
  }
552
- const p = this.detectForbiddenIdentifiers(e);
553
- return p.length > 0 && m.warn(
552
+ const m = this.detectForbiddenIdentifiers(e);
553
+ return m.length > 0 && b.warn(
554
554
  "[Haori]",
555
- "Expression references blocked identifier(s): " + p.join(", ") + ". These are blocked in expressions and evaluate to undefined (often the cause of this error). Use spread {...a, ...b} instead of Object.assign.",
555
+ "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
556
  e
557
- ), m.error("[Haori]", "Expression evaluation error:", e, u), u instanceof ReferenceError ? { value: void 0, unresolvedReference: !0 } : { value: null, unresolvedReference: !1 };
557
+ ), b.error("[Haori]", "Expression evaluation error:", e, u), u instanceof ReferenceError ? { value: void 0, unresolvedReference: !0 } : { value: null, unresolvedReference: !1 };
558
558
  }
559
559
  }
560
- return m.error(
560
+ return b.error(
561
561
  "[Haori]",
562
562
  "Failed to recover missing identifiers:",
563
563
  e,
@@ -591,7 +591,7 @@ return (${e});`;
591
591
  compileFailed: !1
592
592
  };
593
593
  } catch (o) {
594
- return m.error(
594
+ return b.error(
595
595
  "[Haori]",
596
596
  "Failed to compile expression:",
597
597
  e,
@@ -1188,7 +1188,7 @@ B.MAX_IDENTIFIER_RECOVERY_COUNT = 8, B.BUILTIN_NAMESPACE = "haori", B.BUILTIN_HE
1188
1188
  "with",
1189
1189
  "yield"
1190
1190
  ]), B.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
1191
- let z = B;
1191
+ let G = B;
1192
1192
  class ge {
1193
1193
  constructor() {
1194
1194
  this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
@@ -1231,13 +1231,13 @@ class ge {
1231
1231
  const r = await t.task();
1232
1232
  t.resolve(r);
1233
1233
  } catch (r) {
1234
- t.reject(r), m.error("[Haori]", `Task ${t.timestamp} failed:`, r);
1234
+ t.reject(r), b.error("[Haori]", `Task ${t.timestamp} failed:`, r);
1235
1235
  }
1236
1236
  if (performance.now() - e > this.MAX_BUDGET)
1237
1237
  break;
1238
1238
  }
1239
1239
  } catch (e) {
1240
- m.error("[Haori]", "Error processing queue:", e);
1240
+ b.error("[Haori]", "Error processing queue:", e);
1241
1241
  } finally {
1242
1242
  this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
1243
1243
  }
@@ -1320,13 +1320,13 @@ const me = class me {
1320
1320
  }
1321
1321
  };
1322
1322
  me.ASYNC_QUEUE = new ge();
1323
- let P = me;
1324
- const F = class F {
1323
+ let I = me;
1324
+ const x = class x {
1325
1325
  /**
1326
1326
  * 集計状態を初期化します。
1327
1327
  */
1328
1328
  static reset() {
1329
- F.ELEMENT_STORES.clear(), F.ensureGlobalAccess();
1329
+ x.ELEMENT_STORES.clear(), x.ensureGlobalAccess();
1330
1330
  }
1331
1331
  /**
1332
1332
  * 現在の集計結果スナップショットを返します。
@@ -1334,7 +1334,7 @@ const F = class F {
1334
1334
  * @returns エレメントごとの集計結果
1335
1335
  */
1336
1336
  static snapshot() {
1337
- return F.ensureGlobalAccess(), [...F.ELEMENT_STORES.entries()].map(([e, t]) => ({
1337
+ return x.ensureGlobalAccess(), [...x.ELEMENT_STORES.entries()].map(([e, t]) => ({
1338
1338
  elementId: e,
1339
1339
  tagName: t.tagName,
1340
1340
  attributes: [...t.attributes.entries()].map(([r, i]) => ({
@@ -1343,7 +1343,7 @@ const F = class F {
1343
1343
  calls: i.calls,
1344
1344
  totalDurationMs: i.totalDurationMs,
1345
1345
  maxDurationMs: i.maxDurationMs,
1346
- placeholders: F.sortPlaceholders(
1346
+ placeholders: x.sortPlaceholders(
1347
1347
  i.placeholders
1348
1348
  )
1349
1349
  })).sort((r, i) => i.calls - r.calls),
@@ -1353,7 +1353,7 @@ const F = class F {
1353
1353
  calls: i.calls,
1354
1354
  totalDurationMs: i.totalDurationMs,
1355
1355
  maxDurationMs: i.maxDurationMs,
1356
- placeholders: F.sortPlaceholders(
1356
+ placeholders: x.sortPlaceholders(
1357
1357
  i.placeholders
1358
1358
  )
1359
1359
  })).sort((r, i) => i.calls - r.calls)
@@ -1371,29 +1371,29 @@ const F = class F {
1371
1371
  static record(e, t, r) {
1372
1372
  if (!L.isEnabled() || !e || t.length === 0)
1373
1373
  return;
1374
- F.ensureGlobalAccess();
1375
- const i = F.getOrCreateElementStore(
1374
+ x.ensureGlobalAccess();
1375
+ const i = x.getOrCreateElementStore(
1376
1376
  e.element
1377
1377
  );
1378
1378
  if (e.kind === "attribute") {
1379
- const s = F.getOrCreateCounter(
1379
+ const s = x.getOrCreateCounter(
1380
1380
  i.attributes,
1381
1381
  e.rawName,
1382
1382
  e.template
1383
1383
  );
1384
- F.updateCounter(
1384
+ x.updateCounter(
1385
1385
  s,
1386
1386
  t,
1387
1387
  r
1388
1388
  );
1389
1389
  return;
1390
1390
  }
1391
- const n = F.getOrCreateCounter(
1391
+ const n = x.getOrCreateCounter(
1392
1392
  i.texts,
1393
1393
  String(e.childIndex),
1394
1394
  e.template
1395
1395
  );
1396
- F.updateCounter(
1396
+ x.updateCounter(
1397
1397
  n,
1398
1398
  t,
1399
1399
  r
@@ -1406,9 +1406,9 @@ const F = class F {
1406
1406
  if (!L.isEnabled())
1407
1407
  return;
1408
1408
  const e = globalThis;
1409
- e[F.GLOBAL_KEY] === void 0 && (e[F.GLOBAL_KEY] = {
1410
- reset: () => F.reset(),
1411
- snapshot: () => F.snapshot()
1409
+ e[x.GLOBAL_KEY] === void 0 && (e[x.GLOBAL_KEY] = {
1410
+ reset: () => x.reset(),
1411
+ snapshot: () => x.snapshot()
1412
1412
  });
1413
1413
  }
1414
1414
  /**
@@ -1418,7 +1418,7 @@ const F = class F {
1418
1418
  * @returns 集計ストア
1419
1419
  */
1420
1420
  static getOrCreateElementStore(e) {
1421
- const t = F.createElementId(e), r = F.ELEMENT_STORES.get(t);
1421
+ const t = x.createElementId(e), r = x.ELEMENT_STORES.get(t);
1422
1422
  if (r)
1423
1423
  return r;
1424
1424
  const i = {
@@ -1426,7 +1426,7 @@ const F = class F {
1426
1426
  attributes: /* @__PURE__ */ new Map(),
1427
1427
  texts: /* @__PURE__ */ new Map()
1428
1428
  };
1429
- return F.ELEMENT_STORES.set(t, i), i;
1429
+ return x.ELEMENT_STORES.set(t, i), i;
1430
1430
  }
1431
1431
  /**
1432
1432
  * カウンタを取得または初期化します。
@@ -1476,7 +1476,7 @@ const F = class F {
1476
1476
  */
1477
1477
  static updateCounter(e, t, r) {
1478
1478
  e.calls += 1, e.totalDurationMs += r, e.maxDurationMs = Math.max(e.maxDurationMs, r), t.forEach((i) => {
1479
- const n = F.getOrCreatePlaceholder(
1479
+ const n = x.getOrCreatePlaceholder(
1480
1480
  e.placeholders,
1481
1481
  i.expression
1482
1482
  );
@@ -1515,10 +1515,10 @@ const F = class F {
1515
1515
  * @returns 結果と所要時間
1516
1516
  */
1517
1517
  static measure(e) {
1518
- const t = F.now();
1518
+ const t = x.now();
1519
1519
  return {
1520
1520
  value: e(),
1521
- durationMs: F.now() - t
1521
+ durationMs: x.now() - t
1522
1522
  };
1523
1523
  }
1524
1524
  /**
@@ -1545,35 +1545,35 @@ const F = class F {
1545
1545
  return t.join(" > ");
1546
1546
  }
1547
1547
  };
1548
- F.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", F.ELEMENT_STORES = /* @__PURE__ */ new Map();
1549
- let ne = F;
1550
- const X = class X {
1548
+ x.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", x.ELEMENT_STORES = /* @__PURE__ */ new Map();
1549
+ let ne = x;
1550
+ const Q = class Q {
1551
1551
  /**
1552
1552
  * フラグメントのコンストラクタ。
1553
1553
  *
1554
1554
  * @param target 対象ノード
1555
1555
  */
1556
1556
  constructor(e) {
1557
- this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e, X.FRAGMENT_CACHE.set(e, this);
1557
+ this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e, Q.FRAGMENT_CACHE.set(e, this);
1558
1558
  }
1559
1559
  static get(e) {
1560
1560
  if (e == null)
1561
1561
  return null;
1562
- if (X.FRAGMENT_CACHE.has(e))
1563
- return X.FRAGMENT_CACHE.get(e);
1562
+ if (Q.FRAGMENT_CACHE.has(e))
1563
+ return Q.FRAGMENT_CACHE.get(e);
1564
1564
  let t;
1565
1565
  switch (e.nodeType) {
1566
1566
  case Node.ELEMENT_NODE:
1567
1567
  t = new M(e);
1568
1568
  break;
1569
1569
  case Node.TEXT_NODE:
1570
- t = new V(e);
1570
+ t = new j(e);
1571
1571
  break;
1572
1572
  case Node.COMMENT_NODE:
1573
1573
  t = new pe(e);
1574
1574
  break;
1575
1575
  default:
1576
- return m.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
1576
+ return b.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
1577
1577
  }
1578
1578
  return t;
1579
1579
  }
@@ -1595,7 +1595,7 @@ const X = class X {
1595
1595
  return Promise.resolve();
1596
1596
  if (this.parent) {
1597
1597
  const e = this.parent, t = e.skipMutationNodes;
1598
- return P.enqueue(() => {
1598
+ return I.enqueue(() => {
1599
1599
  e.skipMutationNodes = !0, this.target.parentNode === e.getTarget() && e.getTarget().removeChild(this.target), this.mounted = !1;
1600
1600
  }).finally(() => {
1601
1601
  e.skipMutationNodes = t;
@@ -1603,7 +1603,7 @@ const X = class X {
1603
1603
  } else {
1604
1604
  const e = this.target.parentNode;
1605
1605
  if (e)
1606
- return P.enqueue(() => {
1606
+ return I.enqueue(() => {
1607
1607
  this.target.parentNode === e && e.removeChild(this.target), this.mounted = !1;
1608
1608
  });
1609
1609
  this.mounted = !1;
@@ -1620,7 +1620,7 @@ const X = class X {
1620
1620
  return Promise.resolve();
1621
1621
  if (this.parent) {
1622
1622
  const e = this.parent, t = e.skipMutationNodes;
1623
- return P.enqueue(() => {
1623
+ return I.enqueue(() => {
1624
1624
  e.skipMutationNodes = !0, this.target.parentNode !== e.getTarget() && e.getTarget().appendChild(this.target), this.mounted = !0;
1625
1625
  }).finally(() => {
1626
1626
  e.skipMutationNodes = t;
@@ -1651,7 +1651,7 @@ const X = class X {
1651
1651
  * @return 除去のPromise
1652
1652
  */
1653
1653
  remove(e = !0) {
1654
- return this.parent && this.parent.removeChild(this), X.FRAGMENT_CACHE.delete(this.target), e ? this.unmount() : Promise.resolve();
1654
+ return this.parent && this.parent.removeChild(this), Q.FRAGMENT_CACHE.delete(this.target), e ? this.unmount() : Promise.resolve();
1655
1655
  }
1656
1656
  /**
1657
1657
  * 対象ノードを取得します。
@@ -1678,9 +1678,9 @@ const X = class X {
1678
1678
  this.parent = e;
1679
1679
  }
1680
1680
  };
1681
- X.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
1682
- let T = X;
1683
- const K = class K extends T {
1681
+ Q.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
1682
+ let S = Q;
1683
+ const z = class z extends S {
1684
1684
  /**
1685
1685
  * エレメントフラグメントのコンストラクタ。
1686
1686
  * アトリビュートや子フラグメントの作成も行います。
@@ -1710,7 +1710,7 @@ const K = class K extends T {
1710
1710
  this.attributeMap.set(t, i);
1711
1711
  }
1712
1712
  }), e.childNodes.forEach((t) => {
1713
- const r = T.get(t);
1713
+ const r = S.get(t);
1714
1714
  r.setParent(this), this.children.push(r);
1715
1715
  });
1716
1716
  }
@@ -1729,7 +1729,7 @@ const K = class K extends T {
1729
1729
  */
1730
1730
  getChildElementFragments() {
1731
1731
  return this.children.filter(
1732
- (e) => e instanceof K
1732
+ (e) => e instanceof z
1733
1733
  );
1734
1734
  }
1735
1735
  /**
@@ -1750,7 +1750,7 @@ const K = class K extends T {
1750
1750
  removeChild(e) {
1751
1751
  const t = this.children.indexOf(e);
1752
1752
  if (t < 0) {
1753
- m.warn("[Haori]", "Child fragment not found.", e);
1753
+ b.warn("[Haori]", "Child fragment not found.", e);
1754
1754
  return;
1755
1755
  }
1756
1756
  this.children.splice(t, 1), e.setParent(null);
@@ -1761,7 +1761,7 @@ const K = class K extends T {
1761
1761
  * @returns クローンされたフラグメント
1762
1762
  */
1763
1763
  clone() {
1764
- const e = new K(
1764
+ const e = new z(
1765
1765
  this.target.cloneNode(!1)
1766
1766
  );
1767
1767
  return this.attributeMap.forEach((t, r) => {
@@ -1776,7 +1776,7 @@ const K = class K extends T {
1776
1776
  */
1777
1777
  normalizeClonedVisibilityState() {
1778
1778
  (this.visible === !1 || this.getTarget().style.display === "none" || this.getTarget().hasAttribute(`${c.prefix}if-false`)) && (this.visible = !0, this.display = null, this.displayPriority = null, this.getTarget().style.removeProperty("display"), this.getTarget().removeAttribute(`${c.prefix}if-false`)), this.children.forEach((e) => {
1779
- e instanceof K && e.normalizeClonedVisibilityState();
1779
+ e instanceof z && e.normalizeClonedVisibilityState();
1780
1780
  });
1781
1781
  }
1782
1782
  /**
@@ -1940,7 +1940,7 @@ const K = class K extends T {
1940
1940
  */
1941
1941
  clearBindingDataCache() {
1942
1942
  this.bindingDataCache = null, this.descendantBindingDataCache = null, this.children.forEach((e) => {
1943
- e instanceof K && e.clearBindingDataCache();
1943
+ e instanceof z && e.clearBindingDataCache();
1944
1944
  });
1945
1945
  }
1946
1946
  /**
@@ -2092,20 +2092,31 @@ const K = class K extends T {
2092
2092
  if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
2093
2093
  const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
2094
2094
  let s;
2095
- return n ? s = e === !0 || e === "true" : i === "false" ? s = e === !1 : Array.isArray(e) ? s = e.map(String).includes(String(i)) : s = i === String(e), n ? this.value = s : s ? Array.isArray(e) ? this.value = String(i) : this.value = e : this.value = null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0, P.enqueue(() => {
2095
+ return n ? s = e === !0 || e === "true" : i === "false" ? s = e === !1 : Array.isArray(e) ? s = e.map(String).includes(String(i)) : s = i === String(e), n ? this.value = s : s ? Array.isArray(e) ? this.value = String(i) : this.value = e : this.value = null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0, I.enqueue(() => {
2096
2096
  r.checked = s, t && r.dispatchEvent(new Event("change", { bubbles: !0 }));
2097
2097
  }).finally(() => {
2098
2098
  this.skipChangeValue = !1;
2099
2099
  }));
2100
+ } else if (r instanceof HTMLSelectElement && r.multiple) {
2101
+ const i = (Array.isArray(e) ? e : e === null ? [] : [e]).map(String);
2102
+ return this.value = i.slice(), this.skipChangeValue = !0, I.enqueue(() => {
2103
+ let n = !1;
2104
+ Array.from(r.options).forEach((s) => {
2105
+ const a = i.includes(s.value);
2106
+ s.selected !== a && (s.selected = a, n = !0);
2107
+ }), n && t && r.dispatchEvent(new Event("change", { bubbles: !0 }));
2108
+ }).finally(() => {
2109
+ this.skipChangeValue = !1;
2110
+ });
2100
2111
  } else if (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement) {
2101
2112
  const i = Array.isArray(e) ? e.join(",") : e;
2102
- return this.value = this.normalizeValueForElement(r, i), this.skipChangeValue = !0, P.enqueue(() => {
2113
+ return this.value = this.normalizeValueForElement(r, i), this.skipChangeValue = !0, I.enqueue(() => {
2103
2114
  r.value = i === null ? "" : String(i), t && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
2104
2115
  }).finally(() => {
2105
2116
  this.skipChangeValue = !1;
2106
2117
  });
2107
2118
  } else
2108
- return m.warn(
2119
+ return b.warn(
2109
2120
  "[Haori]",
2110
2121
  "setValue is not supported for this element type.",
2111
2122
  r
@@ -2164,7 +2175,9 @@ const K = class K extends T {
2164
2175
  }
2165
2176
  } else
2166
2177
  this.value = this.normalizeValueForElement(e, e.value);
2167
- else e instanceof HTMLTextAreaElement ? this.value = e.value : e instanceof HTMLSelectElement && (this.value = e.value);
2178
+ else e instanceof HTMLTextAreaElement ? this.value = e.value : e instanceof HTMLSelectElement && (e.multiple ? this.value = Array.from(e.selectedOptions).map(
2179
+ (t) => t.value
2180
+ ) : this.value = e.value);
2168
2181
  }
2169
2182
  /**
2170
2183
  * 属性の値を評価して設定します。
@@ -2207,7 +2220,7 @@ const K = class K extends T {
2207
2220
  return Promise.resolve();
2208
2221
  this.attributeMap.delete(e), this.skipMutationAttributes = !0;
2209
2222
  const r = this.getTarget();
2210
- return P.enqueue(() => {
2223
+ return I.enqueue(() => {
2211
2224
  r.removeAttribute(e), t !== e && r.removeAttribute(t);
2212
2225
  }).finally(() => {
2213
2226
  this.skipMutationAttributes = !1;
@@ -2231,7 +2244,7 @@ const K = class K extends T {
2231
2244
  if (n) {
2232
2245
  const ce = this.attributeMap.get(e);
2233
2246
  if (ce && (ce.isEvaluate || ce.isForceEvaluation()) && !s.isEvaluate && !s.isForceEvaluation())
2234
- return this.skipMutationAttributes = !0, P.enqueue(() => {
2247
+ return this.skipMutationAttributes = !0, I.enqueue(() => {
2235
2248
  }).finally(() => {
2236
2249
  this.skipMutationAttributes = !1;
2237
2250
  });
@@ -2242,9 +2255,9 @@ const K = class K extends T {
2242
2255
  element: a,
2243
2256
  rawName: e,
2244
2257
  template: r
2245
- }), l = s.isEvaluate || s.isRawEvaluate, h = e === t && K.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), u = s.isSingleExpression(), p = G.joinEvaluateResults(o.results), v = o.results.length === 1 ? o.results[0] : p, R = !s.isForceEvaluation() && (t !== e || h || u ? o.hasUnresolvedReference || v === null || v === void 0 || v === !1 : l && p === ""), I = s.isForceEvaluation() ? r : u ? v : p, A = i && s.isEvaluate && t === "value" && (a instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(a.type) || a instanceof HTMLTextAreaElement || a instanceof HTMLSelectElement), y = a.getRootNode(), b = A && a === y.activeElement, S = R || I === null || I === !1 ? null : String(I), k = e !== t && a.getAttribute(e) !== r, C = S === null ? a.hasAttribute(t) : a.getAttribute(t) !== S, O = A && !b && S !== null && a.value !== S, j = t === "checked" && a instanceof HTMLInputElement && (a.type === "checkbox" || a.type === "radio"), $ = t === "selected" && a instanceof HTMLOptionElement, ee = y.activeElement, be = ee !== null && (j && a === ee || $ && a.closest("select") === ee), te = S !== null, ve = j && !be && a.checked !== te, ye = $ && !be && a.selected !== te;
2246
- return !k && !C && !O && !ve && !ye ? (A && !b && S !== null && (this.value = this.normalizeValueForElement(a, S)), Promise.resolve()) : (this.skipMutationAttributes = !0, P.enqueue(() => {
2247
- k && a.setAttribute(e, r), S === null ? a.removeAttribute(t) : (C && (a.setAttribute(t, S), t === `${c.prefix}bind` && this.recordSelfWrittenBind(S)), A && !b && (this.value = this.normalizeValueForElement(a, S), O && (a.value = S))), ve && (a.checked = te), ye && (a.selected = te);
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);
2248
2261
  }).finally(() => {
2249
2262
  this.skipMutationAttributes = !1;
2250
2263
  }));
@@ -2260,7 +2273,7 @@ const K = class K extends T {
2260
2273
  return Promise.resolve();
2261
2274
  this.attributeMap.delete(e), this.skipMutationAttributes = !0;
2262
2275
  const t = this.getTarget();
2263
- return P.enqueue(() => {
2276
+ return I.enqueue(() => {
2264
2277
  t.removeAttribute(e);
2265
2278
  }).finally(() => {
2266
2279
  this.skipMutationAttributes = !1;
@@ -2296,7 +2309,7 @@ const K = class K extends T {
2296
2309
  value: r.results[0],
2297
2310
  hasUnresolvedReference: r.hasUnresolvedReference
2298
2311
  } : {
2299
- value: G.joinEvaluateResults(r.results),
2312
+ value: Y.joinEvaluateResults(r.results),
2300
2313
  hasUnresolvedReference: r.hasUnresolvedReference
2301
2314
  };
2302
2315
  }
@@ -2341,7 +2354,7 @@ const K = class K extends T {
2341
2354
  const i = t ? r.nextSibling : r;
2342
2355
  let n = t ? r.nextSibling : r;
2343
2356
  for (; n !== null; ) {
2344
- const s = T.get(n);
2357
+ const s = S.get(n);
2345
2358
  if (s !== null) {
2346
2359
  const a = this.children.indexOf(s);
2347
2360
  if (a !== -1)
@@ -2363,13 +2376,13 @@ const K = class K extends T {
2363
2376
  if (this.skipMutationNodes)
2364
2377
  return Promise.resolve();
2365
2378
  if (e === this)
2366
- return m.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
2379
+ return b.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
2367
2380
  const i = /* @__PURE__ */ new Set();
2368
2381
  let n = this.parent;
2369
2382
  for (; n; )
2370
2383
  i.add(n), n = n.getParent();
2371
2384
  if (i.has(e))
2372
- return m.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
2385
+ return b.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
2373
2386
  const s = e.getParent() === this;
2374
2387
  let a = -1, o = -1;
2375
2388
  s && (a = this.children.indexOf(e), t !== null && (o = this.children.indexOf(t)));
@@ -2379,23 +2392,23 @@ const K = class K extends T {
2379
2392
  if (t === null)
2380
2393
  this.children.push(e);
2381
2394
  else {
2382
- let p;
2383
- if (s ? a !== -1 && a < o ? p = o - 1 : p = o : p = this.children.indexOf(t), p === -1) {
2395
+ let m;
2396
+ if (s ? a !== -1 && a < o ? m = o - 1 : m = o : m = this.children.indexOf(t), m === -1) {
2384
2397
  const v = this.resolveInsertionPointFromDom(
2385
2398
  t,
2386
2399
  !1
2387
2400
  );
2388
- v === null ? (m.warn(
2401
+ v === null ? (b.warn(
2389
2402
  "[Haori]",
2390
2403
  "Reference child not found in children.",
2391
2404
  t
2392
2405
  ), this.children.push(e)) : (this.children.splice(v.index, 0, e), h = v.referenceNode);
2393
2406
  } else
2394
- this.children.splice(p, 0, e);
2407
+ this.children.splice(m, 0, e);
2395
2408
  }
2396
2409
  e.setParent(this), e.setMounted(this.mounted);
2397
2410
  const u = this.skipMutationNodes;
2398
- return this.skipMutationNodes = !0, P.enqueue(() => {
2411
+ return this.skipMutationNodes = !0, I.enqueue(() => {
2399
2412
  this.target.insertBefore(e.getTarget(), h);
2400
2413
  }).finally(() => {
2401
2414
  this.skipMutationNodes = u;
@@ -2417,7 +2430,7 @@ const K = class K extends T {
2417
2430
  t,
2418
2431
  !0
2419
2432
  );
2420
- return i === null ? (m.warn(
2433
+ return i === null ? (b.warn(
2421
2434
  "[Haori]",
2422
2435
  "Reference child not found in children.",
2423
2436
  t
@@ -2504,7 +2517,7 @@ const K = class K extends T {
2504
2517
  return t === null ? null : t.closestByAttribute(e);
2505
2518
  }
2506
2519
  };
2507
- K.BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
2520
+ z.BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
2508
2521
  "allowfullscreen",
2509
2522
  "async",
2510
2523
  "autofocus",
@@ -2529,8 +2542,8 @@ K.BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
2529
2542
  "reversed",
2530
2543
  "selected"
2531
2544
  ]);
2532
- let M = K;
2533
- class V extends T {
2545
+ let M = z;
2546
+ class j extends S {
2534
2547
  /**
2535
2548
  * テキストフラグメントのコンストラクタ。
2536
2549
  * 対象テキストノードの内容を初期化します。
@@ -2538,7 +2551,7 @@ class V extends T {
2538
2551
  * @param target 対象テキストノード
2539
2552
  */
2540
2553
  constructor(e) {
2541
- super(e), this.skipMutation = !1, this.renderedText = null, this.text = e.textContent || "", this.contents = new G(this.text);
2554
+ super(e), this.skipMutation = !1, this.renderedText = null, this.text = e.textContent || "", this.contents = new Y(this.text);
2542
2555
  }
2543
2556
  /**
2544
2557
  * フラグメントをクローンします。
@@ -2546,7 +2559,7 @@ class V extends T {
2546
2559
  * @returns クローンされたフラグメント
2547
2560
  */
2548
2561
  clone() {
2549
- const e = new V(this.target.cloneNode(!0));
2562
+ const e = new j(this.target.cloneNode(!0));
2550
2563
  return e.mounted = !1, e.text = this.text, e.contents = this.contents, e.renderedText = this.renderedText, e;
2551
2564
  }
2552
2565
  /**
@@ -2572,7 +2585,7 @@ class V extends T {
2572
2585
  * @returns 更新のPromise
2573
2586
  */
2574
2587
  setContent(e) {
2575
- return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, this.contents = new G(e), this.evaluate());
2588
+ return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, this.contents = new Y(e), this.evaluate());
2576
2589
  }
2577
2590
  /**
2578
2591
  * フラグメントを評価します。
@@ -2582,7 +2595,7 @@ class V extends T {
2582
2595
  evaluate() {
2583
2596
  return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
2584
2597
  new Error("Parent fragment is required for raw evaluation")
2585
- ) : P.enqueue(() => {
2598
+ ) : I.enqueue(() => {
2586
2599
  this.skipMutation = !0;
2587
2600
  let e = this.text;
2588
2601
  this.contents.isRawEvaluate ? e = this.contents.evaluate(
@@ -2593,7 +2606,7 @@ class V extends T {
2593
2606
  childIndex: this.parent.getChildren().indexOf(this),
2594
2607
  template: this.text
2595
2608
  }
2596
- )[0] : this.contents.isEvaluate && (e = G.joinEvaluateResults(
2609
+ )[0] : this.contents.isEvaluate && (e = Y.joinEvaluateResults(
2597
2610
  this.contents.evaluate(this.parent.getBindingData(), {
2598
2611
  kind: "text",
2599
2612
  element: this.parent.getTarget(),
@@ -2608,7 +2621,7 @@ class V extends T {
2608
2621
  });
2609
2622
  }
2610
2623
  }
2611
- class pe extends T {
2624
+ class pe extends S {
2612
2625
  /**
2613
2626
  * コメントフラグメントのコンストラクタ。
2614
2627
  * 対象コメントノードの内容を初期化します。
@@ -2642,7 +2655,7 @@ class pe extends T {
2642
2655
  * @return 更新のPromise
2643
2656
  */
2644
2657
  setContent(e) {
2645
- return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, P.enqueue(() => {
2658
+ return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, I.enqueue(() => {
2646
2659
  this.skipMutation = !0, this.target.textContent = this.text;
2647
2660
  }).finally(() => {
2648
2661
  this.skipMutation = !1;
@@ -2708,7 +2721,7 @@ const oe = class oe {
2708
2721
  */
2709
2722
  checkRawExpressions() {
2710
2723
  for (let e = 0; e < this.contents.length; e++)
2711
- this.contents[e].type === 2 && this.contents.length > 1 && (m.error(
2724
+ this.contents[e].type === 2 && this.contents.length > 1 && (b.error(
2712
2725
  "[Haori]",
2713
2726
  "Raw expressions are not allowed in multi-content expressions."
2714
2727
  ), this.contents[e].type = 1);
@@ -2755,7 +2768,7 @@ const oe = class oe {
2755
2768
  try {
2756
2769
  if (r(l)) {
2757
2770
  const h = ne.measure(
2758
- () => z.evaluateDetailed(l.text, e)
2771
+ () => G.evaluateDetailed(l.text, e)
2759
2772
  ), u = h.value;
2760
2773
  a += h.durationMs, s.push({
2761
2774
  expression: l.text,
@@ -2764,7 +2777,7 @@ const oe = class oe {
2764
2777
  } else
2765
2778
  n.push(l.text);
2766
2779
  } catch (h) {
2767
- m.error(
2780
+ b.error(
2768
2781
  "[Haori]",
2769
2782
  `Error evaluating ${i} expression: ${l.text}`,
2770
2783
  h
@@ -2781,8 +2794,8 @@ const oe = class oe {
2781
2794
  }
2782
2795
  };
2783
2796
  oe.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
2784
- let G = oe;
2785
- const le = class le extends G {
2797
+ let Y = oe;
2798
+ const le = class le extends Y {
2786
2799
  /**
2787
2800
  * コンストラクタ。
2788
2801
  *
@@ -2827,7 +2840,7 @@ const le = class le extends G {
2827
2840
  (i) => this.forceEvaluation && i.type === 0 || i.type === 1 || i.type === 2,
2828
2841
  "attribute"
2829
2842
  );
2830
- return this.forceEvaluation && r.results.length > 1 ? (m.error(
2843
+ return this.forceEvaluation && r.results.length > 1 ? (b.error(
2831
2844
  "[Haori]",
2832
2845
  "each or if expressions must have a single content.",
2833
2846
  r.results
@@ -2846,7 +2859,7 @@ le.FORCE_EVALUATION_ATTRIBUTES = [
2846
2859
  "hor-derive"
2847
2860
  ];
2848
2861
  let se = le;
2849
- class Q {
2862
+ class Z {
2850
2863
  /**
2851
2864
  * 実行モードを取得します。
2852
2865
  *
@@ -2876,7 +2889,7 @@ class Q {
2876
2889
  * @return すべてのレンダリングが完了したら解決される Promise
2877
2890
  */
2878
2891
  static waitForRenders() {
2879
- return P.waitForIdle();
2892
+ return I.waitForIdle();
2880
2893
  }
2881
2894
  /**
2882
2895
  * 通知ダイアログを表示します。
@@ -2885,7 +2898,7 @@ class Q {
2885
2898
  * @returns 通知が閉じられると解決されるPromise
2886
2899
  */
2887
2900
  static dialog(e) {
2888
- return P.enqueue(() => {
2901
+ return I.enqueue(() => {
2889
2902
  window.alert(e);
2890
2903
  }, !0);
2891
2904
  }
@@ -2913,7 +2926,7 @@ class Q {
2913
2926
  * @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
2914
2927
  */
2915
2928
  static confirm(e) {
2916
- return P.enqueue(() => window.confirm(e), !0);
2929
+ return I.enqueue(() => window.confirm(e), !0);
2917
2930
  }
2918
2931
  /**
2919
2932
  * ダイアログを開きます。
@@ -2921,8 +2934,8 @@ class Q {
2921
2934
  * @param element 開くダイアログのHTML要素
2922
2935
  */
2923
2936
  static openDialog(e) {
2924
- return P.enqueue(() => {
2925
- e instanceof HTMLDialogElement ? (Q.clearMessagesSync(e), e.showModal()) : m.error("[Haori]", "Element is not a dialog: ", e);
2937
+ return I.enqueue(() => {
2938
+ e instanceof HTMLDialogElement ? (Z.clearMessagesSync(e), e.showModal()) : b.error("[Haori]", "Element is not a dialog: ", e);
2926
2939
  }, !0);
2927
2940
  }
2928
2941
  /**
@@ -2931,8 +2944,8 @@ class Q {
2931
2944
  * @param element 閉じるダイアログのHTML要素
2932
2945
  */
2933
2946
  static closeDialog(e) {
2934
- return P.enqueue(() => {
2935
- e instanceof HTMLDialogElement ? e.close() : m.error("[Haori]", "Element is not a dialog: ", e);
2947
+ return I.enqueue(() => {
2948
+ e instanceof HTMLDialogElement ? e.close() : b.error("[Haori]", "Element is not a dialog: ", e);
2936
2949
  }, !0);
2937
2950
  }
2938
2951
  /**
@@ -2942,7 +2955,7 @@ class Q {
2942
2955
  * @param message エラーメッセージ
2943
2956
  */
2944
2957
  static addErrorMessage(e, t) {
2945
- return Q.addMessage(e, t, "error");
2958
+ return Z.addMessage(e, t, "error");
2946
2959
  }
2947
2960
  /**
2948
2961
  * メッセージをレベル付きで追加します。
@@ -2952,7 +2965,7 @@ class Q {
2952
2965
  * @param level メッセージのレベル(省略可能)
2953
2966
  */
2954
2967
  static addMessage(e, t, r) {
2955
- return P.enqueue(() => {
2968
+ return I.enqueue(() => {
2956
2969
  const i = e instanceof HTMLFormElement ? e : e.parentElement ?? e;
2957
2970
  i.setAttribute("data-message", t), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
2958
2971
  }, !0);
@@ -2963,8 +2976,8 @@ class Q {
2963
2976
  * @param parent メッセージをクリアする親要素
2964
2977
  */
2965
2978
  static clearMessages(e) {
2966
- return P.enqueue(() => {
2967
- Q.clearMessagesSync(e);
2979
+ return I.enqueue(() => {
2980
+ Z.clearMessagesSync(e);
2968
2981
  }, !0);
2969
2982
  }
2970
2983
  /**
@@ -3029,7 +3042,7 @@ class Q {
3029
3042
  * @returns 表示要素の配列
3030
3043
  */
3031
3044
  static pages(e, t, r) {
3032
- return Ne(e, t, r);
3045
+ return Fe(e, t, r);
3033
3046
  }
3034
3047
  /**
3035
3048
  * `YYYY-MM` 形式の年月文字列に月数を加算します。
@@ -3053,7 +3066,7 @@ class Q {
3053
3066
  * @returns 年月情報の降順配列。不正な入力は空配列
3054
3067
  */
3055
3068
  static monthRange(e, t) {
3056
- return Fe(e, t);
3069
+ return Ne(e, t);
3057
3070
  }
3058
3071
  /**
3059
3072
  * ページレスポンスから表示用サマリーを作ります。
@@ -3105,7 +3118,7 @@ class Q {
3105
3118
  * @returns 重複排除後の新しい配列。非配列は空配列
3106
3119
  */
3107
3120
  static distinct(e, t) {
3108
- return Ie(e, t);
3121
+ return Pe(e, t);
3109
3122
  }
3110
3123
  /**
3111
3124
  * 配列を `item[key]` ごとのグループへ分けて返します。
@@ -3126,9 +3139,9 @@ function Ae() {
3126
3139
  const e = globalThis.window?.Haori;
3127
3140
  return Ke.every(
3128
3141
  (r) => typeof e?.[r] == "function"
3129
- ) ? e : Q;
3142
+ ) ? e : Z;
3130
3143
  }
3131
- class E {
3144
+ class A {
3132
3145
  /**
3133
3146
  * フォーム内にある入力エレメントの値をオブジェクトとして取得します。
3134
3147
  * data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
@@ -3139,7 +3152,7 @@ class E {
3139
3152
  */
3140
3153
  static getValues(e) {
3141
3154
  const t = {};
3142
- return E.getPartValues(e, t);
3155
+ return A.getPartValues(e, t);
3143
3156
  }
3144
3157
  /**
3145
3158
  * フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
@@ -3150,26 +3163,28 @@ class E {
3150
3163
  * @returns values と同じオブジェクト
3151
3164
  */
3152
3165
  static getPartValues(e, t) {
3166
+ if (e.getTarget().hasAttribute(`${c.prefix}if-false`))
3167
+ return t;
3153
3168
  const r = e.getAttribute("name"), i = e.getAttribute(`${c.prefix}form-object`), n = e.getAttribute(`${c.prefix}form-list`);
3154
3169
  if (r) {
3155
3170
  if (n)
3156
3171
  Array.isArray(t[String(r)]) ? t[String(r)].push(e.getValue()) : t[String(r)] = [e.getValue()];
3157
- else if (E.isGroupedCheckable(e)) {
3158
- const s = e.getValue(), a = String(r);
3159
- s === null ? a in t || (t[a] = null) : t[a] === null || t[a] === void 0 ? t[a] = s : Array.isArray(t[a]) ? t[a].push(s) : t[a] = [t[a], s];
3172
+ else if (A.isGroupedCheckable(e)) {
3173
+ const s = e.getTarget(), o = (s instanceof HTMLInputElement ? s.checked : !0) ? e.getValue() : null, l = String(r);
3174
+ 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];
3160
3175
  } else
3161
3176
  t[String(r)] = e.getValue();
3162
- i && m.warn(
3177
+ i && b.warn(
3163
3178
  "Haori",
3164
3179
  `Element cannot have both ${c.prefix}form-object and name attributes.`
3165
3180
  );
3166
3181
  for (const s of e.getChildElementFragments())
3167
- E.getPartValues(s, t);
3182
+ A.getPartValues(s, t);
3168
3183
  } else if (i) {
3169
3184
  const s = {};
3170
3185
  for (const a of e.getChildElementFragments())
3171
- E.getPartValues(a, s);
3172
- Object.keys(s).length > 0 && (t[String(i)] = s), n && m.warn(
3186
+ A.getPartValues(a, s);
3187
+ Object.keys(s).length > 0 && (t[String(i)] = s), n && b.warn(
3173
3188
  "Haori",
3174
3189
  `Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
3175
3190
  );
@@ -3177,12 +3192,12 @@ class E {
3177
3192
  const s = [];
3178
3193
  for (const a of e.getChildElementFragments()) {
3179
3194
  const o = {};
3180
- E.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
3195
+ A.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
3181
3196
  }
3182
3197
  s.length > 0 && (t[String(n)] = s);
3183
3198
  } else
3184
3199
  for (const s of e.getChildElementFragments())
3185
- E.getPartValues(s, t);
3200
+ A.getPartValues(s, t);
3186
3201
  return t;
3187
3202
  }
3188
3203
  /**
@@ -3195,7 +3210,7 @@ class E {
3195
3210
  * @returns Promise(DOMの更新が完了したら解決される)
3196
3211
  */
3197
3212
  static setValues(e, t, r = !1) {
3198
- return E.setPartValues(e, t, null, r, !0);
3213
+ return A.setPartValues(e, t, null, r, !0);
3199
3214
  }
3200
3215
  /**
3201
3216
  * フォーム内にある入力エレメントに値をイベントなしで設定します。
@@ -3207,7 +3222,7 @@ class E {
3207
3222
  * @returns Promise(DOMの更新が完了したら解決される)
3208
3223
  */
3209
3224
  static syncValues(e, t, r = !1) {
3210
- return E.setPartValues(e, t, null, r, !1);
3225
+ return A.setPartValues(e, t, null, r, !1);
3211
3226
  }
3212
3227
  /**
3213
3228
  * 値による上書きをグループ単位で扱うべき入力要素(boolean 型でない
@@ -3220,6 +3235,16 @@ class E {
3220
3235
  const t = e.getTarget();
3221
3236
  return t instanceof HTMLInputElement ? t.type === "radio" ? !0 : t.type !== "checkbox" ? !1 : t.value !== "true" && t.value !== "false" : !1;
3222
3237
  }
3238
+ /**
3239
+ * 複数選択の select 要素かどうかを判定します。
3240
+ *
3241
+ * @param fragment 対象フラグメント
3242
+ * @returns `<select multiple>` の場合 true
3243
+ */
3244
+ static isMultipleSelect(e) {
3245
+ const t = e.getTarget();
3246
+ return t instanceof HTMLSelectElement && t.multiple;
3247
+ }
3223
3248
  /**
3224
3249
  * 単一フラグメントへ値を設定します。
3225
3250
  *
@@ -3246,24 +3271,24 @@ class E {
3246
3271
  if (!h || i) {
3247
3272
  const u = t[String(a)];
3248
3273
  l && Array.isArray(u) && r !== null ? s.push(
3249
- E.applyFragmentValue(e, u[r] ?? null, n)
3250
- ) : typeof u > "u" || (Array.isArray(u) && E.isGroupedCheckable(e) || typeof u == "string" || typeof u == "number" || typeof u == "boolean" || u === null ? s.push(
3251
- E.applyFragmentValue(
3274
+ A.applyFragmentValue(e, u[r] ?? null, n)
3275
+ ) : 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(
3276
+ A.applyFragmentValue(
3252
3277
  e,
3253
3278
  u,
3254
3279
  n
3255
3280
  )
3256
3281
  ) : s.push(
3257
- E.applyFragmentValue(e, String(u), n)
3282
+ A.applyFragmentValue(e, String(u), n)
3258
3283
  ));
3259
3284
  }
3260
3285
  } else if (o) {
3261
3286
  const u = t[String(o)];
3262
3287
  if (u && typeof u == "object")
3263
- for (const p of e.getChildElementFragments())
3288
+ for (const m of e.getChildElementFragments())
3264
3289
  s.push(
3265
- E.setPartValues(
3266
- p,
3290
+ A.setPartValues(
3291
+ m,
3267
3292
  u,
3268
3293
  null,
3269
3294
  i,
@@ -3273,24 +3298,24 @@ class E {
3273
3298
  } else if (l) {
3274
3299
  const u = t[String(l)];
3275
3300
  if (Array.isArray(u)) {
3276
- const p = e.getChildElementFragments();
3277
- for (let v = 0; v < p.length; v++) {
3278
- const R = p[v];
3301
+ const m = e.getChildElementFragments();
3302
+ for (let v = 0; v < m.length; v++) {
3303
+ const T = m[v];
3279
3304
  u.length > v ? s.push(
3280
- E.setPartValues(
3281
- R,
3305
+ A.setPartValues(
3306
+ T,
3282
3307
  u[v],
3283
3308
  v,
3284
3309
  i,
3285
3310
  n
3286
3311
  )
3287
- ) : s.push(E.setPartValues(R, {}, v, i, n));
3312
+ ) : s.push(A.setPartValues(T, {}, v, i, n));
3288
3313
  }
3289
3314
  }
3290
3315
  } else
3291
3316
  for (const u of e.getChildElementFragments())
3292
3317
  s.push(
3293
- E.setPartValues(u, t, null, i, n)
3318
+ A.setPartValues(u, t, null, i, n)
3294
3319
  );
3295
3320
  return Promise.all(s).then(() => {
3296
3321
  });
@@ -3303,10 +3328,10 @@ class E {
3303
3328
  * @returns すべての初期化処理が完了するPromise
3304
3329
  */
3305
3330
  static async reset(e) {
3306
- E.clearValues(e), await Promise.all([
3307
- E.clearMessages(e),
3308
- E.clearEachClones(e)
3309
- ]), await P.enqueue(() => {
3331
+ A.clearValues(e), await Promise.all([
3332
+ A.clearMessages(e),
3333
+ A.clearEachClones(e)
3334
+ ]), await I.enqueue(() => {
3310
3335
  const r = e.getTarget();
3311
3336
  if (r instanceof HTMLFormElement)
3312
3337
  r.reset();
@@ -3319,20 +3344,20 @@ class E {
3319
3344
  }
3320
3345
  }
3321
3346
  });
3322
- const t = E.collectBindingTargetForms(e);
3347
+ const t = A.collectBindingTargetForms(e);
3323
3348
  for (const r of t) {
3324
- const i = E.getInitialBindingData(r);
3325
- i && await x.setBindingData(r.getTarget(), i);
3349
+ const i = A.getInitialBindingData(r);
3350
+ i && await k.setBindingData(r.getTarget(), i);
3326
3351
  }
3327
- E.syncValuesFromDom(e);
3352
+ A.syncValuesFromDom(e);
3328
3353
  for (const r of t) {
3329
- const i = E.getInitialBindingData(r);
3354
+ const i = A.getInitialBindingData(r);
3330
3355
  if (r.getRawBindingData() === null && i === null)
3331
3356
  continue;
3332
- const n = E.getValues(r), s = r.getAttribute(`${c.prefix}form-arg`), a = { ...i || {} };
3333
- s ? a[String(s)] = n : Object.assign(a, n), await x.setBindingData(r.getTarget(), a);
3357
+ 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);
3334
3359
  }
3335
- await x.evaluateAll(e);
3360
+ await k.evaluateAll(e);
3336
3361
  }
3337
3362
  /**
3338
3363
  * data-bind 属性で宣言された初期バインドデータを取得します。
@@ -3342,7 +3367,7 @@ class E {
3342
3367
  */
3343
3368
  static getInitialBindingData(e) {
3344
3369
  const t = e.getInitialBindAttribute();
3345
- return t === null ? null : x.parseDataBind(t);
3370
+ return t === null ? null : k.parseDataBind(t);
3346
3371
  }
3347
3372
  /**
3348
3373
  * フラグメント配下の入力要素について、内部値を現在の DOM 値と再同期します。
@@ -3353,7 +3378,7 @@ class E {
3353
3378
  const t = e.getTarget();
3354
3379
  (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement) && e.syncValue();
3355
3380
  for (const r of e.getChildElementFragments())
3356
- E.syncValuesFromDom(r);
3381
+ A.syncValuesFromDom(r);
3357
3382
  }
3358
3383
  /**
3359
3384
  * リセット後にバインドデータを更新すべきフォームフラグメントを収集します。
@@ -3369,7 +3394,7 @@ class E {
3369
3394
  t instanceof HTMLFormElement ? r.push(t) : r.push(...Array.from(t.querySelectorAll("form")));
3370
3395
  const i = [];
3371
3396
  for (const n of r) {
3372
- const s = T.get(n);
3397
+ const s = S.get(n);
3373
3398
  s instanceof M && i.push(s);
3374
3399
  }
3375
3400
  return i;
@@ -3406,7 +3431,7 @@ class E {
3406
3431
  static clearValues(e) {
3407
3432
  e.clearValue();
3408
3433
  for (const t of e.getChildElementFragments())
3409
- E.clearValues(t);
3434
+ A.clearValues(t);
3410
3435
  }
3411
3436
  /**
3412
3437
  * フラグメントとその子要素のメッセージをクリアします。
@@ -3429,7 +3454,7 @@ class E {
3429
3454
  * @return Promise(メッセージの追加が完了したら解決される)
3430
3455
  */
3431
3456
  static addErrorMessage(e, t, r) {
3432
- return E.addMessage(e, t, r, "error");
3457
+ return A.addMessage(e, t, r, "error");
3433
3458
  }
3434
3459
  /**
3435
3460
  * キーに一致するフラグメントにレベル付きメッセージを追加します。
@@ -3442,7 +3467,7 @@ class E {
3442
3467
  * @return Promise(メッセージの追加が完了したら解決される)
3443
3468
  */
3444
3469
  static addMessage(e, t, r, i) {
3445
- const n = [], s = Ae(), a = s.addMessage, o = (h) => typeof a == "function" ? a.call(s, h, r, i) : s.addErrorMessage(h, r), l = E.findFragmentsByKey(e, t);
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);
3446
3471
  return l.forEach((h) => {
3447
3472
  n.push(o(h.getTarget()));
3448
3473
  }), l.length === 0 && n.push(o(e.getTarget())), Promise.all(n).then(() => {
@@ -3456,7 +3481,7 @@ class E {
3456
3481
  * @returns 一致するフラグメントの配列
3457
3482
  */
3458
3483
  static findFragmentsByKey(e, t) {
3459
- return E.findFragmentByKeyParts(e, t.split("."));
3484
+ return A.findFragmentByKeyParts(e, t.split("."));
3460
3485
  }
3461
3486
  /**
3462
3487
  * 指定されたキーに一致するフラグメントを検索します。
@@ -3470,7 +3495,7 @@ class E {
3470
3495
  const r = [], i = t[0];
3471
3496
  if (t.length == 1 && e.getAttribute("name") === i && r.push(e), e.hasAttribute(`${c.prefix}form-object`))
3472
3497
  t.length > 1 && e.getAttribute(`${c.prefix}form-object`) === i && e.getChildElementFragments().forEach((s) => {
3473
- r.push(...E.findFragmentByKeyParts(s, t.slice(1)));
3498
+ r.push(...A.findFragmentByKeyParts(s, t.slice(1)));
3474
3499
  });
3475
3500
  else if (e.hasAttribute(`${c.prefix}form-list`)) {
3476
3501
  if (t.length > 1) {
@@ -3480,11 +3505,11 @@ class E {
3480
3505
  if (n === o) {
3481
3506
  const l = i.substring(s + 1, a), h = Number(l);
3482
3507
  if (isNaN(h))
3483
- m.error("Haori", `Invalid index: ${i}`);
3508
+ b.error("Haori", `Invalid index: ${i}`);
3484
3509
  else {
3485
- const u = e.getChildElementFragments().filter((p) => p.hasAttribute(`${c.prefix}row`));
3510
+ const u = e.getChildElementFragments().filter((m) => m.hasAttribute(`${c.prefix}row`));
3486
3511
  h < u.length && r.push(
3487
- ...E.findFragmentByKeyParts(u[h], t.slice(1))
3512
+ ...A.findFragmentByKeyParts(u[h], t.slice(1))
3488
3513
  );
3489
3514
  }
3490
3515
  }
@@ -3492,7 +3517,7 @@ class E {
3492
3517
  }
3493
3518
  } else
3494
3519
  e.getChildElementFragments().forEach((n) => {
3495
- r.push(...E.findFragmentByKeyParts(n, t));
3520
+ r.push(...A.findFragmentByKeyParts(n, t));
3496
3521
  });
3497
3522
  return r;
3498
3523
  }
@@ -3541,14 +3566,6 @@ class N {
3541
3566
  static ready(e) {
3542
3567
  N.dispatch(document, "ready", { version: e });
3543
3568
  }
3544
- /**
3545
- * renderイベントを発火します。
3546
- *
3547
- * @param target 評価対象要素
3548
- */
3549
- static render(e) {
3550
- N.dispatch(e, "render", { target: e });
3551
- }
3552
3569
  /**
3553
3570
  * importstartイベントを発火します。
3554
3571
  *
@@ -3744,7 +3761,7 @@ const ze = {
3744
3761
  function Ge(f, e) {
3745
3762
  return f.replace(/\{\{([\s\S]+?)\}\}/g, (t, r) => {
3746
3763
  try {
3747
- const i = z.evaluate(String(r).trim(), e);
3764
+ const i = G.evaluate(String(r).trim(), e);
3748
3765
  return i == null ? "" : String(i);
3749
3766
  } catch {
3750
3767
  return "";
@@ -3757,7 +3774,7 @@ function Ye(f, e) {
3757
3774
  return null;
3758
3775
  if (!t.includes("{{"))
3759
3776
  return t;
3760
- const r = T.get(f), i = r instanceof M ? r.getBindingData() : {}, n = Ge(t, i);
3777
+ const r = S.get(f), i = r instanceof M ? r.getBindingData() : {}, n = Ge(t, i);
3761
3778
  return n === "" ? null : n;
3762
3779
  }
3763
3780
  function Je(f, e, t) {
@@ -3844,7 +3861,7 @@ function ie() {
3844
3861
  const e = globalThis.window?.Haori;
3845
3862
  return Xe.every(
3846
3863
  (r) => typeof e?.[r] == "function"
3847
- ) ? e : Q;
3864
+ ) ? e : Z;
3848
3865
  }
3849
3866
  const Ze = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
3850
3867
  function _e(f) {
@@ -3927,7 +3944,7 @@ const g = class g {
3927
3944
  return { value: e.replace(
3928
3945
  g.DATA_PLACEHOLDER_REGEX,
3929
3946
  (n, s, a) => {
3930
- const o = z.evaluateDetailed(
3947
+ const o = G.evaluateDetailed(
3931
3948
  s ?? a ?? "",
3932
3949
  t
3933
3950
  );
@@ -4007,7 +4024,7 @@ const g = class g {
4007
4024
  return { value: e.replace(
4008
4025
  g.DATA_PLACEHOLDER_REGEX,
4009
4026
  (n, s, a, o) => {
4010
- const l = z.evaluateDetailed(
4027
+ const l = G.evaluateDetailed(
4011
4028
  s ?? a ?? "",
4012
4029
  t
4013
4030
  );
@@ -4044,7 +4061,7 @@ const g = class g {
4044
4061
  const a = r.trim();
4045
4062
  if (g.SINGLE_PLACEHOLDER_REGEX.test(a))
4046
4063
  return {
4047
- value: x.parseDataBind(n),
4064
+ value: k.parseDataBind(n),
4048
4065
  hasUnresolvedReference: s
4049
4066
  };
4050
4067
  if (a.startsWith("{") || a.startsWith("[")) {
@@ -4053,7 +4070,7 @@ const g = class g {
4053
4070
  e.getBindingData()
4054
4071
  );
4055
4072
  return {
4056
- value: x.parseDataBind(l.value),
4073
+ value: k.parseDataBind(l.value),
4057
4074
  hasUnresolvedReference: s || l.hasUnresolvedReference
4058
4075
  };
4059
4076
  }
@@ -4062,7 +4079,7 @@ const g = class g {
4062
4079
  e.getBindingData()
4063
4080
  );
4064
4081
  return {
4065
- value: x.parseDataBind(o.value),
4082
+ value: k.parseDataBind(o.value),
4066
4083
  hasUnresolvedReference: s || o.hasUnresolvedReference
4067
4084
  };
4068
4085
  }
@@ -4080,22 +4097,22 @@ const g = class g {
4080
4097
  if (t) {
4081
4098
  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, `
4082
4099
  `)), e.hasAttribute(g.attrName(t, "data")) && (r.dataAttrName = g.attrName(t, "data")), e.hasAttribute(g.attrName(t, "form"))) {
4083
- const y = e.getRawAttribute(
4100
+ const p = e.getRawAttribute(
4084
4101
  g.attrName(t, "form")
4085
4102
  );
4086
- if (y) {
4087
- const b = document.body.querySelector(y);
4088
- b !== null ? r.formFragment = E.getFormFragment(
4089
- T.get(b)
4090
- ) : m.error(
4103
+ if (p) {
4104
+ const y = document.body.querySelector(p);
4105
+ y !== null ? r.formFragment = A.getFormFragment(
4106
+ S.get(y)
4107
+ ) : b.error(
4091
4108
  "Haori",
4092
- `Form element not found: ${y} (${g.attrName(t, "form")})`
4109
+ `Form element not found: ${p} (${g.attrName(t, "form")})`
4093
4110
  );
4094
4111
  } else
4095
- r.formFragment = E.getFormFragment(e);
4096
- } else (t === "change" || t === "input") && (r.formFragment = E.getFormFragment(e));
4112
+ r.formFragment = A.getFormFragment(e);
4113
+ } else (t === "change" || t === "input") && (r.formFragment = A.getFormFragment(e));
4097
4114
  if (e.hasAttribute(`${c.prefix}${t}-before-run`)) {
4098
- const y = e.getRawAttribute(
4115
+ const p = e.getRawAttribute(
4099
4116
  `${c.prefix}${t}-before-run`
4100
4117
  );
4101
4118
  try {
@@ -4104,100 +4121,100 @@ const g = class g {
4104
4121
  "fetchOptions",
4105
4122
  `
4106
4123
  "use strict";
4107
- ${y}
4124
+ ${p}
4108
4125
  `
4109
4126
  );
4110
- } catch (b) {
4111
- m.error("Haori", `Invalid before script: ${b}`);
4127
+ } catch (y) {
4128
+ b.error("Haori", `Invalid before script: ${y}`);
4112
4129
  }
4113
4130
  }
4114
- const A = g.attrName(t, "run");
4115
- if (e.hasAttribute(A)) {
4116
- const y = String(e.getAttribute(A) ?? "");
4117
- let b = null;
4131
+ const E = g.attrName(t, "run");
4132
+ if (e.hasAttribute(E)) {
4133
+ const p = String(e.getAttribute(E) ?? "");
4134
+ let y = null;
4118
4135
  try {
4119
- b = new Function(
4136
+ y = new Function(
4120
4137
  "event",
4121
4138
  `"use strict"; return (
4122
- ${y}
4139
+ ${p}
4123
4140
  );`
4124
4141
  );
4125
4142
  } catch {
4126
4143
  try {
4127
- b = new Function(
4144
+ y = new Function(
4128
4145
  "event",
4129
4146
  `"use strict";
4130
- ${y}
4147
+ ${p}
4131
4148
  `
4132
4149
  );
4133
- } catch (S) {
4134
- m.error("Haori", `Invalid run script: ${S}`);
4150
+ } catch (R) {
4151
+ b.error("Haori", `Invalid run script: ${R}`);
4135
4152
  }
4136
4153
  }
4137
- b && (r.runScript = b);
4154
+ y && (r.runScript = y);
4138
4155
  }
4139
4156
  }
4140
4157
  const i = g.attrName(t, "fetch"), n = e.hasAttribute(i);
4141
4158
  if (n) {
4142
- const A = e.getAttributeEvaluation(i);
4143
- A && (r.fetchHasUnresolvedReference = A.hasUnresolvedReference, r.fetchUrl = A.hasUnresolvedReference ? null : A.value);
4159
+ const E = e.getAttributeEvaluation(i);
4160
+ E && (r.fetchHasUnresolvedReference = E.hasUnresolvedReference, r.fetchUrl = E.hasUnresolvedReference ? null : E.value);
4144
4161
  }
4145
4162
  const s = {};
4146
4163
  if (t) {
4147
- const A = g.attrName(t, "fetch-method");
4148
- if (e.hasAttribute(A)) {
4149
- const y = e.getAttributeEvaluation(A);
4150
- y?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = y?.value;
4164
+ const E = g.attrName(t, "fetch-method");
4165
+ if (e.hasAttribute(E)) {
4166
+ const p = e.getAttributeEvaluation(E);
4167
+ p?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = p?.value;
4151
4168
  }
4152
4169
  } else {
4153
- const A = g.attrName(null, "method", !0);
4154
- if (e.hasAttribute(A)) {
4155
- const y = e.getAttributeEvaluation(
4156
- A
4170
+ const E = g.attrName(null, "method", !0);
4171
+ if (e.hasAttribute(E)) {
4172
+ const p = e.getAttributeEvaluation(
4173
+ E
4157
4174
  );
4158
- y?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = y?.value;
4175
+ p?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = p?.value;
4159
4176
  }
4160
4177
  }
4161
4178
  if (t) {
4162
- const A = g.attrName(t, "fetch-headers");
4163
- if (e.hasAttribute(A)) {
4164
- const y = e.getRawAttribute(
4165
- A
4179
+ const E = g.attrName(t, "fetch-headers");
4180
+ if (e.hasAttribute(E)) {
4181
+ const p = e.getRawAttribute(
4182
+ E
4166
4183
  );
4167
4184
  try {
4168
- s.headers = x.parseDataBind(y);
4169
- } catch (b) {
4170
- m.error("Haori", `Invalid fetch headers: ${b}`);
4185
+ s.headers = k.parseDataBind(p);
4186
+ } catch (y) {
4187
+ b.error("Haori", `Invalid fetch headers: ${y}`);
4171
4188
  }
4172
4189
  }
4173
4190
  } else {
4174
- const A = g.attrName(
4191
+ const E = g.attrName(
4175
4192
  null,
4176
4193
  "headers",
4177
4194
  !0
4178
4195
  );
4179
- if (e.hasAttribute(A)) {
4180
- const y = e.getRawAttribute(
4181
- A
4196
+ if (e.hasAttribute(E)) {
4197
+ const p = e.getRawAttribute(
4198
+ E
4182
4199
  );
4183
4200
  try {
4184
- s.headers = x.parseDataBind(y);
4185
- } catch (b) {
4186
- m.error("Haori", `Invalid fetch headers: ${b}`);
4201
+ s.headers = k.parseDataBind(p);
4202
+ } catch (y) {
4203
+ b.error("Haori", `Invalid fetch headers: ${y}`);
4187
4204
  }
4188
4205
  }
4189
4206
  }
4190
4207
  if (t) {
4191
- const A = g.attrName(t, "fetch-content-type");
4192
- if (e.hasAttribute(A)) {
4193
- const y = e.getAttributeEvaluation(A);
4194
- y?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4208
+ const E = g.attrName(t, "fetch-content-type");
4209
+ if (e.hasAttribute(E)) {
4210
+ const p = e.getAttributeEvaluation(E);
4211
+ p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4195
4212
  ...s.headers,
4196
- "Content-Type": y?.value
4213
+ "Content-Type": p?.value
4197
4214
  };
4198
4215
  } else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
4199
- let y = !1;
4200
- s.headers && typeof s.headers == "object" && (y = "Content-Type" in s.headers), y || (s.headers = {
4216
+ let p = !1;
4217
+ s.headers && typeof s.headers == "object" && (p = "Content-Type" in s.headers), p || (s.headers = {
4201
4218
  ...s.headers,
4202
4219
  "Content-Type": "application/json"
4203
4220
  });
@@ -4206,20 +4223,20 @@ ${y}
4206
4223
  "Content-Type": "application/x-www-form-urlencoded"
4207
4224
  });
4208
4225
  } else {
4209
- const A = g.attrName(
4226
+ const E = g.attrName(
4210
4227
  null,
4211
4228
  "content-type",
4212
4229
  !0
4213
4230
  );
4214
- if (e.hasAttribute(A)) {
4215
- const y = e.getAttributeEvaluation(A);
4216
- y?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4231
+ if (e.hasAttribute(E)) {
4232
+ const p = e.getAttributeEvaluation(E);
4233
+ p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
4217
4234
  ...s.headers,
4218
- "Content-Type": y?.value
4235
+ "Content-Type": p?.value
4219
4236
  };
4220
4237
  } else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
4221
- let y = !1;
4222
- s.headers && typeof s.headers == "object" && (y = "Content-Type" in s.headers), y || (s.headers = {
4238
+ let p = !1;
4239
+ s.headers && typeof s.headers == "object" && (p = "Content-Type" in s.headers), p || (s.headers = {
4223
4240
  ...s.headers,
4224
4241
  "Content-Type": "application/json"
4225
4242
  });
@@ -4231,15 +4248,15 @@ ${y}
4231
4248
  Object.keys(s).length > 0 && (r.fetchOptions = s);
4232
4249
  const a = t ? g.attrName(t, "bind") : g.attrName(null, "bind", !0);
4233
4250
  if (e.hasAttribute(a)) {
4234
- const A = e.getRawAttribute(a);
4235
- if (A) {
4236
- const y = document.body.querySelectorAll(A);
4237
- y.length > 0 ? (r.bindFragments = [], y.forEach((b) => {
4238
- const S = T.get(b);
4239
- S && r.bindFragments.push(S);
4240
- })) : m.error(
4251
+ const E = e.getRawAttribute(a);
4252
+ if (E) {
4253
+ const p = document.body.querySelectorAll(E);
4254
+ p.length > 0 ? (r.bindFragments = [], p.forEach((y) => {
4255
+ const R = S.get(y);
4256
+ R && r.bindFragments.push(R);
4257
+ })) : b.error(
4241
4258
  "Haori",
4242
- `Bind element not found: ${A} (${a})`
4259
+ `Bind element not found: ${E} (${a})`
4243
4260
  );
4244
4261
  }
4245
4262
  }
@@ -4257,47 +4274,47 @@ ${y}
4257
4274
  ) : e.hasAttribute(h) && (r.bindArg = e.getRawAttribute(h));
4258
4275
  const u = t ? g.attrName(t, "bind-params") : g.attrName(null, "bind-params", !0);
4259
4276
  if (e.hasAttribute(u)) {
4260
- const A = e.getRawAttribute(u);
4261
- r.bindParams = A.split("&").map((y) => y.trim());
4277
+ const E = e.getRawAttribute(u);
4278
+ r.bindParams = E.split("&").map((p) => p.trim());
4262
4279
  }
4263
- const p = t ? g.attrName(t, "bind-append") : g.attrName(null, "bind-append", !0);
4264
- if (e.hasAttribute(p)) {
4265
- const A = e.getRawAttribute(p);
4266
- r.bindAppendParams = A.split("&").map((y) => y.trim()).filter(Boolean);
4280
+ const m = t ? g.attrName(t, "bind-append") : g.attrName(null, "bind-append", !0);
4281
+ if (e.hasAttribute(m)) {
4282
+ const E = e.getRawAttribute(m);
4283
+ r.bindAppendParams = E.split("&").map((p) => p.trim()).filter(Boolean);
4267
4284
  }
4268
4285
  const v = t ? g.attrName(t, "bind-merge") : g.attrName(null, "bind-merge", !0);
4269
4286
  e.hasAttribute(v) && (r.bindMerge = !0);
4270
- const R = t ? g.attrName(t, "bind-transform") : g.attrName(null, "bind-transform", !0);
4271
- e.hasAttribute(R) && (r.bindTransform = e.getRawAttribute(R));
4272
- const I = t ? g.attrName(t, "copy-params") : null;
4273
- if (I && e.hasAttribute(I)) {
4274
- const A = e.getRawAttribute(I);
4275
- r.copyParams = A.split("&").map((y) => y.trim()).filter(Boolean);
4287
+ const T = t ? g.attrName(t, "bind-transform") : g.attrName(null, "bind-transform", !0);
4288
+ 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);
4276
4293
  }
4277
4294
  if (t) {
4278
4295
  if (e.hasAttribute(g.attrName(t, "adjust"))) {
4279
- const b = e.getRawAttribute(
4296
+ const y = e.getRawAttribute(
4280
4297
  g.attrName(t, "adjust")
4281
4298
  );
4282
- if (b) {
4283
- const S = document.body.querySelectorAll(b);
4284
- S.length > 0 ? (r.adjustFragments = [], S.forEach((k) => {
4285
- const C = T.get(k);
4286
- C && r.adjustFragments.push(C);
4287
- })) : m.error(
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);
4303
+ F && r.adjustFragments.push(F);
4304
+ })) : b.error(
4288
4305
  "Haori",
4289
- `Adjust element not found: ${b} (${g.attrName(t, "adjust")})`
4306
+ `Adjust element not found: ${y} (${g.attrName(t, "adjust")})`
4290
4307
  );
4291
4308
  }
4292
4309
  if (e.hasAttribute(g.attrName(t, "adjust-value"))) {
4293
- const S = e.getRawAttribute(
4310
+ const R = e.getRawAttribute(
4294
4311
  g.attrName(t, "adjust-value")
4295
- ), k = Number(S);
4296
- isNaN(k) || (r.adjustValue = k);
4312
+ ), P = Number(R);
4313
+ isNaN(P) || (r.adjustValue = P);
4297
4314
  }
4298
4315
  }
4299
4316
  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`)) {
4300
- const b = e.getRawAttribute(
4317
+ const y = e.getRawAttribute(
4301
4318
  `${c.prefix}${t}-after-run`
4302
4319
  );
4303
4320
  try {
@@ -4305,11 +4322,11 @@ ${y}
4305
4322
  "response",
4306
4323
  `
4307
4324
  "use strict";
4308
- ${b}
4325
+ ${y}
4309
4326
  `
4310
4327
  );
4311
- } catch (S) {
4312
- m.error("Haori", `Invalid after script: ${S}`);
4328
+ } catch (R) {
4329
+ b.error("Haori", `Invalid after script: ${R}`);
4313
4330
  }
4314
4331
  }
4315
4332
  if (e.hasAttribute(g.attrName(t, "dialog")) && (r.dialogMessage = e.getAttribute(g.attrName(t, "dialog")).replace(/\\n/g, `
@@ -4317,21 +4334,21 @@ ${b}
4317
4334
  r.toastMessage = e.getAttribute(
4318
4335
  g.attrName(t, "toast")
4319
4336
  );
4320
- const b = e.getRawAttribute(
4337
+ const y = e.getRawAttribute(
4321
4338
  g.attrName(t, "toast-level")
4322
- ), k = ["info", "warning", "error", "success"].includes(b);
4323
- r.toastLevel = k ? b : null;
4339
+ ), P = ["info", "warning", "error", "success"].includes(y);
4340
+ r.toastLevel = P ? y : null;
4324
4341
  }
4325
4342
  if (e.hasAttribute(g.attrName(t, "redirect"))) {
4326
4343
  r.redirectUrl = e.getAttribute(
4327
4344
  g.attrName(t, "redirect")
4328
4345
  );
4329
- const b = g.attrName(
4346
+ const y = g.attrName(
4330
4347
  t,
4331
4348
  "redirect-return-param"
4332
4349
  );
4333
- e.hasAttribute(b) && (r.redirectReturnParam = e.getAttribute(
4334
- b
4350
+ e.hasAttribute(y) && (r.redirectReturnParam = e.getAttribute(
4351
+ y
4335
4352
  ));
4336
4353
  }
4337
4354
  if (e.hasAttribute(g.attrName(t, "scroll-error")) && (r.scrollOnError = !0), e.hasAttribute(g.attrName(t, "scroll")) && (r.scrollTarget = e.getAttribute(
@@ -4339,19 +4356,19 @@ ${b}
4339
4356
  )), e.hasAttribute(g.attrName(t, "history")) && (r.historyUrl = e.getAttribute(
4340
4357
  g.attrName(t, "history")
4341
4358
  )), e.hasAttribute(g.attrName(t, "history-data")) && (r.historyDataAttrName = g.attrName(t, "history-data")), e.hasAttribute(g.attrName(t, "history-form"))) {
4342
- const b = e.getRawAttribute(
4359
+ const y = e.getRawAttribute(
4343
4360
  g.attrName(t, "history-form")
4344
4361
  );
4345
- if (b) {
4346
- const S = document.body.querySelector(b);
4347
- S !== null ? r.historyFormFragment = E.getFormFragment(
4348
- T.get(S)
4349
- ) : m.error(
4362
+ if (y) {
4363
+ const R = document.body.querySelector(y);
4364
+ R !== null ? r.historyFormFragment = A.getFormFragment(
4365
+ S.get(R)
4366
+ ) : b.error(
4350
4367
  "Haori",
4351
- `Form element not found: ${b} (${g.attrName(t, "history-form")})`
4368
+ `Form element not found: ${y} (${g.attrName(t, "history-form")})`
4352
4369
  );
4353
4370
  } else
4354
- r.historyFormFragment = E.getFormFragment(e);
4371
+ r.historyFormFragment = A.getFormFragment(e);
4355
4372
  }
4356
4373
  [
4357
4374
  "reset-before",
@@ -4361,82 +4378,93 @@ ${b}
4361
4378
  "copy",
4362
4379
  "open",
4363
4380
  "close"
4364
- ].forEach((b) => {
4365
- const S = g.attrName(t, b);
4366
- if (!e.hasAttribute(S))
4381
+ ].forEach((y) => {
4382
+ const R = g.attrName(t, y);
4383
+ if (!e.hasAttribute(R))
4367
4384
  return;
4368
- const k = e.getRawAttribute(S), C = [];
4369
- if (k)
4370
- document.body.querySelectorAll(k).forEach((j) => {
4371
- const $ = T.get(j);
4372
- $ && C.push($);
4373
- }), C.length === 0 && m.error("Haori", `Element not found: ${k} (${S})`);
4374
- else if (b === "open" || b === "close") {
4375
- const O = e.getTarget().closest("dialog");
4376
- O ? C.push(T.get(O)) : m.error("Haori", `Ancestor <dialog> not found (${S})`);
4385
+ const P = e.getRawAttribute(R), F = [];
4386
+ if (P)
4387
+ document.body.querySelectorAll(P).forEach(($) => {
4388
+ const W = S.get($);
4389
+ W && F.push(W);
4390
+ }), F.length === 0 && b.error("Haori", `Element not found: ${P} (${R})`);
4391
+ else if (y === "open" || y === "close") {
4392
+ const U = e.getTarget().closest("dialog");
4393
+ U ? F.push(S.get(U)) : b.error("Haori", `Ancestor <dialog> not found (${R})`);
4377
4394
  } else
4378
- C.push(e);
4379
- if (C.length > 0)
4380
- switch (b) {
4395
+ F.push(e);
4396
+ if (F.length > 0)
4397
+ switch (y) {
4381
4398
  case "reset-before":
4382
- r.resetBeforeFragments = C;
4399
+ r.resetBeforeFragments = F;
4383
4400
  break;
4384
4401
  case "reset":
4385
- r.resetFragments = C;
4402
+ r.resetFragments = F;
4386
4403
  break;
4387
4404
  case "refetch":
4388
- r.refetchFragments = C;
4405
+ r.refetchFragments = F;
4389
4406
  break;
4390
4407
  case "click":
4391
- r.clickFragments = C;
4408
+ r.clickFragments = F;
4392
4409
  break;
4393
4410
  case "copy":
4394
- r.copyFragments = C;
4411
+ r.copyFragments = F;
4395
4412
  break;
4396
4413
  case "open":
4397
- r.openFragments = C;
4414
+ r.openFragments = F;
4398
4415
  break;
4399
4416
  case "close":
4400
- r.closeFragments = C;
4417
+ r.closeFragments = F;
4401
4418
  break;
4402
4419
  }
4403
4420
  });
4404
- const y = g.attrName(t, "copy-source");
4405
- if (e.hasAttribute(y)) {
4406
- const b = e.getRawAttribute(
4407
- y
4421
+ const p = g.attrName(t, "copy-source");
4422
+ if (e.hasAttribute(p)) {
4423
+ const y = e.getRawAttribute(
4424
+ p
4408
4425
  );
4409
- if (b) {
4410
- const S = document.body.querySelector(b);
4411
- if (S !== null) {
4412
- const k = T.get(S);
4413
- k ? r.copySourceFragment = k : m.error(
4426
+ if (y) {
4427
+ const R = document.body.querySelector(y);
4428
+ if (R !== null) {
4429
+ const P = S.get(R);
4430
+ P ? r.copySourceFragment = P : b.error(
4414
4431
  "Haori",
4415
- `Element is not managed by Haori: ${b} (${y})`
4432
+ `Element is not managed by Haori: ${y} (${p})`
4416
4433
  );
4417
4434
  } else
4418
- m.error(
4435
+ b.error(
4419
4436
  "Haori",
4420
- `Element not found: ${b} (${y})`
4437
+ `Element not found: ${y} (${p})`
4421
4438
  );
4422
4439
  } else
4423
4440
  r.copySourceFragment = e;
4424
4441
  }
4425
4442
  }
4426
4443
  if (!t && (e.hasAttribute(g.attrName(null, "data", !0)) && (r.dataAttrName = g.attrName(null, "data", !0)), e.hasAttribute(g.attrName(null, "form", !0)))) {
4427
- const A = e.getRawAttribute(
4444
+ const E = e.getRawAttribute(
4428
4445
  g.attrName(null, "form", !0)
4429
4446
  );
4430
- if (A) {
4431
- const y = document.body.querySelector(A);
4432
- y !== null ? r.formFragment = E.getFormFragment(
4433
- T.get(y)
4434
- ) : m.error(
4447
+ if (E) {
4448
+ const p = document.body.querySelector(E);
4449
+ p !== null ? r.formFragment = A.getFormFragment(
4450
+ S.get(p)
4451
+ ) : b.error(
4435
4452
  "Haori",
4436
- `Form element not found: ${A} (${g.attrName(null, "fetch-form", !0)})`
4453
+ `Form element not found: ${E} (${g.attrName(null, "fetch-form", !0)})`
4437
4454
  );
4438
4455
  } else
4439
- r.formFragment = E.getFormFragment(e);
4456
+ r.formFragment = A.getFormFragment(e);
4457
+ }
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 = [];
4461
+ E ? (document.body.querySelectorAll(E).forEach((R) => {
4462
+ const P = S.get(R);
4463
+ P && p.push(P);
4464
+ }), p.length === 0 && b.error(
4465
+ "Haori",
4466
+ `Element not found: ${E} (${O})`
4467
+ )) : p.push(e), p.length > 0 && (r.fetchStateFragments = p);
4440
4468
  }
4441
4469
  return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [e], r.defaultSelfBind = !0), r;
4442
4470
  }
@@ -4506,14 +4534,14 @@ ${b}
4506
4534
  );
4507
4535
  u === !1 && this.domEvent && this.domEvent.preventDefault(), u != null && typeof u.then == "function" && await u;
4508
4536
  } catch (u) {
4509
- m.error("Haori", `Run script execution error: ${u}`);
4537
+ b.error("Haori", `Run script execution error: ${u}`);
4510
4538
  }
4511
4539
  }
4512
4540
  if (!await this.confirm())
4513
4541
  return !1;
4514
4542
  this.options.resetBeforeFragments && this.options.resetBeforeFragments.length > 0 && (await Promise.all(
4515
4543
  this.options.resetBeforeFragments.map(
4516
- (h) => E.reset(h)
4544
+ (h) => A.reset(h)
4517
4545
  )
4518
4546
  ), this.captureHistorySnapshots());
4519
4547
  const r = this.prepareFetchRequest(), i = r.payload;
@@ -4531,48 +4559,52 @@ ${b}
4531
4559
  }
4532
4560
  const a = Object.keys(i).length > 0;
4533
4561
  if (n) {
4534
- const h = { ...s || {} }, u = r.requestedMethod, p = r.effectiveMethod, v = r.transportMode === "query-get", R = r.queryString;
4535
- if (v && m.info("Haori demo fetch normalization", {
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", {
4536
4564
  runtime: c.runtime,
4537
4565
  requestedMethod: u,
4538
- effectiveMethod: p,
4566
+ effectiveMethod: m,
4539
4567
  transportMode: "query-get",
4540
4568
  url: n,
4541
4569
  payload: a ? i : void 0,
4542
- queryString: R
4570
+ queryString: T
4543
4571
  }), this.options.targetFragment && n) {
4544
- const I = performance.now(), A = {
4572
+ const C = performance.now(), O = {
4545
4573
  runtime: c.runtime,
4546
4574
  requestedMethod: u,
4547
- effectiveMethod: p,
4575
+ effectiveMethod: m,
4548
4576
  transportMode: v ? "query-get" : "http",
4549
- ...v ? { queryString: R } : {}
4577
+ ...v ? { queryString: T } : {}
4550
4578
  };
4551
4579
  return N.fetchStart(
4552
4580
  this.options.targetFragment.getTarget(),
4553
4581
  n,
4554
4582
  h,
4555
4583
  a ? i : void 0,
4556
- A
4557
- ), fetch(n, h).then((y) => this.handleFetchResult(
4558
- y,
4584
+ O
4585
+ ), await this.injectFetchState("loading"), fetch(n, h).then((E) => this.handleFetchResult(
4586
+ E,
4559
4587
  n || void 0,
4560
- I
4561
- )).catch((y) => {
4588
+ C
4589
+ )).catch(async (E) => {
4562
4590
  throw n && N.fetchError(
4563
4591
  this.options.targetFragment.getTarget(),
4564
4592
  n,
4565
- y
4566
- ), y;
4593
+ E
4594
+ ), await this.injectFetchState(
4595
+ "error",
4596
+ null,
4597
+ E instanceof Error ? E.message : String(E)
4598
+ ), E;
4567
4599
  });
4568
4600
  }
4569
- return fetch(n, h).then((I) => this.handleFetchResult(I, n || void 0));
4601
+ return fetch(n, h).then((C) => this.handleFetchResult(C, n || void 0));
4570
4602
  }
4571
4603
  if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && a) {
4572
- const h = this.options.formFragment, u = h.getTarget(), p = /* @__PURE__ */ new Set();
4573
- e && e.appliedDisabledAttribute && this.options.targetFragment && p.add(this.options.targetFragment);
4604
+ const h = this.options.formFragment, u = h.getTarget(), m = /* @__PURE__ */ new Set();
4605
+ e && e.appliedDisabledAttribute && this.options.targetFragment && m.add(this.options.targetFragment);
4574
4606
  const v = h.getBindingData();
4575
- Object.assign(v, i), await x.setBindingData(u, v, p);
4607
+ Object.assign(v, i), await k.setBindingData(u, v, m);
4576
4608
  }
4577
4609
  const o = a ? i : {}, l = new Response(JSON.stringify(o), {
4578
4610
  headers: { "Content-Type": "application/json" }
@@ -4622,7 +4654,11 @@ ${b}
4622
4654
  new Error(`${e.status} ${e.statusText}`),
4623
4655
  e.status,
4624
4656
  r
4625
- ), await this.handleFetchError(e)), !1;
4657
+ ), await this.handleFetchError(e), await this.injectFetchState(
4658
+ "error",
4659
+ e.status,
4660
+ e.statusText || null
4661
+ )), !1;
4626
4662
  if (this.options.targetFragment && t && r && N.fetchEnd(
4627
4663
  this.options.targetFragment.getTarget(),
4628
4664
  t,
@@ -4637,15 +4673,15 @@ ${b}
4637
4673
  }
4638
4674
  }
4639
4675
  const n = [];
4640
- n.push(this.bindResult(e)), n.push(this.adjust()), n.push(this.addRow()), n.push(this.removeRow()), n.push(this.movePrevRow()), n.push(this.moveNextRow()), await Promise.all(n), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
4641
- this.options.resetFragments.map((a) => E.reset(a))
4676
+ n.push(this.bindResult(e)), n.push(this.adjust()), n.push(this.addRow()), n.push(this.removeRow()), n.push(this.movePrevRow()), n.push(this.moveNextRow()), await Promise.all(n), await this.injectFetchState("success", e.status, null), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
4677
+ this.options.resetFragments.map((a) => A.reset(a))
4642
4678
  ), await this.copy();
4643
4679
  const s = [];
4644
4680
  if (this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
4645
4681
  s.push(new g(a, null).run());
4646
4682
  }), this.options.clickFragments && this.options.clickFragments.length > 0)
4647
4683
  for (const a of this.options.clickFragments) {
4648
- await x.evaluateAll(a);
4684
+ await k.evaluateAll(a);
4649
4685
  const o = a.getTarget();
4650
4686
  typeof o.click == "function" ? o.click() : o.dispatchEvent(
4651
4687
  new MouseEvent("click", { bubbles: !0, cancelable: !0 })
@@ -4653,10 +4689,10 @@ ${b}
4653
4689
  }
4654
4690
  if (this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
4655
4691
  const o = a.getTarget();
4656
- o instanceof HTMLElement ? s.push(i.openDialog(o)) : m.error("Haori", "Element is not an HTML element: ", o);
4692
+ o instanceof HTMLElement ? s.push(i.openDialog(o)) : b.error("Haori", "Element is not an HTML element: ", o);
4657
4693
  }), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
4658
4694
  const o = a.getTarget();
4659
- o instanceof HTMLElement ? s.push(i.closeDialog(o)) : m.error("Haori", "Element is not an HTML element: ", o);
4695
+ o instanceof HTMLElement ? s.push(i.closeDialog(o)) : b.error("Haori", "Element is not an HTML element: ", o);
4660
4696
  }), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
4661
4697
  this.options.toastMessage,
4662
4698
  this.options.toastLevel ?? "info"
@@ -4667,7 +4703,7 @@ ${b}
4667
4703
  const h = new URLSearchParams(window.location.search).get(o);
4668
4704
  if (h !== null) {
4669
4705
  const u = h.trim();
4670
- $e.isSafeLocalPath(u) ? a = u : m.warn(
4706
+ $e.isSafeLocalPath(u) ? a = u : b.warn(
4671
4707
  "Haori",
4672
4708
  `戻り先パスが安全なローカルパスではないため、既定の遷移先へフォールバックします: ${h}`
4673
4709
  );
@@ -4691,12 +4727,12 @@ ${b}
4691
4727
  const s = e ? this.options.historyUrl : window.location.pathname, a = new URL(s, window.location.href);
4692
4728
  if (a.origin !== window.location.origin) {
4693
4729
  const l = "history.pushState: cross-origin URL is not allowed: " + a.toString();
4694
- m.error("Haori", l);
4730
+ b.error("Haori", l);
4695
4731
  return;
4696
4732
  }
4697
4733
  const o = (l) => {
4698
4734
  for (const [h, u] of Object.entries(l))
4699
- u != null && (Array.isArray(u) ? u.forEach((p) => a.searchParams.append(h, String(p))) : typeof u == "object" ? a.searchParams.set(h, JSON.stringify(u)) : a.searchParams.set(h, String(u)));
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)));
4700
4736
  };
4701
4737
  i && o(t), n && o(r), history.pushState(
4702
4738
  { [Qe]: !0 },
@@ -4704,7 +4740,7 @@ ${b}
4704
4740
  a.toString()
4705
4741
  );
4706
4742
  } catch (s) {
4707
- m.error("Haori", `history.pushState failed: ${s}`);
4743
+ b.error("Haori", `history.pushState failed: ${s}`);
4708
4744
  }
4709
4745
  }
4710
4746
  /**
@@ -4712,7 +4748,7 @@ ${b}
4712
4748
  */
4713
4749
  async handleFetchError(e) {
4714
4750
  let t = null;
4715
- this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t = E.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
4751
+ this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
4716
4752
  const r = t ? t.getTarget() : document.body;
4717
4753
  await ie().clearMessages(r);
4718
4754
  const i = async (a) => {
@@ -4731,17 +4767,17 @@ ${b}
4731
4767
  const l = /* @__PURE__ */ new Map(), h = [];
4732
4768
  for (const u of a)
4733
4769
  if (u && typeof u == "object" && !Array.isArray(u)) {
4734
- const p = u.key, v = u.message, R = typeof p == "string" && p.length > 0 ? p : null, I = typeof v == "string" ? v : v != null ? String(v) : "";
4735
- if (I.length === 0)
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)
4736
4772
  continue;
4737
- if (R !== null) {
4738
- const A = l.get(R) ?? [];
4739
- A.push(I), l.set(R, A);
4773
+ if (T !== null) {
4774
+ const O = l.get(T) ?? [];
4775
+ O.push(C), l.set(T, O);
4740
4776
  } else
4741
- h.push(I);
4777
+ h.push(C);
4742
4778
  } else typeof u == "string" && u.length > 0 && h.push(u);
4743
- for (const [u, p] of l)
4744
- o.push({ key: u, message: p.join(`
4779
+ for (const [u, m] of l)
4780
+ o.push({ key: u, message: m.join(`
4745
4781
  `) });
4746
4782
  for (const u of h)
4747
4783
  o.push({ message: u });
@@ -4761,7 +4797,7 @@ ${b}
4761
4797
  if (o.length === 0)
4762
4798
  return await i(`${e.status} ${e.statusText}`), n(), !1;
4763
4799
  for (const l of o)
4764
- l.key && t ? await E.addErrorMessage(t, l.key, l.message) : await i(l.message);
4800
+ l.key && t ? await A.addErrorMessage(t, l.key, l.message) : await i(l.message);
4765
4801
  return n(), !1;
4766
4802
  } catch {
4767
4803
  }
@@ -4837,11 +4873,11 @@ ${b}
4837
4873
  let i = t ? JSON.parse(r) : r;
4838
4874
  if (this.options.bindTransform)
4839
4875
  try {
4840
- i = z.evaluate(this.options.bindTransform, {
4876
+ i = G.evaluate(this.options.bindTransform, {
4841
4877
  response: i
4842
4878
  });
4843
4879
  } catch (s) {
4844
- m.error("Haori", `Invalid bind-transform: ${s}`);
4880
+ b.error("Haori", `Invalid bind-transform: ${s}`);
4845
4881
  }
4846
4882
  if (this.options.bindParams) {
4847
4883
  const s = {};
@@ -4863,7 +4899,7 @@ ${b}
4863
4899
  } else
4864
4900
  a[o] = i;
4865
4901
  n.push(
4866
- x.setBindingData(
4902
+ k.setBindingData(
4867
4903
  s.getTarget(),
4868
4904
  a,
4869
4905
  /* @__PURE__ */ new Set(),
@@ -4877,13 +4913,13 @@ ${b}
4877
4913
  });
4878
4914
  else if (typeof i == "string") {
4879
4915
  if (this.options.defaultSelfBind) {
4880
- m.warn(
4916
+ b.warn(
4881
4917
  "Haori",
4882
4918
  "string data is not bound because no bind target was specified."
4883
4919
  );
4884
4920
  return;
4885
4921
  }
4886
- return m.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
4922
+ return b.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
4887
4923
  new Error("string data cannot be bound without a bindArg.")
4888
4924
  );
4889
4925
  } else
@@ -4893,7 +4929,7 @@ ${b}
4893
4929
  i
4894
4930
  ), o = this.options.bindMerge ? { ...s.getRawBindingData() ?? {}, ...a } : a;
4895
4931
  n.push(
4896
- x.setBindingData(
4932
+ k.setBindingData(
4897
4933
  s.getTarget(),
4898
4934
  o,
4899
4935
  /* @__PURE__ */ new Set(),
@@ -4934,7 +4970,7 @@ ${b}
4934
4970
  ...i.getBindingData(),
4935
4971
  ...t
4936
4972
  };
4937
- return x.setBindingData(i.getTarget(), n);
4973
+ return k.setBindingData(i.getTarget(), n);
4938
4974
  });
4939
4975
  return Promise.all(r).then(() => {
4940
4976
  });
@@ -4943,7 +4979,7 @@ ${b}
4943
4979
  * copy のコピー元データを取得します。
4944
4980
  */
4945
4981
  resolveCopySourceData() {
4946
- return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ? E.getValues(this.options.copySourceFragment) : { ...this.options.copySourceFragment.getBindingData() } : this.options.formFragment ? E.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
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() } : {};
4947
4983
  }
4948
4984
  /**
4949
4985
  * data 属性とフォーム値を統合した送信データを作成します。
@@ -4961,7 +4997,7 @@ ${b}
4961
4997
  buildPayloadResolution() {
4962
4998
  const e = {};
4963
4999
  let t = !1;
4964
- if (this.options.formFragment && Object.assign(e, E.getValues(this.options.formFragment)), this.options.data && typeof this.options.data == "object" && Object.assign(e, this.options.data), this.options.targetFragment && this.options.dataAttrName) {
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) {
4965
5001
  const r = g.resolveDataAttributeDetailed(
4966
5002
  this.options.targetFragment,
4967
5003
  this.options.dataAttrName
@@ -5010,15 +5046,15 @@ ${b}
5010
5046
  const u = s.get("Content-Type") || "";
5011
5047
  if (/multipart\/form-data/i.test(u)) {
5012
5048
  s.delete("Content-Type");
5013
- const p = new FormData();
5014
- for (const [v, R] of Object.entries(t))
5015
- R == null ? p.append(v, "") : R instanceof Blob ? p.append(v, R) : Array.isArray(R) ? R.forEach((I) => p.append(v, String(I))) : typeof R == "object" ? p.append(v, JSON.stringify(R)) : p.append(v, String(R));
5016
- n.body = p;
5049
+ 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));
5052
+ n.body = m;
5017
5053
  } else if (/application\/x-www-form-urlencoded/i.test(u)) {
5018
- const p = new URLSearchParams();
5019
- for (const [v, R] of Object.entries(t))
5020
- R !== void 0 && (R === null ? p.append(v, "") : Array.isArray(R) ? R.forEach((I) => p.append(v, String(I))) : typeof R == "object" ? p.append(v, JSON.stringify(R)) : p.append(v, String(R)));
5021
- n.body = p;
5054
+ 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)));
5057
+ n.body = m;
5022
5058
  } else
5023
5059
  s.set("Content-Type", "application/json"), n.body = JSON.stringify(t);
5024
5060
  }
@@ -5043,7 +5079,7 @@ ${b}
5043
5079
  this.options.targetFragment && this.options.historyDataAttrName ? this.historyDataSnapshot = g.resolveDataAttribute(
5044
5080
  this.options.targetFragment,
5045
5081
  this.options.historyDataAttrName
5046
- ) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? E.getValues(this.options.historyFormFragment) : void 0;
5082
+ ) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? A.getValues(this.options.historyFormFragment) : void 0;
5047
5083
  }
5048
5084
  /**
5049
5085
  * history-data の評価値を取得します。
@@ -5065,7 +5101,7 @@ ${b}
5065
5101
  if (this.historyFormSnapshot !== void 0)
5066
5102
  return this.historyFormSnapshot;
5067
5103
  if (this.options.historyFormFragment)
5068
- return E.getValues(this.options.historyFormFragment);
5104
+ return A.getValues(this.options.historyFormFragment);
5069
5105
  }
5070
5106
  /**
5071
5107
  * copy-params が指定されている場合は include / exclude を考慮して抽出します。
@@ -5113,11 +5149,11 @@ ${b}
5113
5149
  */
5114
5150
  getRowFragment() {
5115
5151
  if (!this.options.targetFragment)
5116
- return m.error("Haori", "Target fragment is not specified for row operation."), null;
5152
+ return b.error("Haori", "Target fragment is not specified for row operation."), null;
5117
5153
  const e = this.options.targetFragment.closestByAttribute(
5118
5154
  `${c.prefix}row`
5119
5155
  );
5120
- return e || (m.error("Haori", "Row fragment not found."), null);
5156
+ return e || (b.error("Haori", "Row fragment not found."), null);
5121
5157
  }
5122
5158
  /**
5123
5159
  * 行を追加します。
@@ -5133,7 +5169,7 @@ ${b}
5133
5169
  const t = [], r = e.clone();
5134
5170
  return t.push(
5135
5171
  e.getParent().insertAfter(r, e)
5136
- ), t.push(x.evaluateAll(r)), t.push(E.reset(r)), Promise.all(t).then(() => {
5172
+ ), t.push(k.evaluateAll(r)), t.push(A.reset(r)), Promise.all(t).then(() => {
5137
5173
  });
5138
5174
  }
5139
5175
  /**
@@ -5184,6 +5220,42 @@ ${b}
5184
5220
  const r = e.getParent();
5185
5221
  return r ? r.insertAfter(e, t) : Promise.resolve();
5186
5222
  }
5223
+ /**
5224
+ * フェッチ状態を `_fetch` として対象要素群のバインディングデータへ注入します。
5225
+ *
5226
+ * `data-fetch-state` / `data-{event}-fetch-state` で指定された要素に対し、
5227
+ * `loading` / `success` / `error` の各状態を `_fetch` キーで設定します。
5228
+ * `reflectToAttribute=false` で呼ぶため data-bind 属性は汚さず、bindchange
5229
+ * イベントも発火しませんが、対象要素の再評価(data-if 等)は実行されます。
5230
+ * 指定要素が無い場合は何もしません。
5231
+ *
5232
+ * @param status フェッチ状態('loading' | 'success' | 'error')
5233
+ * @param statusCode HTTP ステータスコード(無い場合は null)
5234
+ * @param message エラーメッセージ等(無い場合は null)
5235
+ * @returns 注入完了の Promise
5236
+ */
5237
+ async injectFetchState(e, t = null, r = null) {
5238
+ const i = this.options.fetchStateFragments;
5239
+ if (!i || i.length === 0)
5240
+ return;
5241
+ const n = {
5242
+ status: e,
5243
+ loading: e === "loading",
5244
+ success: e === "success",
5245
+ error: e === "error",
5246
+ statusCode: t,
5247
+ message: r
5248
+ };
5249
+ await Promise.all(
5250
+ i.map((s) => {
5251
+ const a = s.getTarget(), o = {
5252
+ ...s.getRawBindingData() ?? {},
5253
+ _fetch: n
5254
+ };
5255
+ return k.setBindingData(a, o, /* @__PURE__ */ new Set(), !1, !1);
5256
+ })
5257
+ );
5258
+ }
5187
5259
  };
5188
5260
  g.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, g.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/, g.RUNNING_CLICK_TARGETS = /* @__PURE__ */ new WeakSet();
5189
5261
  let q = g;
@@ -5205,24 +5277,24 @@ class nt {
5205
5277
  try {
5206
5278
  r = await fetch(e, t);
5207
5279
  } catch (n) {
5208
- throw m.error("[Haori]", "Failed to fetch import source:", e, n), new Error(`Failed to fetch: ${e}`);
5280
+ throw b.error("[Haori]", "Failed to fetch import source:", e, n), new Error(`Failed to fetch: ${e}`);
5209
5281
  }
5210
5282
  if (!r.ok) {
5211
5283
  Be(r.status);
5212
5284
  const n = `${r.status} ${r.statusText}`;
5213
- throw m.error("[Haori]", "Import HTTP error:", e, n), new Error(`Failed to load ${e}: ${n}`);
5285
+ throw b.error("[Haori]", "Import HTTP error:", e, n), new Error(`Failed to load ${e}: ${n}`);
5214
5286
  }
5215
5287
  let i;
5216
5288
  try {
5217
5289
  i = await r.text();
5218
5290
  } catch (n) {
5219
- throw m.error("[Haori]", "Failed to read response text:", e, n), new Error(`Failed to read response from: ${e}`);
5291
+ throw b.error("[Haori]", "Failed to read response text:", e, n), new Error(`Failed to read response from: ${e}`);
5220
5292
  }
5221
5293
  try {
5222
5294
  const s = new DOMParser().parseFromString(i, "text/html");
5223
- return s && s.body ? s.body.innerHTML : (m.warn("[Haori]", "No body found in imported document:", e), i);
5295
+ return s && s.body ? s.body.innerHTML : (b.warn("[Haori]", "No body found in imported document:", e), i);
5224
5296
  } catch (n) {
5225
- return m.error("[Haori]", "Failed to parse imported HTML:", e, n), i;
5297
+ return b.error("[Haori]", "Failed to parse imported HTML:", e, n), i;
5226
5298
  }
5227
5299
  }
5228
5300
  }
@@ -5277,7 +5349,7 @@ const d = class d {
5277
5349
  * @returns data-attr-* の内部反映なら true
5278
5350
  */
5279
5351
  static isAliasedAttributeReflection(e, t) {
5280
- const r = T.get(e);
5352
+ const r = S.get(e);
5281
5353
  return r instanceof M ? r.hasAttribute(
5282
5354
  `${c.prefix}${d.ATTRIBUTE_ALIAS_SUFFIX}${t}`
5283
5355
  ) : !1;
@@ -5309,7 +5381,7 @@ const d = class d {
5309
5381
  static reevaluateChildren(e) {
5310
5382
  const t = [];
5311
5383
  return e.getChildren().forEach((r) => {
5312
- r instanceof M ? t.push(d.evaluateAll(r)) : r instanceof V && t.push(d.evaluateText(r));
5384
+ r instanceof M ? t.push(d.evaluateAll(r)) : r instanceof j && t.push(d.evaluateText(r));
5313
5385
  }), Promise.all(t).then(() => {
5314
5386
  });
5315
5387
  }
@@ -5407,20 +5479,20 @@ const d = class d {
5407
5479
  const s = performance.now();
5408
5480
  return t.setAttribute(`${c.prefix}importing`, ""), N.importStart(t, n), nt.load(n).then((a) => {
5409
5481
  const o = new TextEncoder().encode(a).length;
5410
- return P.enqueue(() => {
5482
+ return I.enqueue(() => {
5411
5483
  t.innerHTML = a;
5412
5484
  }).then(() => {
5413
5485
  if (t.removeAttribute(`${c.prefix}importing`), N.importEnd(t, n, o, s), !document.body.hasAttribute("data-haori-ready")) {
5414
5486
  const l = [];
5415
5487
  return t.childNodes.forEach((h) => {
5416
- const u = T.get(h);
5417
- u instanceof M ? l.push(d.scan(u.getTarget())) : u instanceof V && l.push(d.evaluateText(u));
5488
+ const u = S.get(h);
5489
+ u instanceof M ? l.push(d.scan(u.getTarget())) : u instanceof j && l.push(d.evaluateText(u));
5418
5490
  }), Promise.all(l).then(() => {
5419
5491
  });
5420
5492
  }
5421
5493
  });
5422
5494
  }).catch((a) => {
5423
- t.removeAttribute(`${c.prefix}importing`), N.importError(t, n, a), m.error("[Haori]", "Failed to import HTML:", n, a);
5495
+ t.removeAttribute(`${c.prefix}importing`), N.importError(t, n, a), b.error("[Haori]", "Failed to import HTML:", n, a);
5424
5496
  }).finally(() => {
5425
5497
  if (r.running = !1, r.rerunRequested)
5426
5498
  return r.rerunRequested = !1, d.executeManagedImport(e);
@@ -5433,7 +5505,7 @@ const d = class d {
5433
5505
  * @returns Promise (スキャンが完了したときに解決される)
5434
5506
  */
5435
5507
  static scan(e) {
5436
- const t = T.get(e);
5508
+ const t = S.get(e);
5437
5509
  return t ? d.initializeElementFragment(t, !1) : Promise.resolve();
5438
5510
  }
5439
5511
  /**
@@ -5463,7 +5535,7 @@ const d = class d {
5463
5535
  }
5464
5536
  const r = [];
5465
5537
  return e.getChildren().forEach((i) => {
5466
- i instanceof M ? r.push(d.initializeElementFragment(i, t)) : i instanceof V && r.push(d.evaluateText(i));
5538
+ i instanceof M ? r.push(d.initializeElementFragment(i, t)) : i instanceof j && r.push(d.evaluateText(i));
5467
5539
  }), Promise.all(r).then(() => {
5468
5540
  d.refreshDerivedSubtreeSignature(e);
5469
5541
  });
@@ -5547,7 +5619,7 @@ const d = class d {
5547
5619
  * @returns Promise (DOM操作が完了したときに解決される)
5548
5620
  */
5549
5621
  static setAttribute(e, t, r, i = !1) {
5550
- const n = T.get(e), s = d.getAliasedAttributeName(t);
5622
+ const n = S.get(e), s = d.getAliasedAttributeName(t);
5551
5623
  if (s !== null)
5552
5624
  return r === null ? n.removeAliasedAttribute(t, s) : n.setAliasedAttribute(
5553
5625
  t,
@@ -5609,8 +5681,8 @@ const d = class d {
5609
5681
  if (h === null)
5610
5682
  a.push(d.setBindingData(e, u, /* @__PURE__ */ new Set(), !0));
5611
5683
  else {
5612
- const p = n.getRawBindingData() || {};
5613
- p[String(h)] = u, a.push(d.setBindingData(e, p, /* @__PURE__ */ new Set(), !0));
5684
+ const m = n.getRawBindingData() || {};
5685
+ m[String(h)] = u, a.push(d.setBindingData(e, m, /* @__PURE__ */ new Set(), !0));
5614
5686
  }
5615
5687
  break;
5616
5688
  }
@@ -5643,15 +5715,15 @@ const d = class d {
5643
5715
  * @returns Promise (DOM操作が完了したときに解決される)
5644
5716
  */
5645
5717
  static setBindingData(e, t, r = /* @__PURE__ */ new Set(), i = !1, n = !0) {
5646
- const s = T.get(e), a = s.getRawBindingData();
5718
+ const s = S.get(e), a = s.getRawBindingData();
5647
5719
  s.setBindingData(t), n && N.bindChange(e, a, t, "manual");
5648
5720
  const o = () => {
5649
5721
  s.markBindingWorkStart();
5650
5722
  const l = s.getRawBindingData() ?? t;
5651
5723
  let h = n ? s.setAttribute(`${c.prefix}bind`, JSON.stringify(l)) : Promise.resolve();
5652
5724
  if (e.tagName === "FORM") {
5653
- const u = s.getAttribute(`${c.prefix}form-arg`), p = u && l[String(u)] && typeof l[String(u)] == "object" && !Array.isArray(l[String(u)]) ? l[String(u)] : u ? {} : l;
5654
- h = h.then(() => E.syncValues(s, p));
5725
+ 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));
5655
5727
  }
5656
5728
  return h = h.then(() => d.evaluateAll(s, r)), h = h.then(
5657
5729
  () => d.reevaluateReactiveSpecialAttributes(s, r)
@@ -5682,7 +5754,7 @@ const d = class d {
5682
5754
  * `resolved: true` のときは解決済みスコープ(常にオブジェクト)。
5683
5755
  */
5684
5756
  static getBindingData(e, t = {}) {
5685
- const r = T.get(e);
5757
+ const r = S.get(e);
5686
5758
  return r instanceof M ? t.resolved ? r.getBindingData() : r.getRawBindingData() : null;
5687
5759
  }
5688
5760
  /**
@@ -5701,26 +5773,26 @@ const d = class d {
5701
5773
  * @return 解決済みスコープと各キーの由来情報
5702
5774
  */
5703
5775
  static dumpScope(e) {
5704
- const t = T.get(e);
5776
+ const t = S.get(e);
5705
5777
  if (!t)
5706
5778
  return { resolved: {}, sources: {} };
5707
5779
  const r = t.getBindingData(), i = {}, n = (l) => {
5708
5780
  const h = l.getTarget();
5709
5781
  return h.id ? `#${h.id}` : h.tagName.toLowerCase();
5710
- }, s = (l, h, u, p) => {
5782
+ }, s = (l, h, u, m) => {
5711
5783
  if (l)
5712
5784
  for (const v of Object.keys(l))
5713
5785
  v in i || (i[v] = {
5714
5786
  value: l[v],
5715
5787
  source: n(h),
5716
5788
  kind: u,
5717
- depth: p
5789
+ depth: m
5718
5790
  });
5719
5791
  };
5720
5792
  let a = t, o = 0;
5721
5793
  for (; a; )
5722
5794
  a !== t && s(a.getRawDerivedBindingData(), a, "derive", o), s(a.getRawBindingData(), a, "bind", o), a = a.getParent(), o += 1;
5723
- return L.isEnabled() && m.info("[Haori]", "scope dump for", e, { resolved: r, sources: i }), { resolved: r, sources: i };
5795
+ return L.isEnabled() && b.info("[Haori]", "scope dump for", e, { resolved: r, sources: i }), { resolved: r, sources: i };
5724
5796
  }
5725
5797
  /**
5726
5798
  * data-bind 属性の値をパースします。
@@ -5733,7 +5805,7 @@ const d = class d {
5733
5805
  try {
5734
5806
  return JSON.parse(e);
5735
5807
  } catch (t) {
5736
- return m.error("[Haori]", "Invalid JSON in data-bind:", t), {};
5808
+ return b.error("[Haori]", "Invalid JSON in data-bind:", t), {};
5737
5809
  }
5738
5810
  else {
5739
5811
  const t = new URLSearchParams(e), r = {};
@@ -5749,11 +5821,11 @@ const d = class d {
5749
5821
  * @param node 追加するノード
5750
5822
  */
5751
5823
  static addNode(e, t) {
5752
- const r = T.get(e);
5824
+ const r = S.get(e);
5753
5825
  if (r.isSkipMutationNodes())
5754
5826
  return;
5755
- const i = T.get(t.nextSibling), n = T.get(t);
5756
- n && (r.insertBefore(n, i), n instanceof M ? d.scan(n.getTarget()) : n instanceof V && d.evaluateText(n));
5827
+ 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));
5757
5829
  }
5758
5830
  /**
5759
5831
  * ノードを親要素から削除します。
@@ -5761,7 +5833,7 @@ const d = class d {
5761
5833
  * @param node 削除するノード
5762
5834
  */
5763
5835
  static removeNode(e) {
5764
- const t = T.get(e);
5836
+ const t = S.get(e);
5765
5837
  if (t) {
5766
5838
  const r = t.getParent();
5767
5839
  if (r && r.isSkipMutationNodes())
@@ -5776,7 +5848,7 @@ const d = class d {
5776
5848
  * @param text 新しいテキスト
5777
5849
  */
5778
5850
  static changeText(e, t) {
5779
- const r = T.get(e);
5851
+ const r = S.get(e);
5780
5852
  r && r.setContent(t);
5781
5853
  }
5782
5854
  /**
@@ -5788,14 +5860,14 @@ const d = class d {
5788
5860
  * @returns Promise (DOM操作が完了したときに解決される)
5789
5861
  */
5790
5862
  static changeValue(e, t) {
5791
- const r = T.get(e);
5863
+ const r = S.get(e);
5792
5864
  if (r.getValue() === t)
5793
5865
  return Promise.resolve();
5794
5866
  const i = [];
5795
5867
  i.push(r.setValue(t));
5796
5868
  const n = d.getFormFragment(r);
5797
5869
  if (n) {
5798
- const s = E.getValues(n), a = n.getAttribute(`${c.prefix}form-arg`);
5870
+ const s = A.getValues(n), a = n.getAttribute(`${c.prefix}form-arg`);
5799
5871
  let o;
5800
5872
  a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(d.setBindingData(n.getTarget(), o));
5801
5873
  }
@@ -5827,22 +5899,22 @@ const d = class d {
5827
5899
  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`);
5828
5900
  let l = !1, h = !1, u = null;
5829
5901
  if (!i && e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), !i && e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), i) {
5830
- const p = d.createDeriveInputSignature(
5902
+ const m = d.createDeriveInputSignature(
5831
5903
  e,
5832
5904
  a,
5833
5905
  o
5834
5906
  );
5835
- p === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
5907
+ m === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
5836
5908
  () => d.evaluateDerive(e, a, o).then(
5837
5909
  () => {
5838
5910
  }
5839
5911
  )
5840
- )) : e.getDeriveInputSignature() !== p && (r = r.then(() => d.evaluateDerive(
5912
+ )) : e.getDeriveInputSignature() !== m && (r = r.then(() => d.evaluateDerive(
5841
5913
  e,
5842
5914
  a,
5843
5915
  o
5844
5916
  ).then(() => {
5845
- e.setDeriveInputSignature(p);
5917
+ e.setDeriveInputSignature(m);
5846
5918
  })));
5847
5919
  }
5848
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(() => {
@@ -5861,14 +5933,14 @@ const d = class d {
5861
5933
  })), r.then(() => {
5862
5934
  if (l)
5863
5935
  return;
5864
- const p = [];
5936
+ const m = [];
5865
5937
  return e.getChildren().forEach((v) => {
5866
5938
  if (v instanceof M) {
5867
5939
  if (d.canSkipUnchangedNestedEach(v))
5868
5940
  return;
5869
- p.push(d.evaluateAll(v, t));
5870
- } else v instanceof V && p.push(d.evaluateText(v));
5871
- }), Promise.all(p).then(() => {
5941
+ m.push(d.evaluateAll(v, t));
5942
+ } else v instanceof j && m.push(d.evaluateText(v));
5943
+ }), Promise.all(m).then(() => {
5872
5944
  });
5873
5945
  }).then(() => {
5874
5946
  h && u !== null && e.setDeriveSubtreeSignature(u);
@@ -5890,7 +5962,7 @@ const d = class d {
5890
5962
  const i = e.getRawDerivedBindingData(), n = typeof r == "string" ? r.trim() : "";
5891
5963
  if (!t || n === "")
5892
5964
  return i === null ? Promise.resolve(!1) : (e.setDerivedBindingData(null), Promise.resolve(!0));
5893
- const s = z.evaluateDetailed(
5965
+ const s = G.evaluateDetailed(
5894
5966
  t,
5895
5967
  e.getBindingData()
5896
5968
  );
@@ -5946,7 +6018,7 @@ const d = class d {
5946
6018
  const a = {};
5947
6019
  i.forEach((o) => {
5948
6020
  o in r && (a[o] = r[o]);
5949
- }), m.info(
6021
+ }), b.info(
5950
6022
  "[Haori]",
5951
6023
  "data-if is falsy (hidden):",
5952
6024
  t,
@@ -5975,7 +6047,7 @@ const d = class d {
5975
6047
  e.getChildren().forEach((s) => {
5976
6048
  s instanceof M ? n.push(
5977
6049
  s.isMounted() ? d.evaluateAll(s) : d.scan(s.getTarget())
5978
- ) : s instanceof V && n.push(d.evaluateText(s));
6050
+ ) : s instanceof j && n.push(d.evaluateText(s));
5979
6051
  }), t.push(
5980
6052
  e.show().then(() => {
5981
6053
  N.show(e.getTarget()), i || d.triggerLoadOnShow(e);
@@ -5998,7 +6070,7 @@ const d = class d {
5998
6070
  static triggerLoadOnShow(e) {
5999
6071
  const t = `${c.prefix}load-`;
6000
6072
  e.getTarget().getAttributeNames().some((i) => i.startsWith(t)) && new q(e, "load").run().catch((i) => {
6001
- m.error("[Haori]", "data-load procedure error (on show):", i);
6073
+ b.error("[Haori]", "data-load procedure error (on show):", i);
6002
6074
  });
6003
6075
  }
6004
6076
  /**
@@ -6046,13 +6118,52 @@ const d = class d {
6046
6118
  do
6047
6119
  t.rerunRequested = !1, await d.performEachUpdate(e);
6048
6120
  while (t.rerunRequested);
6049
- e.getTarget().setAttribute(`${c.prefix}each-done`, "");
6121
+ const i = e.getTarget();
6122
+ i.setAttribute(`${c.prefix}each-done`, ""), d.runEachRenderedScript(i);
6050
6123
  } finally {
6051
6124
  t.running = !1, t.settled = null;
6052
6125
  }
6053
6126
  })();
6054
6127
  return t.settled = r, r;
6055
6128
  }
6129
+ /**
6130
+ * data-each-rendered-run 属性に指定された JS を、描画確定後に一度実行します。
6131
+ *
6132
+ * data-each の再描画が安定し `data-each-done` が付与されるたびに呼び出され、
6133
+ * 再 fetch・再バインドのたびに確実な再同期契機を提供します。本体内の `this`
6134
+ * は対象コンテナ要素に束縛され、外部の select 拡張ライブラリ(Choices.js 等)
6135
+ * の再同期フック(例: `window.__choicesRefresh(this)`)として利用できます。
6136
+ *
6137
+ * @param target data-each コンテナ要素
6138
+ */
6139
+ static runEachRenderedScript(e) {
6140
+ const t = `${c.prefix}each-rendered-run`;
6141
+ if (!e.hasAttribute(t))
6142
+ return;
6143
+ const r = String(e.getAttribute(t) ?? "");
6144
+ let i = null;
6145
+ try {
6146
+ i = new Function(
6147
+ `"use strict"; return (
6148
+ ${r}
6149
+ );`
6150
+ );
6151
+ } catch {
6152
+ try {
6153
+ i = new Function(`"use strict";
6154
+ ${r}
6155
+ `);
6156
+ } catch (n) {
6157
+ b.error("Haori", `Invalid each-rendered-run script: ${n}`);
6158
+ }
6159
+ }
6160
+ if (i)
6161
+ try {
6162
+ i.call(e);
6163
+ } catch (n) {
6164
+ b.error("Haori", `each-rendered-run execution error: ${n}`);
6165
+ }
6166
+ }
6056
6167
  /**
6057
6168
  * data-each の差分更新本体を実行します(再入制御は呼び出し側で行います)。
6058
6169
  *
@@ -6084,10 +6195,10 @@ const d = class d {
6084
6195
  (l) => !l.hasAttribute(`${c.prefix}each-before`) && !l.hasAttribute(`${c.prefix}each-after`)
6085
6196
  ).forEach((l) => {
6086
6197
  if (!s) {
6087
- const u = T.get(l);
6198
+ const u = S.get(l);
6088
6199
  u instanceof M && (r = u.clone(), d.markFreshInitializationSkippable(r), e.setTemplate(r), s = !0);
6089
6200
  }
6090
- const h = T.get(l);
6201
+ const h = S.get(l);
6091
6202
  h instanceof M && e.getChildren().includes(h) && (e.removeChild(h), h.setMounted(!1)), l.parentNode && l.parentNode.removeChild(l);
6092
6203
  });
6093
6204
  }
@@ -6107,7 +6218,7 @@ const d = class d {
6107
6218
  */
6108
6219
  static resolveEachItems(e) {
6109
6220
  const t = e.getAttributeEvaluation(`${c.prefix}each`), r = t?.value;
6110
- return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (m.error("[Haori]", "Invalid each attribute:", r), null);
6221
+ return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (b.error("[Haori]", "Invalid each attribute:", r), null);
6111
6222
  }
6112
6223
  /**
6113
6224
  * nested data-each の入力が同値で、要素自身に他の動的要素が無い場合は
@@ -6265,7 +6376,7 @@ const d = class d {
6265
6376
  */
6266
6377
  static logDerivedSubtreeProfileSnapshot(e, t) {
6267
6378
  const r = d.getOrCreateDerivedSubtreeProfile(e);
6268
- r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1), m.info("[Haori][derive-profile]", {
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]", {
6269
6380
  reason: t,
6270
6381
  hostId: r.hostId,
6271
6382
  signatureComputeTotal: r.signatureComputeTotal,
@@ -6297,7 +6408,7 @@ const d = class d {
6297
6408
  const n = e.getRawAttribute(i);
6298
6409
  return typeof n == "string" && n.includes("{{");
6299
6410
  }) ? !0 : e.getChildren().some(
6300
- (i) => i instanceof V && i.hasDynamicContent()
6411
+ (i) => i instanceof j && i.hasDynamicContent()
6301
6412
  );
6302
6413
  }
6303
6414
  /**
@@ -6307,7 +6418,7 @@ const d = class d {
6307
6418
  * @returns subtree 全体を省略可能なら true
6308
6419
  */
6309
6420
  static markFreshInitializationSkippable(e) {
6310
- const t = e.getAttributeNames().some((n) => d.isFreshInitializationDynamicAttribute(e, n)), r = e.getChildren().some((n) => n instanceof M ? !d.markFreshInitializationSkippable(n) : n instanceof V ? n.hasDynamicContent() : !1), i = !t && !r;
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;
6311
6422
  return e.setFreshInitializationSkippable(i), i;
6312
6423
  }
6313
6424
  /**
@@ -6332,85 +6443,85 @@ const d = class d {
6332
6443
  static updateDiff(e, t) {
6333
6444
  const r = e.getTemplate();
6334
6445
  if (r === null)
6335
- return m.error("[Haori]", "Template is not set for each element."), Promise.resolve();
6446
+ return b.error("[Haori]", "Template is not set for each element."), Promise.resolve();
6336
6447
  let i = e.getAttribute(`${c.prefix}each-index`);
6337
6448
  i && (i = String(i));
6338
6449
  const n = e.getAttribute(`${c.prefix}each-key`), s = e.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
6339
- t.forEach((b, S) => {
6340
- const k = d.createListKey(
6341
- b,
6450
+ t.forEach((p, y) => {
6451
+ const R = d.createListKey(
6452
+ p,
6342
6453
  n ? String(n) : null,
6343
- S
6454
+ y
6344
6455
  );
6345
- o.push(k), a.set(k, { item: b, itemIndex: S });
6456
+ o.push(R), a.set(R, { item: p, itemIndex: y });
6346
6457
  });
6347
6458
  const l = new Set(o), h = [];
6348
- let u = e.getChildren().filter((b) => b instanceof M).filter(
6349
- (b) => !b.hasAttribute(`${c.prefix}each-before`) && !b.hasAttribute(`${c.prefix}each-after`)
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`)
6350
6461
  );
6351
- const p = u.map((b) => b.getListKey());
6352
- u = u.filter((b) => l.has(String(b.getListKey())) ? !0 : (h.push(b.remove()), !1));
6353
- const v = u.map((b) => b.getListKey()), R = /* @__PURE__ */ new Map();
6354
- u.forEach((b) => {
6355
- const S = b.getListKey();
6356
- S !== null && !R.has(S) && R.set(S, b);
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);
6357
6468
  });
6358
- const I = e.getChildElementFragments().slice(), A = I.filter(
6359
- (b) => b.hasAttribute(`${c.prefix}each-before`)
6469
+ const C = e.getChildElementFragments().slice(), O = C.filter(
6470
+ (p) => p.hasAttribute(`${c.prefix}each-before`)
6360
6471
  ).length;
6361
- let y = Promise.resolve();
6362
- return o.forEach((b, S) => {
6363
- const { item: k, itemIndex: C } = a.get(b);
6364
- let O;
6365
- const j = R.get(b);
6366
- if (j)
6367
- O = j, y = y.then(
6472
+ let E = Promise.resolve();
6473
+ return o.forEach((p, y) => {
6474
+ const { item: R, itemIndex: P } = a.get(p);
6475
+ let F;
6476
+ const U = T.get(p);
6477
+ if (U)
6478
+ F = U, E = E.then(
6368
6479
  () => d.updateRowFragment(
6369
- O,
6370
- k,
6480
+ F,
6481
+ R,
6371
6482
  i,
6372
- C,
6483
+ P,
6373
6484
  s ? String(s) : null,
6374
- b
6485
+ p
6375
6486
  ).then(($) => {
6376
6487
  if ($)
6377
- return d.evaluateAll(O);
6488
+ return d.evaluateAll(F);
6378
6489
  })
6379
6490
  );
6380
6491
  else {
6381
- O = r.clone();
6382
- const $ = A + S;
6383
- y = y.then(
6492
+ F = r.clone();
6493
+ const $ = O + y;
6494
+ E = E.then(
6384
6495
  () => d.updateRowFragment(
6385
- O,
6386
- k,
6496
+ F,
6497
+ R,
6387
6498
  i,
6388
- C,
6499
+ P,
6389
6500
  s ? String(s) : null,
6390
- b
6501
+ p
6391
6502
  ).then(() => {
6392
- const ee = I[$] ?? null;
6393
- return e.insertBefore(O, ee).then(() => {
6394
- I.splice($, 0, O);
6395
- }).then(() => d.initializeFreshEachRow(O));
6503
+ const W = C[$] ?? null;
6504
+ return e.insertBefore(F, W).then(() => {
6505
+ C.splice($, 0, F);
6506
+ }).then(() => d.initializeFreshEachRow(F));
6396
6507
  })
6397
6508
  );
6398
6509
  }
6399
- }), Promise.all(h).then(() => y).then(() => {
6400
- const b = o.filter(
6510
+ }), Promise.all(h).then(() => E).then(() => {
6511
+ const p = o.filter(
6401
6512
  ($) => $ !== null
6402
- ), S = v.filter(
6513
+ ), y = v.filter(
6403
6514
  ($) => $ !== null
6404
- ), k = new Set(S), C = b.filter(($) => !k.has($)), j = p.filter(
6515
+ ), R = new Set(y), P = p.filter(($) => !R.has($)), U = m.filter(
6405
6516
  ($) => $ !== null
6406
6517
  ).filter(
6407
6518
  ($) => !l.has($)
6408
6519
  );
6409
6520
  N.eachUpdate(
6410
6521
  e.getTarget(),
6411
- C,
6412
- j,
6413
- b
6522
+ P,
6523
+ U,
6524
+ p
6414
6525
  );
6415
6526
  });
6416
6527
  }
@@ -6456,7 +6567,7 @@ const d = class d {
6456
6567
  [n]: t
6457
6568
  }, r && (a[r] = i);
6458
6569
  else
6459
- return m.error(
6570
+ return b.error(
6460
6571
  "[Haori]",
6461
6572
  `Primitive value requires '${c.prefix}each-arg' attribute: ${t}`
6462
6573
  ), Promise.resolve(!1);
@@ -6567,8 +6678,8 @@ d.ATTRIBUTE_ALIAS_SUFFIX = "attr-", d.PRIORITY_ATTRIBUTE_SUFFIXES = [
6567
6678
  "import",
6568
6679
  "url-param"
6569
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();
6570
- let x = d;
6571
- const _ = class _ {
6681
+ let k = d;
6682
+ const ee = class ee {
6572
6683
  /**
6573
6684
  * コンストラクタ。
6574
6685
  *
@@ -6576,11 +6687,11 @@ const _ = class _ {
6576
6687
  */
6577
6688
  constructor(e = document) {
6578
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 = () => {
6579
- const t = document.documentElement, r = T.get(t);
6690
+ const t = document.documentElement, r = S.get(t);
6580
6691
  r && new q(r, "load").run();
6581
6692
  }, this.onPopstate = (t) => {
6582
6693
  const r = t.state;
6583
- !r || r[_.HISTORY_STATE_KEY] !== !0 || location.reload();
6694
+ !r || r[ee.HISTORY_STATE_KEY] !== !0 || location.reload();
6584
6695
  }, this.root = e;
6585
6696
  }
6586
6697
  /**
@@ -6632,8 +6743,8 @@ const _ = class _ {
6632
6743
  subscribeCustomEvent(e) {
6633
6744
  if (e === null || e === "")
6634
6745
  return;
6635
- if (_.BUILTIN_EVENT_NAMES.has(e)) {
6636
- m.warn(
6746
+ if (ee.BUILTIN_EVENT_NAMES.has(e)) {
6747
+ b.warn(
6637
6748
  "[Haori]",
6638
6749
  `data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`
6639
6750
  );
@@ -6655,9 +6766,9 @@ const _ = class _ {
6655
6766
  this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach((i) => {
6656
6767
  if (i.getAttribute(this.onAttributeName) !== e)
6657
6768
  return;
6658
- const n = T.get(i);
6769
+ const n = S.get(i);
6659
6770
  n instanceof M && new q(n, "on", t).run().catch((s) => {
6660
- m.error("[Haori]", "Procedure execution error:", s);
6771
+ b.error("[Haori]", "Procedure execution error:", s);
6661
6772
  });
6662
6773
  });
6663
6774
  }
@@ -6701,13 +6812,21 @@ const _ = class _ {
6701
6812
  return;
6702
6813
  }
6703
6814
  r.hasAttribute(`${c.prefix}${t}-prevent`) && e.preventDefault();
6704
- const i = T.get(r);
6815
+ const i = S.get(r);
6705
6816
  if (!i)
6706
6817
  return;
6707
- (t === "change" || t === "input") && i instanceof M && i.syncValue();
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);
6820
+ for (const a of Array.from(s)) {
6821
+ if (a === r || !(a instanceof HTMLInputElement) || a.type !== "radio" || a.form !== r.form)
6822
+ continue;
6823
+ const o = S.get(a);
6824
+ o instanceof M && o.syncValue();
6825
+ }
6826
+ }
6708
6827
  const n = () => {
6709
6828
  new q(i, t, e).run().catch((s) => {
6710
- m.error("[Haori]", "Procedure execution error:", s);
6829
+ b.error("[Haori]", "Procedure execution error:", s);
6711
6830
  });
6712
6831
  };
6713
6832
  if (t === "click" && r.hasAttribute(`${c.prefix}click-defer`)) {
@@ -6759,13 +6878,13 @@ const _ = class _ {
6759
6878
  return null;
6760
6879
  }
6761
6880
  };
6762
- _.HISTORY_STATE_KEY = "__haoriHistoryState__", _.BUILTIN_EVENT_NAMES = /* @__PURE__ */ new Set([
6881
+ ee.HISTORY_STATE_KEY = "__haoriHistoryState__", ee.BUILTIN_EVENT_NAMES = /* @__PURE__ */ new Set([
6763
6882
  "click",
6764
6883
  "change",
6765
6884
  "input",
6766
6885
  "load"
6767
6886
  ]);
6768
- let fe = _;
6887
+ let fe = ee;
6769
6888
  const D = class D {
6770
6889
  /**
6771
6890
  * ノードが現在の Window に属する HTMLElement かどうかを判定します。
@@ -6785,7 +6904,7 @@ const D = class D {
6785
6904
  }));
6786
6905
  }
6787
6906
  static syncElement(e) {
6788
- const t = D.registrations.get(e), r = T.get(e);
6907
+ const t = D.registrations.get(e), r = S.get(e);
6789
6908
  if (!r || !D.shouldObserve(r)) {
6790
6909
  t && (t.observer.disconnect(), D.registrations.delete(e));
6791
6910
  return;
@@ -6805,17 +6924,17 @@ const D = class D {
6805
6924
  (l) => {
6806
6925
  const h = D.registrations.get(e);
6807
6926
  h && l.forEach((u) => {
6808
- !u.isIntersecting || h.running || D.isDisabled(h.fragment) || (h.running = !0, new q(h.fragment, "intersect").runWithResult().then((p) => {
6809
- p && h.once && (h.observer.disconnect(), D.registrations.delete(e));
6810
- }).catch((p) => {
6811
- m.error(
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));
6929
+ }).catch((m) => {
6930
+ b.error(
6812
6931
  "[Haori]",
6813
6932
  "Intersect procedure execution error:",
6814
- p
6933
+ m
6815
6934
  );
6816
6935
  }).finally(() => {
6817
- const p = D.registrations.get(e);
6818
- p && (p.running = !1);
6936
+ const m = D.registrations.get(e);
6937
+ m && (m.running = !1);
6819
6938
  }));
6820
6939
  });
6821
6940
  },
@@ -6863,7 +6982,7 @@ const D = class D {
6863
6982
  if (typeof r != "string" || r.trim() === "")
6864
6983
  return null;
6865
6984
  const i = document.querySelector(r);
6866
- return D.isHtmlElement(i) ? i : (m.error("[Haori]", `Intersect root element not found: ${r}`), null);
6985
+ return D.isHtmlElement(i) ? i : (b.error("[Haori]", `Intersect root element not found: ${r}`), null);
6867
6986
  }
6868
6987
  static resolveRootMargin(e) {
6869
6988
  const t = `${c.prefix}intersect-root-margin`, r = e.getAttribute(t);
@@ -6893,7 +7012,7 @@ D.CONFIG_KEYS = /* @__PURE__ */ new Set([
6893
7012
  "disabled",
6894
7013
  "once"
6895
7014
  ]), D.registrations = /* @__PURE__ */ new Map();
6896
- let Z = D;
7015
+ let _ = D;
6897
7016
  function st(f) {
6898
7017
  typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => f()) : Promise.resolve().then(f);
6899
7018
  }
@@ -6927,7 +7046,7 @@ const w = class w {
6927
7046
  * @param element 対象要素
6928
7047
  */
6929
7048
  static syncElement(e) {
6930
- const t = w.registrations.get(e), r = T.get(e);
7049
+ const t = w.registrations.get(e), r = S.get(e);
6931
7050
  if (!(r instanceof M) || !w.shouldObserve(r)) {
6932
7051
  t && (t.observer.disconnect(), w.registrations.delete(e));
6933
7052
  return;
@@ -6936,7 +7055,7 @@ const w = class w {
6936
7055
  return;
6937
7056
  const i = w.resolveVarName(r);
6938
7057
  if (i === "") {
6939
- t && (t.observer.disconnect(), w.registrations.delete(e)), m.warn(
7058
+ t && (t.observer.disconnect(), w.registrations.delete(e)), b.warn(
6940
7059
  "[Haori]",
6941
7060
  'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").'
6942
7061
  );
@@ -6954,9 +7073,9 @@ const w = class w {
6954
7073
  if (!h)
6955
7074
  return;
6956
7075
  let u = !1;
6957
- l.forEach((p) => {
6958
- const v = p.target;
6959
- h.observedRows.has(v) && (p.isIntersecting ? h.visibleRows.has(v) || (h.visibleRows.add(v), u = !0) : h.visibleRows.delete(v) && (u = !0));
7076
+ 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));
6960
7079
  }), u && w.scheduleCompute(h);
6961
7080
  },
6962
7081
  {
@@ -7033,7 +7152,7 @@ const w = class w {
7033
7152
  if (typeof r != "string" || r.trim() === "")
7034
7153
  return null;
7035
7154
  const i = document.querySelector(r);
7036
- return w.isHtmlElement(i) ? i : (m.error("[Haori]", `Visible range root element not found: ${r}`), null);
7155
+ return w.isHtmlElement(i) ? i : (b.error("[Haori]", `Visible range root element not found: ${r}`), null);
7037
7156
  }
7038
7157
  /**
7039
7158
  * rootMargin を解決します。
@@ -7132,7 +7251,7 @@ const w = class w {
7132
7251
  static publish(e, t) {
7133
7252
  const r = w.resolveBindOwner(e.fragment);
7134
7253
  if (!r) {
7135
- m.warn(
7254
+ b.warn(
7136
7255
  "[Haori]",
7137
7256
  "data-each-visible found no ancestor data-bind scope to publish into."
7138
7257
  );
@@ -7143,14 +7262,14 @@ const w = class w {
7143
7262
  };
7144
7263
  n[e.varName] = { ...t };
7145
7264
  const s = e.fragment.getTarget(), a = i === s ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([e.fragment]);
7146
- x.setBindingData(
7265
+ k.setBindingData(
7147
7266
  i,
7148
7267
  n,
7149
7268
  a,
7150
7269
  !1,
7151
7270
  !1
7152
7271
  ).catch((o) => {
7153
- m.error("[Haori]", "Failed to publish visible range:", o);
7272
+ b.error("[Haori]", "Failed to publish visible range:", o);
7154
7273
  });
7155
7274
  }
7156
7275
  /**
@@ -7172,7 +7291,7 @@ const w = class w {
7172
7291
  }
7173
7292
  };
7174
7293
  w.THRESHOLD = 0, w.DEFAULT_ROOT_MARGIN = "0px", w.registrations = /* @__PURE__ */ new Map();
7175
- let Y = w;
7294
+ let J = w;
7176
7295
  const H = class H {
7177
7296
  /**
7178
7297
  * 既存の MutationObserver をすべて停止します。
@@ -7191,10 +7310,26 @@ const H = class H {
7191
7310
  return;
7192
7311
  H._initialized = !0, H.disconnectMutationObservers();
7193
7312
  const e = await Promise.allSettled([
7194
- x.scan(document.head),
7195
- x.scan(document.body)
7313
+ k.scan(document.head),
7314
+ k.scan(document.body)
7196
7315
  ]), [t, r] = e;
7197
- t.status !== "fulfilled" && m.error("[Haori]", "Failed to build head fragment:", t.reason), r.status !== "fulfilled" && m.error("[Haori]", "Failed to build body fragment:", r.reason), await P.wait(), document.body.setAttribute("data-haori-ready", ""), H.observe(document.head), H.observe(document.body), new fe().start(), Z.syncTree(document.body), Y.syncTree(document.body);
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);
7317
+ }
7318
+ /**
7319
+ * 指定ノードが「外部管理」サブツリーに属するかどうかを判定します。
7320
+ *
7321
+ * `data-external` 属性を持つ要素とその子孫で発生した DOM 変更は、外部の
7322
+ * select 拡張ライブラリ(Choices.js など)が生成・更新する DOM とみなし、
7323
+ * Haori の監視・自動更新の対象から除外します。これにより、外部生成 DOM が
7324
+ * Haori に破壊・干渉されることを防ぎます。`data-each` による `<option>` の
7325
+ * 配列バインドは Haori のバインド評価パイプラインが駆動するため、監視除外
7326
+ * 下でも維持されます。
7327
+ *
7328
+ * @param node 判定対象のノード(要素・テキスト・コメントいずれも可)
7329
+ * @returns 外部管理サブツリーに属する場合 true
7330
+ */
7331
+ static isExternallyManaged(e) {
7332
+ return (e instanceof Element ? e : e?.parentElement ?? null)?.closest(`[${c.prefix}external]`) != null;
7198
7333
  }
7199
7334
  /**
7200
7335
  * 指定された要素を監視します。
@@ -7205,34 +7340,36 @@ const H = class H {
7205
7340
  const t = new MutationObserver(async (r) => {
7206
7341
  for (const i of r)
7207
7342
  try {
7343
+ if (H.isExternallyManaged(i.target))
7344
+ continue;
7208
7345
  switch (i.type) {
7209
7346
  case "attributes": {
7210
7347
  const n = i.target;
7211
- if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && x.isAliasedAttributeReflection(
7348
+ if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && k.isAliasedAttributeReflection(
7212
7349
  n,
7213
7350
  i.attributeName
7214
7351
  ))
7215
7352
  break;
7216
- x.setAttribute(
7353
+ k.setAttribute(
7217
7354
  n,
7218
7355
  i.attributeName,
7219
7356
  n.getAttribute(i.attributeName),
7220
7357
  !0
7221
- ), Z.syncElement(n), Y.syncElement(n);
7358
+ ), _.syncElement(n), J.syncElement(n);
7222
7359
  break;
7223
7360
  }
7224
7361
  case "childList": {
7225
7362
  Array.from(i.removedNodes).forEach((n) => {
7226
- Z.cleanupTree(n), Y.cleanupTree(n), x.removeNode(n);
7363
+ _.cleanupTree(n), J.cleanupTree(n), k.removeNode(n);
7227
7364
  }), Array.from(i.addedNodes).forEach((n) => {
7228
- n.parentElement instanceof Element && (x.addNode(n.parentElement, n), Z.syncTree(n), Y.syncTree(n));
7229
- }), i.target instanceof Element && Y.syncElement(
7365
+ n.parentElement instanceof Element && (k.addNode(n.parentElement, n), _.syncTree(n), J.syncTree(n));
7366
+ }), i.target instanceof Element && J.syncElement(
7230
7367
  i.target
7231
7368
  );
7232
7369
  break;
7233
7370
  }
7234
7371
  case "characterData": {
7235
- i.target instanceof Text || i.target instanceof Comment ? x.changeText(i.target, i.target.textContent) : m.warn(
7372
+ i.target instanceof Text || i.target instanceof Comment ? k.changeText(i.target, i.target.textContent) : b.warn(
7236
7373
  "[Haori]",
7237
7374
  "Unsupported character data type:",
7238
7375
  i.target
@@ -7240,11 +7377,11 @@ const H = class H {
7240
7377
  break;
7241
7378
  }
7242
7379
  default:
7243
- m.warn("[Haori]", "Unknown mutation type:", i.type);
7380
+ b.warn("[Haori]", "Unknown mutation type:", i.type);
7244
7381
  continue;
7245
7382
  }
7246
7383
  } catch (n) {
7247
- m.error("[Haori]", "Error processing mutation:", n);
7384
+ b.error("[Haori]", "Error processing mutation:", n);
7248
7385
  }
7249
7386
  });
7250
7387
  t.observe(e, {
@@ -7258,16 +7395,16 @@ const H = class H {
7258
7395
  H._initialized = !1, H._mutationObservers = [];
7259
7396
  let ae = H;
7260
7397
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", ae.init) : ae.init();
7261
- const at = () => Q.waitForRenders(), ot = "0.20.0";
7398
+ const at = () => Z.waitForRenders(), ot = "0.24.0";
7262
7399
  export {
7263
- x as Core,
7400
+ k as Core,
7264
7401
  c as Env,
7265
- E as Form,
7266
- T as Fragment,
7267
- Q as Haori,
7268
- m as Log,
7269
- P as Queue,
7270
- Q as default,
7402
+ A as Form,
7403
+ S as Fragment,
7404
+ Z as Haori,
7405
+ b as Log,
7406
+ I as Queue,
7407
+ Z as default,
7271
7408
  ot as version,
7272
7409
  at as waitForRenders
7273
7410
  };