egatari 0.6.12 → 0.6.13

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.ja.md +2 -2
  3. package/README.md +2 -2
  4. package/bin/egatari.mjs +3 -1
  5. package/components.lock.json +141 -51
  6. package/components2.lock.json +500 -1
  7. package/kit/browser.mjs +19 -7
  8. package/kit/check-messages.mjs +2 -0
  9. package/kit/check.mjs +2 -0
  10. package/kit/core/article-links.mjs +5 -4
  11. package/kit/core/article-messages.mjs +6 -1
  12. package/kit/core/article-render.mjs +61 -42
  13. package/kit/core/article-text.mjs +42 -1
  14. package/kit/core/article.mjs +7 -6
  15. package/kit/core/build-core.mjs +4 -0
  16. package/kit/core/caution.mjs +49 -0
  17. package/kit/core/check-parity.mjs +1 -0
  18. package/kit/core/check-rules.mjs +3 -0
  19. package/kit/core/check-source.mjs +2 -0
  20. package/kit/core/colab-core.mjs +1 -1
  21. package/kit/core/llm-pack-assemble.mjs +4 -3
  22. package/kit/core/llm-pack-data.mjs +124 -10
  23. package/kit/core/part-labels.mjs +3 -0
  24. package/kit/core/purposes.mjs +6 -8
  25. package/kit/instruction-version.json +1 -1
  26. package/kit/layouts.css +8 -1
  27. package/kit/player.json +1 -1
  28. package/kit/player.lock.json +2 -2
  29. package/package.json +1 -1
  30. package/themes/asagi/theme.json +1 -1
  31. package/themes/asagi/tokens.css +2 -0
  32. package/themes/bengara/theme.json +1 -1
  33. package/themes/bengara/tokens.css +2 -0
  34. package/themes/business/theme.json +1 -1
  35. package/themes/business/tokens.css +2 -0
  36. package/themes/default/theme.json +1 -1
  37. package/themes/default/tokens.css +2 -0
  38. package/themes/kogecha/theme.json +1 -1
  39. package/themes/kogecha/tokens.css +2 -0
  40. package/themes/kokugo/theme.json +1 -1
  41. package/themes/kokugo/tokens.css +2 -0
  42. package/themes/murasaki/theme.json +1 -1
  43. package/themes/murasaki/tokens.css +2 -0
  44. package/themes/sumi/theme.json +1 -1
  45. package/themes/sumi/tokens.css +2 -0
  46. package/themes/tokiwa/theme.json +1 -1
  47. package/themes/tokiwa/tokens.css +2 -0
  48. package/themes.lock.json +92 -28
  49. package/vendor/components/CATALOG.md +6 -3
  50. package/vendor/components/sha256/061415b5f5a1861e115103224ebbcaf689b602cd9972516001f50f4646d3692a/README.en.md +33 -0
  51. package/vendor/components/sha256/061415b5f5a1861e115103224ebbcaf689b602cd9972516001f50f4646d3692a/index.js +390 -0
  52. package/vendor/components/sha256/1854c2d9091a44f465a8de71de2ef3cfa26de3750c67aba4d0ab6eef9b826b8c/README.en.md +21 -0
  53. package/vendor/components/sha256/1854c2d9091a44f465a8de71de2ef3cfa26de3750c67aba4d0ab6eef9b826b8c/index.js +108 -0
  54. package/vendor/components/sha256/19803bbabc26cab7937b17c101f0529239ad505e2ef72a5b21c5d0b9afb063b5/README.en.md +35 -0
  55. package/vendor/components/sha256/19803bbabc26cab7937b17c101f0529239ad505e2ef72a5b21c5d0b9afb063b5/index.js +179 -0
  56. package/vendor/components/sha256/1fac9a4c6608f0150a51275fb11bad0dcff00bed1696c2d93d150fa97219e41a/README.en.md +23 -0
  57. package/vendor/components/sha256/1fac9a4c6608f0150a51275fb11bad0dcff00bed1696c2d93d150fa97219e41a/index.js +147 -0
  58. package/vendor/components/sha256/24e433f4e96427b5b4625ea6542ae74393a8610a9e3d331d01481b3185c827d4/README.en.md +66 -0
  59. package/vendor/components/sha256/24e433f4e96427b5b4625ea6542ae74393a8610a9e3d331d01481b3185c827d4/index.js +984 -0
  60. package/vendor/components/sha256/336f518ad98df0700348406a1fcc4a2de6843b68de0d2e6fcb2cf92428cc3f32/index.js +121 -0
  61. package/vendor/components/sha256/362590bb028486c9b92c90b0c04bb21c9989b7da1b9d234f0d3c26093770eb52/index.js +228 -0
  62. package/vendor/components/sha256/3c79d2605e1949c302a5e190dab3d12812e548af7d66e80dd73dc517dfa1ae3d/index.js +268 -0
  63. package/vendor/components/sha256/4526a332a77fce02370c58d6acd2b83777bfac10aca91e304f105ca2d6935e21/README.en.md +40 -0
  64. package/vendor/components/sha256/4526a332a77fce02370c58d6acd2b83777bfac10aca91e304f105ca2d6935e21/index.js +405 -0
  65. package/vendor/components/sha256/46fd8b2bfa296e18d7720dec9c9639421fb02cec1b641e50e2cadefcc3945675/README.en.md +31 -0
  66. package/vendor/components/sha256/46fd8b2bfa296e18d7720dec9c9639421fb02cec1b641e50e2cadefcc3945675/index.js +236 -0
  67. package/vendor/components/sha256/49fc5add9b34d9a34fcf9ffa3772da4a36d054feead033a7212b98ce1e18705d/index.js +465 -0
  68. package/vendor/components/sha256/4bedc6e22490461bb624d1801954aed230e9f47e393d2a9779c89c4c6483ab3e/README.en.md +42 -0
  69. package/vendor/components/sha256/4bedc6e22490461bb624d1801954aed230e9f47e393d2a9779c89c4c6483ab3e/index.js +549 -0
  70. package/vendor/components/sha256/5b3a29cd3ad1c572ba2864430fde589a0fa90f5a7cf6c8753ccfc97dd16d99f3/README.en.md +37 -0
  71. package/vendor/components/sha256/5b3a29cd3ad1c572ba2864430fde589a0fa90f5a7cf6c8753ccfc97dd16d99f3/index.js +501 -0
  72. package/vendor/components/sha256/6e9d8d26ba0427f26a8143ecaf1ff3a3fec1a6cb114ef5feed15a62f6a6e77c2/README.en.md +54 -0
  73. package/vendor/components/sha256/6e9d8d26ba0427f26a8143ecaf1ff3a3fec1a6cb114ef5feed15a62f6a6e77c2/index.js +470 -0
  74. package/vendor/components/sha256/9ffe48f7c39657aacbbca355c8268a4682f306c0e453bdd73b69c3ed7e0cb030/README.en.md +30 -0
  75. package/vendor/components/sha256/9ffe48f7c39657aacbbca355c8268a4682f306c0e453bdd73b69c3ed7e0cb030/index.js +192 -0
  76. package/vendor/components/sha256/a04ba1b59cae0406ad91c64da77df1f77d0ae6fb5629da4549452f68b926a20b/index.js +315 -0
  77. package/vendor/components/sha256/c129c1c6c5df8ddafed87ea41fe6f9fc03784b2904059321f970d16ff3238bf8/index.js +312 -0
  78. package/vendor/components/sha256/d831672acd189fd9e6bd294bdbceab539f4b2dc4ec0415e776a9fe740c499544/index.js +97 -0
  79. package/vendor/components/sha256/dc5d9e6da444ef49ac343c870271c6679601040bf3a38a389a7991ffd39dd0fc/index.js +607 -0
  80. package/vendor/components/sha256/deae02519dd79e53cf18137777d486cb3b3234ab02a71d26c4e2925593b047ba/LICENSE-tabler.txt +21 -0
  81. package/vendor/components/sha256/deae02519dd79e53cf18137777d486cb3b3234ab02a71d26c4e2925593b047ba/index.js +4868 -0
  82. package/vendor/components/sha256/deae02519dd79e53cf18137777d486cb3b3234ab02a71d26c4e2925593b047ba/names.txt +4808 -0
  83. package/vendor/components/sha256/e76667b8fbaeb6c5d05ada81b2230f21388e2e68f3437034d2a54ead1c8ccbef/README.en.md +32 -0
  84. package/vendor/components/sha256/e76667b8fbaeb6c5d05ada81b2230f21388e2e68f3437034d2a54ead1c8ccbef/index.js +222 -0
  85. package/vendor/components-2/manifest-2.9.0.json +2204 -0
  86. package/vendor/components-2/manifest-2.9.1.json +2204 -0
  87. package/vendor/egatari-spec/SOURCE.json +3 -3
  88. package/vendor/themes/asagi/1.3.0/theme.json +14 -0
  89. package/vendor/themes/asagi/1.3.0/tokens.css +36 -0
  90. package/vendor/themes/bengara/1.0.0/theme.json +13 -0
  91. package/vendor/themes/bengara/1.0.0/tokens.css +66 -0
  92. package/vendor/themes/business/1.3.0/theme.json +5 -0
  93. package/vendor/themes/business/1.3.0/tokens.css +47 -0
  94. package/vendor/themes/default/1.5.0/README.ja.md +65 -0
  95. package/vendor/themes/default/1.5.0/README.md +65 -0
  96. package/vendor/themes/default/1.5.0/theme.json +4 -0
  97. package/vendor/themes/default/1.5.0/tokens.css +95 -0
  98. package/vendor/themes/kogecha/1.3.0/theme.json +10 -0
  99. package/vendor/themes/kogecha/1.3.0/tokens.css +35 -0
  100. package/vendor/themes/kokugo/1.3.0/theme.json +5 -0
  101. package/vendor/themes/kokugo/1.3.0/tokens.css +31 -0
  102. package/vendor/themes/murasaki/1.3.0/theme.json +10 -0
  103. package/vendor/themes/murasaki/1.3.0/tokens.css +31 -0
  104. package/vendor/themes/sumi/1.3.0/theme.json +10 -0
  105. package/vendor/themes/sumi/1.3.0/tokens.css +57 -0
  106. package/vendor/themes/tokiwa/1.3.0/theme.json +10 -0
  107. package/vendor/themes/tokiwa/1.3.0/tokens.css +33 -0
@@ -0,0 +1,236 @@
1
+ // m-quad:2 軸の位置づけ(ポジショニングマップ・SWOT 風の 4 象限)。点を段階ごとに 1 つずつ置く
2
+ // <m-quad style="height:420px"><script type="application/json">
3
+ // {"x": {"lo": "手作業", "hi": "自動"}, "y": {"lo": "高い", "hi": "安い"},
4
+ // "quads": {"tr": "狙う場所", "tl": "", "bl": "", "br": ""},
5
+ // "items": [{"label": "A 社", "x": 0.25, "y": 0.7}, {"label": "自社", "x": 0.8, "y": 0.82, "self": true, "to": {"x": 0.9, "y": 0.9, "label": "3 年後"}}]}
6
+ // (JSON の終わり)</m-quad>
7
+ // 座標は 0〜1(0.5 が軸の交わるところ)。軸と両端の言葉は段階 0 から見える。象限の名前は quads-step(既定 0)で出る
8
+ // 点は既定で 1 つ = 1 段階(step で直接、at で段階の中の開始秒)。self の点は強調の色で大きく、着いたときに輪が広がる
9
+ // to は移動先:to.step(既定は点の次の段階)に、点が破線の跡を引きながら滑る
10
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・prog・lerp・clamp・previewOpacity を使い、プレイヤーのグローバルは使わない
11
+ egatariParts.define({name: "quad", version: "2.1.1", requires: {base: "1.2.0"}, element: "m-quad"}, function(deps){
12
+ "use strict";
13
+ var base = deps.base;
14
+ return class extends base.MotionElement {
15
+ static partName = "quad"; // the registry name (define meta name), for report prefixes
16
+ // データの形(kit/shape.js)。x・y は 0〜1(0.5 が軸の交わるところ)
17
+ static shape = {
18
+ schema: {type: "object", additionalProperties: false, required: ["items"], properties: {
19
+ x: {type: "object", properties: {lo: {type: "string"}, hi: {type: "string"}}}, y: {type: "object", properties: {lo: {type: "string"}, hi: {type: "string"}}},
20
+ quads: {type: "object", properties: {tr: {type: "string"}, tl: {type: "string"}, bl: {type: "string"}, br: {type: "string"}, fill: {type: "string"}}},
21
+ items: {type: "array", minItems: 1, items: {type: "object", required: ["x", "y"], properties: {
22
+ label: {type: "string"}, x: {type: "number"}, y: {type: "number"}, step: {type: "integer"}, at: {type: "number"}, tone: {type: "string"}, anchor: {enum: ["right", "left", "above", "below"]},
23
+ r: {type: "number"}, self: {type: "boolean"}, to: {type: "object", required: ["x", "y"], properties: {x: {type: "number"}, y: {type: "number"}, label: {type: "string"}, step: {type: "integer"}, at: {type: "number"}}}}}}}},
24
+ example: {x: {lo: "手作業", hi: "自動"}, y: {lo: "高い", hi: "安い"}, items: [{label: "A 社", x: 0.25, y: 0.7}, {label: "自社", x: 0.8, y: 0.82, self: true}]},
25
+ };
26
+ static props = {
27
+ fade: {type: "number", default: 0.5, doc: "点が現れる秒数"},
28
+ move: {type: "number", default: 1.2, doc: "to の移動の秒数"},
29
+ size: {type: "number", default: 26, doc: "点の名前の字の大きさ(px)"},
30
+ "quads-step": {type: "number", default: 0, doc: "象限の名前を出すステップ(0 = 初めから)"},
31
+ };
32
+ get steps(){
33
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
34
+ var m = this.props["quads-step"];
35
+ this.plan().forEach(function(o){ m = Math.max(m, o.step, o.to ? o.to.step : 0); });
36
+ return m;
37
+ }
38
+ // 点の段階と開始時刻(データだけから決める)
39
+ plan(){
40
+ if (this._plan) return this._plan;
41
+ var d = this.data || {}, q0 = this.props["quads-step"], n = 0, seen = {};
42
+ return (this._plan = (d.items || []).map(function(it){
43
+ var step = it.step !== undefined ? it.step : q0 + (++n);
44
+ n = Math.max(n, step - q0);
45
+ var j = seen[step] = (seen[step] || 0) + 1;
46
+ var to = it.to ? {x: it.to.x, y: it.to.y, label: it.to.label || "", step: it.to.step !== undefined ? it.to.step : step + 1, at: it.to.at || 0} : null;
47
+ return {it: it, step: step, at: it.at !== undefined ? it.at : (j - 1) * 0.6, to: to};
48
+ }));
49
+ }
50
+ mount(ctx){
51
+ var P = this.props, D = base, self = this, d = this.data || {};
52
+ this.style.display = "block"; this.style.position = "relative";
53
+ var W = this.clientWidth, H = this.clientHeight;
54
+ var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
55
+ // 読み上げ:最後の形(点はすべて置かれ、to の点は行き先にいる)を 1 文で。作者の aria-label があればそれを使う(上書きしない)
56
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
57
+ this.setAttribute("role", "img");
58
+ if (!this._aria) this.setAttribute("aria-label", this.summary(/^ja\b/i.test(ctx.lang || "ja")));
59
+ // 図の枠:両端の言葉の分だけ上下と左右に余白
60
+ var m = {l: 12, r: 12, t: 40, b: 40};
61
+ var x0 = m.l, x1 = W - m.r, y0 = m.t, y1 = H - m.b, cx = (x0 + x1) / 2, cy = (y0 + y1) / 2;
62
+ this.X = function(v){ return x0 + v * (x1 - x0); };
63
+ this.Y = function(v){ return y1 - v * (y1 - y0); };
64
+ // 象限の地(右上だけ淡く塗れる:quads.fill = "tr" など)と名前
65
+ var q = d.quads || {}, xa0 = d.x || {}, gQ = D.el("g", {}, svg);
66
+ this.quadG = D.el("g", {}, svg);
67
+ var corner = {tr: [cx, y0, x1 - cx, cy - y0, x1 - 16, y0 + 34, "end"], tl: [x0, y0, cx - x0, cy - y0, x0 + 16, y0 + 34, "start"],
68
+ bl: [x0, cy, cx - x0, y1 - cy, x0 + 16, y1 - 16, "start"], br: [cx, cy, x1 - cx, y1 - cy, x1 - 16, y1 - 16, "end"]};
69
+ ["tr", "tl", "bl", "br"].forEach(function(key){
70
+ var c = corner[key];
71
+ if (q.fill === key) D.el("rect", {x: c[0], y: c[1], width: Math.max(0, c[2]), height: Math.max(0, c[3]), fill: "var(--term-tint)"}, gQ);
72
+ });
73
+ // 軸(両向きの矢印)と両端の言葉。横軸の言葉は軸の下、縦軸の言葉は軸の上端・下端の外
74
+ var ax = D.el("g", {}, svg), K = "var(--fg)";
75
+ D.el("line", {x1: x0, y1: cy, x2: x1, y2: cy, stroke: K, "stroke-width": 2, class: "axis"}, ax);
76
+ D.el("line", {x1: cx, y1: y0, x2: cx, y2: y1, stroke: K, "stroke-width": 2, class: "axis"}, ax);
77
+ [[x1, cy, 0], [x0, cy, 180], [cx, y0, -90], [cx, y1, 90]].forEach(function(a){
78
+ D.el("path", {d: "M0,0L-14,-7L-14,7Z", fill: K, transform: "translate(" + a[0] + " " + a[1] + ") rotate(" + a[2] + ")"}, ax);
79
+ });
80
+ var xa = xa0, ya = d.y || {};
81
+ if (xa.lo) D.mtext(ax, x0 + 4, cy + 34, xa.lo, {"text-anchor": "start", "font-size": 24});
82
+ if (xa.hi) D.mtext(ax, x1 - 4, cy + 34, xa.hi, {"text-anchor": "end", "font-size": 24});
83
+ if (ya.hi) D.mtext(ax, cx, y0 - 14, ya.hi, {"text-anchor": "middle", "font-size": 24});
84
+ if (ya.lo) D.mtext(ax, cx, y1 + 32, ya.lo, {"text-anchor": "middle", "font-size": 24});
85
+ // 点の名前の置き場所(既定は右。anchor で left / above / below)。
86
+ // 名前が軸の線を横切るなら、丸の反対の側 → 上 → 下の順に置き直す(点の始めの位置と to の位置の両方で確かめる)。
87
+ // 象限の名前を置いたあとは、その名前にかかる置き場所も避ける。幅は字から見積もる(base の textWidth:テーマの字で測った幅。mtext の *_^ は数えない)
88
+ var est = function(s, z){ return D.textWidth(s || "", z, {font: self, mark: true}); };
89
+ var meet = function(a, b, gp){ return a[0] < b[2] + gp && a[2] > b[0] - gp && a[1] < b[3] + gp && a[3] > b[1] - gp; };
90
+ var items = this.plan().map(function(o){
91
+ var it = o.it, me = !!it.self, r = it.r || (me ? 14 : 11), off = r + 10, w = est(it.label, P.size);
92
+ var place = function(an){ return an === "left" ? [-off, 9, "end"] : an === "above" ? [0, -off - 4, "middle"] : an === "below" ? [0, off + 22, "middle"] : [off, 9, "start"]; };
93
+ var boxAt = function(an, px, py){
94
+ var lp = place(an), lx = px + lp[0], ly = py + lp[1], a0 = lp[2] === "start" ? lx : lp[2] === "end" ? lx - w : lx - w / 2;
95
+ return [a0, ly - P.size * 0.88, a0 + w, ly + P.size * 0.22];
96
+ };
97
+ var crosses = function(an, px, py){
98
+ var b = boxAt(an, px, py);
99
+ return (b[0] - 6 < cx && b[2] + 6 > cx && b[1] < y1 && b[3] > y0) || (b[1] - 6 < cy && b[3] + 6 > cy && b[0] < x1 && b[2] > x0);
100
+ };
101
+ var pts = [[self.X(it.x), self.Y(it.y)]].concat(o.to ? [[self.X(o.to.x), self.Y(o.to.y)]] : []);
102
+ var pref = it.anchor || "right", order = [pref, pref === "left" ? "right" : pref === "right" ? "left" : pref === "above" ? "below" : "above", "above", "below", "left", "right"];
103
+ var pick = function(names){
104
+ return order.filter(function(a){ return !pts.some(function(q){ return crosses(a, q[0], q[1]) || names.some(function(nb){ return meet(boxAt(a, q[0], q[1]), nb, 6); }); }); })[0];
105
+ };
106
+ var an = pick([]) || pref;
107
+ return {o: o, it: it, me: me, r: r, pts: pts, place: place, boxAt: boxAt, pick: pick, an: an,
108
+ // 丸と名前が占める箱(点の始めと to の位置)
109
+ boxes: function(a){ return [].concat.apply([], pts.map(function(q){ return [[q[0] - r, q[1] - r, q[0] + r, q[1] + r], boxAt(a, q[0], q[1])]; })); }};
110
+ });
111
+ // 象限の名前:隅(外側の角)に置く。点や点の名前、軸の言葉にかかるなら、同じ象限の残りの 3 つの隅を順に試す。
112
+ // どこもかかるなら外側の角に置き、点の名前のほうを動かす(上の pick)。動かせなければ知らせる(layout)
113
+ var axisBoxes = [];
114
+ if (xa0.lo) axisBoxes.push([x0 + 4, cy + 34 - 24 * 0.88, x0 + 4 + est(xa0.lo, 24), cy + 34 + 24 * 0.22]);
115
+ if (xa0.hi) axisBoxes.push([x1 - 4 - est(xa0.hi, 24), cy + 34 - 24 * 0.88, x1 - 4, cy + 34 + 24 * 0.22]);
116
+ var names = [];
117
+ ["tr", "tl", "bl", "br"].forEach(function(key){
118
+ if (!q[key]) return;
119
+ var c = corner[key], top = key[0] === "t", right = key[1] === "r", w = est(q[key], 26);
120
+ var ins = [c[0] + 16, c[0] + c[2] - 16], ys = top ? [y0 + 34, cy - 16] : [y1 - 16, cy + 42];
121
+ var cand = [[right ? ins[1] : ins[0], ys[0], right ? "end" : "start"], [right ? ins[0] : ins[1], ys[0], right ? "start" : "end"],
122
+ [right ? ins[1] : ins[0], ys[1], right ? "end" : "start"], [right ? ins[0] : ins[1], ys[1], right ? "start" : "end"]];
123
+ var boxOf = function(k){ var x = k[2] === "end" ? k[0] - w : k[0]; return [x, k[1] - 26 * 0.88, x + w, k[1] + 26 * 0.22]; };
124
+ var busy = function(b){ return axisBoxes.some(function(a){ return meet(b, a, 6); }) || items.some(function(m){ return m.boxes(m.an).some(function(a){ return meet(b, a, 6); }); }); };
125
+ var k = cand.filter(function(k){ return !busy(boxOf(k)); })[0] || cand[0];
126
+ D.mtext(self.quadG, k[0], k[1], q[key], {"text-anchor": k[2], "font-size": 26, "font-weight": 700, fill: q.fill === key ? "var(--term)" : "var(--muted)"});
127
+ names.push({key: key, box: boxOf(k)});
128
+ });
129
+ items.forEach(function(m){
130
+ if (!names.length || !m.boxes(m.an).some(function(a){ return names.some(function(nm){ return meet(a, nm.box, 6); }); })) return;
131
+ var a = m.pick(names.map(function(nm){ return nm.box; }));
132
+ if (a) m.an = a;
133
+ else ctx.report("layout", "[quad] the label " + JSON.stringify(m.it.label || "") + " overlaps a quadrant name and has no free side; move the point or shorten a name");
134
+ });
135
+ // 点:丸と名前
136
+ var gT = D.el("g", {}, svg), gP = D.el("g", {}, svg);
137
+ // data-part:Studio の形の検査(geometry check)が測る印。点の丸は mark(id は items の並びで p1, p2 …)、点の名前と行き先の名前は
138
+ // その点の label(箱の外の字)、動いた跡は p<n> から @moved への edge(破線が data-part-line、矢じりは端)
139
+ this.pts = items.map(function(m, i){
140
+ var o = m.o, it = m.it, me = m.me, r = m.r, col = me ? "var(--emph)" : it.tone === "term" ? "var(--term)" : it.tone === "fg" ? "var(--fg)" : "var(--muted)";
141
+ var pid = "p" + (i + 1), lb = {"data-part": "label", "data-part-id": pid, "data-part-of": "mark", "data-part-at": "outside"};
142
+ var gM = o.to ? D.el("g", {"data-part": "edge", "data-part-id": pid + "\u2192@moved", "data-part-from": pid, "data-part-to": "@moved"}, gT) : null;
143
+ var trail = o.to ? D.el("line", {stroke: col, "stroke-width": 2.5, "stroke-dasharray": "7 6", opacity: 0, "data-part-line": ""}, gM) : null;
144
+ // 動いた跡の印(最後の形にも残す):出発点の白抜きの丸と、行き先へ向く矢じり(丸の手前)
145
+ var from = o.to ? D.el("circle", {cx: self.X(it.x).toFixed(2), cy: self.Y(it.y).toFixed(2), r: (r * 0.8).toFixed(1), fill: "var(--bg)", stroke: col, "stroke-width": 2.5, opacity: 0}, gT) : null;
146
+ var head = o.to ? D.el("path", {d: "M0,0L-14,-7L-14,7Z", fill: col, opacity: 0}, gM) : null;
147
+ var ring = me ? D.el("circle", {r: r, fill: "none", stroke: col, "stroke-width": 3, opacity: 0}, gP) : null;
148
+ var g = D.el("g", {opacity: 0}, gP);
149
+ D.el("circle", {cx: 0, cy: 0, r: r, fill: col, stroke: "var(--bg)", "stroke-width": 2.5, "data-part": "mark", "data-part-id": pid}, g);
150
+ var lp = m.place(m.an);
151
+ D.mtext(g, lp[0], lp[1], it.label || "", Object.assign({"text-anchor": lp[2], "font-size": P.size, "font-weight": me ? 700 : 400, fill: me ? col : "var(--fg)"}, lb));
152
+ var lab2 = o.to && o.to.label ? D.mtext(gP, 0, 0, o.to.label, Object.assign({"text-anchor": "middle", "font-size": 24, fill: col, opacity: 0}, lb)) : null;
153
+ return {o: o, g: g, ring: ring, r: r, trail: trail, from: from, head: head, lab2: lab2};
154
+ });
155
+ }
156
+ // 最後の形を 1 文で(読み上げの名前):象限の名前と、点ごとの最後の位置(右上・左下など。to の点は出発点から行き先へ)
157
+ summary(ja){
158
+ var d = this.data || {}, q = d.quads || {}, xa = d.x || {}, ya = d.y || {};
159
+ var where = function(x, y, bare){
160
+ var h = x > 0.5 ? (ja ? "右" : "right") : x < 0.5 ? (ja ? "左" : "left") : "", v = y > 0.5 ? (ja ? "上" : "upper") : y < 0.5 ? (ja ? "下" : "lower") : "";
161
+ var key = (y > 0.5 ? "t" : "b") + (x > 0.5 ? "r" : "l");
162
+ var s = ja ? (h + v || "中央") : ([v, h].filter(Boolean).join(" ") || "centre");
163
+ return s + (h && v && q[key] && !bare ? (ja ? "(" + q[key] + ")" : " (" + q[key] + ")") : "");
164
+ };
165
+ var axis = function(a, n){ return a.lo || a.hi ? (ja ? n + ":" + (a.lo || "") + "→" + (a.hi || "") : n + ": " + (a.lo || "") + " to " + (a.hi || "")) : ""; };
166
+ var ax = [axis(xa, ja ? "横" : "x"), axis(ya, ja ? "縦" : "y")].filter(Boolean).join(ja ? "、" : "; ");
167
+ var pts = this.plan().map(function(o){
168
+ var it = o.it, nm = it.label || (ja ? "点" : "a point");
169
+ if (!o.to) return ja ? nm + "は" + where(it.x, it.y) : nm + " is " + where(it.x, it.y);
170
+ var lb = o.to.label ? (ja ? "(" + o.to.label + ")" : " (" + o.to.label + ")") : "", w0 = where(it.x, it.y), w1 = where(o.to.x, o.to.y, true);
171
+ // 同じ象限の中の移動なら、行き先に象限の名前を繰り返さない
172
+ if (w1 !== where(it.x, it.y, true)) w1 = where(o.to.x, o.to.y);
173
+ return ja ? nm + "は" + w0 + "から" + w1 + "へ" + lb : nm + " moves from " + w0 + " to " + w1 + lb;
174
+ });
175
+ return (ja ? "4 象限" : "Four quadrants") + (ax ? (ja ? "(" + ax + ")" : " (" + ax + ")") : "") + (ja ? ":" : ": ") + pts.join(ja ? "、" : ", ");
176
+ }
177
+ duration(k){
178
+ var P = this.props, d = k === P["quads-step"] && k > 0 ? P.fade : 0;
179
+ this.plan().forEach(function(o){
180
+ if (o.step === k) d = Math.max(d, o.at + P.fade + (o.it.self ? 0.6 : 0));
181
+ if (o.to && o.to.step === k) d = Math.max(d, o.to.at + P.move + 0.3);
182
+ });
183
+ return d;
184
+ }
185
+ // 同じ段階に 2 つ以上の点があれば、2 つ目からの開始時刻を口述原稿の {cue} に合わせられる
186
+ cues(k){
187
+ var c = [];
188
+ this.plan().forEach(function(o){ if (o.step === k && o.at > 0) c.push(o.at); });
189
+ return c.length ? c.sort(function(a, b){ return a - b; }) : null;
190
+ }
191
+ render(k, t, ctx){
192
+ var P = this.props, D = base, self = this;
193
+ // 先の段階を薄く見せる表示(授業の表示):後の段階の点(動いた後の位置)・動く跡・行き先の名前・象限の名前を、
194
+ // テーマの --preview-opacity の濃さに。今の段階に出ている点は元の位置のまま
195
+ var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
196
+ var pr = function(step, at, dur){ return step < k ? 1 : step > k ? 0 : D.prog(t, at, dur); };
197
+ var qs = P["quads-step"];
198
+ this.quadG.setAttribute("opacity", (qs === 0 ? 1 : preview && qs > k ? PV : pr(qs, 0, P.fade)).toFixed(3));
199
+ this.pts.forEach(function(p){
200
+ var o = p.o, e = pr(o.step, o.at, P.fade), fp = preview && o.step > k, fm = preview && o.to && o.to.step > k;
201
+ var m = o.to ? (fp ? 1 : pr(o.to.step, o.to.at, P.move)) : 0;
202
+ if (fp) e = 1;
203
+ var x0 = self.X(o.it.x), y0 = self.Y(o.it.y);
204
+ var x = o.to ? D.lerp(x0, self.X(o.to.x), m) : x0, y = o.to ? D.lerp(y0, self.Y(o.to.y), m) : y0;
205
+ var s = D.lerp(0.6, 1, e);
206
+ p.g.setAttribute("opacity", fp ? PV.toFixed(3) : e.toFixed(3));
207
+ p.g.setAttribute("transform", "translate(" + x.toFixed(2) + " " + y.toFixed(2) + ") scale(" + s.toFixed(4) + ")");
208
+ // 自社の点:着いたときに輪が 1 回広がって消える(最終状態では出さない)
209
+ if (p.ring){
210
+ var rt = !fp && o.step === k && t !== Infinity ? D.clamp((t - o.at - P.fade * 0.6) / 0.8) : 1;
211
+ p.ring.setAttribute("cx", x.toFixed(2)); p.ring.setAttribute("cy", y.toFixed(2));
212
+ p.ring.setAttribute("r", (p.r * (1 + 1.6 * rt)).toFixed(2));
213
+ p.ring.setAttribute("opacity", (rt > 0 && rt < 1 ? 0.8 * (1 - rt) : 0).toFixed(3));
214
+ }
215
+ if (p.trail){
216
+ p.trail.setAttribute("x1", x0.toFixed(2)); p.trail.setAttribute("y1", y0.toFixed(2));
217
+ p.trail.setAttribute("x2", x.toFixed(2)); p.trail.setAttribute("y2", y.toFixed(2));
218
+ if (fm){ p.trail.setAttribute("x2", self.X(o.to.x).toFixed(2)); p.trail.setAttribute("y2", self.Y(o.to.y).toFixed(2)); }
219
+ p.trail.setAttribute("opacity", fm ? PV : m > 0 ? 0.9 : 0);
220
+ // 出発点の丸は跡と同じ濃さ。矢じりは今の点の丸の手前(丸の縁から 3px)に、跡が丸と出発点の丸の外に出ている長さがあるときだけ
221
+ var hx = fm ? self.X(o.to.x) : x, hy = fm ? self.Y(o.to.y) : y, len = Math.hypot(hx - x0, hy - y0), ho = fm ? PV : m > 0 ? 0.9 : 0;
222
+ p.from.setAttribute("opacity", ho);
223
+ if (len > p.r * 1.8 + 3 + 14 + 4){
224
+ var ux = (hx - x0) / len, uy = (hy - y0) / len, tip = p.r * s + 3;
225
+ p.head.setAttribute("transform", "translate(" + (hx - ux * tip).toFixed(2) + " " + (hy - uy * tip).toFixed(2) + ") rotate(" + (Math.atan2(uy, ux) * 180 / Math.PI).toFixed(1) + ")");
226
+ p.head.setAttribute("opacity", ho);
227
+ } else { p.head.removeAttribute("transform"); p.head.setAttribute("opacity", 0); } // 作った直後と同じ(呼ぶ順で DOM が変わらない)
228
+ }
229
+ if (p.lab2){
230
+ p.lab2.setAttribute("x", self.X(o.to.x).toFixed(2)); p.lab2.setAttribute("y", (self.Y(o.to.y) - p.r - 14).toFixed(2));
231
+ p.lab2.setAttribute("opacity", fm ? PV.toFixed(3) : pr(o.to.step, o.to.at + P.move * 0.8, 0.3).toFixed(3));
232
+ }
233
+ });
234
+ }
235
+ };
236
+ });