egatari 0.6.16 → 0.6.18

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 (137) hide show
  1. package/CHANGELOG.md +43 -1
  2. package/README.ja.md +14 -13
  3. package/README.md +2 -1
  4. package/components.lock.json +119 -45
  5. package/components2.lock.json +639 -1
  6. package/kit/check-messages.mjs +5 -0
  7. package/kit/check.mjs +6 -0
  8. package/kit/core/bookmark.mjs +28 -0
  9. package/kit/core/build-core.mjs +4 -2
  10. package/kit/core/check-parity.mjs +4 -0
  11. package/kit/core/check-rules.mjs +3 -2
  12. package/kit/core/check-source.mjs +6 -0
  13. package/kit/core/llm-pack-assemble.mjs +37 -66
  14. package/kit/core/llm-pack-data.mjs +839 -45
  15. package/kit/core/llm-pack.mjs +6 -4
  16. package/kit/core/llm-request.mjs +2 -2
  17. package/kit/core/new-deck-pack.mjs +38 -44
  18. package/kit/core/new-deck.mjs +82 -74
  19. package/kit/core/part-labels.mjs +2 -0
  20. package/kit/core/purposes.mjs +9 -3
  21. package/kit/core/sample-info.mjs +17 -3
  22. package/kit/core/slide-ops.mjs +22 -0
  23. package/kit/core/tate-mix.mjs +25 -0
  24. package/kit/core/theme-derive.mjs +56 -17
  25. package/kit/core/theme-shapes.mjs +15 -1
  26. package/kit/deck.js +53 -2
  27. package/kit/instruction-version.json +1 -1
  28. package/kit/llm-pack.mjs +5 -7
  29. package/kit/player.json +1 -1
  30. package/kit/player.lock.json +2 -2
  31. package/kit/presenter.js +36 -4
  32. package/kit/tools.js +54 -2
  33. package/package.json +1 -1
  34. package/vendor/components/CATALOG.md +24 -22
  35. package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
  36. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
  37. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
  38. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
  39. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
  40. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
  41. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
  42. package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
  43. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
  44. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
  45. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
  46. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
  47. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
  48. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
  49. package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
  50. package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
  51. package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
  52. package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
  53. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
  54. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
  55. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
  56. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
  57. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
  58. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
  59. package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
  60. package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
  61. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
  62. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
  63. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
  64. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
  65. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
  66. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
  67. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
  68. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
  69. package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
  70. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
  71. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
  72. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
  73. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
  74. package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
  75. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
  76. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
  77. package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
  78. package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
  79. package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
  80. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
  81. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
  82. package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
  83. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
  84. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
  85. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
  86. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
  87. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
  88. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
  89. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
  90. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
  91. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
  92. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
  93. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
  94. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
  95. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
  96. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
  97. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
  98. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
  99. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
  100. package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
  101. package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
  102. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
  103. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
  104. package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
  105. package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
  106. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
  107. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
  108. package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
  109. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
  110. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
  111. package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
  112. package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
  113. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
  114. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
  115. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
  116. package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
  117. package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
  118. package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
  119. package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
  120. package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
  121. package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
  122. package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
  123. package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
  124. package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
  125. package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
  126. package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
  127. package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
  128. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
  129. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
  130. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
  131. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
  132. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
  133. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
  134. package/vendor/components-2/manifest-2.16.0.json +2919 -0
  135. package/vendor/components-2/manifest-2.17.0.json +2852 -0
  136. package/vendor/components-2/manifest-2.18.0.json +3182 -0
  137. package/vendor/egatari-spec/SOURCE.json +2 -2
@@ -0,0 +1,268 @@
1
+ // m-timer:グループワークの進行タイマー。段階 0 は準備の画面、段階 k で phases[k-1] の残り時間を数える(元は雲居玄道が研修の資料のために作った部品)
2
+ // <m-timer style="height:432px"><script type="application/json">
3
+ // {"ready": {"title": "準備の確認", "text": "用紙とペンがそろっているか"},
4
+ // "phases": [{"title": "① 付箋に書く", "short": "付箋に書く", "text": "1 枚に 1 件", "sec": 180}, …]}
5
+ // (JSON の終わり)</m-timer>
6
+ // duration(k) = phases[k-1].sec。実行系は t を実時間で進めるので、時計は (k, t) だけで決まる。→ キー(段階を進める)がスタートの合図
7
+ // 左:題・説明・残り時間の大きな時計・進みの棒。右:区切りの一覧(今の区切りに枠、終わった区切りは --muted)
8
+ // 最後の 1 分は時計と棒が --emph。最後の 10 秒は時計が 1 秒おきに薄くなる(注目のため。動画・動きを減らす設定・最後の状態では止まる)
9
+ // 字は部品の中に書かない:授業の言語(ctx.lang。<html lang> から)で日本語か英語の表を選び、データの labels で上書きできる
10
+ // +1 分・−1 分(仕様 §8.4 ctx.extend、egatari-spec 485ae54):実行系が ctx.extend を渡すときだけボタンを出す。延ばした秒数は見る人の状態で、
11
+ // 同じスライドにいるあいだは残り、ほかのスライドから入ったとき・飛んだとき(ctx.entered)だけ戻る。ctx.reset ではボタンのフォーカスだけを戻す(仕様 §8.4)。動画・印刷は作者の秒数
12
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・prog を使い、プレイヤーのグローバルは使わない。
13
+ // 延長を戻すのは ctx.entered だけ(1.x の deck:pos の代わりはない)。日本語かどうかは mount の ctx.lang、動画かどうかは ctx.mode。
14
+ // 要素の大きさの問題は ctx.report("size", …)。印刷の前後は document.defaultView の beforeprint・afterprint
15
+ egatariParts.define({name: "timer", version: "2.0.7", requires: {base: "1.3.0"}, element: "m-timer"}, function(deps){
16
+ "use strict";
17
+ var base = deps.base;
18
+ var CSS_ID = "timer-2-0-6-css"; // the style element this part writes, named with its name and version (spec §6.1 Identifiers)
19
+ var JA = {ready: "準備の確認", total: "合計", remaining: "残り", done: "時間", start: "準備ができたら → キーでスタート", next: "終了 → キーで次へ", end: "終了",
20
+ min: "分", sec: "秒", plus: "+1 分", minus: "−1 分"};
21
+ var EN = {ready: "Ready?", total: "Total", remaining: "Remaining", done: "Time's up", start: "When ready, press → to start", next: "Time's up. Press → for the next", end: "Time's up",
22
+ min: " min", sec: " s", plus: "+1 min", minus: "−1 min"};
23
+ var CSS = [
24
+ "m-timer .tm-say{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}",
25
+ "m-timer .tm-ctl{position:absolute;display:flex;gap:12px}",
26
+ "m-timer .tm-btn{min-width:112px;height:52px;padding:0 14px;font:700 27px/1 var(--font-cap,var(--font-sans,sans-serif));color:var(--fg);background:var(--bg);border:2px solid var(--term);border-radius:8px;cursor:pointer;touch-action:manipulation}",
27
+ "m-timer .tm-btn:active{background:var(--term-tint)}",
28
+ "m-timer .tm-btn:focus-visible{outline:3px solid var(--emph);outline-offset:2px}",
29
+ "@media print{m-timer .tm-ctl{display:none!important}}",
30
+ ].join("\n");
31
+ return class extends base.MotionElement {
32
+ static partName = "timer"; // the registry name (define meta name), for report prefixes
33
+ static variants = ["fade"];
34
+ static interactive = true; // 操作できるパーツ(docs/conventions.md §6)
35
+ static preview = "none"; // 先の時間は中身ではないので、授業の表示でも先の区切りを見せない(仕様 §8.4、docs/conventions.md §1.2)
36
+ static clock = true; // 経った時間そのものが中身:動きを減らす設定でも実時間の t で描く(仕様 §9.1)
37
+ // 「道具」の組(頼まれたときだけ使う部品)と、新規作成の道具の札(docs/conventions.md §7。tools/release.mjs が manifest に写す。JSON で書く)
38
+ static group = "tool";
39
+ static tile = {"label": {"ja": "タイマー", "en": "Timer"}, "examples": {"ja": "グループワークの時間・残り時間・ベル", "en": "Group-work time, time left, bells"}, "icon": "timer"};
40
+ static viewerInput = true; // 見る人の入力(区切りの時間を延ばす・縮める。仕様 §8.4)
41
+ // データの形(kit/shape.js)
42
+ static shape = {
43
+ schema: {type: "object", additionalProperties: false, required: ["phases"], properties: {
44
+ ready: {type: "object", additionalProperties: false, properties: {title: {type: "string"}, text: {type: "string"}}},
45
+ phases: {type: "array", minItems: 1, maxItems: 8, items: {type: "object", additionalProperties: false, required: ["title", "sec"], properties: {
46
+ title: {type: "string"}, short: {type: "string"}, text: {type: "string"}, sec: {type: "integer"}, bells: {type: "array", maxItems: 6, items: {type: "object", additionalProperties: false, required: ["left"], properties: {left: {type: "integer"}, count: {type: "integer"}}}}}}},
47
+ bells: {type: "array", maxItems: 6, items: {type: "object", additionalProperties: false, required: ["left"], properties: {left: {type: "integer"}, count: {type: "integer"}}}},
48
+ done: {type: "string"},
49
+ labels: {type: "object", additionalProperties: false, properties: {
50
+ ready: {type: "string"}, total: {type: "string"}, remaining: {type: "string"}, done: {type: "string"}, start: {type: "string"},
51
+ next: {type: "string"}, end: {type: "string"}, min: {type: "string"}, sec: {type: "string"}, plus: {type: "string"}, minus: {type: "string"}}}}},
52
+ example: {ready: {title: "準備の確認", text: "用紙とペンがそろっているか"}, phases: [{title: "① 付箋に書く", short: "付箋に書く", sec: 180}, {title: "② 島で選ぶ", short: "島で選ぶ", sec: 300}]},
53
+ note: {en: "phases is a list of {\"title\", \"sec\"} (sec: whole seconds, not \"3分\"); one phase per step",
54
+ ja: "phases は {\"title\", \"sec\"} の並び(sec は秒の整数。\"3分\" のような字ではない)。区切り 1 つが 1 ステップ"},
55
+ };
56
+ static props = {};
57
+ get steps(){ return this.getAttribute("steps") !== null ? +this.getAttribute("steps") : ((this.data || {}).phases || []).length; }
58
+ // 字の表(授業の言語 ctx.lang で選ぶ。mount が this.ja を決めてから読む。データの labels が勝つ。古い書き方の "done" も受け付ける)
59
+ get L(){
60
+ if (this._L) return this._L;
61
+ var d = this.data || {}, tbl = this.ja ? JA : EN, o = {};
62
+ for (var k in tbl) o[k] = tbl[k];
63
+ if (typeof d.done === "string") o.done = o.end = d.done;
64
+ var lb = d.labels || {};
65
+ for (var j in lb) o[j] = lb[j];
66
+ return (this._L = o);
67
+ }
68
+ mount(ctx){
69
+ this.ja = /^ja\b/i.test(ctx.lang);
70
+ var self = this, d = this.data || {};
71
+ this.P = d.phases || [];
72
+ if (this.P.some(function(p){ return !(p.sec > 0); })) throw new Error("every phase needs sec > 0 (whole seconds)");
73
+ // 読み上げ:要素は区切りとその時間を名前にした group(中の知らせ role="status" と ±1 分のボタンはそのまま届く)。作者の aria-label があればそれを使う(上書きしない)
74
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
75
+ this.setAttribute("role", "group");
76
+ if (!this._aria) this.setAttribute("aria-label", (this.ja ? "タイマー:" : "Timer: ") + this.P.map(function(p){ return p.title + " " + self.span(p.sec); }).join(this.ja ? "、" : ", "));
77
+ this.video = ctx.mode === "video";
78
+ this.style.display = "block"; this.style.position = "relative";
79
+ if (!document.getElementById(CSS_ID)){ var st = document.createElement("style"); st.id = CSS_ID; st.textContent = CSS; document.head.appendChild(st); }
80
+ // 読み上げソフトへの知らせ(区切りの始まりと終わりだけ。毎秒は読まない)
81
+ this.say = document.createElement("div"); this.say.className = "tm-say"; this.say.setAttribute("role", "status"); this.say.setAttribute("aria-live", "polite");
82
+ this.appendChild(this.say);
83
+ this._ext = {};
84
+ this.total = this.P.reduce(function(a, p){ return a + p.sec; }, 0);
85
+ // 印刷は作者の秒数で描く(延長は消さない。afterprint で戻す)。beforeprint・afterprint は文書の窓(document.defaultView)に来る
86
+ var view = document.defaultView;
87
+ if (!this.video && view){
88
+ view.addEventListener("beforeprint", function(){ self._printing = true; self.redraw(); });
89
+ view.addEventListener("afterprint", function(){ self._printing = false; self.redraw(); });
90
+ }
91
+ this.place(ctx);
92
+ }
93
+ // 配置が変わった知らせ(仕様 §8.4 layout):要素の大きさが mount のときと変わったときだけ置き直す(変換で縮めるだけなら呼ばれない。
94
+ // 横に並んだ文の字が後から読み込まれて、段組みの中の幅が変わるときなど)。大きさ 0(隠れている)なら前の配置のまま
95
+ layout(ctx){
96
+ var W = this.clientWidth, H = this.clientHeight;
97
+ if (!W || !H || (W === this.W && H === this.H)) return;
98
+ this.place(ctx);
99
+ this.redraw();
100
+ }
101
+ // 大きさで決まる絵(svg と区切りの一覧、ボタンの位置)を作る。延長・読み上げの知らせは残す
102
+ place(ctx){
103
+ var self = this, D = base, d = this.data || {}, L = this.L;
104
+ var W = this.clientWidth, H = this.clientHeight;
105
+ if (this.svg) this.svg.remove();
106
+ var f = this.f = Math.max(0.6, Math.min(1.2, H / 432, W / 1180)), F = function(z){ return Math.max(24, Math.round(z * f)); };
107
+ var LW = this.LW = W * 0.525, RX = W * 0.576;
108
+ var svg = this.svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, style: "display:block;overflow:visible"});
109
+ this.insertBefore(svg, this.say);
110
+ // 字の幅(base の textWidth:テーマの字で測った幅)
111
+ var est = this.est = function(s, z){ return D.textWidth(s, z, {font: self}); };
112
+ // 題(長ければ 24 px まで小さく)と説明(2 行まで。幅で折り返す)
113
+ var fit = function(s, max, z, what){
114
+ var y = z; while (y > 24 && est(s, y) > max) y--;
115
+ if (est(s, y) > max) ctx.report("size", "[timer] the " + what + " " + JSON.stringify(s) + " does not fit (" + Math.ceil(est(s, y) - max) + " px too wide); shorten it");
116
+ return y;
117
+ };
118
+ var wrap = function(s, max, z, what){
119
+ var out = [];
120
+ String(s || "").split("\n").forEach(function(line){
121
+ var cur = "";
122
+ [...line].forEach(function(c){ if (cur && est(cur + c, z) > max){ out.push(cur); cur = ""; } cur += c; });
123
+ out.push(cur);
124
+ });
125
+ if (out.length > 2) ctx.report("size", "[timer] the text of " + what + " needs " + out.length + " lines (2 fit); shorten it");
126
+ return out.slice(0, 2);
127
+ };
128
+ var heads = [d.ready || {}].concat(this.P);
129
+ this.heads = heads.map(function(h, j){
130
+ var title = h.title || (j === 0 ? L.ready : "");
131
+ return {title: title, size: fit(title, LW, F(44), j ? "title of phase " + j : "ready title"), lines: wrap(h.text, LW, F(30), j ? "phase " + j : "ready")};
132
+ });
133
+ this.ttl = D.el("text", {x: 0, y: 46 * f, "font-weight": 700}, svg);
134
+ this.l1 = D.el("text", {x: 0, y: 96 * f, "font-size": F(30), fill: "var(--fg)"}, svg);
135
+ this.l2 = D.el("text", {x: 0, y: 136 * f, "font-size": F(30), fill: "var(--fg)"}, svg);
136
+ this.lab = D.el("text", {x: 0, y: 190 * f, "font-size": F(26), fill: "var(--muted)"}, svg);
137
+ // 時計:「00:00」が左の幅に収まる大きさ。字の上端が「残り」の字に重ならないように下げる
138
+ var cz = Math.min(150 * f, LW / 3.0), cy = 190 * f + 14 + cz * 0.98, by = cy + 18 * f;
139
+ this.clock = D.el("text", {x: 0, y: cy.toFixed(1), "font-size": cz.toFixed(0), "font-weight": 700, style: "font-variant-numeric:tabular-nums"}, svg);
140
+ D.el("rect", {x: 0, y: by.toFixed(1), width: LW, height: 20 * f, rx: 10 * f, fill: "var(--line)"}, svg);
141
+ this.bar = D.el("rect", {x: 0, y: by.toFixed(1), width: 0, height: 20 * f, rx: 10 * f}, svg);
142
+ if (by + 20 * f > H - 40 * f) ctx.report("size", "[timer] the element is too low for the clock, the bar and the line under it (make it taller)");
143
+ this.foot = D.el("text", {x: 0, y: H - 4, "font-size": F(32), "font-weight": 700, fill: "var(--emph)"}, svg);
144
+ // 区切りの一覧
145
+ var n = this.P.length, top = 180 * f, rh = Math.min(48 * f, (H - top) / Math.max(n, 1));
146
+ if (rh < 34) ctx.report("size", "[timer] " + n + " phases do not fit in the list (make the element taller or use fewer phases)");
147
+ this.rows = this.P.map(function(p, j){
148
+ var y = top + j * rh, s = (j + 1) + (self.ja ? " " : " ") + self.span(p.sec) + (self.ja ? " " : " ") + (p.short || p.title);
149
+ var box = D.el("rect", {x: RX, y: y, width: Math.max(0, W - RX), height: Math.max(0, rh - 6), rx: 8, fill: "none", stroke: "none", "stroke-width": 2.5}, svg);
150
+ var tx = D.el("text", {x: RX + 14, y: y + rh / 2 + 7, "font-size": fit(s, W - RX - 28, F(28), "phase list entry")}, svg);
151
+ tx.textContent = s;
152
+ return {box: box, tx: tx};
153
+ });
154
+ this.RX = RX; this.W = W; this.H = H;
155
+ if (this.btns) Object.assign(this.btns.style, {left: RX + "px", top: Math.round(96 * f - 34) + "px"});
156
+ }
157
+ // 秒数の書き方:「3分」「20秒」「1分30秒」(英語は 3 min・20 s)
158
+ span(s){
159
+ var L = this.L, m = Math.floor(s / 60), r = s % 60;
160
+ return s < 60 ? s + L.sec : r === 0 ? m + L.min : m + L.min + (this.ja ? "" : " ") + r + L.sec;
161
+ }
162
+ clockText(s){ s = Math.max(0, Math.ceil(s - 1e-9)); return Math.floor(s / 60) + ":" + ("0" + (s % 60)).slice(-2); }
163
+ duration(k){ return k >= 1 && this.P[k - 1] ? this.P[k - 1].sec : 0; }
164
+ // 学会タイマーのようなベル(仕様 §8.4「Component sounds」):部品は音を鳴らさず、鳴らす時刻を宣言するだけ。鳴らすのは再生器
165
+ // (発表の再生で t が前へ越えたときだけ、Web Audio で合成。動画には同じ時刻で入る。延長は再生器がずらす)。
166
+ // bells は区切りの bells か、全体の bells:[{left: 残りの秒, count: 1〜3}]。書かなければ鳴らない。音だけに頼らず、時計と色でも示す
167
+ events(k){
168
+ var p = k >= 1 && this.P[k - 1];
169
+ if (!p) return [];
170
+ var bells = (p.bells || (this.data && this.data.bells) || []);
171
+ return bells.filter(function(b){ return b.left >= 0 && b.left <= p.sec; })
172
+ .map(function(b){ return {t: p.sec - b.left, sound: "bell", count: Math.max(1, Math.min(3, b.count || 1))}; })
173
+ .sort(function(a, b){ return a.t - b.t; });
174
+ }
175
+ // ---- 見る人の状態:区切りごとに延ばした秒数(−sec より短くはしない)
176
+ ext(k){ return this.video || this._printing ? 0 : this._ext[k] || 0; }
177
+ extend(dl){
178
+ var ctx = this._ctx, k = this._k;
179
+ if (this.video || !ctx || typeof ctx.extend !== "function" || !(k >= 1)) return;
180
+ var sec = this.P[k - 1].sec, cur = this._ext[k] || 0, el = this._t === Infinity ? sec + cur : Math.min(this._t || 0, sec + cur);
181
+ // 縮めるのは今の時刻まで(0:00 で終わる)。延ばすのは 1 時間まで
182
+ var next = Math.max(cur + dl, el - sec, -sec);
183
+ next = Math.min(next, 3600);
184
+ if (next === cur) return;
185
+ var r = ctx.extend(next - cur);
186
+ this._ext[k] = typeof r === "number" && isFinite(r) ? r : next;
187
+ this.redraw();
188
+ this.say.textContent = this.L.remaining + " " + this.clockText(sec + this._ext[k] - Math.min(el, sec + this._ext[k]));
189
+ this.dispatchEvent(new CustomEvent("egatari-input", {bubbles: true, detail: {step: k, extend: this._ext[k]}}));
190
+ }
191
+ reset(){
192
+ var had = Object.keys(this._ext).some(function(k){ return this._ext[k]; }, this);
193
+ this._ext = {};
194
+ if (had) this.dispatchEvent(new CustomEvent("egatari-input", {bubbles: true, detail: {step: this._k, extend: 0}}));
195
+ return had;
196
+ }
197
+ // 触った跡だけを戻す(ctx.reset):ボタンのフォーカスを外す。延長(見る人の入力)は残す
198
+ untouch(){
199
+ var a = document.activeElement;
200
+ if (a && a !== this && this.contains(a) && a.blur) a.blur();
201
+ }
202
+ // 入力のあとの描き直し:最後の (k, t) で paint だけを呼ぶ(render を通さないので、ctx.entered・ctx.reset を繰り返さない)
203
+ redraw(){ if (this._k !== undefined) this.paint(this._k, this._t, this._ctx); }
204
+ // +1 分・−1 分:実行系が ctx.extend を渡したときに初めて作る(渡さない実行系・動画では作らない)
205
+ buttons(){
206
+ if (this.btns || this.video) return;
207
+ var self = this, L = this.L, box = this.btns = document.createElement("div");
208
+ box.className = "tm-ctl";
209
+ Object.assign(box.style, {left: this.RX + "px", top: Math.round(96 * this.f - 34) + "px"});
210
+ [[L.minus, -60], [L.plus, 60]].forEach(function(b){
211
+ var e = document.createElement("button");
212
+ e.type = "button"; e.className = "tm-btn"; e.textContent = b[0]; e.setAttribute("aria-label", b[0]);
213
+ e.addEventListener("click", function(ev){ ev.stopPropagation(); self.extend(b[1]); if (ev.detail !== 0) e.blur(); });
214
+ e.addEventListener("keydown", function(ev){
215
+ var up = ev.key === "+", dn = ev.key === "-" || ev.key === "−";
216
+ if (up || dn){ ev.preventDefault(); ev.stopPropagation(); self.extend(up ? 60 : -60); }
217
+ });
218
+ box.appendChild(e);
219
+ });
220
+ this.appendChild(box);
221
+ }
222
+ render(k, t, ctx){
223
+ if (ctx.entered === true) this.reset();
224
+ if (ctx.reset) this.untouch();
225
+ // 描き直し(redraw)で reset・entered をもう一度使わないように、それを除いて覚える(extend などはそのまま)
226
+ this._k = k; this._t = t; this._ctx = Object.assign({}, ctx); delete this._ctx.reset; delete this._ctx.entered;
227
+ this.paint(k, t, this._ctx);
228
+ }
229
+ // (k, t) と延長の絵。ctx は render の ctx から reset・entered を除いたもの
230
+ paint(k, t, ctx){
231
+ var D = base, L = this.L, P = this.P, n = P.length, run = k >= 1 && P[k - 1];
232
+ var hasExt = !this.video && ctx && typeof ctx.extend === "function";
233
+ if (hasExt) this.buttons();
234
+ if (this.btns) this.btns.style.display = hasExt && run ? "" : "none";
235
+ // 延ばした合計は実行系が持つ(ctx.extend(0) は変えずに読むだけ。仕様 §8.4)。発表者の画面で延ばした分もこれでそろう
236
+ if (hasExt && run){ var r0 = ctx.extend(0); if (typeof r0 === "number" && isFinite(r0)) this._ext[k] = r0; }
237
+ var sec = run ? P[k - 1].sec : 0, end = sec + (run ? this.ext(k) : 0);
238
+ var el = !run ? 0 : t === Infinity ? end : Math.min(Math.max(0, t), end);
239
+ var rem = run ? end - el : this.total, finished = run && el >= end, warn = run && rem <= 60;
240
+ // fade(見せ方 0):区切りが始まると、題・説明・時計がフェードして現れる
241
+ var a = run && t !== Infinity ? D.prog(t, 0, 0.4) : 1;
242
+ var h = this.heads[run ? k : 0];
243
+ this.ttl.textContent = h.title; this.ttl.setAttribute("font-size", h.size);
244
+ this.ttl.style.fill = run ? "var(--term)" : "var(--emph)";
245
+ this.l1.textContent = h.lines[0] || ""; this.l2.textContent = h.lines[1] || "";
246
+ [this.ttl, this.l1, this.l2].forEach(function(e){ e.setAttribute("opacity", a.toFixed(3)); });
247
+ this.lab.textContent = !run ? L.total : finished ? L.done : L.remaining;
248
+ this.clock.textContent = this.clockText(rem);
249
+ this.clock.style.fill = !run ? "var(--muted)" : warn || finished ? "var(--emph)" : "var(--fg)";
250
+ // 最後の 10 秒は 1 秒おきに薄く(注目のため。動画・最後の状態では止まる。動きを減らす設定では実行系が最後の状態で描く)
251
+ var pulse = run && !finished && rem <= 10 && t !== Infinity && !this.video && Math.floor(t) % 2 === 1;
252
+ this.clock.setAttribute("opacity", (pulse ? 0.45 : a).toFixed(3));
253
+ this.bar.setAttribute("width", (this.LW * (run ? el / end : 0)).toFixed(1));
254
+ this.bar.style.fill = warn || finished ? "var(--emph)" : "var(--term)";
255
+ this.foot.textContent = !run ? L.start : finished ? (k < n ? L.next : L.end) : "";
256
+ this.rows.forEach(function(r, j){
257
+ var cur = run && j + 1 === k, done = run && j + 1 < k;
258
+ r.box.style.fill = cur ? "var(--term-tint)" : "none";
259
+ r.box.style.stroke = cur ? "var(--term)" : "none";
260
+ // 終わった区切りは --muted(薄くしても 4.5:1 は保つので、透明にはしない)
261
+ r.tx.style.fill = done ? "var(--muted)" : "var(--fg)";
262
+ r.tx.setAttribute("font-weight", cur ? "700" : "400");
263
+ });
264
+ var s = !run ? "" : finished ? h.title + (this.ja ? ":" : ": ") + L.done : h.title;
265
+ if (this._said !== s && !this.video){ this._said = s; this.say.textContent = s; }
266
+ }
267
+ };
268
+ });