egatari 0.6.14 → 0.6.16

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 (270) hide show
  1. package/CHANGELOG.md +62 -1
  2. package/README.ja.md +65 -64
  3. package/README.md +40 -39
  4. package/bin/egatari.mjs +3 -3
  5. package/components.lock.json +507 -153
  6. package/components2.lock.json +1710 -33
  7. package/kit/check-messages.mjs +105 -71
  8. package/kit/check.mjs +17 -11
  9. package/kit/core/article-messages.mjs +15 -15
  10. package/kit/core/article-render.mjs +1 -1
  11. package/kit/core/article-text.mjs +3 -1
  12. package/kit/core/build-core.mjs +23 -1
  13. package/kit/core/check-parity.mjs +2 -2
  14. package/kit/core/check-rules.mjs +12 -7
  15. package/kit/core/colab-core.mjs +2 -2
  16. package/kit/core/comment-core.mjs +6 -0
  17. package/kit/core/export-name.mjs +2 -2
  18. package/kit/core/geometry-check.mjs +363 -25
  19. package/kit/core/layout-scan.mjs +75 -5
  20. package/kit/core/live-policy.mjs +2 -2
  21. package/kit/core/live.mjs +2 -2
  22. package/kit/core/llm-fix.mjs +24 -13
  23. package/kit/core/llm-insert.mjs +11 -11
  24. package/kit/core/llm-outline.mjs +7 -7
  25. package/kit/core/llm-pack-assemble.mjs +5 -2
  26. package/kit/core/llm-pack-data.mjs +225 -39
  27. package/kit/core/llm-pack.mjs +3 -3
  28. package/kit/core/new-deck.mjs +17 -3
  29. package/kit/core/part-labels.mjs +6 -0
  30. package/kit/core/parts2.mjs +5 -5
  31. package/kit/core/player.mjs +18 -0
  32. package/kit/core/portable.mjs +26 -8
  33. package/kit/core/purposes.mjs +2 -2
  34. package/kit/core/ref-voice.mjs +1 -1
  35. package/kit/core/scorm.mjs +1 -1
  36. package/kit/core/sound-preferences.mjs +1 -1
  37. package/kit/core/theme-derive.mjs +209 -0
  38. package/kit/core/themes-list.mjs +1 -1
  39. package/kit/core/themes-lock.mjs +1 -1
  40. package/kit/core/tier-a.mjs +20 -8
  41. package/kit/deck.js +7 -4
  42. package/kit/instruction-version.json +1 -1
  43. package/kit/live.js +20 -20
  44. package/kit/player.json +1 -1
  45. package/kit/player.lock.json +2 -2
  46. package/kit/presenter.js +5 -3
  47. package/kit/templates/new-deck.mjs +6 -6
  48. package/kit/tools.js +13 -6
  49. package/kit/track.js +1 -1
  50. package/package.json +4 -2
  51. package/server/dev.mjs +3 -2
  52. package/server/editor-ui.js +28 -20
  53. package/server/hints.js +22 -2
  54. package/tts/yomi.yaml +8 -0
  55. package/vendor/components/CATALOG.md +21 -14
  56. package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/README.en.md +40 -0
  57. package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/index.js +408 -0
  58. package/vendor/components/sha256/0396a1895978803ae342b7f598f187b17ead47800e8f8317a5cb041111349813/index.js +278 -0
  59. package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/README.en.md +26 -0
  60. package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/index.js +322 -0
  61. package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/README.en.md +54 -0
  62. package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/index.js +470 -0
  63. package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/README.en.md +18 -0
  64. package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/index.js +279 -0
  65. package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/README.en.md +31 -0
  66. package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/index.js +267 -0
  67. package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/README.en.md +53 -0
  68. package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/index.js +171 -0
  69. package/vendor/components/sha256/1117758820dc561f41cf9d1cc0bab8cf3173cde7771ac10a12b94c96007c0f55/index.js +268 -0
  70. package/vendor/components/sha256/137017ad452afe209bdff81bc02ffae99c6b60a1c4aed2383515974f65511ff2/index.js +205 -0
  71. package/vendor/components/sha256/1a1471ba5f68e54304825a64e736afeda421e3763cdcbcdab2e45509562a0291/index.js +607 -0
  72. package/vendor/components/sha256/1b15fcc12b2fa43821e6299e87aae31aa69dbbc5a0d1b80088a5d7c5f8b8f7f5/index.js +429 -0
  73. package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/README.en.md +23 -0
  74. package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/index.js +147 -0
  75. package/vendor/components/sha256/21c099461befc0d382ddfe982f2a6cd8eeb6dd731252164ac619525e4bacdf0d/index.js +242 -0
  76. package/vendor/components/sha256/2352e0e22460f4a3c46dca6cef27cd9c63f161a411f1cf56c75c585e9124503c/index.js +315 -0
  77. package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/README.en.md +53 -0
  78. package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/index.js +171 -0
  79. package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/README.en.md +38 -0
  80. package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/index.js +414 -0
  81. package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/README.en.md +45 -0
  82. package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/index.js +211 -0
  83. package/vendor/components/sha256/2f111b900898579b3ec1611c2110db336a46d9133171a0cbb125ee37bd1f24f8/index.js +592 -0
  84. package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/README.en.md +45 -0
  85. package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/index.js +211 -0
  86. package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/README.en.md +20 -0
  87. package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/index.js +310 -0
  88. package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/README.en.md +35 -0
  89. package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/index.js +179 -0
  90. package/vendor/components/sha256/3af0b84b1799fc64ec74d6da9cbd343eccd89e8a11c81bfb444562c911284442/index.js +342 -0
  91. package/vendor/components/sha256/3c69bf3b3c6b9f76048fbc0839b3aa9699723570086d3d44bac799230ed6de5b/index.js +121 -0
  92. package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/README.en.md +37 -0
  93. package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/index.js +501 -0
  94. package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/README.en.md +38 -0
  95. package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/index.js +414 -0
  96. package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/README.en.md +30 -0
  97. package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/index.js +305 -0
  98. package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/README.en.md +31 -0
  99. package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/index.js +236 -0
  100. package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/README.en.md +21 -0
  101. package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/index.js +108 -0
  102. package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/README.en.md +28 -0
  103. package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/index.js +213 -0
  104. package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/README.en.md +35 -0
  105. package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/index.js +179 -0
  106. package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/README.en.md +53 -0
  107. package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/index.js +171 -0
  108. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ABCJS-ADAPTER.md +101 -0
  109. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/LICENSE-abcjs.txt +21 -0
  110. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/chords.json +89 -0
  111. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/doremi.json +261 -0
  112. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/extras.json +192 -0
  113. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/kaeru.json +521 -0
  114. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/rhythm.json +248 -0
  115. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ties.json +360 -0
  116. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/index.js +508 -0
  117. package/vendor/components/sha256/59996a56df462b36e24a928d4397c9308d9e39ad8224ebd19fb5c981608ef458/index.js +521 -0
  118. package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/README.en.md +30 -0
  119. package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/index.js +305 -0
  120. package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/README.en.md +30 -0
  121. package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/index.js +192 -0
  122. package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/README.en.md +20 -0
  123. package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/index.js +307 -0
  124. package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/README.en.md +24 -0
  125. package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/index.js +554 -0
  126. package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/README.en.md +25 -0
  127. package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/index.js +316 -0
  128. package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/README.en.md +18 -0
  129. package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/index.js +279 -0
  130. package/vendor/components/sha256/624acb997c4975ace65570b529b3ba00baa421c80ecb7fc80f392a64e8c573a7/index.js +107 -0
  131. package/vendor/components/sha256/62602488ee33dd4bdef8516de16da5ab27d7f7265d5041681beab80e08f1d482/index.js +97 -0
  132. package/vendor/components/sha256/67eaf344bddac79b74ed03fdcd70285c7b52b160e6c5ffbd6897848179aa5230/index.js +818 -0
  133. package/vendor/components/sha256/682c9c8871eccd19ff1264e0323a2e4c5798b0488b612ba0339c6fe85aab5914/index.js +926 -0
  134. package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/README.en.md +51 -0
  135. package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/index.js +230 -0
  136. package/vendor/components/sha256/72138936ed0b8fd3cb0214ae7ed250ae3f1f8b21ed6fd593544947774064ba0d/index.js +250 -0
  137. package/vendor/components/sha256/74c1a0f3ed1370c5003aa5770ee28cea2ce994d415680116a92fdbcd5854ba62/index.js +198 -0
  138. package/vendor/components/sha256/76125035eb153b98befa9c735bcd9fc4f99f774dc1d082fdae40acaadfe7d95b/index.js +818 -0
  139. package/vendor/components/sha256/7728cf7dde88a6688aba0ed70f23f7e21362a147beac09c1fa1a4b773e08e93b/index.js +354 -0
  140. package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/README.en.md +23 -0
  141. package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/index.js +289 -0
  142. package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/README.en.md +31 -0
  143. package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/index.js +236 -0
  144. package/vendor/components/sha256/7d50e50fbb6c5ec636b62509bd88ddaac1870e0522cf11bcc293ce924d48072d/index.js +312 -0
  145. package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/README.en.md +42 -0
  146. package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/index.js +549 -0
  147. package/vendor/components/sha256/87fc302c41b2bfeea88951ed689ec01b4dc79218c4bc69b310dc2228dfa2e153/index.js +926 -0
  148. package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/README.en.md +24 -0
  149. package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/index.js +103 -0
  150. package/vendor/components/sha256/89c8c16788e24df17920542ed6eb6557dea4a10e835de8fe839e439ccbba8014/index.js +69 -0
  151. package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/README.en.md +44 -0
  152. package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/index.js +304 -0
  153. package/vendor/components/sha256/8d9af78aef44ad2f98101c67d32473373d39725a09c923969aa621d5f5b124bb/index.js +121 -0
  154. package/vendor/components/sha256/8f861d71df72a82be86a3e63abf7d69bbab5aac6fa68be6e077c4e19c3519ed8/index.js +312 -0
  155. package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/README.en.md +54 -0
  156. package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/index.js +470 -0
  157. package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/README.en.md +24 -0
  158. package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/index.js +214 -0
  159. package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/README.en.md +33 -0
  160. package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/index.js +390 -0
  161. package/vendor/components/sha256/9289efef4a75afe011e54a17e34db08cfb16a450b2e0653e6a98525495cfba99/index.js +315 -0
  162. package/vendor/components/sha256/93256a923199ea51108cdb7491c3c96f376dbef15b64cbf1a1aa7cc5726b4970/index.js +429 -0
  163. package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/README.en.md +24 -0
  164. package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/index.js +550 -0
  165. package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/README.en.md +28 -0
  166. package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/index.js +213 -0
  167. package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/README.en.md +40 -0
  168. package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/index.js +348 -0
  169. package/vendor/components/sha256/97c074a5473618c65f4c23263f056870a0b7940e73475f2a1f32f68c08d8eb0f/index.js +198 -0
  170. package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/README.en.md +66 -0
  171. package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/index.js +984 -0
  172. package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/README.en.md +34 -0
  173. package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/index.js +244 -0
  174. package/vendor/components/sha256/a18b2b15d00c76462a43823b5c270c7ddd7c31794da9c236f74f20f80ec2ffdb/index.js +354 -0
  175. package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/README.en.md +32 -0
  176. package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/index.js +222 -0
  177. package/vendor/components/sha256/a979207c60fbd2a12cb557297eb0217eb098d660de684530a0f43d0d9c64e6ef/index.js +312 -0
  178. package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/README.en.md +34 -0
  179. package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/index.js +244 -0
  180. package/vendor/components/sha256/af7ed69b8969f6da14784b6e9d26e4dfd20147772ea172a99bd936a71be10fcd/index.js +278 -0
  181. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ABCJS-ADAPTER.md +101 -0
  182. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/LICENSE-abcjs.txt +21 -0
  183. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/chords.json +89 -0
  184. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/doremi.json +261 -0
  185. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/extras.json +192 -0
  186. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/kaeru.json +521 -0
  187. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/rhythm.json +248 -0
  188. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ties.json +360 -0
  189. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/index.js +508 -0
  190. package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/README.en.md +66 -0
  191. package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/index.js +990 -0
  192. package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/README.en.md +24 -0
  193. package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/index.js +550 -0
  194. package/vendor/components/sha256/b8096d7a60609520981273673761a110e40e3bdf52a7ab5548363b20e16f6e93/index.js +404 -0
  195. package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/README.en.md +32 -0
  196. package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/index.js +222 -0
  197. package/vendor/components/sha256/bd8e3893df02411deccc1d6d7b02292ca0d59dfeddfafcf99419430981572c82/index.js +351 -0
  198. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ABCJS-ADAPTER.md +101 -0
  199. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/LICENSE-abcjs.txt +21 -0
  200. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/chords.json +89 -0
  201. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/doremi.json +261 -0
  202. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/extras.json +192 -0
  203. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/kaeru.json +521 -0
  204. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/rhythm.json +248 -0
  205. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ties.json +360 -0
  206. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/index.js +508 -0
  207. package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/README.en.md +31 -0
  208. package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/index.js +267 -0
  209. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/LICENSE-strokesvg.txt +115 -0
  210. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/OFL.txt +93 -0
  211. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/index.js +749 -0
  212. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/strokes-CHANGES.md +20 -0
  213. package/vendor/components/sha256/c791e69e722f64146242f97acb29a341160d0c327cfe1d76307954d80e70db85/index.js +268 -0
  214. package/vendor/components/sha256/c8c0de41d603b61c6ec4dc1da5b50559e213dd1f3693ee5019df858016fd6daf/index.js +747 -0
  215. package/vendor/components/sha256/c99d4f2ab443484b9f462e405c72ea4794838b88f8823f27c606d12cbbedb996/index.js +404 -0
  216. package/vendor/components/sha256/cbde046e30c35db60259911a88e2ae0bedaf545e29b1da8b8ce13bc602a33c19/index.js +465 -0
  217. package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/README.en.md +51 -0
  218. package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/index.js +228 -0
  219. package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/README.en.md +35 -0
  220. package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/index.js +179 -0
  221. package/vendor/components/sha256/cf0985ffcd8e7cbe2175ddb9a4342b2a4aa3f322794188fc99af8789b494460d/index.js +521 -0
  222. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/LICENSE-strokesvg.txt +115 -0
  223. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/OFL.txt +93 -0
  224. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/index.js +749 -0
  225. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/strokes-CHANGES.md +20 -0
  226. package/vendor/components/sha256/d01dc7fd78d08dd720ed86b39d7877dc0913d72e914036088a86af2df2faee52/index.js +484 -0
  227. package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/README.en.md +24 -0
  228. package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/index.js +214 -0
  229. package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/README.en.md +31 -0
  230. package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/index.js +271 -0
  231. package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/README.en.md +25 -0
  232. package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/index.js +316 -0
  233. package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/README.en.md +23 -0
  234. package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/index.js +120 -0
  235. package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/README.en.md +40 -0
  236. package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/index.js +405 -0
  237. package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/README.en.md +66 -0
  238. package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/index.js +984 -0
  239. package/vendor/components/sha256/ddd4b9cbbc282cbb3117ff662e1a14ecdb3cc7c16072a574418ec6a6eecef4d8/index.js +107 -0
  240. package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/README.en.md +22 -0
  241. package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/index.js +145 -0
  242. package/vendor/components/sha256/e2da948daac7bfac158857877b5a6932dbd2369e73901abcef118c92dd20b725/index.js +747 -0
  243. package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/README.en.md +42 -0
  244. package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/index.js +268 -0
  245. package/vendor/components/sha256/e653a4da80f7761442dc5b504ea5b0700fd0acf1979beeff56122cfdb3d4654c/index.js +607 -0
  246. package/vendor/components/sha256/ea217c6821e931b2d8474bf56d38f2dcc89ec705fe1d276f313e1c7e8db2b98a/index.js +233 -0
  247. package/vendor/components/sha256/ea2e4e24838574f607879c7d05556281258c018331e4da3e6f3a5263173f2e99/index.js +75 -0
  248. package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/README.en.md +42 -0
  249. package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/index.js +549 -0
  250. package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/README.en.md +44 -0
  251. package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/index.js +203 -0
  252. package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/README.en.md +34 -0
  253. package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/index.js +244 -0
  254. package/vendor/components/sha256/fa1a09c10181456143d125d68dbbdcacde6bab2e4a2b3e573367103ce28ebf55/index.js +228 -0
  255. package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/README.en.md +51 -0
  256. package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/index.js +228 -0
  257. package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/README.en.md +23 -0
  258. package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/index.js +147 -0
  259. package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/README.en.md +20 -0
  260. package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/index.js +307 -0
  261. package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/README.en.md +26 -0
  262. package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/index.js +322 -0
  263. package/vendor/components-2/manifest-2.12.0.json +2348 -0
  264. package/vendor/components-2/manifest-2.13.0.json +2477 -0
  265. package/vendor/components-2/manifest-2.14.0.json +2460 -0
  266. package/vendor/components-2/manifest-2.14.1.json +2460 -0
  267. package/vendor/components-2/manifest-2.15.0.json +2460 -0
  268. package/vendor/egatari-spec/SOURCE.json +3 -3
  269. package/vendor/egatari-spec/schema/deck-meta.schema.json +16 -1
  270. package/vendor/egatari-spec/schema/egatari-metadata.schema.json +17 -2
@@ -0,0 +1,607 @@
1
+ // m-codetree:ハフマン木で 2 値の系列を復号する(ファクシミリの MH 符号:白と黒のランを交互に読む)
2
+ // <m-codetree style="height:530px"><script type="application/json">
3
+ // {"table": [{"run": 2, "white": "0111", "black": "11"}, {"run": 64, "white": "11011", "black": "0000001111"}, …],
4
+ // "bits": "11011011111"}
5
+ // (JSON の終わり)</m-codetree>
6
+ // 木は表から作る(根の左が白の木、右が黒の木。枝の 0 が左、1 が右)。表は [{run, white, black}] か {"white": {"符号": ラン}, "black": {…}}。
7
+ // run が 64 以上はメイクアップ符号(同じ色のまま、次に終端符号が続く)、64 未満は終端符号(次は反対の色)、"EOL" は行の終わり(次は白)。
8
+ // 1 段階 = 1 符号語。段階の中で読む 1 ビットごとに cue(口述原稿の {cue})。最後の段階は「まとめ」(復号した符号語の道をすべて出す)。
9
+ // 画面:上に符号の系列と読む位置、中に木(今の色の木だけを広げ、ほかは畳む)、下に復号した画素の並び(ランの長さだけの白・黒の升目)。
10
+ // 段階の決め方:1 ビット 1 段階にすると口述原稿が 1 ビット 1 行に細切れになるので、1 符号語 = 1 段階とし、ビットは段階の中の cue にした
11
+ // (cues(k) は読むビットごとの時刻。原稿に {cue} をビットの数だけ書けば読む位置が言葉に合い、書かなければ動きの長さのまま)。
12
+ // 段階 0 は白の木だけを広げた初めの姿。段階 k の中:木を広げ直す(move 秒)→ 根から色の木へ → 1 ビットごとに 1 本(bit 秒)→ 葉に着く →
13
+ // 画素の升目を塗る(fill 秒)。最後の段階(summary="false" で外す)は両方の木と復号したすべての道(印刷・静止の姿)
14
+ // data-mark(頭の ct は属性 mark で変える):ct-root、ct-w / ct-b(色の木の根)、ct-w-1101(白の木の符号 1101 の節・葉)、ct-w64 / ct-b2 / ct-weol
15
+ // (葉の数字)、ct-bit-3(系列の 3 桁目)、ct-cw-2(2 つ目の符号語の括弧と結果)、ct-run-1(1 つ目の画素のラン)、ct-scan(画素の並び)、ct-bad(表にない枝)、
16
+ // ct-crumb(窓の上の「ここまで」)
17
+ // 深い木(黒の符号は 13 ビットまで):入らなければ window 段の窓だけを見せ、たどる点を追って木を下から上へ流す(窓の位置も (k, t) だけで決まる)。
18
+ // 窓では木をたどる道を背骨にして並べ直し(道から分かれた枝は反対の側に三角で畳む)、窓を横にも動かして道を真ん中に置く。
19
+ // 親が窓の上にある枝は描かない(入ってくる道だけを上の縁から描く)。窓の上に「黒の木:ここまで 0000 0110」。window="auto"(既定)は段の間が 44 px より狭くなるときだけ流す。
20
+ // まとめの段階は窓を使わず、復号したすべての道の木を部品の高さに詰めて描く(段の間 SUM_GAP px 以上のとき。印刷・台本の小さい絵は最後の姿だけなので)。
21
+ // それより狭ければ、いちばん深い道の窓にして layout で知らせる。窓の段の間が 24 px より狭いときも layout で知らせる。最後の姿(t = Infinity)では窓の縁で薄れない
22
+ // 画面の文言(NAMES/NAMES_EN)は ctx.lang の日英に従う(ja なら日本語、それ以外は英語)。JSON の labels で上書きできる:
23
+ // white black start read makeup term eol invalid incomplete dangling done scan crumb({c} は色、{n} は桁)
24
+ // 復号の規則は codetree-core(試験は tools/test-codetree.mjs)
25
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・prog・lerp・previewOpacity と、表・木・復号の codetree-core を使い、
26
+ // プレイヤーのグローバルは使わない
27
+ egatariParts.define({name: "codetree", version: "2.0.7", requires: {base: "1.3.0", "codetree-core": "1.0.0"}, element: "m-codetree"}, function(deps){
28
+ "use strict";
29
+ var base = deps.base;
30
+ var D = base;
31
+
32
+ // ---------------------------------------------------------------- 表・木・復号(codetree-core)
33
+ var CORE = deps["codetree-core"];
34
+ var build = CORE.build, decode = CORE.decode, runs = CORE.runs;
35
+ var COLORS = ["white", "black"]; // 色の木の順(codetree-core と同じ)
36
+
37
+
38
+ // ---------------------------------------------------------------- 部品
39
+ // 表示の文字(ctx.lang、見る人の言語ではなく文書の言語)。子の JSON の labels が勝つ
40
+ var NAMES = {white: "白", black: "黒", start: "最初は白の木から読む", read: "{c}の木をたどる", makeup: "メイクアップ符号:次も{c}",
41
+ term: "終端符号:次は{c}", eol: "行の終わり:次は白", invalid: "表にない符号({n} 桁目)", incomplete: "系列が符号の途中で終わる",
42
+ dangling: "メイクアップ符号の後に終端符号がない", done: "復号完了", scan: "画素", crumb: "{c}の木:ここまで"};
43
+ var NAMES_EN = {white: "white", black: "black", start: "Start with the white tree", read: "Following the {c} tree", makeup: "Make-up code: {c} continues",
44
+ term: "Terminating code: next is {c}", eol: "End of line: next is white", invalid: "Not in the table (digit {n})", incomplete: "The sequence ends mid-code",
45
+ dangling: "Make-up code with no terminating code after it", done: "Decoded", scan: "Pixels", crumb: "{c} tree: so far"};
46
+ var LETTER = {white: "w", black: "b"};
47
+ // 字の幅の見積もり(字の読み込みによらず同じ配置にする)
48
+ // 誤りの段階でたどれる道(表にない枝の手前まで)
49
+ function errPath(e){ return e.kind === "invalid" ? e.code.slice(0, -1) : e.code; }
50
+ // 枝の字の位置:親 a から子 b への線の f の所から、線に垂直に外側へ off px(字の中心。y は字の基線)
51
+ function labelAt(a, b, f, off){
52
+ var dx = b.x - a.x, dy = b.y - a.y, L = Math.hypot(dx, dy) || 1, nx = dx < 0 ? -dy / L : dy / L, ny = -Math.abs(dx) / L;
53
+ return {x: a.x + dx * f + nx * off, y: a.y + dy * f + ny * off + 8};
54
+ }
55
+ function fmt0(s, c){ return String(s).replace("{c}", c); }
56
+ // まとめの段階で、すべての道の木を窓なしで描く段の間の下限(px)。窓の段の間の下限(読める大きさ)は WIN_GAP
57
+ var SUM_GAP = 20, WIN_GAP = 40; // 窓の段の間は 0・1 の字(24 px)が枝の線にかからない広さ
58
+ // 字の幅(base の textWidth:font の要素の字で測った幅)
59
+ function textW(s, fs, font){ return base.textWidth(s, fs, {font: font}); }
60
+
61
+ return class extends base.MotionElement {
62
+ static partName = "codetree"; // the registry name (define meta name), for report prefixes
63
+ static shape = {
64
+ schema: {type: "object", additionalProperties: false, required: ["table"], properties: {
65
+ table: {type: ["array", "object"], items: {type: "object", required: ["run"], properties: {run: {type: ["integer", "string"]}, white: {type: "string"}, black: {type: "string"}}},
66
+ properties: {white: {type: "object"}, black: {type: "object"}}},
67
+ bits: {type: "string"}, labels: {type: "object"}}},
68
+ example: {table: [{run: 2, white: "0111", black: "11"}, {run: 64, white: "11011", black: "0000001111"}], bits: "110110111"},
69
+ };
70
+ static props = {
71
+ bits: {type: "string", default: "", doc: "復号する系列(JSON の bits より先)"},
72
+ depth: {type: "number", default: 4, doc: "畳まずに見せる深さ(読む道はいつも広げる)"},
73
+ bit: {type: "number", default: 0.6, doc: "1 ビットを読む秒数"},
74
+ move: {type: "number", default: 0.6, doc: "木を広げ直す秒数"},
75
+ fill: {type: "number", default: 0.8, doc: "画素の升目を塗る秒数"},
76
+ summary: {type: "bool", default: true, doc: "最後にまとめのステップを足す"},
77
+ mark: {type: "string", default: "ct", doc: "data-mark の頭"},
78
+ window: {type: "string", default: "auto", doc: "木を見せる段の数(auto:入らなければ、たどる点を追って木を流す)"},
79
+ };
80
+ // 復号と段階の計画(データだけから決める)
81
+ model(){
82
+ if (this._model) return this._model;
83
+ var d = this.data || {}, P = this.props;
84
+ var trees = build(d.table), r = decode(trees, P.bits || d.bits || "");
85
+ var plan = r.tokens.map(function(t, i){ return {type: "tok", tok: i}; });
86
+ if (r.error && r.error.kind !== "dangling") plan.push({type: "err"});
87
+ if (P.summary && plan.length) plan.push({type: "sum"});
88
+ return (this._model = {trees: trees, dec: r, plan: plan, runs: runs(r.tokens)});
89
+ }
90
+ get steps(){
91
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
92
+ return this.model().plan.length;
93
+ }
94
+ // 段階 k(1〜)の時刻:s(i) は道の i 本目(0 本目は根から色の木へ)を引き始める時刻。cue は読む 1 ビットごと
95
+ times(k){
96
+ var m = this.model(), P = this.props, p = m.plan[k - 1];
97
+ if (!p) return null;
98
+ var nb = p.type === "tok" ? m.dec.tokens[p.tok].code.length : p.type === "err" ? m.dec.error.code.length : 0;
99
+ var s = function(i){ return P.move + i * P.bit; };
100
+ var A = s(nb) + 0.7 * P.bit; // 葉に着く
101
+ return {nb: nb, s: s, A: A, F0: A + 0.15, F1: A + 0.15 + P.fill};
102
+ }
103
+ duration(k){
104
+ var m = this.model(), p = m.plan[k - 1], T = this.times(k);
105
+ if (!p) return 0;
106
+ if (p.type === "sum") return this.props.move + 1.1;
107
+ if (p.type === "err") return T.A + 0.5;
108
+ return T.F1 + 0.1;
109
+ }
110
+ cues(k){
111
+ var p = this.model().plan[k - 1], T = this.times(k);
112
+ if (!p || p.type === "sum") return null;
113
+ var c = [];
114
+ for (var i = 1; i <= T.nb; i++) c.push(+T.s(i).toFixed(3));
115
+ return c;
116
+ }
117
+ // 段階 k の木の形:見せる節の位置と種類(int 広げた節・fan 畳んだ節・leaf 葉)
118
+ layoutFor(k){
119
+ var m = this.model(), p = k ? m.plan[k - 1] : null, dec = m.dec;
120
+ var focus, paths = {white: [], black: []}, both = false, cur = null;
121
+ if (!p){ focus = "white"; }
122
+ else if (p.type === "tok"){ var t = dec.tokens[p.tok]; focus = t.color; paths[focus].push(t.code); cur = {color: focus, code: t.code}; }
123
+ else if (p.type === "err"){ focus = dec.error.color; var ep = errPath(dec.error); paths[focus].push(dec.error.code); cur = {color: focus, code: ep, bad: dec.error.kind === "invalid" ? dec.error.code : null}; }
124
+ else {
125
+ both = true;
126
+ dec.tokens.forEach(function(t){ paths[t.color].push(t.code); });
127
+ if (dec.error && dec.error.kind !== "dangling") paths[dec.error.color].push(dec.error.code);
128
+ }
129
+ var W = this.W, G = this.G, self = this;
130
+ var spine = function(sp, a){
131
+ var nodes = {}, ghosts = {}, maxLv = 1;
132
+ var put = function(o){ nodes[o.id] = o; maxLv = Math.max(maxLv, o.lv); return o; };
133
+ var r = put({id: "r", lv: 0, kind: "int", kids: [], c: null, code: "", x: 0});
134
+ var pc = sp ? sp.color : "white";
135
+ COLORS.forEach(function(c){
136
+ var n = m.trees[c], d = c === "white" ? -1 : 1;
137
+ r.kids.push(put({id: LETTER[c], c: c, code: "", lv: 1, parent: "r", leaf: null, kids: [], kind: c === pc ? "int" : "fan", x: d * a}));
138
+ });
139
+ var node = m.trees[pc], o = nodes[LETTER[pc]], code = sp ? sp.code : "";
140
+ for (var i = 0; i < code.length && node && !node.leaf; i++){
141
+ var b = +code[i], dir = b ? 1 : -1, nx = null;
142
+ o.kind = "int";
143
+ [b, 1 - b].forEach(function(bb){
144
+ var kid = node.kids[bb], id = o.id + bb, x = o.x + (bb === b ? dir : -dir) * a;
145
+ if (!kid){ var g = {id: id, lv: o.lv + 1, ghost: true, kids: [], x: x}; ghosts[id] = g; return; }
146
+ var k2 = put({id: id, c: pc, code: kid.code, lv: o.lv + 1, parent: o.id, leaf: kid.leaf, kids: [], kind: kid.leaf ? "leaf" : "fan", x: x});
147
+ o.kids.push(k2);
148
+ if (bb === b) nx = k2;
149
+ });
150
+ node = node.kids[b]; o = nx;
151
+ if (!o) break;
152
+ }
153
+ return {nodes: nodes, slots: [], maxLv: maxLv, ghosts: ghosts};
154
+ };
155
+ var make = function(depth){
156
+ var nodes = {}, slots = [], maxLv = 1, ghosts = {};
157
+ var open = function(c, n){
158
+ if (n.leaf) return false;
159
+ if (!both && c !== focus) return false;
160
+ var onPath = paths[c].some(function(q){ return q.length > n.code.length && q.slice(0, n.code.length) === n.code; });
161
+ if (onPath) return true;
162
+ return n.code.length < depth;
163
+ };
164
+ var visit = function(c, n, id, lv, parent){
165
+ var o = {id: id, c: c, code: n.code, lv: lv, parent: parent, leaf: n.leaf, kids: []};
166
+ nodes[id] = o; maxLv = Math.max(maxLv, lv);
167
+ if (open(c, n)){
168
+ o.kind = "int";
169
+ // 表にない枝は空きの場所(ghost)にする:1 の子だけでも右に寄り、誤りの × をそこに置ける
170
+ [0, 1].forEach(function(b){
171
+ if (n.kids[b]) o.kids.push(visit(c, n.kids[b], id + b, lv + 1, id));
172
+ else { var g = {id: id + b, lv: lv + 1, ghost: true, kids: []}; ghosts[id + b] = g; slots.push(g); o.kids.push(g); }
173
+ });
174
+ if (!o.kids.length){ o.kind = "fan"; slots.push(o); }
175
+ } else { o.kind = n.leaf ? "leaf" : "fan"; slots.push(o); }
176
+ return o;
177
+ };
178
+ nodes.r = {id: "r", lv: 0, kind: "int", kids: [], c: null, code: ""};
179
+ COLORS.forEach(function(c){ nodes.r.kids.push(visit(c, m.trees[c], LETTER[c], 1, "r")); });
180
+ return {nodes: nodes, slots: slots, maxLv: maxLv, ghosts: ghosts};
181
+ };
182
+ var d = Math.max(1, this.props.depth), L = make(d);
183
+ while (d > 1 && W / L.slots.length < 64){ d--; L = make(d); }
184
+ var avail = G.treeBottom - G.treeTop - 44, wp = String(this.props.window || "auto").trim(), nwin = /^\d+$/.test(wp) ? Math.max(2, +wp) : 0;
185
+ var follow = nwin ? L.maxLv > nwin : avail / L.maxLv < 44;
186
+ // まとめ(both)は、すべての道の木(make の L)が段の間 SUM_GAP 以上で入るなら窓を使わない。入らなければいちばん深い道の窓(mount が知らせる)
187
+ var sumGap = Math.min(78, avail / L.maxLv), sumLv = L.maxLv;
188
+ if (both && follow && sumGap >= SUM_GAP) follow = false;
189
+ // 窓で追うときは、木の幅を部品に合わせず、枠の幅を決めて並べ、窓を横にも動かす(render が今の節を真ん中に置く)
190
+ // 窓で追うときは、たどる道を背骨にして並べ直す:道の子は 0 なら左・1 なら右へ a px、道から分かれた枝は反対の側に畳んで置く。
191
+ // 窓を横にも動かし(render が今の節を真ん中に置く)、窓の中を今の道のまわりに使う
192
+ var sw = W / L.slots.length;
193
+ if (follow){
194
+ var sp = cur ? {color: cur.color, code: cur.bad || cur.code} : null;
195
+ if (!sp){ COLORS.forEach(function(c){ paths[c].forEach(function(q){ if (!sp || q.length > sp.code.length) sp = {color: c, code: q}; }); }); }
196
+ L = spine(sp, Math.min(150, W / 7.5));
197
+ } else {
198
+ L.slots.forEach(function(o, i){ o.x = (i + 0.5) * sw; });
199
+ var px = function(o){ if (o.x === undefined){ o.kids.forEach(px); o.x = (o.kids[0].x + o.kids[o.kids.length - 1].x) / 2; } return o.x; };
200
+ px(L.nodes.r);
201
+ }
202
+ // 段の間:葉の数字と畳んだ節の三角の分を下に空ける
203
+ // 木が入らなければ(段の間が 44 px より狭くなる、または段の数が属性 window より多い)、win 段の窓だけを見せ、
204
+ // たどる点を追って窓を下へ流す(窓の上は「ここまで」の行)。段の位置は y0 + (lv − cam) × gap(cam は render が (k, t) から決める)
205
+ L.follow = follow;
206
+ if (!L.follow){ L.y0 = G.treeTop; L.win = L.maxLv; L.gap = Math.min(78, avail / L.maxLv); }
207
+ else { L.y0 = G.treeTop + 44; var av2 = G.treeBottom - 44 - L.y0; L.win = nwin || Math.max(2, Math.floor(av2 / 56)); L.gap = av2 / L.win; }
208
+ L.camMax = Math.max(0, L.maxLv - L.win);
209
+ var gap = L.gap;
210
+ Object.keys(L.nodes).forEach(function(id){ var o = L.nodes[id]; o.y = L.y0 + o.lv * gap; });
211
+ Object.keys(L.ghosts).forEach(function(id){ var o = L.ghosts[id]; o.y = L.y0 + o.lv * gap; });
212
+ // まとめで窓を合わせる道(いちばん深い道)
213
+ L.deep = null;
214
+ COLORS.forEach(function(c){ paths[c].forEach(function(q){ if (!L.deep || q.length > L.deep.code.length) L.deep = {color: c, code: q}; }); });
215
+ // 0 と 1 を書く枝:今の道(とまとめのすべての道)の節の 2 つの子へ。根から色の木への枝はいつも
216
+ var lab = {w: 1, b: 1};
217
+ COLORS.forEach(function(c){ paths[c].forEach(function(q){ for (var i = 0; i < q.length; i++){ var pre = LETTER[c] + q.slice(0, i); lab[pre + "0"] = 1; lab[pre + "1"] = 1; } }); });
218
+ if (cur && cur.bad){ var pre = LETTER[cur.color] + cur.code; lab[pre + "0"] = 1; lab[pre + "1"] = 1; }
219
+ L.lab = lab; L.sw = sw; L.gap = gap; L.cur = cur; L.paths = paths; L.both = both; L.focus = focus; L.sumGap = sumGap; L.sumLv = sumLv;
220
+ return L;
221
+ }
222
+ // 窓の位置(段の数で。0 は根が窓の上の段):たどる点の段 λ の 1 段下までが窓に入るように、λ から滑らかに決める
223
+ // 横は、たどる点(まとめはいちばん深い道の葉)を真ん中に置く:{lv: 窓の上の段, x: 左へずらす px}
224
+ camAt(k, t){
225
+ var L = this.lay[k];
226
+ if (!L.follow) return {lv: 0, x: 0};
227
+ var p = k ? this.model().plan[k - 1] : null, lam = 0, path = null;
228
+ if (p && (p.type === "tok" || p.type === "err")){
229
+ var T = this.times(k), P = this.props, n = L.cur.code.length + 1;
230
+ for (var i = 0; i < n; i++) lam += D.prog(t, T.s(i), 0.7 * P.bit);
231
+ path = L.cur;
232
+ var lv = Math.max(0, Math.min(L.camMax, lam + 1 - L.win));
233
+ if (L.cur.bad) lv = Math.max(0, Math.min(L.camMax, lam + 0.6 * D.prog(t, T.s(T.nb), 0.3) + 1 - L.win));
234
+ } else if (p && L.deep){ lam = L.deep.code.length + 1; path = L.deep; lv = Math.max(0, Math.min(L.camMax, lam + 1 - L.win)); }
235
+ else lv = 0;
236
+ // 道の節の x を λ で補う
237
+ var ids = ["r"];
238
+ if (path){ ids.push(LETTER[path.color]); for (var j = 1; j <= path.code.length; j++) ids.push(LETTER[path.color] + path.code.slice(0, j)); }
239
+ var xAt = function(u){
240
+ u = Math.max(0, u);
241
+ var i0 = Math.min(ids.length - 1, Math.floor(u)), i1 = Math.min(ids.length - 1, i0 + 1), f = Math.min(1, u - i0);
242
+ return D.lerp(L.nodes[ids[i0]].x, L.nodes[ids[i1]].x, f);
243
+ };
244
+ // 真ん中に置くのは、たどる点と、窓の上の段の道の節の中ほど(道が片側へ寄っても、窓の中の道が真ん中に来る)
245
+ var x = (xAt(lam) + xAt(Math.max(lv, lam - L.win + 1))) / 2;
246
+ return {lv: lv, x: x - this.W / 2};
247
+ }
248
+ mount(ctx){
249
+ var D2 = D, P = this.props, self = this, m = this.model(), dec = m.dec, d = this.data || {}, MK = P.mark;
250
+ var ja = this.ja = /^ja\b/i.test((ctx && ctx.lang) || "ja");
251
+ var Lb = this.Lb = Object.assign({}, ja ? NAMES : NAMES_EN, d.labels || {});
252
+ this.style.display = "block"; this.style.position = "relative";
253
+ var W0 = this.clientWidth, H = this.clientHeight;
254
+ this.W = W0 - 8; this.H = H;
255
+ this.G = {treeTop: 112, treeBottom: H - 96, scanY: H - 82};
256
+ var svg = D2.el("svg", {viewBox: "0 0 " + W0 + " " + H, width: W0, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
257
+ // 読み上げ:最後の形(復号した符号語の色とラン、終わりの一言)を 1 文で。作者の aria-label があればそれを使う(上書きしない)
258
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
259
+ this.setAttribute("role", "img");
260
+ if (!this._aria){
261
+ var er = dec.error;
262
+ var toks = dec.tokens.map(function(t){ return t.kind === "eol" ? "EOL" : Lb[t.color] + " " + t.run; });
263
+ var end = !er ? Lb.done : fmt0(Lb[er.kind], "").replace("{n}", er.pos + 1);
264
+ // 長い系列は初めの 12 語と語の数(1 文に収める)
265
+ if (toks.length > 12) toks = toks.slice(0, 12).concat([ja ? "…(全 " + toks.length + " 語)" : "… (" + toks.length + " codewords)"]);
266
+ this.setAttribute("aria-label", !dec.bits ? (ja ? "ハフマン木" : "Huffman tree") :
267
+ (ja ? "ハフマン木で " + dec.bits + " を復号:" : "Decoding " + dec.bits + " with the Huffman tree: ") + toks.join(ja ? "、" : ", ") + (ja ? "(" + end + ")" : " (" + end + ")"));
268
+ }
269
+ var root = D2.el("g", {transform: "translate(4 0)"}, svg);
270
+ this.lay = [];
271
+ for (var k = 0; k <= m.plan.length; k++) this.lay.push(this.layoutFor(k));
272
+ // 段が読めないほど詰まるとき(窓の段の間が WIN_GAP 未満、まとめがすべての道を描けない)は知らせる
273
+ var report = ctx && typeof ctx.report === "function" ? function(s){ ctx.report("layout", "[codetree] " + s); } : function(){};
274
+ var tight = this.lay.filter(function(L){ return L.follow && L.gap < WIN_GAP; })[0];
275
+ if (tight) report("the element is too short: the tree view shows " + tight.win + " levels only " + tight.gap.toFixed(1) + " px apart (at least " + WIN_GAP + " px are needed); make the element taller or show fewer levels at a time");
276
+ var sumL = this.lay[m.plan.length];
277
+ if (sumL && sumL.both && sumL.follow) report("the summary cannot show all decoded paths: the whole tree (" + sumL.sumLv + " levels deep) would be " + sumL.sumGap.toFixed(1) + " px per level (at least " + SUM_GAP + " px are needed), so it shows the deepest path only; make the element taller (about " + Math.ceil(sumL.sumLv * SUM_GAP + 252) + " px)");
278
+ // ---- 上:符号の系列と読む位置
279
+ var nb = dec.bits.length, label0 = D2.el("text", {x: 0, y: 34, "font-size": 24, fill: "var(--muted)"}, root);
280
+ label0.textContent = ja ? "符号" : "Code";
281
+ var bx0 = 64, cs = Math.max(22, Math.min(44, (this.W * 0.56 - bx0) / Math.max(1, nb))), bfs = Math.max(24, Math.min(32, cs * 0.75));
282
+ this.B = {x0: bx0, cs: cs};
283
+ var gBits = D2.el("g", {}, root);
284
+ this.ptr = D2.el("rect", {x: 0, y: 4, width: cs - 2, height: 40, rx: 6, fill: "none", stroke: "var(--emph)", "stroke-width": 3, opacity: 0}, gBits);
285
+ this.bitEls = [...dec.bits].map(function(b, j){
286
+ var e = D2.el("text", {x: bx0 + (j + 0.5) * cs, y: 35, "font-size": bfs, "text-anchor": "middle", "font-weight": 700, fill: "var(--muted)", "data-mark": MK + "-bit-" + (j + 1)}, gBits);
287
+ e.textContent = b; return e;
288
+ });
289
+ // 符号語ごとの括弧と結果(色の升目+ランの長さ)
290
+ var swatch = function(g, x, y, c, s){ return D2.el("rect", {x: x, y: y, width: s, height: s, fill: c === "black" ? "var(--fg)" : "var(--bg)", stroke: "var(--fg)", "stroke-width": 2}, g); };
291
+ var bRight = -Infinity;
292
+ this.brk = dec.tokens.map(function(t, i){
293
+ var g = D2.el("g", {opacity: 0, "data-mark": MK + "-cw-" + (i + 1)}, root);
294
+ var a = bx0 + t.start * cs + 4, b = bx0 + t.end * cs - 4;
295
+ D2.el("path", {d: "M" + a + ",48v8H" + b + "v-8", fill: "none", stroke: "var(--fg)", "stroke-width": 2}, g);
296
+ var s = t.kind === "eol" ? "EOL" : Lb[t.color] + " " + t.run, w = t.kind === "eol" ? textW(s, 24, self) : 20 + 6 + textW(s, 24, self), x = Math.max((a + b) / 2 - w / 2, bRight + 12);
297
+ bRight = x + w;
298
+ if (t.kind !== "eol") swatch(g, x, 64, t.color, 18);
299
+ var tx = D2.el("text", {x: t.kind === "eol" ? x : x + 26, y: 82, "font-size": 24, fill: "var(--fg)"}, g);
300
+ tx.textContent = s;
301
+ return g;
302
+ });
303
+ // 右上の一言(読む前と読んだ後の 2 つを重ねて入れ替える)
304
+ this.note = [0, 1].map(function(){ return D2.el("text", {x: self.W, y: 34, "font-size": 24, "text-anchor": "end", fill: "var(--fg)", opacity: 0}, root); });
305
+ // ---- 中:木。どの段階かで見せる節をまとめて作る
306
+ var gE = D2.el("g", {}, root), gP = D2.el("g", {}, root), gN = D2.el("g", {}, root);
307
+ var all = {};
308
+ this.lay.forEach(function(L){ Object.keys(L.nodes).forEach(function(id){ all[id] = L.nodes[id]; }); });
309
+ this.els = {};
310
+ Object.keys(all).forEach(function(id){
311
+ var o = all[id], e = {id: id, parent: o.parent};
312
+ if (o.parent){
313
+ e.edge = D2.el("line", {stroke: "var(--line)", "stroke-width": 2.5}, gE);
314
+ var top = o.parent === "r";
315
+ e.lab = D2.el("text", {"font-size": 24, "text-anchor": "middle", fill: "var(--muted)"}, gE);
316
+ e.lab.textContent = top ? Lb[o.c] : id.slice(-1);
317
+ e.bit = id.slice(-1);
318
+ }
319
+ var g = D2.el("g", {}, gN);
320
+ if (id !== "r") g.setAttribute("data-mark", MK + "-" + (o.c === "white" ? "w" : "b") + (o.code ? "-" + o.code : ""));
321
+ else g.setAttribute("data-mark", MK + "-root");
322
+ e.fan = D2.el("path", {d: "M0,13L-15,36L15,36Z", fill: "var(--line)", opacity: 0}, g);
323
+ if (o.leaf){
324
+ e.dot = D2.el("circle", {r: 13, fill: "var(--accent2)"}, g);
325
+ e.ring = D2.el("circle", {r: 13, fill: "none", stroke: "var(--emph)", "stroke-width": 3, opacity: 0}, g);
326
+ e.num = D2.el("text", {y: 42, "font-size": 24, "text-anchor": "middle", fill: "var(--fg)", "data-mark": MK + "-" + LETTER[o.c] + (o.leaf.run === "EOL" ? "eol" : o.leaf.run)}, g);
327
+ e.num.textContent = o.leaf.run === "EOL" ? "EOL" : String(o.leaf.run);
328
+ } else if (id === "r") e.dot = D2.el("circle", {r: 9, fill: "var(--fg)"}, g);
329
+ else e.dot = D2.el("circle", {r: o.lv === 1 ? 12 : 10, fill: o.c === "black" ? "var(--fg)" : "var(--bg)", stroke: "var(--fg)", "stroke-width": 2.5}, g);
330
+ e.g = g;
331
+ self.els[id] = e;
332
+ });
333
+ // 道(段階ごとに 1 本。まとめではすべて)
334
+ this.paths = m.plan.map(function(p, j){
335
+ var o = j < m.plan.length && p.type !== "sum" ? self.lay[j + 1].cur : null;
336
+ if (!o) return null;
337
+ var ids = ["r", LETTER[o.color]];
338
+ for (var i = 1; i <= o.code.length; i++) ids.push(LETTER[o.color] + o.code.slice(0, i));
339
+ var segs = ids.slice(1).map(function(id, i){ return {a: ids[i], b: id, line: D2.el("line", {stroke: "var(--emph)", "stroke-width": 6, "stroke-linecap": "round", opacity: 0}, gP)}; });
340
+ return {ids: ids, segs: segs, bad: o.bad};
341
+ });
342
+ // 表にない枝:破線の枝と × と、読んだビット
343
+ this.stub = D2.el("g", {opacity: 0, "data-mark": MK + "-bad"}, gP);
344
+ this.stubLine = D2.el("line", {stroke: "var(--emph)", "stroke-width": 4, "stroke-dasharray": "7 6"}, this.stub);
345
+ this.stubLab = D2.el("text", {"font-size": 24, "font-weight": 700, "text-anchor": "middle", fill: "var(--emph)"}, this.stub);
346
+ this.cross = D2.el("text", {"font-size": 34, "font-weight": 700, "text-anchor": "middle", fill: "var(--emph)"}, this.stub);
347
+ this.cross.textContent = "×";
348
+ // 窓の上の「ここまで」の行:今の符号語の色と、ここまで読んだビット
349
+ this.crumb = D2.el("text", {x: 0, y: this.G.treeTop + 14, "font-size": 24, fill: "var(--muted)", opacity: 0, "data-mark": MK + "-crumb"}, root);
350
+ this.crumbHead = D2.el("tspan", {}, this.crumb);
351
+ this.crumbBits = D2.el("tspan", {"font-weight": 700, fill: "var(--emph)"}, this.crumb);
352
+ this.token = D2.el("circle", {r: 9, fill: "var(--emph)", stroke: "var(--bg)", "stroke-width": 2.5, opacity: 0}, gP);
353
+ // ---- 下:復号した画素の並び
354
+ var G = this.G, sx0 = 70, total = m.runs.reduce(function(a, r){ return a + r.len; }, 0);
355
+ var sl = D2.el("text", {x: 0, y: G.scanY + 22, "font-size": 24, fill: "var(--muted)"}, root);
356
+ sl.textContent = Lb.scan;
357
+ var sc = total ? Math.max(0, Math.min(20, (this.W - sx0) / total)) : 0;
358
+ this.S = {x0: sx0, sc: sc, total: total};
359
+ var gS = D2.el("g", {"data-mark": MK + "-scan"}, root);
360
+ D2.el("line", {x1: sx0, x2: sx0 + total * sc, y1: G.scanY + 28, y2: G.scanY + 28, stroke: "var(--line)", "stroke-width": 2}, gS);
361
+ var cellEach = total <= 160 && sc >= 5;
362
+ this.cells = [];
363
+ var cell = 0;
364
+ dec.tokens.forEach(function(t, i){
365
+ if (t.kind === "eol") return;
366
+ var c = t.color === "black" ? "var(--fg)" : "var(--bg)";
367
+ if (cellEach) for (var q = 0; q < t.run; q++) self.cells.push({tok: i, n: q, e: D2.el("rect", {x: sx0 + (cell + q) * sc, y: G.scanY, width: sc, height: 28, fill: c, stroke: "var(--fg)", "stroke-width": 1, opacity: 0}, gS)});
368
+ else self.cells.push({tok: i, n: -1, run: t.run, x: sx0 + cell * sc, e: D2.el("rect", {x: sx0 + cell * sc, y: G.scanY, width: 0, height: 28, fill: c, stroke: "var(--fg)", "stroke-width": 1.5}, gS)});
369
+ cell += t.run;
370
+ });
371
+ // ランの括弧と長さ(メイクアップ+終端は「64 + 2 = 66」)
372
+ this.runEls = m.runs.map(function(r, j){
373
+ var g = D2.el("g", {opacity: 0, "data-mark": MK + "-run-" + (j + 1)}, root);
374
+ var br = D2.el("path", {fill: "none", stroke: "var(--fg)", "stroke-width": 2}, g);
375
+ var sw = swatch(g, 0, G.scanY + 46, r.color, 18);
376
+ var tx = D2.el("text", {y: G.scanY + 64, "font-size": 24, fill: "var(--fg)"}, g);
377
+ return {g: g, br: br, sw: sw, tx: tx, r: r};
378
+ });
379
+ }
380
+ // 色は style 属性に base.el と同じ書き方("fill:var(--x);")で書く。style.fill に代入すると "fill: var(--x);" になり、
381
+ // 作った直後と描き直した後で属性の字が変わる(docs/contract.md §3、tools/test-dom-order.mjs)
382
+ // 段階 k の今の道の進み(0〜1 の各辺)と、葉の後の進み
383
+ render(k, t, ctx){
384
+ var D2 = D, P = this.props, m = this.model(), dec = m.dec, self = this, Lb = this.Lb;
385
+ var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 0;
386
+ var p = k ? m.plan[k - 1] : null, T = k ? this.times(k) : null;
387
+ var A = k ? this.lay[k - 1] : this.lay[0], B = this.lay[k];
388
+ var mv = k ? D2.prog(t, 0, P.move) : 1;
389
+ // ---- 節の位置:両方にあれば滑らせ、片方だけなら近い祖先から伸びる/祖先へ縮む
390
+ var anc = function(L, id){ var o = L.nodes[id]; if (o) return o; var e = self.els[id]; while (e && !L.nodes[e.id]) e = self.els[e.parent]; return e ? L.nodes[e.id] : L.nodes.r; };
391
+ var cA = k ? this.camAt(k - 1, Infinity) : {lv: 0, x: 0}, cB = this.camAt(k, t), camA = cA.lv, camB = cB.lv, G = this.G, Wd = this.W;
392
+ var yOf = function(L, o, cam){ return L.y0 + (o.lv - cam) * L.gap; };
393
+ // 窓の上下(木が入るときは広く)。外へ出る節は 26 px で薄れる
394
+ var bnd = function(L){ return L.follow ? [L.y0 - 8, L.y0 + L.win * L.gap + 8] : [G.treeTop - 40, G.treeBottom + 40]; };
395
+ var bA = bnd(A), bB = bnd(B), wTop = D2.lerp(bA[0], bB[0], mv), wBot = D2.lerp(bA[1], bB[1], mv);
396
+ // 最後の姿(t = Infinity。印刷と台本の小さい絵)は薄れの途中を残さない:半分より濃ければ描き、薄ければ描かない
397
+ var solid = t === Infinity ? function(v){ return v >= 0.5 ? 1 : 0; } : function(v){ return v; };
398
+ var wf = function(y){ return solid(D2.clamp((y - (wTop - 26)) / 26) * D2.clamp((wBot + 26 - y) / 26)); };
399
+ // 横の縁でも薄れる(窓で追うときだけ、部品の左右の外へ出る節)
400
+ var wfx = function(x){ return solid(D2.clamp((x + 20) / 30) * D2.clamp((Wd + 20 - x) / 30)); };
401
+ var lim = wTop - 10;
402
+ // 線の始め(親)が窓の上にあれば、窓の上の縁で切る(線は上から流れ込む)
403
+ var clip = function(a, b){ if (a.y >= lim || b.y <= lim) return a; var f = (lim - a.y) / (b.y - a.y); return {x: D2.lerp(a.x, b.x, f), y: lim}; };
404
+ var pos = {};
405
+ Object.keys(this.els).forEach(function(id){
406
+ var a = A.nodes[id], b = B.nodes[id], pa = a || anc(A, id), pb = b || anc(B, id);
407
+ // 消える節は前半で消え、現れる節は後半で現れる(深い木を畳むときに途中の姿が重ならない)
408
+ var op = (a ? Math.max(0, 1 - 2 * mv) : 0) + (b ? Math.max(0, 2 * mv - 1) : 0);
409
+ if (a && b) op = 1;
410
+ var fan = ((a && a.kind === "fan" ? 1 - mv : 0) + (b && b.kind === "fan" ? mv : 0));
411
+ var y = D2.lerp(yOf(A, pa, camA), yOf(B, pb, camB), mv), x = D2.lerp(pa.x - cA.x, pb.x - cB.x, mv);
412
+ pos[id] = {x: x, y: y, op: op * wf(y) * wfx(x), fan: fan,
413
+ lab: (A.lab[id] && a ? (b ? 1 - mv : 1) : 0) + (B.lab[id] && b ? (a ? mv : 1) : 0)};
414
+ });
415
+ // 窓の上の縁:親が窓の外にある節は(今の道の節のほかは)出さない。縁に枝のない節が浮かないように
416
+ var keep = {r: 1}, kp = B.cur || B.deep;
417
+ if (kp){ keep[LETTER[kp.color]] = 1; for (var j0 = 1; j0 <= kp.code.length; j0++) keep[LETTER[kp.color] + kp.code.slice(0, j0)] = 1; }
418
+ Object.keys(pos).forEach(function(id){
419
+ var par = self.els[id].parent;
420
+ if (par && !keep[id]) pos[id].op *= solid(D2.clamp((pos[par].y - (lim - 30)) / 30));
421
+ });
422
+ // ---- 今の道・前の道
423
+ var segP = function(i){ return T ? D2.prog(t, T.s(i), 0.7 * P.bit) : 0; };
424
+ var onPath = {};
425
+ this.paths.forEach(function(q, j){
426
+ if (!q) return;
427
+ var st = j + 1, dr, op;
428
+ if (p && p.type === "sum"){ op = 1; dr = function(){ return st === k - 1 ? 1 : D2.prog(t, P.move * 0.5, 0.9); }; }
429
+ else if (st === k){ op = 1; dr = segP; }
430
+ else if (st === k - 1){ op = Math.max(0, 1 - 2 * mv); dr = function(){ return 1; }; }
431
+ else { op = 0; dr = function(){ return 0; }; }
432
+ q.segs.forEach(function(s, i){
433
+ var a = pos[s.a], b = pos[s.b], f = dr(i), tip = {x: D2.lerp(a.x, b.x, f), y: D2.lerp(a.y, b.y, f)}, a0 = clip(a, tip);
434
+ s.line.setAttribute("x1", a0.x.toFixed(2)); s.line.setAttribute("y1", a0.y.toFixed(2));
435
+ s.line.setAttribute("x2", tip.x.toFixed(2)); s.line.setAttribute("y2", tip.y.toFixed(2));
436
+ s.line.setAttribute("opacity", f > 0 && tip.y > lim ? (op * Math.min(1, wf(tip.y) * 1.5)).toFixed(3) : 0);
437
+ if (f >= 1 && op > 0.5) onPath[s.b] = 1;
438
+ });
439
+ });
440
+ // ---- 節と枝
441
+ var hit = {}; // 葉に着いた(葉の数字を強調)
442
+ if (p && p.type === "tok"){ var tk = dec.tokens[p.tok]; if (t >= T.A) hit[LETTER[tk.color] + tk.code] = 1; }
443
+ if (p && p.type === "sum") dec.tokens.forEach(function(x){ hit[LETTER[x.color] + x.code] = 1; });
444
+ Object.keys(this.els).forEach(function(id){
445
+ var e = self.els[id], q = pos[id];
446
+ e.g.setAttribute("transform", "translate(" + q.x.toFixed(2) + " " + q.y.toFixed(2) + ")");
447
+ e.g.setAttribute("opacity", q.op.toFixed(3));
448
+ e.fan.setAttribute("opacity", q.fan.toFixed(3));
449
+ if (e.edge){
450
+ var a = pos[e.parent], a1 = clip(a, q);
451
+ e.edge.setAttribute("x1", a1.x.toFixed(2)); e.edge.setAttribute("y1", a1.y.toFixed(2));
452
+ e.edge.setAttribute("x2", q.x.toFixed(2)); e.edge.setAttribute("y2", q.y.toFixed(2));
453
+ // 親が窓の上にある枝は描かない(入ってくる道は道の線が描く)
454
+ e.edge.setAttribute("opacity", a.y < lim ? 0 : Math.min(q.op, 1.6 * a.op).toFixed(3));
455
+ // 枝の字:根からの枝は線の中ほどの上、0 と 1 は親に近いところの外側
456
+ // 線に垂直に、外側(0 は左上、1 は右上)へ離す
457
+ var top = e.parent === "r", lp = labelAt(a, q, top ? 0.5 : 0.42, top ? 20 : 17);
458
+ e.lab.setAttribute("x", lp.x.toFixed(2)); e.lab.setAttribute("y", lp.y.toFixed(2));
459
+ e.lab.setAttribute("opacity", Math.min(q.op, q.lab, wf(lp.y - 8)).toFixed(3));
460
+ e.lab.setAttribute("style", "fill:" + (onPath[id] ? "var(--emph)" : "var(--muted)") + ";");
461
+ e.lab.setAttribute("font-weight", onPath[id] ? 700 : 400);
462
+ }
463
+ if (e.num){
464
+ var h = !!hit[id];
465
+ e.num.setAttribute("style", "fill:" + (h ? "var(--emph)" : "var(--fg)") + ";");
466
+ e.num.setAttribute("font-weight", h ? 700 : 400);
467
+ // 着いたときに輪が 1 回広がる(最終状態には出ない)
468
+ var u = p && p.type === "tok" && h && t !== Infinity ? (t - T.A) / 0.6 : -1;
469
+ if (u > 0 && u < 1){ e.ring.setAttribute("r", (13 + 14 * u).toFixed(2)); e.ring.setAttribute("opacity", (1 - u).toFixed(3)); }
470
+ else e.ring.setAttribute("opacity", 0);
471
+ }
472
+ });
473
+ // ---- 道をたどる点
474
+ var tokOp = 0, tp = pos.r;
475
+ if (p && (p.type === "tok" || p.type === "err") && t !== Infinity){
476
+ var q = this.paths[k - 1], i = 0;
477
+ while (i < q.segs.length - 1 && segP(i) >= 1) i++;
478
+ var s = q.segs[i], f = segP(i), a = pos[s.a], b = pos[s.b];
479
+ tp = {x: D2.lerp(a.x, b.x, f), y: D2.lerp(a.y, b.y, f)};
480
+ tokOp = D2.prog(t, T.s(0) - 0.2, 0.2) * (1 - D2.prog(t, T.A, 0.4));
481
+ }
482
+ this.token.setAttribute("cx", tp.x.toFixed(2)); this.token.setAttribute("cy", tp.y.toFixed(2));
483
+ this.token.setAttribute("opacity", tokOp.toFixed(3));
484
+ // 表にない枝の × (誤りの段階と、まとめ)
485
+ var cx = 0, stubOn = false;
486
+ if (p && dec.error && dec.error.kind === "invalid" && (p.type === "err" || p.type === "sum")){
487
+ var er = dec.error, last = pos[LETTER[er.color] + errPath(er)], gh = this.lay[k].ghosts[LETTER[er.color] + er.code];
488
+ if (gh){
489
+ stubOn = true;
490
+ gh = {x: gh.x - cB.x, y: yOf(this.lay[k], gh, camB)};
491
+ this.stubLine.setAttribute("x1", last.x.toFixed(2)); this.stubLine.setAttribute("y1", last.y.toFixed(2));
492
+ this.stubLine.setAttribute("x2", gh.x.toFixed(2)); this.stubLine.setAttribute("y2", (gh.y - 14).toFixed(2));
493
+ this.cross.setAttribute("x", gh.x.toFixed(2)); this.cross.setAttribute("y", (gh.y + 12).toFixed(2));
494
+ var sp = labelAt(last, gh, 0.42, 17);
495
+ this.stubLab.setAttribute("x", sp.x.toFixed(2)); this.stubLab.setAttribute("y", sp.y.toFixed(2));
496
+ this.stubLab.textContent = er.code.slice(-1);
497
+ cx = p.type === "err" ? D2.prog(t, T.s(T.nb), 0.3) : 1;
498
+ }
499
+ }
500
+ // 描かないとき(opacity 0)は、前に描いた位置と字を残さない(作った直後の姿に戻す。呼ぶ順で DOM が変わらないように)
501
+ if (!stubOn){
502
+ var clr = function(e, names){ names.forEach(function(nm){ e.removeAttribute(nm); }); };
503
+ clr(this.stubLine, ["x1", "y1", "x2", "y2"]); clr(this.cross, ["x", "y"]); clr(this.stubLab, ["x", "y"]);
504
+ this.stubLab.textContent = "";
505
+ }
506
+ this.stub.setAttribute("opacity", cx.toFixed(3));
507
+ // ---- 系列:読んだ符号語は fg、今の符号語の読んだビットは emph、まだのビットは muted
508
+ var cur = p && p.type === "tok" ? dec.tokens[p.tok] : p && p.type === "err" ? dec.error : null;
509
+ var doneEnd = p && p.type === "sum" ? dec.bits.length : cur ? cur.start : 0;
510
+ var readUpTo = -1; // 今の符号語で読んだビット(の桁)
511
+ if (cur && T) for (var j = 1; j <= T.nb; j++) if (t >= T.s(j)) readUpTo = cur.start + j - 1;
512
+ if (p && p.type === "err" && dec.error.kind === "invalid" && t >= T.s(T.nb)) readUpTo = dec.error.pos;
513
+ this.bitEls.forEach(function(e, j){
514
+ var c = j < doneEnd ? "var(--fg)" : j <= readUpTo ? "var(--emph)" : "var(--muted)";
515
+ if (p && p.type === "sum" && dec.error && dec.error.kind !== "dangling" && j >= dec.error.start) c = "var(--emph)";
516
+ if (p && p.type === "tok" && j >= cur.start && j < cur.end && t >= T.F0) c = "var(--fg)";
517
+ e.setAttribute("style", "fill:" + (c) + ";");
518
+ });
519
+ var po = 0, pj = 0;
520
+ if (cur && T && t !== Infinity){
521
+ var jj = 0;
522
+ for (var j2 = 1; j2 <= T.nb; j2++) if (t >= T.s(j2)) jj = j2;
523
+ pj = cur.start + (jj >= 2 ? D2.lerp(jj - 2, jj - 1, D2.prog(t, T.s(jj), 0.2)) : 0);
524
+ po = D2.prog(t, T.s(1) - 0.25, 0.25) * (p.type === "tok" ? 1 - D2.prog(t, T.F0, 0.4) : 1);
525
+ }
526
+ if (p && p.type === "err" && t === Infinity){ pj = dec.error.start + T.nb - 1; po = 1; }
527
+ this.ptr.setAttribute("x", (this.B.x0 + pj * this.B.cs + 1).toFixed(2));
528
+ this.ptr.setAttribute("opacity", po.toFixed(3));
529
+ // 符号語の括弧:読み終えた符号語
530
+ var tokDone = function(i){ if (!p) return 0; if (p.type === "sum" || p.type === "err") return 1; return i < p.tok ? 1 : i === p.tok ? D2.prog(t, T.F0, 0.3) : 0; };
531
+ // 先を薄く見せる表示:後の段階で読む符号語の括弧と、復号する画素を、最後の形のままテーマの --preview-opacity(なければ 0.45)で描く。
532
+ // 木の道は段階ごとに窓が動くので先は描かない
533
+ var ahead = function(i){ return preview && (!p || (p.type === "tok" && i > p.tok)); };
534
+ this.brk.forEach(function(g, i){ g.setAttribute("opacity", ahead(i) ? PV.toFixed(3) : tokDone(i).toFixed(3)); });
535
+ // ---- 画素:葉に着いてから升目を左から塗る
536
+ var fillOf = function(i){ if (!p) return 0; if (p.type === "sum" || p.type === "err") return 1; return i < p.tok ? 1 : i === p.tok ? D2.prog(t, T.F0, P.fill) : 0; };
537
+ var shown = {}; // 符号語ごとの塗った升目の数
538
+ dec.tokens.forEach(function(x, i){ shown[i] = x.kind === "eol" ? 0 : Math.round(x.run * fillOf(i)); });
539
+ this.cells.forEach(function(c){
540
+ var ah = ahead(c.tok);
541
+ if (c.n >= 0) c.e.setAttribute("opacity", ah ? PV : c.n < shown[c.tok] ? 1 : 0);
542
+ else {
543
+ c.e.setAttribute("width", ((ah ? c.run : shown[c.tok]) * self.S.sc).toFixed(2));
544
+ if (ah) c.e.setAttribute("opacity", PV); else c.e.removeAttribute("opacity");
545
+ }
546
+ });
547
+ // ランの括弧と長さ。字は重ならないように左から順に置く
548
+ var right = -Infinity, S = this.S, G = this.G;
549
+ this.runEls.forEach(function(o){
550
+ var vis = o.r.toks.filter(function(i){ return shown[i] > 0; });
551
+ if (!vis.length){
552
+ o.g.setAttribute("opacity", 0);
553
+ o.br.removeAttribute("d"); o.sw.setAttribute("x", "0"); o.tx.removeAttribute("x"); // 作った直後と同じ(色の升目は x="0" で作る。消すと属性の順が変わる)
554
+ o.tx.textContent = "";
555
+ return;
556
+ }
557
+ var len = vis.reduce(function(a, i){ return a + shown[i]; }, 0);
558
+ var parts = vis.map(function(i){ return dec.tokens[i].run; });
559
+ var full = vis.every(function(i){ return shown[i] === dec.tokens[i].run; });
560
+ var s = Lb[o.r.color] + " " + (parts.length > 1 ? parts.join(self.ja ? " + " : " + ") + (self.ja ? " = " : " = ") + parts.reduce(function(a, b){ return a + b; }, 0) : String(full ? parts[0] : len));
561
+ var a = S.x0 + o.r.start * S.sc, b = a + len * S.sc;
562
+ o.br.setAttribute("d", "M" + (a + 1) + "," + (G.scanY + 34) + "v6H" + Math.max(a + 2, b - 1) + "v-6");
563
+ var w = 26 + textW(s, 24, self), x = Math.max((a + b) / 2 - w / 2, right + 16, S.x0);
564
+ x = Math.min(x, self.W - w);
565
+ right = x + w;
566
+ o.sw.setAttribute("x", x.toFixed(2));
567
+ o.tx.setAttribute("x", (x + 26).toFixed(2));
568
+ o.tx.textContent = s;
569
+ o.g.setAttribute("opacity", 1);
570
+ });
571
+ // ---- 「ここまで」の行:窓が根から離れたときだけ。今の段階でまだ読んでいなければ前の符号語
572
+ var cw = null, nread = 0;
573
+ if (p && (p.type === "tok" || p.type === "err")){
574
+ cw = this.lay[k].cur; for (var j3 = 1; j3 <= T.nb; j3++) if (t >= T.s(j3)) nread = j3;
575
+ cw = {color: cw.color, code: (cw.bad || cw.code).slice(0, nread)};
576
+ } else if (p && p.type === "sum") cw = B.deep;
577
+ if ((!cw || !cw.code) && k > 1 && this.lay[k - 1].cur) cw = this.lay[k - 1].cur;
578
+ var camNow = D2.lerp(camA, camB, mv), co = cw && cw.code ? D2.clamp((camNow - 0.3) / 0.4) * (B.follow ? 1 : Math.max(0, 1 - 2 * mv)) : 0;
579
+ if (cw){
580
+ this.crumbHead.textContent = fmt0(Lb.crumb, cw.color ? Lb[cw.color] : "") + " ";
581
+ this.crumbBits.textContent = (cw.code.match(/.{1,4}/g) || []).join(" ");
582
+ } else { this.crumbHead.textContent = ""; this.crumbBits.textContent = ""; }
583
+ this.crumb.setAttribute("opacity", co.toFixed(3));
584
+ // ---- 右上の一言
585
+ var fmt = function(s, o){ return s.replace("{c}", o.c ? Lb[o.c] : "").replace("{n}", o.n || ""); };
586
+ var other = function(c){ return c === "white" ? "black" : "white"; };
587
+ var n0 = "", n1 = "", sw = 0;
588
+ if (!p){ n1 = Lb.start; sw = 1; }
589
+ else if (p.type === "tok"){
590
+ var x = dec.tokens[p.tok];
591
+ n0 = fmt(Lb.read, {c: x.color});
592
+ n1 = fmt(Lb[x.kind], {c: x.kind === "term" ? other(x.color) : x.color});
593
+ sw = D2.prog(t, T.F0, 0.4);
594
+ } else if (p.type === "err"){
595
+ n0 = fmt(Lb.read, {c: dec.error.color});
596
+ n1 = fmt(Lb[dec.error.kind], {n: dec.error.pos + 1});
597
+ sw = D2.prog(t, T.s(T.nb), 0.4);
598
+ } else {
599
+ n0 = ""; n1 = !dec.error ? Lb.done : fmt(Lb[dec.error.kind], {n: dec.error.pos + 1}); sw = D2.prog(t, P.move, 0.4);
600
+ }
601
+ this.note[0].textContent = n0; this.note[1].textContent = n1;
602
+ // 前の一言が消えてから次を出す(重ねて入れ替えると読めない)
603
+ this.note[0].setAttribute("opacity", Math.max(0, 1 - 2 * sw).toFixed(3)); this.note[1].setAttribute("opacity", Math.max(0, 2 * sw - 1).toFixed(3));
604
+ this.note[1].setAttribute("style", "fill:" + (p && (p.type === "err" || p.type === "sum") ? "var(--emph)" : "var(--fg)") + ";");
605
+ }
606
+ };
607
+ });