lookatstudy-mobile 0.31.2 → 0.31.3

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 (134) hide show
  1. package/package.json +1 -1
  2. package/server.cjs +57 -3
  3. package/web/assets/{CanvasStage-BbqLSbD4.js → CanvasStage-Ccxan7wh.js} +1 -1
  4. package/web/assets/{CommandPalette-DQ5w84ic.js → CommandPalette-D8HzDvja.js} +1 -1
  5. package/web/assets/{CourseSearchPanel-ThxY4JL1.js → CourseSearchPanel-Dp11zUeA.js} +1 -1
  6. package/web/assets/{ExamView-DVLRcljJ.js → ExamView-BkOpDSyH.js} +1 -1
  7. package/web/assets/{ReviewPanel-D1jKVMQK.js → ReviewPanel-CyvrUQ9n.js} +1 -1
  8. package/web/assets/{SettingsView-BHoTkY38.js → SettingsView-DWTo5AIC.js} +2 -2
  9. package/web/assets/{VoicePanel-BP1Ur7sF.js → VoicePanel-CZfLESc_.js} +1 -1
  10. package/web/assets/{abnfDiagram-VCTEODGH-Ca-5zS8J.js → abnfDiagram-VCTEODGH-CPRwAUhv.js} +1 -1
  11. package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-ZI6_0Jfq.js → abnfDiagram-VCTEODGH-ODA7YWAP-Dp2Ugi00.js} +1 -1
  12. package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-B2bOUqy0.js → architectureDiagram-5GKGNRK7-C4PU3XN7-BSi9GIa8.js} +1 -1
  13. package/web/assets/{architectureDiagram-5GKGNRK7-DCEYr1uX.js → architectureDiagram-5GKGNRK7-CratLAN7.js} +1 -1
  14. package/web/assets/{arrow-right---oCZhx2.js → arrow-right-BsX3ZJnE.js} +1 -1
  15. package/web/assets/{blockDiagram-I7D4REHJ-Dx9xiTwp.js → blockDiagram-I7D4REHJ-D53LWAaI.js} +1 -1
  16. package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-Do5yGQuh.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-ydsf1o4S.js} +1 -1
  17. package/web/assets/{c4Diagram-7LVT6UL2-DXh9Ebug.js → c4Diagram-7LVT6UL2-zyk0vkS1.js} +1 -1
  18. package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-DH7ShBLp.js → c4Diagram-UCG6FXSJ-75X3U2P3-DoTJpJZT.js} +1 -1
  19. package/web/assets/channel-D1pzr5s8.js +1 -0
  20. package/web/assets/{chunk-2Q5K7J3B-Bbluh_im.js → chunk-2Q5K7J3B-Bb-Fbn7J.js} +1 -1
  21. package/web/assets/{chunk-5VM5RSS4-CwJZ1eAQ.js → chunk-5VM5RSS4-BUnm5mZw.js} +1 -1
  22. package/web/assets/{chunk-7XDTSPCN-3TtQfLC2.js → chunk-7XDTSPCN-BJpcbmYi.js} +1 -1
  23. package/web/assets/{chunk-CTNIYPP6--48noAMq.js → chunk-CTNIYPP6-_5LkeW58.js} +1 -1
  24. package/web/assets/{chunk-CXNFBKHE-BMfLUSYr.js → chunk-CXNFBKHE-Cl_w1xK3.js} +1 -1
  25. package/web/assets/{chunk-F27PBJKO-DQz5Eh8R.js → chunk-F27PBJKO-DOnNDX_T.js} +1 -1
  26. package/web/assets/{chunk-IMKFNOWR-mEHtzDJe.js → chunk-IMKFNOWR-DcOUgIY6.js} +1 -1
  27. package/web/assets/{chunk-ISA7TJRJ-Cua7d2fi.js → chunk-ISA7TJRJ-4ehz2eVS.js} +1 -1
  28. package/web/assets/{chunk-JWPE2WC7-DqWkk9f8.js → chunk-JWPE2WC7-gdjQngWd.js} +1 -1
  29. package/web/assets/{chunk-LV3HUYFY-BCzMQT8Q.js → chunk-LV3HUYFY-0dwD8rCC.js} +1 -1
  30. package/web/assets/{chunk-M3IUQBOH-B-r9ydC6.js → chunk-M3IUQBOH-kelT6RI-.js} +1 -1
  31. package/web/assets/{chunk-NDIOYS4C-DkAwrWHj.js → chunk-NDIOYS4C-DO0anlkR.js} +1 -1
  32. package/web/assets/{chunk-POPQ4Y6H-BjpioqkZ.js → chunk-POPQ4Y6H-v0VjJgg_.js} +1 -1
  33. package/web/assets/{chunk-RE4WF27V-CJEnGv6g.js → chunk-RE4WF27V-DxIwGJut.js} +1 -1
  34. package/web/assets/{chunk-SVP7TREG-DGaiaQgi.js → chunk-SVP7TREG-L0IIA3ui.js} +1 -1
  35. package/web/assets/{chunk-TICWLB2K-DqXyoflV.js → chunk-TICWLB2K-DGxX8kin.js} +1 -1
  36. package/web/assets/{chunk-VII2H2IX-CHqS8QXi.js → chunk-VII2H2IX-CPilSdxU.js} +1 -1
  37. package/web/assets/{chunk-X5GNSKZ3-CPiurspk.js → chunk-X5GNSKZ3-C6884RNs.js} +1 -1
  38. package/web/assets/{chunk-XCWWM2C3-CnpRc-BX.js → chunk-XCWWM2C3-CqqN87BO.js} +1 -1
  39. package/web/assets/{chunk-XXDRQBXY-xXPgDheN.js → chunk-XXDRQBXY-DWCWq3oG.js} +1 -1
  40. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-bHJ5LzCU.js +1 -0
  41. package/web/assets/classDiagram-ZZMXUADV-B1mvkdHx.js +1 -0
  42. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-bHJ5LzCU.js +1 -0
  43. package/web/assets/classDiagram-v2-VYDZK3BY-B1mvkdHx.js +1 -0
  44. package/web/assets/{core-iYZpQJa6.js → core-4rNLJNcM.js} +1 -1
  45. package/web/assets/{cose-bilkent-JH36ORCC-Dr_WUhVB.js → cose-bilkent-JH36ORCC-BRAHxXkx.js} +1 -1
  46. package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-CQsWVK5X.js → cose-bilkent-JH36ORCC-OB24KH3T-PEuVsnbK.js} +1 -1
  47. package/web/assets/{cynefin-OW5HDTMX-fybCqBi3.js → cynefin-OW5HDTMX-B96xQPn_.js} +1 -1
  48. package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-DwLRaQ37.js → cynefin-OW5HDTMX-GVF3BKWE-CmwiFdFp.js} +1 -1
  49. package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-D7Mzcgjs.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-BS4Rn_lU.js} +1 -1
  50. package/web/assets/{cynefinDiagram-5FMLGOSQ-BLqywzF8.js → cynefinDiagram-5FMLGOSQ-WsNJrzND.js} +1 -1
  51. package/web/assets/{dagre-3AP2YEHR-DCERTXHT-C3dpohva.js → dagre-3AP2YEHR-DCERTXHT-DqLa7f22.js} +1 -1
  52. package/web/assets/{dagre-GXQ25YYZ-QPjECY_W.js → dagre-GXQ25YYZ-ChTZSRWH.js} +1 -1
  53. package/web/assets/{diagram-S7CK7UJ4-CwZRApeF.js → diagram-S7CK7UJ4-Cte8nBIL.js} +1 -1
  54. package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-Czqn_Fna.js → diagram-S7CK7UJ4-MULGZGEL-DrYBAuoV.js} +1 -1
  55. package/web/assets/{diagram-UQ7AKVKN-Bo8gzrdx.js → diagram-UQ7AKVKN-BdhZy6LW.js} +1 -1
  56. package/web/assets/{diagram-UQ7AKVKN-YQBY353J-CgDXcRAT.js → diagram-UQ7AKVKN-YQBY353J-SIQXtTtG.js} +1 -1
  57. package/web/assets/{diagram-VSXAHHWV-0w4db5zY.js → diagram-VSXAHHWV-C9IXdf46.js} +1 -1
  58. package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-DbTl04rE.js → diagram-VSXAHHWV-WLNH2ELY-eoBcSKFt.js} +1 -1
  59. package/web/assets/{diagram-VX7I27RA-DJvH_pmt.js → diagram-VX7I27RA-CFTomYjh.js} +1 -1
  60. package/web/assets/{diagram-VX7I27RA-XW6YQV5G-fzWHr6UJ.js → diagram-VX7I27RA-XW6YQV5G-Bd1uZFA4.js} +1 -1
  61. package/web/assets/{diagram-Z3DM3KII-DsT5qGVe.js → diagram-Z3DM3KII-Dqfg4VTQ.js} +1 -1
  62. package/web/assets/{diagram-Z3DM3KII-HG7RF65D-CDqb1-LL.js → diagram-Z3DM3KII-HG7RF65D-BwiG8Jl0.js} +1 -1
  63. package/web/assets/{ebnfDiagram-PWID7BFC-BoB0yBxV.js → ebnfDiagram-PWID7BFC-Cxj0Vv3C.js} +1 -1
  64. package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-Dl7tZHv0.js → ebnfDiagram-PWID7BFC-OKY4VHYD-CBeGh1kf.js} +1 -1
  65. package/web/assets/{erDiagram-RLTQ6QDP-TcPkrxxF.js → erDiagram-RLTQ6QDP-g318DvBL.js} +1 -1
  66. package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-C13XODn3.js → erDiagram-SSCWMZ5O-PIPKOIK7-B-Gfdf5U.js} +1 -1
  67. package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-DNbmNTnm.js → flowDiagram-A5DVABFB-2Z4AVO5R-CCYPuJH_.js} +1 -1
  68. package/web/assets/{flowDiagram-HODETNUW-D2o5XxIm.js → flowDiagram-HODETNUW-B9oC9dAn.js} +1 -1
  69. package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-C5IgtJLL.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-7FynKk0s.js} +1 -1
  70. package/web/assets/{ganttDiagram-EL5Y4UJY-D36iMZvH.js → ganttDiagram-EL5Y4UJY-hu6hQzSA.js} +1 -1
  71. package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-BA7YVBKU.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-CLS0NrEQ.js} +1 -1
  72. package/web/assets/{gitGraphDiagram-WWUBYQGX-DoayvLMW.js → gitGraphDiagram-WWUBYQGX-yTtXkuKU.js} +1 -1
  73. package/web/assets/{index-DtMB_WdP.js → index-BTHtdpYN.js} +1 -1
  74. package/web/assets/{index-Zmq94tKz.js → index-Brv5KtDR.js} +3 -3
  75. package/web/assets/{index-5UvRMS_e.js → index-DJ_vjgYj.js} +1 -1
  76. package/web/assets/{infoDiagram-27XIBGKW-DbMBXMvx.js → infoDiagram-27XIBGKW-c42LSbRO.js} +1 -1
  77. package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-NdEBDyb0.js → infoDiagram-RXCK75RN-HANS5KVC-CVdQLogu.js} +1 -1
  78. package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-CzqV69s-.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-BE12eSht.js} +1 -1
  79. package/web/assets/{ishikawaDiagram-5VMMS53U-j9THtiQE.js → ishikawaDiagram-5VMMS53U-DzJncJmv.js} +1 -1
  80. package/web/assets/{journeyDiagram-3NMN7TZE-C3h3msUP.js → journeyDiagram-3NMN7TZE-wTWsGARh.js} +1 -1
  81. package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-ChETfPiS.js → journeyDiagram-EYS64GPL-OAPELBT7-DYBkNRJQ.js} +1 -1
  82. package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-Wjr70XLu.js → kanban-definition-3QL26DDD-I7RKWQQY-DXa9FemT.js} +1 -1
  83. package/web/assets/{kanban-definition-UXKFOSKX-C1b6cL5N.js → kanban-definition-UXKFOSKX-M71sF3uC.js} +1 -1
  84. package/web/assets/{katex-N6JRN4PM-BIpBcqrZ.js → katex-N6JRN4PM-vlvahC1J.js} +1 -1
  85. package/web/assets/{layout-D2XzcM9d.js → layout-CDVV66Zl.js} +1 -1
  86. package/web/assets/{main-Dj875aWF.js → main-CmX_gEtO.js} +8 -8
  87. package/web/assets/{mermaid-layout-elk.core-CNNSrMhF.js → mermaid-layout-elk.core-VAQhTNif.js} +2 -2
  88. package/web/assets/{mermaid.core-CnNeOEec.js → mermaid.core-BBr71c1E.js} +5 -5
  89. package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-CE91aZQc.js → mindmap-definition-FBJOCRG2-KIYZG64Y-BJs0jBiv.js} +1 -1
  90. package/web/assets/{mindmap-definition-YA3MSWOX-Dz0JwUgH.js → mindmap-definition-YA3MSWOX-5jMWortW.js} +1 -1
  91. package/web/assets/{pegDiagram-XKGWAZYB-BEOg8IHd.js → pegDiagram-XKGWAZYB-DWJAfH3i.js} +1 -1
  92. package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-CB6_i_dk.js → pegDiagram-XKGWAZYB-OIP57N6J-SoiZ0uez.js} +1 -1
  93. package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-C_aP-GDD.js → pieDiagram-E7YTZNPT-2UOTW327-4wOQMxnh.js} +1 -1
  94. package/web/assets/{pieDiagram-E7YTZNPT-Btcl-uz0.js → pieDiagram-E7YTZNPT-CcLjyCkM.js} +1 -1
  95. package/web/assets/{quadrantDiagram-AXDQQJYC-CA7HBTBO.js → quadrantDiagram-AXDQQJYC-Df75lDtG.js} +1 -1
  96. package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-CAd5tIhG.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-CTIClnUv.js} +1 -1
  97. package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-CLWiLZG6.js → railroadDiagram-O6MQD6OU-34742W6X-BUdIAX73.js} +1 -1
  98. package/web/assets/{railroadDiagram-O6MQD6OU-B7dkMwzi.js → railroadDiagram-O6MQD6OU-CGPAxOfe.js} +1 -1
  99. package/web/assets/{render-O7CIS3YK-DQb_czkx.js → render-O7CIS3YK-BysEI-dU.js} +7 -7
  100. package/web/assets/{requirementDiagram-BXWQKSXE-C70GJhMZ.js → requirementDiagram-BXWQKSXE-DmpSPAPs.js} +1 -1
  101. package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-Bc0CRxi2.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-C658Njt8.js} +1 -1
  102. package/web/assets/{rotate-ccw-JEjtXKlH.js → rotate-ccw-D1E9nBsz.js} +1 -1
  103. package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-B9PL6--N.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-0LGs5Ekr.js} +1 -1
  104. package/web/assets/{sankeyDiagram-P5KCCOFB-BJl2AqaQ.js → sankeyDiagram-P5KCCOFB-8tWaAOQW.js} +1 -1
  105. package/web/assets/{sequenceDiagram-WJ2MYXX4-DtmTM2Q1.js → sequenceDiagram-WJ2MYXX4-Cu8XQLW7.js} +1 -1
  106. package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-DH1L8a7Q.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-Do020RsJ.js} +1 -1
  107. package/web/assets/{sizeCapture-INFHLROL-e9akerky.js → sizeCapture-INFHLROL-C4il96Zo.js} +1 -1
  108. package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-CSyLq32l.js → sizeCapture-X5ZJPWSS-PSGVOMYM-Dl4mKOl5.js} +1 -1
  109. package/web/assets/{stateDiagram-D77RDMKH-Dc057ccO.js → stateDiagram-D77RDMKH-DZehEkpF.js} +1 -1
  110. package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-D_uV5i1Q.js → stateDiagram-HBIQ2CUA-4M2S6MAN-CVgF7-_1.js} +1 -1
  111. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-Bte2wVWv.js +1 -0
  112. package/web/assets/stateDiagram-v2-MP3YSRHH-v1GXQ5wD.js +1 -0
  113. package/web/assets/{swimlanes-42K2YHIH-ILKBiMPk.js → swimlanes-42K2YHIH-BQWg4acA.js} +1 -1
  114. package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-CJ7qUhPg.js → swimlanes-XN3QIQJK-N6N2CCQ6-DekhJu9e.js} +1 -1
  115. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-zx5EFXza.js +8 -0
  116. package/web/assets/swimlanesDiagram-VR7AAH4N-BQyNIwz7.js +8 -0
  117. package/web/assets/{timeline-definition-24CTP7MA-BckRkRye.js → timeline-definition-24CTP7MA-BT6KUlBa.js} +1 -1
  118. package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-DxSbNuQs.js → timeline-definition-24CTP7MA-KN7RSRVM-Du30VadP.js} +1 -1
  119. package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-hG9roRh0.js → vennDiagram-4TSXK5OY-AKJ7LXAN-DQjUgbCT.js} +1 -1
  120. package/web/assets/{vennDiagram-4TSXK5OY-Bxkq0y0p.js → vennDiagram-4TSXK5OY-DTkmcJDL.js} +1 -1
  121. package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-CLmKLRJP.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-BDk6JeO1.js} +1 -1
  122. package/web/assets/{wardleyDiagram-VM6X3IG4-CaTbamBI.js → wardleyDiagram-VM6X3IG4-C-NFt9uI.js} +1 -1
  123. package/web/assets/{xychartDiagram-S5SC5T6Z-CHtC3u6M.js → xychartDiagram-S5SC5T6Z-CxTqubEh.js} +1 -1
  124. package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-ZjDcqfTl.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-CcfG2mA9.js} +1 -1
  125. package/web/index.html +1 -1
  126. package/web/assets/channel-CNRWz7VW.js +0 -1
  127. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-C5s2iR9J.js +0 -1
  128. package/web/assets/classDiagram-ZZMXUADV-Cjli-tvb.js +0 -1
  129. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-C5s2iR9J.js +0 -1
  130. package/web/assets/classDiagram-v2-VYDZK3BY-Cjli-tvb.js +0 -1
  131. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-DBkBTIqA.js +0 -1
  132. package/web/assets/stateDiagram-v2-MP3YSRHH-D6iIkIH3.js +0 -1
  133. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-lkgr5sGZ.js +0 -8
  134. package/web/assets/swimlanesDiagram-VR7AAH4N-D-ke9u7H.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CourseSearchPanel-ThxY4JL1.js","./index-CJuEfFQr.js","./index-CvvLDKMx.css","./index-5UvRMS_e.js","./index-DtMB_WdP.js","./cpp-DddhVWhK.js","./c-BIGW1oBm.js","./ruby-B6QtyW_S.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./sql-CRqJ_cUM.js","./graphql-ChdNCCLP.js","./typescript-BPQ3VLAy.js","./jsx-g9-lgVsj.js","./tsx-COt5Ahok.js","./shellscript-Yzrsuije.js","./lua-BaeVxFsk.js","./yaml-Buea-lGh.js","./php-Csjmro_R.js","./json-Cp-IABpG.js","./scss-D5BDwBP9.js","./latex-B2nUCzCX.js","./r-Cf5RLm7j.js","./vue-CHlpWS_5.js","./core-iYZpQJa6.js","./index-Zmq94tKz.js","./CanvasStage-BbqLSbD4.js","./arrow-right---oCZhx2.js","./rotate-ccw-JEjtXKlH.js","./ReviewPanel-D1jKVMQK.js","./VoicePanel-BP1Ur7sF.js","./SettingsView-BHoTkY38.js","./ExamView-DVLRcljJ.js","./CommandPalette-DQ5w84ic.js","./CompanionBotLab-4Juuhsy3.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CourseSearchPanel-Dp11zUeA.js","./index-CJuEfFQr.js","./index-CvvLDKMx.css","./index-DJ_vjgYj.js","./index-BTHtdpYN.js","./cpp-DddhVWhK.js","./c-BIGW1oBm.js","./ruby-B6QtyW_S.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./sql-CRqJ_cUM.js","./graphql-ChdNCCLP.js","./typescript-BPQ3VLAy.js","./jsx-g9-lgVsj.js","./tsx-COt5Ahok.js","./shellscript-Yzrsuije.js","./lua-BaeVxFsk.js","./yaml-Buea-lGh.js","./php-Csjmro_R.js","./json-Cp-IABpG.js","./scss-D5BDwBP9.js","./latex-B2nUCzCX.js","./r-Cf5RLm7j.js","./vue-CHlpWS_5.js","./core-4rNLJNcM.js","./index-Brv5KtDR.js","./CanvasStage-Ccxan7wh.js","./arrow-right-BsX3ZJnE.js","./rotate-ccw-D1E9nBsz.js","./ReviewPanel-CyvrUQ9n.js","./VoicePanel-CZfLESc_.js","./SettingsView-DWTo5AIC.js","./ExamView-BkOpDSyH.js","./CommandPalette-D8HzDvja.js","./CompanionBotLab-4Juuhsy3.js"])))=>i.map(i=>d[i]);
2
2
  var x1=Object.defineProperty;var b1=(e,t,n)=>t in e?x1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ea=(e,t,n)=>b1(e,typeof t!="symbol"?t+"":t,n);import{r as k,p as y1,j as x,a as Wu,g as Al,u as Cl,q as $u,c as us,t as E1,v as So,w as v1,x as T1,y as Ht,z as k1,A as w1,B as S1,F as Yu,D as Gu,E as A1,G as C1,H as _1,I as Ku,J as Xu,K as I1,L as N1,N as R1,s as L1,m as Vi,O as P1,P as Qu,o as Ao,M as M1,Q as D1,R as Ju,S as qi,T as O1,U as F1,W as va,d as Kt,X as Zu,Y as B1,Z as ec,_ as j1,$ as H1,a0 as U1,a1 as z1,a2 as V1,a3 as q1,a4 as W1,a5 as tc,a6 as Dn,a7 as $1,a8 as Y1,a9 as G1,aa as nc,ab as K1,ac as X1,ad as Q1,ae as J1,af as _l}from"./index-CJuEfFQr.js";const Z1="modulepreload",ex=function(e,t){return new URL(e,t).href},rc={},we=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let a=function(c){return Promise.all(c.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=a(n.map(c=>{if(c=ex(c,r),c in rc)return;rc[c]=!0;const f=c.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(!!r)for(let p=o.length-1;p>=0;p--){const g=o[p];if(g.href===c&&(!f||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${h}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":Z1,f||(m.as="script"),m.crossOrigin="",m.href=c,u&&m.setAttribute("nonce",u),document.head.appendChild(m),f)return new Promise((p,g)=>{m.addEventListener("load",p),m.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return t().catch(i)})};/**
3
3
  * @license lucide-react v0.468.0 - ISC
4
4
  *
@@ -375,7 +375,7 @@ var x1=Object.defineProperty;var b1=(e,t,n)=>t in e?x1(e,t,{enumerable:!0,config
375
375
  3. 我会点选项猜,你【下一回合】再揭晓,顺带把这课最核心的一点讲清楚。
376
376
  铁律:起手不要讲座、不要用 generate_quiz 出计分题、不要计分。把我勾住是唯一目标。`,"starter.go-deeper.label":"深入这点","starter.go-deeper.hint":"把刚揭晓的概念讲深一层","starter.go-deeper.message":"帮我深入讲讲「{title}」刚才那个核心点——展开它的结构、细节和容易忽略的边界。","starter.give-example.label":"举个例子","starter.give-example.hint":"用真实例子帮你看懂","starter.give-example.message":"给我一个「{title}」的实际例子或用法,让我更具体地理解。","starter.quiz-me.label":"考考我","starter.quiz-me.hint":"出题检验(答对涨掌握度)","starter.quiz-me.message":"出一道关于「{title}」的应用题考考我,看我是否真懂了——我答完请判断对错。","starter.confused.label":"我没太懂","starter.confused.hint":"告诉 AI 你卡在哪(会记下)","starter.confused.message":"关于「{title}」,我有地方不太懂,帮我理一理——先问我是哪里不清楚。","map.world.study":"学习","map.world.practice":"实操","pane.switcher":"视图切换","pane.map":"课程","pane.chat":"导师","pane.notes":"黑板","pane.resizeTooltip":"拖拽调整栏宽,双击恢复默认","pane.resizeRailAria":"调整课程栏宽度","pane.resizeChatAria":"调整导师栏宽度","map.streaming.notice":"AI 正在后台回答,可随意切换节点","map.generating":"正在生成课程路径…","map.empty.cta.title":"开始你的第一门课","map.empty.cta.desc":"导入一个 GitHub 学习仓库,自动生成选关路径","map.empty.cta.btn":"点这里导入 →","map.empty.practice":"这个课程暂无实操练习内容","node.locked.chapterHint":"(完成本章所有课时后解锁)","node.due.hint":"(待复习)","import.empty":"还没有课程。用下方导入第一个吧。","import.cta":"导入新课程","import.tab.url":"URL","import.tab.md":"MD","import.tab.folder":"文件夹","import.url.placeholder":"GitHub 仓库 / 网页文章 / arXiv 论文 链接","import.url.desc":"粘贴任意链接自动识别:GitHub 仓库 / arXiv 论文 / 网页文章 / B站·YouTube 视频(转写成课;B站多分P 不带 ?p= 导整季;更多站点需自装 yt-dlp)。","import.btn.url":"导入","import.btn.url.busy":"导入中…","import.placeholder.name":"课程名称(可选)","import.placeholder.md":"粘贴任意长文本或 Markdown…(没有小标题会自动分段)","import.btn.md":"导入为课程","import.btn.md.busy":"生成中…","import.folder.desc":"递归扫描 .txt/.md/.html/.pdf,适合已下载的课程资料包。","import.btn.folder":"选择文件夹","import.tab.epub":"电子书","import.epub.desc":"EPUB 电子书按章节拆课(章节边界来自书的目录与书脊顺序)。","import.btn.epub":"选择 EPUB 文件导入","import.tab.audio":"音频","import.audio.desc":"播客/讲座音频或本地视频(mp4)本地转写成课(音频 wav/mp3/m4a/flac,视频 mp4/m4v/mov,可多选=多集)。首次使用自动下载 Whisper 模型(约 1GB)。","import.btn.audio":"选择音频文件导入","import.tab.pack":"课程包","import.btn.pack":"选择课程包文件导入","import.pack.desc":"课程包是别人分享的导入方案快照(零 AI 调用,秒过分类和结构设计)。GitHub 仓库内容一致时直接复用;有更新会自动丢弃消失文件对应的课。","import.export":"导出","import.folder.pathPlaceholder":"服务器侧文件夹路径(如 /storage/emulated/0/Download/我的课程)","import.folder.pathRequired":"请填写服务器侧文件夹路径","import.pack.export":"导出课程包(分享给别人零 AI 导入)","import.pack.exported":"课程包已导出:{path}","import.error.resume":"从断点重试(跳过已完成的 AI 步骤)","import.success.reused":"复用已有方案,零 AI 调用","import.btn.folder.busy":"处理中…","import.delete":"删除","import.delete.confirm":"所有进度和练习都会清除,无法撤销。","import.delete.current":"删除当前课程","course.empty.title":"选择一门课程开始学习","course.empty.desc":"从左侧「导入课程」面板选择一门已导入的课程,或导入新课程。","import.success.md":"生成成功","import.success.folder":"导入成功","import.error.network":`
377
377
 
378
- 网络受限或私有仓库请改用「Markdown」方式。`,"import.progress.elapsed":"已 {s}s","import.progress.title":"正在导入课程…","import.progress.starting":"正在启动…","import.progress.note":"导入在后台进行,可继续浏览其他课程","import.progress.cancel":"取消导入","import.cancelled":"已取消导入","toast.threadCreateFailed":"创建失败了,再试一次","toast.threadCreated":"新对话","toast.threadRenamed":"已重命名","toast.threadArchived":"已归档","toast.threadDeleted":"已删除","toast.threadDefault":"新会话","toast.restored":"已恢复","toast.noteSaved":"已加到笔记","toast.noteDeleted":"已删除笔记","toast.artifactSaved":"已记到笔记本","artifact.type.concept_map":"概念图","artifact.type.quiz":"练习题","artifact.type.compare_table":"对比表","artifact.type.diagram":"流程图","artifact.type.code_walkthrough":"代码讲解","artifact.type.unknown":"产物","command.placeholder":"输入指令或问题…(↑↓ 选择,Enter 确认)","command.empty.node":"没有匹配的命令","command.empty.nonode":"先在左侧选一个节点,才能用这些命令","command.footer.hint":"AI 导师会根据指令生成对应内容","command.footer.keys":"↵ 确认 · esc 关闭","command.group.node":"基于当前节点","command.group.mode":"学习模式","command.group.nav":"导航","command.explain_simple":"用大白话解释这一节","command.quiz_3":"出 3 道练习题考考我","command.concept_map":"画个概念图理清结构","command.compare_prev":"和上一节做对比表","command.socratic":"切到苏格拉底模式(提问引导)","command.exam_mode":"切到考试冲刺模式","review.title":"复习","review.nudge":"📅 今天有 {n} 个待复习,点左侧地图的「复习」入口巩固一下","review.loading":"正在检查哪些课该复习了…","review.empty.title":"还没有复习项","review.empty.desc":"完成一些练习后,这里会出现间隔复习提醒","review.due.count":"个待复习","review.start":"开始复习","review.shuffle":"混合练习(随机交错)","review.interleave":"交错复习","review.reviewLesson":"复习该课","review.selectSection":"选择章节","review.dueIn":"待复习","review.noDueInSection":"该章节暂无待复习内容","review.srsHint":"复习提醒","review.myProgress":"我的课程进度","review.overdueQuickHint":"逾期项,点击直接复习","review.quadrant.overdue":"逾期","review.quadrant.short":"短期","review.quadrant.long":"长期","review.quadrant.inactive":"待激活","review.quadrant.more":"更多","review.tip":"复习采用 SM-2 间隔重复算法。逾期项优先复习;长期记忆项间隔更长。单次复习封顶 {n} 题,避免积压压垮节奏。","review.selfrated":"✓ 已记录,掌握度已更新","review.selfrate.title":"复习完了吗?给自己打分","review.selfrate.again":"忘了","review.selfrate.again.hint":"明天重练","review.selfrate.remembered":"记得","review.selfrate.remembered.hint":"推迟几天","review.selfrate.mastered":"很熟","review.selfrate.mastered.hint":"很久后再看","lang.original":"原文","error.checkReadyFailed":"无法检查就绪状态","notebook.tab.explain":"讲解","notebook.tab.notes":"笔记","notebook.tab.board":"黑板","notebook.board.empty":"对话里产生概念图、流程图、对比表、代码讲解时,这里会实时展示最新的一幅大图,方便边看边问。","notebook.zone.understand":"理解","notebook.zone.note":"记录","notebook.zone.practice":"练习","notebook.empty.explain.title":"选一节课开始","notebook.empty.explain.desc":"在左侧地图选一个课时,这里会显示讲解内容","notebook.empty.notes.title":"还没有笔记","notebook.empty.notes.desc":"选中讲解文字画线,或让 AI 生成概念图/对比表,会出现在这里","settings.group.ai":"主模型","settings.group.speech":"语音模型","settings.group.vision":"看图模型","settings.group.appearance":"外观与语言","settings.group.data":"数据","settings.dsh.title":"从 dsh 插件迁移学习进度","settings.dsh.desc":"导入 dsh-plugin-lookatstudy 的课程、掌握度、复习计划、考试星数、XP 与连续天数。导入前自动备份;重复导入安全,同名同结构课程直接写入不另建副本。","settings.dsh.detectFound":"检测到本机插件数据(state v{v})","settings.dsh.detectNone":"未检测到本机 dsh 插件数据——可点击下方按钮选择 state.json 文件导入。","settings.dsh.import":"导入","settings.dsh.pickFile":"选择 state.json 导入","settings.dsh.importing":"导入中…","settings.dsh.done":"已导入:{courses} 门课程 · {nodes} 节点 · {progress} 条进度 · {srs} 条复习 · XP +{xp}","settings.dsh.skipped":"跳过 {n} 门无效课程","settings.dsh.failed":"导入失败","settings.group.about":"关于","settings.row.version":"版本","settings.version.hint":"点版本号可查看该版的更新内容。","settings.row.provider":"服务商","settings.row.theme":"主题","settings.row.interface_lang":"界面语言","settings.row.import_lang":"导入偏好","settings.custom.form_title":"添加自定义 Provider","settings.footer.hint":"主模型区的改动需保存后生效,其余即时生效","settings.footer.save":"保存 AI 配置","header.energy":"今日能量","header.level.title":"等级(累计经验值的持久成长线,不随每日能量清零)","settings.title":"设置","view.tree":"技能树","view.dashboard":"仪表盘","view.import":"导入课程","mode.chat":"💬 对话","mode.exercise":"📝 练习","mode.settings":"⚙️ 设置","chat.starter.hint":"💡 从下面选一个开始,或者直接输入你的问题","chat.no_key.title":"还没有配置 AI 模型","chat.no_key.desc":"配置后即可开始 AI 导师对话和练习","chat.no_key.btn":"去配置模型","chat.input.placeholder":"问 AI 导师…(Enter 发送)","chat.input.no_node":"先在左侧选一个 lesson…","chat.send":"发送","chat.stop":"停止","chat.clear":"清空对话历史","chat.selection.quote":"提问这段","chat.soul.label":"风格:","chat.no_key.short":"未配置 AI 模型","chat.no_key.cta":"去配置 →","chat.attach.add":"添加图片或文件(可粘贴 / 拖拽)","chat.attach.remove":"移除 {name}","chat.attach.tooMany":"一条消息最多 {n} 个附件","chat.attach.tooLargeImage":"图片超过 5MB:{name}","chat.attach.tooLargeText":"文本文件超过 256KB:{name}","chat.attach.unsupported":"暂不支持该类型:{name}(支持图片与常见文本 / 代码文件)","chat.attach.visionUnsupported":"当前模型不支持看图,请用右侧模型切换器选一个带眼睛图标的模型,或在设置 → AI 看图里配置视觉模型覆盖","chat.attach.bridgeChip":"主模型是纯文本:图片将先由 {model} 转译成文字再交给它","chat.attach.preview":"查看 {name}","chat.attach.textChip":"文本附件,内容已随消息发给 AI","chat.attach.imageOnlyText":"请看这张图片。","context.label":"上下文","context.aria":"上下文已用 {p}","context.approx":"约","context.system":"系统提示","context.node":"课文","context.learner":"学习者状态","context.history":"对话历史","context.draft":"草稿","context.unknownWindow":"模型窗口未知","model.picker.label":"模型","model.picker.manage":"管理模型与密钥…","model.picker.vision":"支持看图","model.picker.noneConfigured":"还没有配置任何 provider 密钥","effort.label":"思考强度","effort.auto.label":"自动","effort.auto.desc":"模型默认行为,不干预","effort.fast.label":"快速","effort.fast.desc":"尽量关思考,答得快、省 token","effort.deep.label":"深度","effort.deep.desc":"尽量开思考,难题多想几步","effort.unsupported":"当前 provider 暂不支持思考强度切换","soul.direct":"精讲","soul.guide":"引导","soul.practice":"实战","soul.direct.desc":"精讲派 · 新手/想搞懂时用。先讲清楚再确认,给完整范例,不让你猜","soul.guide.desc":"引导派 · 有点基础、想自己推时用。不直接给答案,用引导性问题帮你推导","soul.practice.desc":"实战派 · 想动手时用。围绕真实世界的乱问题,在做中把概念织成网","settings.provider":"AI 服务商(Provider)","settings.model":"模型(Model)","settings.apikey":"API Key","settings.test":"测试连接","settings.testing":"测试中…","settings.save":"保存设置","settings.saved":"✅ 已保存","settings.daily_goal":"每日学习目标(XP)","settings.custom.add":"+ 添加自定义 Provider","settings.language":"语言(Language)","settings.add_custom":"自定义","settings.custom.label_ph":"名称","settings.custom.baseurl_ph":"Base URL(如 https://api.example.com/v1)","settings.custom.model_ph":"模型 ID","settings.custom.new":"新建自定义","settings.custom.form_title_vision":"配置看图模型(自定义 provider)","settings.custom.model_ph_vision":"如 glm-4.6v / gpt-4o","settings.custom.form_title_tts":"配置朗读 provider(OpenAI 兼容 /audio/speech 端点)","settings.custom.model_ph_tts":"如 tts-1 / FunAudioLLM/CosyVoice2-0.5B","settings.custom.form_title_asr":"配置听写 provider(OpenAI 兼容 /audio/transcriptions 端点)","settings.custom.model_ph_asr":"如 whisper-large-v3-turbo","settings.custom.apikey_ph":"API Key(可选)","settings.custom.save":"保存","settings.custom.windowLabel":"上下文窗口(tokens)","settings.custom.windowPh":"如 128000 或 128k(留空 = 未知)","settings.custom.windowHint":"当前模型的最大上下文,可在模型官方文档查到。填了输入框旁的上下文表才会显示占比。","settings.custom.vision":"支持看图(多模态)","settings.custom.visionHint":"勾选后系统将图片直接发给主模型;不勾选则走视觉转译桥(需在 AI 看图区配视觉模型)或跳过图片。","settings.delete_custom":"删除此自定义 Provider","settings.delete_custom_confirm":"删除自定义 Provider「{name}」?无法撤销。","settings.key.overwrite_ph":"覆盖…","settings.key.paste_ph":"粘贴 key","settings.key.get":"获取 →","settings.refresh":"刷新","settings.discovering":"刷新中…","settings.discover_failed":"刷新失败(可能网络受限)","settings.daily_goal.hint":"XP / 天(每答对一题 +10 XP)","settings.theme.auto":"跟随系统","settings.theme.light":"浅色","settings.theme.dark":"深色","settings.theme.following":"当前跟随系统:{mode}","settings.lang_pref.desc":"导入课程时自动按此偏好选择翻译。仓库原文语言与偏好一致时直接用原文;无对应翻译时也用原文。","settings.img_download":"图片下载","settings.img_download.desc":"导入课程时自动下载 md/notebook 里引用的图片(默认开启)","settings.multimodal.toggle":"AI 看图(聊天时)","settings.multimodal.toggle.desc":"开启后,聊天时 AI 能看到当前课关联的图片并讲解;问图/图表/架构图时生效(需 vision 模型)。导入时下载图片由上面的「图片下载」控制。","settings.group.memory":"学习者记忆","settings.memory.toggle":"让 AI 记住我","settings.memory.toggle.desc":"开启后,AI 会跨会话记住你的学习方式(偏好/卡点/反复混淆),越教越懂你。你拿皇冠(通关一节)时自动总结;也可手动触发。所有记忆只存本地。","settings.group.companion":"伴学伙伴","settings.companion.toggle":"伴学伙伴","settings.companion.toggle.desc":"伴学伙伴常驻课程地图、笔记本与对话栏:高光时刻一起庆祝,朗读课文时对口型,你的每次键击它都跟着拍手。五款形象随时换,只在本地运行。","settings.companion.sfx":"宠物音效","settings.companion.sfx.desc":"戳他/被拍/落地时的短促啾哔声(合成音,低音量)","settings.companion.pet":"桌宠模式","settings.companion.pet.desc":"伴学伙伴在应用外常驻桌面:透明置顶、慢慢巡游,点他仍可互动。开启后应用内的伙伴会休息,避免双影。","settings.companion.form":"形象","companion.name":"小焰","companion.form.ember.name":"小焰","companion.form.ember.desc":"赤焰守护机——热情的原点,能量核随今日 XP 充能","companion.form.frost.name":"霜绒","companion.form.frost.desc":"冰晶守望机——冷静沉稳,六瓣冰晶核逐瓣点亮","companion.form.moss.name":"苔芽","companion.form.moss.desc":"自然精灵机——温软陪伴,胸口种子随进度发芽张叶","companion.form.astro.name":"星尘","companion.form.astro.desc":"星空观测机——夜空屏面,能量核是随 XP 变圆的月相","companion.form.ink.name":"墨墨","companion.form.ink.desc":"砚上学者机——书房静气,墨池水位就是今日进度","companion.form.custom.name":"自定义","companion.form.custom.desc":"自定义纸偶——你的角色站在悬浮盘上,导入立绘即可上场","companion.custom.title":"自定义纸偶包","companion.custom.import":"导入立绘 PNG","companion.custom.apply":"应用为我的伴学","companion.custom.delete":"删除包","companion.custom.cutDone":"切分完成","companion.custom.routeVision":"识图精切","companion.custom.routeGeometric":"几何切分","companion.custom.routeL1":"贴纸档(整图)","companion.custom.applied":"已应用——伴学已切换为你的纸偶","companion.custom.deleted":"已删除","companion.custom.locating":"识图模型定位部件中… 首次较慢","companion.custom.applying":"正在应用包…","companion.custom.visionFallback":"识图不可用,已用几何切分","companion.custom.fail":"失败","companion.bots.add":"新建","companion.bots.veh":"换载具","companion.veh.silver":"银灰","companion.bots.deleteConfirm":"删除这个纸偶?删除后无法恢复。","companion.wizard.copyFail":"复制失败,请手动全选 Prompt 复制","companion.wizard.title":"制作我的伴学bot","companion.wizard.s1":"① 准备角色原图","companion.wizard.s1body":"找一张要变成伴学的角色图——游戏、动漫、自己画的都行。正面、单人、角色完整清晰的图效果最好。这张图不会上传给 LookatStudy,只用在下一步的生成网站里。","companion.wizard.s2":"② 去免费生成站做出 Q 版立绘","companion.wizard.s2body":"打开下面的生成站(豆包 / 即梦,都免费):上传角色原图 → 粘贴下面的 Prompt → 发送 → 下载生成的竖版 2:3 PNG。","companion.wizard.s2doubao":"打开豆包","companion.wizard.s2jimeng":"打开即梦","companion.wizard.s2chatgpt":"打开 ChatGPT","companion.wizard.copy":"一键复制 Prompt","companion.wizard.copied":"已复制,去生成站粘贴","companion.wizard.s3":"③ 选载具、导入生成图并命名","companion.wizard.vehicle":"载具风格(悬浮小平台)","companion.wizard.pick":"选择生成的 PNG","companion.wizard.namePh":"给纸偶起个名字","companion.wizard.save":"保存并使用","companion.wizard.prompt":`生成图片:任务:参考图中的角色,转成 Q 版(chibi)A-pose 立绘设定图。参考图是角色身份的唯一依据:姿势和构图以本提示词为准,身份特征全部跟参考图一致。
378
+ 网络受限或私有仓库请改用「Markdown」方式。`,"import.progress.elapsed":"已 {s}s","import.progress.title":"正在导入课程…","import.progress.starting":"正在启动…","import.progress.note":"导入在后台进行,可继续浏览其他课程","import.progress.cancel":"取消导入","import.cancelled":"已取消导入","toast.threadCreateFailed":"创建失败了,再试一次","toast.threadCreated":"新对话","toast.threadRenamed":"已重命名","toast.threadArchived":"已归档","toast.threadDeleted":"已删除","toast.threadDefault":"新会话","toast.restored":"已恢复","toast.noteSaved":"已加到笔记","toast.noteDeleted":"已删除笔记","toast.artifactSaved":"已记到笔记本","artifact.type.concept_map":"概念图","artifact.type.quiz":"练习题","artifact.type.compare_table":"对比表","artifact.type.diagram":"流程图","artifact.type.code_walkthrough":"代码讲解","artifact.type.unknown":"产物","command.placeholder":"输入指令或问题…(↑↓ 选择,Enter 确认)","command.empty.node":"没有匹配的命令","command.empty.nonode":"先在左侧选一个节点,才能用这些命令","command.footer.hint":"AI 导师会根据指令生成对应内容","command.footer.keys":"↵ 确认 · esc 关闭","command.group.node":"基于当前节点","command.group.mode":"学习模式","command.group.nav":"导航","command.explain_simple":"用大白话解释这一节","command.quiz_3":"出 3 道练习题考考我","command.concept_map":"画个概念图理清结构","command.compare_prev":"和上一节做对比表","command.socratic":"切到苏格拉底模式(提问引导)","command.exam_mode":"切到考试冲刺模式","review.title":"复习","review.nudge":"📅 今天有 {n} 个待复习,点左侧地图的「复习」入口巩固一下","review.loading":"正在检查哪些课该复习了…","review.empty.title":"还没有复习项","review.empty.desc":"完成一些练习后,这里会出现间隔复习提醒","review.due.count":"个待复习","review.start":"开始复习","review.shuffle":"混合练习(随机交错)","review.interleave":"交错复习","review.reviewLesson":"复习该课","review.selectSection":"选择章节","review.dueIn":"待复习","review.noDueInSection":"该章节暂无待复习内容","review.srsHint":"复习提醒","review.myProgress":"我的课程进度","review.overdueQuickHint":"逾期项,点击直接复习","review.quadrant.overdue":"逾期","review.quadrant.short":"短期","review.quadrant.long":"长期","review.quadrant.inactive":"待激活","review.quadrant.more":"更多","review.tip":"复习采用 SM-2 间隔重复算法。逾期项优先复习;长期记忆项间隔更长。单次复习封顶 {n} 题,避免积压压垮节奏。","review.selfrated":"✓ 已记录,掌握度已更新","review.selfrate.title":"复习完了吗?给自己打分","review.selfrate.again":"忘了","review.selfrate.again.hint":"明天重练","review.selfrate.remembered":"记得","review.selfrate.remembered.hint":"推迟几天","review.selfrate.mastered":"很熟","review.selfrate.mastered.hint":"很久后再看","lang.original":"原文","error.checkReadyFailed":"无法检查就绪状态","notebook.tab.explain":"讲解","notebook.tab.notes":"笔记","notebook.tab.board":"黑板","notebook.board.empty":"对话里产生概念图、流程图、对比表、代码讲解时,这里会实时展示最新的一幅大图,方便边看边问。","notebook.zone.understand":"理解","notebook.zone.note":"记录","notebook.zone.practice":"练习","notebook.empty.explain.title":"选一节课开始","notebook.empty.explain.desc":"在左侧地图选一个课时,这里会显示讲解内容","notebook.empty.notes.title":"还没有笔记","notebook.empty.notes.desc":"选中讲解文字画线,或让 AI 生成概念图/对比表,会出现在这里","settings.group.ai":"主模型","settings.group.speech":"语音模型","settings.group.vision":"看图模型","settings.group.appearance":"外观与语言","settings.group.data":"数据","settings.dsh.title":"从 dsh 插件迁移学习进度","settings.dsh.desc":"导入 dsh-plugin-lookatstudy 的课程、掌握度、复习计划、考试星数、XP 与连续天数。导入前自动备份;重复导入安全,同名同结构课程直接写入不另建副本。","settings.dsh.detectFound":"检测到本机插件数据(state v{v})","settings.dsh.detectNone":"未检测到本机 dsh 插件数据——可点击下方按钮选择 state.json 文件导入。","settings.dsh.import":"导入","settings.dsh.pickFile":"选择 state.json 导入","settings.dsh.importing":"导入中…","settings.dsh.done":"已导入:{courses} 门课程 · {nodes} 节点 · {progress} 条进度 · {srs} 条复习 · XP +{xp}","settings.dsh.skipped":"跳过 {n} 门无效课程","settings.dsh.failed":"导入失败","settings.group.about":"关于","settings.row.version":"版本","settings.version.hint":"点版本号可查看该版的更新内容。","settings.row.provider":"服务商","settings.row.theme":"主题","settings.row.interface_lang":"界面语言","settings.row.import_lang":"导入偏好","settings.custom.form_title":"添加自定义 Provider","settings.footer.hint":"主模型区的改动需保存后生效,其余即时生效","settings.footer.save":"保存 AI 配置","header.energy":"今日能量","header.level.title":"等级(累计经验值的持久成长线,不随每日能量清零)","settings.title":"设置","view.tree":"技能树","view.dashboard":"仪表盘","view.import":"导入课程","mode.chat":"💬 对话","mode.exercise":"📝 练习","mode.settings":"⚙️ 设置","chat.starter.hint":"💡 从下面选一个开始,或者直接输入你的问题","chat.no_key.title":"还没有配置 AI 模型","chat.no_key.desc":"配置后即可开始 AI 导师对话和练习","chat.no_key.btn":"去配置模型","chat.input.placeholder":"问 AI 导师…(Enter 发送)","chat.input.no_node":"先在左侧选一个 lesson…","chat.send":"发送","chat.stop":"停止","chat.clear":"清空对话历史","chat.selection.quote":"提问这段","chat.soul.label":"风格:","chat.no_key.short":"未配置 AI 模型","chat.no_key.cta":"去配置 →","chat.attach.add":"添加图片或文件(可粘贴 / 拖拽)","chat.attach.remove":"移除 {name}","chat.attach.tooMany":"一条消息最多 {n} 个附件","chat.attach.tooLargeImage":"图片超过 5MB:{name}","chat.attach.tooLargeText":"文本文件超过 256KB:{name}","chat.attach.unsupported":"暂不支持该类型:{name}(支持图片与常见文本 / 代码文件)","chat.attach.visionUnsupported":"当前模型不支持看图,请用右侧模型切换器选一个带眼睛图标的模型,或在设置 → AI 看图里配置视觉模型覆盖","chat.attach.bridgeChip":"主模型是纯文本:图片将先由 {model} 转译成文字再交给它","chat.attach.preview":"查看 {name}","chat.attach.textChip":"文本附件,内容已随消息发给 AI","chat.attach.imageOnlyText":"请看这张图片。","context.label":"上下文","context.aria":"上下文已用 {p}","context.approx":"约","context.system":"系统提示","context.node":"课文","context.learner":"学习者状态","context.history":"对话历史","context.draft":"草稿","context.unknownWindow":"模型窗口未知","model.picker.label":"模型","model.picker.manage":"管理模型与密钥…","model.picker.vision":"支持看图","model.picker.noneConfigured":"还没有配置任何 provider 密钥","effort.label":"思考强度","effort.auto.label":"自动","effort.auto.desc":"模型默认行为,不干预","effort.fast.label":"快速","effort.fast.desc":"尽量关思考,答得快、省 token","effort.deep.label":"深度","effort.deep.desc":"尽量开思考,难题多想几步","effort.unsupported":"当前 provider 暂不支持思考强度切换","soul.direct":"精讲","soul.guide":"引导","soul.practice":"实战","soul.direct.desc":"精讲派 · 新手/想搞懂时用。先讲清楚再确认,给完整范例,不让你猜","soul.guide.desc":"引导派 · 有点基础、想自己推时用。不直接给答案,用引导性问题帮你推导","soul.practice.desc":"实战派 · 想动手时用。围绕真实世界的乱问题,在做中把概念织成网","settings.provider":"AI 服务商(Provider)","settings.model":"模型(Model)","settings.apikey":"API Key","settings.test":"测试连接","settings.testing":"测试中…","settings.save":"保存设置","settings.saved":"✅ 已保存","settings.daily_goal":"每日学习目标(XP)","settings.custom.add":"+ 添加自定义 Provider","settings.language":"语言(Language)","settings.add_custom":"自定义","settings.custom.label_ph":"名称","settings.custom.baseurl_ph":"Base URL(如 https://api.example.com/v1)","settings.custom.model_ph":"模型 ID","settings.custom.new":"新建自定义","settings.custom.form_title_vision":"配置看图模型(自定义 provider)","settings.custom.model_ph_vision":"如 glm-4.6v / gpt-4o","settings.custom.form_title_tts":"配置朗读 provider(OpenAI 兼容 /audio/speech 端点)","settings.custom.model_ph_tts":"如 tts-1 / FunAudioLLM/CosyVoice2-0.5B","settings.custom.form_title_asr":"配置听写 provider(OpenAI 兼容 /audio/transcriptions 端点)","settings.custom.model_ph_asr":"如 whisper-large-v3-turbo","settings.custom.apikey_ph":"API Key(可选)","settings.custom.save":"保存","settings.custom.windowLabel":"上下文窗口(tokens)","settings.custom.windowPh":"如 128000 或 128k(留空 = 未知)","settings.custom.windowHint":"当前模型的最大上下文,可在模型官方文档查到。填了输入框旁的上下文表才会显示占比。","settings.custom.vision":"支持看图(多模态)","settings.custom.visionHint":"勾选后系统将图片直接发给主模型;不勾选则走视觉转译桥(需在 AI 看图区配视觉模型)或跳过图片。","settings.delete_custom":"删除此自定义 Provider","settings.delete_custom_confirm":"删除自定义 Provider「{name}」?无法撤销。","settings.key.overwrite_ph":"覆盖…","settings.key.paste_ph":"粘贴 key","settings.key.get":"获取 →","settings.refresh":"刷新","settings.discovering":"刷新中…","settings.discover_failed":"刷新失败(可能网络受限)","settings.daily_goal.hint":"XP / 天(每答对一题 +10 XP)","settings.theme.auto":"跟随系统","settings.theme.light":"浅色","settings.theme.dark":"深色","settings.theme.following":"当前跟随系统:{mode}","settings.lang_pref.desc":"导入课程时自动按此偏好选择翻译。仓库原文语言与偏好一致时直接用原文;无对应翻译时也用原文。","settings.img_download":"图片下载","settings.img_download.desc":"导入课程时自动下载 md/notebook 里引用的图片(默认开启)","settings.multimodal.toggle":"AI 看图(聊天时)","settings.multimodal.toggle.desc":"开启后,聊天时 AI 能看到当前课关联的图片并讲解;问图/图表/架构图时生效(需 vision 模型)。导入时下载图片由上面的「图片下载」控制。","settings.group.memory":"学习者记忆","settings.memory.toggle":"让 AI 记住我","settings.memory.toggle.desc":"开启后,AI 会跨会话记住你的学习方式(偏好/卡点/反复混淆),越教越懂你。你拿皇冠(通关一节)时自动总结;也可手动触发。所有记忆只存本地。","settings.group.companion":"伴学伙伴","settings.companion.toggle":"伴学伙伴","settings.companion.toggle.desc":"伴学伙伴常驻课程地图、笔记本与对话栏:高光时刻一起庆祝,朗读课文时对口型,你的每次键击它都跟着拍手。五款形象随时换,只在本地运行。","settings.companion.sfx":"宠物音效","settings.companion.sfx.desc":"戳他/被拍/落地时的短促啾哔声(合成音,低音量)","settings.companion.pet":"桌宠模式","settings.companion.pet.desc":"伴学伙伴在应用外常驻桌面:透明置顶、慢慢巡游,点他仍可互动。开启后应用内的伙伴会休息,避免双影。","settings.companion.form":"形象","companion.name":"小焰","companion.form.ember.name":"小焰","companion.form.ember.desc":"赤焰守护机——热情的原点,能量核随今日 XP 充能","companion.form.frost.name":"霜绒","companion.form.frost.desc":"冰晶守望机——冷静沉稳,六瓣冰晶核逐瓣点亮","companion.form.moss.name":"苔芽","companion.form.moss.desc":"自然精灵机——温软陪伴,胸口种子随进度发芽张叶","companion.form.astro.name":"星尘","companion.form.astro.desc":"星空观测机——夜空屏面,能量核是随 XP 变圆的月相","companion.form.ink.name":"墨墨","companion.form.ink.desc":"砚上学者机——书房静气,墨池水位就是今日进度","companion.form.custom.name":"自定义","companion.form.custom.desc":"自定义纸偶——你的角色站在悬浮盘上,导入立绘即可上场","companion.custom.title":"自定义纸偶包","companion.custom.import":"导入立绘 PNG","companion.custom.apply":"应用为我的伴学","companion.custom.delete":"删除包","companion.custom.cutDone":"切分完成","companion.custom.routeVision":"识图精切","companion.custom.routeGeometric":"几何切分","companion.custom.routeL1":"贴纸档(整图)","companion.custom.applied":"已应用——伴学已切换为你的纸偶","companion.custom.deleted":"已删除","companion.custom.locating":"识图模型定位部件中… 首次较慢","companion.custom.applying":"正在应用包…","companion.custom.visionFallback":"识图不可用,已降级为单件贴纸(自动抠掉背景)","companion.custom.fail":"失败","companion.bots.add":"新建","companion.bots.veh":"换载具","companion.veh.silver":"银灰","companion.bots.deleteConfirm":"删除这个纸偶?删除后无法恢复。","companion.wizard.copyFail":"复制失败,请手动全选 Prompt 复制","companion.wizard.title":"制作我的伴学bot","companion.wizard.s1":"① 准备角色原图","companion.wizard.s1body":"找一张要变成伴学的角色图——游戏、动漫、自己画的都行。正面、单人、角色完整清晰的图效果最好。这张图不会上传给 LookatStudy,只用在下一步的生成网站里。","companion.wizard.s2":"② 去免费生成站做出 Q 版立绘","companion.wizard.s2body":"打开下面的生成站(豆包 / 即梦,都免费):上传角色原图 → 粘贴下面的 Prompt → 发送 → 下载生成的竖版 2:3 PNG。","companion.wizard.s2doubao":"打开豆包","companion.wizard.s2jimeng":"打开即梦","companion.wizard.s2chatgpt":"打开 ChatGPT","companion.wizard.copy":"一键复制 Prompt","companion.wizard.copied":"已复制,去生成站粘贴","companion.wizard.s3":"③ 选载具、导入生成图并命名","companion.wizard.vehicle":"载具风格(悬浮小平台)","companion.wizard.pick":"选择生成的 PNG","companion.wizard.namePh":"给纸偶起个名字","companion.wizard.save":"保存并使用","companion.wizard.prompt":`生成图片:任务:参考图中的角色,转成 Q 版(chibi)A-pose 立绘设定图。参考图是角色身份的唯一依据:姿势和构图以本提示词为准,身份特征全部跟参考图一致。
379
379
  角色锁定(以下特征必须与参考图完全一致,只允许随 Q 版画风等比简化,不得改动、不得省略):
380
380
  1. 发型发色:发型轮廓、刘海方向、发色、发饰
381
381
  2. 五官:瞳色、瞳形、眉形、默认表情
@@ -394,7 +394,7 @@ Q 版规则(唯一允许的改变就是头身比与画风):二头身——
394
394
  3. I'll pick an option and guess; in your NEXT turn, reveal the answer and teach the one core idea of this lesson.
395
395
  Iron rules: no lecture to start, no generate_quiz scored questions, no scoring. Hooking me is the only goal.`,"starter.go-deeper.label":"Go deeper","starter.go-deeper.hint":"Unpack the concept one level down","starter.go-deeper.message":"Go deeper on “{title}” — expand the structure, the details, and the easy-to-miss edge cases of the core point we just uncovered.","starter.give-example.label":"Give an example","starter.give-example.hint":"Make it concrete with a real example","starter.give-example.message":"Give me a concrete example or use case for “{title}” so I can understand it more tangibly.","starter.quiz-me.label":"Quiz me","starter.quiz-me.hint":"Retrieve and apply (correct answers raise mastery)","starter.quiz-me.message":"Quiz me with one applied question about “{title}” to check whether I really get it — judge my answer when I respond.","starter.confused.label":"I'm lost","starter.confused.hint":"Tell the AI where you're stuck (it takes notes)","starter.confused.message":"I'm fuzzy on part of “{title}” — help me untangle it, and start by asking which part isn't clear.","map.world.study":"Learn","map.world.practice":"Practice","pane.switcher":"Switch view","pane.map":"Course","pane.chat":"Tutor","pane.notes":"Blackboard","pane.resizeTooltip":"Drag to resize, double-click to reset","pane.resizeRailAria":"Resize course pane width","pane.resizeChatAria":"Resize tutor pane width","map.streaming.notice":"AI is responding in the background. Feel free to switch nodes.","map.generating":"Generating course path…","map.empty.cta.title":"Start your first course","map.empty.cta.desc":"Import a GitHub learning repo to auto-generate a skill path","map.empty.cta.btn":"Click to import →","map.empty.practice":"No practice content for this course","node.locked.chapterHint":"(unlocks after completing all lessons in this chapter)","node.due.hint":"(due for review)","import.empty":"No courses yet. Import your first one below.","import.cta":"Import New Course","import.tab.url":"URL","import.tab.md":"MD","import.tab.folder":"Folder","import.url.placeholder":"GitHub repo / web article / arXiv paper link","import.url.desc":"Paste any link — GitHub repo / arXiv paper / web article / Bilibili·YouTube video (transcribed into a course; multi-part Bilibili videos import the whole season without ?p=; more sites need yt-dlp installed).","import.btn.url":"Import","import.btn.url.busy":"Importing…","import.placeholder.name":"Course name (optional)","import.placeholder.md":"Paste any long text or Markdown… (auto-split when there are no headings)","import.btn.md":"Import as Course","import.btn.md.busy":"Generating…","import.folder.desc":"Recursively scans .txt/.md/.html/.pdf. For downloaded course material packs.","import.btn.folder":"Select Folder","import.tab.epub":"eBook","import.epub.desc":"EPUB books become one lesson per chapter (chapter order from the book's spine & TOC).","import.btn.epub":"Pick an EPUB file","import.tab.audio":"Audio","import.audio.desc":"Audio (wav/mp3/m4a/flac) or local video (mp4/m4v/mov) transcribed locally into a course; multi-select = multiple episodes. Whisper model (~1 GB) downloads automatically on first use.","import.btn.audio":"Pick audio files","import.tab.pack":"Pack","import.btn.pack":"Pick a course pack file","import.pack.desc":"A course pack is a shared import-plan snapshot — zero AI calls, classification and structure design are instant. Reused as-is when the GitHub repo matches; if the repo moved on, lessons pointing at removed files are dropped automatically.","import.export":"Export","import.folder.pathPlaceholder":"Server-side folder path (e.g. /storage/emulated/0/Download/my-course)","import.folder.pathRequired":"Enter the server-side folder path first","import.pack.export":"Export course pack (share for zero-AI import)","import.pack.exported":"Course pack exported: {path}","import.error.resume":"Retry from checkpoint (skips finished AI steps)","import.success.reused":"reused saved plan, zero AI calls","import.btn.folder.busy":"Processing…","import.delete":"Delete","import.delete.confirm":"All progress and exercises will be erased. This cannot be undone.","import.delete.current":"Delete current course","course.empty.title":"Pick a course to start learning","course.empty.desc":"Choose an imported course from the Import panel on the left, or import a new one.","import.success.md":"Generated","import.success.folder":"Imported","import.error.network":`
396
396
 
397
- For restricted networks or private repos, use the Markdown method.`,"import.progress.elapsed":"{s}s elapsed","import.progress.title":"Importing course…","import.progress.starting":"Starting…","import.progress.note":"Import runs in the background — keep browsing other courses","import.progress.cancel":"Cancel import","import.cancelled":"Import cancelled","toast.threadCreateFailed":"Couldn't create — try again","toast.threadCreated":"New chat","toast.threadRenamed":"Renamed","toast.threadArchived":"Archived","toast.threadDeleted":"Deleted","toast.threadDefault":"New thread","toast.restored":"Restored","toast.noteSaved":"Added to notes","toast.noteDeleted":"Note deleted","toast.artifactSaved":"Saved to notebook","artifact.type.concept_map":"Concept Map","artifact.type.quiz":"Quiz","artifact.type.compare_table":"Comparison Table","artifact.type.diagram":"Diagram","artifact.type.code_walkthrough":"Code Walkthrough","artifact.type.unknown":"Artifact","command.placeholder":"Type a command or question… (↑↓ to select, Enter to confirm)","command.empty.node":"No matching commands","command.empty.nonode":"Select a node on the left first","command.footer.hint":"The AI tutor generates content based on your command","command.footer.keys":"↵ confirm · esc to close","command.group.node":"Current Node","command.group.mode":"Study Mode","command.group.nav":"Navigation","command.explain_simple":"Explain this section in plain words","command.quiz_3":"Give me 3 practice questions","command.concept_map":"Draw a concept map","command.compare_prev":"Compare with the previous section","command.socratic":"Switch to Socratic mode (guided questions)","command.exam_mode":"Switch to Exam prep mode","review.title":"Review","review.nudge":"📅 {n} review(s) due today — tap the Review entry in the map to consolidate","review.loading":"Checking what to review…","review.empty.title":"No reviews yet","review.empty.desc":"Complete some exercises and spaced-repetition reminders will appear here","review.due.count":"due","review.start":"Start Review","review.shuffle":"Shuffle (interleaved)","review.interleave":"Interleaved Review","review.reviewLesson":"Review","review.selectSection":"Select a section","review.dueIn":"due","review.noDueInSection":"No reviews in this section","review.srsHint":"Review Reminders","review.myProgress":"My Progress","review.overdueQuickHint":"Overdue items — click to review","review.quadrant.overdue":"Overdue","review.quadrant.short":"Short-term","review.quadrant.long":"Long-term","review.quadrant.inactive":"Inactive","review.quadrant.more":"more","review.tip":"Review uses the SM-2 spaced repetition algorithm. Overdue items first; long-term memory items have longer intervals. Capped at {n} items per session to avoid backlog overwhelm.","review.selfrated":"✓ Recorded. Mastery updated.","review.selfrate.title":"Done reviewing? Rate yourself","review.selfrate.again":"Forgot","review.selfrate.again.hint":"Review tomorrow","review.selfrate.remembered":"Recalled","review.selfrate.remembered.hint":"In a few days","review.selfrate.mastered":"Easy","review.selfrate.mastered.hint":"Much later","lang.original":"Original","error.checkReadyFailed":"Could not check readiness","notebook.tab.explain":"Explain","notebook.tab.notes":"Notes","notebook.tab.board":"Blackboard","notebook.board.empty":"When the tutor produces a concept map, diagram, comparison table, or code walkthrough in chat, the latest one is rendered here in full size.","notebook.zone.understand":"Understand","notebook.zone.note":"Notes","notebook.zone.practice":"Practice","notebook.empty.explain.title":"Pick a lesson to start","notebook.empty.explain.desc":"Select a lesson in the map on the left; its explanation shows here.","notebook.empty.notes.title":"No notes yet","notebook.empty.notes.desc":"Highlight text in the explanation, or have the AI generate a concept map / comparison table — it shows up here.","settings.group.ai":"Main Model","settings.group.speech":"Speech Models","settings.group.vision":"Vision Model","settings.group.appearance":"Appearance & Language","settings.group.data":"Data","settings.dsh.title":"Migrate progress from the dsh plugin","settings.dsh.desc":"Import courses, mastery, review schedule, exam stars, XP and streaks from dsh-plugin-lookatstudy. The database is backed up automatically; re-importing is safe, and an existing course with the same title and structure is written in place instead of being duplicated.","settings.dsh.detectFound":"Local plugin data detected (state v{v})","settings.dsh.detectNone":"No local dsh plugin data found — pick your state.json file below to import it.","settings.dsh.import":"Import","settings.dsh.pickFile":"Pick state.json to import","settings.dsh.importing":"Importing…","settings.dsh.done":"Imported: {courses} courses · {nodes} nodes · {progress} progress rows · {srs} reviews · XP +{xp}","settings.dsh.skipped":"{n} invalid course(s) skipped","settings.dsh.failed":"Import failed","settings.group.about":"About","settings.row.version":"Version","settings.version.hint":"Click the version to see what changed in this release.","settings.row.provider":"Provider","settings.row.theme":"Theme","settings.row.interface_lang":"Interface language","settings.row.import_lang":"Import preference","settings.custom.form_title":"Add custom provider","settings.footer.hint":"Main model changes need Save; everything else is instant.","settings.footer.save":"Save AI config","header.energy":"Today's energy","header.level.title":"Level (cumulative XP growth line — doesn't reset with daily energy)","settings.title":"Settings","view.tree":"Skill Tree","view.dashboard":"Dashboard","view.import":"Import Course","mode.chat":"💬 Chat","mode.exercise":"📝 Practice","mode.settings":"⚙️ Settings","chat.starter.hint":"💡 Pick one to start, or type your question","chat.no_key.title":"No AI model configured","chat.no_key.desc":"Configure a model to start AI tutoring and practice","chat.no_key.btn":"Configure Model","chat.input.placeholder":"Ask your AI tutor… (Enter to send)","chat.input.no_node":"Select a lesson on the left…","chat.send":"Send","chat.stop":"Stop","chat.clear":"Clear chat history","chat.selection.quote":"Ask about this","chat.soul.label":"Style:","chat.no_key.short":"AI model not configured","chat.no_key.cta":"Configure →","chat.attach.add":"Add image or file (paste / drag also works)","chat.attach.remove":"Remove {name}","chat.attach.tooMany":"Up to {n} attachments per message","chat.attach.tooLargeImage":"Image over 5MB: {name}","chat.attach.tooLargeText":"Text file over 256KB: {name}","chat.attach.unsupported":"Unsupported type: {name} (images and common text / code files)","chat.attach.visionUnsupported":"Current model can't see images — pick one with the eye icon in the model switcher, or set a vision model override in Settings → AI vision","chat.attach.bridgeChip":"Main model is text-only: images will be transcribed to text by {model} first","chat.attach.preview":"View {name}","chat.attach.textChip":"Text attachment, content sent with the message","chat.attach.imageOnlyText":"Please look at this image.","context.label":"Context","context.aria":"{p} of context used","context.approx":"~","context.system":"System prompt","context.node":"Lesson","context.learner":"Learner state","context.history":"History","context.draft":"Draft","context.unknownWindow":"model window unknown","model.picker.label":"Model","model.picker.manage":"Manage models & keys…","model.picker.vision":"Vision capable","model.picker.noneConfigured":"No provider key configured yet","effort.label":"Thinking effort","effort.auto.label":"Auto","effort.auto.desc":"Model default, no override","effort.fast.label":"Fast","effort.fast.desc":"Thinking off when possible — quicker, fewer tokens","effort.deep.label":"Deep","effort.deep.desc":"Thinking on when possible — extra steps for hard problems","effort.unsupported":"Current provider doesn't support effort switching","soul.direct":"Direct","soul.guide":"Guide","soul.practice":"Practice","soul.direct.desc":"Direct · for beginners or low energy. Explains clearly then checks, gives full worked examples — never makes you guess","soul.guide.desc":"Guide · when you have some footing and want to reason it out. No direct answers — guiding questions help you derive it","soul.practice.desc":"Practice · for hands-on learners. Each concept lands on a messy real-world problem; learn by doing and connect the dots","settings.provider":"AI Provider","settings.model":"Model","settings.apikey":"API Key","settings.test":"Test Connection","settings.testing":"Testing…","settings.save":"Save Settings","settings.saved":"✅ Saved","settings.daily_goal":"Daily Goal (XP)","settings.custom.add":"+ Add Custom Provider","settings.language":"Language","settings.add_custom":"Custom","settings.custom.label_ph":"Name","settings.custom.baseurl_ph":"Base URL (e.g. https://api.example.com/v1)","settings.custom.model_ph":"Model ID","settings.custom.new":"New custom","settings.custom.form_title_vision":"Configure vision model (custom provider)","settings.custom.model_ph_vision":"e.g. glm-4.6v / gpt-4o","settings.custom.form_title_tts":"Configure TTS provider (OpenAI-compatible /audio/speech)","settings.custom.model_ph_tts":"e.g. tts-1 / FunAudioLLM/CosyVoice2-0.5B","settings.custom.form_title_asr":"Configure dictation provider (OpenAI-compatible /audio/transcriptions)","settings.custom.model_ph_asr":"e.g. whisper-large-v3-turbo","settings.custom.apikey_ph":"API Key (optional)","settings.custom.save":"Save","settings.custom.windowLabel":"Context window (tokens)","settings.custom.windowPh":"e.g. 128000 or 128k (empty = unknown)","settings.custom.windowHint":"Max context of the current model, found in its official docs. The composer context meter only shows a percentage when this is set.","settings.custom.vision":"Supports vision (multimodal)","settings.custom.visionHint":"When checked, images are sent directly to the main model. Unchecked uses the vision bridge (configure a vision model in AI Vision section) or skips images.","settings.delete_custom":"Delete this custom provider","settings.delete_custom_confirm":'Delete custom provider "{name}"? This cannot be undone.',"settings.key.overwrite_ph":"Overwrite…","settings.key.paste_ph":"Paste key","settings.key.get":"Get key →","settings.refresh":"Refresh","settings.discovering":"Refreshing…","settings.discover_failed":"Refresh failed (network may be restricted)","settings.daily_goal.hint":"XP / day (+10 XP per correct answer)","settings.theme.auto":"System","settings.theme.light":"Light","settings.theme.dark":"Dark","settings.theme.following":"Following system: {mode}","settings.lang_pref.desc":"When importing a course, auto-pick the translation matching this preference. If the repo's source language already matches, the original is used; if no translation exists, the original is used as well.","settings.img_download":"Image download","settings.img_download.desc":"Auto-download images referenced in markdown/notebooks during import (on by default)","settings.multimodal.toggle":"AI vision (in chat)","settings.multimodal.toggle.desc":"When on, the AI can see and explain this lesson's images during chat — used for diagrams/charts/architecture (needs a vision model).","settings.group.memory":"Learner memory","settings.memory.toggle":"Let the AI remember me","settings.memory.toggle.desc":"When on, the AI remembers how you learn across sessions (preferences / stuck points / recurring confusions) and adapts over time. Auto-summarized when you earn a crown (clear a node); also manually triggerable. All memory stays local.","settings.group.companion":"Learning companion","settings.companion.toggle":"Learning companion","settings.companion.toggle.desc":"Your companion lives in the course map, notebook and chat: celebrates wins, lip-syncs read-alouds, and taps along with every keystroke. Five forms to switch between. Fully local.","settings.companion.sfx":"Pet sounds","settings.companion.sfx.desc":"Short chirps when poked/hit/landing (synthesized, low volume)","settings.companion.pet":"Desktop pet mode","settings.companion.pet.desc":"Keep the companion on your desktop outside the app: transparent, always on top, wandering slowly — still poke-able. The in-app buddy takes a rest so you never see double.","settings.companion.form":"Form","companion.name":"Ember","companion.form.ember.name":"Ember","companion.form.ember.desc":"Blazing guardian — the passionate original; core charges with today's XP","companion.form.frost.name":"Frost","companion.form.frost.desc":"Crystal watcher — calm and steady; the hex core lights petal by petal","companion.form.moss.name":"Moss","companion.form.moss.desc":"Nature spirit — gentle company; the seed sprouts as you progress","companion.form.astro.name":"Astro","companion.form.astro.desc":"Stargazer — night-sky visor; the core moon waxes with today's XP","companion.form.ink.name":"Ink","companion.form.ink.desc":"Inkstone scholar — quiet study vibes; the ink pool rises with your progress","companion.form.custom.name":"Puppet","companion.form.custom.desc":"Custom paper puppet — import a character sheet and it rides the hover disc","companion.custom.title":"Custom puppet pack","companion.custom.import":"Import PNG sheet","companion.custom.apply":"Apply as my companion","companion.custom.delete":"Delete pack","companion.custom.cutDone":"Cut complete","companion.custom.routeVision":"vision cut","companion.custom.routeGeometric":"geometric cut","companion.custom.routeL1":"sticker tier (whole image)","companion.custom.applied":"Applied — your companion is now the puppet","companion.custom.deleted":"Deleted","companion.custom.locating":"Vision model locating parts… first run is slow","companion.custom.applying":"Applying pack…","companion.custom.visionFallback":"Vision unavailable, used geometric cut","companion.custom.fail":"Failed","companion.bots.add":"New","companion.bots.veh":"Change vehicle","companion.veh.silver":"Silver","companion.bots.deleteConfirm":"Delete this puppet? This cannot be undone.","companion.wizard.copyFail":"Copy failed — please select the prompt manually","companion.wizard.title":"Make my companion bot","companion.wizard.s1":"① Prepare the character image","companion.wizard.s1body":"Find an image of the character you want as your study buddy — a game, anime, or your own art. Front-facing, single character, clean and complete works best. It is not uploaded to LookatStudy; it is only used on the generation site in the next step.","companion.wizard.s2":"② Generate the chibi sheet on a free site","companion.wizard.s2body":"Open a generation site below (Doubao / Jimeng — both free): upload the character image → paste the Prompt below → send → download the portrait 2:3 PNG it creates.","companion.wizard.s2doubao":"Open Doubao","companion.wizard.s2jimeng":"Open Jimeng","companion.wizard.s2chatgpt":"Open ChatGPT","companion.wizard.copy":"Copy prompt","companion.wizard.copied":"Copied — paste it on the site","companion.wizard.s3":"③ Pick a vehicle, import and name it","companion.wizard.vehicle":"Vehicle style (hover platform)","companion.wizard.pick":"Choose the generated PNG","companion.wizard.namePh":"Name your puppet","companion.wizard.save":"Save & use","companion.wizard.prompt":`Image generation task: turn the character in the reference image into a Q-version (chibi) A-pose character sheet. The reference image is the only source of truth for the character's identity: pose and composition follow this prompt, identity features follow the reference image.
397
+ For restricted networks or private repos, use the Markdown method.`,"import.progress.elapsed":"{s}s elapsed","import.progress.title":"Importing course…","import.progress.starting":"Starting…","import.progress.note":"Import runs in the background — keep browsing other courses","import.progress.cancel":"Cancel import","import.cancelled":"Import cancelled","toast.threadCreateFailed":"Couldn't create — try again","toast.threadCreated":"New chat","toast.threadRenamed":"Renamed","toast.threadArchived":"Archived","toast.threadDeleted":"Deleted","toast.threadDefault":"New thread","toast.restored":"Restored","toast.noteSaved":"Added to notes","toast.noteDeleted":"Note deleted","toast.artifactSaved":"Saved to notebook","artifact.type.concept_map":"Concept Map","artifact.type.quiz":"Quiz","artifact.type.compare_table":"Comparison Table","artifact.type.diagram":"Diagram","artifact.type.code_walkthrough":"Code Walkthrough","artifact.type.unknown":"Artifact","command.placeholder":"Type a command or question… (↑↓ to select, Enter to confirm)","command.empty.node":"No matching commands","command.empty.nonode":"Select a node on the left first","command.footer.hint":"The AI tutor generates content based on your command","command.footer.keys":"↵ confirm · esc to close","command.group.node":"Current Node","command.group.mode":"Study Mode","command.group.nav":"Navigation","command.explain_simple":"Explain this section in plain words","command.quiz_3":"Give me 3 practice questions","command.concept_map":"Draw a concept map","command.compare_prev":"Compare with the previous section","command.socratic":"Switch to Socratic mode (guided questions)","command.exam_mode":"Switch to Exam prep mode","review.title":"Review","review.nudge":"📅 {n} review(s) due today — tap the Review entry in the map to consolidate","review.loading":"Checking what to review…","review.empty.title":"No reviews yet","review.empty.desc":"Complete some exercises and spaced-repetition reminders will appear here","review.due.count":"due","review.start":"Start Review","review.shuffle":"Shuffle (interleaved)","review.interleave":"Interleaved Review","review.reviewLesson":"Review","review.selectSection":"Select a section","review.dueIn":"due","review.noDueInSection":"No reviews in this section","review.srsHint":"Review Reminders","review.myProgress":"My Progress","review.overdueQuickHint":"Overdue items — click to review","review.quadrant.overdue":"Overdue","review.quadrant.short":"Short-term","review.quadrant.long":"Long-term","review.quadrant.inactive":"Inactive","review.quadrant.more":"more","review.tip":"Review uses the SM-2 spaced repetition algorithm. Overdue items first; long-term memory items have longer intervals. Capped at {n} items per session to avoid backlog overwhelm.","review.selfrated":"✓ Recorded. Mastery updated.","review.selfrate.title":"Done reviewing? Rate yourself","review.selfrate.again":"Forgot","review.selfrate.again.hint":"Review tomorrow","review.selfrate.remembered":"Recalled","review.selfrate.remembered.hint":"In a few days","review.selfrate.mastered":"Easy","review.selfrate.mastered.hint":"Much later","lang.original":"Original","error.checkReadyFailed":"Could not check readiness","notebook.tab.explain":"Explain","notebook.tab.notes":"Notes","notebook.tab.board":"Blackboard","notebook.board.empty":"When the tutor produces a concept map, diagram, comparison table, or code walkthrough in chat, the latest one is rendered here in full size.","notebook.zone.understand":"Understand","notebook.zone.note":"Notes","notebook.zone.practice":"Practice","notebook.empty.explain.title":"Pick a lesson to start","notebook.empty.explain.desc":"Select a lesson in the map on the left; its explanation shows here.","notebook.empty.notes.title":"No notes yet","notebook.empty.notes.desc":"Highlight text in the explanation, or have the AI generate a concept map / comparison table — it shows up here.","settings.group.ai":"Main Model","settings.group.speech":"Speech Models","settings.group.vision":"Vision Model","settings.group.appearance":"Appearance & Language","settings.group.data":"Data","settings.dsh.title":"Migrate progress from the dsh plugin","settings.dsh.desc":"Import courses, mastery, review schedule, exam stars, XP and streaks from dsh-plugin-lookatstudy. The database is backed up automatically; re-importing is safe, and an existing course with the same title and structure is written in place instead of being duplicated.","settings.dsh.detectFound":"Local plugin data detected (state v{v})","settings.dsh.detectNone":"No local dsh plugin data found — pick your state.json file below to import it.","settings.dsh.import":"Import","settings.dsh.pickFile":"Pick state.json to import","settings.dsh.importing":"Importing…","settings.dsh.done":"Imported: {courses} courses · {nodes} nodes · {progress} progress rows · {srs} reviews · XP +{xp}","settings.dsh.skipped":"{n} invalid course(s) skipped","settings.dsh.failed":"Import failed","settings.group.about":"About","settings.row.version":"Version","settings.version.hint":"Click the version to see what changed in this release.","settings.row.provider":"Provider","settings.row.theme":"Theme","settings.row.interface_lang":"Interface language","settings.row.import_lang":"Import preference","settings.custom.form_title":"Add custom provider","settings.footer.hint":"Main model changes need Save; everything else is instant.","settings.footer.save":"Save AI config","header.energy":"Today's energy","header.level.title":"Level (cumulative XP growth line — doesn't reset with daily energy)","settings.title":"Settings","view.tree":"Skill Tree","view.dashboard":"Dashboard","view.import":"Import Course","mode.chat":"💬 Chat","mode.exercise":"📝 Practice","mode.settings":"⚙️ Settings","chat.starter.hint":"💡 Pick one to start, or type your question","chat.no_key.title":"No AI model configured","chat.no_key.desc":"Configure a model to start AI tutoring and practice","chat.no_key.btn":"Configure Model","chat.input.placeholder":"Ask your AI tutor… (Enter to send)","chat.input.no_node":"Select a lesson on the left…","chat.send":"Send","chat.stop":"Stop","chat.clear":"Clear chat history","chat.selection.quote":"Ask about this","chat.soul.label":"Style:","chat.no_key.short":"AI model not configured","chat.no_key.cta":"Configure →","chat.attach.add":"Add image or file (paste / drag also works)","chat.attach.remove":"Remove {name}","chat.attach.tooMany":"Up to {n} attachments per message","chat.attach.tooLargeImage":"Image over 5MB: {name}","chat.attach.tooLargeText":"Text file over 256KB: {name}","chat.attach.unsupported":"Unsupported type: {name} (images and common text / code files)","chat.attach.visionUnsupported":"Current model can't see images — pick one with the eye icon in the model switcher, or set a vision model override in Settings → AI vision","chat.attach.bridgeChip":"Main model is text-only: images will be transcribed to text by {model} first","chat.attach.preview":"View {name}","chat.attach.textChip":"Text attachment, content sent with the message","chat.attach.imageOnlyText":"Please look at this image.","context.label":"Context","context.aria":"{p} of context used","context.approx":"~","context.system":"System prompt","context.node":"Lesson","context.learner":"Learner state","context.history":"History","context.draft":"Draft","context.unknownWindow":"model window unknown","model.picker.label":"Model","model.picker.manage":"Manage models & keys…","model.picker.vision":"Vision capable","model.picker.noneConfigured":"No provider key configured yet","effort.label":"Thinking effort","effort.auto.label":"Auto","effort.auto.desc":"Model default, no override","effort.fast.label":"Fast","effort.fast.desc":"Thinking off when possible — quicker, fewer tokens","effort.deep.label":"Deep","effort.deep.desc":"Thinking on when possible — extra steps for hard problems","effort.unsupported":"Current provider doesn't support effort switching","soul.direct":"Direct","soul.guide":"Guide","soul.practice":"Practice","soul.direct.desc":"Direct · for beginners or low energy. Explains clearly then checks, gives full worked examples — never makes you guess","soul.guide.desc":"Guide · when you have some footing and want to reason it out. No direct answers — guiding questions help you derive it","soul.practice.desc":"Practice · for hands-on learners. Each concept lands on a messy real-world problem; learn by doing and connect the dots","settings.provider":"AI Provider","settings.model":"Model","settings.apikey":"API Key","settings.test":"Test Connection","settings.testing":"Testing…","settings.save":"Save Settings","settings.saved":"✅ Saved","settings.daily_goal":"Daily Goal (XP)","settings.custom.add":"+ Add Custom Provider","settings.language":"Language","settings.add_custom":"Custom","settings.custom.label_ph":"Name","settings.custom.baseurl_ph":"Base URL (e.g. https://api.example.com/v1)","settings.custom.model_ph":"Model ID","settings.custom.new":"New custom","settings.custom.form_title_vision":"Configure vision model (custom provider)","settings.custom.model_ph_vision":"e.g. glm-4.6v / gpt-4o","settings.custom.form_title_tts":"Configure TTS provider (OpenAI-compatible /audio/speech)","settings.custom.model_ph_tts":"e.g. tts-1 / FunAudioLLM/CosyVoice2-0.5B","settings.custom.form_title_asr":"Configure dictation provider (OpenAI-compatible /audio/transcriptions)","settings.custom.model_ph_asr":"e.g. whisper-large-v3-turbo","settings.custom.apikey_ph":"API Key (optional)","settings.custom.save":"Save","settings.custom.windowLabel":"Context window (tokens)","settings.custom.windowPh":"e.g. 128000 or 128k (empty = unknown)","settings.custom.windowHint":"Max context of the current model, found in its official docs. The composer context meter only shows a percentage when this is set.","settings.custom.vision":"Supports vision (multimodal)","settings.custom.visionHint":"When checked, images are sent directly to the main model. Unchecked uses the vision bridge (configure a vision model in AI Vision section) or skips images.","settings.delete_custom":"Delete this custom provider","settings.delete_custom_confirm":'Delete custom provider "{name}"? This cannot be undone.',"settings.key.overwrite_ph":"Overwrite…","settings.key.paste_ph":"Paste key","settings.key.get":"Get key →","settings.refresh":"Refresh","settings.discovering":"Refreshing…","settings.discover_failed":"Refresh failed (network may be restricted)","settings.daily_goal.hint":"XP / day (+10 XP per correct answer)","settings.theme.auto":"System","settings.theme.light":"Light","settings.theme.dark":"Dark","settings.theme.following":"Following system: {mode}","settings.lang_pref.desc":"When importing a course, auto-pick the translation matching this preference. If the repo's source language already matches, the original is used; if no translation exists, the original is used as well.","settings.img_download":"Image download","settings.img_download.desc":"Auto-download images referenced in markdown/notebooks during import (on by default)","settings.multimodal.toggle":"AI vision (in chat)","settings.multimodal.toggle.desc":"When on, the AI can see and explain this lesson's images during chat — used for diagrams/charts/architecture (needs a vision model).","settings.group.memory":"Learner memory","settings.memory.toggle":"Let the AI remember me","settings.memory.toggle.desc":"When on, the AI remembers how you learn across sessions (preferences / stuck points / recurring confusions) and adapts over time. Auto-summarized when you earn a crown (clear a node); also manually triggerable. All memory stays local.","settings.group.companion":"Learning companion","settings.companion.toggle":"Learning companion","settings.companion.toggle.desc":"Your companion lives in the course map, notebook and chat: celebrates wins, lip-syncs read-alouds, and taps along with every keystroke. Five forms to switch between. Fully local.","settings.companion.sfx":"Pet sounds","settings.companion.sfx.desc":"Short chirps when poked/hit/landing (synthesized, low volume)","settings.companion.pet":"Desktop pet mode","settings.companion.pet.desc":"Keep the companion on your desktop outside the app: transparent, always on top, wandering slowly — still poke-able. The in-app buddy takes a rest so you never see double.","settings.companion.form":"Form","companion.name":"Ember","companion.form.ember.name":"Ember","companion.form.ember.desc":"Blazing guardian — the passionate original; core charges with today's XP","companion.form.frost.name":"Frost","companion.form.frost.desc":"Crystal watcher — calm and steady; the hex core lights petal by petal","companion.form.moss.name":"Moss","companion.form.moss.desc":"Nature spirit — gentle company; the seed sprouts as you progress","companion.form.astro.name":"Astro","companion.form.astro.desc":"Stargazer — night-sky visor; the core moon waxes with today's XP","companion.form.ink.name":"Ink","companion.form.ink.desc":"Inkstone scholar — quiet study vibes; the ink pool rises with your progress","companion.form.custom.name":"Puppet","companion.form.custom.desc":"Custom paper puppet — import a character sheet and it rides the hover disc","companion.custom.title":"Custom puppet pack","companion.custom.import":"Import PNG sheet","companion.custom.apply":"Apply as my companion","companion.custom.delete":"Delete pack","companion.custom.cutDone":"Cut complete","companion.custom.routeVision":"vision cut","companion.custom.routeGeometric":"geometric cut","companion.custom.routeL1":"sticker tier (whole image)","companion.custom.applied":"Applied — your companion is now the puppet","companion.custom.deleted":"Deleted","companion.custom.locating":"Vision model locating parts… first run is slow","companion.custom.applying":"Applying pack…","companion.custom.visionFallback":"Vision unavailable, fell back to a single sticker (background auto-keyed)","companion.custom.fail":"Failed","companion.bots.add":"New","companion.bots.veh":"Change vehicle","companion.veh.silver":"Silver","companion.bots.deleteConfirm":"Delete this puppet? This cannot be undone.","companion.wizard.copyFail":"Copy failed — please select the prompt manually","companion.wizard.title":"Make my companion bot","companion.wizard.s1":"① Prepare the character image","companion.wizard.s1body":"Find an image of the character you want as your study buddy — a game, anime, or your own art. Front-facing, single character, clean and complete works best. It is not uploaded to LookatStudy; it is only used on the generation site in the next step.","companion.wizard.s2":"② Generate the chibi sheet on a free site","companion.wizard.s2body":"Open a generation site below (Doubao / Jimeng — both free): upload the character image → paste the Prompt below → send → download the portrait 2:3 PNG it creates.","companion.wizard.s2doubao":"Open Doubao","companion.wizard.s2jimeng":"Open Jimeng","companion.wizard.s2chatgpt":"Open ChatGPT","companion.wizard.copy":"Copy prompt","companion.wizard.copied":"Copied — paste it on the site","companion.wizard.s3":"③ Pick a vehicle, import and name it","companion.wizard.vehicle":"Vehicle style (hover platform)","companion.wizard.pick":"Choose the generated PNG","companion.wizard.namePh":"Name your puppet","companion.wizard.save":"Save & use","companion.wizard.prompt":`Image generation task: turn the character in the reference image into a Q-version (chibi) A-pose character sheet. The reference image is the only source of truth for the character's identity: pose and composition follow this prompt, identity features follow the reference image.
398
398
  Character lock — the following must match the reference image exactly, only simplified proportionally with the chibi style; do not change or drop any:
399
399
  1. Hair: silhouette, bangs direction, hair color, hair accessories
400
400
  2. Face: eye color, eye shape, eyebrows, default expression
@@ -433,7 +433,7 @@ Based on my performance, decide what comes next: explain why I got questions wro
433
433
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
434
434
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
435
435
  * THE SOFTWARE.
436
- */var ib=ds.exports,uc;function sb(){return uc||(uc=1,(function(e,t){(function(r,s){e.exports=s()})(ib,function(){return(function(n){var r={};function s(i){if(r[i])return r[i].exports;var a=r[i]={i,l:!1,exports:{}};return n[i].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=n,s.c=r,s.d=function(i,a,o){s.o(i,a)||Object.defineProperty(i,a,{enumerable:!0,get:o})},s.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},s.t=function(i,a){if(a&1&&(i=s(i)),a&8||a&4&&typeof i=="object"&&i&&i.__esModule)return i;var o=Object.create(null);if(s.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:i}),a&2&&typeof i!="string")for(var l in i)s.d(o,l,(function(u){return i[u]}).bind(null,l));return o},s.n=function(i){var a=i&&i.__esModule?function(){return i.default}:function(){return i};return s.d(a,"a",a),a},s.o=function(i,a){return Object.prototype.hasOwnProperty.call(i,a)},s.p="",s(s.s=20)})([(function(n,r){var s={};n.exports=s,(function(){s._baseDelta=1e3/60,s._nextId=0,s._seed=0,s._nowStartTime=+new Date,s._warnedOnce={},s._decomp=null,s.extend=function(a,o){var l,u;typeof o=="boolean"?(l=2,u=o):(l=1,u=!0);for(var c=l;c<arguments.length;c++){var f=arguments[c];if(f)for(var h in f)u&&f[h]&&f[h].constructor===Object&&(!a[h]||a[h].constructor===Object)?(a[h]=a[h]||{},s.extend(a[h],u,f[h])):a[h]=f[h]}return a},s.clone=function(a,o){return s.extend({},o,a)},s.keys=function(a){if(Object.keys)return Object.keys(a);var o=[];for(var l in a)o.push(l);return o},s.values=function(a){var o=[];if(Object.keys){for(var l=Object.keys(a),u=0;u<l.length;u++)o.push(a[l[u]]);return o}for(var c in a)o.push(a[c]);return o},s.get=function(a,o,l,u){o=o.split(".").slice(l,u);for(var c=0;c<o.length;c+=1)a=a[o[c]];return a},s.set=function(a,o,l,u,c){var f=o.split(".").slice(u,c);return s.get(a,o,0,-1)[f[f.length-1]]=l,l},s.shuffle=function(a){for(var o=a.length-1;o>0;o--){var l=Math.floor(s.random()*(o+1)),u=a[o];a[o]=a[l],a[l]=u}return a},s.choose=function(a){return a[Math.floor(s.random()*a.length)]},s.isElement=function(a){return typeof HTMLElement<"u"?a instanceof HTMLElement:!!(a&&a.nodeType&&a.nodeName)},s.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"},s.isFunction=function(a){return typeof a=="function"},s.isPlainObject=function(a){return typeof a=="object"&&a.constructor===Object},s.isString=function(a){return toString.call(a)==="[object String]"},s.clamp=function(a,o,l){return a<o?o:a>l?l:a},s.sign=function(a){return a<0?-1:1},s.now=function(){if(typeof window<"u"&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-s._nowStartTime},s.random=function(a,o){return a=typeof a<"u"?a:0,o=typeof o<"u"?o:1,a+i()*(o-a)};var i=function(){return s._seed=(s._seed*9301+49297)%233280,s._seed/233280};s.colorToNumber=function(a){return a=a.replace("#",""),a.length==3&&(a=a.charAt(0)+a.charAt(0)+a.charAt(1)+a.charAt(1)+a.charAt(2)+a.charAt(2)),parseInt(a,16)},s.logLevel=1,s.log=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.info=function(){console&&s.logLevel>0&&s.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warn=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warnOnce=function(){var a=Array.prototype.slice.call(arguments).join(" ");s._warnedOnce[a]||(s.warn(a),s._warnedOnce[a]=!0)},s.deprecated=function(a,o,l){a[o]=s.chain(function(){s.warnOnce("🔅 deprecated 🔅",l)},a[o])},s.nextId=function(){return s._nextId++},s.indexOf=function(a,o){if(a.indexOf)return a.indexOf(o);for(var l=0;l<a.length;l++)if(a[l]===o)return l;return-1},s.map=function(a,o){if(a.map)return a.map(o);for(var l=[],u=0;u<a.length;u+=1)l.push(o(a[u]));return l},s.topologicalSort=function(a){var o=[],l=[],u=[];for(var c in a)!l[c]&&!u[c]&&s._topologicalSort(c,l,u,a,o);return o},s._topologicalSort=function(a,o,l,u,c){var f=u[a]||[];l[a]=!0;for(var h=0;h<f.length;h+=1){var d=f[h];l[d]||o[d]||s._topologicalSort(d,o,l,u,c)}l[a]=!1,o[a]=!0,c.push(a)},s.chain=function(){for(var a=[],o=0;o<arguments.length;o+=1){var l=arguments[o];l._chained?a.push.apply(a,l._chained):a.push(l)}var u=function(){for(var c,f=new Array(arguments.length),h=0,d=arguments.length;h<d;h++)f[h]=arguments[h];for(h=0;h<a.length;h+=1){var m=a[h].apply(c,f);typeof m<"u"&&(c=m)}return c};return u._chained=a,u},s.chainPathBefore=function(a,o,l){return s.set(a,o,s.chain(l,s.get(a,o)))},s.chainPathAfter=function(a,o,l){return s.set(a,o,s.chain(s.get(a,o),l))},s.setDecomp=function(a){s._decomp=a},s.getDecomp=function(){var a=s._decomp;try{!a&&typeof window<"u"&&(a=window.decomp),!a&&typeof Wu<"u"&&(a=Wu.decomp)}catch{a=null}return a}})()}),(function(n,r){var s={};n.exports=s,(function(){s.create=function(i){var a={min:{x:0,y:0},max:{x:0,y:0}};return i&&s.update(a,i),a},s.update=function(i,a,o){i.min.x=1/0,i.max.x=-1/0,i.min.y=1/0,i.max.y=-1/0;for(var l=0;l<a.length;l++){var u=a[l];u.x>i.max.x&&(i.max.x=u.x),u.x<i.min.x&&(i.min.x=u.x),u.y>i.max.y&&(i.max.y=u.y),u.y<i.min.y&&(i.min.y=u.y)}o&&(o.x>0?i.max.x+=o.x:i.min.x+=o.x,o.y>0?i.max.y+=o.y:i.min.y+=o.y)},s.contains=function(i,a){return a.x>=i.min.x&&a.x<=i.max.x&&a.y>=i.min.y&&a.y<=i.max.y},s.overlaps=function(i,a){return i.min.x<=a.max.x&&i.max.x>=a.min.x&&i.max.y>=a.min.y&&i.min.y<=a.max.y},s.translate=function(i,a){i.min.x+=a.x,i.max.x+=a.x,i.min.y+=a.y,i.max.y+=a.y},s.shift=function(i,a){var o=i.max.x-i.min.x,l=i.max.y-i.min.y;i.min.x=a.x,i.max.x=a.x+o,i.min.y=a.y,i.max.y=a.y+l}})()}),(function(n,r){var s={};n.exports=s,(function(){s.create=function(i,a){return{x:i||0,y:a||0}},s.clone=function(i){return{x:i.x,y:i.y}},s.magnitude=function(i){return Math.sqrt(i.x*i.x+i.y*i.y)},s.magnitudeSquared=function(i){return i.x*i.x+i.y*i.y},s.rotate=function(i,a,o){var l=Math.cos(a),u=Math.sin(a);o||(o={});var c=i.x*l-i.y*u;return o.y=i.x*u+i.y*l,o.x=c,o},s.rotateAbout=function(i,a,o,l){var u=Math.cos(a),c=Math.sin(a);l||(l={});var f=o.x+((i.x-o.x)*u-(i.y-o.y)*c);return l.y=o.y+((i.x-o.x)*c+(i.y-o.y)*u),l.x=f,l},s.normalise=function(i){var a=s.magnitude(i);return a===0?{x:0,y:0}:{x:i.x/a,y:i.y/a}},s.dot=function(i,a){return i.x*a.x+i.y*a.y},s.cross=function(i,a){return i.x*a.y-i.y*a.x},s.cross3=function(i,a,o){return(a.x-i.x)*(o.y-i.y)-(a.y-i.y)*(o.x-i.x)},s.add=function(i,a,o){return o||(o={}),o.x=i.x+a.x,o.y=i.y+a.y,o},s.sub=function(i,a,o){return o||(o={}),o.x=i.x-a.x,o.y=i.y-a.y,o},s.mult=function(i,a){return{x:i.x*a,y:i.y*a}},s.div=function(i,a){return{x:i.x/a,y:i.y/a}},s.perp=function(i,a){return a=a===!0?-1:1,{x:a*-i.y,y:a*i.x}},s.neg=function(i){return{x:-i.x,y:-i.y}},s.angle=function(i,a){return Math.atan2(a.y-i.y,a.x-i.x)},s._temp=[s.create(),s.create(),s.create(),s.create(),s.create(),s.create()]})()}),(function(n,r,s){var i={};n.exports=i;var a=s(2),o=s(0);(function(){i.create=function(l,u){for(var c=[],f=0;f<l.length;f++){var h=l[f],d={x:h.x,y:h.y,index:f,body:u,isInternal:!1};c.push(d)}return c},i.fromPath=function(l,u){var c=/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig,f=[];return l.replace(c,function(h,d,m){f.push({x:parseFloat(d),y:parseFloat(m)})}),i.create(f,u)},i.centre=function(l){for(var u=i.area(l,!0),c={x:0,y:0},f,h,d,m=0;m<l.length;m++)d=(m+1)%l.length,f=a.cross(l[m],l[d]),h=a.mult(a.add(l[m],l[d]),f),c=a.add(c,h);return a.div(c,6*u)},i.mean=function(l){for(var u={x:0,y:0},c=0;c<l.length;c++)u.x+=l[c].x,u.y+=l[c].y;return a.div(u,l.length)},i.area=function(l,u){for(var c=0,f=l.length-1,h=0;h<l.length;h++)c+=(l[f].x-l[h].x)*(l[f].y+l[h].y),f=h;return u?c/2:Math.abs(c)/2},i.inertia=function(l,u){for(var c=0,f=0,h=l,d,m,p=0;p<h.length;p++)m=(p+1)%h.length,d=Math.abs(a.cross(h[m],h[p])),c+=d*(a.dot(h[m],h[m])+a.dot(h[m],h[p])+a.dot(h[p],h[p])),f+=d;return u/6*(c/f)},i.translate=function(l,u,c){c=typeof c<"u"?c:1;var f=l.length,h=u.x*c,d=u.y*c,m;for(m=0;m<f;m++)l[m].x+=h,l[m].y+=d;return l},i.rotate=function(l,u,c){if(u!==0){var f=Math.cos(u),h=Math.sin(u),d=c.x,m=c.y,p=l.length,g,y,T,v;for(v=0;v<p;v++)g=l[v],y=g.x-d,T=g.y-m,g.x=d+(y*f-T*h),g.y=m+(y*h+T*f);return l}},i.contains=function(l,u){for(var c=u.x,f=u.y,h=l.length,d=l[h-1],m,p=0;p<h;p++){if(m=l[p],(c-d.x)*(m.y-d.y)+(f-d.y)*(d.x-m.x)>0)return!1;d=m}return!0},i.scale=function(l,u,c,f){if(u===1&&c===1)return l;f=f||i.centre(l);for(var h,d,m=0;m<l.length;m++)h=l[m],d=a.sub(h,f),l[m].x=f.x+d.x*u,l[m].y=f.y+d.y*c;return l},i.chamfer=function(l,u,c,f,h){typeof u=="number"?u=[u]:u=u||[8],c=typeof c<"u"?c:-1,f=f||2,h=h||14;for(var d=[],m=0;m<l.length;m++){var p=l[m-1>=0?m-1:l.length-1],g=l[m],y=l[(m+1)%l.length],T=u[m<u.length?m:u.length-1];if(T===0){d.push(g);continue}var v=a.normalise({x:g.y-p.y,y:p.x-g.x}),C=a.normalise({x:y.y-g.y,y:g.x-y.x}),E=Math.sqrt(2*Math.pow(T,2)),w=a.mult(o.clone(v),T),_=a.normalise(a.mult(a.add(v,C),.5)),S=a.sub(g,a.mult(_,E)),I=c;c===-1&&(I=Math.pow(T,.32)*1.75),I=o.clamp(I,f,h),I%2===1&&(I+=1);for(var A=Math.acos(a.dot(v,C)),P=A/I,N=0;N<I;N++)d.push(a.add(a.rotate(w,P*N),S))}return d},i.clockwiseSort=function(l){var u=i.mean(l);return l.sort(function(c,f){return a.angle(u,c)-a.angle(u,f)}),l},i.isConvex=function(l){var u=0,c=l.length,f,h,d,m;if(c<3)return null;for(f=0;f<c;f++)if(h=(f+1)%c,d=(f+2)%c,m=(l[h].x-l[f].x)*(l[d].y-l[h].y),m-=(l[h].y-l[f].y)*(l[d].x-l[h].x),m<0?u|=1:m>0&&(u|=2),u===3)return!1;return u!==0?!0:null},i.hull=function(l){var u=[],c=[],f,h;for(l=l.slice(0),l.sort(function(d,m){var p=d.x-m.x;return p!==0?p:d.y-m.y}),h=0;h<l.length;h+=1){for(f=l[h];c.length>=2&&a.cross3(c[c.length-2],c[c.length-1],f)<=0;)c.pop();c.push(f)}for(h=l.length-1;h>=0;h-=1){for(f=l[h];u.length>=2&&a.cross3(u[u.length-2],u[u.length-1],f)<=0;)u.pop();u.push(f)}return u.pop(),c.pop(),u.concat(c)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(2),l=s(7),u=s(0),c=s(1),f=s(11);(function(){i._timeCorrection=!0,i._inertiaScale=4,i._nextCollidingGroupId=1,i._nextNonCollidingGroupId=-1,i._nextCategory=1,i._baseDelta=1e3/60,i.create=function(d){var m={id:u.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:a.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,strokeStyle:null,fillStyle:null,lineWidth:null,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0}},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,deltaTime:16.666666666666668,_original:null},p=u.extend(m,d);return h(p,d),p},i.nextGroup=function(d){return d?i._nextNonCollidingGroupId--:i._nextCollidingGroupId++},i.nextCategory=function(){return i._nextCategory=i._nextCategory<<1,i._nextCategory};var h=function(d,m){m=m||{},i.set(d,{bounds:d.bounds||c.create(d.vertices),positionPrev:d.positionPrev||o.clone(d.position),anglePrev:d.anglePrev||d.angle,vertices:d.vertices,parts:d.parts||[d],isStatic:d.isStatic,isSleeping:d.isSleeping,parent:d.parent||d}),a.rotate(d.vertices,d.angle,d.position),f.rotate(d.axes,d.angle),c.update(d.bounds,d.vertices,d.velocity),i.set(d,{axes:m.axes||d.axes,area:m.area||d.area,mass:m.mass||d.mass,inertia:m.inertia||d.inertia});var p=d.isStatic?"#14151f":u.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),g=d.isStatic?"#555":"#ccc",y=d.isStatic&&d.render.fillStyle===null?1:0;d.render.fillStyle=d.render.fillStyle||p,d.render.strokeStyle=d.render.strokeStyle||g,d.render.lineWidth=d.render.lineWidth||y,d.render.sprite.xOffset+=-(d.bounds.min.x-d.position.x)/(d.bounds.max.x-d.bounds.min.x),d.render.sprite.yOffset+=-(d.bounds.min.y-d.position.y)/(d.bounds.max.y-d.bounds.min.y)};i.set=function(d,m,p){var g;typeof m=="string"&&(g=m,m={},m[g]=p);for(g in m)if(Object.prototype.hasOwnProperty.call(m,g))switch(p=m[g],g){case"isStatic":i.setStatic(d,p);break;case"isSleeping":l.set(d,p);break;case"mass":i.setMass(d,p);break;case"density":i.setDensity(d,p);break;case"inertia":i.setInertia(d,p);break;case"vertices":i.setVertices(d,p);break;case"position":i.setPosition(d,p);break;case"angle":i.setAngle(d,p);break;case"velocity":i.setVelocity(d,p);break;case"angularVelocity":i.setAngularVelocity(d,p);break;case"speed":i.setSpeed(d,p);break;case"angularSpeed":i.setAngularSpeed(d,p);break;case"parts":i.setParts(d,p);break;case"centre":i.setCentre(d,p);break;default:d[g]=p}},i.setStatic=function(d,m){for(var p=0;p<d.parts.length;p++){var g=d.parts[p];g.isStatic=m,m?(g._original={restitution:g.restitution,friction:g.friction,mass:g.mass,inertia:g.inertia,density:g.density,inverseMass:g.inverseMass,inverseInertia:g.inverseInertia},g.restitution=0,g.friction=1,g.mass=g.inertia=g.density=1/0,g.inverseMass=g.inverseInertia=0,g.positionPrev.x=g.position.x,g.positionPrev.y=g.position.y,g.anglePrev=g.angle,g.angularVelocity=0,g.speed=0,g.angularSpeed=0,g.motion=0):g._original&&(g.restitution=g._original.restitution,g.friction=g._original.friction,g.mass=g._original.mass,g.inertia=g._original.inertia,g.density=g._original.density,g.inverseMass=g._original.inverseMass,g.inverseInertia=g._original.inverseInertia,g._original=null)}},i.setMass=function(d,m){var p=d.inertia/(d.mass/6);d.inertia=p*(m/6),d.inverseInertia=1/d.inertia,d.mass=m,d.inverseMass=1/d.mass,d.density=d.mass/d.area},i.setDensity=function(d,m){i.setMass(d,m*d.area),d.density=m},i.setInertia=function(d,m){d.inertia=m,d.inverseInertia=1/d.inertia},i.setVertices=function(d,m){m[0].body===d?d.vertices=m:d.vertices=a.create(m,d),d.axes=f.fromVertices(d.vertices),d.area=a.area(d.vertices),i.setMass(d,d.density*d.area);var p=a.centre(d.vertices);a.translate(d.vertices,p,-1),i.setInertia(d,i._inertiaScale*a.inertia(d.vertices,d.mass)),a.translate(d.vertices,d.position),c.update(d.bounds,d.vertices,d.velocity)},i.setParts=function(d,m,p){var g;for(m=m.slice(0),d.parts.length=0,d.parts.push(d),d.parent=d,g=0;g<m.length;g++){var y=m[g];y!==d&&(y.parent=d,d.parts.push(y))}if(d.parts.length!==1){if(p=typeof p<"u"?p:!0,p){var T=[];for(g=0;g<m.length;g++)T=T.concat(m[g].vertices);a.clockwiseSort(T);var v=a.hull(T),C=a.centre(v);i.setVertices(d,v),a.translate(d.vertices,C)}var E=i._totalProperties(d);d.area=E.area,d.parent=d,d.position.x=E.centre.x,d.position.y=E.centre.y,d.positionPrev.x=E.centre.x,d.positionPrev.y=E.centre.y,i.setMass(d,E.mass),i.setInertia(d,E.inertia),i.setPosition(d,E.centre)}},i.setCentre=function(d,m,p){p?(d.positionPrev.x+=m.x,d.positionPrev.y+=m.y,d.position.x+=m.x,d.position.y+=m.y):(d.positionPrev.x=m.x-(d.position.x-d.positionPrev.x),d.positionPrev.y=m.y-(d.position.y-d.positionPrev.y),d.position.x=m.x,d.position.y=m.y)},i.setPosition=function(d,m,p){var g=o.sub(m,d.position);p?(d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.velocity.x=g.x,d.velocity.y=g.y,d.speed=o.magnitude(g)):(d.positionPrev.x+=g.x,d.positionPrev.y+=g.y);for(var y=0;y<d.parts.length;y++){var T=d.parts[y];T.position.x+=g.x,T.position.y+=g.y,a.translate(T.vertices,g),c.update(T.bounds,T.vertices,d.velocity)}},i.setAngle=function(d,m,p){var g=m-d.angle;p?(d.anglePrev=d.angle,d.angularVelocity=g,d.angularSpeed=Math.abs(g)):d.anglePrev+=g;for(var y=0;y<d.parts.length;y++){var T=d.parts[y];T.angle+=g,a.rotate(T.vertices,g,d.position),f.rotate(T.axes,g),c.update(T.bounds,T.vertices,d.velocity),y>0&&o.rotateAbout(T.position,g,d.position,T.position)}},i.setVelocity=function(d,m){var p=d.deltaTime/i._baseDelta;d.positionPrev.x=d.position.x-m.x*p,d.positionPrev.y=d.position.y-m.y*p,d.velocity.x=(d.position.x-d.positionPrev.x)/p,d.velocity.y=(d.position.y-d.positionPrev.y)/p,d.speed=o.magnitude(d.velocity)},i.getVelocity=function(d){var m=i._baseDelta/d.deltaTime;return{x:(d.position.x-d.positionPrev.x)*m,y:(d.position.y-d.positionPrev.y)*m}},i.getSpeed=function(d){return o.magnitude(i.getVelocity(d))},i.setSpeed=function(d,m){i.setVelocity(d,o.mult(o.normalise(i.getVelocity(d)),m))},i.setAngularVelocity=function(d,m){var p=d.deltaTime/i._baseDelta;d.anglePrev=d.angle-m*p,d.angularVelocity=(d.angle-d.anglePrev)/p,d.angularSpeed=Math.abs(d.angularVelocity)},i.getAngularVelocity=function(d){return(d.angle-d.anglePrev)*i._baseDelta/d.deltaTime},i.getAngularSpeed=function(d){return Math.abs(i.getAngularVelocity(d))},i.setAngularSpeed=function(d,m){i.setAngularVelocity(d,u.sign(i.getAngularVelocity(d))*m)},i.translate=function(d,m,p){i.setPosition(d,o.add(d.position,m),p)},i.rotate=function(d,m,p,g){if(!p)i.setAngle(d,d.angle+m,g);else{var y=Math.cos(m),T=Math.sin(m),v=d.position.x-p.x,C=d.position.y-p.y;i.setPosition(d,{x:p.x+(v*y-C*T),y:p.y+(v*T+C*y)},g),i.setAngle(d,d.angle+m,g)}},i.scale=function(d,m,p,g){var y=0,T=0;g=g||d.position;for(var v=0;v<d.parts.length;v++){var C=d.parts[v];a.scale(C.vertices,m,p,g),C.axes=f.fromVertices(C.vertices),C.area=a.area(C.vertices),i.setMass(C,d.density*C.area),a.translate(C.vertices,{x:-C.position.x,y:-C.position.y}),i.setInertia(C,i._inertiaScale*a.inertia(C.vertices,C.mass)),a.translate(C.vertices,{x:C.position.x,y:C.position.y}),v>0&&(y+=C.area,T+=C.inertia),C.position.x=g.x+(C.position.x-g.x)*m,C.position.y=g.y+(C.position.y-g.y)*p,c.update(C.bounds,C.vertices,d.velocity)}d.parts.length>1&&(d.area=y,d.isStatic||(i.setMass(d,d.density*y),i.setInertia(d,T))),d.circleRadius&&(m===p?d.circleRadius*=m:d.circleRadius=null)},i.update=function(d,m){m=(typeof m<"u"?m:1e3/60)*d.timeScale;var p=m*m,g=i._timeCorrection?m/(d.deltaTime||m):1,y=1-d.frictionAir*(m/u._baseDelta),T=(d.position.x-d.positionPrev.x)*g,v=(d.position.y-d.positionPrev.y)*g;d.velocity.x=T*y+d.force.x/d.mass*p,d.velocity.y=v*y+d.force.y/d.mass*p,d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.position.x+=d.velocity.x,d.position.y+=d.velocity.y,d.deltaTime=m,d.angularVelocity=(d.angle-d.anglePrev)*y*g+d.torque/d.inertia*p,d.anglePrev=d.angle,d.angle+=d.angularVelocity;for(var C=0;C<d.parts.length;C++){var E=d.parts[C];a.translate(E.vertices,d.velocity),C>0&&(E.position.x+=d.velocity.x,E.position.y+=d.velocity.y),d.angularVelocity!==0&&(a.rotate(E.vertices,d.angularVelocity,d.position),f.rotate(E.axes,d.angularVelocity),C>0&&o.rotateAbout(E.position,d.angularVelocity,d.position,E.position)),c.update(E.bounds,E.vertices,d.velocity)}},i.updateVelocities=function(d){var m=i._baseDelta/d.deltaTime,p=d.velocity;p.x=(d.position.x-d.positionPrev.x)*m,p.y=(d.position.y-d.positionPrev.y)*m,d.speed=Math.sqrt(p.x*p.x+p.y*p.y),d.angularVelocity=(d.angle-d.anglePrev)*m,d.angularSpeed=Math.abs(d.angularVelocity)},i.applyForce=function(d,m,p){var g={x:m.x-d.position.x,y:m.y-d.position.y};d.force.x+=p.x,d.force.y+=p.y,d.torque+=g.x*p.y-g.y*p.x},i._totalProperties=function(d){for(var m={mass:0,area:0,inertia:0,centre:{x:0,y:0}},p=d.parts.length===1?0:1;p<d.parts.length;p++){var g=d.parts[p],y=g.mass!==1/0?g.mass:1;m.mass+=y,m.area+=g.area,m.inertia+=g.inertia,m.centre=o.add(m.centre,o.mult(g.position,y))}return m.centre=o.div(m.centre,m.mass),m}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0);(function(){i.on=function(o,l,u){for(var c=l.split(" "),f,h=0;h<c.length;h++)f=c[h],o.events=o.events||{},o.events[f]=o.events[f]||[],o.events[f].push(u);return u},i.off=function(o,l,u){if(!l){o.events={};return}typeof l=="function"&&(u=l,l=a.keys(o.events).join(" "));for(var c=l.split(" "),f=0;f<c.length;f++){var h=o.events[c[f]],d=[];if(u&&h)for(var m=0;m<h.length;m++)h[m]!==u&&d.push(h[m]);o.events[c[f]]=d}},i.trigger=function(o,l,u){var c,f,h,d,m=o.events;if(m&&a.keys(m).length>0){u||(u={}),c=l.split(" ");for(var p=0;p<c.length;p++)if(f=c[p],h=m[f],h){d=a.clone(u,!1),d.name=f,d.source=o;for(var g=0;g<h.length;g++)h[g].apply(o,[d])}}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(5),o=s(0),l=s(1),u=s(4);(function(){i.create=function(c){return o.extend({id:o.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},c)},i.setModified=function(c,f,h,d){if(c.isModified=f,f&&c.cache&&(c.cache.allBodies=null,c.cache.allConstraints=null,c.cache.allComposites=null),h&&c.parent&&i.setModified(c.parent,f,h,d),d)for(var m=0;m<c.composites.length;m++){var p=c.composites[m];i.setModified(p,f,h,d)}},i.add=function(c,f){var h=[].concat(f);a.trigger(c,"beforeAdd",{object:f});for(var d=0;d<h.length;d++){var m=h[d];switch(m.type){case"body":if(m.parent!==m){o.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}i.addBody(c,m);break;case"constraint":i.addConstraint(c,m);break;case"composite":i.addComposite(c,m);break;case"mouseConstraint":i.addConstraint(c,m.constraint);break}}return a.trigger(c,"afterAdd",{object:f}),c},i.remove=function(c,f,h){var d=[].concat(f);a.trigger(c,"beforeRemove",{object:f});for(var m=0;m<d.length;m++){var p=d[m];switch(p.type){case"body":i.removeBody(c,p,h);break;case"constraint":i.removeConstraint(c,p,h);break;case"composite":i.removeComposite(c,p,h);break;case"mouseConstraint":i.removeConstraint(c,p.constraint);break}}return a.trigger(c,"afterRemove",{object:f}),c},i.addComposite=function(c,f){return c.composites.push(f),f.parent=c,i.setModified(c,!0,!0,!1),c},i.removeComposite=function(c,f,h){var d=o.indexOf(c.composites,f);if(d!==-1&&i.removeCompositeAt(c,d),h)for(var m=0;m<c.composites.length;m++)i.removeComposite(c.composites[m],f,!0);return c},i.removeCompositeAt=function(c,f){return c.composites.splice(f,1),i.setModified(c,!0,!0,!1),c},i.addBody=function(c,f){return c.bodies.push(f),i.setModified(c,!0,!0,!1),c},i.removeBody=function(c,f,h){var d=o.indexOf(c.bodies,f);if(d!==-1&&i.removeBodyAt(c,d),h)for(var m=0;m<c.composites.length;m++)i.removeBody(c.composites[m],f,!0);return c},i.removeBodyAt=function(c,f){return c.bodies.splice(f,1),i.setModified(c,!0,!0,!1),c},i.addConstraint=function(c,f){return c.constraints.push(f),i.setModified(c,!0,!0,!1),c},i.removeConstraint=function(c,f,h){var d=o.indexOf(c.constraints,f);if(d!==-1&&i.removeConstraintAt(c,d),h)for(var m=0;m<c.composites.length;m++)i.removeConstraint(c.composites[m],f,!0);return c},i.removeConstraintAt=function(c,f){return c.constraints.splice(f,1),i.setModified(c,!0,!0,!1),c},i.clear=function(c,f,h){if(h)for(var d=0;d<c.composites.length;d++)i.clear(c.composites[d],f,!0);return f?c.bodies=c.bodies.filter(function(m){return m.isStatic}):c.bodies.length=0,c.constraints.length=0,c.composites.length=0,i.setModified(c,!0,!0,!1),c},i.allBodies=function(c){if(c.cache&&c.cache.allBodies)return c.cache.allBodies;for(var f=[].concat(c.bodies),h=0;h<c.composites.length;h++)f=f.concat(i.allBodies(c.composites[h]));return c.cache&&(c.cache.allBodies=f),f},i.allConstraints=function(c){if(c.cache&&c.cache.allConstraints)return c.cache.allConstraints;for(var f=[].concat(c.constraints),h=0;h<c.composites.length;h++)f=f.concat(i.allConstraints(c.composites[h]));return c.cache&&(c.cache.allConstraints=f),f},i.allComposites=function(c){if(c.cache&&c.cache.allComposites)return c.cache.allComposites;for(var f=[].concat(c.composites),h=0;h<c.composites.length;h++)f=f.concat(i.allComposites(c.composites[h]));return c.cache&&(c.cache.allComposites=f),f},i.get=function(c,f,h){var d,m;switch(h){case"body":d=i.allBodies(c);break;case"constraint":d=i.allConstraints(c);break;case"composite":d=i.allComposites(c).concat(c);break}return d?(m=d.filter(function(p){return p.id.toString()===f.toString()}),m.length===0?null:m[0]):null},i.move=function(c,f,h){return i.remove(c,f),i.add(h,f),c},i.rebase=function(c){for(var f=i.allBodies(c).concat(i.allConstraints(c)).concat(i.allComposites(c)),h=0;h<f.length;h++)f[h].id=o.nextId();return c},i.translate=function(c,f,h){for(var d=h?i.allBodies(c):c.bodies,m=0;m<d.length;m++)u.translate(d[m],f);return c},i.rotate=function(c,f,h,d){for(var m=Math.cos(f),p=Math.sin(f),g=d?i.allBodies(c):c.bodies,y=0;y<g.length;y++){var T=g[y],v=T.position.x-h.x,C=T.position.y-h.y;u.setPosition(T,{x:h.x+(v*m-C*p),y:h.y+(v*p+C*m)}),u.rotate(T,f)}return c},i.scale=function(c,f,h,d,m){for(var p=m?i.allBodies(c):c.bodies,g=0;g<p.length;g++){var y=p[g],T=y.position.x-d.x,v=y.position.y-d.y;u.setPosition(y,{x:d.x+T*f,y:d.y+v*h}),u.scale(y,f,h)}return c},i.bounds=function(c){for(var f=i.allBodies(c),h=[],d=0;d<f.length;d+=1){var m=f[d];h.push(m.bounds.min,m.bounds.max)}return l.create(h)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(4),o=s(5),l=s(0);(function(){i._motionWakeThreshold=.18,i._motionSleepThreshold=.08,i._minBias=.9,i.update=function(u,c){for(var f=c/l._baseDelta,h=i._motionSleepThreshold,d=0;d<u.length;d++){var m=u[d],p=a.getSpeed(m),g=a.getAngularSpeed(m),y=p*p+g*g;if(m.force.x!==0||m.force.y!==0){i.set(m,!1);continue}var T=Math.min(m.motion,y),v=Math.max(m.motion,y);m.motion=i._minBias*T+(1-i._minBias)*v,m.sleepThreshold>0&&m.motion<h?(m.sleepCounter+=1,m.sleepCounter>=m.sleepThreshold/f&&i.set(m,!0)):m.sleepCounter>0&&(m.sleepCounter-=1)}},i.afterCollisions=function(u){for(var c=i._motionSleepThreshold,f=0;f<u.length;f++){var h=u[f];if(h.isActive){var d=h.collision,m=d.bodyA.parent,p=d.bodyB.parent;if(!(m.isSleeping&&p.isSleeping||m.isStatic||p.isStatic)&&(m.isSleeping||p.isSleeping)){var g=m.isSleeping&&!m.isStatic?m:p,y=g===m?p:m;!g.isStatic&&y.motion>c&&i.set(g,!1)}}}},i.set=function(u,c){var f=u.isSleeping;c?(u.isSleeping=!0,u.sleepCounter=u.sleepThreshold,u.positionImpulse.x=0,u.positionImpulse.y=0,u.positionPrev.x=u.position.x,u.positionPrev.y=u.position.y,u.anglePrev=u.angle,u.speed=0,u.angularSpeed=0,u.motion=0,f||o.trigger(u,"sleepStart")):(u.isSleeping=!1,u.sleepCounter=0,f&&o.trigger(u,"sleepEnd"))}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(9);(function(){var l=[],u={overlap:0,axis:null},c={overlap:0,axis:null};i.create=function(f,h){return{pair:null,collided:!1,bodyA:f,bodyB:h,parentA:f.parent,parentB:h.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},i.collides=function(f,h,d){if(i._overlapAxes(u,f.vertices,h.vertices,f.axes),u.overlap<=0||(i._overlapAxes(c,h.vertices,f.vertices,h.axes),c.overlap<=0))return null;var m=d&&d.table[o.id(f,h)],p;m?p=m.collision:(p=i.create(f,h),p.collided=!0,p.bodyA=f.id<h.id?f:h,p.bodyB=f.id<h.id?h:f,p.parentA=p.bodyA.parent,p.parentB=p.bodyB.parent),f=p.bodyA,h=p.bodyB;var g;u.overlap<c.overlap?g=u:g=c;var y=p.normal,T=p.supports,v=g.axis,C=v.x,E=v.y;C*(h.position.x-f.position.x)+E*(h.position.y-f.position.y)<0?(y.x=C,y.y=E):(y.x=-C,y.y=-E),p.tangent.x=-y.y,p.tangent.y=y.x,p.depth=g.overlap,p.penetration.x=y.x*p.depth,p.penetration.y=y.y*p.depth;var w=i._findSupports(f,h,y,1),_=0;if(a.contains(f.vertices,w[0])&&(T[_++]=w[0]),a.contains(f.vertices,w[1])&&(T[_++]=w[1]),_<2){var S=i._findSupports(h,f,y,-1);a.contains(h.vertices,S[0])&&(T[_++]=S[0]),_<2&&a.contains(h.vertices,S[1])&&(T[_++]=S[1])}return _===0&&(T[_++]=w[0]),T.length=_,p},i._overlapAxes=function(f,h,d,m){var p=h.length,g=d.length,y=h[0].x,T=h[0].y,v=d[0].x,C=d[0].y,E=m.length,w=Number.MAX_VALUE,_=0,S,I,A,P,N,j;for(N=0;N<E;N++){var M=m[N],L=M.x,B=M.y,V=y*L+T*B,F=v*L+C*B,q=V,R=F;for(j=1;j<p;j+=1)P=h[j].x*L+h[j].y*B,P>q?q=P:P<V&&(V=P);for(j=1;j<g;j+=1)P=d[j].x*L+d[j].y*B,P>R?R=P:P<F&&(F=P);if(I=q-F,A=R-V,S=I<A?I:A,S<w&&(w=S,_=N,S<=0))break}f.axis=m[_],f.overlap=w},i._projectToAxis=function(f,h,d){for(var m=h[0].x*d.x+h[0].y*d.y,p=m,g=1;g<h.length;g+=1){var y=h[g].x*d.x+h[g].y*d.y;y>p?p=y:y<m&&(m=y)}f.min=m,f.max=p},i._findSupports=function(f,h,d,m){var p=h.vertices,g=p.length,y=f.position.x,T=f.position.y,v=d.x*m,C=d.y*m,E=Number.MAX_VALUE,w,_,S,I,A;for(A=0;A<g;A+=1)_=p[A],I=v*(y-_.x)+C*(T-_.y),I<E&&(E=I,w=_);return S=p[(g+w.index-1)%g],E=v*(y-S.x)+C*(T-S.y),_=p[(w.index+1)%g],v*(y-_.x)+C*(T-_.y)<E?(l[0]=w,l[1]=_,l):(l[0]=w,l[1]=S,l)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(16);(function(){i.create=function(o,l){var u=o.bodyA,c=o.bodyB,f={id:i.id(u,c),bodyA:u,bodyB:c,collision:o,contacts:[],activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:u.isSensor||c.isSensor,timeCreated:l,timeUpdated:l,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return i.update(f,o,l),f},i.update=function(o,l,u){var c=o.contacts,f=l.supports,h=o.activeContacts,d=l.parentA,m=l.parentB,p=d.vertices.length;o.isActive=!0,o.timeUpdated=u,o.collision=l,o.separation=l.depth,o.inverseMass=d.inverseMass+m.inverseMass,o.friction=d.friction<m.friction?d.friction:m.friction,o.frictionStatic=d.frictionStatic>m.frictionStatic?d.frictionStatic:m.frictionStatic,o.restitution=d.restitution>m.restitution?d.restitution:m.restitution,o.slop=d.slop>m.slop?d.slop:m.slop,l.pair=o,h.length=0;for(var g=0;g<f.length;g++){var y=f[g],T=y.body===d?y.index:p+y.index,v=c[T];v?h.push(v):h.push(c[T]=a.create(y))}},i.setActive=function(o,l,u){l?(o.isActive=!0,o.timeUpdated=u):(o.isActive=!1,o.activeContacts.length=0)},i.id=function(o,l){return o.id<l.id?"A"+o.id+"B"+l.id:"A"+l.id+"B"+o.id}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(2),l=s(7),u=s(1),c=s(11),f=s(0);(function(){i._warming=.4,i._torqueDampen=1,i._minLength=1e-6,i.create=function(h){var d=h;d.bodyA&&!d.pointA&&(d.pointA={x:0,y:0}),d.bodyB&&!d.pointB&&(d.pointB={x:0,y:0});var m=d.bodyA?o.add(d.bodyA.position,d.pointA):d.pointA,p=d.bodyB?o.add(d.bodyB.position,d.pointB):d.pointB,g=o.magnitude(o.sub(m,p));d.length=typeof d.length<"u"?d.length:g,d.id=d.id||f.nextId(),d.label=d.label||"Constraint",d.type="constraint",d.stiffness=d.stiffness||(d.length>0?1:.7),d.damping=d.damping||0,d.angularStiffness=d.angularStiffness||0,d.angleA=d.bodyA?d.bodyA.angle:d.angleA,d.angleB=d.bodyB?d.bodyB.angle:d.angleB,d.plugin={};var y={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return d.length===0&&d.stiffness>.1?(y.type="pin",y.anchors=!1):d.stiffness<.9&&(y.type="spring"),d.render=f.extend(y,d.render),d},i.preSolveAll=function(h){for(var d=0;d<h.length;d+=1){var m=h[d],p=m.constraintImpulse;m.isStatic||p.x===0&&p.y===0&&p.angle===0||(m.position.x+=p.x,m.position.y+=p.y,m.angle+=p.angle)}},i.solveAll=function(h,d){for(var m=f.clamp(d/f._baseDelta,0,1),p=0;p<h.length;p+=1){var g=h[p],y=!g.bodyA||g.bodyA&&g.bodyA.isStatic,T=!g.bodyB||g.bodyB&&g.bodyB.isStatic;(y||T)&&i.solve(h[p],m)}for(p=0;p<h.length;p+=1)g=h[p],y=!g.bodyA||g.bodyA&&g.bodyA.isStatic,T=!g.bodyB||g.bodyB&&g.bodyB.isStatic,!y&&!T&&i.solve(h[p],m)},i.solve=function(h,d){var m=h.bodyA,p=h.bodyB,g=h.pointA,y=h.pointB;if(!(!m&&!p)){m&&!m.isStatic&&(o.rotate(g,m.angle-h.angleA,g),h.angleA=m.angle),p&&!p.isStatic&&(o.rotate(y,p.angle-h.angleB,y),h.angleB=p.angle);var T=g,v=y;if(m&&(T=o.add(m.position,g)),p&&(v=o.add(p.position,y)),!(!T||!v)){var C=o.sub(T,v),E=o.magnitude(C);E<i._minLength&&(E=i._minLength);var w=(E-h.length)/E,_=h.stiffness>=1||h.length===0,S=_?h.stiffness*d:h.stiffness*d*d,I=h.damping*d,A=o.mult(C,w*S),P=(m?m.inverseMass:0)+(p?p.inverseMass:0),N=(m?m.inverseInertia:0)+(p?p.inverseInertia:0),j=P+N,M,L,B,V,F;if(I>0){var q=o.create();B=o.div(C,E),F=o.sub(p&&o.sub(p.position,p.positionPrev)||q,m&&o.sub(m.position,m.positionPrev)||q),V=o.dot(B,F)}m&&!m.isStatic&&(L=m.inverseMass/P,m.constraintImpulse.x-=A.x*L,m.constraintImpulse.y-=A.y*L,m.position.x-=A.x*L,m.position.y-=A.y*L,I>0&&(m.positionPrev.x-=I*B.x*V*L,m.positionPrev.y-=I*B.y*V*L),M=o.cross(g,A)/j*i._torqueDampen*m.inverseInertia*(1-h.angularStiffness),m.constraintImpulse.angle-=M,m.angle-=M),p&&!p.isStatic&&(L=p.inverseMass/P,p.constraintImpulse.x+=A.x*L,p.constraintImpulse.y+=A.y*L,p.position.x+=A.x*L,p.position.y+=A.y*L,I>0&&(p.positionPrev.x+=I*B.x*V*L,p.positionPrev.y+=I*B.y*V*L),M=o.cross(y,A)/j*i._torqueDampen*p.inverseInertia*(1-h.angularStiffness),p.constraintImpulse.angle+=M,p.angle+=M)}}},i.postSolveAll=function(h){for(var d=0;d<h.length;d++){var m=h[d],p=m.constraintImpulse;if(!(m.isStatic||p.x===0&&p.y===0&&p.angle===0)){l.set(m,!1);for(var g=0;g<m.parts.length;g++){var y=m.parts[g];a.translate(y.vertices,p),g>0&&(y.position.x+=p.x,y.position.y+=p.y),p.angle!==0&&(a.rotate(y.vertices,p.angle,m.position),c.rotate(y.axes,p.angle),g>0&&o.rotateAbout(y.position,p.angle,m.position,y.position)),u.update(y.bounds,y.vertices,m.velocity)}p.angle*=i._warming,p.x*=i._warming,p.y*=i._warming}}},i.pointAWorld=function(h){return{x:(h.bodyA?h.bodyA.position.x:0)+(h.pointA?h.pointA.x:0),y:(h.bodyA?h.bodyA.position.y:0)+(h.pointA?h.pointA.y:0)}},i.pointBWorld=function(h){return{x:(h.bodyB?h.bodyB.position.x:0)+(h.pointB?h.pointB.x:0),y:(h.bodyB?h.bodyB.position.y:0)+(h.pointB?h.pointB.y:0)}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(2),o=s(0);(function(){i.fromVertices=function(l){for(var u={},c=0;c<l.length;c++){var f=(c+1)%l.length,h=a.normalise({x:l[f].y-l[c].y,y:l[c].x-l[f].x}),d=h.y===0?1/0:h.x/h.y;d=d.toFixed(3).toString(),u[d]=h}return o.values(u)},i.rotate=function(l,u){if(u!==0)for(var c=Math.cos(u),f=Math.sin(u),h=0;h<l.length;h++){var d=l[h],m;m=d.x*c-d.y*f,d.y=d.x*f+d.y*c,d.x=m}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(0),l=s(4),u=s(1),c=s(2);(function(){i.rectangle=function(f,h,d,m,p){p=p||{};var g={label:"Rectangle Body",position:{x:f,y:h},vertices:a.fromPath("L 0 0 L "+d+" 0 L "+d+" "+m+" L 0 "+m)};if(p.chamfer){var y=p.chamfer;g.vertices=a.chamfer(g.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete p.chamfer}return l.create(o.extend({},g,p))},i.trapezoid=function(f,h,d,m,p,g){g=g||{},p*=.5;var y=(1-p*2)*d,T=d*p,v=T+y,C=v+T,E;p<.5?E="L 0 0 L "+T+" "+-m+" L "+v+" "+-m+" L "+C+" 0":E="L 0 0 L "+v+" "+-m+" L "+C+" 0";var w={label:"Trapezoid Body",position:{x:f,y:h},vertices:a.fromPath(E)};if(g.chamfer){var _=g.chamfer;w.vertices=a.chamfer(w.vertices,_.radius,_.quality,_.qualityMin,_.qualityMax),delete g.chamfer}return l.create(o.extend({},w,g))},i.circle=function(f,h,d,m,p){m=m||{};var g={label:"Circle Body",circleRadius:d};p=p||25;var y=Math.ceil(Math.max(10,Math.min(p,d)));return y%2===1&&(y+=1),i.polygon(f,h,y,d,o.extend({},g,m))},i.polygon=function(f,h,d,m,p){if(p=p||{},d<3)return i.circle(f,h,m,p);for(var g=2*Math.PI/d,y="",T=g*.5,v=0;v<d;v+=1){var C=T+v*g,E=Math.cos(C)*m,w=Math.sin(C)*m;y+="L "+E.toFixed(3)+" "+w.toFixed(3)+" "}var _={label:"Polygon Body",position:{x:f,y:h},vertices:a.fromPath(y)};if(p.chamfer){var S=p.chamfer;_.vertices=a.chamfer(_.vertices,S.radius,S.quality,S.qualityMin,S.qualityMax),delete p.chamfer}return l.create(o.extend({},_,p))},i.fromVertices=function(f,h,d,m,p,g,y,T){var v=o.getDecomp(),C,E,w,_,S,I,A,P,N,j,M;for(C=!!(v&&v.quickDecomp),m=m||{},w=[],p=typeof p<"u"?p:!1,g=typeof g<"u"?g:.01,y=typeof y<"u"?y:10,T=typeof T<"u"?T:.01,o.isArray(d[0])||(d=[d]),j=0;j<d.length;j+=1)if(I=d[j],_=a.isConvex(I),S=!_,S&&!C&&o.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),_||!C)_?I=a.clockwiseSort(I):I=a.hull(I),w.push({position:{x:f,y:h},vertices:I});else{var L=I.map(function(z){return[z.x,z.y]});v.makeCCW(L),g!==!1&&v.removeCollinearPoints(L,g),T!==!1&&v.removeDuplicatePoints&&v.removeDuplicatePoints(L,T);var B=v.quickDecomp(L);for(A=0;A<B.length;A++){var V=B[A],F=V.map(function(z){return{x:z[0],y:z[1]}});y>0&&a.area(F)<y||w.push({position:a.centre(F),vertices:F})}}for(A=0;A<w.length;A++)w[A]=l.create(o.extend(w[A],m));if(p){var q=5;for(A=0;A<w.length;A++){var R=w[A];for(P=A+1;P<w.length;P++){var $=w[P];if(u.overlaps(R.bounds,$.bounds)){var X=R.vertices,D=$.vertices;for(N=0;N<R.vertices.length;N++)for(M=0;M<$.vertices.length;M++){var Z=c.magnitudeSquared(c.sub(X[(N+1)%X.length],D[M])),le=c.magnitudeSquared(c.sub(X[N],D[(M+1)%D.length]));Z<q&&le<q&&(X[N].isInternal=!0,D[M].isInternal=!0)}}}}}return w.length>1?(E=l.create(o.extend({parts:w.slice(0)},m)),l.setPosition(E,{x:f,y:h}),E):w[0]}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0),o=s(8);(function(){i.create=function(l){var u={bodies:[],pairs:null};return a.extend(u,l)},i.setBodies=function(l,u){l.bodies=u.slice(0)},i.clear=function(l){l.bodies=[]},i.collisions=function(l){var u=[],c=l.pairs,f=l.bodies,h=f.length,d=i.canCollide,m=o.collides,p,g;for(f.sort(i._compareBoundsX),p=0;p<h;p++){var y=f[p],T=y.bounds,v=y.bounds.max.x,C=y.bounds.max.y,E=y.bounds.min.y,w=y.isStatic||y.isSleeping,_=y.parts.length,S=_===1;for(g=p+1;g<h;g++){var I=f[g],A=I.bounds;if(A.min.x>v)break;if(!(C<A.min.y||E>A.max.y)&&!(w&&(I.isStatic||I.isSleeping))&&d(y.collisionFilter,I.collisionFilter)){var P=I.parts.length;if(S&&P===1){var N=m(y,I,c);N&&u.push(N)}else for(var j=_>1?1:0,M=P>1?1:0,L=j;L<_;L++)for(var B=y.parts[L],T=B.bounds,V=M;V<P;V++){var F=I.parts[V],A=F.bounds;if(!(T.min.x>A.max.x||T.max.x<A.min.x||T.max.y<A.min.y||T.min.y>A.max.y)){var N=m(B,F,c);N&&u.push(N)}}}}}return u},i.canCollide=function(l,u){return l.group===u.group&&l.group!==0?l.group>0:(l.mask&u.category)!==0&&(u.mask&l.category)!==0},i._compareBoundsX=function(l,u){return l.bounds.min.x-u.bounds.min.x}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0);(function(){i.create=function(o){var l={};return o||a.log("Mouse.create: element was undefined, defaulting to document.body","warn"),l.element=o||document.body,l.absolute={x:0,y:0},l.position={x:0,y:0},l.mousedownPosition={x:0,y:0},l.mouseupPosition={x:0,y:0},l.offset={x:0,y:0},l.scale={x:1,y:1},l.wheelDelta=0,l.button=-1,l.pixelRatio=parseInt(l.element.getAttribute("data-pixel-ratio"),10)||1,l.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},l.mousemove=function(u){var c=i._getRelativeMousePosition(u,l.element,l.pixelRatio),f=u.changedTouches;f&&(l.button=0,u.preventDefault()),l.absolute.x=c.x,l.absolute.y=c.y,l.position.x=l.absolute.x*l.scale.x+l.offset.x,l.position.y=l.absolute.y*l.scale.y+l.offset.y,l.sourceEvents.mousemove=u},l.mousedown=function(u){var c=i._getRelativeMousePosition(u,l.element,l.pixelRatio),f=u.changedTouches;f?(l.button=0,u.preventDefault()):l.button=u.button,l.absolute.x=c.x,l.absolute.y=c.y,l.position.x=l.absolute.x*l.scale.x+l.offset.x,l.position.y=l.absolute.y*l.scale.y+l.offset.y,l.mousedownPosition.x=l.position.x,l.mousedownPosition.y=l.position.y,l.sourceEvents.mousedown=u},l.mouseup=function(u){var c=i._getRelativeMousePosition(u,l.element,l.pixelRatio),f=u.changedTouches;f&&u.preventDefault(),l.button=-1,l.absolute.x=c.x,l.absolute.y=c.y,l.position.x=l.absolute.x*l.scale.x+l.offset.x,l.position.y=l.absolute.y*l.scale.y+l.offset.y,l.mouseupPosition.x=l.position.x,l.mouseupPosition.y=l.position.y,l.sourceEvents.mouseup=u},l.mousewheel=function(u){l.wheelDelta=Math.max(-1,Math.min(1,u.wheelDelta||-u.detail)),u.preventDefault()},i.setElement(l,l.element),l},i.setElement=function(o,l){o.element=l,l.addEventListener("mousemove",o.mousemove),l.addEventListener("mousedown",o.mousedown),l.addEventListener("mouseup",o.mouseup),l.addEventListener("mousewheel",o.mousewheel),l.addEventListener("DOMMouseScroll",o.mousewheel),l.addEventListener("touchmove",o.mousemove),l.addEventListener("touchstart",o.mousedown),l.addEventListener("touchend",o.mouseup)},i.clearSourceEvents=function(o){o.sourceEvents.mousemove=null,o.sourceEvents.mousedown=null,o.sourceEvents.mouseup=null,o.sourceEvents.mousewheel=null,o.wheelDelta=0},i.setOffset=function(o,l){o.offset.x=l.x,o.offset.y=l.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y},i.setScale=function(o,l){o.scale.x=l.x,o.scale.y=l.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y},i._getRelativeMousePosition=function(o,l,u){var c=l.getBoundingClientRect(),f=document.documentElement||document.body.parentNode||document.body,h=window.pageXOffset!==void 0?window.pageXOffset:f.scrollLeft,d=window.pageYOffset!==void 0?window.pageYOffset:f.scrollTop,m=o.changedTouches,p,g;return m?(p=m[0].pageX-c.left-h,g=m[0].pageY-c.top-d):(p=o.pageX-c.left-h,g=o.pageY-c.top-d),{x:p/(l.clientWidth/(l.width||l.clientWidth)*u),y:g/(l.clientHeight/(l.height||l.clientHeight)*u)}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0);(function(){i._registry={},i.register=function(o){if(i.isPlugin(o)||a.warn("Plugin.register:",i.toString(o),"does not implement all required fields."),o.name in i._registry){var l=i._registry[o.name],u=i.versionParse(o.version).number,c=i.versionParse(l.version).number;u>c?(a.warn("Plugin.register:",i.toString(l),"was upgraded to",i.toString(o)),i._registry[o.name]=o):u<c?a.warn("Plugin.register:",i.toString(l),"can not be downgraded to",i.toString(o)):o!==l&&a.warn("Plugin.register:",i.toString(o),"is already registered to different plugin object")}else i._registry[o.name]=o;return o},i.resolve=function(o){return i._registry[i.dependencyParse(o).name]},i.toString=function(o){return typeof o=="string"?o:(o.name||"anonymous")+"@"+(o.version||o.range||"0.0.0")},i.isPlugin=function(o){return o&&o.name&&o.version&&o.install},i.isUsed=function(o,l){return o.used.indexOf(l)>-1},i.isFor=function(o,l){var u=o.for&&i.dependencyParse(o.for);return!o.for||l.name===u.name&&i.versionSatisfies(l.version,u.range)},i.use=function(o,l){if(o.uses=(o.uses||[]).concat(l||[]),o.uses.length===0){a.warn("Plugin.use:",i.toString(o),"does not specify any dependencies to install.");return}for(var u=i.dependencies(o),c=a.topologicalSort(u),f=[],h=0;h<c.length;h+=1)if(c[h]!==o.name){var d=i.resolve(c[h]);if(!d){f.push("❌ "+c[h]);continue}i.isUsed(o,d.name)||(i.isFor(d,o)||(a.warn("Plugin.use:",i.toString(d),"is for",d.for,"but installed on",i.toString(o)+"."),d._warned=!0),d.install?d.install(o):(a.warn("Plugin.use:",i.toString(d),"does not specify an install function."),d._warned=!0),d._warned?(f.push("🔶 "+i.toString(d)),delete d._warned):f.push("✅ "+i.toString(d)),o.used.push(d.name))}f.length>0&&a.info(f.join(" "))},i.dependencies=function(o,l){var u=i.dependencyParse(o),c=u.name;if(l=l||{},!(c in l)){o=i.resolve(o)||o,l[c]=a.map(o.uses||[],function(h){i.isPlugin(h)&&i.register(h);var d=i.dependencyParse(h),m=i.resolve(h);return m&&!i.versionSatisfies(m.version,d.range)?(a.warn("Plugin.dependencies:",i.toString(m),"does not satisfy",i.toString(d),"used by",i.toString(u)+"."),m._warned=!0,o._warned=!0):m||(a.warn("Plugin.dependencies:",i.toString(h),"used by",i.toString(u),"could not be resolved."),o._warned=!0),d.name});for(var f=0;f<l[c].length;f+=1)i.dependencies(l[c][f],l);return l}},i.dependencyParse=function(o){if(a.isString(o)){var l=/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/;return l.test(o)||a.warn("Plugin.dependencyParse:",o,"is not a valid dependency string."),{name:o.split("@")[0],range:o.split("@")[1]||"*"}}return{name:o.name,range:o.range||o.version}},i.versionParse=function(o){var l=/^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;l.test(o)||a.warn("Plugin.versionParse:",o,"is not a valid version or range.");var u=l.exec(o),c=Number(u[4]),f=Number(u[5]),h=Number(u[6]);return{isRange:!!(u[1]||u[2]),version:u[3],range:o,operator:u[1]||u[2]||"",major:c,minor:f,patch:h,parts:[c,f,h],prerelease:u[7],number:c*1e8+f*1e4+h}},i.versionSatisfies=function(o,l){l=l||"*";var u=i.versionParse(l),c=i.versionParse(o);if(u.isRange){if(u.operator==="*"||o==="*")return!0;if(u.operator===">")return c.number>u.number;if(u.operator===">=")return c.number>=u.number;if(u.operator==="~")return c.major===u.major&&c.minor===u.minor&&c.patch>=u.patch;if(u.operator==="^")return u.major>0?c.major===u.major&&c.number>=u.number:u.minor>0?c.minor===u.minor&&c.patch>=u.patch:c.patch===u.patch}return o===l||o==="*"}})()}),(function(n,r){var s={};n.exports=s,(function(){s.create=function(i){return{vertex:i,normalImpulse:0,tangentImpulse:0}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(7),o=s(18),l=s(13),u=s(19),c=s(5),f=s(6),h=s(10),d=s(0),m=s(4);(function(){i.create=function(p){p=p||{};var g={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0}},y=d.extend(g,p);return y.world=p.world||f.create({label:"World"}),y.pairs=p.pairs||u.create(),y.detector=p.detector||l.create(),y.grid={buckets:[]},y.world.gravity=y.gravity,y.broadphase=y.grid,y.metrics={},y},i.update=function(p,g){var y=d.now(),T=p.world,v=p.detector,C=p.pairs,E=p.timing,w=E.timestamp,_;g=typeof g<"u"?g:d._baseDelta,g*=E.timeScale,E.timestamp+=g,E.lastDelta=g;var S={timestamp:E.timestamp,delta:g};c.trigger(p,"beforeUpdate",S);var I=f.allBodies(T),A=f.allConstraints(T);for(T.isModified&&(l.setBodies(v,I),f.setModified(T,!1,!1,!0)),p.enableSleeping&&a.update(I,g),i._bodiesApplyGravity(I,p.gravity),g>0&&i._bodiesUpdate(I,g),h.preSolveAll(I),_=0;_<p.constraintIterations;_++)h.solveAll(A,g);h.postSolveAll(I),v.pairs=p.pairs;var P=l.collisions(v);u.update(C,P,w),p.enableSleeping&&a.afterCollisions(C.list),C.collisionStart.length>0&&c.trigger(p,"collisionStart",{pairs:C.collisionStart});var N=d.clamp(20/p.positionIterations,0,1);for(o.preSolvePosition(C.list),_=0;_<p.positionIterations;_++)o.solvePosition(C.list,g,N);for(o.postSolvePosition(I),h.preSolveAll(I),_=0;_<p.constraintIterations;_++)h.solveAll(A,g);for(h.postSolveAll(I),o.preSolveVelocity(C.list),_=0;_<p.velocityIterations;_++)o.solveVelocity(C.list,g);return i._bodiesUpdateVelocities(I),C.collisionActive.length>0&&c.trigger(p,"collisionActive",{pairs:C.collisionActive}),C.collisionEnd.length>0&&c.trigger(p,"collisionEnd",{pairs:C.collisionEnd}),i._bodiesClearForces(I),c.trigger(p,"afterUpdate",S),p.timing.lastElapsed=d.now()-y,p},i.merge=function(p,g){if(d.extend(p,g),g.world){p.world=g.world,i.clear(p);for(var y=f.allBodies(p.world),T=0;T<y.length;T++){var v=y[T];a.set(v,!1),v.id=d.nextId()}}},i.clear=function(p){u.clear(p.pairs),l.clear(p.detector)},i._bodiesClearForces=function(p){for(var g=p.length,y=0;y<g;y++){var T=p[y];T.force.x=0,T.force.y=0,T.torque=0}},i._bodiesApplyGravity=function(p,g){var y=typeof g.scale<"u"?g.scale:.001,T=p.length;if(!(g.x===0&&g.y===0||y===0))for(var v=0;v<T;v++){var C=p[v];C.isStatic||C.isSleeping||(C.force.y+=C.mass*g.y*y,C.force.x+=C.mass*g.x*y)}},i._bodiesUpdate=function(p,g){for(var y=p.length,T=0;T<y;T++){var v=p[T];v.isStatic||v.isSleeping||m.update(v,g)}},i._bodiesUpdateVelocities=function(p){for(var g=p.length,y=0;y<g;y++)m.updateVelocities(p[y])}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(0),l=s(1);(function(){i._restingThresh=2,i._restingThreshTangent=Math.sqrt(6),i._positionDampen=.9,i._positionWarming=.8,i._frictionNormalMultiplier=5,i._frictionMaxStatic=Number.MAX_VALUE,i.preSolvePosition=function(u){var c,f,h,d=u.length;for(c=0;c<d;c++)f=u[c],f.isActive&&(h=f.activeContacts.length,f.collision.parentA.totalContacts+=h,f.collision.parentB.totalContacts+=h)},i.solvePosition=function(u,c,f){var h,d,m,p,g,y,T,v,C=i._positionDampen*(f||1),E=o.clamp(c/o._baseDelta,0,1),w=u.length;for(h=0;h<w;h++)d=u[h],!(!d.isActive||d.isSensor)&&(m=d.collision,p=m.parentA,g=m.parentB,y=m.normal,d.separation=y.x*(g.positionImpulse.x+m.penetration.x-p.positionImpulse.x)+y.y*(g.positionImpulse.y+m.penetration.y-p.positionImpulse.y));for(h=0;h<w;h++)d=u[h],!(!d.isActive||d.isSensor)&&(m=d.collision,p=m.parentA,g=m.parentB,y=m.normal,v=d.separation-d.slop*E,(p.isStatic||g.isStatic)&&(v*=2),p.isStatic||p.isSleeping||(T=C/p.totalContacts,p.positionImpulse.x+=y.x*v*T,p.positionImpulse.y+=y.y*v*T),g.isStatic||g.isSleeping||(T=C/g.totalContacts,g.positionImpulse.x-=y.x*v*T,g.positionImpulse.y-=y.y*v*T))},i.postSolvePosition=function(u){for(var c=i._positionWarming,f=u.length,h=a.translate,d=l.update,m=0;m<f;m++){var p=u[m],g=p.positionImpulse,y=g.x,T=g.y,v=p.velocity;if(p.totalContacts=0,y!==0||T!==0){for(var C=0;C<p.parts.length;C++){var E=p.parts[C];h(E.vertices,g),d(E.bounds,E.vertices,v),E.position.x+=y,E.position.y+=T}p.positionPrev.x+=y,p.positionPrev.y+=T,y*v.x+T*v.y<0?(g.x=0,g.y=0):(g.x*=c,g.y*=c)}}},i.preSolveVelocity=function(u){var c=u.length,f,h;for(f=0;f<c;f++){var d=u[f];if(!(!d.isActive||d.isSensor)){var m=d.activeContacts,p=m.length,g=d.collision,y=g.parentA,T=g.parentB,v=g.normal,C=g.tangent;for(h=0;h<p;h++){var E=m[h],w=E.vertex,_=E.normalImpulse,S=E.tangentImpulse;if(_!==0||S!==0){var I=v.x*_+C.x*S,A=v.y*_+C.y*S;y.isStatic||y.isSleeping||(y.positionPrev.x+=I*y.inverseMass,y.positionPrev.y+=A*y.inverseMass,y.anglePrev+=y.inverseInertia*((w.x-y.position.x)*A-(w.y-y.position.y)*I)),T.isStatic||T.isSleeping||(T.positionPrev.x-=I*T.inverseMass,T.positionPrev.y-=A*T.inverseMass,T.anglePrev-=T.inverseInertia*((w.x-T.position.x)*A-(w.y-T.position.y)*I))}}}}},i.solveVelocity=function(u,c){var f=c/o._baseDelta,h=f*f,d=h*f,m=-i._restingThresh*f,p=i._restingThreshTangent,g=i._frictionNormalMultiplier*f,y=i._frictionMaxStatic,T=u.length,v,C,E,w;for(E=0;E<T;E++){var _=u[E];if(!(!_.isActive||_.isSensor)){var S=_.collision,I=S.parentA,A=S.parentB,P=I.velocity,N=A.velocity,j=S.normal.x,M=S.normal.y,L=S.tangent.x,B=S.tangent.y,V=_.activeContacts,F=V.length,q=1/F,R=I.inverseMass+A.inverseMass,$=_.friction*_.frictionStatic*g;for(P.x=I.position.x-I.positionPrev.x,P.y=I.position.y-I.positionPrev.y,N.x=A.position.x-A.positionPrev.x,N.y=A.position.y-A.positionPrev.y,I.angularVelocity=I.angle-I.anglePrev,A.angularVelocity=A.angle-A.anglePrev,w=0;w<F;w++){var X=V[w],D=X.vertex,Z=D.x-I.position.x,le=D.y-I.position.y,z=D.x-A.position.x,ee=D.y-A.position.y,K=P.x-le*I.angularVelocity,ce=P.y+Z*I.angularVelocity,fe=N.x-ee*A.angularVelocity,re=N.y+z*A.angularVelocity,ne=K-fe,ge=ce-re,Te=j*ne+M*ge,Ne=L*ne+B*ge,Oe=_.separation+Te,be=Math.min(Oe,1);be=Oe<0?0:be;var Fe=be*$;Ne<-Fe||Ne>Fe?(C=Ne>0?Ne:-Ne,v=_.friction*(Ne>0?1:-1)*d,v<-C?v=-C:v>C&&(v=C)):(v=Ne,C=y);var te=Z*M-le*j,Re=z*M-ee*j,me=q/(R+I.inverseInertia*te*te+A.inverseInertia*Re*Re),je=(1+_.restitution)*Te*me;if(v*=me,Te<m)X.normalImpulse=0;else{var st=X.normalImpulse;X.normalImpulse+=je,X.normalImpulse>0&&(X.normalImpulse=0),je=X.normalImpulse-st}if(Ne<-p||Ne>p)X.tangentImpulse=0;else{var Be=X.tangentImpulse;X.tangentImpulse+=v,X.tangentImpulse<-C&&(X.tangentImpulse=-C),X.tangentImpulse>C&&(X.tangentImpulse=C),v=X.tangentImpulse-Be}var at=j*je+L*v,G=M*je+B*v;I.isStatic||I.isSleeping||(I.positionPrev.x+=at*I.inverseMass,I.positionPrev.y+=G*I.inverseMass,I.anglePrev+=(Z*G-le*at)*I.inverseInertia),A.isStatic||A.isSleeping||(A.positionPrev.x-=at*A.inverseMass,A.positionPrev.y-=G*A.inverseMass,A.anglePrev-=(z*G-ee*at)*A.inverseInertia)}}}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(9),o=s(0);(function(){i.create=function(l){return o.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},l)},i.update=function(l,u,c){var f=l.list,h=f.length,d=l.table,m=u.length,p=l.collisionStart,g=l.collisionEnd,y=l.collisionActive,T,v,C,E;for(p.length=0,g.length=0,y.length=0,E=0;E<h;E++)f[E].confirmedActive=!1;for(E=0;E<m;E++)T=u[E],C=T.pair,C?(C.isActive?y.push(C):p.push(C),a.update(C,T,c),C.confirmedActive=!0):(C=a.create(T,c),d[C.id]=C,p.push(C),f.push(C));var w=[];for(h=f.length,E=0;E<h;E++)C=f[E],C.confirmedActive||(a.setActive(C,!1,c),g.push(C),!C.collision.bodyA.isSleeping&&!C.collision.bodyB.isSleeping&&w.push(E));for(E=0;E<w.length;E++)v=w[E]-E,C=f[v],f.splice(v,1),delete d[C.id]},i.clear=function(l){return l.table={},l.list.length=0,l.collisionStart.length=0,l.collisionActive.length=0,l.collisionEnd.length=0,l}})()}),(function(n,r,s){var i=n.exports=s(21);i.Axes=s(11),i.Bodies=s(12),i.Body=s(4),i.Bounds=s(1),i.Collision=s(8),i.Common=s(0),i.Composite=s(6),i.Composites=s(22),i.Constraint=s(10),i.Contact=s(16),i.Detector=s(13),i.Engine=s(17),i.Events=s(5),i.Grid=s(23),i.Mouse=s(14),i.MouseConstraint=s(24),i.Pair=s(9),i.Pairs=s(19),i.Plugin=s(15),i.Query=s(25),i.Render=s(26),i.Resolver=s(18),i.Runner=s(27),i.SAT=s(28),i.Sleeping=s(7),i.Svg=s(29),i.Vector=s(2),i.Vertices=s(3),i.World=s(30),i.Engine.run=i.Runner.run,i.Common.deprecated(i.Engine,"run","Engine.run ➤ use Matter.Runner.run(engine) instead")}),(function(n,r,s){var i={};n.exports=i;var a=s(15),o=s(0);(function(){i.name="matter-js",i.version="0.19.0",i.uses=[],i.used=[],i.use=function(){a.use(i,Array.prototype.slice.call(arguments))},i.before=function(l,u){return l=l.replace(/^Matter./,""),o.chainPathBefore(i,l,u)},i.after=function(l,u){return l=l.replace(/^Matter./,""),o.chainPathAfter(i,l,u)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(6),o=s(10),l=s(0),u=s(4),c=s(12),f=l.deprecated;(function(){i.stack=function(h,d,m,p,g,y,T){for(var v=a.create({label:"Stack"}),C=h,E=d,w,_=0,S=0;S<p;S++){for(var I=0,A=0;A<m;A++){var P=T(C,E,A,S,w,_);if(P){var N=P.bounds.max.y-P.bounds.min.y,j=P.bounds.max.x-P.bounds.min.x;N>I&&(I=N),u.translate(P,{x:j*.5,y:N*.5}),C=P.bounds.max.x+g,a.addBody(v,P),w=P,_+=1}else C+=g}E+=I+y,C=h}return v},i.chain=function(h,d,m,p,g,y){for(var T=h.bodies,v=1;v<T.length;v++){var C=T[v-1],E=T[v],w=C.bounds.max.y-C.bounds.min.y,_=C.bounds.max.x-C.bounds.min.x,S=E.bounds.max.y-E.bounds.min.y,I=E.bounds.max.x-E.bounds.min.x,A={bodyA:C,pointA:{x:_*d,y:w*m},bodyB:E,pointB:{x:I*p,y:S*g}},P=l.extend(A,y);a.addConstraint(h,o.create(P))}return h.label+=" Chain",h},i.mesh=function(h,d,m,p,g){var y=h.bodies,T,v,C,E,w;for(T=0;T<m;T++){for(v=1;v<d;v++)C=y[v-1+T*d],E=y[v+T*d],a.addConstraint(h,o.create(l.extend({bodyA:C,bodyB:E},g)));if(T>0)for(v=0;v<d;v++)C=y[v+(T-1)*d],E=y[v+T*d],a.addConstraint(h,o.create(l.extend({bodyA:C,bodyB:E},g))),p&&v>0&&(w=y[v-1+(T-1)*d],a.addConstraint(h,o.create(l.extend({bodyA:w,bodyB:E},g)))),p&&v<d-1&&(w=y[v+1+(T-1)*d],a.addConstraint(h,o.create(l.extend({bodyA:w,bodyB:E},g))))}return h.label+=" Mesh",h},i.pyramid=function(h,d,m,p,g,y,T){return i.stack(h,d,m,p,g,y,function(v,C,E,w,_,S){var I=Math.min(p,Math.ceil(m/2)),A=_?_.bounds.max.x-_.bounds.min.x:0;if(!(w>I)){w=I-w;var P=w,N=m-1-w;if(!(E<P||E>N)){S===1&&u.translate(_,{x:(E+(m%2===1?1:-1))*A,y:0});var j=_?E*A:0;return T(h+j+E*g,C,E,w,_,S)}}})},i.newtonsCradle=function(h,d,m,p,g){for(var y=a.create({label:"Newtons Cradle"}),T=0;T<m;T++){var v=1.9,C=c.circle(h+T*(p*v),d+g,p,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),E=o.create({pointA:{x:h+T*(p*v),y:d},bodyB:C});a.addBody(y,C),a.addConstraint(y,E)}return y},f(i,"newtonsCradle","Composites.newtonsCradle ➤ moved to newtonsCradle example"),i.car=function(h,d,m,p,g){var y=u.nextGroup(!0),T=20,v=-m*.5+T,C=m*.5-T,E=0,w=a.create({label:"Car"}),_=c.rectangle(h,d,m,p,{collisionFilter:{group:y},chamfer:{radius:p*.5},density:2e-4}),S=c.circle(h+v,d+E,g,{collisionFilter:{group:y},friction:.8}),I=c.circle(h+C,d+E,g,{collisionFilter:{group:y},friction:.8}),A=o.create({bodyB:_,pointB:{x:v,y:E},bodyA:S,stiffness:1,length:0}),P=o.create({bodyB:_,pointB:{x:C,y:E},bodyA:I,stiffness:1,length:0});return a.addBody(w,_),a.addBody(w,S),a.addBody(w,I),a.addConstraint(w,A),a.addConstraint(w,P),w},f(i,"car","Composites.car ➤ moved to car example"),i.softBody=function(h,d,m,p,g,y,T,v,C,E){C=l.extend({inertia:1/0},C),E=l.extend({stiffness:.2,render:{type:"line",anchors:!1}},E);var w=i.stack(h,d,m,p,g,y,function(_,S){return c.circle(_,S,v,C)});return i.mesh(w,m,p,T,E),w.label="Soft Body",w},f(i,"softBody","Composites.softBody ➤ moved to softBody and cloth examples")})()}),(function(n,r,s){var i={};n.exports=i;var a=s(9),o=s(0),l=o.deprecated;(function(){i.create=function(u){var c={buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return o.extend(c,u)},i.update=function(u,c,f,h){var d,m,p,g=f.world,y=u.buckets,T,v,C=!1;for(d=0;d<c.length;d++){var E=c[d];if(!(E.isSleeping&&!h)&&!(g.bounds&&(E.bounds.max.x<g.bounds.min.x||E.bounds.min.x>g.bounds.max.x||E.bounds.max.y<g.bounds.min.y||E.bounds.min.y>g.bounds.max.y))){var w=i._getRegion(u,E);if(!E.region||w.id!==E.region.id||h){(!E.region||h)&&(E.region=w);var _=i._regionUnion(w,E.region);for(m=_.startCol;m<=_.endCol;m++)for(p=_.startRow;p<=_.endRow;p++){v=i._getBucketId(m,p),T=y[v];var S=m>=w.startCol&&m<=w.endCol&&p>=w.startRow&&p<=w.endRow,I=m>=E.region.startCol&&m<=E.region.endCol&&p>=E.region.startRow&&p<=E.region.endRow;!S&&I&&I&&T&&i._bucketRemoveBody(u,T,E),(E.region===w||S&&!I||h)&&(T||(T=i._createBucket(y,v)),i._bucketAddBody(u,T,E))}E.region=w,C=!0}}}C&&(u.pairsList=i._createActivePairsList(u))},l(i,"update","Grid.update ➤ replaced by Matter.Detector"),i.clear=function(u){u.buckets={},u.pairs={},u.pairsList=[]},l(i,"clear","Grid.clear ➤ replaced by Matter.Detector"),i._regionUnion=function(u,c){var f=Math.min(u.startCol,c.startCol),h=Math.max(u.endCol,c.endCol),d=Math.min(u.startRow,c.startRow),m=Math.max(u.endRow,c.endRow);return i._createRegion(f,h,d,m)},i._getRegion=function(u,c){var f=c.bounds,h=Math.floor(f.min.x/u.bucketWidth),d=Math.floor(f.max.x/u.bucketWidth),m=Math.floor(f.min.y/u.bucketHeight),p=Math.floor(f.max.y/u.bucketHeight);return i._createRegion(h,d,m,p)},i._createRegion=function(u,c,f,h){return{id:u+","+c+","+f+","+h,startCol:u,endCol:c,startRow:f,endRow:h}},i._getBucketId=function(u,c){return"C"+u+"R"+c},i._createBucket=function(u,c){var f=u[c]=[];return f},i._bucketAddBody=function(u,c,f){var h=u.pairs,d=a.id,m=c.length,p;for(p=0;p<m;p++){var g=c[p];if(!(f.id===g.id||f.isStatic&&g.isStatic)){var y=d(f,g),T=h[y];T?T[2]+=1:h[y]=[f,g,1]}}c.push(f)},i._bucketRemoveBody=function(u,c,f){var h=u.pairs,d=a.id,m;c.splice(o.indexOf(c,f),1);var p=c.length;for(m=0;m<p;m++){var g=h[d(f,c[m])];g&&(g[2]-=1)}},i._createActivePairsList=function(u){var c,f=u.pairs,h=o.keys(f),d=h.length,m=[],p;for(p=0;p<d;p++)c=f[h[p]],c[2]>0?m.push(c):delete f[h[p]];return m}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(7),l=s(14),u=s(5),c=s(13),f=s(10),h=s(6),d=s(0),m=s(1);(function(){i.create=function(p,g){var y=(p?p.mouse:null)||(g?g.mouse:null);y||(p&&p.render&&p.render.canvas?y=l.create(p.render.canvas):g&&g.element?y=l.create(g.element):(y=l.create(),d.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var T=f.create({label:"Mouse Constraint",pointA:y.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),v={type:"mouseConstraint",mouse:y,element:null,body:null,constraint:T,collisionFilter:{category:1,mask:4294967295,group:0}},C=d.extend(v,g);return u.on(p,"beforeUpdate",function(){var E=h.allBodies(p.world);i.update(C,E),i._triggerEvents(C)}),C},i.update=function(p,g){var y=p.mouse,T=p.constraint,v=p.body;if(y.button===0){if(T.bodyB)o.set(T.bodyB,!1),T.pointA=y.position;else for(var C=0;C<g.length;C++)if(v=g[C],m.contains(v.bounds,y.position)&&c.canCollide(v.collisionFilter,p.collisionFilter))for(var E=v.parts.length>1?1:0;E<v.parts.length;E++){var w=v.parts[E];if(a.contains(w.vertices,y.position)){T.pointA=y.position,T.bodyB=p.body=v,T.pointB={x:y.position.x-v.position.x,y:y.position.y-v.position.y},T.angleB=v.angle,o.set(v,!1),u.trigger(p,"startdrag",{mouse:y,body:v});break}}}else T.bodyB=p.body=null,T.pointB=null,v&&u.trigger(p,"enddrag",{mouse:y,body:v})},i._triggerEvents=function(p){var g=p.mouse,y=g.sourceEvents;y.mousemove&&u.trigger(p,"mousemove",{mouse:g}),y.mousedown&&u.trigger(p,"mousedown",{mouse:g}),y.mouseup&&u.trigger(p,"mouseup",{mouse:g}),l.clearSourceEvents(g)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(2),o=s(8),l=s(1),u=s(12),c=s(3);(function(){i.collides=function(f,h){for(var d=[],m=h.length,p=f.bounds,g=o.collides,y=l.overlaps,T=0;T<m;T++){var v=h[T],C=v.parts.length,E=C===1?0:1;if(y(v.bounds,p))for(var w=E;w<C;w++){var _=v.parts[w];if(y(_.bounds,p)){var S=g(_,f);if(S){d.push(S);break}}}}return d},i.ray=function(f,h,d,m){m=m||1e-100;for(var p=a.angle(h,d),g=a.magnitude(a.sub(h,d)),y=(d.x+h.x)*.5,T=(d.y+h.y)*.5,v=u.rectangle(y,T,g,m,{angle:p}),C=i.collides(v,f),E=0;E<C.length;E+=1){var w=C[E];w.body=w.bodyB=w.bodyA}return C},i.region=function(f,h,d){for(var m=[],p=0;p<f.length;p++){var g=f[p],y=l.overlaps(g.bounds,h);(y&&!d||!y&&d)&&m.push(g)}return m},i.point=function(f,h){for(var d=[],m=0;m<f.length;m++){var p=f[m];if(l.contains(p.bounds,h))for(var g=p.parts.length===1?0:1;g<p.parts.length;g++){var y=p.parts[g];if(l.contains(y.bounds,h)&&c.contains(y.vertices,h)){d.push(p);break}}}return d}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(4),o=s(0),l=s(6),u=s(1),c=s(5),f=s(2),h=s(14);(function(){var d,m;typeof window<"u"&&(d=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(E){window.setTimeout(function(){E(o.now())},1e3/60)},m=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),i._goodFps=30,i._goodDelta=1e3/60,i.create=function(E){var w={engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,timing:{historySize:60,delta:0,deltaHistory:[],lastTime:0,lastTimestamp:0,lastElapsed:0,timestampElapsed:0,timestampElapsedHistory:[],engineDeltaHistory:[],engineElapsedHistory:[],elapsedHistory:[]},options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",hasBounds:!!E.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showStats:!1,showPerformance:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},_=o.extend(w,E);return _.canvas&&(_.canvas.width=_.options.width||_.canvas.width,_.canvas.height=_.options.height||_.canvas.height),_.mouse=E.mouse,_.engine=E.engine,_.canvas=_.canvas||y(_.options.width,_.options.height),_.context=_.canvas.getContext("2d"),_.textures={},_.bounds=_.bounds||{min:{x:0,y:0},max:{x:_.canvas.width,y:_.canvas.height}},_.controller=i,_.options.showBroadphase=!1,_.options.pixelRatio!==1&&i.setPixelRatio(_,_.options.pixelRatio),o.isElement(_.element)&&_.element.appendChild(_.canvas),_},i.run=function(E){(function w(_){E.frameRequestId=d(w),p(E,_),i.world(E,_),(E.options.showStats||E.options.showDebug)&&i.stats(E,E.context,_),(E.options.showPerformance||E.options.showDebug)&&i.performance(E,E.context,_)})()},i.stop=function(E){m(E.frameRequestId)},i.setPixelRatio=function(E,w){var _=E.options,S=E.canvas;w==="auto"&&(w=T(S)),_.pixelRatio=w,S.setAttribute("data-pixel-ratio",w),S.width=_.width*w,S.height=_.height*w,S.style.width=_.width+"px",S.style.height=_.height+"px"},i.lookAt=function(E,w,_,S){S=typeof S<"u"?S:!0,w=o.isArray(w)?w:[w],_=_||{x:0,y:0};for(var I={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},A=0;A<w.length;A+=1){var P=w[A],N=P.bounds?P.bounds.min:P.min||P.position||P,j=P.bounds?P.bounds.max:P.max||P.position||P;N&&j&&(N.x<I.min.x&&(I.min.x=N.x),j.x>I.max.x&&(I.max.x=j.x),N.y<I.min.y&&(I.min.y=N.y),j.y>I.max.y&&(I.max.y=j.y))}var M=I.max.x-I.min.x+2*_.x,L=I.max.y-I.min.y+2*_.y,B=E.canvas.height,V=E.canvas.width,F=V/B,q=M/L,R=1,$=1;q>F?$=q/F:R=F/q,E.options.hasBounds=!0,E.bounds.min.x=I.min.x,E.bounds.max.x=I.min.x+M*R,E.bounds.min.y=I.min.y,E.bounds.max.y=I.min.y+L*$,S&&(E.bounds.min.x+=M*.5-M*R*.5,E.bounds.max.x+=M*.5-M*R*.5,E.bounds.min.y+=L*.5-L*$*.5,E.bounds.max.y+=L*.5-L*$*.5),E.bounds.min.x-=_.x,E.bounds.max.x-=_.x,E.bounds.min.y-=_.y,E.bounds.max.y-=_.y,E.mouse&&(h.setScale(E.mouse,{x:(E.bounds.max.x-E.bounds.min.x)/E.canvas.width,y:(E.bounds.max.y-E.bounds.min.y)/E.canvas.height}),h.setOffset(E.mouse,E.bounds.min))},i.startViewTransform=function(E){var w=E.bounds.max.x-E.bounds.min.x,_=E.bounds.max.y-E.bounds.min.y,S=w/E.options.width,I=_/E.options.height;E.context.setTransform(E.options.pixelRatio/S,0,0,E.options.pixelRatio/I,0,0),E.context.translate(-E.bounds.min.x,-E.bounds.min.y)},i.endViewTransform=function(E){E.context.setTransform(E.options.pixelRatio,0,0,E.options.pixelRatio,0,0)},i.world=function(E,w){var _=o.now(),S=E.engine,I=S.world,A=E.canvas,P=E.context,N=E.options,j=E.timing,M=l.allBodies(I),L=l.allConstraints(I),B=N.wireframes?N.wireframeBackground:N.background,V=[],F=[],q,R={timestamp:S.timing.timestamp};if(c.trigger(E,"beforeRender",R),E.currentBackground!==B&&C(E,B),P.globalCompositeOperation="source-in",P.fillStyle="transparent",P.fillRect(0,0,A.width,A.height),P.globalCompositeOperation="source-over",N.hasBounds){for(q=0;q<M.length;q++){var $=M[q];u.overlaps($.bounds,E.bounds)&&V.push($)}for(q=0;q<L.length;q++){var X=L[q],D=X.bodyA,Z=X.bodyB,le=X.pointA,z=X.pointB;D&&(le=f.add(D.position,X.pointA)),Z&&(z=f.add(Z.position,X.pointB)),!(!le||!z)&&(u.contains(E.bounds,le)||u.contains(E.bounds,z))&&F.push(X)}i.startViewTransform(E),E.mouse&&(h.setScale(E.mouse,{x:(E.bounds.max.x-E.bounds.min.x)/E.options.width,y:(E.bounds.max.y-E.bounds.min.y)/E.options.height}),h.setOffset(E.mouse,E.bounds.min))}else F=L,V=M,E.options.pixelRatio!==1&&E.context.setTransform(E.options.pixelRatio,0,0,E.options.pixelRatio,0,0);!N.wireframes||S.enableSleeping&&N.showSleeping?i.bodies(E,V,P):(N.showConvexHulls&&i.bodyConvexHulls(E,V,P),i.bodyWireframes(E,V,P)),N.showBounds&&i.bodyBounds(E,V,P),(N.showAxes||N.showAngleIndicator)&&i.bodyAxes(E,V,P),N.showPositions&&i.bodyPositions(E,V,P),N.showVelocity&&i.bodyVelocity(E,V,P),N.showIds&&i.bodyIds(E,V,P),N.showSeparations&&i.separations(E,S.pairs.list,P),N.showCollisions&&i.collisions(E,S.pairs.list,P),N.showVertexNumbers&&i.vertexNumbers(E,V,P),N.showMousePosition&&i.mousePosition(E,E.mouse,P),i.constraints(F,P),N.hasBounds&&i.endViewTransform(E),c.trigger(E,"afterRender",R),j.lastElapsed=o.now()-_},i.stats=function(E,w,_){for(var S=E.engine,I=S.world,A=l.allBodies(I),P=0,N=55,j=44,M=0,L=0,B=0;B<A.length;B+=1)P+=A[B].parts.length;var V={Part:P,Body:A.length,Cons:l.allConstraints(I).length,Comp:l.allComposites(I).length,Pair:S.pairs.list.length};w.fillStyle="#0e0f19",w.fillRect(M,L,N*5.5,j),w.font="12px Arial",w.textBaseline="top",w.textAlign="right";for(var F in V){var q=V[F];w.fillStyle="#aaa",w.fillText(F,M+N,L+8),w.fillStyle="#eee",w.fillText(q,M+N,L+26),M+=N}},i.performance=function(E,w){var _=E.engine,S=E.timing,I=S.deltaHistory,A=S.elapsedHistory,P=S.timestampElapsedHistory,N=S.engineDeltaHistory,j=S.engineElapsedHistory,M=_.timing.lastDelta,L=g(I),B=g(A),V=g(N),F=g(j),q=g(P),R=q/L||0,$=1e3/L||0,X=4,D=12,Z=60,le=34,z=10,ee=69;w.fillStyle="#0e0f19",w.fillRect(0,50,D*4+Z*5+22,le),i.status(w,z,ee,Z,X,I.length,Math.round($)+" fps",$/i._goodFps,function(K){return I[K]/L-1}),i.status(w,z+D+Z,ee,Z,X,N.length,M.toFixed(2)+" dt",i._goodDelta/M,function(K){return N[K]/V-1}),i.status(w,z+(D+Z)*2,ee,Z,X,j.length,F.toFixed(2)+" ut",1-F/i._goodFps,function(K){return j[K]/F-1}),i.status(w,z+(D+Z)*3,ee,Z,X,A.length,B.toFixed(2)+" rt",1-B/i._goodFps,function(K){return A[K]/B-1}),i.status(w,z+(D+Z)*4,ee,Z,X,P.length,R.toFixed(2)+" x",R*R*R,function(K){return(P[K]/I[K]/R||0)-1})},i.status=function(E,w,_,S,I,A,P,N,j){E.strokeStyle="#888",E.fillStyle="#444",E.lineWidth=1,E.fillRect(w,_+7,S,1),E.beginPath(),E.moveTo(w,_+7-I*o.clamp(.4*j(0),-2,2));for(var M=0;M<S;M+=1)E.lineTo(w+M,_+7-(M<A?I*o.clamp(.4*j(M),-2,2):0));E.stroke(),E.fillStyle="hsl("+o.clamp(25+95*N,0,120)+",100%,60%)",E.fillRect(w,_-7,4,4),E.font="12px Arial",E.textBaseline="middle",E.textAlign="right",E.fillStyle="#eee",E.fillText(P,w+S,_-5)},i.constraints=function(E,w){for(var _=w,S=0;S<E.length;S++){var I=E[S];if(!(!I.render.visible||!I.pointA||!I.pointB)){var A=I.bodyA,P=I.bodyB,N,j;if(A?N=f.add(A.position,I.pointA):N=I.pointA,I.render.type==="pin")_.beginPath(),_.arc(N.x,N.y,3,0,2*Math.PI),_.closePath();else{if(P?j=f.add(P.position,I.pointB):j=I.pointB,_.beginPath(),_.moveTo(N.x,N.y),I.render.type==="spring")for(var M=f.sub(j,N),L=f.perp(f.normalise(M)),B=Math.ceil(o.clamp(I.length/5,12,20)),V,F=1;F<B;F+=1)V=F%2===0?1:-1,_.lineTo(N.x+M.x*(F/B)+L.x*V*4,N.y+M.y*(F/B)+L.y*V*4);_.lineTo(j.x,j.y)}I.render.lineWidth&&(_.lineWidth=I.render.lineWidth,_.strokeStyle=I.render.strokeStyle,_.stroke()),I.render.anchors&&(_.fillStyle=I.render.strokeStyle,_.beginPath(),_.arc(N.x,N.y,3,0,2*Math.PI),_.arc(j.x,j.y,3,0,2*Math.PI),_.closePath(),_.fill())}}},i.bodies=function(E,w,_){var S=_;E.engine;var I=E.options,A=I.showInternalEdges||!I.wireframes,P,N,j,M;for(j=0;j<w.length;j++)if(P=w[j],!!P.render.visible){for(M=P.parts.length>1?1:0;M<P.parts.length;M++)if(N=P.parts[M],!!N.render.visible){if(I.showSleeping&&P.isSleeping?S.globalAlpha=.5*N.render.opacity:N.render.opacity!==1&&(S.globalAlpha=N.render.opacity),N.render.sprite&&N.render.sprite.texture&&!I.wireframes){var L=N.render.sprite,B=v(E,L.texture);S.translate(N.position.x,N.position.y),S.rotate(N.angle),S.drawImage(B,B.width*-L.xOffset*L.xScale,B.height*-L.yOffset*L.yScale,B.width*L.xScale,B.height*L.yScale),S.rotate(-N.angle),S.translate(-N.position.x,-N.position.y)}else{if(N.circleRadius)S.beginPath(),S.arc(N.position.x,N.position.y,N.circleRadius,0,2*Math.PI);else{S.beginPath(),S.moveTo(N.vertices[0].x,N.vertices[0].y);for(var V=1;V<N.vertices.length;V++)!N.vertices[V-1].isInternal||A?S.lineTo(N.vertices[V].x,N.vertices[V].y):S.moveTo(N.vertices[V].x,N.vertices[V].y),N.vertices[V].isInternal&&!A&&S.moveTo(N.vertices[(V+1)%N.vertices.length].x,N.vertices[(V+1)%N.vertices.length].y);S.lineTo(N.vertices[0].x,N.vertices[0].y),S.closePath()}I.wireframes?(S.lineWidth=1,S.strokeStyle="#bbb",S.stroke()):(S.fillStyle=N.render.fillStyle,N.render.lineWidth&&(S.lineWidth=N.render.lineWidth,S.strokeStyle=N.render.strokeStyle,S.stroke()),S.fill())}S.globalAlpha=1}}},i.bodyWireframes=function(E,w,_){var S=_,I=E.options.showInternalEdges,A,P,N,j,M;for(S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.render.visible)for(M=A.parts.length>1?1:0;M<A.parts.length;M++){for(P=A.parts[M],S.moveTo(P.vertices[0].x,P.vertices[0].y),j=1;j<P.vertices.length;j++)!P.vertices[j-1].isInternal||I?S.lineTo(P.vertices[j].x,P.vertices[j].y):S.moveTo(P.vertices[j].x,P.vertices[j].y),P.vertices[j].isInternal&&!I&&S.moveTo(P.vertices[(j+1)%P.vertices.length].x,P.vertices[(j+1)%P.vertices.length].y);S.lineTo(P.vertices[0].x,P.vertices[0].y)}S.lineWidth=1,S.strokeStyle="#bbb",S.stroke()},i.bodyConvexHulls=function(E,w,_){var S=_,I,A,P;for(S.beginPath(),A=0;A<w.length;A++)if(I=w[A],!(!I.render.visible||I.parts.length===1)){for(S.moveTo(I.vertices[0].x,I.vertices[0].y),P=1;P<I.vertices.length;P++)S.lineTo(I.vertices[P].x,I.vertices[P].y);S.lineTo(I.vertices[0].x,I.vertices[0].y)}S.lineWidth=1,S.strokeStyle="rgba(255,255,255,0.2)",S.stroke()},i.vertexNumbers=function(E,w,_){var S=_,I,A,P;for(I=0;I<w.length;I++){var N=w[I].parts;for(P=N.length>1?1:0;P<N.length;P++){var j=N[P];for(A=0;A<j.vertices.length;A++)S.fillStyle="rgba(255,255,255,0.2)",S.fillText(I+"_"+A,j.position.x+(j.vertices[A].x-j.position.x)*.8,j.position.y+(j.vertices[A].y-j.position.y)*.8)}}},i.mousePosition=function(E,w,_){var S=_;S.fillStyle="rgba(255,255,255,0.8)",S.fillText(w.position.x+" "+w.position.y,w.position.x+5,w.position.y-5)},i.bodyBounds=function(E,w,_){var S=_;E.engine;var I=E.options;S.beginPath();for(var A=0;A<w.length;A++){var P=w[A];if(P.render.visible)for(var N=w[A].parts,j=N.length>1?1:0;j<N.length;j++){var M=N[j];S.rect(M.bounds.min.x,M.bounds.min.y,M.bounds.max.x-M.bounds.min.x,M.bounds.max.y-M.bounds.min.y)}}I.wireframes?S.strokeStyle="rgba(255,255,255,0.08)":S.strokeStyle="rgba(0,0,0,0.1)",S.lineWidth=1,S.stroke()},i.bodyAxes=function(E,w,_){var S=_;E.engine;var I=E.options,A,P,N,j;for(S.beginPath(),P=0;P<w.length;P++){var M=w[P],L=M.parts;if(M.render.visible)if(I.showAxes)for(N=L.length>1?1:0;N<L.length;N++)for(A=L[N],j=0;j<A.axes.length;j++){var B=A.axes[j];S.moveTo(A.position.x,A.position.y),S.lineTo(A.position.x+B.x*20,A.position.y+B.y*20)}else for(N=L.length>1?1:0;N<L.length;N++)for(A=L[N],j=0;j<A.axes.length;j++)S.moveTo(A.position.x,A.position.y),S.lineTo((A.vertices[0].x+A.vertices[A.vertices.length-1].x)/2,(A.vertices[0].y+A.vertices[A.vertices.length-1].y)/2)}I.wireframes?(S.strokeStyle="indianred",S.lineWidth=1):(S.strokeStyle="rgba(255, 255, 255, 0.4)",S.globalCompositeOperation="overlay",S.lineWidth=2),S.stroke(),S.globalCompositeOperation="source-over"},i.bodyPositions=function(E,w,_){var S=_;E.engine;var I=E.options,A,P,N,j;for(S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.render.visible)for(j=0;j<A.parts.length;j++)P=A.parts[j],S.arc(P.position.x,P.position.y,3,0,2*Math.PI,!1),S.closePath();for(I.wireframes?S.fillStyle="indianred":S.fillStyle="rgba(0,0,0,0.5)",S.fill(),S.beginPath(),N=0;N<w.length;N++)A=w[N],A.render.visible&&(S.arc(A.positionPrev.x,A.positionPrev.y,2,0,2*Math.PI,!1),S.closePath());S.fillStyle="rgba(255,165,0,0.8)",S.fill()},i.bodyVelocity=function(E,w,_){var S=_;S.beginPath();for(var I=0;I<w.length;I++){var A=w[I];if(A.render.visible){var P=a.getVelocity(A);S.moveTo(A.position.x,A.position.y),S.lineTo(A.position.x+P.x,A.position.y+P.y)}}S.lineWidth=3,S.strokeStyle="cornflowerblue",S.stroke()},i.bodyIds=function(E,w,_){var S=_,I,A;for(I=0;I<w.length;I++)if(w[I].render.visible){var P=w[I].parts;for(A=P.length>1?1:0;A<P.length;A++){var N=P[A];S.font="12px Arial",S.fillStyle="rgba(255,255,255,0.5)",S.fillText(N.id,N.position.x+10,N.position.y-10)}}},i.collisions=function(E,w,_){var S=_,I=E.options,A,P,N,j;for(S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.isActive)for(P=A.collision,j=0;j<A.activeContacts.length;j++){var M=A.activeContacts[j],L=M.vertex;S.rect(L.x-1.5,L.y-1.5,3.5,3.5)}for(I.wireframes?S.fillStyle="rgba(255,255,255,0.7)":S.fillStyle="orange",S.fill(),S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.isActive&&(P=A.collision,A.activeContacts.length>0)){var B=A.activeContacts[0].vertex.x,V=A.activeContacts[0].vertex.y;A.activeContacts.length===2&&(B=(A.activeContacts[0].vertex.x+A.activeContacts[1].vertex.x)/2,V=(A.activeContacts[0].vertex.y+A.activeContacts[1].vertex.y)/2),P.bodyB===P.supports[0].body||P.bodyA.isStatic===!0?S.moveTo(B-P.normal.x*8,V-P.normal.y*8):S.moveTo(B+P.normal.x*8,V+P.normal.y*8),S.lineTo(B,V)}I.wireframes?S.strokeStyle="rgba(255,165,0,0.7)":S.strokeStyle="orange",S.lineWidth=1,S.stroke()},i.separations=function(E,w,_){var S=_,I=E.options,A,P,N,j,M;for(S.beginPath(),M=0;M<w.length;M++)if(A=w[M],!!A.isActive){P=A.collision,N=P.bodyA,j=P.bodyB;var L=1;!j.isStatic&&!N.isStatic&&(L=.5),j.isStatic&&(L=0),S.moveTo(j.position.x,j.position.y),S.lineTo(j.position.x-P.penetration.x*L,j.position.y-P.penetration.y*L),L=1,!j.isStatic&&!N.isStatic&&(L=.5),N.isStatic&&(L=0),S.moveTo(N.position.x,N.position.y),S.lineTo(N.position.x+P.penetration.x*L,N.position.y+P.penetration.y*L)}I.wireframes?S.strokeStyle="rgba(255,165,0,0.5)":S.strokeStyle="orange",S.stroke()},i.inspector=function(E,w){E.engine;var _=E.selected,S=E.render,I=S.options,A;if(I.hasBounds){var P=S.bounds.max.x-S.bounds.min.x,N=S.bounds.max.y-S.bounds.min.y,j=P/S.options.width,M=N/S.options.height;w.scale(1/j,1/M),w.translate(-S.bounds.min.x,-S.bounds.min.y)}for(var L=0;L<_.length;L++){var B=_[L].data;switch(w.translate(.5,.5),w.lineWidth=1,w.strokeStyle="rgba(255,165,0,0.9)",w.setLineDash([1,2]),B.type){case"body":A=B.bounds,w.beginPath(),w.rect(Math.floor(A.min.x-3),Math.floor(A.min.y-3),Math.floor(A.max.x-A.min.x+6),Math.floor(A.max.y-A.min.y+6)),w.closePath(),w.stroke();break;case"constraint":var V=B.pointA;B.bodyA&&(V=B.pointB),w.beginPath(),w.arc(V.x,V.y,10,0,2*Math.PI),w.closePath(),w.stroke();break}w.setLineDash([]),w.translate(-.5,-.5)}E.selectStart!==null&&(w.translate(.5,.5),w.lineWidth=1,w.strokeStyle="rgba(255,165,0,0.6)",w.fillStyle="rgba(255,165,0,0.1)",A=E.selectBounds,w.beginPath(),w.rect(Math.floor(A.min.x),Math.floor(A.min.y),Math.floor(A.max.x-A.min.x),Math.floor(A.max.y-A.min.y)),w.closePath(),w.stroke(),w.fill(),w.translate(-.5,-.5)),I.hasBounds&&w.setTransform(1,0,0,1,0,0)};var p=function(E,w){var _=E.engine,S=E.timing,I=S.historySize,A=_.timing.timestamp;S.delta=w-S.lastTime||i._goodDelta,S.lastTime=w,S.timestampElapsed=A-S.lastTimestamp||0,S.lastTimestamp=A,S.deltaHistory.unshift(S.delta),S.deltaHistory.length=Math.min(S.deltaHistory.length,I),S.engineDeltaHistory.unshift(_.timing.lastDelta),S.engineDeltaHistory.length=Math.min(S.engineDeltaHistory.length,I),S.timestampElapsedHistory.unshift(S.timestampElapsed),S.timestampElapsedHistory.length=Math.min(S.timestampElapsedHistory.length,I),S.engineElapsedHistory.unshift(_.timing.lastElapsed),S.engineElapsedHistory.length=Math.min(S.engineElapsedHistory.length,I),S.elapsedHistory.unshift(S.lastElapsed),S.elapsedHistory.length=Math.min(S.elapsedHistory.length,I)},g=function(E){for(var w=0,_=0;_<E.length;_+=1)w+=E[_];return w/E.length||0},y=function(E,w){var _=document.createElement("canvas");return _.width=E,_.height=w,_.oncontextmenu=function(){return!1},_.onselectstart=function(){return!1},_},T=function(E){var w=E.getContext("2d"),_=window.devicePixelRatio||1,S=w.webkitBackingStorePixelRatio||w.mozBackingStorePixelRatio||w.msBackingStorePixelRatio||w.oBackingStorePixelRatio||w.backingStorePixelRatio||1;return _/S},v=function(E,w){var _=E.textures[w];return _||(_=E.textures[w]=new Image,_.src=w,_)},C=function(E,w){var _=w;/(jpg|gif|png)$/.test(w)&&(_="url("+w+")"),E.canvas.style.background=_,E.canvas.style.backgroundSize="contain",E.currentBackground=w}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(5),o=s(17),l=s(0);(function(){var u,c;if(typeof window<"u"&&(u=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,c=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),!u){var f;u=function(h){f=setTimeout(function(){h(l.now())},1e3/60)},c=function(){clearTimeout(f)}}i.create=function(h){var d={fps:60,deltaSampleSize:60,counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,frameRequestId:null,isFixed:!1,enabled:!0},m=l.extend(d,h);return m.delta=m.delta||1e3/m.fps,m.deltaMin=m.deltaMin||1e3/m.fps,m.deltaMax=m.deltaMax||1e3/(m.fps*.5),m.fps=1e3/m.delta,m},i.run=function(h,d){return typeof h.positionIterations<"u"&&(d=h,h=i.create()),(function m(p){h.frameRequestId=u(m),p&&h.enabled&&i.tick(h,d,p)})(),h},i.tick=function(h,d,m){var p=d.timing,g;h.isFixed?g=h.delta:(g=m-h.timePrev||h.delta,h.timePrev=m,h.deltaHistory.push(g),h.deltaHistory=h.deltaHistory.slice(-h.deltaSampleSize),g=Math.min.apply(null,h.deltaHistory),g=g<h.deltaMin?h.deltaMin:g,g=g>h.deltaMax?h.deltaMax:g,h.delta=g);var y={timestamp:p.timestamp};a.trigger(h,"beforeTick",y),h.frameCounter+=1,m-h.counterTimestamp>=1e3&&(h.fps=h.frameCounter*((m-h.counterTimestamp)/1e3),h.counterTimestamp=m,h.frameCounter=0),a.trigger(h,"tick",y),a.trigger(h,"beforeUpdate",y),o.update(d,g),a.trigger(h,"afterUpdate",y),a.trigger(h,"afterTick",y)},i.stop=function(h){c(h.frameRequestId)},i.start=function(h,d){i.run(h,d)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(8),o=s(0),l=o.deprecated;(function(){i.collides=function(u,c){return a.collides(u,c)},l(i,"collides","SAT.collides ➤ replaced by Collision.collides")})()}),(function(n,r,s){var i={};n.exports=i,s(1);var a=s(0);(function(){i.pathToVertices=function(o,l){typeof window<"u"&&!("SVGPathSeg"in window)&&a.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var u,c,f,h,d,m,p,g,y,T,v=[],C,E,w=0,_=0,S=0;l=l||15;var I=function(P,N,j){var M=j%2===1&&j>1;if(!y||P!=y.x||N!=y.y){y&&M?(C=y.x,E=y.y):(C=0,E=0);var L={x:C+P,y:E+N};(M||!y)&&(y=L),v.push(L),_=C+P,S=E+N}},A=function(P){var N=P.pathSegTypeAsLetter.toUpperCase();if(N!=="Z"){switch(N){case"M":case"L":case"T":case"C":case"S":case"Q":_=P.x,S=P.y;break;case"H":_=P.x;break;case"V":S=P.y;break}I(_,S,P.pathSegType)}};for(i._svgPathToAbsolute(o),f=o.getTotalLength(),m=[],u=0;u<o.pathSegList.numberOfItems;u+=1)m.push(o.pathSegList.getItem(u));for(p=m.concat();w<f;){if(T=o.getPathSegAtLength(w),d=m[T],d!=g){for(;p.length&&p[0]!=d;)A(p.shift());g=d}switch(d.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":h=o.getPointAtLength(w),I(h.x,h.y,0);break}w+=l}for(u=0,c=p.length;u<c;++u)A(p[u]);return v},i._svgPathToAbsolute=function(o){for(var l,u,c,f,h,d,m=o.pathSegList,p=0,g=0,y=m.numberOfItems,T=0;T<y;++T){var v=m.getItem(T),C=v.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(C))"x"in v&&(p=v.x),"y"in v&&(g=v.y);else switch("x1"in v&&(c=p+v.x1),"x2"in v&&(h=p+v.x2),"y1"in v&&(f=g+v.y1),"y2"in v&&(d=g+v.y2),"x"in v&&(p+=v.x),"y"in v&&(g+=v.y),C){case"m":m.replaceItem(o.createSVGPathSegMovetoAbs(p,g),T);break;case"l":m.replaceItem(o.createSVGPathSegLinetoAbs(p,g),T);break;case"h":m.replaceItem(o.createSVGPathSegLinetoHorizontalAbs(p),T);break;case"v":m.replaceItem(o.createSVGPathSegLinetoVerticalAbs(g),T);break;case"c":m.replaceItem(o.createSVGPathSegCurvetoCubicAbs(p,g,c,f,h,d),T);break;case"s":m.replaceItem(o.createSVGPathSegCurvetoCubicSmoothAbs(p,g,h,d),T);break;case"q":m.replaceItem(o.createSVGPathSegCurvetoQuadraticAbs(p,g,c,f),T);break;case"t":m.replaceItem(o.createSVGPathSegCurvetoQuadraticSmoothAbs(p,g),T);break;case"a":m.replaceItem(o.createSVGPathSegArcAbs(p,g,v.r1,v.r2,v.angle,v.largeArcFlag,v.sweepFlag),T);break;case"z":case"Z":p=l,g=u;break}(C=="M"||C=="m")&&(l=p,u=g)}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(6);s(0),(function(){i.create=a.create,i.add=a.add,i.remove=a.remove,i.clear=a.clear,i.addComposite=a.addComposite,i.addBody=a.addBody,i.addConstraint=a.addConstraint})()})])})})(ds)),ds.exports}var ab=sb();const pn=Al(ab);{const e=pn.Resolver;e&&typeof e._restingThresh=="number"&&(e._restingThresh=1.4)}const ob=6,zt=28,gn=.92,wa=1.12,lb=34;function cc(e,t,n){return Math.hypot(t-e.startX,n-e.startY)<ob?"click":"drag"}function ub(e){const t=e.length;if(t===0)return"";const n=s=>`${s.x.toFixed(1)} ${s.y.toFixed(1)}`;if(t===1)return`M ${n(e[0])}`;if(t===2)return`M ${n(e[0])} L ${n(e[1])}`;let r=`M ${n(e[0])}`;for(let s=1;s<t-1;s++){const i=e[s],a=e[s+1];r+=` Q ${n(i)} ${((i.x+a.x)/2).toFixed(1)} ${((i.y+a.y)/2).toFixed(1)}`}return`${r} L ${n(e[t-1])}`}function cb(e,t){return e*Math.exp(-t/90)}function db(e,t,n,r){const s=`translate3d(${e.toFixed(1)}px, ${t.toFixed(1)}px, 0)`;if(n<.01)return s;const i=r*180/Math.PI,a=Math.min(.35,n);return`${s} rotate(${i.toFixed(1)}deg) scale(${(1+a).toFixed(3)}, ${(1-a).toFixed(3)}) rotate(${(-i).toFixed(1)}deg)`}const Wh=4e-5,fb=5e-4;function $h(e,t,n){return Math.sin(n*37e-5+t*.0013)*.6+Math.sin(n*19e-5+e*7e-4+1.7)*.4}function Yh(e){switch(e){case"storm":return{wind:.95,gust:1,rainRate:.006,snowRate:0,airDrag:1.05};case"rain":return{wind:.6,gust:.25,rainRate:.004,snowRate:0,airDrag:1};case"snow":return{wind:.25,gust:0,rainRate:0,snowRate:4e-4,airDrag:1};case"fog":return{wind:.06,gust:0,rainRate:0,snowRate:0,airDrag:1.7};case"cloudy":return{wind:.4,gust:.1,rainRate:0,snowRate:0,airDrag:1};case"clear":default:return{wind:.3,gust:0,rainRate:0,snowRate:0,airDrag:1}}}function Gh(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,(t>>>0)/4294967295}const Ur=120,hb=.9,dc=.7,mb=.09,pb=2.2,gb=2,Sa=zt*2.45,xb=.006,Aa=22,Ca=.06;function bb(e){var j;const t=e.ballRadius??zt,n=Yh(e.weather??"clear"),{Engine:r,Bodies:s,Body:i,Composite:a,Constraint:o,Events:l}=pn,u=r.create();u.gravity.y=1,u.positionIterations=8,u.velocityIterations=4;const c=e.nodes.map(M=>{var F,q;const L=((F=M.spawn)==null?void 0:F.x)??M.x,B=((q=M.spawn)==null?void 0:q.y)??M.y,V=s.circle(L,B,t,{restitution:.5,friction:.01,frictionAir:.03*n.airDrag,density:M.isExam?.0016:.001,inertia:1/0,isStatic:!!M.locked,collisionFilter:{group:0,category:2,mask:6}});return{nodeId:M.id,body:V,layoutX:M.x,layoutY:M.y,isExam:!!M.isExam,snow:0,field:0,squash:0,squashAngle:0}});for(const M of c){a.add(u.world,M.body);const L=(j=e.nodes.find(B=>B.id===M.nodeId))==null?void 0:j.spawn;L&&(L.vx!==void 0||L.vy!==void 0)&&i.setVelocity(M.body,{x:L.vx??0,y:L.vy??0})}const f=Ur/2,h={isStatic:!0,restitution:.4,friction:.05,collisionFilter:{category:4,mask:2}},d=(M,L)=>({x:Math.min(e.width-t,Math.max(t,M)),y:Math.min(e.height-t,Math.max(t,L))});a.add(u.world,[s.rectangle(e.width/2,-f,e.width*3,Ur,h),s.rectangle(e.width/2,e.height+f,e.width*3,Ur,h),s.rectangle(-f,e.height/2,Ur,e.height*3,h),s.rectangle(e.width+f,e.height/2,Ur,e.height*3,h)]);const m=M=>({x:M.body.position.x,y:M.body.position.y+t*gn}),p=[];function g(M,L,B,V,F){return"body"in M?o.create({bodyA:M.body,pointA:M.offset,bodyB:L,pointB:B,length:V,stiffness:F,damping:.05}):o.create({pointA:M.point,bodyB:L,pointB:B,length:V,stiffness:F,damping:.05})}function y(M,L,B,V){const F={x:B.body.position.x,y:B.body.position.y+t*gn},q=F.x-M.x,R=F.y-M.y,$=Math.max(60,Math.hypot(q,R)),X=Math.max(5,Math.min(14,Math.round($/lb))),D=$*wa/X,Z=[];let le=L?{body:L,offset:{x:M.x-L.position.x,y:M.y-L.position.y}}:{point:M},z=!0;for(let ee=1;ee<X;ee++){const K=ee/X,ce=Math.sin(Math.PI*K)*$*(wa-1)*.85,fe=s.circle(M.x+q*K,M.y+R*K+ce,3.5,{density:7e-4,frictionAir:.1*n.airDrag,collisionFilter:{category:8,mask:0}});Z.push(fe),a.add(u.world,fe),a.add(u.world,g(le,fe,void 0,D,z?dc:hb)),z=!1,le={body:fe,offset:{x:0,y:0}}}a.add(u.world,g(le,B.body,{x:0,y:t*gn},D,dc)),p.push({from:V,to:B.nodeId,restLen:$*wa,particles:Z})}const T=c[0],v=T?{x:e.anchorKnotX??T.layoutX,y:Cs}:{x:e.width/2,y:Cs};T&&y(v,null,T,"__anchor");for(let M=0;M<c.length-1;M++){const L=c[M],B=c[M+1];y(m(L),L.body,B,L.nodeId)}const C=c[c.length-1],E=e.nextKnot&&(C!=null&&C.isExam)?e.nextKnot:void 0;E&&C&&y(E,null,C,"__next");const w=new Map;for(const M of c){let L=0;for(const V of p)if(V.from===M.nodeId||V.to===M.nodeId)for(const F of V.particles)L+=F.mass*.5;const B=Math.min(.25,L/M.body.mass);w.set(M.nodeId,(1+B)*(.96+Gh(M.nodeId)*.08))}let _=0,S=1;l.on(u,"beforeUpdate",()=>{const M=u.timing.timestamp;_*=.97,n.gust>0&&Math.random()<.0025*n.gust&&(_=n.gust*(.6+Math.random()*.4),S=Math.random()<.5?-1:1);for(const L of c){const B=L.body.mass,V=u.gravity.y*u.gravity.scale,F=$h(L.body.position.x,L.body.position.y,M)*n.wind*Wh*B+S*_*fb*B;let q=-B*V*(w.get(L.nodeId)??1);n.rainRate>0&&Math.random()<n.rainRate&&(q+=B*V*.35,i.applyForce(L.body,L.body.position,{x:(Math.random()-.5)*B*V*.3,y:0})),i.applyForce(L.body,L.body.position,{x:F,y:q})}});const I=[],A=(M,L,B,V)=>{if(M.snow<=Ca)return;const F=Math.max(1,Math.min(V,Math.round(M.snow*V)+1));for(let q=0;q<F;q++){const R=-(.35+Math.random()*1.9),$=t*(.55+Math.random()*.45);I.push({x:M.body.position.x+Math.cos(R)*$,y:M.body.position.y+Math.sin(R)*$,vx:M.body.velocity.x*.75+L.x*(.5+Math.random()*1.8)+(Math.random()-.5)*1.2,vy:M.body.velocity.y*.75+L.y*(.5+Math.random()*1.8)-.6-Math.random()*.8,amount:.02+Math.min(.05,B*.004)})}M.snow=Math.max(Ca*.5,M.snow-F*(.03+Math.min(.07,B*.005))),I.length>96&&I.splice(0,I.length-96)},P=[];l.on(u,"collisionStart",M=>{var L;for(const B of M.pairs){const{bodyA:V,bodyB:F}=B,q=c.find(z=>z.body===V),R=c.find(z=>z.body===F);if(!q&&!R)continue;const $={x:V.velocity.x-F.velocity.x,y:V.velocity.y-F.velocity.y},X=Math.hypot($.x,$.y);if(X<pb)continue;const D=B.collision.normal,Z=(L=B.collision.supports)==null?void 0:L[0];P.push(Z?{x:Z.x,y:Z.y,speed:X}:{x:(V.position.x+F.position.x)/2,y:(V.position.y+F.position.y)/2,speed:X}),P.length>64&&P.shift();const le=Math.min(.32,X*.028);q&&le>q.squash&&(q.squash=le,q.squashAngle=Math.atan2(D.y,D.x)),R&&le>R.squash&&(R.squash=le,R.squashAngle=Math.atan2(-D.y,-D.x)),q&&A(q,{x:D.x,y:D.y},X,5),R&&A(R,{x:-D.x,y:-D.y},X,5)}}),l.on(u,"afterUpdate",()=>{if(!(n.snowRate<=0))for(const M of c)M.snow=Math.min(1,M.snow+n.snowRate)});let N=null;return{balls:c,links:p,anchor:v,nextKnot:E,ball(M){return c.find(L=>L.nodeId===M)},step(M){r.update(u,Math.min(33,Math.max(8,M)));for(let L=0;L<c.length;L++){const B=c[L];for(let V=L+1;V<c.length;V++){const F=c[V],q=F.body.position.x-B.body.position.x,R=F.body.position.y-B.body.position.y,$=q*q+R*R;if($>=Sa*Sa||$<.01)continue;const X=Math.sqrt($),D=(X-2*t)/(Sa-2*t),Z=D<=0?1:D>=1?0:1-D,z=Math.hypot(B.body.velocity.x-F.body.velocity.x,B.body.velocity.y-F.body.velocity.y)<1.2?xb*Z*Z:0,ee=q/X,K=R/X;B.body.isStatic||i.applyForce(B.body,B.body.position,{x:-ee*z*B.body.mass,y:-K*z*B.body.mass}),F.body.isStatic||i.applyForce(F.body,F.body.position,{x:ee*z*F.body.mass,y:K*z*F.body.mass}),B.field=Math.max(B.field,Z),F.field=Math.max(F.field,Z)}}for(const L of c)L.field*=.88;for(const L of c){if(L.body.isStatic)continue;const B=L.body.velocity,V=Math.hypot(B.x,B.y);V>Aa&&i.setVelocity(L.body,{x:B.x/V*Aa,y:B.y/V*Aa})}for(let L=0;L<c.length;L++){const B=c[L];for(let V=L+1;V<c.length;V++){const F=c[V];let q=F.body.position.x-B.body.position.x,R=F.body.position.y-B.body.position.y,$=Math.hypot(q,R);if($>=t*2)continue;$<.01&&(q=1,R=0,$=1);const X=t*2-$+.05,D=q/$,Z=R/$;B.body.isStatic&&F.body.isStatic||(B.body.isStatic?i.setPosition(F.body,{x:F.body.position.x+D*X,y:F.body.position.y+Z*X}):F.body.isStatic?i.setPosition(B.body,{x:B.body.position.x-D*X,y:B.body.position.y-Z*X}):(i.setPosition(B.body,{x:B.body.position.x-D*X/2,y:B.body.position.y-Z*X/2}),i.setPosition(F.body,{x:F.body.position.x+D*X/2,y:F.body.position.y+Z*X/2})))}}for(const L of c){const B=Math.hypot(L.body.velocity.x,L.body.velocity.y);L.snow>Ca&&B>gb&&A(L,{x:L.body.velocity.x/B,y:L.body.velocity.y/B},B,2)}for(const L of c){if(L.body.isStatic)continue;const B=L.body.position.x,V=L.body.position.y,F=Math.min(e.width-t,Math.max(t,B)),q=Math.min(e.height-t,Math.max(t,V));(F!==B||q!==V)&&(i.setPosition(L.body,{x:F,y:q}),i.setVelocity(L.body,{x:B<t||B>e.width-t?0:L.body.velocity.x,y:V<t||V>e.height-t?0:L.body.velocity.y}))}},beginDrag(M,L,B){this.endDrag();const V=this.ball(M);if(!V)return;const F=o.create({pointA:d(L,B),bodyB:V.body,length:0,stiffness:mb,damping:.12});a.add(u.world,F),N={constraint:F,nodeId:M}},moveDrag(M,L){if(!N)return;const B=d(M,L);N.constraint.pointA=B},endDrag(){N&&(a.remove(u.world,N.constraint),N=null)},isDragging(){return N!==null},drainImpacts(){const M=P.slice();return P.length=0,M},drainFlakes(){const M=I.slice();return I.length=0,M},dispose(){this.endDrag(),l.off(u,"beforeUpdate"),l.off(u,"afterUpdate"),l.off(u,"collisionStart"),a.clear(u.world,!1),r.clear(u)}}}const Cs=-12;function $i(e,t,n=20){return t<=n*2?t/2:n+Gh(e)*(t-n*2)}function yb(e,t,n,r=zt){if(t<=0||Math.abs(t-n)<=1)return e;const s=n/t,i={x:Math.min(n-r,Math.max(r,e.x*s)),y:e.y,vy:e.vy};return e.vx!==void 0&&(i.vx=e.vx*s),i}const Yn=(e,t,n)=>e+(t-e)*n,Ys=(e,t,n)=>e<t?t:e>n?n:e,yi=e=>e<0?0:e>1?1:e*e*(3-2*e);function Gn(e,t,n){return[Yn(e[0],t[0],n),Yn(e[1],t[1],n),Yn(e[2],t[2],n)]}const _a=e=>`rgb(${e[0]|0},${e[1]|0},${e[2]|0})`,wr=(e,t)=>`rgba(${e[0]|0},${e[1]|0},${e[2]|0},${t})`;function Gs(){return[{t:0,top:[8,10,26],mid:[16,20,44],hor:[34,30,58]},{t:.12,top:[30,32,72],mid:[78,56,104],hor:[158,100,116]},{t:.22,top:[124,156,214],mid:[232,152,120],hor:[250,196,128]},{t:.36,top:[80,142,196],mid:[132,186,226],hor:[188,214,232]},{t:.5,top:[60,120,178],mid:[108,168,212],hor:[168,200,226]},{t:.62,top:[120,132,152],mid:[150,150,160],hor:[180,178,182]},{t:.74,top:[70,60,88],mid:[108,78,110],hor:[180,110,100]},{t:.86,top:[40,30,60],mid:[88,44,76],hor:[168,72,72]},{t:1,top:[8,10,26],mid:[16,20,44],hor:[34,30,58]}]}function Ks(e,t){return e.map(n=>({t:n.t,top:t(n.top),mid:t(n.mid),hor:t(n.hor)}))}const Ia=()=>Ks(Gs(),e=>[e[0]*1,e[1]*1.15,e[2]*.7]),Yi=()=>Ks(Gs(),e=>[e[0]*.75,e[1]*1,Math.min(255,e[2]*1.25)]),Na=()=>Ks(Gs(),e=>[Math.min(255,e[0]*1.35),e[1]*.8,e[2]*.55]),fc=()=>Ks(Gs(),e=>{const t=(e[0]+e[1]+e[2])/3;return[t*.7+e[0]*.1,t*.7+e[1]*.1,t*.95+e[2]*.15]}),Ra={far:[28,50,36],near:[56,110,52],snowy:!1},Gi={far:[20,48,30],near:[34,82,40],snowy:!1},La={far:[54,36,24],near:[128,78,36],snowy:!1},hc={far:[60,66,82],near:[232,236,244],snowy:!0};function Ut(e){return t=>{let n=e;return t>.3&&t<.5?n=Yn(n,Math.min(1,n+.2),yi((t-.3)/.2)):t>=.5&&t<.74?n=Math.min(1,n+.15):t>=.74&&t<.84&&(n=Yn(n,Math.max(0,n-.3),yi((t-.74)/.1))),Ys(n,0,1)}}const Kh={"spring|clear":{season:"spring",weather:"clear",sky:Ia(),cloudCover:Ut(.1),particles:"none",lightning:!1,fogAlpha:0,ground:Ra},"spring|cloudy":{season:"spring",weather:"cloudy",sky:Ia(),cloudCover:Ut(.5),particles:"none",lightning:!1,fogAlpha:0,ground:Ra},"spring|rain":{season:"spring",weather:"rain",sky:Ia(),cloudCover:Ut(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:Ra},"summer|clear":{season:"summer",weather:"clear",sky:Yi(),cloudCover:Ut(.1),particles:"none",lightning:!1,fogAlpha:0,ground:Gi},"summer|cloudy":{season:"summer",weather:"cloudy",sky:Yi(),cloudCover:Ut(.5),particles:"none",lightning:!1,fogAlpha:0,ground:Gi},"summer|rain":{season:"summer",weather:"rain",sky:Yi(),cloudCover:Ut(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:Gi},"summer|storm":{season:"summer",weather:"storm",sky:Yi(),cloudCover:Ut(1),particles:"rain",lightning:!0,fogAlpha:0,ground:Gi},"autumn|clear":{season:"autumn",weather:"clear",sky:Na(),cloudCover:Ut(.15),particles:"none",lightning:!1,fogAlpha:0,ground:La,sunTint:[255,180,110]},"autumn|cloudy":{season:"autumn",weather:"cloudy",sky:Na(),cloudCover:Ut(.55),particles:"none",lightning:!1,fogAlpha:0,ground:La},"autumn|storm":{season:"autumn",weather:"storm",sky:Na(),cloudCover:Ut(1),particles:"rain",lightning:!0,fogAlpha:0,ground:La},"winter|clear":{season:"winter",weather:"clear",sky:fc(),cloudCover:Ut(.2),particles:"none",lightning:!1,fogAlpha:0,ground:hc,sunTint:[220,230,245]},"winter|snow":{season:"winter",weather:"snow",sky:fc(),cloudCover:Ut(.9),particles:"snow",lightning:!1,fogAlpha:.2,ground:hc}},mc=Object.keys(Kh);function Eb(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function vb(e){const t=`${e??"none"}:${Math.floor(performance.now()/1e3)}`;return mc[Eb(t)%mc.length]}function Tb(e,t){let n=0;for(;n<t.length-1&&e>t[n+1].t;)n++;const r=t[n],s=t[Math.min(n+1,t.length-1)],i=yi(Ys((e-r.t)/(s.t-r.t||1),0,1));return{top:Gn(r.top,s.top,i),mid:Gn(r.mid,s.mid,i),hor:Gn(r.hor,s.hor,i)}}function kb(e,t,n,r,s){if(e<r||e>s)return null;const i=(e-r)/(s-r),a=Yn(.1,.9,i),o=n*.26,l=n*.98,u=l-Math.sin(i*Math.PI)*(l-o);return{x:a*t,y:u,peakness:Math.sin(i*Math.PI)}}function wb(e,t,n,r,s){let i;if(e>=r)i=(e-r)/(1-r+s);else if(e<=s)i=(1-r+e)/(1-r+s);else return null;const a=Yn(.12,.88,i),o=n*.26,l=n*.98,u=l-Math.sin(i*Math.PI)*(l-o);return{x:a*t,y:u,peakness:Math.sin(i*Math.PI)}}function Xh(e){return function(){e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function pc(e,t){const n=Xh(20260809),r=Math.max(28,Math.round(e*t/7e3)),s=[];for(let i=0;i<r;i++)s.push({x:n(),y:n()*.7,r:n()*1.2+.3,tw:n()*Math.PI*2,sp:.6+n()*1.4,big:n()<.06});return s}function Sb(){const e=Xh(7),t=[];for(let n=0;n<6;n++)t.push({x:e(),y:.12+e()*.4,s:.55+e()*1.2,speed:18e-6+e()*35e-6,seed:e()*1e3,drift:e()*.035+.008});return t}function Ab(e,t,n,r){const s=e.createLinearGradient(0,0,0,r);s.addColorStop(0,_a(t.top)),s.addColorStop(.55,_a(t.mid)),s.addColorStop(1,_a(t.hor)),e.fillStyle=s,e.fillRect(0,0,n,r)}function Cb(e,t,n,r,s,i){let a=0;if(t<.22?a=yi(1-t/.22):t>.8&&(a=yi((t-.8)/.2)),!(a<=.01))for(const o of n){const l=.55+.45*Math.sin(i*o.sp+o.tw),u=a*l;if(u<.02)continue;e.fillStyle=`rgba(255,248,228,${u})`;const c=o.big?o.r*1.8:o.r;e.beginPath(),e.arc(o.x*r,o.y*s,c,0,Math.PI*2),e.fill(),o.big&&(e.fillStyle=`rgba(255,240,210,${u*.35})`,e.fillRect(o.x*r-c*4,o.y*s-.4,c*8,.8),e.fillRect(o.x*r-.4,o.y*s-c*4,.8,c*8))}}function _b(e,t,n){if(!t)return;const{x:r,y:s,peakness:i}=t,a=28+i*8,o=e.createRadialGradient(r,s,a*.4,r,s,a*5);o.addColorStop(0,"rgba(255,236,190,0.55)"),o.addColorStop(.4,"rgba(255,210,150,0.16)"),o.addColorStop(1,"rgba(255,200,140,0)"),e.fillStyle=o,e.fillRect(r-a*5,s-a*5,a*10,a*10);const l=e.createRadialGradient(r,s,0,r,s,a),u=n??[255,236,180],c=n?Gn(n,[255,214,150],.5):[255,214,150];l.addColorStop(0,"rgba(255,252,238,1)"),l.addColorStop(.7,wr(u,1)),l.addColorStop(1,wr(c,.9)),e.fillStyle=l,e.beginPath(),e.arc(r,s,a,0,Math.PI*2),e.fill()}function Ib(e,t){if(!t)return;const{x:n,y:r}=t,s=24,i=e.createRadialGradient(n,r,s*.8,n,r,s*5);i.addColorStop(0,"rgba(220,232,255,0.38)"),i.addColorStop(.5,"rgba(220,232,255,0.1)"),i.addColorStop(1,"rgba(220,232,255,0)"),e.fillStyle=i,e.fillRect(n-s*5,r-s*5,s*10,s*10);const a=e.createRadialGradient(n-s*.25,r-s*.3,s*.2,n,r,s);a.addColorStop(0,"rgba(255,254,247,1)"),a.addColorStop(.7,"rgba(244,242,232,1)"),a.addColorStop(1,"rgba(214,222,236,1)"),e.fillStyle=a,e.beginPath(),e.arc(n,r,s,0,Math.PI*2),e.fill(),e.fillStyle="rgba(150,160,180,0.16)";const o=[[-10,-6,4],[5,3,5],[-3,9,3],[11,-8,3]];for(const[l,u,c]of o)e.beginPath(),e.arc(n+l,r+u,c,0,Math.PI*2),e.fill()}function Nb(e,t,n,r,s,i){const a=18*r,o=[[0,0,1],[-1.1,.1,.8],[1.1,.1,.8],[-.5,-.5,.7],[.6,-.45,.75],[-1.8,.3,.6],[1.8,.3,.6]];e.save(),e.translate(t,n),e.fillStyle=wr([s[0]*.7,s[1]*.7,s[2]*.78],i*.9);for(const[l,u,c]of o)e.beginPath(),e.arc(l*a,u*a*1.1+a*.45,a*c*1.05,0,Math.PI*2),e.fill();e.fillStyle=wr(s,i);for(const[l,u,c]of o)e.beginPath(),e.arc(l*a,u*a,a*c,0,Math.PI*2),e.fill();e.restore()}function Rb(e,t,n,r,s,i,a,o,l){const u=a(t);if(u<.02)return;const c=Gn(o.hor,[255,255,255],.35),f=Gn(o.mid,[20,20,30],.45),h=l?f:c;for(let d=0;d<n.length;d++){const m=n[d],p=(m.x+i*m.speed)%1.2-.1,g=m.y+Math.sin(i*1e-4+m.seed)*m.drift;d/n.length<u&&Nb(e,p*r,g*s,m.s,h,Ys(u*.92,0,.92))}}const mr=[];let Hn=[];const Jr=[];let Un=[];const Ki=[],zr=[];let Zr=[];function Lb(e,t,n,r,s,i){if(s<.04)return;const a=r*(.02+s*.07),o=.12+s*.73,l=t-r*o,u=t+r*o,c=n-Math.sqrt(Math.max(0,r*r-r*o*(r*o))),f=n-r-a,h=(c+f)/2;e.save(),e.beginPath(),e.moveTo(l,c),e.bezierCurveTo(l,h,t-r*.3,f,t,f),e.bezierCurveTo(t+r*.3,f,u,h,u,c),e.quadraticCurveTo(t,n-r*.78,l,c),e.closePath();const d=e.createLinearGradient(0,f,0,c);d.addColorStop(0,"rgba(255,255,255,0.98)"),d.addColorStop(.65,"rgba(245,250,255,0.95)"),d.addColorStop(1,"rgba(218,230,246,0.9)"),e.fillStyle=d,e.fill(),e.strokeStyle="rgba(168,192,225,0.28)",e.lineWidth=1.5,e.beginPath(),e.moveTo(l,c),e.quadraticCurveTo(t,n-r*.78,u,c),e.stroke(),e.restore()}function Pa(e,t,n,r,s){const i=Math.sin(r),a=Math.cos(r);return{x:e+Math.sin(s)*i*n,y:t-a*n}}function Pb(e,t,n,r){e.save(),e.beginPath(),e.arc(t,n,r*.99,0,Math.PI*2),e.clip();const s=e.createRadialGradient(t-r*.35,n-r*.4,0,t-r*.35,n-r*.4,r*.8);s.addColorStop(0,"rgba(255,255,255,0.4)"),s.addColorStop(.5,"rgba(255,255,255,0.12)"),s.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=s,e.fillRect(t-r,n-r,r*2,r*2),e.strokeStyle="rgba(255,255,255,0.55)",e.lineWidth=1.8,e.beginPath(),e.arc(t,n,r*.92,Math.PI*1.15,Math.PI*1.5),e.stroke(),e.restore()}function Mb(e,t){if(t.length!==0){e.save();for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.x+=r.vx,r.y+=r.vy,r.vy+=.14,r.vx*=.985,r.vy*=.99,r.life--,r.life<=0){t.splice(n,1);continue}const s=r.life/r.maxLife;e.fillStyle=`rgba(248,250,255,${(.9*s).toFixed(3)})`,e.beginPath(),e.arc(r.x,r.y,r.r*(.5+.5*s),0,Math.PI*2),e.fill()}e.restore()}}function Qh(e,t){e.save();for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.x+=r.vx,r.y+=r.vy,r.vy+=.18,r.life--,r.life<=0){t.splice(n,1);continue}const s=Math.min(1,r.life/20)*.8;e.fillStyle=`rgba(215,238,255,${s})`,e.beginPath(),e.arc(r.x,r.y,1.3,0,Math.PI*2),e.fill()}e.restore()}function Db(e,t,n,r,s,i){e.save(),e.beginPath(),e.arc(t,n,r*.99,0,Math.PI*2),e.clip();for(let a=s.length-1;a>=0;a--){const o=s[a];if(o.prog+=o.speed,o.life--,o.prog>Math.PI*1.05||o.life<=0){s.splice(a,1);continue}const l=7;for(let f=0;f<l;f++){const h=o.prog-o.len*(f/l),d=o.prog-o.len*((f+1)/l),m=Pa(t,n,r,h,o.theta),p=Pa(t,n,r,d,o.theta),g=(1-f/l)*.42;e.strokeStyle=`rgba(200,228,250,${g})`,e.lineWidth=o.thick*(1-f/l*.7),e.lineCap="round",e.beginPath(),e.moveTo(m.x,m.y),e.lineTo(p.x,p.y),e.stroke()}const u=Pa(t,n,r,o.prog,o.theta),c=e.createRadialGradient(u.x-1.2,u.y-1.2,0,u.x,u.y,o.thick*1.3);c.addColorStop(0,"rgba(255,255,255,0.85)"),c.addColorStop(.4,"rgba(180,215,240,0.5)"),c.addColorStop(1,"rgba(120,165,205,0.25)"),e.fillStyle=c,e.beginPath(),e.arc(u.x,u.y,o.thick*1.1,0,Math.PI*2),e.fill()}e.restore()}function Ob(e,t,n,r){for(;mr.length<t.length;)mr.push([]);for(;Hn.length<t.length;)Hn.push(0);for(;Zr.length<t.length;)Zr.push(.3);for(;Jr.length<t.length;)Jr.push([]);for(;Un.length<t.length;)Un.push(0);for(let s=0;s<t.length;s++){const i=t[s];if(n.particles==="snow"){const a=i.snow!==void 0?i.snow:Math.min(1,(Zr[s]??.3)+8e-4);Zr[s]=a,Lb(e,i.x,i.y,i.r,a)}else if(n.particles==="rain"){if(Pb(e,i.x,i.y,i.r),Hn[s]=Hn[s]-1,Hn[s]<=0&&mr[s].length<3){const a=Math.random()<.5?-1:1;mr[s].push({theta:a*(.2+Math.random()*.3),prog:.1+Math.random()*.2,speed:.012+Math.random()*.012,len:.3+Math.random()*.3,thick:1.6+Math.random()*1.4,life:250+Math.random()*200}),Hn[s]=40+Math.random()*60}if(Db(e,i.x,i.y,i.r,mr[s]),Un[s]=Un[s]-1,Un[s]<=0){const a=i.x+(Math.random()-.5)*i.r*1.2,o=a-i.x,l=i.y-Math.sqrt(Math.max(0,i.r*i.r-o*o)),u=4+Math.floor(Math.random()*3);for(let c=0;c<u;c++){const f=o<0?-1:1;Jr[s].push({x:a,y:l,vx:f*(.5+Math.random()*2)*(Math.random()<.5?-1:1),vy:-(1.5+Math.random()*2.5),life:18+Math.floor(Math.random()*14)})}Un[s]=30+Math.floor(Math.random()*50)}Qh(e,Jr[s])}}}function Fb(e,t,n,r,s){e.save(),e.strokeStyle=s?"rgba(205,224,244,0.42)":"rgba(210,224,238,0.3)",e.lineWidth=s?1:.7,e.lineCap="round";const i=s?.013:.007;for(const a of r){a.y+=a.v*i,a.y>1&&(a.y-=1,a.x=Math.random());const o=a.x*t,l=a.y*n;e.beginPath(),e.moveTo(o,l),e.lineTo(o,l+a.len),e.stroke()}e.restore()}function Bb(e,t,n,r,s){e.save(),e.fillStyle="rgba(250,250,255,0.85)";for(const i of r){i.y+=i.v*.004;const a=(i.x+Math.sin(s*5e-4+i.phase)*.02)*t,o=i.y*n;i.y>1&&(i.y-=1),e.beginPath(),e.arc(a,o,i.r,0,Math.PI*2),e.fill()}e.restore()}function jb(e,t,n,r,s){const i=e.createLinearGradient(0,n*.4,0,n),a=Gn(s.hor,[255,255,255],.3);i.addColorStop(0,wr(a,0)),i.addColorStop(1,wr(a,r)),e.fillStyle=i,e.fillRect(0,n*.4,t,n*.6)}let cr=0,gc=0;function Hb(e,t,n,r,s){if(s>gc&&(cr=1,gc=s+1400+Math.random()*2600),cr*=.86,cr<.02){cr=0;return}if(e.fillStyle=`rgba(255,255,255,${cr*.5})`,e.fillRect(0,0,t,n),cr>.6){e.save(),e.strokeStyle="rgba(255,255,255,0.95)",e.lineWidth=2.2,e.shadowColor="rgba(220,230,255,0.9)",e.shadowBlur=22;let i=t*(.3+Math.random()*.4),a=0;for(e.beginPath(),e.moveTo(i,a);a<n*.6;)i+=(Math.random()-.5)*60,a+=24+Math.random()*30,e.lineTo(i,a);e.stroke(),e.restore()}}function Ub(e,t,n,r){const s=e.getContext("2d");if(!s)return()=>{};const i=s,a=n;let o=0,l=0,u=1,c=pc(1,1);const f=Sb();let h=[],d=[],m=0,p=0,g=!0;const y=performance.now(),T=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function v(){const I=a.getBoundingClientRect();if(u=Math.min(window.devicePixelRatio||1,2),o=Math.max(1,I.width),l=Math.max(1,I.height),e.width=Math.floor(o*u),e.height=Math.floor(l*u),e.style.width=o+"px",e.style.height=l+"px",i.setTransform(u,0,0,u,0,0),c=pc(o,l),r.particles==="rain"&&h.length===0){const A=r.weather==="storm",P=A?140:70;for(let N=0;N<P;N++)h.push({x:Math.random(),y:Math.random(),len:A?12+Math.random()*14:6+Math.random()*8,v:A?.9+Math.random()*.4:.5+Math.random()*.3})}if(r.particles==="snow"&&d.length===0)for(let A=0;A<120;A++)d.push({x:Math.random(),y:Math.random(),r:.8+Math.random()*1.6,v:.5+Math.random()*.8,phase:Math.random()*Math.PI*2})}function C(){const I=t.scrollHeight-t.clientHeight;m=I>0?Ys(t.scrollTop/I,0,1):0}function E(I){if(!g)return;const A=m,P=T?0:(I-y)/1e3,N=Tb(A,r.sky);Ab(i,N,o,l),Cb(i,A,c,o,l,P),Ib(i,wb(A,o,l,.92,.08)),_b(i,kb(A,o,l,.16,.88),r.sunTint),Rb(i,A,f,o,l,I,r.cloudCover,N,r.weather==="storm"),r.particles==="rain"&&Fb(i,o,l,h,r.weather==="storm"),r.particles==="snow"&&Bb(i,o,l,d,I),r.fogAlpha>0&&jb(i,o,l,r.fogAlpha,N),r.lightning&&Hb(i,o,l,!0,I),T||(p=requestAnimationFrame(E))}const w=()=>C(),_=new ResizeObserver(()=>{v(),C()});_.observe(a),v(),C();let S;if(T){let I=!1;S=()=>{C(),I||(I=!0,requestAnimationFrame(()=>{I=!1,E(performance.now())}))},t.addEventListener("scroll",S,{passive:!0}),E(performance.now())}else S=w,t.addEventListener("scroll",S,{passive:!0}),p=requestAnimationFrame(E);return()=>{g=!1,cancelAnimationFrame(p),_.disconnect(),t.removeEventListener("scroll",S)}}function zb(e,t,n,r,s,i){const a=()=>{mr.length=0,Zr.length=0,Hn.length=0,Jr.length=0,Un.length=0,Ki.length=0,zr.length=0;const T=e.getContext("2d");T&&T.clearRect(0,0,e.width,e.height)};if(a(),window.matchMedia("(prefers-reduced-motion: reduce)").matches)return()=>{};if(n.particles!=="rain"&&n.particles!=="snow")return()=>{};const l=e.getContext("2d");if(!l)return()=>{};const u=l;let c=0,f=0,h=1,d=0,m=!0;function p(){const T=t.getBoundingClientRect();h=Math.min(window.devicePixelRatio||1,2),c=Math.max(1,T.width),f=Math.max(1,T.height),e.width=Math.floor(c*h),e.height=Math.floor(f*h),e.style.width=c+"px",e.style.height=f+"px",u.setTransform(h,0,0,h,0,0)}function g(T){if(!m)return;u.clearRect(0,0,c,f);const v=r();if(Ob(u,v,n),s){for(const C of s()){const E=3+Math.min(5,Math.floor(C.speed/3));for(let w=0;w<E;w++)Ki.push({x:C.x,y:C.y,vx:(Math.random()-.5)*3.2,vy:-(1.5+Math.random()*2.5),life:16+Math.floor(Math.random()*12)})}Ki.length>0&&Qh(u,Ki)}if(i){for(const C of i()){const E=1+Math.min(2,Math.round(C.amount*40));for(let w=0;w<E;w++){const _=55+Math.floor(Math.random()*40);zr.push({x:C.x+(Math.random()-.5)*8,y:C.y+(Math.random()-.5)*6,vx:C.vx*.6+(Math.random()-.5)*.8,vy:C.vy*.6-Math.random()*.5,life:_,maxLife:_,r:1.2+Math.random()*2.2})}}for(;zr.length>240;)zr.shift();Mb(u,zr)}d=requestAnimationFrame(g)}const y=new ResizeObserver(p);return y.observe(t),p(),d=requestAnimationFrame(g),()=>{m=!1,cancelAnimationFrame(d),y.disconnect(),a()}}const Vb=k.lazy(()=>we(()=>import("./CourseSearchPanel-ThxY4JL1.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.CourseSearchPanel})));function qb(e){const t=Ke(),[n,r]=k.useState("import"),[s,i]=k.useState("study"),a=k.useRef(null),o=k.useRef(null),l=Math.round(e.overallMastery*100),c=!Cl(),f=k.useRef([]),h=k.useRef(N=>{f.current.push(...N),f.current.length>64&&f.current.splice(0,f.current.length-64)}).current,d=k.useRef([]),m=k.useRef(new Map),p=k.useRef(N=>{d.current.push(...N),d.current.length>96&&d.current.splice(0,d.current.length-96)}).current,g=e.sections.filter(N=>(N.world??"study")===s),y=e.sections.some(N=>N.world==="practice"),[T,v]=k.useState(null);k.useEffect(()=>{v(vb(e.courseId))},[e.courseId]);const C=T?Kh[T]??null:null;k.useEffect(()=>($u({nav:a.current,visible:n==="map",weather:(C==null?void 0:C.weather)??"clear"}),()=>{$u({visible:!1,nav:null})}),[n,C,a]);const[E,w]=k.useState(!1);k.useEffect(()=>{if(!e.selectedNodeId)return;const N=o.current;if(!N)return;const j=N.querySelector(`[data-node-id="${CSS.escape(e.selectedNodeId)}"]`);if(!j)return;const M=N.getBoundingClientRect(),L=j.getBoundingClientRect();(L.top<M.top+60||L.bottom>M.bottom-60)&&j.scrollIntoView({behavior:"smooth",block:"center"})},[e.selectedNodeId]);const _=k.useRef(null);k.useEffect(()=>{w(!1),e.courseId&&(_.current===null||_.current!==e.courseId)&&(r("map"),i("study")),!e.courseId&&_.current!==null&&(r("import"),i("study")),_.current=e.courseId},[e.courseId]);const[S,I]=k.useState(null),A=k.useRef({}),P=k.useRef(null);return k.useEffect(()=>{var L,B;const N=A.current,j={};let M=null;for(const V of e.tree){const F=((L=e.progressMap[V.id])==null?void 0:L.status)??"locked";j[V.id]=F,N[V.id]==="locked"&&F!=="locked"&&!M&&(M=V.id)}if(M&&Object.keys(N).length>0){const V=(B=a.current)==null?void 0:B.querySelector(`[data-testid="map-node-${M.slice(0,8)}"], [data-testid="exam-node-${M.slice(0,8)}"]`),F=V==null?void 0:V.getBoundingClientRect(),q=!!F&&F.width>0&&F.left>=0&&F.right<=window.innerWidth&&F.top>=0;us("unlock",q?{origin:{x:F.left+F.width/2,y:F.top+4}}:void 0)}A.current=j},[e.tree,e.progressMap]),x.jsxs("nav",{ref:a,className:`map-rail-scope relative h-full flex flex-col bg-surface-rail shrink-0 overflow-hidden ${e.fullWidth?"w-full":e.width==null?"w-[300px]":""}`,style:!e.fullWidth&&e.width!=null?{width:e.width}:void 0,"data-testid":"map-rail",children:[C&&x.jsxs(x.Fragment,{children:[x.jsx($b,{scrollRef:o,navRef:a,preset:C}),x.jsx(Yb,{scrollRef:o,navRef:a,preset:C,getImpacts:()=>f.current.splice(0),getFlakes:()=>d.current.splice(0),orbSnowRef:m})]}),x.jsxs("div",{className:"absolute top-0 left-0 right-0 z-40 px-2 pt-2 pb-2 pointer-events-none [&_button]:pointer-events-auto","data-testid":"map-rail-topbar",children:[x.jsxs("div",{className:"flex p-1 rounded-lg gap-1 mb-2",style:{background:"rgb(var(--surface-rail-rgb) / 0.55)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[x.jsxs("button",{onClick:()=>r("map"),"data-testid":"map-tab-map",className:`flex-1 flex items-center justify-center gap-1 py-1.5 rounded-md text-label font-bold transition-colors ${n==="map"?"bg-brand/20 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Rh,{className:"w-3 h-3"})," ",t("map.tab.map")]}),x.jsxs("button",{onClick:()=>r("import"),"data-testid":"map-tab-import",className:`flex-1 flex items-center justify-center gap-1 py-1.5 rounded-md text-label font-bold transition-colors ${n==="import"?"bg-brand/20 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Ws,{className:"w-3 h-3"})," ",t("map.tab.import")]})]}),n==="map"&&x.jsxs("div",{className:"px-3 py-2 rounded-lg pointer-events-auto",style:{background:"rgb(var(--surface-rail-rgb) / 0.55)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("h2",{className:"text-body font-extrabold text-white truncate flex-1","data-tooltip":e.courseTitle??"",children:e.courseTitle??t("map.course.none")}),e.availableLanguages.length>0&&x.jsx(Zb,{available:e.availableLanguages,current:e.currentLocale,onChange:e.onLocaleChange}),e.courseId&&x.jsx("button",{onClick:N=>{const j=N.currentTarget.getBoundingClientRect();I({id:e.courseId,title:e.courseTitle??"",rect:j})},"data-testid":"course-delete-btn","aria-label":t("import.delete.current"),"data-tooltip":t("import.delete.current"),className:"shrink-0 flex items-center justify-center w-5 h-5 rounded-md text-white/40 hover:text-warning hover:bg-white/10 transition-colors",children:x.jsx(Dh,{className:"w-3 h-3"})})]}),x.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[x.jsx("div",{className:"flex-1 h-2.5 bg-black/40 rounded-full overflow-hidden ring-1 ring-white/10",children:x.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,l)}%`}})}),x.jsxs("span",{className:"text-label font-extrabold tabular-nums text-white drop-shadow-[0_1px_3px_rgba(0,0,0,0.6)]",children:[l,"%"]})]}),x.jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1.5 text-caption",children:[x.jsxs("button",{onClick:()=>w(!0),"data-testid":"map-search-btn",className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-white/5 ring-1 ring-white/10 hover:bg-white/10 transition-colors",children:[x.jsx(Ox,{className:"w-3 h-3 text-white/50"}),x.jsx("span",{className:"font-bold text-white/60",children:t("map.search.label")})]}),x.jsxs("button",{onClick:e.onOpenReview,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-full transition-colors ${e.dueCount>0?"bg-review/20 ring-1 ring-review/30 hover:bg-review/30":"bg-white/5 ring-1 ring-white/10 hover:bg-white/10"}`,"data-testid":"map-review-badge",children:[x.jsx(Cn,{className:`w-3 h-3 ${e.dueCount>0?"text-review":"text-white/50"}`}),x.jsx("span",{className:`font-bold ${e.dueCount>0?"text-review":"text-white/60"}`,children:t("map.review.label")}),e.dueCount>0&&x.jsx("span",{className:"font-extrabold text-review tabular-nums",children:e.dueCount})]})]}),y&&x.jsxs("div",{className:"flex gap-1 mt-1.5 p-0.5 rounded-lg bg-black/30",children:[x.jsxs("button",{onClick:()=>i("study"),"data-testid":"world-tab-study",className:`flex-1 flex items-center justify-center gap-1 py-1 rounded-md text-caption font-bold transition-colors ${s==="study"?"bg-brand/30 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Cn,{className:"w-3 h-3"})," ",t("map.world.study")]}),x.jsxs("button",{onClick:()=>i("practice"),"data-testid":"world-tab-practice",className:`flex-1 flex items-center justify-center gap-1 py-1 rounded-md text-caption font-bold transition-colors ${s==="practice"?"bg-accent/30 text-accent":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Fh,{className:"w-3 h-3"})," ",t("map.world.practice")]})]})]})]}),x.jsx("div",{className:"absolute inset-0 overflow-hidden z-10",children:x.jsxs("div",{className:"flex h-full transition-transform duration-300",style:{transform:n==="map"?"translateX(0)":"translateX(-50%)",width:"200%"},children:[x.jsx("div",{className:"w-1/2 h-full relative",children:x.jsx("div",{ref:o,className:"map-path h-full overflow-y-auto overflow-x-hidden px-2 pt-48 pb-4","data-testid":"map-path",onPointerDown:N=>{P.current={x:N.clientX,y:N.clientY}},onClick:N=>{const j=P.current;P.current=null,!(!j||Math.hypot(N.clientX-j.x,N.clientY-j.y)>6)&&(N.target.closest("button, a, input, textarea, select")||E1(N.clientX,N.clientY))},children:x.jsxs("div",{className:`map-sky-content ${C?`env-${C.season} env-${C.weather}`:""}`,children:[e.streaming&&x.jsxs("div",{className:"mb-3 mx-1 px-3 py-2 rounded-xl bg-brand/10 border border-brand/30 flex items-center gap-2 text-label text-brand font-medium backdrop-blur-sm","data-testid":"streaming-notice",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),t("map.streaming.notice")]}),e.sections.length===0?e.courseTitle?x.jsxs("div",{className:"text-center text-label text-white/60 mt-8 px-4 flex items-center justify-center gap-2",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),t("map.generating")]}):x.jsxs("button",{onClick:()=>r("import"),className:"block w-full mt-8 mx-auto p-4 rounded-2xl border-2 border-dashed border-brand/40 hover:border-brand hover:bg-brand/5 transition-all text-center group","data-testid":"map-empty-cta",children:[x.jsx("div",{className:"text-3xl mb-2 group-hover:scale-110 transition-transform",children:"🗺️"}),x.jsx("div",{className:"text-body font-bold text-white/90 mb-1",children:t("map.empty.cta.title")}),x.jsx("div",{className:"text-label text-white/60 leading-relaxed",children:t("map.empty.cta.desc")}),x.jsx("div",{className:"mt-2 text-caption text-brand font-bold",children:t("map.empty.cta.btn")})]}):g.length===0?x.jsx("div",{className:"text-center text-label text-white/60 mt-8 px-4",children:t(s==="practice"?"map.empty.practice":"map.generating")}):x.jsx("div",{className:"space-y-6 pt-2",children:g.map((N,j)=>x.jsx(Gb,{section:N,sectionIndex:j,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,dueNodeIds:e.dueNodeIds,streamingNodeIds:e.streamingNodeIds,onJumpNode:e.onJumpNode,physics:c,physicsWeather:(C==null?void 0:C.weather)??"clear",scrollRef:o,navRef:a,onImpacts:h,onFlakes:p,orbSnowRef:m},N.id))})]})})}),x.jsx("div",{className:"w-1/2 h-full overflow-y-auto px-3 pt-20 pb-3 space-y-2.5",children:x.jsx(Wb,{courses:e.courses,selectedCourseId:e.courseId,onSelectCourse:N=>{e.onSelectCourse(N),r("map")},onDeleteCourse:(N,j,M)=>I({id:N,title:j,rect:M}),onCoursesChanged:e.onCoursesChanged})})]})}),E&&e.courseId&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(Vb,{sections:e.sections,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,onJump:N=>{i(N.world??"study"),w(!1),So(null,null,N.id),e.onJumpNode(N.id)},onClose:()=>w(!1)})}),S&&x.jsx(Vh,{anchorRect:S.rect,message:`${S.title} — ${t("import.delete.confirm")}`,danger:!0,confirmLabel:t("import.delete"),testid:"course-delete-confirm",onConfirm:()=>{e.onDeleteCourse(S.id),I(null)},onCancel:()=>I(null)})]})}function Wb({courses:e,selectedCourseId:t,onSelectCourse:n,onDeleteCourse:r,onCoursesChanged:s}){const i=Ke(),[a,o]=k.useState("url"),[l,u]=k.useState(!1),[c,f]=k.useState(""),[h,d]=k.useState(""),m=k.useRef(null),p=k.useRef(null),g=k.useRef(null),[y,T]=k.useState(""),[v,C]=k.useState(""),[E,w]=k.useState(!1),[_,S]=k.useState(null),[I,A]=k.useState(null),[P,N]=k.useState(null),[j,M]=k.useState(null),[L,B]=k.useState([]),[,V]=k.useState(0),F=k.useRef(null);k.useEffect(()=>{const re=oe.on("import:progress",ge=>{B(Te=>{const Ne=/\d+\/\d+/.test(ge),Oe=Te[Te.length-1];if(Ne&&Oe&&Oe.status==="working"){const Fe=[...Te];return Fe[Fe.length-1]={...Oe,msg:ge},Fe}const be=Te.map(Fe=>Fe.status==="working"?{...Fe,status:"done"}:Fe);return be.push({msg:ge,status:"working",ts:Date.now()}),be})}),ne=setInterval(()=>V(ge=>ge+1),1e3);return()=>{re(),clearInterval(ne)}},[]),k.useEffect(()=>oe.on("import:done",ne=>{w(!1),Ht(!1),ne.cancelled||k1(ne.ok),N(ne.ok?null:ne.planId??null),ne.ok?(A(`${i("import.success.folder")}: ${ne.title??""}${ne.reused?`(${i("import.success.reused")})`:""}`),M(ne.courseId?{courseId:ne.courseId,packable:ne.packable??!1}:null),s()):ne.cancelled?(B([]),S(null),A(i("import.cancelled"))):S(ne.error??"导入失败")}),[s,i]),k.useEffect(()=>{const re=F.current;re&&(re.scrollTop=re.scrollHeight)},[L]);const q=async()=>{if(!(!c.trim()||E)){S(null),A(null),B([]);try{await oe.importUrl(c.trim()),w(!0),Ht(!0)}catch(re){S(re instanceof Error?re.message:String(re))}}},R=async()=>{if(!(!y.trim()||E)){S(null),A(null),B([]);try{await oe.importText({name:v.trim()||void 0,text:y.trim()}),w(!0),Ht(!0)}catch(re){S(re instanceof Error?re.message:String(re))}}},$=async()=>{var ne;if(E)return;if(S(null),A(null),B([]),!hn){(ne=p.current)==null||ne.click();return}await oe.importEpub().catch(ge=>(S(ge instanceof Error?ge.message:String(ge)),null))&&(w(!0),Ht(!0))},X=async re=>{if(!(!re||E)){S(null),A(null),B([]);try{const ne=new Uint8Array(await re.arrayBuffer());let ge="";for(let Ne=0;Ne<ne.length;Ne+=32768)ge+=String.fromCharCode(...ne.subarray(Ne,Ne+32768));await oe.importEpub({fileName:re.name,contentBase64:btoa(ge)})&&w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},D=async()=>{if(E)return;if(S(null),A(null),B([]),!hn){const ne=h.trim();if(!ne){S(i("import.folder.pathRequired"));return}try{await oe.importLocalFolder(ne)&&w(!0),Ht(!0)}catch(ge){S(ge instanceof Error?ge.message:String(ge))}return}await oe.importLocalFolder()&&(w(!0),Ht(!0))},Z=async()=>{var ne;if(E)return;if(S(null),A(null),B([]),!hn){(ne=m.current)==null||ne.click();return}await oe.importPack().catch(ge=>(S(ge instanceof Error?ge.message:String(ge)),null))&&(w(!0),Ht(!0))},le=async re=>{if(!(!re||E)){S(null),A(null),B([]);try{const ne=await re.text();await oe.importPack({fileName:re.name,content:ne})&&w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},z=async()=>{var ne;if(E)return;if(S(null),A(null),B([]),!hn){(ne=g.current)==null||ne.click();return}await oe.importAudio().catch(ge=>(S(ge instanceof Error?ge.message:String(ge)),null))&&(w(!0),Ht(!0))},ee=async re=>{if(!(!re||re.length===0||E)){S(null),A(null),B([]);try{const ne=[];for(const Te of Array.from(re)){const Ne=new Uint8Array(await Te.arrayBuffer());let Oe="";for(let be=0;be<Ne.length;be+=32768)Oe+=String.fromCharCode(...Ne.subarray(be,be+32768));ne.push({fileName:Te.name,contentBase64:btoa(Oe)})}await oe.importAudio(ne)&&w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},K=async re=>{if(!E){S(null),B([]);try{await oe.importResume(re),w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},ce=async re=>{try{const ne=await oe.exportPack(re);ne!=null&&ne.content&&ne.fileName?(fe(ne.fileName,ne.content),A(i("import.pack.exported",{path:ne.fileName}))):ne!=null&&ne.path&&A(i("import.pack.exported",{path:ne.path}))}catch(ne){S(ne instanceof Error?ne.message:String(ne))}},fe=(re,ne)=>{const ge=new Blob([ne],{type:"application/json"}),Te=URL.createObjectURL(ge),Ne=document.createElement("a");Ne.href=Te,Ne.download=re,Ne.click(),setTimeout(()=>URL.revokeObjectURL(Te),5e3)};return x.jsxs(x.Fragment,{children:[e.length===0?x.jsxs("div",{className:"text-center py-10",children:[x.jsx("div",{className:"text-3xl mb-2 opacity-30",children:"📚"}),x.jsx("p",{className:"text-label text-white/45 leading-relaxed",children:i("import.empty")})]}):x.jsx("div",{className:"space-y-2","data-testid":"course-list",children:e.map(re=>{const ne=re.id===t;return x.jsxs("div",{"data-testid":"course-row",className:`relative rounded-xl transition-all duration-150 group ${ne?"bg-brand/12 ring-1 ring-brand/40":"bg-white/5 hover:bg-white/10 hover:-translate-y-0.5"}`,children:[x.jsx("button",{onClick:()=>n(re.id),className:"w-full text-left p-3",children:x.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:`text-body font-bold truncate ${ne?"text-brand":"text-white/90"}`,children:re.title}),x.jsx("div",{className:"text-caption text-white/40 truncate mt-0.5",children:re.repoName})]}),ne&&x.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full bg-brand flex items-center justify-center",children:x.jsx(An,{className:"w-3 h-3 text-white"})})]})}),x.jsxs("div",{className:"absolute bottom-1.5 right-2 flex items-center gap-2.5 opacity-0 group-hover:opacity-100 pointer-coarse:opacity-100 focus-within:opacity-100 transition-opacity",children:[x.jsxs("button",{onClick:ge=>{ge.stopPropagation(),S(null),A(null),oe.exportPack(re.id).then(Te=>{Te!=null&&Te.content&&Te.fileName?(fe(Te.fileName,Te.content),A(i("import.pack.exported",{path:Te.fileName}))):Te!=null&&Te.path&&A(i("import.pack.exported",{path:Te.path}))}).catch(Te=>{S(Te instanceof Error?Te.message:String(Te))})},"data-testid":"course-row-export",className:"text-caption text-white/40 hover:text-brand flex items-center gap-0.5",children:[x.jsx(ic,{className:"w-2.5 h-2.5"})," ",i("import.export")]}),x.jsxs("button",{onClick:ge=>{ge.stopPropagation();const Te=ge.currentTarget.getBoundingClientRect();r(re.id,re.title,Te)},"data-testid":"course-row-delete",className:"text-caption text-white/40 hover:text-warning flex items-center gap-0.5",children:[x.jsx(Dh,{className:"w-2.5 h-2.5"})," ",i("import.delete")]})]})]},re.id)})}),x.jsxs("div",{className:e.length>0?"mt-6":"",children:[x.jsxs("button",{onClick:()=>u(!l),className:`w-full flex items-center justify-center gap-1.5 py-3 rounded-xl border-2 border-dashed transition-all text-body font-bold ${l?"border-brand/40 bg-brand/8 text-brand":"border-white/20 hover:border-brand/50 hover:bg-brand/8 text-white/70 hover:text-brand"}`,children:[x.jsx(Ph,{className:`w-4 h-4 transition-transform ${l?"rotate-45":""}`})," ",i("import.cta")]}),l&&x.jsxs("div",{className:"mt-3 space-y-3",children:[E?x.jsxs("div",{className:"rounded-xl bg-black/30 border border-brand/30 p-4","data-testid":"import-progress",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[x.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin shrink-0"}),x.jsx("span",{className:"text-body font-bold text-white/90",children:i("import.progress.title")}),x.jsx("button",{onClick:()=>{oe.importCancel()},"data-testid":"import-cancel-btn",className:"ml-auto text-caption text-white/50 hover:text-warning transition-colors",children:i("import.progress.cancel")})]}),x.jsx("div",{className:"text-caption text-white/40 mb-2.5",children:i("import.progress.note")}),(a==="url"?c.trim():a==="markdown"&&v.trim())?x.jsx("div",{className:"text-caption text-white/40 font-mono truncate mb-2.5",children:a==="url"?c.trim():v.trim()}):null,x.jsx("div",{ref:F,className:"space-y-1.5 max-h-[40vh] overflow-y-auto pr-1",children:L.length===0?x.jsx("div",{className:"text-caption text-white/50 py-1",children:i("import.progress.starting")}):L.map((re,ne)=>x.jsxs("div",{className:"flex items-start gap-1.5 text-caption",children:[re.status==="done"?x.jsx(An,{className:"w-3 h-3 text-brand shrink-0 mt-px"}):x.jsx("span",{className:"inline-block w-2.5 h-2.5 border-2 border-brand border-t-transparent rounded-full animate-spin shrink-0 mt-px"}),x.jsxs("span",{className:re.status==="done"?"text-white/40":"text-white/90",children:[re.msg,re.status==="working"&&x.jsxs("span",{className:"text-white/35 ml-1",children:["(",i("import.progress.elapsed",{s:Math.floor((Date.now()-re.ts)/1e3)}),")"]})]})]},ne))})]}):x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"@container flex flex-wrap gap-1 p-1 bg-white/5 rounded-lg",children:[{k:"url",label:i("import.tab.url"),icon:Sx},{k:"markdown",label:i("import.tab.md"),icon:Ws},{k:"folder",label:i("import.tab.folder"),icon:gx},{k:"epub",label:i("import.tab.epub"),icon:Cn},{k:"audio",label:i("import.tab.audio"),icon:cs},{k:"pack",label:i("import.tab.pack"),icon:ic}].map(({k:re,label:ne,icon:ge})=>x.jsxs("button",{onClick:()=>o(re),className:`min-w-[72px] flex-1 flex items-center justify-center gap-0.5 py-1.5 px-0.5 rounded-md font-bold transition-colors ${a===re?"bg-brand/15 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(ge,{className:"w-3 h-3 shrink-0"}),x.jsx("span",{className:"whitespace-nowrap",style:{fontSize:"clamp(0.75rem, 4cqi, 0.875rem)"},children:ne})]},re))}),a==="url"?x.jsxs("section",{className:"space-y-2","data-testid":"import-url-section",children:[x.jsx("input",{type:"text",value:c,onChange:re=>f(re.target.value),placeholder:i("import.url.placeholder"),"data-testid":"repo-url-input",className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors"}),x.jsx("p",{className:"text-caption text-white/45 leading-relaxed",children:i("import.url.desc")}),x.jsx("button",{onClick:q,disabled:!c.trim()||E,"data-testid":"import-url-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.url")})]}):a==="markdown"?x.jsxs("section",{className:"space-y-2","data-testid":"import-md-section",children:[x.jsx("input",{type:"text",value:v,onChange:re=>C(re.target.value),placeholder:i("import.placeholder.name"),"data-testid":"md-name-input",className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors"}),x.jsx("textarea",{value:y,onChange:re=>T(re.target.value),placeholder:i("import.placeholder.md"),"data-testid":"md-text-input",rows:4,className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors resize-none"}),x.jsx("button",{onClick:R,disabled:!y.trim()||E,"data-testid":"import-md-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.md")})]}):a==="folder"?x.jsxs("section",{className:"space-y-2","data-testid":"import-folder-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.folder.desc")}),!hn&&x.jsx("input",{type:"text",value:h,onChange:re=>d(re.target.value),placeholder:i("import.folder.pathPlaceholder"),"data-testid":"import-folder-path",className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors"}),x.jsx("button",{onClick:D,disabled:E||!hn&&!h.trim(),"data-testid":"import-folder-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.folder")})]}):a==="epub"?x.jsxs("section",{className:"space-y-2","data-testid":"import-epub-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.epub.desc")}),!hn&&x.jsx("input",{ref:p,type:"file",accept:".epub,application/epub+zip",className:"hidden","data-testid":"import-epub-file",onChange:re=>{var ne;X((ne=re.target.files)==null?void 0:ne[0]),re.currentTarget.value=""}}),x.jsx("button",{onClick:$,disabled:E,"data-testid":"import-epub-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.epub")})]}):a==="audio"?x.jsxs("section",{className:"space-y-2","data-testid":"import-audio-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.audio.desc")}),!hn&&x.jsx("input",{ref:g,type:"file",multiple:!0,accept:".wav,.mp3,.m4a,.flac,.aac,.ogg,.opus,audio/*",className:"hidden","data-testid":"import-audio-file",onChange:re=>{ee(re.target.files),re.currentTarget.value=""}}),x.jsx("button",{onClick:z,disabled:E,"data-testid":"import-audio-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.audio")})]}):x.jsxs("section",{className:"space-y-2","data-testid":"import-pack-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.pack.desc")}),!hn&&x.jsx("input",{ref:m,type:"file",accept:".json,application/json",className:"hidden","data-testid":"import-pack-file",onChange:re=>{var ne;le((ne=re.target.files)==null?void 0:ne[0]),re.currentTarget.value=""}}),x.jsx("button",{onClick:Z,disabled:E,"data-testid":"import-pack-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.pack")})]})]}),_&&x.jsxs("div",{className:"border border-warning/40 text-warning-light text-label rounded-lg p-2 whitespace-pre-wrap","data-testid":"import-error",children:[_,P&&x.jsx("button",{onClick:()=>void K(P),disabled:E,"data-testid":"import-resume-btn",className:"block mt-1.5 text-label font-bold text-warning-light hover:text-warning underline underline-offset-2 disabled:opacity-40",children:i("import.error.resume")})]}),I&&x.jsxs("div",{className:"border border-brand/30 text-brand text-label rounded-lg p-2","data-testid":"import-success",children:[x.jsx(An,{className:"inline-block w-3.5 h-3.5 mr-1 align-[-3px]"}),I,(j==null?void 0:j.packable)&&x.jsx("button",{onClick:()=>void ce(j.courseId),disabled:E,"data-testid":"import-export-pack-btn",className:"block mt-1.5 text-label font-bold hover:underline underline-offset-2 disabled:opacity-40",children:i("import.pack.export")})]})]})]})]})}function $b({scrollRef:e,navRef:t,preset:n}){const r=k.useRef(null);return k.useEffect(()=>{const s=r.current,i=e.current,a=t.current;return!s||!i||!a?void 0:Ub(s,i,a,n)},[e,t,n]),x.jsx("canvas",{ref:r,className:"map-sky-canvas","aria-hidden":"true"})}function Yb({scrollRef:e,navRef:t,preset:n,getImpacts:r,getFlakes:s,orbSnowRef:i}){const a=k.useRef(null);return k.useEffect(()=>{const o=a.current,l=t.current,u=e.current;if(!o||!l||!u)return;let c=null,f=null;const h=()=>{c=null,f=null},d=new MutationObserver(h);d.observe(u,{childList:!0,subtree:!0}),window.addEventListener("resize",h);const p=zb(o,l,n,()=>{var T,v;c||(c=Array.from(u.querySelectorAll(".lesson-bubble")));const g=f??l.getBoundingClientRect();f=g;const y=[];for(const C of c){const E=C.getBoundingClientRect();if(E.bottom<g.top||E.top>g.bottom)continue;const w=(T=C.closest("[data-node-id]"))==null?void 0:T.getAttribute("data-node-id"),_=w?(v=i==null?void 0:i.current)==null?void 0:v.get(w):void 0;y.push({x:E.left-g.left+E.width/2,y:E.top-g.top+E.height/2,r:E.width/2,..._!==void 0?{snow:_}:{}})}return y},r,s);return()=>{p(),d.disconnect(),window.removeEventListener("resize",h)}},[e,t,n,r,s]),x.jsx("canvas",{ref:a,className:"map-orb-weather-canvas","aria-hidden":"true"})}function Gb({section:e,sectionIndex:t,tree:n,progressMap:r,selectedNodeId:s,dueNodeIds:i,streamingNodeIds:a,onJumpNode:o,physics:l,physicsWeather:u,scrollRef:c,navRef:f,onImpacts:h,onFlakes:d,orbSnowRef:m}){const p=n.filter(z=>z.parentId===e.id).sort((z,ee)=>z.orderIdx-ee.orderIdx),g=p.filter(z=>z.type==="lesson"),y=g.length>0&&g.every(z=>{var ee;return(((ee=r[z.id])==null?void 0:ee.mastery)??0)>=Yx}),T=k.useRef(null),[v,C]=k.useState(268);k.useEffect(()=>{if(!T.current)return;const z=()=>{var ce;const K=((ce=T.current)==null?void 0:ce.clientWidth)??268;C(K>0?K:268)};z();const ee=new ResizeObserver(z);return ee.observe(T.current),()=>ee.disconnect()},[]);const E=nb(p.length,v,e.id),w=E.height,_=110,S=76,I=k.useRef(null),A=k.useRef(new Map),P=k.useRef(0),N=k.useRef(null),j=k.useRef(0),M=p.map(z=>z.id).join(","),L=p.map(z=>{var ee;return(z.type==="exam"?!y:(((ee=r[z.id])==null?void 0:ee.status)??"locked")==="locked")?1:0}).join("");k.useEffect(()=>{var Be,at;if(!l||p.length===0||v<=0)return;const z=T.current,ee=c.current;if(!z||!ee)return;let K;const ce=p[p.length-1];if((ce==null?void 0:ce.type)==="exam"){const G=(at=(Be=z.closest("section"))==null?void 0:Be.nextElementSibling)==null?void 0:at.querySelector(".map-signpost");G&&(K={x:$i(`${e.id}:next`,v),y:G.getBoundingClientRect().top-z.getBoundingClientRect().top})}const fe=bb({nodes:E.nodes.map((G,se)=>{const xe=p[se];return{id:xe.id,x:G.x,y:G.y,isExam:xe.type==="exam",locked:B(xe),spawn:(()=>{const Ee=A.current.get(xe.id);return Ee?yb(Ee,P.current,v):void 0})()}}),width:v,height:E.height+40,weather:u,anchorKnotX:$i(`${e.id}:knot`,v),nextKnot:K});I.current=fe,v1(e.id,fe,z);const re=z.querySelector("[data-next-knot]");re&&(fe.nextKnot?(re.setAttribute("cx",String(fe.nextKnot.x)),re.setAttribute("cy",String(fe.nextKnot.y))):re.setAttribute("opacity","0"));const ne=z.querySelector("[data-exam-rope]");ne&&!fe.nextKnot&&ne.setAttribute("opacity","0");const ge=new Map;for(const G of z.querySelectorAll("[data-node-id]"))G.dataset.nodeId&&ge.set(G.dataset.nodeId,G);const Te=Array.from(z.querySelectorAll("[data-rope]")),Ne=Array.from(z.querySelectorAll("[data-pulse]")),Oe=Array.from(z.querySelectorAll("[data-field]"));let be=!0;const Fe=new IntersectionObserver(G=>{for(const se of G)be=se.isIntersecting},{root:ee,rootMargin:"200px 0px 200px 0px"});Fe.observe(z);const te=520,Re=[];let me=0,je=performance.now();const st=G=>{var lt;me=requestAnimationFrame(st);const se=Math.min(50,G-je);if(je=G,!be)return;fe.step(se);for(const ve of fe.balls){const Le=ge.get(ve.nodeId);Le&&(Le.style.transform=db(ve.body.position.x-ve.layoutX,ve.body.position.y-ve.layoutY,ve.squash,ve.squashAngle)),ve.squash=cb(ve.squash,se),(lt=m.current)==null||lt.set(ve.nodeId,ve.snow)}const xe=ve=>{if(ve==="__anchor")return fe.anchor;if(ve==="__next")return fe.nextKnot??fe.anchor;const Le=fe.ball(ve);if(Le)return{x:Le.body.position.x,y:Le.body.position.y+zt*gn};const ze=p.findIndex(ye=>ye.id===ve),Ye=ze>=0?E.nodes[ze]:void 0;return Ye?{x:Ye.x,y:Ye.y+zt*gn}:{x:0,y:0}};for(let ve=0;ve<fe.links.length&&ve<Te.length;ve++){const Le=fe.links[ve],ze=[xe(Le.from)];for(const Ye of Le.particles)ze.push({x:Ye.position.x,y:Ye.position.y});ze.push(xe(Le.to)),Te[ve].setAttribute("d",ub(ze))}for(let ve=0;ve<fe.balls.length&&ve<Oe.length;ve++){const Le=fe.balls[ve],ze=Oe[ve];Le.field>.03?(ze.setAttribute("cx",String(Le.body.position.x)),ze.setAttribute("cy",String(Le.body.position.y)),ze.setAttribute("r",String(zt+4+Le.field*5)),ze.setAttribute("opacity",String((.3*Le.field).toFixed(3)))):ze.setAttribute("opacity","0")}const Ee=fe.drainImpacts();for(const ve of Ee)Re.push({x:ve.x,y:ve.y,t0:G,s:Math.min(1,ve.speed/14)});for(let ve=Re.length-1;ve>=0;ve--)G-Re[ve].t0>te&&Re.splice(ve,1);for(let ve=0;ve<Ne.length;ve++){const Le=Re[ve],ze=Ne[ve];if(!Le){ze.setAttribute("opacity","0");continue}const Ye=(G-Le.t0)/te;ze.setAttribute("cx",String(Le.x)),ze.setAttribute("cy",String(Le.y)),ze.setAttribute("r",String(6+Ye*(14+Le.s*14))),ze.setAttribute("opacity",String(.55*(1-Ye))),ze.setAttribute("stroke-width",String(2+Le.s*1.5))}const Pe=fe.drainFlakes();if((Ee.length>0||Pe.length>0)&&f.current){const ve=z.getBoundingClientRect(),Le=f.current.getBoundingClientRect(),ze=Ye=>({x:Ye.x+ve.left-Le.left,y:Ye.y+ve.top-Le.top});Ee.length>0&&h(Ee.map(Ye=>({...ze(Ye),speed:Ye.speed}))),Pe.length>0&&d(Pe.map(Ye=>({...ze(Ye),vx:Ye.vx,vy:Ye.vy,amount:Ye.amount})))}};return me=requestAnimationFrame(st),()=>{cancelAnimationFrame(me),Fe.disconnect();for(const G of fe.balls)A.current.set(G.nodeId,{x:G.body.position.x,y:G.body.position.y,vx:G.body.velocity.x,vy:G.body.velocity.y});P.current=v,T1(e.id),fe.dispose(),I.current=null;for(const G of ge.values())G.style.transform=""}},[l,v,M,L,e.id,u]);const B=z=>{var ee;return z?z.type==="exam"?!y:(((ee=r[z.id])==null?void 0:ee.status)??"locked")==="locked":!0},V=(z,ee)=>{if(!(!I.current||z.button!==0||B(p.find(fe=>fe.id===ee))||!T.current)){try{z.currentTarget.setPointerCapture(z.pointerId)}catch{}j.current=0,N.current={track:{startX:z.clientX,startY:z.clientY},id:z.pointerId,dragging:!1,nodeId:ee}}},F=z=>{const ee=N.current,K=I.current;if(!ee||!K||z.pointerId!==ee.id)return;const ce=T.current;if(!ce||(!ee.dragging&&cc(ee.track,z.clientX,z.clientY)==="drag"&&(ee.dragging=!0,z.currentTarget.style.zIndex="40",K.beginDrag(ee.nodeId,z.clientX-ce.getBoundingClientRect().left,z.clientY-ce.getBoundingClientRect().top)),!ee.dragging))return;const fe=ce.getBoundingClientRect();K.moveDrag(z.clientX-fe.left,z.clientY-fe.top)},q=z=>{var K;const ee=N.current;if(!(!ee||z.pointerId!==ee.id)){if((K=I.current)==null||K.endDrag(),z.currentTarget.style.zIndex="",cc(ee.track,z.clientX,z.clientY)==="drag")j.current=Date.now()+300;else{const ce=p.find(fe=>fe.id===ee.nodeId);ce&&Date.now()>=j.current&&!B(ce)&&(So(z.clientX,z.clientY,ce.id),o(ce.id))}N.current=null}},R=z=>{const ee=p[z],K=ee?r[ee.id]:void 0,ce=(K==null?void 0:K.status)==="mastered"||(K==null?void 0:K.status)==="in_progress"||(K==null?void 0:K.status)==="available";return{stroke:ce?"var(--brand)":"var(--ink-faint)",strokeWidth:ce?4:2.5,strokeOpacity:ce?.6:.5,strokeDasharray:ce?"none":"3 7"}},$=E.nodes[0]?{x:$i(`${e.id}:knot`,v),y:Cs}:{x:v/2,y:Cs},X=p[p.length-1],D=(X==null?void 0:X.type)==="exam",Z=E.nodes[E.nodes.length-1],le=D&&Z?{x:$i(`${e.id}:next`,v),y:w+24}:void 0;return x.jsxs("section",{"data-testid":`map-section-${e.id.slice(0,8)}`,className:"py-3 px-2",children:[x.jsxs("div",{className:"map-signpost flex items-center gap-2 mb-3 px-2.5 py-1.5 rounded-lg shadow-sm",children:[x.jsx("span",{className:"w-6 h-6 rounded-full bg-gold text-neutral-900 text-caption font-extrabold flex items-center justify-center shrink-0 ring-2 ring-gold/40 shadow-sm",children:t+1}),x.jsx("span",{className:"text-label font-bold text-white truncate flex-1 drop-shadow-[0_1px_2px_rgba(0,0,0,0.7)]",children:e.title})]}),x.jsxs("div",{ref:T,className:"relative",style:{minHeight:w},children:[x.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",style:{height:w,overflow:"visible"},children:l?x.jsxs(x.Fragment,{children:[E.nodes[0]&&x.jsx("circle",{cx:$.x,cy:$.y,r:3.5,fill:"#ffc800",opacity:.9}),E.nodes[0]&&x.jsx("path",{"data-rope":0,d:`M ${$.x} ${$.y} L ${E.nodes[0].x} ${E.nodes[0].y+zt*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:R(0)}),E.segments.map((z,ee)=>x.jsx("path",{"data-rope":ee+1,d:`M ${z.from.x} ${z.from.y+zt*gn} L ${z.to.x} ${z.to.y+zt*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:R(z.index)},z.index)),le&&Z&&x.jsxs(x.Fragment,{children:[x.jsx("path",{"data-rope":E.segments.length+1,"data-exam-rope":!0,d:`M ${le.x} ${le.y} L ${Z.x} ${Z.y+zt*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:R(p.length-1)}),x.jsx("circle",{"data-next-knot":!0,cx:le.x,cy:le.y,r:3.5,fill:"#ffc800",opacity:.9})]}),Array.from({length:8},(z,ee)=>x.jsx("circle",{"data-pulse":ee,cx:0,cy:0,r:0,fill:"none",stroke:"white",opacity:0},ee)),p.map((z,ee)=>x.jsx("circle",{"data-field":ee,cx:0,cy:0,r:0,fill:"none",stroke:"#1cb0f6",strokeWidth:2,opacity:0},`f-${z.id}`))]}):E.segments.map(z=>{const ee=Kb(p[z.index],r);return x.jsx("path",{d:rb(z),stroke:ee?"var(--brand)":"var(--ink-faint)",strokeWidth:ee?4:2.5,strokeOpacity:ee?.6:.5,fill:"none",strokeLinecap:"round",strokeDasharray:ee?"none":"3 7",style:ee?{pathLength:1,animation:"path-draw 600ms var(--ease-out-expo)"}:void 0},z.index)})}),p.map((z,ee)=>{const K=E.nodes[ee];if(!K)return null;const ce=No(z.id),fe=`${ce%40/10}s`,re=`${5+ce%30/10}s`;return x.jsx("div",{"data-node-id":z.id,"data-noswipe":"",className:l?`absolute hover:z-30 will-change-transform ${B(z)?"cursor-not-allowed":"cursor-grab active:cursor-grabbing"}`:"absolute balloon-bob hover:z-30",style:{left:K.x-_/2,top:K.y-S/2+10,width:_,...l?{touchAction:"pan-y"}:{"--bob-delay":fe,"--bob-duration":re}},onPointerDown:l?ne=>V(ne,z.id):void 0,onPointerMove:l?F:void 0,onPointerUp:l?q:void 0,onPointerCancel:l?q:void 0,children:x.jsx(Xb,{lesson:z,progress:r[z.id],isSelected:z.id===s,isDue:i.has(z.id),isStreaming:a.includes(z.id),chapterLessonsMastered:y,onClick:()=>{Date.now()<j.current||(So(null,null,z.id),o(z.id))}})},z.id)})]})]})}function Kb(e,t){const n=e?t[e.id]:void 0;return(n==null?void 0:n.status)==="mastered"||(n==null?void 0:n.status)==="in_progress"||(n==null?void 0:n.status)==="available"}function Xb({lesson:e,progress:t,isSelected:n,isDue:r,isStreaming:s,chapterLessonsMastered:i,onClick:a}){const o=Ke(),l=(t==null?void 0:t.status)??"locked",u=(t==null?void 0:t.crownLevel)??0,c=e.type==="exam",f=Math.min(3,u),h=c?!i:l==="locked",d=c&&h,m=!c&&(l==="in_progress"||l==="mastered"),p=l==="mastered"?100:l==="in_progress"?Math.round(((t==null?void 0:t.mastery)??0)*100):0;return x.jsxs("div",{className:"group relative flex flex-col items-center w-full",children:[x.jsxs("button",{onClick:()=>!h&&a(),disabled:h,"data-testid":`${c?"exam-node":"map-node"}-${e.id.slice(0,8)}`,className:`group relative w-14 h-14 flex items-center justify-center text-2xl rounded-full transition-all duration-200 ${c?d?"lesson-bubble exam-bubble-locked":Jb(u>0):Qb(l)} ${h?"cursor-not-allowed":"cursor-pointer hover:scale-105"} ${n?"ring-4 ring-accent ring-offset-2 ring-offset-neutral-50 dark:ring-offset-neutral-950":""}`,title:void 0,"data-tooltip":d?`🔒 ${e.title}${o("node.locked.chapterHint")}`:c?`🎯 ${e.title}`:h?`🔒 ${e.title}`:r?`📖 ${e.title}${o("node.due.hint")}`:e.title,children:[s&&x.jsx(Nh,{className:"absolute -top-1.5 -right-1.5 z-10 w-4 h-4 text-accent bg-surface-0 rounded-full p-0.5 animate-spin shadow-pop pointer-events-none","aria-label":o("thread.streamingBadge"),"data-testid":`node-streaming-${e.id.slice(0,8)}`}),m&&x.jsxs("svg",{className:"absolute inset-0 w-full h-full -rotate-90 pointer-events-none",viewBox:"0 0 56 56","aria-hidden":"true",children:[x.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:"rgb(255 255 255 / 0.2)",strokeWidth:"2.5"}),x.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:l==="mastered"?"#ffc800":"white",strokeWidth:"2.5",strokeLinecap:"round",strokeDasharray:`${p/100*157} 157`,className:"transition-all duration-500"})]}),c?d?x.jsx("span",{"aria-label":"exam-locked",className:"relative z-10 opacity-60",children:"🔒"}):x.jsx(zx,{"aria-label":"exam",className:"relative z-10 w-6 h-6 text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.4)]",strokeWidth:2.5}):h?x.jsx("span",{"aria-label":"locked",className:"relative z-10 opacity-50",children:"🔒"}):l==="mastered"?x.jsx("span",{"aria-label":"mastered",className:"relative z-10 drop-shadow-lg crown-sparkle",children:"👑"}):l==="in_progress"?x.jsx(Cn,{"aria-label":"in-progress",className:"relative z-10 w-6 h-6 text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.4)]",strokeWidth:2.5}):x.jsx("span",{"aria-label":"available",className:"relative z-10 drop-shadow",children:"⭐"}),r&&!h&&!c&&x.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-review text-white text-caption flex items-center justify-center font-bold border-2 border-neutral-50 dark:border-neutral-950",children:"!"})]}),c&&x.jsx("div",{className:"flex gap-0.5 mt-1","data-testid":`map-stars-${e.id.slice(0,8)}`,children:[0,1,2].map(g=>x.jsx("span",{className:`text-caption ${g<f?"text-gold":"text-white/25"}`,children:"★"},g))}),n&&x.jsx("div",{className:"mt-1 text-caption text-center leading-tight max-w-[120px] font-bold px-1.5 py-0.5 rounded-md bg-brand/90 text-white shadow-sm",children:e.title})]})}function Qb(e){switch(e){case"locked":return"lesson-bubble lesson-bubble-locked";case"available":return"lesson-bubble lesson-bubble-available";case"in_progress":return"lesson-bubble lesson-bubble-in-progress";case"mastered":return"lesson-bubble lesson-bubble-mastered";default:return"lesson-bubble lesson-bubble-locked"}}function Jb(e){return e?"lesson-bubble exam-bubble-passed":"lesson-bubble exam-bubble"}function Zb({available:e,current:t,onChange:n}){const r=Ke(),[s,i]=k.useState(!1),a={en:"English","zh-CN":"中文","zh-TW":"繁體",ja:"日本語",ko:"한국어",fr:"Français",de:"Deutsch",es:"Español","pt-BR":"Português",ru:"Русский",it:"Italiano",ar:"العربية",hi:"हिन्दी",tr:"Türkçe",pl:"Polski",nl:"Nederlands",id:"Indonesia",vi:"Tiếng Việt",th:"ไทย",sv:"Svenska",fi:"Suomi"},o=t?a[t]??t:r("lang.original");return x.jsxs("div",{className:"relative shrink-0",children:[x.jsxs("button",{onClick:()=>i(!s),className:"flex items-center gap-1 px-1.5 py-0.5 rounded-md text-caption font-bold text-white/80 hover:text-white hover:bg-white/10 transition-colors","data-testid":"lang-switcher-btn",children:[x.jsx(bx,{className:"w-3 h-3"}),o]}),s&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>i(!1)}),x.jsxs("div",{className:"absolute top-full right-0 mt-1 z-50 bg-surface-0 rounded-lg shadow-elevated p-1 min-w-[100px] max-h-48 overflow-y-auto",children:[x.jsx("button",{"data-testid":"lang-option-original",onClick:()=>{n(null),i(!1)},className:`w-full text-left px-2 py-1 rounded-md text-caption font-bold transition-colors ${t===null?"bg-brand/15 text-brand":"text-ink-muted hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:r("lang.original")}),e.map(l=>x.jsx("button",{"data-testid":`lang-option-${l}`,onClick:()=>{n(l),i(!1)},className:`w-full text-left px-2 py-1 rounded-md text-caption font-bold transition-colors ${t===l?"bg-brand/15 text-brand":"text-ink-muted hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:a[l]??l},l))]})]})]})}const ey=500,On=8;function ty(){const[e,t]=k.useState(null),[n,r]=k.useState({mode:"cursor",x:0,y:0}),[s,i]=k.useState({w:0,h:0}),a=k.useRef(null),o=k.useCallback(()=>window.matchMedia("(pointer: coarse)").matches,[]),l=k.useCallback(g=>{o()||r(y=>y.mode==="cursor"?{...y,x:g.clientX,y:g.clientY}:y)},[o]),u=k.useCallback(g=>{var v;if(o())return;const y=(v=g.target)==null?void 0:v.closest("[data-tooltip]"),T=y==null?void 0:y.getAttribute("data-tooltip");if(T){t(T),r({mode:"cursor",x:g.clientX,y:g.clientY});return}t(null)},[o]),c=k.useCallback(g=>{var T,v;if(o())return;((v=(T=g.target)==null?void 0:T.closest)==null?void 0:v.call(T,"[data-tooltip]"))&&t(null)},[o]);if(k.useEffect(()=>(document.addEventListener("mousemove",l,{passive:!0}),document.addEventListener("mouseover",u,{passive:!0}),document.addEventListener("mouseout",c,{passive:!0}),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseover",u),document.removeEventListener("mouseout",c)}),[l,u,c]),k.useEffect(()=>{let g=null;const y=()=>{g&&(clearTimeout(g),g=null)},T=w=>{var A;if(!o()||w.touches.length!==1)return y();const _=(A=w.target)==null?void 0:A.closest("[data-tooltip]"),S=_==null?void 0:_.getAttribute("data-tooltip");if(!S||!_)return y();const I=_;y(),g=setTimeout(()=>{I.isConnected&&(t(S),r({mode:"rect",x:0,y:0,rect:I.getBoundingClientRect()}))},ey)},v=()=>{y(),t(w=>w&&null)},C=()=>y(),E=()=>{y(),t(null)};return document.addEventListener("touchstart",T,{passive:!0}),document.addEventListener("touchend",v,{passive:!0}),document.addEventListener("touchmove",C,{passive:!0}),document.addEventListener("touchcancel",E,{passive:!0}),()=>{y(),document.removeEventListener("touchstart",T),document.removeEventListener("touchend",v),document.removeEventListener("touchmove",C),document.removeEventListener("touchcancel",E)}},[o]),k.useLayoutEffect(()=>{a.current&&e&&i({w:a.current.offsetWidth,h:a.current.offsetHeight})},[e]),!e)return null;const f=window.innerWidth,h=window.innerHeight;let d,m,p;if(n.mode==="rect"&&n.rect){const g=n.rect;d=g.left+g.width/2-s.w/2,m=g.top-s.h-6,p="none",m<On&&(m=g.bottom+6)}else d=n.x,m=n.y-6,p="translate(0, -100%)";return d=Math.min(Math.max(d,On),Math.max(On,f-s.w-On)),m=Math.min(Math.max(m,On),Math.max(On,h-s.h-On)),jh.createPortal(x.jsx("div",{ref:a,style:{position:"fixed",left:d,top:m,transform:p,zIndex:99999,pointerEvents:"none",visibility:s.w?"visible":"hidden",background:"rgb(var(--surface-0-rgb) / 0.92)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",color:"var(--ink)",border:"1px solid rgb(var(--border-rgb) / 0.5)",fontSize:"0.875rem",fontWeight:600,lineHeight:1.4,padding:"4px 10px",borderRadius:"8px",maxWidth:"260px",wordBreak:"break-word",boxShadow:"0 4px 12px rgb(var(--shadow-rgb) / 0.15)",whiteSpace:"normal"},children:e}),document.body)}function j4(){}function xc(e){const t=[],n=String(e||"");let r=n.indexOf(","),s=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const a=n.slice(s,r).trim();(a||!i)&&t.push(a),s=r+1,r=n.indexOf(",",s)}return t}function Jh(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ny=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ry=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iy={};function bc(e,t){return(iy.jsx?ry:ny).test(e)}const sy=/[ \t\n\f\r]/g;function ay(e){return typeof e=="object"?e.type==="text"?yc(e.value):!1:yc(e)}function yc(e){return e.replace(sy,"")===""}class Ni{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ni.prototype.normal={};Ni.prototype.property={};Ni.prototype.space=void 0;function Zh(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Ni(n,r,t)}function Ei(e){return e.toLowerCase()}class Pt{constructor(t,n){this.attribute=n,this.property=t}}Pt.prototype.attribute="";Pt.prototype.booleanish=!1;Pt.prototype.boolean=!1;Pt.prototype.commaOrSpaceSeparated=!1;Pt.prototype.commaSeparated=!1;Pt.prototype.defined=!1;Pt.prototype.mustUseProperty=!1;Pt.prototype.number=!1;Pt.prototype.overloadedBoolean=!1;Pt.prototype.property="";Pt.prototype.spaceSeparated=!1;Pt.prototype.space=void 0;let oy=0;const Ie=rr(),ft=rr(),Ro=rr(),ue=rr(),et=rr(),Kn=rr(),Ft=rr();function rr(){return 2**++oy}const Lo=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:ft,commaOrSpaceSeparated:Ft,commaSeparated:Kn,number:ue,overloadedBoolean:Ro,spaceSeparated:et},Symbol.toStringTag,{value:"Module"})),Ma=Object.keys(Lo);class Dl extends Pt{constructor(t,n,r,s){let i=-1;if(super(t,n),Ec(this,"space",s),typeof r=="number")for(;++i<Ma.length;){const a=Ma[i];Ec(this,Ma[i],(r&Lo[a])===Lo[a])}}}Dl.prototype.defined=!0;function Ec(e,t,n){n&&(e[t]=n)}function Ir(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Dl(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Ei(r)]=r,n[Ei(i.attribute)]=r}return new Ni(t,n,e.space)}const em=Ir({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:ue,ariaColIndex:ue,ariaColSpan:ue,ariaControls:et,ariaCurrent:null,ariaDescribedBy:et,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:et,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:et,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:et,ariaLevel:ue,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:et,ariaPlaceholder:null,ariaPosInSet:ue,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:et,ariaRowCount:ue,ariaRowIndex:ue,ariaRowSpan:ue,ariaSelected:ft,ariaSetSize:ue,ariaSort:null,ariaValueMax:ue,ariaValueMin:ue,ariaValueNow:ue,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tm(e,t){return t in e?e[t]:t}function nm(e,t){return tm(e,t.toLowerCase())}const ly=Ir({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Kn,acceptCharset:et,accessKey:et,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alpha:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:et,autoFocus:Ie,autoPlay:Ie,blocking:et,capture:null,charSet:null,checked:Ie,cite:null,className:et,closedBy:null,colorSpace:null,cols:ue,colSpan:ue,command:null,commandFor:null,content:null,contentEditable:ft,controls:Ie,controlsList:et,coords:ue|Kn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:Ro,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:et,height:ue,hidden:Ro,high:ue,href:null,hrefLang:null,htmlFor:et,httpEquiv:et,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:et,itemRef:et,itemScope:Ie,itemType:et,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:ue,manifest:null,max:null,maxLength:ue,media:null,method:null,min:null,minLength:ue,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:ue,pattern:null,ping:et,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:et,required:Ie,reversed:Ie,rows:ue,rowSpan:ue,sandbox:et,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootCustomElementRegistry:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shadowRootSerializable:Ie,shape:null,size:ue,sizes:null,slot:null,span:ue,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ue,step:null,style:null,tabIndex:ue,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:ft,width:ue,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:et,axis:null,background:null,bgColor:null,border:ue,borderColor:null,bottomMargin:ue,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:ue,leftMargin:ue,link:null,longDesc:null,lowSrc:null,marginHeight:ue,marginWidth:ue,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:ue,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:ue,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ue,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ie,disablePictureInPicture:Ie,disableRemotePlayback:Ie,exportParts:Kn,part:et,prefix:null,property:null,results:ue,security:null,unselectable:null},space:"html",transform:nm}),uy=Ir({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ft,accentHeight:ue,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ue,amplitude:ue,arabicForm:null,ascent:ue,attributeName:null,attributeType:null,azimuth:ue,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ue,by:null,calcMode:null,capHeight:ue,className:et,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ue,diffuseConstant:ue,direction:null,display:null,dur:null,divisor:ue,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:ue,enableBackground:null,end:null,event:null,exponent:ue,externalResourcesRequired:null,fill:null,fillOpacity:ue,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Kn,g2:Kn,glyphName:Kn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ue,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ue,horizOriginX:ue,horizOriginY:ue,id:null,ideographic:ue,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ue,k:ue,k1:ue,k2:ue,k3:ue,k4:ue,kernelMatrix:Ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ue,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ue,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ue,overlineThickness:ue,paintOrder:null,panose1:null,path:null,pathLength:ue,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:et,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ue,pointsAtY:ue,pointsAtZ:ue,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ft,rev:Ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ft,requiredFeatures:Ft,requiredFonts:Ft,requiredFormats:Ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ue,specularExponent:ue,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ue,strikethroughThickness:ue,string:null,stroke:null,strokeDashArray:Ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ue,strokeOpacity:ue,strokeWidth:null,style:null,surfaceScale:ue,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ft,tabIndex:ue,tableValues:null,target:null,targetX:ue,targetY:ue,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ue,underlineThickness:ue,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ue,values:null,vAlphabetic:ue,vMathematical:ue,vectorEffect:null,vHanging:ue,vIdeographic:ue,version:null,vertAdvY:ue,vertOriginX:ue,vertOriginY:ue,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ue,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tm}),rm=Ir({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),im=Ir({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:nm}),sm=Ir({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),cy={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},dy=/[A-Z]/g,vc=/-[a-z]/g,fy=/^data[-\w.:]+$/i;function Xs(e,t){const n=Ei(t);let r=t,s=Pt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&fy.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(vc,my);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!vc.test(i)){let a=i.replace(dy,hy);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Dl}return new s(r,t)}function hy(e){return"-"+e.toLowerCase()}function my(e){return e.charAt(1).toUpperCase()}const Ri=Zh([em,ly,rm,im,sm],"html"),Nn=Zh([em,uy,rm,im,sm],"svg");function Tc(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function am(e){return e.join(" ").trim()}var dr={},Da,kc;function py(){if(kc)return Da;kc=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
436
+ */var ib=ds.exports,uc;function sb(){return uc||(uc=1,(function(e,t){(function(r,s){e.exports=s()})(ib,function(){return(function(n){var r={};function s(i){if(r[i])return r[i].exports;var a=r[i]={i,l:!1,exports:{}};return n[i].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=n,s.c=r,s.d=function(i,a,o){s.o(i,a)||Object.defineProperty(i,a,{enumerable:!0,get:o})},s.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},s.t=function(i,a){if(a&1&&(i=s(i)),a&8||a&4&&typeof i=="object"&&i&&i.__esModule)return i;var o=Object.create(null);if(s.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:i}),a&2&&typeof i!="string")for(var l in i)s.d(o,l,(function(u){return i[u]}).bind(null,l));return o},s.n=function(i){var a=i&&i.__esModule?function(){return i.default}:function(){return i};return s.d(a,"a",a),a},s.o=function(i,a){return Object.prototype.hasOwnProperty.call(i,a)},s.p="",s(s.s=20)})([(function(n,r){var s={};n.exports=s,(function(){s._baseDelta=1e3/60,s._nextId=0,s._seed=0,s._nowStartTime=+new Date,s._warnedOnce={},s._decomp=null,s.extend=function(a,o){var l,u;typeof o=="boolean"?(l=2,u=o):(l=1,u=!0);for(var c=l;c<arguments.length;c++){var f=arguments[c];if(f)for(var h in f)u&&f[h]&&f[h].constructor===Object&&(!a[h]||a[h].constructor===Object)?(a[h]=a[h]||{},s.extend(a[h],u,f[h])):a[h]=f[h]}return a},s.clone=function(a,o){return s.extend({},o,a)},s.keys=function(a){if(Object.keys)return Object.keys(a);var o=[];for(var l in a)o.push(l);return o},s.values=function(a){var o=[];if(Object.keys){for(var l=Object.keys(a),u=0;u<l.length;u++)o.push(a[l[u]]);return o}for(var c in a)o.push(a[c]);return o},s.get=function(a,o,l,u){o=o.split(".").slice(l,u);for(var c=0;c<o.length;c+=1)a=a[o[c]];return a},s.set=function(a,o,l,u,c){var f=o.split(".").slice(u,c);return s.get(a,o,0,-1)[f[f.length-1]]=l,l},s.shuffle=function(a){for(var o=a.length-1;o>0;o--){var l=Math.floor(s.random()*(o+1)),u=a[o];a[o]=a[l],a[l]=u}return a},s.choose=function(a){return a[Math.floor(s.random()*a.length)]},s.isElement=function(a){return typeof HTMLElement<"u"?a instanceof HTMLElement:!!(a&&a.nodeType&&a.nodeName)},s.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"},s.isFunction=function(a){return typeof a=="function"},s.isPlainObject=function(a){return typeof a=="object"&&a.constructor===Object},s.isString=function(a){return toString.call(a)==="[object String]"},s.clamp=function(a,o,l){return a<o?o:a>l?l:a},s.sign=function(a){return a<0?-1:1},s.now=function(){if(typeof window<"u"&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-s._nowStartTime},s.random=function(a,o){return a=typeof a<"u"?a:0,o=typeof o<"u"?o:1,a+i()*(o-a)};var i=function(){return s._seed=(s._seed*9301+49297)%233280,s._seed/233280};s.colorToNumber=function(a){return a=a.replace("#",""),a.length==3&&(a=a.charAt(0)+a.charAt(0)+a.charAt(1)+a.charAt(1)+a.charAt(2)+a.charAt(2)),parseInt(a,16)},s.logLevel=1,s.log=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.info=function(){console&&s.logLevel>0&&s.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warn=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warnOnce=function(){var a=Array.prototype.slice.call(arguments).join(" ");s._warnedOnce[a]||(s.warn(a),s._warnedOnce[a]=!0)},s.deprecated=function(a,o,l){a[o]=s.chain(function(){s.warnOnce("🔅 deprecated 🔅",l)},a[o])},s.nextId=function(){return s._nextId++},s.indexOf=function(a,o){if(a.indexOf)return a.indexOf(o);for(var l=0;l<a.length;l++)if(a[l]===o)return l;return-1},s.map=function(a,o){if(a.map)return a.map(o);for(var l=[],u=0;u<a.length;u+=1)l.push(o(a[u]));return l},s.topologicalSort=function(a){var o=[],l=[],u=[];for(var c in a)!l[c]&&!u[c]&&s._topologicalSort(c,l,u,a,o);return o},s._topologicalSort=function(a,o,l,u,c){var f=u[a]||[];l[a]=!0;for(var h=0;h<f.length;h+=1){var d=f[h];l[d]||o[d]||s._topologicalSort(d,o,l,u,c)}l[a]=!1,o[a]=!0,c.push(a)},s.chain=function(){for(var a=[],o=0;o<arguments.length;o+=1){var l=arguments[o];l._chained?a.push.apply(a,l._chained):a.push(l)}var u=function(){for(var c,f=new Array(arguments.length),h=0,d=arguments.length;h<d;h++)f[h]=arguments[h];for(h=0;h<a.length;h+=1){var m=a[h].apply(c,f);typeof m<"u"&&(c=m)}return c};return u._chained=a,u},s.chainPathBefore=function(a,o,l){return s.set(a,o,s.chain(l,s.get(a,o)))},s.chainPathAfter=function(a,o,l){return s.set(a,o,s.chain(s.get(a,o),l))},s.setDecomp=function(a){s._decomp=a},s.getDecomp=function(){var a=s._decomp;try{!a&&typeof window<"u"&&(a=window.decomp),!a&&typeof Wu<"u"&&(a=Wu.decomp)}catch{a=null}return a}})()}),(function(n,r){var s={};n.exports=s,(function(){s.create=function(i){var a={min:{x:0,y:0},max:{x:0,y:0}};return i&&s.update(a,i),a},s.update=function(i,a,o){i.min.x=1/0,i.max.x=-1/0,i.min.y=1/0,i.max.y=-1/0;for(var l=0;l<a.length;l++){var u=a[l];u.x>i.max.x&&(i.max.x=u.x),u.x<i.min.x&&(i.min.x=u.x),u.y>i.max.y&&(i.max.y=u.y),u.y<i.min.y&&(i.min.y=u.y)}o&&(o.x>0?i.max.x+=o.x:i.min.x+=o.x,o.y>0?i.max.y+=o.y:i.min.y+=o.y)},s.contains=function(i,a){return a.x>=i.min.x&&a.x<=i.max.x&&a.y>=i.min.y&&a.y<=i.max.y},s.overlaps=function(i,a){return i.min.x<=a.max.x&&i.max.x>=a.min.x&&i.max.y>=a.min.y&&i.min.y<=a.max.y},s.translate=function(i,a){i.min.x+=a.x,i.max.x+=a.x,i.min.y+=a.y,i.max.y+=a.y},s.shift=function(i,a){var o=i.max.x-i.min.x,l=i.max.y-i.min.y;i.min.x=a.x,i.max.x=a.x+o,i.min.y=a.y,i.max.y=a.y+l}})()}),(function(n,r){var s={};n.exports=s,(function(){s.create=function(i,a){return{x:i||0,y:a||0}},s.clone=function(i){return{x:i.x,y:i.y}},s.magnitude=function(i){return Math.sqrt(i.x*i.x+i.y*i.y)},s.magnitudeSquared=function(i){return i.x*i.x+i.y*i.y},s.rotate=function(i,a,o){var l=Math.cos(a),u=Math.sin(a);o||(o={});var c=i.x*l-i.y*u;return o.y=i.x*u+i.y*l,o.x=c,o},s.rotateAbout=function(i,a,o,l){var u=Math.cos(a),c=Math.sin(a);l||(l={});var f=o.x+((i.x-o.x)*u-(i.y-o.y)*c);return l.y=o.y+((i.x-o.x)*c+(i.y-o.y)*u),l.x=f,l},s.normalise=function(i){var a=s.magnitude(i);return a===0?{x:0,y:0}:{x:i.x/a,y:i.y/a}},s.dot=function(i,a){return i.x*a.x+i.y*a.y},s.cross=function(i,a){return i.x*a.y-i.y*a.x},s.cross3=function(i,a,o){return(a.x-i.x)*(o.y-i.y)-(a.y-i.y)*(o.x-i.x)},s.add=function(i,a,o){return o||(o={}),o.x=i.x+a.x,o.y=i.y+a.y,o},s.sub=function(i,a,o){return o||(o={}),o.x=i.x-a.x,o.y=i.y-a.y,o},s.mult=function(i,a){return{x:i.x*a,y:i.y*a}},s.div=function(i,a){return{x:i.x/a,y:i.y/a}},s.perp=function(i,a){return a=a===!0?-1:1,{x:a*-i.y,y:a*i.x}},s.neg=function(i){return{x:-i.x,y:-i.y}},s.angle=function(i,a){return Math.atan2(a.y-i.y,a.x-i.x)},s._temp=[s.create(),s.create(),s.create(),s.create(),s.create(),s.create()]})()}),(function(n,r,s){var i={};n.exports=i;var a=s(2),o=s(0);(function(){i.create=function(l,u){for(var c=[],f=0;f<l.length;f++){var h=l[f],d={x:h.x,y:h.y,index:f,body:u,isInternal:!1};c.push(d)}return c},i.fromPath=function(l,u){var c=/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig,f=[];return l.replace(c,function(h,d,m){f.push({x:parseFloat(d),y:parseFloat(m)})}),i.create(f,u)},i.centre=function(l){for(var u=i.area(l,!0),c={x:0,y:0},f,h,d,m=0;m<l.length;m++)d=(m+1)%l.length,f=a.cross(l[m],l[d]),h=a.mult(a.add(l[m],l[d]),f),c=a.add(c,h);return a.div(c,6*u)},i.mean=function(l){for(var u={x:0,y:0},c=0;c<l.length;c++)u.x+=l[c].x,u.y+=l[c].y;return a.div(u,l.length)},i.area=function(l,u){for(var c=0,f=l.length-1,h=0;h<l.length;h++)c+=(l[f].x-l[h].x)*(l[f].y+l[h].y),f=h;return u?c/2:Math.abs(c)/2},i.inertia=function(l,u){for(var c=0,f=0,h=l,d,m,p=0;p<h.length;p++)m=(p+1)%h.length,d=Math.abs(a.cross(h[m],h[p])),c+=d*(a.dot(h[m],h[m])+a.dot(h[m],h[p])+a.dot(h[p],h[p])),f+=d;return u/6*(c/f)},i.translate=function(l,u,c){c=typeof c<"u"?c:1;var f=l.length,h=u.x*c,d=u.y*c,m;for(m=0;m<f;m++)l[m].x+=h,l[m].y+=d;return l},i.rotate=function(l,u,c){if(u!==0){var f=Math.cos(u),h=Math.sin(u),d=c.x,m=c.y,p=l.length,g,y,T,v;for(v=0;v<p;v++)g=l[v],y=g.x-d,T=g.y-m,g.x=d+(y*f-T*h),g.y=m+(y*h+T*f);return l}},i.contains=function(l,u){for(var c=u.x,f=u.y,h=l.length,d=l[h-1],m,p=0;p<h;p++){if(m=l[p],(c-d.x)*(m.y-d.y)+(f-d.y)*(d.x-m.x)>0)return!1;d=m}return!0},i.scale=function(l,u,c,f){if(u===1&&c===1)return l;f=f||i.centre(l);for(var h,d,m=0;m<l.length;m++)h=l[m],d=a.sub(h,f),l[m].x=f.x+d.x*u,l[m].y=f.y+d.y*c;return l},i.chamfer=function(l,u,c,f,h){typeof u=="number"?u=[u]:u=u||[8],c=typeof c<"u"?c:-1,f=f||2,h=h||14;for(var d=[],m=0;m<l.length;m++){var p=l[m-1>=0?m-1:l.length-1],g=l[m],y=l[(m+1)%l.length],T=u[m<u.length?m:u.length-1];if(T===0){d.push(g);continue}var v=a.normalise({x:g.y-p.y,y:p.x-g.x}),C=a.normalise({x:y.y-g.y,y:g.x-y.x}),E=Math.sqrt(2*Math.pow(T,2)),w=a.mult(o.clone(v),T),_=a.normalise(a.mult(a.add(v,C),.5)),S=a.sub(g,a.mult(_,E)),I=c;c===-1&&(I=Math.pow(T,.32)*1.75),I=o.clamp(I,f,h),I%2===1&&(I+=1);for(var A=Math.acos(a.dot(v,C)),P=A/I,N=0;N<I;N++)d.push(a.add(a.rotate(w,P*N),S))}return d},i.clockwiseSort=function(l){var u=i.mean(l);return l.sort(function(c,f){return a.angle(u,c)-a.angle(u,f)}),l},i.isConvex=function(l){var u=0,c=l.length,f,h,d,m;if(c<3)return null;for(f=0;f<c;f++)if(h=(f+1)%c,d=(f+2)%c,m=(l[h].x-l[f].x)*(l[d].y-l[h].y),m-=(l[h].y-l[f].y)*(l[d].x-l[h].x),m<0?u|=1:m>0&&(u|=2),u===3)return!1;return u!==0?!0:null},i.hull=function(l){var u=[],c=[],f,h;for(l=l.slice(0),l.sort(function(d,m){var p=d.x-m.x;return p!==0?p:d.y-m.y}),h=0;h<l.length;h+=1){for(f=l[h];c.length>=2&&a.cross3(c[c.length-2],c[c.length-1],f)<=0;)c.pop();c.push(f)}for(h=l.length-1;h>=0;h-=1){for(f=l[h];u.length>=2&&a.cross3(u[u.length-2],u[u.length-1],f)<=0;)u.pop();u.push(f)}return u.pop(),c.pop(),u.concat(c)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(2),l=s(7),u=s(0),c=s(1),f=s(11);(function(){i._timeCorrection=!0,i._inertiaScale=4,i._nextCollidingGroupId=1,i._nextNonCollidingGroupId=-1,i._nextCategory=1,i._baseDelta=1e3/60,i.create=function(d){var m={id:u.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:a.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,strokeStyle:null,fillStyle:null,lineWidth:null,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0}},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,deltaTime:16.666666666666668,_original:null},p=u.extend(m,d);return h(p,d),p},i.nextGroup=function(d){return d?i._nextNonCollidingGroupId--:i._nextCollidingGroupId++},i.nextCategory=function(){return i._nextCategory=i._nextCategory<<1,i._nextCategory};var h=function(d,m){m=m||{},i.set(d,{bounds:d.bounds||c.create(d.vertices),positionPrev:d.positionPrev||o.clone(d.position),anglePrev:d.anglePrev||d.angle,vertices:d.vertices,parts:d.parts||[d],isStatic:d.isStatic,isSleeping:d.isSleeping,parent:d.parent||d}),a.rotate(d.vertices,d.angle,d.position),f.rotate(d.axes,d.angle),c.update(d.bounds,d.vertices,d.velocity),i.set(d,{axes:m.axes||d.axes,area:m.area||d.area,mass:m.mass||d.mass,inertia:m.inertia||d.inertia});var p=d.isStatic?"#14151f":u.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),g=d.isStatic?"#555":"#ccc",y=d.isStatic&&d.render.fillStyle===null?1:0;d.render.fillStyle=d.render.fillStyle||p,d.render.strokeStyle=d.render.strokeStyle||g,d.render.lineWidth=d.render.lineWidth||y,d.render.sprite.xOffset+=-(d.bounds.min.x-d.position.x)/(d.bounds.max.x-d.bounds.min.x),d.render.sprite.yOffset+=-(d.bounds.min.y-d.position.y)/(d.bounds.max.y-d.bounds.min.y)};i.set=function(d,m,p){var g;typeof m=="string"&&(g=m,m={},m[g]=p);for(g in m)if(Object.prototype.hasOwnProperty.call(m,g))switch(p=m[g],g){case"isStatic":i.setStatic(d,p);break;case"isSleeping":l.set(d,p);break;case"mass":i.setMass(d,p);break;case"density":i.setDensity(d,p);break;case"inertia":i.setInertia(d,p);break;case"vertices":i.setVertices(d,p);break;case"position":i.setPosition(d,p);break;case"angle":i.setAngle(d,p);break;case"velocity":i.setVelocity(d,p);break;case"angularVelocity":i.setAngularVelocity(d,p);break;case"speed":i.setSpeed(d,p);break;case"angularSpeed":i.setAngularSpeed(d,p);break;case"parts":i.setParts(d,p);break;case"centre":i.setCentre(d,p);break;default:d[g]=p}},i.setStatic=function(d,m){for(var p=0;p<d.parts.length;p++){var g=d.parts[p];g.isStatic=m,m?(g._original={restitution:g.restitution,friction:g.friction,mass:g.mass,inertia:g.inertia,density:g.density,inverseMass:g.inverseMass,inverseInertia:g.inverseInertia},g.restitution=0,g.friction=1,g.mass=g.inertia=g.density=1/0,g.inverseMass=g.inverseInertia=0,g.positionPrev.x=g.position.x,g.positionPrev.y=g.position.y,g.anglePrev=g.angle,g.angularVelocity=0,g.speed=0,g.angularSpeed=0,g.motion=0):g._original&&(g.restitution=g._original.restitution,g.friction=g._original.friction,g.mass=g._original.mass,g.inertia=g._original.inertia,g.density=g._original.density,g.inverseMass=g._original.inverseMass,g.inverseInertia=g._original.inverseInertia,g._original=null)}},i.setMass=function(d,m){var p=d.inertia/(d.mass/6);d.inertia=p*(m/6),d.inverseInertia=1/d.inertia,d.mass=m,d.inverseMass=1/d.mass,d.density=d.mass/d.area},i.setDensity=function(d,m){i.setMass(d,m*d.area),d.density=m},i.setInertia=function(d,m){d.inertia=m,d.inverseInertia=1/d.inertia},i.setVertices=function(d,m){m[0].body===d?d.vertices=m:d.vertices=a.create(m,d),d.axes=f.fromVertices(d.vertices),d.area=a.area(d.vertices),i.setMass(d,d.density*d.area);var p=a.centre(d.vertices);a.translate(d.vertices,p,-1),i.setInertia(d,i._inertiaScale*a.inertia(d.vertices,d.mass)),a.translate(d.vertices,d.position),c.update(d.bounds,d.vertices,d.velocity)},i.setParts=function(d,m,p){var g;for(m=m.slice(0),d.parts.length=0,d.parts.push(d),d.parent=d,g=0;g<m.length;g++){var y=m[g];y!==d&&(y.parent=d,d.parts.push(y))}if(d.parts.length!==1){if(p=typeof p<"u"?p:!0,p){var T=[];for(g=0;g<m.length;g++)T=T.concat(m[g].vertices);a.clockwiseSort(T);var v=a.hull(T),C=a.centre(v);i.setVertices(d,v),a.translate(d.vertices,C)}var E=i._totalProperties(d);d.area=E.area,d.parent=d,d.position.x=E.centre.x,d.position.y=E.centre.y,d.positionPrev.x=E.centre.x,d.positionPrev.y=E.centre.y,i.setMass(d,E.mass),i.setInertia(d,E.inertia),i.setPosition(d,E.centre)}},i.setCentre=function(d,m,p){p?(d.positionPrev.x+=m.x,d.positionPrev.y+=m.y,d.position.x+=m.x,d.position.y+=m.y):(d.positionPrev.x=m.x-(d.position.x-d.positionPrev.x),d.positionPrev.y=m.y-(d.position.y-d.positionPrev.y),d.position.x=m.x,d.position.y=m.y)},i.setPosition=function(d,m,p){var g=o.sub(m,d.position);p?(d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.velocity.x=g.x,d.velocity.y=g.y,d.speed=o.magnitude(g)):(d.positionPrev.x+=g.x,d.positionPrev.y+=g.y);for(var y=0;y<d.parts.length;y++){var T=d.parts[y];T.position.x+=g.x,T.position.y+=g.y,a.translate(T.vertices,g),c.update(T.bounds,T.vertices,d.velocity)}},i.setAngle=function(d,m,p){var g=m-d.angle;p?(d.anglePrev=d.angle,d.angularVelocity=g,d.angularSpeed=Math.abs(g)):d.anglePrev+=g;for(var y=0;y<d.parts.length;y++){var T=d.parts[y];T.angle+=g,a.rotate(T.vertices,g,d.position),f.rotate(T.axes,g),c.update(T.bounds,T.vertices,d.velocity),y>0&&o.rotateAbout(T.position,g,d.position,T.position)}},i.setVelocity=function(d,m){var p=d.deltaTime/i._baseDelta;d.positionPrev.x=d.position.x-m.x*p,d.positionPrev.y=d.position.y-m.y*p,d.velocity.x=(d.position.x-d.positionPrev.x)/p,d.velocity.y=(d.position.y-d.positionPrev.y)/p,d.speed=o.magnitude(d.velocity)},i.getVelocity=function(d){var m=i._baseDelta/d.deltaTime;return{x:(d.position.x-d.positionPrev.x)*m,y:(d.position.y-d.positionPrev.y)*m}},i.getSpeed=function(d){return o.magnitude(i.getVelocity(d))},i.setSpeed=function(d,m){i.setVelocity(d,o.mult(o.normalise(i.getVelocity(d)),m))},i.setAngularVelocity=function(d,m){var p=d.deltaTime/i._baseDelta;d.anglePrev=d.angle-m*p,d.angularVelocity=(d.angle-d.anglePrev)/p,d.angularSpeed=Math.abs(d.angularVelocity)},i.getAngularVelocity=function(d){return(d.angle-d.anglePrev)*i._baseDelta/d.deltaTime},i.getAngularSpeed=function(d){return Math.abs(i.getAngularVelocity(d))},i.setAngularSpeed=function(d,m){i.setAngularVelocity(d,u.sign(i.getAngularVelocity(d))*m)},i.translate=function(d,m,p){i.setPosition(d,o.add(d.position,m),p)},i.rotate=function(d,m,p,g){if(!p)i.setAngle(d,d.angle+m,g);else{var y=Math.cos(m),T=Math.sin(m),v=d.position.x-p.x,C=d.position.y-p.y;i.setPosition(d,{x:p.x+(v*y-C*T),y:p.y+(v*T+C*y)},g),i.setAngle(d,d.angle+m,g)}},i.scale=function(d,m,p,g){var y=0,T=0;g=g||d.position;for(var v=0;v<d.parts.length;v++){var C=d.parts[v];a.scale(C.vertices,m,p,g),C.axes=f.fromVertices(C.vertices),C.area=a.area(C.vertices),i.setMass(C,d.density*C.area),a.translate(C.vertices,{x:-C.position.x,y:-C.position.y}),i.setInertia(C,i._inertiaScale*a.inertia(C.vertices,C.mass)),a.translate(C.vertices,{x:C.position.x,y:C.position.y}),v>0&&(y+=C.area,T+=C.inertia),C.position.x=g.x+(C.position.x-g.x)*m,C.position.y=g.y+(C.position.y-g.y)*p,c.update(C.bounds,C.vertices,d.velocity)}d.parts.length>1&&(d.area=y,d.isStatic||(i.setMass(d,d.density*y),i.setInertia(d,T))),d.circleRadius&&(m===p?d.circleRadius*=m:d.circleRadius=null)},i.update=function(d,m){m=(typeof m<"u"?m:1e3/60)*d.timeScale;var p=m*m,g=i._timeCorrection?m/(d.deltaTime||m):1,y=1-d.frictionAir*(m/u._baseDelta),T=(d.position.x-d.positionPrev.x)*g,v=(d.position.y-d.positionPrev.y)*g;d.velocity.x=T*y+d.force.x/d.mass*p,d.velocity.y=v*y+d.force.y/d.mass*p,d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.position.x+=d.velocity.x,d.position.y+=d.velocity.y,d.deltaTime=m,d.angularVelocity=(d.angle-d.anglePrev)*y*g+d.torque/d.inertia*p,d.anglePrev=d.angle,d.angle+=d.angularVelocity;for(var C=0;C<d.parts.length;C++){var E=d.parts[C];a.translate(E.vertices,d.velocity),C>0&&(E.position.x+=d.velocity.x,E.position.y+=d.velocity.y),d.angularVelocity!==0&&(a.rotate(E.vertices,d.angularVelocity,d.position),f.rotate(E.axes,d.angularVelocity),C>0&&o.rotateAbout(E.position,d.angularVelocity,d.position,E.position)),c.update(E.bounds,E.vertices,d.velocity)}},i.updateVelocities=function(d){var m=i._baseDelta/d.deltaTime,p=d.velocity;p.x=(d.position.x-d.positionPrev.x)*m,p.y=(d.position.y-d.positionPrev.y)*m,d.speed=Math.sqrt(p.x*p.x+p.y*p.y),d.angularVelocity=(d.angle-d.anglePrev)*m,d.angularSpeed=Math.abs(d.angularVelocity)},i.applyForce=function(d,m,p){var g={x:m.x-d.position.x,y:m.y-d.position.y};d.force.x+=p.x,d.force.y+=p.y,d.torque+=g.x*p.y-g.y*p.x},i._totalProperties=function(d){for(var m={mass:0,area:0,inertia:0,centre:{x:0,y:0}},p=d.parts.length===1?0:1;p<d.parts.length;p++){var g=d.parts[p],y=g.mass!==1/0?g.mass:1;m.mass+=y,m.area+=g.area,m.inertia+=g.inertia,m.centre=o.add(m.centre,o.mult(g.position,y))}return m.centre=o.div(m.centre,m.mass),m}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0);(function(){i.on=function(o,l,u){for(var c=l.split(" "),f,h=0;h<c.length;h++)f=c[h],o.events=o.events||{},o.events[f]=o.events[f]||[],o.events[f].push(u);return u},i.off=function(o,l,u){if(!l){o.events={};return}typeof l=="function"&&(u=l,l=a.keys(o.events).join(" "));for(var c=l.split(" "),f=0;f<c.length;f++){var h=o.events[c[f]],d=[];if(u&&h)for(var m=0;m<h.length;m++)h[m]!==u&&d.push(h[m]);o.events[c[f]]=d}},i.trigger=function(o,l,u){var c,f,h,d,m=o.events;if(m&&a.keys(m).length>0){u||(u={}),c=l.split(" ");for(var p=0;p<c.length;p++)if(f=c[p],h=m[f],h){d=a.clone(u,!1),d.name=f,d.source=o;for(var g=0;g<h.length;g++)h[g].apply(o,[d])}}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(5),o=s(0),l=s(1),u=s(4);(function(){i.create=function(c){return o.extend({id:o.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},c)},i.setModified=function(c,f,h,d){if(c.isModified=f,f&&c.cache&&(c.cache.allBodies=null,c.cache.allConstraints=null,c.cache.allComposites=null),h&&c.parent&&i.setModified(c.parent,f,h,d),d)for(var m=0;m<c.composites.length;m++){var p=c.composites[m];i.setModified(p,f,h,d)}},i.add=function(c,f){var h=[].concat(f);a.trigger(c,"beforeAdd",{object:f});for(var d=0;d<h.length;d++){var m=h[d];switch(m.type){case"body":if(m.parent!==m){o.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}i.addBody(c,m);break;case"constraint":i.addConstraint(c,m);break;case"composite":i.addComposite(c,m);break;case"mouseConstraint":i.addConstraint(c,m.constraint);break}}return a.trigger(c,"afterAdd",{object:f}),c},i.remove=function(c,f,h){var d=[].concat(f);a.trigger(c,"beforeRemove",{object:f});for(var m=0;m<d.length;m++){var p=d[m];switch(p.type){case"body":i.removeBody(c,p,h);break;case"constraint":i.removeConstraint(c,p,h);break;case"composite":i.removeComposite(c,p,h);break;case"mouseConstraint":i.removeConstraint(c,p.constraint);break}}return a.trigger(c,"afterRemove",{object:f}),c},i.addComposite=function(c,f){return c.composites.push(f),f.parent=c,i.setModified(c,!0,!0,!1),c},i.removeComposite=function(c,f,h){var d=o.indexOf(c.composites,f);if(d!==-1&&i.removeCompositeAt(c,d),h)for(var m=0;m<c.composites.length;m++)i.removeComposite(c.composites[m],f,!0);return c},i.removeCompositeAt=function(c,f){return c.composites.splice(f,1),i.setModified(c,!0,!0,!1),c},i.addBody=function(c,f){return c.bodies.push(f),i.setModified(c,!0,!0,!1),c},i.removeBody=function(c,f,h){var d=o.indexOf(c.bodies,f);if(d!==-1&&i.removeBodyAt(c,d),h)for(var m=0;m<c.composites.length;m++)i.removeBody(c.composites[m],f,!0);return c},i.removeBodyAt=function(c,f){return c.bodies.splice(f,1),i.setModified(c,!0,!0,!1),c},i.addConstraint=function(c,f){return c.constraints.push(f),i.setModified(c,!0,!0,!1),c},i.removeConstraint=function(c,f,h){var d=o.indexOf(c.constraints,f);if(d!==-1&&i.removeConstraintAt(c,d),h)for(var m=0;m<c.composites.length;m++)i.removeConstraint(c.composites[m],f,!0);return c},i.removeConstraintAt=function(c,f){return c.constraints.splice(f,1),i.setModified(c,!0,!0,!1),c},i.clear=function(c,f,h){if(h)for(var d=0;d<c.composites.length;d++)i.clear(c.composites[d],f,!0);return f?c.bodies=c.bodies.filter(function(m){return m.isStatic}):c.bodies.length=0,c.constraints.length=0,c.composites.length=0,i.setModified(c,!0,!0,!1),c},i.allBodies=function(c){if(c.cache&&c.cache.allBodies)return c.cache.allBodies;for(var f=[].concat(c.bodies),h=0;h<c.composites.length;h++)f=f.concat(i.allBodies(c.composites[h]));return c.cache&&(c.cache.allBodies=f),f},i.allConstraints=function(c){if(c.cache&&c.cache.allConstraints)return c.cache.allConstraints;for(var f=[].concat(c.constraints),h=0;h<c.composites.length;h++)f=f.concat(i.allConstraints(c.composites[h]));return c.cache&&(c.cache.allConstraints=f),f},i.allComposites=function(c){if(c.cache&&c.cache.allComposites)return c.cache.allComposites;for(var f=[].concat(c.composites),h=0;h<c.composites.length;h++)f=f.concat(i.allComposites(c.composites[h]));return c.cache&&(c.cache.allComposites=f),f},i.get=function(c,f,h){var d,m;switch(h){case"body":d=i.allBodies(c);break;case"constraint":d=i.allConstraints(c);break;case"composite":d=i.allComposites(c).concat(c);break}return d?(m=d.filter(function(p){return p.id.toString()===f.toString()}),m.length===0?null:m[0]):null},i.move=function(c,f,h){return i.remove(c,f),i.add(h,f),c},i.rebase=function(c){for(var f=i.allBodies(c).concat(i.allConstraints(c)).concat(i.allComposites(c)),h=0;h<f.length;h++)f[h].id=o.nextId();return c},i.translate=function(c,f,h){for(var d=h?i.allBodies(c):c.bodies,m=0;m<d.length;m++)u.translate(d[m],f);return c},i.rotate=function(c,f,h,d){for(var m=Math.cos(f),p=Math.sin(f),g=d?i.allBodies(c):c.bodies,y=0;y<g.length;y++){var T=g[y],v=T.position.x-h.x,C=T.position.y-h.y;u.setPosition(T,{x:h.x+(v*m-C*p),y:h.y+(v*p+C*m)}),u.rotate(T,f)}return c},i.scale=function(c,f,h,d,m){for(var p=m?i.allBodies(c):c.bodies,g=0;g<p.length;g++){var y=p[g],T=y.position.x-d.x,v=y.position.y-d.y;u.setPosition(y,{x:d.x+T*f,y:d.y+v*h}),u.scale(y,f,h)}return c},i.bounds=function(c){for(var f=i.allBodies(c),h=[],d=0;d<f.length;d+=1){var m=f[d];h.push(m.bounds.min,m.bounds.max)}return l.create(h)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(4),o=s(5),l=s(0);(function(){i._motionWakeThreshold=.18,i._motionSleepThreshold=.08,i._minBias=.9,i.update=function(u,c){for(var f=c/l._baseDelta,h=i._motionSleepThreshold,d=0;d<u.length;d++){var m=u[d],p=a.getSpeed(m),g=a.getAngularSpeed(m),y=p*p+g*g;if(m.force.x!==0||m.force.y!==0){i.set(m,!1);continue}var T=Math.min(m.motion,y),v=Math.max(m.motion,y);m.motion=i._minBias*T+(1-i._minBias)*v,m.sleepThreshold>0&&m.motion<h?(m.sleepCounter+=1,m.sleepCounter>=m.sleepThreshold/f&&i.set(m,!0)):m.sleepCounter>0&&(m.sleepCounter-=1)}},i.afterCollisions=function(u){for(var c=i._motionSleepThreshold,f=0;f<u.length;f++){var h=u[f];if(h.isActive){var d=h.collision,m=d.bodyA.parent,p=d.bodyB.parent;if(!(m.isSleeping&&p.isSleeping||m.isStatic||p.isStatic)&&(m.isSleeping||p.isSleeping)){var g=m.isSleeping&&!m.isStatic?m:p,y=g===m?p:m;!g.isStatic&&y.motion>c&&i.set(g,!1)}}}},i.set=function(u,c){var f=u.isSleeping;c?(u.isSleeping=!0,u.sleepCounter=u.sleepThreshold,u.positionImpulse.x=0,u.positionImpulse.y=0,u.positionPrev.x=u.position.x,u.positionPrev.y=u.position.y,u.anglePrev=u.angle,u.speed=0,u.angularSpeed=0,u.motion=0,f||o.trigger(u,"sleepStart")):(u.isSleeping=!1,u.sleepCounter=0,f&&o.trigger(u,"sleepEnd"))}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(9);(function(){var l=[],u={overlap:0,axis:null},c={overlap:0,axis:null};i.create=function(f,h){return{pair:null,collided:!1,bodyA:f,bodyB:h,parentA:f.parent,parentB:h.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},i.collides=function(f,h,d){if(i._overlapAxes(u,f.vertices,h.vertices,f.axes),u.overlap<=0||(i._overlapAxes(c,h.vertices,f.vertices,h.axes),c.overlap<=0))return null;var m=d&&d.table[o.id(f,h)],p;m?p=m.collision:(p=i.create(f,h),p.collided=!0,p.bodyA=f.id<h.id?f:h,p.bodyB=f.id<h.id?h:f,p.parentA=p.bodyA.parent,p.parentB=p.bodyB.parent),f=p.bodyA,h=p.bodyB;var g;u.overlap<c.overlap?g=u:g=c;var y=p.normal,T=p.supports,v=g.axis,C=v.x,E=v.y;C*(h.position.x-f.position.x)+E*(h.position.y-f.position.y)<0?(y.x=C,y.y=E):(y.x=-C,y.y=-E),p.tangent.x=-y.y,p.tangent.y=y.x,p.depth=g.overlap,p.penetration.x=y.x*p.depth,p.penetration.y=y.y*p.depth;var w=i._findSupports(f,h,y,1),_=0;if(a.contains(f.vertices,w[0])&&(T[_++]=w[0]),a.contains(f.vertices,w[1])&&(T[_++]=w[1]),_<2){var S=i._findSupports(h,f,y,-1);a.contains(h.vertices,S[0])&&(T[_++]=S[0]),_<2&&a.contains(h.vertices,S[1])&&(T[_++]=S[1])}return _===0&&(T[_++]=w[0]),T.length=_,p},i._overlapAxes=function(f,h,d,m){var p=h.length,g=d.length,y=h[0].x,T=h[0].y,v=d[0].x,C=d[0].y,E=m.length,w=Number.MAX_VALUE,_=0,S,I,A,P,N,j;for(N=0;N<E;N++){var M=m[N],L=M.x,B=M.y,V=y*L+T*B,F=v*L+C*B,q=V,R=F;for(j=1;j<p;j+=1)P=h[j].x*L+h[j].y*B,P>q?q=P:P<V&&(V=P);for(j=1;j<g;j+=1)P=d[j].x*L+d[j].y*B,P>R?R=P:P<F&&(F=P);if(I=q-F,A=R-V,S=I<A?I:A,S<w&&(w=S,_=N,S<=0))break}f.axis=m[_],f.overlap=w},i._projectToAxis=function(f,h,d){for(var m=h[0].x*d.x+h[0].y*d.y,p=m,g=1;g<h.length;g+=1){var y=h[g].x*d.x+h[g].y*d.y;y>p?p=y:y<m&&(m=y)}f.min=m,f.max=p},i._findSupports=function(f,h,d,m){var p=h.vertices,g=p.length,y=f.position.x,T=f.position.y,v=d.x*m,C=d.y*m,E=Number.MAX_VALUE,w,_,S,I,A;for(A=0;A<g;A+=1)_=p[A],I=v*(y-_.x)+C*(T-_.y),I<E&&(E=I,w=_);return S=p[(g+w.index-1)%g],E=v*(y-S.x)+C*(T-S.y),_=p[(w.index+1)%g],v*(y-_.x)+C*(T-_.y)<E?(l[0]=w,l[1]=_,l):(l[0]=w,l[1]=S,l)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(16);(function(){i.create=function(o,l){var u=o.bodyA,c=o.bodyB,f={id:i.id(u,c),bodyA:u,bodyB:c,collision:o,contacts:[],activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:u.isSensor||c.isSensor,timeCreated:l,timeUpdated:l,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return i.update(f,o,l),f},i.update=function(o,l,u){var c=o.contacts,f=l.supports,h=o.activeContacts,d=l.parentA,m=l.parentB,p=d.vertices.length;o.isActive=!0,o.timeUpdated=u,o.collision=l,o.separation=l.depth,o.inverseMass=d.inverseMass+m.inverseMass,o.friction=d.friction<m.friction?d.friction:m.friction,o.frictionStatic=d.frictionStatic>m.frictionStatic?d.frictionStatic:m.frictionStatic,o.restitution=d.restitution>m.restitution?d.restitution:m.restitution,o.slop=d.slop>m.slop?d.slop:m.slop,l.pair=o,h.length=0;for(var g=0;g<f.length;g++){var y=f[g],T=y.body===d?y.index:p+y.index,v=c[T];v?h.push(v):h.push(c[T]=a.create(y))}},i.setActive=function(o,l,u){l?(o.isActive=!0,o.timeUpdated=u):(o.isActive=!1,o.activeContacts.length=0)},i.id=function(o,l){return o.id<l.id?"A"+o.id+"B"+l.id:"A"+l.id+"B"+o.id}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(2),l=s(7),u=s(1),c=s(11),f=s(0);(function(){i._warming=.4,i._torqueDampen=1,i._minLength=1e-6,i.create=function(h){var d=h;d.bodyA&&!d.pointA&&(d.pointA={x:0,y:0}),d.bodyB&&!d.pointB&&(d.pointB={x:0,y:0});var m=d.bodyA?o.add(d.bodyA.position,d.pointA):d.pointA,p=d.bodyB?o.add(d.bodyB.position,d.pointB):d.pointB,g=o.magnitude(o.sub(m,p));d.length=typeof d.length<"u"?d.length:g,d.id=d.id||f.nextId(),d.label=d.label||"Constraint",d.type="constraint",d.stiffness=d.stiffness||(d.length>0?1:.7),d.damping=d.damping||0,d.angularStiffness=d.angularStiffness||0,d.angleA=d.bodyA?d.bodyA.angle:d.angleA,d.angleB=d.bodyB?d.bodyB.angle:d.angleB,d.plugin={};var y={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return d.length===0&&d.stiffness>.1?(y.type="pin",y.anchors=!1):d.stiffness<.9&&(y.type="spring"),d.render=f.extend(y,d.render),d},i.preSolveAll=function(h){for(var d=0;d<h.length;d+=1){var m=h[d],p=m.constraintImpulse;m.isStatic||p.x===0&&p.y===0&&p.angle===0||(m.position.x+=p.x,m.position.y+=p.y,m.angle+=p.angle)}},i.solveAll=function(h,d){for(var m=f.clamp(d/f._baseDelta,0,1),p=0;p<h.length;p+=1){var g=h[p],y=!g.bodyA||g.bodyA&&g.bodyA.isStatic,T=!g.bodyB||g.bodyB&&g.bodyB.isStatic;(y||T)&&i.solve(h[p],m)}for(p=0;p<h.length;p+=1)g=h[p],y=!g.bodyA||g.bodyA&&g.bodyA.isStatic,T=!g.bodyB||g.bodyB&&g.bodyB.isStatic,!y&&!T&&i.solve(h[p],m)},i.solve=function(h,d){var m=h.bodyA,p=h.bodyB,g=h.pointA,y=h.pointB;if(!(!m&&!p)){m&&!m.isStatic&&(o.rotate(g,m.angle-h.angleA,g),h.angleA=m.angle),p&&!p.isStatic&&(o.rotate(y,p.angle-h.angleB,y),h.angleB=p.angle);var T=g,v=y;if(m&&(T=o.add(m.position,g)),p&&(v=o.add(p.position,y)),!(!T||!v)){var C=o.sub(T,v),E=o.magnitude(C);E<i._minLength&&(E=i._minLength);var w=(E-h.length)/E,_=h.stiffness>=1||h.length===0,S=_?h.stiffness*d:h.stiffness*d*d,I=h.damping*d,A=o.mult(C,w*S),P=(m?m.inverseMass:0)+(p?p.inverseMass:0),N=(m?m.inverseInertia:0)+(p?p.inverseInertia:0),j=P+N,M,L,B,V,F;if(I>0){var q=o.create();B=o.div(C,E),F=o.sub(p&&o.sub(p.position,p.positionPrev)||q,m&&o.sub(m.position,m.positionPrev)||q),V=o.dot(B,F)}m&&!m.isStatic&&(L=m.inverseMass/P,m.constraintImpulse.x-=A.x*L,m.constraintImpulse.y-=A.y*L,m.position.x-=A.x*L,m.position.y-=A.y*L,I>0&&(m.positionPrev.x-=I*B.x*V*L,m.positionPrev.y-=I*B.y*V*L),M=o.cross(g,A)/j*i._torqueDampen*m.inverseInertia*(1-h.angularStiffness),m.constraintImpulse.angle-=M,m.angle-=M),p&&!p.isStatic&&(L=p.inverseMass/P,p.constraintImpulse.x+=A.x*L,p.constraintImpulse.y+=A.y*L,p.position.x+=A.x*L,p.position.y+=A.y*L,I>0&&(p.positionPrev.x+=I*B.x*V*L,p.positionPrev.y+=I*B.y*V*L),M=o.cross(y,A)/j*i._torqueDampen*p.inverseInertia*(1-h.angularStiffness),p.constraintImpulse.angle+=M,p.angle+=M)}}},i.postSolveAll=function(h){for(var d=0;d<h.length;d++){var m=h[d],p=m.constraintImpulse;if(!(m.isStatic||p.x===0&&p.y===0&&p.angle===0)){l.set(m,!1);for(var g=0;g<m.parts.length;g++){var y=m.parts[g];a.translate(y.vertices,p),g>0&&(y.position.x+=p.x,y.position.y+=p.y),p.angle!==0&&(a.rotate(y.vertices,p.angle,m.position),c.rotate(y.axes,p.angle),g>0&&o.rotateAbout(y.position,p.angle,m.position,y.position)),u.update(y.bounds,y.vertices,m.velocity)}p.angle*=i._warming,p.x*=i._warming,p.y*=i._warming}}},i.pointAWorld=function(h){return{x:(h.bodyA?h.bodyA.position.x:0)+(h.pointA?h.pointA.x:0),y:(h.bodyA?h.bodyA.position.y:0)+(h.pointA?h.pointA.y:0)}},i.pointBWorld=function(h){return{x:(h.bodyB?h.bodyB.position.x:0)+(h.pointB?h.pointB.x:0),y:(h.bodyB?h.bodyB.position.y:0)+(h.pointB?h.pointB.y:0)}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(2),o=s(0);(function(){i.fromVertices=function(l){for(var u={},c=0;c<l.length;c++){var f=(c+1)%l.length,h=a.normalise({x:l[f].y-l[c].y,y:l[c].x-l[f].x}),d=h.y===0?1/0:h.x/h.y;d=d.toFixed(3).toString(),u[d]=h}return o.values(u)},i.rotate=function(l,u){if(u!==0)for(var c=Math.cos(u),f=Math.sin(u),h=0;h<l.length;h++){var d=l[h],m;m=d.x*c-d.y*f,d.y=d.x*f+d.y*c,d.x=m}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(0),l=s(4),u=s(1),c=s(2);(function(){i.rectangle=function(f,h,d,m,p){p=p||{};var g={label:"Rectangle Body",position:{x:f,y:h},vertices:a.fromPath("L 0 0 L "+d+" 0 L "+d+" "+m+" L 0 "+m)};if(p.chamfer){var y=p.chamfer;g.vertices=a.chamfer(g.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete p.chamfer}return l.create(o.extend({},g,p))},i.trapezoid=function(f,h,d,m,p,g){g=g||{},p*=.5;var y=(1-p*2)*d,T=d*p,v=T+y,C=v+T,E;p<.5?E="L 0 0 L "+T+" "+-m+" L "+v+" "+-m+" L "+C+" 0":E="L 0 0 L "+v+" "+-m+" L "+C+" 0";var w={label:"Trapezoid Body",position:{x:f,y:h},vertices:a.fromPath(E)};if(g.chamfer){var _=g.chamfer;w.vertices=a.chamfer(w.vertices,_.radius,_.quality,_.qualityMin,_.qualityMax),delete g.chamfer}return l.create(o.extend({},w,g))},i.circle=function(f,h,d,m,p){m=m||{};var g={label:"Circle Body",circleRadius:d};p=p||25;var y=Math.ceil(Math.max(10,Math.min(p,d)));return y%2===1&&(y+=1),i.polygon(f,h,y,d,o.extend({},g,m))},i.polygon=function(f,h,d,m,p){if(p=p||{},d<3)return i.circle(f,h,m,p);for(var g=2*Math.PI/d,y="",T=g*.5,v=0;v<d;v+=1){var C=T+v*g,E=Math.cos(C)*m,w=Math.sin(C)*m;y+="L "+E.toFixed(3)+" "+w.toFixed(3)+" "}var _={label:"Polygon Body",position:{x:f,y:h},vertices:a.fromPath(y)};if(p.chamfer){var S=p.chamfer;_.vertices=a.chamfer(_.vertices,S.radius,S.quality,S.qualityMin,S.qualityMax),delete p.chamfer}return l.create(o.extend({},_,p))},i.fromVertices=function(f,h,d,m,p,g,y,T){var v=o.getDecomp(),C,E,w,_,S,I,A,P,N,j,M;for(C=!!(v&&v.quickDecomp),m=m||{},w=[],p=typeof p<"u"?p:!1,g=typeof g<"u"?g:.01,y=typeof y<"u"?y:10,T=typeof T<"u"?T:.01,o.isArray(d[0])||(d=[d]),j=0;j<d.length;j+=1)if(I=d[j],_=a.isConvex(I),S=!_,S&&!C&&o.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),_||!C)_?I=a.clockwiseSort(I):I=a.hull(I),w.push({position:{x:f,y:h},vertices:I});else{var L=I.map(function(z){return[z.x,z.y]});v.makeCCW(L),g!==!1&&v.removeCollinearPoints(L,g),T!==!1&&v.removeDuplicatePoints&&v.removeDuplicatePoints(L,T);var B=v.quickDecomp(L);for(A=0;A<B.length;A++){var V=B[A],F=V.map(function(z){return{x:z[0],y:z[1]}});y>0&&a.area(F)<y||w.push({position:a.centre(F),vertices:F})}}for(A=0;A<w.length;A++)w[A]=l.create(o.extend(w[A],m));if(p){var q=5;for(A=0;A<w.length;A++){var R=w[A];for(P=A+1;P<w.length;P++){var $=w[P];if(u.overlaps(R.bounds,$.bounds)){var X=R.vertices,D=$.vertices;for(N=0;N<R.vertices.length;N++)for(M=0;M<$.vertices.length;M++){var Z=c.magnitudeSquared(c.sub(X[(N+1)%X.length],D[M])),le=c.magnitudeSquared(c.sub(X[N],D[(M+1)%D.length]));Z<q&&le<q&&(X[N].isInternal=!0,D[M].isInternal=!0)}}}}}return w.length>1?(E=l.create(o.extend({parts:w.slice(0)},m)),l.setPosition(E,{x:f,y:h}),E):w[0]}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0),o=s(8);(function(){i.create=function(l){var u={bodies:[],pairs:null};return a.extend(u,l)},i.setBodies=function(l,u){l.bodies=u.slice(0)},i.clear=function(l){l.bodies=[]},i.collisions=function(l){var u=[],c=l.pairs,f=l.bodies,h=f.length,d=i.canCollide,m=o.collides,p,g;for(f.sort(i._compareBoundsX),p=0;p<h;p++){var y=f[p],T=y.bounds,v=y.bounds.max.x,C=y.bounds.max.y,E=y.bounds.min.y,w=y.isStatic||y.isSleeping,_=y.parts.length,S=_===1;for(g=p+1;g<h;g++){var I=f[g],A=I.bounds;if(A.min.x>v)break;if(!(C<A.min.y||E>A.max.y)&&!(w&&(I.isStatic||I.isSleeping))&&d(y.collisionFilter,I.collisionFilter)){var P=I.parts.length;if(S&&P===1){var N=m(y,I,c);N&&u.push(N)}else for(var j=_>1?1:0,M=P>1?1:0,L=j;L<_;L++)for(var B=y.parts[L],T=B.bounds,V=M;V<P;V++){var F=I.parts[V],A=F.bounds;if(!(T.min.x>A.max.x||T.max.x<A.min.x||T.max.y<A.min.y||T.min.y>A.max.y)){var N=m(B,F,c);N&&u.push(N)}}}}}return u},i.canCollide=function(l,u){return l.group===u.group&&l.group!==0?l.group>0:(l.mask&u.category)!==0&&(u.mask&l.category)!==0},i._compareBoundsX=function(l,u){return l.bounds.min.x-u.bounds.min.x}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0);(function(){i.create=function(o){var l={};return o||a.log("Mouse.create: element was undefined, defaulting to document.body","warn"),l.element=o||document.body,l.absolute={x:0,y:0},l.position={x:0,y:0},l.mousedownPosition={x:0,y:0},l.mouseupPosition={x:0,y:0},l.offset={x:0,y:0},l.scale={x:1,y:1},l.wheelDelta=0,l.button=-1,l.pixelRatio=parseInt(l.element.getAttribute("data-pixel-ratio"),10)||1,l.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},l.mousemove=function(u){var c=i._getRelativeMousePosition(u,l.element,l.pixelRatio),f=u.changedTouches;f&&(l.button=0,u.preventDefault()),l.absolute.x=c.x,l.absolute.y=c.y,l.position.x=l.absolute.x*l.scale.x+l.offset.x,l.position.y=l.absolute.y*l.scale.y+l.offset.y,l.sourceEvents.mousemove=u},l.mousedown=function(u){var c=i._getRelativeMousePosition(u,l.element,l.pixelRatio),f=u.changedTouches;f?(l.button=0,u.preventDefault()):l.button=u.button,l.absolute.x=c.x,l.absolute.y=c.y,l.position.x=l.absolute.x*l.scale.x+l.offset.x,l.position.y=l.absolute.y*l.scale.y+l.offset.y,l.mousedownPosition.x=l.position.x,l.mousedownPosition.y=l.position.y,l.sourceEvents.mousedown=u},l.mouseup=function(u){var c=i._getRelativeMousePosition(u,l.element,l.pixelRatio),f=u.changedTouches;f&&u.preventDefault(),l.button=-1,l.absolute.x=c.x,l.absolute.y=c.y,l.position.x=l.absolute.x*l.scale.x+l.offset.x,l.position.y=l.absolute.y*l.scale.y+l.offset.y,l.mouseupPosition.x=l.position.x,l.mouseupPosition.y=l.position.y,l.sourceEvents.mouseup=u},l.mousewheel=function(u){l.wheelDelta=Math.max(-1,Math.min(1,u.wheelDelta||-u.detail)),u.preventDefault()},i.setElement(l,l.element),l},i.setElement=function(o,l){o.element=l,l.addEventListener("mousemove",o.mousemove),l.addEventListener("mousedown",o.mousedown),l.addEventListener("mouseup",o.mouseup),l.addEventListener("mousewheel",o.mousewheel),l.addEventListener("DOMMouseScroll",o.mousewheel),l.addEventListener("touchmove",o.mousemove),l.addEventListener("touchstart",o.mousedown),l.addEventListener("touchend",o.mouseup)},i.clearSourceEvents=function(o){o.sourceEvents.mousemove=null,o.sourceEvents.mousedown=null,o.sourceEvents.mouseup=null,o.sourceEvents.mousewheel=null,o.wheelDelta=0},i.setOffset=function(o,l){o.offset.x=l.x,o.offset.y=l.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y},i.setScale=function(o,l){o.scale.x=l.x,o.scale.y=l.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y},i._getRelativeMousePosition=function(o,l,u){var c=l.getBoundingClientRect(),f=document.documentElement||document.body.parentNode||document.body,h=window.pageXOffset!==void 0?window.pageXOffset:f.scrollLeft,d=window.pageYOffset!==void 0?window.pageYOffset:f.scrollTop,m=o.changedTouches,p,g;return m?(p=m[0].pageX-c.left-h,g=m[0].pageY-c.top-d):(p=o.pageX-c.left-h,g=o.pageY-c.top-d),{x:p/(l.clientWidth/(l.width||l.clientWidth)*u),y:g/(l.clientHeight/(l.height||l.clientHeight)*u)}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(0);(function(){i._registry={},i.register=function(o){if(i.isPlugin(o)||a.warn("Plugin.register:",i.toString(o),"does not implement all required fields."),o.name in i._registry){var l=i._registry[o.name],u=i.versionParse(o.version).number,c=i.versionParse(l.version).number;u>c?(a.warn("Plugin.register:",i.toString(l),"was upgraded to",i.toString(o)),i._registry[o.name]=o):u<c?a.warn("Plugin.register:",i.toString(l),"can not be downgraded to",i.toString(o)):o!==l&&a.warn("Plugin.register:",i.toString(o),"is already registered to different plugin object")}else i._registry[o.name]=o;return o},i.resolve=function(o){return i._registry[i.dependencyParse(o).name]},i.toString=function(o){return typeof o=="string"?o:(o.name||"anonymous")+"@"+(o.version||o.range||"0.0.0")},i.isPlugin=function(o){return o&&o.name&&o.version&&o.install},i.isUsed=function(o,l){return o.used.indexOf(l)>-1},i.isFor=function(o,l){var u=o.for&&i.dependencyParse(o.for);return!o.for||l.name===u.name&&i.versionSatisfies(l.version,u.range)},i.use=function(o,l){if(o.uses=(o.uses||[]).concat(l||[]),o.uses.length===0){a.warn("Plugin.use:",i.toString(o),"does not specify any dependencies to install.");return}for(var u=i.dependencies(o),c=a.topologicalSort(u),f=[],h=0;h<c.length;h+=1)if(c[h]!==o.name){var d=i.resolve(c[h]);if(!d){f.push("❌ "+c[h]);continue}i.isUsed(o,d.name)||(i.isFor(d,o)||(a.warn("Plugin.use:",i.toString(d),"is for",d.for,"but installed on",i.toString(o)+"."),d._warned=!0),d.install?d.install(o):(a.warn("Plugin.use:",i.toString(d),"does not specify an install function."),d._warned=!0),d._warned?(f.push("🔶 "+i.toString(d)),delete d._warned):f.push("✅ "+i.toString(d)),o.used.push(d.name))}f.length>0&&a.info(f.join(" "))},i.dependencies=function(o,l){var u=i.dependencyParse(o),c=u.name;if(l=l||{},!(c in l)){o=i.resolve(o)||o,l[c]=a.map(o.uses||[],function(h){i.isPlugin(h)&&i.register(h);var d=i.dependencyParse(h),m=i.resolve(h);return m&&!i.versionSatisfies(m.version,d.range)?(a.warn("Plugin.dependencies:",i.toString(m),"does not satisfy",i.toString(d),"used by",i.toString(u)+"."),m._warned=!0,o._warned=!0):m||(a.warn("Plugin.dependencies:",i.toString(h),"used by",i.toString(u),"could not be resolved."),o._warned=!0),d.name});for(var f=0;f<l[c].length;f+=1)i.dependencies(l[c][f],l);return l}},i.dependencyParse=function(o){if(a.isString(o)){var l=/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/;return l.test(o)||a.warn("Plugin.dependencyParse:",o,"is not a valid dependency string."),{name:o.split("@")[0],range:o.split("@")[1]||"*"}}return{name:o.name,range:o.range||o.version}},i.versionParse=function(o){var l=/^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;l.test(o)||a.warn("Plugin.versionParse:",o,"is not a valid version or range.");var u=l.exec(o),c=Number(u[4]),f=Number(u[5]),h=Number(u[6]);return{isRange:!!(u[1]||u[2]),version:u[3],range:o,operator:u[1]||u[2]||"",major:c,minor:f,patch:h,parts:[c,f,h],prerelease:u[7],number:c*1e8+f*1e4+h}},i.versionSatisfies=function(o,l){l=l||"*";var u=i.versionParse(l),c=i.versionParse(o);if(u.isRange){if(u.operator==="*"||o==="*")return!0;if(u.operator===">")return c.number>u.number;if(u.operator===">=")return c.number>=u.number;if(u.operator==="~")return c.major===u.major&&c.minor===u.minor&&c.patch>=u.patch;if(u.operator==="^")return u.major>0?c.major===u.major&&c.number>=u.number:u.minor>0?c.minor===u.minor&&c.patch>=u.patch:c.patch===u.patch}return o===l||o==="*"}})()}),(function(n,r){var s={};n.exports=s,(function(){s.create=function(i){return{vertex:i,normalImpulse:0,tangentImpulse:0}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(7),o=s(18),l=s(13),u=s(19),c=s(5),f=s(6),h=s(10),d=s(0),m=s(4);(function(){i.create=function(p){p=p||{};var g={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0}},y=d.extend(g,p);return y.world=p.world||f.create({label:"World"}),y.pairs=p.pairs||u.create(),y.detector=p.detector||l.create(),y.grid={buckets:[]},y.world.gravity=y.gravity,y.broadphase=y.grid,y.metrics={},y},i.update=function(p,g){var y=d.now(),T=p.world,v=p.detector,C=p.pairs,E=p.timing,w=E.timestamp,_;g=typeof g<"u"?g:d._baseDelta,g*=E.timeScale,E.timestamp+=g,E.lastDelta=g;var S={timestamp:E.timestamp,delta:g};c.trigger(p,"beforeUpdate",S);var I=f.allBodies(T),A=f.allConstraints(T);for(T.isModified&&(l.setBodies(v,I),f.setModified(T,!1,!1,!0)),p.enableSleeping&&a.update(I,g),i._bodiesApplyGravity(I,p.gravity),g>0&&i._bodiesUpdate(I,g),h.preSolveAll(I),_=0;_<p.constraintIterations;_++)h.solveAll(A,g);h.postSolveAll(I),v.pairs=p.pairs;var P=l.collisions(v);u.update(C,P,w),p.enableSleeping&&a.afterCollisions(C.list),C.collisionStart.length>0&&c.trigger(p,"collisionStart",{pairs:C.collisionStart});var N=d.clamp(20/p.positionIterations,0,1);for(o.preSolvePosition(C.list),_=0;_<p.positionIterations;_++)o.solvePosition(C.list,g,N);for(o.postSolvePosition(I),h.preSolveAll(I),_=0;_<p.constraintIterations;_++)h.solveAll(A,g);for(h.postSolveAll(I),o.preSolveVelocity(C.list),_=0;_<p.velocityIterations;_++)o.solveVelocity(C.list,g);return i._bodiesUpdateVelocities(I),C.collisionActive.length>0&&c.trigger(p,"collisionActive",{pairs:C.collisionActive}),C.collisionEnd.length>0&&c.trigger(p,"collisionEnd",{pairs:C.collisionEnd}),i._bodiesClearForces(I),c.trigger(p,"afterUpdate",S),p.timing.lastElapsed=d.now()-y,p},i.merge=function(p,g){if(d.extend(p,g),g.world){p.world=g.world,i.clear(p);for(var y=f.allBodies(p.world),T=0;T<y.length;T++){var v=y[T];a.set(v,!1),v.id=d.nextId()}}},i.clear=function(p){u.clear(p.pairs),l.clear(p.detector)},i._bodiesClearForces=function(p){for(var g=p.length,y=0;y<g;y++){var T=p[y];T.force.x=0,T.force.y=0,T.torque=0}},i._bodiesApplyGravity=function(p,g){var y=typeof g.scale<"u"?g.scale:.001,T=p.length;if(!(g.x===0&&g.y===0||y===0))for(var v=0;v<T;v++){var C=p[v];C.isStatic||C.isSleeping||(C.force.y+=C.mass*g.y*y,C.force.x+=C.mass*g.x*y)}},i._bodiesUpdate=function(p,g){for(var y=p.length,T=0;T<y;T++){var v=p[T];v.isStatic||v.isSleeping||m.update(v,g)}},i._bodiesUpdateVelocities=function(p){for(var g=p.length,y=0;y<g;y++)m.updateVelocities(p[y])}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(0),l=s(1);(function(){i._restingThresh=2,i._restingThreshTangent=Math.sqrt(6),i._positionDampen=.9,i._positionWarming=.8,i._frictionNormalMultiplier=5,i._frictionMaxStatic=Number.MAX_VALUE,i.preSolvePosition=function(u){var c,f,h,d=u.length;for(c=0;c<d;c++)f=u[c],f.isActive&&(h=f.activeContacts.length,f.collision.parentA.totalContacts+=h,f.collision.parentB.totalContacts+=h)},i.solvePosition=function(u,c,f){var h,d,m,p,g,y,T,v,C=i._positionDampen*(f||1),E=o.clamp(c/o._baseDelta,0,1),w=u.length;for(h=0;h<w;h++)d=u[h],!(!d.isActive||d.isSensor)&&(m=d.collision,p=m.parentA,g=m.parentB,y=m.normal,d.separation=y.x*(g.positionImpulse.x+m.penetration.x-p.positionImpulse.x)+y.y*(g.positionImpulse.y+m.penetration.y-p.positionImpulse.y));for(h=0;h<w;h++)d=u[h],!(!d.isActive||d.isSensor)&&(m=d.collision,p=m.parentA,g=m.parentB,y=m.normal,v=d.separation-d.slop*E,(p.isStatic||g.isStatic)&&(v*=2),p.isStatic||p.isSleeping||(T=C/p.totalContacts,p.positionImpulse.x+=y.x*v*T,p.positionImpulse.y+=y.y*v*T),g.isStatic||g.isSleeping||(T=C/g.totalContacts,g.positionImpulse.x-=y.x*v*T,g.positionImpulse.y-=y.y*v*T))},i.postSolvePosition=function(u){for(var c=i._positionWarming,f=u.length,h=a.translate,d=l.update,m=0;m<f;m++){var p=u[m],g=p.positionImpulse,y=g.x,T=g.y,v=p.velocity;if(p.totalContacts=0,y!==0||T!==0){for(var C=0;C<p.parts.length;C++){var E=p.parts[C];h(E.vertices,g),d(E.bounds,E.vertices,v),E.position.x+=y,E.position.y+=T}p.positionPrev.x+=y,p.positionPrev.y+=T,y*v.x+T*v.y<0?(g.x=0,g.y=0):(g.x*=c,g.y*=c)}}},i.preSolveVelocity=function(u){var c=u.length,f,h;for(f=0;f<c;f++){var d=u[f];if(!(!d.isActive||d.isSensor)){var m=d.activeContacts,p=m.length,g=d.collision,y=g.parentA,T=g.parentB,v=g.normal,C=g.tangent;for(h=0;h<p;h++){var E=m[h],w=E.vertex,_=E.normalImpulse,S=E.tangentImpulse;if(_!==0||S!==0){var I=v.x*_+C.x*S,A=v.y*_+C.y*S;y.isStatic||y.isSleeping||(y.positionPrev.x+=I*y.inverseMass,y.positionPrev.y+=A*y.inverseMass,y.anglePrev+=y.inverseInertia*((w.x-y.position.x)*A-(w.y-y.position.y)*I)),T.isStatic||T.isSleeping||(T.positionPrev.x-=I*T.inverseMass,T.positionPrev.y-=A*T.inverseMass,T.anglePrev-=T.inverseInertia*((w.x-T.position.x)*A-(w.y-T.position.y)*I))}}}}},i.solveVelocity=function(u,c){var f=c/o._baseDelta,h=f*f,d=h*f,m=-i._restingThresh*f,p=i._restingThreshTangent,g=i._frictionNormalMultiplier*f,y=i._frictionMaxStatic,T=u.length,v,C,E,w;for(E=0;E<T;E++){var _=u[E];if(!(!_.isActive||_.isSensor)){var S=_.collision,I=S.parentA,A=S.parentB,P=I.velocity,N=A.velocity,j=S.normal.x,M=S.normal.y,L=S.tangent.x,B=S.tangent.y,V=_.activeContacts,F=V.length,q=1/F,R=I.inverseMass+A.inverseMass,$=_.friction*_.frictionStatic*g;for(P.x=I.position.x-I.positionPrev.x,P.y=I.position.y-I.positionPrev.y,N.x=A.position.x-A.positionPrev.x,N.y=A.position.y-A.positionPrev.y,I.angularVelocity=I.angle-I.anglePrev,A.angularVelocity=A.angle-A.anglePrev,w=0;w<F;w++){var X=V[w],D=X.vertex,Z=D.x-I.position.x,le=D.y-I.position.y,z=D.x-A.position.x,ee=D.y-A.position.y,K=P.x-le*I.angularVelocity,ce=P.y+Z*I.angularVelocity,fe=N.x-ee*A.angularVelocity,re=N.y+z*A.angularVelocity,ne=K-fe,ge=ce-re,Te=j*ne+M*ge,Ne=L*ne+B*ge,Oe=_.separation+Te,be=Math.min(Oe,1);be=Oe<0?0:be;var Fe=be*$;Ne<-Fe||Ne>Fe?(C=Ne>0?Ne:-Ne,v=_.friction*(Ne>0?1:-1)*d,v<-C?v=-C:v>C&&(v=C)):(v=Ne,C=y);var te=Z*M-le*j,Re=z*M-ee*j,me=q/(R+I.inverseInertia*te*te+A.inverseInertia*Re*Re),je=(1+_.restitution)*Te*me;if(v*=me,Te<m)X.normalImpulse=0;else{var st=X.normalImpulse;X.normalImpulse+=je,X.normalImpulse>0&&(X.normalImpulse=0),je=X.normalImpulse-st}if(Ne<-p||Ne>p)X.tangentImpulse=0;else{var Be=X.tangentImpulse;X.tangentImpulse+=v,X.tangentImpulse<-C&&(X.tangentImpulse=-C),X.tangentImpulse>C&&(X.tangentImpulse=C),v=X.tangentImpulse-Be}var at=j*je+L*v,G=M*je+B*v;I.isStatic||I.isSleeping||(I.positionPrev.x+=at*I.inverseMass,I.positionPrev.y+=G*I.inverseMass,I.anglePrev+=(Z*G-le*at)*I.inverseInertia),A.isStatic||A.isSleeping||(A.positionPrev.x-=at*A.inverseMass,A.positionPrev.y-=G*A.inverseMass,A.anglePrev-=(z*G-ee*at)*A.inverseInertia)}}}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(9),o=s(0);(function(){i.create=function(l){return o.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},l)},i.update=function(l,u,c){var f=l.list,h=f.length,d=l.table,m=u.length,p=l.collisionStart,g=l.collisionEnd,y=l.collisionActive,T,v,C,E;for(p.length=0,g.length=0,y.length=0,E=0;E<h;E++)f[E].confirmedActive=!1;for(E=0;E<m;E++)T=u[E],C=T.pair,C?(C.isActive?y.push(C):p.push(C),a.update(C,T,c),C.confirmedActive=!0):(C=a.create(T,c),d[C.id]=C,p.push(C),f.push(C));var w=[];for(h=f.length,E=0;E<h;E++)C=f[E],C.confirmedActive||(a.setActive(C,!1,c),g.push(C),!C.collision.bodyA.isSleeping&&!C.collision.bodyB.isSleeping&&w.push(E));for(E=0;E<w.length;E++)v=w[E]-E,C=f[v],f.splice(v,1),delete d[C.id]},i.clear=function(l){return l.table={},l.list.length=0,l.collisionStart.length=0,l.collisionActive.length=0,l.collisionEnd.length=0,l}})()}),(function(n,r,s){var i=n.exports=s(21);i.Axes=s(11),i.Bodies=s(12),i.Body=s(4),i.Bounds=s(1),i.Collision=s(8),i.Common=s(0),i.Composite=s(6),i.Composites=s(22),i.Constraint=s(10),i.Contact=s(16),i.Detector=s(13),i.Engine=s(17),i.Events=s(5),i.Grid=s(23),i.Mouse=s(14),i.MouseConstraint=s(24),i.Pair=s(9),i.Pairs=s(19),i.Plugin=s(15),i.Query=s(25),i.Render=s(26),i.Resolver=s(18),i.Runner=s(27),i.SAT=s(28),i.Sleeping=s(7),i.Svg=s(29),i.Vector=s(2),i.Vertices=s(3),i.World=s(30),i.Engine.run=i.Runner.run,i.Common.deprecated(i.Engine,"run","Engine.run ➤ use Matter.Runner.run(engine) instead")}),(function(n,r,s){var i={};n.exports=i;var a=s(15),o=s(0);(function(){i.name="matter-js",i.version="0.19.0",i.uses=[],i.used=[],i.use=function(){a.use(i,Array.prototype.slice.call(arguments))},i.before=function(l,u){return l=l.replace(/^Matter./,""),o.chainPathBefore(i,l,u)},i.after=function(l,u){return l=l.replace(/^Matter./,""),o.chainPathAfter(i,l,u)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(6),o=s(10),l=s(0),u=s(4),c=s(12),f=l.deprecated;(function(){i.stack=function(h,d,m,p,g,y,T){for(var v=a.create({label:"Stack"}),C=h,E=d,w,_=0,S=0;S<p;S++){for(var I=0,A=0;A<m;A++){var P=T(C,E,A,S,w,_);if(P){var N=P.bounds.max.y-P.bounds.min.y,j=P.bounds.max.x-P.bounds.min.x;N>I&&(I=N),u.translate(P,{x:j*.5,y:N*.5}),C=P.bounds.max.x+g,a.addBody(v,P),w=P,_+=1}else C+=g}E+=I+y,C=h}return v},i.chain=function(h,d,m,p,g,y){for(var T=h.bodies,v=1;v<T.length;v++){var C=T[v-1],E=T[v],w=C.bounds.max.y-C.bounds.min.y,_=C.bounds.max.x-C.bounds.min.x,S=E.bounds.max.y-E.bounds.min.y,I=E.bounds.max.x-E.bounds.min.x,A={bodyA:C,pointA:{x:_*d,y:w*m},bodyB:E,pointB:{x:I*p,y:S*g}},P=l.extend(A,y);a.addConstraint(h,o.create(P))}return h.label+=" Chain",h},i.mesh=function(h,d,m,p,g){var y=h.bodies,T,v,C,E,w;for(T=0;T<m;T++){for(v=1;v<d;v++)C=y[v-1+T*d],E=y[v+T*d],a.addConstraint(h,o.create(l.extend({bodyA:C,bodyB:E},g)));if(T>0)for(v=0;v<d;v++)C=y[v+(T-1)*d],E=y[v+T*d],a.addConstraint(h,o.create(l.extend({bodyA:C,bodyB:E},g))),p&&v>0&&(w=y[v-1+(T-1)*d],a.addConstraint(h,o.create(l.extend({bodyA:w,bodyB:E},g)))),p&&v<d-1&&(w=y[v+1+(T-1)*d],a.addConstraint(h,o.create(l.extend({bodyA:w,bodyB:E},g))))}return h.label+=" Mesh",h},i.pyramid=function(h,d,m,p,g,y,T){return i.stack(h,d,m,p,g,y,function(v,C,E,w,_,S){var I=Math.min(p,Math.ceil(m/2)),A=_?_.bounds.max.x-_.bounds.min.x:0;if(!(w>I)){w=I-w;var P=w,N=m-1-w;if(!(E<P||E>N)){S===1&&u.translate(_,{x:(E+(m%2===1?1:-1))*A,y:0});var j=_?E*A:0;return T(h+j+E*g,C,E,w,_,S)}}})},i.newtonsCradle=function(h,d,m,p,g){for(var y=a.create({label:"Newtons Cradle"}),T=0;T<m;T++){var v=1.9,C=c.circle(h+T*(p*v),d+g,p,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),E=o.create({pointA:{x:h+T*(p*v),y:d},bodyB:C});a.addBody(y,C),a.addConstraint(y,E)}return y},f(i,"newtonsCradle","Composites.newtonsCradle ➤ moved to newtonsCradle example"),i.car=function(h,d,m,p,g){var y=u.nextGroup(!0),T=20,v=-m*.5+T,C=m*.5-T,E=0,w=a.create({label:"Car"}),_=c.rectangle(h,d,m,p,{collisionFilter:{group:y},chamfer:{radius:p*.5},density:2e-4}),S=c.circle(h+v,d+E,g,{collisionFilter:{group:y},friction:.8}),I=c.circle(h+C,d+E,g,{collisionFilter:{group:y},friction:.8}),A=o.create({bodyB:_,pointB:{x:v,y:E},bodyA:S,stiffness:1,length:0}),P=o.create({bodyB:_,pointB:{x:C,y:E},bodyA:I,stiffness:1,length:0});return a.addBody(w,_),a.addBody(w,S),a.addBody(w,I),a.addConstraint(w,A),a.addConstraint(w,P),w},f(i,"car","Composites.car ➤ moved to car example"),i.softBody=function(h,d,m,p,g,y,T,v,C,E){C=l.extend({inertia:1/0},C),E=l.extend({stiffness:.2,render:{type:"line",anchors:!1}},E);var w=i.stack(h,d,m,p,g,y,function(_,S){return c.circle(_,S,v,C)});return i.mesh(w,m,p,T,E),w.label="Soft Body",w},f(i,"softBody","Composites.softBody ➤ moved to softBody and cloth examples")})()}),(function(n,r,s){var i={};n.exports=i;var a=s(9),o=s(0),l=o.deprecated;(function(){i.create=function(u){var c={buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return o.extend(c,u)},i.update=function(u,c,f,h){var d,m,p,g=f.world,y=u.buckets,T,v,C=!1;for(d=0;d<c.length;d++){var E=c[d];if(!(E.isSleeping&&!h)&&!(g.bounds&&(E.bounds.max.x<g.bounds.min.x||E.bounds.min.x>g.bounds.max.x||E.bounds.max.y<g.bounds.min.y||E.bounds.min.y>g.bounds.max.y))){var w=i._getRegion(u,E);if(!E.region||w.id!==E.region.id||h){(!E.region||h)&&(E.region=w);var _=i._regionUnion(w,E.region);for(m=_.startCol;m<=_.endCol;m++)for(p=_.startRow;p<=_.endRow;p++){v=i._getBucketId(m,p),T=y[v];var S=m>=w.startCol&&m<=w.endCol&&p>=w.startRow&&p<=w.endRow,I=m>=E.region.startCol&&m<=E.region.endCol&&p>=E.region.startRow&&p<=E.region.endRow;!S&&I&&I&&T&&i._bucketRemoveBody(u,T,E),(E.region===w||S&&!I||h)&&(T||(T=i._createBucket(y,v)),i._bucketAddBody(u,T,E))}E.region=w,C=!0}}}C&&(u.pairsList=i._createActivePairsList(u))},l(i,"update","Grid.update ➤ replaced by Matter.Detector"),i.clear=function(u){u.buckets={},u.pairs={},u.pairsList=[]},l(i,"clear","Grid.clear ➤ replaced by Matter.Detector"),i._regionUnion=function(u,c){var f=Math.min(u.startCol,c.startCol),h=Math.max(u.endCol,c.endCol),d=Math.min(u.startRow,c.startRow),m=Math.max(u.endRow,c.endRow);return i._createRegion(f,h,d,m)},i._getRegion=function(u,c){var f=c.bounds,h=Math.floor(f.min.x/u.bucketWidth),d=Math.floor(f.max.x/u.bucketWidth),m=Math.floor(f.min.y/u.bucketHeight),p=Math.floor(f.max.y/u.bucketHeight);return i._createRegion(h,d,m,p)},i._createRegion=function(u,c,f,h){return{id:u+","+c+","+f+","+h,startCol:u,endCol:c,startRow:f,endRow:h}},i._getBucketId=function(u,c){return"C"+u+"R"+c},i._createBucket=function(u,c){var f=u[c]=[];return f},i._bucketAddBody=function(u,c,f){var h=u.pairs,d=a.id,m=c.length,p;for(p=0;p<m;p++){var g=c[p];if(!(f.id===g.id||f.isStatic&&g.isStatic)){var y=d(f,g),T=h[y];T?T[2]+=1:h[y]=[f,g,1]}}c.push(f)},i._bucketRemoveBody=function(u,c,f){var h=u.pairs,d=a.id,m;c.splice(o.indexOf(c,f),1);var p=c.length;for(m=0;m<p;m++){var g=h[d(f,c[m])];g&&(g[2]-=1)}},i._createActivePairsList=function(u){var c,f=u.pairs,h=o.keys(f),d=h.length,m=[],p;for(p=0;p<d;p++)c=f[h[p]],c[2]>0?m.push(c):delete f[h[p]];return m}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(3),o=s(7),l=s(14),u=s(5),c=s(13),f=s(10),h=s(6),d=s(0),m=s(1);(function(){i.create=function(p,g){var y=(p?p.mouse:null)||(g?g.mouse:null);y||(p&&p.render&&p.render.canvas?y=l.create(p.render.canvas):g&&g.element?y=l.create(g.element):(y=l.create(),d.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var T=f.create({label:"Mouse Constraint",pointA:y.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),v={type:"mouseConstraint",mouse:y,element:null,body:null,constraint:T,collisionFilter:{category:1,mask:4294967295,group:0}},C=d.extend(v,g);return u.on(p,"beforeUpdate",function(){var E=h.allBodies(p.world);i.update(C,E),i._triggerEvents(C)}),C},i.update=function(p,g){var y=p.mouse,T=p.constraint,v=p.body;if(y.button===0){if(T.bodyB)o.set(T.bodyB,!1),T.pointA=y.position;else for(var C=0;C<g.length;C++)if(v=g[C],m.contains(v.bounds,y.position)&&c.canCollide(v.collisionFilter,p.collisionFilter))for(var E=v.parts.length>1?1:0;E<v.parts.length;E++){var w=v.parts[E];if(a.contains(w.vertices,y.position)){T.pointA=y.position,T.bodyB=p.body=v,T.pointB={x:y.position.x-v.position.x,y:y.position.y-v.position.y},T.angleB=v.angle,o.set(v,!1),u.trigger(p,"startdrag",{mouse:y,body:v});break}}}else T.bodyB=p.body=null,T.pointB=null,v&&u.trigger(p,"enddrag",{mouse:y,body:v})},i._triggerEvents=function(p){var g=p.mouse,y=g.sourceEvents;y.mousemove&&u.trigger(p,"mousemove",{mouse:g}),y.mousedown&&u.trigger(p,"mousedown",{mouse:g}),y.mouseup&&u.trigger(p,"mouseup",{mouse:g}),l.clearSourceEvents(g)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(2),o=s(8),l=s(1),u=s(12),c=s(3);(function(){i.collides=function(f,h){for(var d=[],m=h.length,p=f.bounds,g=o.collides,y=l.overlaps,T=0;T<m;T++){var v=h[T],C=v.parts.length,E=C===1?0:1;if(y(v.bounds,p))for(var w=E;w<C;w++){var _=v.parts[w];if(y(_.bounds,p)){var S=g(_,f);if(S){d.push(S);break}}}}return d},i.ray=function(f,h,d,m){m=m||1e-100;for(var p=a.angle(h,d),g=a.magnitude(a.sub(h,d)),y=(d.x+h.x)*.5,T=(d.y+h.y)*.5,v=u.rectangle(y,T,g,m,{angle:p}),C=i.collides(v,f),E=0;E<C.length;E+=1){var w=C[E];w.body=w.bodyB=w.bodyA}return C},i.region=function(f,h,d){for(var m=[],p=0;p<f.length;p++){var g=f[p],y=l.overlaps(g.bounds,h);(y&&!d||!y&&d)&&m.push(g)}return m},i.point=function(f,h){for(var d=[],m=0;m<f.length;m++){var p=f[m];if(l.contains(p.bounds,h))for(var g=p.parts.length===1?0:1;g<p.parts.length;g++){var y=p.parts[g];if(l.contains(y.bounds,h)&&c.contains(y.vertices,h)){d.push(p);break}}}return d}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(4),o=s(0),l=s(6),u=s(1),c=s(5),f=s(2),h=s(14);(function(){var d,m;typeof window<"u"&&(d=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(E){window.setTimeout(function(){E(o.now())},1e3/60)},m=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),i._goodFps=30,i._goodDelta=1e3/60,i.create=function(E){var w={engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,timing:{historySize:60,delta:0,deltaHistory:[],lastTime:0,lastTimestamp:0,lastElapsed:0,timestampElapsed:0,timestampElapsedHistory:[],engineDeltaHistory:[],engineElapsedHistory:[],elapsedHistory:[]},options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",hasBounds:!!E.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showStats:!1,showPerformance:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},_=o.extend(w,E);return _.canvas&&(_.canvas.width=_.options.width||_.canvas.width,_.canvas.height=_.options.height||_.canvas.height),_.mouse=E.mouse,_.engine=E.engine,_.canvas=_.canvas||y(_.options.width,_.options.height),_.context=_.canvas.getContext("2d"),_.textures={},_.bounds=_.bounds||{min:{x:0,y:0},max:{x:_.canvas.width,y:_.canvas.height}},_.controller=i,_.options.showBroadphase=!1,_.options.pixelRatio!==1&&i.setPixelRatio(_,_.options.pixelRatio),o.isElement(_.element)&&_.element.appendChild(_.canvas),_},i.run=function(E){(function w(_){E.frameRequestId=d(w),p(E,_),i.world(E,_),(E.options.showStats||E.options.showDebug)&&i.stats(E,E.context,_),(E.options.showPerformance||E.options.showDebug)&&i.performance(E,E.context,_)})()},i.stop=function(E){m(E.frameRequestId)},i.setPixelRatio=function(E,w){var _=E.options,S=E.canvas;w==="auto"&&(w=T(S)),_.pixelRatio=w,S.setAttribute("data-pixel-ratio",w),S.width=_.width*w,S.height=_.height*w,S.style.width=_.width+"px",S.style.height=_.height+"px"},i.lookAt=function(E,w,_,S){S=typeof S<"u"?S:!0,w=o.isArray(w)?w:[w],_=_||{x:0,y:0};for(var I={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},A=0;A<w.length;A+=1){var P=w[A],N=P.bounds?P.bounds.min:P.min||P.position||P,j=P.bounds?P.bounds.max:P.max||P.position||P;N&&j&&(N.x<I.min.x&&(I.min.x=N.x),j.x>I.max.x&&(I.max.x=j.x),N.y<I.min.y&&(I.min.y=N.y),j.y>I.max.y&&(I.max.y=j.y))}var M=I.max.x-I.min.x+2*_.x,L=I.max.y-I.min.y+2*_.y,B=E.canvas.height,V=E.canvas.width,F=V/B,q=M/L,R=1,$=1;q>F?$=q/F:R=F/q,E.options.hasBounds=!0,E.bounds.min.x=I.min.x,E.bounds.max.x=I.min.x+M*R,E.bounds.min.y=I.min.y,E.bounds.max.y=I.min.y+L*$,S&&(E.bounds.min.x+=M*.5-M*R*.5,E.bounds.max.x+=M*.5-M*R*.5,E.bounds.min.y+=L*.5-L*$*.5,E.bounds.max.y+=L*.5-L*$*.5),E.bounds.min.x-=_.x,E.bounds.max.x-=_.x,E.bounds.min.y-=_.y,E.bounds.max.y-=_.y,E.mouse&&(h.setScale(E.mouse,{x:(E.bounds.max.x-E.bounds.min.x)/E.canvas.width,y:(E.bounds.max.y-E.bounds.min.y)/E.canvas.height}),h.setOffset(E.mouse,E.bounds.min))},i.startViewTransform=function(E){var w=E.bounds.max.x-E.bounds.min.x,_=E.bounds.max.y-E.bounds.min.y,S=w/E.options.width,I=_/E.options.height;E.context.setTransform(E.options.pixelRatio/S,0,0,E.options.pixelRatio/I,0,0),E.context.translate(-E.bounds.min.x,-E.bounds.min.y)},i.endViewTransform=function(E){E.context.setTransform(E.options.pixelRatio,0,0,E.options.pixelRatio,0,0)},i.world=function(E,w){var _=o.now(),S=E.engine,I=S.world,A=E.canvas,P=E.context,N=E.options,j=E.timing,M=l.allBodies(I),L=l.allConstraints(I),B=N.wireframes?N.wireframeBackground:N.background,V=[],F=[],q,R={timestamp:S.timing.timestamp};if(c.trigger(E,"beforeRender",R),E.currentBackground!==B&&C(E,B),P.globalCompositeOperation="source-in",P.fillStyle="transparent",P.fillRect(0,0,A.width,A.height),P.globalCompositeOperation="source-over",N.hasBounds){for(q=0;q<M.length;q++){var $=M[q];u.overlaps($.bounds,E.bounds)&&V.push($)}for(q=0;q<L.length;q++){var X=L[q],D=X.bodyA,Z=X.bodyB,le=X.pointA,z=X.pointB;D&&(le=f.add(D.position,X.pointA)),Z&&(z=f.add(Z.position,X.pointB)),!(!le||!z)&&(u.contains(E.bounds,le)||u.contains(E.bounds,z))&&F.push(X)}i.startViewTransform(E),E.mouse&&(h.setScale(E.mouse,{x:(E.bounds.max.x-E.bounds.min.x)/E.options.width,y:(E.bounds.max.y-E.bounds.min.y)/E.options.height}),h.setOffset(E.mouse,E.bounds.min))}else F=L,V=M,E.options.pixelRatio!==1&&E.context.setTransform(E.options.pixelRatio,0,0,E.options.pixelRatio,0,0);!N.wireframes||S.enableSleeping&&N.showSleeping?i.bodies(E,V,P):(N.showConvexHulls&&i.bodyConvexHulls(E,V,P),i.bodyWireframes(E,V,P)),N.showBounds&&i.bodyBounds(E,V,P),(N.showAxes||N.showAngleIndicator)&&i.bodyAxes(E,V,P),N.showPositions&&i.bodyPositions(E,V,P),N.showVelocity&&i.bodyVelocity(E,V,P),N.showIds&&i.bodyIds(E,V,P),N.showSeparations&&i.separations(E,S.pairs.list,P),N.showCollisions&&i.collisions(E,S.pairs.list,P),N.showVertexNumbers&&i.vertexNumbers(E,V,P),N.showMousePosition&&i.mousePosition(E,E.mouse,P),i.constraints(F,P),N.hasBounds&&i.endViewTransform(E),c.trigger(E,"afterRender",R),j.lastElapsed=o.now()-_},i.stats=function(E,w,_){for(var S=E.engine,I=S.world,A=l.allBodies(I),P=0,N=55,j=44,M=0,L=0,B=0;B<A.length;B+=1)P+=A[B].parts.length;var V={Part:P,Body:A.length,Cons:l.allConstraints(I).length,Comp:l.allComposites(I).length,Pair:S.pairs.list.length};w.fillStyle="#0e0f19",w.fillRect(M,L,N*5.5,j),w.font="12px Arial",w.textBaseline="top",w.textAlign="right";for(var F in V){var q=V[F];w.fillStyle="#aaa",w.fillText(F,M+N,L+8),w.fillStyle="#eee",w.fillText(q,M+N,L+26),M+=N}},i.performance=function(E,w){var _=E.engine,S=E.timing,I=S.deltaHistory,A=S.elapsedHistory,P=S.timestampElapsedHistory,N=S.engineDeltaHistory,j=S.engineElapsedHistory,M=_.timing.lastDelta,L=g(I),B=g(A),V=g(N),F=g(j),q=g(P),R=q/L||0,$=1e3/L||0,X=4,D=12,Z=60,le=34,z=10,ee=69;w.fillStyle="#0e0f19",w.fillRect(0,50,D*4+Z*5+22,le),i.status(w,z,ee,Z,X,I.length,Math.round($)+" fps",$/i._goodFps,function(K){return I[K]/L-1}),i.status(w,z+D+Z,ee,Z,X,N.length,M.toFixed(2)+" dt",i._goodDelta/M,function(K){return N[K]/V-1}),i.status(w,z+(D+Z)*2,ee,Z,X,j.length,F.toFixed(2)+" ut",1-F/i._goodFps,function(K){return j[K]/F-1}),i.status(w,z+(D+Z)*3,ee,Z,X,A.length,B.toFixed(2)+" rt",1-B/i._goodFps,function(K){return A[K]/B-1}),i.status(w,z+(D+Z)*4,ee,Z,X,P.length,R.toFixed(2)+" x",R*R*R,function(K){return(P[K]/I[K]/R||0)-1})},i.status=function(E,w,_,S,I,A,P,N,j){E.strokeStyle="#888",E.fillStyle="#444",E.lineWidth=1,E.fillRect(w,_+7,S,1),E.beginPath(),E.moveTo(w,_+7-I*o.clamp(.4*j(0),-2,2));for(var M=0;M<S;M+=1)E.lineTo(w+M,_+7-(M<A?I*o.clamp(.4*j(M),-2,2):0));E.stroke(),E.fillStyle="hsl("+o.clamp(25+95*N,0,120)+",100%,60%)",E.fillRect(w,_-7,4,4),E.font="12px Arial",E.textBaseline="middle",E.textAlign="right",E.fillStyle="#eee",E.fillText(P,w+S,_-5)},i.constraints=function(E,w){for(var _=w,S=0;S<E.length;S++){var I=E[S];if(!(!I.render.visible||!I.pointA||!I.pointB)){var A=I.bodyA,P=I.bodyB,N,j;if(A?N=f.add(A.position,I.pointA):N=I.pointA,I.render.type==="pin")_.beginPath(),_.arc(N.x,N.y,3,0,2*Math.PI),_.closePath();else{if(P?j=f.add(P.position,I.pointB):j=I.pointB,_.beginPath(),_.moveTo(N.x,N.y),I.render.type==="spring")for(var M=f.sub(j,N),L=f.perp(f.normalise(M)),B=Math.ceil(o.clamp(I.length/5,12,20)),V,F=1;F<B;F+=1)V=F%2===0?1:-1,_.lineTo(N.x+M.x*(F/B)+L.x*V*4,N.y+M.y*(F/B)+L.y*V*4);_.lineTo(j.x,j.y)}I.render.lineWidth&&(_.lineWidth=I.render.lineWidth,_.strokeStyle=I.render.strokeStyle,_.stroke()),I.render.anchors&&(_.fillStyle=I.render.strokeStyle,_.beginPath(),_.arc(N.x,N.y,3,0,2*Math.PI),_.arc(j.x,j.y,3,0,2*Math.PI),_.closePath(),_.fill())}}},i.bodies=function(E,w,_){var S=_;E.engine;var I=E.options,A=I.showInternalEdges||!I.wireframes,P,N,j,M;for(j=0;j<w.length;j++)if(P=w[j],!!P.render.visible){for(M=P.parts.length>1?1:0;M<P.parts.length;M++)if(N=P.parts[M],!!N.render.visible){if(I.showSleeping&&P.isSleeping?S.globalAlpha=.5*N.render.opacity:N.render.opacity!==1&&(S.globalAlpha=N.render.opacity),N.render.sprite&&N.render.sprite.texture&&!I.wireframes){var L=N.render.sprite,B=v(E,L.texture);S.translate(N.position.x,N.position.y),S.rotate(N.angle),S.drawImage(B,B.width*-L.xOffset*L.xScale,B.height*-L.yOffset*L.yScale,B.width*L.xScale,B.height*L.yScale),S.rotate(-N.angle),S.translate(-N.position.x,-N.position.y)}else{if(N.circleRadius)S.beginPath(),S.arc(N.position.x,N.position.y,N.circleRadius,0,2*Math.PI);else{S.beginPath(),S.moveTo(N.vertices[0].x,N.vertices[0].y);for(var V=1;V<N.vertices.length;V++)!N.vertices[V-1].isInternal||A?S.lineTo(N.vertices[V].x,N.vertices[V].y):S.moveTo(N.vertices[V].x,N.vertices[V].y),N.vertices[V].isInternal&&!A&&S.moveTo(N.vertices[(V+1)%N.vertices.length].x,N.vertices[(V+1)%N.vertices.length].y);S.lineTo(N.vertices[0].x,N.vertices[0].y),S.closePath()}I.wireframes?(S.lineWidth=1,S.strokeStyle="#bbb",S.stroke()):(S.fillStyle=N.render.fillStyle,N.render.lineWidth&&(S.lineWidth=N.render.lineWidth,S.strokeStyle=N.render.strokeStyle,S.stroke()),S.fill())}S.globalAlpha=1}}},i.bodyWireframes=function(E,w,_){var S=_,I=E.options.showInternalEdges,A,P,N,j,M;for(S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.render.visible)for(M=A.parts.length>1?1:0;M<A.parts.length;M++){for(P=A.parts[M],S.moveTo(P.vertices[0].x,P.vertices[0].y),j=1;j<P.vertices.length;j++)!P.vertices[j-1].isInternal||I?S.lineTo(P.vertices[j].x,P.vertices[j].y):S.moveTo(P.vertices[j].x,P.vertices[j].y),P.vertices[j].isInternal&&!I&&S.moveTo(P.vertices[(j+1)%P.vertices.length].x,P.vertices[(j+1)%P.vertices.length].y);S.lineTo(P.vertices[0].x,P.vertices[0].y)}S.lineWidth=1,S.strokeStyle="#bbb",S.stroke()},i.bodyConvexHulls=function(E,w,_){var S=_,I,A,P;for(S.beginPath(),A=0;A<w.length;A++)if(I=w[A],!(!I.render.visible||I.parts.length===1)){for(S.moveTo(I.vertices[0].x,I.vertices[0].y),P=1;P<I.vertices.length;P++)S.lineTo(I.vertices[P].x,I.vertices[P].y);S.lineTo(I.vertices[0].x,I.vertices[0].y)}S.lineWidth=1,S.strokeStyle="rgba(255,255,255,0.2)",S.stroke()},i.vertexNumbers=function(E,w,_){var S=_,I,A,P;for(I=0;I<w.length;I++){var N=w[I].parts;for(P=N.length>1?1:0;P<N.length;P++){var j=N[P];for(A=0;A<j.vertices.length;A++)S.fillStyle="rgba(255,255,255,0.2)",S.fillText(I+"_"+A,j.position.x+(j.vertices[A].x-j.position.x)*.8,j.position.y+(j.vertices[A].y-j.position.y)*.8)}}},i.mousePosition=function(E,w,_){var S=_;S.fillStyle="rgba(255,255,255,0.8)",S.fillText(w.position.x+" "+w.position.y,w.position.x+5,w.position.y-5)},i.bodyBounds=function(E,w,_){var S=_;E.engine;var I=E.options;S.beginPath();for(var A=0;A<w.length;A++){var P=w[A];if(P.render.visible)for(var N=w[A].parts,j=N.length>1?1:0;j<N.length;j++){var M=N[j];S.rect(M.bounds.min.x,M.bounds.min.y,M.bounds.max.x-M.bounds.min.x,M.bounds.max.y-M.bounds.min.y)}}I.wireframes?S.strokeStyle="rgba(255,255,255,0.08)":S.strokeStyle="rgba(0,0,0,0.1)",S.lineWidth=1,S.stroke()},i.bodyAxes=function(E,w,_){var S=_;E.engine;var I=E.options,A,P,N,j;for(S.beginPath(),P=0;P<w.length;P++){var M=w[P],L=M.parts;if(M.render.visible)if(I.showAxes)for(N=L.length>1?1:0;N<L.length;N++)for(A=L[N],j=0;j<A.axes.length;j++){var B=A.axes[j];S.moveTo(A.position.x,A.position.y),S.lineTo(A.position.x+B.x*20,A.position.y+B.y*20)}else for(N=L.length>1?1:0;N<L.length;N++)for(A=L[N],j=0;j<A.axes.length;j++)S.moveTo(A.position.x,A.position.y),S.lineTo((A.vertices[0].x+A.vertices[A.vertices.length-1].x)/2,(A.vertices[0].y+A.vertices[A.vertices.length-1].y)/2)}I.wireframes?(S.strokeStyle="indianred",S.lineWidth=1):(S.strokeStyle="rgba(255, 255, 255, 0.4)",S.globalCompositeOperation="overlay",S.lineWidth=2),S.stroke(),S.globalCompositeOperation="source-over"},i.bodyPositions=function(E,w,_){var S=_;E.engine;var I=E.options,A,P,N,j;for(S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.render.visible)for(j=0;j<A.parts.length;j++)P=A.parts[j],S.arc(P.position.x,P.position.y,3,0,2*Math.PI,!1),S.closePath();for(I.wireframes?S.fillStyle="indianred":S.fillStyle="rgba(0,0,0,0.5)",S.fill(),S.beginPath(),N=0;N<w.length;N++)A=w[N],A.render.visible&&(S.arc(A.positionPrev.x,A.positionPrev.y,2,0,2*Math.PI,!1),S.closePath());S.fillStyle="rgba(255,165,0,0.8)",S.fill()},i.bodyVelocity=function(E,w,_){var S=_;S.beginPath();for(var I=0;I<w.length;I++){var A=w[I];if(A.render.visible){var P=a.getVelocity(A);S.moveTo(A.position.x,A.position.y),S.lineTo(A.position.x+P.x,A.position.y+P.y)}}S.lineWidth=3,S.strokeStyle="cornflowerblue",S.stroke()},i.bodyIds=function(E,w,_){var S=_,I,A;for(I=0;I<w.length;I++)if(w[I].render.visible){var P=w[I].parts;for(A=P.length>1?1:0;A<P.length;A++){var N=P[A];S.font="12px Arial",S.fillStyle="rgba(255,255,255,0.5)",S.fillText(N.id,N.position.x+10,N.position.y-10)}}},i.collisions=function(E,w,_){var S=_,I=E.options,A,P,N,j;for(S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.isActive)for(P=A.collision,j=0;j<A.activeContacts.length;j++){var M=A.activeContacts[j],L=M.vertex;S.rect(L.x-1.5,L.y-1.5,3.5,3.5)}for(I.wireframes?S.fillStyle="rgba(255,255,255,0.7)":S.fillStyle="orange",S.fill(),S.beginPath(),N=0;N<w.length;N++)if(A=w[N],!!A.isActive&&(P=A.collision,A.activeContacts.length>0)){var B=A.activeContacts[0].vertex.x,V=A.activeContacts[0].vertex.y;A.activeContacts.length===2&&(B=(A.activeContacts[0].vertex.x+A.activeContacts[1].vertex.x)/2,V=(A.activeContacts[0].vertex.y+A.activeContacts[1].vertex.y)/2),P.bodyB===P.supports[0].body||P.bodyA.isStatic===!0?S.moveTo(B-P.normal.x*8,V-P.normal.y*8):S.moveTo(B+P.normal.x*8,V+P.normal.y*8),S.lineTo(B,V)}I.wireframes?S.strokeStyle="rgba(255,165,0,0.7)":S.strokeStyle="orange",S.lineWidth=1,S.stroke()},i.separations=function(E,w,_){var S=_,I=E.options,A,P,N,j,M;for(S.beginPath(),M=0;M<w.length;M++)if(A=w[M],!!A.isActive){P=A.collision,N=P.bodyA,j=P.bodyB;var L=1;!j.isStatic&&!N.isStatic&&(L=.5),j.isStatic&&(L=0),S.moveTo(j.position.x,j.position.y),S.lineTo(j.position.x-P.penetration.x*L,j.position.y-P.penetration.y*L),L=1,!j.isStatic&&!N.isStatic&&(L=.5),N.isStatic&&(L=0),S.moveTo(N.position.x,N.position.y),S.lineTo(N.position.x+P.penetration.x*L,N.position.y+P.penetration.y*L)}I.wireframes?S.strokeStyle="rgba(255,165,0,0.5)":S.strokeStyle="orange",S.stroke()},i.inspector=function(E,w){E.engine;var _=E.selected,S=E.render,I=S.options,A;if(I.hasBounds){var P=S.bounds.max.x-S.bounds.min.x,N=S.bounds.max.y-S.bounds.min.y,j=P/S.options.width,M=N/S.options.height;w.scale(1/j,1/M),w.translate(-S.bounds.min.x,-S.bounds.min.y)}for(var L=0;L<_.length;L++){var B=_[L].data;switch(w.translate(.5,.5),w.lineWidth=1,w.strokeStyle="rgba(255,165,0,0.9)",w.setLineDash([1,2]),B.type){case"body":A=B.bounds,w.beginPath(),w.rect(Math.floor(A.min.x-3),Math.floor(A.min.y-3),Math.floor(A.max.x-A.min.x+6),Math.floor(A.max.y-A.min.y+6)),w.closePath(),w.stroke();break;case"constraint":var V=B.pointA;B.bodyA&&(V=B.pointB),w.beginPath(),w.arc(V.x,V.y,10,0,2*Math.PI),w.closePath(),w.stroke();break}w.setLineDash([]),w.translate(-.5,-.5)}E.selectStart!==null&&(w.translate(.5,.5),w.lineWidth=1,w.strokeStyle="rgba(255,165,0,0.6)",w.fillStyle="rgba(255,165,0,0.1)",A=E.selectBounds,w.beginPath(),w.rect(Math.floor(A.min.x),Math.floor(A.min.y),Math.floor(A.max.x-A.min.x),Math.floor(A.max.y-A.min.y)),w.closePath(),w.stroke(),w.fill(),w.translate(-.5,-.5)),I.hasBounds&&w.setTransform(1,0,0,1,0,0)};var p=function(E,w){var _=E.engine,S=E.timing,I=S.historySize,A=_.timing.timestamp;S.delta=w-S.lastTime||i._goodDelta,S.lastTime=w,S.timestampElapsed=A-S.lastTimestamp||0,S.lastTimestamp=A,S.deltaHistory.unshift(S.delta),S.deltaHistory.length=Math.min(S.deltaHistory.length,I),S.engineDeltaHistory.unshift(_.timing.lastDelta),S.engineDeltaHistory.length=Math.min(S.engineDeltaHistory.length,I),S.timestampElapsedHistory.unshift(S.timestampElapsed),S.timestampElapsedHistory.length=Math.min(S.timestampElapsedHistory.length,I),S.engineElapsedHistory.unshift(_.timing.lastElapsed),S.engineElapsedHistory.length=Math.min(S.engineElapsedHistory.length,I),S.elapsedHistory.unshift(S.lastElapsed),S.elapsedHistory.length=Math.min(S.elapsedHistory.length,I)},g=function(E){for(var w=0,_=0;_<E.length;_+=1)w+=E[_];return w/E.length||0},y=function(E,w){var _=document.createElement("canvas");return _.width=E,_.height=w,_.oncontextmenu=function(){return!1},_.onselectstart=function(){return!1},_},T=function(E){var w=E.getContext("2d"),_=window.devicePixelRatio||1,S=w.webkitBackingStorePixelRatio||w.mozBackingStorePixelRatio||w.msBackingStorePixelRatio||w.oBackingStorePixelRatio||w.backingStorePixelRatio||1;return _/S},v=function(E,w){var _=E.textures[w];return _||(_=E.textures[w]=new Image,_.src=w,_)},C=function(E,w){var _=w;/(jpg|gif|png)$/.test(w)&&(_="url("+w+")"),E.canvas.style.background=_,E.canvas.style.backgroundSize="contain",E.currentBackground=w}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(5),o=s(17),l=s(0);(function(){var u,c;if(typeof window<"u"&&(u=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,c=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),!u){var f;u=function(h){f=setTimeout(function(){h(l.now())},1e3/60)},c=function(){clearTimeout(f)}}i.create=function(h){var d={fps:60,deltaSampleSize:60,counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,frameRequestId:null,isFixed:!1,enabled:!0},m=l.extend(d,h);return m.delta=m.delta||1e3/m.fps,m.deltaMin=m.deltaMin||1e3/m.fps,m.deltaMax=m.deltaMax||1e3/(m.fps*.5),m.fps=1e3/m.delta,m},i.run=function(h,d){return typeof h.positionIterations<"u"&&(d=h,h=i.create()),(function m(p){h.frameRequestId=u(m),p&&h.enabled&&i.tick(h,d,p)})(),h},i.tick=function(h,d,m){var p=d.timing,g;h.isFixed?g=h.delta:(g=m-h.timePrev||h.delta,h.timePrev=m,h.deltaHistory.push(g),h.deltaHistory=h.deltaHistory.slice(-h.deltaSampleSize),g=Math.min.apply(null,h.deltaHistory),g=g<h.deltaMin?h.deltaMin:g,g=g>h.deltaMax?h.deltaMax:g,h.delta=g);var y={timestamp:p.timestamp};a.trigger(h,"beforeTick",y),h.frameCounter+=1,m-h.counterTimestamp>=1e3&&(h.fps=h.frameCounter*((m-h.counterTimestamp)/1e3),h.counterTimestamp=m,h.frameCounter=0),a.trigger(h,"tick",y),a.trigger(h,"beforeUpdate",y),o.update(d,g),a.trigger(h,"afterUpdate",y),a.trigger(h,"afterTick",y)},i.stop=function(h){c(h.frameRequestId)},i.start=function(h,d){i.run(h,d)}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(8),o=s(0),l=o.deprecated;(function(){i.collides=function(u,c){return a.collides(u,c)},l(i,"collides","SAT.collides ➤ replaced by Collision.collides")})()}),(function(n,r,s){var i={};n.exports=i,s(1);var a=s(0);(function(){i.pathToVertices=function(o,l){typeof window<"u"&&!("SVGPathSeg"in window)&&a.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var u,c,f,h,d,m,p,g,y,T,v=[],C,E,w=0,_=0,S=0;l=l||15;var I=function(P,N,j){var M=j%2===1&&j>1;if(!y||P!=y.x||N!=y.y){y&&M?(C=y.x,E=y.y):(C=0,E=0);var L={x:C+P,y:E+N};(M||!y)&&(y=L),v.push(L),_=C+P,S=E+N}},A=function(P){var N=P.pathSegTypeAsLetter.toUpperCase();if(N!=="Z"){switch(N){case"M":case"L":case"T":case"C":case"S":case"Q":_=P.x,S=P.y;break;case"H":_=P.x;break;case"V":S=P.y;break}I(_,S,P.pathSegType)}};for(i._svgPathToAbsolute(o),f=o.getTotalLength(),m=[],u=0;u<o.pathSegList.numberOfItems;u+=1)m.push(o.pathSegList.getItem(u));for(p=m.concat();w<f;){if(T=o.getPathSegAtLength(w),d=m[T],d!=g){for(;p.length&&p[0]!=d;)A(p.shift());g=d}switch(d.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":h=o.getPointAtLength(w),I(h.x,h.y,0);break}w+=l}for(u=0,c=p.length;u<c;++u)A(p[u]);return v},i._svgPathToAbsolute=function(o){for(var l,u,c,f,h,d,m=o.pathSegList,p=0,g=0,y=m.numberOfItems,T=0;T<y;++T){var v=m.getItem(T),C=v.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(C))"x"in v&&(p=v.x),"y"in v&&(g=v.y);else switch("x1"in v&&(c=p+v.x1),"x2"in v&&(h=p+v.x2),"y1"in v&&(f=g+v.y1),"y2"in v&&(d=g+v.y2),"x"in v&&(p+=v.x),"y"in v&&(g+=v.y),C){case"m":m.replaceItem(o.createSVGPathSegMovetoAbs(p,g),T);break;case"l":m.replaceItem(o.createSVGPathSegLinetoAbs(p,g),T);break;case"h":m.replaceItem(o.createSVGPathSegLinetoHorizontalAbs(p),T);break;case"v":m.replaceItem(o.createSVGPathSegLinetoVerticalAbs(g),T);break;case"c":m.replaceItem(o.createSVGPathSegCurvetoCubicAbs(p,g,c,f,h,d),T);break;case"s":m.replaceItem(o.createSVGPathSegCurvetoCubicSmoothAbs(p,g,h,d),T);break;case"q":m.replaceItem(o.createSVGPathSegCurvetoQuadraticAbs(p,g,c,f),T);break;case"t":m.replaceItem(o.createSVGPathSegCurvetoQuadraticSmoothAbs(p,g),T);break;case"a":m.replaceItem(o.createSVGPathSegArcAbs(p,g,v.r1,v.r2,v.angle,v.largeArcFlag,v.sweepFlag),T);break;case"z":case"Z":p=l,g=u;break}(C=="M"||C=="m")&&(l=p,u=g)}}})()}),(function(n,r,s){var i={};n.exports=i;var a=s(6);s(0),(function(){i.create=a.create,i.add=a.add,i.remove=a.remove,i.clear=a.clear,i.addComposite=a.addComposite,i.addBody=a.addBody,i.addConstraint=a.addConstraint})()})])})})(ds)),ds.exports}var ab=sb();const pn=Al(ab);{const e=pn.Resolver;e&&typeof e._restingThresh=="number"&&(e._restingThresh=1.4)}const ob=6,zt=28,gn=.92,wa=1.12,lb=34;function cc(e,t,n){return Math.hypot(t-e.startX,n-e.startY)<ob?"click":"drag"}function ub(e){const t=e.length;if(t===0)return"";const n=s=>`${s.x.toFixed(1)} ${s.y.toFixed(1)}`;if(t===1)return`M ${n(e[0])}`;if(t===2)return`M ${n(e[0])} L ${n(e[1])}`;let r=`M ${n(e[0])}`;for(let s=1;s<t-1;s++){const i=e[s],a=e[s+1];r+=` Q ${n(i)} ${((i.x+a.x)/2).toFixed(1)} ${((i.y+a.y)/2).toFixed(1)}`}return`${r} L ${n(e[t-1])}`}function cb(e,t){return e*Math.exp(-t/90)}function db(e,t,n,r){const s=`translate3d(${e.toFixed(1)}px, ${t.toFixed(1)}px, 0)`;if(n<.01)return s;const i=r*180/Math.PI,a=Math.min(.35,n);return`${s} rotate(${i.toFixed(1)}deg) scale(${(1+a).toFixed(3)}, ${(1-a).toFixed(3)}) rotate(${(-i).toFixed(1)}deg)`}const Wh=4e-5,fb=5e-4;function $h(e,t,n){return Math.sin(n*37e-5+t*.0013)*.6+Math.sin(n*19e-5+e*7e-4+1.7)*.4}function Yh(e){switch(e){case"storm":return{wind:.95,gust:1,rainRate:.006,snowRate:0,airDrag:1.05};case"rain":return{wind:.6,gust:.25,rainRate:.004,snowRate:0,airDrag:1};case"snow":return{wind:.25,gust:0,rainRate:0,snowRate:4e-4,airDrag:1};case"fog":return{wind:.06,gust:0,rainRate:0,snowRate:0,airDrag:1.7};case"cloudy":return{wind:.4,gust:.1,rainRate:0,snowRate:0,airDrag:1};case"clear":default:return{wind:.3,gust:0,rainRate:0,snowRate:0,airDrag:1}}}function Gh(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,(t>>>0)/4294967295}const Ur=120,hb=.9,dc=.7,mb=.09,pb=2.2,gb=2,Sa=zt*2.45,xb=.006,Aa=22,Ca=.06;function bb(e){var j;const t=e.ballRadius??zt,n=Yh(e.weather??"clear"),{Engine:r,Bodies:s,Body:i,Composite:a,Constraint:o,Events:l}=pn,u=r.create();u.gravity.y=1,u.positionIterations=8,u.velocityIterations=4;const c=e.nodes.map(M=>{var F,q;const L=((F=M.spawn)==null?void 0:F.x)??M.x,B=((q=M.spawn)==null?void 0:q.y)??M.y,V=s.circle(L,B,t,{restitution:.5,friction:.01,frictionAir:.03*n.airDrag,density:M.isExam?.0016:.001,inertia:1/0,isStatic:!!M.locked,collisionFilter:{group:0,category:2,mask:6}});return{nodeId:M.id,body:V,layoutX:M.x,layoutY:M.y,isExam:!!M.isExam,snow:0,field:0,squash:0,squashAngle:0}});for(const M of c){a.add(u.world,M.body);const L=(j=e.nodes.find(B=>B.id===M.nodeId))==null?void 0:j.spawn;L&&(L.vx!==void 0||L.vy!==void 0)&&i.setVelocity(M.body,{x:L.vx??0,y:L.vy??0})}const f=Ur/2,h={isStatic:!0,restitution:.4,friction:.05,collisionFilter:{category:4,mask:2}},d=(M,L)=>({x:Math.min(e.width-t,Math.max(t,M)),y:Math.min(e.height-t,Math.max(t,L))});a.add(u.world,[s.rectangle(e.width/2,-f,e.width*3,Ur,h),s.rectangle(e.width/2,e.height+f,e.width*3,Ur,h),s.rectangle(-f,e.height/2,Ur,e.height*3,h),s.rectangle(e.width+f,e.height/2,Ur,e.height*3,h)]);const m=M=>({x:M.body.position.x,y:M.body.position.y+t*gn}),p=[];function g(M,L,B,V,F){return"body"in M?o.create({bodyA:M.body,pointA:M.offset,bodyB:L,pointB:B,length:V,stiffness:F,damping:.05}):o.create({pointA:M.point,bodyB:L,pointB:B,length:V,stiffness:F,damping:.05})}function y(M,L,B,V){const F={x:B.body.position.x,y:B.body.position.y+t*gn},q=F.x-M.x,R=F.y-M.y,$=Math.max(60,Math.hypot(q,R)),X=Math.max(5,Math.min(14,Math.round($/lb))),D=$*wa/X,Z=[];let le=L?{body:L,offset:{x:M.x-L.position.x,y:M.y-L.position.y}}:{point:M},z=!0;for(let ee=1;ee<X;ee++){const K=ee/X,ce=Math.sin(Math.PI*K)*$*(wa-1)*.85,fe=s.circle(M.x+q*K,M.y+R*K+ce,3.5,{density:7e-4,frictionAir:.1*n.airDrag,collisionFilter:{category:8,mask:0}});Z.push(fe),a.add(u.world,fe),a.add(u.world,g(le,fe,void 0,D,z?dc:hb)),z=!1,le={body:fe,offset:{x:0,y:0}}}a.add(u.world,g(le,B.body,{x:0,y:t*gn},D,dc)),p.push({from:V,to:B.nodeId,restLen:$*wa,particles:Z})}const T=c[0],v=T?{x:e.anchorKnotX??T.layoutX,y:Cs}:{x:e.width/2,y:Cs};T&&y(v,null,T,"__anchor");for(let M=0;M<c.length-1;M++){const L=c[M],B=c[M+1];y(m(L),L.body,B,L.nodeId)}const C=c[c.length-1],E=e.nextKnot&&(C!=null&&C.isExam)?e.nextKnot:void 0;E&&C&&y(E,null,C,"__next");const w=new Map;for(const M of c){let L=0;for(const V of p)if(V.from===M.nodeId||V.to===M.nodeId)for(const F of V.particles)L+=F.mass*.5;const B=Math.min(.25,L/M.body.mass);w.set(M.nodeId,(1+B)*(.96+Gh(M.nodeId)*.08))}let _=0,S=1;l.on(u,"beforeUpdate",()=>{const M=u.timing.timestamp;_*=.97,n.gust>0&&Math.random()<.0025*n.gust&&(_=n.gust*(.6+Math.random()*.4),S=Math.random()<.5?-1:1);for(const L of c){const B=L.body.mass,V=u.gravity.y*u.gravity.scale,F=$h(L.body.position.x,L.body.position.y,M)*n.wind*Wh*B+S*_*fb*B;let q=-B*V*(w.get(L.nodeId)??1);n.rainRate>0&&Math.random()<n.rainRate&&(q+=B*V*.35,i.applyForce(L.body,L.body.position,{x:(Math.random()-.5)*B*V*.3,y:0})),i.applyForce(L.body,L.body.position,{x:F,y:q})}});const I=[],A=(M,L,B,V)=>{if(M.snow<=Ca)return;const F=Math.max(1,Math.min(V,Math.round(M.snow*V)+1));for(let q=0;q<F;q++){const R=-(.35+Math.random()*1.9),$=t*(.55+Math.random()*.45);I.push({x:M.body.position.x+Math.cos(R)*$,y:M.body.position.y+Math.sin(R)*$,vx:M.body.velocity.x*.75+L.x*(.5+Math.random()*1.8)+(Math.random()-.5)*1.2,vy:M.body.velocity.y*.75+L.y*(.5+Math.random()*1.8)-.6-Math.random()*.8,amount:.02+Math.min(.05,B*.004)})}M.snow=Math.max(Ca*.5,M.snow-F*(.03+Math.min(.07,B*.005))),I.length>96&&I.splice(0,I.length-96)},P=[];l.on(u,"collisionStart",M=>{var L;for(const B of M.pairs){const{bodyA:V,bodyB:F}=B,q=c.find(z=>z.body===V),R=c.find(z=>z.body===F);if(!q&&!R)continue;const $={x:V.velocity.x-F.velocity.x,y:V.velocity.y-F.velocity.y},X=Math.hypot($.x,$.y);if(X<pb)continue;const D=B.collision.normal,Z=(L=B.collision.supports)==null?void 0:L[0];P.push(Z?{x:Z.x,y:Z.y,speed:X}:{x:(V.position.x+F.position.x)/2,y:(V.position.y+F.position.y)/2,speed:X}),P.length>64&&P.shift();const le=Math.min(.32,X*.028);q&&le>q.squash&&(q.squash=le,q.squashAngle=Math.atan2(D.y,D.x)),R&&le>R.squash&&(R.squash=le,R.squashAngle=Math.atan2(-D.y,-D.x)),q&&A(q,{x:D.x,y:D.y},X,5),R&&A(R,{x:-D.x,y:-D.y},X,5)}}),l.on(u,"afterUpdate",()=>{if(!(n.snowRate<=0))for(const M of c)M.snow=Math.min(1,M.snow+n.snowRate)});let N=null;return{balls:c,links:p,anchor:v,nextKnot:E,ball(M){return c.find(L=>L.nodeId===M)},step(M){r.update(u,Math.min(33,Math.max(8,M)));for(let L=0;L<c.length;L++){const B=c[L];for(let V=L+1;V<c.length;V++){const F=c[V],q=F.body.position.x-B.body.position.x,R=F.body.position.y-B.body.position.y,$=q*q+R*R;if($>=Sa*Sa||$<.01)continue;const X=Math.sqrt($),D=(X-2*t)/(Sa-2*t),Z=D<=0?1:D>=1?0:1-D,z=Math.hypot(B.body.velocity.x-F.body.velocity.x,B.body.velocity.y-F.body.velocity.y)<1.2?xb*Z*Z:0,ee=q/X,K=R/X;B.body.isStatic||i.applyForce(B.body,B.body.position,{x:-ee*z*B.body.mass,y:-K*z*B.body.mass}),F.body.isStatic||i.applyForce(F.body,F.body.position,{x:ee*z*F.body.mass,y:K*z*F.body.mass}),B.field=Math.max(B.field,Z),F.field=Math.max(F.field,Z)}}for(const L of c)L.field*=.88;for(const L of c){if(L.body.isStatic)continue;const B=L.body.velocity,V=Math.hypot(B.x,B.y);V>Aa&&i.setVelocity(L.body,{x:B.x/V*Aa,y:B.y/V*Aa})}for(let L=0;L<c.length;L++){const B=c[L];for(let V=L+1;V<c.length;V++){const F=c[V];let q=F.body.position.x-B.body.position.x,R=F.body.position.y-B.body.position.y,$=Math.hypot(q,R);if($>=t*2)continue;$<.01&&(q=1,R=0,$=1);const X=t*2-$+.05,D=q/$,Z=R/$;B.body.isStatic&&F.body.isStatic||(B.body.isStatic?i.setPosition(F.body,{x:F.body.position.x+D*X,y:F.body.position.y+Z*X}):F.body.isStatic?i.setPosition(B.body,{x:B.body.position.x-D*X,y:B.body.position.y-Z*X}):(i.setPosition(B.body,{x:B.body.position.x-D*X/2,y:B.body.position.y-Z*X/2}),i.setPosition(F.body,{x:F.body.position.x+D*X/2,y:F.body.position.y+Z*X/2})))}}for(const L of c){const B=Math.hypot(L.body.velocity.x,L.body.velocity.y);L.snow>Ca&&B>gb&&A(L,{x:L.body.velocity.x/B,y:L.body.velocity.y/B},B,2)}for(const L of c){if(L.body.isStatic)continue;const B=L.body.position.x,V=L.body.position.y,F=Math.min(e.width-t,Math.max(t,B)),q=Math.min(e.height-t,Math.max(t,V));(F!==B||q!==V)&&(i.setPosition(L.body,{x:F,y:q}),i.setVelocity(L.body,{x:B<t||B>e.width-t?0:L.body.velocity.x,y:V<t||V>e.height-t?0:L.body.velocity.y}))}},beginDrag(M,L,B){this.endDrag();const V=this.ball(M);if(!V)return;const F=o.create({pointA:d(L,B),bodyB:V.body,length:0,stiffness:mb,damping:.12});a.add(u.world,F),N={constraint:F,nodeId:M}},moveDrag(M,L){if(!N)return;const B=d(M,L);N.constraint.pointA=B},endDrag(){N&&(a.remove(u.world,N.constraint),N=null)},isDragging(){return N!==null},drainImpacts(){const M=P.slice();return P.length=0,M},drainFlakes(){const M=I.slice();return I.length=0,M},dispose(){this.endDrag(),l.off(u,"beforeUpdate"),l.off(u,"afterUpdate"),l.off(u,"collisionStart"),a.clear(u.world,!1),r.clear(u)}}}const Cs=-12;function $i(e,t,n=20){return t<=n*2?t/2:n+Gh(e)*(t-n*2)}function yb(e,t,n,r=zt){if(t<=0||Math.abs(t-n)<=1)return e;const s=n/t,i={x:Math.min(n-r,Math.max(r,e.x*s)),y:e.y,vy:e.vy};return e.vx!==void 0&&(i.vx=e.vx*s),i}const Yn=(e,t,n)=>e+(t-e)*n,Ys=(e,t,n)=>e<t?t:e>n?n:e,yi=e=>e<0?0:e>1?1:e*e*(3-2*e);function Gn(e,t,n){return[Yn(e[0],t[0],n),Yn(e[1],t[1],n),Yn(e[2],t[2],n)]}const _a=e=>`rgb(${e[0]|0},${e[1]|0},${e[2]|0})`,wr=(e,t)=>`rgba(${e[0]|0},${e[1]|0},${e[2]|0},${t})`;function Gs(){return[{t:0,top:[8,10,26],mid:[16,20,44],hor:[34,30,58]},{t:.12,top:[30,32,72],mid:[78,56,104],hor:[158,100,116]},{t:.22,top:[124,156,214],mid:[232,152,120],hor:[250,196,128]},{t:.36,top:[80,142,196],mid:[132,186,226],hor:[188,214,232]},{t:.5,top:[60,120,178],mid:[108,168,212],hor:[168,200,226]},{t:.62,top:[120,132,152],mid:[150,150,160],hor:[180,178,182]},{t:.74,top:[70,60,88],mid:[108,78,110],hor:[180,110,100]},{t:.86,top:[40,30,60],mid:[88,44,76],hor:[168,72,72]},{t:1,top:[8,10,26],mid:[16,20,44],hor:[34,30,58]}]}function Ks(e,t){return e.map(n=>({t:n.t,top:t(n.top),mid:t(n.mid),hor:t(n.hor)}))}const Ia=()=>Ks(Gs(),e=>[e[0]*1,e[1]*1.15,e[2]*.7]),Yi=()=>Ks(Gs(),e=>[e[0]*.75,e[1]*1,Math.min(255,e[2]*1.25)]),Na=()=>Ks(Gs(),e=>[Math.min(255,e[0]*1.35),e[1]*.8,e[2]*.55]),fc=()=>Ks(Gs(),e=>{const t=(e[0]+e[1]+e[2])/3;return[t*.7+e[0]*.1,t*.7+e[1]*.1,t*.95+e[2]*.15]}),Ra={far:[28,50,36],near:[56,110,52],snowy:!1},Gi={far:[20,48,30],near:[34,82,40],snowy:!1},La={far:[54,36,24],near:[128,78,36],snowy:!1},hc={far:[60,66,82],near:[232,236,244],snowy:!0};function Ut(e){return t=>{let n=e;return t>.3&&t<.5?n=Yn(n,Math.min(1,n+.2),yi((t-.3)/.2)):t>=.5&&t<.74?n=Math.min(1,n+.15):t>=.74&&t<.84&&(n=Yn(n,Math.max(0,n-.3),yi((t-.74)/.1))),Ys(n,0,1)}}const Kh={"spring|clear":{season:"spring",weather:"clear",sky:Ia(),cloudCover:Ut(.1),particles:"none",lightning:!1,fogAlpha:0,ground:Ra},"spring|cloudy":{season:"spring",weather:"cloudy",sky:Ia(),cloudCover:Ut(.5),particles:"none",lightning:!1,fogAlpha:0,ground:Ra},"spring|rain":{season:"spring",weather:"rain",sky:Ia(),cloudCover:Ut(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:Ra},"summer|clear":{season:"summer",weather:"clear",sky:Yi(),cloudCover:Ut(.1),particles:"none",lightning:!1,fogAlpha:0,ground:Gi},"summer|cloudy":{season:"summer",weather:"cloudy",sky:Yi(),cloudCover:Ut(.5),particles:"none",lightning:!1,fogAlpha:0,ground:Gi},"summer|rain":{season:"summer",weather:"rain",sky:Yi(),cloudCover:Ut(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:Gi},"summer|storm":{season:"summer",weather:"storm",sky:Yi(),cloudCover:Ut(1),particles:"rain",lightning:!0,fogAlpha:0,ground:Gi},"autumn|clear":{season:"autumn",weather:"clear",sky:Na(),cloudCover:Ut(.15),particles:"none",lightning:!1,fogAlpha:0,ground:La,sunTint:[255,180,110]},"autumn|cloudy":{season:"autumn",weather:"cloudy",sky:Na(),cloudCover:Ut(.55),particles:"none",lightning:!1,fogAlpha:0,ground:La},"autumn|storm":{season:"autumn",weather:"storm",sky:Na(),cloudCover:Ut(1),particles:"rain",lightning:!0,fogAlpha:0,ground:La},"winter|clear":{season:"winter",weather:"clear",sky:fc(),cloudCover:Ut(.2),particles:"none",lightning:!1,fogAlpha:0,ground:hc,sunTint:[220,230,245]},"winter|snow":{season:"winter",weather:"snow",sky:fc(),cloudCover:Ut(.9),particles:"snow",lightning:!1,fogAlpha:.2,ground:hc}},mc=Object.keys(Kh);function Eb(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function vb(e){const t=`${e??"none"}:${Math.floor(performance.now()/1e3)}`;return mc[Eb(t)%mc.length]}function Tb(e,t){let n=0;for(;n<t.length-1&&e>t[n+1].t;)n++;const r=t[n],s=t[Math.min(n+1,t.length-1)],i=yi(Ys((e-r.t)/(s.t-r.t||1),0,1));return{top:Gn(r.top,s.top,i),mid:Gn(r.mid,s.mid,i),hor:Gn(r.hor,s.hor,i)}}function kb(e,t,n,r,s){if(e<r||e>s)return null;const i=(e-r)/(s-r),a=Yn(.1,.9,i),o=n*.26,l=n*.98,u=l-Math.sin(i*Math.PI)*(l-o);return{x:a*t,y:u,peakness:Math.sin(i*Math.PI)}}function wb(e,t,n,r,s){let i;if(e>=r)i=(e-r)/(1-r+s);else if(e<=s)i=(1-r+e)/(1-r+s);else return null;const a=Yn(.12,.88,i),o=n*.26,l=n*.98,u=l-Math.sin(i*Math.PI)*(l-o);return{x:a*t,y:u,peakness:Math.sin(i*Math.PI)}}function Xh(e){return function(){e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function pc(e,t){const n=Xh(20260809),r=Math.max(28,Math.round(e*t/7e3)),s=[];for(let i=0;i<r;i++)s.push({x:n(),y:n()*.7,r:n()*1.2+.3,tw:n()*Math.PI*2,sp:.6+n()*1.4,big:n()<.06});return s}function Sb(){const e=Xh(7),t=[];for(let n=0;n<6;n++)t.push({x:e(),y:.12+e()*.4,s:.55+e()*1.2,speed:18e-6+e()*35e-6,seed:e()*1e3,drift:e()*.035+.008});return t}function Ab(e,t,n,r){const s=e.createLinearGradient(0,0,0,r);s.addColorStop(0,_a(t.top)),s.addColorStop(.55,_a(t.mid)),s.addColorStop(1,_a(t.hor)),e.fillStyle=s,e.fillRect(0,0,n,r)}function Cb(e,t,n,r,s,i){let a=0;if(t<.22?a=yi(1-t/.22):t>.8&&(a=yi((t-.8)/.2)),!(a<=.01))for(const o of n){const l=.55+.45*Math.sin(i*o.sp+o.tw),u=a*l;if(u<.02)continue;e.fillStyle=`rgba(255,248,228,${u})`;const c=o.big?o.r*1.8:o.r;e.beginPath(),e.arc(o.x*r,o.y*s,c,0,Math.PI*2),e.fill(),o.big&&(e.fillStyle=`rgba(255,240,210,${u*.35})`,e.fillRect(o.x*r-c*4,o.y*s-.4,c*8,.8),e.fillRect(o.x*r-.4,o.y*s-c*4,.8,c*8))}}function _b(e,t,n){if(!t)return;const{x:r,y:s,peakness:i}=t,a=28+i*8,o=e.createRadialGradient(r,s,a*.4,r,s,a*5);o.addColorStop(0,"rgba(255,236,190,0.55)"),o.addColorStop(.4,"rgba(255,210,150,0.16)"),o.addColorStop(1,"rgba(255,200,140,0)"),e.fillStyle=o,e.fillRect(r-a*5,s-a*5,a*10,a*10);const l=e.createRadialGradient(r,s,0,r,s,a),u=n??[255,236,180],c=n?Gn(n,[255,214,150],.5):[255,214,150];l.addColorStop(0,"rgba(255,252,238,1)"),l.addColorStop(.7,wr(u,1)),l.addColorStop(1,wr(c,.9)),e.fillStyle=l,e.beginPath(),e.arc(r,s,a,0,Math.PI*2),e.fill()}function Ib(e,t){if(!t)return;const{x:n,y:r}=t,s=24,i=e.createRadialGradient(n,r,s*.8,n,r,s*5);i.addColorStop(0,"rgba(220,232,255,0.38)"),i.addColorStop(.5,"rgba(220,232,255,0.1)"),i.addColorStop(1,"rgba(220,232,255,0)"),e.fillStyle=i,e.fillRect(n-s*5,r-s*5,s*10,s*10);const a=e.createRadialGradient(n-s*.25,r-s*.3,s*.2,n,r,s);a.addColorStop(0,"rgba(255,254,247,1)"),a.addColorStop(.7,"rgba(244,242,232,1)"),a.addColorStop(1,"rgba(214,222,236,1)"),e.fillStyle=a,e.beginPath(),e.arc(n,r,s,0,Math.PI*2),e.fill(),e.fillStyle="rgba(150,160,180,0.16)";const o=[[-10,-6,4],[5,3,5],[-3,9,3],[11,-8,3]];for(const[l,u,c]of o)e.beginPath(),e.arc(n+l,r+u,c,0,Math.PI*2),e.fill()}function Nb(e,t,n,r,s,i){const a=18*r,o=[[0,0,1],[-1.1,.1,.8],[1.1,.1,.8],[-.5,-.5,.7],[.6,-.45,.75],[-1.8,.3,.6],[1.8,.3,.6]];e.save(),e.translate(t,n),e.fillStyle=wr([s[0]*.7,s[1]*.7,s[2]*.78],i*.9);for(const[l,u,c]of o)e.beginPath(),e.arc(l*a,u*a*1.1+a*.45,a*c*1.05,0,Math.PI*2),e.fill();e.fillStyle=wr(s,i);for(const[l,u,c]of o)e.beginPath(),e.arc(l*a,u*a,a*c,0,Math.PI*2),e.fill();e.restore()}function Rb(e,t,n,r,s,i,a,o,l){const u=a(t);if(u<.02)return;const c=Gn(o.hor,[255,255,255],.35),f=Gn(o.mid,[20,20,30],.45),h=l?f:c;for(let d=0;d<n.length;d++){const m=n[d],p=(m.x+i*m.speed)%1.2-.1,g=m.y+Math.sin(i*1e-4+m.seed)*m.drift;d/n.length<u&&Nb(e,p*r,g*s,m.s,h,Ys(u*.92,0,.92))}}const mr=[];let Hn=[];const Jr=[];let Un=[];const Ki=[],zr=[];let Zr=[];function Lb(e,t,n,r,s,i){if(s<.04)return;const a=r*(.02+s*.07),o=.12+s*.73,l=t-r*o,u=t+r*o,c=n-Math.sqrt(Math.max(0,r*r-r*o*(r*o))),f=n-r-a,h=(c+f)/2;e.save(),e.beginPath(),e.moveTo(l,c),e.bezierCurveTo(l,h,t-r*.3,f,t,f),e.bezierCurveTo(t+r*.3,f,u,h,u,c),e.quadraticCurveTo(t,n-r*.78,l,c),e.closePath();const d=e.createLinearGradient(0,f,0,c);d.addColorStop(0,"rgba(255,255,255,0.98)"),d.addColorStop(.65,"rgba(245,250,255,0.95)"),d.addColorStop(1,"rgba(218,230,246,0.9)"),e.fillStyle=d,e.fill(),e.strokeStyle="rgba(168,192,225,0.28)",e.lineWidth=1.5,e.beginPath(),e.moveTo(l,c),e.quadraticCurveTo(t,n-r*.78,u,c),e.stroke(),e.restore()}function Pa(e,t,n,r,s){const i=Math.sin(r),a=Math.cos(r);return{x:e+Math.sin(s)*i*n,y:t-a*n}}function Pb(e,t,n,r){e.save(),e.beginPath(),e.arc(t,n,r*.99,0,Math.PI*2),e.clip();const s=e.createRadialGradient(t-r*.35,n-r*.4,0,t-r*.35,n-r*.4,r*.8);s.addColorStop(0,"rgba(255,255,255,0.4)"),s.addColorStop(.5,"rgba(255,255,255,0.12)"),s.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=s,e.fillRect(t-r,n-r,r*2,r*2),e.strokeStyle="rgba(255,255,255,0.55)",e.lineWidth=1.8,e.beginPath(),e.arc(t,n,r*.92,Math.PI*1.15,Math.PI*1.5),e.stroke(),e.restore()}function Mb(e,t){if(t.length!==0){e.save();for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.x+=r.vx,r.y+=r.vy,r.vy+=.14,r.vx*=.985,r.vy*=.99,r.life--,r.life<=0){t.splice(n,1);continue}const s=r.life/r.maxLife;e.fillStyle=`rgba(248,250,255,${(.9*s).toFixed(3)})`,e.beginPath(),e.arc(r.x,r.y,r.r*(.5+.5*s),0,Math.PI*2),e.fill()}e.restore()}}function Qh(e,t){e.save();for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.x+=r.vx,r.y+=r.vy,r.vy+=.18,r.life--,r.life<=0){t.splice(n,1);continue}const s=Math.min(1,r.life/20)*.8;e.fillStyle=`rgba(215,238,255,${s})`,e.beginPath(),e.arc(r.x,r.y,1.3,0,Math.PI*2),e.fill()}e.restore()}function Db(e,t,n,r,s,i){e.save(),e.beginPath(),e.arc(t,n,r*.99,0,Math.PI*2),e.clip();for(let a=s.length-1;a>=0;a--){const o=s[a];if(o.prog+=o.speed,o.life--,o.prog>Math.PI*1.05||o.life<=0){s.splice(a,1);continue}const l=7;for(let f=0;f<l;f++){const h=o.prog-o.len*(f/l),d=o.prog-o.len*((f+1)/l),m=Pa(t,n,r,h,o.theta),p=Pa(t,n,r,d,o.theta),g=(1-f/l)*.42;e.strokeStyle=`rgba(200,228,250,${g})`,e.lineWidth=o.thick*(1-f/l*.7),e.lineCap="round",e.beginPath(),e.moveTo(m.x,m.y),e.lineTo(p.x,p.y),e.stroke()}const u=Pa(t,n,r,o.prog,o.theta),c=e.createRadialGradient(u.x-1.2,u.y-1.2,0,u.x,u.y,o.thick*1.3);c.addColorStop(0,"rgba(255,255,255,0.85)"),c.addColorStop(.4,"rgba(180,215,240,0.5)"),c.addColorStop(1,"rgba(120,165,205,0.25)"),e.fillStyle=c,e.beginPath(),e.arc(u.x,u.y,o.thick*1.1,0,Math.PI*2),e.fill()}e.restore()}function Ob(e,t,n,r){for(;mr.length<t.length;)mr.push([]);for(;Hn.length<t.length;)Hn.push(0);for(;Zr.length<t.length;)Zr.push(.3);for(;Jr.length<t.length;)Jr.push([]);for(;Un.length<t.length;)Un.push(0);for(let s=0;s<t.length;s++){const i=t[s];if(n.particles==="snow"){const a=i.snow!==void 0?i.snow:Math.min(1,(Zr[s]??.3)+8e-4);Zr[s]=a,Lb(e,i.x,i.y,i.r,a)}else if(n.particles==="rain"){if(Pb(e,i.x,i.y,i.r),Hn[s]=Hn[s]-1,Hn[s]<=0&&mr[s].length<3){const a=Math.random()<.5?-1:1;mr[s].push({theta:a*(.2+Math.random()*.3),prog:.1+Math.random()*.2,speed:.012+Math.random()*.012,len:.3+Math.random()*.3,thick:1.6+Math.random()*1.4,life:250+Math.random()*200}),Hn[s]=40+Math.random()*60}if(Db(e,i.x,i.y,i.r,mr[s]),Un[s]=Un[s]-1,Un[s]<=0){const a=i.x+(Math.random()-.5)*i.r*1.2,o=a-i.x,l=i.y-Math.sqrt(Math.max(0,i.r*i.r-o*o)),u=4+Math.floor(Math.random()*3);for(let c=0;c<u;c++){const f=o<0?-1:1;Jr[s].push({x:a,y:l,vx:f*(.5+Math.random()*2)*(Math.random()<.5?-1:1),vy:-(1.5+Math.random()*2.5),life:18+Math.floor(Math.random()*14)})}Un[s]=30+Math.floor(Math.random()*50)}Qh(e,Jr[s])}}}function Fb(e,t,n,r,s){e.save(),e.strokeStyle=s?"rgba(205,224,244,0.42)":"rgba(210,224,238,0.3)",e.lineWidth=s?1:.7,e.lineCap="round";const i=s?.013:.007;for(const a of r){a.y+=a.v*i,a.y>1&&(a.y-=1,a.x=Math.random());const o=a.x*t,l=a.y*n;e.beginPath(),e.moveTo(o,l),e.lineTo(o,l+a.len),e.stroke()}e.restore()}function Bb(e,t,n,r,s){e.save(),e.fillStyle="rgba(250,250,255,0.85)";for(const i of r){i.y+=i.v*.004;const a=(i.x+Math.sin(s*5e-4+i.phase)*.02)*t,o=i.y*n;i.y>1&&(i.y-=1),e.beginPath(),e.arc(a,o,i.r,0,Math.PI*2),e.fill()}e.restore()}function jb(e,t,n,r,s){const i=e.createLinearGradient(0,n*.4,0,n),a=Gn(s.hor,[255,255,255],.3);i.addColorStop(0,wr(a,0)),i.addColorStop(1,wr(a,r)),e.fillStyle=i,e.fillRect(0,n*.4,t,n*.6)}let cr=0,gc=0;function Hb(e,t,n,r,s){if(s>gc&&(cr=1,gc=s+1400+Math.random()*2600),cr*=.86,cr<.02){cr=0;return}if(e.fillStyle=`rgba(255,255,255,${cr*.5})`,e.fillRect(0,0,t,n),cr>.6){e.save(),e.strokeStyle="rgba(255,255,255,0.95)",e.lineWidth=2.2,e.shadowColor="rgba(220,230,255,0.9)",e.shadowBlur=22;let i=t*(.3+Math.random()*.4),a=0;for(e.beginPath(),e.moveTo(i,a);a<n*.6;)i+=(Math.random()-.5)*60,a+=24+Math.random()*30,e.lineTo(i,a);e.stroke(),e.restore()}}function Ub(e,t,n,r){const s=e.getContext("2d");if(!s)return()=>{};const i=s,a=n;let o=0,l=0,u=1,c=pc(1,1);const f=Sb();let h=[],d=[],m=0,p=0,g=!0;const y=performance.now(),T=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function v(){const I=a.getBoundingClientRect();if(u=Math.min(window.devicePixelRatio||1,2),o=Math.max(1,I.width),l=Math.max(1,I.height),e.width=Math.floor(o*u),e.height=Math.floor(l*u),e.style.width=o+"px",e.style.height=l+"px",i.setTransform(u,0,0,u,0,0),c=pc(o,l),r.particles==="rain"&&h.length===0){const A=r.weather==="storm",P=A?140:70;for(let N=0;N<P;N++)h.push({x:Math.random(),y:Math.random(),len:A?12+Math.random()*14:6+Math.random()*8,v:A?.9+Math.random()*.4:.5+Math.random()*.3})}if(r.particles==="snow"&&d.length===0)for(let A=0;A<120;A++)d.push({x:Math.random(),y:Math.random(),r:.8+Math.random()*1.6,v:.5+Math.random()*.8,phase:Math.random()*Math.PI*2})}function C(){const I=t.scrollHeight-t.clientHeight;m=I>0?Ys(t.scrollTop/I,0,1):0}function E(I){if(!g)return;const A=m,P=T?0:(I-y)/1e3,N=Tb(A,r.sky);Ab(i,N,o,l),Cb(i,A,c,o,l,P),Ib(i,wb(A,o,l,.92,.08)),_b(i,kb(A,o,l,.16,.88),r.sunTint),Rb(i,A,f,o,l,I,r.cloudCover,N,r.weather==="storm"),r.particles==="rain"&&Fb(i,o,l,h,r.weather==="storm"),r.particles==="snow"&&Bb(i,o,l,d,I),r.fogAlpha>0&&jb(i,o,l,r.fogAlpha,N),r.lightning&&Hb(i,o,l,!0,I),T||(p=requestAnimationFrame(E))}const w=()=>C(),_=new ResizeObserver(()=>{v(),C()});_.observe(a),v(),C();let S;if(T){let I=!1;S=()=>{C(),I||(I=!0,requestAnimationFrame(()=>{I=!1,E(performance.now())}))},t.addEventListener("scroll",S,{passive:!0}),E(performance.now())}else S=w,t.addEventListener("scroll",S,{passive:!0}),p=requestAnimationFrame(E);return()=>{g=!1,cancelAnimationFrame(p),_.disconnect(),t.removeEventListener("scroll",S)}}function zb(e,t,n,r,s,i){const a=()=>{mr.length=0,Zr.length=0,Hn.length=0,Jr.length=0,Un.length=0,Ki.length=0,zr.length=0;const T=e.getContext("2d");T&&T.clearRect(0,0,e.width,e.height)};if(a(),window.matchMedia("(prefers-reduced-motion: reduce)").matches)return()=>{};if(n.particles!=="rain"&&n.particles!=="snow")return()=>{};const l=e.getContext("2d");if(!l)return()=>{};const u=l;let c=0,f=0,h=1,d=0,m=!0;function p(){const T=t.getBoundingClientRect();h=Math.min(window.devicePixelRatio||1,2),c=Math.max(1,T.width),f=Math.max(1,T.height),e.width=Math.floor(c*h),e.height=Math.floor(f*h),e.style.width=c+"px",e.style.height=f+"px",u.setTransform(h,0,0,h,0,0)}function g(T){if(!m)return;u.clearRect(0,0,c,f);const v=r();if(Ob(u,v,n),s){for(const C of s()){const E=3+Math.min(5,Math.floor(C.speed/3));for(let w=0;w<E;w++)Ki.push({x:C.x,y:C.y,vx:(Math.random()-.5)*3.2,vy:-(1.5+Math.random()*2.5),life:16+Math.floor(Math.random()*12)})}Ki.length>0&&Qh(u,Ki)}if(i){for(const C of i()){const E=1+Math.min(2,Math.round(C.amount*40));for(let w=0;w<E;w++){const _=55+Math.floor(Math.random()*40);zr.push({x:C.x+(Math.random()-.5)*8,y:C.y+(Math.random()-.5)*6,vx:C.vx*.6+(Math.random()-.5)*.8,vy:C.vy*.6-Math.random()*.5,life:_,maxLife:_,r:1.2+Math.random()*2.2})}}for(;zr.length>240;)zr.shift();Mb(u,zr)}d=requestAnimationFrame(g)}const y=new ResizeObserver(p);return y.observe(t),p(),d=requestAnimationFrame(g),()=>{m=!1,cancelAnimationFrame(d),y.disconnect(),a()}}const Vb=k.lazy(()=>we(()=>import("./CourseSearchPanel-Dp11zUeA.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.CourseSearchPanel})));function qb(e){const t=Ke(),[n,r]=k.useState("import"),[s,i]=k.useState("study"),a=k.useRef(null),o=k.useRef(null),l=Math.round(e.overallMastery*100),c=!Cl(),f=k.useRef([]),h=k.useRef(N=>{f.current.push(...N),f.current.length>64&&f.current.splice(0,f.current.length-64)}).current,d=k.useRef([]),m=k.useRef(new Map),p=k.useRef(N=>{d.current.push(...N),d.current.length>96&&d.current.splice(0,d.current.length-96)}).current,g=e.sections.filter(N=>(N.world??"study")===s),y=e.sections.some(N=>N.world==="practice"),[T,v]=k.useState(null);k.useEffect(()=>{v(vb(e.courseId))},[e.courseId]);const C=T?Kh[T]??null:null;k.useEffect(()=>($u({nav:a.current,visible:n==="map",weather:(C==null?void 0:C.weather)??"clear"}),()=>{$u({visible:!1,nav:null})}),[n,C,a]);const[E,w]=k.useState(!1);k.useEffect(()=>{if(!e.selectedNodeId)return;const N=o.current;if(!N)return;const j=N.querySelector(`[data-node-id="${CSS.escape(e.selectedNodeId)}"]`);if(!j)return;const M=N.getBoundingClientRect(),L=j.getBoundingClientRect();(L.top<M.top+60||L.bottom>M.bottom-60)&&j.scrollIntoView({behavior:"smooth",block:"center"})},[e.selectedNodeId]);const _=k.useRef(null);k.useEffect(()=>{w(!1),e.courseId&&(_.current===null||_.current!==e.courseId)&&(r("map"),i("study")),!e.courseId&&_.current!==null&&(r("import"),i("study")),_.current=e.courseId},[e.courseId]);const[S,I]=k.useState(null),A=k.useRef({}),P=k.useRef(null);return k.useEffect(()=>{var L,B;const N=A.current,j={};let M=null;for(const V of e.tree){const F=((L=e.progressMap[V.id])==null?void 0:L.status)??"locked";j[V.id]=F,N[V.id]==="locked"&&F!=="locked"&&!M&&(M=V.id)}if(M&&Object.keys(N).length>0){const V=(B=a.current)==null?void 0:B.querySelector(`[data-testid="map-node-${M.slice(0,8)}"], [data-testid="exam-node-${M.slice(0,8)}"]`),F=V==null?void 0:V.getBoundingClientRect(),q=!!F&&F.width>0&&F.left>=0&&F.right<=window.innerWidth&&F.top>=0;us("unlock",q?{origin:{x:F.left+F.width/2,y:F.top+4}}:void 0)}A.current=j},[e.tree,e.progressMap]),x.jsxs("nav",{ref:a,className:`map-rail-scope relative h-full flex flex-col bg-surface-rail shrink-0 overflow-hidden ${e.fullWidth?"w-full":e.width==null?"w-[300px]":""}`,style:!e.fullWidth&&e.width!=null?{width:e.width}:void 0,"data-testid":"map-rail",children:[C&&x.jsxs(x.Fragment,{children:[x.jsx($b,{scrollRef:o,navRef:a,preset:C}),x.jsx(Yb,{scrollRef:o,navRef:a,preset:C,getImpacts:()=>f.current.splice(0),getFlakes:()=>d.current.splice(0),orbSnowRef:m})]}),x.jsxs("div",{className:"absolute top-0 left-0 right-0 z-40 px-2 pt-2 pb-2 pointer-events-none [&_button]:pointer-events-auto","data-testid":"map-rail-topbar",children:[x.jsxs("div",{className:"flex p-1 rounded-lg gap-1 mb-2",style:{background:"rgb(var(--surface-rail-rgb) / 0.55)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[x.jsxs("button",{onClick:()=>r("map"),"data-testid":"map-tab-map",className:`flex-1 flex items-center justify-center gap-1 py-1.5 rounded-md text-label font-bold transition-colors ${n==="map"?"bg-brand/20 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Rh,{className:"w-3 h-3"})," ",t("map.tab.map")]}),x.jsxs("button",{onClick:()=>r("import"),"data-testid":"map-tab-import",className:`flex-1 flex items-center justify-center gap-1 py-1.5 rounded-md text-label font-bold transition-colors ${n==="import"?"bg-brand/20 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Ws,{className:"w-3 h-3"})," ",t("map.tab.import")]})]}),n==="map"&&x.jsxs("div",{className:"px-3 py-2 rounded-lg pointer-events-auto",style:{background:"rgb(var(--surface-rail-rgb) / 0.55)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("h2",{className:"text-body font-extrabold text-white truncate flex-1","data-tooltip":e.courseTitle??"",children:e.courseTitle??t("map.course.none")}),e.availableLanguages.length>0&&x.jsx(Zb,{available:e.availableLanguages,current:e.currentLocale,onChange:e.onLocaleChange}),e.courseId&&x.jsx("button",{onClick:N=>{const j=N.currentTarget.getBoundingClientRect();I({id:e.courseId,title:e.courseTitle??"",rect:j})},"data-testid":"course-delete-btn","aria-label":t("import.delete.current"),"data-tooltip":t("import.delete.current"),className:"shrink-0 flex items-center justify-center w-5 h-5 rounded-md text-white/40 hover:text-warning hover:bg-white/10 transition-colors",children:x.jsx(Dh,{className:"w-3 h-3"})})]}),x.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[x.jsx("div",{className:"flex-1 h-2.5 bg-black/40 rounded-full overflow-hidden ring-1 ring-white/10",children:x.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,l)}%`}})}),x.jsxs("span",{className:"text-label font-extrabold tabular-nums text-white drop-shadow-[0_1px_3px_rgba(0,0,0,0.6)]",children:[l,"%"]})]}),x.jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1.5 text-caption",children:[x.jsxs("button",{onClick:()=>w(!0),"data-testid":"map-search-btn",className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-white/5 ring-1 ring-white/10 hover:bg-white/10 transition-colors",children:[x.jsx(Ox,{className:"w-3 h-3 text-white/50"}),x.jsx("span",{className:"font-bold text-white/60",children:t("map.search.label")})]}),x.jsxs("button",{onClick:e.onOpenReview,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-full transition-colors ${e.dueCount>0?"bg-review/20 ring-1 ring-review/30 hover:bg-review/30":"bg-white/5 ring-1 ring-white/10 hover:bg-white/10"}`,"data-testid":"map-review-badge",children:[x.jsx(Cn,{className:`w-3 h-3 ${e.dueCount>0?"text-review":"text-white/50"}`}),x.jsx("span",{className:`font-bold ${e.dueCount>0?"text-review":"text-white/60"}`,children:t("map.review.label")}),e.dueCount>0&&x.jsx("span",{className:"font-extrabold text-review tabular-nums",children:e.dueCount})]})]}),y&&x.jsxs("div",{className:"flex gap-1 mt-1.5 p-0.5 rounded-lg bg-black/30",children:[x.jsxs("button",{onClick:()=>i("study"),"data-testid":"world-tab-study",className:`flex-1 flex items-center justify-center gap-1 py-1 rounded-md text-caption font-bold transition-colors ${s==="study"?"bg-brand/30 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Cn,{className:"w-3 h-3"})," ",t("map.world.study")]}),x.jsxs("button",{onClick:()=>i("practice"),"data-testid":"world-tab-practice",className:`flex-1 flex items-center justify-center gap-1 py-1 rounded-md text-caption font-bold transition-colors ${s==="practice"?"bg-accent/30 text-accent":"text-white/50 hover:text-white/80"}`,children:[x.jsx(Fh,{className:"w-3 h-3"})," ",t("map.world.practice")]})]})]})]}),x.jsx("div",{className:"absolute inset-0 overflow-hidden z-10",children:x.jsxs("div",{className:"flex h-full transition-transform duration-300",style:{transform:n==="map"?"translateX(0)":"translateX(-50%)",width:"200%"},children:[x.jsx("div",{className:"w-1/2 h-full relative",children:x.jsx("div",{ref:o,className:"map-path h-full overflow-y-auto overflow-x-hidden px-2 pt-48 pb-4","data-testid":"map-path",onPointerDown:N=>{P.current={x:N.clientX,y:N.clientY}},onClick:N=>{const j=P.current;P.current=null,!(!j||Math.hypot(N.clientX-j.x,N.clientY-j.y)>6)&&(N.target.closest("button, a, input, textarea, select")||E1(N.clientX,N.clientY))},children:x.jsxs("div",{className:`map-sky-content ${C?`env-${C.season} env-${C.weather}`:""}`,children:[e.streaming&&x.jsxs("div",{className:"mb-3 mx-1 px-3 py-2 rounded-xl bg-brand/10 border border-brand/30 flex items-center gap-2 text-label text-brand font-medium backdrop-blur-sm","data-testid":"streaming-notice",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),t("map.streaming.notice")]}),e.sections.length===0?e.courseTitle?x.jsxs("div",{className:"text-center text-label text-white/60 mt-8 px-4 flex items-center justify-center gap-2",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),t("map.generating")]}):x.jsxs("button",{onClick:()=>r("import"),className:"block w-full mt-8 mx-auto p-4 rounded-2xl border-2 border-dashed border-brand/40 hover:border-brand hover:bg-brand/5 transition-all text-center group","data-testid":"map-empty-cta",children:[x.jsx("div",{className:"text-3xl mb-2 group-hover:scale-110 transition-transform",children:"🗺️"}),x.jsx("div",{className:"text-body font-bold text-white/90 mb-1",children:t("map.empty.cta.title")}),x.jsx("div",{className:"text-label text-white/60 leading-relaxed",children:t("map.empty.cta.desc")}),x.jsx("div",{className:"mt-2 text-caption text-brand font-bold",children:t("map.empty.cta.btn")})]}):g.length===0?x.jsx("div",{className:"text-center text-label text-white/60 mt-8 px-4",children:t(s==="practice"?"map.empty.practice":"map.generating")}):x.jsx("div",{className:"space-y-6 pt-2",children:g.map((N,j)=>x.jsx(Gb,{section:N,sectionIndex:j,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,dueNodeIds:e.dueNodeIds,streamingNodeIds:e.streamingNodeIds,onJumpNode:e.onJumpNode,physics:c,physicsWeather:(C==null?void 0:C.weather)??"clear",scrollRef:o,navRef:a,onImpacts:h,onFlakes:p,orbSnowRef:m},N.id))})]})})}),x.jsx("div",{className:"w-1/2 h-full overflow-y-auto px-3 pt-20 pb-3 space-y-2.5",children:x.jsx(Wb,{courses:e.courses,selectedCourseId:e.courseId,onSelectCourse:N=>{e.onSelectCourse(N),r("map")},onDeleteCourse:(N,j,M)=>I({id:N,title:j,rect:M}),onCoursesChanged:e.onCoursesChanged})})]})}),E&&e.courseId&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(Vb,{sections:e.sections,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,onJump:N=>{i(N.world??"study"),w(!1),So(null,null,N.id),e.onJumpNode(N.id)},onClose:()=>w(!1)})}),S&&x.jsx(Vh,{anchorRect:S.rect,message:`${S.title} — ${t("import.delete.confirm")}`,danger:!0,confirmLabel:t("import.delete"),testid:"course-delete-confirm",onConfirm:()=>{e.onDeleteCourse(S.id),I(null)},onCancel:()=>I(null)})]})}function Wb({courses:e,selectedCourseId:t,onSelectCourse:n,onDeleteCourse:r,onCoursesChanged:s}){const i=Ke(),[a,o]=k.useState("url"),[l,u]=k.useState(!1),[c,f]=k.useState(""),[h,d]=k.useState(""),m=k.useRef(null),p=k.useRef(null),g=k.useRef(null),[y,T]=k.useState(""),[v,C]=k.useState(""),[E,w]=k.useState(!1),[_,S]=k.useState(null),[I,A]=k.useState(null),[P,N]=k.useState(null),[j,M]=k.useState(null),[L,B]=k.useState([]),[,V]=k.useState(0),F=k.useRef(null);k.useEffect(()=>{const re=oe.on("import:progress",ge=>{B(Te=>{const Ne=/\d+\/\d+/.test(ge),Oe=Te[Te.length-1];if(Ne&&Oe&&Oe.status==="working"){const Fe=[...Te];return Fe[Fe.length-1]={...Oe,msg:ge},Fe}const be=Te.map(Fe=>Fe.status==="working"?{...Fe,status:"done"}:Fe);return be.push({msg:ge,status:"working",ts:Date.now()}),be})}),ne=setInterval(()=>V(ge=>ge+1),1e3);return()=>{re(),clearInterval(ne)}},[]),k.useEffect(()=>oe.on("import:done",ne=>{w(!1),Ht(!1),ne.cancelled||k1(ne.ok),N(ne.ok?null:ne.planId??null),ne.ok?(A(`${i("import.success.folder")}: ${ne.title??""}${ne.reused?`(${i("import.success.reused")})`:""}`),M(ne.courseId?{courseId:ne.courseId,packable:ne.packable??!1}:null),s()):ne.cancelled?(B([]),S(null),A(i("import.cancelled"))):S(ne.error??"导入失败")}),[s,i]),k.useEffect(()=>{const re=F.current;re&&(re.scrollTop=re.scrollHeight)},[L]);const q=async()=>{if(!(!c.trim()||E)){S(null),A(null),B([]);try{await oe.importUrl(c.trim()),w(!0),Ht(!0)}catch(re){S(re instanceof Error?re.message:String(re))}}},R=async()=>{if(!(!y.trim()||E)){S(null),A(null),B([]);try{await oe.importText({name:v.trim()||void 0,text:y.trim()}),w(!0),Ht(!0)}catch(re){S(re instanceof Error?re.message:String(re))}}},$=async()=>{var ne;if(E)return;if(S(null),A(null),B([]),!hn){(ne=p.current)==null||ne.click();return}await oe.importEpub().catch(ge=>(S(ge instanceof Error?ge.message:String(ge)),null))&&(w(!0),Ht(!0))},X=async re=>{if(!(!re||E)){S(null),A(null),B([]);try{const ne=new Uint8Array(await re.arrayBuffer());let ge="";for(let Ne=0;Ne<ne.length;Ne+=32768)ge+=String.fromCharCode(...ne.subarray(Ne,Ne+32768));await oe.importEpub({fileName:re.name,contentBase64:btoa(ge)})&&w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},D=async()=>{if(E)return;if(S(null),A(null),B([]),!hn){const ne=h.trim();if(!ne){S(i("import.folder.pathRequired"));return}try{await oe.importLocalFolder(ne)&&w(!0),Ht(!0)}catch(ge){S(ge instanceof Error?ge.message:String(ge))}return}await oe.importLocalFolder()&&(w(!0),Ht(!0))},Z=async()=>{var ne;if(E)return;if(S(null),A(null),B([]),!hn){(ne=m.current)==null||ne.click();return}await oe.importPack().catch(ge=>(S(ge instanceof Error?ge.message:String(ge)),null))&&(w(!0),Ht(!0))},le=async re=>{if(!(!re||E)){S(null),A(null),B([]);try{const ne=await re.text();await oe.importPack({fileName:re.name,content:ne})&&w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},z=async()=>{var ne;if(E)return;if(S(null),A(null),B([]),!hn){(ne=g.current)==null||ne.click();return}await oe.importAudio().catch(ge=>(S(ge instanceof Error?ge.message:String(ge)),null))&&(w(!0),Ht(!0))},ee=async re=>{if(!(!re||re.length===0||E)){S(null),A(null),B([]);try{const ne=[];for(const Te of Array.from(re)){const Ne=new Uint8Array(await Te.arrayBuffer());let Oe="";for(let be=0;be<Ne.length;be+=32768)Oe+=String.fromCharCode(...Ne.subarray(be,be+32768));ne.push({fileName:Te.name,contentBase64:btoa(Oe)})}await oe.importAudio(ne)&&w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},K=async re=>{if(!E){S(null),B([]);try{await oe.importResume(re),w(!0),Ht(!0)}catch(ne){S(ne instanceof Error?ne.message:String(ne))}}},ce=async re=>{try{const ne=await oe.exportPack(re);ne!=null&&ne.content&&ne.fileName?(fe(ne.fileName,ne.content),A(i("import.pack.exported",{path:ne.fileName}))):ne!=null&&ne.path&&A(i("import.pack.exported",{path:ne.path}))}catch(ne){S(ne instanceof Error?ne.message:String(ne))}},fe=(re,ne)=>{const ge=new Blob([ne],{type:"application/json"}),Te=URL.createObjectURL(ge),Ne=document.createElement("a");Ne.href=Te,Ne.download=re,Ne.click(),setTimeout(()=>URL.revokeObjectURL(Te),5e3)};return x.jsxs(x.Fragment,{children:[e.length===0?x.jsxs("div",{className:"text-center py-10",children:[x.jsx("div",{className:"text-3xl mb-2 opacity-30",children:"📚"}),x.jsx("p",{className:"text-label text-white/45 leading-relaxed",children:i("import.empty")})]}):x.jsx("div",{className:"space-y-2","data-testid":"course-list",children:e.map(re=>{const ne=re.id===t;return x.jsxs("div",{"data-testid":"course-row",className:`relative rounded-xl transition-all duration-150 group ${ne?"bg-brand/12 ring-1 ring-brand/40":"bg-white/5 hover:bg-white/10 hover:-translate-y-0.5"}`,children:[x.jsx("button",{onClick:()=>n(re.id),className:"w-full text-left p-3",children:x.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:`text-body font-bold truncate ${ne?"text-brand":"text-white/90"}`,children:re.title}),x.jsx("div",{className:"text-caption text-white/40 truncate mt-0.5",children:re.repoName})]}),ne&&x.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full bg-brand flex items-center justify-center",children:x.jsx(An,{className:"w-3 h-3 text-white"})})]})}),x.jsxs("div",{className:"absolute bottom-1.5 right-2 flex items-center gap-2.5 opacity-0 group-hover:opacity-100 pointer-coarse:opacity-100 focus-within:opacity-100 transition-opacity",children:[x.jsxs("button",{onClick:ge=>{ge.stopPropagation(),S(null),A(null),oe.exportPack(re.id).then(Te=>{Te!=null&&Te.content&&Te.fileName?(fe(Te.fileName,Te.content),A(i("import.pack.exported",{path:Te.fileName}))):Te!=null&&Te.path&&A(i("import.pack.exported",{path:Te.path}))}).catch(Te=>{S(Te instanceof Error?Te.message:String(Te))})},"data-testid":"course-row-export",className:"text-caption text-white/40 hover:text-brand flex items-center gap-0.5",children:[x.jsx(ic,{className:"w-2.5 h-2.5"})," ",i("import.export")]}),x.jsxs("button",{onClick:ge=>{ge.stopPropagation();const Te=ge.currentTarget.getBoundingClientRect();r(re.id,re.title,Te)},"data-testid":"course-row-delete",className:"text-caption text-white/40 hover:text-warning flex items-center gap-0.5",children:[x.jsx(Dh,{className:"w-2.5 h-2.5"})," ",i("import.delete")]})]})]},re.id)})}),x.jsxs("div",{className:e.length>0?"mt-6":"",children:[x.jsxs("button",{onClick:()=>u(!l),className:`w-full flex items-center justify-center gap-1.5 py-3 rounded-xl border-2 border-dashed transition-all text-body font-bold ${l?"border-brand/40 bg-brand/8 text-brand":"border-white/20 hover:border-brand/50 hover:bg-brand/8 text-white/70 hover:text-brand"}`,children:[x.jsx(Ph,{className:`w-4 h-4 transition-transform ${l?"rotate-45":""}`})," ",i("import.cta")]}),l&&x.jsxs("div",{className:"mt-3 space-y-3",children:[E?x.jsxs("div",{className:"rounded-xl bg-black/30 border border-brand/30 p-4","data-testid":"import-progress",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[x.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin shrink-0"}),x.jsx("span",{className:"text-body font-bold text-white/90",children:i("import.progress.title")}),x.jsx("button",{onClick:()=>{oe.importCancel()},"data-testid":"import-cancel-btn",className:"ml-auto text-caption text-white/50 hover:text-warning transition-colors",children:i("import.progress.cancel")})]}),x.jsx("div",{className:"text-caption text-white/40 mb-2.5",children:i("import.progress.note")}),(a==="url"?c.trim():a==="markdown"&&v.trim())?x.jsx("div",{className:"text-caption text-white/40 font-mono truncate mb-2.5",children:a==="url"?c.trim():v.trim()}):null,x.jsx("div",{ref:F,className:"space-y-1.5 max-h-[40vh] overflow-y-auto pr-1",children:L.length===0?x.jsx("div",{className:"text-caption text-white/50 py-1",children:i("import.progress.starting")}):L.map((re,ne)=>x.jsxs("div",{className:"flex items-start gap-1.5 text-caption",children:[re.status==="done"?x.jsx(An,{className:"w-3 h-3 text-brand shrink-0 mt-px"}):x.jsx("span",{className:"inline-block w-2.5 h-2.5 border-2 border-brand border-t-transparent rounded-full animate-spin shrink-0 mt-px"}),x.jsxs("span",{className:re.status==="done"?"text-white/40":"text-white/90",children:[re.msg,re.status==="working"&&x.jsxs("span",{className:"text-white/35 ml-1",children:["(",i("import.progress.elapsed",{s:Math.floor((Date.now()-re.ts)/1e3)}),")"]})]})]},ne))})]}):x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"@container flex flex-wrap gap-1 p-1 bg-white/5 rounded-lg",children:[{k:"url",label:i("import.tab.url"),icon:Sx},{k:"markdown",label:i("import.tab.md"),icon:Ws},{k:"folder",label:i("import.tab.folder"),icon:gx},{k:"epub",label:i("import.tab.epub"),icon:Cn},{k:"audio",label:i("import.tab.audio"),icon:cs},{k:"pack",label:i("import.tab.pack"),icon:ic}].map(({k:re,label:ne,icon:ge})=>x.jsxs("button",{onClick:()=>o(re),className:`min-w-[72px] flex-1 flex items-center justify-center gap-0.5 py-1.5 px-0.5 rounded-md font-bold transition-colors ${a===re?"bg-brand/15 text-brand":"text-white/50 hover:text-white/80"}`,children:[x.jsx(ge,{className:"w-3 h-3 shrink-0"}),x.jsx("span",{className:"whitespace-nowrap",style:{fontSize:"clamp(0.75rem, 4cqi, 0.875rem)"},children:ne})]},re))}),a==="url"?x.jsxs("section",{className:"space-y-2","data-testid":"import-url-section",children:[x.jsx("input",{type:"text",value:c,onChange:re=>f(re.target.value),placeholder:i("import.url.placeholder"),"data-testid":"repo-url-input",className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors"}),x.jsx("p",{className:"text-caption text-white/45 leading-relaxed",children:i("import.url.desc")}),x.jsx("button",{onClick:q,disabled:!c.trim()||E,"data-testid":"import-url-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.url")})]}):a==="markdown"?x.jsxs("section",{className:"space-y-2","data-testid":"import-md-section",children:[x.jsx("input",{type:"text",value:v,onChange:re=>C(re.target.value),placeholder:i("import.placeholder.name"),"data-testid":"md-name-input",className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors"}),x.jsx("textarea",{value:y,onChange:re=>T(re.target.value),placeholder:i("import.placeholder.md"),"data-testid":"md-text-input",rows:4,className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors resize-none"}),x.jsx("button",{onClick:R,disabled:!y.trim()||E,"data-testid":"import-md-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.md")})]}):a==="folder"?x.jsxs("section",{className:"space-y-2","data-testid":"import-folder-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.folder.desc")}),!hn&&x.jsx("input",{type:"text",value:h,onChange:re=>d(re.target.value),placeholder:i("import.folder.pathPlaceholder"),"data-testid":"import-folder-path",className:"w-full bg-black/25 text-white placeholder:text-white/35 text-body rounded-lg px-3 py-2 border border-white/15 focus:border-brand focus:outline-none transition-colors"}),x.jsx("button",{onClick:D,disabled:E||!hn&&!h.trim(),"data-testid":"import-folder-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.folder")})]}):a==="epub"?x.jsxs("section",{className:"space-y-2","data-testid":"import-epub-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.epub.desc")}),!hn&&x.jsx("input",{ref:p,type:"file",accept:".epub,application/epub+zip",className:"hidden","data-testid":"import-epub-file",onChange:re=>{var ne;X((ne=re.target.files)==null?void 0:ne[0]),re.currentTarget.value=""}}),x.jsx("button",{onClick:$,disabled:E,"data-testid":"import-epub-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.epub")})]}):a==="audio"?x.jsxs("section",{className:"space-y-2","data-testid":"import-audio-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.audio.desc")}),!hn&&x.jsx("input",{ref:g,type:"file",multiple:!0,accept:".wav,.mp3,.m4a,.flac,.aac,.ogg,.opus,audio/*",className:"hidden","data-testid":"import-audio-file",onChange:re=>{ee(re.target.files),re.currentTarget.value=""}}),x.jsx("button",{onClick:z,disabled:E,"data-testid":"import-audio-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.audio")})]}):x.jsxs("section",{className:"space-y-2","data-testid":"import-pack-section",children:[x.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.pack.desc")}),!hn&&x.jsx("input",{ref:m,type:"file",accept:".json,application/json",className:"hidden","data-testid":"import-pack-file",onChange:re=>{var ne;le((ne=re.target.files)==null?void 0:ne[0]),re.currentTarget.value=""}}),x.jsx("button",{onClick:Z,disabled:E,"data-testid":"import-pack-btn",className:"btn-3d-brand w-full px-3 py-2 text-body disabled:opacity-40",children:i("import.btn.pack")})]})]}),_&&x.jsxs("div",{className:"border border-warning/40 text-warning-light text-label rounded-lg p-2 whitespace-pre-wrap","data-testid":"import-error",children:[_,P&&x.jsx("button",{onClick:()=>void K(P),disabled:E,"data-testid":"import-resume-btn",className:"block mt-1.5 text-label font-bold text-warning-light hover:text-warning underline underline-offset-2 disabled:opacity-40",children:i("import.error.resume")})]}),I&&x.jsxs("div",{className:"border border-brand/30 text-brand text-label rounded-lg p-2","data-testid":"import-success",children:[x.jsx(An,{className:"inline-block w-3.5 h-3.5 mr-1 align-[-3px]"}),I,(j==null?void 0:j.packable)&&x.jsx("button",{onClick:()=>void ce(j.courseId),disabled:E,"data-testid":"import-export-pack-btn",className:"block mt-1.5 text-label font-bold hover:underline underline-offset-2 disabled:opacity-40",children:i("import.pack.export")})]})]})]})]})}function $b({scrollRef:e,navRef:t,preset:n}){const r=k.useRef(null);return k.useEffect(()=>{const s=r.current,i=e.current,a=t.current;return!s||!i||!a?void 0:Ub(s,i,a,n)},[e,t,n]),x.jsx("canvas",{ref:r,className:"map-sky-canvas","aria-hidden":"true"})}function Yb({scrollRef:e,navRef:t,preset:n,getImpacts:r,getFlakes:s,orbSnowRef:i}){const a=k.useRef(null);return k.useEffect(()=>{const o=a.current,l=t.current,u=e.current;if(!o||!l||!u)return;let c=null,f=null;const h=()=>{c=null,f=null},d=new MutationObserver(h);d.observe(u,{childList:!0,subtree:!0}),window.addEventListener("resize",h);const p=zb(o,l,n,()=>{var T,v;c||(c=Array.from(u.querySelectorAll(".lesson-bubble")));const g=f??l.getBoundingClientRect();f=g;const y=[];for(const C of c){const E=C.getBoundingClientRect();if(E.bottom<g.top||E.top>g.bottom)continue;const w=(T=C.closest("[data-node-id]"))==null?void 0:T.getAttribute("data-node-id"),_=w?(v=i==null?void 0:i.current)==null?void 0:v.get(w):void 0;y.push({x:E.left-g.left+E.width/2,y:E.top-g.top+E.height/2,r:E.width/2,..._!==void 0?{snow:_}:{}})}return y},r,s);return()=>{p(),d.disconnect(),window.removeEventListener("resize",h)}},[e,t,n,r,s]),x.jsx("canvas",{ref:a,className:"map-orb-weather-canvas","aria-hidden":"true"})}function Gb({section:e,sectionIndex:t,tree:n,progressMap:r,selectedNodeId:s,dueNodeIds:i,streamingNodeIds:a,onJumpNode:o,physics:l,physicsWeather:u,scrollRef:c,navRef:f,onImpacts:h,onFlakes:d,orbSnowRef:m}){const p=n.filter(z=>z.parentId===e.id).sort((z,ee)=>z.orderIdx-ee.orderIdx),g=p.filter(z=>z.type==="lesson"),y=g.length>0&&g.every(z=>{var ee;return(((ee=r[z.id])==null?void 0:ee.mastery)??0)>=Yx}),T=k.useRef(null),[v,C]=k.useState(268);k.useEffect(()=>{if(!T.current)return;const z=()=>{var ce;const K=((ce=T.current)==null?void 0:ce.clientWidth)??268;C(K>0?K:268)};z();const ee=new ResizeObserver(z);return ee.observe(T.current),()=>ee.disconnect()},[]);const E=nb(p.length,v,e.id),w=E.height,_=110,S=76,I=k.useRef(null),A=k.useRef(new Map),P=k.useRef(0),N=k.useRef(null),j=k.useRef(0),M=p.map(z=>z.id).join(","),L=p.map(z=>{var ee;return(z.type==="exam"?!y:(((ee=r[z.id])==null?void 0:ee.status)??"locked")==="locked")?1:0}).join("");k.useEffect(()=>{var Be,at;if(!l||p.length===0||v<=0)return;const z=T.current,ee=c.current;if(!z||!ee)return;let K;const ce=p[p.length-1];if((ce==null?void 0:ce.type)==="exam"){const G=(at=(Be=z.closest("section"))==null?void 0:Be.nextElementSibling)==null?void 0:at.querySelector(".map-signpost");G&&(K={x:$i(`${e.id}:next`,v),y:G.getBoundingClientRect().top-z.getBoundingClientRect().top})}const fe=bb({nodes:E.nodes.map((G,se)=>{const xe=p[se];return{id:xe.id,x:G.x,y:G.y,isExam:xe.type==="exam",locked:B(xe),spawn:(()=>{const Ee=A.current.get(xe.id);return Ee?yb(Ee,P.current,v):void 0})()}}),width:v,height:E.height+40,weather:u,anchorKnotX:$i(`${e.id}:knot`,v),nextKnot:K});I.current=fe,v1(e.id,fe,z);const re=z.querySelector("[data-next-knot]");re&&(fe.nextKnot?(re.setAttribute("cx",String(fe.nextKnot.x)),re.setAttribute("cy",String(fe.nextKnot.y))):re.setAttribute("opacity","0"));const ne=z.querySelector("[data-exam-rope]");ne&&!fe.nextKnot&&ne.setAttribute("opacity","0");const ge=new Map;for(const G of z.querySelectorAll("[data-node-id]"))G.dataset.nodeId&&ge.set(G.dataset.nodeId,G);const Te=Array.from(z.querySelectorAll("[data-rope]")),Ne=Array.from(z.querySelectorAll("[data-pulse]")),Oe=Array.from(z.querySelectorAll("[data-field]"));let be=!0;const Fe=new IntersectionObserver(G=>{for(const se of G)be=se.isIntersecting},{root:ee,rootMargin:"200px 0px 200px 0px"});Fe.observe(z);const te=520,Re=[];let me=0,je=performance.now();const st=G=>{var lt;me=requestAnimationFrame(st);const se=Math.min(50,G-je);if(je=G,!be)return;fe.step(se);for(const ve of fe.balls){const Le=ge.get(ve.nodeId);Le&&(Le.style.transform=db(ve.body.position.x-ve.layoutX,ve.body.position.y-ve.layoutY,ve.squash,ve.squashAngle)),ve.squash=cb(ve.squash,se),(lt=m.current)==null||lt.set(ve.nodeId,ve.snow)}const xe=ve=>{if(ve==="__anchor")return fe.anchor;if(ve==="__next")return fe.nextKnot??fe.anchor;const Le=fe.ball(ve);if(Le)return{x:Le.body.position.x,y:Le.body.position.y+zt*gn};const ze=p.findIndex(ye=>ye.id===ve),Ye=ze>=0?E.nodes[ze]:void 0;return Ye?{x:Ye.x,y:Ye.y+zt*gn}:{x:0,y:0}};for(let ve=0;ve<fe.links.length&&ve<Te.length;ve++){const Le=fe.links[ve],ze=[xe(Le.from)];for(const Ye of Le.particles)ze.push({x:Ye.position.x,y:Ye.position.y});ze.push(xe(Le.to)),Te[ve].setAttribute("d",ub(ze))}for(let ve=0;ve<fe.balls.length&&ve<Oe.length;ve++){const Le=fe.balls[ve],ze=Oe[ve];Le.field>.03?(ze.setAttribute("cx",String(Le.body.position.x)),ze.setAttribute("cy",String(Le.body.position.y)),ze.setAttribute("r",String(zt+4+Le.field*5)),ze.setAttribute("opacity",String((.3*Le.field).toFixed(3)))):ze.setAttribute("opacity","0")}const Ee=fe.drainImpacts();for(const ve of Ee)Re.push({x:ve.x,y:ve.y,t0:G,s:Math.min(1,ve.speed/14)});for(let ve=Re.length-1;ve>=0;ve--)G-Re[ve].t0>te&&Re.splice(ve,1);for(let ve=0;ve<Ne.length;ve++){const Le=Re[ve],ze=Ne[ve];if(!Le){ze.setAttribute("opacity","0");continue}const Ye=(G-Le.t0)/te;ze.setAttribute("cx",String(Le.x)),ze.setAttribute("cy",String(Le.y)),ze.setAttribute("r",String(6+Ye*(14+Le.s*14))),ze.setAttribute("opacity",String(.55*(1-Ye))),ze.setAttribute("stroke-width",String(2+Le.s*1.5))}const Pe=fe.drainFlakes();if((Ee.length>0||Pe.length>0)&&f.current){const ve=z.getBoundingClientRect(),Le=f.current.getBoundingClientRect(),ze=Ye=>({x:Ye.x+ve.left-Le.left,y:Ye.y+ve.top-Le.top});Ee.length>0&&h(Ee.map(Ye=>({...ze(Ye),speed:Ye.speed}))),Pe.length>0&&d(Pe.map(Ye=>({...ze(Ye),vx:Ye.vx,vy:Ye.vy,amount:Ye.amount})))}};return me=requestAnimationFrame(st),()=>{cancelAnimationFrame(me),Fe.disconnect();for(const G of fe.balls)A.current.set(G.nodeId,{x:G.body.position.x,y:G.body.position.y,vx:G.body.velocity.x,vy:G.body.velocity.y});P.current=v,T1(e.id),fe.dispose(),I.current=null;for(const G of ge.values())G.style.transform=""}},[l,v,M,L,e.id,u]);const B=z=>{var ee;return z?z.type==="exam"?!y:(((ee=r[z.id])==null?void 0:ee.status)??"locked")==="locked":!0},V=(z,ee)=>{if(!(!I.current||z.button!==0||B(p.find(fe=>fe.id===ee))||!T.current)){try{z.currentTarget.setPointerCapture(z.pointerId)}catch{}j.current=0,N.current={track:{startX:z.clientX,startY:z.clientY},id:z.pointerId,dragging:!1,nodeId:ee}}},F=z=>{const ee=N.current,K=I.current;if(!ee||!K||z.pointerId!==ee.id)return;const ce=T.current;if(!ce||(!ee.dragging&&cc(ee.track,z.clientX,z.clientY)==="drag"&&(ee.dragging=!0,z.currentTarget.style.zIndex="40",K.beginDrag(ee.nodeId,z.clientX-ce.getBoundingClientRect().left,z.clientY-ce.getBoundingClientRect().top)),!ee.dragging))return;const fe=ce.getBoundingClientRect();K.moveDrag(z.clientX-fe.left,z.clientY-fe.top)},q=z=>{var K;const ee=N.current;if(!(!ee||z.pointerId!==ee.id)){if((K=I.current)==null||K.endDrag(),z.currentTarget.style.zIndex="",cc(ee.track,z.clientX,z.clientY)==="drag")j.current=Date.now()+300;else{const ce=p.find(fe=>fe.id===ee.nodeId);ce&&Date.now()>=j.current&&!B(ce)&&(So(z.clientX,z.clientY,ce.id),o(ce.id))}N.current=null}},R=z=>{const ee=p[z],K=ee?r[ee.id]:void 0,ce=(K==null?void 0:K.status)==="mastered"||(K==null?void 0:K.status)==="in_progress"||(K==null?void 0:K.status)==="available";return{stroke:ce?"var(--brand)":"var(--ink-faint)",strokeWidth:ce?4:2.5,strokeOpacity:ce?.6:.5,strokeDasharray:ce?"none":"3 7"}},$=E.nodes[0]?{x:$i(`${e.id}:knot`,v),y:Cs}:{x:v/2,y:Cs},X=p[p.length-1],D=(X==null?void 0:X.type)==="exam",Z=E.nodes[E.nodes.length-1],le=D&&Z?{x:$i(`${e.id}:next`,v),y:w+24}:void 0;return x.jsxs("section",{"data-testid":`map-section-${e.id.slice(0,8)}`,className:"py-3 px-2",children:[x.jsxs("div",{className:"map-signpost flex items-center gap-2 mb-3 px-2.5 py-1.5 rounded-lg shadow-sm",children:[x.jsx("span",{className:"w-6 h-6 rounded-full bg-gold text-neutral-900 text-caption font-extrabold flex items-center justify-center shrink-0 ring-2 ring-gold/40 shadow-sm",children:t+1}),x.jsx("span",{className:"text-label font-bold text-white truncate flex-1 drop-shadow-[0_1px_2px_rgba(0,0,0,0.7)]",children:e.title})]}),x.jsxs("div",{ref:T,className:"relative",style:{minHeight:w},children:[x.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",style:{height:w,overflow:"visible"},children:l?x.jsxs(x.Fragment,{children:[E.nodes[0]&&x.jsx("circle",{cx:$.x,cy:$.y,r:3.5,fill:"#ffc800",opacity:.9}),E.nodes[0]&&x.jsx("path",{"data-rope":0,d:`M ${$.x} ${$.y} L ${E.nodes[0].x} ${E.nodes[0].y+zt*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:R(0)}),E.segments.map((z,ee)=>x.jsx("path",{"data-rope":ee+1,d:`M ${z.from.x} ${z.from.y+zt*gn} L ${z.to.x} ${z.to.y+zt*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:R(z.index)},z.index)),le&&Z&&x.jsxs(x.Fragment,{children:[x.jsx("path",{"data-rope":E.segments.length+1,"data-exam-rope":!0,d:`M ${le.x} ${le.y} L ${Z.x} ${Z.y+zt*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:R(p.length-1)}),x.jsx("circle",{"data-next-knot":!0,cx:le.x,cy:le.y,r:3.5,fill:"#ffc800",opacity:.9})]}),Array.from({length:8},(z,ee)=>x.jsx("circle",{"data-pulse":ee,cx:0,cy:0,r:0,fill:"none",stroke:"white",opacity:0},ee)),p.map((z,ee)=>x.jsx("circle",{"data-field":ee,cx:0,cy:0,r:0,fill:"none",stroke:"#1cb0f6",strokeWidth:2,opacity:0},`f-${z.id}`))]}):E.segments.map(z=>{const ee=Kb(p[z.index],r);return x.jsx("path",{d:rb(z),stroke:ee?"var(--brand)":"var(--ink-faint)",strokeWidth:ee?4:2.5,strokeOpacity:ee?.6:.5,fill:"none",strokeLinecap:"round",strokeDasharray:ee?"none":"3 7",style:ee?{pathLength:1,animation:"path-draw 600ms var(--ease-out-expo)"}:void 0},z.index)})}),p.map((z,ee)=>{const K=E.nodes[ee];if(!K)return null;const ce=No(z.id),fe=`${ce%40/10}s`,re=`${5+ce%30/10}s`;return x.jsx("div",{"data-node-id":z.id,"data-noswipe":"",className:l?`absolute hover:z-30 will-change-transform ${B(z)?"cursor-not-allowed":"cursor-grab active:cursor-grabbing"}`:"absolute balloon-bob hover:z-30",style:{left:K.x-_/2,top:K.y-S/2+10,width:_,...l?{touchAction:"pan-y"}:{"--bob-delay":fe,"--bob-duration":re}},onPointerDown:l?ne=>V(ne,z.id):void 0,onPointerMove:l?F:void 0,onPointerUp:l?q:void 0,onPointerCancel:l?q:void 0,children:x.jsx(Xb,{lesson:z,progress:r[z.id],isSelected:z.id===s,isDue:i.has(z.id),isStreaming:a.includes(z.id),chapterLessonsMastered:y,onClick:()=>{Date.now()<j.current||(So(null,null,z.id),o(z.id))}})},z.id)})]})]})}function Kb(e,t){const n=e?t[e.id]:void 0;return(n==null?void 0:n.status)==="mastered"||(n==null?void 0:n.status)==="in_progress"||(n==null?void 0:n.status)==="available"}function Xb({lesson:e,progress:t,isSelected:n,isDue:r,isStreaming:s,chapterLessonsMastered:i,onClick:a}){const o=Ke(),l=(t==null?void 0:t.status)??"locked",u=(t==null?void 0:t.crownLevel)??0,c=e.type==="exam",f=Math.min(3,u),h=c?!i:l==="locked",d=c&&h,m=!c&&(l==="in_progress"||l==="mastered"),p=l==="mastered"?100:l==="in_progress"?Math.round(((t==null?void 0:t.mastery)??0)*100):0;return x.jsxs("div",{className:"group relative flex flex-col items-center w-full",children:[x.jsxs("button",{onClick:()=>!h&&a(),disabled:h,"data-testid":`${c?"exam-node":"map-node"}-${e.id.slice(0,8)}`,className:`group relative w-14 h-14 flex items-center justify-center text-2xl rounded-full transition-all duration-200 ${c?d?"lesson-bubble exam-bubble-locked":Jb(u>0):Qb(l)} ${h?"cursor-not-allowed":"cursor-pointer hover:scale-105"} ${n?"ring-4 ring-accent ring-offset-2 ring-offset-neutral-50 dark:ring-offset-neutral-950":""}`,title:void 0,"data-tooltip":d?`🔒 ${e.title}${o("node.locked.chapterHint")}`:c?`🎯 ${e.title}`:h?`🔒 ${e.title}`:r?`📖 ${e.title}${o("node.due.hint")}`:e.title,children:[s&&x.jsx(Nh,{className:"absolute -top-1.5 -right-1.5 z-10 w-4 h-4 text-accent bg-surface-0 rounded-full p-0.5 animate-spin shadow-pop pointer-events-none","aria-label":o("thread.streamingBadge"),"data-testid":`node-streaming-${e.id.slice(0,8)}`}),m&&x.jsxs("svg",{className:"absolute inset-0 w-full h-full -rotate-90 pointer-events-none",viewBox:"0 0 56 56","aria-hidden":"true",children:[x.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:"rgb(255 255 255 / 0.2)",strokeWidth:"2.5"}),x.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:l==="mastered"?"#ffc800":"white",strokeWidth:"2.5",strokeLinecap:"round",strokeDasharray:`${p/100*157} 157`,className:"transition-all duration-500"})]}),c?d?x.jsx("span",{"aria-label":"exam-locked",className:"relative z-10 opacity-60",children:"🔒"}):x.jsx(zx,{"aria-label":"exam",className:"relative z-10 w-6 h-6 text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.4)]",strokeWidth:2.5}):h?x.jsx("span",{"aria-label":"locked",className:"relative z-10 opacity-50",children:"🔒"}):l==="mastered"?x.jsx("span",{"aria-label":"mastered",className:"relative z-10 drop-shadow-lg crown-sparkle",children:"👑"}):l==="in_progress"?x.jsx(Cn,{"aria-label":"in-progress",className:"relative z-10 w-6 h-6 text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.4)]",strokeWidth:2.5}):x.jsx("span",{"aria-label":"available",className:"relative z-10 drop-shadow",children:"⭐"}),r&&!h&&!c&&x.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-review text-white text-caption flex items-center justify-center font-bold border-2 border-neutral-50 dark:border-neutral-950",children:"!"})]}),c&&x.jsx("div",{className:"flex gap-0.5 mt-1","data-testid":`map-stars-${e.id.slice(0,8)}`,children:[0,1,2].map(g=>x.jsx("span",{className:`text-caption ${g<f?"text-gold":"text-white/25"}`,children:"★"},g))}),n&&x.jsx("div",{className:"mt-1 text-caption text-center leading-tight max-w-[120px] font-bold px-1.5 py-0.5 rounded-md bg-brand/90 text-white shadow-sm",children:e.title})]})}function Qb(e){switch(e){case"locked":return"lesson-bubble lesson-bubble-locked";case"available":return"lesson-bubble lesson-bubble-available";case"in_progress":return"lesson-bubble lesson-bubble-in-progress";case"mastered":return"lesson-bubble lesson-bubble-mastered";default:return"lesson-bubble lesson-bubble-locked"}}function Jb(e){return e?"lesson-bubble exam-bubble-passed":"lesson-bubble exam-bubble"}function Zb({available:e,current:t,onChange:n}){const r=Ke(),[s,i]=k.useState(!1),a={en:"English","zh-CN":"中文","zh-TW":"繁體",ja:"日本語",ko:"한국어",fr:"Français",de:"Deutsch",es:"Español","pt-BR":"Português",ru:"Русский",it:"Italiano",ar:"العربية",hi:"हिन्दी",tr:"Türkçe",pl:"Polski",nl:"Nederlands",id:"Indonesia",vi:"Tiếng Việt",th:"ไทย",sv:"Svenska",fi:"Suomi"},o=t?a[t]??t:r("lang.original");return x.jsxs("div",{className:"relative shrink-0",children:[x.jsxs("button",{onClick:()=>i(!s),className:"flex items-center gap-1 px-1.5 py-0.5 rounded-md text-caption font-bold text-white/80 hover:text-white hover:bg-white/10 transition-colors","data-testid":"lang-switcher-btn",children:[x.jsx(bx,{className:"w-3 h-3"}),o]}),s&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>i(!1)}),x.jsxs("div",{className:"absolute top-full right-0 mt-1 z-50 bg-surface-0 rounded-lg shadow-elevated p-1 min-w-[100px] max-h-48 overflow-y-auto",children:[x.jsx("button",{"data-testid":"lang-option-original",onClick:()=>{n(null),i(!1)},className:`w-full text-left px-2 py-1 rounded-md text-caption font-bold transition-colors ${t===null?"bg-brand/15 text-brand":"text-ink-muted hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:r("lang.original")}),e.map(l=>x.jsx("button",{"data-testid":`lang-option-${l}`,onClick:()=>{n(l),i(!1)},className:`w-full text-left px-2 py-1 rounded-md text-caption font-bold transition-colors ${t===l?"bg-brand/15 text-brand":"text-ink-muted hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:a[l]??l},l))]})]})]})}const ey=500,On=8;function ty(){const[e,t]=k.useState(null),[n,r]=k.useState({mode:"cursor",x:0,y:0}),[s,i]=k.useState({w:0,h:0}),a=k.useRef(null),o=k.useCallback(()=>window.matchMedia("(pointer: coarse)").matches,[]),l=k.useCallback(g=>{o()||r(y=>y.mode==="cursor"?{...y,x:g.clientX,y:g.clientY}:y)},[o]),u=k.useCallback(g=>{var v;if(o())return;const y=(v=g.target)==null?void 0:v.closest("[data-tooltip]"),T=y==null?void 0:y.getAttribute("data-tooltip");if(T){t(T),r({mode:"cursor",x:g.clientX,y:g.clientY});return}t(null)},[o]),c=k.useCallback(g=>{var T,v;if(o())return;((v=(T=g.target)==null?void 0:T.closest)==null?void 0:v.call(T,"[data-tooltip]"))&&t(null)},[o]);if(k.useEffect(()=>(document.addEventListener("mousemove",l,{passive:!0}),document.addEventListener("mouseover",u,{passive:!0}),document.addEventListener("mouseout",c,{passive:!0}),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseover",u),document.removeEventListener("mouseout",c)}),[l,u,c]),k.useEffect(()=>{let g=null;const y=()=>{g&&(clearTimeout(g),g=null)},T=w=>{var A;if(!o()||w.touches.length!==1)return y();const _=(A=w.target)==null?void 0:A.closest("[data-tooltip]"),S=_==null?void 0:_.getAttribute("data-tooltip");if(!S||!_)return y();const I=_;y(),g=setTimeout(()=>{I.isConnected&&(t(S),r({mode:"rect",x:0,y:0,rect:I.getBoundingClientRect()}))},ey)},v=()=>{y(),t(w=>w&&null)},C=()=>y(),E=()=>{y(),t(null)};return document.addEventListener("touchstart",T,{passive:!0}),document.addEventListener("touchend",v,{passive:!0}),document.addEventListener("touchmove",C,{passive:!0}),document.addEventListener("touchcancel",E,{passive:!0}),()=>{y(),document.removeEventListener("touchstart",T),document.removeEventListener("touchend",v),document.removeEventListener("touchmove",C),document.removeEventListener("touchcancel",E)}},[o]),k.useLayoutEffect(()=>{a.current&&e&&i({w:a.current.offsetWidth,h:a.current.offsetHeight})},[e]),!e)return null;const f=window.innerWidth,h=window.innerHeight;let d,m,p;if(n.mode==="rect"&&n.rect){const g=n.rect;d=g.left+g.width/2-s.w/2,m=g.top-s.h-6,p="none",m<On&&(m=g.bottom+6)}else d=n.x,m=n.y-6,p="translate(0, -100%)";return d=Math.min(Math.max(d,On),Math.max(On,f-s.w-On)),m=Math.min(Math.max(m,On),Math.max(On,h-s.h-On)),jh.createPortal(x.jsx("div",{ref:a,style:{position:"fixed",left:d,top:m,transform:p,zIndex:99999,pointerEvents:"none",visibility:s.w?"visible":"hidden",background:"rgb(var(--surface-0-rgb) / 0.92)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",color:"var(--ink)",border:"1px solid rgb(var(--border-rgb) / 0.5)",fontSize:"0.875rem",fontWeight:600,lineHeight:1.4,padding:"4px 10px",borderRadius:"8px",maxWidth:"260px",wordBreak:"break-word",boxShadow:"0 4px 12px rgb(var(--shadow-rgb) / 0.15)",whiteSpace:"normal"},children:e}),document.body)}function j4(){}function xc(e){const t=[],n=String(e||"");let r=n.indexOf(","),s=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const a=n.slice(s,r).trim();(a||!i)&&t.push(a),s=r+1,r=n.indexOf(",",s)}return t}function Jh(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ny=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ry=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iy={};function bc(e,t){return(iy.jsx?ry:ny).test(e)}const sy=/[ \t\n\f\r]/g;function ay(e){return typeof e=="object"?e.type==="text"?yc(e.value):!1:yc(e)}function yc(e){return e.replace(sy,"")===""}class Ni{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ni.prototype.normal={};Ni.prototype.property={};Ni.prototype.space=void 0;function Zh(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Ni(n,r,t)}function Ei(e){return e.toLowerCase()}class Pt{constructor(t,n){this.attribute=n,this.property=t}}Pt.prototype.attribute="";Pt.prototype.booleanish=!1;Pt.prototype.boolean=!1;Pt.prototype.commaOrSpaceSeparated=!1;Pt.prototype.commaSeparated=!1;Pt.prototype.defined=!1;Pt.prototype.mustUseProperty=!1;Pt.prototype.number=!1;Pt.prototype.overloadedBoolean=!1;Pt.prototype.property="";Pt.prototype.spaceSeparated=!1;Pt.prototype.space=void 0;let oy=0;const Ie=rr(),ft=rr(),Ro=rr(),ue=rr(),et=rr(),Kn=rr(),Ft=rr();function rr(){return 2**++oy}const Lo=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:ft,commaOrSpaceSeparated:Ft,commaSeparated:Kn,number:ue,overloadedBoolean:Ro,spaceSeparated:et},Symbol.toStringTag,{value:"Module"})),Ma=Object.keys(Lo);class Dl extends Pt{constructor(t,n,r,s){let i=-1;if(super(t,n),Ec(this,"space",s),typeof r=="number")for(;++i<Ma.length;){const a=Ma[i];Ec(this,Ma[i],(r&Lo[a])===Lo[a])}}}Dl.prototype.defined=!0;function Ec(e,t,n){n&&(e[t]=n)}function Ir(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Dl(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Ei(r)]=r,n[Ei(i.attribute)]=r}return new Ni(t,n,e.space)}const em=Ir({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:ue,ariaColIndex:ue,ariaColSpan:ue,ariaControls:et,ariaCurrent:null,ariaDescribedBy:et,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:et,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:et,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:et,ariaLevel:ue,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:et,ariaPlaceholder:null,ariaPosInSet:ue,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:et,ariaRowCount:ue,ariaRowIndex:ue,ariaRowSpan:ue,ariaSelected:ft,ariaSetSize:ue,ariaSort:null,ariaValueMax:ue,ariaValueMin:ue,ariaValueNow:ue,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tm(e,t){return t in e?e[t]:t}function nm(e,t){return tm(e,t.toLowerCase())}const ly=Ir({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Kn,acceptCharset:et,accessKey:et,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alpha:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:et,autoFocus:Ie,autoPlay:Ie,blocking:et,capture:null,charSet:null,checked:Ie,cite:null,className:et,closedBy:null,colorSpace:null,cols:ue,colSpan:ue,command:null,commandFor:null,content:null,contentEditable:ft,controls:Ie,controlsList:et,coords:ue|Kn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:Ro,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:et,height:ue,hidden:Ro,high:ue,href:null,hrefLang:null,htmlFor:et,httpEquiv:et,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:et,itemRef:et,itemScope:Ie,itemType:et,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:ue,manifest:null,max:null,maxLength:ue,media:null,method:null,min:null,minLength:ue,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:ue,pattern:null,ping:et,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:et,required:Ie,reversed:Ie,rows:ue,rowSpan:ue,sandbox:et,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootCustomElementRegistry:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shadowRootSerializable:Ie,shape:null,size:ue,sizes:null,slot:null,span:ue,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ue,step:null,style:null,tabIndex:ue,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:ft,width:ue,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:et,axis:null,background:null,bgColor:null,border:ue,borderColor:null,bottomMargin:ue,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:ue,leftMargin:ue,link:null,longDesc:null,lowSrc:null,marginHeight:ue,marginWidth:ue,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:ue,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:ue,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ue,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ie,disablePictureInPicture:Ie,disableRemotePlayback:Ie,exportParts:Kn,part:et,prefix:null,property:null,results:ue,security:null,unselectable:null},space:"html",transform:nm}),uy=Ir({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ft,accentHeight:ue,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ue,amplitude:ue,arabicForm:null,ascent:ue,attributeName:null,attributeType:null,azimuth:ue,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ue,by:null,calcMode:null,capHeight:ue,className:et,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ue,diffuseConstant:ue,direction:null,display:null,dur:null,divisor:ue,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:ue,enableBackground:null,end:null,event:null,exponent:ue,externalResourcesRequired:null,fill:null,fillOpacity:ue,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Kn,g2:Kn,glyphName:Kn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ue,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ue,horizOriginX:ue,horizOriginY:ue,id:null,ideographic:ue,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ue,k:ue,k1:ue,k2:ue,k3:ue,k4:ue,kernelMatrix:Ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ue,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ue,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ue,overlineThickness:ue,paintOrder:null,panose1:null,path:null,pathLength:ue,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:et,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ue,pointsAtY:ue,pointsAtZ:ue,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ft,rev:Ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ft,requiredFeatures:Ft,requiredFonts:Ft,requiredFormats:Ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ue,specularExponent:ue,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ue,strikethroughThickness:ue,string:null,stroke:null,strokeDashArray:Ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ue,strokeOpacity:ue,strokeWidth:null,style:null,surfaceScale:ue,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ft,tabIndex:ue,tableValues:null,target:null,targetX:ue,targetY:ue,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ue,underlineThickness:ue,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ue,values:null,vAlphabetic:ue,vMathematical:ue,vectorEffect:null,vHanging:ue,vIdeographic:ue,version:null,vertAdvY:ue,vertOriginX:ue,vertOriginY:ue,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ue,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tm}),rm=Ir({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),im=Ir({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:nm}),sm=Ir({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),cy={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},dy=/[A-Z]/g,vc=/-[a-z]/g,fy=/^data[-\w.:]+$/i;function Xs(e,t){const n=Ei(t);let r=t,s=Pt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&fy.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(vc,my);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!vc.test(i)){let a=i.replace(dy,hy);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Dl}return new s(r,t)}function hy(e){return"-"+e.toLowerCase()}function my(e){return e.charAt(1).toUpperCase()}const Ri=Zh([em,ly,rm,im,sm],"html"),Nn=Zh([em,uy,rm,im,sm],"svg");function Tc(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function am(e){return e.join(" ").trim()}var dr={},Da,kc;function py(){if(kc)return Da;kc=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
437
437
  `,u="/",c="*",f="",h="comment",d="declaration";function m(g,y){if(typeof g!="string")throw new TypeError("First argument must be a string");if(!g)return[];y=y||{};var T=1,v=1;function C(M){var L=M.match(t);L&&(T+=L.length);var B=M.lastIndexOf(l);v=~B?M.length-B:v+M.length}function E(){var M={line:T,column:v};return function(L){return L.position=new w(M),I(),L}}function w(M){this.start=M,this.end={line:T,column:v},this.source=y.source}w.prototype.content=g;function _(M){var L=new Error(y.source+":"+T+":"+v+": "+M);if(L.reason=M,L.filename=y.source,L.line=T,L.column=v,L.source=g,!y.silent)throw L}function S(M){var L=M.exec(g);if(L){var B=L[0];return C(B),g=g.slice(B.length),L}}function I(){S(n)}function A(M){var L;for(M=M||[];L=P();)L!==!1&&M.push(L);return M}function P(){var M=E();if(!(u!=g.charAt(0)||c!=g.charAt(1))){for(var L=2;f!=g.charAt(L)&&(c!=g.charAt(L)||u!=g.charAt(L+1));)++L;if(L+=2,f===g.charAt(L-1))return _("End of comment missing");var B=g.slice(2,L-2);return v+=2,C(B),g=g.slice(L),v+=2,M({type:h,comment:B})}}function N(){var M=E(),L=S(r);if(L){if(P(),!S(s))return _("property missing ':'");var B=S(i),V=M({type:d,property:p(L[0].replace(e,f)),value:B?p(B[0].replace(e,f)):f});return S(a),V}}function j(){var M=[];A(M);for(var L;L=N();)L!==!1&&(M.push(L),A(M));return M}return I(),j()}function p(g){return g?g.replace(o,f):f}return Da=m,Da}var wc;function gy(){if(wc)return dr;wc=1;var e=dr&&dr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(dr,"__esModule",{value:!0}),dr.default=n;const t=e(py());function n(r,s){let i=null;if(!r||typeof r!="string")return i;const a=(0,t.default)(r),o=typeof s=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:c}=l;o?s(u,c,l):c&&(i=i||{},i[u]=c)}),i}return dr}var Vr={},Sc;function xy(){if(Sc)return Vr;Sc=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,i=function(u){return!u||n.test(u)||e.test(u)},a=function(u,c){return c.toUpperCase()},o=function(u,c){return"".concat(c,"-")},l=function(u,c){return c===void 0&&(c={}),i(u)?u:(u=u.toLowerCase(),c.reactCompat?u=u.replace(s,o):u=u.replace(r,o),u.replace(t,a))};return Vr.camelCase=l,Vr}var qr,Ac;function by(){if(Ac)return qr;Ac=1;var e=qr&&qr.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(gy()),n=xy();function r(s,i){var a={};return!s||typeof s!="string"||(0,t.default)(s,function(o,l){o&&l&&(a[(0,n.camelCase)(o,i)]=l)}),a}return r.default=r,qr=r,qr}var yy=by();const Ey=Al(yy),Qs=om("end"),un=om("start");function om(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function lm(e){const t=un(e),n=Qs(e);if(t&&n)return{start:t,end:n}}function ri(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Cc(e.position):"start"in e||"end"in e?Cc(e):"line"in e||"column"in e?Po(e):""}function Po(e){return _c(e&&e.line)+":"+_c(e&&e.column)}function Cc(e){return Po(e&&e.start)+"-"+Po(e&&e.end)}function _c(e){return e&&typeof e=="number"?e:1}class kt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?i.ruleId=r:(i.source=r.slice(0,l),i.ruleId=r.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){const l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=o?o.line:void 0,this.name=ri(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}kt.prototype.file="";kt.prototype.name="";kt.prototype.reason="";kt.prototype.message="";kt.prototype.stack="";kt.prototype.column=void 0;kt.prototype.line=void 0;kt.prototype.ancestors=void 0;kt.prototype.cause=void 0;kt.prototype.fatal=void 0;kt.prototype.place=void 0;kt.prototype.ruleId=void 0;kt.prototype.source=void 0;const Ol={}.hasOwnProperty,vy=new Map,Ty=/[A-Z]/g,ky=new Set(["table","tbody","thead","tfoot","tr"]),wy=new Set(["td","th"]),um="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Sy(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Py(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Ly(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Nn:Ri,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=cm(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function cm(e,t,n){if(t.type==="element")return Ay(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Cy(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Iy(e,t,n);if(t.type==="mdxjsEsm")return _y(e,t);if(t.type==="root")return Ny(e,t,n);if(t.type==="text")return Ry(e,t)}function Ay(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Nn,e.schema=s),e.ancestors.push(t);const i=fm(e,t.tagName,!1),a=My(e,t);let o=Bl(e,t);return ky.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!ay(l):!0})),dm(e,a,i,t),Fl(a,o),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function Cy(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}vi(e,t.position)}function _y(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);vi(e,t.position)}function Iy(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Nn,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:fm(e,t.name,!0),a=Dy(e,t),o=Bl(e,t);return dm(e,a,i,t),Fl(a,o),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function Ny(e,t,n){const r={};return Fl(r,Bl(e,t)),e.create(t,e.Fragment,r,n)}function Ry(e,t){return t.value}function dm(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Fl(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ly(e,t,n){return r;function r(s,i,a,o){const u=Array.isArray(a.children)?n:t;return o?u(i,a,o):u(i,a)}}function Py(e,t){return n;function n(r,s,i,a){const o=Array.isArray(i.children),l=un(r);return t(s,i,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function My(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Ol.call(t.properties,s)){const i=Oy(e,s,t.properties[s]);if(i){const[a,o]=i;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&wy.has(t.tagName)?r=o:n[a]=o}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Dy(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else vi(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,i=e.evaluater.evaluateExpression(o.expression)}else vi(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function Bl(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:vy;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const l=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(l){const u=s.get(l)||0;a=l+"-"+u,s.set(l,u+1)}}const o=cm(e,i,a);o!==void 0&&n.push(o)}return n}function Oy(e,t,n){const r=Xs(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Jh(n):am(n)),r.property==="style"){let s=typeof n=="object"?n:Fy(e,String(n));return e.stylePropertyNameCase==="css"&&(s=By(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?cy[r.property]||r.property:r.attribute,n]}}function Fy(e,t){try{return Ey(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new kt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=um+"#cannot-parse-style-attribute",s}}function fm(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,a;for(;++i<s.length;){const o=bc(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(i&&o.type==="Literal"),optional:!1}:o}r=a}else r=bc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Ol.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);vi(e)}function vi(e,t){const n=new kt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=um+"#cannot-handle-mdx-estrees-without-createevaluater",n}function By(e){const t={};let n;for(n in e)Ol.call(e,n)&&(t[jy(n)]=e[n]);return t}function jy(e){let t=e.replace(Ty,Hy);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Hy(e){return"-"+e.toLowerCase()}const Oa={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Uy={};function jl(e,t){const n=Uy,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return hm(e,r,s)}function hm(e,t,n){if(zy(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Ic(e.children,t,n)}return Array.isArray(e)?Ic(e,t,n):""}function Ic(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=hm(e[s],t,n);return r.join("")}function zy(e){return!!(e&&typeof e=="object")}const Nc=document.createElement("i");function Hl(e){const t="&"+e+";";Nc.innerHTML=t;const n=Nc.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Bt(e,t,n,r){const s=e.length;let i=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function Vt(e,t){return e.length>0?(Bt(e,e.length,0,t),e):t}const Rc={}.hasOwnProperty;function mm(e){const t={};let n=-1;for(;++n<e.length;)Vy(t,e[n]);return t}function Vy(e,t){let n;for(n in t){const s=(Rc.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){Rc.call(s,a)||(s[a]=[]);const o=i[a];qy(s[a],Array.isArray(o)?o:o?[o]:[])}}}function qy(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Bt(e,0,0,r)}function pm(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Jt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const At=Rn(/[A-Za-z]/),Tt=Rn(/[\dA-Za-z]/),Wy=Rn(/[#-'*+\--9=?A-Z^-~]/);function _s(e){return e!==null&&(e<32||e===127)}const Mo=Rn(/\d/),$y=Rn(/[\dA-Fa-f]/),Yy=Rn(/[!-/:-@[-`{-~]/);function Ae(e){return e!==null&&e<-2}function rt(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const Js=Rn(new RegExp("\\p{P}|\\p{S}","u")),tr=Rn(/\s/);function Rn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Nr(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Tt(e.charCodeAt(n+1))&&Tt(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const o=e.charCodeAt(n+1);i<56320&&o>56319&&o<57344?(a=String.fromCharCode(i,o),s=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Ve(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(l){return Ue(l)?(e.enter(n),o(l)):t(l)}function o(l){return Ue(l)&&i++<s?(e.consume(l),o):(e.exit(n),t(l))}}const Gy={tokenize:Ky};function Ky(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ve(e,t,"linePrefix")}function s(o){return e.enter("paragraph"),i(o)}function i(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return Ae(o)?(e.consume(o),e.exit("chunkText"),i):(e.consume(o),a)}}const Xy={tokenize:Qy},Lc={tokenize:Jy};function Qy(e){const t=this,n=[];let r=0,s,i,a;return o;function o(v){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,l,u)(v)}return u(v)}function l(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&T();const C=t.events.length;let E=C,w;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){w=t.events[E][1].end;break}y(r);let _=C;for(;_<t.events.length;)t.events[_][1].end={...w},_++;return Bt(t.events,E+1,0,t.events.slice(C)),t.events.length=_,u(v)}return o(v)}function u(v){if(r===n.length){if(!s)return h(v);if(s.currentConstruct&&s.currentConstruct.concrete)return m(v);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Lc,c,f)(v)}function c(v){return s&&T(),y(r),h(v)}function f(v){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(v)}function h(v){return t.containerState={},e.attempt(Lc,d,m)(v)}function d(v){return r++,n.push([t.currentConstruct,t.containerState]),h(v)}function m(v){if(v===null){s&&T(),y(0),e.consume(v);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),p(v)}function p(v){if(v===null){g(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return Ae(v)?(e.consume(v),g(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(v),p)}function g(v,C){const E=t.sliceStream(v);if(C&&E.push(null),v.previous=i,i&&(i.next=v),i=v,s.defineSkip(v.start),s.write(E),t.parser.lazy[v.start.line]){let w=s.events.length;for(;w--;)if(s.events[w][1].start.offset<a&&(!s.events[w][1].end||s.events[w][1].end.offset>a))return;const _=t.events.length;let S=_,I,A;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){if(I){A=t.events[S][1].end;break}I=!0}for(y(r),w=_;w<t.events.length;)t.events[w][1].end={...A},w++;Bt(t.events,S+1,0,t.events.slice(_)),t.events.length=w}}function y(v){let C=n.length;for(;C-- >v;){const E=n[C];t.containerState=E[1],E[0].exit.call(t,e)}n.length=v}function T(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function Jy(e,t,n){return Ve(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Sr(e){if(e===null||rt(e)||tr(e))return 1;if(Js(e))return 2}function Zs(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const Do={name:"attention",resolveAll:Zy,tokenize:e2};function Zy(e,t){let n=-1,r,s,i,a,o,l,u,c;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};Pc(f,-l),Pc(h,l),a={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Vt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Vt(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),u=Vt(u,Zs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Vt(u,[["exit",i,t],["enter",o,t],["exit",o,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(c=2,u=Vt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,Bt(e,r-1,n-r+3,u),n=r+u.length-c-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function e2(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=Sr(r);let i;return a;function a(l){return i=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===i)return e.consume(l),o;const u=e.exit("attentionSequence"),c=Sr(l),f=!c||c===2&&s||n.includes(l),h=!s||s===2&&c||n.includes(r);return u._open=!!(i===42?f:f&&(s||!h)),u._close=!!(i===42?h:h&&(c||!f)),t(l)}}function Pc(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const t2={name:"autolink",tokenize:n2};function n2(e,t,n){let r=0;return s;function s(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(d){return At(d)?(e.consume(d),a):d===64?n(d):u(d)}function a(d){return d===43||d===45||d===46||Tt(d)?(r=1,o(d)):u(d)}function o(d){return d===58?(e.consume(d),r=0,l):(d===43||d===45||d===46||Tt(d))&&r++<32?(e.consume(d),o):(r=0,u(d))}function l(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):d===null||d===32||d===60||_s(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),c):Wy(d)?(e.consume(d),u):n(d)}function c(d){return Tt(d)?f(d):n(d)}function f(d){return d===46?(e.consume(d),r=0,c):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):h(d)}function h(d){if((d===45||Tt(d))&&r++<63){const m=d===45?h:f;return e.consume(d),m}return n(d)}}const Li={partial:!0,tokenize:r2};function r2(e,t,n){return r;function r(i){return Ue(i)?Ve(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||Ae(i)?t(i):n(i)}}const gm={continuation:{tokenize:s2},exit:a2,name:"blockQuote",tokenize:i2};function i2(e,t,n){const r=this;return s;function s(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return Ue(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function s2(e,t,n){const r=this;return s;function s(a){return Ue(a)?Ve(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(gm,t,n)(a)}}function a2(e){e.exit("blockQuote")}const xm={name:"characterEscape",tokenize:o2};function o2(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return Yy(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const bm={name:"characterReference",tokenize:l2};function l2(e,t,n){const r=this;let s=0,i,a;return o;function o(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,a=Tt,c(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=$y,c):(e.enter("characterReferenceValue"),i=7,a=Mo,c(f))}function c(f){if(f===59&&s){const h=e.exit("characterReferenceValue");return a===Tt&&!Hl(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<i?(e.consume(f),c):n(f)}}const Mc={partial:!0,tokenize:c2},Dc={concrete:!0,name:"codeFenced",tokenize:u2};function u2(e,t,n){const r=this,s={partial:!0,tokenize:E};let i=0,a=0,o;return l;function l(w){return u(w)}function u(w){const _=r.events[r.events.length-1];return i=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[1],!0).length:0,o=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(w)}function c(w){return w===o?(a++,e.consume(w),c):a<3?n(w):(e.exit("codeFencedFenceSequence"),Ue(w)?Ve(e,f,"whitespace")(w):f(w))}function f(w){return w===null||Ae(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(Mc,p,C)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(w))}function h(w){return w===null||Ae(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(w)):Ue(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,d,"whitespace")(w)):w===96&&w===o?n(w):(e.consume(w),h)}function d(w){return w===null||Ae(w)?f(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||Ae(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(w)):w===96&&w===o?n(w):(e.consume(w),m)}function p(w){return e.attempt(s,C,g)(w)}function g(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),y}function y(w){return i>0&&Ue(w)?Ve(e,T,"linePrefix",i+1)(w):T(w)}function T(w){return w===null||Ae(w)?e.check(Mc,p,C)(w):(e.enter("codeFlowValue"),v(w))}function v(w){return w===null||Ae(w)?(e.exit("codeFlowValue"),T(w)):(e.consume(w),v)}function C(w){return e.exit("codeFenced"),t(w)}function E(w,_,S){let I=0;return A;function A(L){return w.enter("lineEnding"),w.consume(L),w.exit("lineEnding"),P}function P(L){return w.enter("codeFencedFence"),Ue(L)?Ve(w,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):N(L)}function N(L){return L===o?(w.enter("codeFencedFenceSequence"),j(L)):S(L)}function j(L){return L===o?(I++,w.consume(L),j):I>=a?(w.exit("codeFencedFenceSequence"),Ue(L)?Ve(w,M,"whitespace")(L):M(L)):S(L)}function M(L){return L===null||Ae(L)?(w.exit("codeFencedFence"),_(L)):S(L)}}}function c2(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Fa={name:"codeIndented",tokenize:f2},d2={partial:!0,tokenize:h2};function f2(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),Ve(e,i,"linePrefix",5)(u)}function i(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?l(u):Ae(u)?e.attempt(d2,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||Ae(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function h2(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):Ae(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):Ve(e,i,"linePrefix",5)(a)}function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):Ae(a)?s(a):n(a)}}const m2={name:"codeText",previous:g2,resolve:p2,tokenize:x2};function p2(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function g2(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function x2(e,t,n){let r=0,s,i;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),o(f)}function o(f){return f===96?(e.consume(f),r++,o):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(i=e.enter("codeTextSequence"),s=0,c(f)):Ae(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||Ae(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),u)}function c(f){return f===96?(e.consume(f),s++,c):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(i.type="codeTextData",u(f))}}class b2{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Wr(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Wr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Wr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Wr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Wr(this.left,n.reverse())}}}function Wr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ym(e){const t={};let n=-1,r,s,i,a,o,l,u;const c=new b2(e);for(;++n<c.length;){for(;n in t;)n=t[n];if(r=c.get(n),n&&r[1].type==="chunkFlow"&&c.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,y2(c,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=c.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(c.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...c.get(s)[1].start},o=c.slice(s,n),o.unshift(r),c.splice(s,n-s+1,o))}}return Bt(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function y2(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],u={};let c,f,h=-1,d=n,m=0,p=0;const g=[p];for(;d;){for(;e.get(++s)[1]!==d;);i.push(s),d._tokenizer||(c=r.sliceStream(d),d.next||c.push(null),f&&a.defineSkip(d.start),d._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(c),d._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=d,d=d.next}for(d=n;++h<o.length;)o[h][0]==="exit"&&o[h-1][0]==="enter"&&o[h][1].type===o[h-1][1].type&&o[h][1].start.line!==o[h][1].end.line&&(p=h+1,g.push(p),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(a.events=[],d?(d._tokenizer=void 0,d.previous=void 0):g.pop(),h=g.length;h--;){const y=o.slice(g[h],g[h+1]),T=i.pop();l.push([T,T+y.length-1]),e.splice(T,2,y)}for(l.reverse(),h=-1;++h<l.length;)u[m+l[h][0]]=m+l[h][1],m+=l[h][1]-l[h][0]-1;return u}const E2={resolve:T2,tokenize:k2},v2={partial:!0,tokenize:w2};function T2(e){return ym(e),e}function k2(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(o)}function s(o){return o===null?i(o):Ae(o)?e.check(v2,a,i)(o):(e.consume(o),s)}function i(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function w2(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ve(e,i,"linePrefix")}function i(a){if(a===null||Ae(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Em(e,t,n,r,s,i,a,o,l){const u=l||Number.POSITIVE_INFINITY;let c=0;return f;function f(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),h):y===null||y===32||y===41||_s(y)?n(y):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),p(y))}function h(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),d(y))}function d(y){return y===62?(e.exit("chunkString"),e.exit(o),h(y)):y===null||y===60||Ae(y)?n(y):(e.consume(y),y===92?m:d)}function m(y){return y===60||y===62||y===92?(e.consume(y),d):d(y)}function p(y){return!c&&(y===null||y===41||rt(y))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(y)):c<u&&y===40?(e.consume(y),c++,p):y===41?(e.consume(y),c--,p):y===null||y===32||y===40||_s(y)?n(y):(e.consume(y),y===92?g:p)}function g(y){return y===40||y===41||y===92?(e.consume(y),p):p(y)}}function vm(e,t,n,r,s,i){const a=this;let o=0,l;return u;function u(d){return e.enter(r),e.enter(s),e.consume(d),e.exit(s),e.enter(i),c}function c(d){return o>999||d===null||d===91||d===93&&!l||d===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(d):d===93?(e.exit(i),e.enter(s),e.consume(d),e.exit(s),e.exit(r),t):Ae(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),f(d))}function f(d){return d===null||d===91||d===93||Ae(d)||o++>999?(e.exit("chunkString"),c(d)):(e.consume(d),l||(l=!Ue(d)),d===92?h:f)}function h(d){return d===91||d===92||d===93?(e.consume(d),o++,f):f(d)}}function Tm(e,t,n,r,s,i){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),a=h===40?41:h,l):n(h)}function l(h){return h===a?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(i),u(h))}function u(h){return h===a?(e.exit(i),l(a)):h===null?n(h):Ae(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Ve(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===a||h===null||Ae(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:c)}function f(h){return h===a||h===92?(e.consume(h),c):c(h)}}function ii(e,t){let n;return r;function r(s){return Ae(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Ue(s)?Ve(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const S2={name:"definition",tokenize:C2},A2={partial:!0,tokenize:_2};function C2(e,t,n){const r=this;let s;return i;function i(d){return e.enter("definition"),a(d)}function a(d){return vm.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function o(d){return s=Jt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter("definitionMarker"),e.consume(d),e.exit("definitionMarker"),l):n(d)}function l(d){return rt(d)?ii(e,u)(d):u(d)}function u(d){return Em(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function c(d){return e.attempt(A2,f,f)(d)}function f(d){return Ue(d)?Ve(e,h,"whitespace")(d):h(d)}function h(d){return d===null||Ae(d)?(e.exit("definition"),r.parser.defined.push(s),t(d)):n(d)}}function _2(e,t,n){return r;function r(o){return rt(o)?ii(e,s)(o):n(o)}function s(o){return Tm(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function i(o){return Ue(o)?Ve(e,a,"whitespace")(o):a(o)}function a(o){return o===null||Ae(o)?t(o):n(o)}}const I2={name:"hardBreakEscape",tokenize:N2};function N2(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return Ae(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const R2={name:"headingAtx",resolve:L2,tokenize:P2};function L2(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Bt(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function P2(e,t,n){let r=0;return s;function s(c){return e.enter("atxHeading"),i(c)}function i(c){return e.enter("atxHeadingSequence"),a(c)}function a(c){return c===35&&r++<6?(e.consume(c),a):c===null||rt(c)?(e.exit("atxHeadingSequence"),o(c)):n(c)}function o(c){return c===35?(e.enter("atxHeadingSequence"),l(c)):c===null||Ae(c)?(e.exit("atxHeading"),t(c)):Ue(c)?Ve(e,o,"whitespace")(c):(e.enter("atxHeadingText"),u(c))}function l(c){return c===35?(e.consume(c),l):(e.exit("atxHeadingSequence"),o(c))}function u(c){return c===null||c===35||rt(c)?(e.exit("atxHeadingText"),o(c)):(e.consume(c),u)}}const M2=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Oc=["pre","script","style","textarea"],D2={concrete:!0,name:"htmlFlow",resolveTo:B2,tokenize:j2},O2={partial:!0,tokenize:U2},F2={partial:!0,tokenize:H2};function B2(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function j2(e,t,n){const r=this;let s,i,a,o,l;return u;function u(D){return c(D)}function c(D){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(D),f}function f(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),i=!0,p):D===63?(e.consume(D),s=3,r.interrupt?t:R):At(D)?(e.consume(D),a=String.fromCharCode(D),g):n(D)}function h(D){return D===45?(e.consume(D),s=2,d):D===91?(e.consume(D),s=5,o=0,m):At(D)?(e.consume(D),s=4,r.interrupt?t:R):n(D)}function d(D){return D===45?(e.consume(D),r.interrupt?t:R):n(D)}function m(D){const Z="CDATA[";return D===Z.charCodeAt(o++)?(e.consume(D),o===Z.length?r.interrupt?t:N:m):n(D)}function p(D){return At(D)?(e.consume(D),a=String.fromCharCode(D),g):n(D)}function g(D){if(D===null||D===47||D===62||rt(D)){const Z=D===47,le=a.toLowerCase();return!Z&&!i&&Oc.includes(le)?(s=1,r.interrupt?t(D):N(D)):M2.includes(a.toLowerCase())?(s=6,Z?(e.consume(D),y):r.interrupt?t(D):N(D)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(D):i?T(D):v(D))}return D===45||Tt(D)?(e.consume(D),a+=String.fromCharCode(D),g):n(D)}function y(D){return D===62?(e.consume(D),r.interrupt?t:N):n(D)}function T(D){return Ue(D)?(e.consume(D),T):A(D)}function v(D){return D===47?(e.consume(D),A):D===58||D===95||At(D)?(e.consume(D),C):Ue(D)?(e.consume(D),v):A(D)}function C(D){return D===45||D===46||D===58||D===95||Tt(D)?(e.consume(D),C):E(D)}function E(D){return D===61?(e.consume(D),w):Ue(D)?(e.consume(D),E):v(D)}function w(D){return D===null||D===60||D===61||D===62||D===96?n(D):D===34||D===39?(e.consume(D),l=D,_):Ue(D)?(e.consume(D),w):S(D)}function _(D){return D===l?(e.consume(D),l=null,I):D===null||Ae(D)?n(D):(e.consume(D),_)}function S(D){return D===null||D===34||D===39||D===47||D===60||D===61||D===62||D===96||rt(D)?E(D):(e.consume(D),S)}function I(D){return D===47||D===62||Ue(D)?v(D):n(D)}function A(D){return D===62?(e.consume(D),P):n(D)}function P(D){return D===null||Ae(D)?N(D):Ue(D)?(e.consume(D),P):n(D)}function N(D){return D===45&&s===2?(e.consume(D),B):D===60&&s===1?(e.consume(D),V):D===62&&s===4?(e.consume(D),$):D===63&&s===3?(e.consume(D),R):D===93&&s===5?(e.consume(D),q):Ae(D)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(O2,X,j)(D)):D===null||Ae(D)?(e.exit("htmlFlowData"),j(D)):(e.consume(D),N)}function j(D){return e.check(F2,M,X)(D)}function M(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),L}function L(D){return D===null||Ae(D)?j(D):(e.enter("htmlFlowData"),N(D))}function B(D){return D===45?(e.consume(D),R):N(D)}function V(D){return D===47?(e.consume(D),a="",F):N(D)}function F(D){if(D===62){const Z=a.toLowerCase();return Oc.includes(Z)?(e.consume(D),$):N(D)}return At(D)&&a.length<8?(e.consume(D),a+=String.fromCharCode(D),F):N(D)}function q(D){return D===93?(e.consume(D),R):N(D)}function R(D){return D===62?(e.consume(D),$):D===45&&s===2?(e.consume(D),R):N(D)}function $(D){return D===null||Ae(D)?(e.exit("htmlFlowData"),X(D)):(e.consume(D),$)}function X(D){return e.exit("htmlFlow"),t(D)}}function H2(e,t,n){const r=this;return s;function s(a){return Ae(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function U2(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Li,t,n)}}const z2={name:"htmlText",tokenize:V2};function V2(e,t,n){const r=this;let s,i,a;return o;function o(R){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(R),l}function l(R){return R===33?(e.consume(R),u):R===47?(e.consume(R),E):R===63?(e.consume(R),v):At(R)?(e.consume(R),S):n(R)}function u(R){return R===45?(e.consume(R),c):R===91?(e.consume(R),i=0,m):At(R)?(e.consume(R),T):n(R)}function c(R){return R===45?(e.consume(R),d):n(R)}function f(R){return R===null?n(R):R===45?(e.consume(R),h):Ae(R)?(a=f,V(R)):(e.consume(R),f)}function h(R){return R===45?(e.consume(R),d):f(R)}function d(R){return R===62?B(R):R===45?h(R):f(R)}function m(R){const $="CDATA[";return R===$.charCodeAt(i++)?(e.consume(R),i===$.length?p:m):n(R)}function p(R){return R===null?n(R):R===93?(e.consume(R),g):Ae(R)?(a=p,V(R)):(e.consume(R),p)}function g(R){return R===93?(e.consume(R),y):p(R)}function y(R){return R===62?B(R):R===93?(e.consume(R),y):p(R)}function T(R){return R===null||R===62?B(R):Ae(R)?(a=T,V(R)):(e.consume(R),T)}function v(R){return R===null?n(R):R===63?(e.consume(R),C):Ae(R)?(a=v,V(R)):(e.consume(R),v)}function C(R){return R===62?B(R):v(R)}function E(R){return At(R)?(e.consume(R),w):n(R)}function w(R){return R===45||Tt(R)?(e.consume(R),w):_(R)}function _(R){return Ae(R)?(a=_,V(R)):Ue(R)?(e.consume(R),_):B(R)}function S(R){return R===45||Tt(R)?(e.consume(R),S):R===47||R===62||rt(R)?I(R):n(R)}function I(R){return R===47?(e.consume(R),B):R===58||R===95||At(R)?(e.consume(R),A):Ae(R)?(a=I,V(R)):Ue(R)?(e.consume(R),I):B(R)}function A(R){return R===45||R===46||R===58||R===95||Tt(R)?(e.consume(R),A):P(R)}function P(R){return R===61?(e.consume(R),N):Ae(R)?(a=P,V(R)):Ue(R)?(e.consume(R),P):I(R)}function N(R){return R===null||R===60||R===61||R===62||R===96?n(R):R===34||R===39?(e.consume(R),s=R,j):Ae(R)?(a=N,V(R)):Ue(R)?(e.consume(R),N):(e.consume(R),M)}function j(R){return R===s?(e.consume(R),s=void 0,L):R===null?n(R):Ae(R)?(a=j,V(R)):(e.consume(R),j)}function M(R){return R===null||R===34||R===39||R===60||R===61||R===96?n(R):R===47||R===62||rt(R)?I(R):(e.consume(R),M)}function L(R){return R===47||R===62||rt(R)?I(R):n(R)}function B(R){return R===62?(e.consume(R),e.exit("htmlTextData"),e.exit("htmlText"),t):n(R)}function V(R){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),F}function F(R){return Ue(R)?Ve(e,q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):q(R)}function q(R){return e.enter("htmlTextData"),a(R)}}const Ul={name:"labelEnd",resolveAll:Y2,resolveTo:G2,tokenize:K2},q2={tokenize:X2},W2={tokenize:Q2},$2={tokenize:J2};function Y2(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&Bt(e,0,e.length,n),e}function G2(e,t){let n=e.length,r=0,s,i,a,o;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const l={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},c={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",u,t]],o=Vt(o,e.slice(i+1,i+r+3)),o=Vt(o,[["enter",c,t]]),o=Vt(o,Zs(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=Vt(o,[["exit",c,t],e[a-2],e[a-1],["exit",u,t]]),o=Vt(o,e.slice(a+1)),o=Vt(o,[["exit",l,t]]),Bt(e,i,e.length,o),e}function K2(e,t,n){const r=this;let s=r.events.length,i,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return o;function o(h){return i?i._inactive?f(h):(a=r.parser.defined.includes(Jt(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(q2,c,a?c:f)(h):h===91?e.attempt(W2,c,a?u:f)(h):a?c(h):f(h)}function u(h){return e.attempt($2,c,f)(h)}function c(h){return t(h)}function f(h){return i._balanced=!0,n(h)}}function X2(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return rt(f)?ii(e,i)(f):i(f)}function i(f){return f===41?c(f):Em(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return rt(f)?ii(e,l)(f):c(f)}function o(f){return n(f)}function l(f){return f===34||f===39||f===40?Tm(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):c(f)}function u(f){return rt(f)?ii(e,c)(f):c(f)}function c(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function Q2(e,t,n){const r=this;return s;function s(o){return vm.call(r,e,i,a,"reference","referenceMarker","referenceString")(o)}function i(o){return r.parser.defined.includes(Jt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function J2(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const Z2={name:"labelStartImage",resolveAll:Ul.resolveAll,tokenize:eE};function eE(e,t,n){const r=this;return s;function s(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),i}function i(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const tE={name:"labelStartLink",resolveAll:Ul.resolveAll,tokenize:nE};function nE(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Ba={name:"lineEnding",tokenize:rE};function rE(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}const fs={name:"thematicBreak",tokenize:iE};function iE(e,t,n){let r=0,s;return i;function i(u){return e.enter("thematicBreak"),a(u)}function a(u){return s=u,o(u)}function o(u){return u===s?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||Ae(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===s?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Ue(u)?Ve(e,o,"whitespace")(u):o(u))}}const Lt={continuation:{tokenize:lE},exit:cE,name:"list",tokenize:oE},sE={partial:!0,tokenize:dE},aE={partial:!0,tokenize:uE};function oE(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return o;function o(d){const m=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:Mo(d)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(fs,n,u)(d):u(d);if(!r.interrupt||d===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(d)}return n(d)}function l(d){return Mo(d)&&++a<10?(e.consume(d),l):(!r.interrupt||a<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit("listItemValue"),u(d)):n(d)}function u(d){return e.enter("listItemMarker"),e.consume(d),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||d,e.check(Li,r.interrupt?n:c,e.attempt(sE,h,f))}function c(d){return r.containerState.initialBlankLine=!0,i++,h(d)}function f(d){return Ue(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),h):n(d)}function h(d){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function lE(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Li,s,i);function s(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(e,t,"listItemIndent",r.containerState.size+1)(o)}function i(o){return r.containerState.furtherBlankLines||!Ue(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(aE,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(Lt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function uE(e,t,n){const r=this;return Ve(e,s,"listItemIndent",r.containerState.size+1);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function cE(e){e.exit(this.containerState.type)}function dE(e,t,n){const r=this;return Ve(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!Ue(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const Fc={name:"setextUnderline",resolveTo:fE,tokenize:hE};function fE(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function hE(e,t,n){const r=this;let s;return i;function i(u){let c=r.events.length,f;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){f=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===s?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),Ue(u)?Ve(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Ae(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const mE={tokenize:pE};function pE(e){const t=this,n=e.attempt(Li,r,e.attempt(this.parser.constructs.flowInitial,s,Ve(e,e.attempt(this.parser.constructs.flow,s,e.attempt(E2,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const gE={resolveAll:wm()},xE=km("string"),bE=km("text");function km(e){return{resolveAll:wm(e==="text"?yE:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,o);return a;function a(c){return u(c)?i(c):o(c)}function o(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),l}function l(c){return u(c)?(n.exit("data"),i(c)):(n.consume(c),l)}function u(c){if(c===null)return!0;const f=s[c];let h=-1;if(f)for(;++h<f.length;){const d=f[h];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function wm(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function yE(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let i=s.length,a=-1,o=0,l;for(;i--;){const u=s[i];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(u===-2)l=!0,o++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const u={type:n===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const EE={42:Lt,43:Lt,45:Lt,48:Lt,49:Lt,50:Lt,51:Lt,52:Lt,53:Lt,54:Lt,55:Lt,56:Lt,57:Lt,62:gm},vE={91:S2},TE={[-2]:Fa,[-1]:Fa,32:Fa},kE={35:R2,42:fs,45:[Fc,fs],60:D2,61:Fc,95:fs,96:Dc,126:Dc},wE={38:bm,92:xm},SE={[-5]:Ba,[-4]:Ba,[-3]:Ba,33:Z2,38:bm,42:Do,60:[t2,z2],91:tE,92:[I2,xm],93:Ul,95:Do,96:m2},AE={null:[Do,gE]},CE={null:[42,95]},_E={null:[]},IE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:CE,contentInitial:vE,disable:_E,document:EE,flow:kE,flowInitial:TE,insideSpan:AE,string:wE,text:SE},Symbol.toStringTag,{value:"Module"}));function NE(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let a=[],o=[];const l={attempt:_(E),check:_(w),consume:T,enter:v,exit:C,interrupt:_(w,{interrupt:!0})},u={code:null,containerState:{},defineSkip:p,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:d,write:f};let c=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function f(P){return a=Vt(a,P),g(),a[a.length-1]!==null?[]:(S(t,0),u.events=Zs(i,u.events,u),u.events)}function h(P,N){return LE(d(P),N)}function d(P){return RE(a,P)}function m(){const{_bufferIndex:P,_index:N,line:j,column:M,offset:L}=r;return{_bufferIndex:P,_index:N,line:j,column:M,offset:L}}function p(P){s[P.line]=P.column,A()}function g(){let P;for(;r._index<a.length;){const N=a[r._index];if(typeof N=="string")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<N.length;)y(N.charCodeAt(r._bufferIndex));else y(N)}}function y(P){c=c(P)}function T(P){Ae(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,A()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=P}function v(P,N){const j=N||{};return j.type=P,j.start=m(),u.events.push(["enter",j,u]),o.push(j),j}function C(P){const N=o.pop();return N.end=m(),u.events.push(["exit",N,u]),N}function E(P,N){S(P,N.from)}function w(P,N){N.restore()}function _(P,N){return j;function j(M,L,B){let V,F,q,R;return Array.isArray(M)?X(M):"tokenize"in M?X([M]):$(M);function $(z){return ee;function ee(K){const ce=K!==null&&z[K],fe=K!==null&&z.null,re=[...Array.isArray(ce)?ce:ce?[ce]:[],...Array.isArray(fe)?fe:fe?[fe]:[]];return X(re)(K)}}function X(z){return V=z,F=0,z.length===0?B:D(z[F])}function D(z){return ee;function ee(K){return R=I(),q=z,z.partial||(u.currentConstruct=z),z.name&&u.parser.constructs.disable.null.includes(z.name)?le():z.tokenize.call(N?Object.assign(Object.create(u),N):u,l,Z,le)(K)}}function Z(z){return P(q,R),L}function le(z){return R.restore(),++F<V.length?D(V[F]):B}}}function S(P,N){P.resolveAll&&!i.includes(P)&&i.push(P),P.resolve&&Bt(u.events,N,u.events.length-N,P.resolve(u.events.slice(N),u)),P.resolveTo&&(u.events=P.resolveTo(u.events,u))}function I(){const P=m(),N=u.previous,j=u.currentConstruct,M=u.events.length,L=Array.from(o);return{from:M,restore:B};function B(){r=P,u.previous=N,u.currentConstruct=j,u.events.length=M,o=L,A()}}function A(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function RE(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,i)];else{if(a=e.slice(n,s),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function LE(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
438
438
  `;break}case-3:{a=`\r
439
439
  `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(i)}s=i===-2,r.push(a)}return r.join("")}function PE(e){const r={constructs:mm([IE,...(e||{}).extensions||[]]),content:s(Gy),defined:[],document:s(Xy),flow:s(mE),lazy:{},string:s(xE),text:s(bE)};return r;function s(i){return a;function a(o){return NE(r,i,o)}}}function ME(e){for(;!ym(e););return e}const Bc=/[\0\t\n\r]/g;function DE(){let e=1,t="",n=!0,r;return s;function s(i,a,o){const l=[];let u,c,f,h,d;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),f=0,t="",n&&(i.charCodeAt(0)===65279&&f++,n=void 0);f<i.length;){if(Bc.lastIndex=f,u=Bc.exec(i),h=u&&u.index!==void 0?u.index:i.length,d=i.charCodeAt(h),!u){t=i.slice(f);break}if(d===10&&f===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<h&&(l.push(i.slice(f,h)),e+=h-f),d){case 0:{l.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,l.push(-2);e++<c;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const OE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FE(e){return e.replace(OE,BE)}function BE(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return pm(n.slice(i?2:1),i?16:10)}return Hl(n)||e}const Sm={}.hasOwnProperty;function jE(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),HE(n)(ME(PE(n).document().write(DE()(e,t,!0))))}function HE(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(te),autolinkProtocol:I,autolinkEmail:I,atxHeading:i(Ne),blockQuote:i(fe),characterEscape:I,characterReference:I,codeFenced:i(re),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(re,a),codeText:i(ne,a),codeTextData:I,data:I,codeFlowValue:I,definition:i(ge),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(Te),hardBreakEscape:i(Oe),hardBreakTrailing:i(Oe),htmlFlow:i(be,a),htmlFlowData:I,htmlText:i(be,a),htmlTextData:I,image:i(Fe),label:a,link:i(te),listItem:i(me),listItemValue:h,listOrdered:i(Re,f),listUnordered:i(Re),paragraph:i(je),reference:D,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Ne),strong:i(st),thematicBreak:i(at)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:ce,autolinkProtocol:K,blockQuote:l(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:le,characterReferenceMarkerNumeric:le,characterReferenceValue:z,characterReference:ee,codeFenced:l(g),codeFencedFence:p,codeFencedFenceInfo:d,codeFencedFenceMeta:m,codeFlowValue:A,codeIndented:l(y),codeText:l(L),codeTextData:A,data:A,definition:l(),definitionDestinationString:C,definitionLabelString:T,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(N),hardBreakTrailing:l(N),htmlFlow:l(j),htmlFlowData:A,htmlText:l(M),htmlTextData:A,image:l(V),label:q,labelText:F,lineEnding:P,link:l(B),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Z,resourceDestinationString:R,resourceTitleString:$,resource:X,setextHeading:l(S),setextHeadingLineSequence:_,setextHeadingText:w,strong:l(),thematicBreak:l()}};Am(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(G){let se={type:"root",children:[]};const xe={stack:[se],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:c,data:n},Ee=[];let Pe=-1;for(;++Pe<G.length;)if(G[Pe][1].type==="listOrdered"||G[Pe][1].type==="listUnordered")if(G[Pe][0]==="enter")Ee.push(Pe);else{const lt=Ee.pop();Pe=s(G,lt,Pe)}for(Pe=-1;++Pe<G.length;){const lt=t[G[Pe][0]];Sm.call(lt,G[Pe][1].type)&&lt[G[Pe][1].type].call(Object.assign({sliceSerialize:G[Pe][2].sliceSerialize},xe),G[Pe][1])}if(xe.tokenStack.length>0){const lt=xe.tokenStack[xe.tokenStack.length-1];(lt[1]||jc).call(xe,void 0,lt[0])}for(se.position={start:yn(G.length>0?G[0][1].start:{line:1,column:1,offset:0}),end:yn(G.length>0?G[G.length-2][1].end:{line:1,column:1,offset:0})},Pe=-1;++Pe<t.transforms.length;)se=t.transforms[Pe](se)||se;return se}function s(G,se,xe){let Ee=se-1,Pe=-1,lt=!1,ve,Le,ze,Ye;for(;++Ee<=xe;){const ye=G[Ee];switch(ye[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ye[0]==="enter"?Pe++:Pe--,Ye=void 0;break}case"lineEndingBlank":{ye[0]==="enter"&&(ve&&!Ye&&!Pe&&!ze&&(ze=Ee),Ye=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ye=void 0}if(!Pe&&ye[0]==="enter"&&ye[1].type==="listItemPrefix"||Pe===-1&&ye[0]==="exit"&&(ye[1].type==="listUnordered"||ye[1].type==="listOrdered")){if(ve){let qe=Ee;for(Le=void 0;qe--;){const St=G[qe];if(St[1].type==="lineEnding"||St[1].type==="lineEndingBlank"){if(St[0]==="exit")continue;Le&&(G[Le][1].type="lineEndingBlank",lt=!0),St[1].type="lineEnding",Le=qe}else if(!(St[1].type==="linePrefix"||St[1].type==="blockQuotePrefix"||St[1].type==="blockQuotePrefixWhitespace"||St[1].type==="blockQuoteMarker"||St[1].type==="listItemIndent"))break}ze&&(!Le||ze<Le)&&(ve._spread=!0),ve.end=Object.assign({},Le?G[Le][1].start:ye[1].end),G.splice(Le||Ee,0,["exit",ve,ye[2]]),Ee++,xe++}if(ye[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},ye[1].start),end:void 0};ve=qe,G.splice(Ee,0,["enter",qe,ye[2]]),Ee++,xe++,ze=void 0,Ye=!0}}}return G[se][1]._spread=lt,xe}function i(G,se){return xe;function xe(Ee){o.call(this,G(Ee),Ee),se&&se.call(this,Ee)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(G,se,xe){this.stack[this.stack.length-1].children.push(G),this.stack.push(G),this.tokenStack.push([se,xe||void 0]),G.position={start:yn(se.start),end:void 0}}function l(G){return se;function se(xe){G&&G.call(this,xe),u.call(this,xe)}}function u(G,se){const xe=this.stack.pop(),Ee=this.tokenStack.pop();if(Ee)Ee[0].type!==G.type&&(se?se.call(this,G,Ee[0]):(Ee[1]||jc).call(this,G,Ee[0]));else throw new Error("Cannot close `"+G.type+"` ("+ri({start:G.start,end:G.end})+"): it’s not open");xe.position.end=yn(G.end)}function c(){return jl(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(G){if(this.data.expectingFirstListItemValue){const se=this.stack[this.stack.length-2];se.start=Number.parseInt(this.sliceSerialize(G),10),this.data.expectingFirstListItemValue=void 0}}function d(){const G=this.resume(),se=this.stack[this.stack.length-1];se.lang=G}function m(){const G=this.resume(),se=this.stack[this.stack.length-1];se.meta=G}function p(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const G=this.resume(),se=this.stack[this.stack.length-1];se.value=G.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const G=this.resume(),se=this.stack[this.stack.length-1];se.value=G.replace(/(\r?\n|\r)$/g,"")}function T(G){const se=this.resume(),xe=this.stack[this.stack.length-1];xe.label=se,xe.identifier=Jt(this.sliceSerialize(G)).toLowerCase()}function v(){const G=this.resume(),se=this.stack[this.stack.length-1];se.title=G}function C(){const G=this.resume(),se=this.stack[this.stack.length-1];se.url=G}function E(G){const se=this.stack[this.stack.length-1];if(!se.depth){const xe=this.sliceSerialize(G).length;se.depth=xe}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function _(G){const se=this.stack[this.stack.length-1];se.depth=this.sliceSerialize(G).codePointAt(0)===61?1:2}function S(){this.data.setextHeadingSlurpLineEnding=void 0}function I(G){const xe=this.stack[this.stack.length-1].children;let Ee=xe[xe.length-1];(!Ee||Ee.type!=="text")&&(Ee=Be(),Ee.position={start:yn(G.start),end:void 0},xe.push(Ee)),this.stack.push(Ee)}function A(G){const se=this.stack.pop();se.value+=this.sliceSerialize(G),se.position.end=yn(G.end)}function P(G){const se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const xe=se.children[se.children.length-1];xe.position.end=yn(G.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(se.type)&&(I.call(this,G),A.call(this,G))}function N(){this.data.atHardBreak=!0}function j(){const G=this.resume(),se=this.stack[this.stack.length-1];se.value=G}function M(){const G=this.resume(),se=this.stack[this.stack.length-1];se.value=G}function L(){const G=this.resume(),se=this.stack[this.stack.length-1];se.value=G}function B(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=se,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function V(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=se,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function F(G){const se=this.sliceSerialize(G),xe=this.stack[this.stack.length-2];xe.label=FE(se),xe.identifier=Jt(se).toLowerCase()}function q(){const G=this.stack[this.stack.length-1],se=this.resume(),xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,xe.type==="link"){const Ee=G.children;xe.children=Ee}else xe.alt=se}function R(){const G=this.resume(),se=this.stack[this.stack.length-1];se.url=G}function $(){const G=this.resume(),se=this.stack[this.stack.length-1];se.title=G}function X(){this.data.inReference=void 0}function D(){this.data.referenceType="collapsed"}function Z(G){const se=this.resume(),xe=this.stack[this.stack.length-1];xe.label=se,xe.identifier=Jt(this.sliceSerialize(G)).toLowerCase(),this.data.referenceType="full"}function le(G){this.data.characterReferenceType=G.type}function z(G){const se=this.sliceSerialize(G),xe=this.data.characterReferenceType;let Ee;xe?(Ee=pm(se,xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ee=Hl(se);const Pe=this.stack[this.stack.length-1];Pe.value+=Ee}function ee(G){const se=this.stack.pop();se.position.end=yn(G.end)}function K(G){A.call(this,G);const se=this.stack[this.stack.length-1];se.url=this.sliceSerialize(G)}function ce(G){A.call(this,G);const se=this.stack[this.stack.length-1];se.url="mailto:"+this.sliceSerialize(G)}function fe(){return{type:"blockquote",children:[]}}function re(){return{type:"code",lang:null,meta:null,value:""}}function ne(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Te(){return{type:"emphasis",children:[]}}function Ne(){return{type:"heading",depth:0,children:[]}}function Oe(){return{type:"break"}}function be(){return{type:"html",value:""}}function Fe(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function Re(G){return{type:"list",ordered:G.type==="listOrdered",start:null,spread:G._spread,children:[]}}function me(G){return{type:"listItem",spread:G._spread,checked:null,children:[]}}function je(){return{type:"paragraph",children:[]}}function st(){return{type:"strong",children:[]}}function Be(){return{type:"text",value:""}}function at(){return{type:"thematicBreak"}}}function yn(e){return{line:e.line,column:e.column,offset:e.offset}}function Am(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Am(e,r):UE(e,r)}}function UE(e,t){let n;for(n in t)if(Sm.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function jc(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ri({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ri({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ri({start:t.start,end:t.end})+") is still open")}function zE(e){const t=this;t.parser=n;function n(r){return jE(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function VE(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function qE(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -462,7 +462,7 @@ Based on my performance, decide what comes next: explain why I got questions wro
462
462
  `,...i.current()});return/^[\t ]/.test(u)&&(u=Ti(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),l(),o(),u}Vm.peek=ck;function Vm(e){return e.value||""}function ck(){return"<"}qm.peek=dk;function qm(e,t,n,r){const s=Yl(n),i=s==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(o=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(e.title,{before:u,after:s,...l.current()})),u+=l.move(s),o()),u+=l.move(")"),a(),u}function dk(){return"!"}Wm.peek=fk;function Wm(e,t,n,r){const s=e.referenceType,i=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const u=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(u+"]["),a();const c=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=c,i(),s==="full"||!u||u!==f?l+=o.move(f+"]"):s==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function fk(){return"!"}$m.peek=hk;function $m(e,t,n){let r=e.value||"",s="`",i=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++i<n.unsafe.length;){const a=n.unsafe[i],o=n.compilePattern(a);let l;if(a.atBreak)for(;l=o.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return s+r+s}function hk(){return"`"}function Ym(e,t){const n=jl(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Gm.peek=mk;function Gm(e,t,n,r){const s=Yl(n),i=s==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(Ym(e,n)){const c=n.stack;n.stack=[],o=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),o(),n.stack=c,f}o=n.enter("link"),l=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${i}`),u+=a.move(" "+s),u+=a.move(n.safe(e.title,{before:u,after:s,...a.current()})),u+=a.move(s),l()),u+=a.move(")"),o(),u}function mk(e,t,n){return Ym(e,n)?"<":"["}Km.peek=pk;function Km(e,t,n,r){const s=e.referenceType,i=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(u+"]["),a();const c=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=c,i(),s==="full"||!u||u!==f?l+=o.move(f+"]"):s==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function pk(){return"["}function Gl(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function gk(e){const t=Gl(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function xk(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Xm(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function bk(e,t,n,r){const s=n.enter("list"),i=n.bulletCurrent;let a=e.ordered?xk(n):Gl(n);const o=e.ordered?a==="."?")":".":gk(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const c=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&c&&(!c.children||!c.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Xm(n)===a&&c){let f=-1;for(;++f<e.children.length;){const h=e.children[f];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=i,s(),u}function yk(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ek(e,t,n,r){const s=yk(n);let i=n.bulletCurrent||Gl(n);t&&t.type==="list"&&t.ordered&&(i=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+i);let a=i.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(i+" ".repeat(a-i.length)),o.shift(a);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,o.current()),c);return l(),u;function c(f,h,d){return h?(d?"":" ".repeat(a))+f:(d?i:i+" ".repeat(a-i.length))+f}}function vk(e,t,n,r){const s=n.enter("paragraph"),i=n.enter("phrasing"),a=n.containerPhrasing(e,r);return i(),s(),a}const Tk=ta(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function kk(e,t,n,r){return(e.children.some(function(a){return Tk(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function wk(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Qm.peek=Sk;function Qm(e,t,n,r){const s=wk(n),i=n.enter("strong"),a=n.createTracker(r),o=a.move(s+s);let l=a.move(n.containerPhrasing(e,{after:s,before:o,...a.current()}));const u=l.charCodeAt(0),c=Ns(r.before.charCodeAt(r.before.length-1),u,s);c.inside&&(l=Ti(u)+l.slice(1));const f=l.charCodeAt(l.length-1),h=Ns(r.after.charCodeAt(0),f,s);h.inside&&(l=l.slice(0,-1)+Ti(f));const d=a.move(s+s);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:c.outside},o+l+d}function Sk(e,t,n){return n.options.strong||"*"}function Ak(e,t,n,r){return n.safe(e.value,r)}function Ck(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function _k(e,t,n){const r=(Xm(n)+(n.options.ruleSpaces?" ":"")).repeat(Ck(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Jm={blockquote:QT,break:sd,code:rk,definition:sk,emphasis:zm,hardBreak:sd,heading:uk,html:Vm,image:qm,imageReference:Wm,inlineCode:$m,link:Gm,linkReference:Km,list:bk,listItem:Ek,paragraph:vk,root:kk,strong:Qm,text:Ak,thematicBreak:_k};function Ik(){return{enter:{table:Nk,tableData:ad,tableHeader:ad,tableRow:Lk},exit:{codeText:Pk,table:Rk,tableData:Xa,tableHeader:Xa,tableRow:Xa}}}function Nk(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Rk(e){this.exit(e),this.data.inTable=void 0}function Lk(e){this.enter({type:"tableRow",children:[]},e)}function Xa(e){this.exit(e)}function ad(e){this.enter({type:"tableCell",children:[]},e)}function Pk(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Mk));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Mk(e,t){return t==="|"?t:e}function Dk(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
463
463
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:a,tableCell:l,tableRow:o}};function a(d,m,p,g){return u(c(d,p,g),d.align)}function o(d,m,p,g){const y=f(d,p,g),T=u([y]);return T.slice(0,T.indexOf(`
464
464
  `))}function l(d,m,p,g){const y=p.enter("tableCell"),T=p.enter("phrasing"),v=p.containerPhrasing(d,{...g,before:i,after:i});return T(),y(),v}function u(d,m){return KT(d,{align:m,alignDelimiters:r,padding:n,stringLength:s})}function c(d,m,p){const g=d.children;let y=-1;const T=[],v=m.enter("table");for(;++y<g.length;)T[y]=f(g[y],m,p);return v(),T}function f(d,m,p){const g=d.children;let y=-1;const T=[],v=m.enter("tableRow");for(;++y<g.length;)T[y]=l(g[y],d,m,p);return v(),T}function h(d,m,p){let g=Jm.inlineCode(d,m,p);return p.stack.includes("tableCell")&&(g=g.replace(/\|/g,"\\$&")),g}}function Ok(){return{exit:{taskListCheckValueChecked:od,taskListCheckValueUnchecked:od,paragraph:Bk}}}function Fk(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:jk}}}function od(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Bk(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.children;let i=-1,a;for(;++i<s.length;){const o=s[i];if(o.type==="paragraph"){a=o;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function jk(e,t,n,r){const s=e.children[0],i=typeof e.checked=="boolean"&&s&&s.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);i&&o.move(a);let l=Jm.listItem(e,t,n,{...r,...o.current()});return i&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(c){return c+a}}function Hk(){return[bT(),jT(),VT(),Ik(),Ok()]}function Uk(e){return{extensions:[yT(),HT(e),qT(),Dk(e),Fk()]}}const zk={tokenize:Gk,partial:!0},Zm={tokenize:Kk,partial:!0},ep={tokenize:Xk,partial:!0},tp={tokenize:Qk,partial:!0},Vk={tokenize:Jk,partial:!0},np={name:"wwwAutolink",tokenize:$k,previous:ip},rp={name:"protocolAutolink",tokenize:Yk,previous:sp},bn={name:"emailAutolink",tokenize:Wk,previous:ap},cn={};function qk(){return{text:cn}}let Fn=48;for(;Fn<123;)cn[Fn]=bn,Fn++,Fn===58?Fn=65:Fn===91&&(Fn=97);cn[43]=bn;cn[45]=bn;cn[46]=bn;cn[95]=bn;cn[72]=[bn,rp];cn[104]=[bn,rp];cn[87]=[bn,np];cn[119]=[bn,np];function Wk(e,t,n){const r=this;let s,i;return a;function a(f){return!Ho(f)||!ap.call(r,r.previous)||Kl(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(f))}function o(f){return Ho(f)?(e.consume(f),o):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(Vk,c,u)(f):f===45||f===95||Tt(f)?(i=!0,e.consume(f),l):c(f)}function u(f){return e.consume(f),s=!0,l}function c(f){return i&&s&&At(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function $k(e,t,n){const r=this;return s;function s(a){return a!==87&&a!==119||!ip.call(r,r.previous)||Kl(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(zk,e.attempt(Zm,e.attempt(ep,i),n),n)(a))}function i(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function Yk(e,t,n){const r=this;let s="",i=!1;return a;function a(f){return(f===72||f===104)&&sp.call(r,r.previous)&&!Kl(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(f),e.consume(f),o):n(f)}function o(f){if(At(f)&&s.length<5)return s+=String.fromCodePoint(f),e.consume(f),o;if(f===58){const h=s.toLowerCase();if(h==="http"||h==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),i?u:(i=!0,l)):n(f)}function u(f){return f===null||_s(f)||rt(f)||tr(f)||Js(f)?n(f):e.attempt(Zm,e.attempt(ep,c),n)(f)}function c(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function Gk(e,t,n){let r=0;return s;function s(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),s):a===46&&r===3?(e.consume(a),i):n(a)}function i(a){return a===null?n(a):t(a)}}function Kk(e,t,n){let r,s,i;return a;function a(u){return u===46||u===95?e.check(tp,l,o)(u):u===null||rt(u)||tr(u)||u!==45&&Js(u)?l(u):(i=!0,e.consume(u),a)}function o(u){return u===95?r=!0:(s=r,r=void 0),e.consume(u),a}function l(u){return s||r||!i?n(u):t(u)}}function Xk(e,t){let n=0,r=0;return s;function s(a){return a===40?(n++,e.consume(a),s):a===41&&r<n?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(tp,t,i)(a):a===null||rt(a)||tr(a)?t(a):(e.consume(a),s)}function i(a){return a===41&&r++,e.consume(a),s}}function Qk(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),i):o===93?(e.consume(o),s):o===60||o===null||rt(o)||tr(o)?t(o):n(o)}function s(o){return o===null||o===40||o===91||rt(o)||tr(o)?t(o):r(o)}function i(o){return At(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):At(o)?(e.consume(o),a):n(o)}}function Jk(e,t,n){return r;function r(i){return e.consume(i),s}function s(i){return Tt(i)?n(i):t(i)}}function ip(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||rt(e)}function sp(e){return!At(e)}function ap(e){return!(e===47||Ho(e))}function Ho(e){return e===43||e===45||e===46||e===95||Tt(e)}function Kl(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Zk={tokenize:ow,partial:!0};function ew(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:iw,continuation:{tokenize:sw},exit:aw}},text:{91:{name:"gfmFootnoteCall",tokenize:rw},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:tw,resolveTo:nw}}}}function tw(e,t,n){const r=this;let s=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;s--;){const l=r.events[s][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return n(l);const u=Jt(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function nw(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function rw(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,a;return o;function o(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(i>999||f===93&&!a||f===null||f===91||rt(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return s.includes(Jt(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return rt(f)||(a=!0),i++,e.consume(f),f===92?c:u}function c(f){return f===91||f===92||f===93?(e.consume(f),i++,u):u(f)}}function iw(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,a=0,o;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(m)}function c(m){if(a>999||m===93&&!o||m===null||m===91||rt(m))return n(m);if(m===93){e.exit("chunkString");const p=e.exit("gfmFootnoteDefinitionLabelString");return i=Jt(r.sliceSerialize(p)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return rt(m)||(o=!0),a++,e.consume(m),m===92?f:c}function f(m){return m===91||m===92||m===93?(e.consume(m),a++,c):c(m)}function h(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),s.includes(i)||s.push(i),Ve(e,d,"gfmFootnoteDefinitionWhitespace")):n(m)}function d(m){return t(m)}}function sw(e,t,n){return e.check(Li,t,e.attempt(Zk,t,n))}function aw(e){e.exit("gfmFootnoteDefinition")}function ow(e,t,n){const r=this;return Ve(e,s,"gfmFootnoteDefinitionIndent",5);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(i):n(i)}}function lw(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:i,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let u=l;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[l][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[l][1].end)},f={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[l][1].start)},h=[["enter",c,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",f,o]],d=o.parser.constructs.insideSpan.null;d&&Bt(h,h.length,0,Zs(d,a.slice(u+1,l),o)),Bt(h,h.length,0,[["exit",f,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",c,o]]),Bt(a,u-1,l-u+3,h),l=u+h.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function i(a,o,l){const u=this.previous,c=this.events;let f=0;return h;function h(m){return u===126&&c[c.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),d(m))}function d(m){const p=Sr(u);if(m===126)return f>1?l(m):(a.consume(m),f++,d);if(f<2&&!n)return l(m);const g=a.exit("strikethroughSequenceTemporary"),y=Sr(m);return g._open=!y||y===2&&!!p,g._close=!p||p===2&&!!y,o(m)}}}class uw{constructor(){this.map=[]}add(t,n,r){cw(this,t,n,r)}consume(t){if(this.map.sort(function(i,a){return i[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const i of s)t.push(i);s=r.pop()}this.map.length=0}}function cw(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function dw(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const i=r.length-1;r[i]=r[i]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function fw(){return{flow:{null:{name:"table",tokenize:hw,resolveAll:mw}}}}function hw(e,t,n){const r=this;let s=0,i=0,a;return o;function o(A){let P=r.events.length-1;for(;P>-1;){const M=r.events[P][1].type;if(M==="lineEnding"||M==="linePrefix")P--;else break}const N=P>-1?r.events[P][1].type:null,j=N==="tableHead"||N==="tableRow"?w:l;return j===w&&r.parser.lazy[r.now().line]?n(A):j(A)}function l(A){return e.enter("tableHead"),e.enter("tableRow"),u(A)}function u(A){return A===124||(a=!0,i+=1),c(A)}function c(A){return A===null?n(A):Ae(A)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),d):n(A):Ue(A)?Ve(e,c,"whitespace")(A):(i+=1,a&&(a=!1,s+=1),A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),a=!0,c):(e.enter("data"),f(A)))}function f(A){return A===null||A===124||rt(A)?(e.exit("data"),c(A)):(e.consume(A),A===92?h:f)}function h(A){return A===92||A===124?(e.consume(A),f):f(A)}function d(A){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(A):(e.enter("tableDelimiterRow"),a=!1,Ue(A)?Ve(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):m(A))}function m(A){return A===45||A===58?g(A):A===124?(a=!0,e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),p):E(A)}function p(A){return Ue(A)?Ve(e,g,"whitespace")(A):g(A)}function g(A){return A===58?(i+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),y):A===45?(i+=1,y(A)):A===null||Ae(A)?C(A):E(A)}function y(A){return A===45?(e.enter("tableDelimiterFiller"),T(A)):E(A)}function T(A){return A===45?(e.consume(A),T):A===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(A))}function v(A){return Ue(A)?Ve(e,C,"whitespace")(A):C(A)}function C(A){return A===124?m(A):A===null||Ae(A)?!a||s!==i?E(A):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(A)):E(A)}function E(A){return n(A)}function w(A){return e.enter("tableRow"),_(A)}function _(A){return A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),_):A===null||Ae(A)?(e.exit("tableRow"),t(A)):Ue(A)?Ve(e,_,"whitespace")(A):(e.enter("data"),S(A))}function S(A){return A===null||A===124||rt(A)?(e.exit("data"),_(A)):(e.consume(A),A===92?I:S)}function I(A){return A===92||A===124?(e.consume(A),S):S(A)}}function mw(e,t){let n=-1,r=!0,s=0,i=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,u,c,f;const h=new uw;for(;++n<e.length;){const d=e[n],m=d[1];d[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(ld(h,t,l,u,c),c=void 0,l=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,f=void 0,i=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,c={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",c,t]])),s=m.type==="tableDelimiterRow"?2:c?3:1):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],f=Zi(h,t,i,s,void 0,f),i=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(a[0]=a[1],f=Zi(h,t,i,s,void 0,f)),i=a,a=[i[1],n,0,0])):m.type==="tableHead"?(o=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,i[1]!==0?(a[0]=a[1],f=Zi(h,t,i,s,n,f)):a[1]!==0&&(f=Zi(h,t,a,s,n,f)),s=0):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&ld(h,t,l,u,c),h.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]==="enter"&&d[1].type==="table"&&(d[1]._align=dw(t.events,n))}return e}function Zi(e,t,n,r,s,i){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(i.end=Object.assign({},pr(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=pr(t.events,n[1]);if(i={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",i,t]]),n[2]!==0){const u=pr(t.events,n[2]),c=pr(t.events,n[3]),f={type:o,start:Object.assign({},u),end:Object.assign({},c)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const h=t.events[n[2]],d=t.events[n[3]];if(h[1].end=Object.assign({},d[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,p=n[3]-n[2]-1;e.add(m,p,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return s!==void 0&&(i.end=Object.assign({},pr(t.events,s)),e.add(s,0,[["exit",i,t]]),i=void 0),i}function ld(e,t,n,r,s){const i=[],a=pr(t.events,n);s&&(s.end=Object.assign({},a),i.push(["exit",s,t])),r.end=Object.assign({},a),i.push(["exit",r,t]),e.add(n+1,0,i)}function pr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const pw={name:"tasklistCheck",tokenize:xw};function gw(){return{text:{91:pw}}}function xw(e,t,n){const r=this;return s;function s(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),i)}function i(l){return rt(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return Ae(l)?t(l):Ue(l)?e.check({tokenize:bw},t,n)(l):n(l)}}function bw(e,t,n){return Ve(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function yw(e){return mm([qk(),ew(),lw(e),fw(),gw()])}const Ew={};function op(e){const t=this,n=e||Ew,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(yw(n)),i.push(Hk()),a.push(Uk(n))}const ud=/[#.]/g;function vw(e,t){const n=e||"",r={};let s=0,i,a;for(;s<n.length;){ud.lastIndex=s;const o=ud.exec(n),l=n.slice(s,o?o.index:n.length);l&&(i?i==="#"?r.id=l:Array.isArray(r.className)?r.className.push(l):r.className=[l]:a=l,s+=l.length),o&&(i=o[0],s++)}return{type:"element",tagName:a||t||"div",properties:r,children:[]}}function lp(e,t,n){const r=n?Sw(n):void 0;function s(i,a,...o){let l;if(i==null){l={type:"root",children:[]};const u=a;o.unshift(u)}else{l=vw(i,t);const u=l.tagName.toLowerCase(),c=r?r.get(u):void 0;if(l.tagName=c||u,Tw(a))o.unshift(a);else for(const[f,h]of Object.entries(a))kw(e,l.properties,f,h)}for(const u of o)Uo(l.children,u);return l.type==="element"&&l.tagName==="template"&&(l.content={type:"root",children:l.children},l.children=[]),l}return s}function Tw(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,n=Object.keys(e);for(const r of n){const s=t[r];if(s&&typeof s=="object"){if(!Array.isArray(s))return!0;const i=s;for(const a of i)if(typeof a!="number"&&typeof a!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function kw(e,t,n,r){const s=Xs(e,n);let i;if(r!=null){if(typeof r=="number"){if(Number.isNaN(r))return;i=r}else typeof r=="boolean"?i=r:typeof r=="string"?s.spaceSeparated?i=Tc(r):s.commaSeparated?i=xc(r):s.commaOrSpaceSeparated?i=Tc(xc(r).join(" ")):i=cd(s,s.property,r):Array.isArray(r)?i=[...r]:i=s.property==="style"?ww(r):String(r);if(Array.isArray(i)){const a=[];for(const o of i)a.push(cd(s,s.property,o));i=a}s.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[s.property]=i}}function Uo(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const n of t)Uo(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?Uo(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function cd(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||Ei(n)===Ei(t)))return!0}return n}function ww(e){const t=[];for(const[n,r]of Object.entries(e))t.push([n,r].join(": "));return t.join("; ")}function Sw(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const Aw=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],Cw=lp(Ri,"div"),_w=lp(Nn,"g",Aw);function Iw(e){const t=String(e),n=[];return{toOffset:s,toPoint:r};function r(i){if(typeof i=="number"&&i>-1&&i<=t.length){let a=0;for(;;){let o=n[a];if(o===void 0){const l=dd(t,n[a-1]);o=l===-1?t.length+1:l+1,n[a]=o}if(o>i)return{line:a+1,column:i-(a>0?n[a-1]:0)+1,offset:i};a++}}}function s(i){if(i&&typeof i.line=="number"&&typeof i.column=="number"&&!Number.isNaN(i.line)&&!Number.isNaN(i.column)){for(;n.length<i.line;){const o=n[n.length-1],l=dd(t,o),u=l===-1?t.length+1:l+1;if(o===u)break;n.push(u)}const a=(i.line>1?n[i.line-2]:0)+i.column-1;if(a<n[i.line-1])return a}}}function dd(e,t){const n=e.indexOf("\r",t),r=e.indexOf(`
465
- `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}const qn={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},up={}.hasOwnProperty,Nw=Object.prototype;function Rw(e,t){const n=t||{};return Xl({file:n.file||void 0,location:!1,schema:n.space==="svg"?Nn:Ri,verbose:n.verbose||!1},e)}function Xl(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},hs(e,r,n),n}case"#document":case"#document-fragment":{const r=t,s="mode"in r?r.mode==="quirks"||r.mode==="limited-quirks":!1;if(n={type:"root",children:cp(e,t.childNodes),data:{quirksMode:s}},e.file&&e.location){const i=String(e.file),a=Iw(i),o=a.toPoint(0),l=a.toPoint(i.length);n.position={start:o,end:l}}return n}case"#documentType":{const r=t;return n={type:"doctype"},hs(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},hs(e,r,n),n}default:return n=Lw(e,t),n}}function cp(e,t){let n=-1;const r=[];for(;++n<t.length;){const s=Xl(e,t[n]);r.push(s)}return r}function Lw(e,t){const n=e.schema;e.schema=t.namespaceURI===qn.svg?Nn:Ri;let r=-1;const s={};for(;++r<t.attrs.length;){const o=t.attrs[r],l=(o.prefix?o.prefix+":":"")+o.name;up.call(Nw,l)||(s[l]=o.value)}const a=(e.schema.space==="svg"?_w:Cw)(t.tagName,s,cp(e,t.childNodes));if(hs(e,t,a),a.tagName==="template"){const o=t,l=o.sourceCodeLocation,u=l&&l.startTag&&xr(l.startTag),c=l&&l.endTag&&xr(l.endTag),f=Xl(e,o.content);u&&c&&e.file&&(f.position={start:u.end,end:c.start}),a.content=f}return e.schema=n,a}function hs(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=Pw(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function Pw(e,t,n){const r=xr(n);if(t.type==="element"){const s=t.children[t.children.length-1];if(r&&!n.endTag&&s&&s.position&&s.position.end&&(r.end=Object.assign({},s.position.end)),e.verbose){const i={};let a;if(n.attrs)for(a in n.attrs)up.call(n.attrs,a)&&(i[Xs(e.schema,a).property]=xr(n.attrs[a]));n.startTag;const o=xr(n.startTag),l=n.endTag?xr(n.endTag):void 0,u={opening:o};l&&(u.closing=l),u.properties=i,t.data={position:u}}}return r}function xr(e){const t=fd({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=fd({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function fd(e){return e.line&&e.column?e:void 0}const Mw={},Dw={}.hasOwnProperty,dp=Um("type",{handlers:{root:Fw,element:zw,text:Hw,comment:Uw,doctype:jw}});function Ow(e,t){const r=(t||Mw).space;return dp(e,r==="svg"?Nn:Ri)}function Fw(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=Ql(e.children,n,t),Rr(e,n),n}function Bw(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=Ql(e.children,n,t),Rr(e,n),n}function jw(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return Rr(e,t),t}function Hw(e){const t={nodeName:"#text",value:e.value,parentNode:null};return Rr(e,t),t}function Uw(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return Rr(e,t),t}function zw(e,t){const n=t;let r=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(r=Nn);const s=[];let i;if(e.properties){for(i in e.properties)if(i!=="children"&&Dw.call(e.properties,i)){const l=Vw(r,i,e.properties[i]);l&&s.push(l)}}const a=r.space,o={nodeName:e.tagName,tagName:e.tagName,attrs:s,namespaceURI:qn[a],childNodes:[],parentNode:null};return o.childNodes=Ql(e.children,o,r),Rr(e,o),e.tagName==="template"&&e.content&&(o.content=Bw(e.content,r)),o}function Vw(e,t,n){const r=Xs(e,t);if(n===!1||n===null||n===void 0||typeof n=="number"&&Number.isNaN(n)||!n&&r.boolean)return;Array.isArray(n)&&(n=r.commaSeparated?Jh(n):am(n));const s={name:r.attribute,value:n===!0?"":String(n)};if(r.space&&r.space!=="html"&&r.space!=="svg"){const i=s.name.indexOf(":");i<0?s.prefix="":(s.name=s.name.slice(i+1),s.prefix=r.attribute.slice(0,i)),s.namespace=qn[r.space]}return s}function Ql(e,t,n){let r=-1;const s=[];if(e)for(;++r<e.length;){const i=dp(e[r],n);i.parentNode=t,s.push(i)}return s}function Rr(e,t){const n=e.position;n&&n.start&&n.end&&(n.start.offset,n.end.offset,t.sourceCodeLocation={startLine:n.start.line,startCol:n.start.column,startOffset:n.start.offset,endLine:n.end.line,endCol:n.end.column,endOffset:n.end.offset})}const qw=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],Ww=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),ot="�";var O;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(O||(O={}));const Rt={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function fp(e){return e>=55296&&e<=57343}function $w(e){return e>=56320&&e<=57343}function Yw(e,t){return(e-55296)*1024+9216+t}function hp(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function mp(e){return e>=64976&&e<=65007||Ww.has(e)}var Q;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(Q||(Q={}));const Gw=65536;class Kw{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=Gw,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,n){const{line:r,col:s,offset:i}=this,a=s+n,o=i+n;return{code:t,startLine:r,endLine:r,startCol:a,endCol:a,startOffset:o,endOffset:o}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const n=this.html.charCodeAt(this.pos+1);if($w(n))return this.pos++,this._addGap(),Yw(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,O.EOF;return this._err(Q.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,n){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=n}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,n){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(t,this.pos);for(let r=0;r<t.length;r++)if((this.html.charCodeAt(this.pos+r)|32)!==t.charCodeAt(r))return!1;return!0}peek(t){const n=this.pos+t;if(n>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,O.EOF;const r=this.html.charCodeAt(n);return r===O.CARRIAGE_RETURN?O.LINE_FEED:r}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,O.EOF;let t=this.html.charCodeAt(this.pos);return t===O.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,O.LINE_FEED):t===O.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,fp(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===O.LINE_FEED||t===O.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){hp(t)?this._err(Q.controlCharacterInInputStream):mp(t)&&this._err(Q.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var He;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(He||(He={}));function pp(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}const Xw=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),Qw=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function Jw(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=Qw.get(e))!==null&&t!==void 0?t:e}var xt;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(xt||(xt={}));const Zw=32;var wn;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(wn||(wn={}));function zo(e){return e>=xt.ZERO&&e<=xt.NINE}function eS(e){return e>=xt.UPPER_A&&e<=xt.UPPER_F||e>=xt.LOWER_A&&e<=xt.LOWER_F}function tS(e){return e>=xt.UPPER_A&&e<=xt.UPPER_Z||e>=xt.LOWER_A&&e<=xt.LOWER_Z||zo(e)}function nS(e){return e===xt.EQUALS||tS(e)}var gt;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(gt||(gt={}));var xn;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(xn||(xn={}));class rS{constructor(t,n,r){this.decodeTree=t,this.emitCodePoint=n,this.errors=r,this.state=gt.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=xn.Strict}startEntity(t){this.decodeMode=t,this.state=gt.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case gt.EntityStart:return t.charCodeAt(n)===xt.NUM?(this.state=gt.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=gt.NamedEntity,this.stateNamedEntity(t,n));case gt.NumericStart:return this.stateNumericStart(t,n);case gt.NumericDecimal:return this.stateNumericDecimal(t,n);case gt.NumericHex:return this.stateNumericHex(t,n);case gt.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|Zw)===xt.LOWER_X?(this.state=gt.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=gt.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,r,s){if(n!==r){const i=r-n;this.result=this.result*Math.pow(s,i)+Number.parseInt(t.substr(n,i),s),this.consumed+=i}}stateNumericHex(t,n){const r=n;for(;n<t.length;){const s=t.charCodeAt(n);if(zo(s)||eS(s))n+=1;else return this.addToNumericResult(t,r,n,16),this.emitNumericEntity(s,3)}return this.addToNumericResult(t,r,n,16),-1}stateNumericDecimal(t,n){const r=n;for(;n<t.length;){const s=t.charCodeAt(n);if(zo(s))n+=1;else return this.addToNumericResult(t,r,n,10),this.emitNumericEntity(s,2)}return this.addToNumericResult(t,r,n,10),-1}emitNumericEntity(t,n){var r;if(this.consumed<=n)return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===xt.SEMI)this.consumed+=1;else if(this.decodeMode===xn.Strict)return 0;return this.emitCodePoint(Jw(this.result),this.consumed),this.errors&&(t!==xt.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){const{decodeTree:r}=this;let s=r[this.treeIndex],i=(s&wn.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const a=t.charCodeAt(n);if(this.treeIndex=iS(r,s,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===xn.Attribute&&(i===0||nS(a))?0:this.emitNotTerminatedNamedEntity();if(s=r[this.treeIndex],i=(s&wn.VALUE_LENGTH)>>14,i!==0){if(a===xt.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==xn.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:n,decodeTree:r}=this,s=(r[n]&wn.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,s,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,r){const{decodeTree:s}=this;return this.emitCodePoint(n===1?s[t]&~wn.VALUE_LENGTH:s[t+1],r),n===3&&this.emitCodePoint(s[t+2],r),r}end(){var t;switch(this.state){case gt.NamedEntity:return this.result!==0&&(this.decodeMode!==xn.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case gt.NumericDecimal:return this.emitNumericEntity(0,2);case gt.NumericHex:return this.emitNumericEntity(0,3);case gt.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case gt.EntityStart:return 0}}}function iS(e,t,n,r){const s=(t&wn.BRANCH_LENGTH)>>7,i=t&wn.JUMP_TABLE;if(s===0)return i!==0&&r===i?n:-1;if(i){const l=r-i;return l<0||l>=s?-1:e[n+l]-1}let a=n,o=a+s-1;for(;a<=o;){const l=a+o>>>1,u=e[l];if(u<r)a=l+1;else if(u>r)o=l-1;else return e[l+s]}return-1}var ie;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(ie||(ie={}));var Xn;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(Xn||(Xn={}));var qt;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(qt||(qt={}));var Y;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(Y||(Y={}));var b;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(b||(b={}));const sS=new Map([[Y.A,b.A],[Y.ADDRESS,b.ADDRESS],[Y.ANNOTATION_XML,b.ANNOTATION_XML],[Y.APPLET,b.APPLET],[Y.AREA,b.AREA],[Y.ARTICLE,b.ARTICLE],[Y.ASIDE,b.ASIDE],[Y.B,b.B],[Y.BASE,b.BASE],[Y.BASEFONT,b.BASEFONT],[Y.BGSOUND,b.BGSOUND],[Y.BIG,b.BIG],[Y.BLOCKQUOTE,b.BLOCKQUOTE],[Y.BODY,b.BODY],[Y.BR,b.BR],[Y.BUTTON,b.BUTTON],[Y.CAPTION,b.CAPTION],[Y.CENTER,b.CENTER],[Y.CODE,b.CODE],[Y.COL,b.COL],[Y.COLGROUP,b.COLGROUP],[Y.DD,b.DD],[Y.DESC,b.DESC],[Y.DETAILS,b.DETAILS],[Y.DIALOG,b.DIALOG],[Y.DIR,b.DIR],[Y.DIV,b.DIV],[Y.DL,b.DL],[Y.DT,b.DT],[Y.EM,b.EM],[Y.EMBED,b.EMBED],[Y.FIELDSET,b.FIELDSET],[Y.FIGCAPTION,b.FIGCAPTION],[Y.FIGURE,b.FIGURE],[Y.FONT,b.FONT],[Y.FOOTER,b.FOOTER],[Y.FOREIGN_OBJECT,b.FOREIGN_OBJECT],[Y.FORM,b.FORM],[Y.FRAME,b.FRAME],[Y.FRAMESET,b.FRAMESET],[Y.H1,b.H1],[Y.H2,b.H2],[Y.H3,b.H3],[Y.H4,b.H4],[Y.H5,b.H5],[Y.H6,b.H6],[Y.HEAD,b.HEAD],[Y.HEADER,b.HEADER],[Y.HGROUP,b.HGROUP],[Y.HR,b.HR],[Y.HTML,b.HTML],[Y.I,b.I],[Y.IMG,b.IMG],[Y.IMAGE,b.IMAGE],[Y.INPUT,b.INPUT],[Y.IFRAME,b.IFRAME],[Y.KEYGEN,b.KEYGEN],[Y.LABEL,b.LABEL],[Y.LI,b.LI],[Y.LINK,b.LINK],[Y.LISTING,b.LISTING],[Y.MAIN,b.MAIN],[Y.MALIGNMARK,b.MALIGNMARK],[Y.MARQUEE,b.MARQUEE],[Y.MATH,b.MATH],[Y.MENU,b.MENU],[Y.META,b.META],[Y.MGLYPH,b.MGLYPH],[Y.MI,b.MI],[Y.MO,b.MO],[Y.MN,b.MN],[Y.MS,b.MS],[Y.MTEXT,b.MTEXT],[Y.NAV,b.NAV],[Y.NOBR,b.NOBR],[Y.NOFRAMES,b.NOFRAMES],[Y.NOEMBED,b.NOEMBED],[Y.NOSCRIPT,b.NOSCRIPT],[Y.OBJECT,b.OBJECT],[Y.OL,b.OL],[Y.OPTGROUP,b.OPTGROUP],[Y.OPTION,b.OPTION],[Y.P,b.P],[Y.PARAM,b.PARAM],[Y.PLAINTEXT,b.PLAINTEXT],[Y.PRE,b.PRE],[Y.RB,b.RB],[Y.RP,b.RP],[Y.RT,b.RT],[Y.RTC,b.RTC],[Y.RUBY,b.RUBY],[Y.S,b.S],[Y.SCRIPT,b.SCRIPT],[Y.SEARCH,b.SEARCH],[Y.SECTION,b.SECTION],[Y.SELECT,b.SELECT],[Y.SOURCE,b.SOURCE],[Y.SMALL,b.SMALL],[Y.SPAN,b.SPAN],[Y.STRIKE,b.STRIKE],[Y.STRONG,b.STRONG],[Y.STYLE,b.STYLE],[Y.SUB,b.SUB],[Y.SUMMARY,b.SUMMARY],[Y.SUP,b.SUP],[Y.TABLE,b.TABLE],[Y.TBODY,b.TBODY],[Y.TEMPLATE,b.TEMPLATE],[Y.TEXTAREA,b.TEXTAREA],[Y.TFOOT,b.TFOOT],[Y.TD,b.TD],[Y.TH,b.TH],[Y.THEAD,b.THEAD],[Y.TITLE,b.TITLE],[Y.TR,b.TR],[Y.TRACK,b.TRACK],[Y.TT,b.TT],[Y.U,b.U],[Y.UL,b.UL],[Y.SVG,b.SVG],[Y.VAR,b.VAR],[Y.WBR,b.WBR],[Y.XMP,b.XMP]]);function Lr(e){var t;return(t=sS.get(e))!==null&&t!==void 0?t:b.UNKNOWN}const ae=b,aS={[ie.HTML]:new Set([ae.ADDRESS,ae.APPLET,ae.AREA,ae.ARTICLE,ae.ASIDE,ae.BASE,ae.BASEFONT,ae.BGSOUND,ae.BLOCKQUOTE,ae.BODY,ae.BR,ae.BUTTON,ae.CAPTION,ae.CENTER,ae.COL,ae.COLGROUP,ae.DD,ae.DETAILS,ae.DIR,ae.DIV,ae.DL,ae.DT,ae.EMBED,ae.FIELDSET,ae.FIGCAPTION,ae.FIGURE,ae.FOOTER,ae.FORM,ae.FRAME,ae.FRAMESET,ae.H1,ae.H2,ae.H3,ae.H4,ae.H5,ae.H6,ae.HEAD,ae.HEADER,ae.HGROUP,ae.HR,ae.HTML,ae.IFRAME,ae.IMG,ae.INPUT,ae.LI,ae.LINK,ae.LISTING,ae.MAIN,ae.MARQUEE,ae.MENU,ae.META,ae.NAV,ae.NOEMBED,ae.NOFRAMES,ae.NOSCRIPT,ae.OBJECT,ae.OL,ae.P,ae.PARAM,ae.PLAINTEXT,ae.PRE,ae.SCRIPT,ae.SECTION,ae.SELECT,ae.SOURCE,ae.STYLE,ae.SUMMARY,ae.TABLE,ae.TBODY,ae.TD,ae.TEMPLATE,ae.TEXTAREA,ae.TFOOT,ae.TH,ae.THEAD,ae.TITLE,ae.TR,ae.TRACK,ae.UL,ae.WBR,ae.XMP]),[ie.MATHML]:new Set([ae.MI,ae.MO,ae.MN,ae.MS,ae.MTEXT,ae.ANNOTATION_XML]),[ie.SVG]:new Set([ae.TITLE,ae.FOREIGN_OBJECT,ae.DESC]),[ie.XLINK]:new Set,[ie.XML]:new Set,[ie.XMLNS]:new Set},Vo=new Set([ae.H1,ae.H2,ae.H3,ae.H4,ae.H5,ae.H6]);Y.STYLE,Y.SCRIPT,Y.XMP,Y.IFRAME,Y.NOEMBED,Y.NOFRAMES,Y.PLAINTEXT;var H;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(H||(H={}));const dt={DATA:H.DATA,RCDATA:H.RCDATA,RAWTEXT:H.RAWTEXT,SCRIPT_DATA:H.SCRIPT_DATA,PLAINTEXT:H.PLAINTEXT,CDATA_SECTION:H.CDATA_SECTION};function oS(e){return e>=O.DIGIT_0&&e<=O.DIGIT_9}function ei(e){return e>=O.LATIN_CAPITAL_A&&e<=O.LATIN_CAPITAL_Z}function lS(e){return e>=O.LATIN_SMALL_A&&e<=O.LATIN_SMALL_Z}function En(e){return lS(e)||ei(e)}function hd(e){return En(e)||oS(e)}function es(e){return e+32}function gp(e){return e===O.SPACE||e===O.LINE_FEED||e===O.TABULATION||e===O.FORM_FEED}function md(e){return gp(e)||e===O.SOLIDUS||e===O.GREATER_THAN_SIGN}function uS(e){return e===O.NULL?Q.nullCharacterReference:e>1114111?Q.characterReferenceOutsideUnicodeRange:fp(e)?Q.surrogateCharacterReference:mp(e)?Q.noncharacterCharacterReference:hp(e)||e===O.CARRIAGE_RETURN?Q.controlCharacterReference:null}class cS{constructor(t,n){this.options=t,this.handler=n,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=H.DATA,this.returnState=H.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new Kw(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new rS(Xw,(r,s)=>{this.preprocessor.pos=this.entityStartPos+s-1,this._flushCodePointConsumedAsCharacterReference(r)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(Q.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:r=>{this._err(Q.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+r)},validateNumericCharacterReference:r=>{const s=uS(r);s&&this._err(s,1)}}:void 0)}_err(t,n=0){var r,s;(s=(r=this.handler).onParseError)===null||s===void 0||s.call(r,this.preprocessor.getError(t,n))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t==null||t())}write(t,n,r){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||r==null||r()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let n=0;n<t;n++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,n){return this.preprocessor.startsWith(t,n)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:He.START_TAG,tagName:"",tagID:b.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:He.END_TAG,tagName:"",tagID:b.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:He.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:He.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,n){this.currentCharacterToken={type:t,chars:n,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,n;const r=this.currentToken;if(pp(r,this.currentAttr.name)===null){if(r.attrs.push(this.currentAttr),r.location&&this.currentLocation){const s=(t=(n=r.location).attrs)!==null&&t!==void 0?t:n.attrs=Object.create(null);s[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(Q.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(t){this._emitCurrentCharacterToken(t.location),this.currentToken=null,t.location&&(t.location.endLine=this.preprocessor.line,t.location.endCol=this.preprocessor.col+1,t.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const t=this.currentToken;this.prepareToken(t),t.tagID=Lr(t.tagName),t.type===He.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(Q.endTagWithAttributes),t.selfClosing&&this._err(Q.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case He.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case He.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case He.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:He.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=n;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,n)}_emitCodePoint(t){const n=gp(t)?He.WHITESPACE_CHARACTER:t===O.NULL?He.NULL_CHARACTER:He.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(He.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=H.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?xn.Attribute:xn.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===H.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===H.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===H.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case H.DATA:{this._stateData(t);break}case H.RCDATA:{this._stateRcdata(t);break}case H.RAWTEXT:{this._stateRawtext(t);break}case H.SCRIPT_DATA:{this._stateScriptData(t);break}case H.PLAINTEXT:{this._statePlaintext(t);break}case H.TAG_OPEN:{this._stateTagOpen(t);break}case H.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case H.TAG_NAME:{this._stateTagName(t);break}case H.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case H.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case H.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case H.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case H.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case H.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case H.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case H.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case H.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case H.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case H.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case H.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case H.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case H.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case H.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case H.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case H.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case H.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case H.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case H.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case H.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case H.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case H.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case H.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case H.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case H.BOGUS_COMMENT:{this._stateBogusComment(t);break}case H.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case H.COMMENT_START:{this._stateCommentStart(t);break}case H.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case H.COMMENT:{this._stateComment(t);break}case H.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case H.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case H.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case H.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case H.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case H.COMMENT_END:{this._stateCommentEnd(t);break}case H.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case H.DOCTYPE:{this._stateDoctype(t);break}case H.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case H.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case H.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case H.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case H.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case H.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case H.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case H.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case H.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case H.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case H.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case H.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case H.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case H.CDATA_SECTION:{this._stateCdataSection(t);break}case H.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case H.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case H.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case H.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case O.LESS_THAN_SIGN:{this.state=H.TAG_OPEN;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitCodePoint(t);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case O.AMPERSAND:{this._startCharacterReference();break}case O.LESS_THAN_SIGN:{this.state=H.RCDATA_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case O.LESS_THAN_SIGN:{this.state=H.RAWTEXT_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(En(t))this._createStartTagToken(),this.state=H.TAG_NAME,this._stateTagName(t);else switch(t){case O.EXCLAMATION_MARK:{this.state=H.MARKUP_DECLARATION_OPEN;break}case O.SOLIDUS:{this.state=H.END_TAG_OPEN;break}case O.QUESTION_MARK:{this._err(Q.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=H.BOGUS_COMMENT,this._stateBogusComment(t);break}case O.EOF:{this._err(Q.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(Q.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=H.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(En(t))this._createEndTagToken(),this.state=H.TAG_NAME,this._stateTagName(t);else switch(t){case O.GREATER_THAN_SIGN:{this._err(Q.missingEndTagName),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(Q.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=H.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_ATTRIBUTE_NAME;break}case O.SOLIDUS:{this.state=H.SELF_CLOSING_START_TAG;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentTagToken();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.tagName+=ot;break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(ei(t)?es(t):t)}}_stateRcdataLessThanSign(t){t===O.SOLIDUS?this.state=H.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=H.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){En(t)?(this.state=H.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=H.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const n=this.currentToken;switch(n.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=H.BEFORE_ATTRIBUTE_NAME,!1;case O.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=H.SELF_CLOSING_START_TAG,!1;case O.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=H.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===O.SOLIDUS?this.state=H.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=H.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){En(t)?(this.state=H.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=H.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case O.SOLIDUS:{this.state=H.SCRIPT_DATA_END_TAG_OPEN;break}case O.EXCLAMATION_MARK:{this.state=H.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=H.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){En(t)?(this.state=H.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===O.HYPHEN_MINUS?(this.state=H.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===O.HYPHEN_MINUS?(this.state=H.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case O.HYPHEN_MINUS:{this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.GREATER_THAN_SIGN:{this.state=H.SCRIPT_DATA,this._emitChars(">");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===O.SOLIDUS?this.state=H.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:En(t)?(this._emitChars("<"),this.state=H.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){En(t)?(this.state=H.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&md(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case O.HYPHEN_MINUS:{this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.GREATER_THAN_SIGN:{this.state=H.SCRIPT_DATA,this._emitChars(">");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===O.SOLIDUS?(this.state=H.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&md(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=H.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.SOLIDUS:case O.GREATER_THAN_SIGN:case O.EOF:{this.state=H.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case O.EQUALS_SIGN:{this._err(Q.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=H.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=H.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:case O.SOLIDUS:case O.GREATER_THAN_SIGN:case O.EOF:{this._leaveAttrName(),this.state=H.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case O.EQUALS_SIGN:{this._leaveAttrName(),this.state=H.BEFORE_ATTRIBUTE_VALUE;break}case O.QUOTATION_MARK:case O.APOSTROPHE:case O.LESS_THAN_SIGN:{this._err(Q.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.name+=ot;break}default:this.currentAttr.name+=String.fromCodePoint(ei(t)?es(t):t)}}_stateAfterAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.SOLIDUS:{this.state=H.SELF_CLOSING_START_TAG;break}case O.EQUALS_SIGN:{this.state=H.BEFORE_ATTRIBUTE_VALUE;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=H.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{this.state=H.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this.state=H.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingAttributeValue),this.state=H.DATA,this.emitCurrentTagToken();break}default:this.state=H.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case O.QUOTATION_MARK:{this.state=H.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case O.APOSTROPHE:{this.state=H.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this._leaveAttrValue(),this.state=H.BEFORE_ATTRIBUTE_NAME;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=H.DATA,this.emitCurrentTagToken();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case O.QUOTATION_MARK:case O.APOSTROPHE:case O.LESS_THAN_SIGN:case O.EQUALS_SIGN:case O.GRAVE_ACCENT:{this._err(Q.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this._leaveAttrValue(),this.state=H.BEFORE_ATTRIBUTE_NAME;break}case O.SOLIDUS:{this._leaveAttrValue(),this.state=H.SELF_CLOSING_START_TAG;break}case O.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=H.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this._err(Q.missingWhitespaceBetweenAttributes),this.state=H.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case O.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=H.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this._err(Q.unexpectedSolidusInTag),this.state=H.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentComment(n);break}case O.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.data+=ot;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(Rt.DASH_DASH,!0)?(this._createCommentToken(Rt.DASH_DASH.length+1),this.state=H.COMMENT_START):this._consumeSequenceIfMatch(Rt.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Rt.DOCTYPE.length+1),this.state=H.DOCTYPE):this._consumeSequenceIfMatch(Rt.CDATA_START,!0)?this.inForeignNode?this.state=H.CDATA_SECTION:(this._err(Q.cdataInHtmlContent),this._createCommentToken(Rt.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=H.BOGUS_COMMENT):this._ensureHibernation()||(this._err(Q.incorrectlyOpenedComment),this._createCommentToken(2),this.state=H.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_START_DASH;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptClosingOfEmptyComment),this.state=H.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=H.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_END;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptClosingOfEmptyComment),this.state=H.DATA,this.emitCurrentComment(n);break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=H.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_END_DASH;break}case O.LESS_THAN_SIGN:{n.data+="<",this.state=H.COMMENT_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.data+=ot;break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case O.EXCLAMATION_MARK:{n.data+="!",this.state=H.COMMENT_LESS_THAN_SIGN_BANG;break}case O.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=H.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===O.HYPHEN_MINUS?this.state=H.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=H.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===O.HYPHEN_MINUS?this.state=H.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=H.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==O.GREATER_THAN_SIGN&&t!==O.EOF&&this._err(Q.nestedComment),this.state=H.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_END;break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=H.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentComment(n);break}case O.EXCLAMATION_MARK:{this.state=H.COMMENT_END_BANG;break}case O.HYPHEN_MINUS:{n.data+="-";break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=H.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{n.data+="--!",this.state=H.COMMENT_END_DASH;break}case O.GREATER_THAN_SIGN:{this._err(Q.incorrectlyClosedComment),this.state=H.DATA,this.emitCurrentComment(n);break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=H.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this.state=H.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case O.EOF:{this._err(Q.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingWhitespaceBeforeDoctypeName),this.state=H.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(ei(t))this._createDoctypeToken(String.fromCharCode(es(t))),this.state=H.DOCTYPE_NAME;else switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.NULL:{this._err(Q.unexpectedNullCharacter),this._createDoctypeToken(ot),this.state=H.DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=H.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.AFTER_DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.name+=ot;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(ei(t)?es(t):t)}}_stateAfterDoctypeName(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Rt.PUBLIC,!1)?this.state=H.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Rt.SYSTEM,!1)?this.state=H.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(Q.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.QUOTATION_MARK:{this._err(Q.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(Q.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case O.QUOTATION_MARK:{this.state=H.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.publicId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case O.APOSTROPHE:{this.state=H.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.publicId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.QUOTATION_MARK:{this._err(Q.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(Q.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.QUOTATION_MARK:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.QUOTATION_MARK:{this._err(Q.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(Q.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case O.QUOTATION_MARK:{this.state=H.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.systemId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case O.APOSTROPHE:{this.state=H.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.systemId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.NULL:{this._err(Q.unexpectedNullCharacter);break}case O.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case O.RIGHT_SQUARE_BRACKET:{this.state=H.CDATA_SECTION_BRACKET;break}case O.EOF:{this._err(Q.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===O.RIGHT_SQUARE_BRACKET?this.state=H.CDATA_SECTION_END:(this._emitChars("]"),this.state=H.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case O.GREATER_THAN_SIGN:{this.state=H.DATA;break}case O.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=H.CDATA_SECTION,this._stateCdataSection(t)}}_stateCharacterReference(){let t=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(t<0)if(this.preprocessor.lastChunkWritten)t=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}t===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(O.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&hd(this.preprocessor.peek(1))?H.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){hd(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===O.SEMICOLON&&this._err(Q.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const xp=new Set([b.DD,b.DT,b.LI,b.OPTGROUP,b.OPTION,b.P,b.RB,b.RP,b.RT,b.RTC]),pd=new Set([...xp,b.CAPTION,b.COLGROUP,b.TBODY,b.TD,b.TFOOT,b.TH,b.THEAD,b.TR]),Rs=new Set([b.APPLET,b.CAPTION,b.HTML,b.MARQUEE,b.OBJECT,b.TABLE,b.TD,b.TEMPLATE,b.TH]),dS=new Set([...Rs,b.OL,b.UL]),fS=new Set([...Rs,b.BUTTON]),gd=new Set([b.ANNOTATION_XML,b.MI,b.MN,b.MO,b.MS,b.MTEXT]),xd=new Set([b.DESC,b.FOREIGN_OBJECT,b.TITLE]),hS=new Set([b.TR,b.TEMPLATE,b.HTML]),mS=new Set([b.TBODY,b.TFOOT,b.THEAD,b.TEMPLATE,b.HTML]),pS=new Set([b.TABLE,b.TEMPLATE,b.HTML]),gS=new Set([b.TD,b.TH]);class xS{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,n,r){this.treeAdapter=n,this.handler=r,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=b.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===b.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===ie.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,n){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=n,this.currentTagId=n,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,n,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,n){const r=this._indexOf(t);this.items[r]=n,r===this.stackTop&&(this.current=n)}insertAfter(t,n,r){const s=this._indexOf(t)+1;this.items.splice(s,0,n),this.tagIDs.splice(s,0,r),this.stackTop++,s===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,s===this.stackTop)}popUntilTagNamePopped(t){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(t,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==ie.HTML);this.shortenToLength(Math.max(n,0))}shortenToLength(t){for(;this.stackTop>=t;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop<t)}}popUntilElementPopped(t){const n=this._indexOf(t);this.shortenToLength(Math.max(n,0))}popUntilPopped(t,n){const r=this._indexOfTagNames(t,n);this.shortenToLength(Math.max(r,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Vo,ie.HTML)}popUntilTableCellPopped(){this.popUntilPopped(gS,ie.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,n){for(let r=this.stackTop;r>=0;r--)if(t.has(this.tagIDs[r])&&this.treeAdapter.getNamespaceURI(this.items[r])===n)return r;return-1}clearBackTo(t,n){const r=this._indexOfTagNames(t,n);this.shortenToLength(r+1)}clearBackToTableContext(){this.clearBackTo(pS,ie.HTML)}clearBackToTableBodyContext(){this.clearBackTo(mS,ie.HTML)}clearBackToTableRowContext(){this.clearBackTo(hS,ie.HTML)}remove(t){const n=this._indexOf(t);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===b.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const n=this._indexOf(t)-1;return n>=0?this.items[n]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===b.HTML}hasInDynamicScope(t,n){for(let r=this.stackTop;r>=0;r--){const s=this.tagIDs[r];switch(this.treeAdapter.getNamespaceURI(this.items[r])){case ie.HTML:{if(s===t)return!0;if(n.has(s))return!1;break}case ie.SVG:{if(xd.has(s))return!1;break}case ie.MATHML:{if(gd.has(s))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,Rs)}hasInListItemScope(t){return this.hasInDynamicScope(t,dS)}hasInButtonScope(t){return this.hasInDynamicScope(t,fS)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case ie.HTML:{if(Vo.has(n))return!0;if(Rs.has(n))return!1;break}case ie.SVG:{if(xd.has(n))return!1;break}case ie.MATHML:{if(gd.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===ie.HTML)switch(this.tagIDs[n]){case t:return!0;case b.TABLE:case b.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===ie.HTML)switch(this.tagIDs[t]){case b.TBODY:case b.THEAD:case b.TFOOT:return!0;case b.TABLE:case b.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===ie.HTML)switch(this.tagIDs[n]){case t:return!0;case b.OPTION:case b.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&xp.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&pd.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&pd.has(this.currentTagId);)this.pop()}}const Qa=3;var sn;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(sn||(sn={}));const bd={type:sn.Marker};class bS{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const r=[],s=n.length,i=this.treeAdapter.getTagName(t),a=this.treeAdapter.getNamespaceURI(t);for(let o=0;o<this.entries.length;o++){const l=this.entries[o];if(l.type===sn.Marker)break;const{element:u}=l;if(this.treeAdapter.getTagName(u)===i&&this.treeAdapter.getNamespaceURI(u)===a){const c=this.treeAdapter.getAttrList(u);c.length===s&&r.push({idx:o,attrs:c})}}return r}_ensureNoahArkCondition(t){if(this.entries.length<Qa)return;const n=this.treeAdapter.getAttrList(t),r=this._getNoahArkConditionCandidates(t,n);if(r.length<Qa)return;const s=new Map(n.map(a=>[a.name,a.value]));let i=0;for(let a=0;a<r.length;a++){const o=r[a];o.attrs.every(l=>s.get(l.name)===l.value)&&(i+=1,i>=Qa&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(bd)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:sn.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:sn.Element,element:t,token:n})}removeEntry(t){const n=this.entries.indexOf(t);n!==-1&&this.entries.splice(n,1)}clearToLastMarker(){const t=this.entries.indexOf(bd);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(r=>r.type===sn.Marker||this.treeAdapter.getTagName(r.element)===t);return n&&n.type===sn.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===sn.Element&&n.element===t)}}const vn={createDocument(){return{nodeName:"#document",mode:qt.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,r){const s=e.childNodes.find(i=>i.nodeName==="#documentType");if(s)s.name=t,s.publicId=n,s.systemId=r;else{const i={nodeName:"#documentType",name:t,publicId:n,systemId:r,parentNode:null};vn.appendChild(e,i)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(vn.isTextNode(n)){n.value+=t;return}}vn.appendChild(e,vn.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&vn.isTextNode(r)?r.value+=t:vn.insertBefore(e,vn.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(r=>r.name));for(let r=0;r<t.length;r++)n.has(t[r].name)||e.attrs.push(t[r])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},bp="html",yS="about:legacy-compat",ES="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",yp=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],vS=[...yp,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],TS=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Ep=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],kS=[...Ep,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function yd(e,t){return t.some(n=>e.startsWith(n))}function wS(e){return e.name===bp&&e.publicId===null&&(e.systemId===null||e.systemId===yS)}function SS(e){if(e.name!==bp)return qt.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===ES)return qt.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),TS.has(n))return qt.QUIRKS;let r=t===null?vS:yp;if(yd(n,r))return qt.QUIRKS;if(r=t===null?Ep:kS,yd(n,r))return qt.LIMITED_QUIRKS}return qt.NO_QUIRKS}const Ed={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},AS="definitionurl",CS="definitionURL",_S=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),IS=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:ie.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:ie.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:ie.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:ie.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:ie.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:ie.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:ie.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:ie.XML}],["xml:space",{prefix:"xml",name:"space",namespace:ie.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:ie.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:ie.XMLNS}]]),NS=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),RS=new Set([b.B,b.BIG,b.BLOCKQUOTE,b.BODY,b.BR,b.CENTER,b.CODE,b.DD,b.DIV,b.DL,b.DT,b.EM,b.EMBED,b.H1,b.H2,b.H3,b.H4,b.H5,b.H6,b.HEAD,b.HR,b.I,b.IMG,b.LI,b.LISTING,b.MENU,b.META,b.NOBR,b.OL,b.P,b.PRE,b.RUBY,b.S,b.SMALL,b.SPAN,b.STRONG,b.STRIKE,b.SUB,b.SUP,b.TABLE,b.TT,b.U,b.UL,b.VAR]);function LS(e){const t=e.tagID;return t===b.FONT&&e.attrs.some(({name:r})=>r===Xn.COLOR||r===Xn.SIZE||r===Xn.FACE)||RS.has(t)}function vp(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===AS){e.attrs[t].name=CS;break}}function Tp(e){for(let t=0;t<e.attrs.length;t++){const n=_S.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function Jl(e){for(let t=0;t<e.attrs.length;t++){const n=IS.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function PS(e){const t=NS.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Lr(e.tagName))}function MS(e,t){return t===ie.MATHML&&(e===b.MI||e===b.MO||e===b.MN||e===b.MS||e===b.MTEXT)}function DS(e,t,n){if(t===ie.MATHML&&e===b.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===Xn.ENCODING){const s=n[r].value.toLowerCase();return s===Ed.TEXT_HTML||s===Ed.APPLICATION_XML}}return t===ie.SVG&&(e===b.FOREIGN_OBJECT||e===b.DESC||e===b.TITLE)}function OS(e,t,n,r){return(!r||r===ie.HTML)&&DS(e,t,n)||(!r||r===ie.MATHML)&&MS(e,t)}const FS="hidden",BS=8,jS=3;var U;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(U||(U={}));const HS={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},kp=new Set([b.TABLE,b.TBODY,b.TFOOT,b.THEAD,b.TR]),vd={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:vn,onParseError:null};class Td{constructor(t,n,r=null,s=null){this.fragmentContext=r,this.scriptHandler=s,this.currentToken=null,this.stopped=!1,this.insertionMode=U.INITIAL,this.originalInsertionMode=U.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...vd,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=n??this.treeAdapter.createDocument(),this.tokenizer=new cS(this.options,this),this.activeFormattingElements=new bS(this.treeAdapter),this.fragmentContextID=r?Lr(this.treeAdapter.getTagName(r)):b.UNKNOWN,this._setContextModes(r??this.document,this.fragmentContextID),this.openElements=new xS(this.document,this.treeAdapter,this)}static parse(t,n){const r=new this(n);return r.tokenizer.write(t,!0),r.document}static getFragmentParser(t,n){const r={...vd,...n};t??(t=r.treeAdapter.createElement(Y.TEMPLATE,ie.HTML,[]));const s=r.treeAdapter.createElement("documentmock",ie.HTML,[]),i=new this(r,s,t);return i.fragmentContextID===b.TEMPLATE&&i.tmplInsertionModeStack.unshift(U.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),n=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,n),n}_err(t,n,r){var s;if(!this.onParseError)return;const i=(s=t.location)!==null&&s!==void 0?s:HS,a={code:n,startLine:i.startLine,startCol:i.startCol,startOffset:i.startOffset,endLine:r?i.startLine:i.endLine,endCol:r?i.startCol:i.endCol,endOffset:r?i.startOffset:i.endOffset};this.onParseError(a)}onItemPush(t,n,r){var s,i;(i=(s=this.treeAdapter).onItemPush)===null||i===void 0||i.call(s,t),r&&this.openElements.stackTop>0&&this._setContextModes(t,n)}onItemPop(t,n){var r,s;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(s=(r=this.treeAdapter).onItemPop)===null||s===void 0||s.call(r,t,this.openElements.current),n){let i,a;this.openElements.stackTop===0&&this.fragmentContext?(i=this.fragmentContext,a=this.fragmentContextID):{current:i,currentTagId:a}=this.openElements,this._setContextModes(i,a)}}_setContextModes(t,n){const r=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===ie.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,ie.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=U.TEXT}switchToPlaintextParsing(){this.insertionMode=U.TEXT,this.originalInsertionMode=U.IN_BODY,this.tokenizer.state=dt.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===Y.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==ie.HTML))switch(this.fragmentContextID){case b.TITLE:case b.TEXTAREA:{this.tokenizer.state=dt.RCDATA;break}case b.STYLE:case b.XMP:case b.IFRAME:case b.NOEMBED:case b.NOFRAMES:case b.NOSCRIPT:{this.tokenizer.state=dt.RAWTEXT;break}case b.SCRIPT:{this.tokenizer.state=dt.SCRIPT_DATA;break}case b.PLAINTEXT:{this.tokenizer.state=dt.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",r=t.publicId||"",s=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,r,s),t.location){const a=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));a&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const r=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,r)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const r=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(r??this.document,t)}}_appendElement(t,n){const r=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(r,t.location)}_insertElement(t,n){const r=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(r,t.location),this.openElements.push(r,t.tagID)}_insertFakeElement(t,n){const r=this.treeAdapter.createElement(t,ie.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,ie.HTML,t.attrs),r=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,r),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(Y.HTML,ie.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,b.HTML)}_appendCommentNode(t,n){const r=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,r),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,t.location)}_insertCharacters(t){let n,r;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:r}=this._findFosterParentingLocation(),r?this.treeAdapter.insertTextBefore(n,t.chars,r):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const s=this.treeAdapter.getChildNodes(n),i=r?s.lastIndexOf(r):s.length,a=s[i-1];if(this.treeAdapter.getNodeSourceCodeLocation(a)){const{endLine:l,endCol:u,endOffset:c}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(a,{endLine:l,endCol:u,endOffset:c})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}_adoptNodes(t,n){for(let r=this.treeAdapter.getFirstChild(t);r;r=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(r),this.treeAdapter.appendChild(n,r)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const r=n.location,s=this.treeAdapter.getTagName(t),i=n.type===He.END_TAG&&s===n.tagName?{endTag:{...r},endLine:r.endLine,endCol:r.endCol,endOffset:r.endOffset}:{endLine:r.startLine,endCol:r.startCol,endOffset:r.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,i)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,r;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,r=this.fragmentContextID):{current:n,currentTagId:r}=this.openElements,t.tagID===b.SVG&&this.treeAdapter.getTagName(n)===Y.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===ie.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===b.MGLYPH||t.tagID===b.MALIGNMARK)&&r!==void 0&&!this._isIntegrationPoint(r,n,ie.HTML)}_processToken(t){switch(t.type){case He.CHARACTER:{this.onCharacter(t);break}case He.NULL_CHARACTER:{this.onNullCharacter(t);break}case He.COMMENT:{this.onComment(t);break}case He.DOCTYPE:{this.onDoctype(t);break}case He.START_TAG:{this._processStartTag(t);break}case He.END_TAG:{this.onEndTag(t);break}case He.EOF:{this.onEof(t);break}case He.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,r){const s=this.treeAdapter.getNamespaceURI(n),i=this.treeAdapter.getAttrList(n);return OS(t,s,i,r)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(s=>s.type===sn.Marker||this.openElements.contains(s.element)),r=n===-1?t-1:n-1;for(let s=r;s>=0;s--){const i=this.activeFormattingElements.entries[s];this._insertElement(i.token,this.treeAdapter.getNamespaceURI(i.element)),i.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=U.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(b.P),this.openElements.popUntilTagNamePopped(b.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case b.TR:{this.insertionMode=U.IN_ROW;return}case b.TBODY:case b.THEAD:case b.TFOOT:{this.insertionMode=U.IN_TABLE_BODY;return}case b.CAPTION:{this.insertionMode=U.IN_CAPTION;return}case b.COLGROUP:{this.insertionMode=U.IN_COLUMN_GROUP;return}case b.TABLE:{this.insertionMode=U.IN_TABLE;return}case b.BODY:{this.insertionMode=U.IN_BODY;return}case b.FRAMESET:{this.insertionMode=U.IN_FRAMESET;return}case b.SELECT:{this._resetInsertionModeForSelect(t);return}case b.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case b.HTML:{this.insertionMode=this.headElement?U.AFTER_HEAD:U.BEFORE_HEAD;return}case b.TD:case b.TH:{if(t>0){this.insertionMode=U.IN_CELL;return}break}case b.HEAD:{if(t>0){this.insertionMode=U.IN_HEAD;return}break}}this.insertionMode=U.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const r=this.openElements.tagIDs[n];if(r===b.TEMPLATE)break;if(r===b.TABLE){this.insertionMode=U.IN_SELECT_IN_TABLE;return}}this.insertionMode=U.IN_SELECT}_isElementCausesFosterParenting(t){return kp.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const n=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case b.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===ie.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case b.TABLE:{const r=this.treeAdapter.getParentNode(n);return r?{parent:r,beforeElement:n}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,t,n.beforeElement):this.treeAdapter.appendChild(n.parent,t)}_isSpecialElement(t,n){const r=this.treeAdapter.getNamespaceURI(t);return aS[r].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){gC(this,t);return}switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{ai(this,t);break}case U.BEFORE_HEAD:{oi(this,t);break}case U.IN_HEAD:{li(this,t);break}case U.IN_HEAD_NO_SCRIPT:{ui(this,t);break}case U.AFTER_HEAD:{ci(this,t);break}case U.IN_BODY:case U.IN_CAPTION:case U.IN_CELL:case U.IN_TEMPLATE:{Sp(this,t);break}case U.TEXT:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{Ja(this,t);break}case U.IN_TABLE_TEXT:{Rp(this,t);break}case U.IN_COLUMN_GROUP:{Ls(this,t);break}case U.AFTER_BODY:{Ps(this,t);break}case U.AFTER_AFTER_BODY:{ms(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){pC(this,t);return}switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{ai(this,t);break}case U.BEFORE_HEAD:{oi(this,t);break}case U.IN_HEAD:{li(this,t);break}case U.IN_HEAD_NO_SCRIPT:{ui(this,t);break}case U.AFTER_HEAD:{ci(this,t);break}case U.TEXT:{this._insertCharacters(t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{Ja(this,t);break}case U.IN_COLUMN_GROUP:{Ls(this,t);break}case U.AFTER_BODY:{Ps(this,t);break}case U.AFTER_AFTER_BODY:{ms(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){qo(this,t);return}switch(this.insertionMode){case U.INITIAL:case U.BEFORE_HTML:case U.BEFORE_HEAD:case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:case U.IN_BODY:case U.IN_TABLE:case U.IN_CAPTION:case U.IN_COLUMN_GROUP:case U.IN_TABLE_BODY:case U.IN_ROW:case U.IN_CELL:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:case U.IN_TEMPLATE:case U.IN_FRAMESET:case U.AFTER_FRAMESET:{qo(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.AFTER_BODY:{YS(this,t);break}case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{GS(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case U.INITIAL:{KS(this,t);break}case U.BEFORE_HEAD:case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:{this._err(t,Q.misplacedDoctype);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,Q.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?xC(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{XS(this,t);break}case U.BEFORE_HEAD:{JS(this,t);break}case U.IN_HEAD:{en(this,t);break}case U.IN_HEAD_NO_SCRIPT:{tA(this,t);break}case U.AFTER_HEAD:{rA(this,t);break}case U.IN_BODY:{wt(this,t);break}case U.IN_TABLE:{Ar(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.IN_CAPTION:{ZA(this,t);break}case U.IN_COLUMN_GROUP:{tu(this,t);break}case U.IN_TABLE_BODY:{aa(this,t);break}case U.IN_ROW:{oa(this,t);break}case U.IN_CELL:{nC(this,t);break}case U.IN_SELECT:{Mp(this,t);break}case U.IN_SELECT_IN_TABLE:{iC(this,t);break}case U.IN_TEMPLATE:{aC(this,t);break}case U.AFTER_BODY:{lC(this,t);break}case U.IN_FRAMESET:{uC(this,t);break}case U.AFTER_FRAMESET:{dC(this,t);break}case U.AFTER_AFTER_BODY:{hC(this,t);break}case U.AFTER_AFTER_FRAMESET:{mC(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?bC(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{QS(this,t);break}case U.BEFORE_HEAD:{ZS(this,t);break}case U.IN_HEAD:{eA(this,t);break}case U.IN_HEAD_NO_SCRIPT:{nA(this,t);break}case U.AFTER_HEAD:{iA(this,t);break}case U.IN_BODY:{sa(this,t);break}case U.TEXT:{VA(this,t);break}case U.IN_TABLE:{ki(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.IN_CAPTION:{eC(this,t);break}case U.IN_COLUMN_GROUP:{tC(this,t);break}case U.IN_TABLE_BODY:{Wo(this,t);break}case U.IN_ROW:{Pp(this,t);break}case U.IN_CELL:{rC(this,t);break}case U.IN_SELECT:{Dp(this,t);break}case U.IN_SELECT_IN_TABLE:{sC(this,t);break}case U.IN_TEMPLATE:{oC(this,t);break}case U.AFTER_BODY:{Fp(this,t);break}case U.IN_FRAMESET:{cC(this,t);break}case U.AFTER_FRAMESET:{fC(this,t);break}case U.AFTER_AFTER_BODY:{ms(this,t);break}}}onEof(t){switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{ai(this,t);break}case U.BEFORE_HEAD:{oi(this,t);break}case U.IN_HEAD:{li(this,t);break}case U.IN_HEAD_NO_SCRIPT:{ui(this,t);break}case U.AFTER_HEAD:{ci(this,t);break}case U.IN_BODY:case U.IN_TABLE:case U.IN_CAPTION:case U.IN_COLUMN_GROUP:case U.IN_TABLE_BODY:case U.IN_ROW:case U.IN_CELL:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:{Ip(this,t);break}case U.TEXT:{qA(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.IN_TEMPLATE:{Op(this,t);break}case U.AFTER_BODY:case U.IN_FRAMESET:case U.AFTER_FRAMESET:case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{eu(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===O.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:case U.TEXT:case U.IN_COLUMN_GROUP:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:case U.IN_FRAMESET:case U.AFTER_FRAMESET:{this._insertCharacters(t);break}case U.IN_BODY:case U.IN_CAPTION:case U.IN_CELL:case U.IN_TEMPLATE:case U.AFTER_BODY:case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{wp(this,t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{Ja(this,t);break}case U.IN_TABLE_TEXT:{Np(this,t);break}}}}function US(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):_p(e,t),n}function zS(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){const s=e.openElements.items[r];if(s===t.element)break;e._isSpecialElement(s,e.openElements.tagIDs[r])&&(n=s)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function VS(e,t,n){let r=t,s=e.openElements.getCommonAncestor(t);for(let i=0,a=s;a!==n;i++,a=s){s=e.openElements.getCommonAncestor(a);const o=e.activeFormattingElements.getElementEntry(a),l=o&&i>=jS;!o||l?(l&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(a)):(a=qS(e,o),r===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(a,r),r=a)}return r}function qS(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function WS(e,t,n){const r=e.treeAdapter.getTagName(t),s=Lr(r);if(e._isElementCausesFosterParenting(s))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);s===b.TEMPLATE&&i===ie.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function $S(e,t,n){const r=e.treeAdapter.getNamespaceURI(n.element),{token:s}=n,i=e.treeAdapter.createElement(s.tagName,r,s.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,s),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,i,s.tagID)}function Zl(e,t){for(let n=0;n<BS;n++){const r=US(e,t);if(!r)break;const s=zS(e,r);if(!s)break;e.activeFormattingElements.bookmark=r;const i=VS(e,s,r.element),a=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(i),a&&WS(e,a,i),$S(e,s,r)}}function qo(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function YS(e,t){e._appendCommentNode(t,e.openElements.items[0])}function GS(e,t){e._appendCommentNode(t,e.document)}function eu(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const r=e.openElements.items[0],s=e.treeAdapter.getNodeSourceCodeLocation(r);if(s&&!s.endTag&&(e._setEndLocation(r,t),e.openElements.stackTop>=1)){const i=e.openElements.items[1],a=e.treeAdapter.getNodeSourceCodeLocation(i);a&&!a.endTag&&e._setEndLocation(i,t)}}}}function KS(e,t){e._setDocumentType(t);const n=t.forceQuirks?qt.QUIRKS:SS(t);wS(t)||e._err(t,Q.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=U.BEFORE_HTML}function Yr(e,t){e._err(t,Q.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,qt.QUIRKS),e.insertionMode=U.BEFORE_HTML,e._processToken(t)}function XS(e,t){t.tagID===b.HTML?(e._insertElement(t,ie.HTML),e.insertionMode=U.BEFORE_HEAD):ai(e,t)}function QS(e,t){const n=t.tagID;(n===b.HTML||n===b.HEAD||n===b.BODY||n===b.BR)&&ai(e,t)}function ai(e,t){e._insertFakeRootElement(),e.insertionMode=U.BEFORE_HEAD,e._processToken(t)}function JS(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.HEAD:{e._insertElement(t,ie.HTML),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD;break}default:oi(e,t)}}function ZS(e,t){const n=t.tagID;n===b.HEAD||n===b.BODY||n===b.HTML||n===b.BR?oi(e,t):e._err(t,Q.endTagWithoutMatchingOpenElement)}function oi(e,t){e._insertFakeElement(Y.HEAD,b.HEAD),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD,e._processToken(t)}function en(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.BASE:case b.BASEFONT:case b.BGSOUND:case b.LINK:case b.META:{e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.TITLE:{e._switchToTextParsing(t,dt.RCDATA);break}case b.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,dt.RAWTEXT):(e._insertElement(t,ie.HTML),e.insertionMode=U.IN_HEAD_NO_SCRIPT);break}case b.NOFRAMES:case b.STYLE:{e._switchToTextParsing(t,dt.RAWTEXT);break}case b.SCRIPT:{e._switchToTextParsing(t,dt.SCRIPT_DATA);break}case b.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=U.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(U.IN_TEMPLATE);break}case b.HEAD:{e._err(t,Q.misplacedStartTagForHeadElement);break}default:li(e,t)}}function eA(e,t){switch(t.tagID){case b.HEAD:{e.openElements.pop(),e.insertionMode=U.AFTER_HEAD;break}case b.BODY:case b.BR:case b.HTML:{li(e,t);break}case b.TEMPLATE:{ir(e,t);break}default:e._err(t,Q.endTagWithoutMatchingOpenElement)}}function ir(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==b.TEMPLATE&&e._err(t,Q.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(b.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,Q.endTagWithoutMatchingOpenElement)}function li(e,t){e.openElements.pop(),e.insertionMode=U.AFTER_HEAD,e._processToken(t)}function tA(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.BASEFONT:case b.BGSOUND:case b.HEAD:case b.LINK:case b.META:case b.NOFRAMES:case b.STYLE:{en(e,t);break}case b.NOSCRIPT:{e._err(t,Q.nestedNoscriptInHead);break}default:ui(e,t)}}function nA(e,t){switch(t.tagID){case b.NOSCRIPT:{e.openElements.pop(),e.insertionMode=U.IN_HEAD;break}case b.BR:{ui(e,t);break}default:e._err(t,Q.endTagWithoutMatchingOpenElement)}}function ui(e,t){const n=t.type===He.EOF?Q.openElementsLeftAfterEof:Q.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=U.IN_HEAD,e._processToken(t)}function rA(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.BODY:{e._insertElement(t,ie.HTML),e.framesetOk=!1,e.insertionMode=U.IN_BODY;break}case b.FRAMESET:{e._insertElement(t,ie.HTML),e.insertionMode=U.IN_FRAMESET;break}case b.BASE:case b.BASEFONT:case b.BGSOUND:case b.LINK:case b.META:case b.NOFRAMES:case b.SCRIPT:case b.STYLE:case b.TEMPLATE:case b.TITLE:{e._err(t,Q.abandonedHeadElementChild),e.openElements.push(e.headElement,b.HEAD),en(e,t),e.openElements.remove(e.headElement);break}case b.HEAD:{e._err(t,Q.misplacedStartTagForHeadElement);break}default:ci(e,t)}}function iA(e,t){switch(t.tagID){case b.BODY:case b.HTML:case b.BR:{ci(e,t);break}case b.TEMPLATE:{ir(e,t);break}default:e._err(t,Q.endTagWithoutMatchingOpenElement)}}function ci(e,t){e._insertFakeElement(Y.BODY,b.BODY),e.insertionMode=U.IN_BODY,ia(e,t)}function ia(e,t){switch(t.type){case He.CHARACTER:{Sp(e,t);break}case He.WHITESPACE_CHARACTER:{wp(e,t);break}case He.COMMENT:{qo(e,t);break}case He.START_TAG:{wt(e,t);break}case He.END_TAG:{sa(e,t);break}case He.EOF:{Ip(e,t);break}}}function wp(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Sp(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function sA(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function aA(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function oA(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_FRAMESET)}function lA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML)}function uA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Vo.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,ie.HTML)}function cA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function dA(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),n||(e.formElement=e.openElements.current))}function fA(e,t){e.framesetOk=!1;const n=t.tagID;for(let r=e.openElements.stackTop;r>=0;r--){const s=e.openElements.tagIDs[r];if(n===b.LI&&s===b.LI||(n===b.DD||n===b.DT)&&(s===b.DD||s===b.DT)){e.openElements.generateImpliedEndTagsWithExclusion(s),e.openElements.popUntilTagNamePopped(s);break}if(s!==b.ADDRESS&&s!==b.DIV&&s!==b.P&&e._isSpecialElement(e.openElements.items[r],s))break}e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML)}function hA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),e.tokenizer.state=dt.PLAINTEXT}function mA(e,t){e.openElements.hasInScope(b.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(b.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.framesetOk=!1}function pA(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(Y.A);n&&(Zl(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function gA(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function xA(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(b.NOBR)&&(Zl(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,ie.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function bA(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function yA(e,t){e.treeAdapter.getDocumentMode(e.document)!==qt.QUIRKS&&e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),e.framesetOk=!1,e.insertionMode=U.IN_TABLE}function Ap(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ie.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Cp(e){const t=pp(e,Xn.TYPE);return t!=null&&t.toLowerCase()===FS}function EA(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ie.HTML),Cp(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function vA(e,t){e._appendElement(t,ie.HTML),t.ackSelfClosing=!0}function TA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._appendElement(t,ie.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function kA(e,t){t.tagName=Y.IMG,t.tagID=b.IMG,Ap(e,t)}function wA(e,t){e._insertElement(t,ie.HTML),e.skipNextNewLine=!0,e.tokenizer.state=dt.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=U.TEXT}function SA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,dt.RAWTEXT)}function AA(e,t){e.framesetOk=!1,e._switchToTextParsing(t,dt.RAWTEXT)}function kd(e,t){e._switchToTextParsing(t,dt.RAWTEXT)}function CA(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===U.IN_TABLE||e.insertionMode===U.IN_CAPTION||e.insertionMode===U.IN_TABLE_BODY||e.insertionMode===U.IN_ROW||e.insertionMode===U.IN_CELL?U.IN_SELECT_IN_TABLE:U.IN_SELECT}function _A(e,t){e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML)}function IA(e,t){e.openElements.hasInScope(b.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,ie.HTML)}function NA(e,t){e.openElements.hasInScope(b.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(b.RTC),e._insertElement(t,ie.HTML)}function RA(e,t){e._reconstructActiveFormattingElements(),vp(t),Jl(t),t.selfClosing?e._appendElement(t,ie.MATHML):e._insertElement(t,ie.MATHML),t.ackSelfClosing=!0}function LA(e,t){e._reconstructActiveFormattingElements(),Tp(t),Jl(t),t.selfClosing?e._appendElement(t,ie.SVG):e._insertElement(t,ie.SVG),t.ackSelfClosing=!0}function wd(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML)}function wt(e,t){switch(t.tagID){case b.I:case b.S:case b.B:case b.U:case b.EM:case b.TT:case b.BIG:case b.CODE:case b.FONT:case b.SMALL:case b.STRIKE:case b.STRONG:{gA(e,t);break}case b.A:{pA(e,t);break}case b.H1:case b.H2:case b.H3:case b.H4:case b.H5:case b.H6:{uA(e,t);break}case b.P:case b.DL:case b.OL:case b.UL:case b.DIV:case b.DIR:case b.NAV:case b.MAIN:case b.MENU:case b.ASIDE:case b.CENTER:case b.FIGURE:case b.FOOTER:case b.HEADER:case b.HGROUP:case b.DIALOG:case b.DETAILS:case b.ADDRESS:case b.ARTICLE:case b.SEARCH:case b.SECTION:case b.SUMMARY:case b.FIELDSET:case b.BLOCKQUOTE:case b.FIGCAPTION:{lA(e,t);break}case b.LI:case b.DD:case b.DT:{fA(e,t);break}case b.BR:case b.IMG:case b.WBR:case b.AREA:case b.EMBED:case b.KEYGEN:{Ap(e,t);break}case b.HR:{TA(e,t);break}case b.RB:case b.RTC:{IA(e,t);break}case b.RT:case b.RP:{NA(e,t);break}case b.PRE:case b.LISTING:{cA(e,t);break}case b.XMP:{SA(e,t);break}case b.SVG:{LA(e,t);break}case b.HTML:{sA(e,t);break}case b.BASE:case b.LINK:case b.META:case b.STYLE:case b.TITLE:case b.SCRIPT:case b.BGSOUND:case b.BASEFONT:case b.TEMPLATE:{en(e,t);break}case b.BODY:{aA(e,t);break}case b.FORM:{dA(e,t);break}case b.NOBR:{xA(e,t);break}case b.MATH:{RA(e,t);break}case b.TABLE:{yA(e,t);break}case b.INPUT:{EA(e,t);break}case b.PARAM:case b.TRACK:case b.SOURCE:{vA(e,t);break}case b.IMAGE:{kA(e,t);break}case b.BUTTON:{mA(e,t);break}case b.APPLET:case b.OBJECT:case b.MARQUEE:{bA(e,t);break}case b.IFRAME:{AA(e,t);break}case b.SELECT:{CA(e,t);break}case b.OPTION:case b.OPTGROUP:{_A(e,t);break}case b.NOEMBED:case b.NOFRAMES:{kd(e,t);break}case b.FRAMESET:{oA(e,t);break}case b.TEXTAREA:{wA(e,t);break}case b.NOSCRIPT:{e.options.scriptingEnabled?kd(e,t):wd(e,t);break}case b.PLAINTEXT:{hA(e,t);break}case b.COL:case b.TH:case b.TD:case b.TR:case b.HEAD:case b.FRAME:case b.TBODY:case b.TFOOT:case b.THEAD:case b.CAPTION:case b.COLGROUP:break;default:wd(e,t)}}function PA(e,t){if(e.openElements.hasInScope(b.BODY)&&(e.insertionMode=U.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function MA(e,t){e.openElements.hasInScope(b.BODY)&&(e.insertionMode=U.AFTER_BODY,Fp(e,t))}function DA(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function OA(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(b.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(b.FORM):n&&e.openElements.remove(n))}function FA(e){e.openElements.hasInButtonScope(b.P)||e._insertFakeElement(Y.P,b.P),e._closePElement()}function BA(e){e.openElements.hasInListItemScope(b.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(b.LI),e.openElements.popUntilTagNamePopped(b.LI))}function jA(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function HA(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function UA(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function zA(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(Y.BR,b.BR),e.openElements.pop(),e.framesetOk=!1}function _p(e,t){const n=t.tagName,r=t.tagID;for(let s=e.openElements.stackTop;s>0;s--){const i=e.openElements.items[s],a=e.openElements.tagIDs[s];if(r===a&&(r!==b.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=s&&e.openElements.shortenToLength(s);break}if(e._isSpecialElement(i,a))break}}function sa(e,t){switch(t.tagID){case b.A:case b.B:case b.I:case b.S:case b.U:case b.EM:case b.TT:case b.BIG:case b.CODE:case b.FONT:case b.NOBR:case b.SMALL:case b.STRIKE:case b.STRONG:{Zl(e,t);break}case b.P:{FA(e);break}case b.DL:case b.UL:case b.OL:case b.DIR:case b.DIV:case b.NAV:case b.PRE:case b.MAIN:case b.MENU:case b.ASIDE:case b.BUTTON:case b.CENTER:case b.FIGURE:case b.FOOTER:case b.HEADER:case b.HGROUP:case b.DIALOG:case b.ADDRESS:case b.ARTICLE:case b.DETAILS:case b.SEARCH:case b.SECTION:case b.SUMMARY:case b.LISTING:case b.FIELDSET:case b.BLOCKQUOTE:case b.FIGCAPTION:{DA(e,t);break}case b.LI:{BA(e);break}case b.DD:case b.DT:{jA(e,t);break}case b.H1:case b.H2:case b.H3:case b.H4:case b.H5:case b.H6:{HA(e);break}case b.BR:{zA(e);break}case b.BODY:{PA(e,t);break}case b.HTML:{MA(e,t);break}case b.FORM:{OA(e);break}case b.APPLET:case b.OBJECT:case b.MARQUEE:{UA(e,t);break}case b.TEMPLATE:{ir(e,t);break}default:_p(e,t)}}function Ip(e,t){e.tmplInsertionModeStack.length>0?Op(e,t):eu(e,t)}function VA(e,t){var n;t.tagID===b.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function qA(e,t){e._err(t,Q.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Ja(e,t){if(e.openElements.currentTagId!==void 0&&kp.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=U.IN_TABLE_TEXT,t.type){case He.CHARACTER:{Rp(e,t);break}case He.WHITESPACE_CHARACTER:{Np(e,t);break}}else Mi(e,t)}function WA(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_CAPTION}function $A(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_COLUMN_GROUP}function YA(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Y.COLGROUP,b.COLGROUP),e.insertionMode=U.IN_COLUMN_GROUP,tu(e,t)}function GA(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_TABLE_BODY}function KA(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Y.TBODY,b.TBODY),e.insertionMode=U.IN_TABLE_BODY,aa(e,t)}function XA(e,t){e.openElements.hasInTableScope(b.TABLE)&&(e.openElements.popUntilTagNamePopped(b.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function QA(e,t){Cp(t)?e._appendElement(t,ie.HTML):Mi(e,t),t.ackSelfClosing=!0}function JA(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,ie.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function Ar(e,t){switch(t.tagID){case b.TD:case b.TH:case b.TR:{KA(e,t);break}case b.STYLE:case b.SCRIPT:case b.TEMPLATE:{en(e,t);break}case b.COL:{YA(e,t);break}case b.FORM:{JA(e,t);break}case b.TABLE:{XA(e,t);break}case b.TBODY:case b.TFOOT:case b.THEAD:{GA(e,t);break}case b.INPUT:{QA(e,t);break}case b.CAPTION:{WA(e,t);break}case b.COLGROUP:{$A(e,t);break}default:Mi(e,t)}}function ki(e,t){switch(t.tagID){case b.TABLE:{e.openElements.hasInTableScope(b.TABLE)&&(e.openElements.popUntilTagNamePopped(b.TABLE),e._resetInsertionMode());break}case b.TEMPLATE:{ir(e,t);break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:case b.TBODY:case b.TD:case b.TFOOT:case b.TH:case b.THEAD:case b.TR:break;default:Mi(e,t)}}function Mi(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,ia(e,t),e.fosterParentingEnabled=n}function Np(e,t){e.pendingCharacterTokens.push(t)}function Rp(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Gr(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Mi(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Lp=new Set([b.CAPTION,b.COL,b.COLGROUP,b.TBODY,b.TD,b.TFOOT,b.TH,b.THEAD,b.TR]);function ZA(e,t){const n=t.tagID;Lp.has(n)?e.openElements.hasInTableScope(b.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(b.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,Ar(e,t)):wt(e,t)}function eC(e,t){const n=t.tagID;switch(n){case b.CAPTION:case b.TABLE:{e.openElements.hasInTableScope(b.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(b.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,n===b.TABLE&&ki(e,t));break}case b.BODY:case b.COL:case b.COLGROUP:case b.HTML:case b.TBODY:case b.TD:case b.TFOOT:case b.TH:case b.THEAD:case b.TR:break;default:sa(e,t)}}function tu(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.COL:{e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.TEMPLATE:{en(e,t);break}default:Ls(e,t)}}function tC(e,t){switch(t.tagID){case b.COLGROUP:{e.openElements.currentTagId===b.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case b.TEMPLATE:{ir(e,t);break}case b.COL:break;default:Ls(e,t)}}function Ls(e,t){e.openElements.currentTagId===b.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE,e._processToken(t))}function aa(e,t){switch(t.tagID){case b.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_ROW;break}case b.TH:case b.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(Y.TR,b.TR),e.insertionMode=U.IN_ROW,oa(e,t);break}case b.CAPTION:case b.COL:case b.COLGROUP:case b.TBODY:case b.TFOOT:case b.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,Ar(e,t));break}default:Ar(e,t)}}function Wo(e,t){const n=t.tagID;switch(t.tagID){case b.TBODY:case b.TFOOT:case b.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case b.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,ki(e,t));break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:case b.TD:case b.TH:case b.TR:break;default:ki(e,t)}}function oa(e,t){switch(t.tagID){case b.TH:case b.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_CELL,e.activeFormattingElements.insertMarker();break}case b.CAPTION:case b.COL:case b.COLGROUP:case b.TBODY:case b.TFOOT:case b.THEAD:case b.TR:{e.openElements.hasInTableScope(b.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,aa(e,t));break}default:Ar(e,t)}}function Pp(e,t){switch(t.tagID){case b.TR:{e.openElements.hasInTableScope(b.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY);break}case b.TABLE:{e.openElements.hasInTableScope(b.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,Wo(e,t));break}case b.TBODY:case b.TFOOT:case b.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(b.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,Wo(e,t));break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:case b.TD:case b.TH:break;default:ki(e,t)}}function nC(e,t){const n=t.tagID;Lp.has(n)?(e.openElements.hasInTableScope(b.TD)||e.openElements.hasInTableScope(b.TH))&&(e._closeTableCell(),oa(e,t)):wt(e,t)}function rC(e,t){const n=t.tagID;switch(n){case b.TD:case b.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_ROW);break}case b.TABLE:case b.TBODY:case b.TFOOT:case b.THEAD:case b.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),Pp(e,t));break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:break;default:sa(e,t)}}function Mp(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.OPTION:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e._insertElement(t,ie.HTML);break}case b.OPTGROUP:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e.openElements.currentTagId===b.OPTGROUP&&e.openElements.pop(),e._insertElement(t,ie.HTML);break}case b.HR:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e.openElements.currentTagId===b.OPTGROUP&&e.openElements.pop(),e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.INPUT:case b.KEYGEN:case b.TEXTAREA:case b.SELECT:{e.openElements.hasInSelectScope(b.SELECT)&&(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode(),t.tagID!==b.SELECT&&e._processStartTag(t));break}case b.SCRIPT:case b.TEMPLATE:{en(e,t);break}}}function Dp(e,t){switch(t.tagID){case b.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===b.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===b.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===b.OPTGROUP&&e.openElements.pop();break}case b.OPTION:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop();break}case b.SELECT:{e.openElements.hasInSelectScope(b.SELECT)&&(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode());break}case b.TEMPLATE:{ir(e,t);break}}}function iC(e,t){const n=t.tagID;n===b.CAPTION||n===b.TABLE||n===b.TBODY||n===b.TFOOT||n===b.THEAD||n===b.TR||n===b.TD||n===b.TH?(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode(),e._processStartTag(t)):Mp(e,t)}function sC(e,t){const n=t.tagID;n===b.CAPTION||n===b.TABLE||n===b.TBODY||n===b.TFOOT||n===b.THEAD||n===b.TR||n===b.TD||n===b.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Dp(e,t)}function aC(e,t){switch(t.tagID){case b.BASE:case b.BASEFONT:case b.BGSOUND:case b.LINK:case b.META:case b.NOFRAMES:case b.SCRIPT:case b.STYLE:case b.TEMPLATE:case b.TITLE:{en(e,t);break}case b.CAPTION:case b.COLGROUP:case b.TBODY:case b.TFOOT:case b.THEAD:{e.tmplInsertionModeStack[0]=U.IN_TABLE,e.insertionMode=U.IN_TABLE,Ar(e,t);break}case b.COL:{e.tmplInsertionModeStack[0]=U.IN_COLUMN_GROUP,e.insertionMode=U.IN_COLUMN_GROUP,tu(e,t);break}case b.TR:{e.tmplInsertionModeStack[0]=U.IN_TABLE_BODY,e.insertionMode=U.IN_TABLE_BODY,aa(e,t);break}case b.TD:case b.TH:{e.tmplInsertionModeStack[0]=U.IN_ROW,e.insertionMode=U.IN_ROW,oa(e,t);break}default:e.tmplInsertionModeStack[0]=U.IN_BODY,e.insertionMode=U.IN_BODY,wt(e,t)}}function oC(e,t){t.tagID===b.TEMPLATE&&ir(e,t)}function Op(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(b.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):eu(e,t)}function lC(e,t){t.tagID===b.HTML?wt(e,t):Ps(e,t)}function Fp(e,t){var n;if(t.tagID===b.HTML){if(e.fragmentContext||(e.insertionMode=U.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===b.HTML){e._setEndLocation(e.openElements.items[0],t);const r=e.openElements.items[1];r&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(r))===null||n===void 0)&&n.endTag)&&e._setEndLocation(r,t)}}else Ps(e,t)}function Ps(e,t){e.insertionMode=U.IN_BODY,ia(e,t)}function uC(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.FRAMESET:{e._insertElement(t,ie.HTML);break}case b.FRAME:{e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.NOFRAMES:{en(e,t);break}}}function cC(e,t){t.tagID===b.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==b.FRAMESET&&(e.insertionMode=U.AFTER_FRAMESET))}function dC(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.NOFRAMES:{en(e,t);break}}}function fC(e,t){t.tagID===b.HTML&&(e.insertionMode=U.AFTER_AFTER_FRAMESET)}function hC(e,t){t.tagID===b.HTML?wt(e,t):ms(e,t)}function ms(e,t){e.insertionMode=U.IN_BODY,ia(e,t)}function mC(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.NOFRAMES:{en(e,t);break}}}function pC(e,t){t.chars=ot,e._insertCharacters(t)}function gC(e,t){e._insertCharacters(t),e.framesetOk=!1}function Bp(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==ie.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function xC(e,t){if(LS(t))Bp(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===ie.MATHML?vp(t):r===ie.SVG&&(PS(t),Tp(t)),Jl(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function bC(e,t){if(t.tagID===b.P||t.tagID===b.BR){Bp(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===ie.HTML){e._endTagOutsideForeignContent(t);break}const s=e.treeAdapter.getTagName(r);if(s.toLowerCase()===t.tagName){t.tagName=s,e.openElements.shortenToLength(n);break}}}Y.AREA,Y.BASE,Y.BASEFONT,Y.BGSOUND,Y.BR,Y.COL,Y.EMBED,Y.FRAME,Y.HR,Y.IMG,Y.INPUT,Y.KEYGEN,Y.LINK,Y.META,Y.PARAM,Y.SOURCE,Y.TRACK,Y.WBR;const yC=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,EC=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),Sd={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function jp(e,t){const n=NC(e),r=Um("type",{handlers:{root:vC,element:TC,text:kC,comment:Up,doctype:wC,raw:AC},unknown:CC}),s={parser:n?new Td(Sd):Td.getFragmentParser(void 0,Sd),handle(o){r(o,s)},stitches:!1,options:t||{}};r(e,s),Pr(s,un());const i=n?s.parser.document:s.parser.getFragment(),a=Rw(i,{file:s.options.file});return s.stitches&&ra(a,"comment",function(o,l,u){const c=o;if(c.value.stitch&&u&&l!==void 0){const f=u.children;return f[l]=c.value.stitch,l}}),a.type==="root"&&a.children.length===1&&a.children[0].type===e.type?a.children[0]:a}function Hp(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function vC(e,t){Hp(e.children,t)}function TC(e,t){_C(e,t),Hp(e.children,t),IC(e,t)}function kC(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:He.CHARACTER,chars:e.value,location:Di(e)};Pr(t,un(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function wC(e,t){const n={type:He.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Di(e)};Pr(t,un(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function SC(e,t){t.stitches=!0;const n=RC(e);if("children"in e&&"children"in n){const r=jp({type:"root",children:e.children},t.options);n.children=r.children}Up({type:"comment",value:{stitch:n}},t)}function Up(e,t){const n=e.value,r={type:He.COMMENT,data:n,location:Di(e)};Pr(t,un(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function AC(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,zp(t,un(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(yC,"&lt;$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const n=t.parser.tokenizer._consume();t.parser.tokenizer._callState(n)}}function CC(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))SC(n,t);else{let r="";throw EC.has(n.type)&&(r=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),new Error("Cannot compile `"+n.type+"` node"+r)}}function Pr(e,t){zp(e,t);const n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=dt.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function zp(e,t){if(t&&t.offset!==void 0){const n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function _C(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===dt.PLAINTEXT)return;Pr(t,un(e));const r=t.parser.openElements.current;let s="namespaceURI"in r?r.namespaceURI:qn.html;s===qn.html&&n==="svg"&&(s=qn.svg);const i=Ow({...e,children:[]},{space:s===qn.svg?"svg":"html"}),a={type:He.START_TAG,tagName:n,tagID:Lr(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:Di(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function IC(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&qw.includes(n)||t.parser.tokenizer.state===dt.PLAINTEXT)return;Pr(t,Qs(e));const r={type:He.END_TAG,tagName:n,tagID:Lr(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Di(e)};t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===dt.RCDATA||t.parser.tokenizer.state===dt.RAWTEXT||t.parser.tokenizer.state===dt.SCRIPT_DATA)&&(t.parser.tokenizer.state=dt.DATA)}function NC(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Di(e){const t=un(e)||{line:void 0,column:void 0,offset:void 0},n=Qs(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function RC(e){return"children"in e?nr({...e,children:[]}):nr(e)}function Vp(e){return function(t,n){return jp(t,{...e,file:n})}}const Bn=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],di={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Bn,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Bn],h2:[["className","sr-only"]],img:[...Bn,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Bn,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Bn],table:[...Bn],ul:[...Bn,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},kn={}.hasOwnProperty;function LC(e,t){let n={type:"root",children:[]};const r={schema:t?{...di,...t}:di,stack:[]},s=qp(r,e);return s&&(Array.isArray(s)?s.length===1?n=s[0]:n.children=s:n=s),n}function qp(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return PC(e,n);case"doctype":return MC(e,n);case"element":return DC(e,n);case"root":return OC(e,n);case"text":return FC(e,n)}}}function PC(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",r=n.indexOf("-->"),i={type:"comment",value:r<0?n:n.slice(0,r)};return Oi(i,t),i}}function MC(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Oi(n,t),n}}function DC(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const r=Wp(e,t.children),s=BC(e,t.properties);e.stack.pop();let i=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(i=!0,e.schema.ancestors&&kn.call(e.schema.ancestors,n))){const o=e.schema.ancestors[n];let l=-1;for(i=!1;++l<o.length;)e.stack.includes(o[l])&&(i=!0)}if(!i)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;const a={type:"element",tagName:n,properties:s,children:r};return Oi(a,t),a}function OC(e,t){const r={type:"root",children:Wp(e,t.children)};return Oi(r,t),r}function FC(e,t){const r={type:"text",value:typeof t.value=="string"?t.value:""};return Oi(r,t),r}function Wp(e,t){const n=[];if(Array.isArray(t)){const r=t;let s=-1;for(;++s<r.length;){const i=qp(e,r[s]);i&&(Array.isArray(i)?n.push(...i):n.push(i))}}return n}function BC(e,t){const n=e.stack[e.stack.length-1],r=e.schema.attributes,s=e.schema.required,i=r&&kn.call(r,n)?r[n]:void 0,a=r&&kn.call(r,"*")?r["*"]:void 0,o=t&&typeof t=="object"?t:{},l={};let u;for(u in o)if(kn.call(o,u)){const c=o[u];let f=Ad(e,Cd(i,u),u,c);f==null&&(f=Ad(e,Cd(a,u),u,c)),f!=null&&(l[u]=f)}if(s&&kn.call(s,n)){const c=s[n];for(u in c)kn.call(c,u)&&!kn.call(l,u)&&(l[u]=c[u])}return l}function Ad(e,t,n,r){return t?Array.isArray(r)?jC(e,t,n,r):$p(e,t,n,r):void 0}function jC(e,t,n,r){let s=-1;const i=[];for(;++s<r.length;){const a=$p(e,t,n,r[s]);(typeof a=="number"||typeof a=="string")&&i.push(a)}return i}function $p(e,t,n,r){if(!(typeof r!="boolean"&&typeof r!="number"&&typeof r!="string")&&HC(e,n,r)){if(typeof t=="object"&&t.length>1){let s=!1,i=0;for(;++i<t.length;){const a=t[i];if(a&&typeof a=="object"&&"flags"in a){if(a.test(String(r))){s=!0;break}}else if(a===r){s=!0;break}}if(!s)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function HC(e,t,n){const r=e.schema.protocols&&kn.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;const s=String(n),i=s.indexOf(":"),a=s.indexOf("?"),o=s.indexOf("#"),l=s.indexOf("/");if(i<0||l>-1&&i>l||a>-1&&i>a||o>-1&&i>o)return!0;let u=-1;for(;++u<r.length;){const c=r[u];if(i===c.length&&s.slice(0,c.length)===c)return!0}return!1}function Oi(e,t){const n=lm(t);t.data&&(e.data=nr(t.data)),n&&(e.position=n)}function Cd(e,t){let n,r=-1;if(e)for(;++r<e.length;){const s=e[r],i=typeof s=="string"?s:s[0];if(i===t)return s;i==="data*"&&(n=s)}if(t.length>4&&t.slice(0,4).toLowerCase()==="data")return n}function Yp(e){return function(t){return LC(t,e)}}var kh;const Gp={...di,protocols:{...di.protocols,src:[...((kh=di.protocols)==null?void 0:kh.src)??["http","https","mailto"],"data"]}},UC={remarkPlugins:[op],rehypePlugins:[Vp,[Yp,Gp]]};let ti=null,_d=null;function zC(){return ti?Promise.resolve(ti):(_d??(_d=Promise.all([we(()=>import("./index-5UvRMS_e.js"),__vite__mapDeps([3,1,2]),import.meta.url),we(()=>import("./index-DtMB_WdP.js"),__vite__mapDeps([4,1,2]),import.meta.url)]).then(([{default:e},{default:t}])=>(ti={remarkPlugins:[op,e],rehypePlugins:[Vp,[Yp,Gp],t]},ti))),_d)}function VC(e){return e.includes("$")||e.includes("\\(")||e.includes("\\[")}function Kp(e){const[t,n]=k.useState(ti),r=VC(e??"");return k.useEffect(()=>{if(!r||t)return;let s=!0;return zC().then(i=>{s&&n(i)}),()=>{s=!1}},[r,t]),t??UC}function qC({retry:e}){const t=Ke();return x.jsxs("div",{className:"text-body text-warning p-4 flex items-start gap-2",children:[x.jsx(Ll,{className:"w-4 h-4 shrink-0 mt-0.5"}),x.jsxs("span",{children:[t("error.renderFailed")," ",x.jsx("button",{className:"underline ml-1",onClick:e,children:t("error.retry")})]})]})}class WC extends k.Component{constructor(){super(...arguments);Ea(this,"state",{error:null});Ea(this,"retry",()=>this.setState({error:null}))}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("[ErrorBoundary caught]",n,r.componentStack)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.retry):x.jsx(qC,{error:this.state.error,retry:this.retry}):this.props.children}}const Qn=new Set(["。","!","?","!","?",";",";","…"]),$C=new Set([",",",","、",":",":"," "," "]),YC=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}]/u;function Ms(e){return e!=null&&YC.test(String.fromCodePoint(e))}const GC=/(?:[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}](?:\uFE0F|\u200D[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}]|[\u{1F3FB}-\u{1F3FF}])*)$/u,vr=new Set(["”",'"',"」","』","》",")","】","])".slice(0,1)]);function KC(e){let t=e;return t=t.replace(/\r\n?/g,`
465
+ `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}const qn={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},up={}.hasOwnProperty,Nw=Object.prototype;function Rw(e,t){const n=t||{};return Xl({file:n.file||void 0,location:!1,schema:n.space==="svg"?Nn:Ri,verbose:n.verbose||!1},e)}function Xl(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},hs(e,r,n),n}case"#document":case"#document-fragment":{const r=t,s="mode"in r?r.mode==="quirks"||r.mode==="limited-quirks":!1;if(n={type:"root",children:cp(e,t.childNodes),data:{quirksMode:s}},e.file&&e.location){const i=String(e.file),a=Iw(i),o=a.toPoint(0),l=a.toPoint(i.length);n.position={start:o,end:l}}return n}case"#documentType":{const r=t;return n={type:"doctype"},hs(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},hs(e,r,n),n}default:return n=Lw(e,t),n}}function cp(e,t){let n=-1;const r=[];for(;++n<t.length;){const s=Xl(e,t[n]);r.push(s)}return r}function Lw(e,t){const n=e.schema;e.schema=t.namespaceURI===qn.svg?Nn:Ri;let r=-1;const s={};for(;++r<t.attrs.length;){const o=t.attrs[r],l=(o.prefix?o.prefix+":":"")+o.name;up.call(Nw,l)||(s[l]=o.value)}const a=(e.schema.space==="svg"?_w:Cw)(t.tagName,s,cp(e,t.childNodes));if(hs(e,t,a),a.tagName==="template"){const o=t,l=o.sourceCodeLocation,u=l&&l.startTag&&xr(l.startTag),c=l&&l.endTag&&xr(l.endTag),f=Xl(e,o.content);u&&c&&e.file&&(f.position={start:u.end,end:c.start}),a.content=f}return e.schema=n,a}function hs(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=Pw(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function Pw(e,t,n){const r=xr(n);if(t.type==="element"){const s=t.children[t.children.length-1];if(r&&!n.endTag&&s&&s.position&&s.position.end&&(r.end=Object.assign({},s.position.end)),e.verbose){const i={};let a;if(n.attrs)for(a in n.attrs)up.call(n.attrs,a)&&(i[Xs(e.schema,a).property]=xr(n.attrs[a]));n.startTag;const o=xr(n.startTag),l=n.endTag?xr(n.endTag):void 0,u={opening:o};l&&(u.closing=l),u.properties=i,t.data={position:u}}}return r}function xr(e){const t=fd({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=fd({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function fd(e){return e.line&&e.column?e:void 0}const Mw={},Dw={}.hasOwnProperty,dp=Um("type",{handlers:{root:Fw,element:zw,text:Hw,comment:Uw,doctype:jw}});function Ow(e,t){const r=(t||Mw).space;return dp(e,r==="svg"?Nn:Ri)}function Fw(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=Ql(e.children,n,t),Rr(e,n),n}function Bw(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=Ql(e.children,n,t),Rr(e,n),n}function jw(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return Rr(e,t),t}function Hw(e){const t={nodeName:"#text",value:e.value,parentNode:null};return Rr(e,t),t}function Uw(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return Rr(e,t),t}function zw(e,t){const n=t;let r=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(r=Nn);const s=[];let i;if(e.properties){for(i in e.properties)if(i!=="children"&&Dw.call(e.properties,i)){const l=Vw(r,i,e.properties[i]);l&&s.push(l)}}const a=r.space,o={nodeName:e.tagName,tagName:e.tagName,attrs:s,namespaceURI:qn[a],childNodes:[],parentNode:null};return o.childNodes=Ql(e.children,o,r),Rr(e,o),e.tagName==="template"&&e.content&&(o.content=Bw(e.content,r)),o}function Vw(e,t,n){const r=Xs(e,t);if(n===!1||n===null||n===void 0||typeof n=="number"&&Number.isNaN(n)||!n&&r.boolean)return;Array.isArray(n)&&(n=r.commaSeparated?Jh(n):am(n));const s={name:r.attribute,value:n===!0?"":String(n)};if(r.space&&r.space!=="html"&&r.space!=="svg"){const i=s.name.indexOf(":");i<0?s.prefix="":(s.name=s.name.slice(i+1),s.prefix=r.attribute.slice(0,i)),s.namespace=qn[r.space]}return s}function Ql(e,t,n){let r=-1;const s=[];if(e)for(;++r<e.length;){const i=dp(e[r],n);i.parentNode=t,s.push(i)}return s}function Rr(e,t){const n=e.position;n&&n.start&&n.end&&(n.start.offset,n.end.offset,t.sourceCodeLocation={startLine:n.start.line,startCol:n.start.column,startOffset:n.start.offset,endLine:n.end.line,endCol:n.end.column,endOffset:n.end.offset})}const qw=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],Ww=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),ot="�";var O;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(O||(O={}));const Rt={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function fp(e){return e>=55296&&e<=57343}function $w(e){return e>=56320&&e<=57343}function Yw(e,t){return(e-55296)*1024+9216+t}function hp(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function mp(e){return e>=64976&&e<=65007||Ww.has(e)}var Q;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(Q||(Q={}));const Gw=65536;class Kw{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=Gw,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,n){const{line:r,col:s,offset:i}=this,a=s+n,o=i+n;return{code:t,startLine:r,endLine:r,startCol:a,endCol:a,startOffset:o,endOffset:o}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const n=this.html.charCodeAt(this.pos+1);if($w(n))return this.pos++,this._addGap(),Yw(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,O.EOF;return this._err(Q.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,n){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=n}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,n){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(t,this.pos);for(let r=0;r<t.length;r++)if((this.html.charCodeAt(this.pos+r)|32)!==t.charCodeAt(r))return!1;return!0}peek(t){const n=this.pos+t;if(n>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,O.EOF;const r=this.html.charCodeAt(n);return r===O.CARRIAGE_RETURN?O.LINE_FEED:r}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,O.EOF;let t=this.html.charCodeAt(this.pos);return t===O.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,O.LINE_FEED):t===O.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,fp(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===O.LINE_FEED||t===O.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){hp(t)?this._err(Q.controlCharacterInInputStream):mp(t)&&this._err(Q.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var He;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(He||(He={}));function pp(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}const Xw=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),Qw=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function Jw(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=Qw.get(e))!==null&&t!==void 0?t:e}var xt;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(xt||(xt={}));const Zw=32;var wn;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(wn||(wn={}));function zo(e){return e>=xt.ZERO&&e<=xt.NINE}function eS(e){return e>=xt.UPPER_A&&e<=xt.UPPER_F||e>=xt.LOWER_A&&e<=xt.LOWER_F}function tS(e){return e>=xt.UPPER_A&&e<=xt.UPPER_Z||e>=xt.LOWER_A&&e<=xt.LOWER_Z||zo(e)}function nS(e){return e===xt.EQUALS||tS(e)}var gt;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(gt||(gt={}));var xn;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(xn||(xn={}));class rS{constructor(t,n,r){this.decodeTree=t,this.emitCodePoint=n,this.errors=r,this.state=gt.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=xn.Strict}startEntity(t){this.decodeMode=t,this.state=gt.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case gt.EntityStart:return t.charCodeAt(n)===xt.NUM?(this.state=gt.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=gt.NamedEntity,this.stateNamedEntity(t,n));case gt.NumericStart:return this.stateNumericStart(t,n);case gt.NumericDecimal:return this.stateNumericDecimal(t,n);case gt.NumericHex:return this.stateNumericHex(t,n);case gt.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|Zw)===xt.LOWER_X?(this.state=gt.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=gt.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,r,s){if(n!==r){const i=r-n;this.result=this.result*Math.pow(s,i)+Number.parseInt(t.substr(n,i),s),this.consumed+=i}}stateNumericHex(t,n){const r=n;for(;n<t.length;){const s=t.charCodeAt(n);if(zo(s)||eS(s))n+=1;else return this.addToNumericResult(t,r,n,16),this.emitNumericEntity(s,3)}return this.addToNumericResult(t,r,n,16),-1}stateNumericDecimal(t,n){const r=n;for(;n<t.length;){const s=t.charCodeAt(n);if(zo(s))n+=1;else return this.addToNumericResult(t,r,n,10),this.emitNumericEntity(s,2)}return this.addToNumericResult(t,r,n,10),-1}emitNumericEntity(t,n){var r;if(this.consumed<=n)return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===xt.SEMI)this.consumed+=1;else if(this.decodeMode===xn.Strict)return 0;return this.emitCodePoint(Jw(this.result),this.consumed),this.errors&&(t!==xt.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){const{decodeTree:r}=this;let s=r[this.treeIndex],i=(s&wn.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const a=t.charCodeAt(n);if(this.treeIndex=iS(r,s,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===xn.Attribute&&(i===0||nS(a))?0:this.emitNotTerminatedNamedEntity();if(s=r[this.treeIndex],i=(s&wn.VALUE_LENGTH)>>14,i!==0){if(a===xt.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==xn.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:n,decodeTree:r}=this,s=(r[n]&wn.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,s,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,r){const{decodeTree:s}=this;return this.emitCodePoint(n===1?s[t]&~wn.VALUE_LENGTH:s[t+1],r),n===3&&this.emitCodePoint(s[t+2],r),r}end(){var t;switch(this.state){case gt.NamedEntity:return this.result!==0&&(this.decodeMode!==xn.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case gt.NumericDecimal:return this.emitNumericEntity(0,2);case gt.NumericHex:return this.emitNumericEntity(0,3);case gt.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case gt.EntityStart:return 0}}}function iS(e,t,n,r){const s=(t&wn.BRANCH_LENGTH)>>7,i=t&wn.JUMP_TABLE;if(s===0)return i!==0&&r===i?n:-1;if(i){const l=r-i;return l<0||l>=s?-1:e[n+l]-1}let a=n,o=a+s-1;for(;a<=o;){const l=a+o>>>1,u=e[l];if(u<r)a=l+1;else if(u>r)o=l-1;else return e[l+s]}return-1}var ie;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(ie||(ie={}));var Xn;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(Xn||(Xn={}));var qt;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(qt||(qt={}));var Y;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(Y||(Y={}));var b;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(b||(b={}));const sS=new Map([[Y.A,b.A],[Y.ADDRESS,b.ADDRESS],[Y.ANNOTATION_XML,b.ANNOTATION_XML],[Y.APPLET,b.APPLET],[Y.AREA,b.AREA],[Y.ARTICLE,b.ARTICLE],[Y.ASIDE,b.ASIDE],[Y.B,b.B],[Y.BASE,b.BASE],[Y.BASEFONT,b.BASEFONT],[Y.BGSOUND,b.BGSOUND],[Y.BIG,b.BIG],[Y.BLOCKQUOTE,b.BLOCKQUOTE],[Y.BODY,b.BODY],[Y.BR,b.BR],[Y.BUTTON,b.BUTTON],[Y.CAPTION,b.CAPTION],[Y.CENTER,b.CENTER],[Y.CODE,b.CODE],[Y.COL,b.COL],[Y.COLGROUP,b.COLGROUP],[Y.DD,b.DD],[Y.DESC,b.DESC],[Y.DETAILS,b.DETAILS],[Y.DIALOG,b.DIALOG],[Y.DIR,b.DIR],[Y.DIV,b.DIV],[Y.DL,b.DL],[Y.DT,b.DT],[Y.EM,b.EM],[Y.EMBED,b.EMBED],[Y.FIELDSET,b.FIELDSET],[Y.FIGCAPTION,b.FIGCAPTION],[Y.FIGURE,b.FIGURE],[Y.FONT,b.FONT],[Y.FOOTER,b.FOOTER],[Y.FOREIGN_OBJECT,b.FOREIGN_OBJECT],[Y.FORM,b.FORM],[Y.FRAME,b.FRAME],[Y.FRAMESET,b.FRAMESET],[Y.H1,b.H1],[Y.H2,b.H2],[Y.H3,b.H3],[Y.H4,b.H4],[Y.H5,b.H5],[Y.H6,b.H6],[Y.HEAD,b.HEAD],[Y.HEADER,b.HEADER],[Y.HGROUP,b.HGROUP],[Y.HR,b.HR],[Y.HTML,b.HTML],[Y.I,b.I],[Y.IMG,b.IMG],[Y.IMAGE,b.IMAGE],[Y.INPUT,b.INPUT],[Y.IFRAME,b.IFRAME],[Y.KEYGEN,b.KEYGEN],[Y.LABEL,b.LABEL],[Y.LI,b.LI],[Y.LINK,b.LINK],[Y.LISTING,b.LISTING],[Y.MAIN,b.MAIN],[Y.MALIGNMARK,b.MALIGNMARK],[Y.MARQUEE,b.MARQUEE],[Y.MATH,b.MATH],[Y.MENU,b.MENU],[Y.META,b.META],[Y.MGLYPH,b.MGLYPH],[Y.MI,b.MI],[Y.MO,b.MO],[Y.MN,b.MN],[Y.MS,b.MS],[Y.MTEXT,b.MTEXT],[Y.NAV,b.NAV],[Y.NOBR,b.NOBR],[Y.NOFRAMES,b.NOFRAMES],[Y.NOEMBED,b.NOEMBED],[Y.NOSCRIPT,b.NOSCRIPT],[Y.OBJECT,b.OBJECT],[Y.OL,b.OL],[Y.OPTGROUP,b.OPTGROUP],[Y.OPTION,b.OPTION],[Y.P,b.P],[Y.PARAM,b.PARAM],[Y.PLAINTEXT,b.PLAINTEXT],[Y.PRE,b.PRE],[Y.RB,b.RB],[Y.RP,b.RP],[Y.RT,b.RT],[Y.RTC,b.RTC],[Y.RUBY,b.RUBY],[Y.S,b.S],[Y.SCRIPT,b.SCRIPT],[Y.SEARCH,b.SEARCH],[Y.SECTION,b.SECTION],[Y.SELECT,b.SELECT],[Y.SOURCE,b.SOURCE],[Y.SMALL,b.SMALL],[Y.SPAN,b.SPAN],[Y.STRIKE,b.STRIKE],[Y.STRONG,b.STRONG],[Y.STYLE,b.STYLE],[Y.SUB,b.SUB],[Y.SUMMARY,b.SUMMARY],[Y.SUP,b.SUP],[Y.TABLE,b.TABLE],[Y.TBODY,b.TBODY],[Y.TEMPLATE,b.TEMPLATE],[Y.TEXTAREA,b.TEXTAREA],[Y.TFOOT,b.TFOOT],[Y.TD,b.TD],[Y.TH,b.TH],[Y.THEAD,b.THEAD],[Y.TITLE,b.TITLE],[Y.TR,b.TR],[Y.TRACK,b.TRACK],[Y.TT,b.TT],[Y.U,b.U],[Y.UL,b.UL],[Y.SVG,b.SVG],[Y.VAR,b.VAR],[Y.WBR,b.WBR],[Y.XMP,b.XMP]]);function Lr(e){var t;return(t=sS.get(e))!==null&&t!==void 0?t:b.UNKNOWN}const ae=b,aS={[ie.HTML]:new Set([ae.ADDRESS,ae.APPLET,ae.AREA,ae.ARTICLE,ae.ASIDE,ae.BASE,ae.BASEFONT,ae.BGSOUND,ae.BLOCKQUOTE,ae.BODY,ae.BR,ae.BUTTON,ae.CAPTION,ae.CENTER,ae.COL,ae.COLGROUP,ae.DD,ae.DETAILS,ae.DIR,ae.DIV,ae.DL,ae.DT,ae.EMBED,ae.FIELDSET,ae.FIGCAPTION,ae.FIGURE,ae.FOOTER,ae.FORM,ae.FRAME,ae.FRAMESET,ae.H1,ae.H2,ae.H3,ae.H4,ae.H5,ae.H6,ae.HEAD,ae.HEADER,ae.HGROUP,ae.HR,ae.HTML,ae.IFRAME,ae.IMG,ae.INPUT,ae.LI,ae.LINK,ae.LISTING,ae.MAIN,ae.MARQUEE,ae.MENU,ae.META,ae.NAV,ae.NOEMBED,ae.NOFRAMES,ae.NOSCRIPT,ae.OBJECT,ae.OL,ae.P,ae.PARAM,ae.PLAINTEXT,ae.PRE,ae.SCRIPT,ae.SECTION,ae.SELECT,ae.SOURCE,ae.STYLE,ae.SUMMARY,ae.TABLE,ae.TBODY,ae.TD,ae.TEMPLATE,ae.TEXTAREA,ae.TFOOT,ae.TH,ae.THEAD,ae.TITLE,ae.TR,ae.TRACK,ae.UL,ae.WBR,ae.XMP]),[ie.MATHML]:new Set([ae.MI,ae.MO,ae.MN,ae.MS,ae.MTEXT,ae.ANNOTATION_XML]),[ie.SVG]:new Set([ae.TITLE,ae.FOREIGN_OBJECT,ae.DESC]),[ie.XLINK]:new Set,[ie.XML]:new Set,[ie.XMLNS]:new Set},Vo=new Set([ae.H1,ae.H2,ae.H3,ae.H4,ae.H5,ae.H6]);Y.STYLE,Y.SCRIPT,Y.XMP,Y.IFRAME,Y.NOEMBED,Y.NOFRAMES,Y.PLAINTEXT;var H;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(H||(H={}));const dt={DATA:H.DATA,RCDATA:H.RCDATA,RAWTEXT:H.RAWTEXT,SCRIPT_DATA:H.SCRIPT_DATA,PLAINTEXT:H.PLAINTEXT,CDATA_SECTION:H.CDATA_SECTION};function oS(e){return e>=O.DIGIT_0&&e<=O.DIGIT_9}function ei(e){return e>=O.LATIN_CAPITAL_A&&e<=O.LATIN_CAPITAL_Z}function lS(e){return e>=O.LATIN_SMALL_A&&e<=O.LATIN_SMALL_Z}function En(e){return lS(e)||ei(e)}function hd(e){return En(e)||oS(e)}function es(e){return e+32}function gp(e){return e===O.SPACE||e===O.LINE_FEED||e===O.TABULATION||e===O.FORM_FEED}function md(e){return gp(e)||e===O.SOLIDUS||e===O.GREATER_THAN_SIGN}function uS(e){return e===O.NULL?Q.nullCharacterReference:e>1114111?Q.characterReferenceOutsideUnicodeRange:fp(e)?Q.surrogateCharacterReference:mp(e)?Q.noncharacterCharacterReference:hp(e)||e===O.CARRIAGE_RETURN?Q.controlCharacterReference:null}class cS{constructor(t,n){this.options=t,this.handler=n,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=H.DATA,this.returnState=H.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new Kw(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new rS(Xw,(r,s)=>{this.preprocessor.pos=this.entityStartPos+s-1,this._flushCodePointConsumedAsCharacterReference(r)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(Q.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:r=>{this._err(Q.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+r)},validateNumericCharacterReference:r=>{const s=uS(r);s&&this._err(s,1)}}:void 0)}_err(t,n=0){var r,s;(s=(r=this.handler).onParseError)===null||s===void 0||s.call(r,this.preprocessor.getError(t,n))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t==null||t())}write(t,n,r){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||r==null||r()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let n=0;n<t;n++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,n){return this.preprocessor.startsWith(t,n)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:He.START_TAG,tagName:"",tagID:b.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:He.END_TAG,tagName:"",tagID:b.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:He.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:He.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,n){this.currentCharacterToken={type:t,chars:n,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,n;const r=this.currentToken;if(pp(r,this.currentAttr.name)===null){if(r.attrs.push(this.currentAttr),r.location&&this.currentLocation){const s=(t=(n=r.location).attrs)!==null&&t!==void 0?t:n.attrs=Object.create(null);s[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(Q.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(t){this._emitCurrentCharacterToken(t.location),this.currentToken=null,t.location&&(t.location.endLine=this.preprocessor.line,t.location.endCol=this.preprocessor.col+1,t.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const t=this.currentToken;this.prepareToken(t),t.tagID=Lr(t.tagName),t.type===He.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(Q.endTagWithAttributes),t.selfClosing&&this._err(Q.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case He.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case He.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case He.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:He.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=n;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,n)}_emitCodePoint(t){const n=gp(t)?He.WHITESPACE_CHARACTER:t===O.NULL?He.NULL_CHARACTER:He.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(He.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=H.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?xn.Attribute:xn.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===H.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===H.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===H.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case H.DATA:{this._stateData(t);break}case H.RCDATA:{this._stateRcdata(t);break}case H.RAWTEXT:{this._stateRawtext(t);break}case H.SCRIPT_DATA:{this._stateScriptData(t);break}case H.PLAINTEXT:{this._statePlaintext(t);break}case H.TAG_OPEN:{this._stateTagOpen(t);break}case H.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case H.TAG_NAME:{this._stateTagName(t);break}case H.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case H.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case H.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case H.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case H.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case H.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case H.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case H.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case H.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case H.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case H.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case H.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case H.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case H.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case H.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case H.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case H.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case H.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case H.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case H.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case H.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case H.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case H.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case H.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case H.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case H.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case H.BOGUS_COMMENT:{this._stateBogusComment(t);break}case H.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case H.COMMENT_START:{this._stateCommentStart(t);break}case H.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case H.COMMENT:{this._stateComment(t);break}case H.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case H.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case H.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case H.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case H.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case H.COMMENT_END:{this._stateCommentEnd(t);break}case H.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case H.DOCTYPE:{this._stateDoctype(t);break}case H.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case H.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case H.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case H.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case H.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case H.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case H.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case H.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case H.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case H.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case H.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case H.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case H.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case H.CDATA_SECTION:{this._stateCdataSection(t);break}case H.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case H.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case H.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case H.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case O.LESS_THAN_SIGN:{this.state=H.TAG_OPEN;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitCodePoint(t);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case O.AMPERSAND:{this._startCharacterReference();break}case O.LESS_THAN_SIGN:{this.state=H.RCDATA_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case O.LESS_THAN_SIGN:{this.state=H.RAWTEXT_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(En(t))this._createStartTagToken(),this.state=H.TAG_NAME,this._stateTagName(t);else switch(t){case O.EXCLAMATION_MARK:{this.state=H.MARKUP_DECLARATION_OPEN;break}case O.SOLIDUS:{this.state=H.END_TAG_OPEN;break}case O.QUESTION_MARK:{this._err(Q.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=H.BOGUS_COMMENT,this._stateBogusComment(t);break}case O.EOF:{this._err(Q.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(Q.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=H.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(En(t))this._createEndTagToken(),this.state=H.TAG_NAME,this._stateTagName(t);else switch(t){case O.GREATER_THAN_SIGN:{this._err(Q.missingEndTagName),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(Q.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=H.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_ATTRIBUTE_NAME;break}case O.SOLIDUS:{this.state=H.SELF_CLOSING_START_TAG;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentTagToken();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.tagName+=ot;break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(ei(t)?es(t):t)}}_stateRcdataLessThanSign(t){t===O.SOLIDUS?this.state=H.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=H.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){En(t)?(this.state=H.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=H.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const n=this.currentToken;switch(n.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=H.BEFORE_ATTRIBUTE_NAME,!1;case O.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=H.SELF_CLOSING_START_TAG,!1;case O.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=H.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===O.SOLIDUS?this.state=H.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=H.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){En(t)?(this.state=H.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=H.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case O.SOLIDUS:{this.state=H.SCRIPT_DATA_END_TAG_OPEN;break}case O.EXCLAMATION_MARK:{this.state=H.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=H.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){En(t)?(this.state=H.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===O.HYPHEN_MINUS?(this.state=H.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===O.HYPHEN_MINUS?(this.state=H.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=H.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case O.HYPHEN_MINUS:{this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.GREATER_THAN_SIGN:{this.state=H.SCRIPT_DATA,this._emitChars(">");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===O.SOLIDUS?this.state=H.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:En(t)?(this._emitChars("<"),this.state=H.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){En(t)?(this.state=H.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&md(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=H.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case O.HYPHEN_MINUS:{this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.GREATER_THAN_SIGN:{this.state=H.SCRIPT_DATA,this._emitChars(">");break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case O.EOF:{this._err(Q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===O.SOLIDUS?(this.state=H.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&md(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=H.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=H.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.SOLIDUS:case O.GREATER_THAN_SIGN:case O.EOF:{this.state=H.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case O.EQUALS_SIGN:{this._err(Q.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=H.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=H.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:case O.SOLIDUS:case O.GREATER_THAN_SIGN:case O.EOF:{this._leaveAttrName(),this.state=H.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case O.EQUALS_SIGN:{this._leaveAttrName(),this.state=H.BEFORE_ATTRIBUTE_VALUE;break}case O.QUOTATION_MARK:case O.APOSTROPHE:case O.LESS_THAN_SIGN:{this._err(Q.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.name+=ot;break}default:this.currentAttr.name+=String.fromCodePoint(ei(t)?es(t):t)}}_stateAfterAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.SOLIDUS:{this.state=H.SELF_CLOSING_START_TAG;break}case O.EQUALS_SIGN:{this.state=H.BEFORE_ATTRIBUTE_VALUE;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=H.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{this.state=H.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this.state=H.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingAttributeValue),this.state=H.DATA,this.emitCurrentTagToken();break}default:this.state=H.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case O.QUOTATION_MARK:{this.state=H.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case O.APOSTROPHE:{this.state=H.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this._leaveAttrValue(),this.state=H.BEFORE_ATTRIBUTE_NAME;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=H.DATA,this.emitCurrentTagToken();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case O.QUOTATION_MARK:case O.APOSTROPHE:case O.LESS_THAN_SIGN:case O.EQUALS_SIGN:case O.GRAVE_ACCENT:{this._err(Q.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this._leaveAttrValue(),this.state=H.BEFORE_ATTRIBUTE_NAME;break}case O.SOLIDUS:{this._leaveAttrValue(),this.state=H.SELF_CLOSING_START_TAG;break}case O.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=H.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this._err(Q.missingWhitespaceBetweenAttributes),this.state=H.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case O.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=H.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(Q.eofInTag),this._emitEOFToken();break}default:this._err(Q.unexpectedSolidusInTag),this.state=H.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentComment(n);break}case O.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.data+=ot;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(Rt.DASH_DASH,!0)?(this._createCommentToken(Rt.DASH_DASH.length+1),this.state=H.COMMENT_START):this._consumeSequenceIfMatch(Rt.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Rt.DOCTYPE.length+1),this.state=H.DOCTYPE):this._consumeSequenceIfMatch(Rt.CDATA_START,!0)?this.inForeignNode?this.state=H.CDATA_SECTION:(this._err(Q.cdataInHtmlContent),this._createCommentToken(Rt.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=H.BOGUS_COMMENT):this._ensureHibernation()||(this._err(Q.incorrectlyOpenedComment),this._createCommentToken(2),this.state=H.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_START_DASH;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptClosingOfEmptyComment),this.state=H.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=H.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_END;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptClosingOfEmptyComment),this.state=H.DATA,this.emitCurrentComment(n);break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=H.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_END_DASH;break}case O.LESS_THAN_SIGN:{n.data+="<",this.state=H.COMMENT_LESS_THAN_SIGN;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.data+=ot;break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case O.EXCLAMATION_MARK:{n.data+="!",this.state=H.COMMENT_LESS_THAN_SIGN_BANG;break}case O.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=H.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===O.HYPHEN_MINUS?this.state=H.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=H.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===O.HYPHEN_MINUS?this.state=H.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=H.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==O.GREATER_THAN_SIGN&&t!==O.EOF&&this._err(Q.nestedComment),this.state=H.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=H.COMMENT_END;break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=H.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentComment(n);break}case O.EXCLAMATION_MARK:{this.state=H.COMMENT_END_BANG;break}case O.HYPHEN_MINUS:{n.data+="-";break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=H.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case O.HYPHEN_MINUS:{n.data+="--!",this.state=H.COMMENT_END_DASH;break}case O.GREATER_THAN_SIGN:{this._err(Q.incorrectlyClosedComment),this.state=H.DATA,this.emitCurrentComment(n);break}case O.EOF:{this._err(Q.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=H.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this.state=H.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case O.EOF:{this._err(Q.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingWhitespaceBeforeDoctypeName),this.state=H.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(ei(t))this._createDoctypeToken(String.fromCharCode(es(t))),this.state=H.DOCTYPE_NAME;else switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.NULL:{this._err(Q.unexpectedNullCharacter),this._createDoctypeToken(ot),this.state=H.DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=H.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.AFTER_DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.name+=ot;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(ei(t)?es(t):t)}}_stateAfterDoctypeName(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Rt.PUBLIC,!1)?this.state=H.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Rt.SYSTEM,!1)?this.state=H.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(Q.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.QUOTATION_MARK:{this._err(Q.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(Q.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{n.publicId="",this.state=H.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case O.QUOTATION_MARK:{this.state=H.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.publicId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case O.APOSTROPHE:{this.state=H.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.publicId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case O.GREATER_THAN_SIGN:{this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.QUOTATION_MARK:{this._err(Q.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(Q.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.QUOTATION_MARK:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=H.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.QUOTATION_MARK:{this._err(Q.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(Q.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{n.systemId="",this.state=H.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(Q.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.DATA,this.emitCurrentDoctype(n);break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case O.QUOTATION_MARK:{this.state=H.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.systemId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case O.APOSTROPHE:{this.state=H.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.NULL:{this._err(Q.unexpectedNullCharacter),n.systemId+=ot;break}case O.GREATER_THAN_SIGN:{this._err(Q.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.EOF:{this._err(Q.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Q.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=H.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=H.DATA;break}case O.NULL:{this._err(Q.unexpectedNullCharacter);break}case O.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case O.RIGHT_SQUARE_BRACKET:{this.state=H.CDATA_SECTION_BRACKET;break}case O.EOF:{this._err(Q.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===O.RIGHT_SQUARE_BRACKET?this.state=H.CDATA_SECTION_END:(this._emitChars("]"),this.state=H.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case O.GREATER_THAN_SIGN:{this.state=H.DATA;break}case O.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=H.CDATA_SECTION,this._stateCdataSection(t)}}_stateCharacterReference(){let t=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(t<0)if(this.preprocessor.lastChunkWritten)t=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}t===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(O.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&hd(this.preprocessor.peek(1))?H.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){hd(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===O.SEMICOLON&&this._err(Q.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const xp=new Set([b.DD,b.DT,b.LI,b.OPTGROUP,b.OPTION,b.P,b.RB,b.RP,b.RT,b.RTC]),pd=new Set([...xp,b.CAPTION,b.COLGROUP,b.TBODY,b.TD,b.TFOOT,b.TH,b.THEAD,b.TR]),Rs=new Set([b.APPLET,b.CAPTION,b.HTML,b.MARQUEE,b.OBJECT,b.TABLE,b.TD,b.TEMPLATE,b.TH]),dS=new Set([...Rs,b.OL,b.UL]),fS=new Set([...Rs,b.BUTTON]),gd=new Set([b.ANNOTATION_XML,b.MI,b.MN,b.MO,b.MS,b.MTEXT]),xd=new Set([b.DESC,b.FOREIGN_OBJECT,b.TITLE]),hS=new Set([b.TR,b.TEMPLATE,b.HTML]),mS=new Set([b.TBODY,b.TFOOT,b.THEAD,b.TEMPLATE,b.HTML]),pS=new Set([b.TABLE,b.TEMPLATE,b.HTML]),gS=new Set([b.TD,b.TH]);class xS{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,n,r){this.treeAdapter=n,this.handler=r,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=b.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===b.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===ie.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,n){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=n,this.currentTagId=n,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,n,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,n){const r=this._indexOf(t);this.items[r]=n,r===this.stackTop&&(this.current=n)}insertAfter(t,n,r){const s=this._indexOf(t)+1;this.items.splice(s,0,n),this.tagIDs.splice(s,0,r),this.stackTop++,s===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,s===this.stackTop)}popUntilTagNamePopped(t){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(t,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==ie.HTML);this.shortenToLength(Math.max(n,0))}shortenToLength(t){for(;this.stackTop>=t;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop<t)}}popUntilElementPopped(t){const n=this._indexOf(t);this.shortenToLength(Math.max(n,0))}popUntilPopped(t,n){const r=this._indexOfTagNames(t,n);this.shortenToLength(Math.max(r,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Vo,ie.HTML)}popUntilTableCellPopped(){this.popUntilPopped(gS,ie.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,n){for(let r=this.stackTop;r>=0;r--)if(t.has(this.tagIDs[r])&&this.treeAdapter.getNamespaceURI(this.items[r])===n)return r;return-1}clearBackTo(t,n){const r=this._indexOfTagNames(t,n);this.shortenToLength(r+1)}clearBackToTableContext(){this.clearBackTo(pS,ie.HTML)}clearBackToTableBodyContext(){this.clearBackTo(mS,ie.HTML)}clearBackToTableRowContext(){this.clearBackTo(hS,ie.HTML)}remove(t){const n=this._indexOf(t);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===b.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const n=this._indexOf(t)-1;return n>=0?this.items[n]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===b.HTML}hasInDynamicScope(t,n){for(let r=this.stackTop;r>=0;r--){const s=this.tagIDs[r];switch(this.treeAdapter.getNamespaceURI(this.items[r])){case ie.HTML:{if(s===t)return!0;if(n.has(s))return!1;break}case ie.SVG:{if(xd.has(s))return!1;break}case ie.MATHML:{if(gd.has(s))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,Rs)}hasInListItemScope(t){return this.hasInDynamicScope(t,dS)}hasInButtonScope(t){return this.hasInDynamicScope(t,fS)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case ie.HTML:{if(Vo.has(n))return!0;if(Rs.has(n))return!1;break}case ie.SVG:{if(xd.has(n))return!1;break}case ie.MATHML:{if(gd.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===ie.HTML)switch(this.tagIDs[n]){case t:return!0;case b.TABLE:case b.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===ie.HTML)switch(this.tagIDs[t]){case b.TBODY:case b.THEAD:case b.TFOOT:return!0;case b.TABLE:case b.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===ie.HTML)switch(this.tagIDs[n]){case t:return!0;case b.OPTION:case b.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&xp.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&pd.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&pd.has(this.currentTagId);)this.pop()}}const Qa=3;var sn;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(sn||(sn={}));const bd={type:sn.Marker};class bS{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const r=[],s=n.length,i=this.treeAdapter.getTagName(t),a=this.treeAdapter.getNamespaceURI(t);for(let o=0;o<this.entries.length;o++){const l=this.entries[o];if(l.type===sn.Marker)break;const{element:u}=l;if(this.treeAdapter.getTagName(u)===i&&this.treeAdapter.getNamespaceURI(u)===a){const c=this.treeAdapter.getAttrList(u);c.length===s&&r.push({idx:o,attrs:c})}}return r}_ensureNoahArkCondition(t){if(this.entries.length<Qa)return;const n=this.treeAdapter.getAttrList(t),r=this._getNoahArkConditionCandidates(t,n);if(r.length<Qa)return;const s=new Map(n.map(a=>[a.name,a.value]));let i=0;for(let a=0;a<r.length;a++){const o=r[a];o.attrs.every(l=>s.get(l.name)===l.value)&&(i+=1,i>=Qa&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(bd)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:sn.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:sn.Element,element:t,token:n})}removeEntry(t){const n=this.entries.indexOf(t);n!==-1&&this.entries.splice(n,1)}clearToLastMarker(){const t=this.entries.indexOf(bd);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(r=>r.type===sn.Marker||this.treeAdapter.getTagName(r.element)===t);return n&&n.type===sn.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===sn.Element&&n.element===t)}}const vn={createDocument(){return{nodeName:"#document",mode:qt.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,r){const s=e.childNodes.find(i=>i.nodeName==="#documentType");if(s)s.name=t,s.publicId=n,s.systemId=r;else{const i={nodeName:"#documentType",name:t,publicId:n,systemId:r,parentNode:null};vn.appendChild(e,i)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(vn.isTextNode(n)){n.value+=t;return}}vn.appendChild(e,vn.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&vn.isTextNode(r)?r.value+=t:vn.insertBefore(e,vn.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(r=>r.name));for(let r=0;r<t.length;r++)n.has(t[r].name)||e.attrs.push(t[r])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},bp="html",yS="about:legacy-compat",ES="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",yp=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],vS=[...yp,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],TS=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Ep=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],kS=[...Ep,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function yd(e,t){return t.some(n=>e.startsWith(n))}function wS(e){return e.name===bp&&e.publicId===null&&(e.systemId===null||e.systemId===yS)}function SS(e){if(e.name!==bp)return qt.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===ES)return qt.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),TS.has(n))return qt.QUIRKS;let r=t===null?vS:yp;if(yd(n,r))return qt.QUIRKS;if(r=t===null?Ep:kS,yd(n,r))return qt.LIMITED_QUIRKS}return qt.NO_QUIRKS}const Ed={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},AS="definitionurl",CS="definitionURL",_S=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),IS=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:ie.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:ie.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:ie.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:ie.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:ie.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:ie.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:ie.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:ie.XML}],["xml:space",{prefix:"xml",name:"space",namespace:ie.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:ie.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:ie.XMLNS}]]),NS=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),RS=new Set([b.B,b.BIG,b.BLOCKQUOTE,b.BODY,b.BR,b.CENTER,b.CODE,b.DD,b.DIV,b.DL,b.DT,b.EM,b.EMBED,b.H1,b.H2,b.H3,b.H4,b.H5,b.H6,b.HEAD,b.HR,b.I,b.IMG,b.LI,b.LISTING,b.MENU,b.META,b.NOBR,b.OL,b.P,b.PRE,b.RUBY,b.S,b.SMALL,b.SPAN,b.STRONG,b.STRIKE,b.SUB,b.SUP,b.TABLE,b.TT,b.U,b.UL,b.VAR]);function LS(e){const t=e.tagID;return t===b.FONT&&e.attrs.some(({name:r})=>r===Xn.COLOR||r===Xn.SIZE||r===Xn.FACE)||RS.has(t)}function vp(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===AS){e.attrs[t].name=CS;break}}function Tp(e){for(let t=0;t<e.attrs.length;t++){const n=_S.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function Jl(e){for(let t=0;t<e.attrs.length;t++){const n=IS.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function PS(e){const t=NS.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Lr(e.tagName))}function MS(e,t){return t===ie.MATHML&&(e===b.MI||e===b.MO||e===b.MN||e===b.MS||e===b.MTEXT)}function DS(e,t,n){if(t===ie.MATHML&&e===b.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===Xn.ENCODING){const s=n[r].value.toLowerCase();return s===Ed.TEXT_HTML||s===Ed.APPLICATION_XML}}return t===ie.SVG&&(e===b.FOREIGN_OBJECT||e===b.DESC||e===b.TITLE)}function OS(e,t,n,r){return(!r||r===ie.HTML)&&DS(e,t,n)||(!r||r===ie.MATHML)&&MS(e,t)}const FS="hidden",BS=8,jS=3;var U;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(U||(U={}));const HS={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},kp=new Set([b.TABLE,b.TBODY,b.TFOOT,b.THEAD,b.TR]),vd={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:vn,onParseError:null};class Td{constructor(t,n,r=null,s=null){this.fragmentContext=r,this.scriptHandler=s,this.currentToken=null,this.stopped=!1,this.insertionMode=U.INITIAL,this.originalInsertionMode=U.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...vd,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=n??this.treeAdapter.createDocument(),this.tokenizer=new cS(this.options,this),this.activeFormattingElements=new bS(this.treeAdapter),this.fragmentContextID=r?Lr(this.treeAdapter.getTagName(r)):b.UNKNOWN,this._setContextModes(r??this.document,this.fragmentContextID),this.openElements=new xS(this.document,this.treeAdapter,this)}static parse(t,n){const r=new this(n);return r.tokenizer.write(t,!0),r.document}static getFragmentParser(t,n){const r={...vd,...n};t??(t=r.treeAdapter.createElement(Y.TEMPLATE,ie.HTML,[]));const s=r.treeAdapter.createElement("documentmock",ie.HTML,[]),i=new this(r,s,t);return i.fragmentContextID===b.TEMPLATE&&i.tmplInsertionModeStack.unshift(U.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),n=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,n),n}_err(t,n,r){var s;if(!this.onParseError)return;const i=(s=t.location)!==null&&s!==void 0?s:HS,a={code:n,startLine:i.startLine,startCol:i.startCol,startOffset:i.startOffset,endLine:r?i.startLine:i.endLine,endCol:r?i.startCol:i.endCol,endOffset:r?i.startOffset:i.endOffset};this.onParseError(a)}onItemPush(t,n,r){var s,i;(i=(s=this.treeAdapter).onItemPush)===null||i===void 0||i.call(s,t),r&&this.openElements.stackTop>0&&this._setContextModes(t,n)}onItemPop(t,n){var r,s;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(s=(r=this.treeAdapter).onItemPop)===null||s===void 0||s.call(r,t,this.openElements.current),n){let i,a;this.openElements.stackTop===0&&this.fragmentContext?(i=this.fragmentContext,a=this.fragmentContextID):{current:i,currentTagId:a}=this.openElements,this._setContextModes(i,a)}}_setContextModes(t,n){const r=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===ie.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,ie.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=U.TEXT}switchToPlaintextParsing(){this.insertionMode=U.TEXT,this.originalInsertionMode=U.IN_BODY,this.tokenizer.state=dt.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===Y.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==ie.HTML))switch(this.fragmentContextID){case b.TITLE:case b.TEXTAREA:{this.tokenizer.state=dt.RCDATA;break}case b.STYLE:case b.XMP:case b.IFRAME:case b.NOEMBED:case b.NOFRAMES:case b.NOSCRIPT:{this.tokenizer.state=dt.RAWTEXT;break}case b.SCRIPT:{this.tokenizer.state=dt.SCRIPT_DATA;break}case b.PLAINTEXT:{this.tokenizer.state=dt.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",r=t.publicId||"",s=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,r,s),t.location){const a=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));a&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const r=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,r)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const r=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(r??this.document,t)}}_appendElement(t,n){const r=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(r,t.location)}_insertElement(t,n){const r=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(r,t.location),this.openElements.push(r,t.tagID)}_insertFakeElement(t,n){const r=this.treeAdapter.createElement(t,ie.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,ie.HTML,t.attrs),r=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,r),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(Y.HTML,ie.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,b.HTML)}_appendCommentNode(t,n){const r=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,r),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,t.location)}_insertCharacters(t){let n,r;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:r}=this._findFosterParentingLocation(),r?this.treeAdapter.insertTextBefore(n,t.chars,r):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const s=this.treeAdapter.getChildNodes(n),i=r?s.lastIndexOf(r):s.length,a=s[i-1];if(this.treeAdapter.getNodeSourceCodeLocation(a)){const{endLine:l,endCol:u,endOffset:c}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(a,{endLine:l,endCol:u,endOffset:c})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}_adoptNodes(t,n){for(let r=this.treeAdapter.getFirstChild(t);r;r=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(r),this.treeAdapter.appendChild(n,r)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const r=n.location,s=this.treeAdapter.getTagName(t),i=n.type===He.END_TAG&&s===n.tagName?{endTag:{...r},endLine:r.endLine,endCol:r.endCol,endOffset:r.endOffset}:{endLine:r.startLine,endCol:r.startCol,endOffset:r.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,i)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,r;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,r=this.fragmentContextID):{current:n,currentTagId:r}=this.openElements,t.tagID===b.SVG&&this.treeAdapter.getTagName(n)===Y.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===ie.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===b.MGLYPH||t.tagID===b.MALIGNMARK)&&r!==void 0&&!this._isIntegrationPoint(r,n,ie.HTML)}_processToken(t){switch(t.type){case He.CHARACTER:{this.onCharacter(t);break}case He.NULL_CHARACTER:{this.onNullCharacter(t);break}case He.COMMENT:{this.onComment(t);break}case He.DOCTYPE:{this.onDoctype(t);break}case He.START_TAG:{this._processStartTag(t);break}case He.END_TAG:{this.onEndTag(t);break}case He.EOF:{this.onEof(t);break}case He.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,r){const s=this.treeAdapter.getNamespaceURI(n),i=this.treeAdapter.getAttrList(n);return OS(t,s,i,r)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(s=>s.type===sn.Marker||this.openElements.contains(s.element)),r=n===-1?t-1:n-1;for(let s=r;s>=0;s--){const i=this.activeFormattingElements.entries[s];this._insertElement(i.token,this.treeAdapter.getNamespaceURI(i.element)),i.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=U.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(b.P),this.openElements.popUntilTagNamePopped(b.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case b.TR:{this.insertionMode=U.IN_ROW;return}case b.TBODY:case b.THEAD:case b.TFOOT:{this.insertionMode=U.IN_TABLE_BODY;return}case b.CAPTION:{this.insertionMode=U.IN_CAPTION;return}case b.COLGROUP:{this.insertionMode=U.IN_COLUMN_GROUP;return}case b.TABLE:{this.insertionMode=U.IN_TABLE;return}case b.BODY:{this.insertionMode=U.IN_BODY;return}case b.FRAMESET:{this.insertionMode=U.IN_FRAMESET;return}case b.SELECT:{this._resetInsertionModeForSelect(t);return}case b.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case b.HTML:{this.insertionMode=this.headElement?U.AFTER_HEAD:U.BEFORE_HEAD;return}case b.TD:case b.TH:{if(t>0){this.insertionMode=U.IN_CELL;return}break}case b.HEAD:{if(t>0){this.insertionMode=U.IN_HEAD;return}break}}this.insertionMode=U.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const r=this.openElements.tagIDs[n];if(r===b.TEMPLATE)break;if(r===b.TABLE){this.insertionMode=U.IN_SELECT_IN_TABLE;return}}this.insertionMode=U.IN_SELECT}_isElementCausesFosterParenting(t){return kp.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const n=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case b.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===ie.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case b.TABLE:{const r=this.treeAdapter.getParentNode(n);return r?{parent:r,beforeElement:n}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,t,n.beforeElement):this.treeAdapter.appendChild(n.parent,t)}_isSpecialElement(t,n){const r=this.treeAdapter.getNamespaceURI(t);return aS[r].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){gC(this,t);return}switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{ai(this,t);break}case U.BEFORE_HEAD:{oi(this,t);break}case U.IN_HEAD:{li(this,t);break}case U.IN_HEAD_NO_SCRIPT:{ui(this,t);break}case U.AFTER_HEAD:{ci(this,t);break}case U.IN_BODY:case U.IN_CAPTION:case U.IN_CELL:case U.IN_TEMPLATE:{Sp(this,t);break}case U.TEXT:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{Ja(this,t);break}case U.IN_TABLE_TEXT:{Rp(this,t);break}case U.IN_COLUMN_GROUP:{Ls(this,t);break}case U.AFTER_BODY:{Ps(this,t);break}case U.AFTER_AFTER_BODY:{ms(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){pC(this,t);return}switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{ai(this,t);break}case U.BEFORE_HEAD:{oi(this,t);break}case U.IN_HEAD:{li(this,t);break}case U.IN_HEAD_NO_SCRIPT:{ui(this,t);break}case U.AFTER_HEAD:{ci(this,t);break}case U.TEXT:{this._insertCharacters(t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{Ja(this,t);break}case U.IN_COLUMN_GROUP:{Ls(this,t);break}case U.AFTER_BODY:{Ps(this,t);break}case U.AFTER_AFTER_BODY:{ms(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){qo(this,t);return}switch(this.insertionMode){case U.INITIAL:case U.BEFORE_HTML:case U.BEFORE_HEAD:case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:case U.IN_BODY:case U.IN_TABLE:case U.IN_CAPTION:case U.IN_COLUMN_GROUP:case U.IN_TABLE_BODY:case U.IN_ROW:case U.IN_CELL:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:case U.IN_TEMPLATE:case U.IN_FRAMESET:case U.AFTER_FRAMESET:{qo(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.AFTER_BODY:{YS(this,t);break}case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{GS(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case U.INITIAL:{KS(this,t);break}case U.BEFORE_HEAD:case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:{this._err(t,Q.misplacedDoctype);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,Q.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?xC(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{XS(this,t);break}case U.BEFORE_HEAD:{JS(this,t);break}case U.IN_HEAD:{en(this,t);break}case U.IN_HEAD_NO_SCRIPT:{tA(this,t);break}case U.AFTER_HEAD:{rA(this,t);break}case U.IN_BODY:{wt(this,t);break}case U.IN_TABLE:{Ar(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.IN_CAPTION:{ZA(this,t);break}case U.IN_COLUMN_GROUP:{tu(this,t);break}case U.IN_TABLE_BODY:{aa(this,t);break}case U.IN_ROW:{oa(this,t);break}case U.IN_CELL:{nC(this,t);break}case U.IN_SELECT:{Mp(this,t);break}case U.IN_SELECT_IN_TABLE:{iC(this,t);break}case U.IN_TEMPLATE:{aC(this,t);break}case U.AFTER_BODY:{lC(this,t);break}case U.IN_FRAMESET:{uC(this,t);break}case U.AFTER_FRAMESET:{dC(this,t);break}case U.AFTER_AFTER_BODY:{hC(this,t);break}case U.AFTER_AFTER_FRAMESET:{mC(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?bC(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{QS(this,t);break}case U.BEFORE_HEAD:{ZS(this,t);break}case U.IN_HEAD:{eA(this,t);break}case U.IN_HEAD_NO_SCRIPT:{nA(this,t);break}case U.AFTER_HEAD:{iA(this,t);break}case U.IN_BODY:{sa(this,t);break}case U.TEXT:{VA(this,t);break}case U.IN_TABLE:{ki(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.IN_CAPTION:{eC(this,t);break}case U.IN_COLUMN_GROUP:{tC(this,t);break}case U.IN_TABLE_BODY:{Wo(this,t);break}case U.IN_ROW:{Pp(this,t);break}case U.IN_CELL:{rC(this,t);break}case U.IN_SELECT:{Dp(this,t);break}case U.IN_SELECT_IN_TABLE:{sC(this,t);break}case U.IN_TEMPLATE:{oC(this,t);break}case U.AFTER_BODY:{Fp(this,t);break}case U.IN_FRAMESET:{cC(this,t);break}case U.AFTER_FRAMESET:{fC(this,t);break}case U.AFTER_AFTER_BODY:{ms(this,t);break}}}onEof(t){switch(this.insertionMode){case U.INITIAL:{Yr(this,t);break}case U.BEFORE_HTML:{ai(this,t);break}case U.BEFORE_HEAD:{oi(this,t);break}case U.IN_HEAD:{li(this,t);break}case U.IN_HEAD_NO_SCRIPT:{ui(this,t);break}case U.AFTER_HEAD:{ci(this,t);break}case U.IN_BODY:case U.IN_TABLE:case U.IN_CAPTION:case U.IN_COLUMN_GROUP:case U.IN_TABLE_BODY:case U.IN_ROW:case U.IN_CELL:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:{Ip(this,t);break}case U.TEXT:{qA(this,t);break}case U.IN_TABLE_TEXT:{Gr(this,t);break}case U.IN_TEMPLATE:{Op(this,t);break}case U.AFTER_BODY:case U.IN_FRAMESET:case U.AFTER_FRAMESET:case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{eu(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===O.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:case U.TEXT:case U.IN_COLUMN_GROUP:case U.IN_SELECT:case U.IN_SELECT_IN_TABLE:case U.IN_FRAMESET:case U.AFTER_FRAMESET:{this._insertCharacters(t);break}case U.IN_BODY:case U.IN_CAPTION:case U.IN_CELL:case U.IN_TEMPLATE:case U.AFTER_BODY:case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{wp(this,t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{Ja(this,t);break}case U.IN_TABLE_TEXT:{Np(this,t);break}}}}function US(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):_p(e,t),n}function zS(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){const s=e.openElements.items[r];if(s===t.element)break;e._isSpecialElement(s,e.openElements.tagIDs[r])&&(n=s)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function VS(e,t,n){let r=t,s=e.openElements.getCommonAncestor(t);for(let i=0,a=s;a!==n;i++,a=s){s=e.openElements.getCommonAncestor(a);const o=e.activeFormattingElements.getElementEntry(a),l=o&&i>=jS;!o||l?(l&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(a)):(a=qS(e,o),r===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(a,r),r=a)}return r}function qS(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function WS(e,t,n){const r=e.treeAdapter.getTagName(t),s=Lr(r);if(e._isElementCausesFosterParenting(s))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);s===b.TEMPLATE&&i===ie.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function $S(e,t,n){const r=e.treeAdapter.getNamespaceURI(n.element),{token:s}=n,i=e.treeAdapter.createElement(s.tagName,r,s.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,s),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,i,s.tagID)}function Zl(e,t){for(let n=0;n<BS;n++){const r=US(e,t);if(!r)break;const s=zS(e,r);if(!s)break;e.activeFormattingElements.bookmark=r;const i=VS(e,s,r.element),a=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(i),a&&WS(e,a,i),$S(e,s,r)}}function qo(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function YS(e,t){e._appendCommentNode(t,e.openElements.items[0])}function GS(e,t){e._appendCommentNode(t,e.document)}function eu(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const r=e.openElements.items[0],s=e.treeAdapter.getNodeSourceCodeLocation(r);if(s&&!s.endTag&&(e._setEndLocation(r,t),e.openElements.stackTop>=1)){const i=e.openElements.items[1],a=e.treeAdapter.getNodeSourceCodeLocation(i);a&&!a.endTag&&e._setEndLocation(i,t)}}}}function KS(e,t){e._setDocumentType(t);const n=t.forceQuirks?qt.QUIRKS:SS(t);wS(t)||e._err(t,Q.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=U.BEFORE_HTML}function Yr(e,t){e._err(t,Q.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,qt.QUIRKS),e.insertionMode=U.BEFORE_HTML,e._processToken(t)}function XS(e,t){t.tagID===b.HTML?(e._insertElement(t,ie.HTML),e.insertionMode=U.BEFORE_HEAD):ai(e,t)}function QS(e,t){const n=t.tagID;(n===b.HTML||n===b.HEAD||n===b.BODY||n===b.BR)&&ai(e,t)}function ai(e,t){e._insertFakeRootElement(),e.insertionMode=U.BEFORE_HEAD,e._processToken(t)}function JS(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.HEAD:{e._insertElement(t,ie.HTML),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD;break}default:oi(e,t)}}function ZS(e,t){const n=t.tagID;n===b.HEAD||n===b.BODY||n===b.HTML||n===b.BR?oi(e,t):e._err(t,Q.endTagWithoutMatchingOpenElement)}function oi(e,t){e._insertFakeElement(Y.HEAD,b.HEAD),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD,e._processToken(t)}function en(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.BASE:case b.BASEFONT:case b.BGSOUND:case b.LINK:case b.META:{e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.TITLE:{e._switchToTextParsing(t,dt.RCDATA);break}case b.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,dt.RAWTEXT):(e._insertElement(t,ie.HTML),e.insertionMode=U.IN_HEAD_NO_SCRIPT);break}case b.NOFRAMES:case b.STYLE:{e._switchToTextParsing(t,dt.RAWTEXT);break}case b.SCRIPT:{e._switchToTextParsing(t,dt.SCRIPT_DATA);break}case b.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=U.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(U.IN_TEMPLATE);break}case b.HEAD:{e._err(t,Q.misplacedStartTagForHeadElement);break}default:li(e,t)}}function eA(e,t){switch(t.tagID){case b.HEAD:{e.openElements.pop(),e.insertionMode=U.AFTER_HEAD;break}case b.BODY:case b.BR:case b.HTML:{li(e,t);break}case b.TEMPLATE:{ir(e,t);break}default:e._err(t,Q.endTagWithoutMatchingOpenElement)}}function ir(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==b.TEMPLATE&&e._err(t,Q.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(b.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,Q.endTagWithoutMatchingOpenElement)}function li(e,t){e.openElements.pop(),e.insertionMode=U.AFTER_HEAD,e._processToken(t)}function tA(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.BASEFONT:case b.BGSOUND:case b.HEAD:case b.LINK:case b.META:case b.NOFRAMES:case b.STYLE:{en(e,t);break}case b.NOSCRIPT:{e._err(t,Q.nestedNoscriptInHead);break}default:ui(e,t)}}function nA(e,t){switch(t.tagID){case b.NOSCRIPT:{e.openElements.pop(),e.insertionMode=U.IN_HEAD;break}case b.BR:{ui(e,t);break}default:e._err(t,Q.endTagWithoutMatchingOpenElement)}}function ui(e,t){const n=t.type===He.EOF?Q.openElementsLeftAfterEof:Q.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=U.IN_HEAD,e._processToken(t)}function rA(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.BODY:{e._insertElement(t,ie.HTML),e.framesetOk=!1,e.insertionMode=U.IN_BODY;break}case b.FRAMESET:{e._insertElement(t,ie.HTML),e.insertionMode=U.IN_FRAMESET;break}case b.BASE:case b.BASEFONT:case b.BGSOUND:case b.LINK:case b.META:case b.NOFRAMES:case b.SCRIPT:case b.STYLE:case b.TEMPLATE:case b.TITLE:{e._err(t,Q.abandonedHeadElementChild),e.openElements.push(e.headElement,b.HEAD),en(e,t),e.openElements.remove(e.headElement);break}case b.HEAD:{e._err(t,Q.misplacedStartTagForHeadElement);break}default:ci(e,t)}}function iA(e,t){switch(t.tagID){case b.BODY:case b.HTML:case b.BR:{ci(e,t);break}case b.TEMPLATE:{ir(e,t);break}default:e._err(t,Q.endTagWithoutMatchingOpenElement)}}function ci(e,t){e._insertFakeElement(Y.BODY,b.BODY),e.insertionMode=U.IN_BODY,ia(e,t)}function ia(e,t){switch(t.type){case He.CHARACTER:{Sp(e,t);break}case He.WHITESPACE_CHARACTER:{wp(e,t);break}case He.COMMENT:{qo(e,t);break}case He.START_TAG:{wt(e,t);break}case He.END_TAG:{sa(e,t);break}case He.EOF:{Ip(e,t);break}}}function wp(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Sp(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function sA(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function aA(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function oA(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_FRAMESET)}function lA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML)}function uA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Vo.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,ie.HTML)}function cA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function dA(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),n||(e.formElement=e.openElements.current))}function fA(e,t){e.framesetOk=!1;const n=t.tagID;for(let r=e.openElements.stackTop;r>=0;r--){const s=e.openElements.tagIDs[r];if(n===b.LI&&s===b.LI||(n===b.DD||n===b.DT)&&(s===b.DD||s===b.DT)){e.openElements.generateImpliedEndTagsWithExclusion(s),e.openElements.popUntilTagNamePopped(s);break}if(s!==b.ADDRESS&&s!==b.DIV&&s!==b.P&&e._isSpecialElement(e.openElements.items[r],s))break}e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML)}function hA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),e.tokenizer.state=dt.PLAINTEXT}function mA(e,t){e.openElements.hasInScope(b.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(b.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.framesetOk=!1}function pA(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(Y.A);n&&(Zl(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function gA(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function xA(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(b.NOBR)&&(Zl(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,ie.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function bA(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function yA(e,t){e.treeAdapter.getDocumentMode(e.document)!==qt.QUIRKS&&e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._insertElement(t,ie.HTML),e.framesetOk=!1,e.insertionMode=U.IN_TABLE}function Ap(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ie.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Cp(e){const t=pp(e,Xn.TYPE);return t!=null&&t.toLowerCase()===FS}function EA(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ie.HTML),Cp(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function vA(e,t){e._appendElement(t,ie.HTML),t.ackSelfClosing=!0}function TA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._appendElement(t,ie.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function kA(e,t){t.tagName=Y.IMG,t.tagID=b.IMG,Ap(e,t)}function wA(e,t){e._insertElement(t,ie.HTML),e.skipNextNewLine=!0,e.tokenizer.state=dt.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=U.TEXT}function SA(e,t){e.openElements.hasInButtonScope(b.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,dt.RAWTEXT)}function AA(e,t){e.framesetOk=!1,e._switchToTextParsing(t,dt.RAWTEXT)}function kd(e,t){e._switchToTextParsing(t,dt.RAWTEXT)}function CA(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===U.IN_TABLE||e.insertionMode===U.IN_CAPTION||e.insertionMode===U.IN_TABLE_BODY||e.insertionMode===U.IN_ROW||e.insertionMode===U.IN_CELL?U.IN_SELECT_IN_TABLE:U.IN_SELECT}function _A(e,t){e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML)}function IA(e,t){e.openElements.hasInScope(b.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,ie.HTML)}function NA(e,t){e.openElements.hasInScope(b.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(b.RTC),e._insertElement(t,ie.HTML)}function RA(e,t){e._reconstructActiveFormattingElements(),vp(t),Jl(t),t.selfClosing?e._appendElement(t,ie.MATHML):e._insertElement(t,ie.MATHML),t.ackSelfClosing=!0}function LA(e,t){e._reconstructActiveFormattingElements(),Tp(t),Jl(t),t.selfClosing?e._appendElement(t,ie.SVG):e._insertElement(t,ie.SVG),t.ackSelfClosing=!0}function wd(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ie.HTML)}function wt(e,t){switch(t.tagID){case b.I:case b.S:case b.B:case b.U:case b.EM:case b.TT:case b.BIG:case b.CODE:case b.FONT:case b.SMALL:case b.STRIKE:case b.STRONG:{gA(e,t);break}case b.A:{pA(e,t);break}case b.H1:case b.H2:case b.H3:case b.H4:case b.H5:case b.H6:{uA(e,t);break}case b.P:case b.DL:case b.OL:case b.UL:case b.DIV:case b.DIR:case b.NAV:case b.MAIN:case b.MENU:case b.ASIDE:case b.CENTER:case b.FIGURE:case b.FOOTER:case b.HEADER:case b.HGROUP:case b.DIALOG:case b.DETAILS:case b.ADDRESS:case b.ARTICLE:case b.SEARCH:case b.SECTION:case b.SUMMARY:case b.FIELDSET:case b.BLOCKQUOTE:case b.FIGCAPTION:{lA(e,t);break}case b.LI:case b.DD:case b.DT:{fA(e,t);break}case b.BR:case b.IMG:case b.WBR:case b.AREA:case b.EMBED:case b.KEYGEN:{Ap(e,t);break}case b.HR:{TA(e,t);break}case b.RB:case b.RTC:{IA(e,t);break}case b.RT:case b.RP:{NA(e,t);break}case b.PRE:case b.LISTING:{cA(e,t);break}case b.XMP:{SA(e,t);break}case b.SVG:{LA(e,t);break}case b.HTML:{sA(e,t);break}case b.BASE:case b.LINK:case b.META:case b.STYLE:case b.TITLE:case b.SCRIPT:case b.BGSOUND:case b.BASEFONT:case b.TEMPLATE:{en(e,t);break}case b.BODY:{aA(e,t);break}case b.FORM:{dA(e,t);break}case b.NOBR:{xA(e,t);break}case b.MATH:{RA(e,t);break}case b.TABLE:{yA(e,t);break}case b.INPUT:{EA(e,t);break}case b.PARAM:case b.TRACK:case b.SOURCE:{vA(e,t);break}case b.IMAGE:{kA(e,t);break}case b.BUTTON:{mA(e,t);break}case b.APPLET:case b.OBJECT:case b.MARQUEE:{bA(e,t);break}case b.IFRAME:{AA(e,t);break}case b.SELECT:{CA(e,t);break}case b.OPTION:case b.OPTGROUP:{_A(e,t);break}case b.NOEMBED:case b.NOFRAMES:{kd(e,t);break}case b.FRAMESET:{oA(e,t);break}case b.TEXTAREA:{wA(e,t);break}case b.NOSCRIPT:{e.options.scriptingEnabled?kd(e,t):wd(e,t);break}case b.PLAINTEXT:{hA(e,t);break}case b.COL:case b.TH:case b.TD:case b.TR:case b.HEAD:case b.FRAME:case b.TBODY:case b.TFOOT:case b.THEAD:case b.CAPTION:case b.COLGROUP:break;default:wd(e,t)}}function PA(e,t){if(e.openElements.hasInScope(b.BODY)&&(e.insertionMode=U.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function MA(e,t){e.openElements.hasInScope(b.BODY)&&(e.insertionMode=U.AFTER_BODY,Fp(e,t))}function DA(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function OA(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(b.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(b.FORM):n&&e.openElements.remove(n))}function FA(e){e.openElements.hasInButtonScope(b.P)||e._insertFakeElement(Y.P,b.P),e._closePElement()}function BA(e){e.openElements.hasInListItemScope(b.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(b.LI),e.openElements.popUntilTagNamePopped(b.LI))}function jA(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function HA(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function UA(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function zA(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(Y.BR,b.BR),e.openElements.pop(),e.framesetOk=!1}function _p(e,t){const n=t.tagName,r=t.tagID;for(let s=e.openElements.stackTop;s>0;s--){const i=e.openElements.items[s],a=e.openElements.tagIDs[s];if(r===a&&(r!==b.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=s&&e.openElements.shortenToLength(s);break}if(e._isSpecialElement(i,a))break}}function sa(e,t){switch(t.tagID){case b.A:case b.B:case b.I:case b.S:case b.U:case b.EM:case b.TT:case b.BIG:case b.CODE:case b.FONT:case b.NOBR:case b.SMALL:case b.STRIKE:case b.STRONG:{Zl(e,t);break}case b.P:{FA(e);break}case b.DL:case b.UL:case b.OL:case b.DIR:case b.DIV:case b.NAV:case b.PRE:case b.MAIN:case b.MENU:case b.ASIDE:case b.BUTTON:case b.CENTER:case b.FIGURE:case b.FOOTER:case b.HEADER:case b.HGROUP:case b.DIALOG:case b.ADDRESS:case b.ARTICLE:case b.DETAILS:case b.SEARCH:case b.SECTION:case b.SUMMARY:case b.LISTING:case b.FIELDSET:case b.BLOCKQUOTE:case b.FIGCAPTION:{DA(e,t);break}case b.LI:{BA(e);break}case b.DD:case b.DT:{jA(e,t);break}case b.H1:case b.H2:case b.H3:case b.H4:case b.H5:case b.H6:{HA(e);break}case b.BR:{zA(e);break}case b.BODY:{PA(e,t);break}case b.HTML:{MA(e,t);break}case b.FORM:{OA(e);break}case b.APPLET:case b.OBJECT:case b.MARQUEE:{UA(e,t);break}case b.TEMPLATE:{ir(e,t);break}default:_p(e,t)}}function Ip(e,t){e.tmplInsertionModeStack.length>0?Op(e,t):eu(e,t)}function VA(e,t){var n;t.tagID===b.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function qA(e,t){e._err(t,Q.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Ja(e,t){if(e.openElements.currentTagId!==void 0&&kp.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=U.IN_TABLE_TEXT,t.type){case He.CHARACTER:{Rp(e,t);break}case He.WHITESPACE_CHARACTER:{Np(e,t);break}}else Mi(e,t)}function WA(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_CAPTION}function $A(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_COLUMN_GROUP}function YA(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Y.COLGROUP,b.COLGROUP),e.insertionMode=U.IN_COLUMN_GROUP,tu(e,t)}function GA(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_TABLE_BODY}function KA(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Y.TBODY,b.TBODY),e.insertionMode=U.IN_TABLE_BODY,aa(e,t)}function XA(e,t){e.openElements.hasInTableScope(b.TABLE)&&(e.openElements.popUntilTagNamePopped(b.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function QA(e,t){Cp(t)?e._appendElement(t,ie.HTML):Mi(e,t),t.ackSelfClosing=!0}function JA(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,ie.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function Ar(e,t){switch(t.tagID){case b.TD:case b.TH:case b.TR:{KA(e,t);break}case b.STYLE:case b.SCRIPT:case b.TEMPLATE:{en(e,t);break}case b.COL:{YA(e,t);break}case b.FORM:{JA(e,t);break}case b.TABLE:{XA(e,t);break}case b.TBODY:case b.TFOOT:case b.THEAD:{GA(e,t);break}case b.INPUT:{QA(e,t);break}case b.CAPTION:{WA(e,t);break}case b.COLGROUP:{$A(e,t);break}default:Mi(e,t)}}function ki(e,t){switch(t.tagID){case b.TABLE:{e.openElements.hasInTableScope(b.TABLE)&&(e.openElements.popUntilTagNamePopped(b.TABLE),e._resetInsertionMode());break}case b.TEMPLATE:{ir(e,t);break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:case b.TBODY:case b.TD:case b.TFOOT:case b.TH:case b.THEAD:case b.TR:break;default:Mi(e,t)}}function Mi(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,ia(e,t),e.fosterParentingEnabled=n}function Np(e,t){e.pendingCharacterTokens.push(t)}function Rp(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Gr(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Mi(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Lp=new Set([b.CAPTION,b.COL,b.COLGROUP,b.TBODY,b.TD,b.TFOOT,b.TH,b.THEAD,b.TR]);function ZA(e,t){const n=t.tagID;Lp.has(n)?e.openElements.hasInTableScope(b.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(b.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,Ar(e,t)):wt(e,t)}function eC(e,t){const n=t.tagID;switch(n){case b.CAPTION:case b.TABLE:{e.openElements.hasInTableScope(b.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(b.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,n===b.TABLE&&ki(e,t));break}case b.BODY:case b.COL:case b.COLGROUP:case b.HTML:case b.TBODY:case b.TD:case b.TFOOT:case b.TH:case b.THEAD:case b.TR:break;default:sa(e,t)}}function tu(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.COL:{e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.TEMPLATE:{en(e,t);break}default:Ls(e,t)}}function tC(e,t){switch(t.tagID){case b.COLGROUP:{e.openElements.currentTagId===b.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case b.TEMPLATE:{ir(e,t);break}case b.COL:break;default:Ls(e,t)}}function Ls(e,t){e.openElements.currentTagId===b.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE,e._processToken(t))}function aa(e,t){switch(t.tagID){case b.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_ROW;break}case b.TH:case b.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(Y.TR,b.TR),e.insertionMode=U.IN_ROW,oa(e,t);break}case b.CAPTION:case b.COL:case b.COLGROUP:case b.TBODY:case b.TFOOT:case b.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,Ar(e,t));break}default:Ar(e,t)}}function Wo(e,t){const n=t.tagID;switch(t.tagID){case b.TBODY:case b.TFOOT:case b.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case b.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,ki(e,t));break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:case b.TD:case b.TH:case b.TR:break;default:ki(e,t)}}function oa(e,t){switch(t.tagID){case b.TH:case b.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,ie.HTML),e.insertionMode=U.IN_CELL,e.activeFormattingElements.insertMarker();break}case b.CAPTION:case b.COL:case b.COLGROUP:case b.TBODY:case b.TFOOT:case b.THEAD:case b.TR:{e.openElements.hasInTableScope(b.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,aa(e,t));break}default:Ar(e,t)}}function Pp(e,t){switch(t.tagID){case b.TR:{e.openElements.hasInTableScope(b.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY);break}case b.TABLE:{e.openElements.hasInTableScope(b.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,Wo(e,t));break}case b.TBODY:case b.TFOOT:case b.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(b.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,Wo(e,t));break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:case b.TD:case b.TH:break;default:ki(e,t)}}function nC(e,t){const n=t.tagID;Lp.has(n)?(e.openElements.hasInTableScope(b.TD)||e.openElements.hasInTableScope(b.TH))&&(e._closeTableCell(),oa(e,t)):wt(e,t)}function rC(e,t){const n=t.tagID;switch(n){case b.TD:case b.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_ROW);break}case b.TABLE:case b.TBODY:case b.TFOOT:case b.THEAD:case b.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),Pp(e,t));break}case b.BODY:case b.CAPTION:case b.COL:case b.COLGROUP:case b.HTML:break;default:sa(e,t)}}function Mp(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.OPTION:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e._insertElement(t,ie.HTML);break}case b.OPTGROUP:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e.openElements.currentTagId===b.OPTGROUP&&e.openElements.pop(),e._insertElement(t,ie.HTML);break}case b.HR:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop(),e.openElements.currentTagId===b.OPTGROUP&&e.openElements.pop(),e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.INPUT:case b.KEYGEN:case b.TEXTAREA:case b.SELECT:{e.openElements.hasInSelectScope(b.SELECT)&&(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode(),t.tagID!==b.SELECT&&e._processStartTag(t));break}case b.SCRIPT:case b.TEMPLATE:{en(e,t);break}}}function Dp(e,t){switch(t.tagID){case b.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===b.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===b.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===b.OPTGROUP&&e.openElements.pop();break}case b.OPTION:{e.openElements.currentTagId===b.OPTION&&e.openElements.pop();break}case b.SELECT:{e.openElements.hasInSelectScope(b.SELECT)&&(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode());break}case b.TEMPLATE:{ir(e,t);break}}}function iC(e,t){const n=t.tagID;n===b.CAPTION||n===b.TABLE||n===b.TBODY||n===b.TFOOT||n===b.THEAD||n===b.TR||n===b.TD||n===b.TH?(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode(),e._processStartTag(t)):Mp(e,t)}function sC(e,t){const n=t.tagID;n===b.CAPTION||n===b.TABLE||n===b.TBODY||n===b.TFOOT||n===b.THEAD||n===b.TR||n===b.TD||n===b.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(b.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Dp(e,t)}function aC(e,t){switch(t.tagID){case b.BASE:case b.BASEFONT:case b.BGSOUND:case b.LINK:case b.META:case b.NOFRAMES:case b.SCRIPT:case b.STYLE:case b.TEMPLATE:case b.TITLE:{en(e,t);break}case b.CAPTION:case b.COLGROUP:case b.TBODY:case b.TFOOT:case b.THEAD:{e.tmplInsertionModeStack[0]=U.IN_TABLE,e.insertionMode=U.IN_TABLE,Ar(e,t);break}case b.COL:{e.tmplInsertionModeStack[0]=U.IN_COLUMN_GROUP,e.insertionMode=U.IN_COLUMN_GROUP,tu(e,t);break}case b.TR:{e.tmplInsertionModeStack[0]=U.IN_TABLE_BODY,e.insertionMode=U.IN_TABLE_BODY,aa(e,t);break}case b.TD:case b.TH:{e.tmplInsertionModeStack[0]=U.IN_ROW,e.insertionMode=U.IN_ROW,oa(e,t);break}default:e.tmplInsertionModeStack[0]=U.IN_BODY,e.insertionMode=U.IN_BODY,wt(e,t)}}function oC(e,t){t.tagID===b.TEMPLATE&&ir(e,t)}function Op(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(b.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):eu(e,t)}function lC(e,t){t.tagID===b.HTML?wt(e,t):Ps(e,t)}function Fp(e,t){var n;if(t.tagID===b.HTML){if(e.fragmentContext||(e.insertionMode=U.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===b.HTML){e._setEndLocation(e.openElements.items[0],t);const r=e.openElements.items[1];r&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(r))===null||n===void 0)&&n.endTag)&&e._setEndLocation(r,t)}}else Ps(e,t)}function Ps(e,t){e.insertionMode=U.IN_BODY,ia(e,t)}function uC(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.FRAMESET:{e._insertElement(t,ie.HTML);break}case b.FRAME:{e._appendElement(t,ie.HTML),t.ackSelfClosing=!0;break}case b.NOFRAMES:{en(e,t);break}}}function cC(e,t){t.tagID===b.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==b.FRAMESET&&(e.insertionMode=U.AFTER_FRAMESET))}function dC(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.NOFRAMES:{en(e,t);break}}}function fC(e,t){t.tagID===b.HTML&&(e.insertionMode=U.AFTER_AFTER_FRAMESET)}function hC(e,t){t.tagID===b.HTML?wt(e,t):ms(e,t)}function ms(e,t){e.insertionMode=U.IN_BODY,ia(e,t)}function mC(e,t){switch(t.tagID){case b.HTML:{wt(e,t);break}case b.NOFRAMES:{en(e,t);break}}}function pC(e,t){t.chars=ot,e._insertCharacters(t)}function gC(e,t){e._insertCharacters(t),e.framesetOk=!1}function Bp(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==ie.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function xC(e,t){if(LS(t))Bp(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===ie.MATHML?vp(t):r===ie.SVG&&(PS(t),Tp(t)),Jl(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function bC(e,t){if(t.tagID===b.P||t.tagID===b.BR){Bp(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===ie.HTML){e._endTagOutsideForeignContent(t);break}const s=e.treeAdapter.getTagName(r);if(s.toLowerCase()===t.tagName){t.tagName=s,e.openElements.shortenToLength(n);break}}}Y.AREA,Y.BASE,Y.BASEFONT,Y.BGSOUND,Y.BR,Y.COL,Y.EMBED,Y.FRAME,Y.HR,Y.IMG,Y.INPUT,Y.KEYGEN,Y.LINK,Y.META,Y.PARAM,Y.SOURCE,Y.TRACK,Y.WBR;const yC=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,EC=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),Sd={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function jp(e,t){const n=NC(e),r=Um("type",{handlers:{root:vC,element:TC,text:kC,comment:Up,doctype:wC,raw:AC},unknown:CC}),s={parser:n?new Td(Sd):Td.getFragmentParser(void 0,Sd),handle(o){r(o,s)},stitches:!1,options:t||{}};r(e,s),Pr(s,un());const i=n?s.parser.document:s.parser.getFragment(),a=Rw(i,{file:s.options.file});return s.stitches&&ra(a,"comment",function(o,l,u){const c=o;if(c.value.stitch&&u&&l!==void 0){const f=u.children;return f[l]=c.value.stitch,l}}),a.type==="root"&&a.children.length===1&&a.children[0].type===e.type?a.children[0]:a}function Hp(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function vC(e,t){Hp(e.children,t)}function TC(e,t){_C(e,t),Hp(e.children,t),IC(e,t)}function kC(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:He.CHARACTER,chars:e.value,location:Di(e)};Pr(t,un(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function wC(e,t){const n={type:He.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Di(e)};Pr(t,un(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function SC(e,t){t.stitches=!0;const n=RC(e);if("children"in e&&"children"in n){const r=jp({type:"root",children:e.children},t.options);n.children=r.children}Up({type:"comment",value:{stitch:n}},t)}function Up(e,t){const n=e.value,r={type:He.COMMENT,data:n,location:Di(e)};Pr(t,un(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function AC(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,zp(t,un(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(yC,"&lt;$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const n=t.parser.tokenizer._consume();t.parser.tokenizer._callState(n)}}function CC(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))SC(n,t);else{let r="";throw EC.has(n.type)&&(r=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),new Error("Cannot compile `"+n.type+"` node"+r)}}function Pr(e,t){zp(e,t);const n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=dt.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function zp(e,t){if(t&&t.offset!==void 0){const n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function _C(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===dt.PLAINTEXT)return;Pr(t,un(e));const r=t.parser.openElements.current;let s="namespaceURI"in r?r.namespaceURI:qn.html;s===qn.html&&n==="svg"&&(s=qn.svg);const i=Ow({...e,children:[]},{space:s===qn.svg?"svg":"html"}),a={type:He.START_TAG,tagName:n,tagID:Lr(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:Di(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function IC(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&qw.includes(n)||t.parser.tokenizer.state===dt.PLAINTEXT)return;Pr(t,Qs(e));const r={type:He.END_TAG,tagName:n,tagID:Lr(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Di(e)};t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===dt.RCDATA||t.parser.tokenizer.state===dt.RAWTEXT||t.parser.tokenizer.state===dt.SCRIPT_DATA)&&(t.parser.tokenizer.state=dt.DATA)}function NC(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Di(e){const t=un(e)||{line:void 0,column:void 0,offset:void 0},n=Qs(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function RC(e){return"children"in e?nr({...e,children:[]}):nr(e)}function Vp(e){return function(t,n){return jp(t,{...e,file:n})}}const Bn=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],di={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Bn,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Bn],h2:[["className","sr-only"]],img:[...Bn,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Bn,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Bn],table:[...Bn],ul:[...Bn,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},kn={}.hasOwnProperty;function LC(e,t){let n={type:"root",children:[]};const r={schema:t?{...di,...t}:di,stack:[]},s=qp(r,e);return s&&(Array.isArray(s)?s.length===1?n=s[0]:n.children=s:n=s),n}function qp(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return PC(e,n);case"doctype":return MC(e,n);case"element":return DC(e,n);case"root":return OC(e,n);case"text":return FC(e,n)}}}function PC(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",r=n.indexOf("-->"),i={type:"comment",value:r<0?n:n.slice(0,r)};return Oi(i,t),i}}function MC(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Oi(n,t),n}}function DC(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const r=Wp(e,t.children),s=BC(e,t.properties);e.stack.pop();let i=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(i=!0,e.schema.ancestors&&kn.call(e.schema.ancestors,n))){const o=e.schema.ancestors[n];let l=-1;for(i=!1;++l<o.length;)e.stack.includes(o[l])&&(i=!0)}if(!i)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;const a={type:"element",tagName:n,properties:s,children:r};return Oi(a,t),a}function OC(e,t){const r={type:"root",children:Wp(e,t.children)};return Oi(r,t),r}function FC(e,t){const r={type:"text",value:typeof t.value=="string"?t.value:""};return Oi(r,t),r}function Wp(e,t){const n=[];if(Array.isArray(t)){const r=t;let s=-1;for(;++s<r.length;){const i=qp(e,r[s]);i&&(Array.isArray(i)?n.push(...i):n.push(i))}}return n}function BC(e,t){const n=e.stack[e.stack.length-1],r=e.schema.attributes,s=e.schema.required,i=r&&kn.call(r,n)?r[n]:void 0,a=r&&kn.call(r,"*")?r["*"]:void 0,o=t&&typeof t=="object"?t:{},l={};let u;for(u in o)if(kn.call(o,u)){const c=o[u];let f=Ad(e,Cd(i,u),u,c);f==null&&(f=Ad(e,Cd(a,u),u,c)),f!=null&&(l[u]=f)}if(s&&kn.call(s,n)){const c=s[n];for(u in c)kn.call(c,u)&&!kn.call(l,u)&&(l[u]=c[u])}return l}function Ad(e,t,n,r){return t?Array.isArray(r)?jC(e,t,n,r):$p(e,t,n,r):void 0}function jC(e,t,n,r){let s=-1;const i=[];for(;++s<r.length;){const a=$p(e,t,n,r[s]);(typeof a=="number"||typeof a=="string")&&i.push(a)}return i}function $p(e,t,n,r){if(!(typeof r!="boolean"&&typeof r!="number"&&typeof r!="string")&&HC(e,n,r)){if(typeof t=="object"&&t.length>1){let s=!1,i=0;for(;++i<t.length;){const a=t[i];if(a&&typeof a=="object"&&"flags"in a){if(a.test(String(r))){s=!0;break}}else if(a===r){s=!0;break}}if(!s)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function HC(e,t,n){const r=e.schema.protocols&&kn.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;const s=String(n),i=s.indexOf(":"),a=s.indexOf("?"),o=s.indexOf("#"),l=s.indexOf("/");if(i<0||l>-1&&i>l||a>-1&&i>a||o>-1&&i>o)return!0;let u=-1;for(;++u<r.length;){const c=r[u];if(i===c.length&&s.slice(0,c.length)===c)return!0}return!1}function Oi(e,t){const n=lm(t);t.data&&(e.data=nr(t.data)),n&&(e.position=n)}function Cd(e,t){let n,r=-1;if(e)for(;++r<e.length;){const s=e[r],i=typeof s=="string"?s:s[0];if(i===t)return s;i==="data*"&&(n=s)}if(t.length>4&&t.slice(0,4).toLowerCase()==="data")return n}function Yp(e){return function(t){return LC(t,e)}}var kh;const Gp={...di,protocols:{...di.protocols,src:[...((kh=di.protocols)==null?void 0:kh.src)??["http","https","mailto"],"data"]}},UC={remarkPlugins:[op],rehypePlugins:[Vp,[Yp,Gp]]};let ti=null,_d=null;function zC(){return ti?Promise.resolve(ti):(_d??(_d=Promise.all([we(()=>import("./index-DJ_vjgYj.js"),__vite__mapDeps([3,1,2]),import.meta.url),we(()=>import("./index-BTHtdpYN.js"),__vite__mapDeps([4,1,2]),import.meta.url)]).then(([{default:e},{default:t}])=>(ti={remarkPlugins:[op,e],rehypePlugins:[Vp,[Yp,Gp],t]},ti))),_d)}function VC(e){return e.includes("$")||e.includes("\\(")||e.includes("\\[")}function Kp(e){const[t,n]=k.useState(ti),r=VC(e??"");return k.useEffect(()=>{if(!r||t)return;let s=!0;return zC().then(i=>{s&&n(i)}),()=>{s=!1}},[r,t]),t??UC}function qC({retry:e}){const t=Ke();return x.jsxs("div",{className:"text-body text-warning p-4 flex items-start gap-2",children:[x.jsx(Ll,{className:"w-4 h-4 shrink-0 mt-0.5"}),x.jsxs("span",{children:[t("error.renderFailed")," ",x.jsx("button",{className:"underline ml-1",onClick:e,children:t("error.retry")})]})]})}class WC extends k.Component{constructor(){super(...arguments);Ea(this,"state",{error:null});Ea(this,"retry",()=>this.setState({error:null}))}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("[ErrorBoundary caught]",n,r.componentStack)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.retry):x.jsx(qC,{error:this.state.error,retry:this.retry}):this.props.children}}const Qn=new Set(["。","!","?","!","?",";",";","…"]),$C=new Set([",",",","、",":",":"," "," "]),YC=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}]/u;function Ms(e){return e!=null&&YC.test(String.fromCodePoint(e))}const GC=/(?:[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}](?:\uFE0F|\u200D[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}]|[\u{1F3FB}-\u{1F3FF}])*)$/u,vr=new Set(["”",'"',"」","』","》",")","】","])".slice(0,1)]);function KC(e){let t=e;return t=t.replace(/\r\n?/g,`
466
466
  `),t=t.replace(/(?:^|\n)[ \t]*(?:```|~~~)[^\n]*\n[\s\S]*?(?:\n[ \t]*(?:```|~~~)[^\n]*|\n?$)/g,`
467
467
  `),t=t.replace(/`[^`\n]*`/g,""),t=t.replace(/!\[[^\]]*\]\([^)\n]*\)/g,""),t=t.replace(/\[([^\]]+)\]\([^)\n]*\)/g,"$1"),t=t.replace(/^[ \t]{0,3}#{1,6}[ \t]+/gm,""),t=t.replace(/^[ \t]*(?:[-*+]|\d+\.)[ \t]+/gm,""),t=t.replace(/^[ \t]*>[ \t]?/gm,""),t=t.replace(/\|/g," "),t=t.replace(/^[ \t]*[-: ]{3,}[ \t]*$/gm,""),t=t.replace(/(\*\*|__)(.*?)\1/g,"$2"),t=t.replace(new RegExp("(?<![*\\w])(\\*|_)(?!\\s)(.+?)(?<!\\s)\\1(?![*\\w])","g"),"$2"),t=t.replace(/~~(.+?)~~/g,"$1"),t=t.replace(/\n{3,}/g,`
468
468
 
@@ -471,8 +471,8 @@ Based on my performance, decide what comes next: explain why I got questions wro
471
471
  `?!0:GC.test(t)}function JC(e,t,n,r=400){const s=e.length,i=o=>{if(o<0||o>=s)return-1;const l=e[o];if(l===`
472
472
  `)return o+1;if(Qn.has(l)){let c=o+1;for(;c<s&&(Qn.has(e[c])||vr.has(e[c]));)c++;return c}if(l==="."){const c=o>0?e[o-1]:"",f=o+1<s?e[o+1]:"";if((f===""||/\s/.test(f))&&!/\d/.test(c)){let h=o+1;for(;h<s&&(vr.has(e[h])||Qn.has(e[h]));)h++;return h}return-1}const u=e.codePointAt(o);if(Ms(u)){let c=o+(u>65535?2:1);for(;c<s;){const f=e.codePointAt(c),h=f>65535?2:1;if(f===65039||f===8205||f>=127995&&f<=127999||Ms(f)){c+=h;continue}break}return c}return-1};let a=t;{let o=!1;for(let l=Math.min(t,s)-1;l>=0&&t-l<=r;l--){const u=i(l);if(u>=0){o=!0,u<=t&&(a=u);break}}!o&&t<=r&&(a=0)}if(Qp(e.slice(0,Math.min(n,s)))){let o=Math.min(n,s);for(;o<s&&vr.has(e[o]);)o++;return{start:a,end:o}}for(let o=n;o<s&&o-n<=r;o++){const l=i(o);if(l>=0)return{start:a,end:l}}return{start:a,end:s}}function wi(e,t,n){const r=[];let s="";const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(o){const l=o.parentElement;if(!l)return NodeFilter.FILTER_REJECT;const u=l.tagName;return u==="SCRIPT"||u==="STYLE"||l.closest(".katex-html")||l.closest(".katex-mathml")&&!l.closest("annotation")||!(n!=null&&n.includeMarks)&&l.closest("mark.lookatstudy-underline")||t&&!l.closest(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let a;for(;a=i.nextNode();){const o=a,l=o.textContent??"",u=s.length;s+=l,r.push({node:o,start:u,end:s.length})}return{text:s,nodes:r}}function Jp(e,t){const n=Id(e.startContainer,e.startOffset,t,"start"),r=Id(e.endContainer,e.endOffset,t,"end");return n==null||r==null||r<=n?null:{start:n,end:r}}function Id(e,t,n,r){var s,i,a;if(e.nodeType===Node.TEXT_NODE){for(const o of n.nodes)if(o.node===e)return o.start+Math.min(t,((s=o.node.textContent)==null?void 0:s.length)??0);return r==="start"?((i=n.nodes[0])==null?void 0:i.start)??null:((a=n.nodes[n.nodes.length-1])==null?void 0:a.end)??null}if(e instanceof Element){const o=Array.from(e.childNodes);if(r==="end"){for(let u=t;u<o.length;u++){const c=Zp(o[u],n);if(c!=null)return c}const l=n.nodes[n.nodes.length-1];return l?l.end:null}else{for(let u=t;u>=0;u--){const c=e0(o[u],n);if(c!=null)return c}const l=n.nodes[0];return l?l.start:null}}return null}function Zp(e,t){if(e.nodeType===Node.TEXT_NODE){for(const n of t.nodes)if(n.node===e)return n.start;return null}if(e instanceof Element)for(const n of e.childNodes){const r=Zp(n,t);if(r!=null)return r}return null}function e0(e,t){if(e.nodeType===Node.TEXT_NODE){for(const n of t.nodes)if(n.node===e)return n.end;return null}if(e instanceof Element){let n=null;for(const r of e.childNodes){const s=e0(r,t);s!=null&&(n=s)}return n}return null}function $o(e,t,n){var o,l,u,c;if(n<=t)return null;let r=null,s=0,i=null,a=0;for(const f of e.nodes)if(!r&&t>=f.start&&t<f.end&&(r=f.node,s=t-f.start),!i&&n>f.start&&n<=f.end&&(i=f.node,a=n-f.start),r&&i)break;if(!r&&e.nodes.length>0){const f=e.nodes[e.nodes.length-1];r=f.node,s=((o=f.node.textContent)==null?void 0:o.length)??0}if(!i&&e.nodes.length>0){const f=e.nodes[e.nodes.length-1];i=f.node,a=((l=f.node.textContent)==null?void 0:l.length)??0}if(!r||!i)return null;try{const f=document.createRange();return f.setStart(r,Math.min(s,((u=r.textContent)==null?void 0:u.length)??0)),f.setEnd(i,Math.min(a,((c=i.textContent)==null?void 0:c.length)??0)),f}catch{return null}}function t0(e,t){e.querySelectorAll("mark.lookatstudy-underline").forEach(i=>{const a=i.parentNode;if(a){for(;i.firstChild;)a.insertBefore(i.firstChild,i);a.removeChild(i)}}),e.normalize();const n=new Map;if(t.length===0)return n;const r=wi(e),s=[];for(const i of t){const a=ZC(r.text,i.text,i.surrounding);a>=0&&s.push({noteId:i.noteId,start:a,end:a+i.text.length})}s.sort((i,a)=>a.start-i.start);for(const i of s){const a=$o(r,i.start,i.end);if(!a)continue;const o=e3(a,i.noteId);o&&n.set(i.noteId,o)}return n}function ZC(e,t,n){if(!t)return-1;let r=e.indexOf(t);if(r<0){const s=t.replace(/\s+/g," ").trim();if(r=e.replace(/\s+/g," ").indexOf(s),r<0)return-1;const a=t.slice(0,Math.min(15,t.length));return e.indexOf(a)}if(n&&n.length>5){const s=e.indexOf(n.slice(0,20));if(s>=0){let i=r,a=Math.abs(r-s),o=r+1;for(;;){const l=e.indexOf(t,o);if(l<0)break;const u=Math.abs(l-s);u<a&&(i=l,a=u),o=l+1}return i}}return r}function e3(e,t){const n="color: inherit; background: transparent; border-bottom: 2px solid rgb(34, 197, 94); padding-bottom: 1px;",r=document.createElement("mark");return r.className="lookatstudy-underline",r.dataset.noteId=t,r.style.cssText=n,n0(e,r)}function n0(e,t){var n;if(e.startContainer===e.endContainer&&e.startContainer.nodeType===Node.TEXT_NODE)try{return e.surroundContents(t),t}catch{}try{const r=[],s=document.createTreeWalker(e.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode(o){return e.intersectsNode(o)&&(o===e.startContainer||o===e.endContainer||e.intersectsNode(o))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let i;for(;i=s.nextNode();)r.push(i);if(r.length===0)return null;let a=null;for(const o of r){let l=o;if(o===e.startContainer&&e.startOffset>0&&(l=o.splitText(e.startOffset)),o===e.endContainer||l===e.endContainer){const c=l===e.endContainer?e.endOffset:e.endOffset-(o===e.startContainer?e.startOffset:0);c<l.textContent.length&&l.splitText(c)}if(!l.textContent)continue;const u=a?t.cloneNode(!1):t;(n=l.parentNode)==null||n.insertBefore(u,l),u.appendChild(l),a||(a=u)}return a}catch{return null}}const r0="cp-reading-mark",i0="cp-reading";function Jn(e){var n;const t=CSS;try{(n=t.highlights)==null||n.delete(i0)}catch{}nu=null,ru=null,e.querySelectorAll(`.${r0}`).forEach(r=>{const s=r.parentNode;if(s){for(;r.firstChild;)s.insertBefore(r.firstChild,r);s.removeChild(r)}}),e.normalize()}const t3=/[0-9A-Za-z\u00C0-\u024F\u0370-\u03FF\u0400-\u04FF\u4E00-\u9FFF\u3040-\u30FF\uAC00-\uD7AF]/,n3=`「『(([【<《"'“‘`,r3=`。』」))]】>》"'”’!!??…,,、;;::`;function s0(e){const t=e.codePointAt(0);let n=e;return t>=65281&&t<=65374&&(n=String.fromCharCode(t-65248)),t3.test(n)?n.toLowerCase():null}function i3(e){let t="";const n=[];for(let r=0;r<e.length;r++){const s=s0(e[r]);s!==null&&(t+=s,n.push(r))}return{canon:t,map:n}}function s3(e,t){if(t<=0)return 0;let n=0,r=e.length;for(;n<r;){const s=n+r>>1;e[s]<t?n=s+1:r=s}return n}function Nd(e,t,n){const{canon:r,map:s}=i3(e),i=t.trim().split(/\s+/).map(m=>[...m].map(s0).filter(Boolean).join("")).filter(m=>m.length>0);if(i.length===0||r.length===0){const m=t.trim();if(!m)return null;const p=e.indexOf(m,Math.max(0,n));return p>=0?{start:p,end:p+m.length}:null}const a=s3(s,Math.max(0,n)),o=i.join("");let l=-1,u=-1;const c=r.indexOf(o,a);if(c>=0)l=c,u=c+o.length-1;else{let m=a;for(const p of i){const g=r.indexOf(p,m);if(g<0)return null;l<0&&(l=g),u=g+p.length-1,m=u+1}if(l<0||u-l+1>o.length*3+40)return null}if(u>=s.length||l<0)return null;let f=s[l],h=s[u]+1;const d=n>0?n:0;for(let m=0;m<3&&f-1>=d&&n3.includes(e[f-1]);m++)f--;for(let m=0;m<4&&h<e.length&&r3.includes(e[h]);m++)h++;return{start:f,end:h}}const Yo=new WeakMap;function a0(e){Yo.delete(e)}function o0(e,t,n){Jn(e);const r=t.trim();if(!r)return null;const s=wi(e,n==null?void 0:n.within,{includeMarks:!0}),i=Yo.get(e)??0;let a=Nd(s.text,r,i);if(!a&&i>0&&(a=Nd(s.text,r,0)),!a)return null;Yo.set(e,a.end);const o=$o(s,a.start,a.end);if(!o)return null;const l=JC(s.text,a.start,a.end);ru=$o(s,l.start,l.end);const u=CSS;if(typeof Highlight<"u"&&u.highlights)try{return u.highlights.set(i0,new Highlight(o)),nu=o,o}catch{}const c=document.createElement("span");return c.className=r0,n0(o,c)?o:null}let nu=null;function a3(){return nu}let ru=null;function o3(){return ru}function l0(e,t){var a,o,l;const n=e.getClientRects(),r=n.length>0&&n[0].height>0?n[0]:(a=e.startContainer.parentElement??e.startContainer)==null?void 0:a.getBoundingClientRect();if(!r||r.height<=0)return;if(!t){(l=(o=e.startContainer.parentElement??e.startContainer)==null?void 0:o.scrollIntoView)==null||l.call(o,{behavior:"smooth",block:"center"});return}const s=t.getBoundingClientRect();if(r.top>=s.top+48&&r.bottom<=s.bottom-48)return;const i=t.scrollTop+(r.top+r.height/2)-(s.top+s.height/2);t.scrollTo({top:Math.max(0,i),behavior:"smooth"})}let ps=null,Go=null;function l3(e){ps=e,Go=(e==null?void 0:e.textContent)??null}function u3(){if(c3(ps))return ps;if(Go){for(const e of document.querySelectorAll("mark.lookatstudy-underline"))if(e.textContent===Go)return ps=e,e}return null}function c3(e){return!!e&&e.isConnected}function u0(e){e.scrollIntoView({behavior:"smooth",block:"center"}),e.style.transition="background 0.3s, border-bottom-color 0.3s, border-bottom-width 0.3s",e.style.background="rgba(250, 204, 21, 0.35)",e.style.borderBottom="4px solid rgb(34, 197, 94)",setTimeout(()=>{e.style.color="inherit",e.style.background="transparent",e.style.borderBottom="2px solid rgb(34, 197, 94)"},1500)}function c0(e){const t=[];let n=!1;for(const r of e.split(`
473
473
  `)){if(/^[ \t]*(?:```|~~~)/.test(r)){t.push(r),n=!n;continue}t.push(n?r:r.replace(/\\\[|\\\]|\\\(|\\\)/g,s=>s==="\\["||s==="\\]"?"$$":"$"))}return t.join(`
474
- `)}function d0(e,t,n,r,s){const a=r??e,o=a.top+a.height/2;return!s&&a.right+8+n<=t?{left:a.right+8,top:o,transform:"translate(0, -50%)"}:!s&&e.left-8-n>=0?{left:e.left-8,top:o,transform:"translate(-100%, -50%)"}:{left:Math.min(Math.max(e.left,0),Math.max(0,t-n)),top:a.bottom+8,transform:"translate(0, 0)"}}const Rd="lookatstudy-tts-settings-changed";function Ld(e){const t=n=>{const r=n.toLowerCase();return r==="zh-cn"||r==="zh_cn"||r==="zh"?0:r.startsWith("zh")?1:2};return[...e].sort((n,r)=>t(n.lang)-t(r.lang)||n.lang.localeCompare(r.lang)||n.name.localeCompare(r.name))}function Pd(e,t){if(e.length===0)return null;const n=t==null?void 0:t.trim();if(n){const i=e.find(a=>a.name===n);if(i)return i}const r=Ld(e.filter(i=>i.default));return r.length>0&&d3(r[0].lang)?r[0]:Ld(e)[0]??null}function d3(e){return e.toLowerCase().startsWith("zh")}function H4(e){return`${e.name} · ${e.lang}`}const f3=[["\\leq","小于等于"],["\\le","小于等于"],["\\geq","大于等于"],["\\ge","大于等于"],["\\neq","不等于"],["\\ne","不等于"],["\\approx","约等于"],["\\equiv","恒等于"],["\\pm","正负"],["\\times","乘以"],["\\cdot","点乘"],["\\div","除以"],["\\to","趋于"],["\\rightarrow","趋于"],["\\Rightarrow","推出"],["\\infty","无穷"],["\\sum","求和"],["\\prod","连乘"],["\\int","积分"],["\\lim","极限"],["\\log","对数"],["\\ln","自然对数"],["\\exp","指数"],["\\in","属于"],["\\subset","包含于"],["\\cup","并"],["\\cap","交"],["\\forall","任意"],["\\exists","存在"],["\\partial","偏导"],["\\nabla","梯度"],["\\angle","角"],["\\degree","度"],["\\cdots","点点点"],["\\ldots","点点点"]],h3={alpha:"阿尔法",beta:"贝塔",gamma:"伽马",delta:"德尔塔",epsilon:"艾普西隆",zeta:"泽塔",eta:"伊塔",theta:"西塔",iota:"约塔",kappa:"卡帕",lambda:"拉姆达",mu:"缪",nu:"纽",xi:"克西",pi:"派",rho:"柔",sigma:"西格马",tau:"陶",phi:"斐",chi:"凯",psi:"普西",omega:"欧米伽"};function m3(e,t){if(e[t]!=="{")return null;let n=0;for(let r=t;r<e.length;r++)if(e[r]==="{")n++;else if(e[r]==="}"&&(n--,n===0))return{body:e.slice(t+1,r),end:r+1};return null}function Kr(e,t){const n=m3(e,t);return n||{body:e[t]??"",end:t+1}}function p3(e){let t=e;t=t.replace(/\\(?:left|right|displaystyle|limits)\b/g," "),t=t.replace(/\\[,;!\s]|\\quad|\\qquad|~/g," ");for(let n=0;n<12;n++){let r=t;r=r.replace(/\\[dt]?frac(?![A-Za-z])/g,"\\frac");{let s;for(;(s=r.indexOf("\\frac"))>=0;){const i=Kr(r,s+5),a=Kr(r,i.end);r=r.slice(0,s)+`${i.body} 分之 ${a.body} `+r.slice(a.end)}}{let s;for(;(s=r.indexOf("\\binom"))>=0;){const i=Kr(r,s+6),a=Kr(r,i.end);r=r.slice(0,s)+`${i.body} 取 ${a.body} `+r.slice(a.end)}}r=r.replace(/\\sqrt\s*\[( {[^{}]*} |[^\s\\]+)\s*\]\s*/g,(s,i)=>`${i.trim()} 次根号 `);{let s;for(;(s=r.indexOf("\\sqrt"))>=0;){const i=Kr(r,s+5);r=r.slice(0,s)+`根号 ${i.body} `+r.slice(i.end)}}if(r=r.replace(/\\(?:mathbf|mathbb|mathrm|mathit|boldsymbol|text|operatorname)\s*/g,s=>s.startsWith("\\text")?"":" "),r===t){t=r;break}t=r}for(let n=0;n<8;n++){const r=t.replace(/(\\frac|[\w)\]}]|\s)\s*\^\s*(\{[^{}]*\}|[^\s])|(\\frac|[\w)\]}]| )\s*_\s*(\{[^{}]*\}|[^\s])/g,(s,i,a,o,l)=>a!==void 0?`${i} 的 ${a.replace(/[{}]/g,"")} 次方`:`${o} 下标 ${l.replace(/[{}]/g,"")}`);if(r===t)break;t=r}for(const[n,r]of f3)t=t.split(n).join(` ${r} `);return t=t.replace(/\\([A-Za-z]+)\b/g,(n,r)=>` ${h3[r]??r} `),t=t.replace(/[{}]/g," "),t.replace(/\s+/g," ").trim()}function g3(e){return e.replace(/\$\$([^$]+)\$\$|\$([^$]+)\$/g,(t,n,r)=>{const s=p3(n??r??"");return s?` ${s} `:""})}const Md=new WeakMap;let f0=null;function Za(e){f0=e}function x3(){return f0}const h0=1024;function m0(e){let t=Md.get(e);return t||(t=e.createAnalyser(),t.fftSize=h0,t.smoothingTimeConstant=.55,Md.set(e,t)),t}function b3(e,t){try{const n=m0(e);t.connect(n),n.connect(e.destination)}catch{try{t.connect(e.destination)}catch{}}}const Tr=1024,Dd=512,y3=3500,E3=7500,v3=.3,T3=.16,k3=1400,w3=2800,ts=70,p0=new Float64Array(Tr);for(let e=0;e<Tr;e++)p0[e]=.5*(1-Math.cos(2*Math.PI*e/(Tr-1)));function S3(e,t){const n=e.length;for(let r=1,s=0;r<n;r++){let i=n>>1;for(;s&i;i>>=1)s^=i;if(s|=i,r<s){const a=e[r];e[r]=e[s],e[s]=a;const o=t[r];t[r]=t[s],t[s]=o}}for(let r=2;r<=n;r<<=1){const s=-2*Math.PI/r,i=Math.cos(s),a=Math.sin(s),o=r>>1;for(let l=0;l<n;l+=r){let u=1,c=0;for(let f=0;f<o;f++){const h=e[l+f],d=t[l+f],m=e[l+f+o],p=t[l+f+o],g=m*u-p*c,y=m*c+p*u;e[l+f]=h+g,t[l+f]=d+y,e[l+f+o]=h-g,t[l+f+o]=d-y;const T=u*i-c*a;c=u*a+c*i,u=T}}}}function A3(e,t){const n=e.length;let r=0;const s=new Float64Array(n),i=new Float64Array(n);for(let p=0;p<n;p++){const g=e[p];r+=Math.abs(g),s[p]=g*p0[p]}S3(s,i);const a=n>>1,o=t/n,l=new Float64Array(a);let u=0,c=0,f=0,h=0,d=0,m=0;for(let p=0;p<a;p++){const g=p*o;if(g>=t/2-o)break;const y=Math.hypot(s[p],i[p])/a;l[p]=y,u+=y,g>=y3&&g<E3&&(c+=y),g>=Yu.lo&&g<Yu.hi?(f+=y,h+=y*g):g>=Gu.lo&&g<Gu.hi&&(d+=y,m+=y*g)}return{level:n>0?Math.min(1,r/n/.22):0,f1:f>0?h/f:400,f2:d>0?m/d:800,hfRatio:u>0?c/u:0}}function C3(e,t){return e.level<=w1?"closed":e.hfRatio>=v3?"SS":e.hfRatio>=T3&&e.level<.45?"FV":t==="closed"&&e.f2>=k3&&e.f2<=w3?"L":S1(e.f1,e.f2,e.level)}function _3(e,t){const n=[],r=(c,f,h,d)=>{if(f<=0)return;const m=n[n.length-1];if(m&&m.viseme===h&&Math.abs(m.t+m.dur-c)<1e-9){m.dur+=f,m.level=Math.max(m.level,d);return}n.push({t:c,dur:f,viseme:h,level:d})};if(e.length<Tr)return{cues:[{t:0,dur:Math.max(0,e.length/t),viseme:"closed",level:0}],duration:Math.max(0,e.length/t)};let s="closed";const i=Dd/t;for(let c=0;c+Tr<=e.length;c+=Dd){const f=e.subarray(c,c+Tr),h=A3(f,t),d=C3(h,s);r(c/t,i,d,h.level),s=d}const a=e.length/t,o=n.length>0?n[n.length-1].t+n[n.length-1].dur:0;o<a-1e-9&&r(o,a-o,"closed",0);const l=n[0];if(l&&l.viseme!=="closed")if(l.dur<=ts/1e3)l.viseme="closed";else{const c=Math.min(l.dur*.5,ts/1e3);l.dur-=c,l.t+=c,n.unshift({t:0,dur:c,viseme:"closed",level:0})}const u=n[n.length-1];if(u&&u.viseme!=="closed"){const c=Math.min(u.dur*.5,ts/1e3);u.dur-=c,n.push({t:u.t+u.dur,dur:c,viseme:"closed",level:0})}for(let c=n.length-1;c>=1;c--){const f=n[c];if(f.viseme!=="closed"&&f.dur<ts/1e3){const h=n[c-1];h.dur+=f.dur,n.splice(c,1)}}return{cues:n,duration:a}}function I3(e){const t=[...e].filter(s=>s.dur>0&&Number.isFinite(s.t)).sort((s,i)=>s.t-i.t),n=[];let r=0;for(const s of t){const i=Math.max(0,s.t/1e3),a=s.dur/1e3;i>r+1e-9&&n.push({t:r,dur:i-r,viseme:"closed",level:0});const o=n[n.length-1];o&&o.viseme===s.viseme&&Math.abs(o.t+o.dur-i)<1e-9?(o.dur+=a,o.level=Math.max(o.level,Math.min(1,Math.max(0,s.level)))):n.push({t:i,dur:a,viseme:s.viseme,level:Math.min(1,Math.max(0,s.level))}),r=i+a}return{cues:n,duration:r}}function N3(e,t){const n=e.cues;if(n.length===0||t<0)return null;let r=0,s=n.length-1;for(;r<s;){const a=r+s+1>>1;n[a].t<=t?r=a:s=a-1}const i=n[r];return t<=i.t+i.dur+1e-9?i:null}function g0(){const[e,t]=k.useState(null),[n,r]=k.useState(null),[s,i]=k.useState(null),[a,o]=k.useState([]),l=k.useRef([]),[u,c]=k.useState(null),[f,h]=k.useState(!1),d=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),g=k.useRef(0),y=k.useRef(!1),T=k.useRef([]),v=k.useRef(0),C=k.useRef(0),E=k.useRef(!1),w=k.useRef(null),_=k.useRef(0),S=k.useRef(null),I=k.useRef(null),A=k.useRef(null);A.current||(A.current=()=>{const F=I.current,q=typeof window<"u"?window.speechSynthesis:void 0;if(!F||F.stopped||!q)return;if(F.i>=F.sentences.length){I.current=null,w.current=null,t(null),r(null),i(null);return}const R=F.i,$=g3(F.sentences[R]),X=new SpeechSynthesisUtterance($);F.voice&&(X.voice=F.voice,X.lang=F.voice.lang),X.rate=F.rate,X.onstart=()=>{!I.current||I.current.stopped||i({index:R,total:F.sentences.length,text:$})};const D=()=>{var Z;!I.current||I.current.stopped||(I.current.i+=1,(Z=A.current)==null||Z.call(A))};X.onend=D,X.onerror=D,q.speak(X)});const P=k.useCallback((F,q)=>{var D;if(typeof window>"u"||!("speechSynthesis"in window)){c("engine-unavailable");return}const R=XC(q);if(R.length===0){c("empty-text");return}l.current=R.slice(),o(R.slice()),_.current=R.length,r({index:0,total:R.length,text:R[0]??""});const $=S.current,X=Pd(window.speechSynthesis.getVoices(),($==null?void 0:$.systemVoice)??null);I.current={messageId:F,sentences:R,i:0,stopped:!1,voice:X,rate:Od($==null?void 0:$.speed)},window.speechSynthesis.cancel(),(D=A.current)==null||D.call(A)},[]),N=()=>{if(!d.current){const F=window.AudioContext??window.webkitAudioContext;d.current=new F}return d.current.resume(),d.current},j=k.useCallback(()=>{E.current&&C.current>=v.current&&!y.current&&(w.current=null,t(null),r(null),i(null))},[]),M=k.useCallback(()=>{const F=d.current;if(!F||y.current)return;const q=m.current.get(g.current);if(!q){j();return}const R=g.current;m.current.delete(R),y.current=!0,i({index:R,total:_.current,text:l.current[R]??""}),g.current+=1;const $=F.createBufferSource();$.buffer=q,b3(F,$),Za({ctx:F,timeline:p.current.get(R)??null,startedAtCtxTime:F.currentTime,analyser:m0(F)}),$.onended=()=>{C.current+=1,y.current=!1,Za(null),M()},T.current.push($),$.start()},[j]),L=k.useCallback(()=>{for(const F of T.current)try{F.onended=null,F.stop()}catch{}T.current=[],m.current.clear(),p.current.clear(),Za(null),y.current=!1,v.current=0,C.current=0,E.current=!1,w.current=null,g.current=0,_.current=0,l.current=[],o([]),t(null),r(null),i(null),I.current&&(I.current.stopped=!0,I.current=null),typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()},[]),B=k.useCallback(()=>{L(),window.api.ttsStop().catch(()=>{})},[L]),V=k.useCallback((F,q)=>{var R;if(w.current===F){B();return}if(L(),window.dispatchEvent(new CustomEvent("lookatstudy-speech-start",{detail:F})),c(null),w.current=F,v.current=0,C.current=0,E.current=!1,g.current=0,_.current=0,t(F),r({index:0,total:0,text:""}),((R=S.current)==null?void 0:R.engine)==="system"){P(F,q);return}N(),window.api.ttsSpeak(q,F).then($=>{if($.ok){$.firstUse&&h(!0);return}L(),$.reason!=="empty-text"&&c($.reason)}).catch(()=>L())},[P,B,L]);return k.useEffect(()=>{const F=window.api.on("speech:ttsAudio",$=>{if($.messageId!==w.current)return;const X=N();v.current+=1,_.current=$.sentenceTotal,r({index:$.sentenceIndex,total:$.sentenceTotal,text:$.sentence??""}),$.sentence!=null&&(l.current[$.sentenceIndex]=$.sentence,o(l.current.slice())),X.decodeAudioData($.wavBytes).then(D=>{var Z;if($.messageId===w.current){m.current.set($.sentenceIndex,D);try{const le=(Z=$.visemeCues)!=null&&Z.length?I3($.visemeCues):_3(R3(D),D.sampleRate);le&&p.current.set($.sentenceIndex,le)}catch{}M()}},()=>{$.messageId===w.current&&(v.current-=1,M())})}),q=window.api.on("speech:ttsDone",$=>{$.messageId===w.current&&(E.current=!0,j())}),R=window.api.on("speech:ttsError",()=>L());return()=>{F(),q(),R()}},[j,M,L]),k.useEffect(()=>L,[L]),k.useEffect(()=>{const F=q=>{const R=q.detail;w.current&&R!==w.current&&L()};return window.addEventListener("lookatstudy-speech-start",F),()=>window.removeEventListener("lookatstudy-speech-start",F)},[L]),k.useEffect(()=>{let F=!0;const q=()=>{Promise.all([window.api.getSetting("tts_engine"),window.api.getSetting("tts_system_voice"),window.api.getSetting("tts_speed")]).then(([R,$,X])=>{F&&(S.current={engine:(R??"").trim(),systemVoice:$??null,speed:Od(X)})}).catch(()=>{})};return q(),window.addEventListener(Rd,q),()=>{F=!1,window.removeEventListener(Rd,q)}},[]),k.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const F=()=>{var R;const q=I.current;!q||q.voice||(q.voice=Pd(window.speechSynthesis.getVoices(),((R=S.current)==null?void 0:R.systemVoice)??null))};return window.speechSynthesis.addEventListener("voiceschanged",F),()=>window.speechSynthesis.removeEventListener("voiceschanged",F)},[]),k.useEffect(()=>{A1(e!==null)},[e]),{speakingMessageId:e,speakingSentence:n,playingSentence:s,streamTexts:a,failReason:u,clearFailReason:()=>c(null),onlineNotice:f,clearOnlineNotice:()=>h(!1),speak:V,stop:B}}function R3(e){if(e.numberOfChannels===1)return e.getChannelData(0);const t=e.getChannelData(0),n=e.getChannelData(1),r=new Float32Array(t.length);for(let s=0;s<t.length;s++)r[s]=(t[s]+n[s])/2;return r}function Od(e){const t=typeof e=="number"?e:Number.parseFloat(e??"");return Number.isFinite(t)?Math.min(2,Math.max(.5,t)):1}const x0=k.createContext(null);let L3=0;const P3={default:4e3,success:4e3,info:4e3,warning:5e3,error:6e3},M3={default:null,success:x.jsx(Nl,{className:"w-4 h-4 text-brand shrink-0"}),error:x.jsx(cx,{className:"w-4 h-4 text-warning shrink-0"}),warning:x.jsx(Ll,{className:"w-4 h-4 text-review shrink-0"}),info:x.jsx(Tx,{className:"w-4 h-4 text-accent shrink-0"})};function D3({children:e}){const[t,n]=k.useState([]),r=k.useCallback(a=>{n(o=>o.filter(l=>l.id!==a))},[]),s=k.useCallback(a=>{n(o=>o.map(l=>l.id===a?{...l,exiting:!0}:l))},[]),i=k.useCallback((a,o)=>{const l=++L3,u=(o==null?void 0:o.severity)??"default",c=(o==null?void 0:o.duration)??P3[u],f={id:l,message:a,action:o==null?void 0:o.action,duration:c,severity:u,exiting:!1};n(h=>[...h,f]),window.setTimeout(()=>s(l),c)},[s]);return x.jsxs(x0.Provider,{value:{show:i},children:[e,x.jsx("div",{className:"fixed top-14 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 pointer-events-none",role:"region","aria-live":"polite","aria-label":"Notifications",children:t.map(a=>x.jsx(O3,{item:a,onAction:()=>{a.action.onClick(),s(a.id)},onDismiss:()=>s(a.id),onExitDone:()=>r(a.id)},a.id))})]})}function O3({item:e,onAction:t,onDismiss:n,onExitDone:r}){const s=Ke(),i=M3[e.severity];return x.jsxs("div",{className:`pointer-events-auto flex items-center gap-2.5 pl-4 pr-2 py-2 rounded-full bg-surface-0 text-ink-strong text-body shadow-elevated max-w-md ${e.exiting?"toast-exit":"toast-enter"}`,"data-testid":`toast-${e.id}`,"data-severity":e.severity,onAnimationEnd:e.exiting?r:void 0,children:[i,x.jsx("span",{className:"flex-1",children:e.message}),e.action&&x.jsx("button",{onClick:t,className:"text-brand font-bold text-body hover:underline shrink-0 px-1.5 py-1 rounded transition-colors hover:bg-brand/10","data-testid":`toast-action-${e.id}`,children:e.action.label}),x.jsx("button",{onClick:n,className:"text-ink-muted hover:text-ink-strong shrink-0 w-6 h-6 flex items-center justify-center rounded transition-colors hover:bg-surface-3","aria-label":s("action.close"),children:x.jsx(kr,{className:"w-3.5 h-3.5"})})]})}function iu(){const e=k.useContext(x0);return e||{show:()=>{}}}const b0={typescript:()=>we(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),tsx:()=>we(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),javascript:()=>we(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),jsx:()=>we(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),python:()=>we(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),go:()=>we(()=>import("./go-C27-OAKa.js"),[],import.meta.url),rust:()=>we(()=>import("./rust-B1yitclQ.js"),[],import.meta.url),java:()=>we(()=>import("./java-CylS5w8V.js"),[],import.meta.url),c:()=>we(()=>import("./c-BIGW1oBm.js"),[],import.meta.url),cpp:()=>we(()=>import("./cpp-DddhVWhK.js"),__vite__mapDeps([5,6]),import.meta.url),csharp:()=>we(()=>import("./csharp-DSvCPggb.js"),[],import.meta.url),ruby:()=>we(()=>import("./ruby-B6QtyW_S.js"),__vite__mapDeps([7,8,9,10,11,12,13,14,15,16,17,5,6,18,19,20]),import.meta.url),php:()=>we(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([21,8,9,10,11,12,13,22]),import.meta.url),swift:()=>we(()=>import("./swift-C2oV4EkX.js"),[],import.meta.url),kotlin:()=>we(()=>import("./kotlin-BdnUsdx6.js"),[],import.meta.url),lua:()=>we(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([19,6]),import.meta.url),r:()=>we(()=>import("./r-Cf5RLm7j.js"),[],import.meta.url),shellscript:()=>we(()=>import("./shellscript-Yzrsuije.js"),[],import.meta.url),sql:()=>we(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),html:()=>we(()=>import("./html-pp8916En.js"),__vite__mapDeps([8,9,10]),import.meta.url),css:()=>we(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),scss:()=>we(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([23,10]),import.meta.url),xml:()=>we(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([11,12]),import.meta.url),json:()=>we(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),yaml:()=>we(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url),toml:()=>we(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),ini:()=>we(()=>import("./ini-BEwlwnbL.js"),[],import.meta.url),markdown:()=>we(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),dockerfile:()=>we(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),makefile:()=>we(()=>import("./makefile-CHLpvVh8.js"),[],import.meta.url),diff:()=>we(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),graphql:()=>we(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([14,9,15,16,17]),import.meta.url),latex:()=>we(()=>import("./latex-B2nUCzCX.js"),__vite__mapDeps([24,25]),import.meta.url),vue:()=>we(()=>import("./vue-CHlpWS_5.js"),__vite__mapDeps([26,10,9,15,22,8]),import.meta.url)},Fd={js:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",py:"python",python3:"python",rb:"ruby",golang:"go",rs:"rust",cs:"csharp",kt:"kotlin",sh:"shellscript",bash:"shellscript",zsh:"shellscript",shell:"shellscript",console:"shellscript",yml:"yaml",md:"markdown",gfm:"markdown",docker:"dockerfile",tex:"latex",plaintext:"",txt:"",text:""};function F3(e){const t=e.trim().toLowerCase();return t?t in Fd?Fd[t]||null:t in b0?t:null:null}let Xr=null;const Bd=new Set;function su(){return Xr||(Xr=(async()=>{const[e,t,n,r]=await Promise.all([we(()=>import("./core-iYZpQJa6.js"),__vite__mapDeps([27,1,2]),import.meta.url),we(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),we(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url),we(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url)]);return e.createHighlighterCore({themes:[n.default,r.default],langs:[],engine:t.createJavaScriptRegexEngine({forgiving:!0})})})(),Xr.catch(()=>{Xr=null})),Xr}async function y0(e){const t=F3(e);if(!t)return null;if(Bd.has(t))return t;const n=b0[t];if(!n)return null;const r=await su(),s=await n();return await r.loadLanguage(s),Bd.add(t),t}async function B3(e,t){try{const n=await y0(t);return n?(await su()).codeToHtml(e,{lang:n,themes:{light:"github-light",dark:"github-dark"},defaultColor:"dark"}):null}catch{return null}}const j3=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");async function U4(e,t){try{const n=await y0(t);return n?(await su()).codeToTokens(e,{lang:n,theme:"github-dark"}).tokens.map(i=>i.map(a=>`<span style="color:${a.color}">${j3(a.content)}</span>`).join("")):null}catch{return null}}function H3(e){const t=Array.isArray(e)?e[0]:e,n=(t==null?void 0:t.props)??{},r=/language-(\w+)/.exec(n.className??""),s=n.children,i=typeof s=="string"?s:Array.isArray(s)?s.join(""):"";return{lang:(r==null?void 0:r[1])??"",text:i}}function E0({children:e,...t}){const n=Ke(),[r,s]=k.useState(!1),[i,a]=k.useState(null),{lang:o,text:l}=H3(e);k.useEffect(()=>{let c=!0;if(l)return B3(l.replace(/\n$/,""),o).then(f=>{c&&f&&a(f)}),()=>{c=!1}},[l]);const u=()=>{var c;(c=navigator.clipboard)==null||c.writeText(l).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})};return x.jsxs("div",{className:"relative group my-3","data-testid":"md-codeblock",children:[x.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-1 border border-b-0 border-[var(--border-faint)] rounded-t-md",children:[x.jsx("span",{className:"text-caption font-mono text-ink-faint uppercase tracking-wider",children:o||"code"}),x.jsx("button",{onClick:u,"aria-label":n("chat.copy"),className:"text-caption text-ink-muted hover:text-brand transition-colors opacity-0 group-hover:opacity-100 pointer-coarse:opacity-100 inline-flex items-center gap-1","data-testid":"md-copy",children:r?x.jsxs(x.Fragment,{children:[x.jsx(An,{className:"w-3 h-3 inline"}),n("chat.copied")]}):x.jsxs(x.Fragment,{children:[x.jsx(hx,{className:"w-3 h-3 inline"}),n("chat.copy")]})})]}),i?x.jsx("div",{className:"md-shiki","data-testid":"md-shiki",dangerouslySetInnerHTML:{__html:i}}):x.jsx("pre",{...t,className:"!mt-0 !rounded-t-none !border-t-0",children:e})]})}const v0=k.lazy(()=>we(()=>import("./index-Zmq94tKz.js"),__vite__mapDeps([28,1,2,29,30,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer}))),U3=k.lazy(()=>we(()=>import("./CanvasStage-BbqLSbD4.js").then(e=>e.a),__vite__mapDeps([29,1,2]),import.meta.url).then(e=>({default:e.CanvasStage}))),z3=k.lazy(()=>we(()=>import("./ReviewPanel-D1jKVMQK.js"),__vite__mapDeps([32,1,2]),import.meta.url).then(e=>({default:e.SelfRatingCard}))),V3={concept_map:Mh,quiz:Ih,compare_table:Ux,diagram:xx,code_walkthrough:fx},q3=new Set(["concept_map","quiz","compare_table","diagram","code_walkthrough"]);function W3(e,t){return q3.has(t)?e(`artifact.type.${t}`):e("artifact.type.unknown")}function $3({selectedNode:e,items:t,loading:n,forceTab:r,canvasArtifact:s,isReviewing:i,onReviewDone:a,onUserTabChange:o,onRemove:l,onTogglePin:u,onRecordQuizResult:c,onSaveContentNote:f,onUpdateNoteComment:h,onJumpToSource:d,onQuoteToChat:m,locale:p}){var _;const g=Ke(),[y,T]=k.useState("content"),v=r??y,C=S=>{T(S),o==null||o()},E=e?t.filter(S=>S.nodeId===e.id):[],w=k.useRef(null);return k.useEffect(()=>{var S;(S=w.current)==null||S.scrollTo({top:0})},[e==null?void 0:e.id]),x.jsxs("div",{className:"relative h-full flex flex-col bg-surface-2","data-testid":"notebook-panel",children:[x.jsx("div",{className:"px-3 pt-3 pb-1 shrink-0","data-testid":"notebook-tabs",children:x.jsxs("div",{className:"flex p-1 rounded-lg gap-1 bg-ink/[0.08]",role:"tablist","aria-label":"Notebook",children:[x.jsx(ro,{label:g("notebook.tab.explain"),icon:Cn,active:v==="content",onClick:()=>C("content"),testid:"tab-content"}),x.jsx(ro,{label:g("notebook.tab.notes"),icon:Cx,active:v==="notes",onClick:()=>C("notes"),testid:"tab-notes",badge:E.length>0?String(E.length):void 0}),x.jsx(ro,{label:g("notebook.tab.board"),icon:Ta,active:v==="board",onClick:()=>C("board"),testid:"tab-board"})]})}),x.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 animate-tab-slide",ref:w,role:"tabpanel",children:v==="board"?x.jsx("div",{className:"h-full flex flex-col","data-testid":"board-tab-content",children:s?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"px-4 pt-3 pb-2 shrink-0 flex items-center gap-2 min-w-0",children:[x.jsx(Ta,{className:"w-4 h-4 text-ink-muted shrink-0"}),x.jsx("span",{className:"text-label font-bold text-ink truncate",children:((_=s.output)==null?void 0:_.title)??s.toolName})]}),x.jsx("div",{className:"flex-1 min-h-0 px-2 pb-2",children:x.jsx("div",{className:"h-full rounded-xl overflow-hidden bg-surface-0/60 border border-[var(--border-faint)]",children:x.jsx(k.Suspense,{fallback:null,children:x.jsx(U3,{testid:"board-canvas-stage",children:x.jsx(v0,{data:s.output,variant:"canvas"})})})})})]}):x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[x.jsx(Ta,{className:"w-10 h-10 mb-3 text-ink-muted opacity-30"}),x.jsx("div",{className:"text-body text-ink-muted max-w-sm leading-relaxed",children:g("notebook.board.empty")})]})}):x.jsx(x.Fragment,{children:x.jsx("div",{className:"mx-auto w-full max-w-[960px] min-h-full flex flex-col",children:v==="content"?x.jsx(Y3,{selectedNode:e,contentNotes:E.filter(S=>S.artifactType==="user_note"&&S.sourceAnchor),onQuoteToChat:m,onSaveContentNote:f,locale:p,isReviewing:i,onReviewDone:a}):x.jsx(G3,{items:E,loading:n,selectedNode:e,onRemove:l,onTogglePin:u,onRecordQuizResult:c,onUpdateNoteComment:h,onJumpToSource:d})})})},v)]})}function Y3({selectedNode:e,contentNotes:t,onQuoteToChat:n,onSaveContentNote:r,locale:s,isReviewing:i,onReviewDone:a}){const o=Ke(),l=iu(),u=g0();k.useEffect(()=>{if(u.failReason){const L=u.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":u.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":u.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":u.failReason==="edge-failed"?"chat.speech.edge_failed":"chat.speech.model_missing";l.show(o(L),{severity:"warning"}),u.clearFailReason()}else u.onlineNotice&&(l.show(o("chat.speech.edge_disclosed"),{severity:"info"}),u.clearOnlineNotice())},[u.failReason,u.onlineNotice,l,o,u]);const c=k.useRef(u.stop);c.current=u.stop;const f=e?`content-${e.id}`:null;k.useEffect(()=>()=>{c.current()},[f]);const[h,d]=k.useState(null),m=Kp(h??""),[p,g]=k.useState(!1),[y,T]=k.useState(!1),[v,C]=k.useState([]),[E,w]=k.useState(null),_=k.useRef(null),S=k.useRef(null),I=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;k.useEffect(()=>{if(!e){d(null),T(!1);return}let L=!1;return g(!0),T(!1),oe.getNodeContent(e.id,s??void 0).then(B=>{L||d(B)}).catch(()=>{L||(d(null),T(!0))}).finally(()=>{L||g(!1)}),()=>{L=!0}},[e==null?void 0:e.id,s]),k.useEffect(()=>{if(!e){C([]);return}let L=!1;return oe.listAssetsByNode(e.id).then(B=>{L||C(B)}).catch(()=>{L||C([])}),()=>{L=!0}},[e==null?void 0:e.id]),k.useEffect(()=>{if(!h||!_.current)return;const L=[];for(const V of t)try{const F=JSON.parse(V.sourceAnchor);if(F.type==="content"){const q=JSON.parse(V.data).text??"";q&&L.push({noteId:V.id,text:q,surrounding:F.surroundingText})}}catch{}const B=setTimeout(()=>{S.current&&t0(S.current,L)},80);return()=>clearTimeout(B)},[h,t]),k.useEffect(()=>{const L=B=>{var q;const V=B.detail;if(!V)return;const F=(q=S.current)==null?void 0:q.querySelector(`mark[data-note-id="${V}"]`);F&&u0(F)};return window.addEventListener("lookatstudy-jump-to-note",L),()=>window.removeEventListener("lookatstudy-jump-to-note",L)},[]);const A=u.speakingMessageId===f&&u.playingSentence!=null?u.playingSentence.index:null;k.useEffect(()=>{const L=S.current;if(!L)return;if(A==null){Jn(L);return}const B=Xp(u.streamTexts,A);if(!B)return;A===0&&a0(L);const V=setTimeout(()=>{const F=o0(L,B);F&&l0(F,L.closest(".overflow-y-auto"))},30);return()=>clearTimeout(V)},[A,u.streamTexts,f]),k.useEffect(()=>{A==null&&S.current&&Jn(S.current)},[A]);const P=k.useRef(!1);P.current=A!=null,k.useEffect(()=>()=>{P.current&&Jn(document.body)},[]);const N=k.useCallback(()=>{var K;if(!n&&!r)return;const L=window.getSelection(),B=(L==null?void 0:L.toString().trim())??"";if(B.length<2||B.length>500){w(null);return}const V=L==null?void 0:L.getRangeAt(0);if(!V||!((K=_.current)!=null&&K.contains(V.commonAncestorContainer))){w(null);return}const F=V.getBoundingClientRect(),q=_.current.getBoundingClientRect(),R=S.current;let $=null;if(R&&R.contains(V.commonAncestorContainer)){const ce=wi(R);$=Jp(V,ce)}const X=R?wi(R).text:B,D=$?$.start:X.indexOf(B),Z=D>=0?X.slice(Math.max(0,D-30),D+B.length+30):B,le=V.getClientRects(),z=le.length?le[le.length-1]:F,ee=d0({left:F.left-q.left,top:F.top-q.top,right:F.right-q.left,bottom:F.bottom-q.top,width:F.width,height:F.height},q.width,n?I?190:150:I?140:100,{left:z.left-q.left,top:z.top-q.top,right:z.right-q.left,bottom:z.bottom-q.top,width:z.width,height:z.height},I);w({x:ee.left,y:ee.top,transform:ee.transform,text:B,surrounding:Z,offsets:$??void 0})},[n,r,I]);k.useEffect(()=>{const L=I?600:250;let B=null,V=null,F=!1;const q=()=>{var D;return(((D=window.getSelection())==null?void 0:D.toString().trim().length)??0)>=2},R=()=>{q()?(V&&(clearTimeout(V),V=null),w(D=>D&&null),B&&clearTimeout(B),B=setTimeout(()=>{B=null,!F&&q()&&N()},L)):V||(V=setTimeout(()=>w(D=>D&&null),250))},$=D=>{var le;const Z=D.target;(le=Z==null?void 0:Z.closest)!=null&&le.call(Z,"[data-selection-popover]")||(F=!0)},X=()=>{F=!1,B&&(clearTimeout(B),B=null),!V&&q()&&N()};return document.addEventListener("selectionchange",R),window.addEventListener("pointerdown",$,!0),window.addEventListener("pointerup",X,!0),window.addEventListener("pointercancel",X,!0),()=>{document.removeEventListener("selectionchange",R),window.removeEventListener("pointerdown",$,!0),window.removeEventListener("pointerup",X,!0),window.removeEventListener("pointercancel",X,!0),B&&clearTimeout(B),V&&clearTimeout(V)}},[N]);const j=k.useCallback(()=>{var B;if(!E||!n)return;const L=E.text.length>200?E.text.slice(0,200)+"…":E.text;n(o("notebook.quote.template",{text:L})),w(null),(B=window.getSelection())==null||B.removeAllRanges()},[E,n,o]),M=k.useCallback(()=>{var B,V,F;if(!E||!r||!e)return;const L=E.text.length>200?E.text.slice(0,200)+"…":E.text;r(L,{type:"content",surroundingText:E.surrounding,startOffset:(B=E.offsets)==null?void 0:B.start,endOffset:(V=E.offsets)==null?void 0:V.end}),C1(),setTimeout(()=>{var $;const q=($=S.current)==null?void 0:$.querySelectorAll("mark.lookatstudy-underline"),R=q&&q.length>0?q[q.length-1]:null;R&&l3(R)},200),w(null),(F=window.getSelection())==null||F.removeAllRanges()},[E,r,e]);return e?x.jsxs("div",{className:"p-5 relative","data-testid":"node-content",ref:_,children:[!p&&!y&&h&&x.jsx("div",{className:"sticky top-0 z-20 flex justify-end gap-2 -mt-2 pointer-events-none",children:x.jsx("button",{onClick:()=>u.speak(f??"content",h),"data-tooltip":u.speakingMessageId===f?o("chat.speech.stop"):o("chat.speech.read_aloud_node"),"aria-label":u.speakingMessageId===f?o("chat.speech.stop"):o("chat.speech.read_aloud_node"),"data-testid":u.speakingMessageId===f?"node-content-speak-active":"node-content-speak",className:`pointer-events-auto shrink-0 rounded-full p-2 bg-surface-2 shadow-elevated transition-colors ${u.speakingMessageId===f?"text-brand animate-pulse":"text-ink-muted hover:text-ink-strong"}`,children:u.speakingMessageId===f?x.jsx(Rl,{className:"w-4 h-4"}):x.jsx(Oh,{className:"w-4 h-4"})})}),x.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-1",children:e.type==="section"?o("notebook.node_type.section"):e.type==="concept"?o("notebook.node_type.concept"):o("notebook.node_type.lesson")}),x.jsx("div",{className:"flex items-start justify-between gap-3 mb-4",children:x.jsx("h2",{className:"text-title font-extrabold text-ink-strong tracking-tight","data-testid":"node-content-title",children:e.title})}),p?x.jsxs("div",{className:"text-body text-ink-muted flex items-center gap-2",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),o("notebook.content.loading")]}):y?x.jsxs("div",{className:"text-body text-warning",children:[o("notebook.content.load_failed"),x.jsx("button",{className:"underline ml-1",onClick:()=>{T(!1),g(!0),oe.getNodeContent(e.id,s??void 0).then(d).catch(()=>T(!0)).finally(()=>g(!1))},children:o("notebook.content.retry")})]}):h?x.jsx(WC,{fallback:(L,B)=>x.jsxs("div",{className:"prose prose-sm max-w-[80ch] leading-relaxed [&_pre]:max-w-full [&_pre]:overflow-x-auto",children:[x.jsx("div",{className:"text-body text-warning mb-2",children:o("notebook.content.render_failed")}),x.jsxs("pre",{className:"text-caption text-ink-muted whitespace-pre-wrap break-words bg-surface-1 p-3 rounded",children:[h.slice(0,500),h.length>500?`
475
- `+o("notebook.content.truncated"):""]}),x.jsx("div",{className:"flex gap-2 mt-2",children:x.jsx("button",{className:"text-caption underline text-accent",onClick:B,children:o("notebook.content.retry_render")})})]}),children:x.jsx("div",{ref:S,className:"prose prose-sm max-w-[80ch] leading-relaxed break-words overflow-x-auto [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_img]:max-w-full [&_video]:max-w-full [&_iframe]:max-w-full select-text",children:x.jsx(Om,{remarkPlugins:m.remarkPlugins,rehypePlugins:m.rehypePlugins,urlTransform:L=>L,components:{pre({children:L,...B}){return x.jsx(E0,{...B,children:L})},a({children:L,...B}){return x.jsx("a",{...B,target:"_blank",rel:"noopener noreferrer",children:L})},img({src:L,alt:B,...V}){return x.jsx(K3,{src:L,alt:B,assets:v,...V})},table({children:L}){return x.jsx("div",{className:"overflow-x-auto my-4",children:x.jsx("table",{children:L})})}},children:c0(h)})})},`${e.id}-${s??"orig"}`):x.jsx("div",{className:"text-body text-ink-muted",children:o("notebook.content.empty")}),v.length>0&&x.jsxs("div",{className:"mt-6 pt-4 border-t border-[var(--border-faint)]",children:[x.jsxs("div",{className:"text-label font-bold text-ink-muted mb-2 flex items-center gap-1",children:[x.jsx(vx,{className:"w-3.5 h-3.5"}),x.jsx("span",{children:o("notebook.images.heading",{n:v.length})})]}),x.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:v.map(L=>x.jsx(X3,{asset:L},L.id))})]}),E&&x.jsxs("div",{"data-selection-popover":!0,style:{left:E.x,top:E.y,transform:E.transform},className:"absolute z-20 flex items-center gap-0.5 msg-enter whitespace-nowrap",children:[n&&x.jsxs("button",{onClick:j,"data-testid":"quote-to-chat-btn","aria-label":o("notebook.quote.ask"),className:"px-2 py-1.5 rounded-lg bg-brand text-white text-label font-bold shadow-elevated flex items-center gap-1 hover:bg-brand-light transition-colors",children:[x.jsx(Lh,{className:"w-3 h-3"}),o("notebook.quote.ask")]}),x.jsxs("button",{onClick:M,"data-testid":"save-note-btn","aria-label":o("notebook.quote.add_note"),className:"px-2 py-1.5 rounded-lg bg-accent text-white text-label font-bold shadow-elevated flex items-center gap-1 hover:brightness-110 transition",title:o("notebook.quote.save_note.title"),children:[x.jsx(bi,{className:"w-3.5 h-3.5"}),o("notebook.quote.add_note")]})]}),e.sourcePath&&x.jsx("div",{className:"mt-6 pt-3 border-t border-[var(--border-faint)] text-label text-ink-muted",children:o("notebook.source.label",{path:e.sourcePath})}),x.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-accent/5 border border-accent/20 text-body text-ink-muted flex items-start gap-1.5",children:[x.jsx(wx,{className:"w-3.5 h-3.5 shrink-0 mt-0.5 text-accent"}),x.jsx("span",{children:o("notebook.quote.hint")})]}),i&&e&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(z3,{nodeId:e.id,onRated:a})})]}):x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[x.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),x.jsx("div",{className:"text-body text-ink-muted max-w-xs",children:o("notebook.empty.select_node")})]})}function G3({items:e,loading:t,selectedNode:n,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o}){const l=Ke();if(!n)return x.jsx(jd,{message:l("notebook.empty.notes.title"),icon:"📓"});if(t)return x.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-body text-ink-muted",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),l("notebook.empty.notes.title")]});const u=e.filter(p=>["concept_map","compare_table","diagram","code_walkthrough"].includes(p.artifactType)),c=e.filter(p=>p.artifactType==="user_note"),f=e.filter(p=>p.artifactType==="quiz"),h=e.length,d=f.filter(p=>p.lastResult==="correct").length,m=f.filter(p=>p.lastResult==="wrong").length;return h===0?x.jsx(jd,{message:l("notebook.empty.no_notes_message"),icon:"🧩"}):x.jsxs("div",{className:"p-4 space-y-3","data-testid":"notes-list",children:[x.jsx(eo,{title:l("notebook.zone.understand"),icon:x.jsx(Mh,{className:"w-4 h-4"}),subtitle:l("notebook.zone.understand.subtitle"),count:u.length,testid:"zone-understand",defaultOpen:!1,children:u.length===0?x.jsx(to,{hint:l("notebook.zone.understand.empty_hint")}):u.map(p=>x.jsx(no,{item:p,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},p.id))}),x.jsx(eo,{title:l("notebook.zone.note"),icon:x.jsx(bi,{className:"w-4 h-4"}),subtitle:l("notebook.zone.note.subtitle"),count:c.length,testid:"zone-note",defaultOpen:!1,children:c.length===0?x.jsx(to,{hint:l("notebook.zone.note.empty_hint")}):c.map(p=>x.jsx(no,{item:p,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},p.id))}),x.jsx(eo,{title:l("notebook.zone.practice"),icon:x.jsx(Ih,{className:"w-4 h-4"}),subtitle:f.length>0?l("notebook.zone.practice.subtitle_stats",{total:f.length,correct:d,wrong:m}):l("notebook.zone.practice.subtitle_empty"),count:f.length,testid:"zone-practice",defaultOpen:!1,children:f.length===0?x.jsx(to,{hint:l("notebook.zone.practice.empty_hint")}):f.map(p=>x.jsx(no,{item:p,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},p.id))})]})}function eo({title:e,icon:t,subtitle:n,count:r,testid:s,defaultOpen:i=!0,children:a}){const[o,l]=k.useState(i),u=k.useRef(!0),c=k.useRef(r);return k.useEffect(()=>{if(u.current){u.current=!1,c.current=r;return}r>c.current&&l(!0),c.current=r},[r]),x.jsxs("section",{className:"rounded-xl bg-surface-1 overflow-hidden","data-testid":s,children:[x.jsxs("button",{onClick:()=>l(f=>!f),"aria-expanded":o,className:"w-full flex items-center gap-2 px-3 py-2.5 bg-surface-1/50 hover:bg-surface-3/60 transition-colors text-left","data-testid":`${s}-toggle`,children:[x.jsx(Il,{className:`w-4 h-4 text-ink-muted transition-transform duration-200 ease-out-back ${o?"":"-rotate-90"}`}),x.jsx("span",{className:"text-body text-ink-strong flex items-center",children:t}),x.jsx("span",{className:"text-body font-bold text-ink",children:e}),x.jsx("span",{className:"text-caption font-bold px-1.5 py-0.5 rounded-full bg-brand/15 text-brand",children:r}),x.jsx("span",{className:"text-label text-ink-muted ml-auto truncate",children:n})]}),x.jsx("div",{className:"grid transition-all duration-200 ease-out-expo",style:{gridTemplateRows:o?"1fr":"0fr"},children:x.jsx("div",{className:"overflow-hidden",children:x.jsx("div",{className:"p-3 space-y-3",children:a})})})]})}function to({hint:e}){return x.jsx("div",{className:"text-center py-3 text-body text-ink-muted",children:e})}function no({item:e,onRemove:t,onTogglePin:n,onRecordQuizResult:r,onUpdateNoteComment:s,onJumpToSource:i}){const a=Ke(),[o,l]=k.useState(!1),[u,c]=k.useState(e.notes??""),f=k.useCallback((v,C,E)=>{e.nodeId&&oe.recordQuizAnswer(e.nodeId,E).catch(()=>{}),r(e.id,E)},[e.nodeId,e.id,r]),h=e.artifactType==="user_note";let d="",m=null;if(h){try{d=JSON.parse(e.data).text??""}catch{d=e.title??""}try{e.sourceAnchor&&(m=JSON.parse(e.sourceAnchor))}catch{m=null}}let p=null;if(!h)try{p=JSON.parse(e.data)}catch{p=null}const g=new Date(e.createdAt),y=`${g.getMonth()+1}/${g.getDate()} ${g.getHours().toString().padStart(2,"0")}:${g.getMinutes().toString().padStart(2,"0")}`;if(h){const v=e.notes&&e.notes.trim().length>0?e.notes:null,C=()=>{c(v??""),l(!0)},E=()=>{c(v??""),l(!1)},w=()=>{s==null||s(e.id,u),l(!1)};return x.jsx("div",{className:`bg-surface-2 rounded-lg p-3 relative ${e.pinned?"ring-1 ring-brand/40 bg-brand/5":""}`,"data-testid":`canvas-item-${e.id.slice(0,8)}`,children:x.jsxs("div",{className:"flex items-start gap-2",children:[x.jsx(Px,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"text-body text-ink leading-relaxed whitespace-pre-wrap",children:d}),s&&o?x.jsxs("div",{className:"mt-2 space-y-1.5","data-testid":`note-comment-edit-${e.id.slice(0,8)}`,children:[x.jsx("textarea",{value:u,onChange:_=>c(_.target.value),rows:2,placeholder:a(v?"notebook.note.comment.ph_edit":"notebook.note.comment.ph_new"),className:"w-full text-label leading-relaxed p-2 rounded-md border border-[var(--border-faint)] bg-surface-0 text-ink resize-none focus:outline-none focus:border-brand","data-testid":`note-comment-textarea-${e.id.slice(0,8)}`}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs("button",{onClick:w,className:"inline-flex items-center gap-1 text-caption font-bold text-white bg-brand hover:bg-brand/90 px-2 py-0.5 rounded","data-testid":`note-comment-save-${e.id.slice(0,8)}`,children:[x.jsx(An,{className:"w-3 h-3"})," ",a("notebook.action.save")]}),x.jsxs("button",{onClick:E,className:"inline-flex items-center gap-1 text-caption text-ink-muted hover:text-ink","data-testid":`note-comment-cancel-${e.id.slice(0,8)}`,children:[x.jsx(kr,{className:"w-3 h-3"})," ",a("notebook.action.cancel")]})]})]}):v?x.jsxs("div",{className:"mt-2 px-2.5 py-1.5 rounded-lg bg-ink/5",children:[x.jsx("div",{className:"text-label text-ink-muted italic leading-relaxed whitespace-pre-wrap",children:v}),s&&x.jsxs("button",{onClick:C,className:"mt-1 inline-flex items-center gap-0.5 text-caption text-ink-muted hover:text-accent","data-testid":`note-comment-edit-btn-${e.id.slice(0,8)}`,title:a("notebook.note.edit_comment"),children:[x.jsx(bi,{className:"w-2.5 h-2.5"})," ",a("notebook.note.edit_comment")]})]}):s?x.jsxs("button",{onClick:C,className:"mt-2 inline-flex items-center gap-0.5 text-caption text-ink-muted hover:text-accent","data-testid":`note-comment-add-${e.id.slice(0,8)}`,title:a("notebook.note.add_comment"),children:[x.jsx(bi,{className:"w-2.5 h-2.5"})," ",a("notebook.note.add_comment")]}):null,m&&i&&x.jsx("button",{onClick:()=>i(m,d,e.id),className:"mt-2 inline-flex items-center gap-1 text-caption text-accent hover:underline font-bold","data-testid":`note-source-${e.id.slice(0,8)}`,children:m.type==="content"?x.jsxs(x.Fragment,{children:[x.jsx(Cn,{className:"w-3 h-3"}),a("notebook.source.jump_content")]}):x.jsxs(x.Fragment,{children:[x.jsx(Lh,{className:"w-3 h-3"}),a("notebook.source.jump_chat")]})}),x.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[x.jsx("span",{className:"text-caption text-ink-muted",children:y}),x.jsx("button",{onClick:()=>t(e.id),className:"text-caption text-ink-muted hover:text-warning","data-testid":`canvas-delete-${e.id.slice(0,8)}`,title:a("notebook.note.delete"),children:x.jsx(Co,{className:"w-3 h-3"})})]})]})]})})}const T=V3[e.artifactType]??Lx;return x.jsxs("div",{className:`bg-surface-2 rounded-lg p-3 relative ${e.pinned?"ring-1 ring-brand/40 bg-brand/5":""}`,"data-testid":`canvas-item-${e.id.slice(0,8)}`,children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.jsx("span",{className:"text-body inline-flex items-center text-ink-strong",children:x.jsx(T,{className:"w-4 h-4"})}),x.jsx("span",{className:"text-label font-bold text-ink-muted flex-1 truncate",children:e.title??W3(a,e.artifactType)}),e.artifactType==="quiz"&&e.lastResult&&x.jsx("span",{className:`text-caption font-bold px-1.5 py-0.5 rounded-full ${e.lastResult==="correct"?"bg-brand/15 text-brand":"bg-warning/15 text-warning"}`,"data-testid":`quiz-result-${e.id.slice(0,8)}`,children:e.lastResult==="correct"?a("notebook.quiz.last_correct"):a("notebook.quiz.last_wrong")}),e.pinned?x.jsxs("span",{className:"text-caption text-brand font-bold flex items-center gap-0.5",children:[x.jsx(sc,{className:"w-2.5 h-2.5"}),a("notebook.note.pinned")]}):null,x.jsx("button",{onClick:()=>n(e.id),className:"text-caption text-ink-muted hover:text-brand","data-testid":`canvas-pin-${e.id.slice(0,8)}`,title:e.pinned?a("notebook.note.unpin"):a("notebook.note.pin"),children:x.jsx(sc,{className:"w-3 h-3"})}),x.jsx("button",{onClick:()=>t(e.id),className:"text-caption text-ink-muted hover:text-warning","data-testid":`canvas-delete-${e.id.slice(0,8)}`,title:a("notebook.note.delete"),children:x.jsx(Co,{className:"w-3 h-3"})})]}),x.jsx("div",{className:"text-label",children:p?x.jsx(k.Suspense,{fallback:null,children:x.jsx(v0,{data:p,onQuizAnswered:f})}):x.jsx("div",{className:"text-ink-muted",children:a("notebook.artifact.broken")})}),x.jsx("div",{className:"text-caption text-ink-muted mt-2",children:y})]})}function jd({message:e,icon:t}){return x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6","data-testid":"empty-notebook",children:[x.jsx("div",{className:"text-4xl mb-3 opacity-30",children:t}),x.jsx("div",{className:"text-body text-ink-muted max-w-xs leading-relaxed",children:e})]})}function ro({label:e,icon:t,active:n,onClick:r,testid:s,badge:i}){return x.jsxs("button",{onClick:r,"data-testid":s,role:"tab","aria-selected":n,className:`flex-1 flex items-center justify-center gap-1 py-1.5 rounded-md text-label font-bold transition-colors ${n?"bg-brand/20 text-brand":"text-ink-muted hover:text-ink-strong"}`,children:[x.jsx(t,{className:"w-3 h-3"}),x.jsx("span",{children:e}),i&&x.jsx("span",{className:`text-caption px-1.5 py-0.5 rounded-full font-bold ${n?"bg-brand/30 text-brand":"bg-ink/10 text-ink-faint"}`,children:i})]})}function K3({src:e,alt:t,assets:n,...r}){const[s,i]=k.useState(null),a=e??"",o=k.useMemo(()=>{if(!a||a.startsWith("http")||a.startsWith("data:"))return null;const u=a.split("/").pop()??a;return n.find(c=>{var f;return(f=c.sourcePath)==null?void 0:f.endsWith(u)})??n.find(c=>c.filename===u)??null},[a,n]);if(k.useEffect(()=>{if(!o){i(null);return}let u=!1;return oe.getAssetDataUrl(o.id).then(c=>{u||i(c)}),()=>{u=!0}},[o]),!a)return null;const l=s??a;return x.jsx("img",{src:l,alt:t??"","data-asset-id":o==null?void 0:o.id,className:"rounded-lg max-w-full h-auto my-3",loading:"lazy",...r})}function X3({asset:e}){const t=Ke(),[n,r]=k.useState(null),[s,i]=k.useState(!1);return k.useEffect(()=>{let a=!1;return oe.getAssetDataUrl(e.id).then(o=>{a||r(o)}),()=>{a=!0}},[e.id]),x.jsxs(x.Fragment,{children:[x.jsx("button",{onClick:()=>i(!0),className:"block rounded-lg overflow-hidden bg-ink/5 dark:bg-ink/10 hover:ring-2 hover:ring-accent transition-all",title:e.altText??e.filename,children:n?x.jsx("img",{src:n,alt:e.altText??e.filename,"data-asset-id":e.id,className:"w-full h-24 object-cover",loading:"lazy"}):x.jsx("div",{className:"w-full h-24 flex items-center justify-center text-ink-faint text-caption",children:t("notebook.asset.loading")})}),s&&n&&x.jsxs("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-8 cursor-pointer",onClick:()=>i(!1),children:[x.jsx("img",{src:n,alt:e.altText??e.filename,"data-asset-id":e.id,className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg"}),x.jsx("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white","aria-label":t("action.close"),onClick:a=>{a.stopPropagation(),i(!1)},children:x.jsx(kr,{className:"w-6 h-6"})})]})]})}function Q3(e){const[t,n]=k.useState([]),[r,s]=k.useState(!0),i=k.useCallback(async()=>{if(!e){n([]),s(!1);return}try{const m=await oe.canvasList(e);n(m)}catch{n([])}finally{s(!1)}},[e]);k.useEffect(()=>{i()},[i]);const a=k.useCallback(async m=>{if(!e)return null;try{const p=await oe.canvasSave({...m,courseId:e});return n(g=>g.some(y=>y.id===p.id)?g:[p,...g]),p}catch{return null}},[e]),o=k.useCallback(async m=>{if(!e)return null;try{const p=await oe.canvasSaveUserNote({...m,courseId:e});return n(g=>[p,...g]),p}catch{return null}},[e]),l=k.useCallback(async(m,p)=>{try{const g=await oe.canvasRecordQuizResult(m,p);return g&&n(y=>y.map(T=>T.id===m?g:T)),g}catch{return null}},[]),u=k.useCallback(async(m,p)=>{try{const g=await oe.canvasUpdateUserNoteComment(m,p);return g&&n(y=>y.map(T=>T.id===m?g:T)),g}catch{return null}},[]),c=k.useCallback(async m=>{try{await oe.canvasDelete(m),n(p=>p.filter(g=>g.id!==m))}catch{}},[]),f=k.useCallback(async m=>{try{const p=await oe.canvasTogglePin(m);p&&n(g=>g.map(T=>T.id===m?p:T).sort((T,v)=>v.pinned!==T.pinned?v.pinned-T.pinned:v.createdAt.localeCompare(T.createdAt)))}catch{}},[]),h=k.useCallback(m=>m===null?t:t.filter(p=>p.nodeId===m),[t]),d=k.useCallback((m,p)=>{const g=m===null?t:t.filter(y=>y.nodeId===m);return p==="note"?g.filter(y=>y.artifactType==="user_note"):p==="practice"?g.filter(y=>y.artifactType==="quiz"):g.filter(y=>["concept_map","compare_table","diagram","code_walkthrough"].includes(y.artifactType))},[t]);return{items:t,loading:r,reload:i,save:a,saveUserNote:o,recordQuizResult:l,updateUserNoteComment:u,remove:c,togglePin:f,byNode:h,byZone:d}}const Hd={small:16,medium:17,large:18},Ud="lookatstudy-font-size",J3="medium";function Z3(){const[e,t]=k.useState(()=>{if(typeof localStorage<"u"){const r=localStorage.getItem(Ud);if(r&&r in Hd)return r}return J3});k.useEffect(()=>{document.documentElement.style.fontSize=`${Hd[e]}px`,localStorage.setItem(Ud,e)},[e]);const n=k.useCallback(r=>{t(s=>{const i=["small","medium","large"],a=i.indexOf(s),o=r==="up"?Math.min(a+1,i.length-1):Math.max(a-1,0);return i[o]})},[]);return{size:e,bump:n}}const io=new Map;function e_({ref_:e,onOpen:t}){const n=Ke(),[r,s]=k.useState(e.previewUrl??(e.file?io.get(e.file)??null:null));return k.useEffect(()=>{if(r||!e.file)return;let i=!1;return(async()=>{const a=io.get(e.file);if(a){i||s(a);return}const o=await oe.getAttachmentDataUrl(e.file);o&&!i&&(io.set(e.file,o),s(o))})(),()=>{i=!0}},[e.file,r]),r?x.jsx("button",{type:"button",onClick:()=>t(r),"aria-label":n("chat.attach.preview",{name:e.name}),className:"w-24 h-24 rounded-lg overflow-hidden border border-[var(--border)] hover:border-accent transition-colors shrink-0",children:x.jsx("img",{src:r,alt:e.name,className:"w-full h-full object-cover"})}):x.jsx("div",{className:"w-24 h-24 rounded-lg bg-ink/[0.06] flex items-center justify-center text-caption text-ink-faint",title:e.name,children:e.name.slice(0,8)})}function t_({src:e,name:t,onClose:n}){return k.useEffect(()=>{const r=s=>{s.key==="Escape"&&n()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n]),x.jsxs("div",{role:"dialog","aria-label":t,className:"fixed inset-0 z-[70] bg-black/80 flex items-center justify-center p-8 cursor-zoom-out animate-[toast-enter_.15s_ease-out]",onClick:n,"data-testid":"attachment-lightbox",children:[x.jsx("img",{src:e,alt:t,className:"max-w-full max-h-full object-contain rounded-lg shadow-elevated"}),x.jsx("button",{type:"button","aria-label":"close",onClick:n,className:"absolute top-4 right-4 w-9 h-9 rounded-full bg-white/10 hover:bg-white/20 text-white flex items-center justify-center transition-colors",children:x.jsx(kr,{className:"w-4 h-4"})})]})}function n_({parts:e}){const t=Ke(),[n,r]=k.useState(null),s=e.filter(o=>o.type==="attachment").map(o=>o.attachment);if(s.length===0)return null;const i=s.filter(o=>o.kind==="image"),a=s.filter(o=>o.kind==="text");return x.jsxs("div",{className:"flex flex-col gap-1.5 mb-1","data-testid":"message-attachments",children:[i.length>0&&x.jsx("div",{className:"flex gap-1.5 flex-wrap",children:i.map((o,l)=>x.jsx(e_,{ref_:o,onOpen:u=>r({src:u,name:o.name})},o.file??o.previewUrl??`${o.name}:${l}`))}),a.length>0&&x.jsx("div",{className:"flex gap-1.5 flex-wrap",children:a.map((o,l)=>x.jsxs("span",{"data-tooltip":t("chat.attach.textChip"),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-ink/[0.06] text-caption text-ink-muted",children:[x.jsx(Ws,{className:"w-3 h-3 shrink-0"}),x.jsx("span",{className:"truncate max-w-[12rem]",children:o.name})]},`${o.name}:${l}`))}),n&&x.jsx(t_,{src:n.src,name:n.name,onClose:()=>r(null)})]})}const r_=k.lazy(()=>we(()=>import("./index-Zmq94tKz.js"),__vite__mapDeps([28,1,2,29,30,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer})));function i_({messages:e,streaming:t,onApplyProposal:n,onRejectProposal:r,summary:s,onStartLearning:i,agentReady:a=!0,onGotoSettings:o,hasNode:l=!0,selectedNodeId:u,threadId:c,onSaveChatNote:f,chatNotes:h,onPickQuizAction:d,onQuizCompleted:m,cardMode:p=!1}){const g=Ke(),y=iu(),T=g0();k.useEffect(()=>{if(T.failReason){const F=T.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":T.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":T.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":T.failReason==="edge-failed"?"chat.speech.edge_failed":T.failReason==="custom-provider-missing"?"chat.speech.custom_provider_missing":"chat.speech.model_missing";y.show(g(F),{severity:"warning"}),T.clearFailReason()}},[T.failReason,y,g,T]),k.useEffect(()=>{T.onlineNotice&&(y.show(g("chat.speech.edge_disclosed"),{severity:"info"}),T.clearOnlineNotice())},[T.onlineNotice,y,g,T]);const v=k.useCallback((F,q,R)=>{u&&oe.recordQuizAnswer(u,R,F.kc).catch(()=>{})},[u]),[C,E]=k.useState(null);k.useEffect(()=>{if(!u){E(null);return}let F=!1;const q=()=>oe.getProgress(u).then($=>{F||E(($==null?void 0:$.mastery)??null)}).catch(()=>{});q();const R=oe.on("state:changed",$=>{$==="mastery"&&q()});return()=>{F=!0,R()}},[u]);const w=k.useRef(null),_=k.useRef(!0),[S,I]=k.useState(!1);k.useEffect(()=>{const F=q=>{const R=q.detail;if(!(R!=null&&R.msgId))return;const $=document.querySelector(`[data-msg-id="${R.msgId}"]`);$&&($.scrollIntoView({behavior:"smooth",block:"center"}),$.classList.add("ring-2","ring-accent","rounded-lg"),setTimeout(()=>$.classList.remove("ring-2","ring-accent","rounded-lg"),2500))};return window.addEventListener("lookatstudy-highlight-message",F),()=>window.removeEventListener("lookatstudy-highlight-message",F)},[]),k.useEffect(()=>{if(t||!w.current||!h||h.length===0)return;const F=setTimeout(()=>{if(!w.current)return;const q=new Map;for(const R of h)try{const $=JSON.parse(R.sourceAnchor);if($.type==="chat"&&$.msgId){const X=JSON.parse(R.data).text??"";if(X){const D=q.get($.msgId)??[];D.push({noteId:R.id,text:X}),q.set($.msgId,D)}}}catch{}for(const[R,$]of q){const X=w.current.querySelector(`[data-msg-id="${R}"]`);X&&t0(X,$)}},150);return()=>clearTimeout(F)},[e,h,t]),k.useEffect(()=>{const F=q=>{var X;const R=q.detail;if(!R)return;const $=(X=w.current)==null?void 0:X.querySelector(`mark[data-note-id="${R}"]`);$&&u0($)};return window.addEventListener("lookatstudy-jump-to-chat-note",F),()=>window.removeEventListener("lookatstudy-jump-to-chat-note",F)},[]);const[A,P]=k.useState(null),N=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,j=k.useCallback(()=>{if(!f||!c)return;const F=window.getSelection(),q=(F==null?void 0:F.toString().trim())??"";if(q.length<2||q.length>500){P(null);return}const R=F==null?void 0:F.getRangeAt(0);if(!R){P(null);return}const $=w.current;if(!($!=null&&$.contains(R.commonAncestorContainer))){P(null);return}let X=R.commonAncestorContainer,D=null;for(;X&&X!==$;){if(X instanceof HTMLElement&&X.dataset.msgId){D=X;break}X=X.parentNode}if(!D){P(null);return}const Z=D.dataset.msgId,le=wi(D),z=Jp(R,le),ee=R.getBoundingClientRect(),K=$.getBoundingClientRect(),ce=R.getClientRects(),fe=ce.length?ce[ce.length-1]:ee,re=d0({left:ee.left-K.left,top:ee.top-K.top,right:ee.right-K.left,bottom:ee.bottom-K.top,width:ee.width,height:ee.height},K.width,N?150:110,{left:fe.left-K.left,top:fe.top-K.top,right:fe.right-K.left,bottom:fe.bottom-K.top,width:fe.width,height:fe.height},N);P({x:re.left,y:re.top,transform:re.transform,text:q,msgId:Z,startOffset:z==null?void 0:z.start,endOffset:z==null?void 0:z.end})},[f,c,N]);k.useEffect(()=>{const F=N?600:250;let q=null,R=null,$=!1;const X=()=>{var z;return(((z=window.getSelection())==null?void 0:z.toString().trim().length)??0)>=2},D=()=>{X()?(R&&(clearTimeout(R),R=null),P(z=>z&&null),q&&clearTimeout(q),q=setTimeout(()=>{q=null,!$&&X()&&j()},F)):R||(R=setTimeout(()=>P(z=>z&&null),250))},Z=z=>{var K;const ee=z.target;(K=ee==null?void 0:ee.closest)!=null&&K.call(ee,"[data-selection-popover]")||($=!0)},le=()=>{$=!1,q&&(clearTimeout(q),q=null),!R&&X()&&j()};return document.addEventListener("selectionchange",D),window.addEventListener("pointerdown",Z,!0),window.addEventListener("pointerup",le,!0),window.addEventListener("pointercancel",le,!0),()=>{document.removeEventListener("selectionchange",D),window.removeEventListener("pointerdown",Z,!0),window.removeEventListener("pointerup",le,!0),window.removeEventListener("pointercancel",le,!0),q&&clearTimeout(q),R&&clearTimeout(R)}},[j]);const M=k.useCallback(()=>{var q;if(!A||!f)return;const F=A.text.length>200?A.text.slice(0,200)+"…":A.text;f(F,A.msgId,A.startOffset,A.endOffset),P(null),(q=window.getSelection())==null||q.removeAllRanges()},[A,f]),L=k.useCallback(()=>{const F=w.current;if(!F)return;const q=F.scrollHeight-F.scrollTop-F.clientHeight<80;_.current=q,I(R=>R===!q?R:!q)},[]);k.useEffect(()=>{if(!_.current)return;const F=w.current;F&&(F.scrollTop=F.scrollHeight)},[e,t]);const B=e.length>0&&e[e.length-1].role==="user";k.useEffect(()=>{if(!B)return;_.current=!0,I(!1);const F=w.current;F&&(F.scrollTop=F.scrollHeight)},[B]);const V=k.useCallback(()=>{const F=w.current;F&&(F.scrollTop=F.scrollHeight,_.current=!0,I(!1))},[]);return x.jsxs("div",{className:"relative flex-1 min-h-0",children:[x.jsxs("div",{ref:w,onScroll:L,className:`h-full overflow-y-auto px-3 py-4 space-y-2 relative ${p?"":"px-5 py-6 space-y-6"}`,"data-testid":"chat-stream",children:[e.length===0&&x.jsx("div",{className:"mt-10 mx-auto max-w-md","data-testid":"chat-empty-state",children:l?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"text-center mb-4",children:[x.jsx("div",{className:"text-4xl mb-2 opacity-30",children:"📖"}),x.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:g("chat.empty.greeting")}),x.jsx("div",{className:"text-ink-muted text-label",children:g("chat.empty.overview")})]}),s?x.jsxs("div",{className:"surface-card p-4 mb-4",children:[x.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-2",children:g("chat.empty.summary.title")}),x.jsx("div",{className:"text-body text-ink-muted leading-relaxed whitespace-pre-wrap",children:s})]}):x.jsx("div",{className:"surface-card p-4 mb-4 text-center",children:x.jsx("div",{className:"text-body text-ink-muted",children:g("chat.empty.summary.none")})}),a?x.jsx(x.Fragment,{children:i&&x.jsxs("button",{onClick:i,disabled:t,"data-testid":"start-learning-btn",className:"btn-3d-brand w-full py-3 text-body font-bold flex items-center justify-center gap-2 disabled:opacity-40",children:[x.jsx(Mx,{className:"w-4 h-4"}),x.jsx("span",{children:g("chat.empty.start")})]})}):x.jsxs("div",{className:"surface-card p-4 mb-2","data-testid":"keyless-card",children:[x.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:g("chat.empty.keyless.title")}),x.jsx("div",{className:"text-label text-ink-muted mb-3",children:g("chat.empty.keyless.desc")}),x.jsxs("button",{onClick:o,className:"btn-3d-brand w-full py-2 text-body font-bold flex items-center justify-center gap-2",children:[x.jsx(ws,{className:"w-4 h-4"}),x.jsx("span",{children:g("chat.empty.keyless.btn")})]})]})]}):x.jsxs("div",{className:"text-center mt-16","data-testid":"no-node-selected",children:[x.jsx("div",{className:"text-5xl mb-3 opacity-25",children:"🗺️"}),x.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:g("chat.empty.no_node.title")}),x.jsx("div",{className:"text-body text-ink-muted max-w-xs mx-auto",children:g("chat.empty.no_node.desc")})]})}),e.map(F=>x.jsx("div",{className:p?"":"contents",children:x.jsx("div",{className:p&&F.role==="assistant"?"surface-card p-4 rounded-2xl shadow-card":void 0,children:x.jsx(s_,{msg:F,onApplyProposal:n,onRejectProposal:r,onQuizAnswered:v,quizMastery:C,onPickAction:d,onQuizCompleted:m,speakingMessageId:T.speakingMessageId,speakingSentence:T.speakingSentence,playingSentence:T.playingSentence,streamTexts:T.streamTexts,onSpeak:T.speak})})},F.id)),t&&x.jsxs("div",{className:"flex items-center gap-1.5 text-body text-brand",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"})]})]}),S&&e.length>0&&x.jsxs("button",{onClick:V,"data-testid":"scroll-to-bottom","aria-label":g("chat.scroll.bottom"),title:g("chat.scroll.bottom"),className:"absolute bottom-4 right-4 w-9 h-9 rounded-full bg-ink-strong text-surface-0 shadow-elevated flex items-center justify-center hover:scale-105 active:scale-95 transition-transform msg-enter",children:[x.jsx(Il,{className:"w-5 h-5"}),t&&x.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 bg-brand rounded-full border-2 border-[var(--ink-strong)] animate-pulse"})]}),A&&x.jsxs("button",{onClick:M,"data-testid":"save-chat-note-btn","data-selection-popover":!0,style:{left:A.x,top:A.y,transform:A.transform},className:"absolute z-20 px-3 py-1.5 rounded-lg bg-brand text-white text-body font-bold shadow-elevated flex items-center gap-1 hover:bg-brand-light transition msg-enter whitespace-nowrap",title:g("chat.note.add.title"),children:[x.jsx(bi,{className:"w-3 h-3"})," ",g("chat.note.add")]})]})}function zd(e){const t=[];for(const n of e)if(n.role==="assistant")for(let r=0;r<n.parts.length;r++){const s=n.parts[r];s.type==="tool-call"&&s.state==="output-available"&&s.output&&typeof s.output=="object"&&"artifactType"in s.output&&t.push({id:`${n.id}-${r}`,toolName:s.toolName,output:s.output})}return t}function s_({msg:e,onApplyProposal:t,onRejectProposal:n,onQuizAnswered:r,quizMastery:s,onPickAction:i,onQuizCompleted:a,speakingMessageId:o,speakingSentence:l,playingSentence:u,streamTexts:c,onSpeak:f}){const h=Ke(),d=k.useRef(null),m=e.parts.map(T=>T.type==="text"?T.text:"").join("").trim(),p=o===e.id,g=p&&u!=null?u.index:null;k.useEffect(()=>{const T=d.current;if(!T)return;if(g==null){Jn(T);return}const v=Xp(c??[],g);if(!v)return;g===0&&a0(T);const C=setTimeout(()=>{const E=o0(T,v,{within:'[data-testid="part-text"]'});E&&l0(E,T.closest(".overflow-y-auto"))},30);return()=>clearTimeout(C)},[g,c]),k.useEffect(()=>{g==null&&d.current&&Jn(d.current)},[g]);const y=k.useRef(!1);return y.current=g!=null,k.useEffect(()=>()=>{y.current&&Jn(document.body)},[]),e.role==="user"?x.jsx("div",{className:"msg-enter flex justify-end","data-testid":"msg-user","data-msg-id":e.id,children:x.jsxs("div",{className:"max-w-[85%] bg-ink/[0.04] rounded-2xl rounded-br-md px-4 py-2.5",children:[x.jsx(n_,{parts:e.parts}),x.jsx("div",{className:"font-medium text-ink-strong whitespace-pre-wrap select-text text-body",children:e.displayText??e.parts.map((T,v)=>T.type==="text"?x.jsx("span",{children:T.text},v):null)})]})}):x.jsxs("div",{className:"msg-enter",ref:d,"data-testid":"msg-assistant","data-msg-id":e.id,children:[x.jsx("div",{className:"min-w-0 space-y-2.5",children:e.parts.map((T,v)=>x.jsx(a_,{part:T,msgId:e.id,toolCallIdx:v,onApplyProposal:t,onRejectProposal:n,onQuizAnswered:r,quizMastery:s,onPickAction:i,onQuizCompleted:a},v))}),f&&m&&x.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[x.jsx("button",{onClick:()=>f(e.id,m),"data-testid":p?"speech-stop-btn":"speech-speak-btn","aria-label":h(p?"chat.speech.stop":"chat.speech.speak"),title:h(p?"chat.speech.stop":"chat.speech.speak"),className:`w-7 h-7 rounded-lg flex items-center justify-center transition ${p?"bg-brand/15 text-brand":"text-ink-muted hover:bg-ink/[0.06] hover:text-ink"}`,children:p?x.jsx(Rl,{className:"w-3.5 h-3.5"}):x.jsx(Oh,{className:"w-4 h-4"})}),p&&l&&l.total>0&&x.jsx("span",{className:"text-caption text-ink-muted",children:h("chat.speech.progress").replace("{n}",String(l.index+1)).replace("{total}",String(l.total))})]})]})}function a_({part:e,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onQuizAnswered:i,quizMastery:a,onPickAction:o,onQuizCompleted:l}){const u=Kp(e.type==="text"?e.text:"");if(e.type==="text")return x.jsx("div",{className:"prose prose-sm max-w-[80ch] leading-relaxed break-words [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_img]:max-w-full [&_video]:max-w-full [&_iframe]:max-w-full select-text","data-testid":"part-text",children:x.jsx(Om,{remarkPlugins:u.remarkPlugins,rehypePlugins:u.rehypePlugins,urlTransform:m=>m,components:u_,children:c0(e.text)})});if(e.type==="reasoning")return x.jsx(o_,{text:e.text});if(e.type!=="tool-call")return null;const{toolName:c,state:f,output:h,error:d}=e;return x.jsx(l_,{toolName:c,state:f,output:h,error:d,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onQuizAnswered:i,quizMastery:a,onPickAction:o,onQuizCompleted:l})}function o_({text:e}){const t=Ke(),[n,r]=k.useState(!1);return x.jsxs("div",{className:"rounded-lg bg-surface-1/60 border border-[var(--border-faint)]","data-testid":"part-reasoning",children:[x.jsxs("button",{onClick:()=>r(s=>!s),className:"w-full flex items-center justify-between px-3 py-1.5 text-label font-bold text-ink-muted hover:text-ink-strong transition-colors",children:[x.jsxs("span",{children:[n?"▾":"▸"," ",t("chat.reasoning.label")]}),x.jsx("span",{className:"text-ink-muted font-normal",children:t("chat.reasoning.chars",{n:e.length})})]}),n&&x.jsx("div",{className:"px-3 pb-2.5 text-label text-ink-muted whitespace-pre-wrap leading-relaxed border-t border-[var(--border-faint)]/60 pt-2",children:e})]})}function l_({toolName:e,state:t,output:n,error:r,msgId:s,toolCallIdx:i,onApplyProposal:a,onRejectProposal:o,onQuizAnswered:l,quizMastery:u,onPickAction:c,onQuizCompleted:f}){const h=Ke(),m=(e==="record_answer"||e==="mark_mastered")&&t==="output-available"&&typeof n=="object"&&n!==null?n:null;if(m!=null&&m.proposalId){const y=m.status;return y==="applied"?x.jsxs("div",{className:"proposal-card rounded-xl border border-gold/30 bg-gold/5 p-3 flex items-center gap-2","data-testid":"part-proposal",children:[x.jsx(Nl,{className:"w-4 h-4 text-gold shrink-0"}),x.jsx("span",{className:"text-body font-bold text-ink",children:h("chat.proposal.applied")})]}):y==="rejected"?x.jsxs("div",{className:"proposal-card rounded-xl border border-ink/10 bg-ink/5 p-3 flex items-center gap-2","data-testid":"part-proposal",children:[x.jsx(dx,{className:"w-4 h-4 text-ink-muted shrink-0"}),x.jsx("span",{className:"text-body text-ink-muted",children:h("chat.proposal.rejected")})]}):x.jsxs("div",{className:"proposal-card relative rounded-xl border border-brand/30 bg-brand/5 overflow-hidden","data-testid":"part-proposal",children:[x.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-brand"}),x.jsxs("div",{className:"pl-4 pr-3 py-3",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-brand/15 text-brand shrink-0",children:x.jsx(yx,{className:"w-4 h-4"})}),x.jsx("span",{className:"text-lead font-bold text-ink",children:h("chat.proposal.mastered.title")})]}),m.message&&x.jsx("div",{className:"text-body text-ink mb-2 leading-relaxed",children:m.message}),x.jsx("div",{className:"text-caption text-ink-muted mb-3",children:h("chat.proposal.mastered.hint")}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("button",{onClick:()=>a==null?void 0:a(m.proposalId,s,i),"data-testid":"proposal-apply",className:"btn-3d-brand px-4 py-1.5 text-body",children:[x.jsx(An,{className:"w-3.5 h-3.5 inline"}),h("chat.proposal.confirm")]}),x.jsx("button",{onClick:()=>o==null?void 0:o(m.proposalId,s,i),"data-testid":"proposal-reject",className:"btn-3d-neutral px-4 py-1.5 text-body",children:h("chat.proposal.later")})]})]})]})}if(t==="output-available"&&n&&typeof n=="object"&&"artifactType"in n){const y=n.artifactType;return x.jsx("div",{className:"my-1 max-w-full","data-testid":`inline-artifact-${y}`,"data-tool":e,children:x.jsx(k.Suspense,{fallback:null,children:x.jsx(r_,{data:n,onQuizAnswered:l,quizMastery:u,onPickAction:c,onQuizCompleted:f})})})}const g=c_(e,h);return x.jsx("div",{className:"inline-flex items-center gap-1.5 text-label px-2.5 py-1 rounded-md bg-surface-1/60 border border-[var(--border-faint)]","data-testid":"part-tool","data-tool":e,"data-state":t,children:t==="input-available"?x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),x.jsxs("span",{className:"text-ink-muted",children:[g,"…"]})]}):t==="output-error"?x.jsxs(x.Fragment,{children:[x.jsx(Ah,{className:"w-3.5 h-3.5 text-warning shrink-0"}),x.jsxs("span",{className:"text-warning",children:[g,": ",r]})]}):x.jsxs(x.Fragment,{children:[x.jsx(Fh,{className:"w-3.5 h-3.5 text-ink-faint shrink-0"}),x.jsx("span",{className:"text-ink-muted",children:g})]})})}const u_={pre({children:e,...t}){return x.jsx(E0,{...t,children:e})},a({children:e,...t}){return x.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer",children:e})},table({children:e}){return x.jsx("div",{className:"overflow-x-auto my-4",children:x.jsx("table",{children:e})})}};function c_(e,t){return{get_node_info:t("chat.tool.get_node_info"),record_answer:t("chat.tool.record_answer"),mark_mastered:t("chat.tool.mark_mastered"),show_concept_map:t("chat.tool.show_concept_map"),generate_quiz:t("chat.tool.generate_quiz"),compare_table:t("chat.tool.compare_table"),draw_diagram:t("chat.tool.draw_diagram"),show_code_walkthrough:t("chat.tool.show_code_walkthrough")}[e]??e}const fi={maxPerMessage:4,maxImageBytes:5*1024*1024,maxTextBytes:256*1024},d_=new Set(["txt","md","markdown","rst","org","adoc","log","csv","tsv","json","yaml","yml","toml","ini","env","py","js","mjs","cjs","ts","tsx","jsx","go","rs","java","c","h","cpp","hpp","cs","rb","sh","bash","zsh","ps1","sql","html","htm","css","scss","vue","svelte","kt","swift","php","lua","r","dart","scala","clj","ex","exs","erl","hs","ml","jl","m","mm","pl","vb","bat","dockerfile"]);function Vd(e){const t=e.lastIndexOf(".");return t<=0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function f_(e,t,n){return t&&t.startsWith("image/")||["png","jpg","jpeg","webp","gif","bmp"].includes(Vd(e))?n>fi.maxImageBytes?{ok:!1,reason:"tooLargeImage"}:{ok:!0,kind:"image"}:d_.has(Vd(e))?n>fi.maxTextBytes?{ok:!1,reason:"tooLargeText"}:{ok:!0,kind:"text"}:{ok:!1,reason:"unsupported"}}function h_(e,t){const n=e.length,r=n*2,s=new ArrayBuffer(44+r),i=new DataView(s),a=(l,u)=>{for(let c=0;c<u.length;c++)i.setUint8(l+c,u.charCodeAt(c))};a(0,"RIFF"),i.setUint32(4,36+r,!0),a(8,"WAVE"),a(12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),a(36,"data"),i.setUint32(40,r,!0);let o=44;for(let l=0;l<n;l++){const u=e[l]<=-1?-1:e[l]>=1?1:e[l];i.setInt16(o,Math.round(u*32767),!0),o+=2}return s}function m_(e,t){const n=Math.floor(e.length/t),r=new Float32Array(n);for(let s=0;s<n;s++){const i=s*t,a=Math.floor(i),o=i-a,l=e[a]??0,u=e[a+1]??l;r[s]=l+(u-l)*o}return r}function p_(e,t,n={}){if(e.length===0||e.length!==t.length)return e;const r=n.threshold??.012;let s=0;for(;s<e.length-1&&t[s]<r;)s+=1;let i=e.length;for(;i>s+1&&t[i-1]<r;)i-=1;return e.slice(s,i)}function g_(e={}){const t=e.rmsThreshold??.015,n=e.minSpeechMs??300,r=e.silenceMs??1200,s=e.maxMs??6e4,i=e.autoStop!==!1;let a=null,o=0,l=null,u=null,c=!1;return{feed(f,h){a==null&&(a=h);const d=u==null?0:Math.max(0,h-u);if(u=h,f>=t)o+=d,o>=n&&(c=!0,l=h);else if(i&&c&&l!=null&&h-l>=r)return"auto-stop";return i&&h-a>=s?"auto-stop":"listening"},hadSpeech(){return c}}}const so=16e3;function x_(e,t={}){const[n,r]=k.useState(!1),[s,i]=k.useState(!1),[a,o]=k.useState(0),[l,u]=k.useState(null),[c,f]=k.useState(null),h=k.useRef(null),d=k.useRef(null),m=k.useRef(null),p=k.useRef([]),g=k.useRef([]),y=k.useRef(!1),T=k.useRef(null),v=k.useRef(0),C=k.useRef(e);C.current=e;const E=k.useRef(t);E.current=t;const w=k.useRef(!1),_=k.useRef(!1),S=k.useCallback(()=>{var j,M,L;y.current=!1,(j=m.current)==null||j.disconnect(),m.current=null,(M=d.current)==null||M.getTracks().forEach(B=>B.stop()),d.current=null,(L=h.current)==null||L.close().catch(()=>{}),h.current=null,p.current=[],g.current=[],T.current=null,o(0)},[]),I=k.useCallback(()=>{var X;const j=p.current,M=g.current,L=((X=T.current)==null?void 0:X.hadSpeech())??!1;p.current=[],g.current=[];let B=0;for(const D of j)B+=D.length;if(S(),r(!1),B===0)return;if(!L){f("no-speech");return}const V=p_(j,M);let F=0;for(const D of V)F+=D.length;const q=new Float32Array(F);let R=0;for(const D of V)q.set(D,R),R+=D.length;const $=h_(q,so);i(!0),f(null),window.api.asrTranscribe($,E.current.locale).then(D=>{D.ok?C.current(D.text):f(D.reason)}).catch(()=>f("asr-failed")).finally(()=>i(!1))},[S]),A=k.useCallback(()=>{y.current&&I()},[I]),P=k.useCallback(()=>{y.current||w.current||(u(null),w.current=!0,(async()=>{var j;try{if(((j=navigator.mediaDevices)==null?void 0:j.getUserMedia)==null){u(window.isSecureContext?"mic-unavailable":"mic-insecure-context");return}const M=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}}),L=window.AudioContext??window.webkitAudioContext;let B;try{B=new L({sampleRate:so})}catch{B=new L}h.current=B,d.current=M,y.current=!0,T.current=g_({autoStop:E.current.autoStop!==!1});const V=B.createMediaStreamSource(M),F=B.createScriptProcessor(4096,1,1);m.current=F;const q=B.sampleRate/so;F.onaudioprocess=$=>{var ee;if(!y.current)return;const X=$.inputBuffer.getChannelData(0),D=q===1?new Float32Array(X):m_(X,q);p.current.push(D);let Z=0;for(let K=0;K<D.length;K++)Z+=D[K]*D[K];const le=Math.sqrt(Z/D.length);g.current.push(le),v.current=v.current*.7+le*.3,o(Math.min(1,v.current*8)),_1(Math.min(1,v.current*8)),((ee=T.current)==null?void 0:ee.feed(le,performance.now()))==="auto-stop"&&y.current&&I()},V.connect(F);const R=B.createGain();R.gain.value=0,F.connect(R),R.connect(B.destination),r(!0),_.current&&(_.current=!1,I())}catch(M){S(),r(!1),u(M instanceof Error?M.message:String(M))}finally{w.current=!1}})())},[S,I]),N=k.useCallback(()=>{y.current?A():w.current&&(_.current=!0)},[A]);return k.useEffect(()=>()=>{y.current&&S()},[S]),{listening:n,transcribing:s,level:a,startError:l,transcribeError:c,clearTranscribeError:()=>f(null),beginHold:P,endHold:N}}function b_({onGotoSettings:e}){var p;const t=Ke(),[n,r]=k.useState(!1),[s,i]=k.useState(null),[a,o]=k.useState(""),[l,u]=k.useState(""),c=k.useRef(null),f=k.useCallback(async()=>{var g,y;try{const[T,v,C,E]=await Promise.all([oe.getProviderPresets(),oe.listCustomProviders(),oe.getSetting("active_provider"),oe.getSetting("active_model")]),w=C??"glm",_=await Promise.all(T.map(async j=>await oe.getSetting(j.apiKeySetting)!=null)),S=new Set;T.forEach((j,M)=>{(_[M]||j.id===w)&&S.add(j.id)});const I=[],A=(j,M,L)=>{for(const B of L)I.push({providerId:j,providerLabel:M,modelId:B.id,modelLabel:B.label,vision:(B.capabilities??[]).includes("vision"),contextWindow:B.contextWindow})};for(const j of T)S.has(j.id)&&A(j.id,j.label,j.models);const P=v.filter(j=>j.kind==="llm");for(const j of P)A(j.id,j.label,j.models);const N=E??"";if(N&&!I.some(j=>j.providerId===w&&j.modelId===N)){const j=((g=T.find(M=>M.id===w))==null?void 0:g.label)??((y=P.find(M=>M.id===w))==null?void 0:y.label)??w;I.unshift({providerId:w,providerLabel:j,modelId:N,modelLabel:N,vision:!0,contextWindow:null})}i(I),o(w),u(N)}catch{i([])}},[]);k.useEffect(()=>{f();const g=()=>void f();return window.addEventListener("llm-config-changed",g),()=>window.removeEventListener("llm-config-changed",g)},[f]),k.useEffect(()=>{if(!n)return;const g=T=>{var v;T.target instanceof Node&&((v=c.current)==null?void 0:v.contains(T.target))!==!0&&r(!1)},y=T=>{T.key==="Escape"&&r(!1)};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",y)}},[n]);const h=async g=>{if(r(!1),!(g.providerId===a&&g.modelId===l))try{await oe.setSetting("active_provider",g.providerId),await oe.setSetting("active_model",g.modelId),o(g.providerId),u(g.modelId),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},d=((p=s==null?void 0:s.find(g=>g.providerId===a&&g.modelId===l))==null?void 0:p.modelLabel)??l??t("model.picker.label"),m=[];for(const g of s??[]){const y=m[m.length-1];y&&y.label===g.providerLabel?y.rows.push(g):m.push({label:g.providerLabel,rows:[g]})}return x.jsxs("div",{ref:c,className:"relative","data-testid":"composer-model",children:[x.jsxs("button",{type:"button",onClick:()=>r(!n),"aria-haspopup":"menu","aria-expanded":n,"data-tooltip":t("model.picker.label"),"data-testid":"composer-model-trigger",className:"flex items-center gap-1 max-w-[13rem] px-1.5 py-0.5 rounded-full text-caption font-medium text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors",children:[x.jsx(ox,{className:"w-3 h-3 shrink-0 coarse-only","aria-hidden":!0}),x.jsx("span",{className:"truncate tb-label",children:d}),x.jsx(Sh,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${n?"":"rotate-180"}`})]}),n&&x.jsxs("div",{role:"menu","aria-label":t("model.picker.label"),"data-testid":"composer-model-menu",className:"absolute bottom-full right-0 mb-1.5 z-50 w-64 max-w-[calc(100vw-1.5rem)] max-h-72 overflow-y-auto bg-surface-0 rounded-xl shadow-elevated border border-[var(--border)] py-1.5",children:[m.length===0&&x.jsx("div",{className:"px-3 py-2 text-caption text-ink-faint",children:t("model.picker.noneConfigured")}),m.map(g=>x.jsxs("div",{role:"group","aria-label":g.label,children:[x.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-caption font-bold text-ink-faint",children:g.label}),g.rows.map(y=>{const T=y.providerId===a&&y.modelId===l;return x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T,onClick:()=>void h(y),className:`w-full flex items-center gap-1.5 px-3 py-1.5 text-left transition-colors ${T?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"}`,children:[x.jsx(An,{className:`w-3.5 h-3.5 shrink-0 ${T?"opacity-100":"opacity-0"}`}),x.jsx("span",{className:"flex-1 truncate text-label",children:y.modelLabel}),y.vision&&x.jsx(px,{className:"w-3 h-3 shrink-0 text-ink-faint","aria-label":t("model.picker.vision")})]},`${y.providerId}:${y.modelId}`)})]},g.label)),x.jsx("div",{className:"border-t border-[var(--border)] mt-1 pt-1",children:x.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{r(!1),e()},className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-left text-label text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors",children:[x.jsx(Fx,{className:"w-3.5 h-3.5"}),t("model.picker.manage")]})})]})]})}const Ko=5.5,qd=2*Math.PI*Ko,fr=["system","node","learner","history","draft"],Wd={system:"bg-accent",node:"bg-brand",learner:"bg-gold",history:"bg-ink/50",draft:"bg-exam"};function y_({info:e,historyTokens:t,draftTokens:n}){const r=Ke(),[s,i]=k.useState(!1),a=k.useRef(null);if(k.useEffect(()=>{!(e!=null&&e.contextWindow)&&s&&i(!1)},[e==null?void 0:e.contextWindow,s]),k.useEffect(()=>{if(!s)return;const h=m=>{var p;m.target instanceof Node&&((p=a.current)==null?void 0:p.contains(m.target))!==!0&&i(!1)},d=m=>{m.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",h),document.addEventListener("keydown",d),()=>{document.removeEventListener("pointerdown",h),document.removeEventListener("keydown",d)}},[s]),!e)return null;const o={system:e.systemTokens,node:e.nodeTokens,learner:e.learnerTokens,history:t,draft:n},l=fr.reduce((h,d)=>h+o[d],0),u=Wx(l,e.contextWindow),c=u!==null&&u>=85,f=$x(fr.map(h=>o[h]),u??0);return x.jsxs("span",{ref:a,className:"relative inline-flex items-center","data-testid":"composer-context",children:[x.jsxs("button",{type:"button",onClick:()=>i(!s),disabled:e.contextWindow===null,"aria-label":r("context.aria",{p:u!==null?`${u}%`:ur(l)}),"aria-haspopup":"dialog","aria-expanded":s,"data-testid":"composer-context-trigger","data-tooltip":e.contextWindow===null?`${r("context.label")} ~${ur(l)} · ${r("context.unknownWindow")}`:r("context.aria",{p:`${u}%`}),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-full text-caption font-medium transition-colors ${c?"text-warning":"text-ink-muted"} hover:bg-ink/[0.06] disabled:hover:bg-transparent`,children:[x.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":!0,className:"shrink-0",children:[x.jsx("circle",{cx:"7",cy:"7",r:Ko,fill:"none",strokeWidth:"2",className:"stroke-ink/20"}),x.jsx("circle",{cx:"7",cy:"7",r:Ko,fill:"none",strokeWidth:"2",stroke:"currentColor",strokeLinecap:"round",strokeDasharray:`${qd*(u??100)/100} ${qd}`,transform:"rotate(-90 7 7)"})]}),u!==null?x.jsxs("span",{className:"tb-label",children:[u,"%"]}):x.jsxs("span",{className:"tb-label",children:["~",ur(l)]})]}),s&&e.contextWindow!==null&&x.jsxs("div",{role:"dialog","aria-label":r("context.label"),"data-testid":"composer-context-panel",className:"absolute bottom-full right-0 mb-1.5 z-50 w-64 max-w-[calc(100vw-1.5rem)] bg-surface-0 rounded-xl shadow-elevated border border-[var(--border)] p-3",children:[x.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[x.jsx("span",{className:"text-label font-bold text-ink-strong",children:r("context.label")}),x.jsxs("span",{className:`text-caption ${c?"text-warning":"text-ink-muted"}`,children:[r("context.approx")," ",ur(l)," / ",ur(e.contextWindow)]})]}),x.jsx("div",{className:"flex h-2 rounded-full overflow-hidden bg-ink/10 mb-2",role:"img","aria-label":`${u}%`,children:fr.map(h=>f[fr.indexOf(h)]>0?x.jsx("div",{className:Wd[h],style:{width:`${f[fr.indexOf(h)]}%`}},h):null)}),x.jsx("dl",{className:"space-y-1",children:fr.map(h=>x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("dt",{className:"flex items-center gap-1.5 text-caption text-ink-muted",children:[x.jsx("span",{className:`w-2 h-2 rounded-sm ${Wd[h]}`,"aria-hidden":!0}),r(`context.${h}`)]}),x.jsxs("dd",{className:"text-caption text-ink-strong tabular-nums",children:["~",ur(o[h])]})]},h))})]})]})}const Xo={glm:{fast:e=>{e.thinking={type:"disabled"},e.reasoning_effort="low"},deep:e=>{e.thinking={type:"enabled"}}},qwen:{fast:e=>{e.enable_thinking=!1},deep:e=>{e.enable_thinking=!0}},siliconcloud:{fast:e=>{e.enable_thinking=!1},deep:e=>{e.enable_thinking=!0}}};function E_(e,t,n){if(e==="openai"||e in Xo)return e;const r=(t??"").toLowerCase(),s=(n??"").toLowerCase();return r.includes("bigmodel.cn")||r.includes("z.ai")||s.startsWith("glm")?"glm":r.includes("dashscope")||s.startsWith("qwen")?"qwen":r.includes("siliconflow")?"siliconcloud":e}function v_(e,t,n){return t==="anthropic"||t==="google"||e==="openai"||e in Xo?!0:E_(e,n==null?void 0:n.baseUrl,n==null?void 0:n.model)in Xo}const ao=[{value:"",labelKey:"effort.auto.label",descKey:"effort.auto.desc"},{value:"fast",labelKey:"effort.fast.label",descKey:"effort.fast.desc"},{value:"deep",labelKey:"effort.deep.label",descKey:"effort.deep.desc"}];function T_(){const e=Ke(),[t,n]=k.useState(!1),[r,s]=k.useState(""),[i,a]=k.useState(!0),o=k.useRef(null),l=k.useRef(null),[u,c]=k.useState("right"),[f,h]=k.useState(0),d=k.useRef(0),[m,p]=k.useState(0);k.useLayoutEffect(()=>{if(!t){p(0),d.current=0,h(0);return}const v=l.current;if(!v)return;const C=v.getBoundingClientRect(),E=C.left-d.current,w=C.right-d.current,_=window.innerWidth;if(m===0){if(E<8&&w<=_-8){c("left"),p(1);return}if(w>_-8&&E>=8){c("right"),p(1);return}p(1)}const S=Math.min(0,_-8-w)+Math.max(0,8-E);S!==d.current&&(d.current=S,h(S))},[t,m]);const g=k.useCallback(async()=>{var v;try{const[C,E,w,_,S]=await Promise.all([oe.getSetting("active_provider"),oe.getSetting("reasoning_effort"),oe.getProviderPresets(),oe.listCustomProviders(),oe.getSetting("active_model")]),I=C??"glm",A=_.find(j=>j.id===I),P=((v=w.find(j=>j.id===I))==null?void 0:v.protocol)??(A==null?void 0:A.protocol)??"openai-compatible";a(v_(I,P,{baseUrl:A==null?void 0:A.baseUrl,model:S??(A==null?void 0:A.defaultModel)}));const N=E??"";s(N==="fast"||N==="deep"?N:"")}catch{a(!1)}},[]);k.useEffect(()=>{g();const v=()=>void g();return window.addEventListener("llm-config-changed",v),()=>window.removeEventListener("llm-config-changed",v)},[g]),k.useEffect(()=>{if(!t)return;const v=E=>{var w;E.target instanceof Node&&((w=o.current)==null?void 0:w.contains(E.target))!==!0&&n(!1)},C=E=>{E.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",C),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",C)}},[t]);const y=async v=>{if(n(!1),v!==r){s(v);try{await oe.setSetting("reasoning_effort",v)}catch{s(r)}}},T=ao.find(v=>v.value===r)??ao[0];return x.jsxs("div",{ref:o,className:"relative","data-testid":"composer-effort",children:[x.jsxs("button",{type:"button",onClick:()=>!!i&&n(!t),disabled:!i,"aria-haspopup":"menu","aria-expanded":t,"data-testid":"composer-effort-trigger","data-tooltip":e(i?"effort.label":"effort.unsupported"),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-full text-caption font-medium transition-colors ${r?"text-accent":"text-ink-muted"} ${i?"hover:text-ink-strong hover:bg-ink/[0.06]":"opacity-40 cursor-not-allowed"}`,children:[x.jsx(lx,{className:"w-3 h-3 shrink-0"}),x.jsx("span",{className:"truncate tb-label",children:e(T.labelKey)}),x.jsx(Sh,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${t?"":"rotate-180"}`})]}),t&&x.jsx("div",{ref:l,role:"menu","aria-label":e("effort.label"),"data-testid":"composer-effort-menu",style:{transform:f?`translateX(${f}px)`:void 0},className:`absolute bottom-full ${u==="right"?"right-0":"left-0"} mb-1.5 z-50 w-60 max-w-[calc(100vw-1.5rem)] bg-surface-0 rounded-xl shadow-elevated border border-[var(--border)] py-1.5`,children:ao.map(v=>{const C=v.value===r;return x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":C,onClick:()=>void y(v.value),className:`w-full flex items-start gap-1.5 px-3 py-1.5 text-left transition-colors ${C?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"}`,children:[x.jsx(An,{className:`w-3.5 h-3.5 shrink-0 mt-0.5 ${C?"opacity-100":"opacity-0"}`}),x.jsxs("span",{className:"flex-1",children:[x.jsx("span",{className:"block text-label font-bold",children:e(v.labelKey)}),x.jsx("span",{className:"block text-caption text-ink-faint",children:e(v.descKey)})]})]},v.value||"auto")})})]})}const k_=k.lazy(()=>we(()=>import("./VoicePanel-BP1Ur7sF.js"),__vite__mapDeps([33,1,2,31]),import.meta.url).then(e=>({default:e.VoicePanel}))),w_={direct:"soul.direct",guide:"soul.guide",practice:"soul.practice"},S_={direct:Cn,guide:Ch,practice:Ex},A_={direct:"soul.direct.desc",guide:"soul.guide.desc",practice:"soul.practice.desc"},C_=["image/png","image/jpeg","image/webp","image/gif",".txt",".md",".markdown",".rst",".org",".adoc",".log",".csv",".tsv",".json",".yaml",".yml",".toml",".ini",".py",".js",".mjs",".cjs",".ts",".tsx",".jsx",".go",".rs",".java",".c",".h",".cpp",".hpp",".cs",".rb",".sh",".sql",".html",".css",".scss",".vue",".svelte",".kt",".swift",".php"].join(",");let $d=0;function __({nodeId:e,agentReady:t,streaming:n,souls:r,activeSoul:s,starterPrompts:i,onPickSoul:a,onSend:o,onStop:l,onLogFriction:u,onGotoSettings:c,insertText:f,historyTokens:h}){const d=Ke(),m=zh(),[p,g]=k.useState(""),[y,T]=k.useState([]),[v,C]=k.useState(null),[E,w]=k.useState(null),[_,S]=k.useState(!1),I=k.useRef(null),A=k.useRef(0),[P,N]=k.useState(!0);k.useEffect(()=>{oe.getSetting("asr_auto_stop").then(te=>N(te!=="0"))},[]);const[j,M]=k.useState(!1);k.useEffect(()=>(Ku(j),()=>Ku(!1)),[j]);const[L,B]=k.useState(""),[V,F]=k.useState(!1),[q,R]=k.useState(null),$=x_(te=>{B(te),F(!0)},{locale:m,autoStop:P}),X=$.startError??$.transcribeError;k.useEffect(()=>{if(!X)return;R(d(X==="no-speech"?"chat.speech.no_speech":X==="model-missing"?"chat.speech.asr_model_missing":X==="engine-unavailable"?"chat.speech.engine_unavailable":X==="custom-provider-missing"?"chat.speech.custom_provider_missing":X==="groq-key-missing"?"chat.speech.groq_key_missing":X==="azure-key-missing"?"chat.speech.azure_stt_key_missing":X==="azure-region-missing"?"chat.speech.azure_stt_region_missing":X==="mic-insecure-context"?"chat.speech.asr_insecure_context":X==="mic-unavailable"?"chat.speech.asr_start_fail":"chat.speech.asr_failed")),$.clearTranscribeError()},[X,$,d]);const D=q?"error":$.listening?"recording":$.transcribing?"transcribing":V?"review":"idle",Z=(te,Re,me)=>{I1(),o(te,Re,me)},le=k.useCallback(()=>{B(""),F(!1),R(null)},[]),z=k.useCallback(()=>{M(!1),le()},[le]),ee=()=>{const te=L.trim();!te||n||!e||(Z(te),z())};k.useEffect(()=>{f&&g(te=>te.trim()?`${te}
474
+ `)}function d0(e,t,n,r,s){const a=r??e,o=a.top+a.height/2;return!s&&a.right+8+n<=t?{left:a.right+8,top:o,transform:"translate(0, -50%)"}:!s&&e.left-8-n>=0?{left:e.left-8,top:o,transform:"translate(-100%, -50%)"}:{left:Math.min(Math.max(e.left,0),Math.max(0,t-n)),top:a.bottom+8,transform:"translate(0, 0)"}}const Rd="lookatstudy-tts-settings-changed";function Ld(e){const t=n=>{const r=n.toLowerCase();return r==="zh-cn"||r==="zh_cn"||r==="zh"?0:r.startsWith("zh")?1:2};return[...e].sort((n,r)=>t(n.lang)-t(r.lang)||n.lang.localeCompare(r.lang)||n.name.localeCompare(r.name))}function Pd(e,t){if(e.length===0)return null;const n=t==null?void 0:t.trim();if(n){const i=e.find(a=>a.name===n);if(i)return i}const r=Ld(e.filter(i=>i.default));return r.length>0&&d3(r[0].lang)?r[0]:Ld(e)[0]??null}function d3(e){return e.toLowerCase().startsWith("zh")}function H4(e){return`${e.name} · ${e.lang}`}const f3=[["\\leq","小于等于"],["\\le","小于等于"],["\\geq","大于等于"],["\\ge","大于等于"],["\\neq","不等于"],["\\ne","不等于"],["\\approx","约等于"],["\\equiv","恒等于"],["\\pm","正负"],["\\times","乘以"],["\\cdot","点乘"],["\\div","除以"],["\\to","趋于"],["\\rightarrow","趋于"],["\\Rightarrow","推出"],["\\infty","无穷"],["\\sum","求和"],["\\prod","连乘"],["\\int","积分"],["\\lim","极限"],["\\log","对数"],["\\ln","自然对数"],["\\exp","指数"],["\\in","属于"],["\\subset","包含于"],["\\cup","并"],["\\cap","交"],["\\forall","任意"],["\\exists","存在"],["\\partial","偏导"],["\\nabla","梯度"],["\\angle","角"],["\\degree","度"],["\\cdots","点点点"],["\\ldots","点点点"]],h3={alpha:"阿尔法",beta:"贝塔",gamma:"伽马",delta:"德尔塔",epsilon:"艾普西隆",zeta:"泽塔",eta:"伊塔",theta:"西塔",iota:"约塔",kappa:"卡帕",lambda:"拉姆达",mu:"缪",nu:"纽",xi:"克西",pi:"派",rho:"柔",sigma:"西格马",tau:"陶",phi:"斐",chi:"凯",psi:"普西",omega:"欧米伽"};function m3(e,t){if(e[t]!=="{")return null;let n=0;for(let r=t;r<e.length;r++)if(e[r]==="{")n++;else if(e[r]==="}"&&(n--,n===0))return{body:e.slice(t+1,r),end:r+1};return null}function Kr(e,t){const n=m3(e,t);return n||{body:e[t]??"",end:t+1}}function p3(e){let t=e;t=t.replace(/\\(?:left|right|displaystyle|limits)\b/g," "),t=t.replace(/\\[,;!\s]|\\quad|\\qquad|~/g," ");for(let n=0;n<12;n++){let r=t;r=r.replace(/\\[dt]?frac(?![A-Za-z])/g,"\\frac");{let s;for(;(s=r.indexOf("\\frac"))>=0;){const i=Kr(r,s+5),a=Kr(r,i.end);r=r.slice(0,s)+`${i.body} 分之 ${a.body} `+r.slice(a.end)}}{let s;for(;(s=r.indexOf("\\binom"))>=0;){const i=Kr(r,s+6),a=Kr(r,i.end);r=r.slice(0,s)+`${i.body} 取 ${a.body} `+r.slice(a.end)}}r=r.replace(/\\sqrt\s*\[( {[^{}]*} |[^\s\\]+)\s*\]\s*/g,(s,i)=>`${i.trim()} 次根号 `);{let s;for(;(s=r.indexOf("\\sqrt"))>=0;){const i=Kr(r,s+5);r=r.slice(0,s)+`根号 ${i.body} `+r.slice(i.end)}}if(r=r.replace(/\\(?:mathbf|mathbb|mathrm|mathit|boldsymbol|text|operatorname)\s*/g,s=>s.startsWith("\\text")?"":" "),r===t){t=r;break}t=r}for(let n=0;n<8;n++){const r=t.replace(/(\\frac|[\w)\]}]|\s)\s*\^\s*(\{[^{}]*\}|[^\s])|(\\frac|[\w)\]}]| )\s*_\s*(\{[^{}]*\}|[^\s])/g,(s,i,a,o,l)=>a!==void 0?`${i} 的 ${a.replace(/[{}]/g,"")} 次方`:`${o} 下标 ${l.replace(/[{}]/g,"")}`);if(r===t)break;t=r}for(const[n,r]of f3)t=t.split(n).join(` ${r} `);return t=t.replace(/\\([A-Za-z]+)\b/g,(n,r)=>` ${h3[r]??r} `),t=t.replace(/[{}]/g," "),t.replace(/\s+/g," ").trim()}function g3(e){return e.replace(/\$\$([^$]+)\$\$|\$([^$]+)\$/g,(t,n,r)=>{const s=p3(n??r??"");return s?` ${s} `:""})}const Md=new WeakMap;let f0=null;function Za(e){f0=e}function x3(){return f0}const h0=1024;function m0(e){let t=Md.get(e);return t||(t=e.createAnalyser(),t.fftSize=h0,t.smoothingTimeConstant=.55,Md.set(e,t)),t}function b3(e,t){try{const n=m0(e);t.connect(n),n.connect(e.destination)}catch{try{t.connect(e.destination)}catch{}}}const Tr=1024,Dd=512,y3=3500,E3=7500,v3=.3,T3=.16,k3=1400,w3=2800,ts=70,p0=new Float64Array(Tr);for(let e=0;e<Tr;e++)p0[e]=.5*(1-Math.cos(2*Math.PI*e/(Tr-1)));function S3(e,t){const n=e.length;for(let r=1,s=0;r<n;r++){let i=n>>1;for(;s&i;i>>=1)s^=i;if(s|=i,r<s){const a=e[r];e[r]=e[s],e[s]=a;const o=t[r];t[r]=t[s],t[s]=o}}for(let r=2;r<=n;r<<=1){const s=-2*Math.PI/r,i=Math.cos(s),a=Math.sin(s),o=r>>1;for(let l=0;l<n;l+=r){let u=1,c=0;for(let f=0;f<o;f++){const h=e[l+f],d=t[l+f],m=e[l+f+o],p=t[l+f+o],g=m*u-p*c,y=m*c+p*u;e[l+f]=h+g,t[l+f]=d+y,e[l+f+o]=h-g,t[l+f+o]=d-y;const T=u*i-c*a;c=u*a+c*i,u=T}}}}function A3(e,t){const n=e.length;let r=0;const s=new Float64Array(n),i=new Float64Array(n);for(let p=0;p<n;p++){const g=e[p];r+=Math.abs(g),s[p]=g*p0[p]}S3(s,i);const a=n>>1,o=t/n,l=new Float64Array(a);let u=0,c=0,f=0,h=0,d=0,m=0;for(let p=0;p<a;p++){const g=p*o;if(g>=t/2-o)break;const y=Math.hypot(s[p],i[p])/a;l[p]=y,u+=y,g>=y3&&g<E3&&(c+=y),g>=Yu.lo&&g<Yu.hi?(f+=y,h+=y*g):g>=Gu.lo&&g<Gu.hi&&(d+=y,m+=y*g)}return{level:n>0?Math.min(1,r/n/.22):0,f1:f>0?h/f:400,f2:d>0?m/d:800,hfRatio:u>0?c/u:0}}function C3(e,t){return e.level<=w1?"closed":e.hfRatio>=v3?"SS":e.hfRatio>=T3&&e.level<.45?"FV":t==="closed"&&e.f2>=k3&&e.f2<=w3?"L":S1(e.f1,e.f2,e.level)}function _3(e,t){const n=[],r=(c,f,h,d)=>{if(f<=0)return;const m=n[n.length-1];if(m&&m.viseme===h&&Math.abs(m.t+m.dur-c)<1e-9){m.dur+=f,m.level=Math.max(m.level,d);return}n.push({t:c,dur:f,viseme:h,level:d})};if(e.length<Tr)return{cues:[{t:0,dur:Math.max(0,e.length/t),viseme:"closed",level:0}],duration:Math.max(0,e.length/t)};let s="closed";const i=Dd/t;for(let c=0;c+Tr<=e.length;c+=Dd){const f=e.subarray(c,c+Tr),h=A3(f,t),d=C3(h,s);r(c/t,i,d,h.level),s=d}const a=e.length/t,o=n.length>0?n[n.length-1].t+n[n.length-1].dur:0;o<a-1e-9&&r(o,a-o,"closed",0);const l=n[0];if(l&&l.viseme!=="closed")if(l.dur<=ts/1e3)l.viseme="closed";else{const c=Math.min(l.dur*.5,ts/1e3);l.dur-=c,l.t+=c,n.unshift({t:0,dur:c,viseme:"closed",level:0})}const u=n[n.length-1];if(u&&u.viseme!=="closed"){const c=Math.min(u.dur*.5,ts/1e3);u.dur-=c,n.push({t:u.t+u.dur,dur:c,viseme:"closed",level:0})}for(let c=n.length-1;c>=1;c--){const f=n[c];if(f.viseme!=="closed"&&f.dur<ts/1e3){const h=n[c-1];h.dur+=f.dur,n.splice(c,1)}}return{cues:n,duration:a}}function I3(e){const t=[...e].filter(s=>s.dur>0&&Number.isFinite(s.t)).sort((s,i)=>s.t-i.t),n=[];let r=0;for(const s of t){const i=Math.max(0,s.t/1e3),a=s.dur/1e3;i>r+1e-9&&n.push({t:r,dur:i-r,viseme:"closed",level:0});const o=n[n.length-1];o&&o.viseme===s.viseme&&Math.abs(o.t+o.dur-i)<1e-9?(o.dur+=a,o.level=Math.max(o.level,Math.min(1,Math.max(0,s.level)))):n.push({t:i,dur:a,viseme:s.viseme,level:Math.min(1,Math.max(0,s.level))}),r=i+a}return{cues:n,duration:r}}function N3(e,t){const n=e.cues;if(n.length===0||t<0)return null;let r=0,s=n.length-1;for(;r<s;){const a=r+s+1>>1;n[a].t<=t?r=a:s=a-1}const i=n[r];return t<=i.t+i.dur+1e-9?i:null}function g0(){const[e,t]=k.useState(null),[n,r]=k.useState(null),[s,i]=k.useState(null),[a,o]=k.useState([]),l=k.useRef([]),[u,c]=k.useState(null),[f,h]=k.useState(!1),d=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),g=k.useRef(0),y=k.useRef(!1),T=k.useRef([]),v=k.useRef(0),C=k.useRef(0),E=k.useRef(!1),w=k.useRef(null),_=k.useRef(0),S=k.useRef(null),I=k.useRef(null),A=k.useRef(null);A.current||(A.current=()=>{const F=I.current,q=typeof window<"u"?window.speechSynthesis:void 0;if(!F||F.stopped||!q)return;if(F.i>=F.sentences.length){I.current=null,w.current=null,t(null),r(null),i(null);return}const R=F.i,$=g3(F.sentences[R]),X=new SpeechSynthesisUtterance($);F.voice&&(X.voice=F.voice,X.lang=F.voice.lang),X.rate=F.rate,X.onstart=()=>{!I.current||I.current.stopped||i({index:R,total:F.sentences.length,text:$})};const D=()=>{var Z;!I.current||I.current.stopped||(I.current.i+=1,(Z=A.current)==null||Z.call(A))};X.onend=D,X.onerror=D,q.speak(X)});const P=k.useCallback((F,q)=>{var D;if(typeof window>"u"||!("speechSynthesis"in window)){c("engine-unavailable");return}const R=XC(q);if(R.length===0){c("empty-text");return}l.current=R.slice(),o(R.slice()),_.current=R.length,r({index:0,total:R.length,text:R[0]??""});const $=S.current,X=Pd(window.speechSynthesis.getVoices(),($==null?void 0:$.systemVoice)??null);I.current={messageId:F,sentences:R,i:0,stopped:!1,voice:X,rate:Od($==null?void 0:$.speed)},window.speechSynthesis.cancel(),(D=A.current)==null||D.call(A)},[]),N=()=>{if(!d.current){const F=window.AudioContext??window.webkitAudioContext;d.current=new F}return d.current.resume(),d.current},j=k.useCallback(()=>{E.current&&C.current>=v.current&&!y.current&&(w.current=null,t(null),r(null),i(null))},[]),M=k.useCallback(()=>{const F=d.current;if(!F||y.current)return;const q=m.current.get(g.current);if(!q){j();return}const R=g.current;m.current.delete(R),y.current=!0,i({index:R,total:_.current,text:l.current[R]??""}),g.current+=1;const $=F.createBufferSource();$.buffer=q,b3(F,$),Za({ctx:F,timeline:p.current.get(R)??null,startedAtCtxTime:F.currentTime,analyser:m0(F)}),$.onended=()=>{C.current+=1,y.current=!1,Za(null),M()},T.current.push($),$.start()},[j]),L=k.useCallback(()=>{for(const F of T.current)try{F.onended=null,F.stop()}catch{}T.current=[],m.current.clear(),p.current.clear(),Za(null),y.current=!1,v.current=0,C.current=0,E.current=!1,w.current=null,g.current=0,_.current=0,l.current=[],o([]),t(null),r(null),i(null),I.current&&(I.current.stopped=!0,I.current=null),typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()},[]),B=k.useCallback(()=>{L(),window.api.ttsStop().catch(()=>{})},[L]),V=k.useCallback((F,q)=>{var R;if(w.current===F){B();return}if(L(),window.dispatchEvent(new CustomEvent("lookatstudy-speech-start",{detail:F})),c(null),w.current=F,v.current=0,C.current=0,E.current=!1,g.current=0,_.current=0,t(F),r({index:0,total:0,text:""}),((R=S.current)==null?void 0:R.engine)==="system"){P(F,q);return}N(),window.api.ttsSpeak(q,F).then($=>{if($.ok){$.firstUse&&h(!0);return}L(),$.reason!=="empty-text"&&c($.reason)}).catch(()=>L())},[P,B,L]);return k.useEffect(()=>{const F=window.api.on("speech:ttsAudio",$=>{if($.messageId!==w.current)return;const X=N();v.current+=1,_.current=$.sentenceTotal,r({index:$.sentenceIndex,total:$.sentenceTotal,text:$.sentence??""}),$.sentence!=null&&(l.current[$.sentenceIndex]=$.sentence,o(l.current.slice())),X.decodeAudioData($.wavBytes).then(D=>{var Z;if($.messageId===w.current){m.current.set($.sentenceIndex,D);try{const le=(Z=$.visemeCues)!=null&&Z.length?I3($.visemeCues):_3(R3(D),D.sampleRate);le&&p.current.set($.sentenceIndex,le)}catch{}M()}},()=>{$.messageId===w.current&&(v.current-=1,M())})}),q=window.api.on("speech:ttsDone",$=>{$.messageId===w.current&&(E.current=!0,j())}),R=window.api.on("speech:ttsError",()=>L());return()=>{F(),q(),R()}},[j,M,L]),k.useEffect(()=>L,[L]),k.useEffect(()=>{const F=q=>{const R=q.detail;w.current&&R!==w.current&&L()};return window.addEventListener("lookatstudy-speech-start",F),()=>window.removeEventListener("lookatstudy-speech-start",F)},[L]),k.useEffect(()=>{let F=!0;const q=()=>{Promise.all([window.api.getSetting("tts_engine"),window.api.getSetting("tts_system_voice"),window.api.getSetting("tts_speed")]).then(([R,$,X])=>{F&&(S.current={engine:(R??"").trim(),systemVoice:$??null,speed:Od(X)})}).catch(()=>{})};return q(),window.addEventListener(Rd,q),()=>{F=!1,window.removeEventListener(Rd,q)}},[]),k.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const F=()=>{var R;const q=I.current;!q||q.voice||(q.voice=Pd(window.speechSynthesis.getVoices(),((R=S.current)==null?void 0:R.systemVoice)??null))};return window.speechSynthesis.addEventListener("voiceschanged",F),()=>window.speechSynthesis.removeEventListener("voiceschanged",F)},[]),k.useEffect(()=>{A1(e!==null)},[e]),{speakingMessageId:e,speakingSentence:n,playingSentence:s,streamTexts:a,failReason:u,clearFailReason:()=>c(null),onlineNotice:f,clearOnlineNotice:()=>h(!1),speak:V,stop:B}}function R3(e){if(e.numberOfChannels===1)return e.getChannelData(0);const t=e.getChannelData(0),n=e.getChannelData(1),r=new Float32Array(t.length);for(let s=0;s<t.length;s++)r[s]=(t[s]+n[s])/2;return r}function Od(e){const t=typeof e=="number"?e:Number.parseFloat(e??"");return Number.isFinite(t)?Math.min(2,Math.max(.5,t)):1}const x0=k.createContext(null);let L3=0;const P3={default:4e3,success:4e3,info:4e3,warning:5e3,error:6e3},M3={default:null,success:x.jsx(Nl,{className:"w-4 h-4 text-brand shrink-0"}),error:x.jsx(cx,{className:"w-4 h-4 text-warning shrink-0"}),warning:x.jsx(Ll,{className:"w-4 h-4 text-review shrink-0"}),info:x.jsx(Tx,{className:"w-4 h-4 text-accent shrink-0"})};function D3({children:e}){const[t,n]=k.useState([]),r=k.useCallback(a=>{n(o=>o.filter(l=>l.id!==a))},[]),s=k.useCallback(a=>{n(o=>o.map(l=>l.id===a?{...l,exiting:!0}:l))},[]),i=k.useCallback((a,o)=>{const l=++L3,u=(o==null?void 0:o.severity)??"default",c=(o==null?void 0:o.duration)??P3[u],f={id:l,message:a,action:o==null?void 0:o.action,duration:c,severity:u,exiting:!1};n(h=>[...h,f]),window.setTimeout(()=>s(l),c)},[s]);return x.jsxs(x0.Provider,{value:{show:i},children:[e,x.jsx("div",{className:"fixed top-14 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 pointer-events-none",role:"region","aria-live":"polite","aria-label":"Notifications",children:t.map(a=>x.jsx(O3,{item:a,onAction:()=>{a.action.onClick(),s(a.id)},onDismiss:()=>s(a.id),onExitDone:()=>r(a.id)},a.id))})]})}function O3({item:e,onAction:t,onDismiss:n,onExitDone:r}){const s=Ke(),i=M3[e.severity];return x.jsxs("div",{className:`pointer-events-auto flex items-center gap-2.5 pl-4 pr-2 py-2 rounded-full bg-surface-0 text-ink-strong text-body shadow-elevated max-w-md ${e.exiting?"toast-exit":"toast-enter"}`,"data-testid":`toast-${e.id}`,"data-severity":e.severity,onAnimationEnd:e.exiting?r:void 0,children:[i,x.jsx("span",{className:"flex-1",children:e.message}),e.action&&x.jsx("button",{onClick:t,className:"text-brand font-bold text-body hover:underline shrink-0 px-1.5 py-1 rounded transition-colors hover:bg-brand/10","data-testid":`toast-action-${e.id}`,children:e.action.label}),x.jsx("button",{onClick:n,className:"text-ink-muted hover:text-ink-strong shrink-0 w-6 h-6 flex items-center justify-center rounded transition-colors hover:bg-surface-3","aria-label":s("action.close"),children:x.jsx(kr,{className:"w-3.5 h-3.5"})})]})}function iu(){const e=k.useContext(x0);return e||{show:()=>{}}}const b0={typescript:()=>we(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),tsx:()=>we(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),javascript:()=>we(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),jsx:()=>we(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),python:()=>we(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),go:()=>we(()=>import("./go-C27-OAKa.js"),[],import.meta.url),rust:()=>we(()=>import("./rust-B1yitclQ.js"),[],import.meta.url),java:()=>we(()=>import("./java-CylS5w8V.js"),[],import.meta.url),c:()=>we(()=>import("./c-BIGW1oBm.js"),[],import.meta.url),cpp:()=>we(()=>import("./cpp-DddhVWhK.js"),__vite__mapDeps([5,6]),import.meta.url),csharp:()=>we(()=>import("./csharp-DSvCPggb.js"),[],import.meta.url),ruby:()=>we(()=>import("./ruby-B6QtyW_S.js"),__vite__mapDeps([7,8,9,10,11,12,13,14,15,16,17,5,6,18,19,20]),import.meta.url),php:()=>we(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([21,8,9,10,11,12,13,22]),import.meta.url),swift:()=>we(()=>import("./swift-C2oV4EkX.js"),[],import.meta.url),kotlin:()=>we(()=>import("./kotlin-BdnUsdx6.js"),[],import.meta.url),lua:()=>we(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([19,6]),import.meta.url),r:()=>we(()=>import("./r-Cf5RLm7j.js"),[],import.meta.url),shellscript:()=>we(()=>import("./shellscript-Yzrsuije.js"),[],import.meta.url),sql:()=>we(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),html:()=>we(()=>import("./html-pp8916En.js"),__vite__mapDeps([8,9,10]),import.meta.url),css:()=>we(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),scss:()=>we(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([23,10]),import.meta.url),xml:()=>we(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([11,12]),import.meta.url),json:()=>we(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),yaml:()=>we(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url),toml:()=>we(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),ini:()=>we(()=>import("./ini-BEwlwnbL.js"),[],import.meta.url),markdown:()=>we(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),dockerfile:()=>we(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),makefile:()=>we(()=>import("./makefile-CHLpvVh8.js"),[],import.meta.url),diff:()=>we(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),graphql:()=>we(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([14,9,15,16,17]),import.meta.url),latex:()=>we(()=>import("./latex-B2nUCzCX.js"),__vite__mapDeps([24,25]),import.meta.url),vue:()=>we(()=>import("./vue-CHlpWS_5.js"),__vite__mapDeps([26,10,9,15,22,8]),import.meta.url)},Fd={js:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",py:"python",python3:"python",rb:"ruby",golang:"go",rs:"rust",cs:"csharp",kt:"kotlin",sh:"shellscript",bash:"shellscript",zsh:"shellscript",shell:"shellscript",console:"shellscript",yml:"yaml",md:"markdown",gfm:"markdown",docker:"dockerfile",tex:"latex",plaintext:"",txt:"",text:""};function F3(e){const t=e.trim().toLowerCase();return t?t in Fd?Fd[t]||null:t in b0?t:null:null}let Xr=null;const Bd=new Set;function su(){return Xr||(Xr=(async()=>{const[e,t,n,r]=await Promise.all([we(()=>import("./core-4rNLJNcM.js"),__vite__mapDeps([27,1,2]),import.meta.url),we(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),we(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url),we(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url)]);return e.createHighlighterCore({themes:[n.default,r.default],langs:[],engine:t.createJavaScriptRegexEngine({forgiving:!0})})})(),Xr.catch(()=>{Xr=null})),Xr}async function y0(e){const t=F3(e);if(!t)return null;if(Bd.has(t))return t;const n=b0[t];if(!n)return null;const r=await su(),s=await n();return await r.loadLanguage(s),Bd.add(t),t}async function B3(e,t){try{const n=await y0(t);return n?(await su()).codeToHtml(e,{lang:n,themes:{light:"github-light",dark:"github-dark"},defaultColor:"dark"}):null}catch{return null}}const j3=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");async function U4(e,t){try{const n=await y0(t);return n?(await su()).codeToTokens(e,{lang:n,theme:"github-dark"}).tokens.map(i=>i.map(a=>`<span style="color:${a.color}">${j3(a.content)}</span>`).join("")):null}catch{return null}}function H3(e){const t=Array.isArray(e)?e[0]:e,n=(t==null?void 0:t.props)??{},r=/language-(\w+)/.exec(n.className??""),s=n.children,i=typeof s=="string"?s:Array.isArray(s)?s.join(""):"";return{lang:(r==null?void 0:r[1])??"",text:i}}function E0({children:e,...t}){const n=Ke(),[r,s]=k.useState(!1),[i,a]=k.useState(null),{lang:o,text:l}=H3(e);k.useEffect(()=>{let c=!0;if(l)return B3(l.replace(/\n$/,""),o).then(f=>{c&&f&&a(f)}),()=>{c=!1}},[l]);const u=()=>{var c;(c=navigator.clipboard)==null||c.writeText(l).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})};return x.jsxs("div",{className:"relative group my-3","data-testid":"md-codeblock",children:[x.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-1 border border-b-0 border-[var(--border-faint)] rounded-t-md",children:[x.jsx("span",{className:"text-caption font-mono text-ink-faint uppercase tracking-wider",children:o||"code"}),x.jsx("button",{onClick:u,"aria-label":n("chat.copy"),className:"text-caption text-ink-muted hover:text-brand transition-colors opacity-0 group-hover:opacity-100 pointer-coarse:opacity-100 inline-flex items-center gap-1","data-testid":"md-copy",children:r?x.jsxs(x.Fragment,{children:[x.jsx(An,{className:"w-3 h-3 inline"}),n("chat.copied")]}):x.jsxs(x.Fragment,{children:[x.jsx(hx,{className:"w-3 h-3 inline"}),n("chat.copy")]})})]}),i?x.jsx("div",{className:"md-shiki","data-testid":"md-shiki",dangerouslySetInnerHTML:{__html:i}}):x.jsx("pre",{...t,className:"!mt-0 !rounded-t-none !border-t-0",children:e})]})}const v0=k.lazy(()=>we(()=>import("./index-Brv5KtDR.js"),__vite__mapDeps([28,1,2,29,30,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer}))),U3=k.lazy(()=>we(()=>import("./CanvasStage-Ccxan7wh.js").then(e=>e.a),__vite__mapDeps([29,1,2]),import.meta.url).then(e=>({default:e.CanvasStage}))),z3=k.lazy(()=>we(()=>import("./ReviewPanel-CyvrUQ9n.js"),__vite__mapDeps([32,1,2]),import.meta.url).then(e=>({default:e.SelfRatingCard}))),V3={concept_map:Mh,quiz:Ih,compare_table:Ux,diagram:xx,code_walkthrough:fx},q3=new Set(["concept_map","quiz","compare_table","diagram","code_walkthrough"]);function W3(e,t){return q3.has(t)?e(`artifact.type.${t}`):e("artifact.type.unknown")}function $3({selectedNode:e,items:t,loading:n,forceTab:r,canvasArtifact:s,isReviewing:i,onReviewDone:a,onUserTabChange:o,onRemove:l,onTogglePin:u,onRecordQuizResult:c,onSaveContentNote:f,onUpdateNoteComment:h,onJumpToSource:d,onQuoteToChat:m,locale:p}){var _;const g=Ke(),[y,T]=k.useState("content"),v=r??y,C=S=>{T(S),o==null||o()},E=e?t.filter(S=>S.nodeId===e.id):[],w=k.useRef(null);return k.useEffect(()=>{var S;(S=w.current)==null||S.scrollTo({top:0})},[e==null?void 0:e.id]),x.jsxs("div",{className:"relative h-full flex flex-col bg-surface-2","data-testid":"notebook-panel",children:[x.jsx("div",{className:"px-3 pt-3 pb-1 shrink-0","data-testid":"notebook-tabs",children:x.jsxs("div",{className:"flex p-1 rounded-lg gap-1 bg-ink/[0.08]",role:"tablist","aria-label":"Notebook",children:[x.jsx(ro,{label:g("notebook.tab.explain"),icon:Cn,active:v==="content",onClick:()=>C("content"),testid:"tab-content"}),x.jsx(ro,{label:g("notebook.tab.notes"),icon:Cx,active:v==="notes",onClick:()=>C("notes"),testid:"tab-notes",badge:E.length>0?String(E.length):void 0}),x.jsx(ro,{label:g("notebook.tab.board"),icon:Ta,active:v==="board",onClick:()=>C("board"),testid:"tab-board"})]})}),x.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 animate-tab-slide",ref:w,role:"tabpanel",children:v==="board"?x.jsx("div",{className:"h-full flex flex-col","data-testid":"board-tab-content",children:s?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"px-4 pt-3 pb-2 shrink-0 flex items-center gap-2 min-w-0",children:[x.jsx(Ta,{className:"w-4 h-4 text-ink-muted shrink-0"}),x.jsx("span",{className:"text-label font-bold text-ink truncate",children:((_=s.output)==null?void 0:_.title)??s.toolName})]}),x.jsx("div",{className:"flex-1 min-h-0 px-2 pb-2",children:x.jsx("div",{className:"h-full rounded-xl overflow-hidden bg-surface-0/60 border border-[var(--border-faint)]",children:x.jsx(k.Suspense,{fallback:null,children:x.jsx(U3,{testid:"board-canvas-stage",children:x.jsx(v0,{data:s.output,variant:"canvas"})})})})})]}):x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[x.jsx(Ta,{className:"w-10 h-10 mb-3 text-ink-muted opacity-30"}),x.jsx("div",{className:"text-body text-ink-muted max-w-sm leading-relaxed",children:g("notebook.board.empty")})]})}):x.jsx(x.Fragment,{children:x.jsx("div",{className:"mx-auto w-full max-w-[960px] min-h-full flex flex-col",children:v==="content"?x.jsx(Y3,{selectedNode:e,contentNotes:E.filter(S=>S.artifactType==="user_note"&&S.sourceAnchor),onQuoteToChat:m,onSaveContentNote:f,locale:p,isReviewing:i,onReviewDone:a}):x.jsx(G3,{items:E,loading:n,selectedNode:e,onRemove:l,onTogglePin:u,onRecordQuizResult:c,onUpdateNoteComment:h,onJumpToSource:d})})})},v)]})}function Y3({selectedNode:e,contentNotes:t,onQuoteToChat:n,onSaveContentNote:r,locale:s,isReviewing:i,onReviewDone:a}){const o=Ke(),l=iu(),u=g0();k.useEffect(()=>{if(u.failReason){const L=u.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":u.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":u.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":u.failReason==="edge-failed"?"chat.speech.edge_failed":"chat.speech.model_missing";l.show(o(L),{severity:"warning"}),u.clearFailReason()}else u.onlineNotice&&(l.show(o("chat.speech.edge_disclosed"),{severity:"info"}),u.clearOnlineNotice())},[u.failReason,u.onlineNotice,l,o,u]);const c=k.useRef(u.stop);c.current=u.stop;const f=e?`content-${e.id}`:null;k.useEffect(()=>()=>{c.current()},[f]);const[h,d]=k.useState(null),m=Kp(h??""),[p,g]=k.useState(!1),[y,T]=k.useState(!1),[v,C]=k.useState([]),[E,w]=k.useState(null),_=k.useRef(null),S=k.useRef(null),I=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;k.useEffect(()=>{if(!e){d(null),T(!1);return}let L=!1;return g(!0),T(!1),oe.getNodeContent(e.id,s??void 0).then(B=>{L||d(B)}).catch(()=>{L||(d(null),T(!0))}).finally(()=>{L||g(!1)}),()=>{L=!0}},[e==null?void 0:e.id,s]),k.useEffect(()=>{if(!e){C([]);return}let L=!1;return oe.listAssetsByNode(e.id).then(B=>{L||C(B)}).catch(()=>{L||C([])}),()=>{L=!0}},[e==null?void 0:e.id]),k.useEffect(()=>{if(!h||!_.current)return;const L=[];for(const V of t)try{const F=JSON.parse(V.sourceAnchor);if(F.type==="content"){const q=JSON.parse(V.data).text??"";q&&L.push({noteId:V.id,text:q,surrounding:F.surroundingText})}}catch{}const B=setTimeout(()=>{S.current&&t0(S.current,L)},80);return()=>clearTimeout(B)},[h,t]),k.useEffect(()=>{const L=B=>{var q;const V=B.detail;if(!V)return;const F=(q=S.current)==null?void 0:q.querySelector(`mark[data-note-id="${V}"]`);F&&u0(F)};return window.addEventListener("lookatstudy-jump-to-note",L),()=>window.removeEventListener("lookatstudy-jump-to-note",L)},[]);const A=u.speakingMessageId===f&&u.playingSentence!=null?u.playingSentence.index:null;k.useEffect(()=>{const L=S.current;if(!L)return;if(A==null){Jn(L);return}const B=Xp(u.streamTexts,A);if(!B)return;A===0&&a0(L);const V=setTimeout(()=>{const F=o0(L,B);F&&l0(F,L.closest(".overflow-y-auto"))},30);return()=>clearTimeout(V)},[A,u.streamTexts,f]),k.useEffect(()=>{A==null&&S.current&&Jn(S.current)},[A]);const P=k.useRef(!1);P.current=A!=null,k.useEffect(()=>()=>{P.current&&Jn(document.body)},[]);const N=k.useCallback(()=>{var K;if(!n&&!r)return;const L=window.getSelection(),B=(L==null?void 0:L.toString().trim())??"";if(B.length<2||B.length>500){w(null);return}const V=L==null?void 0:L.getRangeAt(0);if(!V||!((K=_.current)!=null&&K.contains(V.commonAncestorContainer))){w(null);return}const F=V.getBoundingClientRect(),q=_.current.getBoundingClientRect(),R=S.current;let $=null;if(R&&R.contains(V.commonAncestorContainer)){const ce=wi(R);$=Jp(V,ce)}const X=R?wi(R).text:B,D=$?$.start:X.indexOf(B),Z=D>=0?X.slice(Math.max(0,D-30),D+B.length+30):B,le=V.getClientRects(),z=le.length?le[le.length-1]:F,ee=d0({left:F.left-q.left,top:F.top-q.top,right:F.right-q.left,bottom:F.bottom-q.top,width:F.width,height:F.height},q.width,n?I?190:150:I?140:100,{left:z.left-q.left,top:z.top-q.top,right:z.right-q.left,bottom:z.bottom-q.top,width:z.width,height:z.height},I);w({x:ee.left,y:ee.top,transform:ee.transform,text:B,surrounding:Z,offsets:$??void 0})},[n,r,I]);k.useEffect(()=>{const L=I?600:250;let B=null,V=null,F=!1;const q=()=>{var D;return(((D=window.getSelection())==null?void 0:D.toString().trim().length)??0)>=2},R=()=>{q()?(V&&(clearTimeout(V),V=null),w(D=>D&&null),B&&clearTimeout(B),B=setTimeout(()=>{B=null,!F&&q()&&N()},L)):V||(V=setTimeout(()=>w(D=>D&&null),250))},$=D=>{var le;const Z=D.target;(le=Z==null?void 0:Z.closest)!=null&&le.call(Z,"[data-selection-popover]")||(F=!0)},X=()=>{F=!1,B&&(clearTimeout(B),B=null),!V&&q()&&N()};return document.addEventListener("selectionchange",R),window.addEventListener("pointerdown",$,!0),window.addEventListener("pointerup",X,!0),window.addEventListener("pointercancel",X,!0),()=>{document.removeEventListener("selectionchange",R),window.removeEventListener("pointerdown",$,!0),window.removeEventListener("pointerup",X,!0),window.removeEventListener("pointercancel",X,!0),B&&clearTimeout(B),V&&clearTimeout(V)}},[N]);const j=k.useCallback(()=>{var B;if(!E||!n)return;const L=E.text.length>200?E.text.slice(0,200)+"…":E.text;n(o("notebook.quote.template",{text:L})),w(null),(B=window.getSelection())==null||B.removeAllRanges()},[E,n,o]),M=k.useCallback(()=>{var B,V,F;if(!E||!r||!e)return;const L=E.text.length>200?E.text.slice(0,200)+"…":E.text;r(L,{type:"content",surroundingText:E.surrounding,startOffset:(B=E.offsets)==null?void 0:B.start,endOffset:(V=E.offsets)==null?void 0:V.end}),C1(),setTimeout(()=>{var $;const q=($=S.current)==null?void 0:$.querySelectorAll("mark.lookatstudy-underline"),R=q&&q.length>0?q[q.length-1]:null;R&&l3(R)},200),w(null),(F=window.getSelection())==null||F.removeAllRanges()},[E,r,e]);return e?x.jsxs("div",{className:"p-5 relative","data-testid":"node-content",ref:_,children:[!p&&!y&&h&&x.jsx("div",{className:"sticky top-0 z-20 flex justify-end gap-2 -mt-2 pointer-events-none",children:x.jsx("button",{onClick:()=>u.speak(f??"content",h),"data-tooltip":u.speakingMessageId===f?o("chat.speech.stop"):o("chat.speech.read_aloud_node"),"aria-label":u.speakingMessageId===f?o("chat.speech.stop"):o("chat.speech.read_aloud_node"),"data-testid":u.speakingMessageId===f?"node-content-speak-active":"node-content-speak",className:`pointer-events-auto shrink-0 rounded-full p-2 bg-surface-2 shadow-elevated transition-colors ${u.speakingMessageId===f?"text-brand animate-pulse":"text-ink-muted hover:text-ink-strong"}`,children:u.speakingMessageId===f?x.jsx(Rl,{className:"w-4 h-4"}):x.jsx(Oh,{className:"w-4 h-4"})})}),x.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-1",children:e.type==="section"?o("notebook.node_type.section"):e.type==="concept"?o("notebook.node_type.concept"):o("notebook.node_type.lesson")}),x.jsx("div",{className:"flex items-start justify-between gap-3 mb-4",children:x.jsx("h2",{className:"text-title font-extrabold text-ink-strong tracking-tight","data-testid":"node-content-title",children:e.title})}),p?x.jsxs("div",{className:"text-body text-ink-muted flex items-center gap-2",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),o("notebook.content.loading")]}):y?x.jsxs("div",{className:"text-body text-warning",children:[o("notebook.content.load_failed"),x.jsx("button",{className:"underline ml-1",onClick:()=>{T(!1),g(!0),oe.getNodeContent(e.id,s??void 0).then(d).catch(()=>T(!0)).finally(()=>g(!1))},children:o("notebook.content.retry")})]}):h?x.jsx(WC,{fallback:(L,B)=>x.jsxs("div",{className:"prose prose-sm max-w-[80ch] leading-relaxed [&_pre]:max-w-full [&_pre]:overflow-x-auto",children:[x.jsx("div",{className:"text-body text-warning mb-2",children:o("notebook.content.render_failed")}),x.jsxs("pre",{className:"text-caption text-ink-muted whitespace-pre-wrap break-words bg-surface-1 p-3 rounded",children:[h.slice(0,500),h.length>500?`
475
+ `+o("notebook.content.truncated"):""]}),x.jsx("div",{className:"flex gap-2 mt-2",children:x.jsx("button",{className:"text-caption underline text-accent",onClick:B,children:o("notebook.content.retry_render")})})]}),children:x.jsx("div",{ref:S,className:"prose prose-sm max-w-[80ch] leading-relaxed break-words overflow-x-auto [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_img]:max-w-full [&_video]:max-w-full [&_iframe]:max-w-full select-text",children:x.jsx(Om,{remarkPlugins:m.remarkPlugins,rehypePlugins:m.rehypePlugins,urlTransform:L=>L,components:{pre({children:L,...B}){return x.jsx(E0,{...B,children:L})},a({children:L,...B}){return x.jsx("a",{...B,target:"_blank",rel:"noopener noreferrer",children:L})},img({src:L,alt:B,...V}){return x.jsx(K3,{src:L,alt:B,assets:v,...V})},table({children:L}){return x.jsx("div",{className:"overflow-x-auto my-4",children:x.jsx("table",{children:L})})}},children:c0(h)})})},`${e.id}-${s??"orig"}`):x.jsx("div",{className:"text-body text-ink-muted",children:o("notebook.content.empty")}),v.length>0&&x.jsxs("div",{className:"mt-6 pt-4 border-t border-[var(--border-faint)]",children:[x.jsxs("div",{className:"text-label font-bold text-ink-muted mb-2 flex items-center gap-1",children:[x.jsx(vx,{className:"w-3.5 h-3.5"}),x.jsx("span",{children:o("notebook.images.heading",{n:v.length})})]}),x.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:v.map(L=>x.jsx(X3,{asset:L},L.id))})]}),E&&x.jsxs("div",{"data-selection-popover":!0,style:{left:E.x,top:E.y,transform:E.transform},className:"absolute z-20 flex items-center gap-0.5 msg-enter whitespace-nowrap",children:[n&&x.jsxs("button",{onClick:j,"data-testid":"quote-to-chat-btn","aria-label":o("notebook.quote.ask"),className:"px-2 py-1.5 rounded-lg bg-brand text-white text-label font-bold shadow-elevated flex items-center gap-1 hover:bg-brand-light transition-colors",children:[x.jsx(Lh,{className:"w-3 h-3"}),o("notebook.quote.ask")]}),x.jsxs("button",{onClick:M,"data-testid":"save-note-btn","aria-label":o("notebook.quote.add_note"),className:"px-2 py-1.5 rounded-lg bg-accent text-white text-label font-bold shadow-elevated flex items-center gap-1 hover:brightness-110 transition",title:o("notebook.quote.save_note.title"),children:[x.jsx(bi,{className:"w-3.5 h-3.5"}),o("notebook.quote.add_note")]})]}),e.sourcePath&&x.jsx("div",{className:"mt-6 pt-3 border-t border-[var(--border-faint)] text-label text-ink-muted",children:o("notebook.source.label",{path:e.sourcePath})}),x.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-accent/5 border border-accent/20 text-body text-ink-muted flex items-start gap-1.5",children:[x.jsx(wx,{className:"w-3.5 h-3.5 shrink-0 mt-0.5 text-accent"}),x.jsx("span",{children:o("notebook.quote.hint")})]}),i&&e&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(z3,{nodeId:e.id,onRated:a})})]}):x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[x.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),x.jsx("div",{className:"text-body text-ink-muted max-w-xs",children:o("notebook.empty.select_node")})]})}function G3({items:e,loading:t,selectedNode:n,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o}){const l=Ke();if(!n)return x.jsx(jd,{message:l("notebook.empty.notes.title"),icon:"📓"});if(t)return x.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-body text-ink-muted",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),l("notebook.empty.notes.title")]});const u=e.filter(p=>["concept_map","compare_table","diagram","code_walkthrough"].includes(p.artifactType)),c=e.filter(p=>p.artifactType==="user_note"),f=e.filter(p=>p.artifactType==="quiz"),h=e.length,d=f.filter(p=>p.lastResult==="correct").length,m=f.filter(p=>p.lastResult==="wrong").length;return h===0?x.jsx(jd,{message:l("notebook.empty.no_notes_message"),icon:"🧩"}):x.jsxs("div",{className:"p-4 space-y-3","data-testid":"notes-list",children:[x.jsx(eo,{title:l("notebook.zone.understand"),icon:x.jsx(Mh,{className:"w-4 h-4"}),subtitle:l("notebook.zone.understand.subtitle"),count:u.length,testid:"zone-understand",defaultOpen:!1,children:u.length===0?x.jsx(to,{hint:l("notebook.zone.understand.empty_hint")}):u.map(p=>x.jsx(no,{item:p,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},p.id))}),x.jsx(eo,{title:l("notebook.zone.note"),icon:x.jsx(bi,{className:"w-4 h-4"}),subtitle:l("notebook.zone.note.subtitle"),count:c.length,testid:"zone-note",defaultOpen:!1,children:c.length===0?x.jsx(to,{hint:l("notebook.zone.note.empty_hint")}):c.map(p=>x.jsx(no,{item:p,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},p.id))}),x.jsx(eo,{title:l("notebook.zone.practice"),icon:x.jsx(Ih,{className:"w-4 h-4"}),subtitle:f.length>0?l("notebook.zone.practice.subtitle_stats",{total:f.length,correct:d,wrong:m}):l("notebook.zone.practice.subtitle_empty"),count:f.length,testid:"zone-practice",defaultOpen:!1,children:f.length===0?x.jsx(to,{hint:l("notebook.zone.practice.empty_hint")}):f.map(p=>x.jsx(no,{item:p,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},p.id))})]})}function eo({title:e,icon:t,subtitle:n,count:r,testid:s,defaultOpen:i=!0,children:a}){const[o,l]=k.useState(i),u=k.useRef(!0),c=k.useRef(r);return k.useEffect(()=>{if(u.current){u.current=!1,c.current=r;return}r>c.current&&l(!0),c.current=r},[r]),x.jsxs("section",{className:"rounded-xl bg-surface-1 overflow-hidden","data-testid":s,children:[x.jsxs("button",{onClick:()=>l(f=>!f),"aria-expanded":o,className:"w-full flex items-center gap-2 px-3 py-2.5 bg-surface-1/50 hover:bg-surface-3/60 transition-colors text-left","data-testid":`${s}-toggle`,children:[x.jsx(Il,{className:`w-4 h-4 text-ink-muted transition-transform duration-200 ease-out-back ${o?"":"-rotate-90"}`}),x.jsx("span",{className:"text-body text-ink-strong flex items-center",children:t}),x.jsx("span",{className:"text-body font-bold text-ink",children:e}),x.jsx("span",{className:"text-caption font-bold px-1.5 py-0.5 rounded-full bg-brand/15 text-brand",children:r}),x.jsx("span",{className:"text-label text-ink-muted ml-auto truncate",children:n})]}),x.jsx("div",{className:"grid transition-all duration-200 ease-out-expo",style:{gridTemplateRows:o?"1fr":"0fr"},children:x.jsx("div",{className:"overflow-hidden",children:x.jsx("div",{className:"p-3 space-y-3",children:a})})})]})}function to({hint:e}){return x.jsx("div",{className:"text-center py-3 text-body text-ink-muted",children:e})}function no({item:e,onRemove:t,onTogglePin:n,onRecordQuizResult:r,onUpdateNoteComment:s,onJumpToSource:i}){const a=Ke(),[o,l]=k.useState(!1),[u,c]=k.useState(e.notes??""),f=k.useCallback((v,C,E)=>{e.nodeId&&oe.recordQuizAnswer(e.nodeId,E).catch(()=>{}),r(e.id,E)},[e.nodeId,e.id,r]),h=e.artifactType==="user_note";let d="",m=null;if(h){try{d=JSON.parse(e.data).text??""}catch{d=e.title??""}try{e.sourceAnchor&&(m=JSON.parse(e.sourceAnchor))}catch{m=null}}let p=null;if(!h)try{p=JSON.parse(e.data)}catch{p=null}const g=new Date(e.createdAt),y=`${g.getMonth()+1}/${g.getDate()} ${g.getHours().toString().padStart(2,"0")}:${g.getMinutes().toString().padStart(2,"0")}`;if(h){const v=e.notes&&e.notes.trim().length>0?e.notes:null,C=()=>{c(v??""),l(!0)},E=()=>{c(v??""),l(!1)},w=()=>{s==null||s(e.id,u),l(!1)};return x.jsx("div",{className:`bg-surface-2 rounded-lg p-3 relative ${e.pinned?"ring-1 ring-brand/40 bg-brand/5":""}`,"data-testid":`canvas-item-${e.id.slice(0,8)}`,children:x.jsxs("div",{className:"flex items-start gap-2",children:[x.jsx(Px,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"text-body text-ink leading-relaxed whitespace-pre-wrap",children:d}),s&&o?x.jsxs("div",{className:"mt-2 space-y-1.5","data-testid":`note-comment-edit-${e.id.slice(0,8)}`,children:[x.jsx("textarea",{value:u,onChange:_=>c(_.target.value),rows:2,placeholder:a(v?"notebook.note.comment.ph_edit":"notebook.note.comment.ph_new"),className:"w-full text-label leading-relaxed p-2 rounded-md border border-[var(--border-faint)] bg-surface-0 text-ink resize-none focus:outline-none focus:border-brand","data-testid":`note-comment-textarea-${e.id.slice(0,8)}`}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs("button",{onClick:w,className:"inline-flex items-center gap-1 text-caption font-bold text-white bg-brand hover:bg-brand/90 px-2 py-0.5 rounded","data-testid":`note-comment-save-${e.id.slice(0,8)}`,children:[x.jsx(An,{className:"w-3 h-3"})," ",a("notebook.action.save")]}),x.jsxs("button",{onClick:E,className:"inline-flex items-center gap-1 text-caption text-ink-muted hover:text-ink","data-testid":`note-comment-cancel-${e.id.slice(0,8)}`,children:[x.jsx(kr,{className:"w-3 h-3"})," ",a("notebook.action.cancel")]})]})]}):v?x.jsxs("div",{className:"mt-2 px-2.5 py-1.5 rounded-lg bg-ink/5",children:[x.jsx("div",{className:"text-label text-ink-muted italic leading-relaxed whitespace-pre-wrap",children:v}),s&&x.jsxs("button",{onClick:C,className:"mt-1 inline-flex items-center gap-0.5 text-caption text-ink-muted hover:text-accent","data-testid":`note-comment-edit-btn-${e.id.slice(0,8)}`,title:a("notebook.note.edit_comment"),children:[x.jsx(bi,{className:"w-2.5 h-2.5"})," ",a("notebook.note.edit_comment")]})]}):s?x.jsxs("button",{onClick:C,className:"mt-2 inline-flex items-center gap-0.5 text-caption text-ink-muted hover:text-accent","data-testid":`note-comment-add-${e.id.slice(0,8)}`,title:a("notebook.note.add_comment"),children:[x.jsx(bi,{className:"w-2.5 h-2.5"})," ",a("notebook.note.add_comment")]}):null,m&&i&&x.jsx("button",{onClick:()=>i(m,d,e.id),className:"mt-2 inline-flex items-center gap-1 text-caption text-accent hover:underline font-bold","data-testid":`note-source-${e.id.slice(0,8)}`,children:m.type==="content"?x.jsxs(x.Fragment,{children:[x.jsx(Cn,{className:"w-3 h-3"}),a("notebook.source.jump_content")]}):x.jsxs(x.Fragment,{children:[x.jsx(Lh,{className:"w-3 h-3"}),a("notebook.source.jump_chat")]})}),x.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[x.jsx("span",{className:"text-caption text-ink-muted",children:y}),x.jsx("button",{onClick:()=>t(e.id),className:"text-caption text-ink-muted hover:text-warning","data-testid":`canvas-delete-${e.id.slice(0,8)}`,title:a("notebook.note.delete"),children:x.jsx(Co,{className:"w-3 h-3"})})]})]})]})})}const T=V3[e.artifactType]??Lx;return x.jsxs("div",{className:`bg-surface-2 rounded-lg p-3 relative ${e.pinned?"ring-1 ring-brand/40 bg-brand/5":""}`,"data-testid":`canvas-item-${e.id.slice(0,8)}`,children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.jsx("span",{className:"text-body inline-flex items-center text-ink-strong",children:x.jsx(T,{className:"w-4 h-4"})}),x.jsx("span",{className:"text-label font-bold text-ink-muted flex-1 truncate",children:e.title??W3(a,e.artifactType)}),e.artifactType==="quiz"&&e.lastResult&&x.jsx("span",{className:`text-caption font-bold px-1.5 py-0.5 rounded-full ${e.lastResult==="correct"?"bg-brand/15 text-brand":"bg-warning/15 text-warning"}`,"data-testid":`quiz-result-${e.id.slice(0,8)}`,children:e.lastResult==="correct"?a("notebook.quiz.last_correct"):a("notebook.quiz.last_wrong")}),e.pinned?x.jsxs("span",{className:"text-caption text-brand font-bold flex items-center gap-0.5",children:[x.jsx(sc,{className:"w-2.5 h-2.5"}),a("notebook.note.pinned")]}):null,x.jsx("button",{onClick:()=>n(e.id),className:"text-caption text-ink-muted hover:text-brand","data-testid":`canvas-pin-${e.id.slice(0,8)}`,title:e.pinned?a("notebook.note.unpin"):a("notebook.note.pin"),children:x.jsx(sc,{className:"w-3 h-3"})}),x.jsx("button",{onClick:()=>t(e.id),className:"text-caption text-ink-muted hover:text-warning","data-testid":`canvas-delete-${e.id.slice(0,8)}`,title:a("notebook.note.delete"),children:x.jsx(Co,{className:"w-3 h-3"})})]}),x.jsx("div",{className:"text-label",children:p?x.jsx(k.Suspense,{fallback:null,children:x.jsx(v0,{data:p,onQuizAnswered:f})}):x.jsx("div",{className:"text-ink-muted",children:a("notebook.artifact.broken")})}),x.jsx("div",{className:"text-caption text-ink-muted mt-2",children:y})]})}function jd({message:e,icon:t}){return x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6","data-testid":"empty-notebook",children:[x.jsx("div",{className:"text-4xl mb-3 opacity-30",children:t}),x.jsx("div",{className:"text-body text-ink-muted max-w-xs leading-relaxed",children:e})]})}function ro({label:e,icon:t,active:n,onClick:r,testid:s,badge:i}){return x.jsxs("button",{onClick:r,"data-testid":s,role:"tab","aria-selected":n,className:`flex-1 flex items-center justify-center gap-1 py-1.5 rounded-md text-label font-bold transition-colors ${n?"bg-brand/20 text-brand":"text-ink-muted hover:text-ink-strong"}`,children:[x.jsx(t,{className:"w-3 h-3"}),x.jsx("span",{children:e}),i&&x.jsx("span",{className:`text-caption px-1.5 py-0.5 rounded-full font-bold ${n?"bg-brand/30 text-brand":"bg-ink/10 text-ink-faint"}`,children:i})]})}function K3({src:e,alt:t,assets:n,...r}){const[s,i]=k.useState(null),a=e??"",o=k.useMemo(()=>{if(!a||a.startsWith("http")||a.startsWith("data:"))return null;const u=a.split("/").pop()??a;return n.find(c=>{var f;return(f=c.sourcePath)==null?void 0:f.endsWith(u)})??n.find(c=>c.filename===u)??null},[a,n]);if(k.useEffect(()=>{if(!o){i(null);return}let u=!1;return oe.getAssetDataUrl(o.id).then(c=>{u||i(c)}),()=>{u=!0}},[o]),!a)return null;const l=s??a;return x.jsx("img",{src:l,alt:t??"","data-asset-id":o==null?void 0:o.id,className:"rounded-lg max-w-full h-auto my-3",loading:"lazy",...r})}function X3({asset:e}){const t=Ke(),[n,r]=k.useState(null),[s,i]=k.useState(!1);return k.useEffect(()=>{let a=!1;return oe.getAssetDataUrl(e.id).then(o=>{a||r(o)}),()=>{a=!0}},[e.id]),x.jsxs(x.Fragment,{children:[x.jsx("button",{onClick:()=>i(!0),className:"block rounded-lg overflow-hidden bg-ink/5 dark:bg-ink/10 hover:ring-2 hover:ring-accent transition-all",title:e.altText??e.filename,children:n?x.jsx("img",{src:n,alt:e.altText??e.filename,"data-asset-id":e.id,className:"w-full h-24 object-cover",loading:"lazy"}):x.jsx("div",{className:"w-full h-24 flex items-center justify-center text-ink-faint text-caption",children:t("notebook.asset.loading")})}),s&&n&&x.jsxs("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-8 cursor-pointer",onClick:()=>i(!1),children:[x.jsx("img",{src:n,alt:e.altText??e.filename,"data-asset-id":e.id,className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg"}),x.jsx("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white","aria-label":t("action.close"),onClick:a=>{a.stopPropagation(),i(!1)},children:x.jsx(kr,{className:"w-6 h-6"})})]})]})}function Q3(e){const[t,n]=k.useState([]),[r,s]=k.useState(!0),i=k.useCallback(async()=>{if(!e){n([]),s(!1);return}try{const m=await oe.canvasList(e);n(m)}catch{n([])}finally{s(!1)}},[e]);k.useEffect(()=>{i()},[i]);const a=k.useCallback(async m=>{if(!e)return null;try{const p=await oe.canvasSave({...m,courseId:e});return n(g=>g.some(y=>y.id===p.id)?g:[p,...g]),p}catch{return null}},[e]),o=k.useCallback(async m=>{if(!e)return null;try{const p=await oe.canvasSaveUserNote({...m,courseId:e});return n(g=>[p,...g]),p}catch{return null}},[e]),l=k.useCallback(async(m,p)=>{try{const g=await oe.canvasRecordQuizResult(m,p);return g&&n(y=>y.map(T=>T.id===m?g:T)),g}catch{return null}},[]),u=k.useCallback(async(m,p)=>{try{const g=await oe.canvasUpdateUserNoteComment(m,p);return g&&n(y=>y.map(T=>T.id===m?g:T)),g}catch{return null}},[]),c=k.useCallback(async m=>{try{await oe.canvasDelete(m),n(p=>p.filter(g=>g.id!==m))}catch{}},[]),f=k.useCallback(async m=>{try{const p=await oe.canvasTogglePin(m);p&&n(g=>g.map(T=>T.id===m?p:T).sort((T,v)=>v.pinned!==T.pinned?v.pinned-T.pinned:v.createdAt.localeCompare(T.createdAt)))}catch{}},[]),h=k.useCallback(m=>m===null?t:t.filter(p=>p.nodeId===m),[t]),d=k.useCallback((m,p)=>{const g=m===null?t:t.filter(y=>y.nodeId===m);return p==="note"?g.filter(y=>y.artifactType==="user_note"):p==="practice"?g.filter(y=>y.artifactType==="quiz"):g.filter(y=>["concept_map","compare_table","diagram","code_walkthrough"].includes(y.artifactType))},[t]);return{items:t,loading:r,reload:i,save:a,saveUserNote:o,recordQuizResult:l,updateUserNoteComment:u,remove:c,togglePin:f,byNode:h,byZone:d}}const Hd={small:16,medium:17,large:18},Ud="lookatstudy-font-size",J3="medium";function Z3(){const[e,t]=k.useState(()=>{if(typeof localStorage<"u"){const r=localStorage.getItem(Ud);if(r&&r in Hd)return r}return J3});k.useEffect(()=>{document.documentElement.style.fontSize=`${Hd[e]}px`,localStorage.setItem(Ud,e)},[e]);const n=k.useCallback(r=>{t(s=>{const i=["small","medium","large"],a=i.indexOf(s),o=r==="up"?Math.min(a+1,i.length-1):Math.max(a-1,0);return i[o]})},[]);return{size:e,bump:n}}const io=new Map;function e_({ref_:e,onOpen:t}){const n=Ke(),[r,s]=k.useState(e.previewUrl??(e.file?io.get(e.file)??null:null));return k.useEffect(()=>{if(r||!e.file)return;let i=!1;return(async()=>{const a=io.get(e.file);if(a){i||s(a);return}const o=await oe.getAttachmentDataUrl(e.file);o&&!i&&(io.set(e.file,o),s(o))})(),()=>{i=!0}},[e.file,r]),r?x.jsx("button",{type:"button",onClick:()=>t(r),"aria-label":n("chat.attach.preview",{name:e.name}),className:"w-24 h-24 rounded-lg overflow-hidden border border-[var(--border)] hover:border-accent transition-colors shrink-0",children:x.jsx("img",{src:r,alt:e.name,className:"w-full h-full object-cover"})}):x.jsx("div",{className:"w-24 h-24 rounded-lg bg-ink/[0.06] flex items-center justify-center text-caption text-ink-faint",title:e.name,children:e.name.slice(0,8)})}function t_({src:e,name:t,onClose:n}){return k.useEffect(()=>{const r=s=>{s.key==="Escape"&&n()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n]),x.jsxs("div",{role:"dialog","aria-label":t,className:"fixed inset-0 z-[70] bg-black/80 flex items-center justify-center p-8 cursor-zoom-out animate-[toast-enter_.15s_ease-out]",onClick:n,"data-testid":"attachment-lightbox",children:[x.jsx("img",{src:e,alt:t,className:"max-w-full max-h-full object-contain rounded-lg shadow-elevated"}),x.jsx("button",{type:"button","aria-label":"close",onClick:n,className:"absolute top-4 right-4 w-9 h-9 rounded-full bg-white/10 hover:bg-white/20 text-white flex items-center justify-center transition-colors",children:x.jsx(kr,{className:"w-4 h-4"})})]})}function n_({parts:e}){const t=Ke(),[n,r]=k.useState(null),s=e.filter(o=>o.type==="attachment").map(o=>o.attachment);if(s.length===0)return null;const i=s.filter(o=>o.kind==="image"),a=s.filter(o=>o.kind==="text");return x.jsxs("div",{className:"flex flex-col gap-1.5 mb-1","data-testid":"message-attachments",children:[i.length>0&&x.jsx("div",{className:"flex gap-1.5 flex-wrap",children:i.map((o,l)=>x.jsx(e_,{ref_:o,onOpen:u=>r({src:u,name:o.name})},o.file??o.previewUrl??`${o.name}:${l}`))}),a.length>0&&x.jsx("div",{className:"flex gap-1.5 flex-wrap",children:a.map((o,l)=>x.jsxs("span",{"data-tooltip":t("chat.attach.textChip"),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-ink/[0.06] text-caption text-ink-muted",children:[x.jsx(Ws,{className:"w-3 h-3 shrink-0"}),x.jsx("span",{className:"truncate max-w-[12rem]",children:o.name})]},`${o.name}:${l}`))}),n&&x.jsx(t_,{src:n.src,name:n.name,onClose:()=>r(null)})]})}const r_=k.lazy(()=>we(()=>import("./index-Brv5KtDR.js"),__vite__mapDeps([28,1,2,29,30,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer})));function i_({messages:e,streaming:t,onApplyProposal:n,onRejectProposal:r,summary:s,onStartLearning:i,agentReady:a=!0,onGotoSettings:o,hasNode:l=!0,selectedNodeId:u,threadId:c,onSaveChatNote:f,chatNotes:h,onPickQuizAction:d,onQuizCompleted:m,cardMode:p=!1}){const g=Ke(),y=iu(),T=g0();k.useEffect(()=>{if(T.failReason){const F=T.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":T.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":T.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":T.failReason==="edge-failed"?"chat.speech.edge_failed":T.failReason==="custom-provider-missing"?"chat.speech.custom_provider_missing":"chat.speech.model_missing";y.show(g(F),{severity:"warning"}),T.clearFailReason()}},[T.failReason,y,g,T]),k.useEffect(()=>{T.onlineNotice&&(y.show(g("chat.speech.edge_disclosed"),{severity:"info"}),T.clearOnlineNotice())},[T.onlineNotice,y,g,T]);const v=k.useCallback((F,q,R)=>{u&&oe.recordQuizAnswer(u,R,F.kc).catch(()=>{})},[u]),[C,E]=k.useState(null);k.useEffect(()=>{if(!u){E(null);return}let F=!1;const q=()=>oe.getProgress(u).then($=>{F||E(($==null?void 0:$.mastery)??null)}).catch(()=>{});q();const R=oe.on("state:changed",$=>{$==="mastery"&&q()});return()=>{F=!0,R()}},[u]);const w=k.useRef(null),_=k.useRef(!0),[S,I]=k.useState(!1);k.useEffect(()=>{const F=q=>{const R=q.detail;if(!(R!=null&&R.msgId))return;const $=document.querySelector(`[data-msg-id="${R.msgId}"]`);$&&($.scrollIntoView({behavior:"smooth",block:"center"}),$.classList.add("ring-2","ring-accent","rounded-lg"),setTimeout(()=>$.classList.remove("ring-2","ring-accent","rounded-lg"),2500))};return window.addEventListener("lookatstudy-highlight-message",F),()=>window.removeEventListener("lookatstudy-highlight-message",F)},[]),k.useEffect(()=>{if(t||!w.current||!h||h.length===0)return;const F=setTimeout(()=>{if(!w.current)return;const q=new Map;for(const R of h)try{const $=JSON.parse(R.sourceAnchor);if($.type==="chat"&&$.msgId){const X=JSON.parse(R.data).text??"";if(X){const D=q.get($.msgId)??[];D.push({noteId:R.id,text:X}),q.set($.msgId,D)}}}catch{}for(const[R,$]of q){const X=w.current.querySelector(`[data-msg-id="${R}"]`);X&&t0(X,$)}},150);return()=>clearTimeout(F)},[e,h,t]),k.useEffect(()=>{const F=q=>{var X;const R=q.detail;if(!R)return;const $=(X=w.current)==null?void 0:X.querySelector(`mark[data-note-id="${R}"]`);$&&u0($)};return window.addEventListener("lookatstudy-jump-to-chat-note",F),()=>window.removeEventListener("lookatstudy-jump-to-chat-note",F)},[]);const[A,P]=k.useState(null),N=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,j=k.useCallback(()=>{if(!f||!c)return;const F=window.getSelection(),q=(F==null?void 0:F.toString().trim())??"";if(q.length<2||q.length>500){P(null);return}const R=F==null?void 0:F.getRangeAt(0);if(!R){P(null);return}const $=w.current;if(!($!=null&&$.contains(R.commonAncestorContainer))){P(null);return}let X=R.commonAncestorContainer,D=null;for(;X&&X!==$;){if(X instanceof HTMLElement&&X.dataset.msgId){D=X;break}X=X.parentNode}if(!D){P(null);return}const Z=D.dataset.msgId,le=wi(D),z=Jp(R,le),ee=R.getBoundingClientRect(),K=$.getBoundingClientRect(),ce=R.getClientRects(),fe=ce.length?ce[ce.length-1]:ee,re=d0({left:ee.left-K.left,top:ee.top-K.top,right:ee.right-K.left,bottom:ee.bottom-K.top,width:ee.width,height:ee.height},K.width,N?150:110,{left:fe.left-K.left,top:fe.top-K.top,right:fe.right-K.left,bottom:fe.bottom-K.top,width:fe.width,height:fe.height},N);P({x:re.left,y:re.top,transform:re.transform,text:q,msgId:Z,startOffset:z==null?void 0:z.start,endOffset:z==null?void 0:z.end})},[f,c,N]);k.useEffect(()=>{const F=N?600:250;let q=null,R=null,$=!1;const X=()=>{var z;return(((z=window.getSelection())==null?void 0:z.toString().trim().length)??0)>=2},D=()=>{X()?(R&&(clearTimeout(R),R=null),P(z=>z&&null),q&&clearTimeout(q),q=setTimeout(()=>{q=null,!$&&X()&&j()},F)):R||(R=setTimeout(()=>P(z=>z&&null),250))},Z=z=>{var K;const ee=z.target;(K=ee==null?void 0:ee.closest)!=null&&K.call(ee,"[data-selection-popover]")||($=!0)},le=()=>{$=!1,q&&(clearTimeout(q),q=null),!R&&X()&&j()};return document.addEventListener("selectionchange",D),window.addEventListener("pointerdown",Z,!0),window.addEventListener("pointerup",le,!0),window.addEventListener("pointercancel",le,!0),()=>{document.removeEventListener("selectionchange",D),window.removeEventListener("pointerdown",Z,!0),window.removeEventListener("pointerup",le,!0),window.removeEventListener("pointercancel",le,!0),q&&clearTimeout(q),R&&clearTimeout(R)}},[j]);const M=k.useCallback(()=>{var q;if(!A||!f)return;const F=A.text.length>200?A.text.slice(0,200)+"…":A.text;f(F,A.msgId,A.startOffset,A.endOffset),P(null),(q=window.getSelection())==null||q.removeAllRanges()},[A,f]),L=k.useCallback(()=>{const F=w.current;if(!F)return;const q=F.scrollHeight-F.scrollTop-F.clientHeight<80;_.current=q,I(R=>R===!q?R:!q)},[]);k.useEffect(()=>{if(!_.current)return;const F=w.current;F&&(F.scrollTop=F.scrollHeight)},[e,t]);const B=e.length>0&&e[e.length-1].role==="user";k.useEffect(()=>{if(!B)return;_.current=!0,I(!1);const F=w.current;F&&(F.scrollTop=F.scrollHeight)},[B]);const V=k.useCallback(()=>{const F=w.current;F&&(F.scrollTop=F.scrollHeight,_.current=!0,I(!1))},[]);return x.jsxs("div",{className:"relative flex-1 min-h-0",children:[x.jsxs("div",{ref:w,onScroll:L,className:`h-full overflow-y-auto px-3 py-4 space-y-2 relative ${p?"":"px-5 py-6 space-y-6"}`,"data-testid":"chat-stream",children:[e.length===0&&x.jsx("div",{className:"mt-10 mx-auto max-w-md","data-testid":"chat-empty-state",children:l?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"text-center mb-4",children:[x.jsx("div",{className:"text-4xl mb-2 opacity-30",children:"📖"}),x.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:g("chat.empty.greeting")}),x.jsx("div",{className:"text-ink-muted text-label",children:g("chat.empty.overview")})]}),s?x.jsxs("div",{className:"surface-card p-4 mb-4",children:[x.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-2",children:g("chat.empty.summary.title")}),x.jsx("div",{className:"text-body text-ink-muted leading-relaxed whitespace-pre-wrap",children:s})]}):x.jsx("div",{className:"surface-card p-4 mb-4 text-center",children:x.jsx("div",{className:"text-body text-ink-muted",children:g("chat.empty.summary.none")})}),a?x.jsx(x.Fragment,{children:i&&x.jsxs("button",{onClick:i,disabled:t,"data-testid":"start-learning-btn",className:"btn-3d-brand w-full py-3 text-body font-bold flex items-center justify-center gap-2 disabled:opacity-40",children:[x.jsx(Mx,{className:"w-4 h-4"}),x.jsx("span",{children:g("chat.empty.start")})]})}):x.jsxs("div",{className:"surface-card p-4 mb-2","data-testid":"keyless-card",children:[x.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:g("chat.empty.keyless.title")}),x.jsx("div",{className:"text-label text-ink-muted mb-3",children:g("chat.empty.keyless.desc")}),x.jsxs("button",{onClick:o,className:"btn-3d-brand w-full py-2 text-body font-bold flex items-center justify-center gap-2",children:[x.jsx(ws,{className:"w-4 h-4"}),x.jsx("span",{children:g("chat.empty.keyless.btn")})]})]})]}):x.jsxs("div",{className:"text-center mt-16","data-testid":"no-node-selected",children:[x.jsx("div",{className:"text-5xl mb-3 opacity-25",children:"🗺️"}),x.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:g("chat.empty.no_node.title")}),x.jsx("div",{className:"text-body text-ink-muted max-w-xs mx-auto",children:g("chat.empty.no_node.desc")})]})}),e.map(F=>x.jsx("div",{className:p?"":"contents",children:x.jsx("div",{className:p&&F.role==="assistant"?"surface-card p-4 rounded-2xl shadow-card":void 0,children:x.jsx(s_,{msg:F,onApplyProposal:n,onRejectProposal:r,onQuizAnswered:v,quizMastery:C,onPickAction:d,onQuizCompleted:m,speakingMessageId:T.speakingMessageId,speakingSentence:T.speakingSentence,playingSentence:T.playingSentence,streamTexts:T.streamTexts,onSpeak:T.speak})})},F.id)),t&&x.jsxs("div",{className:"flex items-center gap-1.5 text-body text-brand",children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"})]})]}),S&&e.length>0&&x.jsxs("button",{onClick:V,"data-testid":"scroll-to-bottom","aria-label":g("chat.scroll.bottom"),title:g("chat.scroll.bottom"),className:"absolute bottom-4 right-4 w-9 h-9 rounded-full bg-ink-strong text-surface-0 shadow-elevated flex items-center justify-center hover:scale-105 active:scale-95 transition-transform msg-enter",children:[x.jsx(Il,{className:"w-5 h-5"}),t&&x.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 bg-brand rounded-full border-2 border-[var(--ink-strong)] animate-pulse"})]}),A&&x.jsxs("button",{onClick:M,"data-testid":"save-chat-note-btn","data-selection-popover":!0,style:{left:A.x,top:A.y,transform:A.transform},className:"absolute z-20 px-3 py-1.5 rounded-lg bg-brand text-white text-body font-bold shadow-elevated flex items-center gap-1 hover:bg-brand-light transition msg-enter whitespace-nowrap",title:g("chat.note.add.title"),children:[x.jsx(bi,{className:"w-3 h-3"})," ",g("chat.note.add")]})]})}function zd(e){const t=[];for(const n of e)if(n.role==="assistant")for(let r=0;r<n.parts.length;r++){const s=n.parts[r];s.type==="tool-call"&&s.state==="output-available"&&s.output&&typeof s.output=="object"&&"artifactType"in s.output&&t.push({id:`${n.id}-${r}`,toolName:s.toolName,output:s.output})}return t}function s_({msg:e,onApplyProposal:t,onRejectProposal:n,onQuizAnswered:r,quizMastery:s,onPickAction:i,onQuizCompleted:a,speakingMessageId:o,speakingSentence:l,playingSentence:u,streamTexts:c,onSpeak:f}){const h=Ke(),d=k.useRef(null),m=e.parts.map(T=>T.type==="text"?T.text:"").join("").trim(),p=o===e.id,g=p&&u!=null?u.index:null;k.useEffect(()=>{const T=d.current;if(!T)return;if(g==null){Jn(T);return}const v=Xp(c??[],g);if(!v)return;g===0&&a0(T);const C=setTimeout(()=>{const E=o0(T,v,{within:'[data-testid="part-text"]'});E&&l0(E,T.closest(".overflow-y-auto"))},30);return()=>clearTimeout(C)},[g,c]),k.useEffect(()=>{g==null&&d.current&&Jn(d.current)},[g]);const y=k.useRef(!1);return y.current=g!=null,k.useEffect(()=>()=>{y.current&&Jn(document.body)},[]),e.role==="user"?x.jsx("div",{className:"msg-enter flex justify-end","data-testid":"msg-user","data-msg-id":e.id,children:x.jsxs("div",{className:"max-w-[85%] bg-ink/[0.04] rounded-2xl rounded-br-md px-4 py-2.5",children:[x.jsx(n_,{parts:e.parts}),x.jsx("div",{className:"font-medium text-ink-strong whitespace-pre-wrap select-text text-body",children:e.displayText??e.parts.map((T,v)=>T.type==="text"?x.jsx("span",{children:T.text},v):null)})]})}):x.jsxs("div",{className:"msg-enter",ref:d,"data-testid":"msg-assistant","data-msg-id":e.id,children:[x.jsx("div",{className:"min-w-0 space-y-2.5",children:e.parts.map((T,v)=>x.jsx(a_,{part:T,msgId:e.id,toolCallIdx:v,onApplyProposal:t,onRejectProposal:n,onQuizAnswered:r,quizMastery:s,onPickAction:i,onQuizCompleted:a},v))}),f&&m&&x.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[x.jsx("button",{onClick:()=>f(e.id,m),"data-testid":p?"speech-stop-btn":"speech-speak-btn","aria-label":h(p?"chat.speech.stop":"chat.speech.speak"),title:h(p?"chat.speech.stop":"chat.speech.speak"),className:`w-7 h-7 rounded-lg flex items-center justify-center transition ${p?"bg-brand/15 text-brand":"text-ink-muted hover:bg-ink/[0.06] hover:text-ink"}`,children:p?x.jsx(Rl,{className:"w-3.5 h-3.5"}):x.jsx(Oh,{className:"w-4 h-4"})}),p&&l&&l.total>0&&x.jsx("span",{className:"text-caption text-ink-muted",children:h("chat.speech.progress").replace("{n}",String(l.index+1)).replace("{total}",String(l.total))})]})]})}function a_({part:e,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onQuizAnswered:i,quizMastery:a,onPickAction:o,onQuizCompleted:l}){const u=Kp(e.type==="text"?e.text:"");if(e.type==="text")return x.jsx("div",{className:"prose prose-sm max-w-[80ch] leading-relaxed break-words [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_img]:max-w-full [&_video]:max-w-full [&_iframe]:max-w-full select-text","data-testid":"part-text",children:x.jsx(Om,{remarkPlugins:u.remarkPlugins,rehypePlugins:u.rehypePlugins,urlTransform:m=>m,components:u_,children:c0(e.text)})});if(e.type==="reasoning")return x.jsx(o_,{text:e.text});if(e.type!=="tool-call")return null;const{toolName:c,state:f,output:h,error:d}=e;return x.jsx(l_,{toolName:c,state:f,output:h,error:d,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onQuizAnswered:i,quizMastery:a,onPickAction:o,onQuizCompleted:l})}function o_({text:e}){const t=Ke(),[n,r]=k.useState(!1);return x.jsxs("div",{className:"rounded-lg bg-surface-1/60 border border-[var(--border-faint)]","data-testid":"part-reasoning",children:[x.jsxs("button",{onClick:()=>r(s=>!s),className:"w-full flex items-center justify-between px-3 py-1.5 text-label font-bold text-ink-muted hover:text-ink-strong transition-colors",children:[x.jsxs("span",{children:[n?"▾":"▸"," ",t("chat.reasoning.label")]}),x.jsx("span",{className:"text-ink-muted font-normal",children:t("chat.reasoning.chars",{n:e.length})})]}),n&&x.jsx("div",{className:"px-3 pb-2.5 text-label text-ink-muted whitespace-pre-wrap leading-relaxed border-t border-[var(--border-faint)]/60 pt-2",children:e})]})}function l_({toolName:e,state:t,output:n,error:r,msgId:s,toolCallIdx:i,onApplyProposal:a,onRejectProposal:o,onQuizAnswered:l,quizMastery:u,onPickAction:c,onQuizCompleted:f}){const h=Ke(),m=(e==="record_answer"||e==="mark_mastered")&&t==="output-available"&&typeof n=="object"&&n!==null?n:null;if(m!=null&&m.proposalId){const y=m.status;return y==="applied"?x.jsxs("div",{className:"proposal-card rounded-xl border border-gold/30 bg-gold/5 p-3 flex items-center gap-2","data-testid":"part-proposal",children:[x.jsx(Nl,{className:"w-4 h-4 text-gold shrink-0"}),x.jsx("span",{className:"text-body font-bold text-ink",children:h("chat.proposal.applied")})]}):y==="rejected"?x.jsxs("div",{className:"proposal-card rounded-xl border border-ink/10 bg-ink/5 p-3 flex items-center gap-2","data-testid":"part-proposal",children:[x.jsx(dx,{className:"w-4 h-4 text-ink-muted shrink-0"}),x.jsx("span",{className:"text-body text-ink-muted",children:h("chat.proposal.rejected")})]}):x.jsxs("div",{className:"proposal-card relative rounded-xl border border-brand/30 bg-brand/5 overflow-hidden","data-testid":"part-proposal",children:[x.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-brand"}),x.jsxs("div",{className:"pl-4 pr-3 py-3",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-brand/15 text-brand shrink-0",children:x.jsx(yx,{className:"w-4 h-4"})}),x.jsx("span",{className:"text-lead font-bold text-ink",children:h("chat.proposal.mastered.title")})]}),m.message&&x.jsx("div",{className:"text-body text-ink mb-2 leading-relaxed",children:m.message}),x.jsx("div",{className:"text-caption text-ink-muted mb-3",children:h("chat.proposal.mastered.hint")}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("button",{onClick:()=>a==null?void 0:a(m.proposalId,s,i),"data-testid":"proposal-apply",className:"btn-3d-brand px-4 py-1.5 text-body",children:[x.jsx(An,{className:"w-3.5 h-3.5 inline"}),h("chat.proposal.confirm")]}),x.jsx("button",{onClick:()=>o==null?void 0:o(m.proposalId,s,i),"data-testid":"proposal-reject",className:"btn-3d-neutral px-4 py-1.5 text-body",children:h("chat.proposal.later")})]})]})]})}if(t==="output-available"&&n&&typeof n=="object"&&"artifactType"in n){const y=n.artifactType;return x.jsx("div",{className:"my-1 max-w-full","data-testid":`inline-artifact-${y}`,"data-tool":e,children:x.jsx(k.Suspense,{fallback:null,children:x.jsx(r_,{data:n,onQuizAnswered:l,quizMastery:u,onPickAction:c,onQuizCompleted:f})})})}const g=c_(e,h);return x.jsx("div",{className:"inline-flex items-center gap-1.5 text-label px-2.5 py-1 rounded-md bg-surface-1/60 border border-[var(--border-faint)]","data-testid":"part-tool","data-tool":e,"data-state":t,children:t==="input-available"?x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),x.jsxs("span",{className:"text-ink-muted",children:[g,"…"]})]}):t==="output-error"?x.jsxs(x.Fragment,{children:[x.jsx(Ah,{className:"w-3.5 h-3.5 text-warning shrink-0"}),x.jsxs("span",{className:"text-warning",children:[g,": ",r]})]}):x.jsxs(x.Fragment,{children:[x.jsx(Fh,{className:"w-3.5 h-3.5 text-ink-faint shrink-0"}),x.jsx("span",{className:"text-ink-muted",children:g})]})})}const u_={pre({children:e,...t}){return x.jsx(E0,{...t,children:e})},a({children:e,...t}){return x.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer",children:e})},table({children:e}){return x.jsx("div",{className:"overflow-x-auto my-4",children:x.jsx("table",{children:e})})}};function c_(e,t){return{get_node_info:t("chat.tool.get_node_info"),record_answer:t("chat.tool.record_answer"),mark_mastered:t("chat.tool.mark_mastered"),show_concept_map:t("chat.tool.show_concept_map"),generate_quiz:t("chat.tool.generate_quiz"),compare_table:t("chat.tool.compare_table"),draw_diagram:t("chat.tool.draw_diagram"),show_code_walkthrough:t("chat.tool.show_code_walkthrough")}[e]??e}const fi={maxPerMessage:4,maxImageBytes:5*1024*1024,maxTextBytes:256*1024},d_=new Set(["txt","md","markdown","rst","org","adoc","log","csv","tsv","json","yaml","yml","toml","ini","env","py","js","mjs","cjs","ts","tsx","jsx","go","rs","java","c","h","cpp","hpp","cs","rb","sh","bash","zsh","ps1","sql","html","htm","css","scss","vue","svelte","kt","swift","php","lua","r","dart","scala","clj","ex","exs","erl","hs","ml","jl","m","mm","pl","vb","bat","dockerfile"]);function Vd(e){const t=e.lastIndexOf(".");return t<=0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function f_(e,t,n){return t&&t.startsWith("image/")||["png","jpg","jpeg","webp","gif","bmp"].includes(Vd(e))?n>fi.maxImageBytes?{ok:!1,reason:"tooLargeImage"}:{ok:!0,kind:"image"}:d_.has(Vd(e))?n>fi.maxTextBytes?{ok:!1,reason:"tooLargeText"}:{ok:!0,kind:"text"}:{ok:!1,reason:"unsupported"}}function h_(e,t){const n=e.length,r=n*2,s=new ArrayBuffer(44+r),i=new DataView(s),a=(l,u)=>{for(let c=0;c<u.length;c++)i.setUint8(l+c,u.charCodeAt(c))};a(0,"RIFF"),i.setUint32(4,36+r,!0),a(8,"WAVE"),a(12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),a(36,"data"),i.setUint32(40,r,!0);let o=44;for(let l=0;l<n;l++){const u=e[l]<=-1?-1:e[l]>=1?1:e[l];i.setInt16(o,Math.round(u*32767),!0),o+=2}return s}function m_(e,t){const n=Math.floor(e.length/t),r=new Float32Array(n);for(let s=0;s<n;s++){const i=s*t,a=Math.floor(i),o=i-a,l=e[a]??0,u=e[a+1]??l;r[s]=l+(u-l)*o}return r}function p_(e,t,n={}){if(e.length===0||e.length!==t.length)return e;const r=n.threshold??.012;let s=0;for(;s<e.length-1&&t[s]<r;)s+=1;let i=e.length;for(;i>s+1&&t[i-1]<r;)i-=1;return e.slice(s,i)}function g_(e={}){const t=e.rmsThreshold??.015,n=e.minSpeechMs??300,r=e.silenceMs??1200,s=e.maxMs??6e4,i=e.autoStop!==!1;let a=null,o=0,l=null,u=null,c=!1;return{feed(f,h){a==null&&(a=h);const d=u==null?0:Math.max(0,h-u);if(u=h,f>=t)o+=d,o>=n&&(c=!0,l=h);else if(i&&c&&l!=null&&h-l>=r)return"auto-stop";return i&&h-a>=s?"auto-stop":"listening"},hadSpeech(){return c}}}const so=16e3;function x_(e,t={}){const[n,r]=k.useState(!1),[s,i]=k.useState(!1),[a,o]=k.useState(0),[l,u]=k.useState(null),[c,f]=k.useState(null),h=k.useRef(null),d=k.useRef(null),m=k.useRef(null),p=k.useRef([]),g=k.useRef([]),y=k.useRef(!1),T=k.useRef(null),v=k.useRef(0),C=k.useRef(e);C.current=e;const E=k.useRef(t);E.current=t;const w=k.useRef(!1),_=k.useRef(!1),S=k.useCallback(()=>{var j,M,L;y.current=!1,(j=m.current)==null||j.disconnect(),m.current=null,(M=d.current)==null||M.getTracks().forEach(B=>B.stop()),d.current=null,(L=h.current)==null||L.close().catch(()=>{}),h.current=null,p.current=[],g.current=[],T.current=null,o(0)},[]),I=k.useCallback(()=>{var X;const j=p.current,M=g.current,L=((X=T.current)==null?void 0:X.hadSpeech())??!1;p.current=[],g.current=[];let B=0;for(const D of j)B+=D.length;if(S(),r(!1),B===0)return;if(!L){f("no-speech");return}const V=p_(j,M);let F=0;for(const D of V)F+=D.length;const q=new Float32Array(F);let R=0;for(const D of V)q.set(D,R),R+=D.length;const $=h_(q,so);i(!0),f(null),window.api.asrTranscribe($,E.current.locale).then(D=>{D.ok?C.current(D.text):f(D.reason)}).catch(()=>f("asr-failed")).finally(()=>i(!1))},[S]),A=k.useCallback(()=>{y.current&&I()},[I]),P=k.useCallback(()=>{y.current||w.current||(u(null),w.current=!0,(async()=>{var j;try{if(((j=navigator.mediaDevices)==null?void 0:j.getUserMedia)==null){u(window.isSecureContext?"mic-unavailable":"mic-insecure-context");return}const M=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}}),L=window.AudioContext??window.webkitAudioContext;let B;try{B=new L({sampleRate:so})}catch{B=new L}h.current=B,d.current=M,y.current=!0,T.current=g_({autoStop:E.current.autoStop!==!1});const V=B.createMediaStreamSource(M),F=B.createScriptProcessor(4096,1,1);m.current=F;const q=B.sampleRate/so;F.onaudioprocess=$=>{var ee;if(!y.current)return;const X=$.inputBuffer.getChannelData(0),D=q===1?new Float32Array(X):m_(X,q);p.current.push(D);let Z=0;for(let K=0;K<D.length;K++)Z+=D[K]*D[K];const le=Math.sqrt(Z/D.length);g.current.push(le),v.current=v.current*.7+le*.3,o(Math.min(1,v.current*8)),_1(Math.min(1,v.current*8)),((ee=T.current)==null?void 0:ee.feed(le,performance.now()))==="auto-stop"&&y.current&&I()},V.connect(F);const R=B.createGain();R.gain.value=0,F.connect(R),R.connect(B.destination),r(!0),_.current&&(_.current=!1,I())}catch(M){S(),r(!1),u(M instanceof Error?M.message:String(M))}finally{w.current=!1}})())},[S,I]),N=k.useCallback(()=>{y.current?A():w.current&&(_.current=!0)},[A]);return k.useEffect(()=>()=>{y.current&&S()},[S]),{listening:n,transcribing:s,level:a,startError:l,transcribeError:c,clearTranscribeError:()=>f(null),beginHold:P,endHold:N}}function b_({onGotoSettings:e}){var p;const t=Ke(),[n,r]=k.useState(!1),[s,i]=k.useState(null),[a,o]=k.useState(""),[l,u]=k.useState(""),c=k.useRef(null),f=k.useCallback(async()=>{var g,y;try{const[T,v,C,E]=await Promise.all([oe.getProviderPresets(),oe.listCustomProviders(),oe.getSetting("active_provider"),oe.getSetting("active_model")]),w=C??"glm",_=await Promise.all(T.map(async j=>await oe.getSetting(j.apiKeySetting)!=null)),S=new Set;T.forEach((j,M)=>{(_[M]||j.id===w)&&S.add(j.id)});const I=[],A=(j,M,L)=>{for(const B of L)I.push({providerId:j,providerLabel:M,modelId:B.id,modelLabel:B.label,vision:(B.capabilities??[]).includes("vision"),contextWindow:B.contextWindow})};for(const j of T)S.has(j.id)&&A(j.id,j.label,j.models);const P=v.filter(j=>j.kind==="llm");for(const j of P)A(j.id,j.label,j.models);const N=E??"";if(N&&!I.some(j=>j.providerId===w&&j.modelId===N)){const j=((g=T.find(M=>M.id===w))==null?void 0:g.label)??((y=P.find(M=>M.id===w))==null?void 0:y.label)??w;I.unshift({providerId:w,providerLabel:j,modelId:N,modelLabel:N,vision:!0,contextWindow:null})}i(I),o(w),u(N)}catch{i([])}},[]);k.useEffect(()=>{f();const g=()=>void f();return window.addEventListener("llm-config-changed",g),()=>window.removeEventListener("llm-config-changed",g)},[f]),k.useEffect(()=>{if(!n)return;const g=T=>{var v;T.target instanceof Node&&((v=c.current)==null?void 0:v.contains(T.target))!==!0&&r(!1)},y=T=>{T.key==="Escape"&&r(!1)};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",y)}},[n]);const h=async g=>{if(r(!1),!(g.providerId===a&&g.modelId===l))try{await oe.setSetting("active_provider",g.providerId),await oe.setSetting("active_model",g.modelId),o(g.providerId),u(g.modelId),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},d=((p=s==null?void 0:s.find(g=>g.providerId===a&&g.modelId===l))==null?void 0:p.modelLabel)??l??t("model.picker.label"),m=[];for(const g of s??[]){const y=m[m.length-1];y&&y.label===g.providerLabel?y.rows.push(g):m.push({label:g.providerLabel,rows:[g]})}return x.jsxs("div",{ref:c,className:"relative","data-testid":"composer-model",children:[x.jsxs("button",{type:"button",onClick:()=>r(!n),"aria-haspopup":"menu","aria-expanded":n,"data-tooltip":t("model.picker.label"),"data-testid":"composer-model-trigger",className:"flex items-center gap-1 max-w-[13rem] px-1.5 py-0.5 rounded-full text-caption font-medium text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors",children:[x.jsx(ox,{className:"w-3 h-3 shrink-0 coarse-only","aria-hidden":!0}),x.jsx("span",{className:"truncate tb-label",children:d}),x.jsx(Sh,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${n?"":"rotate-180"}`})]}),n&&x.jsxs("div",{role:"menu","aria-label":t("model.picker.label"),"data-testid":"composer-model-menu",className:"absolute bottom-full right-0 mb-1.5 z-50 w-64 max-w-[calc(100vw-1.5rem)] max-h-72 overflow-y-auto bg-surface-0 rounded-xl shadow-elevated border border-[var(--border)] py-1.5",children:[m.length===0&&x.jsx("div",{className:"px-3 py-2 text-caption text-ink-faint",children:t("model.picker.noneConfigured")}),m.map(g=>x.jsxs("div",{role:"group","aria-label":g.label,children:[x.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-caption font-bold text-ink-faint",children:g.label}),g.rows.map(y=>{const T=y.providerId===a&&y.modelId===l;return x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T,onClick:()=>void h(y),className:`w-full flex items-center gap-1.5 px-3 py-1.5 text-left transition-colors ${T?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"}`,children:[x.jsx(An,{className:`w-3.5 h-3.5 shrink-0 ${T?"opacity-100":"opacity-0"}`}),x.jsx("span",{className:"flex-1 truncate text-label",children:y.modelLabel}),y.vision&&x.jsx(px,{className:"w-3 h-3 shrink-0 text-ink-faint","aria-label":t("model.picker.vision")})]},`${y.providerId}:${y.modelId}`)})]},g.label)),x.jsx("div",{className:"border-t border-[var(--border)] mt-1 pt-1",children:x.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{r(!1),e()},className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-left text-label text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors",children:[x.jsx(Fx,{className:"w-3.5 h-3.5"}),t("model.picker.manage")]})})]})]})}const Ko=5.5,qd=2*Math.PI*Ko,fr=["system","node","learner","history","draft"],Wd={system:"bg-accent",node:"bg-brand",learner:"bg-gold",history:"bg-ink/50",draft:"bg-exam"};function y_({info:e,historyTokens:t,draftTokens:n}){const r=Ke(),[s,i]=k.useState(!1),a=k.useRef(null);if(k.useEffect(()=>{!(e!=null&&e.contextWindow)&&s&&i(!1)},[e==null?void 0:e.contextWindow,s]),k.useEffect(()=>{if(!s)return;const h=m=>{var p;m.target instanceof Node&&((p=a.current)==null?void 0:p.contains(m.target))!==!0&&i(!1)},d=m=>{m.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",h),document.addEventListener("keydown",d),()=>{document.removeEventListener("pointerdown",h),document.removeEventListener("keydown",d)}},[s]),!e)return null;const o={system:e.systemTokens,node:e.nodeTokens,learner:e.learnerTokens,history:t,draft:n},l=fr.reduce((h,d)=>h+o[d],0),u=Wx(l,e.contextWindow),c=u!==null&&u>=85,f=$x(fr.map(h=>o[h]),u??0);return x.jsxs("span",{ref:a,className:"relative inline-flex items-center","data-testid":"composer-context",children:[x.jsxs("button",{type:"button",onClick:()=>i(!s),disabled:e.contextWindow===null,"aria-label":r("context.aria",{p:u!==null?`${u}%`:ur(l)}),"aria-haspopup":"dialog","aria-expanded":s,"data-testid":"composer-context-trigger","data-tooltip":e.contextWindow===null?`${r("context.label")} ~${ur(l)} · ${r("context.unknownWindow")}`:r("context.aria",{p:`${u}%`}),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-full text-caption font-medium transition-colors ${c?"text-warning":"text-ink-muted"} hover:bg-ink/[0.06] disabled:hover:bg-transparent`,children:[x.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":!0,className:"shrink-0",children:[x.jsx("circle",{cx:"7",cy:"7",r:Ko,fill:"none",strokeWidth:"2",className:"stroke-ink/20"}),x.jsx("circle",{cx:"7",cy:"7",r:Ko,fill:"none",strokeWidth:"2",stroke:"currentColor",strokeLinecap:"round",strokeDasharray:`${qd*(u??100)/100} ${qd}`,transform:"rotate(-90 7 7)"})]}),u!==null?x.jsxs("span",{className:"tb-label",children:[u,"%"]}):x.jsxs("span",{className:"tb-label",children:["~",ur(l)]})]}),s&&e.contextWindow!==null&&x.jsxs("div",{role:"dialog","aria-label":r("context.label"),"data-testid":"composer-context-panel",className:"absolute bottom-full right-0 mb-1.5 z-50 w-64 max-w-[calc(100vw-1.5rem)] bg-surface-0 rounded-xl shadow-elevated border border-[var(--border)] p-3",children:[x.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[x.jsx("span",{className:"text-label font-bold text-ink-strong",children:r("context.label")}),x.jsxs("span",{className:`text-caption ${c?"text-warning":"text-ink-muted"}`,children:[r("context.approx")," ",ur(l)," / ",ur(e.contextWindow)]})]}),x.jsx("div",{className:"flex h-2 rounded-full overflow-hidden bg-ink/10 mb-2",role:"img","aria-label":`${u}%`,children:fr.map(h=>f[fr.indexOf(h)]>0?x.jsx("div",{className:Wd[h],style:{width:`${f[fr.indexOf(h)]}%`}},h):null)}),x.jsx("dl",{className:"space-y-1",children:fr.map(h=>x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("dt",{className:"flex items-center gap-1.5 text-caption text-ink-muted",children:[x.jsx("span",{className:`w-2 h-2 rounded-sm ${Wd[h]}`,"aria-hidden":!0}),r(`context.${h}`)]}),x.jsxs("dd",{className:"text-caption text-ink-strong tabular-nums",children:["~",ur(o[h])]})]},h))})]})]})}const Xo={glm:{fast:e=>{e.thinking={type:"disabled"},e.reasoning_effort="low"},deep:e=>{e.thinking={type:"enabled"}}},qwen:{fast:e=>{e.enable_thinking=!1},deep:e=>{e.enable_thinking=!0}},siliconcloud:{fast:e=>{e.enable_thinking=!1},deep:e=>{e.enable_thinking=!0}}};function E_(e,t,n){if(e==="openai"||e in Xo)return e;const r=(t??"").toLowerCase(),s=(n??"").toLowerCase();return r.includes("bigmodel.cn")||r.includes("z.ai")||s.startsWith("glm")?"glm":r.includes("dashscope")||s.startsWith("qwen")?"qwen":r.includes("siliconflow")?"siliconcloud":e}function v_(e,t,n){return t==="anthropic"||t==="google"||e==="openai"||e in Xo?!0:E_(e,n==null?void 0:n.baseUrl,n==null?void 0:n.model)in Xo}const ao=[{value:"",labelKey:"effort.auto.label",descKey:"effort.auto.desc"},{value:"fast",labelKey:"effort.fast.label",descKey:"effort.fast.desc"},{value:"deep",labelKey:"effort.deep.label",descKey:"effort.deep.desc"}];function T_(){const e=Ke(),[t,n]=k.useState(!1),[r,s]=k.useState(""),[i,a]=k.useState(!0),o=k.useRef(null),l=k.useRef(null),[u,c]=k.useState("right"),[f,h]=k.useState(0),d=k.useRef(0),[m,p]=k.useState(0);k.useLayoutEffect(()=>{if(!t){p(0),d.current=0,h(0);return}const v=l.current;if(!v)return;const C=v.getBoundingClientRect(),E=C.left-d.current,w=C.right-d.current,_=window.innerWidth;if(m===0){if(E<8&&w<=_-8){c("left"),p(1);return}if(w>_-8&&E>=8){c("right"),p(1);return}p(1)}const S=Math.min(0,_-8-w)+Math.max(0,8-E);S!==d.current&&(d.current=S,h(S))},[t,m]);const g=k.useCallback(async()=>{var v;try{const[C,E,w,_,S]=await Promise.all([oe.getSetting("active_provider"),oe.getSetting("reasoning_effort"),oe.getProviderPresets(),oe.listCustomProviders(),oe.getSetting("active_model")]),I=C??"glm",A=_.find(j=>j.id===I),P=((v=w.find(j=>j.id===I))==null?void 0:v.protocol)??(A==null?void 0:A.protocol)??"openai-compatible";a(v_(I,P,{baseUrl:A==null?void 0:A.baseUrl,model:S??(A==null?void 0:A.defaultModel)}));const N=E??"";s(N==="fast"||N==="deep"?N:"")}catch{a(!1)}},[]);k.useEffect(()=>{g();const v=()=>void g();return window.addEventListener("llm-config-changed",v),()=>window.removeEventListener("llm-config-changed",v)},[g]),k.useEffect(()=>{if(!t)return;const v=E=>{var w;E.target instanceof Node&&((w=o.current)==null?void 0:w.contains(E.target))!==!0&&n(!1)},C=E=>{E.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",C),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",C)}},[t]);const y=async v=>{if(n(!1),v!==r){s(v);try{await oe.setSetting("reasoning_effort",v)}catch{s(r)}}},T=ao.find(v=>v.value===r)??ao[0];return x.jsxs("div",{ref:o,className:"relative","data-testid":"composer-effort",children:[x.jsxs("button",{type:"button",onClick:()=>!!i&&n(!t),disabled:!i,"aria-haspopup":"menu","aria-expanded":t,"data-testid":"composer-effort-trigger","data-tooltip":e(i?"effort.label":"effort.unsupported"),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-full text-caption font-medium transition-colors ${r?"text-accent":"text-ink-muted"} ${i?"hover:text-ink-strong hover:bg-ink/[0.06]":"opacity-40 cursor-not-allowed"}`,children:[x.jsx(lx,{className:"w-3 h-3 shrink-0"}),x.jsx("span",{className:"truncate tb-label",children:e(T.labelKey)}),x.jsx(Sh,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${t?"":"rotate-180"}`})]}),t&&x.jsx("div",{ref:l,role:"menu","aria-label":e("effort.label"),"data-testid":"composer-effort-menu",style:{transform:f?`translateX(${f}px)`:void 0},className:`absolute bottom-full ${u==="right"?"right-0":"left-0"} mb-1.5 z-50 w-60 max-w-[calc(100vw-1.5rem)] bg-surface-0 rounded-xl shadow-elevated border border-[var(--border)] py-1.5`,children:ao.map(v=>{const C=v.value===r;return x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":C,onClick:()=>void y(v.value),className:`w-full flex items-start gap-1.5 px-3 py-1.5 text-left transition-colors ${C?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"}`,children:[x.jsx(An,{className:`w-3.5 h-3.5 shrink-0 mt-0.5 ${C?"opacity-100":"opacity-0"}`}),x.jsxs("span",{className:"flex-1",children:[x.jsx("span",{className:"block text-label font-bold",children:e(v.labelKey)}),x.jsx("span",{className:"block text-caption text-ink-faint",children:e(v.descKey)})]})]},v.value||"auto")})})]})}const k_=k.lazy(()=>we(()=>import("./VoicePanel-CZfLESc_.js"),__vite__mapDeps([33,1,2,31]),import.meta.url).then(e=>({default:e.VoicePanel}))),w_={direct:"soul.direct",guide:"soul.guide",practice:"soul.practice"},S_={direct:Cn,guide:Ch,practice:Ex},A_={direct:"soul.direct.desc",guide:"soul.guide.desc",practice:"soul.practice.desc"},C_=["image/png","image/jpeg","image/webp","image/gif",".txt",".md",".markdown",".rst",".org",".adoc",".log",".csv",".tsv",".json",".yaml",".yml",".toml",".ini",".py",".js",".mjs",".cjs",".ts",".tsx",".jsx",".go",".rs",".java",".c",".h",".cpp",".hpp",".cs",".rb",".sh",".sql",".html",".css",".scss",".vue",".svelte",".kt",".swift",".php"].join(",");let $d=0;function __({nodeId:e,agentReady:t,streaming:n,souls:r,activeSoul:s,starterPrompts:i,onPickSoul:a,onSend:o,onStop:l,onLogFriction:u,onGotoSettings:c,insertText:f,historyTokens:h}){const d=Ke(),m=zh(),[p,g]=k.useState(""),[y,T]=k.useState([]),[v,C]=k.useState(null),[E,w]=k.useState(null),[_,S]=k.useState(!1),I=k.useRef(null),A=k.useRef(0),[P,N]=k.useState(!0);k.useEffect(()=>{oe.getSetting("asr_auto_stop").then(te=>N(te!=="0"))},[]);const[j,M]=k.useState(!1);k.useEffect(()=>(Ku(j),()=>Ku(!1)),[j]);const[L,B]=k.useState(""),[V,F]=k.useState(!1),[q,R]=k.useState(null),$=x_(te=>{B(te),F(!0)},{locale:m,autoStop:P}),X=$.startError??$.transcribeError;k.useEffect(()=>{if(!X)return;R(d(X==="no-speech"?"chat.speech.no_speech":X==="model-missing"?"chat.speech.asr_model_missing":X==="engine-unavailable"?"chat.speech.engine_unavailable":X==="custom-provider-missing"?"chat.speech.custom_provider_missing":X==="groq-key-missing"?"chat.speech.groq_key_missing":X==="azure-key-missing"?"chat.speech.azure_stt_key_missing":X==="azure-region-missing"?"chat.speech.azure_stt_region_missing":X==="mic-insecure-context"?"chat.speech.asr_insecure_context":X==="mic-unavailable"?"chat.speech.asr_start_fail":"chat.speech.asr_failed")),$.clearTranscribeError()},[X,$,d]);const D=q?"error":$.listening?"recording":$.transcribing?"transcribing":V?"review":"idle",Z=(te,Re,me)=>{I1(),o(te,Re,me)},le=k.useCallback(()=>{B(""),F(!1),R(null)},[]),z=k.useCallback(()=>{M(!1),le()},[le]),ee=()=>{const te=L.trim();!te||n||!e||(Z(te),z())};k.useEffect(()=>{f&&g(te=>te.trim()?`${te}
476
476
 
477
477
  ${f}`:f)},[f]),k.useEffect(()=>{if(!e){w(null);return}let te=!1;(async()=>{try{const me=await oe.getContextUsage(e,m);te||w(me)}catch{te||w(null)}})();const Re=()=>{oe.getContextUsage(e,m).then(me=>{te||w(me)}).catch(()=>{})};return window.addEventListener("llm-config-changed",Re),()=>{te=!0,window.removeEventListener("llm-config-changed",Re)}},[e,m]),k.useEffect(()=>{if(!v)return;const te=setTimeout(()=>C(null),3e3);return()=>clearTimeout(te)},[v]);const K=k.useRef(new Set);k.useEffect(()=>()=>{for(const te of K.current)URL.revokeObjectURL(te)},[]);const ce=k.useCallback(te=>{T(Re=>{const me=Re.find(je=>je.id===te);return me!=null&&me.previewUrl&&(URL.revokeObjectURL(me.previewUrl),K.current.delete(me.previewUrl)),Re.filter(je=>je.id!==te)})},[]),fe=k.useCallback(async te=>{if(te.length===0)return;const Re=fi.maxPerMessage-y.length;if(Re<=0){C(d("chat.attach.tooMany",{n:fi.maxPerMessage}));return}const me=te.length>Re?te.slice(0,Re):te;te.length>Re&&C(d("chat.attach.tooMany",{n:fi.maxPerMessage}));const je=[],st=[];for(const Be of me){const at=f_(Be.name,Be.type,Be.size);if(!at.ok){C(at.reason==="unsupported"?d("chat.attach.unsupported",{name:Be.name}):at.reason==="tooLargeImage"?d("chat.attach.tooLargeImage",{name:Be.name}):d("chat.attach.tooLargeText",{name:Be.name}));continue}if(at.kind==="image"){if((E==null?void 0:E.visionCapable)===!1){C(d("chat.attach.visionUnsupported"));continue}const G=await new Promise(xe=>{const Ee=new FileReader;Ee.onload=()=>{const Pe=Ee.result;xe(typeof Pe=="string"?Pe.slice(Pe.indexOf(",")+1):null)},Ee.onerror=()=>xe(null),Ee.readAsDataURL(Be)});if(G===null)continue;const se=URL.createObjectURL(Be);st.push(se),je.push({id:++$d,kind:"image",name:Be.name,mime:Be.type||"image/png",size:Be.size,previewUrl:se,base64:G})}else try{const G=await Be.text();je.push({id:++$d,kind:"text",name:Be.name,mime:Be.type||"text/plain",size:Be.size,text:G})}catch{}}if(je.length>0){for(const Be of st)K.current.add(Be);T(Be=>[...Be,...je])}else for(const Be of st)URL.revokeObjectURL(Be)},[y.length,E==null?void 0:E.visionCapable,d]),re=te=>{const Re=te.trim();if(n||!e||!Re&&y.length===0)return;const me=Re||Pl("chat.attach.imageOnlyText"),je=y.map(st=>({kind:st.kind,name:st.name,mime:st.mime,size:st.size,data:st.kind==="image"?st.base64??"":st.text??"",...st.kind==="image"&&st.previewUrl?{previewUrl:st.previewUrl}:{}}));Z(me,void 0,je.length>0?je:void 0),g(""),T([])},ne=()=>re(p),ge=te=>{n||(Z(te.message,te.label),te.frictionCategory&&(u==null||u(te.frictionCategory,null)))},Te=te=>{const Re=Array.from(te.clipboardData.files??[]);Re.length>0&&(te.preventDefault(),fe(Re))},Ne=te=>{te.dataTransfer.types.includes("Files")&&(te.preventDefault(),A.current+=1,S(!0))},Oe=te=>{te.dataTransfer.types.includes("Files")&&(A.current=Math.max(0,A.current-1),A.current===0&&S(!1))},be=te=>{te.dataTransfer.types.includes("Files")&&(te.preventDefault(),A.current=0,S(!1),fe(Array.from(te.dataTransfer.files??[])))},Fe=k.useMemo(()=>Bh(p),[p]);return t?x.jsxs("div",{className:"px-5 pb-4 pt-1 shrink-0","data-testid":"composer",children:[!j&&i.length>0&&e&&x.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-2","data-testid":"starter-prompts",children:i.map((te,Re)=>x.jsx("button",{onClick:()=>ge(te),disabled:n,"data-testid":`starter-prompt-${Re}`,"data-tooltip":te.hint??te.label,className:"shrink-0 whitespace-nowrap px-2.5 py-1 rounded-full text-caption font-medium text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors disabled:opacity-30",children:te.label},Re))}),x.jsx("div",{className:`composer-card relative rounded-2xl transition-colors px-3 pt-2 pb-1.5 ${_?"bg-accent/10 ring-1 ring-accent":"bg-ink/[0.05] focus-within:bg-ink/[0.07]"}`,onDragEnter:Ne,onDragOver:te=>{te.dataTransfer.types.includes("Files")&&te.preventDefault()},onDragLeave:Oe,onDrop:be,"data-testid":"composer-card",children:j?x.jsxs(x.Fragment,{children:[D!=="idle"&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(k_,{view:D,level:$.level,text:L,onTextChange:B,onSend:ee,onRerecord:le,errorMessage:q,sendDisabled:n||!e||!L.trim()})}),x.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[x.jsxs("span",{className:"flex items-center gap-1.5 text-label text-ink-muted font-medium",children:[x.jsx(cs,{className:"w-3.5 h-3.5 text-accent"}),d("chat.speech.dictation")]}),x.jsxs("button",{type:"button",onClick:z,"data-tooltip":d("chat.speech.back_to_keyboard"),"aria-label":d("chat.speech.back_to_keyboard"),"data-testid":"voice-keyboard-toggle",className:"touch-lift flex items-center gap-1 px-2 py-0.5 rounded-full text-caption font-medium text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors",children:[x.jsx(kx,{className:"w-3.5 h-3.5"}),x.jsx("span",{children:d("chat.speech.keyboard")})]})]}),x.jsxs("button",{type:"button",onPointerDown:te=>{te.preventDefault(),$.beginHold()},onPointerUp:$.endHold,onPointerLeave:$.endHold,onPointerCancel:$.endHold,onContextMenu:te=>te.preventDefault(),disabled:!e||D!=="idle","data-testid":$.listening?"voice-hold-btn-active":"voice-hold-btn",className:`w-full py-5 rounded-xl text-lead font-bold flex items-center justify-center gap-2 transition-all touch-none select-none disabled:opacity-40 ${$.listening?"bg-accent/25 text-accent scale-[0.99]":"bg-accent/10 text-accent hover:bg-accent/20 active:bg-accent/25 active:scale-[0.99]"}`,children:[x.jsx(cs,{className:"w-5 h-5"}),$.listening?d("chat.speech.release_to_stop"):d("chat.speech.hold_to_talk")]})]}):x.jsxs(x.Fragment,{children:[r.length>0&&x.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto mb-1","data-testid":"soul-picker",children:[x.jsx("span",{className:"text-body text-ink-faint shrink-0",children:d("chat.soul.label")}),r.map(te=>{const Re=s===te.name,me=S_[te.name]??Ch,je=d(A_[te.name]??"soul.direct.desc");return x.jsxs("button",{onClick:()=>a(te.name),"data-testid":`soul-pill-${te.name}`,"data-tooltip":je,className:`shrink-0 flex items-center gap-1 px-2 py-0.5 rounded-full text-body font-medium transition-colors ${Re?"bg-brand/15 text-brand":"text-ink-muted hover:text-ink-strong hover:bg-ink/5"}`,children:[x.jsx(me,{className:"w-3.5 h-3.5"}),x.jsx("span",{children:d(w_[te.name]??"soul.direct")})]},te.id)})]}),y.length>0&&x.jsxs("div",{className:"flex gap-1.5 flex-wrap mb-1.5","data-testid":"composer-attachments",children:[(E==null?void 0:E.visionBridgeModel)&&y.some(te=>te.kind==="image")&&x.jsxs("div",{className:"w-full flex items-center gap-1 text-caption text-ink-muted","data-testid":"vision-bridge-chip",children:[x.jsx(Dx,{className:"w-3.5 h-3.5 shrink-0"}),x.jsx("span",{children:d("chat.attach.bridgeChip",{model:E.visionBridgeModel})})]}),y.map(te=>te.kind==="image"?x.jsxs("div",{className:"relative w-16 h-16 shrink-0",children:[x.jsx("img",{src:te.previewUrl,alt:te.name,className:"w-16 h-16 object-cover rounded-lg border border-[var(--border)]"}),x.jsx("button",{type:"button",onClick:()=>ce(te.id),"aria-label":d("chat.attach.remove",{name:te.name}),className:"touch-target-sm absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-ink/70 hover:bg-warning text-white flex items-center justify-center transition-colors",children:x.jsx(kr,{className:"w-3 h-3"})})]},te.id):x.jsxs("span",{className:"inline-flex items-center gap-1 pl-2 pr-1 py-1 rounded-full bg-ink/[0.08] text-caption text-ink-strong",children:[x.jsx(Ws,{className:"w-3 h-3 shrink-0 text-ink-faint"}),x.jsx("span",{className:"truncate max-w-[10rem]",children:te.name}),x.jsx("button",{type:"button",onClick:()=>ce(te.id),"aria-label":d("chat.attach.remove",{name:te.name}),className:"touch-target-sm w-4 h-4 rounded-full hover:bg-ink/20 flex items-center justify-center text-ink-muted hover:text-warning transition-colors",children:x.jsx(kr,{className:"w-2.5 h-2.5"})})]},te.id))]}),v&&x.jsx("div",{className:"text-caption text-warning pb-1",role:"status","data-testid":"composer-notice",children:v}),x.jsxs("div",{className:"flex gap-2 items-end",children:[x.jsx("textarea",{value:p,onChange:te=>g(te.target.value),onFocus:()=>Xu(!0),onBlur:()=>Xu(!1),onKeyDown:te=>{te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),ne())},onPaste:Te,placeholder:d(e?"chat.input.placeholder":"chat.input.no_node"),disabled:n||!e,rows:2,"data-testid":"chat-input",className:"flex-1 bg-transparent text-ink-strong text-body rounded-lg px-1 py-1 resize-none focus:outline-none disabled:opacity-40 placeholder:text-ink-faint"}),n?x.jsx("button",{onClick:l,"data-testid":"chat-stop",className:"btn-icon-3d-warning shrink-0 w-9 h-9",title:d("chat.stop"),"aria-label":d("chat.stop"),children:x.jsx(Rl,{className:"w-3.5 h-3.5 fill-current"})}):x.jsx("button",{onClick:ne,disabled:n||!p.trim()&&y.length===0||!e,"data-testid":"chat-send",className:"btn-icon-3d-brand shrink-0 w-9 h-9",title:d("chat.send"),"aria-label":d("chat.send"),children:x.jsx(sx,{className:"w-4 h-4"})})]}),x.jsxs("div",{className:"composer-toolbar flex flex-wrap items-center justify-between gap-x-0.5 gap-y-1 mt-0.5",children:[x.jsx("button",{type:"button",onClick:()=>{le(),M(!0)},disabled:!e,"data-tooltip":d("chat.speech.dictation"),"aria-label":d("chat.speech.dictation"),"data-testid":"composer-mic",className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full text-caption font-medium text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors disabled:opacity-50",children:x.jsx(cs,{className:"w-3.5 h-3.5"})}),x.jsx("button",{type:"button",onClick:()=>{var te;return(te=I.current)==null?void 0:te.click()},"data-tooltip":d("chat.attach.add"),"aria-label":d("chat.attach.add"),"data-testid":"composer-attach",className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full text-caption font-medium text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06] transition-colors",children:x.jsx(Nx,{className:"w-3 h-3"})}),x.jsx("input",{ref:I,type:"file",multiple:!0,accept:C_,className:"hidden",onChange:te=>{fe(Array.from(te.target.files??[])),te.target.value=""}}),x.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-0.5",children:[x.jsx(T_,{}),x.jsx(y_,{info:E,historyTokens:h,draftTokens:Fe}),x.jsx(b_,{onGotoSettings:c})]})]})]})})]}):x.jsx("div",{className:"px-5 pb-4 shrink-0","data-testid":"composer-nokey",children:x.jsxs("div",{className:"flex items-center justify-center gap-3 py-3 text-body text-ink-muted",children:[x.jsx("span",{children:d("chat.no_key.short")}),x.jsx("button",{onClick:c,className:"text-brand hover:underline font-bold",children:d("chat.no_key.cta")})]})})}const Yd={viseme:"closed",open:0};function I_(e){const[t,n]=k.useState(Yd);return k.useEffect(()=>{if(!e){n(Yd);return}const r=new Uint8Array(256),s=new Uint8Array(h0/2);let i=0,a="",o=null,l=0;const u=()=>{const c=x3();if(c){let f,h;if(c.timeline&&c.timeline.cues.length>0){const p=Math.max(0,c.ctx.currentTime-c.startedAtCtxTime),g=N3(c.timeline,p);f=(g==null?void 0:g.viseme)??"closed",h=(g==null?void 0:g.level)??0}else if(c.analyser){const p=c.analyser;p.getByteTimeDomainData(r),p.getByteFrequencyData(s);const g=N1(r,s,p.context.sampleRate,p.fftSize);f=g.viseme,f!==a.split(":")[0]?(f==="closed"||f===o?f===o&&l++:(o=f,l=1),f!=="closed"&&!(f===o&&l>=2)&&(f=a.split(":")[0]||"closed")):(o=null,l=0),h=g.level}else f="closed",h=0;const d=R1(f,h),m=f+":"+d;m!==a&&(a=m,n({viseme:f,open:d}))}i=requestAnimationFrame(u)};return i=requestAnimationFrame(u),()=>cancelAnimationFrame(i)},[e]),t}const N_=22,R_=35e-5,Gd=.012,Kd=.12,Xd=.3,L_=16.667,oo=12,P_=3.2,Qd=56,hr=.6;function M_(e,t,n,r,s=0,i=0){let a=0,o=0;for(const u of r){const c=e-u.x,f=t-u.y,h=Math.hypot(c,f),d=u.r+n,m=d+Qd;if(h>=m)continue;if(h<1e-4){o-=hr;continue}const p=c/h,g=f/h,y=Math.min(1.6,Math.max(0,1-(h-d)/Qd)),T=s*p+i*g,v=T<0?1+Math.min(1.6,-T/4):1;a+=p*hr*y*v,o+=g*hr*y*v}const l=Math.hypot(a,o);return l>hr*2&&(a=a/l*hr*2,o=o/l*hr*2),{x:a,y:o}}function D_(e,t,n,r=34){const s=n*.001;return{x:e.x+Math.sin(s*.31+t*2.1)*r,y:e.y+Math.sin(s*.47+t*4.7)*(r*.55)+Math.sin(s*1.7+t)*4}}function O_(e,t,n,r,s=L_){const i=Math.max(64,s*s),a=Qo((n.x-e.x)*Gd-t.x*Kd,Xd),o=Qo((n.y-e.y)*Gd-t.y*Kd,Xd);return{fx:a*r/i,fy:o*r/i-r*.001}}function Qo(e,t){return e>t?t:e<-t?-t:e}function F_(e,t,n,r,s,i,a,o,l,u){const c=e-i,f=t-a,h=Math.hypot(c,f),d=s+u;if(h>=d||h<1e-4)return null;const m=c/h,p=f/h,g=n-o,y=r-l,T=g*m+y*p,v=d-h,C=T<0?-T*.9:0;return{nx:m,ny:p,dvx:m*(v*.55+C*.85),dvy:p*(v*.55+C*.85),bfx:-m*C*.02,bfy:-p*C*.02,hitSpeed:-T}}function B_(e,t){return Math.hypot(e,t)<.35?0:Qo(e*.06,.5)}function j_(e,t,n,r=0){const s=[.14,.32,.5,.68,.86],i=[.38,.5,.62],a=(r%15+15)%15;let o={x:e*.5,y:t*.5},l=-1/0;for(let u=0;u<15;u++){const c=(a+u)%15,f=e*s[c%5],h=t*i[Math.floor(c/5)];let d=Math.min(f,e-f);for(const m of n){const p=Math.hypot(f-m.x,h-m.y)-m.r;p<d&&(d=p)}d>l+1e-9&&(l=d,o={x:f,y:h})}return o}function H_(e,t,n=220){let r=null,s=n;for(const i of t){const a=Math.hypot(i.x-e.x,i.y-e.y);a<s&&(s=a,r={x:i.x,y:i.y})}return r}function U_(e){const t=e.radius??N_,{Bodies:n,Body:r,Composite:s,Engine:i}=pn,a=i.create();a.gravity.y=1,a.positionIterations=4,a.velocityIterations=3;const o=n.circle(e.width*.7,120,t,{restitution:.55,friction:.02,frictionAir:.028,density:R_});s.add(a.world,o);const l=240;let u=[];const c=(d,m)=>{for(const g of u)s.remove(a.world,g);const p=(g,y,T,v)=>n.rectangle(g,y,T,v,{isStatic:!0,restitution:.5});u=[p(-l/2,m/2-160,l,m+640),p(d+l/2,m/2-160,l,m+640),p(d/2,m+l/2,d+l*2,l),p(d/2,-320-l/2,d+l*2,l)];for(const g of u)s.add(a.world,g)};c(e.width,e.height);let f=0,h=e.width;return{body:o,resize(d,m){h=d,c(d,m)},step(d,m,p,g,y){const T=g<f;i.update(a,Math.min(33,Math.max(8,d)));let v=!1;if(!T&&m){const j=y!=null&&y.settle?{x:m.x,y:m.y+Math.sin(g*.0012)*2}:D_(m,Math.floor(g/4200),g),M=Math.max(64,d*d),L=O_({x:o.position.x,y:o.position.y},{x:o.velocity.x,y:o.velocity.y},j,o.mass,d),B=M_(o.position.x,o.position.y,t,p,o.velocity.x,o.velocity.y);r.applyForce(o,o.position,{x:L.fx+B.x*o.mass/M,y:L.fy+B.y*o.mass/M}),r.setAngularVelocity(o,o.angularVelocity-o.angle*.06-o.angularVelocity*.08)}{const j=o.velocity,M=Math.hypot(j.x,j.y);M>oo&&r.setVelocity(o,{x:j.x/M*oo,y:j.y/M*oo})}let C=0,E=0,w=0,_=0,S=0;for(const j of p){const M=F_(o.position.x,o.position.y,o.velocity.x,o.velocity.y,t,j.x,j.y,j.vx,j.vy,j.r);M&&(E+=M.nx*Math.min(4,M.dvx),w+=M.ny*Math.min(4,M.dvy),_+=M.dvx*.9,S+=M.dvy*.9,j.isStatic||j.push(M.bfx,M.bfy),M.hitSpeed>C&&(C=M.hitSpeed))}const I=Math.hypot(E,w);I>4&&(E=E/I*4,w=w/I*4);const A=Math.hypot(_,S);A>7&&(_=_/A*7,S=S/A*7),(I>0||A>0)&&(r.setPosition(o,{x:o.position.x+E,y:o.position.y+w}),r.setVelocity(o,{x:o.velocity.x+_,y:o.velocity.y+S})),C>=P_&&!T&&(f=g+900,v=!0);const P=o.position;P.x<t&&(r.setPosition(o,{x:t,y:P.y}),o.velocity.x<0&&r.setVelocity(o,{x:-o.velocity.x*.5,y:o.velocity.y})),P.x>h-t&&(r.setPosition(o,{x:h-t,y:P.y}),o.velocity.x>0&&r.setVelocity(o,{x:-o.velocity.x*.5,y:o.velocity.y}));const N=y==null?void 0:y.ceilY;return N!==void 0&&P.y<N+t&&(r.setPosition(o,{x:P.x,y:N+t}),o.velocity.y<0&&r.setVelocity(o,{x:o.velocity.x,y:-o.velocity.y*.5})),v},dizzyRemaining(d){return Math.max(0,f-d)},throwDizzy(d){f=d+900},dispose(){s.clear(a.world,!1),i.clear(a)}}}const Ot={rail:76,chat:96,notebook:120,titlebar:44};function Jd(){const t=document.querySelector('[data-testid="composer-card"]')??document.querySelector('[data-testid="composer"]')??document.querySelector('[data-testid="composer-nokey"]');if(!t)return null;const n=t.getBoundingClientRect();return{x:n.right-78,y:n.top-44}}function z_(){const e=document.querySelector('[data-testid="notebook-panel"]');if(!e)return null;const t=e.getBoundingClientRect();return{x:t.right-64,y:t.top+84}}function V_({courseId:e}){const t=k.useSyncExternalStore(L1,Vi),n=I_(t.state.talking),r=Cl(),[s,i]=k.useState(!1),[a,o]=k.useState(null),[l,u]=k.useState("rail"),c=k.useRef("rail"),f=k.useRef(null),[h,d]=k.useState(!1),m=k.useRef(!1),p=k.useRef(null),g=k.useRef(null),y=k.useRef(null),T=k.useRef(null),v=k.useRef(t.state.zone),C=k.useRef(!1),E=k.useRef(null),w=k.useRef(!1),_=k.useRef(0),S=k.useRef(null),[I,A]=k.useState(null),P=k.useRef(0),N=k.useRef(null),j=k.useRef(null),M=k.useRef(null),L=k.useRef(0),B=k.useRef(null),V=k.useRef(0),F=k.useRef({pane:"rail",bucket:-1}),q=k.useRef(null),R=k.useRef(null);k.useEffect(()=>{var le,z,ee;if(l===v.current||(v.current=l,r))return;i(!0),(z=(le=p.current)==null?void 0:le.animate)==null||z.call(le,[{transform:"scale(1, 1)"},{transform:"scale(1.08, 0.86)",offset:.3},{transform:"scale(0.96, 1.1)",offset:.65},{transform:"scale(1, 1)"}],{duration:620,easing:"cubic-bezier(0.2, 1.4, 0.4, 1)",composite:"add"}),(ee=p.current)==null||ee.classList.add("cp-takeoff"),setTimeout(()=>{var K;return(K=p.current)==null?void 0:K.classList.remove("cp-takeoff")},650);const Z=[setTimeout(()=>i(!1),950),setTimeout(()=>{var ce;const K=p.current;!K||l==="rail"||(P1(),(ce=K.animate)==null||ce.call(K,[{transform:"scale(1, 1)"},{transform:"scale(1.07, 0.88)",offset:.42},{transform:"scale(0.98, 1.03)",offset:.72},{transform:"scale(1, 1)"}],{duration:280,easing:"ease-out",composite:"add"}))},940)];return()=>{for(const K of Z)clearTimeout(K)}},[l,r]),k.useEffect(()=>{if(!e)return;let Z=!0;return window.api.getDashboard(e).then(le=>{var ce,fe;if(!Z)return;const z=(ce=le==null?void 0:le.frictionByNode)==null?void 0:ce[0];if(!(z!=null&&z.nodeId))return;R.current=z.nodeId;const ee=qi(),K=(fe=ee.nav)==null?void 0:fe.getBoundingClientRect();if(K)for(const{island:re,container:ne}of ee.sections.values()){const ge=re.ball(z.nodeId);if(!ge)continue;const Te=ne.getBoundingClientRect(),Ne=Te.left-K.left+ge.body.position.x,Oe=Te.top-K.top+ge.body.position.y;M.current={x:Ne,y:Math.max(40,Oe-92)},L.current=performance.now()+8e3,setTimeout(()=>{Z&&Qu()},1200);return}}).catch(()=>{}),()=>{Z=!1}},[e]),k.useEffect(()=>{const Z=le=>{const z=le.detail,ee=R.current;z!=="mastery"||!ee||!e||window.api.getDashboard(e).then(K=>{var fe;((fe=K==null?void 0:K.frictionByNode)==null?void 0:fe.some(re=>re.nodeId===ee))||(R.current=null,L.current=0,O1())}).catch(()=>{})};return window.addEventListener("companion-state-changed",Z),()=>window.removeEventListener("companion-state-changed",Z)},[e]),k.useEffect(()=>Ao(Z=>{if(Z.kind!=="correct"&&Z.kind!=="unlock"||!Z.origin||Vi().state.examActive)return;const le=document.elementFromPoint(Z.origin.x,Z.origin.y);if(!le)return;const z=le.closest('[data-testid="map-rail"]');j.current={x:Z.origin.x,y:Z.origin.y,until:performance.now()+3e3,pane:z?"rail":"chat"}}),[]),k.useEffect(()=>{const Z=z=>{const ee=B.current;if(!ee)return;const K=performance.now(),ce=Math.max(8,K-ee.t);B.current={x:z.clientX,y:z.clientY,vx:(z.clientX-ee.x)/ce*16.7,vy:(z.clientY-ee.y)/ce*16.7,t:K}},le=()=>{var ne,ge,Te,Ne;const z=B.current;if(!z)return;B.current=null;const ee=Math.hypot(z.vx,z.vy),K=g.current;if(K){const Oe=(ne=qi().nav)==null?void 0:ne.getBoundingClientRect();Oe&&pn.Body.setPosition(K.body,{x:Math.min(Oe.width-24,Math.max(24,z.x-Oe.left)),y:Math.min(Oe.height-24,Math.max(24,z.y-Oe.top))}),ee>=2.5&&(pn.Body.setVelocity(K.body,{x:z.vx*.9,y:z.vy*.9}),K.throwDizzy(performance.now()))}const ce=qi(),fe=((ge=ce.nav)==null?void 0:ge.getBoundingClientRect())??null;if(!(!!fe&&fe.width>40&&(ce.visible||Vi().state.importing))){const Oe=((Te=document.querySelector("header.app-header"))==null?void 0:Te.getBoundingClientRect())??null;if(!!Oe&&z.y>=Oe.top&&z.y<=Oe.bottom)E.current=null;else{const Fe=((Ne=document.querySelector('[data-testid="notebook-panel"]'))==null?void 0:Ne.getBoundingClientRect())??null,te=Fe&&z.x>=Fe.left&&z.x<=Fe.right&&z.y>=Fe.top&&z.y<=Fe.bottom?"notebook":"chat",Re=((Oe==null?void 0:Oe.bottom)??0)+80;E.current={x:Math.min(Math.max(z.x,60),window.innerWidth-60),y:Math.min(Math.max(z.y,Re),window.innerHeight-60),pane:te}}}Ju(!1,ee)};return window.addEventListener("pointermove",Z,{passive:!0}),window.addEventListener("pointerup",le,{passive:!0}),window.addEventListener("pointercancel",le,{passive:!0}),()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",le),window.removeEventListener("pointercancel",le)}},[]),k.useEffect(()=>{if(!t.enabledLoaded||!t.enabled||t.petMode)return;const Z=p.current;if(!Z)return;let le=0,z=performance.now(),ee=0,K=0,ce=0,fe=-1e9,re=null,ne=0,ge=0,Te=null,Ne=[];const Oe=be=>{var Fr,or,Xe,Pn,Ge,Ui,zi;le=requestAnimationFrame(Oe);const Fe=Math.min(50,be-z);z=be;const te=qi(),Re=te.nav,me=(Re==null?void 0:Re.getBoundingClientRect())??null,je=Vi().state,st=!!B.current,Be=!!me&&me.width>40&&(te.visible||je.importing);if(Be&&!w.current&&(E.current=null),w.current=Be,be-fe>150){fe=be,re=((Fr=document.querySelector('[data-testid="notebook-panel"]'))==null?void 0:Fr.getBoundingClientRect())??null;const ke=((or=document.querySelector("header.app-header"))==null?void 0:or.getBoundingClientRect())??null;Te=ke?{left:ke.left,right:ke.right,top:ke.top,bottom:ke.bottom}:null,ne=(ke==null?void 0:ke.bottom)??0,Ne=ke?Array.from(document.querySelectorAll('header.app-header button, header.app-header [role="button"], header.app-header a, header.app-header input, header.app-header select')).map(We=>{const Qe=We.getBoundingClientRect();return{left:Qe.left,right:Qe.right,top:Qe.top,bottom:Qe.bottom}}):[],ge=((Xe=document.querySelector('[data-testid="map-rail-topbar"]'))==null?void 0:Xe.getBoundingClientRect().bottom)??0}const at=re,G=()=>Math.max(ne,ge)-((me==null?void 0:me.top)??0),se=Math.floor(be/z1);if(F.current.bucket!==se&&(F.current={pane:F1(F.current.pane),bucket:se},Be&&je.zone==="roam")){const ke=document.querySelector('[data-testid="map-review-badge"]'),We=!!ke&&ke.className.includes("bg-review/20");let Qe=null;for(const{island:_e,container:Me}of te.sections.values()){const De=_e.balls.find(it=>!it.body.isStatic);if(De){const it=Me.getBoundingClientRect();Qe={x:it.left+De.body.position.x,y:it.top+De.body.position.y};break}}const ut=L.current>be?M.current:null,Ce=V1(se,{hasReview:We,hasNext:!!Qe,hasFriction:!!ut});if(Ce==="review"&&ke){const _e=ke.getBoundingClientRect();q.current={kind:Ce,until:be+va,pos:{x:_e.right+44,y:_e.bottom+64},fired:!1},F.current.pane="rail"}else Ce==="inspect"&&Qe?(q.current={kind:Ce,until:be+va,pos:{x:Qe.x+34,y:Qe.y-66},fired:!1},F.current.pane="rail"):Ce==="friction"&&ut&&(q.current={kind:Ce,until:be+va,pos:{x:ut.x,y:ut.y},fired:!1},F.current.pane="rail")}const xe=q.current&&be<q.current.until?q.current:null;q.current&&!xe&&(q.current=null);const Ee=q1();if(Ee&&Ee.seq!==_.current&&!je.examActive){_.current=Ee.seq;let ke=Ee.x,We=Ee.y;if((ke==null||We==null)&&Be)for(const{island:Qe,container:ut}of te.sections.values()){const Ce=Qe.ball(Ee.nodeId);if(Ce){const _e=ut.getBoundingClientRect();ke=_e.left+Ce.body.position.x,We=_e.top+Ce.body.position.y;break}}Be&&ke!=null&&We!=null?(S.current={nodeId:Ee.nodeId,x:ke,y:We,until:be+2400,fired:!1,fly:!0},A({until:be+2400})):(S.current={nodeId:Ee.nodeId,x:0,y:0,until:be+1600,fired:!0,fly:!1},A({until:be+1600}))}const Pe=!!S.current&&be<S.current.until;if(S.current&&!Pe&&(S.current=null,A(null)),Pe&&S.current&&!S.current.fired){const ke=S.current;if(ke.fired=!0,ke.fly&&me)for(const{island:We}of te.sections.values()){const Qe=We.ball(ke.nodeId);if(Qe&&!Qe.body.isStatic){pn.Body.applyForce(Qe.body,Qe.body.position,{x:.0035,y:-.005});break}}}const lt=W1();if(lt&&lt.seq!==P.current&&!je.examActive&&(P.current=lt.seq,Be&&me)){const ke=G();N.current={x:Math.min(me.width-44,Math.max(44,lt.x-me.left)),y:Math.min(me.height-44,Math.max(ke+52,lt.y-me.top)),until:be+3200}}const ve=!!N.current&&be<N.current.until;N.current&&!ve&&(N.current=null);const Le=!!j.current&&be<j.current.until;j.current&&!Le&&(j.current=null);const ze=a3(),Ye=ze?ze.startContainer.parentElement??null:null;let ye=null,qe=F.current.pane;const St=je.examActive?(Pn=document.querySelector('[data-testid="exam-timer"]'))==null?void 0:Pn.getBoundingClientRect():void 0;if(St){g.current=null,B.current=null,qe="chat";const ke={x:Math.min(St.right+64,window.innerWidth-70),y:Math.min(St.bottom+56,window.innerHeight-90)},We=y.current??ke;ye=Kt(We,ke,Fe,Dn),ce=Math.max(-.15,Math.min(.15,(ye.x-We.x)*.008))}else if(st){const ke=B.current;g.current=null,ye={x:ke.x,y:ke.y},ce=Math.max(-.5,Math.min(.5,ke.vx*.04)),qe=c.current}else if(Ye&&ze){const ke=Ye.closest('[data-testid="notebook-panel"], [data-testid="chat-stream"]'),We=ke==null?void 0:ke.getBoundingClientRect(),Qe=o3()??ze,ut=Qe.getClientRects(),Ce=[];for(let Je=0;Je<ut.length;Je++){const $e=ut[Je];$e.width>1&&$e.height>1&&Ce.push({left:$e.left,right:$e.right,top:$e.top,bottom:$e.bottom})}const _e=Ce.length?Ce[Ce.length-1]:null,Me=Ce.length?Ce[0]:null,De=Qe.getBoundingClientRect(),it=!!(ke!=null&&ke.closest('[data-testid="chat-stream"]')),It=it?Ot.chat:Ot.notebook;if(qe=it?"chat":"notebook",We&&(_e||De.width>0)){const Je=Zu({left:De.left,right:De.right,top:De.top,bottom:De.bottom},We,It,{first:Me??void 0,last:_e??void 0},Ce),$e={dir:Je.dir,pane:qe};if((((Ge=f.current)==null?void 0:Ge.dir)!==$e.dir||((Ui=f.current)==null?void 0:Ui.pane)!==$e.pane)&&(f.current=$e,o($e)),m.current!==Je.occluding&&(m.current=Je.occluding,d(Je.occluding)),r)ye=Je,ce=0;else{const bt=y.current??{x:Je.x,y:Je.y};ye=Kt(bt,Je,Fe,$1,110),ce=Je.dir==="left"?-.07:Je.dir==="right"?.07:0}}else{f.current!==null&&(f.current=null,o(null)),m.current&&(m.current=!1,d(!1));const Je=We?{x:We.right-70,y:Math.max(We.top+96,ne+It*.8)}:Y1(window.innerHeight,It,ne),$e=y.current??{x:Je.x,y:Je.y};ye=Kt($e,Je,Fe,Dn),ce=Math.max(-.25,Math.min(.25,(ye.x-$e.x)*.01))}}else{f.current!==null&&(f.current=null,o(null)),m.current&&(m.current=!1,d(!1));const ke=je.pose==="writing"?u3():null,We=je.zone,Qe=ke?ke.closest('[data-testid="notebook-panel"], [data-testid="chat-stream"]'):null,ut=ke==null?void 0:ke.getBoundingClientRect(),Ce=!!(Qe&&ut&&ut.width>0);if(ke&&Ce){const _e=Qe,Me=_e.getBoundingClientRect(),De=ut,it=!!_e.closest('[data-testid="chat-stream"]');qe=it?"chat":"notebook";{const It=ke.closest("p, li, h1, h2, h3, h4, h5, h6, blockquote, pre, td, th"),Je=[];if(It){const bt=document.createRange();bt.selectNodeContents(It);const dn=bt.getClientRects();for(let tn=0;tn<dn.length;tn++){const Gt=dn[tn];Gt.width>1&&Gt.height>1&&Je.push({left:Gt.left,right:Gt.right,top:Gt.top,bottom:Gt.bottom})}}const $e=Zu(De,Me,it?Ot.chat:Ot.notebook,{first:De,last:De},Je.length?Je:void 0);if(g.current=null,r)ye=$e,ce=0;else{const bt=y.current??{x:$e.x,y:$e.y};ye=Kt(bt,$e,Fe,Dn),ce=.08}}}else if(Le&&j.current&&j.current.pane!=="rail"){g.current=null;const _e=j.current;qe=_e.pane==="notebook"?"notebook":"chat";const Me=qe==="notebook"?Ot.notebook:Ot.chat,De=B1({x:_e.x,y:_e.y},Me,window.innerWidth,Math.max(ne,ge));if(r)ye=De,ce=0;else{const it=y.current??{x:De.x,y:De.y};ye=Kt(it,De,Fe,Dn),ce=Math.max(-.2,Math.min(.2,(ye.x-it.x)*.01))}}else if(We==="chat"&&Jd()){g.current=null,qe="chat";const _e=Jd();if(r)ye=_e,ce=0;else{const Me=tc("chat",be),De=y.current??{x:_e.x,y:_e.y};ye=Kt(De,{x:_e.x+Me.x,y:_e.y+Me.y},Fe,Dn),ce=Math.max(-.35,Math.min(.35,(ye.x-De.x)*.014))}}else if(We==="notebook"&&at){g.current=null,qe="notebook";const _e=z_()??{x:at.right-70,y:at.top+96};if(r)ye=_e,ce=0;else{const Me=tc("notebook",be),De=y.current??{x:_e.x,y:_e.y};ye=Kt(De,{x:_e.x+Me.x,y:_e.y+Me.y},Fe,Dn),ce=Math.max(-.3,Math.min(.3,(ye.x-De.x)*.012))}}else if(Be&&(Pe||ve||We==="rail"||We==="roam")){const _e=me.width,Me=me.height;if(qe="rail",r)ye={x:me.left+_e*.5,y:me.top+Me*.5},ce=0;else{if((_e!==ee||Me!==K)&&(ee=_e,K=Me,(zi=g.current)==null||zi.resize(_e,Me),M.current=null),!g.current){g.current=U_({width:_e,height:Me});const yt=y.current;yt&&pn.Body.setPosition(g.current.body,{x:Math.min(_e-30,Math.max(30,yt.x-me.left)),y:Math.min(Me-30,Math.max(30,yt.y-me.top))})}const De=g.current,it=[],It=[];for(const{island:yt,container:Br}of te.sections.values()){const lr=Br.getBoundingClientRect();if(lr.bottom<me.top-120||lr.top>me.bottom+120)continue;const jr=lr.left-me.left,Mn=lr.top-me.top;for(const Nt of yt.balls)it.push({x:jr+Nt.body.position.x,y:Mn+Nt.body.position.y,vx:Nt.body.velocity.x,vy:Nt.body.velocity.y,r:zt,isStatic:Nt.body.isStatic,push:(fn,pa)=>pn.Body.applyForce(Nt.body,Nt.body.position,{x:fn,y:pa})}),It.push({x:jr+Nt.body.position.x,y:Mn+Nt.body.position.y-zt-20});for(const Nt of yt.links)for(const fn of Nt.particles)It.push({x:jr+fn.position.x,y:Mn+fn.position.y-8})}const Je=We==="roam";let $e=M.current,bt=!1;if(ve&&N.current)$e={x:N.current.x+28,y:N.current.y-52},bt=!1;else if(Pe&&S.current&&S.current.fly)$e={x:S.current.x-me.left+34,y:S.current.y-me.top-46},bt=!1;else if(Le&&j.current&&j.current.pane==="rail")$e={x:j.current.x-me.left+34,y:j.current.y-me.top-46},bt=!1;else if(xe)$e={x:xe.pos.x-me.left,y:xe.pos.y-me.top},xe.fired||(xe.fired=!0,Qu());else if(Je){const yt=ec(me,Ot.rail,be);$e={x:yt.x-me.left,y:yt.y-me.top}}else{if(je.mode==="veil"){const yt=H_({x:De.body.position.x,y:De.body.position.y},It,220);yt&&($e=yt,bt=!0)}(!$e||be>L.current)&&(M.current=j_(_e,Me,it,Math.floor(be/1e3)),L.current=be+3e3,$e=M.current)}const dn=De.step(Fe,$e,je.mode==="veil"&&!Je?[]:it,be,{settle:bt,ceilY:G()});if(dn&&!C.current&&j1(),C.current=dn||De.dizzyRemaining(be)>0,De.dizzyRemaining(be)===0){const yt=Yh(te.weather);if(yt.wind>=.3){const Br=De.body.mass;pn.Body.applyForce(De.body,De.body.position,{x:$h(De.body.position.x,De.body.position.y,be)*yt.wind*Wh*Br*2.2,y:0})}(te.weather==="rain"||te.weather==="storm")&&je.mode!=="veil"&&be>V.current&&(V.current=be+6e3+Math.random()*4e3,Z.classList.add("cp-shiver"),setTimeout(()=>Z.classList.remove("cp-shiver"),460))}const tn=De.body.position,Gt={x:me.left+tn.x,y:me.top+tn.y},ma=y.current??Gt;ye=Kt(ma,Gt,Fe,Dn),ce=De.body.angle+B_(De.body.velocity.x,De.body.velocity.y)}}else if(g.current=null,Be&&me){qe="rail";const _e=ec(me,Ot.rail,be),Me=y.current??{x:_e.x,y:_e.y};ye=Kt(Me,_e,Fe,G1,140),ce=Math.max(-.25,Math.min(.25,(ye.x-Me.x)*.01))}else if(E.current)if(qe=E.current.pane,r)ye={x:E.current.x,y:E.current.y},ce=0;else{const _e=H1(E.current,be),Me=y.current??_e;ye=Kt(Me,_e,Fe,nc),ce=Math.max(-.2,Math.min(.2,(ye.x-Me.x)*.01))}else if(Te)if(qe="titlebar",r)ye={x:(Te.left+Te.right)/2,y:(Te.top+Te.bottom)/2},ce=0;else{const _e=U1(Te,Ot.titlebar,be),Me=y.current??_e;ye=Kt(Me,_e,Fe,nc),ce=0}}if(qe==="titlebar"&&ye){const ke=Ot.titlebar/2,We=ye.x-ke,Qe=ye.x+ke,ut=ye.y-ke,Ce=ye.y+ke,_e=Ne.some(Me=>We<Me.right&&Qe>Me.left&&ut<Me.bottom&&Ce>Me.top);Z.classList.toggle("cp-titlebar-dim",_e)}else Z.classList.contains("cp-titlebar-dim")&&Z.classList.remove("cp-titlebar-dim");if(c.current!==qe&&(c.current=qe,u(qe)),!ye){Z.style.opacity="0",y.current=null,T.current=null;return}y.current=ye;const sr=Z.offsetWidth||Ot[qe],jt=qe==="rail"?Math.max(ne,ge):ne;qe!=="titlebar"&&ye.y<jt+sr/2+10&&(ye.y=jt+sr/2+10),Z.style.transform=`translate3d(${(ye.x-sr/2).toFixed(1)}px, ${(ye.y-sr/2).toFixed(1)}px, 0) rotate(${(ce*57.2958).toFixed(1)}deg)`;const ar=T.current;if(ar){const ke=ye.x-ar.x,We=ye.y-ar.y,ut=Math.hypot(ke,We)/Math.max(1,Fe);if(Z.style.setProperty("--cp-speed",Math.min(1,ut/.45).toFixed(3)),ut>.02){const Ce=(Math.atan2(We,ke)*57.2958+90+360)%360;Z.style.setProperty("--cp-thrust-deg",Ce.toFixed(1)+"deg")}}T.current={x:ye.x,y:ye.y}};return le=requestAnimationFrame(Oe),()=>{var be;cancelAnimationFrame(le),(be=g.current)==null||be.dispose(),g.current=null}},[t.enabledLoaded,t.enabled,t.petMode,r]);const $=k.useRef(0);if(k.useEffect(()=>{const Z=p.current;if(!Z||t.state.keySeq===$.current||t.state.examActive)return;$.current=t.state.keySeq,Z.classList.remove("cp-keypress"),Z.offsetWidth,Z.classList.add("cp-keypress");const le=setTimeout(()=>Z.classList.remove("cp-keypress"),160);return()=>clearTimeout(le)},[t.state.keySeq]),!t.enabledLoaded||!t.enabled||t.petMode)return null;const X=s?"flying":t.state.typing?"typing":I||(a==null?void 0:a.dir)==="left"?"point":(a==null?void 0:a.dir)==="right"?"pointr":(a==null?void 0:a.dir)==="up"?"pointu":(a==null?void 0:a.dir)==="down"?"pointd":t.state.pose,D=a?Ot[a.pane]:Ot[l];return x.jsx("div",{ref:p,className:`cp-creature fixed left-0 top-0 z-40 will-change-transform ${t.state.mode==="veil"?"cp-veil":""} ${h?"cp-occluding":""} ${t.state.grabbed?"cp-grabbed":""}`,"data-testid":"companion-creature","data-zone":t.state.zone==="roam"?l:t.state.zone,"data-mode":t.state.mode,children:x.jsx(M1,{form:t.form,expression:t.state.expression,screenKey:t.state.typing?t.state.lastKey??(t.state.lastKeyKind==="enter"?"→":t.state.lastKeyKind==="back"?"⌫":null):null,keyFlash:t.state.typing&&t.state.lastKey==null&&(t.state.lastKeyKind==="enter"||t.state.lastKeyKind==="back"),coreLit:t.state.correctStreak>=3,noteTick:Date.now()<t.state.noteTickUntil,pose:X,viseme:n.viseme,openScale:n.open,energyRatio:t.energyRatio,streakLit:t.streakLit,size:D,interactive:!0,ariaLabel:"companion",onPoke:D1,onGrab:(Z,le)=>{B.current||(B.current={x:Z,y:le,vx:0,vy:0,t:performance.now()},Ju(!0))},haloBadge:t.halo,testid:"companion-mascot",keySeq:t.state.keySeq,keySide:t.state.keySide})})}function q_(e,t){if(t.type==="text"){const n=e[e.length-1];return n&&n.type==="text"?[...e.slice(0,-1),{type:"text",text:n.text+t.text}]:[...e,{type:"text",text:t.text}]}if(t.type==="reasoning"){const n=e[e.length-1];return n&&n.type==="reasoning"?[...e.slice(0,-1),{type:"reasoning",text:n.text+t.text}]:[...e,{type:"reasoning",text:t.text}]}if(t.type==="tool-start")return[...e,{type:"tool-call",toolName:t.toolName,state:"input-available"}];if(t.type==="tool-result"){let n=-1;for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.type==="tool-call"&&s.toolName===t.toolName&&s.state==="input-available"){n=r;break}}return n<0?e:e.map((r,s)=>s===n?{...r,state:"output-available",output:t.output}:r)}if(t.type==="tool-error"){let n=-1;for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.type==="tool-call"&&s.toolName===t.toolName&&s.state==="input-available"){n=r;break}}return n<0?e:e.map((r,s)=>s===n?{...r,state:"output-error",error:t.error}:r)}return e}function Jo(e){return{messages:[],streaming:!1,streamingMsgId:null,loaded:!1,focusNodeId:null,touched:e}}function au(e,t,n){if(e.has(t))return e;const r=new Map(e);return r.set(t,Jo(n)),r}function Zd(e,t,n){const r=e.get(t);if(!r||r.touched===n)return e;const s=new Map(e);return s.set(t,{...r,touched:n}),s}function W_(e,t,n,r,s,i){const a=au(e,t,s),o=a.get(t);let l=o.streamingMsgId,u=o.messages;if(!(l&&u.some(h=>h.id===l))){const h=u[u.length-1];o.streaming&&h&&h.role==="assistant"?l=h.id:(l=r(),u=[...u,{id:l,role:"assistant",parts:[]}])}const f=new Map(a);return f.set(t,{...o,messages:u.map(h=>h.id===l?{...h,parts:q_(h.parts,n)}:h),streamingMsgId:l,focusNodeId:i??o.focusNodeId,touched:s}),f}function $_(e,t,n,r){const s=e.get(t);if(!s)return e;let i=-1,a=-1;for(let u=s.messages.length-1;u>=0&&(s.messages[u].role==="user"&&i===-1&&(i=u),s.messages[u].role==="assistant"&&a===-1&&(a=u),!(i!==-1&&a!==-1));u--);const o=s.messages.map((u,c)=>c===i&&(n!=null&&n.userMessageId)?{...u,id:n.userMessageId}:c===a&&(n!=null&&n.assistantMessageId)?{...u,id:n.assistantMessageId}:u),l=new Map(e);return l.set(t,{...s,messages:o,streaming:!1,streamingMsgId:null,touched:r}),l}function T0(e,t,n,r,s){const i=au(e,t,s),a=i.get(t),o=new Map(i);return o.set(t,{...a,messages:[...a.messages,{id:r(),role:"assistant",parts:[{type:"text",text:`⚠️ ${n}`}]}],streaming:!1,streamingMsgId:null,touched:s}),o}function Y_(e,t,n,r){const s=au(e,t,r),i=s.get(t);if(i.streaming)return{buckets:e,accepted:!1};const a=new Map(s);return a.set(t,{...i,messages:[...i.messages,n],streaming:!0,streamingMsgId:null,touched:r}),{buckets:a,accepted:!0}}function G_(e,t,n,r,s){return T0(e,t,n,r,s)}function ef(e,t){if(e.size<=t)return e;const n=Array.from(e.entries()).filter(([,a])=>!a.streaming),r=e.size-n.length,s=Math.max(0,t-r);if(n.length<=s)return e;n.sort((a,o)=>a[1].touched-o[1].touched);const i=new Map(e);for(let a=0;a<n.length-s;a++)i.delete(n[a][0]);return i}let K_=0;const ns=()=>`msg-v2-${++K_}`,tf=8;function X_(e){if(!e)return null;try{const t=JSON.parse(e);return!Array.isArray(t)||t.length===0?null:t.every(r=>typeof r=="object"&&r!==null&&typeof r.type=="string")?t:null}catch{return null}}function Q_(e,t){const[n,r]=k.useState(()=>new Map),s=k.useRef(n);s.current=n;const i=k.useRef(e??"");i.current=e??"",k.useEffect(()=>{if(!e)return;let g=!1;return(async()=>{const y=s.current.get(e);if(y&&(y.loaded||y.messages.length>0)){r(T=>Zd(T,e,Date.now()));return}try{const T=await oe.threadGetMessages(e);if(g)return;r(v=>{const C=v.get(e);if(C&&(C.loaded||C.messages.length>0))return Zd(v,e,Date.now());const E=T.map(_=>{const S=X_(_.partsJson);return{id:_.id,role:_.role,parts:S??[{type:"text",text:_.content}],..._.displayText?{displayText:_.displayText}:{}}}),w=new Map(v);return w.set(e,{...C??Jo(Date.now()),messages:E,loaded:!0,touched:Date.now()}),ef(w,tf)})}catch{}})(),()=>{g=!0}},[e]),k.useEffect(()=>{const g=oe.on("chat:part",(v,C,E)=>{const w=C??i.current;r(_=>ef(W_(_,w,v,ns,Date.now(),E),tf))}),y=oe.on("chat:done",(v,C,E)=>{const w=E??i.current;r(_=>$_(_,w,C,Date.now()))}),T=oe.on("chat:error",(v,C)=>{const E=C??i.current;r(w=>T0(w,E,v,ns,Date.now()))});return()=>{g(),y(),T()}},[]);const a=k.useCallback(async(g,y,T,v)=>{var S;const C=y??e;if(!C||!g.trim()||(S=s.current.get(C))!=null&&S.streaming)return;const E=g.trim(),w={id:ns(),role:"user",parts:[...(v??[]).map(I=>({type:"attachment",attachment:{kind:I.kind,name:I.name,mime:I.mime,size:I.size,...I.previewUrl?{previewUrl:I.previewUrl}:{}}})),{type:"text",text:E}],...T?{displayText:T}:{}},_=Y_(s.current,C,w,Date.now());if(_.accepted){r(_.buckets);try{await oe.agentChatThread(C,E,T,t??null,v)}catch(I){const A=I instanceof Error?I.message:String(I);r(P=>G_(P,C,A,ns,Date.now()))}}},[e,t]),o=k.useCallback(async()=>{if(e){try{await oe.abortAgentChatThread(e)}catch{}r(g=>{const y=g.get(e);if(!(y!=null&&y.streaming))return g;const T=new Map(g);return T.set(e,{...y,streaming:!1,streamingMsgId:null,touched:Date.now()}),T})}},[e]),l=k.useCallback(()=>{e&&r(g=>{const y=g.get(e);if(!y)return g;const T=new Map(g);return T.set(e,{...y,messages:[],streamingMsgId:null,loaded:!0,touched:Date.now()}),T})},[e]);k.useEffect(()=>{const g=y=>{const T=y.detail;if(typeof T!="string")return;const C={explain_simple:{msg:"用大白话给我讲讲这一节的核心概念",labelKey:"command.explain_simple"},quiz_3:{msg:"出 3 道练习题考考我",labelKey:"command.quiz_3"},compare_prev:{msg:"把这一节和上一节做个对比表",labelKey:"command.compare_prev"},concept_map:{msg:"画个概念图帮我理清这一节的知识结构",labelKey:"command.concept_map"},socratic:{msg:"切换到苏格拉底模式,用提问引导我思考",labelKey:"command.socratic"},exam_mode:{msg:"切换到考试冲刺模式,出有难度的题",labelKey:"command.exam_mode"}}[T];C&&a(C.msg,void 0,Pl(C.labelKey))};return window.addEventListener("lookatstudy-command",g),()=>window.removeEventListener("lookatstudy-command",g)},[a]);const u=k.useCallback((g,y,T)=>{e&&r(v=>{const C=v.get(e);if(!C)return v;const E=new Map(v);return E.set(e,{...C,messages:C.messages.map(w=>{if(w.id!==g)return w;const _=[...w.parts],S=_[y];return S&&S.type==="tool-call"&&(_[y]={...S,output:{...typeof S.output=="object"&&S.output?S.output:{},status:T?"applied":"rejected"}}),{...w,parts:_}})}),E})},[e]),c=k.useCallback(g=>{e&&r(y=>{const T=y.get(e)??Jo(Date.now()),v=new Map(y);return v.set(e,{...T,messages:g,loaded:!0,touched:Date.now()}),v})},[e]),f=e?n.get(e):void 0,h=k.useMemo(()=>(f==null?void 0:f.messages)??[],[f]),d=(f==null?void 0:f.streaming)??!1,m=k.useMemo(()=>Array.from(n.entries()).filter(([,g])=>g.streaming).map(([g])=>g),[n]),p=k.useMemo(()=>Array.from(n.values()).filter(g=>g.streaming&&g.focusNodeId).map(g=>g.focusNodeId).filter((g,y,T)=>T.indexOf(g)===y),[n]);return{messages:h,streaming:d,streamingThreadIds:m,streamingNodeIds:p,send:a,stop:o,clear:l,markProposalStatus:u,setMessagesForNode:c}}const rs=(e,t=60)=>e.length>t?e.slice(0,t)+"…":e;function J_(e,t){return t("quiz.hook.label",{correct:e.correct,total:e.total})}function Z_(e,t){const n=e.detail.map((s,i)=>s.correct?t("quiz.hook.lineOk",{n:i+1,prompt:rs(s.prompt)}):t("quiz.hook.lineWrong",{n:i+1,prompt:rs(s.prompt),chosen:rs(s.chosen,30),answer:rs(s.answerText,30)})),r=e.title?`《${e.title}》`:"";return t("quiz.hook.message",{title:r,correct:e.correct,total:e.total})+(n.length?`
478
478
  `+n.join(`
@@ -484,4 +484,4 @@ ${f}`:f)},[f]),k.useEffect(()=>{if(!e){w(null);return}let te=!1;(async()=>{try{c
484
484
  ${E}px !important;
485
485
  ${w}px !important;
486
486
  }
487
- `),()=>{var I;(I=o.current)==null||I.removeAttribute("data-motion-pop-id"),S.contains(_)&&S.removeChild(_)}},[t]),x.jsx(iR,{isPresent:t,childRef:o,sizeRef:l,pop:i,children:i===!1?e:k.cloneElement(e,{ref:f})})}const aR=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:s,presenceAffectsLayout:i,mode:a,anchorX:o,anchorY:l,root:u})=>{const c=uu(oR),f=k.useId(),h=k.useRef(n),d=k.useRef(r);Ds(()=>{h.current=n,d.current=r});let m=!0,p=k.useMemo(()=>(m=!1,{id:f,initial:t,isPresent:n,custom:s,onExitComplete:g=>{c.set(g,!0);for(const y of c.values())if(!y)return;r&&r()},register:g=>(c.set(g,!1),()=>{var y;c.delete(g),!h.current&&!c.size&&((y=d.current)==null||y.call(d))})}),[n,c,r]);return i&&m&&(p={...p}),k.useMemo(()=>{c.forEach((g,y)=>c.set(y,!1))},[n]),k.useEffect(()=>{!n&&!c.size&&r&&r()},[n]),e=x.jsx(sR,{pop:a==="popLayout",isPresent:n,anchorX:o,anchorY:l,root:u,children:e}),x.jsx(la.Provider,{value:p,children:e})};function oR(){return new Map}function Jg(e=!0){const t=k.useContext(la);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:s}=t,i=k.useId();k.useEffect(()=>{if(e)return s(i)},[e]);const a=k.useCallback(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,a]:[!0]}const as=e=>e.key||"";function oh(e){const t=[];return k.Children.forEach(e,n=>{k.isValidElement(n)&&t.push(n)}),t}const lR=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:s=!0,mode:i="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:u})=>{const[c,f]=Jg(a),h=k.useMemo(()=>oh(e),[e]),d=a&&!c?[]:h.map(as),m=k.useRef(!0),p=k.useRef(h),g=uu(()=>new Map),y=k.useRef(new Set),[T,v]=k.useState(h),[C,E]=k.useState(h);Ds(()=>{a&&!c&&!C.length&&(f==null||f())},[c,a,C.length,f]),Ds(()=>{m.current=!1,p.current=h;for(let S=0;S<C.length;S++){const I=as(C[S]);d.includes(I)?(g.delete(I),y.current.delete(I)):g.get(I)!==!0&&g.set(I,!1)}},[C,d.length,d.join("-")]);const w=[];if(h!==T){let S=[...h],I=0;for(const A of C){const P=d.indexOf(as(A));P===-1?(S.splice(I++,0,A),w.push(A)):I=P+w.length+1}return i==="wait"&&w.length&&(S=w),E(oh(S)),v(h),null}const{forceRender:_}=k.useContext(lu);return x.jsx(x.Fragment,{children:C.map(S=>{const I=as(S),A=a&&!c?!1:h===C||d.includes(I),P=()=>{if(y.current.has(I))return;if(g.has(I))y.current.add(I),g.set(I,!0);else return;let N=!0;g.forEach(j=>{j||(N=!1)}),N&&(_==null||_(),E(p.current),a&&(f==null||f()),r&&r())};return x.jsx(aR,{isPresent:A,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:i,root:u,onExitComplete:A?void 0:P,anchorX:o,anchorY:l,children:S},I)})})},Zg=k.createContext({strict:!1}),lh={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let uh=!1;function uR(){if(uh)return;const e={};for(const t in lh)e[t]={isEnabled:n=>lh[t].some(r=>!!n[r])};_g(e),uh=!0}function e1(){return uR(),Y5()}function cR(e){const t=e1();for(const n in e)t[n]={...t[n],...e[n]};_g(t)}const ha=k.createContext({});function dR(e,t){if(fa(e)){const{initial:n,animate:r}=e;return{initial:n===!1||_i(n)?n:void 0,animate:_i(r)?r:void 0}}return e.inherit!==!1?t:{}}function fR(e){const{initial:t,animate:n}=dR(e,k.useContext(ha));return k.useMemo(()=>({initial:t,animate:n}),[ch(t),ch(n)])}function ch(e){return Array.isArray(e)?e.join(" "):e}const Du=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function t1(e,t,n){for(const r in t)!vt(t[r])&&!Dg(r,n)&&(e[r]=t[r])}function hR({transformTemplate:e},t){return k.useMemo(()=>{const n=Du();return Lu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function mR(e,t){const n=e.style||{},r={};return t1(r,n,e),Object.assign(r,hR(e,t)),r}function pR(e,t){const n={},r=mR(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const n1=()=>({...Du(),attrs:{}});function gR(e,t,n,r){const s=k.useMemo(()=>{const i=n1();return Fg(i,t,jg(r),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};t1(i,e.style,e),s.style={...i,...s.style}}return s}const xR=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function qs(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||xR.has(e)}function bR(e,t){return e.startsWith("on")?!qs(e):(t==null?void 0:t(e))??!qs(e)}function yR(e,t,n,r){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||vt(e[i])||(bR(i,r)||n===!0&&qs(i)||!t&&!qs(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const ER=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ou(e){return typeof e!="string"||e.includes("-")?!1:!!(ER.indexOf(e)>-1||/[A-Z]/u.test(e))}function vR(e,t,n,{latestValues:r},s,i=!1,a,o){const u=(a??Ou(e)?gR:pR)(t,r,s,e),c=yR(t,typeof e=="string",i,o),f=e!==k.Fragment?{...c,...u,ref:n}:{},{children:h}=t,d=k.useMemo(()=>vt(h)?h.get():h,[h]);return k.createElement(e,{...f,children:d})}function TR({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,s){return{latestValues:kR(n,r,s,e),renderState:t()}}function kR(e,t,n,r){const s={},i=r(e,{});for(const h in i)s[h]=Ts(i[h]);let{initial:a,animate:o}=e;const l=fa(e),u=Ag(e);t&&u&&!l&&e.inherit!==!1&&(a===void 0&&(a=t.initial),o===void 0&&(o=t.animate));let c=n?n.initial===!1:!1;c=c||a===!1;const f=c?o:a;if(f&&typeof f!="boolean"&&!da(f)){const h=Array.isArray(f)?f:[f];for(let d=0;d<h.length;d++){const m=wu(e,h[d]);if(m){const{transitionEnd:p,transition:g,...y}=m;for(const T in y){let v=y[T];if(Array.isArray(v)){const C=c?v.length-1:0;v=v[C]}v!==null&&(s[T]=v)}for(const T in p)s[T]=p[T]}}}return s}const r1=e=>(t,n)=>{const r=k.useContext(ha),s=k.useContext(la),i=()=>TR(e,t,r,s);return n?i():uu(i)},wR=r1({scrapeMotionValuesFromProps:Pu,createRenderState:Du}),SR=r1({scrapeMotionValuesFromProps:Hg,createRenderState:n1}),AR=Symbol.for("motionComponentSymbol");function CR(e,t,n){const r=k.useRef(n);k.useInsertionEffect(()=>{r.current=n});const s=k.useRef(null);return k.useCallback(i=>{var o;i&&((o=e.onMount)==null||o.call(e,i)),t&&(i?t.mount(i):t.unmount());const a=r.current;if(typeof a=="function")if(i){const l=a(i);typeof l=="function"&&(s.current=l)}else s.current?(s.current(),s.current=null):a(i);else a&&(a.current=i)},[t])}const i1=k.createContext({});function gr(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function _R(e,t,n,r,s,i){var v,C;const{visualElement:a}=k.useContext(ha),o=k.useContext(Zg),l=k.useContext(la),u=k.useContext(Mu),c=u.reducedMotion,f=u.skipAnimations,h=k.useRef(null),d=k.useRef(!1);r=r||o.renderer,!h.current&&r&&(h.current=r(e,{visualState:t,parent:a,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c,skipAnimations:f,isSVG:i}),d.current&&h.current&&(h.current.manuallyAnimateOnMount=!0));const m=h.current,p=k.useContext(i1);m&&!m.projection&&s&&(m.type==="html"||m.type==="svg")&&IR(h.current,n,s,p);const g=k.useRef(!1);k.useInsertionEffect(()=>{m&&g.current&&m.update(n,l)});const y=n[mg],T=k.useRef(!!y&&typeof window<"u"&&!((v=window.MotionHandoffIsComplete)!=null&&v.call(window,y))&&((C=window.MotionHasOptimisedAnimation)==null?void 0:C.call(window,y)));return Ds(()=>{d.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),T.current&&m.animationState&&m.animationState.animateChanges())}),k.useEffect(()=>{m&&(!T.current&&m.animationState&&m.animationState.animateChanges(),T.current&&(queueMicrotask(()=>{var E;(E=window.MotionHandoffMarkAsComplete)==null||E.call(window,y)}),T.current=!1),m.enteringChildren=void 0)}),m}function IR(e,t,n,r){const{layoutId:s,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:c,layoutCrossfade:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:s1(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||o&&gr(o),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,crossfade:f,layoutScroll:l,layoutRoot:u,layoutAnchor:c})}function s1(e){if(e)return e.options.allowProjection!==!1?e.projection:s1(e.parent)}function Eo(e,{forwardMotionProps:t=!1,type:n}={},r,s){r&&cR(r);const i=n?n==="svg":Ou(e),a=i?SR:wR;function o(u,c){let f;const h={...k.useContext(Mu),...u,layoutId:NR(u)},{isStatic:d,isValidProp:m}=h,p=fR(u),g=a(u,d);if(!d&&typeof window<"u"){RR();const y=LR(h);f=y.MeasureLayout,p.visualElement=_R(e,g,h,s,y.ProjectionNode,i)}return x.jsxs(ha.Provider,{value:p,children:[f&&p.visualElement?x.jsx(f,{visualElement:p.visualElement,...h}):null,vR(e,u,CR(g,p.visualElement,c),g,d,t,i,m)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=k.forwardRef(o);return l[AR]=e,l}function NR({layoutId:e}){const t=k.useContext(lu).id;return t&&e!==void 0?t+"-"+e:e}function RR(e,t){k.useContext(Zg).strict}function LR(e){const t=e1(),{drag:n,layout:r}=t;if(!n&&!r)return{};const s={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function PR(e,t){if(typeof Proxy>"u")return Eo;const n=new Map,r=(i,a)=>Eo(i,a,e,t),s=(i,a)=>r(i,a);return new Proxy(s,{get:(i,a)=>a==="create"?r:(n.has(a)||n.set(a,Eo(a,void 0,e,t)),n.get(a))})}const MR=(e,t)=>t.isSVG??Ou(e)?new u6(t):new i6(t,{allowProjection:e!==k.Fragment});class DR extends Ln{constructor(t){super(t),t.animationState||(t.animationState=m6(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();da(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let OR=0;class FR extends Ln{constructor(){super(...arguments),this.id=OR++,this.isExitComplete=!1}update(){var i;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"||typeof a=="object"&&a!==null&&!Array.isArray(a)){const l=er(this.node,a,o);if(l){const{transition:u,transitionEnd:c,...f}=l;for(const h in f)(i=this.node.getValue(h))==null||i.jump(f[h])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const BR={animation:{Feature:DR},exit:{Feature:FR}};function Hi(e){return{point:{x:e.pageX,y:e.pageY}}}const jR=e=>t=>_u(t)&&e(t,Hi(t));function xi(e,t,n,r){return Ii(e,t,jR(n),r)}const a1=({current:e})=>e?e.ownerDocument.defaultView:null,dh=(e,t)=>Math.abs(e-t);function HR(e,t){const n=dh(e.x,t.x),r=dh(e.y,t.y);return Math.sqrt(n**2+r**2)}const fh=new Set(["auto","scroll"]);class o1{constructor(t,n,{transformPagePoint:r,contextWindow:s=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=m=>{this.handleScroll(m.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=os(this.lastRawMoveEventInfo,this.transformPagePoint));const m=vo(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,g=HR(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!g)return;const{point:y}=m,{timestamp:T}=Et;this.history.push({...y,timestamp:T});const{onStart:v,onMove:C}=this.handlers;p||(v&&v(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=p,this.lastMoveEventInfo=os(p,this.transformPagePoint),nt.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:g,onSessionEnd:y,resumeAnimation:T}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=vo(m.type==="pointercancel"?this.lastMoveEventInfo:os(p,this.transformPagePoint),this.history);this.startEvent&&g&&g(m,v),y&&y(m,v)},!_u(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=a,this.contextWindow=s||window;const l=Hi(t),u=os(l,this.transformPagePoint),{point:c}=u,{timestamp:f}=Et;this.history=[{...c,timestamp:f}];const{onSessionStart:h}=n;h&&h(t,vo(u,this.history));const d={passive:!0,capture:!0};this.removeListeners=Fi(xi(this.contextWindow,"pointermove",this.handlePointerMove,d),xi(this.contextWindow,"pointerup",this.handlePointerUp,d),xi(this.contextWindow,"pointercancel",this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(fh.has(r.overflowX)||fh.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,s=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:s.x-n.x,y:s.y-n.y};i.x===0&&i.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,s),nt.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),In(this.updatePoint)}}function os(e,t){return t?{point:t(e.point)}:e}function hh(e,t){return{x:e.x-t.x,y:e.y-t.y}}function vo({point:e},t){return{point:e,delta:hh(e,l1(t)),offset:hh(e,UR(t)),velocity:zR(t,.1)}}function UR(e){return e[0]}function l1(e){return e[e.length-1]}function zR(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=l1(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>Yt(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&s.timestamp-r.timestamp>Yt(t)*2&&(r=e[1]);const i=Wt(s.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const a={x:(s.x-r.x)/i,y:(s.y-r.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function VR(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?tt(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?tt(n,e,r.max):Math.min(e,n)),e}function mh(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function qR(e,{top:t,left:n,bottom:r,right:s}){return{x:mh(e.x,n,s),y:mh(e.y,t,r)}}function ph(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function WR(e,t){return{x:ph(e.x,t.x),y:ph(e.y,t.y)}}function $R(e,t){let n=.5;const r=_t(e),s=_t(t);return s>r?n=Ai(t.min,t.max-r,e.min):r>s&&(n=Ai(e.min,e.max-s,t.min)),ln(0,1,n)}function YR(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const wl=.35;function GR(e=wl){return e===!1?e=0:e===!0&&(e=wl),{x:gh(e,"left","right"),y:gh(e,"top","bottom")}}function gh(e,t,n){return{min:xh(e,t),max:xh(e,n)}}function xh(e,t){return typeof e=="number"?e:e[t]||0}const KR=new WeakMap;class XR{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const i=f=>{n&&this.snapToCursor(Hi(f).point),this.stopAnimation()},a=(f,h)=>{const{drag:d,dragPropagation:m,onDragStart:p}=this.getProps();if(d&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=k5(d),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=h,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),rn(y=>{let T=this.getAxisMotionValue(y).get()||0;if(on.test(T)){const{projection:v}=this.visualElement;if(v&&v.layout){const C=v.layout.layoutBox[y];C&&(T=_t(C)*(parseFloat(T)/100))}}this.originPoint[y]=T}),p&&nt.update(()=>p(f,h),!1,!0),ml(this.visualElement,"transform");const{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},o=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h;const{dragPropagation:d,dragDirectionLock:m,onDirectionLock:p,onDrag:g}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:y}=h;if(m&&this.currentDirection===null){this.currentDirection=JR(y),this.currentDirection!==null&&p&&p(this.currentDirection);return}this.updateAxis("x",h.point,y),this.updateAxis("y",h.point,y),this.visualElement.render(),g&&nt.update(()=>g(f,h),!1,!0)},l=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h,this.stop(f,h),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new o1(t,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:a1(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,s=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!s||!r)return;const{velocity:a}=s;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&nt.postRender(()=>o(r,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:s}=this.getProps();if(!r||!ls(t,s,this.currentDirection))return;const i=this.getAxisMotionValue(t);let a=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(a=VR(a,this.constraints[t],this.elastic[t])),i.set(a)}resolveConstraints(){var i;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,s=this.constraints;t&&gr(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=qR(r.layoutBox,t):this.constraints=!1,this.elastic=GR(n),s!==this.constraints&&!gr(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&rn(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=YR(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!gr(t))return!1;const r=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;s.root&&(s.root.scroll=void 0,s.root.updateScroll());const i=J5(r,s.root,this.visualElement.getTransformPagePoint());let a=WR(s.layout.layoutBox,i);if(n){const o=n(K5(a));this.hasMutatedConstraints=!!o,o&&(a=Ng(o))}return a}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:s,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=rn(c=>{if(!ls(c,n,this.currentDirection))return;let f=l&&l[c]||{};(a===!0||a===c)&&(f={min:0,max:0});const h=s?200:1e6,d=s?40:1e7,m={type:"inertia",velocity:r?t[c]:0,bounceStiffness:h,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...i,...f};return this.startAxisValueAnimation(c,m)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return ml(this.visualElement,t),r.start(ku(t,r,0,n,this.visualElement,!1))}stopAnimation(){rn(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps()[n];return s||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){rn(n=>{const{drag:r}=this.getProps();if(!ls(n,r,this.currentDirection))return;const{projection:s}=this.visualElement,i=this.getAxisMotionValue(n);if(s&&s.layout){const{min:a,max:o}=s.layout.layoutBox[n],l=i.get()||0;i.set(t[n]-tt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!gr(n)||!r||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};rn(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();s[a]=$R({min:l,max:l},this.constraints[a])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),rn(a=>{if(!ls(a,t,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(tt(l,u,s[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;KR.set(this.visualElement,this);const t=this.visualElement.current,n=xi(t,"pointerdown",u=>{const{drag:c,dragListener:f=!0}=this.getProps(),h=u.target,d=h!==t&&I5(h);c&&f&&!d&&this.start(u)});let r;const s=()=>{const{dragConstraints:u}=this.getProps();gr(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),r||(r=QR(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,a=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),nt.read(s);const o=Ii(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:c})=>{this.isDragging&&c&&(rn(f=>{const h=this.getAxisMotionValue(f);h&&(this.originPoint[f]+=u[f].translate,h.set(h.get()+u[f].translate))}),this.visualElement.render())}));return()=>{o(),n(),a(),l&&l(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:s=!1,dragConstraints:i=!1,dragElastic:a=wl,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:s,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function bh(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function QR(e,t,n){const r=Sf(e,bh(n)),s=Sf(t,bh(n));return()=>{r(),s()}}function ls(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function JR(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class ZR extends Ln{constructor(t){super(t),this.removeGroupControls=$t,this.removeListeners=$t,this.controls=new XR(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||$t}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const To=e=>(t,n)=>{e&&nt.update(()=>e(t,n),!1,!0)};class e4 extends Ln{constructor(){super(...arguments),this.removePointerDownListener=$t}onPointerDown(t){this.session=new o1(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:a1(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:s}=this.node.getProps();return{onSessionStart:To(t),onStart:To(n),onMove:To(r),onEnd:(i,a)=>{delete this.session,s&&nt.postRender(()=>s(i,a))}}}mount(){this.removePointerDownListener=xi(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let ko=!1;class t4 extends k.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:s}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),r&&r.register&&s&&r.register(i),ko&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ks.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:s,isPresent:i}=this.props,{projection:a}=r;return a&&(a.isPresent=i,t.layoutDependency!==n&&a.setOptions({...a.options,layoutDependency:n}),ko=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==i?a.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?a.promote():a.relegate()||nt.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),Cu.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:s}=t;ko=!0,s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),r&&r.deregister&&r.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function u1(e){const[t,n]=Jg(),r=k.useContext(lu);return x.jsx(t4,{...e,layoutGroup:r,switchLayoutGroup:k.useContext(i1),isPresent:t,safeToRemove:n})}const n4={pan:{Feature:e4},drag:{Feature:ZR,ProjectionNode:Qg,MeasureLayout:u1}};function yh(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,i=r[s];i&&nt.postRender(()=>i(t,Hi(t)))}class r4 extends Ln{mount(){const{current:t}=this.node;t&&(this.unmount=S5(t,(n,r)=>(yh(this.node,r,"Start"),s=>yh(this.node,s,"End"))))}unmount(){}}class i4 extends Ln{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Fi(Ii(this.node.current,"focus",()=>this.onFocus()),Ii(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Eh(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),i=r[s];i&&nt.postRender(()=>i(t,Hi(t)))}class s4 extends Ln{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=R5(t,(s,i)=>(Eh(this.node,i,"Start"),(a,{success:o})=>Eh(this.node,a,o?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const Sl=new WeakMap,wo=new WeakMap,a4=e=>{const t=Sl.get(e.target);t&&t(e)},o4=e=>{e.forEach(a4)};function l4({root:e,...t}){const n=e||document;wo.has(n)||wo.set(n,{});const r=wo.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(o4,{root:e,...t})),r[s]}function u4(e,t,n){const r=l4(t);return Sl.set(e,n),r.observe(e),()=>{Sl.delete(e),r.unobserve(e)}}const c4={some:0,all:1};class d4 extends Ln{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:s="some",once:i}=t,a={root:n?n.current:void 0,rootMargin:r,threshold:typeof s=="number"?s:c4[s]},o=u=>{const{isIntersecting:c}=u;if(this.isInView===c||(this.isInView=c,i&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:f,onViewportLeave:h}=this.node.getProps(),d=c?f:h;d&&d(u)};this.stopObserver=u4(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(f4(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function f4({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const h4={inView:{Feature:d4},tap:{Feature:s4},focus:{Feature:i4},hover:{Feature:r4}},m4={layout:{ProjectionNode:Qg,MeasureLayout:u1}},p4={...BR,...h4,...n4,...m4},g4=PR(p4,MR),x4=g4;function b4(e){switch(e){case"correct":return{Icon:Nl,color:"var(--brand)"};case"wrong":return{Icon:Ah,color:"var(--warning)"};case"mastery":case"level-up":return{Icon:mx,color:"var(--gold)"};case"unlock":return{Icon:ac,color:"var(--brand)"};case"streak":return{Icon:_h,color:"var(--review)"};case"energy-full":return{Icon:_o,color:"var(--brand)"};case"exam-pass":return{Icon:ax,color:"var(--exam)"};case"lesson-complete":return{Icon:Vx,color:"var(--gold)"};default:return{Icon:ac,color:"var(--brand)"}}}function y4(){const e=Cl(),t=k.useRef(null),n=k.useRef([]),r=k.useRef(0),[s,i]=k.useState(null);return k.useEffect(()=>{if(e)return;const a=t.current;if(!a)return;const o=a.getContext("2d");if(!o)return;const l=()=>{const h=Math.min(window.devicePixelRatio||1,2);a.width=window.innerWidth*h,a.height=window.innerHeight*h,a.style.width=window.innerWidth+"px",a.style.height=window.innerHeight+"px",o.setTransform(h,0,0,h,0,0)};l(),window.addEventListener("resize",l);const u=()=>{o.clearRect(0,0,window.innerWidth,window.innerHeight);const h=n.current;for(let d=h.length-1;d>=0;d--){const m=h[d];if(m.x+=m.vx,m.y+=m.vy,m.vy+=.25,m.vx*=.99,m.rot+=m.vr,m.life--,m.life<=0){h.splice(d,1);continue}const p=Math.min(1,m.life/m.maxLife);o.save(),o.globalAlpha=p,o.translate(m.x,m.y),o.rotate(m.rot),o.fillStyle=m.color,m.shape==="circle"?(o.beginPath(),o.arc(0,0,m.size,0,Math.PI*2),o.fill()):o.fillRect(-m.size/2,-m.size/2,m.size,m.size*.6),o.restore()}r.current=h.length>0?requestAnimationFrame(u):0},f=Ao(h=>{var y,T;const d=K1(h.kind),m=Math.round(d.particles*(h.intensity??1)),p=((y=h.origin)==null?void 0:y.x)??window.innerWidth/2,g=((T=h.origin)==null?void 0:T.y)??window.innerHeight/2;for(let v=0;v<m;v++){const C=Math.PI*2*v/m+Math.random()*.3,E=3+Math.random()*6,w=d.durationMs/16*(.7+Math.random()*.5);n.current.push({x:p,y:g,vx:Math.cos(C)*E,vy:Math.sin(C)*E-2,life:w,maxLife:w,color:d.colors[v%d.colors.length],size:4+Math.random()*5,rot:Math.random()*Math.PI,vr:(Math.random()-.5)*.3,shape:Math.random()<.5?"rect":"circle"})}r.current===0&&(r.current=requestAnimationFrame(u))});return()=>{f(),window.removeEventListener("resize",l),r.current&&cancelAnimationFrame(r.current),r.current=0,n.current=[]}},[e]),k.useEffect(()=>{if(!e)return;let a=0;return Ao(l=>{const u=++a;i({kind:l.kind,id:u}),setTimeout(()=>{u===a&&i(null)},600)})},[e]),e?x.jsx(lR,{children:s&&(()=>{const{Icon:a,color:o}=b4(s.kind);return x.jsx(x4.div,{className:"fixed inset-0 pointer-events-none z-[60] flex items-center justify-center","aria-hidden":"true",initial:{opacity:0},animate:{opacity:.45},exit:{opacity:0},transition:{duration:.2},children:x.jsx(a,{className:"w-24 h-24",color:o,strokeWidth:1.5})},s.id)})()}):x.jsx("canvas",{ref:t,className:"fixed inset-0 pointer-events-none z-[60]","aria-hidden":"true"})}const E4=k.lazy(()=>we(()=>import("./SettingsView-BHoTkY38.js"),__vite__mapDeps([34,1,2]),import.meta.url).then(e=>({default:e.SettingsView}))),v4=k.lazy(()=>we(()=>import("./ExamView-DVLRcljJ.js"),__vite__mapDeps([35,1,2,31,30]),import.meta.url).then(e=>({default:e.ExamView}))),T4=k.lazy(()=>we(()=>import("./CommandPalette-DQ5w84ic.js"),__vite__mapDeps([36,1,2]),import.meta.url).then(e=>({default:e.CommandPalette}))),k4=k.lazy(()=>we(()=>import("./CompanionBotLab-4Juuhsy3.js"),__vite__mapDeps([37,1,2]),import.meta.url).then(e=>({default:e.CompanionBotLab}))),vh=["direct","guide","practice"];function w4(){const e=Ke(),[t,n]=k.useState([]),[r,s]=k.useState([]),[i,a]=k.useState({}),[o,l]=k.useState(null),[u,c]=k.useState(null),[f,h]=k.useState(null),[d,m]=k.useState(null),p=k.useCallback(W=>{m(W instanceof Error?W.message:String(W)),console.error(W)},[]),[g,y]=k.useState([]),[T,v]=k.useState(null),[C,E]=k.useState([]),[w,_]=k.useState(null),[S,I]=k.useState("map"),[A,P]=k.useState(null),[N,j]=k.useState(new Set),[M,L]=k.useState(null),B=k.useRef({active:!1,terminate:null}),[V,F]=k.useState({open:!1,pendingAction:null}),q=k.useRef(null),[R,$]=k.useState(null),[X,D]=k.useState(!1),[Z,le]=k.useState(!0),[z,ee]=k.useState(!0),K=cI(),[ce,fe]=k.useState("notebook"),[re,ne]=k.useState("chat"),ge=k.useRef(re);ge.current=re;const Te=k.useRef(K);k.useEffect(()=>{Te.current!==K&&(K===1?(le(!0),ee(!0)):K===2&&Te.current===3&&fe(sI(ge.current)),Te.current=K)},[K]);const Ne=K===3?re==="rail":K===2?ce==="rail":Z,Oe=K===3?re==="notebook":K===2?ce==="notebook":z,be=K!==3||re==="chat",[Fe,te]=k.useState(null),[Re,me]=k.useState(null);k.useEffect(()=>{let W=!0;return(async()=>{const[J,de]=await Promise.all([oe.getSetting("pane_width_left"),oe.getSetting("pane_width_mid")]);W&&(te(nf(J,Zo,k0)),me(nf(de,Si,S0)))})(),()=>{W=!1}},[]);const je=K===3?"t3":K===2?Ne?"t2-rail":"t2-notebook":"t1",Be=pI(Fe!=null||Re!=null)||window.innerWidth,at=mI(Fe,Re,Be,je),G=hI(K,Ne,Oe),se=k.useRef(null),xe=je==="t2-rail"?Si:hi+(at.mid??A0(Be)),Ee=hi+(je==="t2-notebook"?0:at.rail??w0),Pe=(W,J)=>{W==="rail"?(te(J),oe.setSetting("pane_width_left",J!=null?String(J):"")):(me(J),oe.setSetting("pane_width_mid",J!=null?String(J):""))},lt=()=>{K===1?le(W=>!W):K===2?fe(W=>W==="rail"?"notebook":"rail"):ne(W=>W==="rail"?"chat":"rail")},ve=()=>{K===1?ee(W=>!W):K===2?fe(W=>W==="notebook"?"rail":"notebook"):ne(W=>W==="notebook"?"chat":"notebook")},Le=k.useRef(null),ze=W=>{var de,Se;if(K!==3)return;const J=W.touches[0];Le.current={x:J.clientX,y:J.clientY,multi:W.touches.length>1,noswipe:!!((Se=(de=W.target).closest)!=null&&Se.call(de,"[data-noswipe]"))}},Ye=W=>{const J=Le.current;if(Le.current=null,!J||J.multi||J.noswipe||K!==3)return;const de=W.changedTouches[0],Se=aI(ge.current,de.clientX-J.x,de.clientY-J.y);Se&&ne(Se)},[ye,qe]=k.useState(!1),[St,sr]=k.useState(()=>location.hash==="#companion-bot-lab");k.useEffect(()=>{const W=()=>sr(location.hash==="#companion-bot-lab");return window.addEventListener("hashchange",W),()=>window.removeEventListener("hashchange",W)},[]);const[jt,ar]=k.useState(null),[Fr,or]=k.useState([]),Xe=eI(f,M),Pn=zh(),Ge=Q_(Xe.activeId,Pn);k.useEffect(()=>{X1(Ge.streaming)},[Ge.streaming]);const[Ui,zi]=k.useState(""),ke=k.useCallback(W=>{zi(W)},[]),We=k.useCallback((W,J,de)=>{if(W.type==="content"){if($("content"),de){const Se=Ze=>{document.querySelector(`mark[data-note-id="${de}"]`)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-note",{detail:de})):Ze>0&&setTimeout(()=>Se(Ze-1),150)};setTimeout(()=>Se(10),100)}}else if(W.threadId!==Xe.activeId&&Xe.setActiveId(W.threadId),de){const Se=Ze=>{document.querySelector(`mark[data-note-id="${de}"]`)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-chat-note",{detail:de})):Ze>0&&setTimeout(()=>Se(Ze-1),150)};setTimeout(()=>Se(10),120)}},[Xe]),[Qe,ut]=k.useState(null);k.useEffect(()=>{if(!M){ut(null);return}let W=!1;return oe.getNodeSummary(M,Pn).then(J=>{W||ut(J)}).catch(()=>{W||ut(null)}),()=>{W=!0}},[M,Pn]);const Ce=k.useMemo(()=>r.find(W=>W.id===M)??null,[r,M]),_e=k.useMemo(()=>Fr.map(W=>({...W,label:e(`starter.${W.key}.label`),hint:e(`starter.${W.key}.hint`),message:e(`starter.${W.key}.message`,{title:(Ce==null?void 0:Ce.title)??""})})),[Fr,Ce,e]),Me=k.useRef(null),De=k.useCallback(()=>{var W;Ce&&((W=Me.current)==null||W.call(Me,e("chat.action.startLearningPrompt",{title:Ce.title}),e("chat.action.startLearning",{title:Ce.title})))},[Ce,e]),it=k.useCallback(async()=>{try{const[W,J,de,Se,Ze,Dt]=await Promise.all([oe.listCourses(),oe.getStreak(),oe.listSouls(),oe.getActiveSoul(),oe.getXpStatus(),oe.getDueReviews()]);n(W),l(J),E(de),c(Ze),_(Se),j(new Set(Dt)),f&&!W.some(g1=>g1.id===f)&&(h(null),L(null),s([]),a({}),P(null),y([]),v(null))}catch(W){m(W instanceof Error?W.message:String(W))}},[f]);k.useEffect(()=>{it()},[it]);const It=k.useCallback(async()=>{try{ar(await oe.isAgentReady())}catch{ar({ready:!1,missing:e("error.checkReadyFailed")})}},[e]);k.useEffect(()=>{It();const W=()=>It();return window.addEventListener("llm-config-changed",W),()=>window.removeEventListener("llm-config-changed",W)},[It]);const Je=k.useRef(0),$e=k.useRef(0);k.useEffect(()=>{Je.current=(u==null?void 0:u.todayXp)??0},[u]),k.useEffect(()=>{$e.current=(o==null?void 0:o.currentStreak)??0},[o]);const bt=k.useCallback(async()=>{const W=r.filter(Se=>Se.type==="lesson"||Se.type==="exam"),J=await Promise.all(W.map(async Se=>{const Ze=await oe.getProgress(Se.id);return[Se.id,Ze]})),de={};for(const[Se,Ze]of J)Ze&&(de[Se]=Ze);a(de)},[r]);k.useEffect(()=>oe.on("state:changed",J=>{J==="xp"?oe.getXpStatus().then(de=>{c(de),Je.current<100&&de.todayXp>=100&&us("energy-full")}).catch(()=>{}):J==="streak"?oe.getStreak().then(de=>{l(de),de.currentStreak>$e.current&&us("streak")}).catch(()=>{}):J==="mastery"&&(us("mastery"),it(),bt())}),[it,bt]),k.useEffect(()=>{f&&(oe.getCourseLanguages(f).then(y).catch(()=>y([])),oe.getCourseLanguage(f).then(v).catch(()=>v(null)))},[f]),k.useEffect(()=>{f&&(oe.getCourseTree(f,T??void 0).then(async W=>{s(W);const J=W.filter(Ze=>Ze.type==="lesson"||Ze.type==="exam"),de=await Promise.all(J.map(async Ze=>{const Dt=await oe.getProgress(Ze.id);return[Ze.id,Dt]})),Se={};for(const[Ze,Dt]of de)Dt&&(Se[Ze]=Dt);a(Se)}).catch(p),oe.getDashboard(f).then(P).catch(p))},[f,T,p]),k.useEffect(()=>{if(!M){or([]);return}oe.getStarterPrompts(M).then(or).catch(()=>or([]))},[M]),k.useEffect(()=>{const W=J=>{if(J.key==="Escape"&&Xe.activeId&&(oe.abortAgentChatThread(Xe.activeId).catch(()=>{}),D(!1),qe(!1)),(J.ctrlKey||J.metaKey)&&J.key==="k"&&(J.preventDefault(),qe(de=>!de)),(J.ctrlKey||J.metaKey)&&J.key==="b"&&(J.preventDefault(),lt()),(J.ctrlKey||J.metaKey)&&J.key==="Tab"){if(J.preventDefault(),B.current.active)return;const de=Xe.threads;if(de.length>1){const Se=de.findIndex(Dt=>Dt.id===Xe.activeId),Ze=J.shiftKey?(Se-1+de.length)%de.length:(Se+1)%de.length;Xe.setActiveId(de[Ze].id)}}(!J.target||!J.target.matches("input, textarea, select"))&&(J.key==="1"&&I("map"),J.key==="2"&&I("import"),J.key==="s"&&(J.ctrlKey||J.metaKey)&&(J.preventDefault(),D(!0)))};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[M]);const dn=k.useCallback(async W=>{var J;try{if(W.type==="exam"){L(W.id),$("content");return}if(((J=i[W.id])==null?void 0:J.status)==="locked"){L(null);return}await oe.markNodeAttempted(W.id);const de=await oe.getStreak();await bt(),l(de),L(W.id),$("content"),ya(!1)}catch(de){p(de)}},[i,bt,p]),tn=k.useCallback(W=>{if(B.current.active){F({open:!0,pendingAction:W});return}W()},[]),Gt=k.useCallback(W=>{if(B.current.active&&W.id!==M){F({open:!0,pendingAction:()=>void dn(W)});return}dn(W)},[dn,M]),ma=k.useCallback(W=>{B.current=W},[]),yt=k.useCallback(async()=>{const W=V.pendingAction;F({open:!1,pendingAction:null});const J=B.current;if(B.current={active:!1,terminate:null},J.active&&J.terminate)try{await J.terminate()}catch{}W==null||W()},[V.pendingAction]);$s(q,V.open),k.useEffect(()=>{if(!V.open)return;const W=J=>{J.key==="Escape"&&F({open:!1,pendingAction:null})};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[V.open]);const Br=async W=>{try{await oe.setActiveSoul(W),_(W)}catch(J){p(J)}},lr=k.useCallback(async(W,J,de)=>{try{await oe.applyProposal(W),Ge.markProposalStatus(J,de,!0)}catch(Se){p(Se)}},[Ge,p]),jr=k.useCallback(async(W,J,de)=>{try{await oe.rejectProposal(W),Ge.markProposalStatus(J,de,!1)}catch(Se){p(Se)}},[Ge,p]),Mn=t.find(W=>W.id===f),Nt=k.useMemo(()=>{const W=new Set(r.map(J=>J.id));return new Set([...N].filter(J=>W.has(J)))},[N,r]),fn=Nt.size,pa=k.useMemo(()=>r.filter(W=>W.type==="section").sort((W,J)=>W.orderIdx-J.orderIdx),[r]),d1=k.useMemo(()=>{const W=vh.map(de=>C.find(Se=>Se.name===de)).filter(de=>!!de),J=C.filter(de=>!vh.includes(de.name));return[...W,...J]},[C]),Mt=Q3(f),Fu=Z3(),mt=iu();k.useEffect(()=>oe.on("exam:status",J=>{if(J.status!=="ready"||J.nodeId===M)return;const de=r.find(Se=>Se.id===J.nodeId);de&&mt.show(e("exam.ready.toast",{title:de.title}),{duration:4e3})}),[M,r,mt,e]);const f1=k.useCallback(async W=>{const J=t.find(de=>de.id===W);try{await oe.deleteCourse(W),mt.show(e("import.deleted",{title:(J==null?void 0:J.title)??W}),{duration:3e3}),it()}catch(de){p(de)}},[t,it,p,mt,e]),ga=k.useCallback(async(W,J,de)=>{if(!W.trim()||Ge.streaming)return;if(!Xe.activeId){const Ze=await Xe.ensureThreadForSend(W,J);if(Ze){Ge.send(W,Ze,J,de);return}mt.show(e("toast.threadCreateFailed"));return}const Se=Xe.activeThread;Se&&!Se.title&&Xe.update(Se.id,{title:(J??W).trim()}),Ge.send(W,void 0,J,de)},[Ge,Xe,mt,e]),Bu=k.useRef(Ge.streaming);Bu.current=Ge.streaming;const h1=k.useCallback(W=>{const J=Z_(W,e),de=J_(W,e),Se=Ze=>{var Dt;if(!Bu.current){(Dt=Me.current)==null||Dt.call(Me,J,de);return}Ze>0&&setTimeout(()=>Se(Ze-1),2e3)};Se(10)},[e]);Me.current=ga;const ju=new Set(["concept_map","diagram","compare_table","code_walkthrough"]),Hr=k.useMemo(()=>{const W=zd(Ge.messages).filter(de=>{var Se;return ju.has(((Se=de.output)==null?void 0:Se.artifactType)??"")});if(W.length)return W[W.length-1];const J=Mt.items.filter(de=>ju.has(de.artifactType)).map(de=>{try{return{id:de.id,toolName:de.artifactType,output:JSON.parse(de.data)}}catch{return null}}).filter(de=>de!==null);return J.length?J[J.length-1]:null},[Ge.messages,Mt.items]),Hu=k.useRef(new Set);k.useEffect(()=>{!Hr||Hu.current.has(Hr.id)||(Hu.current.add(Hr.id),Ge.streaming&&$("board"))},[Hr,Ge.streaming]);const m1=k.useMemo(()=>Ge.messages.reduce((W,J)=>W+J.parts.reduce((de,Se)=>Se.type==="text"?de+Bh(Se.text):de,0),0),[Ge.messages]),Uu=k.useRef(!1);k.useEffect(()=>{fn>0&&!Uu.current&&(Uu.current=!0,mt.show(e("review.nudge",{n:fn}),{duration:4e3}))},[fn,mt,e]);const zu=k.useMemo(()=>zd(Ge.messages),[Ge.messages]),Vu=k.useRef(new Set);k.useEffect(()=>{for(const W of zu){const J=W.output;if(!J||!J.artifactType)continue;const de=`${J.artifactType}:${JSON.stringify(J)}`;Vu.current.has(de)||(Vu.current.add(de),Mt.save({nodeId:M,artifactType:J.artifactType,title:J.title??null,data:J}),mt.show(e("toast.artifactSaved"),{duration:3e3}))}},[zu,Mt,M,mt,e]),k.useEffect(()=>{S!=="map"&&$(null)},[S]);const[p1,xa]=k.useState(!1),[ba,ya]=k.useState(!1),qu=(Ce==null?void 0:Ce.type)==="exam";return k.useEffect(()=>{qu&&window.dispatchEvent(new CustomEvent("companion-exam-enter"))},[qu]),k.useEffect(()=>{Q1(ba)},[ba]),x.jsxs("div",{className:"h-[var(--app-height,100vh)] flex flex-col bg-surface-1 text-neutral-900 dark:text-neutral-100 overflow-hidden",children:[x.jsx(A4,{streak:o,xp:u,fontSize:Fu.size,onFontBump:Fu.bump,onOpenSettings:()=>D(!0),leftVisible:Ne,rightVisible:Oe,onToggleLeft:lt,onToggleRight:ve,tier:K,bottomBar:K===3?x.jsx("nav",{className:"inline-flex items-center gap-0.5 p-0.5 rounded-lg bg-ink/5 ring-1 ring-inset ring-[var(--border)]","data-testid":"t3-pane-switcher",role:"tablist","aria-label":e("pane.switcher"),children:[{k:"rail",icon:Rh,label:e("pane.map"),testid:"t3-btn-rail"},{k:"chat",icon:Ax,label:e("pane.chat"),testid:"t3-btn-chat"},{k:"notebook",icon:Rx,label:e("pane.notes"),testid:"t3-btn-notebook"}].map(({k:W,icon:J,label:de,testid:Se})=>x.jsx("button",{role:"tab","aria-selected":re===W,"aria-label":de,"data-testid":Se,"data-tooltip":de,onClick:()=>ne(W),className:`w-8 h-7 flex items-center justify-center rounded-md transition-colors ${re===W?"bg-brand/20 text-brand":"text-ink-muted active:bg-ink/10"}`,children:x.jsx(J,{className:"w-4 h-4"})},W))}):void 0}),d&&x.jsx(I4,{message:d,onClose:()=>m(null)}),x.jsxs("div",{className:"flex-1 flex min-h-0 min-w-0",onTouchStart:ze,onTouchEnd:Ye,children:[Ne&&x.jsx(qb,{fullWidth:K===3,width:K===3?null:at.rail,view:S,onViewChange:I,courseTitle:(Mn==null?void 0:Mn.title)??null,courseId:f,courses:t,sections:pa,tree:r,progressMap:i,selectedNodeId:M,dueCount:fn,dueNodeIds:Nt,overallMastery:(A==null?void 0:A.overallMastery)??0,streak:(o==null?void 0:o.currentStreak)??0,streaming:Ge.streamingThreadIds.length>0,streamingNodeIds:Ge.streamingNodeIds,onJumpNode:W=>{const J=r.find(de=>de.id===W);J&&Gt(J),K===3&&ne("chat")},onOpenReview:()=>xa(!0),onSelectCourse:W=>tn(()=>{h(W),it()}),onDeleteCourse:W=>tn(()=>{f1(W)}),onCoursesChanged:()=>{it()},availableLanguages:g,currentLocale:T,onLocaleChange:async W=>{f&&(await oe.setCourseLanguage(f,W),v(W))}}),G.rail&&be&&x.jsx(rf,{side:"rail",ariaLabel:e("pane.resizeRailAria"),tooltip:e("pane.resizeTooltip"),target:()=>document.querySelector('[data-testid="map-rail"]'),clampLive:W=>el(W,window.innerWidth,xe),onCommit:W=>Pe("rail",W)}),x.jsxs(x.Fragment,{children:[be&&x.jsx("div",{ref:se,className:"relative flex flex-col h-full bg-surface-1 shrink-0 min-w-0 motion-safe:transition-[width] motion-safe:duration-200",style:K===3?{flex:1}:Oe?{width:at.mid!=null?`${at.mid}px`:fI}:{flex:1},"data-testid":"chat-panel",children:f?(Ce==null?void 0:Ce.type)==="exam"?x.jsx(k.Suspense,{fallback:null,children:x.jsx(v4,{examNode:Ce,locale:Pn,onSessionChange:ma,paused:V.open,onExamCompleted:()=>{oe.getProgress(Ce.id).then(W=>{W&&a(J=>({...J,[Ce.id]:W}))})}})}):x.jsxs(x.Fragment,{children:[x.jsx(tI,{threads:Xe.threads,activeThread:Xe.activeThread,focusNodeTitle:(Ce==null?void 0:Ce.title)??null,streamingThreadIds:Ge.streamingThreadIds,onPickThread:W=>{Xe.setActiveId(W)},onCreate:()=>{Xe.create({title:null}),mt.show(e("toast.threadCreated"))},onRename:(W,J)=>{Xe.update(W,{title:J}),mt.show(e("toast.threadRenamed"))},onArchive:W=>{Xe.update(W,{status:"archived"}),mt.show(e("toast.threadArchived"),{duration:5e3,action:{label:e("action.undo"),onClick:()=>Xe.update(W,{status:"active"})}})},onDelete:W=>{const J=Xe.removeWithUndo(W);J&&(mt.show(`${e("toast.threadDeleted")}${J.title?`「${J.title}」`:""}`,{duration:5e3,action:{label:e("action.undo"),onClick:()=>{Xe.restore(J),mt.show(e("toast.restored"))}}}),setTimeout(()=>{oe.threadDelete(J.id).catch(()=>{})},5500))}}),x.jsx(i_,{messages:Ge.messages,streaming:Ge.streaming,onApplyProposal:lr,onRejectProposal:jr,summary:Qe,onStartLearning:jt!=null&&jt.ready?De:void 0,agentReady:(jt==null?void 0:jt.ready)??!1,onGotoSettings:()=>D(!0),hasNode:!!Ce,selectedNodeId:M,threadId:Xe.activeId,onPickQuizAction:W=>{ga(W)},onQuizCompleted:h1,cardMode:K===3,chatNotes:Mt.items.filter(W=>W.artifactType==="user_note"&&W.sourceAnchor),onSaveChatNote:(W,J,de,Se)=>{!Ce||!Xe.activeId||(Mt.saveUserNote({nodeId:Ce.id,text:W,sourceType:"chat",sourceAnchor:{type:"chat",threadId:Xe.activeId,msgId:J,startOffset:de,endOffset:Se}}),mt.show(e("toast.noteSaved"),{duration:2e3}))}}),x.jsx(__,{nodeId:M,agentReady:(jt==null?void 0:jt.ready)??!1,streaming:Ge.streaming,souls:d1,activeSoul:w,starterPrompts:Ge.messages.length>0?_e:[],onPickSoul:Br,onSend:ga,onStop:Ge.stop,onLogFriction:M?(W,J)=>{oe.logFriction(M,W,J),mt.show(e("chat.friction.saved"),{duration:2500})}:void 0,onGotoSettings:()=>D(!0),insertText:Ui,historyTokens:m1})]}):x.jsx("div",{className:"flex-1 flex items-center justify-center px-6","data-testid":"chat-no-course",children:x.jsxs("div",{className:"text-center max-w-sm",children:[x.jsx("div",{className:"text-5xl mb-4 opacity-30",children:"📚"}),x.jsx("div",{className:"text-title font-bold text-ink mb-2",children:e("course.empty.title")}),x.jsx("div",{className:"text-body text-ink-muted leading-relaxed",children:e("course.empty.desc")})]})})}),G.mid&&be&&x.jsx(rf,{side:"mid",ariaLabel:e("pane.resizeChatAria"),tooltip:e("pane.resizeTooltip"),target:()=>se.current,clampLive:W=>C0(W,window.innerWidth,Ee),onCommit:W=>Pe("mid",W)}),Oe&&x.jsx("main",{className:K===3?"flex-1 min-w-0 bg-surface-2":"flex-1 min-w-[440px] bg-surface-2","data-testid":K===3?"notebook-pane-full":void 0,children:x.jsx($3,{selectedNode:Ce,items:Mt.items,loading:Mt.loading,forceTab:R,canvasArtifact:Hr,onUserTabChange:()=>$(null),onRemove:W=>{Mt.remove(W),mt.show(e("toast.noteDeleted"))},onTogglePin:W=>{Mt.togglePin(W)},onRecordQuizResult:(W,J)=>{Mt.recordQuizResult(W,J)},onUpdateNoteComment:(W,J)=>{Mt.updateUserNoteComment(W,J)},onSaveContentNote:(W,J)=>{Ce&&(Mt.saveUserNote({nodeId:Ce.id,text:W,sourceType:"content",sourceAnchor:J}),mt.show(e("toast.noteSaved"),{duration:2e3}))},onJumpToSource:We,onQuoteToChat:ke,locale:T,isReviewing:ba,onReviewDone:()=>ya(!1)})})]})]}),X&&x.jsx(C4,{onClose:()=>D(!1)}),p1&&x.jsx(_4,{onClose:()=>xa(!1),tree:r,dashboard:A,progressMap:i,onPickNode:W=>{tn(()=>{L(W),$("content"),xa(!1),ya(!0)})}}),V.open&&x.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50","data-testid":"exam-leave-modal",children:x.jsxs("div",{ref:q,className:"w-[min(400px,90vw)] rounded-2xl bg-surface-0 p-6 shadow-elevated border border-warning/40",role:"dialog","aria-modal":"true","aria-label":e("exam.leave.title"),children:[x.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[x.jsx(Ll,{className:"w-5 h-5 text-warning shrink-0"}),x.jsx("span",{className:"text-title font-bold text-ink",children:e("exam.leave.title")})]}),x.jsx("div",{className:"text-body text-ink-muted mb-5 leading-relaxed",children:e("exam.leave.message")}),x.jsxs("div",{className:"flex justify-end gap-2",children:[x.jsx("button",{className:"btn-3d-neutral px-4 py-1.5 text-body",onClick:()=>F({open:!1,pendingAction:null}),"data-testid":"exam-leave-cancel",children:e("exam.leave.cancel")}),x.jsx("button",{className:"btn-3d-brand px-4 py-1.5 text-body",style:{background:"var(--warning)",boxShadow:"0 3px 0 0 var(--warning-dark)"},onClick:()=>void yt(),"data-testid":"exam-leave-confirm",children:e("exam.leave.confirm")})]})]})}),ye&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(T4,{onClose:()=>qe(!1),onPick:W=>{qe(!1),S4(W)},hasNode:!!M})}),x.jsx(ty,{}),x.jsx(y4,{}),x.jsx(V_,{courseId:f}),St&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(k4,{})})]})}function S4(e){window.dispatchEvent(new CustomEvent("lookatstudy-command",{detail:e}))}function A4({streak:e,xp:t,fontSize:n,onFontBump:r,onOpenSettings:s,leftVisible:i,rightVisible:a,onToggleLeft:o,onToggleRight:l,tier:u,bottomBar:c}){const f=Ke();return c?x.jsx("header",{className:"app-header shrink-0",children:x.jsxs("div",{className:"flex items-center h-12 px-4",children:[x.jsx("div",{className:"flex-1 flex items-center min-w-0",children:t&&x.jsxs("div",{className:"flex items-center gap-1 shrink-0","data-testid":"xp-bar",title:f("header.energy"),children:[x.jsx(_o,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),x.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]})}),c,x.jsx("div",{className:"flex-1 flex items-center justify-end",children:x.jsx("button",{onClick:s,"data-testid":"header-settings","aria-label":f("header.settings"),className:"text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-300 w-8 h-8 flex items-center justify-center rounded-lg hover:bg-neutral-200 dark:hover:bg-neutral-800/50 transition-colors",title:f("header.settings"),children:x.jsx(ws,{className:"w-4 h-4"})})})]})}):x.jsx("header",{className:"app-header shrink-0 flex flex-col",children:x.jsxs("div",{className:"flex items-center pt-2.5 pb-3 px-6 justify-between",children:[x.jsx("div",{className:"flex items-center gap-2 min-w-0",children:x.jsxs("h1",{className:"text-body font-extrabold tracking-tight text-neutral-900 dark:text-neutral-100 select-none min-w-0 truncate",children:["Lookat",x.jsx("span",{className:"text-brand",children:"Study"})]})}),x.jsxs("div",{className:"flex items-center gap-3",children:[u!==3&&x.jsxs("div",{className:"flex items-center gap-0.5",children:[x.jsx("button",{onClick:o,"data-testid":"layout-toggle-left",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${i?"text-neutral-500 hover:bg-neutral-200 dark:text-neutral-300 dark:hover:bg-neutral-800":"text-neutral-600 bg-neutral-200 dark:bg-neutral-800"}`,title:f("header.toggleLeft"),children:x.jsx(_x,{className:"w-4 h-4"})}),x.jsx("button",{onClick:l,"data-testid":"layout-toggle-right",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${a?"text-neutral-500 hover:bg-neutral-200 dark:text-neutral-300 dark:hover:bg-neutral-800":"text-neutral-600 bg-neutral-200 dark:bg-neutral-800"}`,title:f("header.toggleRight"),children:x.jsx(Ix,{className:"w-4 h-4"})})]}),u!==3&&x.jsxs("div",{className:"flex items-center gap-0.5","data-testid":"font-size-control",children:[x.jsx("button",{onClick:()=>r("down"),disabled:n==="small","data-testid":"font-smaller",className:"text-label w-7 h-7 flex items-center justify-center rounded-md text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-ink/5 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",title:f("header.font.smaller"),children:"A-"}),x.jsx("button",{onClick:()=>r("up"),disabled:n==="large","data-testid":"font-larger",className:"text-body w-7 h-7 flex items-center justify-center rounded-md text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-ink/5 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",title:f("header.font.larger"),children:"A+"})]}),t&&x.jsxs("div",{className:"flex items-center gap-1.5","data-testid":"xp-bar",title:f("header.energy"),children:[x.jsx(_o,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),x.jsx("div",{className:"w-16 h-2 bg-neutral-200 dark:bg-neutral-800 rounded-full overflow-hidden",children:x.jsx("div",{className:"h-full rounded-full bg-brand transition-all duration-500",style:{width:`${Math.min(100,Math.max(3,t.todayXp))}%`}})}),x.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]}),t&&x.jsx("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-brand/10","data-testid":"level-badge",title:f("header.level.title"),children:x.jsxs("span",{className:"text-label font-bold text-brand",children:["Lv.",t.level]})}),e&&x.jsx(N4,{streak:e}),x.jsx("button",{onClick:s,"data-testid":"header-settings",className:"text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-300 w-8 h-8 flex items-center justify-center rounded-lg hover:bg-neutral-200 dark:hover:bg-neutral-800/50 transition-colors",title:f("header.settings"),children:x.jsx(ws,{className:"w-4 h-4"})})]})]})})}function C4({onClose:e}){const t=Ke(),n=k.useRef(null);return $s(n,!0),x.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"settings-drawer",children:[x.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),x.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-label":t("settings.title"),className:"relative w-full max-w-lg h-full bg-surface-0 border-l border-[var(--border)] shadow-elevated flex flex-col",children:[x.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[x.jsx("h2",{className:"text-body font-bold",children:t("settings.title")}),x.jsx("button",{onClick:e,"data-testid":"settings-close","aria-label":t("action.close"),className:"text-ink-muted hover:text-ink-strong w-8 h-8 flex items-center justify-center rounded-lg hover:bg-surface-3",children:"✕"})]}),x.jsx("div",{className:"flex-1 overflow-y-auto",children:x.jsx(k.Suspense,{fallback:null,children:x.jsx(E4,{})})})]})]})}function _4({onClose:e,tree:t,onPickNode:n,dashboard:r,progressMap:s}){const i=Ke(),a=k.useRef(null);$s(a,!0);const[o,l]=k.useState([]);k.useEffect(()=>{oe.getAllSrsItems().then(v=>l(v)).catch(()=>l([]))},[]);const u=k.useMemo(()=>new Map(o.map(v=>[v.nodeId,v])),[o]),c=k.useMemo(()=>{const v=new Map(t.map(E=>[E.id,E])),C=o.filter(E=>v.has(E.nodeId));return{overdue:C.filter(E=>E.overdue),short:C.filter(E=>!E.overdue&&E.intervalDays>0&&E.intervalDays<=7),long:C.filter(E=>!E.overdue&&E.intervalDays>7),inactive:C.filter(E=>E.repetitions===0&&!E.overdue)}},[o,t]),f=k.useMemo(()=>t.filter(C=>C.type==="section"&&(C.world??"study")==="study").sort((C,E)=>C.orderIdx-E.orderIdx).map(C=>({section:C,lessons:t.filter(E=>E.parentId===C.id&&E.type==="lesson").sort((E,w)=>E.orderIdx-w.orderIdx)})),[t]),h=k.useMemo(()=>{const v=new Map;for(const C of(r==null?void 0:r.sections)??[])v.set(C.sectionId,C.avgMastery);return v},[r]),d=k.useMemo(()=>t.filter(v=>{var E;const C=(E=s[v.id])==null?void 0:E.status;return v.type==="lesson"&&(v.world??"study")==="study"&&(C==="in_progress"||C==="mastered")}),[t,s]),[m,p]=k.useState(new Set),g=v=>p(C=>{const E=new Set(C);return E.has(v)?E.delete(v):E.add(v),E}),y=v=>{const C=u.get(v);return C?C.overdue?{color:"bg-review",title:i("review.quadrant.overdue")}:C.intervalDays>0&&C.intervalDays<=7?{color:"bg-gold",title:i("review.quadrant.short")}:C.intervalDays>7?{color:"bg-brand",title:i("review.quadrant.long")}:null:null},T=c.overdue.length>0;return x.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"review-drawer",children:[x.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),x.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-label":i("review.title"),className:"relative w-full max-w-md h-full bg-surface-0 border-l border-[var(--border)] shadow-elevated flex flex-col",children:[x.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[x.jsxs("h2",{className:"text-body font-bold flex items-center gap-1.5",children:[x.jsx(Cn,{className:"w-4 h-4","aria-hidden":"true"})," ",i("review.title")]}),x.jsx("button",{onClick:e,"data-testid":"review-close","aria-label":i("action.close"),className:"text-ink-muted hover:text-ink-strong w-8 h-8 flex items-center justify-center rounded-lg hover:bg-surface-3",children:"✕"})]}),x.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5","data-testid":"review-panel",children:[d.length>0&&x.jsxs("button",{onClick:()=>{const v=d[Math.floor(Math.random()*d.length)];v&&n(v.id)},"data-testid":"review-interleave",className:"btn-3d-neutral w-full py-2.5 text-body flex items-center justify-center gap-1.5",children:[x.jsx(jx,{className:"w-4 h-4"}),i("review.interleave")]}),o.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.srsHint")}),x.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:[{items:c.overdue,label:i("review.quadrant.overdue"),dot:"bg-review"},{items:c.short,label:i("review.quadrant.short"),dot:"bg-gold"},{items:c.long,label:i("review.quadrant.long"),dot:"bg-brand"},{items:c.inactive,label:i("review.quadrant.inactive"),dot:"bg-ink-faint"}].filter(v=>v.items.length>0).map(v=>x.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-surface-3",children:[x.jsx("span",{className:`w-2 h-2 rounded-full ${v.dot}`}),x.jsx("span",{className:"text-label text-ink-muted",children:v.label}),x.jsx("span",{className:"text-label font-extrabold text-ink-strong tabular-nums",children:v.items.length})]},v.label))}),T&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"text-label text-ink-faint mb-1.5",children:i("review.overdueQuickHint")}),x.jsx("div",{className:"flex flex-wrap gap-1.5",children:c.overdue.slice(0,8).map(v=>{const C=t.find(E=>E.id===v.nodeId);return C?x.jsx("button",{onClick:()=>n(v.nodeId),"data-testid":`review-overdue-${v.nodeId.slice(0,8)}`,className:"px-2 py-1 rounded-full bg-review/10 ring-1 ring-review/20 text-label text-review font-bold hover:bg-review/20 transition-colors truncate max-w-[140px]",children:C.title},v.nodeId):null})})]})]}),f.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.myProgress")}),x.jsx("div",{className:"space-y-1",children:f.map(({section:v,lessons:C})=>{const E=Math.round((h.get(v.id)??0)*100),w=m.has(v.id),_=C.filter(S=>{var A;const I=(A=s[S.id])==null?void 0:A.status;return I==="in_progress"||I==="mastered"});return x.jsxs("div",{children:[x.jsxs("button",{onClick:()=>g(v.id),className:"w-full flex items-center gap-2 p-2 rounded-lg hover:bg-surface-3 transition-colors",children:[w?x.jsx(Il,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}):x.jsx(ux,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}),x.jsx("span",{className:"text-body text-ink-strong font-bold truncate flex-1 text-left",children:v.title}),_.length>0&&x.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[x.jsx("div",{className:"w-16 h-1.5 bg-surface-3 rounded-full overflow-hidden",children:x.jsx("div",{className:`h-full rounded-full ${E>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,E)}%`}})}),x.jsxs("span",{className:"text-label tabular-nums text-ink-muted w-8 text-right",children:[E,"%"]})]})]}),w&&x.jsx("div",{className:"ml-5 mt-0.5 mb-1 space-y-0.5","data-testid":"review-lesson-list",children:C.length===0?x.jsx("div",{className:"text-label text-ink-faint py-1.5 pl-1",children:"—"}):C.map(S=>{const I=s[S.id],A=I?Math.round((I.mastery??0)*100):null,P=y(S.id),N=(I==null?void 0:I.status)==="in_progress"||(I==null?void 0:I.status)==="mastered";return x.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg transition-colors ${(P==null?void 0:P.color)==="bg-review"?"bg-review/8":"hover:bg-surface-3"}`,children:[P?x.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${P.color} shrink-0`,title:P.title}):x.jsx("span",{className:"w-1.5 h-1.5 shrink-0"}),x.jsx("span",{className:`text-label truncate flex-1 ${N?"text-ink-strong":"text-ink-faint"}`,children:S.title}),A!==null&&x.jsxs("span",{className:"text-label tabular-nums text-ink-muted shrink-0 w-8 text-right",children:[A,"%"]}),N&&x.jsx("button",{onClick:()=>n(S.id),"data-testid":`review-lesson-${S.id.slice(0,8)}`,className:"shrink-0 px-2 py-0.5 rounded-md bg-brand/15 text-brand text-caption font-bold hover:bg-brand/25 transition-colors",children:i("review.reviewLesson")})]},S.id)})})]},v.id)})})]}),r&&r.frictionByNode.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-caption font-bold text-review uppercase tracking-wider mb-1.5",children:i("dashboard.mini.struggle")}),r.frictionByNode.map(v=>x.jsxs("button",{onClick:()=>n(v.nodeId),className:"flex items-center gap-2 py-0.5 w-full text-left hover:bg-surface-3 rounded px-1",children:[x.jsxs("span",{className:"text-label text-review font-bold tabular-nums",children:[v.count,"×"]}),x.jsx("span",{className:"text-label text-ink-strong truncate flex-1",children:v.title})]},v.nodeId))]}),d.length===0&&o.length===0&&f.length===0&&x.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[x.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),x.jsx("div",{className:"text-body text-ink-muted",children:i("review.empty.title")}),x.jsx("div",{className:"text-label text-ink-faint mt-1",children:i("review.empty.desc")})]})]})]})]})}function I4({message:e,onClose:t}){const n=Ke();return x.jsxs("div",{role:"alert","data-testid":"error-banner",className:"px-4 py-2 border-b border-warning-tint-border text-warning text-body flex items-center justify-between",style:{backgroundColor:"var(--warning-tint)"},children:[x.jsxs("span",{children:["⚠️ ",e]}),x.jsx("button",{className:"ml-3 underline text-warning-light",onClick:t,children:n("action.close")})]})}function N4({streak:e}){const t=Ke();return x.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-full border border-review/20",style:{backgroundColor:"var(--review-tint)"},"data-testid":"streak-badge",title:t("streak.title",{n:e.currentStreak,m:e.longestStreak}),children:[x.jsx(_h,{className:"w-4 h-4 text-review flame-flicker"}),x.jsx("span",{className:"text-body font-extrabold text-review",children:e.currentStreak}),e.freezeCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5 ml-0.5","data-testid":"freeze-badge",title:t("streak.freeze.title",{n:e.freezeCount}),children:[x.jsx(Bx,{className:"w-3 h-3 text-review/80","aria-hidden":"true"}),x.jsx("span",{className:"text-label font-bold text-review/80",children:e.freezeCount})]})]})}window.addEventListener("error",e=>{var t;console.error("[FATAL renderer error]",((t=e.error)==null?void 0:t.stack)||e.message)});window.addEventListener("unhandledrejection",e=>{var t;console.error("[FATAL unhandled rejection]",((t=e.reason)==null?void 0:t.stack)||e.reason)});function R4({rejected:e}){const t=navigator.language.startsWith("zh"),[n,r]=_l.useState(""),s=i=>{i.preventDefault();const a=n.trim();if(!a)return;const o=a.includes("token=")?new URL(a).searchParams.get("token")??"":a;o&&we(async()=>{const{setWebToken:l}=await import("./api-web-BCzlfr07.js");return{setWebToken:l}},[],import.meta.url).then(({setWebToken:l})=>l(o))};return x.jsx("div",{className:"min-h-[var(--app-height,100vh)] bg-[#0e2a12] flex items-center justify-center p-6",children:x.jsxs("form",{onSubmit:s,className:"w-full max-w-sm text-center",children:[x.jsx("div",{className:"text-4xl mb-3",children:"🎈"}),x.jsx("h1",{className:"text-title font-bold text-white mb-1",children:"LookatStudy"}),x.jsx("p",{className:"text-label text-white/55 leading-relaxed mb-5",children:t?"连接本机学习服务:粘贴启动时打印的令牌或整条链接":"Connect to your study server — paste the token or the full link printed at startup"}),e&&x.jsx("p",{className:"text-label text-warning-light mb-3",children:t?"上次的令牌被拒绝了,请重新输入":"Previous token was rejected, please re-enter"}),x.jsx("input",{type:"text",value:n,onChange:i=>r(i.target.value),placeholder:t?"访问令牌":"access token",autoFocus:!0,className:"w-full bg-black/30 text-white placeholder:text-white/30 text-body font-mono rounded-lg px-3 py-2.5 border border-white/20 focus:border-brand focus:outline-none transition-colors mb-3"}),x.jsx("button",{type:"submit",disabled:!n.trim(),className:"btn-3d-brand w-full px-3 py-2.5 text-body disabled:opacity-40",children:t?"连接":"Connect"}),x.jsx("p",{className:"text-caption text-white/40 leading-relaxed mt-5",children:t?"令牌在服务启动日志里,形如 http://127.0.0.1:17890/?token=…,也可以直接打开那个链接。":"The token is in the server startup log, like http://127.0.0.1:17890/?token=… — opening that link directly works too."})]})})}const c1=J1.createRoot(document.getElementById("root"));function L4(){c1.render(x.jsx(_l.StrictMode,{children:x.jsx(D3,{children:x.jsx(w4,{})})}))}function Th(e){c1.render(x.jsx(_l.StrictMode,{children:x.jsx(R4,{rejected:e})}))}async function P4(){const{installAppHeight:e}=await we(async()=>{const{installAppHeight:t}=await import("./app-height-D5bf5z0g.js");return{installAppHeight:t}},[],import.meta.url);if(e(),!window.api){const t=await we(()=>import("./api-web-BCzlfr07.js"),[],import.meta.url);if(window.addEventListener(t.TOKEN_REJECTED_EVENT,()=>Th(!0)),!t.hasWebToken()){Th(!1);return}try{await t.installWebApi()}catch(n){console.error("[boot] web api 安装失败:",n)}}L4()}P4();export{Xs as $,Mm as A,Cn as B,mx as C,Nv as D,Mh as E,Ws as F,yx as G,Ll as H,O4 as I,ac as J,Ih as K,wx as L,Rh as M,F4 as N,Ux as O,Ph as P,U4 as Q,fx as R,jx as S,zx as T,Yx as U,Lx as V,Fh as W,kr as X,ay as Y,Nn as Z,we as _,oe as a,Jh as a0,am as a1,td as a2,Um as a3,Ri as a4,qw as a5,$s as b,he as c,Ox as d,cs as e,Nh as f,Vh as g,cx as h,An as i,Ve as j,Nl as k,ek as l,Ae as m,Ah as n,j4 as o,As as p,H4 as q,jh as r,B4 as s,Ld as t,Ke as u,Rd as v,qn as w,_w as x,Cw as y,ta as z};
487
+ `),()=>{var I;(I=o.current)==null||I.removeAttribute("data-motion-pop-id"),S.contains(_)&&S.removeChild(_)}},[t]),x.jsx(iR,{isPresent:t,childRef:o,sizeRef:l,pop:i,children:i===!1?e:k.cloneElement(e,{ref:f})})}const aR=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:s,presenceAffectsLayout:i,mode:a,anchorX:o,anchorY:l,root:u})=>{const c=uu(oR),f=k.useId(),h=k.useRef(n),d=k.useRef(r);Ds(()=>{h.current=n,d.current=r});let m=!0,p=k.useMemo(()=>(m=!1,{id:f,initial:t,isPresent:n,custom:s,onExitComplete:g=>{c.set(g,!0);for(const y of c.values())if(!y)return;r&&r()},register:g=>(c.set(g,!1),()=>{var y;c.delete(g),!h.current&&!c.size&&((y=d.current)==null||y.call(d))})}),[n,c,r]);return i&&m&&(p={...p}),k.useMemo(()=>{c.forEach((g,y)=>c.set(y,!1))},[n]),k.useEffect(()=>{!n&&!c.size&&r&&r()},[n]),e=x.jsx(sR,{pop:a==="popLayout",isPresent:n,anchorX:o,anchorY:l,root:u,children:e}),x.jsx(la.Provider,{value:p,children:e})};function oR(){return new Map}function Jg(e=!0){const t=k.useContext(la);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:s}=t,i=k.useId();k.useEffect(()=>{if(e)return s(i)},[e]);const a=k.useCallback(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,a]:[!0]}const as=e=>e.key||"";function oh(e){const t=[];return k.Children.forEach(e,n=>{k.isValidElement(n)&&t.push(n)}),t}const lR=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:s=!0,mode:i="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:u})=>{const[c,f]=Jg(a),h=k.useMemo(()=>oh(e),[e]),d=a&&!c?[]:h.map(as),m=k.useRef(!0),p=k.useRef(h),g=uu(()=>new Map),y=k.useRef(new Set),[T,v]=k.useState(h),[C,E]=k.useState(h);Ds(()=>{a&&!c&&!C.length&&(f==null||f())},[c,a,C.length,f]),Ds(()=>{m.current=!1,p.current=h;for(let S=0;S<C.length;S++){const I=as(C[S]);d.includes(I)?(g.delete(I),y.current.delete(I)):g.get(I)!==!0&&g.set(I,!1)}},[C,d.length,d.join("-")]);const w=[];if(h!==T){let S=[...h],I=0;for(const A of C){const P=d.indexOf(as(A));P===-1?(S.splice(I++,0,A),w.push(A)):I=P+w.length+1}return i==="wait"&&w.length&&(S=w),E(oh(S)),v(h),null}const{forceRender:_}=k.useContext(lu);return x.jsx(x.Fragment,{children:C.map(S=>{const I=as(S),A=a&&!c?!1:h===C||d.includes(I),P=()=>{if(y.current.has(I))return;if(g.has(I))y.current.add(I),g.set(I,!0);else return;let N=!0;g.forEach(j=>{j||(N=!1)}),N&&(_==null||_(),E(p.current),a&&(f==null||f()),r&&r())};return x.jsx(aR,{isPresent:A,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:i,root:u,onExitComplete:A?void 0:P,anchorX:o,anchorY:l,children:S},I)})})},Zg=k.createContext({strict:!1}),lh={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let uh=!1;function uR(){if(uh)return;const e={};for(const t in lh)e[t]={isEnabled:n=>lh[t].some(r=>!!n[r])};_g(e),uh=!0}function e1(){return uR(),Y5()}function cR(e){const t=e1();for(const n in e)t[n]={...t[n],...e[n]};_g(t)}const ha=k.createContext({});function dR(e,t){if(fa(e)){const{initial:n,animate:r}=e;return{initial:n===!1||_i(n)?n:void 0,animate:_i(r)?r:void 0}}return e.inherit!==!1?t:{}}function fR(e){const{initial:t,animate:n}=dR(e,k.useContext(ha));return k.useMemo(()=>({initial:t,animate:n}),[ch(t),ch(n)])}function ch(e){return Array.isArray(e)?e.join(" "):e}const Du=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function t1(e,t,n){for(const r in t)!vt(t[r])&&!Dg(r,n)&&(e[r]=t[r])}function hR({transformTemplate:e},t){return k.useMemo(()=>{const n=Du();return Lu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function mR(e,t){const n=e.style||{},r={};return t1(r,n,e),Object.assign(r,hR(e,t)),r}function pR(e,t){const n={},r=mR(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const n1=()=>({...Du(),attrs:{}});function gR(e,t,n,r){const s=k.useMemo(()=>{const i=n1();return Fg(i,t,jg(r),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};t1(i,e.style,e),s.style={...i,...s.style}}return s}const xR=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function qs(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||xR.has(e)}function bR(e,t){return e.startsWith("on")?!qs(e):(t==null?void 0:t(e))??!qs(e)}function yR(e,t,n,r){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||vt(e[i])||(bR(i,r)||n===!0&&qs(i)||!t&&!qs(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const ER=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ou(e){return typeof e!="string"||e.includes("-")?!1:!!(ER.indexOf(e)>-1||/[A-Z]/u.test(e))}function vR(e,t,n,{latestValues:r},s,i=!1,a,o){const u=(a??Ou(e)?gR:pR)(t,r,s,e),c=yR(t,typeof e=="string",i,o),f=e!==k.Fragment?{...c,...u,ref:n}:{},{children:h}=t,d=k.useMemo(()=>vt(h)?h.get():h,[h]);return k.createElement(e,{...f,children:d})}function TR({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,s){return{latestValues:kR(n,r,s,e),renderState:t()}}function kR(e,t,n,r){const s={},i=r(e,{});for(const h in i)s[h]=Ts(i[h]);let{initial:a,animate:o}=e;const l=fa(e),u=Ag(e);t&&u&&!l&&e.inherit!==!1&&(a===void 0&&(a=t.initial),o===void 0&&(o=t.animate));let c=n?n.initial===!1:!1;c=c||a===!1;const f=c?o:a;if(f&&typeof f!="boolean"&&!da(f)){const h=Array.isArray(f)?f:[f];for(let d=0;d<h.length;d++){const m=wu(e,h[d]);if(m){const{transitionEnd:p,transition:g,...y}=m;for(const T in y){let v=y[T];if(Array.isArray(v)){const C=c?v.length-1:0;v=v[C]}v!==null&&(s[T]=v)}for(const T in p)s[T]=p[T]}}}return s}const r1=e=>(t,n)=>{const r=k.useContext(ha),s=k.useContext(la),i=()=>TR(e,t,r,s);return n?i():uu(i)},wR=r1({scrapeMotionValuesFromProps:Pu,createRenderState:Du}),SR=r1({scrapeMotionValuesFromProps:Hg,createRenderState:n1}),AR=Symbol.for("motionComponentSymbol");function CR(e,t,n){const r=k.useRef(n);k.useInsertionEffect(()=>{r.current=n});const s=k.useRef(null);return k.useCallback(i=>{var o;i&&((o=e.onMount)==null||o.call(e,i)),t&&(i?t.mount(i):t.unmount());const a=r.current;if(typeof a=="function")if(i){const l=a(i);typeof l=="function"&&(s.current=l)}else s.current?(s.current(),s.current=null):a(i);else a&&(a.current=i)},[t])}const i1=k.createContext({});function gr(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function _R(e,t,n,r,s,i){var v,C;const{visualElement:a}=k.useContext(ha),o=k.useContext(Zg),l=k.useContext(la),u=k.useContext(Mu),c=u.reducedMotion,f=u.skipAnimations,h=k.useRef(null),d=k.useRef(!1);r=r||o.renderer,!h.current&&r&&(h.current=r(e,{visualState:t,parent:a,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c,skipAnimations:f,isSVG:i}),d.current&&h.current&&(h.current.manuallyAnimateOnMount=!0));const m=h.current,p=k.useContext(i1);m&&!m.projection&&s&&(m.type==="html"||m.type==="svg")&&IR(h.current,n,s,p);const g=k.useRef(!1);k.useInsertionEffect(()=>{m&&g.current&&m.update(n,l)});const y=n[mg],T=k.useRef(!!y&&typeof window<"u"&&!((v=window.MotionHandoffIsComplete)!=null&&v.call(window,y))&&((C=window.MotionHasOptimisedAnimation)==null?void 0:C.call(window,y)));return Ds(()=>{d.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),T.current&&m.animationState&&m.animationState.animateChanges())}),k.useEffect(()=>{m&&(!T.current&&m.animationState&&m.animationState.animateChanges(),T.current&&(queueMicrotask(()=>{var E;(E=window.MotionHandoffMarkAsComplete)==null||E.call(window,y)}),T.current=!1),m.enteringChildren=void 0)}),m}function IR(e,t,n,r){const{layoutId:s,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:c,layoutCrossfade:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:s1(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||o&&gr(o),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,crossfade:f,layoutScroll:l,layoutRoot:u,layoutAnchor:c})}function s1(e){if(e)return e.options.allowProjection!==!1?e.projection:s1(e.parent)}function Eo(e,{forwardMotionProps:t=!1,type:n}={},r,s){r&&cR(r);const i=n?n==="svg":Ou(e),a=i?SR:wR;function o(u,c){let f;const h={...k.useContext(Mu),...u,layoutId:NR(u)},{isStatic:d,isValidProp:m}=h,p=fR(u),g=a(u,d);if(!d&&typeof window<"u"){RR();const y=LR(h);f=y.MeasureLayout,p.visualElement=_R(e,g,h,s,y.ProjectionNode,i)}return x.jsxs(ha.Provider,{value:p,children:[f&&p.visualElement?x.jsx(f,{visualElement:p.visualElement,...h}):null,vR(e,u,CR(g,p.visualElement,c),g,d,t,i,m)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=k.forwardRef(o);return l[AR]=e,l}function NR({layoutId:e}){const t=k.useContext(lu).id;return t&&e!==void 0?t+"-"+e:e}function RR(e,t){k.useContext(Zg).strict}function LR(e){const t=e1(),{drag:n,layout:r}=t;if(!n&&!r)return{};const s={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function PR(e,t){if(typeof Proxy>"u")return Eo;const n=new Map,r=(i,a)=>Eo(i,a,e,t),s=(i,a)=>r(i,a);return new Proxy(s,{get:(i,a)=>a==="create"?r:(n.has(a)||n.set(a,Eo(a,void 0,e,t)),n.get(a))})}const MR=(e,t)=>t.isSVG??Ou(e)?new u6(t):new i6(t,{allowProjection:e!==k.Fragment});class DR extends Ln{constructor(t){super(t),t.animationState||(t.animationState=m6(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();da(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let OR=0;class FR extends Ln{constructor(){super(...arguments),this.id=OR++,this.isExitComplete=!1}update(){var i;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"||typeof a=="object"&&a!==null&&!Array.isArray(a)){const l=er(this.node,a,o);if(l){const{transition:u,transitionEnd:c,...f}=l;for(const h in f)(i=this.node.getValue(h))==null||i.jump(f[h])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const BR={animation:{Feature:DR},exit:{Feature:FR}};function Hi(e){return{point:{x:e.pageX,y:e.pageY}}}const jR=e=>t=>_u(t)&&e(t,Hi(t));function xi(e,t,n,r){return Ii(e,t,jR(n),r)}const a1=({current:e})=>e?e.ownerDocument.defaultView:null,dh=(e,t)=>Math.abs(e-t);function HR(e,t){const n=dh(e.x,t.x),r=dh(e.y,t.y);return Math.sqrt(n**2+r**2)}const fh=new Set(["auto","scroll"]);class o1{constructor(t,n,{transformPagePoint:r,contextWindow:s=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=m=>{this.handleScroll(m.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=os(this.lastRawMoveEventInfo,this.transformPagePoint));const m=vo(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,g=HR(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!g)return;const{point:y}=m,{timestamp:T}=Et;this.history.push({...y,timestamp:T});const{onStart:v,onMove:C}=this.handlers;p||(v&&v(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=p,this.lastMoveEventInfo=os(p,this.transformPagePoint),nt.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:g,onSessionEnd:y,resumeAnimation:T}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=vo(m.type==="pointercancel"?this.lastMoveEventInfo:os(p,this.transformPagePoint),this.history);this.startEvent&&g&&g(m,v),y&&y(m,v)},!_u(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=a,this.contextWindow=s||window;const l=Hi(t),u=os(l,this.transformPagePoint),{point:c}=u,{timestamp:f}=Et;this.history=[{...c,timestamp:f}];const{onSessionStart:h}=n;h&&h(t,vo(u,this.history));const d={passive:!0,capture:!0};this.removeListeners=Fi(xi(this.contextWindow,"pointermove",this.handlePointerMove,d),xi(this.contextWindow,"pointerup",this.handlePointerUp,d),xi(this.contextWindow,"pointercancel",this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(fh.has(r.overflowX)||fh.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,s=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:s.x-n.x,y:s.y-n.y};i.x===0&&i.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,s),nt.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),In(this.updatePoint)}}function os(e,t){return t?{point:t(e.point)}:e}function hh(e,t){return{x:e.x-t.x,y:e.y-t.y}}function vo({point:e},t){return{point:e,delta:hh(e,l1(t)),offset:hh(e,UR(t)),velocity:zR(t,.1)}}function UR(e){return e[0]}function l1(e){return e[e.length-1]}function zR(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=l1(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>Yt(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&s.timestamp-r.timestamp>Yt(t)*2&&(r=e[1]);const i=Wt(s.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const a={x:(s.x-r.x)/i,y:(s.y-r.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function VR(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?tt(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?tt(n,e,r.max):Math.min(e,n)),e}function mh(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function qR(e,{top:t,left:n,bottom:r,right:s}){return{x:mh(e.x,n,s),y:mh(e.y,t,r)}}function ph(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function WR(e,t){return{x:ph(e.x,t.x),y:ph(e.y,t.y)}}function $R(e,t){let n=.5;const r=_t(e),s=_t(t);return s>r?n=Ai(t.min,t.max-r,e.min):r>s&&(n=Ai(e.min,e.max-s,t.min)),ln(0,1,n)}function YR(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const wl=.35;function GR(e=wl){return e===!1?e=0:e===!0&&(e=wl),{x:gh(e,"left","right"),y:gh(e,"top","bottom")}}function gh(e,t,n){return{min:xh(e,t),max:xh(e,n)}}function xh(e,t){return typeof e=="number"?e:e[t]||0}const KR=new WeakMap;class XR{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const i=f=>{n&&this.snapToCursor(Hi(f).point),this.stopAnimation()},a=(f,h)=>{const{drag:d,dragPropagation:m,onDragStart:p}=this.getProps();if(d&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=k5(d),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=h,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),rn(y=>{let T=this.getAxisMotionValue(y).get()||0;if(on.test(T)){const{projection:v}=this.visualElement;if(v&&v.layout){const C=v.layout.layoutBox[y];C&&(T=_t(C)*(parseFloat(T)/100))}}this.originPoint[y]=T}),p&&nt.update(()=>p(f,h),!1,!0),ml(this.visualElement,"transform");const{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},o=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h;const{dragPropagation:d,dragDirectionLock:m,onDirectionLock:p,onDrag:g}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:y}=h;if(m&&this.currentDirection===null){this.currentDirection=JR(y),this.currentDirection!==null&&p&&p(this.currentDirection);return}this.updateAxis("x",h.point,y),this.updateAxis("y",h.point,y),this.visualElement.render(),g&&nt.update(()=>g(f,h),!1,!0)},l=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h,this.stop(f,h),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new o1(t,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:a1(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,s=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!s||!r)return;const{velocity:a}=s;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&nt.postRender(()=>o(r,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:s}=this.getProps();if(!r||!ls(t,s,this.currentDirection))return;const i=this.getAxisMotionValue(t);let a=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(a=VR(a,this.constraints[t],this.elastic[t])),i.set(a)}resolveConstraints(){var i;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,s=this.constraints;t&&gr(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=qR(r.layoutBox,t):this.constraints=!1,this.elastic=GR(n),s!==this.constraints&&!gr(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&rn(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=YR(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!gr(t))return!1;const r=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;s.root&&(s.root.scroll=void 0,s.root.updateScroll());const i=J5(r,s.root,this.visualElement.getTransformPagePoint());let a=WR(s.layout.layoutBox,i);if(n){const o=n(K5(a));this.hasMutatedConstraints=!!o,o&&(a=Ng(o))}return a}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:s,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=rn(c=>{if(!ls(c,n,this.currentDirection))return;let f=l&&l[c]||{};(a===!0||a===c)&&(f={min:0,max:0});const h=s?200:1e6,d=s?40:1e7,m={type:"inertia",velocity:r?t[c]:0,bounceStiffness:h,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...i,...f};return this.startAxisValueAnimation(c,m)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return ml(this.visualElement,t),r.start(ku(t,r,0,n,this.visualElement,!1))}stopAnimation(){rn(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps()[n];return s||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){rn(n=>{const{drag:r}=this.getProps();if(!ls(n,r,this.currentDirection))return;const{projection:s}=this.visualElement,i=this.getAxisMotionValue(n);if(s&&s.layout){const{min:a,max:o}=s.layout.layoutBox[n],l=i.get()||0;i.set(t[n]-tt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!gr(n)||!r||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};rn(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();s[a]=$R({min:l,max:l},this.constraints[a])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),rn(a=>{if(!ls(a,t,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(tt(l,u,s[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;KR.set(this.visualElement,this);const t=this.visualElement.current,n=xi(t,"pointerdown",u=>{const{drag:c,dragListener:f=!0}=this.getProps(),h=u.target,d=h!==t&&I5(h);c&&f&&!d&&this.start(u)});let r;const s=()=>{const{dragConstraints:u}=this.getProps();gr(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),r||(r=QR(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,a=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),nt.read(s);const o=Ii(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:c})=>{this.isDragging&&c&&(rn(f=>{const h=this.getAxisMotionValue(f);h&&(this.originPoint[f]+=u[f].translate,h.set(h.get()+u[f].translate))}),this.visualElement.render())}));return()=>{o(),n(),a(),l&&l(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:s=!1,dragConstraints:i=!1,dragElastic:a=wl,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:s,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function bh(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function QR(e,t,n){const r=Sf(e,bh(n)),s=Sf(t,bh(n));return()=>{r(),s()}}function ls(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function JR(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class ZR extends Ln{constructor(t){super(t),this.removeGroupControls=$t,this.removeListeners=$t,this.controls=new XR(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||$t}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const To=e=>(t,n)=>{e&&nt.update(()=>e(t,n),!1,!0)};class e4 extends Ln{constructor(){super(...arguments),this.removePointerDownListener=$t}onPointerDown(t){this.session=new o1(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:a1(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:s}=this.node.getProps();return{onSessionStart:To(t),onStart:To(n),onMove:To(r),onEnd:(i,a)=>{delete this.session,s&&nt.postRender(()=>s(i,a))}}}mount(){this.removePointerDownListener=xi(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let ko=!1;class t4 extends k.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:s}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),r&&r.register&&s&&r.register(i),ko&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ks.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:s,isPresent:i}=this.props,{projection:a}=r;return a&&(a.isPresent=i,t.layoutDependency!==n&&a.setOptions({...a.options,layoutDependency:n}),ko=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==i?a.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?a.promote():a.relegate()||nt.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),Cu.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:s}=t;ko=!0,s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),r&&r.deregister&&r.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function u1(e){const[t,n]=Jg(),r=k.useContext(lu);return x.jsx(t4,{...e,layoutGroup:r,switchLayoutGroup:k.useContext(i1),isPresent:t,safeToRemove:n})}const n4={pan:{Feature:e4},drag:{Feature:ZR,ProjectionNode:Qg,MeasureLayout:u1}};function yh(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,i=r[s];i&&nt.postRender(()=>i(t,Hi(t)))}class r4 extends Ln{mount(){const{current:t}=this.node;t&&(this.unmount=S5(t,(n,r)=>(yh(this.node,r,"Start"),s=>yh(this.node,s,"End"))))}unmount(){}}class i4 extends Ln{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Fi(Ii(this.node.current,"focus",()=>this.onFocus()),Ii(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Eh(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),i=r[s];i&&nt.postRender(()=>i(t,Hi(t)))}class s4 extends Ln{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=R5(t,(s,i)=>(Eh(this.node,i,"Start"),(a,{success:o})=>Eh(this.node,a,o?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const Sl=new WeakMap,wo=new WeakMap,a4=e=>{const t=Sl.get(e.target);t&&t(e)},o4=e=>{e.forEach(a4)};function l4({root:e,...t}){const n=e||document;wo.has(n)||wo.set(n,{});const r=wo.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(o4,{root:e,...t})),r[s]}function u4(e,t,n){const r=l4(t);return Sl.set(e,n),r.observe(e),()=>{Sl.delete(e),r.unobserve(e)}}const c4={some:0,all:1};class d4 extends Ln{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:s="some",once:i}=t,a={root:n?n.current:void 0,rootMargin:r,threshold:typeof s=="number"?s:c4[s]},o=u=>{const{isIntersecting:c}=u;if(this.isInView===c||(this.isInView=c,i&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:f,onViewportLeave:h}=this.node.getProps(),d=c?f:h;d&&d(u)};this.stopObserver=u4(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(f4(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function f4({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const h4={inView:{Feature:d4},tap:{Feature:s4},focus:{Feature:i4},hover:{Feature:r4}},m4={layout:{ProjectionNode:Qg,MeasureLayout:u1}},p4={...BR,...h4,...n4,...m4},g4=PR(p4,MR),x4=g4;function b4(e){switch(e){case"correct":return{Icon:Nl,color:"var(--brand)"};case"wrong":return{Icon:Ah,color:"var(--warning)"};case"mastery":case"level-up":return{Icon:mx,color:"var(--gold)"};case"unlock":return{Icon:ac,color:"var(--brand)"};case"streak":return{Icon:_h,color:"var(--review)"};case"energy-full":return{Icon:_o,color:"var(--brand)"};case"exam-pass":return{Icon:ax,color:"var(--exam)"};case"lesson-complete":return{Icon:Vx,color:"var(--gold)"};default:return{Icon:ac,color:"var(--brand)"}}}function y4(){const e=Cl(),t=k.useRef(null),n=k.useRef([]),r=k.useRef(0),[s,i]=k.useState(null);return k.useEffect(()=>{if(e)return;const a=t.current;if(!a)return;const o=a.getContext("2d");if(!o)return;const l=()=>{const h=Math.min(window.devicePixelRatio||1,2);a.width=window.innerWidth*h,a.height=window.innerHeight*h,a.style.width=window.innerWidth+"px",a.style.height=window.innerHeight+"px",o.setTransform(h,0,0,h,0,0)};l(),window.addEventListener("resize",l);const u=()=>{o.clearRect(0,0,window.innerWidth,window.innerHeight);const h=n.current;for(let d=h.length-1;d>=0;d--){const m=h[d];if(m.x+=m.vx,m.y+=m.vy,m.vy+=.25,m.vx*=.99,m.rot+=m.vr,m.life--,m.life<=0){h.splice(d,1);continue}const p=Math.min(1,m.life/m.maxLife);o.save(),o.globalAlpha=p,o.translate(m.x,m.y),o.rotate(m.rot),o.fillStyle=m.color,m.shape==="circle"?(o.beginPath(),o.arc(0,0,m.size,0,Math.PI*2),o.fill()):o.fillRect(-m.size/2,-m.size/2,m.size,m.size*.6),o.restore()}r.current=h.length>0?requestAnimationFrame(u):0},f=Ao(h=>{var y,T;const d=K1(h.kind),m=Math.round(d.particles*(h.intensity??1)),p=((y=h.origin)==null?void 0:y.x)??window.innerWidth/2,g=((T=h.origin)==null?void 0:T.y)??window.innerHeight/2;for(let v=0;v<m;v++){const C=Math.PI*2*v/m+Math.random()*.3,E=3+Math.random()*6,w=d.durationMs/16*(.7+Math.random()*.5);n.current.push({x:p,y:g,vx:Math.cos(C)*E,vy:Math.sin(C)*E-2,life:w,maxLife:w,color:d.colors[v%d.colors.length],size:4+Math.random()*5,rot:Math.random()*Math.PI,vr:(Math.random()-.5)*.3,shape:Math.random()<.5?"rect":"circle"})}r.current===0&&(r.current=requestAnimationFrame(u))});return()=>{f(),window.removeEventListener("resize",l),r.current&&cancelAnimationFrame(r.current),r.current=0,n.current=[]}},[e]),k.useEffect(()=>{if(!e)return;let a=0;return Ao(l=>{const u=++a;i({kind:l.kind,id:u}),setTimeout(()=>{u===a&&i(null)},600)})},[e]),e?x.jsx(lR,{children:s&&(()=>{const{Icon:a,color:o}=b4(s.kind);return x.jsx(x4.div,{className:"fixed inset-0 pointer-events-none z-[60] flex items-center justify-center","aria-hidden":"true",initial:{opacity:0},animate:{opacity:.45},exit:{opacity:0},transition:{duration:.2},children:x.jsx(a,{className:"w-24 h-24",color:o,strokeWidth:1.5})},s.id)})()}):x.jsx("canvas",{ref:t,className:"fixed inset-0 pointer-events-none z-[60]","aria-hidden":"true"})}const E4=k.lazy(()=>we(()=>import("./SettingsView-DWTo5AIC.js"),__vite__mapDeps([34,1,2]),import.meta.url).then(e=>({default:e.SettingsView}))),v4=k.lazy(()=>we(()=>import("./ExamView-BkOpDSyH.js"),__vite__mapDeps([35,1,2,31,30]),import.meta.url).then(e=>({default:e.ExamView}))),T4=k.lazy(()=>we(()=>import("./CommandPalette-D8HzDvja.js"),__vite__mapDeps([36,1,2]),import.meta.url).then(e=>({default:e.CommandPalette}))),k4=k.lazy(()=>we(()=>import("./CompanionBotLab-4Juuhsy3.js"),__vite__mapDeps([37,1,2]),import.meta.url).then(e=>({default:e.CompanionBotLab}))),vh=["direct","guide","practice"];function w4(){const e=Ke(),[t,n]=k.useState([]),[r,s]=k.useState([]),[i,a]=k.useState({}),[o,l]=k.useState(null),[u,c]=k.useState(null),[f,h]=k.useState(null),[d,m]=k.useState(null),p=k.useCallback(W=>{m(W instanceof Error?W.message:String(W)),console.error(W)},[]),[g,y]=k.useState([]),[T,v]=k.useState(null),[C,E]=k.useState([]),[w,_]=k.useState(null),[S,I]=k.useState("map"),[A,P]=k.useState(null),[N,j]=k.useState(new Set),[M,L]=k.useState(null),B=k.useRef({active:!1,terminate:null}),[V,F]=k.useState({open:!1,pendingAction:null}),q=k.useRef(null),[R,$]=k.useState(null),[X,D]=k.useState(!1),[Z,le]=k.useState(!0),[z,ee]=k.useState(!0),K=cI(),[ce,fe]=k.useState("notebook"),[re,ne]=k.useState("chat"),ge=k.useRef(re);ge.current=re;const Te=k.useRef(K);k.useEffect(()=>{Te.current!==K&&(K===1?(le(!0),ee(!0)):K===2&&Te.current===3&&fe(sI(ge.current)),Te.current=K)},[K]);const Ne=K===3?re==="rail":K===2?ce==="rail":Z,Oe=K===3?re==="notebook":K===2?ce==="notebook":z,be=K!==3||re==="chat",[Fe,te]=k.useState(null),[Re,me]=k.useState(null);k.useEffect(()=>{let W=!0;return(async()=>{const[J,de]=await Promise.all([oe.getSetting("pane_width_left"),oe.getSetting("pane_width_mid")]);W&&(te(nf(J,Zo,k0)),me(nf(de,Si,S0)))})(),()=>{W=!1}},[]);const je=K===3?"t3":K===2?Ne?"t2-rail":"t2-notebook":"t1",Be=pI(Fe!=null||Re!=null)||window.innerWidth,at=mI(Fe,Re,Be,je),G=hI(K,Ne,Oe),se=k.useRef(null),xe=je==="t2-rail"?Si:hi+(at.mid??A0(Be)),Ee=hi+(je==="t2-notebook"?0:at.rail??w0),Pe=(W,J)=>{W==="rail"?(te(J),oe.setSetting("pane_width_left",J!=null?String(J):"")):(me(J),oe.setSetting("pane_width_mid",J!=null?String(J):""))},lt=()=>{K===1?le(W=>!W):K===2?fe(W=>W==="rail"?"notebook":"rail"):ne(W=>W==="rail"?"chat":"rail")},ve=()=>{K===1?ee(W=>!W):K===2?fe(W=>W==="notebook"?"rail":"notebook"):ne(W=>W==="notebook"?"chat":"notebook")},Le=k.useRef(null),ze=W=>{var de,Se;if(K!==3)return;const J=W.touches[0];Le.current={x:J.clientX,y:J.clientY,multi:W.touches.length>1,noswipe:!!((Se=(de=W.target).closest)!=null&&Se.call(de,"[data-noswipe]"))}},Ye=W=>{const J=Le.current;if(Le.current=null,!J||J.multi||J.noswipe||K!==3)return;const de=W.changedTouches[0],Se=aI(ge.current,de.clientX-J.x,de.clientY-J.y);Se&&ne(Se)},[ye,qe]=k.useState(!1),[St,sr]=k.useState(()=>location.hash==="#companion-bot-lab");k.useEffect(()=>{const W=()=>sr(location.hash==="#companion-bot-lab");return window.addEventListener("hashchange",W),()=>window.removeEventListener("hashchange",W)},[]);const[jt,ar]=k.useState(null),[Fr,or]=k.useState([]),Xe=eI(f,M),Pn=zh(),Ge=Q_(Xe.activeId,Pn);k.useEffect(()=>{X1(Ge.streaming)},[Ge.streaming]);const[Ui,zi]=k.useState(""),ke=k.useCallback(W=>{zi(W)},[]),We=k.useCallback((W,J,de)=>{if(W.type==="content"){if($("content"),de){const Se=Ze=>{document.querySelector(`mark[data-note-id="${de}"]`)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-note",{detail:de})):Ze>0&&setTimeout(()=>Se(Ze-1),150)};setTimeout(()=>Se(10),100)}}else if(W.threadId!==Xe.activeId&&Xe.setActiveId(W.threadId),de){const Se=Ze=>{document.querySelector(`mark[data-note-id="${de}"]`)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-chat-note",{detail:de})):Ze>0&&setTimeout(()=>Se(Ze-1),150)};setTimeout(()=>Se(10),120)}},[Xe]),[Qe,ut]=k.useState(null);k.useEffect(()=>{if(!M){ut(null);return}let W=!1;return oe.getNodeSummary(M,Pn).then(J=>{W||ut(J)}).catch(()=>{W||ut(null)}),()=>{W=!0}},[M,Pn]);const Ce=k.useMemo(()=>r.find(W=>W.id===M)??null,[r,M]),_e=k.useMemo(()=>Fr.map(W=>({...W,label:e(`starter.${W.key}.label`),hint:e(`starter.${W.key}.hint`),message:e(`starter.${W.key}.message`,{title:(Ce==null?void 0:Ce.title)??""})})),[Fr,Ce,e]),Me=k.useRef(null),De=k.useCallback(()=>{var W;Ce&&((W=Me.current)==null||W.call(Me,e("chat.action.startLearningPrompt",{title:Ce.title}),e("chat.action.startLearning",{title:Ce.title})))},[Ce,e]),it=k.useCallback(async()=>{try{const[W,J,de,Se,Ze,Dt]=await Promise.all([oe.listCourses(),oe.getStreak(),oe.listSouls(),oe.getActiveSoul(),oe.getXpStatus(),oe.getDueReviews()]);n(W),l(J),E(de),c(Ze),_(Se),j(new Set(Dt)),f&&!W.some(g1=>g1.id===f)&&(h(null),L(null),s([]),a({}),P(null),y([]),v(null))}catch(W){m(W instanceof Error?W.message:String(W))}},[f]);k.useEffect(()=>{it()},[it]);const It=k.useCallback(async()=>{try{ar(await oe.isAgentReady())}catch{ar({ready:!1,missing:e("error.checkReadyFailed")})}},[e]);k.useEffect(()=>{It();const W=()=>It();return window.addEventListener("llm-config-changed",W),()=>window.removeEventListener("llm-config-changed",W)},[It]);const Je=k.useRef(0),$e=k.useRef(0);k.useEffect(()=>{Je.current=(u==null?void 0:u.todayXp)??0},[u]),k.useEffect(()=>{$e.current=(o==null?void 0:o.currentStreak)??0},[o]);const bt=k.useCallback(async()=>{const W=r.filter(Se=>Se.type==="lesson"||Se.type==="exam"),J=await Promise.all(W.map(async Se=>{const Ze=await oe.getProgress(Se.id);return[Se.id,Ze]})),de={};for(const[Se,Ze]of J)Ze&&(de[Se]=Ze);a(de)},[r]);k.useEffect(()=>oe.on("state:changed",J=>{J==="xp"?oe.getXpStatus().then(de=>{c(de),Je.current<100&&de.todayXp>=100&&us("energy-full")}).catch(()=>{}):J==="streak"?oe.getStreak().then(de=>{l(de),de.currentStreak>$e.current&&us("streak")}).catch(()=>{}):J==="mastery"&&(us("mastery"),it(),bt())}),[it,bt]),k.useEffect(()=>{f&&(oe.getCourseLanguages(f).then(y).catch(()=>y([])),oe.getCourseLanguage(f).then(v).catch(()=>v(null)))},[f]),k.useEffect(()=>{f&&(oe.getCourseTree(f,T??void 0).then(async W=>{s(W);const J=W.filter(Ze=>Ze.type==="lesson"||Ze.type==="exam"),de=await Promise.all(J.map(async Ze=>{const Dt=await oe.getProgress(Ze.id);return[Ze.id,Dt]})),Se={};for(const[Ze,Dt]of de)Dt&&(Se[Ze]=Dt);a(Se)}).catch(p),oe.getDashboard(f).then(P).catch(p))},[f,T,p]),k.useEffect(()=>{if(!M){or([]);return}oe.getStarterPrompts(M).then(or).catch(()=>or([]))},[M]),k.useEffect(()=>{const W=J=>{if(J.key==="Escape"&&Xe.activeId&&(oe.abortAgentChatThread(Xe.activeId).catch(()=>{}),D(!1),qe(!1)),(J.ctrlKey||J.metaKey)&&J.key==="k"&&(J.preventDefault(),qe(de=>!de)),(J.ctrlKey||J.metaKey)&&J.key==="b"&&(J.preventDefault(),lt()),(J.ctrlKey||J.metaKey)&&J.key==="Tab"){if(J.preventDefault(),B.current.active)return;const de=Xe.threads;if(de.length>1){const Se=de.findIndex(Dt=>Dt.id===Xe.activeId),Ze=J.shiftKey?(Se-1+de.length)%de.length:(Se+1)%de.length;Xe.setActiveId(de[Ze].id)}}(!J.target||!J.target.matches("input, textarea, select"))&&(J.key==="1"&&I("map"),J.key==="2"&&I("import"),J.key==="s"&&(J.ctrlKey||J.metaKey)&&(J.preventDefault(),D(!0)))};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[M]);const dn=k.useCallback(async W=>{var J;try{if(W.type==="exam"){L(W.id),$("content");return}if(((J=i[W.id])==null?void 0:J.status)==="locked"){L(null);return}await oe.markNodeAttempted(W.id);const de=await oe.getStreak();await bt(),l(de),L(W.id),$("content"),ya(!1)}catch(de){p(de)}},[i,bt,p]),tn=k.useCallback(W=>{if(B.current.active){F({open:!0,pendingAction:W});return}W()},[]),Gt=k.useCallback(W=>{if(B.current.active&&W.id!==M){F({open:!0,pendingAction:()=>void dn(W)});return}dn(W)},[dn,M]),ma=k.useCallback(W=>{B.current=W},[]),yt=k.useCallback(async()=>{const W=V.pendingAction;F({open:!1,pendingAction:null});const J=B.current;if(B.current={active:!1,terminate:null},J.active&&J.terminate)try{await J.terminate()}catch{}W==null||W()},[V.pendingAction]);$s(q,V.open),k.useEffect(()=>{if(!V.open)return;const W=J=>{J.key==="Escape"&&F({open:!1,pendingAction:null})};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[V.open]);const Br=async W=>{try{await oe.setActiveSoul(W),_(W)}catch(J){p(J)}},lr=k.useCallback(async(W,J,de)=>{try{await oe.applyProposal(W),Ge.markProposalStatus(J,de,!0)}catch(Se){p(Se)}},[Ge,p]),jr=k.useCallback(async(W,J,de)=>{try{await oe.rejectProposal(W),Ge.markProposalStatus(J,de,!1)}catch(Se){p(Se)}},[Ge,p]),Mn=t.find(W=>W.id===f),Nt=k.useMemo(()=>{const W=new Set(r.map(J=>J.id));return new Set([...N].filter(J=>W.has(J)))},[N,r]),fn=Nt.size,pa=k.useMemo(()=>r.filter(W=>W.type==="section").sort((W,J)=>W.orderIdx-J.orderIdx),[r]),d1=k.useMemo(()=>{const W=vh.map(de=>C.find(Se=>Se.name===de)).filter(de=>!!de),J=C.filter(de=>!vh.includes(de.name));return[...W,...J]},[C]),Mt=Q3(f),Fu=Z3(),mt=iu();k.useEffect(()=>oe.on("exam:status",J=>{if(J.status!=="ready"||J.nodeId===M)return;const de=r.find(Se=>Se.id===J.nodeId);de&&mt.show(e("exam.ready.toast",{title:de.title}),{duration:4e3})}),[M,r,mt,e]);const f1=k.useCallback(async W=>{const J=t.find(de=>de.id===W);try{await oe.deleteCourse(W),mt.show(e("import.deleted",{title:(J==null?void 0:J.title)??W}),{duration:3e3}),it()}catch(de){p(de)}},[t,it,p,mt,e]),ga=k.useCallback(async(W,J,de)=>{if(!W.trim()||Ge.streaming)return;if(!Xe.activeId){const Ze=await Xe.ensureThreadForSend(W,J);if(Ze){Ge.send(W,Ze,J,de);return}mt.show(e("toast.threadCreateFailed"));return}const Se=Xe.activeThread;Se&&!Se.title&&Xe.update(Se.id,{title:(J??W).trim()}),Ge.send(W,void 0,J,de)},[Ge,Xe,mt,e]),Bu=k.useRef(Ge.streaming);Bu.current=Ge.streaming;const h1=k.useCallback(W=>{const J=Z_(W,e),de=J_(W,e),Se=Ze=>{var Dt;if(!Bu.current){(Dt=Me.current)==null||Dt.call(Me,J,de);return}Ze>0&&setTimeout(()=>Se(Ze-1),2e3)};Se(10)},[e]);Me.current=ga;const ju=new Set(["concept_map","diagram","compare_table","code_walkthrough"]),Hr=k.useMemo(()=>{const W=zd(Ge.messages).filter(de=>{var Se;return ju.has(((Se=de.output)==null?void 0:Se.artifactType)??"")});if(W.length)return W[W.length-1];const J=Mt.items.filter(de=>ju.has(de.artifactType)).map(de=>{try{return{id:de.id,toolName:de.artifactType,output:JSON.parse(de.data)}}catch{return null}}).filter(de=>de!==null);return J.length?J[J.length-1]:null},[Ge.messages,Mt.items]),Hu=k.useRef(new Set);k.useEffect(()=>{!Hr||Hu.current.has(Hr.id)||(Hu.current.add(Hr.id),Ge.streaming&&$("board"))},[Hr,Ge.streaming]);const m1=k.useMemo(()=>Ge.messages.reduce((W,J)=>W+J.parts.reduce((de,Se)=>Se.type==="text"?de+Bh(Se.text):de,0),0),[Ge.messages]),Uu=k.useRef(!1);k.useEffect(()=>{fn>0&&!Uu.current&&(Uu.current=!0,mt.show(e("review.nudge",{n:fn}),{duration:4e3}))},[fn,mt,e]);const zu=k.useMemo(()=>zd(Ge.messages),[Ge.messages]),Vu=k.useRef(new Set);k.useEffect(()=>{for(const W of zu){const J=W.output;if(!J||!J.artifactType)continue;const de=`${J.artifactType}:${JSON.stringify(J)}`;Vu.current.has(de)||(Vu.current.add(de),Mt.save({nodeId:M,artifactType:J.artifactType,title:J.title??null,data:J}),mt.show(e("toast.artifactSaved"),{duration:3e3}))}},[zu,Mt,M,mt,e]),k.useEffect(()=>{S!=="map"&&$(null)},[S]);const[p1,xa]=k.useState(!1),[ba,ya]=k.useState(!1),qu=(Ce==null?void 0:Ce.type)==="exam";return k.useEffect(()=>{qu&&window.dispatchEvent(new CustomEvent("companion-exam-enter"))},[qu]),k.useEffect(()=>{Q1(ba)},[ba]),x.jsxs("div",{className:"h-[var(--app-height,100vh)] flex flex-col bg-surface-1 text-neutral-900 dark:text-neutral-100 overflow-hidden",children:[x.jsx(A4,{streak:o,xp:u,fontSize:Fu.size,onFontBump:Fu.bump,onOpenSettings:()=>D(!0),leftVisible:Ne,rightVisible:Oe,onToggleLeft:lt,onToggleRight:ve,tier:K,bottomBar:K===3?x.jsx("nav",{className:"inline-flex items-center gap-0.5 p-0.5 rounded-lg bg-ink/5 ring-1 ring-inset ring-[var(--border)]","data-testid":"t3-pane-switcher",role:"tablist","aria-label":e("pane.switcher"),children:[{k:"rail",icon:Rh,label:e("pane.map"),testid:"t3-btn-rail"},{k:"chat",icon:Ax,label:e("pane.chat"),testid:"t3-btn-chat"},{k:"notebook",icon:Rx,label:e("pane.notes"),testid:"t3-btn-notebook"}].map(({k:W,icon:J,label:de,testid:Se})=>x.jsx("button",{role:"tab","aria-selected":re===W,"aria-label":de,"data-testid":Se,"data-tooltip":de,onClick:()=>ne(W),className:`w-8 h-7 flex items-center justify-center rounded-md transition-colors ${re===W?"bg-brand/20 text-brand":"text-ink-muted active:bg-ink/10"}`,children:x.jsx(J,{className:"w-4 h-4"})},W))}):void 0}),d&&x.jsx(I4,{message:d,onClose:()=>m(null)}),x.jsxs("div",{className:"flex-1 flex min-h-0 min-w-0",onTouchStart:ze,onTouchEnd:Ye,children:[Ne&&x.jsx(qb,{fullWidth:K===3,width:K===3?null:at.rail,view:S,onViewChange:I,courseTitle:(Mn==null?void 0:Mn.title)??null,courseId:f,courses:t,sections:pa,tree:r,progressMap:i,selectedNodeId:M,dueCount:fn,dueNodeIds:Nt,overallMastery:(A==null?void 0:A.overallMastery)??0,streak:(o==null?void 0:o.currentStreak)??0,streaming:Ge.streamingThreadIds.length>0,streamingNodeIds:Ge.streamingNodeIds,onJumpNode:W=>{const J=r.find(de=>de.id===W);J&&Gt(J),K===3&&ne("chat")},onOpenReview:()=>xa(!0),onSelectCourse:W=>tn(()=>{h(W),it()}),onDeleteCourse:W=>tn(()=>{f1(W)}),onCoursesChanged:()=>{it()},availableLanguages:g,currentLocale:T,onLocaleChange:async W=>{f&&(await oe.setCourseLanguage(f,W),v(W))}}),G.rail&&be&&x.jsx(rf,{side:"rail",ariaLabel:e("pane.resizeRailAria"),tooltip:e("pane.resizeTooltip"),target:()=>document.querySelector('[data-testid="map-rail"]'),clampLive:W=>el(W,window.innerWidth,xe),onCommit:W=>Pe("rail",W)}),x.jsxs(x.Fragment,{children:[be&&x.jsx("div",{ref:se,className:"relative flex flex-col h-full bg-surface-1 shrink-0 min-w-0 motion-safe:transition-[width] motion-safe:duration-200",style:K===3?{flex:1}:Oe?{width:at.mid!=null?`${at.mid}px`:fI}:{flex:1},"data-testid":"chat-panel",children:f?(Ce==null?void 0:Ce.type)==="exam"?x.jsx(k.Suspense,{fallback:null,children:x.jsx(v4,{examNode:Ce,locale:Pn,onSessionChange:ma,paused:V.open,onExamCompleted:()=>{oe.getProgress(Ce.id).then(W=>{W&&a(J=>({...J,[Ce.id]:W}))})}})}):x.jsxs(x.Fragment,{children:[x.jsx(tI,{threads:Xe.threads,activeThread:Xe.activeThread,focusNodeTitle:(Ce==null?void 0:Ce.title)??null,streamingThreadIds:Ge.streamingThreadIds,onPickThread:W=>{Xe.setActiveId(W)},onCreate:()=>{Xe.create({title:null}),mt.show(e("toast.threadCreated"))},onRename:(W,J)=>{Xe.update(W,{title:J}),mt.show(e("toast.threadRenamed"))},onArchive:W=>{Xe.update(W,{status:"archived"}),mt.show(e("toast.threadArchived"),{duration:5e3,action:{label:e("action.undo"),onClick:()=>Xe.update(W,{status:"active"})}})},onDelete:W=>{const J=Xe.removeWithUndo(W);J&&(mt.show(`${e("toast.threadDeleted")}${J.title?`「${J.title}」`:""}`,{duration:5e3,action:{label:e("action.undo"),onClick:()=>{Xe.restore(J),mt.show(e("toast.restored"))}}}),setTimeout(()=>{oe.threadDelete(J.id).catch(()=>{})},5500))}}),x.jsx(i_,{messages:Ge.messages,streaming:Ge.streaming,onApplyProposal:lr,onRejectProposal:jr,summary:Qe,onStartLearning:jt!=null&&jt.ready?De:void 0,agentReady:(jt==null?void 0:jt.ready)??!1,onGotoSettings:()=>D(!0),hasNode:!!Ce,selectedNodeId:M,threadId:Xe.activeId,onPickQuizAction:W=>{ga(W)},onQuizCompleted:h1,cardMode:K===3,chatNotes:Mt.items.filter(W=>W.artifactType==="user_note"&&W.sourceAnchor),onSaveChatNote:(W,J,de,Se)=>{!Ce||!Xe.activeId||(Mt.saveUserNote({nodeId:Ce.id,text:W,sourceType:"chat",sourceAnchor:{type:"chat",threadId:Xe.activeId,msgId:J,startOffset:de,endOffset:Se}}),mt.show(e("toast.noteSaved"),{duration:2e3}))}}),x.jsx(__,{nodeId:M,agentReady:(jt==null?void 0:jt.ready)??!1,streaming:Ge.streaming,souls:d1,activeSoul:w,starterPrompts:Ge.messages.length>0?_e:[],onPickSoul:Br,onSend:ga,onStop:Ge.stop,onLogFriction:M?(W,J)=>{oe.logFriction(M,W,J),mt.show(e("chat.friction.saved"),{duration:2500})}:void 0,onGotoSettings:()=>D(!0),insertText:Ui,historyTokens:m1})]}):x.jsx("div",{className:"flex-1 flex items-center justify-center px-6","data-testid":"chat-no-course",children:x.jsxs("div",{className:"text-center max-w-sm",children:[x.jsx("div",{className:"text-5xl mb-4 opacity-30",children:"📚"}),x.jsx("div",{className:"text-title font-bold text-ink mb-2",children:e("course.empty.title")}),x.jsx("div",{className:"text-body text-ink-muted leading-relaxed",children:e("course.empty.desc")})]})})}),G.mid&&be&&x.jsx(rf,{side:"mid",ariaLabel:e("pane.resizeChatAria"),tooltip:e("pane.resizeTooltip"),target:()=>se.current,clampLive:W=>C0(W,window.innerWidth,Ee),onCommit:W=>Pe("mid",W)}),Oe&&x.jsx("main",{className:K===3?"flex-1 min-w-0 bg-surface-2":"flex-1 min-w-[440px] bg-surface-2","data-testid":K===3?"notebook-pane-full":void 0,children:x.jsx($3,{selectedNode:Ce,items:Mt.items,loading:Mt.loading,forceTab:R,canvasArtifact:Hr,onUserTabChange:()=>$(null),onRemove:W=>{Mt.remove(W),mt.show(e("toast.noteDeleted"))},onTogglePin:W=>{Mt.togglePin(W)},onRecordQuizResult:(W,J)=>{Mt.recordQuizResult(W,J)},onUpdateNoteComment:(W,J)=>{Mt.updateUserNoteComment(W,J)},onSaveContentNote:(W,J)=>{Ce&&(Mt.saveUserNote({nodeId:Ce.id,text:W,sourceType:"content",sourceAnchor:J}),mt.show(e("toast.noteSaved"),{duration:2e3}))},onJumpToSource:We,onQuoteToChat:ke,locale:T,isReviewing:ba,onReviewDone:()=>ya(!1)})})]})]}),X&&x.jsx(C4,{onClose:()=>D(!1)}),p1&&x.jsx(_4,{onClose:()=>xa(!1),tree:r,dashboard:A,progressMap:i,onPickNode:W=>{tn(()=>{L(W),$("content"),xa(!1),ya(!0)})}}),V.open&&x.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50","data-testid":"exam-leave-modal",children:x.jsxs("div",{ref:q,className:"w-[min(400px,90vw)] rounded-2xl bg-surface-0 p-6 shadow-elevated border border-warning/40",role:"dialog","aria-modal":"true","aria-label":e("exam.leave.title"),children:[x.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[x.jsx(Ll,{className:"w-5 h-5 text-warning shrink-0"}),x.jsx("span",{className:"text-title font-bold text-ink",children:e("exam.leave.title")})]}),x.jsx("div",{className:"text-body text-ink-muted mb-5 leading-relaxed",children:e("exam.leave.message")}),x.jsxs("div",{className:"flex justify-end gap-2",children:[x.jsx("button",{className:"btn-3d-neutral px-4 py-1.5 text-body",onClick:()=>F({open:!1,pendingAction:null}),"data-testid":"exam-leave-cancel",children:e("exam.leave.cancel")}),x.jsx("button",{className:"btn-3d-brand px-4 py-1.5 text-body",style:{background:"var(--warning)",boxShadow:"0 3px 0 0 var(--warning-dark)"},onClick:()=>void yt(),"data-testid":"exam-leave-confirm",children:e("exam.leave.confirm")})]})]})}),ye&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(T4,{onClose:()=>qe(!1),onPick:W=>{qe(!1),S4(W)},hasNode:!!M})}),x.jsx(ty,{}),x.jsx(y4,{}),x.jsx(V_,{courseId:f}),St&&x.jsx(k.Suspense,{fallback:null,children:x.jsx(k4,{})})]})}function S4(e){window.dispatchEvent(new CustomEvent("lookatstudy-command",{detail:e}))}function A4({streak:e,xp:t,fontSize:n,onFontBump:r,onOpenSettings:s,leftVisible:i,rightVisible:a,onToggleLeft:o,onToggleRight:l,tier:u,bottomBar:c}){const f=Ke();return c?x.jsx("header",{className:"app-header shrink-0",children:x.jsxs("div",{className:"flex items-center h-12 px-4",children:[x.jsx("div",{className:"flex-1 flex items-center min-w-0",children:t&&x.jsxs("div",{className:"flex items-center gap-1 shrink-0","data-testid":"xp-bar",title:f("header.energy"),children:[x.jsx(_o,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),x.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]})}),c,x.jsx("div",{className:"flex-1 flex items-center justify-end",children:x.jsx("button",{onClick:s,"data-testid":"header-settings","aria-label":f("header.settings"),className:"text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-300 w-8 h-8 flex items-center justify-center rounded-lg hover:bg-neutral-200 dark:hover:bg-neutral-800/50 transition-colors",title:f("header.settings"),children:x.jsx(ws,{className:"w-4 h-4"})})})]})}):x.jsx("header",{className:"app-header shrink-0 flex flex-col",children:x.jsxs("div",{className:"flex items-center pt-2.5 pb-3 px-6 justify-between",children:[x.jsx("div",{className:"flex items-center gap-2 min-w-0",children:x.jsxs("h1",{className:"text-body font-extrabold tracking-tight text-neutral-900 dark:text-neutral-100 select-none min-w-0 truncate",children:["Lookat",x.jsx("span",{className:"text-brand",children:"Study"})]})}),x.jsxs("div",{className:"flex items-center gap-3",children:[u!==3&&x.jsxs("div",{className:"flex items-center gap-0.5",children:[x.jsx("button",{onClick:o,"data-testid":"layout-toggle-left",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${i?"text-neutral-500 hover:bg-neutral-200 dark:text-neutral-300 dark:hover:bg-neutral-800":"text-neutral-600 bg-neutral-200 dark:bg-neutral-800"}`,title:f("header.toggleLeft"),children:x.jsx(_x,{className:"w-4 h-4"})}),x.jsx("button",{onClick:l,"data-testid":"layout-toggle-right",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${a?"text-neutral-500 hover:bg-neutral-200 dark:text-neutral-300 dark:hover:bg-neutral-800":"text-neutral-600 bg-neutral-200 dark:bg-neutral-800"}`,title:f("header.toggleRight"),children:x.jsx(Ix,{className:"w-4 h-4"})})]}),u!==3&&x.jsxs("div",{className:"flex items-center gap-0.5","data-testid":"font-size-control",children:[x.jsx("button",{onClick:()=>r("down"),disabled:n==="small","data-testid":"font-smaller",className:"text-label w-7 h-7 flex items-center justify-center rounded-md text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-ink/5 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",title:f("header.font.smaller"),children:"A-"}),x.jsx("button",{onClick:()=>r("up"),disabled:n==="large","data-testid":"font-larger",className:"text-body w-7 h-7 flex items-center justify-center rounded-md text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-ink/5 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",title:f("header.font.larger"),children:"A+"})]}),t&&x.jsxs("div",{className:"flex items-center gap-1.5","data-testid":"xp-bar",title:f("header.energy"),children:[x.jsx(_o,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),x.jsx("div",{className:"w-16 h-2 bg-neutral-200 dark:bg-neutral-800 rounded-full overflow-hidden",children:x.jsx("div",{className:"h-full rounded-full bg-brand transition-all duration-500",style:{width:`${Math.min(100,Math.max(3,t.todayXp))}%`}})}),x.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]}),t&&x.jsx("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-brand/10","data-testid":"level-badge",title:f("header.level.title"),children:x.jsxs("span",{className:"text-label font-bold text-brand",children:["Lv.",t.level]})}),e&&x.jsx(N4,{streak:e}),x.jsx("button",{onClick:s,"data-testid":"header-settings",className:"text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-300 w-8 h-8 flex items-center justify-center rounded-lg hover:bg-neutral-200 dark:hover:bg-neutral-800/50 transition-colors",title:f("header.settings"),children:x.jsx(ws,{className:"w-4 h-4"})})]})]})})}function C4({onClose:e}){const t=Ke(),n=k.useRef(null);return $s(n,!0),x.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"settings-drawer",children:[x.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),x.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-label":t("settings.title"),className:"relative w-full max-w-lg h-full bg-surface-0 border-l border-[var(--border)] shadow-elevated flex flex-col",children:[x.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[x.jsx("h2",{className:"text-body font-bold",children:t("settings.title")}),x.jsx("button",{onClick:e,"data-testid":"settings-close","aria-label":t("action.close"),className:"text-ink-muted hover:text-ink-strong w-8 h-8 flex items-center justify-center rounded-lg hover:bg-surface-3",children:"✕"})]}),x.jsx("div",{className:"flex-1 overflow-y-auto",children:x.jsx(k.Suspense,{fallback:null,children:x.jsx(E4,{})})})]})]})}function _4({onClose:e,tree:t,onPickNode:n,dashboard:r,progressMap:s}){const i=Ke(),a=k.useRef(null);$s(a,!0);const[o,l]=k.useState([]);k.useEffect(()=>{oe.getAllSrsItems().then(v=>l(v)).catch(()=>l([]))},[]);const u=k.useMemo(()=>new Map(o.map(v=>[v.nodeId,v])),[o]),c=k.useMemo(()=>{const v=new Map(t.map(E=>[E.id,E])),C=o.filter(E=>v.has(E.nodeId));return{overdue:C.filter(E=>E.overdue),short:C.filter(E=>!E.overdue&&E.intervalDays>0&&E.intervalDays<=7),long:C.filter(E=>!E.overdue&&E.intervalDays>7),inactive:C.filter(E=>E.repetitions===0&&!E.overdue)}},[o,t]),f=k.useMemo(()=>t.filter(C=>C.type==="section"&&(C.world??"study")==="study").sort((C,E)=>C.orderIdx-E.orderIdx).map(C=>({section:C,lessons:t.filter(E=>E.parentId===C.id&&E.type==="lesson").sort((E,w)=>E.orderIdx-w.orderIdx)})),[t]),h=k.useMemo(()=>{const v=new Map;for(const C of(r==null?void 0:r.sections)??[])v.set(C.sectionId,C.avgMastery);return v},[r]),d=k.useMemo(()=>t.filter(v=>{var E;const C=(E=s[v.id])==null?void 0:E.status;return v.type==="lesson"&&(v.world??"study")==="study"&&(C==="in_progress"||C==="mastered")}),[t,s]),[m,p]=k.useState(new Set),g=v=>p(C=>{const E=new Set(C);return E.has(v)?E.delete(v):E.add(v),E}),y=v=>{const C=u.get(v);return C?C.overdue?{color:"bg-review",title:i("review.quadrant.overdue")}:C.intervalDays>0&&C.intervalDays<=7?{color:"bg-gold",title:i("review.quadrant.short")}:C.intervalDays>7?{color:"bg-brand",title:i("review.quadrant.long")}:null:null},T=c.overdue.length>0;return x.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"review-drawer",children:[x.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),x.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-label":i("review.title"),className:"relative w-full max-w-md h-full bg-surface-0 border-l border-[var(--border)] shadow-elevated flex flex-col",children:[x.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[x.jsxs("h2",{className:"text-body font-bold flex items-center gap-1.5",children:[x.jsx(Cn,{className:"w-4 h-4","aria-hidden":"true"})," ",i("review.title")]}),x.jsx("button",{onClick:e,"data-testid":"review-close","aria-label":i("action.close"),className:"text-ink-muted hover:text-ink-strong w-8 h-8 flex items-center justify-center rounded-lg hover:bg-surface-3",children:"✕"})]}),x.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5","data-testid":"review-panel",children:[d.length>0&&x.jsxs("button",{onClick:()=>{const v=d[Math.floor(Math.random()*d.length)];v&&n(v.id)},"data-testid":"review-interleave",className:"btn-3d-neutral w-full py-2.5 text-body flex items-center justify-center gap-1.5",children:[x.jsx(jx,{className:"w-4 h-4"}),i("review.interleave")]}),o.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.srsHint")}),x.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:[{items:c.overdue,label:i("review.quadrant.overdue"),dot:"bg-review"},{items:c.short,label:i("review.quadrant.short"),dot:"bg-gold"},{items:c.long,label:i("review.quadrant.long"),dot:"bg-brand"},{items:c.inactive,label:i("review.quadrant.inactive"),dot:"bg-ink-faint"}].filter(v=>v.items.length>0).map(v=>x.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-surface-3",children:[x.jsx("span",{className:`w-2 h-2 rounded-full ${v.dot}`}),x.jsx("span",{className:"text-label text-ink-muted",children:v.label}),x.jsx("span",{className:"text-label font-extrabold text-ink-strong tabular-nums",children:v.items.length})]},v.label))}),T&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"text-label text-ink-faint mb-1.5",children:i("review.overdueQuickHint")}),x.jsx("div",{className:"flex flex-wrap gap-1.5",children:c.overdue.slice(0,8).map(v=>{const C=t.find(E=>E.id===v.nodeId);return C?x.jsx("button",{onClick:()=>n(v.nodeId),"data-testid":`review-overdue-${v.nodeId.slice(0,8)}`,className:"px-2 py-1 rounded-full bg-review/10 ring-1 ring-review/20 text-label text-review font-bold hover:bg-review/20 transition-colors truncate max-w-[140px]",children:C.title},v.nodeId):null})})]})]}),f.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.myProgress")}),x.jsx("div",{className:"space-y-1",children:f.map(({section:v,lessons:C})=>{const E=Math.round((h.get(v.id)??0)*100),w=m.has(v.id),_=C.filter(S=>{var A;const I=(A=s[S.id])==null?void 0:A.status;return I==="in_progress"||I==="mastered"});return x.jsxs("div",{children:[x.jsxs("button",{onClick:()=>g(v.id),className:"w-full flex items-center gap-2 p-2 rounded-lg hover:bg-surface-3 transition-colors",children:[w?x.jsx(Il,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}):x.jsx(ux,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}),x.jsx("span",{className:"text-body text-ink-strong font-bold truncate flex-1 text-left",children:v.title}),_.length>0&&x.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[x.jsx("div",{className:"w-16 h-1.5 bg-surface-3 rounded-full overflow-hidden",children:x.jsx("div",{className:`h-full rounded-full ${E>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,E)}%`}})}),x.jsxs("span",{className:"text-label tabular-nums text-ink-muted w-8 text-right",children:[E,"%"]})]})]}),w&&x.jsx("div",{className:"ml-5 mt-0.5 mb-1 space-y-0.5","data-testid":"review-lesson-list",children:C.length===0?x.jsx("div",{className:"text-label text-ink-faint py-1.5 pl-1",children:"—"}):C.map(S=>{const I=s[S.id],A=I?Math.round((I.mastery??0)*100):null,P=y(S.id),N=(I==null?void 0:I.status)==="in_progress"||(I==null?void 0:I.status)==="mastered";return x.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg transition-colors ${(P==null?void 0:P.color)==="bg-review"?"bg-review/8":"hover:bg-surface-3"}`,children:[P?x.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${P.color} shrink-0`,title:P.title}):x.jsx("span",{className:"w-1.5 h-1.5 shrink-0"}),x.jsx("span",{className:`text-label truncate flex-1 ${N?"text-ink-strong":"text-ink-faint"}`,children:S.title}),A!==null&&x.jsxs("span",{className:"text-label tabular-nums text-ink-muted shrink-0 w-8 text-right",children:[A,"%"]}),N&&x.jsx("button",{onClick:()=>n(S.id),"data-testid":`review-lesson-${S.id.slice(0,8)}`,className:"shrink-0 px-2 py-0.5 rounded-md bg-brand/15 text-brand text-caption font-bold hover:bg-brand/25 transition-colors",children:i("review.reviewLesson")})]},S.id)})})]},v.id)})})]}),r&&r.frictionByNode.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-caption font-bold text-review uppercase tracking-wider mb-1.5",children:i("dashboard.mini.struggle")}),r.frictionByNode.map(v=>x.jsxs("button",{onClick:()=>n(v.nodeId),className:"flex items-center gap-2 py-0.5 w-full text-left hover:bg-surface-3 rounded px-1",children:[x.jsxs("span",{className:"text-label text-review font-bold tabular-nums",children:[v.count,"×"]}),x.jsx("span",{className:"text-label text-ink-strong truncate flex-1",children:v.title})]},v.nodeId))]}),d.length===0&&o.length===0&&f.length===0&&x.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[x.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),x.jsx("div",{className:"text-body text-ink-muted",children:i("review.empty.title")}),x.jsx("div",{className:"text-label text-ink-faint mt-1",children:i("review.empty.desc")})]})]})]})]})}function I4({message:e,onClose:t}){const n=Ke();return x.jsxs("div",{role:"alert","data-testid":"error-banner",className:"px-4 py-2 border-b border-warning-tint-border text-warning text-body flex items-center justify-between",style:{backgroundColor:"var(--warning-tint)"},children:[x.jsxs("span",{children:["⚠️ ",e]}),x.jsx("button",{className:"ml-3 underline text-warning-light",onClick:t,children:n("action.close")})]})}function N4({streak:e}){const t=Ke();return x.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-full border border-review/20",style:{backgroundColor:"var(--review-tint)"},"data-testid":"streak-badge",title:t("streak.title",{n:e.currentStreak,m:e.longestStreak}),children:[x.jsx(_h,{className:"w-4 h-4 text-review flame-flicker"}),x.jsx("span",{className:"text-body font-extrabold text-review",children:e.currentStreak}),e.freezeCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5 ml-0.5","data-testid":"freeze-badge",title:t("streak.freeze.title",{n:e.freezeCount}),children:[x.jsx(Bx,{className:"w-3 h-3 text-review/80","aria-hidden":"true"}),x.jsx("span",{className:"text-label font-bold text-review/80",children:e.freezeCount})]})]})}window.addEventListener("error",e=>{var t;console.error("[FATAL renderer error]",((t=e.error)==null?void 0:t.stack)||e.message)});window.addEventListener("unhandledrejection",e=>{var t;console.error("[FATAL unhandled rejection]",((t=e.reason)==null?void 0:t.stack)||e.reason)});function R4({rejected:e}){const t=navigator.language.startsWith("zh"),[n,r]=_l.useState(""),s=i=>{i.preventDefault();const a=n.trim();if(!a)return;const o=a.includes("token=")?new URL(a).searchParams.get("token")??"":a;o&&we(async()=>{const{setWebToken:l}=await import("./api-web-BCzlfr07.js");return{setWebToken:l}},[],import.meta.url).then(({setWebToken:l})=>l(o))};return x.jsx("div",{className:"min-h-[var(--app-height,100vh)] bg-[#0e2a12] flex items-center justify-center p-6",children:x.jsxs("form",{onSubmit:s,className:"w-full max-w-sm text-center",children:[x.jsx("div",{className:"text-4xl mb-3",children:"🎈"}),x.jsx("h1",{className:"text-title font-bold text-white mb-1",children:"LookatStudy"}),x.jsx("p",{className:"text-label text-white/55 leading-relaxed mb-5",children:t?"连接本机学习服务:粘贴启动时打印的令牌或整条链接":"Connect to your study server — paste the token or the full link printed at startup"}),e&&x.jsx("p",{className:"text-label text-warning-light mb-3",children:t?"上次的令牌被拒绝了,请重新输入":"Previous token was rejected, please re-enter"}),x.jsx("input",{type:"text",value:n,onChange:i=>r(i.target.value),placeholder:t?"访问令牌":"access token",autoFocus:!0,className:"w-full bg-black/30 text-white placeholder:text-white/30 text-body font-mono rounded-lg px-3 py-2.5 border border-white/20 focus:border-brand focus:outline-none transition-colors mb-3"}),x.jsx("button",{type:"submit",disabled:!n.trim(),className:"btn-3d-brand w-full px-3 py-2.5 text-body disabled:opacity-40",children:t?"连接":"Connect"}),x.jsx("p",{className:"text-caption text-white/40 leading-relaxed mt-5",children:t?"令牌在服务启动日志里,形如 http://127.0.0.1:17890/?token=…,也可以直接打开那个链接。":"The token is in the server startup log, like http://127.0.0.1:17890/?token=… — opening that link directly works too."})]})})}const c1=J1.createRoot(document.getElementById("root"));function L4(){c1.render(x.jsx(_l.StrictMode,{children:x.jsx(D3,{children:x.jsx(w4,{})})}))}function Th(e){c1.render(x.jsx(_l.StrictMode,{children:x.jsx(R4,{rejected:e})}))}async function P4(){const{installAppHeight:e}=await we(async()=>{const{installAppHeight:t}=await import("./app-height-D5bf5z0g.js");return{installAppHeight:t}},[],import.meta.url);if(e(),!window.api){const t=await we(()=>import("./api-web-BCzlfr07.js"),[],import.meta.url);if(window.addEventListener(t.TOKEN_REJECTED_EVENT,()=>Th(!0)),!t.hasWebToken()){Th(!1);return}try{await t.installWebApi()}catch(n){console.error("[boot] web api 安装失败:",n)}}L4()}P4();export{Xs as $,Mm as A,Cn as B,mx as C,Nv as D,Mh as E,Ws as F,yx as G,Ll as H,O4 as I,ac as J,Ih as K,wx as L,Rh as M,F4 as N,Ux as O,Ph as P,U4 as Q,fx as R,jx as S,zx as T,Yx as U,Lx as V,Fh as W,kr as X,ay as Y,Nn as Z,we as _,oe as a,Jh as a0,am as a1,td as a2,Um as a3,Ri as a4,qw as a5,$s as b,he as c,Ox as d,cs as e,Nh as f,Vh as g,cx as h,An as i,Ve as j,Nl as k,ek as l,Ae as m,Ah as n,j4 as o,As as p,H4 as q,jh as r,B4 as s,Ld as t,Ke as u,Rd as v,qn as w,_w as x,Cw as y,ta as z};