egatari 0.6.13 → 0.6.15

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 (260) hide show
  1. package/CHANGELOG.md +60 -1
  2. package/README.ja.md +46 -46
  3. package/bin/egatari.mjs +6 -6
  4. package/components.lock.json +507 -153
  5. package/components2.lock.json +1710 -33
  6. package/kit/build.mjs +3 -1
  7. package/kit/check-messages.mjs +23 -8
  8. package/kit/check.mjs +27 -15
  9. package/kit/core/article-messages.mjs +4 -4
  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 +28 -6
  13. package/kit/core/check-parity.mjs +3 -1
  14. package/kit/core/check-rules.mjs +6 -4
  15. package/kit/core/colab-core.mjs +3 -3
  16. package/kit/core/comment-core.mjs +6 -0
  17. package/kit/core/image-size.mjs +35 -0
  18. package/kit/core/layout-scan.mjs +89 -2
  19. package/kit/core/llm-fix.mjs +39 -6
  20. package/kit/core/llm-pack-assemble.mjs +5 -2
  21. package/kit/core/llm-pack-data.mjs +269 -83
  22. package/kit/core/llm-pack.mjs +3 -3
  23. package/kit/core/new-deck.mjs +17 -3
  24. package/kit/core/part-labels.mjs +9 -3
  25. package/kit/core/parts2.mjs +1 -1
  26. package/kit/core/player.mjs +18 -0
  27. package/kit/core/portable.mjs +44 -4
  28. package/kit/core/purposes.mjs +6 -3
  29. package/kit/core/readable-parts.mjs +42 -0
  30. package/kit/core/themes-lock.mjs +1 -1
  31. package/kit/core/tier-a.mjs +14 -2
  32. package/kit/deck.js +49 -2
  33. package/kit/instruction-version.json +1 -1
  34. package/kit/live.js +6 -6
  35. package/kit/player.json +1 -1
  36. package/kit/player.lock.json +2 -2
  37. package/kit/presenter.js +3 -1
  38. package/kit/readable-parts.mjs +25 -0
  39. package/kit/tools.js +11 -4
  40. package/package.json +4 -2
  41. package/server/dev.mjs +7 -6
  42. package/server/editor-ui.js +9 -4
  43. package/server/hints.js +22 -2
  44. package/tts/yomi.yaml +1 -1
  45. package/vendor/components/CATALOG.md +21 -14
  46. package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/README.en.md +40 -0
  47. package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/index.js +408 -0
  48. package/vendor/components/sha256/0396a1895978803ae342b7f598f187b17ead47800e8f8317a5cb041111349813/index.js +278 -0
  49. package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/README.en.md +26 -0
  50. package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/index.js +322 -0
  51. package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/README.en.md +54 -0
  52. package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/index.js +470 -0
  53. package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/README.en.md +18 -0
  54. package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/index.js +279 -0
  55. package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/README.en.md +31 -0
  56. package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/index.js +267 -0
  57. package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/README.en.md +53 -0
  58. package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/index.js +171 -0
  59. package/vendor/components/sha256/1117758820dc561f41cf9d1cc0bab8cf3173cde7771ac10a12b94c96007c0f55/index.js +268 -0
  60. package/vendor/components/sha256/137017ad452afe209bdff81bc02ffae99c6b60a1c4aed2383515974f65511ff2/index.js +205 -0
  61. package/vendor/components/sha256/1a1471ba5f68e54304825a64e736afeda421e3763cdcbcdab2e45509562a0291/index.js +607 -0
  62. package/vendor/components/sha256/1b15fcc12b2fa43821e6299e87aae31aa69dbbc5a0d1b80088a5d7c5f8b8f7f5/index.js +429 -0
  63. package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/README.en.md +23 -0
  64. package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/index.js +147 -0
  65. package/vendor/components/sha256/21c099461befc0d382ddfe982f2a6cd8eeb6dd731252164ac619525e4bacdf0d/index.js +242 -0
  66. package/vendor/components/sha256/2352e0e22460f4a3c46dca6cef27cd9c63f161a411f1cf56c75c585e9124503c/index.js +315 -0
  67. package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/README.en.md +53 -0
  68. package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/index.js +171 -0
  69. package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/README.en.md +38 -0
  70. package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/index.js +414 -0
  71. package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/README.en.md +45 -0
  72. package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/index.js +211 -0
  73. package/vendor/components/sha256/2f111b900898579b3ec1611c2110db336a46d9133171a0cbb125ee37bd1f24f8/index.js +592 -0
  74. package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/README.en.md +45 -0
  75. package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/index.js +211 -0
  76. package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/README.en.md +20 -0
  77. package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/index.js +310 -0
  78. package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/README.en.md +35 -0
  79. package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/index.js +179 -0
  80. package/vendor/components/sha256/3af0b84b1799fc64ec74d6da9cbd343eccd89e8a11c81bfb444562c911284442/index.js +342 -0
  81. package/vendor/components/sha256/3c69bf3b3c6b9f76048fbc0839b3aa9699723570086d3d44bac799230ed6de5b/index.js +121 -0
  82. package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/README.en.md +37 -0
  83. package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/index.js +501 -0
  84. package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/README.en.md +38 -0
  85. package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/index.js +414 -0
  86. package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/README.en.md +30 -0
  87. package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/index.js +305 -0
  88. package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/README.en.md +31 -0
  89. package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/index.js +236 -0
  90. package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/README.en.md +21 -0
  91. package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/index.js +108 -0
  92. package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/README.en.md +28 -0
  93. package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/index.js +213 -0
  94. package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/README.en.md +35 -0
  95. package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/index.js +179 -0
  96. package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/README.en.md +53 -0
  97. package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/index.js +171 -0
  98. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ABCJS-ADAPTER.md +101 -0
  99. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/LICENSE-abcjs.txt +21 -0
  100. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/chords.json +89 -0
  101. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/doremi.json +261 -0
  102. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/extras.json +192 -0
  103. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/kaeru.json +521 -0
  104. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/rhythm.json +248 -0
  105. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ties.json +360 -0
  106. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/index.js +508 -0
  107. package/vendor/components/sha256/59996a56df462b36e24a928d4397c9308d9e39ad8224ebd19fb5c981608ef458/index.js +521 -0
  108. package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/README.en.md +30 -0
  109. package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/index.js +305 -0
  110. package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/README.en.md +30 -0
  111. package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/index.js +192 -0
  112. package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/README.en.md +20 -0
  113. package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/index.js +307 -0
  114. package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/README.en.md +24 -0
  115. package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/index.js +554 -0
  116. package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/README.en.md +25 -0
  117. package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/index.js +316 -0
  118. package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/README.en.md +18 -0
  119. package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/index.js +279 -0
  120. package/vendor/components/sha256/624acb997c4975ace65570b529b3ba00baa421c80ecb7fc80f392a64e8c573a7/index.js +107 -0
  121. package/vendor/components/sha256/62602488ee33dd4bdef8516de16da5ab27d7f7265d5041681beab80e08f1d482/index.js +97 -0
  122. package/vendor/components/sha256/67eaf344bddac79b74ed03fdcd70285c7b52b160e6c5ffbd6897848179aa5230/index.js +818 -0
  123. package/vendor/components/sha256/682c9c8871eccd19ff1264e0323a2e4c5798b0488b612ba0339c6fe85aab5914/index.js +926 -0
  124. package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/README.en.md +51 -0
  125. package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/index.js +230 -0
  126. package/vendor/components/sha256/72138936ed0b8fd3cb0214ae7ed250ae3f1f8b21ed6fd593544947774064ba0d/index.js +250 -0
  127. package/vendor/components/sha256/74c1a0f3ed1370c5003aa5770ee28cea2ce994d415680116a92fdbcd5854ba62/index.js +198 -0
  128. package/vendor/components/sha256/76125035eb153b98befa9c735bcd9fc4f99f774dc1d082fdae40acaadfe7d95b/index.js +818 -0
  129. package/vendor/components/sha256/7728cf7dde88a6688aba0ed70f23f7e21362a147beac09c1fa1a4b773e08e93b/index.js +354 -0
  130. package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/README.en.md +23 -0
  131. package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/index.js +289 -0
  132. package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/README.en.md +31 -0
  133. package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/index.js +236 -0
  134. package/vendor/components/sha256/7d50e50fbb6c5ec636b62509bd88ddaac1870e0522cf11bcc293ce924d48072d/index.js +312 -0
  135. package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/README.en.md +42 -0
  136. package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/index.js +549 -0
  137. package/vendor/components/sha256/87fc302c41b2bfeea88951ed689ec01b4dc79218c4bc69b310dc2228dfa2e153/index.js +926 -0
  138. package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/README.en.md +24 -0
  139. package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/index.js +103 -0
  140. package/vendor/components/sha256/89c8c16788e24df17920542ed6eb6557dea4a10e835de8fe839e439ccbba8014/index.js +69 -0
  141. package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/README.en.md +44 -0
  142. package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/index.js +304 -0
  143. package/vendor/components/sha256/8d9af78aef44ad2f98101c67d32473373d39725a09c923969aa621d5f5b124bb/index.js +121 -0
  144. package/vendor/components/sha256/8f861d71df72a82be86a3e63abf7d69bbab5aac6fa68be6e077c4e19c3519ed8/index.js +312 -0
  145. package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/README.en.md +54 -0
  146. package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/index.js +470 -0
  147. package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/README.en.md +24 -0
  148. package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/index.js +214 -0
  149. package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/README.en.md +33 -0
  150. package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/index.js +390 -0
  151. package/vendor/components/sha256/9289efef4a75afe011e54a17e34db08cfb16a450b2e0653e6a98525495cfba99/index.js +315 -0
  152. package/vendor/components/sha256/93256a923199ea51108cdb7491c3c96f376dbef15b64cbf1a1aa7cc5726b4970/index.js +429 -0
  153. package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/README.en.md +24 -0
  154. package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/index.js +550 -0
  155. package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/README.en.md +28 -0
  156. package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/index.js +213 -0
  157. package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/README.en.md +40 -0
  158. package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/index.js +348 -0
  159. package/vendor/components/sha256/97c074a5473618c65f4c23263f056870a0b7940e73475f2a1f32f68c08d8eb0f/index.js +198 -0
  160. package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/README.en.md +66 -0
  161. package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/index.js +984 -0
  162. package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/README.en.md +34 -0
  163. package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/index.js +244 -0
  164. package/vendor/components/sha256/a18b2b15d00c76462a43823b5c270c7ddd7c31794da9c236f74f20f80ec2ffdb/index.js +354 -0
  165. package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/README.en.md +32 -0
  166. package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/index.js +222 -0
  167. package/vendor/components/sha256/a979207c60fbd2a12cb557297eb0217eb098d660de684530a0f43d0d9c64e6ef/index.js +312 -0
  168. package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/README.en.md +34 -0
  169. package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/index.js +244 -0
  170. package/vendor/components/sha256/af7ed69b8969f6da14784b6e9d26e4dfd20147772ea172a99bd936a71be10fcd/index.js +278 -0
  171. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ABCJS-ADAPTER.md +101 -0
  172. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/LICENSE-abcjs.txt +21 -0
  173. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/chords.json +89 -0
  174. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/doremi.json +261 -0
  175. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/extras.json +192 -0
  176. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/kaeru.json +521 -0
  177. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/rhythm.json +248 -0
  178. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ties.json +360 -0
  179. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/index.js +508 -0
  180. package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/README.en.md +66 -0
  181. package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/index.js +990 -0
  182. package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/README.en.md +24 -0
  183. package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/index.js +550 -0
  184. package/vendor/components/sha256/b8096d7a60609520981273673761a110e40e3bdf52a7ab5548363b20e16f6e93/index.js +404 -0
  185. package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/README.en.md +32 -0
  186. package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/index.js +222 -0
  187. package/vendor/components/sha256/bd8e3893df02411deccc1d6d7b02292ca0d59dfeddfafcf99419430981572c82/index.js +351 -0
  188. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ABCJS-ADAPTER.md +101 -0
  189. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/LICENSE-abcjs.txt +21 -0
  190. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/chords.json +89 -0
  191. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/doremi.json +261 -0
  192. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/extras.json +192 -0
  193. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/kaeru.json +521 -0
  194. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/rhythm.json +248 -0
  195. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ties.json +360 -0
  196. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/index.js +508 -0
  197. package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/README.en.md +31 -0
  198. package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/index.js +267 -0
  199. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/LICENSE-strokesvg.txt +115 -0
  200. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/OFL.txt +93 -0
  201. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/index.js +749 -0
  202. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/strokes-CHANGES.md +20 -0
  203. package/vendor/components/sha256/c791e69e722f64146242f97acb29a341160d0c327cfe1d76307954d80e70db85/index.js +268 -0
  204. package/vendor/components/sha256/c8c0de41d603b61c6ec4dc1da5b50559e213dd1f3693ee5019df858016fd6daf/index.js +747 -0
  205. package/vendor/components/sha256/c99d4f2ab443484b9f462e405c72ea4794838b88f8823f27c606d12cbbedb996/index.js +404 -0
  206. package/vendor/components/sha256/cbde046e30c35db60259911a88e2ae0bedaf545e29b1da8b8ce13bc602a33c19/index.js +465 -0
  207. package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/README.en.md +51 -0
  208. package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/index.js +228 -0
  209. package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/README.en.md +35 -0
  210. package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/index.js +179 -0
  211. package/vendor/components/sha256/cf0985ffcd8e7cbe2175ddb9a4342b2a4aa3f322794188fc99af8789b494460d/index.js +521 -0
  212. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/LICENSE-strokesvg.txt +115 -0
  213. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/OFL.txt +93 -0
  214. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/index.js +749 -0
  215. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/strokes-CHANGES.md +20 -0
  216. package/vendor/components/sha256/d01dc7fd78d08dd720ed86b39d7877dc0913d72e914036088a86af2df2faee52/index.js +484 -0
  217. package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/README.en.md +24 -0
  218. package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/index.js +214 -0
  219. package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/README.en.md +31 -0
  220. package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/index.js +271 -0
  221. package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/README.en.md +25 -0
  222. package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/index.js +316 -0
  223. package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/README.en.md +23 -0
  224. package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/index.js +120 -0
  225. package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/README.en.md +40 -0
  226. package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/index.js +405 -0
  227. package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/README.en.md +66 -0
  228. package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/index.js +984 -0
  229. package/vendor/components/sha256/ddd4b9cbbc282cbb3117ff662e1a14ecdb3cc7c16072a574418ec6a6eecef4d8/index.js +107 -0
  230. package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/README.en.md +22 -0
  231. package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/index.js +145 -0
  232. package/vendor/components/sha256/e2da948daac7bfac158857877b5a6932dbd2369e73901abcef118c92dd20b725/index.js +747 -0
  233. package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/README.en.md +42 -0
  234. package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/index.js +268 -0
  235. package/vendor/components/sha256/e653a4da80f7761442dc5b504ea5b0700fd0acf1979beeff56122cfdb3d4654c/index.js +607 -0
  236. package/vendor/components/sha256/ea217c6821e931b2d8474bf56d38f2dcc89ec705fe1d276f313e1c7e8db2b98a/index.js +233 -0
  237. package/vendor/components/sha256/ea2e4e24838574f607879c7d05556281258c018331e4da3e6f3a5263173f2e99/index.js +75 -0
  238. package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/README.en.md +42 -0
  239. package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/index.js +549 -0
  240. package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/README.en.md +44 -0
  241. package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/index.js +203 -0
  242. package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/README.en.md +34 -0
  243. package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/index.js +244 -0
  244. package/vendor/components/sha256/fa1a09c10181456143d125d68dbbdcacde6bab2e4a2b3e573367103ce28ebf55/index.js +228 -0
  245. package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/README.en.md +51 -0
  246. package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/index.js +228 -0
  247. package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/README.en.md +23 -0
  248. package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/index.js +147 -0
  249. package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/README.en.md +20 -0
  250. package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/index.js +307 -0
  251. package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/README.en.md +26 -0
  252. package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/index.js +322 -0
  253. package/vendor/components-2/manifest-2.12.0.json +2348 -0
  254. package/vendor/components-2/manifest-2.13.0.json +2477 -0
  255. package/vendor/components-2/manifest-2.14.0.json +2460 -0
  256. package/vendor/components-2/manifest-2.14.1.json +2460 -0
  257. package/vendor/components-2/manifest-2.15.0.json +2460 -0
  258. package/vendor/egatari-spec/SOURCE.json +3 -3
  259. package/vendor/egatari-spec/schema/deck-meta.schema.json +15 -0
  260. package/vendor/egatari-spec/schema/egatari-metadata.schema.json +15 -0
@@ -0,0 +1,550 @@
1
+ // m-network:グラフの探索と巡回路。頂点(作者の座標)と辺(重み・向き)を描き、ステップごとに今の頂点・候補・訪れた頂点を
2
+ // 塗り分け、選んだ辺を 1 本ずつ引き、経路の長さなどの合計を出す。数値と状態は、探索を実際に走らせたスクリプトの出力を書く
3
+ // <m-network style="height:480px"><script type="application/json">
4
+ // {"nodes": [{"id": "A", "x": 0, "y": 0}, {"id": "B", "x": 4, "y": 0}, {"id": "C", "x": 2, "y": 3}],
5
+ // "edges": [{"from": "A", "to": "B", "w": 4}, {"from": "A", "to": "C", "w": 3}, {"from": "B", "to": "C", "w": 2}],
6
+ // "frontierKind": "queue", "total": {"label": "経路の長さ"},
7
+ // "steps": [{"current": "A", "visited": ["A"], "frontier": ["B", "C"], "parent": {"B": "A", "C": "A"}},
8
+ // {"current": "C", "visited": ["A", "C"], "frontier": ["B"], "take": [["A", "C"]], "total": 3}]}
9
+ // (JSON の終わり)</m-network>
10
+ // 座標は作者の単位のまま(y は下向き)。パーツが縦横の比を保って枠に収める。
11
+ // ステップの状態:current・visited・frontier・total は書いたステップからその値(書かなければ前のステップのまま。current の null で消す)。
12
+ // parent は前のステップに足していく(null で消す)。take と drop は選んだ辺の集まりを前のステップから増減する。
13
+ // 状態はステップ 1..k だけから決まる((k, t) だけで画面が決まる)。
14
+ // 色:今の頂点 --emph(太い輪)、候補 --accent2(点線の輪と下の帯)、訪れた頂点 --muted の塗り、選んだ辺と探索の木 --term、ほかの辺 --line。
15
+ // 確かめること(data):知らない id、ない辺の take(complete のときを除く)、選んでいない辺の drop、
16
+ // 選んだ辺がすべて重みを持つときに total が重みの和と合わないこと(total.check: false で確かめない)
17
+ egatariParts.define({name: "network", version: "2.1.0", requires: {base: "1.2.0"}, element: "m-network"}, function(deps){
18
+ "use strict";
19
+ var base = deps.base;
20
+ var ID = {type: "string"};
21
+ var PAIR = {type: "array", minItems: 2, maxItems: 2, items: ID};
22
+ var KIND = {
23
+ queue: {ja: "待ち行列(左が先頭)", en: "Queue (front on the left)"},
24
+ stack: {ja: "スタック(右が上)", en: "Stack (top on the right)"},
25
+ pq: {ja: "優先度付きキュー", en: "Priority queue"},
26
+ set: {ja: "候補", en: "Frontier"},
27
+ };
28
+ return class extends base.MotionElement {
29
+ static partName = "network";
30
+ static preview = "none";
31
+ static shape = {
32
+ schema: {type: "object", additionalProperties: false, required: ["steps"], anyOf: [{required: ["nodes"]}, {required: ["layout"]}], properties: {
33
+ directed: {type: "boolean"},
34
+ complete: {type: "boolean"},
35
+ stochastic: {type: "boolean"},
36
+ frontierKind: {type: "string", enum: ["queue", "stack", "pq", "set"]},
37
+ total: {type: "object", additionalProperties: false, properties: {label: {type: "string"}, unit: {type: "string"}, digits: {type: "integer"}, check: {type: "boolean"}, of: {type: "string", enum: ["path", "taken"]}}},
38
+ nodes: {type: "array", minItems: 1, maxItems: 24, items: {type: "object", additionalProperties: false, required: ["id", "x", "y"], properties: {
39
+ id: ID, x: {type: "number"}, y: {type: "number"}, label: {type: "string"}, shape: {type: "string", enum: ["circle", "ellipse", "box"]}, observed: {type: "boolean"}}}},
40
+ edges: {type: "array", maxItems: 60, items: {type: "object", additionalProperties: false, required: ["from", "to"], properties: {
41
+ from: ID, to: ID, w: {type: "number"}, bi: {type: "boolean"}}}},
42
+ plates: {type: "array", maxItems: 4, items: {type: "object", additionalProperties: false, required: ["nodes"], properties: {nodes: {type: "array", minItems: 1, items: ID}, label: {type: "string"}}}},
43
+ layout: {type: "string", enum: ["trellis"]},
44
+ states: {type: "array", minItems: 1, maxItems: 6, items: ID},
45
+ T: {type: "integer"},
46
+ transitions: {type: "array", maxItems: 36, items: {type: "object", additionalProperties: false, required: ["from", "to"], properties: {from: ID, to: ID, w: {type: "number"}}}},
47
+ steps: {type: "array", minItems: 1, maxItems: 40, items: {type: "object", additionalProperties: false, properties: {
48
+ current: {type: ["string", "null"]},
49
+ visited: {type: "array", items: ID},
50
+ frontier: {type: "array", items: {type: ["string", "array"]}},
51
+ parent: {type: "object"},
52
+ take: {type: "array", items: PAIR},
53
+ drop: {type: "array", items: PAIR},
54
+ total: {type: "number"},
55
+ note: {type: "string"}}}}}},
56
+ example: {nodes: [{id: "A", x: 0, y: 0}, {id: "B", x: 4, y: 0}], edges: [{from: "A", to: "B", w: 4}],
57
+ steps: [{current: "A", frontier: ["B"]}, {current: "B", take: [["A", "B"]], total: 4}]},
58
+ };
59
+ static props = {
60
+ dur: {type: "number", default: 0.6, doc: "1 本の辺を引く秒数(頂点の色の変化はその半分)"},
61
+ size: {type: "number", default: 24, doc: "字の大きさ(px、24 以上)"},
62
+ weights: {type: "bool", default: true, doc: "辺の重みを書く"},
63
+ };
64
+ get steps(){
65
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
66
+ return ((this.data || {}).steps || []).length;
67
+ }
68
+ // 書いたデータ。layout: "trellis"(隠れマルコフモデルの格子)なら、状態 × 時刻の頂点(id は "状態@時刻")と、隣の時刻への遷移の辺に広げる
69
+ get net(){
70
+ if (this._net !== undefined) return this._net;
71
+ var d = this.data || {};
72
+ if (d.layout !== "trellis") return (this._net = d);
73
+ var S = d.states || [], T = Math.max(1, Math.min(8, d.T || 1)), nodes = [], edges = [];
74
+ for (var t = 1; t <= T; t++) S.forEach(function(s, i){ nodes.push({id: s + "@" + t, x: (t - 1) * 3, y: i * 1.6, label: s}); });
75
+ for (var t2 = 1; t2 < T; t2++) (d.transitions || []).forEach(function(e){ edges.push({from: e.from + "@" + t2, to: e.to + "@" + (t2 + 1), w: e.w}); });
76
+ return (this._net = Object.assign({}, d, {nodes: nodes, edges: edges, directed: true, trellisT: T}));
77
+ }
78
+ // 辺の鍵:向きのないグラフでは [A, B] と [B, A] を同じ辺にする
79
+ key(a, b){ return this.directed || a < b ? a + "\u0000" + b : b + "\u0000" + a; }
80
+ // ステップ 0..N の状態と、確かめた結果。データだけから決める(mount の前にも steps が要る)
81
+ plan(){
82
+ if (this._plan) return this._plan;
83
+ var self = this, d = this.net || {}, bad = [];
84
+ if (!(d.nodes || []).length) bad.push("nodes (or layout: \"trellis\" with states and T) are needed");
85
+ if (d.layout === "trellis" && !(this.data.states || []).length) bad.push("layout: \"trellis\" needs states");
86
+ (d.plates || []).forEach(function(pt, i){ (pt.nodes || []).forEach(function(id){ if (!(d.nodes || []).some(function(n){ return n.id === id; })) bad.push("plates[" + i + "]: unknown node \"" + id + "\""); }); });
87
+ this.directed = !!d.directed;
88
+ var ids = {}, edges = {};
89
+ (d.nodes || []).forEach(function(n){ if (ids[n.id]) bad.push("node id \"" + n.id + "\" is used twice"); ids[n.id] = n; });
90
+ (d.edges || []).forEach(function(e, i){
91
+ if (!ids[e.from] || !ids[e.to]){ bad.push("edges[" + i + "] joins an unknown node (" + (ids[e.from] ? e.to : e.from) + ")"); return; }
92
+ edges[self.key(e.from, e.to)] = e;
93
+ });
94
+ // stochastic:向きのあるグラフで、各頂点から出る辺の w の和が 1(推移確率)
95
+ if (d.stochastic){
96
+ if (!this.directed) bad.push("stochastic needs directed: true");
97
+ else Object.keys(ids).forEach(function(id){
98
+ var out = Object.keys(edges).map(function(k){ return edges[k]; }).filter(function(e){ return e.from === id; });
99
+ if (!out.length) return;
100
+ if (out.some(function(e){ return typeof e.w !== "number"; })){ bad.push("stochastic: an edge from " + id + " has no w"); return; }
101
+ var sum = out.reduce(function(a, e){ return a + e.w; }, 0);
102
+ if (Math.abs(sum - 1) > 1e-6) bad.push("stochastic: the edges from " + id + " sum to " + +sum.toFixed(9) + ", not 1");
103
+ });
104
+ }
105
+ var known = function(id, where){ if (ids[id]) return true; bad.push(where + ": unknown node \"" + id + "\""); return false; };
106
+ var check = !(d.total && d.total.check === false);
107
+ var st = {current: null, visited: [], frontier: [], parent: {}, chosen: {}, total: undefined, note: "", take: [], drop: []};
108
+ var states = [st];
109
+ (d.steps || []).forEach(function(s, i){
110
+ var w = "steps[" + i + "]", n = {current: st.current, visited: st.visited, frontier: st.frontier, parent: Object.assign({}, st.parent),
111
+ chosen: Object.assign({}, st.chosen), total: st.total, note: s.note || "", take: [], drop: []};
112
+ if (s.current !== undefined) n.current = s.current === null || known(s.current, w + ".current") ? s.current : null;
113
+ if (s.visited) n.visited = s.visited.filter(function(id){ return known(id, w + ".visited"); });
114
+ if (s.frontier) n.frontier = s.frontier.map(function(f){
115
+ var id = Array.isArray(f) ? f[0] : f;
116
+ if (typeof id !== "string" || !known(id, w + ".frontier")) return null;
117
+ return {id: id, key: Array.isArray(f) && f.length > 1 ? f[1] : undefined};
118
+ }).filter(Boolean);
119
+ if (s.parent) Object.keys(s.parent).forEach(function(c){
120
+ var p = s.parent[c];
121
+ if (!known(c, w + ".parent")) return;
122
+ if (p === null){ delete n.parent[c]; return; }
123
+ if (typeof p === "string" && known(p, w + ".parent." + c)) n.parent[c] = p;
124
+ });
125
+ (s.drop || []).forEach(function(pr){
126
+ var k = self.key(pr[0], pr[1]);
127
+ if (!n.chosen[k]){ bad.push(w + ".drop: " + pr[0] + "–" + pr[1] + " was not chosen"); return; }
128
+ delete n.chosen[k]; n.drop.push(k);
129
+ });
130
+ (s.take || []).forEach(function(pr){
131
+ if (!known(pr[0], w + ".take") || !known(pr[1], w + ".take")) return;
132
+ var k = self.key(pr[0], pr[1]);
133
+ if (!d.complete && !edges[k]){ bad.push(w + ".take: there is no edge " + pr[0] + (self.directed ? "→" : "–") + pr[1]); return; }
134
+ n.chosen[k] = [pr[0], pr[1]]; n.take.push({k: k, a: pr[0], b: pr[1]});
135
+ });
136
+ if (s.total !== undefined){
137
+ n.total = s.total;
138
+ // 何の合計か:total.of、なければ parent があるときは出発点から current までの道のり(探索)、ないときは選んだ辺の w の和(経路・巡回路)
139
+ var of = d.total && d.total.of ? d.total.of : Object.keys(n.parent).length ? "path" : "taken", ws = null, what = "";
140
+ if (of === "path" && n.current){
141
+ ws = []; var c = n.current, seen = {};
142
+ while (n.parent[c] !== undefined && !seen[c]){ seen[c] = 1; var e = edges[self.key(n.parent[c], c)]; if (!e || typeof e.w !== "number"){ ws = null; break; } ws.push(e.w); c = n.parent[c]; }
143
+ what = "the path to " + n.current + " along parent";
144
+ } else if (of === "taken"){
145
+ var ks = Object.keys(n.chosen);
146
+ ws = ks.length && ks.every(function(k){ return edges[k] && typeof edges[k].w === "number"; }) ? ks.map(function(k){ return edges[k].w; }) : null;
147
+ what = "the chosen edges' weights";
148
+ }
149
+ if (check && ws && ws.length){
150
+ var sum = ws.reduce(function(a, x){ return a + x; }, 0);
151
+ // 見せている桁の分だけ許す:辺の数 × ½·10^−d(d は w の小数の桁の最大)
152
+ var dec = ws.reduce(function(m, x){ var f = String(x).split(".")[1]; return Math.max(m, f ? f.length : 0); }, 0);
153
+ // total が w より細かい桁で書かれているときだけ(w を丸めて書いたとき)。同じ桁なら正確に合うはず
154
+ var decT = (String(s.total).split(".")[1] || "").length, exact = 1e-9 * Math.max(1, Math.abs(sum));
155
+ var tol = decT > dec ? Math.max(exact, ws.length * 0.5 * Math.pow(10, -dec) + 1e-12) : exact;
156
+ if (Math.abs(sum - s.total) > tol)
157
+ bad.push(w + ".total is " + s.total + " but " + what + " sums to " + +sum.toFixed(9) + " (total.of: \"path\" or \"taken\"; total.check: false if the total is something else)");
158
+ }
159
+ }
160
+ states.push(n); st = n;
161
+ });
162
+ var digits = d.total && d.total.digits !== undefined ? d.total.digits : states.reduce(function(m, s){
163
+ if (typeof s.total !== "number") return m;
164
+ var x = String(s.total).split(".")[1];
165
+ return Math.max(m, x ? Math.min(4, x.length) : 0);
166
+ }, 0);
167
+ return (this._plan = {ids: ids, edges: edges, states: states, bad: bad, digits: digits,
168
+ hasFrontier: states.some(function(s){ return s.frontier.length; }), hasTotal: states.some(function(s){ return typeof s.total === "number"; }),
169
+ hasNote: states.some(function(s){ return s.note; })});
170
+ }
171
+ mount(ctx){
172
+ var P = this.props, D = base, self = this, pl = this.plan(), d = this.net, ja = /^ja\b/i.test(ctx.lang || "ja");
173
+ this.ja = ja;
174
+ this.style.display = "block"; this.style.position = "relative";
175
+ var W = this.clientWidth, H = this.clientHeight;
176
+ var svg = this.svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
177
+ if (!(P.dur >= 0)){ ctx.report("attr", "[network] dur must be ≥ 0 (got " + this.getAttribute("dur") + "); using 0.6"); P.dur = 0.6; }
178
+ if (!(P.size >= 24)){ ctx.report("attr", "[network] size must be ≥ 24 (got " + this.getAttribute("size") + "); using 24"); P.size = 24; }
179
+ pl.bad.forEach(function(m){ ctx.report("data", "[network] " + m); });
180
+ var fs = P.size, tw = function(s){ return D.textWidth(s, fs, {font: self}); };
181
+ // mtext の記法(*x*_i など)があるときだけ mtext で書く(ない字はこれまでどおり)。幅は記号を除いて測る
182
+ var MARK = /\*[^*\s][^*]*\*|[_^]\S/, plain = function(s){ return s.replace(/\*([^*\s][^*]*)\*/g, "$1").replace(/[_^](\S)/g, "$1"); };
183
+ this.MARK = MARK;
184
+ // 下の帯:1 段目は候補の並びと合計、2 段目はステップの説明
185
+ var rowH = Math.ceil(fs * 1.75), rows = (pl.hasFrontier || pl.hasTotal ? 1 : 0) + (pl.hasNote ? 1 : 0);
186
+ var band = rows ? rows * rowH + 10 : 0;
187
+ // 頂点の大きさ:字の幅 + 余白。短い名前は円、長い名前は角の丸い箱
188
+ var nh = Math.ceil(fs * 1.75), nodes = d.nodes.map(function(n){
189
+ var lab = n.label !== undefined ? n.label : n.id;
190
+ var sh = n.shape || "circle", lw = tw(MARK.test(lab) ? plain(lab) : lab);
191
+ return {n: n, lab: lab, sh: sh, w: sh === "ellipse" ? Math.max(Math.ceil(nh * 1.5), Math.ceil(lw) + 36) : Math.max(nh, Math.ceil(lw) + 24), h: nh};
192
+ });
193
+ var pad = 8, gx0 = pad, gx1 = W - pad, gy0 = pad, gy1 = H - band - pad;
194
+ var hasLoop = Object.keys(pl.edges).some(function(k){ return pl.edges[k].from === pl.edges[k].to; });
195
+ var plateM = (d.plates || []).length ? Math.ceil(fs * 1.3) + 18 : 0, timeRow = d.trellisT ? Math.ceil(fs * 1.5) : 0;
196
+ gy0 += timeRow;
197
+ var mw = Math.max.apply(null, nodes.map(function(o){ return o.w; })) / 2 + 6 + (hasLoop ? nh * 1.6 : 0) + plateM, mh = nh / 2 + 6 + (hasLoop ? nh * 1.6 : 0) + plateM;
198
+ var xs = d.nodes.map(function(n){ return n.x; }), ys = d.nodes.map(function(n){ return n.y; });
199
+ var x0 = Math.min.apply(null, xs), x1 = Math.max.apply(null, xs), y0 = Math.min.apply(null, ys), y1 = Math.max.apply(null, ys);
200
+ var aw = gx1 - gx0 - 2 * mw, ah = gy1 - gy0 - 2 * mh;
201
+ if (aw < nh || ah < nh){
202
+ ctx.report("size", "[network] the element (" + W + "×" + H + " px) is too small for the graph; give it a size, e.g. style=\"height:480px\"");
203
+ aw = Math.max(aw, 1); ah = Math.max(ah, 1);
204
+ }
205
+ var sc = Math.min(x1 > x0 ? aw / (x1 - x0) : Infinity, y1 > y0 ? ah / (y1 - y0) : Infinity);
206
+ if (!isFinite(sc)) sc = 1;
207
+ var ox = gx0 + mw + (aw - (x1 - x0) * sc) / 2, oy = gy0 + mh + (ah - (y1 - y0) * sc) / 2;
208
+ var at = this.at = {};
209
+ nodes.forEach(function(o){ o.x = ox + (o.n.x - x0) * sc; o.y = oy + (o.n.y - y0) * sc; at[o.n.id] = o; });
210
+ // 頂点どうしの重なり
211
+ var gap = 6;
212
+ for (var i = 0; i < nodes.length; i++) for (var j = i + 1; j < nodes.length; j++){
213
+ var a = nodes[i], b = nodes[j];
214
+ if (Math.abs(a.x - b.x) < (a.w + b.w) / 2 + gap && Math.abs(a.y - b.y) < (a.h + b.h) / 2 + gap){
215
+ var need = Math.max(((a.w + b.w) / 2 + gap) / Math.max(1e-9, Math.abs(a.n.x - b.n.x) || 1e-9), ((a.h + b.h) / 2 + gap) / Math.max(1e-9, Math.abs(a.n.y - b.n.y) || 1e-9));
216
+ ctx.report("layout", "[network] nodes " + a.n.id + " and " + b.n.id + " overlap at this size; move them apart (they need about " + Math.ceil(Math.min(need, 1e6) / sc * 100) + "% of their distance) or make the element larger");
217
+ }
218
+ }
219
+ // 辺の形:点の列(頂点の縁から縁まで)。直線、向きの逆の辺もあるときの弧、自己ループ
220
+ var cutAt = function(o, ux, uy){
221
+ if (o.sh === "ellipse") return 1 / Math.sqrt(Math.pow(ux / (o.w / 2), 2) + Math.pow(uy / (o.h / 2), 2));
222
+ if (o.w <= o.h + 0.5 && o.sh !== "box") return o.h / 2;
223
+ var tx = Math.abs(ux) > 1e-9 ? (o.w / 2) / Math.abs(ux) : Infinity, ty = Math.abs(uy) > 1e-9 ? (o.h / 2) / Math.abs(uy) : Infinity;
224
+ return Math.min(tx, ty);
225
+ };
226
+ var rim = function(o, ang){ var ux = Math.cos(ang), uy = Math.sin(ang), c = cutAt(o, ux, uy); return {x: o.x + ux * c, y: o.y + uy * c}; };
227
+ var dirTo = function(o, x, y){ return Math.atan2(y - o.y, x - o.x); };
228
+ // 自己ループの向き:ほかの辺からいちばん離れ、枠の中に収まる向き(上から時計回りに 8 方向)
229
+ var loopExt = nh * 1.25, loopAng = {};
230
+ Object.keys(pl.edges).forEach(function(k){
231
+ var e = pl.edges[k];
232
+ if (e.from !== e.to) return;
233
+ var o = at[e.from], used = [];
234
+ Object.keys(pl.edges).forEach(function(k2){
235
+ var f = pl.edges[k2];
236
+ if (f.from === f.to) return;
237
+ if (f.from === e.from) used.push(dirTo(o, at[f.to].x, at[f.to].y));
238
+ if (f.to === e.from) used.push(dirTo(o, at[f.from].x, at[f.from].y));
239
+ });
240
+ var best = null, bestScore = -1;
241
+ for (var q = 0; q < 8; q++){
242
+ var ang = -Math.PI / 2 + q * Math.PI / 4, r = rim(o, ang), ax = r.x + Math.cos(ang) * loopExt, ay = r.y + Math.sin(ang) * loopExt;
243
+ var fits = ax > nh * 0.5 && ax < W - nh * 0.5 && ay > nh * 0.5 && ay < H - band - nh * 0.5;
244
+ var gapMin = used.reduce(function(m, u){ var dd = Math.abs(((ang - u) % (2 * Math.PI) + 3 * Math.PI) % (2 * Math.PI) - Math.PI); return Math.min(m, dd); }, Math.PI);
245
+ var score = gapMin + (fits ? 10 : 0);
246
+ if (score > bestScore + 1e-9){ bestScore = score; best = ang; }
247
+ }
248
+ loopAng[e.from] = best;
249
+ });
250
+ var geoms = {};
251
+ var geom = this.geom = function(a, b){
252
+ var gk = a + "\u0000" + b;
253
+ if (geoms[gk]) return geoms[gk];
254
+ var A = at[a], B = at[b], pts = [];
255
+ var bez = function(p0, p1, p2, p3){
256
+ for (var i = 0; i <= 24; i++){
257
+ var t = i / 24, u = 1 - t;
258
+ pts.push(p3 ? {x: u * u * u * p0.x + 3 * u * u * t * p1.x + 3 * u * t * t * p2.x + t * t * t * p3.x, y: u * u * u * p0.y + 3 * u * u * t * p1.y + 3 * u * t * t * p2.y + t * t * t * p3.y}
259
+ : {x: u * u * p0.x + 2 * u * t * p1.x + t * t * p2.x, y: u * u * p0.y + 2 * u * t * p1.y + t * t * p2.y});
260
+ }
261
+ };
262
+ if (a === b){
263
+ var th = loopAng[a] !== undefined ? loopAng[a] : -Math.PI / 2, sp = 0.5, r0 = rim(A, th - sp), r1 = rim(A, th + sp);
264
+ var c0 = {x: r0.x + Math.cos(th - sp * 1.4) * loopExt * 1.3, y: r0.y + Math.sin(th - sp * 1.4) * loopExt * 1.3};
265
+ var c1 = {x: r1.x + Math.cos(th + sp * 1.4) * loopExt * 1.3, y: r1.y + Math.sin(th + sp * 1.4) * loopExt * 1.3};
266
+ bez(r0, c0, c1, r1);
267
+ } else if (self.directed && pl.edges[self.key(b, a)] && pl.edges[self.key(a, b)]){
268
+ // 往復の辺:進む向きの右側へふくらむ弧(逆向きの辺は反対側になる)
269
+ var dx = B.x - A.x, dy = B.y - A.y, L = Math.hypot(dx, dy) || 1, bend = Math.min(0.2 * L, nh * 1.6);
270
+ var cx = (A.x + B.x) / 2 - dy / L * bend, cy = (A.y + B.y) / 2 + dx / L * bend;
271
+ bez(rim(A, dirTo(A, cx, cy)), {x: cx, y: cy}, rim(B, dirTo(B, cx, cy)));
272
+ } else {
273
+ var ang2 = Math.atan2(B.y - A.y, B.x - A.x);
274
+ pts.push(rim(A, ang2), rim(B, ang2 + Math.PI));
275
+ }
276
+ return (geoms[gk] = pts);
277
+ };
278
+ var lenOf = function(pts){ var L = 0; for (var i = 1; i < pts.length; i++) L += Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y); return L; };
279
+ // 点の列の先頭から割合 f までの点の列(f = 1 で全部)と、そこでの向き
280
+ var cutPts = this.cutPts = function(pts, f){
281
+ var L = lenOf(pts) * Math.max(0, Math.min(1, f)), out = [pts[0]], acc = 0;
282
+ for (var i = 1; i < pts.length; i++){
283
+ var sl = Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y);
284
+ if (acc + sl >= L){ var r = sl ? (L - acc) / sl : 0; out.push({x: pts[i - 1].x + (pts[i].x - pts[i - 1].x) * r, y: pts[i - 1].y + (pts[i].y - pts[i - 1].y) * r}); return out; }
285
+ acc += sl; out.push(pts[i]);
286
+ }
287
+ return out;
288
+ };
289
+ var pathD = this.pathD = function(pts){ return pts.map(function(p, i){ return (i ? "L" : "M") + p.x.toFixed(1) + " " + p.y.toFixed(1); }).join(""); };
290
+ var at2 = function(pts, f){
291
+ var q = cutPts(pts, f), n = q.length, p = q[n - 1], o = n > 1 ? q[n - 2] : pts[0];
292
+ if (Math.hypot(p.x - o.x, p.y - o.y) < 1e-6){ o = pts[0]; p = pts[1] || pts[0]; }
293
+ var L = Math.hypot(p.x - o.x, p.y - o.y) || 1;
294
+ return {x: q[n - 1].x, y: q[n - 1].y, ux: (p.x - o.x) / L, uy: (p.y - o.y) / L};
295
+ };
296
+ // 板(plate):頂点の組を囲む角の丸い枠、右下の隅に N。いちばん下の層に
297
+ var gPl = D.el("g", {}, svg);
298
+ this.plateLabels = [];
299
+ (d.plates || []).forEach(function(pt){
300
+ var os = (pt.nodes || []).map(function(id){ return at[id]; }).filter(Boolean);
301
+ if (!os.length) return;
302
+ var x0 = Math.min.apply(null, os.map(function(o){ return o.x - o.w / 2; })) - 14, x1 = Math.max.apply(null, os.map(function(o){ return o.x + o.w / 2; })) + 14;
303
+ var y0 = Math.min.apply(null, os.map(function(o){ return o.y - o.h / 2; })) - 14, y1 = Math.max.apply(null, os.map(function(o){ return o.y + o.h / 2; })) + (pt.label ? Math.ceil(fs * 1.3) + 10 : 14);
304
+ D.el("rect", {x: x0.toFixed(1), y: y0.toFixed(1), width: (x1 - x0).toFixed(1), height: (y1 - y0).toFixed(1), rx: 12, fill: "none", stroke: "var(--fg)", "stroke-width": 1.5}, gPl);
305
+ if (pt.label){ var lt = D.el("text", {x: (x1 - 10).toFixed(1), y: (y1 - 10).toFixed(1), "font-size": fs, "text-anchor": "end", fill: "var(--fg)"}, gPl); lt.textContent = pt.label; self.plateLabels.push(lt); }
306
+ });
307
+ // 格子(trellis):列の上に時刻
308
+ if (d.trellisT) for (var tt = 1; tt <= d.trellisT; tt++){
309
+ var col = nodes.filter(function(o){ return /@(\d+)$/.exec(o.n.id) && +/@(\d+)$/.exec(o.n.id)[1] === tt; });
310
+ if (!col.length) continue;
311
+ var ty = Math.min.apply(null, col.map(function(o){ return o.y - o.h / 2; })) - 12, tl = D.el("text", {x: col[0].x.toFixed(1), y: ty.toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--muted)"}, gPl);
312
+ tl.textContent = "t = " + tt;
313
+ }
314
+ var gE = D.el("g", {}, svg), gT = D.el("g", {}, svg), gC = D.el("g", {}, svg), gN = D.el("g", {}, svg), gW = D.el("g", {}, svg), gB = D.el("g", {}, svg);
315
+ var headD = this.headD = function(pts, f, wd){
316
+ var e = at2(pts, f), s = 10 + wd, x = e.x, y = e.y, px = -e.uy, py = e.ux;
317
+ return "M" + x.toFixed(1) + " " + y.toFixed(1) + "L" + (x - e.ux * s + px * s * 0.5).toFixed(1) + " " + (y - e.uy * s + py * s * 0.5).toFixed(1) +
318
+ "L" + (x - e.ux * s - px * s * 0.5).toFixed(1) + " " + (y - e.uy * s - py * s * 0.5).toFixed(1) + "Z";
319
+ };
320
+ var arrow = function(g, pts, col, wd){ return D.el("path", {d: headD(pts, 1, wd), fill: col}, g); };
321
+ // ほかの辺(--line)と重み
322
+ var placed = nodes.map(function(o){ return {x0: o.x - o.w / 2 - 4, x1: o.x + o.w / 2 + 4, y0: o.y - o.h / 2 - 4, y1: o.y + o.h / 2 + 4}; });
323
+ var hit = function(r){ return placed.some(function(q){ return r.x0 < q.x1 && q.x0 < r.x1 && r.y0 < q.y1 && q.y0 < r.y1; }); };
324
+ var inside = function(r){ return r.x0 >= 0 && r.x1 <= W && r.y0 >= 0 && r.y1 <= H - band; };
325
+ var crowded = [];
326
+ this.wlabels = [];
327
+ Object.keys(pl.edges).forEach(function(k){
328
+ var e = pl.edges[k], pts = geom(e.from, e.to);
329
+ // 双方向の辺(bi:潜在の交絡)は破線で両端に矢じり
330
+ D.el("path", Object.assign({d: pathD(pts), fill: "none", stroke: "var(--line)", "stroke-width": 2.5}, e.bi ? {"stroke-dasharray": "8 6"} : {}), gE);
331
+ if (self.directed || e.bi) arrow(gE, pts, "var(--line)", 2.5);
332
+ if (e.bi) arrow(gE, pts.slice().reverse(), "var(--line)", 2.5);
333
+ if (!P.weights || typeof e.w !== "number") return;
334
+ var s = fmt(e.w, decimals(e.w)), w = tw(s) + 8, h = fs + 6, best = null, loop = e.from === e.to;
335
+ (loop ? [0.5] : [0.5, 0.38, 0.62, 0.28, 0.72]).some(function(f){
336
+ return (loop ? [1, -1, 1.8, -1.8] : [1, -1]).some(function(side){
337
+ var g = at2(pts, f), off = (fs * 0.62 + 4) * side, cx = g.x - g.uy * off, cy = g.y + g.ux * off;
338
+ var r = {x0: cx - w / 2, x1: cx + w / 2, y0: cy - h / 2, y1: cy + h / 2, cx: cx, cy: cy};
339
+ if (!hit(r) && inside(r)){ best = r; return true; }
340
+ return false;
341
+ });
342
+ });
343
+ if (!best){ crowded.push(e.from + (self.directed ? "→" : "–") + e.to); return; }
344
+ placed.push(best);
345
+ var t = D.el("text", {x: best.cx.toFixed(1), y: (best.cy + fs * 0.36).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--fg)",
346
+ stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", style: "font-variant-numeric:tabular-nums"}, gW);
347
+ t.textContent = s;
348
+ self.wlabels.push(t);
349
+ });
350
+ if (crowded.length) ctx.report("layout", "[network] no room for the weight of " + crowded.join(", ") + "; move the nodes apart, make the element larger or set weights=\"false\"");
351
+ // 探索の木(parent)と選んだ辺(take):出てきた組ごとに 1 本ずつ作る
352
+ this.tree = {}; this.chosen = {};
353
+ pl.states.forEach(function(s){
354
+ Object.keys(s.parent).forEach(function(c){
355
+ var p = s.parent[c], k = p + "\u0000" + c;
356
+ if (self.tree[k] || p === c) return;
357
+ var pts = geom(p, c), L = lenOf(pts);
358
+ self.tree[k] = {el: D.el("g", {opacity: 0}, gT)};
359
+ D.el("path", {d: pathD(cutPts(pts, Math.max(0, (L - 8) / L))), fill: "none", stroke: "var(--term)", "stroke-width": 4.5, "stroke-linecap": "round"}, self.tree[k].el);
360
+ arrow(self.tree[k].el, pts, "var(--term)", 4.5);
361
+ });
362
+ Object.keys(s.chosen).forEach(function(k){
363
+ if (self.chosen[k]) return;
364
+ self.chosen[k] = {el: D.el("path", {d: "M0 0", fill: "none", stroke: "var(--term)", "stroke-width": 8, "stroke-linecap": "round", opacity: 0}, gC), a: s.chosen[k][0], b: s.chosen[k][1],
365
+ head: self.directed ? D.el("path", {d: "M0 0", fill: "var(--term)", opacity: 0}, gC) : null};
366
+ });
367
+ });
368
+ // 頂点:塗り(訪れた)、点線の輪(候補)、太い輪(今)、名前
369
+ nodes.forEach(function(o){
370
+ var rect = function(grow, attrs){
371
+ var w = o.w + 2 * grow, h = o.h + 2 * grow;
372
+ var shp = o.sh === "ellipse" ? {rx: (w / 2).toFixed(1), ry: (h / 2).toFixed(1)} : o.sh === "box" ? {rx: 6} : {rx: (h / 2).toFixed(1)};
373
+ return D.el("rect", Object.assign({x: (o.x - w / 2).toFixed(1), y: (o.y - h / 2).toFixed(1), width: w.toFixed(1), height: h.toFixed(1)}, shp, attrs), gN);
374
+ };
375
+ // 観測した変数(observed)は塗る(グラフィカルモデルの習わし)
376
+ rect(0, {fill: o.n.observed ? "var(--line)" : "var(--bg)", stroke: "var(--fg)", "stroke-width": 2});
377
+ o.vis = rect(0, {fill: "var(--muted)", opacity: 0});
378
+ o.fr = rect(6, {fill: "none", stroke: "var(--accent2)", "stroke-width": 4, "stroke-dasharray": "8 6", opacity: 0});
379
+ o.cur = rect(4, {fill: "none", stroke: "var(--emph)", "stroke-width": 7, opacity: 0});
380
+ if (MARK.test(o.lab)) D.mtext(gN, o.x, o.y + fs * 0.36, o.lab, {"font-size": fs, "text-anchor": "middle", fill: "var(--fg)"});
381
+ else { var t = D.el("text", {x: o.x.toFixed(1), y: (o.y + fs * 0.36).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--fg)"}, gN); t.textContent = o.lab; }
382
+ });
383
+ this.nodes = nodes;
384
+ // 下の帯
385
+ var by = H - band + 4;
386
+ this.band = {y1: by + rowH / 2 + fs * 0.36, y2: by + rowH * ((pl.hasFrontier || pl.hasTotal) ? 1.5 : 0.5) + fs * 0.36, W: W, g: gB};
387
+ if (pl.hasTotal){
388
+ var tl = d.total && d.total.label !== undefined ? d.total.label : ja ? "合計" : "Total";
389
+ this.totalText = D.el("text", {x: W - 4, y: this.band.y1.toFixed(1), "font-size": fs, "text-anchor": "end", fill: "var(--fg)", style: "font-variant-numeric:tabular-nums", opacity: 0}, gB);
390
+ this.totalLabel = tl;
391
+ var maxs = pl.states.reduce(function(m, s){ return typeof s.total === "number" ? Math.max(m, tw(self.totalString(s.total))) : m; }, 0);
392
+ this.totalW = maxs + 24;
393
+ } else this.totalW = 0;
394
+ if (pl.hasFrontier){
395
+ var kind = KIND[d.frontierKind || "set"];
396
+ this.capText = D.el("text", {x: 4, y: this.band.y1.toFixed(1), "font-size": fs, fill: "var(--fg)"}, gB);
397
+ this.capText.textContent = ja ? kind.ja : kind.en;
398
+ this.capW = tw(this.capText.textContent) + 16;
399
+ if (this.capW + nh + this.totalW > W){ ctx.report("size", "[network] the frontier row has no room (" + W + " px wide)"); }
400
+ var most = Math.max.apply(null, pl.states.map(function(s){ return s.frontier.length; }));
401
+ this.slots = [];
402
+ for (var q = 0; q < most + 1; q++){
403
+ var sg = D.el("g", {opacity: 0}, gB);
404
+ this.slots.push({g: sg, rect: D.el("rect", {x: 0, y: 0, width: 0, height: nh - 8, rx: 6, opacity: 0, fill: "none", stroke: "var(--accent2)", "stroke-width": 3, "stroke-dasharray": "8 6"}, sg),
405
+ text: D.el("text", {x: 0, y: 0, "font-size": fs, "text-anchor": "middle", fill: "var(--fg)"}, sg)});
406
+ }
407
+ }
408
+ if (pl.hasNote){
409
+ this.noteText = D.el("text", {x: 4, y: this.band.y2.toFixed(1), "font-size": fs, fill: "var(--fg)", opacity: 0}, gB);
410
+ // 記法のある説明は、その説明ごとに mtext で作っておき、そのステップで出す
411
+ this.markNotes = {};
412
+ pl.states.forEach(function(st2, k2){ if (st2.note && MARK.test(st2.note)) self.markNotes[k2] = D.mtext(gB, 4, self.band.y2, st2.note, {"font-size": fs, fill: "var(--fg)", opacity: 0}); });
413
+ var long = [];
414
+ pl.states.forEach(function(s, k){ if (s.note && tw(s.note) > W - 8) long.push(k); });
415
+ if (long.length) ctx.report("layout", "[network] the note of step " + long.join(", ") + " is wider than the element (" + W + " px); shorten it (it is cut with …)");
416
+ }
417
+ this.fit = function(s, room){
418
+ if (tw(s) <= room) return s;
419
+ var a = Array.from(s);
420
+ while (a.length && tw(a.join("") + "…") > room) a.pop();
421
+ return a.join("") + "…";
422
+ };
423
+ this.tw = tw;
424
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
425
+ this.setAttribute("role", "img");
426
+ if (!this._aria) this.setAttribute("aria-label", this.summary(ja));
427
+ this.model = {nodes: nodes.map(function(o){ return [o.n.id, +o.x.toFixed(1), +o.y.toFixed(1)]; }), states: pl.states.length};
428
+ function decimals(v){ var x = String(v).split(".")[1]; return x ? Math.min(3, x.length) : 0; }
429
+ }
430
+ totalString(v){
431
+ var u = this.net.total && this.net.total.unit ? this.net.total.unit : "";
432
+ return this.totalLabel + " " + fmt(v, this.plan().digits) + (u ? " " + u : "");
433
+ }
434
+ // 読み上げ:頂点と辺の数、最後に選んだ辺、合計
435
+ summary(ja){
436
+ var pl = this.plan(), d = this.net, last = pl.states[pl.states.length - 1], self = this;
437
+ var ne = Object.keys(pl.edges).length;
438
+ var s = ja ? "グラフ(頂点 " + d.nodes.length + "、辺 " + ne + ")" : "Graph (" + d.nodes.length + " nodes, " + ne + " edges)";
439
+ var ch = Object.keys(last.chosen).map(function(k){ return last.chosen[k].join(self.directed ? "→" : "–"); });
440
+ if (ch.length) s += ja ? "。選んだ辺:" + ch.join("、") : ". Chosen edges: " + ch.join(", ");
441
+ var tr = Object.keys(last.parent).map(function(c){ return last.parent[c] + "→" + c; });
442
+ if (tr.length) s += ja ? "。探索の木:" + tr.join("、") : ". Search tree: " + tr.join(", ");
443
+ if (typeof last.total === "number"){
444
+ var u = d.total && d.total.unit ? d.total.unit : "", lab = d.total && d.total.label !== undefined ? d.total.label : ja ? "合計" : "Total";
445
+ s += (ja ? "。" : ". ") + lab + " " + fmt(last.total, pl.digits) + (u ? " " + u : "");
446
+ }
447
+ return s;
448
+ }
449
+ // ステップ k の時刻:drop が消える(前半)→ take を 1 本ずつ引く。頂点の色は前半で変わる
450
+ timing(k){
451
+ var s = this.plan().states[k], P = this.props;
452
+ if (!s || k === 0) return {fade: 0, start: 0, end: 0};
453
+ var fade = P.dur * 0.5, start = s.drop.length ? fade : 0;
454
+ return {fade: fade, start: start, end: Math.max(fade, start + s.take.length * P.dur)};
455
+ }
456
+ duration(k){ return this.timing(k).end; }
457
+ render(k, t, ctx){
458
+ if (!this.nodes) return;
459
+ var self = this, pl = this.plan(), D = base, P = this.props;
460
+ k = Math.max(0, Math.min(k, pl.states.length - 1));
461
+ var cur = pl.states[k], prev = pl.states[Math.max(0, k - 1)], tm = this.timing(k);
462
+ var e = k === 0 ? 1 : D.prog(t, 0, tm.fade);
463
+ var mix = function(a, b){ return D.lerp(a ? 1 : 0, b ? 1 : 0, e); };
464
+ var inF = function(s, id){ return s.frontier.some(function(f){ return f.id === id; }); };
465
+ this.nodes.forEach(function(o){
466
+ var id = o.n.id;
467
+ o.vis.setAttribute("opacity", (0.35 * mix(prev.visited.indexOf(id) >= 0, cur.visited.indexOf(id) >= 0)).toFixed(3));
468
+ o.fr.setAttribute("opacity", mix(inF(prev, id), inF(cur, id)).toFixed(3));
469
+ o.cur.setAttribute("opacity", mix(prev.current === id, cur.current === id).toFixed(3));
470
+ });
471
+ Object.keys(this.tree).forEach(function(k2){
472
+ var parts = k2.split("\u0000"), was = prev.parent[parts[1]] === parts[0], is = cur.parent[parts[1]] === parts[0];
473
+ self.tree[k2].el.setAttribute("opacity", (k === 0 ? 0 : mix(was, is)).toFixed(3));
474
+ });
475
+ // 選んだ辺:前のステップから残る辺は引いたまま、drop は前半で消え、take は順に端から端へ
476
+ var takeAt = {};
477
+ cur.take.forEach(function(x, j){ takeAt[x.k] = {j: j, a: x.a, b: x.b}; });
478
+ Object.keys(this.chosen).forEach(function(k2){
479
+ var c = self.chosen[k2], el = c.el, a = c.a, b = c.b, f = 0, op = 0;
480
+ if (takeAt[k2] && k > 0){
481
+ a = takeAt[k2].a; b = takeAt[k2].b;
482
+ f = D.prog(t, tm.start + takeAt[k2].j * P.dur, P.dur); op = f > 0 ? 1 : 0;
483
+ } else if (cur.chosen[k2]){
484
+ a = cur.chosen[k2][0]; b = cur.chosen[k2][1]; f = 1; op = 1;
485
+ } else if (prev.chosen[k2] && k > 0){
486
+ a = prev.chosen[k2][0]; b = prev.chosen[k2][1]; f = 1; op = 1 - D.prog(t, 0, tm.fade);
487
+ }
488
+ var pts = self.geom(a, b), L = 0;
489
+ for (var i = 1; i < pts.length; i++) L += Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y);
490
+ // 向きのあるグラフ:線は矢じりの手前で止め、矢じりを線の先に付ける
491
+ var fl = c.head ? f * Math.max(0, (L - 12) / (L || 1)) : f;
492
+ el.setAttribute("d", f > 0 ? self.pathD(self.cutPts(pts, fl)) : "M0 0");
493
+ el.setAttribute("opacity", op.toFixed(3));
494
+ if (c.head){ c.head.setAttribute("d", f > 0 ? self.headD(pts, f, 8) : "M0 0"); c.head.setAttribute("opacity", op.toFixed(3)); }
495
+ });
496
+ // 合計:前の値から今の値へ数え上げる
497
+ if (this.totalText){
498
+ var has = typeof cur.total === "number", from = typeof prev.total === "number" && k > 0 ? prev.total : has ? cur.total : 0;
499
+ var v = has ? D.lerp(from, cur.total, k === 0 ? 1 : D.prog(t, 0, Math.max(tm.end, 0.3))) : 0;
500
+ this.totalText.textContent = has ? this.totalString(+v.toFixed(pl.digits)) : "";
501
+ this.totalText.setAttribute("opacity", has ? 1 : 0);
502
+ }
503
+ // 候補の並び:今のステップの frontier(前半で入れ替わる。どちらか一方だけを見せる)
504
+ if (this.slots){
505
+ var show = k === 0 ? cur : e < 0.5 ? prev : cur, x = this.capW, room = this.band.W - this.totalW - 4, fsz = P.size;
506
+ var items = show.frontier.map(function(f){ return f.key !== undefined ? f.id + " " + fmt(f.key, decimals(f.key)) : (self.at[f.id] ? self.at[f.id].lab : f.id); });
507
+ var empty = !items.length && k > 0;
508
+ if (empty) items = [this.ja ? "(空)" : "(empty)"];
509
+ var nShow = items.length, widths = items.map(function(s){ return Math.max(self.tw(s) + 20, fsz * 1.4); });
510
+ var more = function(n){ return "…+" + n; };
511
+ while (nShow > 0){
512
+ var used = x, j2;
513
+ for (j2 = 0; j2 < nShow; j2++) used += widths[j2] + 8;
514
+ if (nShow < items.length) used += self.tw(more(items.length - nShow)) + 8;
515
+ if (used <= room) break;
516
+ nShow--;
517
+ }
518
+ var op2 = k === 0 ? 1 : Math.abs(e - 0.5) * 2;
519
+ this.slots.forEach(function(sl, j){
520
+ if (j < nShow){
521
+ sl.rect.setAttribute("x", x.toFixed(1)); sl.rect.setAttribute("y", (self.band.y1 - fsz * 0.36 - (self.nodes[0].h - 8) / 2).toFixed(1)); sl.rect.setAttribute("width", widths[j].toFixed(1));
522
+ sl.rect.setAttribute("opacity", empty ? 0 : 1);
523
+ sl.text.setAttribute("x", (x + widths[j] / 2).toFixed(1)); sl.text.setAttribute("y", self.band.y1.toFixed(1)); sl.text.textContent = items[j];
524
+ sl.g.setAttribute("opacity", op2.toFixed(3)); x += widths[j] + 8;
525
+ } else if (j === nShow && nShow < items.length){
526
+ ["x", "y", "width"].forEach(function(a){ sl.rect.setAttribute(a, 0); });
527
+ sl.rect.setAttribute("opacity", 0);
528
+ sl.text.setAttribute("x", (x + self.tw(more(items.length - nShow)) / 2).toFixed(1)); sl.text.setAttribute("y", self.band.y1.toFixed(1)); sl.text.textContent = more(items.length - nShow);
529
+ sl.g.setAttribute("opacity", op2.toFixed(3));
530
+ } else {
531
+ ["x", "y", "width"].forEach(function(a){ sl.rect.setAttribute(a, 0); });
532
+ sl.rect.setAttribute("opacity", 0); sl.text.setAttribute("x", 0); sl.text.setAttribute("y", 0); sl.text.textContent = ""; sl.g.setAttribute("opacity", 0);
533
+ }
534
+ });
535
+ }
536
+ if (this.noteText){
537
+ var mk = this.markNotes[k], no = cur.note ? (k === 0 ? 1 : D.prog(t, 0, tm.fade)).toFixed(3) : 0;
538
+ this.noteText.textContent = cur.note && !mk ? this.fit(cur.note, this.band.W - 8) : "";
539
+ this.noteText.setAttribute("opacity", mk ? 0 : no);
540
+ for (var mkk in this.markNotes) this.markNotes[mkk].setAttribute("opacity", +mkk === k ? no : 0);
541
+ }
542
+ function decimals(v){ var x = String(v).split(".")[1]; return x ? Math.min(3, x.length) : 0; }
543
+ }
544
+ };
545
+ function fmt(v, dg){
546
+ var s = Math.abs(v).toFixed(dg).split("."), i = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
547
+ var neg = v < 0 && +Math.abs(v).toFixed(dg) !== 0;
548
+ return (neg ? "−" : "") + i + (s[1] ? "." + s[1] : "");
549
+ }
550
+ });
@@ -0,0 +1,28 @@
1
+ ---
2
+ summary: Rotate validation folds
3
+ steps: Rows → mean (k+1)
4
+ props:
5
+ dur: Seconds
6
+ size: Text px
7
+ ---
8
+
9
+ JSON:
10
+ - `k`: 2–10; k=5: ≥316px tall (264 without errors)
11
+ - `errors`: k errors (optional).
12
+ - `labels`: k names (optional).
13
+
14
+ <!-- llm: omit -->
15
+ Equal blocks. Row i validates block i: emph tint + outline; training: term tint. Legend explains outline. Blocks ≥40px with enough height: T/V; short rows drop letters first, retaining the legend and outlines. Names once above. Errors/mean: 2 decimals. Final rule and mean below errors; omitted errors leave completed splits at k+1.
16
+
17
+ Wrong lengths, negative errors or invalid k: report, no draw. dur 1s; size 0=26px, ≥24. Bad props default/report.
18
+
19
+ Suggested width: 1184px. Rows shrink from ~46px to 32px before reporting. At default 26px text, minimum height = ceil(99.4+32k+56.1) = **156+32k px** with errors; **104+32k px** without. k=5: 316/264px; k=10: 476/424px. Compact row numbers/errors use monospace.
20
+
21
+ General: f=text px, L=1.45f+4, R=max(32,ceil(1.2f)); minimum=ceil(2L+16+kR+footer+4), footer=L+.4f with errors, else 0. Size reports give k, required/current height and its terms; legend width needed/available; label index and width needed/available.
22
+
23
+ ctx.lang selects ja/en. Font boxes ≥1.43em plus gap. Image role, final summary; preserve author label, hide SVG. No answer preview. Fictional demo.
24
+ <!-- llm: end -->
25
+
26
+ <!-- llm: omit -->
27
+ Per-sample splits (2.1.0): `splits` (`test`, `train` indices) and `samples` (`class`, `group`, `t`) from `uv run tools/sk2ega.py model_selection`. `splitter`: KFold, StratifiedKFold, GroupKFold, TimeSeriesSplit, ShuffleSplit, holdout. Checks: KFold-type splitters test each sample once; groups stay together; time series train on the past; stratified class counts within 1; one holdout split. Class colours: `--series-1`, `--series-3`, `--fg`, `--series-4` in that order, as in m-classify2d. Up to 60 samples and 10 splits.
28
+ <!-- llm: end -->