haori 0.1.4 → 0.2.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 R = class R {
1
+ const D = class D {
2
2
  /**
3
3
  * 開発モードの状態を取得します。
4
4
  *
5
5
  * @returns 開発モードならtrue、そうでなければfalse
6
6
  */
7
7
  static isEnabled() {
8
- return R.devMode;
8
+ return D.devMode;
9
9
  }
10
10
  /**
11
11
  * 開発モードを有効化します。
12
12
  */
13
13
  static enable() {
14
- R.devMode = !0;
14
+ D.devMode = !0;
15
15
  }
16
16
  /**
17
17
  * 開発モードを無効化します。
18
18
  */
19
19
  static disable() {
20
- R.devMode = !1;
20
+ D.devMode = !1;
21
21
  }
22
22
  /**
23
23
  * 開発モードを切り替えます。
@@ -25,11 +25,11 @@ const R = class R {
25
25
  * @param enabled trueで有効化、falseで無効化
26
26
  */
27
27
  static set(t) {
28
- R.devMode = t;
28
+ D.devMode = t;
29
29
  }
30
30
  };
31
- R.devMode = !1;
32
- let O = R;
31
+ D.devMode = !1;
32
+ let C = D;
33
33
  const M = class M {
34
34
  /**
35
35
  * 実行環境からプレフィックスと開発モードかどうかを自動検出します。
@@ -45,15 +45,15 @@ const M = class M {
45
45
  M._prefix = r.endsWith("-") ? r : r + "-";
46
46
  }
47
47
  if (t instanceof HTMLScriptElement && t.hasAttribute(`${M._prefix}dev`)) {
48
- O.set(!0);
48
+ C.set(!0);
49
49
  return;
50
50
  }
51
51
  const e = window.location.hostname;
52
52
  if (e === "localhost" || e.endsWith(".localhost") || e === "127.0.0.1" || e === "::1" || e.endsWith(".local")) {
53
- O.set(!0);
53
+ C.set(!0);
54
54
  return;
55
55
  }
56
- O.set(!1);
56
+ C.set(!1);
57
57
  } catch {
58
58
  }
59
59
  }
@@ -67,9 +67,9 @@ const M = class M {
67
67
  }
68
68
  };
69
69
  M._prefix = "data-";
70
- let h = M;
71
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", h.detect) : h.detect();
72
- class f {
70
+ let f = M;
71
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", f.detect) : f.detect();
72
+ class h {
73
73
  /**
74
74
  * 開発モードでのみコンソールに情報を出力します。
75
75
  *
@@ -77,7 +77,7 @@ class f {
77
77
  * @param args 追加の引数
78
78
  */
79
79
  static info(t, ...e) {
80
- O.isEnabled() && console.log && console.log(t, ...e);
80
+ C.isEnabled() && console.log && console.log(t, ...e);
81
81
  }
82
82
  /**
83
83
  * 開発モードでのみコンソールに警告を出力します。
@@ -86,7 +86,7 @@ class f {
86
86
  * @param args 追加の引数
87
87
  */
88
88
  static warn(t, ...e) {
89
- O.isEnabled() && console.warn && console.warn(t, ...e);
89
+ C.isEnabled() && console.warn && console.warn(t, ...e);
90
90
  }
91
91
  /**
92
92
  * モードに関係なくコンソールにエラーを出力します。
@@ -111,16 +111,16 @@ class z {
111
111
  */
112
112
  enqueue(t, e = !1) {
113
113
  let r, n;
114
- const s = new Promise((a, o) => {
114
+ const i = new Promise((a, o) => {
115
115
  r = a, n = o;
116
- }), i = {
116
+ }), s = {
117
117
  task: t,
118
118
  timestamp: performance.now(),
119
- promise: s,
119
+ promise: i,
120
120
  resolve: r,
121
121
  reject: n
122
122
  };
123
- return e ? this.queue.unshift(i) : this.queue.push(i), this.scheduleProcessing(), s;
123
+ return e ? this.queue.unshift(s) : this.queue.push(s), this.scheduleProcessing(), i;
124
124
  }
125
125
  /**
126
126
  * キューを処理します。
@@ -140,13 +140,13 @@ class z {
140
140
  const r = await e.task();
141
141
  e.resolve(r);
142
142
  } catch (r) {
143
- e.reject(r), f.error("[Haori]", `Task ${e.timestamp} failed:`, r);
143
+ e.reject(r), h.error("[Haori]", `Task ${e.timestamp} failed:`, r);
144
144
  }
145
145
  if (performance.now() - t > this.MAX_BUDGET)
146
146
  break;
147
147
  }
148
148
  } catch (t) {
149
- f.error("[Haori]", "Error processing queue:", t);
149
+ h.error("[Haori]", "Error processing queue:", t);
150
150
  } finally {
151
151
  this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
152
152
  }
@@ -194,7 +194,7 @@ const J = class J {
194
194
  };
195
195
  J.ASYNC_QUEUE = new z();
196
196
  let N = J;
197
- class X {
197
+ class W {
198
198
  /**
199
199
  * 通知ダイアログを表示します。
200
200
  *
@@ -239,7 +239,7 @@ class X {
239
239
  */
240
240
  static openDialog(t) {
241
241
  return N.enqueue(() => {
242
- t instanceof HTMLDialogElement ? t.showModal() : f.error("[Haori]", "Element is not a dialog: ", t);
242
+ t instanceof HTMLDialogElement ? t.showModal() : h.error("[Haori]", "Element is not a dialog: ", t);
243
243
  }, !0);
244
244
  }
245
245
  /**
@@ -249,7 +249,7 @@ class X {
249
249
  */
250
250
  static closeDialog(t) {
251
251
  return N.enqueue(() => {
252
- t instanceof HTMLDialogElement ? t.close() : f.error("[Haori]", "Element is not a dialog: ", t);
252
+ t instanceof HTMLDialogElement ? t.close() : h.error("[Haori]", "Element is not a dialog: ", t);
253
253
  }, !0);
254
254
  }
255
255
  /**
@@ -285,13 +285,13 @@ class X {
285
285
  }
286
286
  }
287
287
  const Q = ["addErrorMessage", "clearMessages"];
288
- function W() {
288
+ function X() {
289
289
  const t = globalThis.window?.Haori;
290
290
  return Q.every(
291
291
  (r) => typeof t?.[r] == "function"
292
- ) ? t : X;
292
+ ) ? t : W;
293
293
  }
294
- class E {
294
+ class b {
295
295
  /**
296
296
  * フォーム内にある入力エレメントの値をオブジェクトとして取得します。
297
297
  * data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
@@ -302,7 +302,7 @@ class E {
302
302
  */
303
303
  static getValues(t) {
304
304
  const e = {};
305
- return E.getPartValues(t, e);
305
+ return b.getPartValues(t, e);
306
306
  }
307
307
  /**
308
308
  * フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
@@ -313,32 +313,32 @@ class E {
313
313
  * @returns values と同じオブジェクト
314
314
  */
315
315
  static getPartValues(t, e) {
316
- const r = t.getAttribute("name"), n = t.getAttribute(`${h.prefix}form-object`), s = t.getAttribute(`${h.prefix}form-list`);
316
+ const r = t.getAttribute("name"), n = t.getAttribute(`${f.prefix}form-object`), i = t.getAttribute(`${f.prefix}form-list`);
317
317
  if (r) {
318
- s ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), n && f.warn(
318
+ i ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), n && h.warn(
319
319
  "Haori",
320
- `Element cannot have both ${h.prefix}form-object and name attributes.`
320
+ `Element cannot have both ${f.prefix}form-object and name attributes.`
321
321
  );
322
- for (const i of t.getChildElementFragments())
323
- E.getPartValues(i, e);
322
+ for (const s of t.getChildElementFragments())
323
+ b.getPartValues(s, e);
324
324
  } else if (n) {
325
- const i = {};
325
+ const s = {};
326
326
  for (const a of t.getChildElementFragments())
327
- E.getPartValues(a, i);
328
- Object.keys(i).length > 0 && (e[String(n)] = i), s && f.warn(
327
+ b.getPartValues(a, s);
328
+ Object.keys(s).length > 0 && (e[String(n)] = s), i && h.warn(
329
329
  "Haori",
330
- `Element cannot have both ${h.prefix}form-list and ${h.prefix}form-object attributes.`
330
+ `Element cannot have both ${f.prefix}form-list and ${f.prefix}form-object attributes.`
331
331
  );
332
- } else if (s) {
333
- const i = [];
332
+ } else if (i) {
333
+ const s = [];
334
334
  for (const a of t.getChildElementFragments()) {
335
335
  const o = {};
336
- E.getPartValues(a, o), Object.keys(o).length > 0 && i.push(o);
336
+ b.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
337
337
  }
338
- i.length > 0 && (e[String(s)] = i);
338
+ s.length > 0 && (e[String(i)] = s);
339
339
  } else
340
- for (const i of t.getChildElementFragments())
341
- E.getPartValues(i, e);
340
+ for (const s of t.getChildElementFragments())
341
+ b.getPartValues(s, e);
342
342
  return e;
343
343
  }
344
344
  /**
@@ -351,7 +351,7 @@ class E {
351
351
  * @returns Promise(DOMの更新が完了したら解決される)
352
352
  */
353
353
  static setValues(t, e, r = !1) {
354
- return E.setPartValues(t, e, null, r);
354
+ return b.setPartValues(t, e, null, r);
355
355
  }
356
356
  /**
357
357
  * フラグメント内にある各入力エレメントに値を設定します。
@@ -363,44 +363,44 @@ class E {
363
363
  * @returns Promise(DOMの更新が完了したら解決される)
364
364
  */
365
365
  static setPartValues(t, e, r = null, n = !1) {
366
- const s = [], i = t.getAttribute("name"), a = t.getAttribute(`${h.prefix}form-object`), o = t.getAttribute(`${h.prefix}form-list`), g = t.getAttribute(`${h.prefix}form-detach`);
367
- if (i) {
368
- if (!g || n) {
369
- const u = e[String(i)];
370
- o && Array.isArray(u) && r !== null ? s.push(t.setValue(u[r])) : typeof u == "string" || typeof u == "number" || typeof u == "boolean" || u === null ? s.push(t.setValue(u)) : s.push(t.setValue(String(u)));
366
+ const i = [], s = t.getAttribute("name"), a = t.getAttribute(`${f.prefix}form-object`), o = t.getAttribute(`${f.prefix}form-list`), p = t.getAttribute(`${f.prefix}form-detach`);
367
+ if (s) {
368
+ if (!p || n) {
369
+ const c = e[String(s)];
370
+ o && Array.isArray(c) && r !== null ? i.push(t.setValue(c[r])) : typeof c == "string" || typeof c == "number" || typeof c == "boolean" || c === null ? i.push(t.setValue(c)) : i.push(t.setValue(String(c)));
371
371
  }
372
372
  } else if (a) {
373
- const u = e[String(a)];
374
- if (u && typeof u == "object")
375
- for (const b of t.getChildElementFragments())
376
- s.push(
377
- E.setPartValues(
378
- b,
379
- u,
373
+ const c = e[String(a)];
374
+ if (c && typeof c == "object")
375
+ for (const y of t.getChildElementFragments())
376
+ i.push(
377
+ b.setPartValues(
378
+ y,
379
+ c,
380
380
  null,
381
381
  n
382
382
  )
383
383
  );
384
384
  } else if (o) {
385
- const u = e[String(o)];
386
- if (Array.isArray(u)) {
387
- const b = t.getChildElementFragments();
388
- for (let l = 0; l < b.length; l++) {
389
- const d = b[l];
390
- u.length > l ? s.push(
391
- E.setPartValues(
385
+ const c = e[String(o)];
386
+ if (Array.isArray(c)) {
387
+ const y = t.getChildElementFragments();
388
+ for (let l = 0; l < y.length; l++) {
389
+ const d = y[l];
390
+ c.length > l ? i.push(
391
+ b.setPartValues(
392
392
  d,
393
- u[l],
393
+ c[l],
394
394
  l,
395
395
  n
396
396
  )
397
- ) : s.push(E.setPartValues(d, {}, l, n));
397
+ ) : i.push(b.setPartValues(d, {}, l, n));
398
398
  }
399
399
  }
400
400
  } else
401
- for (const u of t.getChildElementFragments())
402
- s.push(E.setPartValues(u, e, null, n));
403
- return Promise.all(s).then(() => {
401
+ for (const c of t.getChildElementFragments())
402
+ i.push(b.setPartValues(c, e, null, n));
403
+ return Promise.all(i).then(() => {
404
404
  });
405
405
  }
406
406
  /**
@@ -411,9 +411,9 @@ class E {
411
411
  * @returns すべての初期化処理が完了するPromise
412
412
  */
413
413
  static async reset(t) {
414
- E.clearValues(t), await Promise.all([
415
- E.clearMessages(t),
416
- E.clearEachClones(t)
414
+ b.clearValues(t), await Promise.all([
415
+ b.clearMessages(t),
416
+ b.clearEachClones(t)
417
417
  ]), await N.enqueue(() => {
418
418
  const e = t.getTarget();
419
419
  if (e instanceof HTMLFormElement)
@@ -421,8 +421,8 @@ class E {
421
421
  else {
422
422
  const r = e.parentElement;
423
423
  if (r) {
424
- const n = e.nextElementSibling, s = document.createElement("form");
425
- s.appendChild(e), s.reset(), r.insertBefore(e, n);
424
+ const n = e.nextElementSibling, i = document.createElement("form");
425
+ i.appendChild(e), i.reset(), r.insertBefore(e, n);
426
426
  }
427
427
  }
428
428
  }), await T.evaluateAll(t);
@@ -434,20 +434,20 @@ class E {
434
434
  * 対象エレメント自体は削除しません。
435
435
  */
436
436
  static clearEachClones(t) {
437
- const e = [], r = (s) => {
438
- if (s.hasAttribute(`${h.prefix}each`))
439
- for (const i of s.getChildElementFragments()) {
440
- const a = i.hasAttribute(`${h.prefix}each-before`), o = i.hasAttribute(`${h.prefix}each-after`);
441
- !a && !o && e.push(i.remove());
437
+ const e = [], r = (i) => {
438
+ if (i.hasAttribute(`${f.prefix}each`))
439
+ for (const s of i.getChildElementFragments()) {
440
+ const a = s.hasAttribute(`${f.prefix}each-before`), o = s.hasAttribute(`${f.prefix}each-after`);
441
+ !a && !o && e.push(s.remove());
442
442
  }
443
- }, n = (s) => {
444
- r(s);
445
- for (const i of s.getChildElementFragments())
446
- n(i);
443
+ }, n = (i) => {
444
+ r(i);
445
+ for (const s of i.getChildElementFragments())
446
+ n(s);
447
447
  };
448
448
  r(t);
449
- for (const s of t.getChildElementFragments())
450
- n(s);
449
+ for (const i of t.getChildElementFragments())
450
+ n(i);
451
451
  return Promise.all(e).then(() => {
452
452
  });
453
453
  }
@@ -459,7 +459,7 @@ class E {
459
459
  static clearValues(t) {
460
460
  t.clearValue();
461
461
  for (const e of t.getChildElementFragments())
462
- E.clearValues(e);
462
+ b.clearValues(e);
463
463
  }
464
464
  /**
465
465
  * フラグメントとその子要素のメッセージをクリアします。
@@ -468,7 +468,7 @@ class E {
468
468
  * @returns Promise(メッセージのクリアが完了したら解決される)
469
469
  */
470
470
  static clearMessages(t) {
471
- return W().clearMessages(
471
+ return X().clearMessages(
472
472
  t.getTarget()
473
473
  );
474
474
  }
@@ -482,13 +482,13 @@ class E {
482
482
  * @return Promise(メッセージの追加が完了したら解決される)
483
483
  */
484
484
  static addErrorMessage(t, e, r) {
485
- const n = [], s = W(), i = E.findFragmentsByKey(t, e);
486
- return i.forEach((a) => {
485
+ const n = [], i = X(), s = b.findFragmentsByKey(t, e);
486
+ return s.forEach((a) => {
487
487
  n.push(
488
- s.addErrorMessage(a.getTarget(), r)
488
+ i.addErrorMessage(a.getTarget(), r)
489
489
  );
490
- }), i.length === 0 && n.push(
491
- s.addErrorMessage(t.getTarget(), r)
490
+ }), s.length === 0 && n.push(
491
+ i.addErrorMessage(t.getTarget(), r)
492
492
  ), Promise.all(n).then(() => {
493
493
  });
494
494
  }
@@ -500,7 +500,7 @@ class E {
500
500
  * @returns 一致するフラグメントの配列
501
501
  */
502
502
  static findFragmentsByKey(t, e) {
503
- return E.findFragmentByKeyParts(t, e.split("."));
503
+ return b.findFragmentByKeyParts(t, e.split("."));
504
504
  }
505
505
  /**
506
506
  * 指定されたキーに一致するフラグメントを検索します。
@@ -512,31 +512,31 @@ class E {
512
512
  */
513
513
  static findFragmentByKeyParts(t, e) {
514
514
  const r = [], n = e[0];
515
- if (e.length == 1 && t.getAttribute("name") === n && r.push(t), t.hasAttribute(`${h.prefix}form-object`))
516
- e.length > 1 && t.getAttribute(`${h.prefix}form-object`) === n && t.getChildElementFragments().forEach((i) => {
517
- r.push(...E.findFragmentByKeyParts(i, e.slice(1)));
515
+ if (e.length == 1 && t.getAttribute("name") === n && r.push(t), t.hasAttribute(`${f.prefix}form-object`))
516
+ e.length > 1 && t.getAttribute(`${f.prefix}form-object`) === n && t.getChildElementFragments().forEach((s) => {
517
+ r.push(...b.findFragmentByKeyParts(s, e.slice(1)));
518
518
  });
519
- else if (t.hasAttribute(`${h.prefix}form-list`)) {
519
+ else if (t.hasAttribute(`${f.prefix}form-list`)) {
520
520
  if (e.length > 1) {
521
- const s = t.getAttribute(`${h.prefix}form-list`), i = n.lastIndexOf("["), a = n.lastIndexOf("]");
522
- if (i !== -1 && a !== -1 && i < a) {
523
- const o = n.substring(0, i);
524
- if (s === o) {
525
- const g = n.substring(i + 1, a), u = Number(g);
526
- if (isNaN(u))
527
- f.error("Haori", `Invalid index: ${n}`);
521
+ const i = t.getAttribute(`${f.prefix}form-list`), s = n.lastIndexOf("["), a = n.lastIndexOf("]");
522
+ if (s !== -1 && a !== -1 && s < a) {
523
+ const o = n.substring(0, s);
524
+ if (i === o) {
525
+ const p = n.substring(s + 1, a), c = Number(p);
526
+ if (isNaN(c))
527
+ h.error("Haori", `Invalid index: ${n}`);
528
528
  else {
529
- const b = t.getChildElementFragments().filter((l) => l.hasAttribute(`${h.prefix}row`));
530
- u < b.length && r.push(
531
- ...E.findFragmentByKeyParts(b[u], e.slice(1))
529
+ const y = t.getChildElementFragments().filter((l) => l.hasAttribute(`${f.prefix}row`));
530
+ c < y.length && r.push(
531
+ ...b.findFragmentByKeyParts(y[c], e.slice(1))
532
532
  );
533
533
  }
534
534
  }
535
535
  }
536
536
  }
537
537
  } else
538
- t.getChildElementFragments().forEach((s) => {
539
- r.push(...E.findFragmentByKeyParts(s, e));
538
+ t.getChildElementFragments().forEach((i) => {
539
+ r.push(...b.findFragmentByKeyParts(i, e));
540
540
  });
541
541
  return r;
542
542
  }
@@ -553,7 +553,7 @@ class E {
553
553
  return r ? this.getFormFragment(r) : null;
554
554
  }
555
555
  }
556
- const P = class P {
556
+ const S = class S {
557
557
  /**
558
558
  * 明示バインド内に持ち込まれてはならない危険値を返します。
559
559
  *
@@ -598,28 +598,28 @@ const P = class P {
598
598
  */
599
599
  static evaluate(t, e = {}) {
600
600
  if (t.trim() === "")
601
- return f.warn("[Haori]", t, "Expression is empty"), null;
601
+ return h.warn("[Haori]", t, "Expression is empty"), null;
602
602
  if (this.containsDangerousPatterns(t))
603
- return f.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
603
+ return h.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
604
604
  if (this.containsForbiddenKeys(e))
605
- return f.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
605
+ return h.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
606
606
  if (this.containsForbiddenBindingValues(e))
607
- return f.warn(
607
+ return h.warn(
608
608
  "[Haori]",
609
609
  e,
610
610
  "Binded values contain forbidden values"
611
611
  ), null;
612
- const r = Object.keys(e).filter((i) => !this.FORBIDDEN_BINDING_NAMES.has(i)).sort(), n = `${t}:${r.join(",")}`;
613
- let s = this.EXPRESSION_CACHE.get(n);
614
- if (!s) {
615
- const i = this.buildAssignments(r), a = i ? `"use strict";
616
- ${i};
612
+ const r = Object.keys(e).filter((s) => !this.FORBIDDEN_BINDING_NAMES.has(s)).sort(), n = `${t}:${r.join(",")}`;
613
+ let i = this.EXPRESSION_CACHE.get(n);
614
+ if (!i) {
615
+ const s = this.buildAssignments(r), a = s ? `"use strict";
616
+ ${s};
617
617
  return (${t});` : `"use strict";
618
618
  return (${t});`;
619
619
  try {
620
- s = new Function(...r, a), this.EXPRESSION_CACHE.set(n, s);
620
+ i = new Function(...r, a), this.EXPRESSION_CACHE.set(n, i);
621
621
  } catch (o) {
622
- return f.error(
622
+ return h.error(
623
623
  "[Haori]",
624
624
  "Failed to compile expression:",
625
625
  t,
@@ -628,12 +628,12 @@ return (${t});`;
628
628
  }
629
629
  }
630
630
  try {
631
- const i = [], a = this.wrapBoundValues(e);
631
+ const s = [], a = this.wrapBoundValues(e);
632
632
  return r.forEach((o) => {
633
- i.push(a[o]);
634
- }), this.withBlockedPropertyAccess(() => s(...i));
635
- } catch (i) {
636
- return f.error("[Haori]", "Expression evaluation error:", t, i), i instanceof ReferenceError ? void 0 : null;
633
+ s.push(a[o]);
634
+ }), this.withBlockedPropertyAccess(() => i(...s));
635
+ } catch (s) {
636
+ return h.error("[Haori]", "Expression evaluation error:", t, s), s instanceof ReferenceError ? void 0 : null;
637
637
  }
638
638
  }
639
639
  /**
@@ -664,13 +664,13 @@ return (${t});`;
664
664
  return !1;
665
665
  const r = [];
666
666
  let n = null;
667
- for (let s = 0; s < e.length; s++) {
668
- const i = e[s], a = e[s + 1] || null, o = r[r.length - 1] || null;
669
- if (i.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(i.value) || this.STRICT_FORBIDDEN_NAMES.includes(i.value) || (n?.value === "." || n?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(i.value)) || o === "member" && i.value !== "]" && i.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
670
- this.decodeStringLiteral(i.value)
671
- ) || i.value === "." && a?.type !== "identifier" || i.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
667
+ for (let i = 0; i < e.length; i++) {
668
+ const s = e[i], a = e[i + 1] || null, o = r[r.length - 1] || null;
669
+ if (s.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(s.value) || this.STRICT_FORBIDDEN_NAMES.includes(s.value) || (n?.value === "." || n?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(s.value)) || o === "member" && s.value !== "]" && s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
670
+ this.decodeStringLiteral(s.value)
671
+ ) || s.value === "." && a?.type !== "identifier" || s.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
672
672
  return !1;
673
- switch (i.value) {
673
+ switch (s.value) {
674
674
  case "(":
675
675
  r.push("paren");
676
676
  break;
@@ -680,8 +680,8 @@ return (${t});`;
680
680
  break;
681
681
  }
682
682
  case "[": {
683
- const g = this.startsMemberAccess(n) ? "member" : "array";
684
- r.push(g);
683
+ const p = this.startsMemberAccess(n) ? "member" : "array";
684
+ r.push(p);
685
685
  break;
686
686
  }
687
687
  case "]": {
@@ -690,7 +690,7 @@ return (${t});`;
690
690
  break;
691
691
  }
692
692
  }
693
- n = i;
693
+ n = s;
694
694
  }
695
695
  return r.length === 0;
696
696
  }
@@ -731,41 +731,41 @@ return (${t});`;
731
731
  ">",
732
732
  "<"
733
733
  ]);
734
- let s = 0;
735
- for (; s < t.length; ) {
736
- const i = t[s];
737
- if (/\s/.test(i)) {
738
- s += 1;
734
+ let i = 0;
735
+ for (; i < t.length; ) {
736
+ const s = t[i];
737
+ if (/\s/.test(s)) {
738
+ i += 1;
739
739
  continue;
740
740
  }
741
- if (i === "/" && (t[s + 1] === "/" || t[s + 1] === "*"))
741
+ if (s === "/" && (t[i + 1] === "/" || t[i + 1] === "*"))
742
742
  return null;
743
- if (i === '"' || i === "'") {
744
- const o = this.readStringToken(t, s);
743
+ if (s === '"' || s === "'") {
744
+ const o = this.readStringToken(t, i);
745
745
  if (o === null)
746
746
  return null;
747
- e.push(o.token), s = o.nextIndex;
747
+ e.push(o.token), i = o.nextIndex;
748
748
  continue;
749
749
  }
750
750
  const a = r.find(
751
- (o) => t.startsWith(o, s)
751
+ (o) => t.startsWith(o, i)
752
752
  );
753
753
  if (a) {
754
- e.push({ type: "operator", value: a, position: s }), s += a.length;
754
+ e.push({ type: "operator", value: a, position: i }), i += a.length;
755
755
  continue;
756
756
  }
757
- if (/[0-9]/.test(i)) {
758
- const o = this.readNumberToken(t, s);
759
- e.push(o.token), s = o.nextIndex;
757
+ if (/[0-9]/.test(s)) {
758
+ const o = this.readNumberToken(t, i);
759
+ e.push(o.token), i = o.nextIndex;
760
760
  continue;
761
761
  }
762
- if (/[A-Za-z_$]/.test(i)) {
763
- const o = this.readIdentifierToken(t, s);
764
- e.push(o.token), s = o.nextIndex;
762
+ if (/[A-Za-z_$]/.test(s)) {
763
+ const o = this.readIdentifierToken(t, i);
764
+ e.push(o.token), i = o.nextIndex;
765
765
  continue;
766
766
  }
767
- if (n.has(i)) {
768
- e.push({ type: "operator", value: i, position: s }), s += 1;
767
+ if (n.has(s)) {
768
+ e.push({ type: "operator", value: s, position: i }), i += 1;
769
769
  continue;
770
770
  }
771
771
  return null;
@@ -783,12 +783,12 @@ return (${t});`;
783
783
  const r = t[e];
784
784
  let n = e + 1;
785
785
  for (; n < t.length; ) {
786
- const s = t[n];
787
- if (s === "\\") {
786
+ const i = t[n];
787
+ if (i === "\\") {
788
788
  n += 2;
789
789
  continue;
790
790
  }
791
- if (s === r)
791
+ if (i === r)
792
792
  return {
793
793
  token: {
794
794
  type: "string",
@@ -896,8 +896,8 @@ return (${t});`;
896
896
  */
897
897
  static wrapBoundValues(t) {
898
898
  const e = /* @__PURE__ */ new WeakMap(), r = {};
899
- return Object.entries(t).forEach(([n, s]) => {
900
- r[n] = this.wrapBoundValue(s, e);
899
+ return Object.entries(t).forEach(([n, i]) => {
900
+ r[n] = this.wrapBoundValue(i, e);
901
901
  }), r;
902
902
  }
903
903
  /**
@@ -913,39 +913,39 @@ return (${t});`;
913
913
  const r = t, n = e.get(r);
914
914
  if (n !== void 0)
915
915
  return n;
916
- const s = new Proxy(r, {
917
- get: (i, a, o) => {
916
+ const i = new Proxy(r, {
917
+ get: (s, a, o) => {
918
918
  if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
919
919
  return;
920
- const g = Reflect.get(i, a, o);
921
- return typeof a == "symbol" ? g : this.wrapBoundValue(
922
- g,
920
+ const p = Reflect.get(s, a, o);
921
+ return typeof a == "symbol" ? p : this.wrapBoundValue(
922
+ p,
923
923
  e
924
924
  );
925
925
  },
926
- has: (i, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(i, a),
927
- getOwnPropertyDescriptor: (i, a) => {
926
+ has: (s, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(s, a),
927
+ getOwnPropertyDescriptor: (s, a) => {
928
928
  if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
929
- return Reflect.getOwnPropertyDescriptor(i, a);
929
+ return Reflect.getOwnPropertyDescriptor(s, a);
930
930
  },
931
- apply: (i, a, o) => {
932
- const g = Reflect.apply(
933
- i,
931
+ apply: (s, a, o) => {
932
+ const p = Reflect.apply(
933
+ s,
934
934
  a,
935
935
  o
936
936
  );
937
- return this.isIteratorLike(g) ? g : this.wrapBoundValue(g, e);
937
+ return this.isIteratorLike(p) ? p : this.wrapBoundValue(p, e);
938
938
  },
939
- construct: (i, a, o) => this.wrapBoundValue(
939
+ construct: (s, a, o) => this.wrapBoundValue(
940
940
  Reflect.construct(
941
- i,
941
+ s,
942
942
  a,
943
943
  o
944
944
  ),
945
945
  e
946
946
  )
947
947
  });
948
- return e.set(r, s), s;
948
+ return e.set(r, i), i;
949
949
  }
950
950
  /**
951
951
  * Proxy ラップ対象の値かどうかを判定します。
@@ -978,8 +978,8 @@ return (${t});`;
978
978
  ...n,
979
979
  descriptor: Object.getOwnPropertyDescriptor(n.target, n.property)
980
980
  })).filter((n) => n.descriptor?.configurable === !0);
981
- r.forEach(({ target: n, property: s }) => {
982
- Object.defineProperty(n, s, {
981
+ r.forEach(({ target: n, property: i }) => {
982
+ Object.defineProperty(n, i, {
983
983
  configurable: !0,
984
984
  enumerable: !1,
985
985
  get: () => {
@@ -991,8 +991,8 @@ return (${t});`;
991
991
  try {
992
992
  return t();
993
993
  } finally {
994
- r.forEach(({ target: n, property: s, descriptor: i }) => {
995
- i !== void 0 && Object.defineProperty(n, s, i);
994
+ r.forEach(({ target: n, property: i, descriptor: s }) => {
995
+ s !== void 0 && Object.defineProperty(n, i, s);
996
996
  });
997
997
  }
998
998
  }
@@ -1046,7 +1046,7 @@ return (${t});`;
1046
1046
  return !1;
1047
1047
  }
1048
1048
  };
1049
- P.FORBIDDEN_NAMES = [
1049
+ S.FORBIDDEN_NAMES = [
1050
1050
  // グローバルオブジェクト
1051
1051
  "window",
1052
1052
  "self",
@@ -1078,19 +1078,19 @@ P.FORBIDDEN_NAMES = [
1078
1078
  "sessionStorage",
1079
1079
  "IndexedDB",
1080
1080
  "history"
1081
- ], P.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], P.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), P.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
1082
- ...P.FORBIDDEN_NAMES.filter(
1083
- (t) => !P.REBINDABLE_FORBIDDEN_NAMES.has(t)
1081
+ ], S.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], S.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), S.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
1082
+ ...S.FORBIDDEN_NAMES.filter(
1083
+ (t) => !S.REBINDABLE_FORBIDDEN_NAMES.has(t)
1084
1084
  ),
1085
1085
  "constructor",
1086
1086
  "__proto__",
1087
1087
  "prototype",
1088
- ...P.STRICT_FORBIDDEN_NAMES
1089
- ]), P.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
1088
+ ...S.STRICT_FORBIDDEN_NAMES
1089
+ ]), S.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
1090
1090
  "constructor",
1091
1091
  "__proto__",
1092
1092
  "prototype"
1093
- ]), P.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
1093
+ ]), S.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
1094
1094
  "await",
1095
1095
  "break",
1096
1096
  "case",
@@ -1124,8 +1124,8 @@ P.FORBIDDEN_NAMES = [
1124
1124
  "while",
1125
1125
  "with",
1126
1126
  "yield"
1127
- ]), P.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
1128
- let H = P;
1127
+ ]), S.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
1128
+ let $ = S;
1129
1129
  const k = class k {
1130
1130
  /**
1131
1131
  * フラグメントのコンストラクタ。
@@ -1143,7 +1143,7 @@ const k = class k {
1143
1143
  let e;
1144
1144
  switch (t.nodeType) {
1145
1145
  case Node.ELEMENT_NODE:
1146
- e = new x(t);
1146
+ e = new P(t);
1147
1147
  break;
1148
1148
  case Node.TEXT_NODE:
1149
1149
  e = new I(t);
@@ -1152,7 +1152,7 @@ const k = class k {
1152
1152
  e = new G(t);
1153
1153
  break;
1154
1154
  default:
1155
- return f.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
1155
+ return h.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
1156
1156
  }
1157
1157
  return e;
1158
1158
  }
@@ -1259,7 +1259,7 @@ const k = class k {
1259
1259
  };
1260
1260
  k.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
1261
1261
  let A = k;
1262
- class x extends A {
1262
+ class P extends A {
1263
1263
  /**
1264
1264
  * エレメントフラグメントのコンストラクタ。
1265
1265
  * アトリビュートや子フラグメントの作成も行います。
@@ -1285,7 +1285,7 @@ class x extends A {
1285
1285
  ], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.bindingDataCache = null, this.visible = !0, this.display = null, this.template = null, this.listKey = null, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.syncValue(), t.getAttributeNames().forEach((e) => {
1286
1286
  const r = t.getAttribute(e);
1287
1287
  if (r !== null && !this.attributeMap.has(e)) {
1288
- const n = new L(e, r);
1288
+ const n = new j(e, r);
1289
1289
  this.attributeMap.set(e, n);
1290
1290
  }
1291
1291
  }), t.childNodes.forEach((e) => {
@@ -1308,7 +1308,7 @@ class x extends A {
1308
1308
  */
1309
1309
  getChildElementFragments() {
1310
1310
  return this.children.filter(
1311
- (t) => t instanceof x
1311
+ (t) => t instanceof P
1312
1312
  );
1313
1313
  }
1314
1314
  /**
@@ -1329,7 +1329,7 @@ class x extends A {
1329
1329
  removeChild(t) {
1330
1330
  const e = this.children.indexOf(t);
1331
1331
  if (e < 0) {
1332
- f.warn("[Haori]", "Child fragment not found.", t);
1332
+ h.warn("[Haori]", "Child fragment not found.", t);
1333
1333
  return;
1334
1334
  }
1335
1335
  this.children.splice(e, 1), t.setParent(null);
@@ -1340,10 +1340,12 @@ class x extends A {
1340
1340
  * @returns クローンされたフラグメント
1341
1341
  */
1342
1342
  clone() {
1343
- const t = new x(
1343
+ const t = new P(
1344
1344
  this.target.cloneNode(!1)
1345
1345
  );
1346
- return this.children.forEach((e) => {
1346
+ return this.attributeMap.forEach((e, r) => {
1347
+ t.attributeMap.set(r, e);
1348
+ }), this.children.forEach((e) => {
1347
1349
  const r = e.clone();
1348
1350
  t.getTarget().appendChild(r.getTarget()), t.pushChild(r);
1349
1351
  }), t.mounted = !1, t.bindingData = this.bindingData, t.clearBindingDataCache(), t.visible = this.visible, t.display = this.display, t.template = this.template, t;
@@ -1393,12 +1395,20 @@ class x extends A {
1393
1395
  setBindingData(t) {
1394
1396
  this.bindingData = t, this.clearBindingDataCache();
1395
1397
  }
1398
+ /**
1399
+ * 親フラグメントを設定します。バインドデータキャッシュをクリアします。
1400
+ *
1401
+ * @param parent 親フラグメント
1402
+ */
1403
+ setParent(t) {
1404
+ this.parent !== t && (this.parent = t, this.clearBindingDataCache());
1405
+ }
1396
1406
  /**
1397
1407
  * バインドデータのキャッシュをクリアします。
1398
1408
  */
1399
1409
  clearBindingDataCache() {
1400
1410
  this.bindingDataCache = null, this.children.forEach((t) => {
1401
- t instanceof x && t.clearBindingDataCache();
1411
+ t instanceof P && t.clearBindingDataCache();
1402
1412
  });
1403
1413
  }
1404
1414
  /**
@@ -1456,7 +1466,7 @@ class x extends A {
1456
1466
  e.value = t === null ? "" : String(t), (e instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(e.type) || e instanceof HTMLTextAreaElement) && e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
1457
1467
  }).finally(() => {
1458
1468
  this.skipChangeValue = !1;
1459
- })) : (f.warn(
1469
+ })) : (h.warn(
1460
1470
  "[Haori]",
1461
1471
  "setValue is not supported for this element type.",
1462
1472
  e
@@ -1510,15 +1520,15 @@ class x extends A {
1510
1520
  return Promise.resolve();
1511
1521
  if (e === null)
1512
1522
  return this.removeAttribute(t);
1513
- const r = new L(t, e);
1523
+ const r = new j(t, e);
1514
1524
  this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
1515
- const n = this.getTarget(), s = r.isForceEvaluation() ? e : this.getAttribute(t);
1525
+ const n = this.getTarget(), i = r.isForceEvaluation() ? e : this.getAttribute(t);
1516
1526
  return N.enqueue(() => {
1517
- if (s === null || s === !1)
1527
+ if (i === null || i === !1)
1518
1528
  n.removeAttribute(t);
1519
1529
  else {
1520
- const i = String(s);
1521
- n.getAttribute(t) !== i && n.setAttribute(t, i);
1530
+ const s = String(i);
1531
+ n.getAttribute(t) !== s && n.setAttribute(t, s);
1522
1532
  }
1523
1533
  }).finally(() => {
1524
1534
  this.skipMutationAttributes = !1;
@@ -1553,7 +1563,7 @@ class x extends A {
1553
1563
  if (e === void 0)
1554
1564
  return null;
1555
1565
  const r = e.evaluate(this.getBindingData());
1556
- return r.length === 1 ? r[0] : B.joinEvaluateResults(r);
1566
+ return r.length === 1 ? r[0] : H.joinEvaluateResults(r);
1557
1567
  }
1558
1568
  /**
1559
1569
  * 属性の生の値を取得します。
@@ -1594,15 +1604,15 @@ class x extends A {
1594
1604
  if (r.parentNode !== this.target)
1595
1605
  return null;
1596
1606
  const n = e ? r.nextSibling : r;
1597
- let s = e ? r.nextSibling : r;
1598
- for (; s !== null; ) {
1599
- const i = A.get(s);
1600
- if (i !== null) {
1601
- const a = this.children.indexOf(i);
1607
+ let i = e ? r.nextSibling : r;
1608
+ for (; i !== null; ) {
1609
+ const s = A.get(i);
1610
+ if (s !== null) {
1611
+ const a = this.children.indexOf(s);
1602
1612
  if (a !== -1)
1603
1613
  return { index: a, referenceNode: n };
1604
1614
  }
1605
- s = s.nextSibling;
1615
+ i = i.nextSibling;
1606
1616
  }
1607
1617
  return { index: this.children.length, referenceNode: n };
1608
1618
  }
@@ -1618,42 +1628,42 @@ class x extends A {
1618
1628
  if (this.skipMutationNodes)
1619
1629
  return Promise.resolve();
1620
1630
  if (t === this)
1621
- return f.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
1631
+ return h.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
1622
1632
  const n = /* @__PURE__ */ new Set();
1623
- let s = this.parent;
1624
- for (; s; )
1625
- n.add(s), s = s.getParent();
1633
+ let i = this.parent;
1634
+ for (; i; )
1635
+ n.add(i), i = i.getParent();
1626
1636
  if (n.has(t))
1627
- return f.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
1628
- const i = t.getParent() === this;
1637
+ return h.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
1638
+ const s = t.getParent() === this;
1629
1639
  let a = -1, o = -1;
1630
- i && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
1631
- const g = t.getParent();
1632
- g !== null && g.removeChild(t);
1633
- let u = r === void 0 ? e?.getTarget() || null : r;
1640
+ s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
1641
+ const p = t.getParent();
1642
+ p !== null && p.removeChild(t);
1643
+ let c = r === void 0 ? e?.getTarget() || null : r;
1634
1644
  if (e === null)
1635
1645
  this.children.push(t);
1636
1646
  else {
1637
1647
  let l;
1638
- if (i ? a !== -1 && a < o ? l = o - 1 : l = o : l = this.children.indexOf(e), l === -1) {
1648
+ if (s ? a !== -1 && a < o ? l = o - 1 : l = o : l = this.children.indexOf(e), l === -1) {
1639
1649
  const d = this.resolveInsertionPointFromDom(
1640
1650
  e,
1641
1651
  !1
1642
1652
  );
1643
- d === null ? (f.warn(
1653
+ d === null ? (h.warn(
1644
1654
  "[Haori]",
1645
1655
  "Reference child not found in children.",
1646
1656
  e
1647
- ), this.children.push(t)) : (this.children.splice(d.index, 0, t), u = d.referenceNode);
1657
+ ), this.children.push(t)) : (this.children.splice(d.index, 0, t), c = d.referenceNode);
1648
1658
  } else
1649
1659
  this.children.splice(l, 0, t);
1650
1660
  }
1651
1661
  t.setParent(this), t.setMounted(this.mounted);
1652
- const b = this.skipMutationNodes;
1662
+ const y = this.skipMutationNodes;
1653
1663
  return this.skipMutationNodes = !0, N.enqueue(() => {
1654
- this.target.insertBefore(t.getTarget(), u);
1664
+ this.target.insertBefore(t.getTarget(), c);
1655
1665
  }).finally(() => {
1656
- this.skipMutationNodes = b;
1666
+ this.skipMutationNodes = y;
1657
1667
  });
1658
1668
  }
1659
1669
  /**
@@ -1672,7 +1682,7 @@ class x extends A {
1672
1682
  e,
1673
1683
  !0
1674
1684
  );
1675
- return n === null ? (f.warn(
1685
+ return n === null ? (h.warn(
1676
1686
  "[Haori]",
1677
1687
  "Reference child not found in children.",
1678
1688
  e
@@ -1724,7 +1734,7 @@ class x extends A {
1724
1734
  * @returns エレメントの非表示のPromise
1725
1735
  */
1726
1736
  hide() {
1727
- return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${h.prefix}if-false`, ""), Promise.resolve();
1737
+ return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${f.prefix}if-false`, ""), Promise.resolve();
1728
1738
  }
1729
1739
  /**
1730
1740
  * エレメントを表示します。
@@ -1732,7 +1742,7 @@ class x extends A {
1732
1742
  * @return エレメントの表示のPromise
1733
1743
  */
1734
1744
  show() {
1735
- return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${h.prefix}if-false`), this.visible = !0, Promise.resolve();
1745
+ return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${f.prefix}if-false`), this.visible = !0, Promise.resolve();
1736
1746
  }
1737
1747
  /**
1738
1748
  * 指定した属性名を持つ最も近い親要素を返します。
@@ -1756,7 +1766,7 @@ class I extends A {
1756
1766
  * @param target 対象テキストノード
1757
1767
  */
1758
1768
  constructor(t) {
1759
- super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new B(this.text);
1769
+ super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new H(this.text);
1760
1770
  }
1761
1771
  /**
1762
1772
  * フラグメントをクローンします。
@@ -1782,7 +1792,7 @@ class I extends A {
1782
1792
  * @returns 更新のPromise
1783
1793
  */
1784
1794
  setContent(t) {
1785
- return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new B(t), this.evaluate());
1795
+ return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new H(t), this.evaluate());
1786
1796
  }
1787
1797
  /**
1788
1798
  * フラグメントを評価します。
@@ -1795,7 +1805,7 @@ class I extends A {
1795
1805
  ) : N.enqueue(() => {
1796
1806
  this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
1797
1807
  this.parent.getBindingData()
1798
- )[0] : this.contents.isEvaluate ? this.target.textContent = B.joinEvaluateResults(
1808
+ )[0] : this.contents.isEvaluate ? this.target.textContent = H.joinEvaluateResults(
1799
1809
  this.contents.evaluate(this.parent.getBindingData())
1800
1810
  ) : this.target.textContent = this.text;
1801
1811
  }).finally(() => {
@@ -1844,7 +1854,7 @@ class G extends A {
1844
1854
  }));
1845
1855
  }
1846
1856
  }
1847
- const q = class q {
1857
+ const U = class U {
1848
1858
  /**
1849
1859
  * コンストラクタ。
1850
1860
  *
@@ -1852,26 +1862,26 @@ const q = class q {
1852
1862
  */
1853
1863
  constructor(t) {
1854
1864
  this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
1855
- const e = [...t.matchAll(q.PLACEHOLDER_REGEX)];
1856
- let r = 0, n = !1, s = !1;
1857
- for (const i of e) {
1858
- i.index > r && this.contents.push({
1859
- text: t.slice(r, i.index),
1865
+ const e = [...t.matchAll(U.PLACEHOLDER_REGEX)];
1866
+ let r = 0, n = !1, i = !1;
1867
+ for (const s of e) {
1868
+ s.index > r && this.contents.push({
1869
+ text: t.slice(r, s.index),
1860
1870
  type: 0
1861
1871
  /* TEXT */
1862
1872
  });
1863
1873
  const a = {
1864
- text: i[1] ?? i[2],
1865
- type: i[1] ? 2 : 1
1874
+ text: s[1] ?? s[2],
1875
+ type: s[1] ? 2 : 1
1866
1876
  /* EXPRESSION */
1867
1877
  };
1868
- n = !0, s = s || a.type === 2, this.contents.push(a), r = i.index + i[0].length;
1878
+ n = !0, i = i || a.type === 2, this.contents.push(a), r = s.index + s[0].length;
1869
1879
  }
1870
1880
  r < t.length && this.contents.push({
1871
1881
  text: t.slice(r),
1872
1882
  type: 0
1873
1883
  /* TEXT */
1874
- }), this.isEvaluate = n, this.isRawEvaluate = s, this.checkRawExpressions();
1884
+ }), this.isEvaluate = n, this.isRawEvaluate = i, this.checkRawExpressions();
1875
1885
  }
1876
1886
  /**
1877
1887
  * 評価結果を結合して文字列にします。
@@ -1895,7 +1905,7 @@ const q = class q {
1895
1905
  */
1896
1906
  checkRawExpressions() {
1897
1907
  for (let t = 0; t < this.contents.length; t++)
1898
- this.contents[t].type === 2 && this.contents.length > 1 && (f.error(
1908
+ this.contents[t].type === 2 && this.contents.length > 1 && (h.error(
1899
1909
  "[Haori]",
1900
1910
  "Raw expressions are not allowed in multi-content expressions."
1901
1911
  ), this.contents[t].type = 1);
@@ -1913,12 +1923,12 @@ const q = class q {
1913
1923
  return this.contents.forEach((r) => {
1914
1924
  try {
1915
1925
  if (r.type === 1 || r.type === 2) {
1916
- const n = H.evaluate(r.text, t);
1926
+ const n = $.evaluate(r.text, t);
1917
1927
  e.push(n);
1918
1928
  } else
1919
1929
  e.push(r.text);
1920
1930
  } catch (n) {
1921
- f.error(
1931
+ h.error(
1922
1932
  "[Haori]",
1923
1933
  `Error evaluating text expression: ${r.text}`,
1924
1934
  n
@@ -1927,9 +1937,9 @@ const q = class q {
1927
1937
  }), e;
1928
1938
  }
1929
1939
  };
1930
- q.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
1931
- let B = q;
1932
- const U = class U extends B {
1940
+ U.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
1941
+ let H = U;
1942
+ const q = class q extends H {
1933
1943
  /**
1934
1944
  * コンストラクタ。
1935
1945
  *
@@ -1937,7 +1947,7 @@ const U = class U extends B {
1937
1947
  * @param text 属性値
1938
1948
  */
1939
1949
  constructor(t, e) {
1940
- super(e), this.forceEvaluation = U.FORCE_EVALUATION_ATTRIBUTES.includes(t);
1950
+ super(e), this.forceEvaluation = q.FORCE_EVALUATION_ATTRIBUTES.includes(t);
1941
1951
  }
1942
1952
  /**
1943
1953
  * 強制評価フラグを取得します。
@@ -1960,32 +1970,32 @@ const U = class U extends B {
1960
1970
  return this.contents.forEach((r) => {
1961
1971
  try {
1962
1972
  if (this.forceEvaluation && r.type === 0 || r.type === 1 || r.type === 2) {
1963
- const n = H.evaluate(r.text, t);
1973
+ const n = $.evaluate(r.text, t);
1964
1974
  e.push(n);
1965
1975
  } else
1966
1976
  e.push(r.text);
1967
1977
  } catch (n) {
1968
- f.error(
1978
+ h.error(
1969
1979
  "[Haori]",
1970
1980
  `Error evaluating attribute expression: ${r.text}`,
1971
1981
  n
1972
1982
  ), e.push("");
1973
1983
  }
1974
- }), this.forceEvaluation && e.length > 1 ? (f.error(
1984
+ }), this.forceEvaluation && e.length > 1 ? (h.error(
1975
1985
  "[Haori]",
1976
1986
  "each or if expressions must have a single content.",
1977
1987
  e
1978
1988
  ), [e[0]]) : e;
1979
1989
  }
1980
1990
  };
1981
- U.FORCE_EVALUATION_ATTRIBUTES = [
1991
+ q.FORCE_EVALUATION_ATTRIBUTES = [
1982
1992
  "data-if",
1983
1993
  "hor-if",
1984
1994
  "data-each",
1985
1995
  "hor-each"
1986
1996
  ];
1987
- let L = U;
1988
- class y {
1997
+ let j = q;
1998
+ class E {
1989
1999
  /**
1990
2000
  * カスタムイベントを発火します。
1991
2001
  *
@@ -1995,13 +2005,13 @@ class y {
1995
2005
  * @param options イベントオプション
1996
2006
  */
1997
2007
  static dispatch(t, e, r, n) {
1998
- const s = new CustomEvent(`haori:${e}`, {
2008
+ const i = new CustomEvent(`haori:${e}`, {
1999
2009
  bubbles: n?.bubbles ?? !0,
2000
2010
  cancelable: n?.cancelable ?? !1,
2001
2011
  composed: n?.composed ?? !0,
2002
2012
  detail: r
2003
2013
  });
2004
- return t.dispatchEvent(s);
2014
+ return t.dispatchEvent(i);
2005
2015
  }
2006
2016
  /**
2007
2017
  * readyイベントを発火します。
@@ -2009,7 +2019,7 @@ class y {
2009
2019
  * @param version ライブラリバージョン
2010
2020
  */
2011
2021
  static ready(t) {
2012
- y.dispatch(document, "ready", { version: t });
2022
+ E.dispatch(document, "ready", { version: t });
2013
2023
  }
2014
2024
  /**
2015
2025
  * renderイベントを発火します。
@@ -2017,7 +2027,7 @@ class y {
2017
2027
  * @param target 評価対象要素
2018
2028
  */
2019
2029
  static render(t) {
2020
- y.dispatch(t, "render", { target: t });
2030
+ E.dispatch(t, "render", { target: t });
2021
2031
  }
2022
2032
  /**
2023
2033
  * importstartイベントを発火します。
@@ -2026,7 +2036,7 @@ class y {
2026
2036
  * @param url インポート対象URL
2027
2037
  */
2028
2038
  static importStart(t, e) {
2029
- y.dispatch(t, "importstart", {
2039
+ E.dispatch(t, "importstart", {
2030
2040
  url: e,
2031
2041
  startedAt: performance.now()
2032
2042
  });
@@ -2040,7 +2050,7 @@ class y {
2040
2050
  * @param startedAt 開始時刻
2041
2051
  */
2042
2052
  static importEnd(t, e, r, n) {
2043
- y.dispatch(t, "importend", {
2053
+ E.dispatch(t, "importend", {
2044
2054
  url: e,
2045
2055
  bytes: r,
2046
2056
  durationMs: performance.now() - n
@@ -2054,7 +2064,7 @@ class y {
2054
2064
  * @param error エラー内容
2055
2065
  */
2056
2066
  static importError(t, e, r) {
2057
- y.dispatch(t, "importerror", { url: e, error: r });
2067
+ E.dispatch(t, "importerror", { url: e, error: r });
2058
2068
  }
2059
2069
  /**
2060
2070
  * bindchangeイベントを発火します。
@@ -2065,15 +2075,15 @@ class y {
2065
2075
  * @param reason 変更理由
2066
2076
  */
2067
2077
  static bindChange(t, e, r, n = "other") {
2068
- const s = [], i = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...i, ...a]);
2069
- for (const g of o) {
2070
- const u = e?.[g], b = r[g];
2071
- u !== b && s.push(g);
2078
+ const i = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
2079
+ for (const p of o) {
2080
+ const c = e?.[p], y = r[p];
2081
+ c !== y && i.push(p);
2072
2082
  }
2073
- y.dispatch(t, "bindchange", {
2083
+ E.dispatch(t, "bindchange", {
2074
2084
  previous: e || {},
2075
2085
  next: r,
2076
- changedKeys: s,
2086
+ changedKeys: i,
2077
2087
  reason: n
2078
2088
  });
2079
2089
  }
@@ -2086,7 +2096,7 @@ class y {
2086
2096
  * @param order 現在の順序
2087
2097
  */
2088
2098
  static eachUpdate(t, e, r, n) {
2089
- y.dispatch(t, "eachupdate", {
2099
+ E.dispatch(t, "eachupdate", {
2090
2100
  added: e,
2091
2101
  removed: r,
2092
2102
  order: n,
@@ -2102,7 +2112,7 @@ class y {
2102
2112
  * @param item 行データ
2103
2113
  */
2104
2114
  static rowAdd(t, e, r, n) {
2105
- y.dispatch(t, "rowadd", { key: e, index: r, item: n });
2115
+ E.dispatch(t, "rowadd", { key: e, index: r, item: n });
2106
2116
  }
2107
2117
  /**
2108
2118
  * rowremoveイベントを発火します。
@@ -2112,7 +2122,7 @@ class y {
2112
2122
  * @param index インデックス
2113
2123
  */
2114
2124
  static rowRemove(t, e, r) {
2115
- y.dispatch(t, "rowremove", { key: e, index: r });
2125
+ E.dispatch(t, "rowremove", { key: e, index: r });
2116
2126
  }
2117
2127
  /**
2118
2128
  * rowmoveイベントを発火します。
@@ -2123,7 +2133,7 @@ class y {
2123
2133
  * @param to 移動後インデックス
2124
2134
  */
2125
2135
  static rowMove(t, e, r, n) {
2126
- y.dispatch(t, "rowmove", { key: e, from: r, to: n });
2136
+ E.dispatch(t, "rowmove", { key: e, from: r, to: n });
2127
2137
  }
2128
2138
  /**
2129
2139
  * showイベントを発火します。
@@ -2131,7 +2141,7 @@ class y {
2131
2141
  * @param target data-if要素
2132
2142
  */
2133
2143
  static show(t) {
2134
- y.dispatch(t, "show", { visible: !0 });
2144
+ E.dispatch(t, "show", { visible: !0 });
2135
2145
  }
2136
2146
  /**
2137
2147
  * hideイベントを発火します。
@@ -2139,7 +2149,7 @@ class y {
2139
2149
  * @param target data-if要素
2140
2150
  */
2141
2151
  static hide(t) {
2142
- y.dispatch(t, "hide", { visible: !1 });
2152
+ E.dispatch(t, "hide", { visible: !1 });
2143
2153
  }
2144
2154
  /**
2145
2155
  * fetchstartイベントを発火します。
@@ -2150,7 +2160,7 @@ class y {
2150
2160
  * @param payload 送信データ
2151
2161
  */
2152
2162
  static fetchStart(t, e, r, n) {
2153
- y.dispatch(t, "fetchstart", {
2163
+ E.dispatch(t, "fetchstart", {
2154
2164
  url: e,
2155
2165
  options: r || {},
2156
2166
  payload: n,
@@ -2166,7 +2176,7 @@ class y {
2166
2176
  * @param startedAt 開始時刻
2167
2177
  */
2168
2178
  static fetchEnd(t, e, r, n) {
2169
- y.dispatch(t, "fetchend", {
2179
+ E.dispatch(t, "fetchend", {
2170
2180
  url: e,
2171
2181
  status: r,
2172
2182
  durationMs: performance.now() - n
@@ -2181,12 +2191,12 @@ class y {
2181
2191
  * @param status HTTPステータス(存在する場合)
2182
2192
  * @param startedAt 開始時刻(存在する場合)
2183
2193
  */
2184
- static fetchError(t, e, r, n, s) {
2185
- y.dispatch(t, "fetcherror", {
2194
+ static fetchError(t, e, r, n, i) {
2195
+ E.dispatch(t, "fetcherror", {
2186
2196
  url: e,
2187
2197
  status: n,
2188
2198
  error: r,
2189
- durationMs: s ? performance.now() - s : void 0
2199
+ durationMs: i ? performance.now() - i : void 0
2190
2200
  });
2191
2201
  }
2192
2202
  }
@@ -2202,9 +2212,9 @@ function K() {
2202
2212
  const t = globalThis.window?.Haori;
2203
2213
  return Z.every(
2204
2214
  (r) => typeof t?.[r] == "function"
2205
- ) ? t : X;
2215
+ ) ? t : W;
2206
2216
  }
2207
- const c = class c {
2217
+ const u = class u {
2208
2218
  /**
2209
2219
  * イベント属性名を正しく生成します。
2210
2220
  * 例: ("click", "fetch") => "data-click-fetch"
@@ -2213,7 +2223,7 @@ const c = class c {
2213
2223
  * 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
2214
2224
  */
2215
2225
  static attrName(t, e, r = !1) {
2216
- return t ? `${h.prefix}${t}-${e}` : r ? `${h.prefix}fetch-${e}` : `${h.prefix}${e}`;
2226
+ return t ? `${f.prefix}${t}-${e}` : r ? `${f.prefix}fetch-${e}` : `${f.prefix}${e}`;
2217
2227
  }
2218
2228
  /**
2219
2229
  * data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
@@ -2224,13 +2234,13 @@ const c = class c {
2224
2234
  */
2225
2235
  static resolveDataParamString(t, e) {
2226
2236
  return t.replace(
2227
- c.DATA_PLACEHOLDER_REGEX,
2228
- (r, n, s) => {
2229
- const i = H.evaluate(
2230
- n ?? s ?? "",
2237
+ u.DATA_PLACEHOLDER_REGEX,
2238
+ (r, n, i) => {
2239
+ const s = $.evaluate(
2240
+ n ?? i ?? "",
2231
2241
  e
2232
2242
  );
2233
- return i == null || Number.isNaN(i) ? "" : encodeURIComponent(typeof i == "object" ? JSON.stringify(i) : String(i));
2243
+ return s == null || Number.isNaN(s) ? "" : encodeURIComponent(typeof s == "object" ? JSON.stringify(s) : String(s));
2234
2244
  }
2235
2245
  );
2236
2246
  }
@@ -2243,17 +2253,17 @@ const c = class c {
2243
2253
  */
2244
2254
  static isJsonStringContext(t, e) {
2245
2255
  let r = !1, n = !1;
2246
- for (let s = 0; s < e; s += 1) {
2247
- const i = t[s];
2256
+ for (let i = 0; i < e; i += 1) {
2257
+ const s = t[i];
2248
2258
  if (n) {
2249
2259
  n = !1;
2250
2260
  continue;
2251
2261
  }
2252
- if (i === "\\") {
2262
+ if (s === "\\") {
2253
2263
  n = !0;
2254
2264
  continue;
2255
2265
  }
2256
- i === '"' && (r = !r);
2266
+ s === '"' && (r = !r);
2257
2267
  }
2258
2268
  return r;
2259
2269
  }
@@ -2281,7 +2291,7 @@ const c = class c {
2281
2291
  static stringifyJsonTemplateStringContent(t) {
2282
2292
  if (t == null || Number.isNaN(t))
2283
2293
  return "";
2284
- const e = typeof t == "object" ? c.stringifyJsonTemplateValue(t) : String(t);
2294
+ const e = typeof t == "object" ? u.stringifyJsonTemplateValue(t) : String(t);
2285
2295
  return JSON.stringify(e).slice(1, -1);
2286
2296
  }
2287
2297
  /**
@@ -2293,13 +2303,13 @@ const c = class c {
2293
2303
  */
2294
2304
  static resolveDataJsonString(t, e) {
2295
2305
  return t.replace(
2296
- c.DATA_PLACEHOLDER_REGEX,
2297
- (r, n, s, i) => {
2298
- const a = H.evaluate(
2299
- n ?? s ?? "",
2306
+ u.DATA_PLACEHOLDER_REGEX,
2307
+ (r, n, i, s) => {
2308
+ const a = $.evaluate(
2309
+ n ?? i ?? "",
2300
2310
  e
2301
2311
  );
2302
- return c.isJsonStringContext(t, i) ? c.stringifyJsonTemplateStringContent(a) : c.stringifyJsonTemplateValue(a);
2312
+ return u.isJsonStringContext(t, s) ? u.stringifyJsonTemplateStringContent(a) : u.stringifyJsonTemplateValue(a);
2303
2313
  }
2304
2314
  );
2305
2315
  }
@@ -2316,14 +2326,14 @@ const c = class c {
2316
2326
  return n;
2317
2327
  if (typeof n != "string" || r === null)
2318
2328
  return null;
2319
- const s = r.trim();
2320
- return c.SINGLE_PLACEHOLDER_REGEX.test(s) ? T.parseDataBind(n) : s.startsWith("{") || s.startsWith("[") ? T.parseDataBind(
2321
- c.resolveDataJsonString(
2329
+ const i = r.trim();
2330
+ return u.SINGLE_PLACEHOLDER_REGEX.test(i) ? T.parseDataBind(n) : i.startsWith("{") || i.startsWith("[") ? T.parseDataBind(
2331
+ u.resolveDataJsonString(
2322
2332
  r,
2323
2333
  t.getBindingData()
2324
2334
  )
2325
2335
  ) : T.parseDataBind(
2326
- c.resolveDataParamString(r, t.getBindingData())
2336
+ u.resolveDataParamString(r, t.getBindingData())
2327
2337
  );
2328
2338
  }
2329
2339
  /**
@@ -2338,29 +2348,29 @@ const c = class c {
2338
2348
  targetFragment: t
2339
2349
  };
2340
2350
  if (e) {
2341
- if (t.hasAttribute(c.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(c.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
2342
- c.attrName(e, "confirm")
2343
- )), t.hasAttribute(c.attrName(e, "data")) && (r.data = c.resolveDataAttribute(
2351
+ if (t.hasAttribute(u.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(u.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
2352
+ u.attrName(e, "confirm")
2353
+ )), t.hasAttribute(u.attrName(e, "data")) && (r.data = u.resolveDataAttribute(
2344
2354
  t,
2345
- c.attrName(e, "data")
2346
- )), t.hasAttribute(c.attrName(e, "form"))) {
2355
+ u.attrName(e, "data")
2356
+ )), t.hasAttribute(u.attrName(e, "form"))) {
2347
2357
  const l = t.getRawAttribute(
2348
- c.attrName(e, "form")
2358
+ u.attrName(e, "form")
2349
2359
  );
2350
2360
  if (l) {
2351
2361
  const d = document.body.querySelector(l);
2352
- d !== null ? r.formFragment = E.getFormFragment(
2362
+ d !== null ? r.formFragment = b.getFormFragment(
2353
2363
  A.get(d)
2354
- ) : f.error(
2364
+ ) : h.error(
2355
2365
  "Haori",
2356
- `Form element not found: ${l} (${c.attrName(e, "form")})`
2366
+ `Form element not found: ${l} (${u.attrName(e, "form")})`
2357
2367
  );
2358
2368
  } else
2359
- r.formFragment = E.getFormFragment(t);
2360
- } else e === "change" && (r.formFragment = E.getFormFragment(t));
2361
- if (t.hasAttribute(`${h.prefix}${e}-before-run`)) {
2369
+ r.formFragment = b.getFormFragment(t);
2370
+ } else e === "change" && (r.formFragment = b.getFormFragment(t));
2371
+ if (t.hasAttribute(`${f.prefix}${e}-before-run`)) {
2362
2372
  const l = t.getRawAttribute(
2363
- `${h.prefix}${e}-before-run`
2373
+ `${f.prefix}${e}-before-run`
2364
2374
  );
2365
2375
  try {
2366
2376
  r.beforeCallback = new Function(
@@ -2372,38 +2382,38 @@ ${l}
2372
2382
  `
2373
2383
  );
2374
2384
  } catch (d) {
2375
- f.error("Haori", `Invalid before script: ${d}`);
2385
+ h.error("Haori", `Invalid before script: ${d}`);
2376
2386
  }
2377
2387
  }
2378
2388
  }
2379
- const n = c.attrName(e, "fetch"), s = t.hasAttribute(n);
2380
- s && (r.fetchUrl = t.getAttribute(n));
2381
- const i = {};
2389
+ const n = u.attrName(e, "fetch"), i = t.hasAttribute(n);
2390
+ i && (r.fetchUrl = t.getAttribute(n));
2391
+ const s = {};
2382
2392
  if (e) {
2383
- const l = c.attrName(e, "fetch-method");
2384
- t.hasAttribute(l) && (i.method = t.getAttribute(
2393
+ const l = u.attrName(e, "fetch-method");
2394
+ t.hasAttribute(l) && (s.method = t.getAttribute(
2385
2395
  l
2386
2396
  ));
2387
2397
  } else {
2388
- const l = c.attrName(null, "method", !0);
2389
- t.hasAttribute(l) && (i.method = t.getAttribute(
2398
+ const l = u.attrName(null, "method", !0);
2399
+ t.hasAttribute(l) && (s.method = t.getAttribute(
2390
2400
  l
2391
2401
  ));
2392
2402
  }
2393
2403
  if (e) {
2394
- const l = c.attrName(e, "fetch-headers");
2404
+ const l = u.attrName(e, "fetch-headers");
2395
2405
  if (t.hasAttribute(l)) {
2396
2406
  const d = t.getRawAttribute(
2397
2407
  l
2398
2408
  );
2399
2409
  try {
2400
- i.headers = T.parseDataBind(d);
2401
- } catch (p) {
2402
- f.error("Haori", `Invalid fetch headers: ${p}`);
2410
+ s.headers = T.parseDataBind(d);
2411
+ } catch (g) {
2412
+ h.error("Haori", `Invalid fetch headers: ${g}`);
2403
2413
  }
2404
2414
  }
2405
2415
  } else {
2406
- const l = c.attrName(
2416
+ const l = u.attrName(
2407
2417
  null,
2408
2418
  "headers",
2409
2419
  !0
@@ -2413,111 +2423,111 @@ ${l}
2413
2423
  l
2414
2424
  );
2415
2425
  try {
2416
- i.headers = T.parseDataBind(d);
2417
- } catch (p) {
2418
- f.error("Haori", `Invalid fetch headers: ${p}`);
2426
+ s.headers = T.parseDataBind(d);
2427
+ } catch (g) {
2428
+ h.error("Haori", `Invalid fetch headers: ${g}`);
2419
2429
  }
2420
2430
  }
2421
2431
  }
2422
2432
  if (e) {
2423
- const l = c.attrName(
2433
+ const l = u.attrName(
2424
2434
  e,
2425
2435
  "fetch-content-type"
2426
2436
  );
2427
2437
  if (t.hasAttribute(l))
2428
- i.headers = {
2429
- ...i.headers,
2438
+ s.headers = {
2439
+ ...s.headers,
2430
2440
  "Content-Type": t.getAttribute(l)
2431
2441
  };
2432
- else if (i.method && i.method !== "GET" && i.method !== "HEAD" && i.method !== "OPTIONS") {
2442
+ else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
2433
2443
  let d = !1;
2434
- i.headers && typeof i.headers == "object" && (d = "Content-Type" in i.headers), d || (i.headers = {
2435
- ...i.headers,
2444
+ s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
2445
+ ...s.headers,
2436
2446
  "Content-Type": "application/json"
2437
2447
  });
2438
- } else i.method && (i.method === "GET" || i.method === "HEAD" || i.method === "OPTIONS") && (i.headers = {
2439
- ...i.headers,
2448
+ } else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
2449
+ ...s.headers,
2440
2450
  "Content-Type": "application/x-www-form-urlencoded"
2441
2451
  });
2442
2452
  } else {
2443
- const l = c.attrName(
2453
+ const l = u.attrName(
2444
2454
  null,
2445
2455
  "content-type",
2446
2456
  !0
2447
2457
  );
2448
2458
  if (t.hasAttribute(l))
2449
- i.headers = {
2450
- ...i.headers,
2459
+ s.headers = {
2460
+ ...s.headers,
2451
2461
  "Content-Type": t.getAttribute(l)
2452
2462
  };
2453
- else if (i.method && i.method !== "GET" && i.method !== "HEAD" && i.method !== "OPTIONS") {
2463
+ else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
2454
2464
  let d = !1;
2455
- i.headers && typeof i.headers == "object" && (d = "Content-Type" in i.headers), d || (i.headers = {
2456
- ...i.headers,
2465
+ s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
2466
+ ...s.headers,
2457
2467
  "Content-Type": "application/json"
2458
2468
  });
2459
- } else i.method && (i.method === "GET" || i.method === "HEAD" || i.method === "OPTIONS") && (i.headers = {
2460
- ...i.headers,
2469
+ } else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
2470
+ ...s.headers,
2461
2471
  "Content-Type": "application/x-www-form-urlencoded"
2462
2472
  });
2463
2473
  }
2464
- Object.keys(i).length > 0 && (r.fetchOptions = i);
2465
- const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
2474
+ Object.keys(s).length > 0 && (r.fetchOptions = s);
2475
+ const a = e ? u.attrName(e, "bind") : u.attrName(null, "bind", !0);
2466
2476
  if (t.hasAttribute(a)) {
2467
2477
  const l = t.getRawAttribute(a);
2468
2478
  if (l) {
2469
2479
  const d = document.body.querySelectorAll(l);
2470
- d.length > 0 ? (r.bindFragments = [], d.forEach((p) => {
2471
- const v = A.get(p);
2480
+ d.length > 0 ? (r.bindFragments = [], d.forEach((g) => {
2481
+ const v = A.get(g);
2472
2482
  v && r.bindFragments.push(v);
2473
- })) : f.error(
2483
+ })) : h.error(
2474
2484
  "Haori",
2475
2485
  `Bind element not found: ${l} (${a})`
2476
2486
  );
2477
2487
  }
2478
2488
  }
2479
- const o = c.attrName(e, "bind-arg"), g = c.attrName(
2489
+ const o = u.attrName(e, "bind-arg"), p = u.attrName(
2480
2490
  null,
2481
2491
  "arg",
2482
2492
  !0
2483
- ), u = c.attrName(
2493
+ ), c = u.attrName(
2484
2494
  null,
2485
2495
  "bind-arg",
2486
2496
  !0
2487
2497
  );
2488
- e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(g) ? r.bindArg = t.getRawAttribute(
2489
- g
2490
- ) : t.hasAttribute(u) && (r.bindArg = t.getRawAttribute(u));
2491
- const b = e ? c.attrName(e, "bind-params") : c.attrName(null, "bind-params", !0);
2492
- if (t.hasAttribute(b)) {
2493
- const l = t.getRawAttribute(b);
2498
+ e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(p) ? r.bindArg = t.getRawAttribute(
2499
+ p
2500
+ ) : t.hasAttribute(c) && (r.bindArg = t.getRawAttribute(c));
2501
+ const y = e ? u.attrName(e, "bind-params") : u.attrName(null, "bind-params", !0);
2502
+ if (t.hasAttribute(y)) {
2503
+ const l = t.getRawAttribute(y);
2494
2504
  r.bindParams = l.split("&").map((d) => d.trim());
2495
2505
  }
2496
2506
  if (e) {
2497
- if (t.hasAttribute(c.attrName(e, "adjust"))) {
2507
+ if (t.hasAttribute(u.attrName(e, "adjust"))) {
2498
2508
  const d = t.getRawAttribute(
2499
- c.attrName(e, "adjust")
2509
+ u.attrName(e, "adjust")
2500
2510
  );
2501
2511
  if (d) {
2502
- const p = document.body.querySelectorAll(d);
2503
- p.length > 0 ? (r.adjustFragments = [], p.forEach((v) => {
2512
+ const g = document.body.querySelectorAll(d);
2513
+ g.length > 0 ? (r.adjustFragments = [], g.forEach((v) => {
2504
2514
  const w = A.get(v);
2505
2515
  w && r.adjustFragments.push(w);
2506
- })) : f.error(
2516
+ })) : h.error(
2507
2517
  "Haori",
2508
- `Adjust element not found: ${d} (${c.attrName(e, "adjust")})`
2518
+ `Adjust element not found: ${d} (${u.attrName(e, "adjust")})`
2509
2519
  );
2510
2520
  }
2511
- if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
2512
- const p = t.getRawAttribute(
2513
- c.attrName(e, "adjust-value")
2514
- ), v = Number(p);
2521
+ if (t.hasAttribute(u.attrName(e, "adjust-value"))) {
2522
+ const g = t.getRawAttribute(
2523
+ u.attrName(e, "adjust-value")
2524
+ ), v = Number(g);
2515
2525
  isNaN(v) || (r.adjustValue = v);
2516
2526
  }
2517
2527
  }
2518
- if (t.hasAttribute(c.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(c.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(c.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(c.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${h.prefix}${e}-after-run`)) {
2528
+ if (t.hasAttribute(u.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(u.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(u.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(u.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${f.prefix}${e}-after-run`)) {
2519
2529
  const d = t.getRawAttribute(
2520
- `${h.prefix}${e}-after-run`
2530
+ `${f.prefix}${e}-after-run`
2521
2531
  );
2522
2532
  try {
2523
2533
  r.afterCallback = new Function(
@@ -2527,31 +2537,51 @@ ${l}
2527
2537
  ${d}
2528
2538
  `
2529
2539
  );
2530
- } catch (p) {
2531
- f.error("Haori", `Invalid after script: ${p}`);
2540
+ } catch (g) {
2541
+ h.error("Haori", `Invalid after script: ${g}`);
2532
2542
  }
2533
2543
  }
2534
- t.hasAttribute(c.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
2535
- c.attrName(e, "dialog")
2536
- )), t.hasAttribute(c.attrName(e, "toast")) && (r.toastMessage = t.getAttribute(
2537
- c.attrName(e, "toast")
2538
- )), t.hasAttribute(c.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
2539
- c.attrName(e, "redirect")
2540
- )), [
2544
+ if (t.hasAttribute(u.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
2545
+ u.attrName(e, "dialog")
2546
+ )), t.hasAttribute(u.attrName(e, "toast")) && (r.toastMessage = t.getAttribute(
2547
+ u.attrName(e, "toast")
2548
+ )), t.hasAttribute(u.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
2549
+ u.attrName(e, "redirect")
2550
+ )), t.hasAttribute(u.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
2551
+ u.attrName(e, "history")
2552
+ )), t.hasAttribute(u.attrName(e, "history-data")) && (r.historyData = u.resolveDataAttribute(
2553
+ t,
2554
+ u.attrName(e, "history-data")
2555
+ )), t.hasAttribute(u.attrName(e, "history-form"))) {
2556
+ const d = t.getRawAttribute(
2557
+ u.attrName(e, "history-form")
2558
+ );
2559
+ if (d) {
2560
+ const g = document.body.querySelector(d);
2561
+ g !== null ? r.historyFormFragment = b.getFormFragment(
2562
+ A.get(g)
2563
+ ) : h.error(
2564
+ "Haori",
2565
+ `Form element not found: ${d} (${u.attrName(e, "history-form")})`
2566
+ );
2567
+ } else
2568
+ r.historyFormFragment = b.getFormFragment(t);
2569
+ }
2570
+ [
2541
2571
  "reset",
2542
2572
  "refetch",
2543
2573
  "click",
2544
2574
  "open",
2545
2575
  "close"
2546
2576
  ].forEach((d) => {
2547
- const p = c.attrName(e, d);
2548
- if (!t.hasAttribute(p))
2577
+ const g = u.attrName(e, d);
2578
+ if (!t.hasAttribute(g))
2549
2579
  return;
2550
- const v = t.getRawAttribute(p), w = [];
2551
- if (v ? (document.body.querySelectorAll(v).forEach((S) => {
2552
- const F = A.get(S);
2553
- F && w.push(F);
2554
- }), w.length === 0 && f.error("Haori", `Element not found: ${v} (${p})`)) : w.push(t), w.length > 0)
2580
+ const v = t.getRawAttribute(g), w = [];
2581
+ if (v ? (document.body.querySelectorAll(v).forEach((F) => {
2582
+ const x = A.get(F);
2583
+ x && w.push(x);
2584
+ }), w.length === 0 && h.error("Haori", `Element not found: ${v} (${g})`)) : w.push(t), w.length > 0)
2555
2585
  switch (d) {
2556
2586
  case "reset":
2557
2587
  r.resetFragments = w;
@@ -2571,25 +2601,25 @@ ${d}
2571
2601
  }
2572
2602
  });
2573
2603
  }
2574
- if (!e && (t.hasAttribute(c.attrName(null, "data", !0)) && (r.data = c.resolveDataAttribute(
2604
+ if (!e && (t.hasAttribute(u.attrName(null, "data", !0)) && (r.data = u.resolveDataAttribute(
2575
2605
  t,
2576
- c.attrName(null, "data", !0)
2577
- )), t.hasAttribute(c.attrName(null, "form", !0)))) {
2606
+ u.attrName(null, "data", !0)
2607
+ )), t.hasAttribute(u.attrName(null, "form", !0)))) {
2578
2608
  const l = t.getRawAttribute(
2579
- c.attrName(null, "form", !0)
2609
+ u.attrName(null, "form", !0)
2580
2610
  );
2581
2611
  if (l) {
2582
2612
  const d = document.body.querySelector(l);
2583
- d !== null ? r.formFragment = E.getFormFragment(
2613
+ d !== null ? r.formFragment = b.getFormFragment(
2584
2614
  A.get(d)
2585
- ) : f.error(
2615
+ ) : h.error(
2586
2616
  "Haori",
2587
- `Form element not found: ${l} (${c.attrName(null, "fetch-form", !0)})`
2617
+ `Form element not found: ${l} (${u.attrName(null, "fetch-form", !0)})`
2588
2618
  );
2589
2619
  } else
2590
- r.formFragment = E.getFormFragment(t);
2620
+ r.formFragment = b.getFormFragment(t);
2591
2621
  }
2592
- return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
2622
+ return i && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
2593
2623
  }
2594
2624
  /**
2595
2625
  * ElementFragment の構造的タイプガード。
@@ -2610,7 +2640,7 @@ ${d}
2610
2640
  * @param arg2 イベント名
2611
2641
  */
2612
2642
  constructor(t, e = null) {
2613
- c.isElementFragment(t) ? this.options = c.buildOptions(t, e) : this.options = t;
2643
+ u.isElementFragment(t) ? this.options = u.buildOptions(t, e) : this.options = t;
2614
2644
  }
2615
2645
  /**
2616
2646
  * 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
@@ -2623,82 +2653,82 @@ ${d}
2623
2653
  return Promise.resolve();
2624
2654
  let e = this.options.fetchUrl, r = this.options.fetchOptions;
2625
2655
  if (this.options.beforeCallback) {
2626
- const i = this.options.beforeCallback(
2656
+ const s = this.options.beforeCallback(
2627
2657
  e || null,
2628
2658
  r || null
2629
2659
  );
2630
- if (i != null) {
2631
- if (i === !1 || typeof i == "object" && i.stop)
2660
+ if (s != null) {
2661
+ if (s === !1 || typeof s == "object" && s.stop)
2632
2662
  return Promise.resolve();
2633
- typeof i == "object" && (e = "fetchUrl" in i ? i.fetchUrl : e, r = "fetchOptions" in i ? i.fetchOptions : r);
2663
+ typeof s == "object" && (e = "fetchUrl" in s ? s.fetchUrl : e, r = "fetchOptions" in s ? s.fetchOptions : r);
2634
2664
  }
2635
2665
  }
2636
2666
  const n = {};
2637
2667
  if (this.options.formFragment) {
2638
- const i = E.getValues(this.options.formFragment);
2639
- Object.assign(n, i);
2668
+ const s = b.getValues(this.options.formFragment);
2669
+ Object.assign(n, s);
2640
2670
  }
2641
2671
  this.options.data && typeof this.options.data == "object" && Object.assign(n, this.options.data);
2642
- const s = Object.keys(n).length > 0;
2672
+ const i = Object.keys(n).length > 0;
2643
2673
  if (e) {
2644
- const i = { ...r || {} }, a = new Headers(
2645
- i.headers || void 0
2646
- ), o = (i.method || "GET").toUpperCase();
2674
+ const s = { ...r || {} }, a = new Headers(
2675
+ s.headers || void 0
2676
+ ), o = (s.method || "GET").toUpperCase();
2647
2677
  if (o === "GET" || o === "HEAD" || o === "OPTIONS") {
2648
- if (s) {
2649
- const g = new URL(e, window.location.href), u = new URLSearchParams(g.search);
2650
- for (const [b, l] of Object.entries(n))
2651
- l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((d) => {
2652
- u.append(b, String(d));
2653
- }) : typeof l == "object" || typeof l == "function" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
2654
- g.search = u.toString(), e = g.toString();
2678
+ if (i) {
2679
+ const p = new URL(e, window.location.href), c = new URLSearchParams(p.search);
2680
+ for (const [y, l] of Object.entries(n))
2681
+ l !== void 0 && (l === null ? c.append(y, "") : Array.isArray(l) ? l.forEach((d) => {
2682
+ c.append(y, String(d));
2683
+ }) : typeof l == "object" || typeof l == "function" ? c.append(y, JSON.stringify(l)) : c.append(y, String(l)));
2684
+ p.search = c.toString(), e = p.toString();
2655
2685
  }
2656
- } else if (s) {
2657
- const g = a.get("Content-Type") || "";
2658
- if (/multipart\/form-data/i.test(g)) {
2686
+ } else if (i) {
2687
+ const p = a.get("Content-Type") || "";
2688
+ if (/multipart\/form-data/i.test(p)) {
2659
2689
  a.delete("Content-Type");
2660
- const u = new FormData();
2661
- for (const [b, l] of Object.entries(n))
2662
- l == null ? u.append(b, "") : l instanceof Blob ? u.append(b, l) : Array.isArray(l) ? l.forEach((d) => u.append(b, String(d))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l));
2663
- i.body = u;
2664
- } else if (/application\/x-www-form-urlencoded/i.test(g)) {
2665
- const u = new URLSearchParams();
2666
- for (const [b, l] of Object.entries(n))
2667
- l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((d) => u.append(b, String(d))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
2668
- i.body = u;
2690
+ const c = new FormData();
2691
+ for (const [y, l] of Object.entries(n))
2692
+ l == null ? c.append(y, "") : l instanceof Blob ? c.append(y, l) : Array.isArray(l) ? l.forEach((d) => c.append(y, String(d))) : typeof l == "object" ? c.append(y, JSON.stringify(l)) : c.append(y, String(l));
2693
+ s.body = c;
2694
+ } else if (/application\/x-www-form-urlencoded/i.test(p)) {
2695
+ const c = new URLSearchParams();
2696
+ for (const [y, l] of Object.entries(n))
2697
+ l !== void 0 && (l === null ? c.append(y, "") : Array.isArray(l) ? l.forEach((d) => c.append(y, String(d))) : typeof l == "object" ? c.append(y, JSON.stringify(l)) : c.append(y, String(l)));
2698
+ s.body = c;
2669
2699
  } else
2670
- a.set("Content-Type", "application/json"), i.body = JSON.stringify(n);
2700
+ a.set("Content-Type", "application/json"), s.body = JSON.stringify(n);
2671
2701
  }
2672
- if (i.headers = a, this.options.targetFragment && e) {
2673
- const g = performance.now();
2674
- return y.fetchStart(
2702
+ if (s.headers = a, this.options.targetFragment && e) {
2703
+ const p = performance.now();
2704
+ return E.fetchStart(
2675
2705
  this.options.targetFragment.getTarget(),
2676
2706
  e,
2677
- i,
2678
- s ? n : void 0
2679
- ), fetch(e, i).then((u) => this.handleFetchResult(
2680
- u,
2707
+ s,
2708
+ i ? n : void 0
2709
+ ), fetch(e, s).then((c) => this.handleFetchResult(
2710
+ c,
2681
2711
  e || void 0,
2682
- g
2683
- )).catch((u) => {
2684
- throw e && y.fetchError(
2712
+ p
2713
+ )).catch((c) => {
2714
+ throw e && E.fetchError(
2685
2715
  this.options.targetFragment.getTarget(),
2686
2716
  e,
2687
- u
2688
- ), u;
2717
+ c
2718
+ ), c;
2689
2719
  });
2690
- } else return e ? fetch(e, i).then((g) => this.handleFetchResult(g, e || void 0)) : Promise.resolve();
2720
+ } else return e ? fetch(e, s).then((p) => this.handleFetchResult(p, e || void 0)) : Promise.resolve();
2691
2721
  } else {
2692
- if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
2693
- const o = this.options.formFragment, g = o.getTarget();
2694
- g.setAttribute(
2695
- `${h.prefix}bind`,
2722
+ if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && i) {
2723
+ const o = this.options.formFragment, p = o.getTarget();
2724
+ p.setAttribute(
2725
+ `${f.prefix}bind`,
2696
2726
  JSON.stringify(n)
2697
2727
  );
2698
- const u = o.getBindingData();
2699
- return Object.assign(u, n), T.setBindingData(g, u);
2728
+ const c = o.getBindingData();
2729
+ return Object.assign(c, n), T.setBindingData(p, c);
2700
2730
  }
2701
- const i = s ? n : {}, a = new Response(JSON.stringify(i), {
2731
+ const s = i ? n : {}, a = new Response(JSON.stringify(s), {
2702
2732
  headers: { "Content-Type": "application/json" }
2703
2733
  });
2704
2734
  return this.handleFetchResult(a);
@@ -2711,82 +2741,115 @@ ${d}
2711
2741
  handleFetchResult(t, e, r) {
2712
2742
  const n = K();
2713
2743
  if (!t.ok)
2714
- return this.options.targetFragment && e && y.fetchError(
2744
+ return this.options.targetFragment && e && E.fetchError(
2715
2745
  this.options.targetFragment.getTarget(),
2716
2746
  e,
2717
2747
  new Error(`${t.status} ${t.statusText}`),
2718
2748
  t.status,
2719
2749
  r
2720
2750
  ), this.handleFetchError(t);
2721
- if (this.options.targetFragment && e && r && y.fetchEnd(
2751
+ if (this.options.targetFragment && e && r && E.fetchEnd(
2722
2752
  this.options.targetFragment.getTarget(),
2723
2753
  e,
2724
2754
  t.status,
2725
2755
  r
2726
2756
  ), this.options.afterCallback) {
2727
- const i = this.options.afterCallback(t);
2728
- if (i != null) {
2729
- if (i === !1 || typeof i == "object" && i.stop)
2757
+ const s = this.options.afterCallback(t);
2758
+ if (s != null) {
2759
+ if (s === !1 || typeof s == "object" && s.stop)
2730
2760
  return Promise.resolve();
2731
- typeof i == "object" && "response" in i && (t = "response" in i ? i.response : t);
2761
+ typeof s == "object" && "response" in s && (t = "response" in s ? s.response : t);
2732
2762
  }
2733
2763
  }
2734
- const s = [];
2735
- return s.push(this.bindResult(t)), s.push(this.adjust()), s.push(this.addRow()), s.push(this.removeRow()), s.push(this.movePrevRow()), s.push(this.moveNextRow()), this.options.resetFragments && this.options.resetFragments.length > 0 && this.options.resetFragments.forEach((i) => {
2736
- s.push(E.reset(i));
2737
- }), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((i) => {
2738
- s.push(new c(i, null).run());
2739
- }), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((i) => {
2740
- const a = i.getTarget();
2764
+ const i = [];
2765
+ return i.push(this.bindResult(t)), i.push(this.adjust()), i.push(this.addRow()), i.push(this.removeRow()), i.push(this.movePrevRow()), i.push(this.moveNextRow()), this.options.resetFragments && this.options.resetFragments.length > 0 && this.options.resetFragments.forEach((s) => {
2766
+ i.push(b.reset(s));
2767
+ }), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((s) => {
2768
+ i.push(new u(s, null).run());
2769
+ }), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((s) => {
2770
+ const a = s.getTarget();
2741
2771
  typeof a.click == "function" ? a.click() : a.dispatchEvent(
2742
2772
  new MouseEvent("click", { bubbles: !0, cancelable: !0 })
2743
2773
  );
2744
- }), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((i) => {
2745
- const a = i.getTarget();
2746
- a instanceof HTMLElement ? s.push(n.openDialog(a)) : f.error("Haori", "Element is not an HTML element: ", a);
2747
- }), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((i) => {
2748
- const a = i.getTarget();
2749
- a instanceof HTMLElement ? s.push(n.closeDialog(a)) : f.error("Haori", "Element is not an HTML element: ", a);
2750
- }), Promise.all(s).then(() => this.options.dialogMessage ? n.dialog(this.options.dialogMessage) : Promise.resolve()).then(() => this.options.toastMessage ? n.toast(this.options.toastMessage, "info") : Promise.resolve()).then(() => (this.options.redirectUrl && (window.location.href = this.options.redirectUrl), Promise.resolve()));
2774
+ }), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((s) => {
2775
+ const a = s.getTarget();
2776
+ a instanceof HTMLElement ? i.push(n.openDialog(a)) : h.error("Haori", "Element is not an HTML element: ", a);
2777
+ }), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((s) => {
2778
+ const a = s.getTarget();
2779
+ a instanceof HTMLElement ? i.push(n.closeDialog(a)) : h.error("Haori", "Element is not an HTML element: ", a);
2780
+ }), Promise.all(i).then(() => this.options.dialogMessage ? n.dialog(this.options.dialogMessage) : Promise.resolve()).then(() => this.options.toastMessage ? n.toast(this.options.toastMessage, "info") : Promise.resolve()).then(() => (this.pushHistory(), Promise.resolve())).then(() => (this.options.redirectUrl && (window.location.href = this.options.redirectUrl), Promise.resolve()));
2781
+ }
2782
+ /**
2783
+ * history.pushState を実行します。
2784
+ *
2785
+ * `historyUrl` / `historyData` / `historyFormFragment` の内容を基に URL を組み立て、
2786
+ * `history.pushState()` を呼び出します。いずれも未指定の場合は何もしません。
2787
+ * 不正 URL・オリジン違反・例外は `Log.error` でログ出力してスキップし、後続処理は継続します。
2788
+ */
2789
+ pushHistory() {
2790
+ const t = this.options.historyUrl !== void 0 && this.options.historyUrl !== null, e = this.options.historyData !== void 0 && this.options.historyData !== null, r = this.options.historyFormFragment !== void 0 && this.options.historyFormFragment !== null;
2791
+ if (!(!t && !e && !r))
2792
+ try {
2793
+ const n = t ? this.options.historyUrl : window.location.pathname, i = new URL(n, window.location.href);
2794
+ if (i.origin !== window.location.origin) {
2795
+ const a = "history.pushState: cross-origin URL is not allowed: " + i.toString();
2796
+ h.error(
2797
+ "Haori",
2798
+ a
2799
+ );
2800
+ return;
2801
+ }
2802
+ const s = (a) => {
2803
+ for (const [o, p] of Object.entries(a))
2804
+ p != null && (Array.isArray(p) ? p.forEach((c) => i.searchParams.append(o, String(c))) : typeof p == "object" ? i.searchParams.set(o, JSON.stringify(p)) : i.searchParams.set(o, String(p)));
2805
+ };
2806
+ e && s(this.options.historyData), r && s(
2807
+ b.getValues(
2808
+ this.options.historyFormFragment
2809
+ )
2810
+ ), history.pushState({}, "", i.toString());
2811
+ } catch (n) {
2812
+ h.error("Haori", `history.pushState failed: ${n}`);
2813
+ }
2751
2814
  }
2752
2815
  /**
2753
2816
  * フェッチエラー応答のメッセージを適切な要素へ伝播します。
2754
2817
  */
2755
2818
  async handleFetchError(t) {
2756
2819
  let e = null;
2757
- this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = E.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
2758
- const r = async (s) => {
2759
- const i = e ? e.getTarget() : document.body;
2760
- await K().addErrorMessage(i, s);
2820
+ this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = b.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
2821
+ const r = async (i) => {
2822
+ const s = e ? e.getTarget() : document.body;
2823
+ await K().addErrorMessage(s, i);
2761
2824
  };
2762
2825
  if ((t.headers.get("Content-Type") || "").includes("application/json"))
2763
2826
  try {
2764
- const s = await t.json(), i = [];
2765
- if (s && typeof s == "object") {
2766
- if (typeof s.message == "string" && i.push({ message: s.message }), Array.isArray(s.messages))
2767
- for (const a of s.messages)
2768
- typeof a == "string" && i.push({ message: a });
2769
- if (s.errors && typeof s.errors == "object")
2770
- for (const [a, o] of Object.entries(s.errors))
2771
- Array.isArray(o) ? i.push({ key: a, message: o.join(`
2772
- `) }) : typeof o == "string" ? i.push({ key: a, message: o }) : o != null && i.push({ key: a, message: String(o) });
2773
- if (i.length === 0)
2774
- for (const [a, o] of Object.entries(s))
2775
- a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ? i.push({ key: a, message: o.join(`
2776
- `) }) : typeof o == "string" && i.push({ key: a, message: o }));
2827
+ const i = await t.json(), s = [];
2828
+ if (i && typeof i == "object") {
2829
+ if (typeof i.message == "string" && s.push({ message: i.message }), Array.isArray(i.messages))
2830
+ for (const a of i.messages)
2831
+ typeof a == "string" && s.push({ message: a });
2832
+ if (i.errors && typeof i.errors == "object")
2833
+ for (const [a, o] of Object.entries(i.errors))
2834
+ Array.isArray(o) ? s.push({ key: a, message: o.join(`
2835
+ `) }) : typeof o == "string" ? s.push({ key: a, message: o }) : o != null && s.push({ key: a, message: String(o) });
2836
+ if (s.length === 0)
2837
+ for (const [a, o] of Object.entries(i))
2838
+ a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ? s.push({ key: a, message: o.join(`
2839
+ `) }) : typeof o == "string" && s.push({ key: a, message: o }));
2777
2840
  }
2778
- if (i.length === 0) {
2841
+ if (s.length === 0) {
2779
2842
  await r(`${t.status} ${t.statusText}`);
2780
2843
  return;
2781
2844
  }
2782
- for (const a of i)
2783
- a.key && e ? await E.addErrorMessage(e, a.key, a.message) : await r(a.message);
2845
+ for (const a of s)
2846
+ a.key && e ? await b.addErrorMessage(e, a.key, a.message) : await r(a.message);
2784
2847
  return;
2785
2848
  } catch {
2786
2849
  }
2787
2850
  try {
2788
- const s = await t.text();
2789
- s && s.trim().length > 0 ? await r(s.trim()) : await r(`${t.status} ${t.statusText}`);
2851
+ const i = await t.text();
2852
+ i && i.trim().length > 0 ? await r(i.trim()) : await r(`${t.status} ${t.statusText}`);
2790
2853
  } catch {
2791
2854
  await r(`${t.status} ${t.statusText}`);
2792
2855
  }
@@ -2835,26 +2898,26 @@ ${d}
2835
2898
  bindResult(t) {
2836
2899
  return !this.options.bindFragments || this.options.bindFragments.length === 0 ? Promise.resolve() : (t.headers.get("Content-Type")?.includes("application/json") ? t.json() : t.text()).then((r) => {
2837
2900
  if (this.options.bindParams) {
2838
- const s = {};
2839
- this.options.bindParams.forEach((i) => {
2840
- r && typeof r == "object" && i in r && (s[i] = r[i]);
2841
- }), r = s;
2901
+ const i = {};
2902
+ this.options.bindParams.forEach((s) => {
2903
+ r && typeof r == "object" && s in r && (i[s] = r[s]);
2904
+ }), r = i;
2842
2905
  }
2843
2906
  const n = [];
2844
2907
  if (this.options.bindArg)
2845
- this.options.bindFragments.forEach((s) => {
2846
- const i = s.getBindingData();
2847
- i[this.options.bindArg] = r, n.push(T.setBindingData(s.getTarget(), i));
2908
+ this.options.bindFragments.forEach((i) => {
2909
+ const s = i.getBindingData();
2910
+ s[this.options.bindArg] = r, n.push(T.setBindingData(i.getTarget(), s));
2848
2911
  });
2849
2912
  else {
2850
2913
  if (typeof r == "string")
2851
- return f.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
2914
+ return h.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
2852
2915
  new Error("string data cannot be bound without a bindArg.")
2853
2916
  );
2854
- this.options.bindFragments.forEach((s) => {
2917
+ this.options.bindFragments.forEach((i) => {
2855
2918
  n.push(
2856
2919
  T.setBindingData(
2857
- s.getTarget(),
2920
+ i.getTarget(),
2858
2921
  r
2859
2922
  )
2860
2923
  );
@@ -2874,8 +2937,8 @@ ${d}
2874
2937
  for (const r of this.options.adjustFragments) {
2875
2938
  let n = r.getValue();
2876
2939
  (n == null || n === "") && (n = "0");
2877
- let s = Number(n);
2878
- isNaN(s) && (s = 0), s += t, e.push(r.setValue(String(s)));
2940
+ let i = Number(n);
2941
+ isNaN(i) && (i = 0), i += t, e.push(r.setValue(String(i)));
2879
2942
  }
2880
2943
  return Promise.all(e).then(() => {
2881
2944
  });
@@ -2887,11 +2950,11 @@ ${d}
2887
2950
  */
2888
2951
  getRowFragment() {
2889
2952
  if (!this.options.targetFragment)
2890
- return f.error("Haori", "Target fragment is not specified for row operation."), null;
2953
+ return h.error("Haori", "Target fragment is not specified for row operation."), null;
2891
2954
  const t = this.options.targetFragment.closestByAttribute(
2892
- `${h.prefix}row`
2955
+ `${f.prefix}row`
2893
2956
  );
2894
- return t || (f.error("Haori", "Row fragment not found."), null);
2957
+ return t || (h.error("Haori", "Row fragment not found."), null);
2895
2958
  }
2896
2959
  /**
2897
2960
  * 行を追加します。
@@ -2907,7 +2970,7 @@ ${d}
2907
2970
  const e = [], r = t.clone();
2908
2971
  return e.push(
2909
2972
  t.getParent().insertAfter(r, t)
2910
- ), e.push(T.evaluateAll(r)), e.push(E.reset(r)), Promise.all(e).then(() => {
2973
+ ), e.push(T.evaluateAll(r)), e.push(b.reset(r)), Promise.all(e).then(() => {
2911
2974
  });
2912
2975
  }
2913
2976
  /**
@@ -2922,7 +2985,7 @@ ${d}
2922
2985
  if (!t)
2923
2986
  return Promise.reject(new Error("Row fragment not found."));
2924
2987
  const e = t.getParent();
2925
- return e && e.getChildElementFragments().filter((n) => !n.hasAttribute(`${h.prefix}each-before`) && !n.hasAttribute(`${h.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
2988
+ return e && e.getChildElementFragments().filter((n) => !n.hasAttribute(`${f.prefix}each-before`) && !n.hasAttribute(`${f.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
2926
2989
  }
2927
2990
  /**
2928
2991
  * 前の行へ移動します。
@@ -2959,8 +3022,8 @@ ${d}
2959
3022
  return r ? r.insertAfter(t, e) : Promise.resolve();
2960
3023
  }
2961
3024
  };
2962
- c.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, c.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
2963
- let j = c;
3025
+ u.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, u.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
3026
+ let L = u;
2964
3027
  class _ {
2965
3028
  /**
2966
3029
  * URLのクエリパラメータを取得します。
@@ -2969,8 +3032,8 @@ class _ {
2969
3032
  */
2970
3033
  static readParams() {
2971
3034
  const t = {}, e = window.location.search;
2972
- return new URLSearchParams(e).forEach((n, s) => {
2973
- t[s] = n;
3035
+ return new URLSearchParams(e).forEach((n, i) => {
3036
+ t[i] = n;
2974
3037
  }), t;
2975
3038
  }
2976
3039
  }
@@ -2991,24 +3054,24 @@ class tt {
2991
3054
  let r;
2992
3055
  try {
2993
3056
  r = await fetch(t, e);
2994
- } catch (s) {
2995
- throw f.error("[Haori]", "Failed to fetch import source:", t, s), new Error(`Failed to fetch: ${t}`);
3057
+ } catch (i) {
3058
+ throw h.error("[Haori]", "Failed to fetch import source:", t, i), new Error(`Failed to fetch: ${t}`);
2996
3059
  }
2997
3060
  if (!r.ok) {
2998
- const s = `${r.status} ${r.statusText}`;
2999
- throw f.error("[Haori]", "Import HTTP error:", t, s), new Error(`Failed to load ${t}: ${s}`);
3061
+ const i = `${r.status} ${r.statusText}`;
3062
+ throw h.error("[Haori]", "Import HTTP error:", t, i), new Error(`Failed to load ${t}: ${i}`);
3000
3063
  }
3001
3064
  let n;
3002
3065
  try {
3003
3066
  n = await r.text();
3004
- } catch (s) {
3005
- throw f.error("[Haori]", "Failed to read response text:", t, s), new Error(`Failed to read response from: ${t}`);
3067
+ } catch (i) {
3068
+ throw h.error("[Haori]", "Failed to read response text:", t, i), new Error(`Failed to read response from: ${t}`);
3006
3069
  }
3007
3070
  try {
3008
- const i = new DOMParser().parseFromString(n, "text/html");
3009
- return i && i.body ? i.body.innerHTML : (f.warn("[Haori]", "No body found in imported document:", t), n);
3010
- } catch (s) {
3011
- return f.error("[Haori]", "Failed to parse imported HTML:", t, s), n;
3071
+ const s = new DOMParser().parseFromString(n, "text/html");
3072
+ return s && s.body ? s.body.innerHTML : (h.warn("[Haori]", "No body found in imported document:", t), n);
3073
+ } catch (i) {
3074
+ return h.error("[Haori]", "Failed to parse imported HTML:", t, i), n;
3012
3075
  }
3013
3076
  }
3014
3077
  }
@@ -3021,9 +3084,46 @@ const m = class m {
3021
3084
  */
3022
3085
  static isDeferredAttributeName(t) {
3023
3086
  return m.DEFERRED_ATTRIBUTE_SUFFIXES.some(
3024
- (e) => t === `${h.prefix}${e}`
3087
+ (e) => t === `${f.prefix}${e}`
3025
3088
  );
3026
3089
  }
3090
+ /**
3091
+ * evaluateAll で再評価対象から除外する特殊属性かどうかを判定します。
3092
+ *
3093
+ * @param name 属性名
3094
+ * @returns 除外対象かどうか
3095
+ */
3096
+ static isEvaluateAllExcludedAttributeName(t) {
3097
+ return m.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
3098
+ (e) => t === `${f.prefix}${e}`
3099
+ );
3100
+ }
3101
+ /**
3102
+ * evaluateAll で通常属性を再評価すべきかを判定します。
3103
+ *
3104
+ * @param name 属性名
3105
+ * @param value 属性の生値
3106
+ * @returns 再評価する場合は true
3107
+ */
3108
+ static shouldReevaluateAttribute(t, e) {
3109
+ return e !== null && !m.isEvaluateAllExcludedAttributeName(t) && m.ATTRIBUTE_PLACEHOLDER_REGEX.test(e);
3110
+ }
3111
+ /**
3112
+ * プレースホルダを含む通常属性を再評価します。
3113
+ * 内部状態の更新は同期的に行い、DOM 反映は fragment 側の非同期更新に委ねます。
3114
+ *
3115
+ * @param fragment 対象フラグメント
3116
+ * @returns 再評価完了の Promise
3117
+ */
3118
+ static reevaluateInterpolatedAttributes(t) {
3119
+ let e = Promise.resolve();
3120
+ for (const r of t.getAttributeNames()) {
3121
+ const n = t.getRawAttribute(r);
3122
+ m.shouldReevaluateAttribute(r, n) && (e = e.then(() => t.setAttribute(r, n)));
3123
+ }
3124
+ return e.then(() => {
3125
+ });
3126
+ }
3027
3127
  /**
3028
3128
  * 指定された要素と、その子要素をスキャンし、Fragmentを生成します。
3029
3129
  *
@@ -3036,34 +3136,34 @@ const m = class m {
3036
3136
  return Promise.resolve();
3037
3137
  t.parentNode && (A.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
3038
3138
  const r = [], n = /* @__PURE__ */ new Set();
3039
- for (const s of m.PRIORITY_ATTRIBUTE_SUFFIXES) {
3040
- const i = h.prefix + s;
3041
- e.hasAttribute(i) && (r.push(
3139
+ for (const i of m.PRIORITY_ATTRIBUTE_SUFFIXES) {
3140
+ const s = f.prefix + i;
3141
+ e.hasAttribute(s) && (r.push(
3042
3142
  m.setAttribute(
3043
3143
  e.getTarget(),
3044
- i,
3045
- e.getRawAttribute(i)
3144
+ s,
3145
+ e.getRawAttribute(s)
3046
3146
  )
3047
- ), n.add(i));
3147
+ ), n.add(s));
3048
3148
  }
3049
- for (const s of e.getAttributeNames()) {
3050
- if (n.has(s) || m.isDeferredAttributeName(s))
3149
+ for (const i of e.getAttributeNames()) {
3150
+ if (n.has(i) || m.isDeferredAttributeName(i))
3051
3151
  continue;
3052
- const i = e.getRawAttribute(s);
3053
- i !== null && r.push(m.setAttribute(e.getTarget(), s, i));
3152
+ const s = e.getRawAttribute(i);
3153
+ s !== null && r.push(m.setAttribute(e.getTarget(), i, s));
3054
3154
  }
3055
- for (const s of m.DEFERRED_ATTRIBUTE_SUFFIXES) {
3056
- const i = h.prefix + s;
3057
- e.hasAttribute(i) && (r.push(
3155
+ for (const i of m.DEFERRED_ATTRIBUTE_SUFFIXES) {
3156
+ const s = f.prefix + i;
3157
+ e.hasAttribute(s) && (r.push(
3058
3158
  m.setAttribute(
3059
3159
  e.getTarget(),
3060
- i,
3061
- e.getRawAttribute(i)
3160
+ s,
3161
+ e.getRawAttribute(s)
3062
3162
  )
3063
- ), n.add(i));
3163
+ ), n.add(s));
3064
3164
  }
3065
- return e.getChildren().forEach((s) => {
3066
- s instanceof x ? r.push(m.scan(s.getTarget())) : s instanceof I && r.push(m.evaluateText(s));
3165
+ return e.getChildren().forEach((i) => {
3166
+ i instanceof P ? r.push(m.scan(i.getTarget())) : i instanceof I && r.push(m.evaluateText(i));
3067
3167
  }), Promise.all(r).then(() => {
3068
3168
  });
3069
3169
  }
@@ -3077,51 +3177,51 @@ const m = class m {
3077
3177
  * @returns Promise (DOM操作が完了したときに解決される)
3078
3178
  */
3079
3179
  static setAttribute(t, e, r) {
3080
- const n = A.get(t), s = [];
3180
+ const n = A.get(t), i = [];
3081
3181
  switch (e) {
3082
- case `${h.prefix}bind`: {
3182
+ case `${f.prefix}bind`: {
3083
3183
  r === null ? (n.clearBindingDataCache(), n.setBindingData({})) : n.setBindingData(m.parseDataBind(r));
3084
3184
  break;
3085
3185
  }
3086
- case `${h.prefix}if`:
3087
- s.push(m.evaluateIf(n));
3186
+ case `${f.prefix}if`:
3187
+ i.push(m.evaluateIf(n));
3088
3188
  break;
3089
- case `${h.prefix}each`:
3090
- s.push(m.evaluateEach(n));
3189
+ case `${f.prefix}each`:
3190
+ i.push(m.evaluateEach(n));
3091
3191
  break;
3092
- case `${h.prefix}fetch`:
3093
- s.push(new j(n, null).run());
3192
+ case `${f.prefix}fetch`:
3193
+ i.push(new L(n, null).run());
3094
3194
  break;
3095
- case `${h.prefix}import`: {
3195
+ case `${f.prefix}import`: {
3096
3196
  if (typeof r == "string") {
3097
- const i = n.getTarget(), a = performance.now();
3098
- y.importStart(i, r), s.push(
3197
+ const s = n.getTarget(), a = performance.now();
3198
+ E.importStart(s, r), i.push(
3099
3199
  tt.load(r).then((o) => {
3100
- const g = new TextEncoder().encode(o).length;
3200
+ const p = new TextEncoder().encode(o).length;
3101
3201
  return N.enqueue(() => {
3102
- i.innerHTML = o;
3202
+ s.innerHTML = o;
3103
3203
  }).then(() => {
3104
- y.importEnd(i, r, g, a);
3204
+ E.importEnd(s, r, p, a);
3105
3205
  });
3106
3206
  }).catch((o) => {
3107
- y.importError(i, r, o), f.error("[Haori]", "Failed to import HTML:", r, o);
3207
+ E.importError(s, r, o), h.error("[Haori]", "Failed to import HTML:", r, o);
3108
3208
  })
3109
3209
  );
3110
3210
  }
3111
3211
  break;
3112
3212
  }
3113
- case `${h.prefix}url-param`: {
3114
- const i = n.getAttribute(`${h.prefix}url-arg`), a = _.readParams();
3115
- if (i === null)
3213
+ case `${f.prefix}url-param`: {
3214
+ const s = n.getAttribute(`${f.prefix}url-arg`), a = _.readParams();
3215
+ if (s === null)
3116
3216
  m.setBindingData(t, a);
3117
3217
  else {
3118
3218
  const o = n.getRawBindingData() || {};
3119
- o[String(i)] = a, m.setBindingData(t, o);
3219
+ o[String(s)] = a, m.setBindingData(t, o);
3120
3220
  }
3121
3221
  break;
3122
3222
  }
3123
3223
  }
3124
- return r === null ? s.push(n.removeAttribute(e)) : s.push(n.setAttribute(e, r)), Promise.all(s).then(() => {
3224
+ return r === null ? i.push(n.removeAttribute(e)) : i.push(n.setAttribute(e, r)), Promise.all(i).then(() => {
3125
3225
  });
3126
3226
  }
3127
3227
  /**
@@ -3135,10 +3235,10 @@ const m = class m {
3135
3235
  static setBindingData(t, e) {
3136
3236
  const r = A.get(t), n = r.getRawBindingData();
3137
3237
  r.setBindingData(e);
3138
- const s = [];
3139
- return s.push(
3140
- r.setAttribute(`${h.prefix}bind`, JSON.stringify(e))
3141
- ), s.push(m.evaluateAll(r)), y.bindChange(t, n, e, "manual"), Promise.all(s).then(() => {
3238
+ const i = [];
3239
+ return i.push(
3240
+ r.setAttribute(`${f.prefix}bind`, JSON.stringify(e))
3241
+ ), i.push(m.evaluateAll(r)), E.bindChange(t, n, e, "manual"), Promise.all(i).then(() => {
3142
3242
  });
3143
3243
  }
3144
3244
  /**
@@ -3152,12 +3252,12 @@ const m = class m {
3152
3252
  try {
3153
3253
  return JSON.parse(t);
3154
3254
  } catch (e) {
3155
- return f.error("[Haori]", "Invalid JSON in data-bind:", e), {};
3255
+ return h.error("[Haori]", "Invalid JSON in data-bind:", e), {};
3156
3256
  }
3157
3257
  else {
3158
3258
  const e = new URLSearchParams(t), r = {};
3159
- for (const [n, s] of e.entries())
3160
- r[n] !== void 0 ? Array.isArray(r[n]) ? r[n].push(s) : r[n] = [r[n], s] : r[n] = s;
3259
+ for (const [n, i] of e.entries())
3260
+ r[n] !== void 0 ? Array.isArray(r[n]) ? r[n].push(i) : r[n] = [r[n], i] : r[n] = i;
3161
3261
  return r;
3162
3262
  }
3163
3263
  }
@@ -3171,8 +3271,8 @@ const m = class m {
3171
3271
  const r = A.get(t);
3172
3272
  if (r.isSkipMutationNodes())
3173
3273
  return;
3174
- const n = A.get(e.nextSibling), s = A.get(e);
3175
- s && (r.insertBefore(s, n), s instanceof x ? m.scan(s.getTarget()) : s instanceof I && m.evaluateText(s));
3274
+ const n = A.get(e.nextSibling), i = A.get(e);
3275
+ i && (r.insertBefore(i, n), i instanceof P ? m.scan(i.getTarget()) : i instanceof I && m.evaluateText(i));
3176
3276
  }
3177
3277
  /**
3178
3278
  * ノードを親要素から削除します。
@@ -3212,11 +3312,11 @@ const m = class m {
3212
3312
  return Promise.resolve();
3213
3313
  const n = [];
3214
3314
  n.push(r.setValue(e));
3215
- const s = m.getFormFragment(r);
3216
- if (s) {
3217
- const i = E.getValues(s), a = s.getAttribute(`${h.prefix}form-arg`);
3315
+ const i = m.getFormFragment(r);
3316
+ if (i) {
3317
+ const s = b.getValues(i), a = i.getAttribute(`${f.prefix}form-arg`);
3218
3318
  let o;
3219
- a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = i) : o = i, n.push(m.setBindingData(s.getTarget(), o));
3319
+ a ? (o = i.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, n.push(m.setBindingData(i.getTarget(), o));
3220
3320
  }
3221
3321
  return Promise.all(n).then(() => {
3222
3322
  });
@@ -3241,8 +3341,8 @@ const m = class m {
3241
3341
  */
3242
3342
  static evaluateAll(t) {
3243
3343
  const e = [];
3244
- return t.hasAttribute(`${h.prefix}if`) && e.push(m.evaluateIf(t)), t.hasAttribute(`${h.prefix}each`) && e.push(m.evaluateEach(t)), t.getChildren().forEach((r) => {
3245
- r instanceof x ? e.push(m.evaluateAll(r)) : r instanceof I && e.push(m.evaluateText(r));
3344
+ return e.push(m.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${f.prefix}if`) && e.push(m.evaluateIf(t)), t.hasAttribute(`${f.prefix}each`) && e.push(m.evaluateEach(t)), t.getChildren().forEach((r) => {
3345
+ r instanceof P ? e.push(m.evaluateAll(r)) : r instanceof I && e.push(m.evaluateText(r));
3246
3346
  }), Promise.all(e).then(() => {
3247
3347
  });
3248
3348
  }
@@ -3263,14 +3363,14 @@ const m = class m {
3263
3363
  * @return Promise (DOM操作が完了したときに解決される)
3264
3364
  */
3265
3365
  static evaluateIf(t) {
3266
- const e = [], r = t.getAttribute(`${h.prefix}if`);
3366
+ const e = [], r = t.getAttribute(`${f.prefix}if`);
3267
3367
  return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
3268
3368
  t.hide().then(() => {
3269
- y.hide(t.getTarget());
3369
+ E.hide(t.getTarget());
3270
3370
  })
3271
3371
  ) : t.isVisible() || (e.push(
3272
3372
  t.show().then(() => {
3273
- y.show(t.getTarget());
3373
+ E.show(t.getTarget());
3274
3374
  })
3275
3375
  ), e.push(m.evaluateAll(t))), Promise.all(e).then(() => {
3276
3376
  });
@@ -3287,20 +3387,20 @@ const m = class m {
3287
3387
  let e = t.getTemplate();
3288
3388
  if (e === null) {
3289
3389
  let n = !1;
3290
- t.getChildren().forEach((i) => {
3291
- if (!n && i instanceof x) {
3292
- if (i.hasAttribute(`${h.prefix}each-before`) || i.hasAttribute(`${h.prefix}each-after`))
3390
+ t.getChildren().forEach((s) => {
3391
+ if (!n && s instanceof P) {
3392
+ if (s.hasAttribute(`${f.prefix}each-before`) || s.hasAttribute(`${f.prefix}each-after`))
3293
3393
  return;
3294
- e = i.clone(), t.setTemplate(e), n = !0, t.removeChild(i);
3295
- const a = i.getTarget();
3296
- a.parentNode && a.parentNode.removeChild(a), i.setMounted(!1);
3394
+ e = s.clone(), t.setTemplate(e), n = !0, t.removeChild(s);
3395
+ const a = s.getTarget();
3396
+ a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
3297
3397
  }
3298
3398
  });
3299
- const s = t.getAttribute(`${h.prefix}each`);
3300
- return Array.isArray(s) ? this.updateDiff(t, s) : (f.error("[Haori]", "Invalid each attribute:", s), Promise.reject(new Error("Invalid each attribute.")));
3399
+ const i = t.getAttribute(`${f.prefix}each`);
3400
+ return Array.isArray(i) ? this.updateDiff(t, i) : (h.error("[Haori]", "Invalid each attribute:", i), Promise.reject(new Error("Invalid each attribute.")));
3301
3401
  }
3302
- const r = t.getAttribute(`${h.prefix}each`);
3303
- return Array.isArray(r) ? this.updateDiff(t, r) : (f.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
3402
+ const r = t.getAttribute(`${f.prefix}each`);
3403
+ return Array.isArray(r) ? this.updateDiff(t, r) : (h.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
3304
3404
  }
3305
3405
  /**
3306
3406
  * 差分を更新します。
@@ -3311,69 +3411,73 @@ const m = class m {
3311
3411
  static updateDiff(t, e) {
3312
3412
  const r = t.getTemplate();
3313
3413
  if (r === null)
3314
- return f.error("[Haori]", "Template is not set for each element."), Promise.resolve();
3315
- let n = t.getAttribute(`${h.prefix}each-index`);
3414
+ return h.error("[Haori]", "Template is not set for each element."), Promise.resolve();
3415
+ let n = t.getAttribute(`${f.prefix}each-index`);
3316
3416
  n && (n = String(n));
3317
- const s = t.getAttribute(`${h.prefix}each-key`), i = t.getAttribute(`${h.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
3318
- e.forEach((p, v) => {
3417
+ const i = t.getAttribute(`${f.prefix}each-key`), s = t.getAttribute(`${f.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
3418
+ e.forEach((g, v) => {
3319
3419
  const w = m.createListKey(
3320
- p,
3321
- s ? String(s) : null,
3420
+ g,
3421
+ i ? String(i) : null,
3322
3422
  v
3323
3423
  );
3324
- o.push(w), a.set(w, { item: p, itemIndex: v });
3424
+ o.push(w), a.set(w, { item: g, itemIndex: v });
3325
3425
  });
3326
- const g = [];
3327
- let u = t.getChildren().filter((p) => p instanceof x).filter(
3328
- (p) => !p.hasAttribute(`${h.prefix}each-before`) && !p.hasAttribute(`${h.prefix}each-after`)
3426
+ const p = [];
3427
+ let c = t.getChildren().filter((g) => g instanceof P).filter(
3428
+ (g) => !g.hasAttribute(`${f.prefix}each-before`) && !g.hasAttribute(`${f.prefix}each-after`)
3329
3429
  );
3330
- u = u.filter((p) => o.indexOf(String(p.getListKey())) === -1 ? (g.push(p.remove()), !1) : !0);
3331
- const b = u.map((p) => p.getListKey()), l = t.getChildren().filter((p) => p instanceof x).filter((p) => p.hasAttribute(`${h.prefix}each-before`)).length;
3430
+ c = c.filter((g) => o.indexOf(String(g.getListKey())) === -1 ? (p.push(g.remove()), !1) : !0);
3431
+ const y = c.map((g) => g.getListKey()), l = t.getChildren().filter((g) => g instanceof P).filter((g) => g.hasAttribute(`${f.prefix}each-before`)).length;
3332
3432
  let d = Promise.resolve();
3333
- return o.forEach((p, v) => {
3334
- const w = b.indexOf(p), { item: $, itemIndex: S } = a.get(p);
3335
- let F;
3433
+ return o.forEach((g, v) => {
3434
+ const w = y.indexOf(g), { item: B, itemIndex: F } = a.get(g);
3435
+ let x;
3336
3436
  if (w !== -1)
3337
- F = u[w], m.updateRowFragment(
3338
- F,
3339
- $,
3340
- n,
3341
- S,
3342
- i ? String(i) : null,
3343
- p
3344
- ), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache(), d = d.then(() => m.evaluateAll(F));
3437
+ x = c[w], d = d.then(
3438
+ () => m.updateRowFragment(
3439
+ x,
3440
+ B,
3441
+ n,
3442
+ F,
3443
+ s ? String(s) : null,
3444
+ g
3445
+ ).then(() => m.evaluateAll(x))
3446
+ );
3345
3447
  else {
3346
- F = r.clone(), m.updateRowFragment(
3347
- F,
3348
- $,
3349
- n,
3350
- S,
3351
- i ? String(i) : null,
3352
- p
3353
- ), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache();
3448
+ x = r.clone();
3354
3449
  const Y = l + v;
3355
3450
  d = d.then(
3356
- () => t.insertBefore(
3451
+ () => m.updateRowFragment(
3452
+ x,
3453
+ B,
3454
+ n,
3357
3455
  F,
3358
- t.getChildren()[Y] || null
3359
- ).then(() => m.evaluateAll(F))
3456
+ s ? String(s) : null,
3457
+ g
3458
+ ).then(
3459
+ () => t.insertBefore(
3460
+ x,
3461
+ t.getChildren()[Y] || null
3462
+ ).then(() => m.evaluateAll(x))
3463
+ )
3360
3464
  );
3361
3465
  }
3362
- }), Promise.all(g).then(() => d).then(() => {
3363
- const p = o.filter(
3364
- (S) => S !== null
3365
- ), v = b.filter(
3366
- (S) => S !== null
3367
- ), w = p.filter(
3368
- (S) => !v.includes(S)
3369
- ), $ = v.filter(
3370
- (S) => !p.includes(S)
3466
+ }), Promise.all(p).then(() => d).then(() => {
3467
+ const g = o.filter(
3468
+ (F) => F !== null
3469
+ ), v = y.filter(
3470
+ (F) => F !== null
3471
+ ), w = g.filter(
3472
+ (F) => !v.includes(F)
3473
+ ), B = v.filter(
3474
+ (F) => !g.includes(F)
3371
3475
  );
3372
- y.eachUpdate(
3476
+ E.eachUpdate(
3373
3477
  t.getTarget(),
3374
3478
  w,
3375
- $,
3376
- p
3479
+ B,
3480
+ g
3377
3481
  );
3378
3482
  });
3379
3483
  }
@@ -3389,8 +3493,8 @@ const m = class m {
3389
3493
  let n;
3390
3494
  if (typeof t == "object" && t !== null)
3391
3495
  if (e) {
3392
- const s = t[e];
3393
- s == null ? n = `__index_${r}` : typeof s == "object" ? n = JSON.stringify(s) : n = String(s);
3496
+ const i = t[e];
3497
+ i == null ? n = `__index_${r}` : typeof i == "object" ? n = JSON.stringify(i) : n = String(i);
3394
3498
  } else
3395
3499
  n = `__index_${r}`;
3396
3500
  else
@@ -3406,28 +3510,34 @@ const m = class m {
3406
3510
  * @param index インデックス番号
3407
3511
  * @param arg バインドデータパラメータ名
3408
3512
  * @param listKey リストキー
3513
+ * @returns 行メタデータの更新完了 Promise
3409
3514
  */
3410
- static updateRowFragment(t, e, r, n, s, i) {
3515
+ static updateRowFragment(t, e, r, n, i, s) {
3411
3516
  let a = e;
3412
3517
  if (typeof e == "object" && e !== null)
3413
- a = { ...e }, r && (a[r] = n), s && (a = {
3414
- [s]: a
3518
+ a = { ...e }, r && (a[r] = n), i && (a = {
3519
+ [i]: a
3415
3520
  });
3416
- else if (s)
3521
+ else if (i)
3417
3522
  a = {
3418
- [s]: e
3523
+ [i]: e
3419
3524
  }, r && (a[r] = n);
3420
- else {
3421
- f.error(
3525
+ else
3526
+ return h.error(
3422
3527
  "[Haori]",
3423
- `Primitive value requires '${h.prefix}each-arg' attribute: ${e}`
3424
- );
3425
- return;
3426
- }
3427
- t.setListKey(i), t.setAttribute(`${h.prefix}row`, i), t.setBindingData(a);
3528
+ `Primitive value requires '${f.prefix}each-arg' attribute: ${e}`
3529
+ ), Promise.resolve();
3530
+ return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${f.prefix}row`, s);
3428
3531
  }
3429
3532
  };
3430
- m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"];
3533
+ m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], m.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
3534
+ "bind",
3535
+ "if",
3536
+ "each",
3537
+ "fetch",
3538
+ "import",
3539
+ "url-param"
3540
+ ], m.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
3431
3541
  let T = m;
3432
3542
  class et {
3433
3543
  /**
@@ -3438,7 +3548,7 @@ class et {
3438
3548
  constructor(t = document) {
3439
3549
  this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
3440
3550
  const e = document.documentElement, r = A.get(e);
3441
- r && new j(r, "load").run();
3551
+ r && new L(r, "load").run();
3442
3552
  }, this.root = t;
3443
3553
  }
3444
3554
  /**
@@ -3465,8 +3575,8 @@ class et {
3465
3575
  if (!r)
3466
3576
  return;
3467
3577
  const n = A.get(r);
3468
- n && (e === "change" && n instanceof x && n.syncValue(), new j(n, e).run().catch((s) => {
3469
- f.error("[Haori]", "Procedure execution error:", s);
3578
+ n && (e === "change" && n instanceof P && n.syncValue(), new L(n, e).run().catch((i) => {
3579
+ h.error("[Haori]", "Procedure execution error:", i);
3470
3580
  }));
3471
3581
  }
3472
3582
  /**
@@ -3479,20 +3589,20 @@ class et {
3479
3589
  return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
3480
3590
  }
3481
3591
  }
3482
- const C = class C {
3592
+ const O = class O {
3483
3593
  /**
3484
3594
  * 初期化メソッド。
3485
3595
  * ドキュメントのheadとbodyを監視対象として設定します。
3486
3596
  */
3487
3597
  static async init() {
3488
- if (C._initialized)
3598
+ if (O._initialized)
3489
3599
  return;
3490
- C._initialized = !0;
3600
+ O._initialized = !0;
3491
3601
  const t = await Promise.allSettled([
3492
3602
  T.scan(document.head),
3493
3603
  T.scan(document.body)
3494
3604
  ]), [e, r] = t;
3495
- e.status !== "fulfilled" && f.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && f.error("[Haori]", "Failed to build body fragment:", r.reason), C.observe(document.head), C.observe(document.body), new et().start();
3605
+ e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), O.observe(document.head), O.observe(document.body), new et().start();
3496
3606
  }
3497
3607
  /**
3498
3608
  * 指定された要素を監視します。
@@ -3505,40 +3615,40 @@ const C = class C {
3505
3615
  try {
3506
3616
  switch (n.type) {
3507
3617
  case "attributes": {
3508
- f.info(
3618
+ h.info(
3509
3619
  "[Haori]",
3510
3620
  "Attribute changed:",
3511
3621
  n.target,
3512
3622
  n.attributeName
3513
3623
  );
3514
- const s = n.target;
3624
+ const i = n.target;
3515
3625
  T.setAttribute(
3516
- s,
3626
+ i,
3517
3627
  n.attributeName,
3518
- s.getAttribute(n.attributeName)
3628
+ i.getAttribute(n.attributeName)
3519
3629
  );
3520
3630
  break;
3521
3631
  }
3522
3632
  case "childList": {
3523
- f.info(
3633
+ h.info(
3524
3634
  "[Haori]",
3525
3635
  "Child list changed:",
3526
- Array.from(n.removedNodes).map((s) => s.nodeName),
3527
- Array.from(n.addedNodes).map((s) => s.nodeName)
3528
- ), Array.from(n.removedNodes).forEach((s) => {
3529
- T.removeNode(s);
3530
- }), Array.from(n.addedNodes).forEach((s) => {
3531
- s.parentElement instanceof HTMLElement && T.addNode(s.parentElement, s);
3636
+ Array.from(n.removedNodes).map((i) => i.nodeName),
3637
+ Array.from(n.addedNodes).map((i) => i.nodeName)
3638
+ ), Array.from(n.removedNodes).forEach((i) => {
3639
+ T.removeNode(i);
3640
+ }), Array.from(n.addedNodes).forEach((i) => {
3641
+ i.parentElement instanceof HTMLElement && T.addNode(i.parentElement, i);
3532
3642
  });
3533
3643
  break;
3534
3644
  }
3535
3645
  case "characterData": {
3536
- f.info(
3646
+ h.info(
3537
3647
  "[Haori]",
3538
3648
  "Character data changed:",
3539
3649
  n.target,
3540
3650
  n.target.textContent
3541
- ), n.target instanceof Text || n.target instanceof Comment ? T.changeText(n.target, n.target.textContent) : f.warn(
3651
+ ), n.target instanceof Text || n.target instanceof Comment ? T.changeText(n.target, n.target.textContent) : h.warn(
3542
3652
  "[Haori]",
3543
3653
  "Unsupported character data type:",
3544
3654
  n.target
@@ -3546,33 +3656,33 @@ const C = class C {
3546
3656
  break;
3547
3657
  }
3548
3658
  default:
3549
- f.warn("[Haori]", "Unknown mutation type:", n.type);
3659
+ h.warn("[Haori]", "Unknown mutation type:", n.type);
3550
3660
  continue;
3551
3661
  }
3552
- } catch (s) {
3553
- f.error("[Haori]", "Error processing mutation:", s);
3662
+ } catch (i) {
3663
+ h.error("[Haori]", "Error processing mutation:", i);
3554
3664
  }
3555
3665
  }).observe(t, {
3556
3666
  childList: !0,
3557
3667
  subtree: !0,
3558
3668
  attributes: !0,
3559
3669
  characterData: !0
3560
- }), f.info("[Haori]", "Observer initialized for", t);
3670
+ }), h.info("[Haori]", "Observer initialized for", t);
3561
3671
  }
3562
3672
  };
3563
- C._initialized = !1;
3564
- let V = C;
3673
+ O._initialized = !1;
3674
+ let V = O;
3565
3675
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", V.init) : V.init();
3566
- const rt = "0.1.4";
3676
+ const rt = "0.2.0";
3567
3677
  export {
3568
3678
  T as Core,
3569
- h as Env,
3570
- E as Form,
3679
+ f as Env,
3680
+ b as Form,
3571
3681
  A as Fragment,
3572
- X as Haori,
3573
- f as Log,
3682
+ W as Haori,
3683
+ h as Log,
3574
3684
  N as Queue,
3575
- X as default,
3685
+ W as default,
3576
3686
  rt as version
3577
3687
  };
3578
3688
  //# sourceMappingURL=haori.es.js.map